2019-11-13 07:00:25 +00:00
|
|
|
/**
|
2019-02-10 13:06:05 +00:00
|
|
|
* Widget are responsible for accepting the abstraction layer inputs, interpretting them into rederable props and
|
|
|
|
|
* spawing components based on those props
|
|
|
|
|
* Widgets are also responsible for dispatching actions and updating the state tree
|
|
|
|
|
*/
|
2019-03-18 15:10:30 +00:00
|
|
|
import {
|
2021-06-21 11:09:51 +00:00
|
|
|
CONTAINER_GRID_PADDING,
|
|
|
|
|
CSSUnit,
|
|
|
|
|
CSSUnits,
|
|
|
|
|
PositionType,
|
|
|
|
|
PositionTypes,
|
2019-03-18 15:10:30 +00:00
|
|
|
RenderMode,
|
2019-03-19 14:05:48 +00:00
|
|
|
RenderModes,
|
2021-06-21 11:09:51 +00:00
|
|
|
WidgetType,
|
2019-11-25 05:07:27 +00:00
|
|
|
} from "constants/WidgetConstants";
|
2020-03-27 09:02:11 +00:00
|
|
|
import React, { Component, ReactNode } from "react";
|
2021-06-21 11:09:51 +00:00
|
|
|
import { get, memoize } from "lodash";
|
2019-11-13 07:00:25 +00:00
|
|
|
import DraggableComponent from "components/editorComponents/DraggableComponent";
|
2021-07-26 16:44:10 +00:00
|
|
|
import SnipeableComponent from "components/editorComponents/SnipeableComponent";
|
2019-11-13 07:00:25 +00:00
|
|
|
import ResizableComponent from "components/editorComponents/ResizableComponent";
|
2021-09-15 05:11:13 +00:00
|
|
|
import { ExecuteTriggerPayload } from "constants/AppsmithActionConstants/ActionConstants";
|
2019-11-13 07:00:25 +00:00
|
|
|
import PositionedContainer from "components/designSystems/appsmith/PositionedContainer";
|
2020-03-27 09:02:11 +00:00
|
|
|
import WidgetNameComponent from "components/editorComponents/WidgetNameComponent";
|
2019-11-04 14:22:50 +00:00
|
|
|
import shallowequal from "shallowequal";
|
Feature/entity browse (#220)
# New Feature: Entity Explorer
- Entities are actions (apis and queries), datasources, pages, and widgets
- With this new feature, all entities in the application will be available
to view in the new entity explorer sidebar
- All existing application features from the api sidebar, query sidebar, datasource sidebar and pages sidebar
now are avialable on the entity explorer sidebar
- Users are now able to quickly switch to any entity in the application from the entity explorer sidebar.
- Users can also search all entities in the application from the new sidebar. Use cmd + f or ctrl + f to focus on the search input
- Users can rename entities from the new sidebar
- Users can also perform contextual actions on these entities like set a page as home page, copy/move actions, delete entity, etc from the context menu available alongside the entities in the sidebar
- Users can view the properties of the entities in the sidebar, as well as copy bindings to use in the application.
2020-08-10 08:52:45 +00:00
|
|
|
import { EditorContext } from "components/editorComponents/EditorContextProvider";
|
2019-11-25 05:07:27 +00:00
|
|
|
import ErrorBoundary from "components/editorComponents/ErrorBoundry";
|
2021-02-25 14:00:02 +00:00
|
|
|
import { DerivedPropertiesMap } from "utils/WidgetFactory";
|
2020-11-12 11:23:32 +00:00
|
|
|
import {
|
2021-06-21 11:09:51 +00:00
|
|
|
DataTreeEvaluationProps,
|
|
|
|
|
EVAL_ERROR_PATH,
|
|
|
|
|
EvaluationError,
|
|
|
|
|
PropertyEvaluationErrorType,
|
2020-11-12 11:23:32 +00:00
|
|
|
WidgetDynamicPathListProps,
|
2021-06-21 11:09:51 +00:00
|
|
|
} from "utils/DynamicBindingUtils";
|
2021-03-24 22:05:04 +00:00
|
|
|
import { PropertyPaneConfig } from "constants/PropertyControlConstants";
|
2021-03-01 09:45:54 +00:00
|
|
|
import { BatchPropertyUpdatePayload } from "actions/controlActions";
|
2021-04-23 13:50:55 +00:00
|
|
|
import AppsmithConsole from "utils/AppsmithConsole";
|
|
|
|
|
import { ENTITY_TYPE } from "entities/AppsmithConsole";
|
2022-02-23 04:52:04 +00:00
|
|
|
import PreviewModeComponent from "components/editorComponents/PreviewModeComponent";
|
2022-08-19 10:10:36 +00:00
|
|
|
import { CanvasWidgetStructure } from "./constants";
|
|
|
|
|
import { DataTreeWidget } from "entities/DataTree/dataTreeFactory";
|
|
|
|
|
import Skeleton from "./Skeleton";
|
2020-03-06 09:45:21 +00:00
|
|
|
|
2019-11-13 07:00:25 +00:00
|
|
|
/***
|
|
|
|
|
* BaseWidget
|
|
|
|
|
*
|
|
|
|
|
* The abstract class which is extended/implemented by all widgets.
|
|
|
|
|
* Widgets must adhere to the abstractions provided by BaseWidget.
|
|
|
|
|
*
|
|
|
|
|
* Do not:
|
|
|
|
|
* 1) Use the context directly in the widgets
|
|
|
|
|
* 2) Update or access the dsl in the widgets
|
|
|
|
|
* 3) Call actions in widgets or connect the widgets to the entity reducers
|
|
|
|
|
*
|
|
|
|
|
*/
|
Initialise comments (#3328)
* Initial scaffolding for comments CRUD APIs
* add actions
* add assets
* state management for existing comments and creating new
* add ui components
* add overlay comments wrapper to baseWidget
* add toggle comment mode button at editor header
* trigger tests
* Disallow commenting as someone else
* Add applicationId for comments
* lint
* Add overlay blacklist to prevent component interaction while adding comments
* Comment thread style updates
* Placeholder comment context menu
* Controlled comment thread visibility for making new comments visible by default
* Update comment type description
* Reset input on save
* Resolve comment thread button ui
* fix close on esc key, dont create new comment on outside click
* Submit on enter
* add emoji picker
* Attempt at adding a websocket server in Java
* CRUD APIs for comment threads
* Add API for getting all threads in application
* Move types to a separate file
* Initial commit for real time server (RTS)
* Add script to start RTS
* Fix position property
* Use create comment thread API
* Use add comment to thread API
* Add custom cursor
* Dispatch logout init on 401 errors
* Allow CORS for real time connection
* Add more logs to RTS
* Fix construction of MongoClient
* WIP: Real time comments
* Enable comments
* Minor updates
* Read backend API base URL from environment
* Escape to reset comments mode
* Set popover position as auto and boundary as scroll parent
* Disable warning
* Added permissions for comment threads
* Add resolved API for comment threads
* Migration to set commenting permission on existing apps
* Fix updates bringing the RTS down
* Show view latest button, scroll to bottom on creating a new comment
* Cleanup comment reducer
* Move to typescript for RTS
* Add missing server.ts and tsconfig files
* Resolve / unresolve comment
* Scaffold app comments
* Minor fixes: comment on top of all widgets, add toggle button at viewer header
* Reconnect socket on creating a new app, set connected status in store
* Retry socket connection flow
* Integration tests for comments with api mocks using msw
* Fix circular depependency
* rm file
* Minor cleanup and comments
* Minor refactors: move isScrolledToBottom to common hooks, decouple prevent interactions overlay from comments wrapper
* Use policies when pushing updates in RTS
* ENV var to set if comments are enabled
* Fix: check if editor/viewer is initialised before waiting for init action
* Add tests for comments reducer
* Revert "ENV var to set if comments are enabled"
This reverts commit 988efeaa69d378d943a387e1e73510334958adc5.
* Enable comments for users with appsmith email
* lint
* fix
* Try running a socket.io server inside backend
* Update comment reducer tests
* Init mentions within comments
* Fix comment thread updates with email rooms
* Minor fixes
* Refactors / review suggestions
* lint
* increase cache limit for builds
* Comment out tests for feature that's under development
* Add Dockerfile for RTS
* Fix policies missing for first comment in threads
* Use draftJS for comments input with mentions support
* fix fixtures
* Use thread's policies when querying for threads
* Update socket.io to v4
* Add support for richer body with mentions
* Update comment body type to RawDraftContentState
* fix stale method
* Fix mentions search
* Minor cleanups
* Comment context menu and thread UI updates
* revert: Scaffold app comments
* Yarn dependencies
* Delete comment using id api added
* Init app comments
* Add test for creating thread
* Api for delete comment with id
* Test comment creation response and policies
* Copy comment links
* Fix reset editor state
* Delete valid comment testcase added
* Delete comment TC : code refactor
* Don't allow creating comments with an empty body
* Pin comments WIP[]
* Ignore dependency-reduced-pom.xml files from VCS
* Cleanup of some dev-only files, for review
* Delete comment
* Update socket.io to v4 in RTS
* Pin and resolve comment thread object added in commentThread
* Pin and resolve comment thread object added in commentThread
* Update comment thread API
* Added creationTime and updationTime in comment thread response
* Added creationTime and updationTime in comment thread response
* Added human readable id to comment threads, fallback to username for null name in user document
* Refactor
* lint
* fix test, rm duplicate selector
* comment out saga used for dev
* CommentThread viewed status, username fallback for getName=null, username field added in pin & resolve status
* lint
* trigger tests
Co-authored-by: Shrikant Sharat Kandula <shrikant@appsmith.com>
Co-authored-by: Abhijeet <abhi.nagarnaik@gmail.com>
2021-04-29 10:33:51 +00:00
|
|
|
|
2019-02-11 18:22:23 +00:00
|
|
|
abstract class BaseWidget<
|
2019-10-03 16:24:29 +00:00
|
|
|
T extends WidgetProps,
|
2019-09-09 09:08:54 +00:00
|
|
|
K extends WidgetState
|
2019-04-02 16:12:08 +00:00
|
|
|
> extends Component<T, K> {
|
2019-11-13 07:00:25 +00:00
|
|
|
static contextType = EditorContext;
|
2022-05-25 09:46:14 +00:00
|
|
|
context!: React.ContextType<typeof EditorContext>;
|
2019-11-13 07:00:25 +00:00
|
|
|
|
2021-03-24 22:05:04 +00:00
|
|
|
static getPropertyPaneConfig(): PropertyPaneConfig[] {
|
|
|
|
|
return [];
|
|
|
|
|
}
|
2019-11-19 12:44:58 +00:00
|
|
|
|
2020-01-17 09:28:26 +00:00
|
|
|
static getDerivedPropertiesMap(): DerivedPropertiesMap {
|
|
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-18 07:42:57 +00:00
|
|
|
static getDefaultPropertiesMap(): Record<string, any> {
|
2020-04-17 16:15:09 +00:00
|
|
|
return {};
|
|
|
|
|
}
|
2021-01-04 10:16:08 +00:00
|
|
|
// TODO Find a way to enforce this, (dont let it be set)
|
2020-04-21 07:54:23 +00:00
|
|
|
static getMetaPropertiesMap(): Record<string, any> {
|
2020-04-17 16:15:09 +00:00
|
|
|
return {};
|
2020-02-18 10:41:52 +00:00
|
|
|
}
|
|
|
|
|
|
2019-11-13 07:00:25 +00:00
|
|
|
/**
|
|
|
|
|
* Widget abstraction to register the widget type
|
|
|
|
|
* ```javascript
|
|
|
|
|
* getWidgetType() {
|
|
|
|
|
* return "MY_AWESOME_WIDGET",
|
|
|
|
|
* }
|
|
|
|
|
* ```
|
|
|
|
|
*/
|
2019-10-03 16:24:29 +00:00
|
|
|
|
2019-11-13 07:00:25 +00:00
|
|
|
/**
|
|
|
|
|
* Widgets can execute actions using this `executeAction` method.
|
|
|
|
|
* Triggers may be specific to the widget
|
|
|
|
|
*/
|
2021-09-15 05:11:13 +00:00
|
|
|
executeAction(actionPayload: ExecuteTriggerPayload): void {
|
2019-10-03 16:24:29 +00:00
|
|
|
const { executeAction } = this.context;
|
2021-09-15 05:11:13 +00:00
|
|
|
executeAction &&
|
|
|
|
|
executeAction({
|
|
|
|
|
...actionPayload,
|
|
|
|
|
source: {
|
|
|
|
|
id: this.props.widgetId,
|
|
|
|
|
name: this.props.widgetName,
|
|
|
|
|
},
|
|
|
|
|
});
|
2021-04-23 13:50:55 +00:00
|
|
|
|
|
|
|
|
actionPayload.triggerPropertyName &&
|
|
|
|
|
AppsmithConsole.info({
|
|
|
|
|
text: `${actionPayload.triggerPropertyName} triggered`,
|
|
|
|
|
source: {
|
|
|
|
|
type: ENTITY_TYPE.WIDGET,
|
|
|
|
|
id: this.props.widgetId,
|
|
|
|
|
name: this.props.widgetName,
|
|
|
|
|
},
|
|
|
|
|
});
|
2019-10-03 16:24:29 +00:00
|
|
|
}
|
|
|
|
|
|
2020-01-09 11:39:26 +00:00
|
|
|
disableDrag(disable: boolean) {
|
|
|
|
|
const { disableDrag } = this.context;
|
|
|
|
|
disableDrag && disable !== undefined && disableDrag(disable);
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-15 11:42:11 +00:00
|
|
|
updateWidget(
|
|
|
|
|
operationName: string,
|
|
|
|
|
widgetId: string,
|
|
|
|
|
widgetProperties: any,
|
|
|
|
|
): void {
|
|
|
|
|
const { updateWidget } = this.context;
|
|
|
|
|
updateWidget && updateWidget(operationName, widgetId, widgetProperties);
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-16 10:29:08 +00:00
|
|
|
deleteWidgetProperty(propertyPaths: string[]): void {
|
|
|
|
|
const { deleteWidgetProperty } = this.context;
|
|
|
|
|
const { widgetId } = this.props;
|
|
|
|
|
if (deleteWidgetProperty && widgetId) {
|
|
|
|
|
deleteWidgetProperty(widgetId, propertyPaths);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-21 07:55:56 +00:00
|
|
|
batchUpdateWidgetProperty(
|
|
|
|
|
updates: BatchPropertyUpdatePayload,
|
|
|
|
|
shouldReplay = true,
|
|
|
|
|
): void {
|
2021-02-16 10:29:08 +00:00
|
|
|
const { batchUpdateWidgetProperty } = this.context;
|
|
|
|
|
const { widgetId } = this.props;
|
|
|
|
|
if (batchUpdateWidgetProperty && widgetId) {
|
2021-09-21 07:55:56 +00:00
|
|
|
batchUpdateWidgetProperty(widgetId, updates, shouldReplay);
|
2021-02-16 10:29:08 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-11 10:13:06 +00:00
|
|
|
updateWidgetProperty(propertyName: string, propertyValue: any): void {
|
2021-03-09 05:30:57 +00:00
|
|
|
this.batchUpdateWidgetProperty({
|
|
|
|
|
modify: { [propertyName]: propertyValue },
|
|
|
|
|
});
|
2019-11-07 11:17:53 +00:00
|
|
|
}
|
|
|
|
|
|
2020-03-06 09:45:21 +00:00
|
|
|
resetChildrenMetaProperty(widgetId: string) {
|
|
|
|
|
const { resetChildrenMetaProperty } = this.context;
|
2022-05-25 09:46:14 +00:00
|
|
|
if (resetChildrenMetaProperty) resetChildrenMetaProperty(widgetId);
|
2020-03-06 09:45:21 +00:00
|
|
|
}
|
|
|
|
|
|
2020-03-27 09:02:11 +00:00
|
|
|
/* eslint-disable @typescript-eslint/no-empty-function */
|
Feature/entity browse (#220)
# New Feature: Entity Explorer
- Entities are actions (apis and queries), datasources, pages, and widgets
- With this new feature, all entities in the application will be available
to view in the new entity explorer sidebar
- All existing application features from the api sidebar, query sidebar, datasource sidebar and pages sidebar
now are avialable on the entity explorer sidebar
- Users are now able to quickly switch to any entity in the application from the entity explorer sidebar.
- Users can also search all entities in the application from the new sidebar. Use cmd + f or ctrl + f to focus on the search input
- Users can rename entities from the new sidebar
- Users can also perform contextual actions on these entities like set a page as home page, copy/move actions, delete entity, etc from the context menu available alongside the entities in the sidebar
- Users can view the properties of the entities in the sidebar, as well as copy bindings to use in the application.
2020-08-10 08:52:45 +00:00
|
|
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
2020-03-27 09:02:11 +00:00
|
|
|
componentDidUpdate(prevProps: T) {}
|
|
|
|
|
|
|
|
|
|
componentDidMount(): void {}
|
|
|
|
|
/* eslint-enable @typescript-eslint/no-empty-function */
|
|
|
|
|
|
|
|
|
|
getComponentDimensions = () => {
|
|
|
|
|
return this.calculateWidgetBounds(
|
2019-03-19 14:47:18 +00:00
|
|
|
this.props.rightColumn,
|
|
|
|
|
this.props.leftColumn,
|
|
|
|
|
this.props.topRow,
|
|
|
|
|
this.props.bottomRow,
|
|
|
|
|
this.props.parentColumnSpace,
|
2019-09-09 09:08:54 +00:00
|
|
|
this.props.parentRowSpace,
|
|
|
|
|
);
|
2020-03-27 09:02:11 +00:00
|
|
|
};
|
2019-02-10 13:06:05 +00:00
|
|
|
|
2019-02-11 18:22:23 +00:00
|
|
|
calculateWidgetBounds(
|
|
|
|
|
rightColumn: number,
|
|
|
|
|
leftColumn: number,
|
|
|
|
|
topRow: number,
|
|
|
|
|
bottomRow: number,
|
|
|
|
|
parentColumnSpace: number,
|
2019-09-09 09:08:54 +00:00
|
|
|
parentRowSpace: number,
|
2020-04-03 04:48:40 +00:00
|
|
|
): {
|
|
|
|
|
componentWidth: number;
|
|
|
|
|
componentHeight: number;
|
|
|
|
|
} {
|
2020-03-27 09:02:11 +00:00
|
|
|
return {
|
2019-09-25 17:24:23 +00:00
|
|
|
componentWidth: (rightColumn - leftColumn) * parentColumnSpace,
|
|
|
|
|
componentHeight: (bottomRow - topRow) * parentRowSpace,
|
2019-09-09 09:08:54 +00:00
|
|
|
};
|
2019-02-11 18:22:23 +00:00
|
|
|
}
|
|
|
|
|
|
feat: Controls for labels in widgets to align the widgets in forms and other places (#10600)
* feat: When there are multiple input widgets with different label lengths then the input box looks misaligned
-- Create a new property control for a label position
-- Create a new property control for a label alignment
-- Prototype a label section for Input widget
* feat: When there are multiple input widgets with different label lengths then the input box looks misaligned
-- Add a property, labelWidth in the property pane
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Input widget: Implement all the requirements in case its type is Text
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Adapt the functionalty on other types of the input widget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add label functionalities into DropdownWidget
-- Clean up for the input widget and DRY
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add label functionalities into MultiSelectWidget
-- Eliminate unnecessary component prop, columns
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add label functionalties into Tree Select widget
-- Add styles for alignment between lable and input control over the widgets
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add label functionalities into MultiSelectTreeWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Introduce label functionalities into DatePickerWidget2
-- Use width instead of columns prop in InputWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Apply label functionalities into RichTextEditorWidget
-- Eliminate compactMode from StyledLabel
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Apply label functionalities into CheckboxGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Apply label functionalities into SwitchGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Reimplement switch group for the correct meaning of right alignment
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Apply label functionalities into RadioGroupWidget
-- Add new properties, alignment and inline for consistency
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Adjust cols and rows for RadioGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Eliminate unused StyledRadioProps
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Complete first MVP of enhanced SwitchGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Complete the first MVP of enhanced RadioGroupWidget
-- Eliminate unused StyledSwitch component for SwitchGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add min-height, align-self rules for LabelContainer
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Use original label property for RadioGroupWidget
-- Add a migration for adding isInline and alignment properties for RadioGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Update version to latest one in DSLMigrationsUtils.test.ts
* fix failing jest test
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Reimplement label functionalities on BaseInputWidget, InputWidgetV2, CurrencyInputWidget, PhoneInputWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Eliminate unused imports in DSLMigrationsUtils
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix on the label related test case which is failed in Input_spec.js
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix on #10119: The label text truncates on resizing the input widget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix scroll issue when shrink with MultiSelectWidget and MultiSelectTreeWidget
* fix: Widget Popup test
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Reimplement width and alginment features on the level of label element
-- Prevent actual inputs from DropdownWidget, MultiSelectWidget, SingleSelectTreeWidget, MultiSelectTreeWidget from overflow when resizing
-- Enable label feature on a RadioGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Set label container's default width to 33% when width is not set
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix crash issue when labelWidth is filled by non-numeric value, eliminating passing NaN as its value
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Set flex-grow to zero on input types other than TEXT
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Implement label features on newly created MultiSelectWidgetV2
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Eliminate LabelPositionTypes, directly using enum LabelPosition
-- Add a comment for a constant LABEL_MAX_WIDTH_RATE
-- Directly import React for LabelAlignmentOptionsControl
-- Remove unnecessary constructor for LabelAlignmentOptionsControl
-- Define handleAlign instance method as a higher-order function
-- Only migrate alignment property for RadioGroupWidget
-- Use Object.hasOwnProperty instead of in operator
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Migrate alignment property of RadioGroupWidget in case of currentDSL.version is 52
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Revert currentDSL.version to 52
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add a Jest test case for RadioGroupWidget's alignment property migration
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Replace all nested ternary operators with if statements
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Implement label feature on new version of SelectWidget
-- Add Cypress tests for widgets' label section
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Refactor code for BaseInputWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Change CSS selector for step buttons for Numeric BaseInputWidget
-- Directly use migrateRadioGroupAlignmentProperty migration function without using transformDSL
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix on typo about migrateRadioGroupAlignmentProperty
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add data-testid attributes for Cypress selectors
* feat: Deprecate form button widget
-- Assert flex-direction to row in CheckboxGroup_spec.js
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add a missing data-testid for SelectWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix on failed test cases: CheckboxGroup_spec, DatePicker_2_spec, MultiSelectWidgetV2
* fix: Select popup DSL
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Create a new property control, NumericInputControl
-- Replace all the label properties with the newly created controls
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Create a new Cypress command, checkLabelWidth and apply to all related test cases
-- Increase width in checkboxgroupDsl.json
-- Rename className for label in MultiSelectWidgetV2
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Reimplement the tooltip feature for labels
-- Add missing props for labels in DateField, MultiSelectField, RadioGroupField, SelectField fields for JSONFormWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Refactor property controls, including LabelPositionOptionsControl, LabelAlignmentOptionsControl, NumericInputControl to keep consistency
-- Apply default values into label section
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Extract the label related parts from the various widgets as an independent component
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Eliminate TypeScript any type from BaseInputComponent
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Change labelPosition property type to DROP_DOWN
-- Modify LabelAlignmentOptionsControl to use ButtonTabComponent
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Define getLabelWidth method into BaseWidget
-- Extract the common CSS rules for the widget containers
-- Revert rows and columns for SwitchGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix on the failed test case in DSLMigrationsUtils.test.ts
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix on overflow issue on CheckboxGroupWidget
-- Create a distinctive spec file for label feature
-- Eliminate the redundant label specs with the relevant widgets
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Delete unnecessary files, including Select_spec.js, LabelButton.tsx and LabelPositionOptionsControl.tsx
-- Revise wrong comment for checkLabelForWidget Cypress command
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Do not set the label width only if its value is 0
-- Clean up the component for DatePickerWidget2
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Eliminate unused imports in DatePickerWidget2
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Make RadioGroupWidget's layout flexible in all modes
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix on Cypress test case for RadioGroupWidget in Widgets_Labels_spec
-- Change Cypress commands, including addAction, addSuccessMessage, enterActionValue to accept parentSelector
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Change getLabelWidth method to not have any argument
-- Define some constants for label numbers
-- Extract the common styles for SwitchGroupWidget and RadioGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Refactor some constants
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Eliminate unused width prop from RadioGroupWidget
-- Get labelWidth from getLabelWidth
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Eliminate the min-height restriction on a label
-- Eliminate the scroll on the earlier InputWidgetV2 which was not in compact mode
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add one more condition checking if the current input type is text
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Extract common code base for MultiSelectTreeWidget and MultiSelectWidgetV2
-- Apply a few CSS fixes on the scrollbar issue select related widgets
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Apply some tweaks for earlier widgets with labels so as not to be broken UX
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Fix on the failed Cypress test case in Widget_Popup_spec.js
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Add constants, LABEL_DEFAULT_WIDTH_RATE, SELECT_DEFAULT_HEIGHT, LABEL_MARGIN_OLD_SELECT
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Increase the widths of CheckboxGroupWidget and SwitchGroupWidget
* feat: Controls for labels in widgets to align the widgets in forms and other places
-- Set the font size to 14px for NumericInputControl
Co-authored-by: ohansFavour <fohanekwu@gmail.com>
Co-authored-by: Tolulope Adetula <31691737+Tooluloope@users.noreply.github.com>
2022-04-14 08:47:25 +00:00
|
|
|
getLabelWidth = () => {
|
|
|
|
|
return (Number(this.props.labelWidth) || 0) * this.props.parentColumnSpace;
|
|
|
|
|
};
|
|
|
|
|
|
2021-06-21 11:09:51 +00:00
|
|
|
getErrorCount = memoize((evalErrors: Record<string, EvaluationError[]>) => {
|
|
|
|
|
return Object.values(evalErrors).reduce(
|
|
|
|
|
(prev, curr) =>
|
|
|
|
|
curr.filter(
|
|
|
|
|
(error) => error.errorType !== PropertyEvaluationErrorType.LINT,
|
|
|
|
|
).length + prev,
|
|
|
|
|
0,
|
|
|
|
|
);
|
2021-05-18 13:54:40 +00:00
|
|
|
}, JSON.stringify);
|
|
|
|
|
|
2019-02-11 18:22:23 +00:00
|
|
|
render() {
|
2020-03-17 09:01:29 +00:00
|
|
|
return this.getWidgetView();
|
2019-02-11 18:22:23 +00:00
|
|
|
}
|
2019-02-10 13:06:05 +00:00
|
|
|
|
2021-04-23 05:43:13 +00:00
|
|
|
/**
|
|
|
|
|
* this function is responsive for making the widget resizable.
|
|
|
|
|
* A widget can be made by non-resizable by passing resizeDisabled prop.
|
|
|
|
|
*
|
|
|
|
|
* @param content
|
|
|
|
|
*/
|
2020-03-27 09:02:11 +00:00
|
|
|
makeResizable(content: ReactNode) {
|
|
|
|
|
return (
|
|
|
|
|
<ResizableComponent
|
|
|
|
|
{...this.props}
|
|
|
|
|
paddingOffset={PositionedContainer.padding}
|
|
|
|
|
>
|
|
|
|
|
{content}
|
|
|
|
|
</ResizableComponent>
|
|
|
|
|
);
|
|
|
|
|
}
|
2021-04-23 05:43:13 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* this functions wraps the widget in a component that shows a setting control at the top right
|
|
|
|
|
* which gets shown on hover. A widget can enable/disable this by setting `disablePropertyPane` prop
|
|
|
|
|
*
|
|
|
|
|
* @param content
|
|
|
|
|
* @param showControls
|
|
|
|
|
*/
|
2020-03-27 09:02:11 +00:00
|
|
|
showWidgetName(content: ReactNode, showControls = false) {
|
|
|
|
|
return (
|
2021-04-23 05:43:13 +00:00
|
|
|
<>
|
|
|
|
|
{!this.props.disablePropertyPane && (
|
|
|
|
|
<WidgetNameComponent
|
2021-06-21 11:09:51 +00:00
|
|
|
errorCount={this.getErrorCount(
|
|
|
|
|
get(this.props, EVAL_ERROR_PATH, {}),
|
|
|
|
|
)}
|
2021-04-23 05:43:13 +00:00
|
|
|
parentId={this.props.parentId}
|
|
|
|
|
showControls={showControls}
|
2021-05-18 18:29:39 +00:00
|
|
|
topRow={this.props.detachFromLayout ? 4 : this.props.topRow}
|
2021-04-28 10:28:39 +00:00
|
|
|
type={this.props.type}
|
|
|
|
|
widgetId={this.props.widgetId}
|
|
|
|
|
widgetName={this.props.widgetName}
|
2021-04-23 05:43:13 +00:00
|
|
|
/>
|
|
|
|
|
)}
|
2020-03-27 09:02:11 +00:00
|
|
|
{content}
|
2021-04-23 05:43:13 +00:00
|
|
|
</>
|
2020-03-27 09:02:11 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-23 05:43:13 +00:00
|
|
|
/**
|
|
|
|
|
* wraps the widget in a draggable component.
|
|
|
|
|
* Note: widget drag can be disabled by setting `dragDisabled` prop to true
|
|
|
|
|
*
|
|
|
|
|
* @param content
|
|
|
|
|
*/
|
2020-03-27 09:02:11 +00:00
|
|
|
makeDraggable(content: ReactNode) {
|
|
|
|
|
return <DraggableComponent {...this.props}>{content}</DraggableComponent>;
|
|
|
|
|
}
|
2021-07-26 16:44:10 +00:00
|
|
|
/**
|
|
|
|
|
* wraps the widget in a draggable component.
|
|
|
|
|
* Note: widget drag can be disabled by setting `dragDisabled` prop to true
|
|
|
|
|
*
|
|
|
|
|
* @param content
|
|
|
|
|
*/
|
|
|
|
|
makeSnipeable(content: ReactNode) {
|
|
|
|
|
return <SnipeableComponent {...this.props}>{content}</SnipeableComponent>;
|
|
|
|
|
}
|
2020-03-27 09:02:11 +00:00
|
|
|
|
|
|
|
|
makePositioned(content: ReactNode) {
|
|
|
|
|
const style = this.getPositionStyle();
|
|
|
|
|
return (
|
2020-05-21 06:15:12 +00:00
|
|
|
<PositionedContainer
|
2021-05-27 06:41:38 +00:00
|
|
|
focused={this.props.focused}
|
2022-01-13 13:21:57 +00:00
|
|
|
parentId={this.props.parentId}
|
2021-05-27 06:41:38 +00:00
|
|
|
resizeDisabled={this.props.resizeDisabled}
|
|
|
|
|
selected={this.props.selected}
|
2021-04-28 10:28:39 +00:00
|
|
|
style={style}
|
2020-05-21 06:15:12 +00:00
|
|
|
widgetId={this.props.widgetId}
|
|
|
|
|
widgetType={this.props.type}
|
|
|
|
|
>
|
2020-03-27 09:02:11 +00:00
|
|
|
{content}
|
|
|
|
|
</PositionedContainer>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-21 06:14:50 +00:00
|
|
|
addErrorBoundary(content: ReactNode) {
|
|
|
|
|
return <ErrorBoundary>{content}</ErrorBoundary>;
|
2020-03-27 09:02:11 +00:00
|
|
|
}
|
|
|
|
|
|
2022-02-23 04:52:04 +00:00
|
|
|
addPreviewModeWidget(content: ReactNode): React.ReactElement {
|
|
|
|
|
return (
|
|
|
|
|
<PreviewModeComponent isVisible={this.props.isVisible}>
|
|
|
|
|
{content}
|
|
|
|
|
</PreviewModeComponent>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-19 10:10:36 +00:00
|
|
|
getWidgetComponent = () => {
|
|
|
|
|
const { renderMode, type } = this.props;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The widget mount calls the withWidgetProps with the widgetId and type to fetch the
|
|
|
|
|
* widget props. During the computation of the props (in withWidgetProps) if the evaluated
|
|
|
|
|
* values are not present (which will not be during mount), the widget type is changed to
|
|
|
|
|
* SKELETON_WIDGET.
|
|
|
|
|
*
|
|
|
|
|
* Note: This is done to retain the old rendering flow without any breaking changes.
|
|
|
|
|
* This could be refactored into not changing the widget type but to have a boolean flag.
|
|
|
|
|
*/
|
|
|
|
|
if (type === "SKELETON_WIDGET") {
|
|
|
|
|
return <Skeleton />;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return renderMode === RenderModes.CANVAS
|
|
|
|
|
? this.getCanvasView()
|
|
|
|
|
: this.getPageView();
|
|
|
|
|
};
|
|
|
|
|
|
2020-03-27 09:02:11 +00:00
|
|
|
private getWidgetView(): ReactNode {
|
|
|
|
|
let content: ReactNode;
|
2019-03-18 15:10:30 +00:00
|
|
|
switch (this.props.renderMode) {
|
|
|
|
|
case RenderModes.CANVAS:
|
2022-08-19 10:10:36 +00:00
|
|
|
content = this.getWidgetComponent();
|
2022-02-23 04:52:04 +00:00
|
|
|
content = this.addPreviewModeWidget(content);
|
2020-03-27 09:02:11 +00:00
|
|
|
if (!this.props.detachFromLayout) {
|
2021-04-23 05:43:13 +00:00
|
|
|
if (!this.props.resizeDisabled) content = this.makeResizable(content);
|
2020-03-27 09:02:11 +00:00
|
|
|
content = this.showWidgetName(content);
|
|
|
|
|
content = this.makeDraggable(content);
|
2021-07-26 16:44:10 +00:00
|
|
|
content = this.makeSnipeable(content);
|
|
|
|
|
// NOTE: In sniping mode we are not blocking onClick events from PositionWrapper.
|
2020-03-27 09:02:11 +00:00
|
|
|
content = this.makePositioned(content);
|
2019-11-13 07:00:25 +00:00
|
|
|
}
|
2020-03-27 09:02:11 +00:00
|
|
|
return content;
|
|
|
|
|
|
|
|
|
|
// return this.getCanvasView();
|
2019-03-18 15:10:30 +00:00
|
|
|
case RenderModes.PAGE:
|
2022-08-19 10:10:36 +00:00
|
|
|
content = this.getWidgetComponent();
|
2019-11-13 07:00:25 +00:00
|
|
|
if (this.props.isVisible) {
|
2020-12-21 06:14:50 +00:00
|
|
|
content = this.addErrorBoundary(content);
|
2020-03-27 09:02:11 +00:00
|
|
|
if (!this.props.detachFromLayout) {
|
|
|
|
|
content = this.makePositioned(content);
|
|
|
|
|
}
|
|
|
|
|
return content;
|
2019-11-13 07:00:25 +00:00
|
|
|
}
|
2021-04-28 10:28:39 +00:00
|
|
|
return null;
|
2019-03-18 15:10:30 +00:00
|
|
|
default:
|
2019-11-13 07:00:25 +00:00
|
|
|
throw Error("RenderMode not defined");
|
2019-03-18 15:10:30 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-27 09:02:11 +00:00
|
|
|
abstract getPageView(): ReactNode;
|
2019-03-18 15:10:30 +00:00
|
|
|
|
2020-03-27 09:02:11 +00:00
|
|
|
getCanvasView(): ReactNode {
|
|
|
|
|
const content = this.getPageView();
|
2020-12-21 06:14:50 +00:00
|
|
|
return this.addErrorBoundary(content);
|
2019-03-18 15:10:30 +00:00
|
|
|
}
|
2019-02-10 13:06:05 +00:00
|
|
|
|
2020-03-27 09:02:11 +00:00
|
|
|
// TODO(abhinav): Maybe make this a pure component to bailout from updating altogether.
|
|
|
|
|
// This would involve making all widgets which have "states" to not have states,
|
|
|
|
|
// as they're extending this one.
|
2020-04-13 08:24:13 +00:00
|
|
|
shouldComponentUpdate(nextProps: WidgetProps, nextState: WidgetState) {
|
|
|
|
|
return (
|
|
|
|
|
!shallowequal(nextProps, this.props) ||
|
|
|
|
|
!shallowequal(nextState, this.state)
|
|
|
|
|
);
|
2019-11-04 14:22:50 +00:00
|
|
|
}
|
|
|
|
|
|
2021-04-23 05:43:13 +00:00
|
|
|
/**
|
|
|
|
|
* generates styles that positions the widget
|
|
|
|
|
*/
|
2019-11-13 07:00:25 +00:00
|
|
|
private getPositionStyle(): BaseStyle {
|
2020-03-27 09:02:11 +00:00
|
|
|
const { componentHeight, componentWidth } = this.getComponentDimensions();
|
2021-04-23 05:43:13 +00:00
|
|
|
|
2019-03-19 14:05:48 +00:00
|
|
|
return {
|
2019-11-13 07:00:25 +00:00
|
|
|
positionType: PositionTypes.ABSOLUTE,
|
2020-03-27 09:02:11 +00:00
|
|
|
componentHeight,
|
|
|
|
|
componentWidth,
|
2020-01-16 11:46:21 +00:00
|
|
|
yPosition:
|
2021-04-23 05:43:13 +00:00
|
|
|
this.props.topRow * this.props.parentRowSpace +
|
|
|
|
|
(this.props.noContainerOffset ? 0 : CONTAINER_GRID_PADDING),
|
2020-01-16 11:46:21 +00:00
|
|
|
xPosition:
|
|
|
|
|
this.props.leftColumn * this.props.parentColumnSpace +
|
2021-04-23 05:43:13 +00:00
|
|
|
(this.props.noContainerOffset ? 0 : CONTAINER_GRID_PADDING),
|
2019-03-19 14:05:48 +00:00
|
|
|
xPositionUnit: CSSUnits.PIXEL,
|
2019-09-09 09:08:54 +00:00
|
|
|
yPositionUnit: CSSUnits.PIXEL,
|
|
|
|
|
};
|
2019-03-19 14:05:48 +00:00
|
|
|
}
|
|
|
|
|
|
2020-03-27 09:02:11 +00:00
|
|
|
// TODO(abhinav): These defaultProps seem unneccessary. Check it out.
|
|
|
|
|
static defaultProps: Partial<WidgetProps> | undefined = {
|
2019-09-19 22:25:37 +00:00
|
|
|
parentRowSpace: 1,
|
|
|
|
|
parentColumnSpace: 1,
|
2019-03-19 14:47:18 +00:00
|
|
|
topRow: 0,
|
2019-09-09 09:08:54 +00:00
|
|
|
leftColumn: 0,
|
2021-03-04 05:24:47 +00:00
|
|
|
isLoading: false,
|
|
|
|
|
renderMode: RenderModes.CANVAS,
|
2021-04-23 05:43:13 +00:00
|
|
|
dragDisabled: false,
|
|
|
|
|
dropDisabled: false,
|
|
|
|
|
isDeletable: true,
|
|
|
|
|
resizeDisabled: false,
|
|
|
|
|
disablePropertyPane: false,
|
2019-09-09 09:08:54 +00:00
|
|
|
};
|
2019-02-11 18:22:23 +00:00
|
|
|
}
|
2019-02-10 13:06:05 +00:00
|
|
|
|
2019-11-13 07:00:25 +00:00
|
|
|
export interface BaseStyle {
|
|
|
|
|
componentHeight: number;
|
|
|
|
|
componentWidth: number;
|
|
|
|
|
positionType: PositionType;
|
|
|
|
|
xPosition: number;
|
|
|
|
|
yPosition: number;
|
|
|
|
|
xPositionUnit: CSSUnit;
|
|
|
|
|
yPositionUnit: CSSUnit;
|
|
|
|
|
heightUnit?: CSSUnit;
|
|
|
|
|
widthUnit?: CSSUnit;
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-12 13:06:05 +00:00
|
|
|
export type WidgetState = Record<string, unknown>;
|
2019-02-10 13:06:05 +00:00
|
|
|
|
2022-08-19 10:10:36 +00:00
|
|
|
export interface WidgetBuilder<
|
|
|
|
|
T extends CanvasWidgetStructure,
|
|
|
|
|
S extends WidgetState
|
|
|
|
|
> {
|
2019-09-17 10:11:50 +00:00
|
|
|
buildWidget(widgetProps: T): JSX.Element;
|
2019-02-10 13:06:05 +00:00
|
|
|
}
|
|
|
|
|
|
2020-03-27 09:02:11 +00:00
|
|
|
export interface WidgetBaseProps {
|
2019-09-12 08:11:25 +00:00
|
|
|
widgetId: string;
|
2019-09-17 10:09:00 +00:00
|
|
|
type: WidgetType;
|
2019-09-12 08:11:25 +00:00
|
|
|
widgetName: string;
|
2021-03-04 05:24:47 +00:00
|
|
|
parentId?: string;
|
2020-03-27 09:02:11 +00:00
|
|
|
renderMode: RenderMode;
|
2021-02-23 12:35:09 +00:00
|
|
|
version: number;
|
2022-08-19 10:10:36 +00:00
|
|
|
childWidgets?: DataTreeWidget[];
|
2020-03-27 09:02:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type WidgetRowCols = {
|
2019-08-29 11:22:09 +00:00
|
|
|
leftColumn: number;
|
|
|
|
|
rightColumn: number;
|
2020-03-27 09:02:11 +00:00
|
|
|
topRow: number;
|
|
|
|
|
bottomRow: number;
|
|
|
|
|
minHeight?: number; // Required to reduce the size of CanvasWidgets.
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export interface WidgetPositionProps extends WidgetRowCols {
|
2019-08-29 11:22:09 +00:00
|
|
|
parentColumnSpace: number;
|
|
|
|
|
parentRowSpace: number;
|
2020-03-27 09:02:11 +00:00
|
|
|
// The detachFromLayout flag tells use about the following properties when enabled
|
|
|
|
|
// 1) Widget does not drag/resize
|
|
|
|
|
// 2) Widget CAN (but not neccessarily) be a dropTarget
|
|
|
|
|
// Examples: MainContainer is detached from layout,
|
|
|
|
|
// MODAL_WIDGET is also detached from layout.
|
|
|
|
|
detachFromLayout?: boolean;
|
2021-04-23 05:43:13 +00:00
|
|
|
noContainerOffset?: boolean; // This won't offset the child in parent
|
2020-03-27 09:02:11 +00:00
|
|
|
}
|
|
|
|
|
|
2020-10-21 04:25:32 +00:00
|
|
|
export const WIDGET_STATIC_PROPS = {
|
|
|
|
|
leftColumn: true,
|
|
|
|
|
rightColumn: true,
|
|
|
|
|
topRow: true,
|
|
|
|
|
bottomRow: true,
|
|
|
|
|
minHeight: true,
|
|
|
|
|
parentColumnSpace: true,
|
|
|
|
|
parentRowSpace: true,
|
|
|
|
|
children: true,
|
|
|
|
|
type: true,
|
|
|
|
|
widgetId: true,
|
|
|
|
|
widgetName: true,
|
|
|
|
|
parentId: true,
|
|
|
|
|
renderMode: true,
|
|
|
|
|
detachFromLayout: true,
|
2021-04-23 05:43:13 +00:00
|
|
|
noContainerOffset: false,
|
2020-10-21 04:25:32 +00:00
|
|
|
};
|
|
|
|
|
|
2021-06-18 07:42:57 +00:00
|
|
|
export const WIDGET_DISPLAY_PROPS = {
|
|
|
|
|
isVisible: true,
|
|
|
|
|
isLoading: true,
|
|
|
|
|
isDisabled: true,
|
|
|
|
|
backgroundColor: true,
|
|
|
|
|
};
|
|
|
|
|
|
2020-03-27 09:02:11 +00:00
|
|
|
export interface WidgetDisplayProps {
|
|
|
|
|
//TODO(abhinav): Some of these props are mandatory
|
2019-09-13 10:45:49 +00:00
|
|
|
isVisible?: boolean;
|
2019-11-20 08:10:01 +00:00
|
|
|
isLoading: boolean;
|
2019-11-13 07:00:25 +00:00
|
|
|
isDisabled?: boolean;
|
2019-10-08 09:09:30 +00:00
|
|
|
backgroundColor?: string;
|
2021-12-14 07:55:58 +00:00
|
|
|
animateLoading?: boolean;
|
2019-02-10 13:06:05 +00:00
|
|
|
}
|
|
|
|
|
|
2020-03-27 09:02:11 +00:00
|
|
|
export interface WidgetDataProps
|
|
|
|
|
extends WidgetBaseProps,
|
|
|
|
|
WidgetPositionProps,
|
|
|
|
|
WidgetDisplayProps {}
|
|
|
|
|
|
2020-11-12 11:23:32 +00:00
|
|
|
export interface WidgetProps
|
|
|
|
|
extends WidgetDataProps,
|
|
|
|
|
WidgetDynamicPathListProps,
|
2021-06-21 11:09:51 +00:00
|
|
|
DataTreeEvaluationProps {
|
2020-03-27 09:02:11 +00:00
|
|
|
key?: string;
|
|
|
|
|
isDefaultClickDisabled?: boolean;
|
|
|
|
|
[key: string]: any;
|
|
|
|
|
}
|
2019-09-17 10:11:50 +00:00
|
|
|
|
2019-09-06 09:30:22 +00:00
|
|
|
export interface WidgetCardProps {
|
2019-09-17 10:09:00 +00:00
|
|
|
type: WidgetType;
|
2019-08-29 11:22:09 +00:00
|
|
|
key?: string;
|
2021-09-09 15:10:22 +00:00
|
|
|
displayName: string;
|
|
|
|
|
icon: string;
|
2021-04-23 05:43:13 +00:00
|
|
|
isBeta?: boolean;
|
2019-08-21 12:49:16 +00:00
|
|
|
}
|
|
|
|
|
|
2019-09-19 22:25:37 +00:00
|
|
|
export const WidgetOperations = {
|
|
|
|
|
MOVE: "MOVE",
|
|
|
|
|
RESIZE: "RESIZE",
|
|
|
|
|
ADD_CHILD: "ADD_CHILD",
|
|
|
|
|
UPDATE_PROPERTY: "UPDATE_PROPERTY",
|
|
|
|
|
DELETE: "DELETE",
|
2020-09-16 10:28:01 +00:00
|
|
|
ADD_CHILDREN: "ADD_CHILDREN",
|
2019-09-17 15:09:55 +00:00
|
|
|
};
|
|
|
|
|
|
2019-11-22 14:02:55 +00:00
|
|
|
export type WidgetOperation = typeof WidgetOperations[keyof typeof WidgetOperations];
|
2019-09-17 15:09:55 +00:00
|
|
|
|
2019-09-09 09:08:54 +00:00
|
|
|
export default BaseWidget;
|