## Description TL;DR This is a complete architectural change of of List widget works to support all widgets we currently have and should automatically support any future widgets. It also introduces nested List widgets i.e a list widget can have a another list widget which in turn can have another list widget. Fixes #18206 Fixes #6775 Fixes #13211 Fixes #16582 Fixes #11739 Fixes #15094 Fixes #6840 Fixes #10841 Fixes #17386 Fixes #18340 Fixes #16898 Fixes #17555 Fixes #6858 Fixes #9568 Fixes #17480 Fixes #18523 Fixes #18206 Fixes #16586 Fixes #18106 Fixes #16576 Fixes #14697 Fixes #9607 Fixes #19648 Fixes #19739 Fixes #19652 Fixes #18730 Fixes #19503 Fixes #19498 Fixes #19437 Fixes #5245 Fixes #19150 Fixes #18638 Fixes #11332 Fixes #17901 Fixes #19043 Fixes #17777 Fixes #8237 Fixes #15487 Fixes #15988 Fixes #18621 Fixes #16788 Fixes #18110 Fixes #18382 Fixes #17427 Fixes #18105 Fixes #18287 Fixes #19808 Fixes #14655 ## Type of change - New feature (non-breaking change which adds functionality) ## How Has This Been Tested? - Cypress - Jest - Manual ## Checklist: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes --------- Co-authored-by: Tolulope Adetula <31691737+Tooluloope@users.noreply.github.com> Co-authored-by: Favour Ohanekwu <fohanekwu@gmail.com>
152 lines
5.6 KiB
TypeScript
152 lines
5.6 KiB
TypeScript
import { getPropertyControlTypes } from "components/propertyControls";
|
|
import {
|
|
ValidationResponse,
|
|
ValidationTypes,
|
|
} from "constants/WidgetValidation";
|
|
import { EvaluationSubstitutionType } from "entities/DataTree/dataTreeFactory";
|
|
import { CodeEditorExpected } from "components/editorComponents/CodeEditor";
|
|
import { UpdateWidgetPropertyPayload } from "actions/controlActions";
|
|
import { AppTheme } from "entities/AppTheming";
|
|
import { WidgetProps } from "widgets/BaseWidget";
|
|
import { AdditionalDynamicDataTree } from "utils/autocomplete/customTreeTypeDefCreator";
|
|
import { Stylesheet } from "entities/AppTheming";
|
|
import { ReduxActionType } from "@appsmith/constants/ReduxActionConstants";
|
|
|
|
const ControlTypes = getPropertyControlTypes();
|
|
export type ControlType = typeof ControlTypes[keyof typeof ControlTypes];
|
|
|
|
export type PropertyPaneSectionConfig = {
|
|
sectionName: string;
|
|
id?: string;
|
|
children: PropertyPaneConfig[];
|
|
collapsible?: boolean; // Indicates whether the section could be collapsed or not
|
|
childrenId?: string; // A unique id generated by combining the ids of all the children
|
|
hidden?: (props: any, propertyPath: string) => boolean;
|
|
isDefaultOpen?: boolean;
|
|
propertySectionPath?: string;
|
|
tag?: string; // Used to show a tag right after the section name (only in the search results)
|
|
};
|
|
|
|
export type PropertyHookUpdates = {
|
|
propertyPath: string;
|
|
propertyValue?: unknown;
|
|
isDynamicPropertyPath?: boolean; // Toggles the property mode to JS
|
|
shouldDeleteProperty?: boolean; // Deletes the property, propertyValue is ignored
|
|
};
|
|
|
|
export type PanelConfig = {
|
|
editableTitle: boolean;
|
|
titlePropertyName: string;
|
|
panelIdPropertyName: string;
|
|
children?: PropertyPaneConfig[];
|
|
contentChildren?: PropertyPaneConfig[];
|
|
styleChildren?: PropertyPaneConfig[];
|
|
searchConfig?: PropertyPaneConfig[]; // A combination of contentChildren and contentChildren which will be used to display search results
|
|
updateHook: (
|
|
props: any,
|
|
propertyPath: string,
|
|
propertyValue: any,
|
|
) => Array<PropertyHookUpdates> | undefined;
|
|
};
|
|
|
|
export type PropertyPaneControlConfig = {
|
|
id?: string;
|
|
label: string;
|
|
propertyName: string;
|
|
// Serves in the tooltip
|
|
helpText?: string;
|
|
//Dynamic text serves below the property pane inputs
|
|
helperText?: ((props: any) => string) | string;
|
|
isJSConvertible?: boolean;
|
|
customJSControl?: string;
|
|
controlType: ControlType;
|
|
validationMessage?: string;
|
|
dataTreePath?: string;
|
|
children?: PropertyPaneConfig[];
|
|
panelConfig?: PanelConfig;
|
|
updateRelatedWidgetProperties?: (
|
|
propertyName: string,
|
|
propertyValue: any,
|
|
props: any,
|
|
) => UpdateWidgetPropertyPayload[];
|
|
updateHook?: (
|
|
props: any,
|
|
propertyName: string,
|
|
propertyValue: any,
|
|
) => Array<PropertyHookUpdates> | undefined;
|
|
hidden?: (props: any, propertyPath: string) => boolean;
|
|
invisible?: boolean;
|
|
isBindProperty: boolean;
|
|
isTriggerProperty: boolean;
|
|
validation?: ValidationConfig;
|
|
useValidationMessage?: boolean;
|
|
additionalAutoComplete?: (props: any) => AdditionalDynamicDataTree;
|
|
evaluationSubstitutionType?: EvaluationSubstitutionType;
|
|
dependencies?: string[];
|
|
evaluatedDependencies?: string[]; // dependencies to be picked from the __evaluated__ object
|
|
expected?: CodeEditorExpected;
|
|
getStylesheetValue?: (
|
|
props: any,
|
|
propertyPath: string,
|
|
stylesheet?: Stylesheet,
|
|
) => Stylesheet[string];
|
|
// TODO(abhinav): To fix this, rename the options property of the controls which use this
|
|
// Alternatively, create a new structure
|
|
options?: any;
|
|
// The following should ideally be used internally
|
|
postUpdateAction?: ReduxActionType;
|
|
onBlur?: () => void;
|
|
onFocus?: () => void;
|
|
isPanelProperty?: boolean;
|
|
// Numeric Input Control
|
|
min?: number;
|
|
};
|
|
|
|
type ValidationConfigParams = {
|
|
min?: number; // min allowed for a number
|
|
max?: number; // max allowed for a number
|
|
natural?: boolean; // is a positive integer
|
|
default?: unknown; // default for any type
|
|
unique?: boolean | string[]; // unique in an array (string if a particular path is unique)
|
|
required?: boolean; // required type
|
|
// required is now used to check if value is an empty string.
|
|
requiredKey?: boolean; //required key
|
|
regex?: RegExp; // validator regex for text type
|
|
allowedKeys?: Array<{
|
|
// Allowed keys in an object type
|
|
name: string;
|
|
type: ValidationTypes;
|
|
params?: ValidationConfigParams;
|
|
}>;
|
|
allowedValues?: unknown[]; // Allowed values in a string and array type
|
|
children?: ValidationConfig; // Children configurations in an ARRAY or OBJECT_ARRAY type
|
|
fn?: (
|
|
value: unknown,
|
|
props: any,
|
|
_?: any,
|
|
moment?: any,
|
|
) => ValidationResponse; // Function in a FUNCTION type
|
|
fnString?: string; // AUTO GENERATED, SHOULD NOT BE SET BY WIDGET DEVELOPER
|
|
expected?: CodeEditorExpected; // FUNCTION type expected type and example
|
|
strict?: boolean; //for strict string validation of TEXT type
|
|
ignoreCase?: boolean; //to ignore the case of key
|
|
type?: ValidationTypes; // Used for ValidationType.ARRAY_OF_TYPE_OR_TYPE to define sub type
|
|
params?: ValidationConfigParams; // Used for ValidationType.ARRAY_OF_TYPE_OR_TYPE to define sub type params
|
|
passThroughOnZero?: boolean; // Used for ValidationType.NUMBER to allow 0 to be passed through. Deafults value is true
|
|
limitLineBreaks?: boolean; // Used for ValidationType.TEXT to limit line breaks in a large json object.
|
|
};
|
|
|
|
export type ValidationConfig = {
|
|
type: ValidationTypes;
|
|
params?: ValidationConfigParams;
|
|
dependentPaths?: string[];
|
|
};
|
|
|
|
export type PropertyPaneConfig =
|
|
| PropertyPaneSectionConfig
|
|
| PropertyPaneControlConfig;
|
|
|
|
export interface ActionValidationConfigMap {
|
|
[configProperty: string]: ValidationConfig;
|
|
}
|