@itwin/components-react 3.0.0-dev.72 → 3.0.0-dev.78
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components-react/UiComponents.d.ts +10 -10
- package/lib/components-react/UiComponents.d.ts.map +1 -1
- package/lib/components-react/UiComponents.js +18 -18
- package/lib/components-react/UiComponents.js.map +1 -1
- package/lib/components-react/common/HighlightedText.d.ts +2 -2
- package/lib/components-react/common/HighlightedText.js +1 -1
- package/lib/components-react/common/HighlightedText.js.map +1 -1
- package/lib/components-react/common/HighlightingComponentProps.d.ts +2 -2
- package/lib/components-react/common/HighlightingComponentProps.js.map +1 -1
- package/lib/components-react/common/UseAsyncValue.d.ts +1 -1
- package/lib/components-react/common/UseAsyncValue.js +1 -1
- package/lib/components-react/common/UseAsyncValue.js.map +1 -1
- package/lib/components-react/datepicker/DatePicker.js +28 -28
- package/lib/components-react/datepicker/DatePicker.js.map +1 -1
- package/lib/components-react/editors/BooleanEditor.d.ts +2 -2
- package/lib/components-react/editors/BooleanEditor.js +2 -2
- package/lib/components-react/editors/BooleanEditor.js.map +1 -1
- package/lib/components-react/editors/EnumButtonGroupEditor.d.ts +2 -2
- package/lib/components-react/editors/EnumButtonGroupEditor.js +2 -2
- package/lib/components-react/editors/EnumButtonGroupEditor.js.map +1 -1
- package/lib/components-react/editors/EnumEditor.d.ts +2 -2
- package/lib/components-react/editors/EnumEditor.js +2 -2
- package/lib/components-react/editors/EnumEditor.js.map +1 -1
- package/lib/components-react/editors/ImageCheckBoxEditor.d.ts +2 -2
- package/lib/components-react/editors/ImageCheckBoxEditor.js +2 -2
- package/lib/components-react/editors/ImageCheckBoxEditor.js.map +1 -1
- package/lib/components-react/editors/NumericInputEditor.d.ts +2 -2
- package/lib/components-react/editors/NumericInputEditor.js +2 -2
- package/lib/components-react/editors/NumericInputEditor.js.map +1 -1
- package/lib/components-react/editors/PropertyEditorManager.d.ts +7 -7
- package/lib/components-react/editors/PropertyEditorManager.js +4 -4
- package/lib/components-react/editors/PropertyEditorManager.js.map +1 -1
- package/lib/components-react/editors/SliderEditor.d.ts +2 -2
- package/lib/components-react/editors/SliderEditor.js +2 -2
- package/lib/components-react/editors/SliderEditor.js.map +1 -1
- package/lib/components-react/editors/TextEditor.d.ts +1 -1
- package/lib/components-react/editors/TextEditor.js +1 -1
- package/lib/components-react/editors/TextEditor.js.map +1 -1
- package/lib/components-react/editors/TextareaEditor.d.ts +2 -2
- package/lib/components-react/editors/TextareaEditor.js +2 -2
- package/lib/components-react/editors/TextareaEditor.js.map +1 -1
- package/lib/components-react/editors/ThemedEnumEditor.d.ts +3 -3
- package/lib/components-react/editors/ThemedEnumEditor.d.ts.map +1 -1
- package/lib/components-react/editors/ThemedEnumEditor.js +3 -2
- package/lib/components-react/editors/ThemedEnumEditor.js.map +1 -1
- package/lib/components-react/editors/ToggleEditor.d.ts +2 -2
- package/lib/components-react/editors/ToggleEditor.js +2 -2
- package/lib/components-react/editors/ToggleEditor.js.map +1 -1
- package/lib/components-react/favorite/FavoritePropertiesRenderer.d.ts +1 -1
- package/lib/components-react/favorite/FavoritePropertiesRenderer.js +1 -1
- package/lib/components-react/favorite/FavoritePropertiesRenderer.js.map +1 -1
- package/lib/components-react/filtering/FilteringInput.d.ts +1 -2
- package/lib/components-react/filtering/FilteringInput.d.ts.map +1 -1
- package/lib/components-react/filtering/FilteringInput.js +1 -1
- package/lib/components-react/filtering/FilteringInput.js.map +1 -1
- package/lib/components-react/inputs/ParsedInput.d.ts +2 -2
- package/lib/components-react/inputs/ParsedInput.js +1 -1
- package/lib/components-react/inputs/ParsedInput.js.map +1 -1
- package/lib/components-react/properties/renderers/ActionButtonList.d.ts +2 -2
- package/lib/components-react/properties/renderers/ActionButtonList.js +1 -1
- package/lib/components-react/properties/renderers/ActionButtonList.js.map +1 -1
- package/lib/components-react/properties/renderers/PrimitivePropertyRenderer.d.ts +0 -1
- package/lib/components-react/properties/renderers/PrimitivePropertyRenderer.d.ts.map +1 -1
- package/lib/components-react/properties/renderers/PrimitivePropertyRenderer.js.map +1 -1
- package/lib/components-react/properties/renderers/PropertyRenderer.d.ts +5 -10
- package/lib/components-react/properties/renderers/PropertyRenderer.d.ts.map +1 -1
- package/lib/components-react/properties/renderers/PropertyRenderer.js.map +1 -1
- package/lib/components-react/properties/renderers/label/PropertyLabelRenderer.d.ts +1 -3
- package/lib/components-react/properties/renderers/label/PropertyLabelRenderer.d.ts.map +1 -1
- package/lib/components-react/properties/renderers/label/PropertyLabelRenderer.js.map +1 -1
- package/lib/components-react/properties/renderers/value/PrimitivePropertyValueRenderer.d.ts +1 -1
- package/lib/components-react/properties/renderers/value/PrimitivePropertyValueRenderer.js +1 -1
- package/lib/components-react/properties/renderers/value/PrimitivePropertyValueRenderer.js.map +1 -1
- package/lib/components-react/propertygrid/PropertyCategoryRendererManager.d.ts +1 -1
- package/lib/components-react/propertygrid/PropertyCategoryRendererManager.js.map +1 -1
- package/lib/components-react/propertygrid/PropertyDataProvider.d.ts +1 -3
- package/lib/components-react/propertygrid/PropertyDataProvider.d.ts.map +1 -1
- package/lib/components-react/propertygrid/PropertyDataProvider.js.map +1 -1
- package/lib/components-react/propertygrid/component/PropertyCategoryBlock.d.ts +1 -3
- package/lib/components-react/propertygrid/component/PropertyCategoryBlock.d.ts.map +1 -1
- package/lib/components-react/propertygrid/component/PropertyCategoryBlock.js.map +1 -1
- package/lib/components-react/propertygrid/component/PropertyGridCommons.d.ts +0 -2
- package/lib/components-react/propertygrid/component/PropertyGridCommons.d.ts.map +1 -1
- package/lib/components-react/propertygrid/component/PropertyGridCommons.js.map +1 -1
- package/lib/components-react/propertygrid/dataproviders/FilteringDataProvider.d.ts +13 -4
- package/lib/components-react/propertygrid/dataproviders/FilteringDataProvider.d.ts.map +1 -1
- package/lib/components-react/propertygrid/dataproviders/FilteringDataProvider.js +9 -2
- package/lib/components-react/propertygrid/dataproviders/FilteringDataProvider.js.map +1 -1
- package/lib/components-react/propertygrid/dataproviders/filterers/CompositePropertyDataFilterer.d.ts +2 -2
- package/lib/components-react/propertygrid/dataproviders/filterers/CompositePropertyDataFilterer.js +2 -2
- package/lib/components-react/propertygrid/dataproviders/filterers/CompositePropertyDataFilterer.js.map +1 -1
- package/lib/components-react/propertygrid/dataproviders/filterers/DisplayValuePropertyDataFilterer.d.ts +1 -1
- package/lib/components-react/propertygrid/dataproviders/filterers/DisplayValuePropertyDataFilterer.js +1 -1
- package/lib/components-react/propertygrid/dataproviders/filterers/DisplayValuePropertyDataFilterer.js.map +1 -1
- package/lib/components-react/propertygrid/dataproviders/filterers/LabelPropertyDataFilterer.d.ts +1 -1
- package/lib/components-react/propertygrid/dataproviders/filterers/LabelPropertyDataFilterer.js +1 -1
- package/lib/components-react/propertygrid/dataproviders/filterers/LabelPropertyDataFilterer.js.map +1 -1
- package/lib/components-react/propertygrid/dataproviders/filterers/PropertyCategoryLabelFilterer.d.ts +1 -1
- package/lib/components-react/propertygrid/dataproviders/filterers/PropertyCategoryLabelFilterer.js +1 -1
- package/lib/components-react/propertygrid/dataproviders/filterers/PropertyCategoryLabelFilterer.js.map +1 -1
- package/lib/components-react/propertygrid/dataproviders/filterers/PropertyDataFiltererBase.d.ts +17 -14
- package/lib/components-react/propertygrid/dataproviders/filterers/PropertyDataFiltererBase.d.ts.map +1 -1
- package/lib/components-react/propertygrid/dataproviders/filterers/PropertyDataFiltererBase.js +10 -8
- package/lib/components-react/propertygrid/dataproviders/filterers/PropertyDataFiltererBase.js.map +1 -1
- package/lib/components-react/propertygrid/internal/PropertyGridHooks.d.ts +4 -4
- package/lib/components-react/propertygrid/internal/PropertyGridHooks.js +5 -5
- package/lib/components-react/propertygrid/internal/PropertyGridHooks.js.map +1 -1
- package/lib/components-react/selectable-content/SelectableContent.d.ts +5 -5
- package/lib/components-react/selectable-content/SelectableContent.d.ts.map +1 -1
- package/lib/components-react/selectable-content/SelectableContent.js +3 -2
- package/lib/components-react/selectable-content/SelectableContent.js.map +1 -1
- package/lib/components-react/table/SimpleTableDataProvider.d.ts +2 -2
- package/lib/components-react/table/SimpleTableDataProvider.js +2 -2
- package/lib/components-react/table/SimpleTableDataProvider.js.map +1 -1
- package/lib/components-react/table/columnfiltering/data-grid-addons/AutoCompleteFilter.d.ts.map +1 -1
- package/lib/components-react/table/columnfiltering/data-grid-addons/AutoCompleteFilter.js +1 -0
- package/lib/components-react/table/columnfiltering/data-grid-addons/AutoCompleteFilter.js.map +1 -1
- package/lib/components-react/table/component/Table.d.ts +4 -7
- package/lib/components-react/table/component/Table.d.ts.map +1 -1
- package/lib/components-react/table/component/Table.js.map +1 -1
- package/lib/components-react/toolbar/Item.d.ts +2 -2
- package/lib/components-react/toolbar/Item.js +1 -1
- package/lib/components-react/toolbar/Item.js.map +1 -1
- package/lib/components-react/toolbar/PopupItem.d.ts +2 -2
- package/lib/components-react/toolbar/PopupItem.js +1 -1
- package/lib/components-react/toolbar/PopupItem.js.map +1 -1
- package/lib/components-react/toolbar/PopupItemWithDrag.d.ts +2 -2
- package/lib/components-react/toolbar/PopupItemWithDrag.js +1 -1
- package/lib/components-react/toolbar/PopupItemWithDrag.js.map +1 -1
- package/lib/components-react/toolbar/Toolbar.d.ts +2 -2
- package/lib/components-react/toolbar/Toolbar.js +1 -1
- package/lib/components-react/toolbar/Toolbar.js.map +1 -1
- package/lib/components-react/toolbar/ToolbarWithOverflow.d.ts +6 -6
- package/lib/components-react/toolbar/ToolbarWithOverflow.js +3 -3
- package/lib/components-react/toolbar/ToolbarWithOverflow.js.map +1 -1
- package/lib/components-react/toolbar/utilities/Direction.d.ts +1 -1
- package/lib/components-react/toolbar/utilities/Direction.js +1 -1
- package/lib/components-react/toolbar/utilities/Direction.js.map +1 -1
- package/lib/components-react/tree/HighlightingEngine.d.ts +1 -1
- package/lib/components-react/tree/HighlightingEngine.js +1 -1
- package/lib/components-react/tree/HighlightingEngine.js.map +1 -1
- package/lib/components-react/tree/TreeDataProvider.d.ts +1 -1
- package/lib/components-react/tree/TreeDataProvider.js.map +1 -1
- package/lib/components-react/tree/controlled/TreeHooks.d.ts +3 -4
- package/lib/components-react/tree/controlled/TreeHooks.d.ts.map +1 -1
- package/lib/components-react/tree/controlled/TreeHooks.js +3 -4
- package/lib/components-react/tree/controlled/TreeHooks.js.map +1 -1
- package/lib/components-react/tree/controlled/component/ControlledTree.d.ts +1 -1
- package/lib/components-react/tree/controlled/component/ControlledTree.js.map +1 -1
- package/lib/components-react/tree/controlled/component/TreeNodeEditor.d.ts +9 -6
- package/lib/components-react/tree/controlled/component/TreeNodeEditor.d.ts.map +1 -1
- package/lib/components-react/tree/controlled/component/TreeNodeEditor.js +3 -2
- package/lib/components-react/tree/controlled/component/TreeNodeEditor.js.map +1 -1
- package/lib/components-react/tree/controlled/component/TreeNodeRenderer.d.ts +12 -16
- package/lib/components-react/tree/controlled/component/TreeNodeRenderer.d.ts.map +1 -1
- package/lib/components-react/tree/controlled/component/TreeNodeRenderer.js +1 -1
- package/lib/components-react/tree/controlled/component/TreeNodeRenderer.js.map +1 -1
- package/lib/components-react/tree/controlled/component/TreeRenderer.d.ts +5 -54
- package/lib/components-react/tree/controlled/component/TreeRenderer.d.ts.map +1 -1
- package/lib/components-react/tree/controlled/component/TreeRenderer.js +13 -28
- package/lib/components-react/tree/controlled/component/TreeRenderer.js.map +1 -1
- package/lib/public/locales/en/UiComponents.json +1 -8
- package/package.json +16 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnumButtonGroupEditor.js","sourceRoot":"","sources":["../../../src/components-react/editors/EnumButtonGroupEditor.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,wCAAsC;AACtC,4DAAoC;AACpC,6CAA+B;AAC/B,0DAG+B;AAC/B,kDAAyC;AAEzC,mEAAoF;AAWpF;;GAEG;AACH,MAAa,qBAAsB,SAAQ,KAAK,CAAC,SAA0D;IAA3G;;QACU,aAAQ,GAAG,IAAI,GAAG,EAAs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E,IAAA,oBAAU,EAAC,mCAAmC,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,WAAW,IAClI,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAyB,EAAE,KAAa,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CACrJ,CAAC,CAAC;IACZ,CAAC;CACF;AA/JD,sDA+JC;AAED;;;GAGG;AACH,MAAa,6BAA8B,SAAQ,0CAAkB;IACnE,IAAW,SAAS;QAClB,OAAO,oBAAC,qBAAqB,OAAG,CAAC;IACnC,CAAC;CACF;AAJD,sEAIC;AAED,6CAAqB,CAAC,cAAc,CAAC,kCAAiB,CAAC,IAAI,EAAE,6BAA6B,EAAE,oCAAmB,CAAC,eAAe,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module PropertyEditors\n */\n\nimport \"./EnumButtonGroupEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport {\n ButtonGroupEditorParams, EnumerationChoice, IconDefinition, PropertyEditorParams, PropertyEditorParamTypes, PropertyRecord,\n PropertyValue, PropertyValueFormat, StandardEditorNames, StandardTypeNames,\n} from \"@itwin/appui-abstract\";\nimport { Icon } from \"@itwin/core-react\";\nimport { PropertyEditorProps, TypeEditor } from \"./EditorContainer\";\nimport { PropertyEditorBase, PropertyEditorManager } from \"./PropertyEditorManager\";\n\n// cspell:ignore buttongroup enumbuttongroup\n\n/** @internal */\ninterface EnumButtonGroupEditorState {\n selectValue: string | number;\n enumIcons: IconDefinition[];\n choices: EnumerationChoice[];\n}\n\n/** EnumButtonGroupEditor React component that is a property editor with select input\n * @beta\n */\nexport class EnumButtonGroupEditor extends React.Component<PropertyEditorProps, EnumButtonGroupEditorState> implements TypeEditor {\n private _btnRefs = new Map<string | number, HTMLButtonElement>();\n private _divElement = React.createRef<HTMLDivElement>();\n\n /** @internal */\n public override readonly state: Readonly<EnumButtonGroupEditorState> = {\n selectValue: \"\",\n enumIcons: [],\n choices: [],\n };\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n // istanbul ignore else\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n propertyValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: this.state.selectValue,\n displayValue: \"\",\n };\n }\n\n return propertyValue;\n }\n\n public get htmlElement(): HTMLElement | null {\n return this._divElement.current;\n }\n\n public get hasFocus(): boolean {\n let containsFocus = false;\n // istanbul ignore else\n if (this._divElement.current)\n containsFocus = this._divElement.current.contains(document.activeElement);\n return containsFocus;\n }\n\n /** @internal */\n public override componentDidMount() {\n this.setStateFromProps(); // eslint-disable-line @typescript-eslint/no-floating-promises\n }\n\n /** @internal */\n public override componentDidUpdate(prevProps: PropertyEditorProps) {\n if (this.props.propertyRecord !== prevProps.propertyRecord) {\n this.setStateFromProps(); // eslint-disable-line @typescript-eslint/no-floating-promises\n }\n }\n\n private async setStateFromProps() {\n const { propertyRecord } = this.props;\n\n // istanbul ignore else\n if (propertyRecord && propertyRecord.property.enum && propertyRecord.value.valueFormat === PropertyValueFormat.Primitive) {\n const primitiveValue = propertyRecord.value.value;\n let selectValue: string | number;\n\n if (typeof primitiveValue === \"string\") {\n selectValue = primitiveValue;\n } else {\n selectValue = primitiveValue as number;\n }\n\n let choices: EnumerationChoice[] = [];\n // istanbul ignore else\n if (propertyRecord && propertyRecord.property.enum) {\n if (propertyRecord.property.enum.choices instanceof Promise) {\n choices = await propertyRecord.property.enum.choices;\n } else {\n choices = propertyRecord.property.enum.choices;\n }\n }\n\n const numChoices = choices.length;\n const enumIcons = new Array<IconDefinition>(numChoices);\n enumIcons.fill({ iconSpec: \"icon icon-placeholder\" });\n\n // istanbul ignore else\n if (propertyRecord.property.editor && propertyRecord.property.editor.params) {\n // istanbul ignore else\n if (propertyRecord.property.editor && propertyRecord.property.editor.params) {\n const bgParams = propertyRecord.property.editor.params.find((param: PropertyEditorParams) => param.type === PropertyEditorParamTypes.ButtonGroupData) as ButtonGroupEditorParams;\n // istanbul ignore else\n if (bgParams) {\n bgParams.buttons.forEach((iconDef: IconDefinition, index: number) => {\n // istanbul ignore else\n if (index < numChoices) {\n enumIcons[index] = iconDef;\n }\n });\n }\n }\n }\n\n this.setState({ selectValue, enumIcons, choices });\n }\n }\n\n private _handleButtonClick = (index: number) => {\n const propertyRecord = this.props.propertyRecord as PropertyRecord;\n\n // istanbul ignore else\n if (this.state.choices && this.state.choices.length > index) {\n const selectValue = this.state.choices[index].value;\n\n this.setState({\n selectValue,\n }, async () => {\n // istanbul ignore else\n if (propertyRecord && this.props.onCommit) {\n const propertyValue = await this.getPropertyValue();\n // istanbul ignore else\n if (propertyValue !== undefined) {\n this.props.onCommit({ propertyRecord, newValue: propertyValue });\n }\n }\n });\n }\n };\n\n private getButton(choice: EnumerationChoice, index: number) {\n const choiceValue = this.state.choices ? this.state.choices[index].value : /* istanbul ignore next */ 0;\n const isActive = (choiceValue === this.state.selectValue) ? true : false;\n let isDisabled = false;\n const isEnabledFunction = this.state.enumIcons[index].isEnabledFunction;\n // istanbul ignore else\n if (isEnabledFunction) {\n isDisabled = !isEnabledFunction();\n }\n\n const className = classnames(\n \"components-enumbuttongroup-button\",\n isDisabled && \"nz-is-disabled\",\n isActive && \"nz-is-active\",\n );\n\n return (\n <button\n ref={(ref: HTMLButtonElement) => this._btnRefs.set(choiceValue, ref)}\n data-testid={choice.label}\n className={className}\n title={choice.label}\n key={choice.label}\n onClick={() => this._handleButtonClick(index)}\n >\n <Icon iconSpec={this.state.enumIcons[index].iconSpec} />\n </button >\n );\n }\n\n /** @internal */\n public override render() {\n return (\n <div className={classnames(\"components-enumbuttongroup-editor\", this.props.className)} style={this.props.style} ref={this._divElement}>\n {this.state.choices && this.state.enumIcons.length && this.state.choices.map((choice: EnumerationChoice, index: number) => this.getButton(choice, index))}\n </div>);\n }\n}\n\n/** Enum Property Button Group Editor registered for the \"enum\" type name and the \"enum-buttongroup\" editor name.\n * It uses the [[EnumButtonGroupEditor]] React component.\n * @beta\n */\nexport class EnumPropertyButtonGroupEditor extends PropertyEditorBase { // istanbul ignore next\n public get reactNode(): React.ReactNode {\n return <EnumButtonGroupEditor />;\n }\n}\n\nPropertyEditorManager.registerEditor(StandardTypeNames.Enum, EnumPropertyButtonGroupEditor, StandardEditorNames.EnumButtonGroup);\n"]}
|
|
1
|
+
{"version":3,"file":"EnumButtonGroupEditor.js","sourceRoot":"","sources":["../../../src/components-react/editors/EnumButtonGroupEditor.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,wCAAsC;AACtC,4DAAoC;AACpC,6CAA+B;AAC/B,0DAG+B;AAC/B,kDAAyC;AAEzC,mEAAoF;AAWpF;;GAEG;AACH,MAAa,qBAAsB,SAAQ,KAAK,CAAC,SAA0D;IAA3G;;QACU,aAAQ,GAAG,IAAI,GAAG,EAAsC,CAAC;QACzD,gBAAW,GAAG,KAAK,CAAC,SAAS,EAAkB,CAAC;QAExD,gBAAgB;QACS,UAAK,GAAyC;YACrE,WAAW,EAAE,EAAE;YACf,SAAS,EAAE,EAAE;YACb,OAAO,EAAE,EAAE;SACZ,CAAC;QA2FM,uBAAkB,GAAG,CAAC,KAAa,EAAE,EAAE;YAC7C,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,cAAgC,CAAC;YAEnE,uBAAuB;YACvB,IAAI,IAAI,CAAC,KA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E,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CACrJ,CAAC,CAAC;IACZ,CAAC;CACF;AA/JD,sDA+JC;AAED;;;GAGG;AACH,MAAa,6BAA8B,SAAQ,0CAAkB;IACnE,IAAW,SAAS;QAClB,OAAO,oBAAC,qBAAqB,OAAG,CAAC;IACnC,CAAC;CACF;AAJD,sEAIC;AAED,6CAAqB,CAAC,cAAc,CAAC,kCAAiB,CAAC,IAAI,EAAE,6BAA6B,EAAE,oCAAmB,CAAC,eAAe,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module PropertyEditors\n */\n\nimport \"./EnumButtonGroupEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport {\n ButtonGroupEditorParams, EnumerationChoice, IconDefinition, PropertyEditorParams, PropertyEditorParamTypes, PropertyRecord,\n PropertyValue, PropertyValueFormat, StandardEditorNames, StandardTypeNames,\n} from \"@itwin/appui-abstract\";\nimport { Icon } from \"@itwin/core-react\";\nimport { PropertyEditorProps, TypeEditor } from \"./EditorContainer\";\nimport { PropertyEditorBase, PropertyEditorManager } from \"./PropertyEditorManager\";\n\n// cspell:ignore buttongroup enumbuttongroup\n\n/** @internal */\ninterface EnumButtonGroupEditorState {\n selectValue: string | number;\n enumIcons: IconDefinition[];\n choices: EnumerationChoice[];\n}\n\n/** EnumButtonGroupEditor React component that is a property editor with select input\n * @public\n */\nexport class EnumButtonGroupEditor extends React.Component<PropertyEditorProps, EnumButtonGroupEditorState> implements TypeEditor {\n private _btnRefs = new Map<string | number, HTMLButtonElement>();\n private _divElement = React.createRef<HTMLDivElement>();\n\n /** @internal */\n public override readonly state: Readonly<EnumButtonGroupEditorState> = {\n selectValue: \"\",\n enumIcons: [],\n choices: [],\n };\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n // istanbul ignore else\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n propertyValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: this.state.selectValue,\n displayValue: \"\",\n };\n }\n\n return propertyValue;\n }\n\n public get htmlElement(): HTMLElement | null {\n return this._divElement.current;\n }\n\n public get hasFocus(): boolean {\n let containsFocus = false;\n // istanbul ignore else\n if (this._divElement.current)\n containsFocus = this._divElement.current.contains(document.activeElement);\n return containsFocus;\n }\n\n /** @internal */\n public override componentDidMount() {\n this.setStateFromProps(); // eslint-disable-line @typescript-eslint/no-floating-promises\n }\n\n /** @internal */\n public override componentDidUpdate(prevProps: PropertyEditorProps) {\n if (this.props.propertyRecord !== prevProps.propertyRecord) {\n this.setStateFromProps(); // eslint-disable-line @typescript-eslint/no-floating-promises\n }\n }\n\n private async setStateFromProps() {\n const { propertyRecord } = this.props;\n\n // istanbul ignore else\n if (propertyRecord && propertyRecord.property.enum && propertyRecord.value.valueFormat === PropertyValueFormat.Primitive) {\n const primitiveValue = propertyRecord.value.value;\n let selectValue: string | number;\n\n if (typeof primitiveValue === \"string\") {\n selectValue = primitiveValue;\n } else {\n selectValue = primitiveValue as number;\n }\n\n let choices: EnumerationChoice[] = [];\n // istanbul ignore else\n if (propertyRecord && propertyRecord.property.enum) {\n if (propertyRecord.property.enum.choices instanceof Promise) {\n choices = await propertyRecord.property.enum.choices;\n } else {\n choices = propertyRecord.property.enum.choices;\n }\n }\n\n const numChoices = choices.length;\n const enumIcons = new Array<IconDefinition>(numChoices);\n enumIcons.fill({ iconSpec: \"icon icon-placeholder\" });\n\n // istanbul ignore else\n if (propertyRecord.property.editor && propertyRecord.property.editor.params) {\n // istanbul ignore else\n if (propertyRecord.property.editor && propertyRecord.property.editor.params) {\n const bgParams = propertyRecord.property.editor.params.find((param: PropertyEditorParams) => param.type === PropertyEditorParamTypes.ButtonGroupData) as ButtonGroupEditorParams;\n // istanbul ignore else\n if (bgParams) {\n bgParams.buttons.forEach((iconDef: IconDefinition, index: number) => {\n // istanbul ignore else\n if (index < numChoices) {\n enumIcons[index] = iconDef;\n }\n });\n }\n }\n }\n\n this.setState({ selectValue, enumIcons, choices });\n }\n }\n\n private _handleButtonClick = (index: number) => {\n const propertyRecord = this.props.propertyRecord as PropertyRecord;\n\n // istanbul ignore else\n if (this.state.choices && this.state.choices.length > index) {\n const selectValue = this.state.choices[index].value;\n\n this.setState({\n selectValue,\n }, async () => {\n // istanbul ignore else\n if (propertyRecord && this.props.onCommit) {\n const propertyValue = await this.getPropertyValue();\n // istanbul ignore else\n if (propertyValue !== undefined) {\n this.props.onCommit({ propertyRecord, newValue: propertyValue });\n }\n }\n });\n }\n };\n\n private getButton(choice: EnumerationChoice, index: number) {\n const choiceValue = this.state.choices ? this.state.choices[index].value : /* istanbul ignore next */ 0;\n const isActive = (choiceValue === this.state.selectValue) ? true : false;\n let isDisabled = false;\n const isEnabledFunction = this.state.enumIcons[index].isEnabledFunction;\n // istanbul ignore else\n if (isEnabledFunction) {\n isDisabled = !isEnabledFunction();\n }\n\n const className = classnames(\n \"components-enumbuttongroup-button\",\n isDisabled && \"nz-is-disabled\",\n isActive && \"nz-is-active\",\n );\n\n return (\n <button\n ref={(ref: HTMLButtonElement) => this._btnRefs.set(choiceValue, ref)}\n data-testid={choice.label}\n className={className}\n title={choice.label}\n key={choice.label}\n onClick={() => this._handleButtonClick(index)}\n >\n <Icon iconSpec={this.state.enumIcons[index].iconSpec} />\n </button >\n );\n }\n\n /** @internal */\n public override render() {\n return (\n <div className={classnames(\"components-enumbuttongroup-editor\", this.props.className)} style={this.props.style} ref={this._divElement}>\n {this.state.choices && this.state.enumIcons.length && this.state.choices.map((choice: EnumerationChoice, index: number) => this.getButton(choice, index))}\n </div>);\n }\n}\n\n/** Enum Property Button Group Editor registered for the \"enum\" type name and the \"enum-buttongroup\" editor name.\n * It uses the [[EnumButtonGroupEditor]] React component.\n * @public\n */\nexport class EnumPropertyButtonGroupEditor extends PropertyEditorBase { // istanbul ignore next\n public get reactNode(): React.ReactNode {\n return <EnumButtonGroupEditor />;\n }\n}\n\nPropertyEditorManager.registerEditor(StandardTypeNames.Enum, EnumPropertyButtonGroupEditor, StandardEditorNames.EnumButtonGroup);\n"]}
|
|
@@ -15,7 +15,7 @@ interface EnumEditorState {
|
|
|
15
15
|
parentDiv: HTMLDivElement | null;
|
|
16
16
|
}
|
|
17
17
|
/** EnumEditor React component that is a property editor with select input
|
|
18
|
-
* @
|
|
18
|
+
* @public
|
|
19
19
|
*/
|
|
20
20
|
export declare class EnumEditor extends React.PureComponent<PropertyEditorProps, EnumEditorState> implements TypeEditor {
|
|
21
21
|
private _isMounted;
|
|
@@ -39,7 +39,7 @@ export declare class EnumEditor extends React.PureComponent<PropertyEditorProps,
|
|
|
39
39
|
}
|
|
40
40
|
/** Enum Property Button Group Editor registered for the "enum" type name.
|
|
41
41
|
* It uses the [[EnumEditor]] React component.
|
|
42
|
-
* @
|
|
42
|
+
* @public
|
|
43
43
|
*/
|
|
44
44
|
export declare class EnumPropertyEditor extends PropertyEditorBase {
|
|
45
45
|
get containerHandlesEnter(): boolean;
|
|
@@ -38,7 +38,7 @@ const itwinui_react_1 = require("@itwin/itwinui-react");
|
|
|
38
38
|
const PropertyEditorManager_1 = require("./PropertyEditorManager");
|
|
39
39
|
const UiComponents_1 = require("../UiComponents");
|
|
40
40
|
/** EnumEditor React component that is a property editor with select input
|
|
41
|
-
* @
|
|
41
|
+
* @public
|
|
42
42
|
*/
|
|
43
43
|
class EnumEditor extends React.PureComponent {
|
|
44
44
|
constructor() {
|
|
@@ -171,7 +171,7 @@ class EnumEditor extends React.PureComponent {
|
|
|
171
171
|
exports.EnumEditor = EnumEditor;
|
|
172
172
|
/** Enum Property Button Group Editor registered for the "enum" type name.
|
|
173
173
|
* It uses the [[EnumEditor]] React component.
|
|
174
|
-
* @
|
|
174
|
+
* @public
|
|
175
175
|
*/
|
|
176
176
|
class EnumPropertyEditor extends PropertyEditorManager_1.PropertyEditorBase {
|
|
177
177
|
// istanbul ignore next
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnumEditor.js","sourceRoot":"","sources":["../../../src/components-react/editors/EnumEditor.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6BAA2B;AAC3B,4DAAoC;AACpC,6CAA+B;AAC/B,0DAAiH;AACjH,wDAA4D;AAE5D,mEAAoF;AACpF,kDAA+C;AAU/C;;IAEI;AACJ,MAAa,UAAW,SAAQ,KAAK,CAAC,aAAmD;IAAzF;;QACU,eAAU,GAAG,KAAK,CAAC;QACnB,eAAU,GAAG,2BAAY,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;QACnD,gBAAW,GAAG,KAAK,CAAC,SAAS,EAAkB,CAAC;QAExD,gBAAgB;QACS,UAAK,GAA8B;YAC1D,WAAW,EAAE,EAAE;YACf,aAAa,EAAE,KAAK;YACpB,OAAO,EAAE,EAAE;YACX,SAAS,EAAE,IAAI;SAChB,CAAC;QAgCM,uBAAkB,GAAG,CAAC,QAAgB,EAAE,EAAE;YAChD,uBAAuB;YACvB,IAAI,IAAI,CAAC,UAAU,EAAE;gBACnB,IAAI,WAA4B,CAAC;gBAEjC,qBAAqB;gBACrB,IAAI,IAAI,CAAC,KAAK,CAAC,aAAa;oBAC1B,WAAW,GAAG,QAAQ,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;;oBAErC,WAAW,GAAG,QAAQ,CAAC;gBAEzB,IAAI,CAAC,QAAQ,CAAC;oBACZ,WAAW;iBACZ,EAAE,KAAK,IAAI,EAAE;oBACZ,uBAAuB;oBACvB,IAAI,IAAI,CAAC,KAAK,CAAC,cAAc,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;wBACpD,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,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,EAAE,IAAI,CAAC,kBAAkB,iBACrB,0BAA0B,EACtC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,EAC3B,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,gBACjB,IAAI,CAAC,UAAU,GAAI,CAC7B,CACP,CAAC;IACJ,CAAC;CACF;AA5JD,gCA4JC;AAED;;;IAGI;AACJ,MAAa,kBAAmB,SAAQ,0CAAkB;IACxD,uBAAuB;IACvB,IAAoB,qBAAqB;QACvC,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAoB,gCAAgC;QAClD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAW,SAAS;QAClB,OAAO,oBAAC,UAAU,OAAG,CAAC;IACxB,CAAC;CACF;AAZD,gDAYC;AAED,6CAAqB,CAAC,cAAc,CAAC,kCAAiB,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module PropertyEditors\n */\n\nimport \"./EnumEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { EnumerationChoice, PropertyValue, PropertyValueFormat, StandardTypeNames } from \"@itwin/appui-abstract\";\nimport { Select, SelectOption } from \"@itwin/itwinui-react\";\nimport { PropertyEditorProps, TypeEditor } from \"./EditorContainer\";\nimport { PropertyEditorBase, PropertyEditorManager } from \"./PropertyEditorManager\";\nimport { UiComponents } from \"../UiComponents\";\n\n/** @internal */\ninterface EnumEditorState {\n selectValue: string | number;\n valueIsNumber: boolean;\n options: SelectOption<string>[];\n parentDiv: HTMLDivElement | null;\n}\n\n/** EnumEditor React component that is a property editor with select input\n * @beta\n */\nexport class EnumEditor extends React.PureComponent<PropertyEditorProps, EnumEditorState> implements TypeEditor {\n private _isMounted = false;\n private _ariaLabel = UiComponents.translate(\"editor.enum\");\n private _divElement = React.createRef<HTMLDivElement>();\n\n /** @internal */\n public override readonly state: Readonly<EnumEditorState> = {\n selectValue: \"\",\n valueIsNumber: false,\n options: [],\n parentDiv: null,\n };\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n // istanbul ignore else\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n propertyValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: this.state.selectValue,\n displayValue: \"\",\n };\n }\n\n return propertyValue;\n }\n\n // istanbul ignore next\n public get htmlElement(): HTMLElement | null {\n return this._divElement.current;\n }\n\n // istanbul ignore next\n public get hasFocus(): boolean {\n let containsFocus = false;\n // istanbul ignore else\n if (this._divElement.current)\n containsFocus = this._divElement.current.contains(document.activeElement);\n return containsFocus;\n }\n\n private _updateSelectValue = (newValue: string) => {\n // istanbul ignore else\n if (this._isMounted) {\n let selectValue: string | number;\n\n // istanbul ignore if\n if (this.state.valueIsNumber)\n selectValue = parseInt(newValue, 10);\n else\n selectValue = newValue;\n\n this.setState({\n selectValue,\n }, async () => {\n // istanbul ignore else\n if (this.props.propertyRecord && this.props.onCommit) {\n const propertyValue = await this.getPropertyValue();\n // istanbul ignore else\n if (propertyValue) {\n this.props.onCommit({ propertyRecord: this.props.propertyRecord, newValue: propertyValue });\n }\n }\n });\n }\n };\n\n /** @internal */\n public override componentDidMount() {\n this._isMounted = true;\n this.setStateFromProps(); // eslint-disable-line @typescript-eslint/no-floating-promises\n }\n\n /** @internal */\n public override componentWillUnmount() {\n this._isMounted = false;\n }\n\n /** @internal */\n public override componentDidUpdate(prevProps: PropertyEditorProps) {\n if (this.props.propertyRecord !== prevProps.propertyRecord) {\n this.setStateFromProps(); // eslint-disable-line @typescript-eslint/no-floating-promises\n }\n }\n\n private async setStateFromProps() {\n const { propertyRecord } = this.props;\n let initialValue: string | number = \"\";\n let valueIsNumber: boolean = false;\n\n // istanbul ignore else\n if (propertyRecord && propertyRecord.value.valueFormat === PropertyValueFormat.Primitive) {\n const primitiveValue = propertyRecord.value.value;\n if (typeof primitiveValue === \"string\") {\n initialValue = primitiveValue;\n valueIsNumber = false;\n } else {\n initialValue = primitiveValue as number;\n valueIsNumber = true;\n }\n }\n\n let choices: EnumerationChoice[] | undefined;\n\n if (propertyRecord && propertyRecord.property.enum) {\n // istanbul ignore else\n if (propertyRecord.property.enum.choices instanceof Promise) {\n choices = await propertyRecord.property.enum.choices;\n } else {\n choices = propertyRecord.property.enum.choices;\n }\n }\n\n const options: SelectOption<string>[] = [];\n if (choices) {\n choices.forEach((choice: EnumerationChoice) => {\n options.push({ value: choice.value.toString(), label: choice.label });\n });\n }\n\n // istanbul ignore else\n if (this._isMounted)\n this.setState({ selectValue: initialValue, valueIsNumber, options, parentDiv: this._divElement.current });\n }\n\n /** @internal */\n public override render() {\n const className = classnames(\"components-cell-editor\", \"components-enum-editor\", this.props.className);\n const selectValue = this.state.selectValue !== undefined ? this.state.selectValue.toString() : /* istanbul ignore next */ undefined;\n\n // set min-width to show about 4 characters + down arrow\n const minWidthStyle: React.CSSProperties = {\n minWidth: `6em`,\n };\n\n // The iTwinUI-react Select onBlur still does not work properly, so it cannot be used yet. NEEDSWORK\n // onBlur={this.props.onBlur}\n\n /* The following popoverProps are required for the popup to properly show in floating widgets because this makes it work similar to a portal */\n return (\n <div ref={this._divElement}>\n <Select\n className={className}\n style={this.props.style ? this.props.style : minWidthStyle}\n value={selectValue}\n popoverProps={{ appendTo: () => this.state.parentDiv ? this.state.parentDiv.ownerDocument.body : /* istanbul ignore next */ document.body }}\n onChange={this._updateSelectValue}\n data-testid=\"components-select-editor\"\n options={this.state.options}\n setFocus={this.props.setFocus}\n aria-label={this._ariaLabel} />\n </div>\n );\n }\n}\n\n/** Enum Property Button Group Editor registered for the \"enum\" type name.\n * It uses the [[EnumEditor]] React component.\n * @beta\n */\nexport class EnumPropertyEditor extends PropertyEditorBase {\n // istanbul ignore next\n public override get containerHandlesEnter(): boolean {\n return false;\n }\n public override get containerStopsKeydownPropagation(): boolean {\n return false;\n }\n\n public get reactNode(): React.ReactNode {\n return <EnumEditor />;\n }\n}\n\nPropertyEditorManager.registerEditor(StandardTypeNames.Enum, EnumPropertyEditor);\n"]}
|
|
1
|
+
{"version":3,"file":"EnumEditor.js","sourceRoot":"","sources":["../../../src/components-react/editors/EnumEditor.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6BAA2B;AAC3B,4DAAoC;AACpC,6CAA+B;AAC/B,0DAAiH;AACjH,wDAA4D;AAE5D,mEAAoF;AACpF,kDAA+C;AAU/C;;IAEI;AACJ,MAAa,UAAW,SAAQ,KAAK,CAAC,aAAmD;IAAzF;;QACU,eAAU,GAAG,KAAK,CAAC;QACnB,eAAU,GAAG,2BAAY,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;QACnD,gBAAW,GAAG,KAAK,CAAC,SAAS,EAAkB,CAAC;QAExD,gBAAgB;QACS,UAAK,GAA8B;YAC1D,WAAW,EAAE,EAAE;YACf,aAAa,EAAE,KAAK;YACpB,OAAO,EAAE,EAAE;YACX,SAAS,EAAE,IAAI;SAChB,CAAC;QAgCM,uBAAkB,GAAG,CAAC,QAAgB,EAAE,EAAE;YAChD,uBAAuB;YACvB,IAAI,IAAI,CAAC,UAAU,EAAE;gBACnB,IAAI,WAA4B,CAAC;gBAEjC,qBAAqB;gBACrB,IAAI,IAAI,CAAC,KAAK,CAAC,aAAa;oBAC1B,WAAW,GAAG,QAAQ,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;;oBAErC,WAAW,GAAG,QAAQ,CAAC;gBAEzB,IAAI,CAAC,QAAQ,CAAC;oBACZ,WAAW;iBACZ,EAAE,KAAK,IAAI,EAAE;oBACZ,uBAAuB;oBACvB,IAAI,IAAI,CAAC,KAAK,CAAC,cAAc,IAAI,IAAI,CAAC,KAAK,CAAC,QAA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0BAA0B,CAAC,QAAQ,CAAC,IAAI,EAAE,EAC3I,QAAQ,EAAE,IAAI,CAAC,kBAAkB,iBACrB,0BAA0B,EACtC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,EAC3B,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,gBACjB,IAAI,CAAC,UAAU,GAAI,CAC7B,CACP,CAAC;IACJ,CAAC;CACF;AA5JD,gCA4JC;AAED;;;IAGI;AACJ,MAAa,kBAAmB,SAAQ,0CAAkB;IACxD,uBAAuB;IACvB,IAAoB,qBAAqB;QACvC,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAoB,gCAAgC;QAClD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAW,SAAS;QAClB,OAAO,oBAAC,UAAU,OAAG,CAAC;IACxB,CAAC;CACF;AAZD,gDAYC;AAED,6CAAqB,CAAC,cAAc,CAAC,kCAAiB,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module PropertyEditors\n */\n\nimport \"./EnumEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { EnumerationChoice, PropertyValue, PropertyValueFormat, StandardTypeNames } from \"@itwin/appui-abstract\";\nimport { Select, SelectOption } from \"@itwin/itwinui-react\";\nimport { PropertyEditorProps, TypeEditor } from \"./EditorContainer\";\nimport { PropertyEditorBase, PropertyEditorManager } from \"./PropertyEditorManager\";\nimport { UiComponents } from \"../UiComponents\";\n\n/** @internal */\ninterface EnumEditorState {\n selectValue: string | number;\n valueIsNumber: boolean;\n options: SelectOption<string>[];\n parentDiv: HTMLDivElement | null;\n}\n\n/** EnumEditor React component that is a property editor with select input\n * @public\n */\nexport class EnumEditor extends React.PureComponent<PropertyEditorProps, EnumEditorState> implements TypeEditor {\n private _isMounted = false;\n private _ariaLabel = UiComponents.translate(\"editor.enum\");\n private _divElement = React.createRef<HTMLDivElement>();\n\n /** @internal */\n public override readonly state: Readonly<EnumEditorState> = {\n selectValue: \"\",\n valueIsNumber: false,\n options: [],\n parentDiv: null,\n };\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n // istanbul ignore else\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n propertyValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: this.state.selectValue,\n displayValue: \"\",\n };\n }\n\n return propertyValue;\n }\n\n // istanbul ignore next\n public get htmlElement(): HTMLElement | null {\n return this._divElement.current;\n }\n\n // istanbul ignore next\n public get hasFocus(): boolean {\n let containsFocus = false;\n // istanbul ignore else\n if (this._divElement.current)\n containsFocus = this._divElement.current.contains(document.activeElement);\n return containsFocus;\n }\n\n private _updateSelectValue = (newValue: string) => {\n // istanbul ignore else\n if (this._isMounted) {\n let selectValue: string | number;\n\n // istanbul ignore if\n if (this.state.valueIsNumber)\n selectValue = parseInt(newValue, 10);\n else\n selectValue = newValue;\n\n this.setState({\n selectValue,\n }, async () => {\n // istanbul ignore else\n if (this.props.propertyRecord && this.props.onCommit) {\n const propertyValue = await this.getPropertyValue();\n // istanbul ignore else\n if (propertyValue) {\n this.props.onCommit({ propertyRecord: this.props.propertyRecord, newValue: propertyValue });\n }\n }\n });\n }\n };\n\n /** @internal */\n public override componentDidMount() {\n this._isMounted = true;\n this.setStateFromProps(); // eslint-disable-line @typescript-eslint/no-floating-promises\n }\n\n /** @internal */\n public override componentWillUnmount() {\n this._isMounted = false;\n }\n\n /** @internal */\n public override componentDidUpdate(prevProps: PropertyEditorProps) {\n if (this.props.propertyRecord !== prevProps.propertyRecord) {\n this.setStateFromProps(); // eslint-disable-line @typescript-eslint/no-floating-promises\n }\n }\n\n private async setStateFromProps() {\n const { propertyRecord } = this.props;\n let initialValue: string | number = \"\";\n let valueIsNumber: boolean = false;\n\n // istanbul ignore else\n if (propertyRecord && propertyRecord.value.valueFormat === PropertyValueFormat.Primitive) {\n const primitiveValue = propertyRecord.value.value;\n if (typeof primitiveValue === \"string\") {\n initialValue = primitiveValue;\n valueIsNumber = false;\n } else {\n initialValue = primitiveValue as number;\n valueIsNumber = true;\n }\n }\n\n let choices: EnumerationChoice[] | undefined;\n\n if (propertyRecord && propertyRecord.property.enum) {\n // istanbul ignore else\n if (propertyRecord.property.enum.choices instanceof Promise) {\n choices = await propertyRecord.property.enum.choices;\n } else {\n choices = propertyRecord.property.enum.choices;\n }\n }\n\n const options: SelectOption<string>[] = [];\n if (choices) {\n choices.forEach((choice: EnumerationChoice) => {\n options.push({ value: choice.value.toString(), label: choice.label });\n });\n }\n\n // istanbul ignore else\n if (this._isMounted)\n this.setState({ selectValue: initialValue, valueIsNumber, options, parentDiv: this._divElement.current });\n }\n\n /** @internal */\n public override render() {\n const className = classnames(\"components-cell-editor\", \"components-enum-editor\", this.props.className);\n const selectValue = this.state.selectValue !== undefined ? this.state.selectValue.toString() : /* istanbul ignore next */ undefined;\n\n // set min-width to show about 4 characters + down arrow\n const minWidthStyle: React.CSSProperties = {\n minWidth: `6em`,\n };\n\n // The iTwinUI-react Select onBlur still does not work properly, so it cannot be used yet. NEEDSWORK\n // onBlur={this.props.onBlur}\n\n /* The following popoverProps are required for the popup to properly show in floating widgets because this makes it work similar to a portal */\n return (\n <div ref={this._divElement}>\n <Select\n className={className}\n style={this.props.style ? this.props.style : minWidthStyle}\n value={selectValue}\n popoverProps={{ appendTo: () => this.state.parentDiv ? this.state.parentDiv.ownerDocument.body : /* istanbul ignore next */ document.body }}\n onChange={this._updateSelectValue}\n data-testid=\"components-select-editor\"\n options={this.state.options}\n setFocus={this.props.setFocus}\n aria-label={this._ariaLabel} />\n </div>\n );\n }\n}\n\n/** Enum Property Button Group Editor registered for the \"enum\" type name.\n * It uses the [[EnumEditor]] React component.\n * @public\n */\nexport class EnumPropertyEditor extends PropertyEditorBase {\n // istanbul ignore next\n public override get containerHandlesEnter(): boolean {\n return false;\n }\n public override get containerStopsKeydownPropagation(): boolean {\n return false;\n }\n\n public get reactNode(): React.ReactNode {\n return <EnumEditor />;\n }\n}\n\nPropertyEditorManager.registerEditor(StandardTypeNames.Enum, EnumPropertyEditor);\n"]}
|
|
@@ -17,7 +17,7 @@ interface ImageCheckBoxEditorState {
|
|
|
17
17
|
}
|
|
18
18
|
/** [[ImageCheckBoxEditor]]
|
|
19
19
|
* Boolean editor that renders with an image instead of checkbox
|
|
20
|
-
* @
|
|
20
|
+
* @public
|
|
21
21
|
*/
|
|
22
22
|
export declare class ImageCheckBoxEditor extends React.PureComponent<PropertyEditorProps, ImageCheckBoxEditorState> implements TypeEditor {
|
|
23
23
|
private _isMounted;
|
|
@@ -39,7 +39,7 @@ export declare class ImageCheckBoxEditor extends React.PureComponent<PropertyEdi
|
|
|
39
39
|
}
|
|
40
40
|
/** ImageCheckBox Property Editor registered for the "bool" and "boolean" type names.
|
|
41
41
|
* It uses the [[ImageCheckBoxEditor]] React component.
|
|
42
|
-
* @
|
|
42
|
+
* @public
|
|
43
43
|
*/
|
|
44
44
|
export declare class ImageCheckBoxPropertyEditor extends PropertyEditorBase {
|
|
45
45
|
get reactNode(): React.ReactNode;
|
|
@@ -38,7 +38,7 @@ const PropertyEditorManager_1 = require("./PropertyEditorManager");
|
|
|
38
38
|
const core_react_1 = require("@itwin/core-react");
|
|
39
39
|
/** [[ImageCheckBoxEditor]]
|
|
40
40
|
* Boolean editor that renders with an image instead of checkbox
|
|
41
|
-
* @
|
|
41
|
+
* @public
|
|
42
42
|
*/
|
|
43
43
|
class ImageCheckBoxEditor extends React.PureComponent {
|
|
44
44
|
constructor() {
|
|
@@ -135,7 +135,7 @@ class ImageCheckBoxEditor extends React.PureComponent {
|
|
|
135
135
|
exports.ImageCheckBoxEditor = ImageCheckBoxEditor;
|
|
136
136
|
/** ImageCheckBox Property Editor registered for the "bool" and "boolean" type names.
|
|
137
137
|
* It uses the [[ImageCheckBoxEditor]] React component.
|
|
138
|
-
* @
|
|
138
|
+
* @public
|
|
139
139
|
*/
|
|
140
140
|
class ImageCheckBoxPropertyEditor extends PropertyEditorManager_1.PropertyEditorBase {
|
|
141
141
|
get reactNode() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageCheckBoxEditor.js","sourceRoot":"","sources":["../../../src/components-react/editors/ImageCheckBoxEditor.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,sCAAoC;AACpC,4DAAoC;AACpC,6CAA+B;AAC/B,0DAE+B;AAE/B,mEAAoF;AACpF,kDAAkD;AAalD;;;GAGG;AACH,MAAa,mBAAoB,SAAQ,KAAK,CAAC,aAA4D;IAA3G;;QACU,eAAU,GAAG,KAAK,CAAC;QACnB,kBAAa,GAAsC,KAAK,CAAC,SAAS,EAAE,CAAC;QAE7E,gBAAgB;QACS,UAAK,GAAuC;YACnE,QAAQ,EAAE,EAAE;YACZ,OAAO,EAAE,EAAE;YACX,aAAa,EAAE,KAAK;YACpB,UAAU,EAAE,KAAK;SAClB,CAAC;QAwEM,iBAAY,GAAG,CAAC,OAAgB,EAAE,EAAE;YAC1C,IAAI,CAAC,QAAQ,CAAC;gBACZ,aAAa,EAAE,OAAO;aACvB,EAAE,KAAK,IAAI,EAAE;gBACZ,uBAAuB;gBACvB,IAAI,IAAI,CAAC,KAAK,CAAC,cAAc,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;oBACpD,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;oBACpD,uBAAuB;oBACvB,IAAI,IAAI,CAAC,UAAU,IAAI,aAAa,KAAK,SAAS,EAAE;wBAClD,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,cAAc,EAAE,IAAI,CAAC,KAAK,CAAC,cAAc,EA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EAAE,IAAI,CAAC,aAAa,EAC5B,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAC7B,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,EAC3B,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,IAAI,EACZ,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,UAAU,EACpB,OAAO,EAAE,IAAI,CAAC,YAAY,iBACd,iCAAiC,GAC/B,CACjB,CAAC;IACJ,CAAC;CACF;AArHD,kDAqHC;AAED;;;GAGG;AACH,MAAa,2BAA4B,SAAQ,0CAAkB;IACjE,IAAW,SAAS;QAClB,OAAO,oBAAC,mBAAmB,OAAG,CAAC;IACjC,CAAC;CACF;AAJD,kEAIC;AAED,6CAAqB,CAAC,cAAc,CAAC,kCAAiB,CAAC,OAAO,EAAE,2BAA2B,EAAE,oCAAmB,CAAC,aAAa,CAAC,CAAC;AAChI,6CAAqB,CAAC,cAAc,CAAC,kCAAiB,CAAC,IAAI,EAAE,2BAA2B,EAAE,oCAAmB,CAAC,aAAa,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module PropertyEditors\n */\n\nimport \"./ImageCheckBoxEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport {\n ImageCheckBoxParams, PropertyEditorParams, PropertyEditorParamTypes, PropertyValue, PropertyValueFormat, StandardEditorNames, StandardTypeNames,\n} from \"@itwin/appui-abstract\";\nimport { PropertyEditorProps, TypeEditor } from \"./EditorContainer\";\nimport { PropertyEditorBase, PropertyEditorManager } from \"./PropertyEditorManager\";\nimport { ImageCheckBox } from \"@itwin/core-react\";\n\n// cSpell:ignore imagecheckbox\n\n/** @internal */\ninterface ImageCheckBoxEditorState {\n /** Image for the \"checked\" state */\n imageOn: string;\n /** Image for the \"unchecked\" (default) state */\n imageOff: string;\n checkboxValue: boolean;\n isDisabled?: boolean;\n}\n/** [[ImageCheckBoxEditor]]\n * Boolean editor that renders with an image instead of checkbox\n * @
|
|
1
|
+
{"version":3,"file":"ImageCheckBoxEditor.js","sourceRoot":"","sources":["../../../src/components-react/editors/ImageCheckBoxEditor.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,sCAAoC;AACpC,4DAAoC;AACpC,6CAA+B;AAC/B,0DAE+B;AAE/B,mEAAoF;AACpF,kDAAkD;AAalD;;;GAGG;AACH,MAAa,mBAAoB,SAAQ,KAAK,CAAC,aAA4D;IAA3G;;QACU,eAAU,GAAG,KAAK,CAAC;QACnB,kBAAa,GAAsC,KAAK,CAAC,SAAS,EAAE,CAAC;QAE7E,gBAAgB;QACS,UAAK,GAAuC;YACnE,QAAQ,EAAE,EAAE;YACZ,OAAO,EAAE,EAAE;YACX,aAAa,EAAE,KAAK;YACpB,UAAU,EAAE,KAAK;SAClB,CAAC;QAwEM,iBAAY,GAAG,CAAC,OAAgB,EAAE,EAAE;YAC1C,IAAI,CAAC,QAAQ,CAAC;gBACZ,aAAa,EAAE,OAAO;aACvB,EAAE,KAAK,IAAI,EAAE;gBACZ,uBAAuB;gBACvB,IAAI,IAAI,CAAC,KAAK,CAAC,cAAc,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;oBACpD,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;oBACpD,uBAAuB;oBACvB,IAAI,IAAI,CAAC,UAAU,IAAI,aAAa,KAAK,SAAS,EAAE;wBAClD,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,cAAc,EAAE,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC,CAAC;qBAC7F;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,CAAC,KAAK,CAAC,QAAQ,EAC7B,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,EAC3B,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,IAAI,EACZ,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,UAAU,EACpB,OAAO,EAAE,IAAI,CAAC,YAAY,iBACd,iCAAiC,GAC/B,CACjB,CAAC;IACJ,CAAC;CACF;AArHD,kDAqHC;AAED;;;GAGG;AACH,MAAa,2BAA4B,SAAQ,0CAAkB;IACjE,IAAW,SAAS;QAClB,OAAO,oBAAC,mBAAmB,OAAG,CAAC;IACjC,CAAC;CACF;AAJD,kEAIC;AAED,6CAAqB,CAAC,cAAc,CAAC,kCAAiB,CAAC,OAAO,EAAE,2BAA2B,EAAE,oCAAmB,CAAC,aAAa,CAAC,CAAC;AAChI,6CAAqB,CAAC,cAAc,CAAC,kCAAiB,CAAC,IAAI,EAAE,2BAA2B,EAAE,oCAAmB,CAAC,aAAa,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module PropertyEditors\n */\n\nimport \"./ImageCheckBoxEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport {\n ImageCheckBoxParams, PropertyEditorParams, PropertyEditorParamTypes, PropertyValue, PropertyValueFormat, StandardEditorNames, StandardTypeNames,\n} from \"@itwin/appui-abstract\";\nimport { PropertyEditorProps, TypeEditor } from \"./EditorContainer\";\nimport { PropertyEditorBase, PropertyEditorManager } from \"./PropertyEditorManager\";\nimport { ImageCheckBox } from \"@itwin/core-react\";\n\n// cSpell:ignore imagecheckbox\n\n/** @internal */\ninterface ImageCheckBoxEditorState {\n /** Image for the \"checked\" state */\n imageOn: string;\n /** Image for the \"unchecked\" (default) state */\n imageOff: string;\n checkboxValue: boolean;\n isDisabled?: boolean;\n}\n/** [[ImageCheckBoxEditor]]\n * Boolean editor that renders with an image instead of checkbox\n * @public\n */\nexport class ImageCheckBoxEditor extends React.PureComponent<PropertyEditorProps, ImageCheckBoxEditorState> implements TypeEditor {\n private _isMounted = false;\n private _inputElement: React.RefObject<HTMLInputElement> = React.createRef();\n\n /** @internal */\n public override readonly state: Readonly<ImageCheckBoxEditorState> = {\n imageOff: \"\",\n imageOn: \"\",\n checkboxValue: false,\n isDisabled: false,\n };\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n // istanbul ignore else\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n propertyValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: this.state.checkboxValue,\n displayValue: \"\",\n };\n }\n\n return propertyValue;\n }\n\n public get htmlElement(): HTMLElement | null {\n return this._inputElement.current;\n }\n\n public get hasFocus(): boolean {\n return document.activeElement === this._inputElement.current;\n }\n\n /** @internal */\n public override componentDidMount() {\n this._isMounted = true;\n this.setStateFromProps();\n }\n\n /** @internal */\n public override componentWillUnmount() {\n this._isMounted = false;\n }\n\n /** @internal */\n public override componentDidUpdate(prevProps: PropertyEditorProps) {\n if (this.props.propertyRecord !== prevProps.propertyRecord) {\n this.setStateFromProps();\n }\n }\n\n private setStateFromProps() {\n const { propertyRecord } = this.props;\n let checkboxValue = false;\n let imageOn = \"\";\n let imageOff = \"\";\n let isDisabled = false;\n\n // istanbul ignore else\n if (propertyRecord && propertyRecord.value.valueFormat === PropertyValueFormat.Primitive) {\n const primitiveValue = propertyRecord.value.value;\n checkboxValue = primitiveValue as boolean;\n }\n\n // istanbul ignore else\n if (propertyRecord && propertyRecord.isDisabled)\n isDisabled = propertyRecord.isDisabled;\n\n if (propertyRecord && propertyRecord.property && propertyRecord.property.editor && propertyRecord.property.editor.params) {\n const imageCheckBoxParams = propertyRecord.property.editor.params.find((param: PropertyEditorParams) => param.type === PropertyEditorParamTypes.CheckBoxImages) as ImageCheckBoxParams;\n // istanbul ignore else\n if (imageCheckBoxParams) {\n imageOn = imageCheckBoxParams.imageOn;\n imageOff = imageCheckBoxParams.imageOff;\n }\n }\n this.setState({ imageOn, imageOff, checkboxValue, isDisabled });\n }\n\n private _handleClick = (checked: boolean) => {\n this.setState({\n checkboxValue: checked,\n }, async () => {\n // istanbul ignore else\n if (this.props.propertyRecord && this.props.onCommit) {\n const propertyValue = await this.getPropertyValue();\n // istanbul ignore else\n if (this._isMounted && propertyValue !== undefined) {\n this.props.onCommit({ propertyRecord: this.props.propertyRecord, newValue: propertyValue });\n }\n }\n });\n };\n\n public override render() {\n const className = classnames(\"components-cell-editor\", \"components-imagecheckbox-editor\", this.props.className);\n const checked = this.state.checkboxValue;\n const isDisabled = !!this.state.isDisabled;\n\n return (\n <ImageCheckBox\n inputRef={this._inputElement}\n imageOff={this.state.imageOff}\n imageOn={this.state.imageOn}\n className={className}\n border={true}\n style={this.props.style}\n checked={checked}\n disabled={isDisabled}\n onClick={this._handleClick}\n data-testid=\"components-imagecheckbox-editor\">\n </ImageCheckBox>\n );\n }\n}\n\n/** ImageCheckBox Property Editor registered for the \"bool\" and \"boolean\" type names.\n * It uses the [[ImageCheckBoxEditor]] React component.\n * @public\n */\nexport class ImageCheckBoxPropertyEditor extends PropertyEditorBase {\n public get reactNode(): React.ReactNode {\n return <ImageCheckBoxEditor />;\n }\n}\n\nPropertyEditorManager.registerEditor(StandardTypeNames.Boolean, ImageCheckBoxPropertyEditor, StandardEditorNames.ImageCheckBox);\nPropertyEditorManager.registerEditor(StandardTypeNames.Bool, ImageCheckBoxPropertyEditor, StandardEditorNames.ImageCheckBox);\n"]}
|
|
@@ -19,7 +19,7 @@ interface NumericInputEditorState {
|
|
|
19
19
|
precision?: number;
|
|
20
20
|
}
|
|
21
21
|
/** NumericInputEditor React component that is a property editor with numeric input & up/down buttons
|
|
22
|
-
* @
|
|
22
|
+
* @public
|
|
23
23
|
*/
|
|
24
24
|
export declare class NumericInputEditor extends React.PureComponent<PropertyEditorProps, NumericInputEditorState> implements TypeEditor {
|
|
25
25
|
private _isMounted;
|
|
@@ -43,7 +43,7 @@ export declare class NumericInputEditor extends React.PureComponent<PropertyEdit
|
|
|
43
43
|
}
|
|
44
44
|
/** Numeric Input Property Editor registered for the "number" type name and "numeric-input" editor name.
|
|
45
45
|
* It uses the [[NumericInputEditor]] React component.
|
|
46
|
-
* @
|
|
46
|
+
* @public
|
|
47
47
|
*/
|
|
48
48
|
export declare class NumericInputPropertyEditor extends PropertyEditorBase {
|
|
49
49
|
get reactNode(): React.ReactNode;
|
|
@@ -37,7 +37,7 @@ const appui_abstract_1 = require("@itwin/appui-abstract");
|
|
|
37
37
|
const core_react_1 = require("@itwin/core-react");
|
|
38
38
|
const PropertyEditorManager_1 = require("./PropertyEditorManager");
|
|
39
39
|
/** NumericInputEditor React component that is a property editor with numeric input & up/down buttons
|
|
40
|
-
* @
|
|
40
|
+
* @public
|
|
41
41
|
*/
|
|
42
42
|
class NumericInputEditor extends React.PureComponent {
|
|
43
43
|
constructor() {
|
|
@@ -150,7 +150,7 @@ class NumericInputEditor extends React.PureComponent {
|
|
|
150
150
|
exports.NumericInputEditor = NumericInputEditor;
|
|
151
151
|
/** Numeric Input Property Editor registered for the "number" type name and "numeric-input" editor name.
|
|
152
152
|
* It uses the [[NumericInputEditor]] React component.
|
|
153
|
-
* @
|
|
153
|
+
* @public
|
|
154
154
|
*/
|
|
155
155
|
class NumericInputPropertyEditor extends PropertyEditorManager_1.PropertyEditorBase {
|
|
156
156
|
get reactNode() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumericInputEditor.js","sourceRoot":"","sources":["../../../src/components-react/editors/NumericInputEditor.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,qCAAmC;AACnC,4D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CAAC;IACJ,CAAC;CACF;AA/ID,gDA+IC;AAED;;;GAGG;AACH,MAAa,0BAA2B,SAAQ,0CAAkB;IAChE,IAAW,SAAS;QAClB,OAAO,oBAAC,kBAAkB,OAAG,CAAC;IAChC,CAAC;IACD,uBAAuB;IACvB,IAAoB,qBAAqB;QACvC,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AARD,gEAQC;AAED,6CAAqB,CAAC,cAAc,CAAC,kCAAiB,CAAC,MAAM,EAAE,0BAA0B,EAAE,oCAAmB,CAAC,YAAY,CAAC,CAAC;AAC7H,6CAAqB,CAAC,cAAc,CAAC,kCAAiB,CAAC,GAAG,EAAE,0BAA0B,EAAE,oCAAmB,CAAC,YAAY,CAAC,CAAC;AAC1H,6CAAqB,CAAC,cAAc,CAAC,kCAAiB,CAAC,KAAK,EAAE,0BAA0B,EAAE,oCAAmB,CAAC,YAAY,CAAC,CAAC;AAC5H,6CAAqB,CAAC,cAAc,CAAC,kCAAiB,CAAC,MAAM,EAAE,0BAA0B,EAAE,oCAAmB,CAAC,YAAY,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module PropertyEditors\n */\n\nimport \"./NumericInputEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport {\n InputEditorSizeParams, PropertyEditorParams, PropertyEditorParamTypes, PropertyValue, PropertyValueFormat, RangeEditorParams,\n StandardEditorNames, StandardTypeNames,\n} from \"@itwin/appui-abstract\";\nimport { NumberInput } from \"@itwin/core-react\";\nimport { PropertyEditorProps, TypeEditor } from \"./EditorContainer\";\nimport { PropertyEditorBase, PropertyEditorManager } from \"./PropertyEditorManager\";\n\n/** @internal */\ninterface NumericInputEditorState {\n value: number;\n readonly: boolean;\n isDisabled?: boolean;\n size?: number;\n maxLength?: number;\n\n min?: number;\n max?: number;\n step?: number;\n precision?: number;\n}\n\n/** NumericInputEditor React component that is a property editor with numeric input & up/down buttons\n * @beta\n */\nexport class NumericInputEditor extends React.PureComponent<PropertyEditorProps, NumericInputEditorState> implements TypeEditor {\n private _isMounted = false;\n private _inputElement: React.RefObject<HTMLInputElement> = React.createRef();\n public hasFocus = false; // hot used since containerHandlesEnter is false\n\n /** @internal */\n public override readonly state: Readonly<NumericInputEditorState> = {\n value: 0,\n readonly: false,\n };\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n // istanbul ignore else\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n propertyValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: this.state.value,\n displayValue: \"\",\n };\n }\n\n return propertyValue;\n }\n\n public get htmlElement(): HTMLElement | null {\n return this._inputElement.current;\n }\n\n private _handleCommit = async (): Promise<void> => {\n // istanbul ignore else\n if (this.props.propertyRecord && this.props.onCommit) {\n const propertyValue = await this.getPropertyValue();\n // istanbul ignore else\n if (propertyValue !== undefined) {\n this.props.onCommit({ propertyRecord: this.props.propertyRecord, newValue: propertyValue });\n }\n }\n };\n\n private _updateValue = (value: number | undefined, _stringValue: string): void => {\n const newValue = value !== undefined ? value : /* istanbul ignore next */ 0;\n\n // istanbul ignore else\n if (this._isMounted)\n this.setState({\n value: newValue,\n }, async () => {\n await this._handleCommit();\n });\n };\n\n /** @internal */\n public override componentDidMount() {\n this._isMounted = true;\n this.setStateFromProps(); // eslint-disable-line @typescript-eslint/no-floating-promises\n }\n\n /** @internal */\n public override componentWillUnmount() {\n this._isMounted = false;\n }\n\n /** @internal */\n public override componentDidUpdate(prevProps: PropertyEditorProps) {\n if (this.props.propertyRecord !== prevProps.propertyRecord) {\n this.setStateFromProps(); // eslint-disable-line @typescript-eslint/no-floating-promises\n }\n }\n\n private async setStateFromProps() {\n const record = this.props.propertyRecord;\n let initialValue = 0;\n\n // istanbul ignore else\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n initialValue = record.value.value as number;\n }\n\n const readonly = record && undefined !== record.isReadonly ? record.isReadonly : false;\n let size: number | undefined;\n let maxLength: number | undefined;\n let min: number | undefined;\n let max: number | undefined;\n let step: number | undefined;\n let precision: number | undefined;\n\n const isDisabled = record ? record.isDisabled : undefined;\n\n if (record && record.property && record.property.editor && record.property.editor.params) {\n const editorSizeParams = record.property.editor.params.find((param: PropertyEditorParams) => param.type === PropertyEditorParamTypes.InputEditorSize) as InputEditorSizeParams;\n if (editorSizeParams) {\n // istanbul ignore else\n if (editorSizeParams.size)\n size = editorSizeParams.size;\n // istanbul ignore else\n if (editorSizeParams.maxLength)\n maxLength = editorSizeParams.maxLength;\n }\n\n const rangeParams = record.property.editor.params.find((param: PropertyEditorParams) => param.type === PropertyEditorParamTypes.Range) as RangeEditorParams;\n if (rangeParams) {\n min = rangeParams.minimum;\n max = rangeParams.maximum;\n step = rangeParams.step;\n precision = rangeParams.precision;\n }\n }\n\n // istanbul ignore else\n if (this._isMounted)\n this.setState({ value: initialValue, readonly, size, maxLength, isDisabled, min, max, step, precision });\n }\n\n /** @internal */\n public override render(): React.ReactNode {\n const className = classnames(\"components-cell-editor\", \"components-numeric-input-editor\", this.props.className);\n const minSize = this.state.size ? this.state.size : 8;\n const style: React.CSSProperties = {\n ...this.props.style,\n minWidth: `${minSize * 0.75}em`,\n };\n\n return (\n <NumberInput\n ref={this._inputElement}\n className={className}\n style={style}\n value={this.state.value}\n min={this.state.min}\n max={this.state.max}\n step={this.state.step}\n precision={this.state.precision}\n readOnly={this.state.readonly}\n maxLength={this.state.maxLength}\n onBlur={this.props.onBlur}\n onChange={this._updateValue}\n setFocus={this.props.setFocus && !this.state.isDisabled}\n />\n );\n }\n}\n\n/** Numeric Input Property Editor registered for the \"number\" type name and \"numeric-input\" editor name.\n * It uses the [[NumericInputEditor]] React component.\n * @beta\n */\nexport class NumericInputPropertyEditor extends PropertyEditorBase {\n public get reactNode(): React.ReactNode {\n return <NumericInputEditor />;\n }\n // istanbul ignore next\n public override get containerHandlesEnter(): boolean { // let input editor process enter key\n return false;\n }\n}\n\nPropertyEditorManager.registerEditor(StandardTypeNames.Number, NumericInputPropertyEditor, StandardEditorNames.NumericInput);\nPropertyEditorManager.registerEditor(StandardTypeNames.Int, NumericInputPropertyEditor, StandardEditorNames.NumericInput);\nPropertyEditorManager.registerEditor(StandardTypeNames.Float, NumericInputPropertyEditor, StandardEditorNames.NumericInput);\nPropertyEditorManager.registerEditor(StandardTypeNames.Double, NumericInputPropertyEditor, StandardEditorNames.NumericInput);\n"]}
|
|
1
|
+
{"version":3,"file":"NumericInputEditor.js","sourceRoot":"","sources":["../../../src/components-react/editors/NumericInputEditor.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,qCAAmC;AACnC,4DAAoC;AACpC,6CAA+B;AAC/B,0DAG+B;AAC/B,kDAAgD;AAEhD,mEAAoF;AAgBpF;;GAEG;AACH,MAAa,kBAAmB,SAAQ,KAAK,CAAC,aAA2D;IAAzG;;QACU,eAAU,GAAG,KAAK,CAAC;QACnB,kBAAa,GAAsC,KAAK,CAAC,SAAS,EAAE,CAAC;QACtE,aAAQ,GAAG,KAAK,CAAC,CAAC,gDAAgD;QAEzE,gBAAgB;QACS,UAAK,GAAsC;YAClE,KAAK,EAAE,CAAC;YACR,QAAQ,EAAE,KAAK;SAChB,CAAC;QAsBM,kBAAa,GAAG,KAAK,IAAmB,EAAE;YAChD,uBAAuB;YACvB,IAAI,IAAI,CAAC,KAAK,CAAC,cAAc,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;gBACpD,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;gBACpD,uBAAuB;gBACvB,IAAI,aAAa,KAAK,SAAS,EAAE;oBAC/B,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,cA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C","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module PropertyEditors\n */\n\nimport \"./NumericInputEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport {\n InputEditorSizeParams, PropertyEditorParams, PropertyEditorParamTypes, PropertyValue, PropertyValueFormat, RangeEditorParams,\n StandardEditorNames, StandardTypeNames,\n} from \"@itwin/appui-abstract\";\nimport { NumberInput } from \"@itwin/core-react\";\nimport { PropertyEditorProps, TypeEditor } from \"./EditorContainer\";\nimport { PropertyEditorBase, PropertyEditorManager } from \"./PropertyEditorManager\";\n\n/** @internal */\ninterface NumericInputEditorState {\n value: number;\n readonly: boolean;\n isDisabled?: boolean;\n size?: number;\n maxLength?: number;\n\n min?: number;\n max?: number;\n step?: number;\n precision?: number;\n}\n\n/** NumericInputEditor React component that is a property editor with numeric input & up/down buttons\n * @public\n */\nexport class NumericInputEditor extends React.PureComponent<PropertyEditorProps, NumericInputEditorState> implements TypeEditor {\n private _isMounted = false;\n private _inputElement: React.RefObject<HTMLInputElement> = React.createRef();\n public hasFocus = false; // hot used since containerHandlesEnter is false\n\n /** @internal */\n public override readonly state: Readonly<NumericInputEditorState> = {\n value: 0,\n readonly: false,\n };\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n // istanbul ignore else\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n propertyValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: this.state.value,\n displayValue: \"\",\n };\n }\n\n return propertyValue;\n }\n\n public get htmlElement(): HTMLElement | null {\n return this._inputElement.current;\n }\n\n private _handleCommit = async (): Promise<void> => {\n // istanbul ignore else\n if (this.props.propertyRecord && this.props.onCommit) {\n const propertyValue = await this.getPropertyValue();\n // istanbul ignore else\n if (propertyValue !== undefined) {\n this.props.onCommit({ propertyRecord: this.props.propertyRecord, newValue: propertyValue });\n }\n }\n };\n\n private _updateValue = (value: number | undefined, _stringValue: string): void => {\n const newValue = value !== undefined ? value : /* istanbul ignore next */ 0;\n\n // istanbul ignore else\n if (this._isMounted)\n this.setState({\n value: newValue,\n }, async () => {\n await this._handleCommit();\n });\n };\n\n /** @internal */\n public override componentDidMount() {\n this._isMounted = true;\n this.setStateFromProps(); // eslint-disable-line @typescript-eslint/no-floating-promises\n }\n\n /** @internal */\n public override componentWillUnmount() {\n this._isMounted = false;\n }\n\n /** @internal */\n public override componentDidUpdate(prevProps: PropertyEditorProps) {\n if (this.props.propertyRecord !== prevProps.propertyRecord) {\n this.setStateFromProps(); // eslint-disable-line @typescript-eslint/no-floating-promises\n }\n }\n\n private async setStateFromProps() {\n const record = this.props.propertyRecord;\n let initialValue = 0;\n\n // istanbul ignore else\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n initialValue = record.value.value as number;\n }\n\n const readonly = record && undefined !== record.isReadonly ? record.isReadonly : false;\n let size: number | undefined;\n let maxLength: number | undefined;\n let min: number | undefined;\n let max: number | undefined;\n let step: number | undefined;\n let precision: number | undefined;\n\n const isDisabled = record ? record.isDisabled : undefined;\n\n if (record && record.property && record.property.editor && record.property.editor.params) {\n const editorSizeParams = record.property.editor.params.find((param: PropertyEditorParams) => param.type === PropertyEditorParamTypes.InputEditorSize) as InputEditorSizeParams;\n if (editorSizeParams) {\n // istanbul ignore else\n if (editorSizeParams.size)\n size = editorSizeParams.size;\n // istanbul ignore else\n if (editorSizeParams.maxLength)\n maxLength = editorSizeParams.maxLength;\n }\n\n const rangeParams = record.property.editor.params.find((param: PropertyEditorParams) => param.type === PropertyEditorParamTypes.Range) as RangeEditorParams;\n if (rangeParams) {\n min = rangeParams.minimum;\n max = rangeParams.maximum;\n step = rangeParams.step;\n precision = rangeParams.precision;\n }\n }\n\n // istanbul ignore else\n if (this._isMounted)\n this.setState({ value: initialValue, readonly, size, maxLength, isDisabled, min, max, step, precision });\n }\n\n /** @internal */\n public override render(): React.ReactNode {\n const className = classnames(\"components-cell-editor\", \"components-numeric-input-editor\", this.props.className);\n const minSize = this.state.size ? this.state.size : 8;\n const style: React.CSSProperties = {\n ...this.props.style,\n minWidth: `${minSize * 0.75}em`,\n };\n\n return (\n <NumberInput\n ref={this._inputElement}\n className={className}\n style={style}\n value={this.state.value}\n min={this.state.min}\n max={this.state.max}\n step={this.state.step}\n precision={this.state.precision}\n readOnly={this.state.readonly}\n maxLength={this.state.maxLength}\n onBlur={this.props.onBlur}\n onChange={this._updateValue}\n setFocus={this.props.setFocus && !this.state.isDisabled}\n />\n );\n }\n}\n\n/** Numeric Input Property Editor registered for the \"number\" type name and \"numeric-input\" editor name.\n * It uses the [[NumericInputEditor]] React component.\n * @public\n */\nexport class NumericInputPropertyEditor extends PropertyEditorBase {\n public get reactNode(): React.ReactNode {\n return <NumericInputEditor />;\n }\n // istanbul ignore next\n public override get containerHandlesEnter(): boolean { // let input editor process enter key\n return false;\n }\n}\n\nPropertyEditorManager.registerEditor(StandardTypeNames.Number, NumericInputPropertyEditor, StandardEditorNames.NumericInput);\nPropertyEditorManager.registerEditor(StandardTypeNames.Int, NumericInputPropertyEditor, StandardEditorNames.NumericInput);\nPropertyEditorManager.registerEditor(StandardTypeNames.Float, NumericInputPropertyEditor, StandardEditorNames.NumericInput);\nPropertyEditorManager.registerEditor(StandardTypeNames.Double, NumericInputPropertyEditor, StandardEditorNames.NumericInput);\n"]}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import * as React from "react";
|
|
5
5
|
import { DisplayMessageType, MessageSeverity, PropertyDescription, PropertyRecord, PropertyValue } from "@itwin/appui-abstract";
|
|
6
6
|
/** Asynchronous Error Message returned as part of [[AsyncValueProcessingResult]]
|
|
7
|
-
* @
|
|
7
|
+
* @public
|
|
8
8
|
*/
|
|
9
9
|
export interface AsyncErrorMessage {
|
|
10
10
|
severity: MessageSeverity;
|
|
@@ -13,7 +13,7 @@ export interface AsyncErrorMessage {
|
|
|
13
13
|
messageType?: DisplayMessageType;
|
|
14
14
|
}
|
|
15
15
|
/** Asynchronous Value Process Result
|
|
16
|
-
* @
|
|
16
|
+
* @public
|
|
17
17
|
*/
|
|
18
18
|
export interface AsyncValueProcessingResult {
|
|
19
19
|
encounteredError: boolean;
|
|
@@ -21,14 +21,14 @@ export interface AsyncValueProcessingResult {
|
|
|
21
21
|
errorMessage?: AsyncErrorMessage;
|
|
22
22
|
}
|
|
23
23
|
/** DataControllers can be implemented per typename to validate and commit values.
|
|
24
|
-
* @
|
|
24
|
+
* @public
|
|
25
25
|
*/
|
|
26
26
|
export interface DataController {
|
|
27
27
|
validateValue(newValue: PropertyValue, record: PropertyRecord): Promise<AsyncValueProcessingResult>;
|
|
28
28
|
commitValue(newValue: PropertyValue, record: PropertyRecord): Promise<AsyncValueProcessingResult>;
|
|
29
29
|
}
|
|
30
30
|
/** PropertyEditor is the base class for all property editors.
|
|
31
|
-
* @
|
|
31
|
+
* @public
|
|
32
32
|
*/
|
|
33
33
|
export declare abstract class PropertyEditorBase implements DataController {
|
|
34
34
|
get containerHandlesBlur(): boolean;
|
|
@@ -43,14 +43,14 @@ export declare abstract class PropertyEditorBase implements DataController {
|
|
|
43
43
|
validateValue(newValue: PropertyValue, record: PropertyRecord): Promise<AsyncValueProcessingResult>;
|
|
44
44
|
}
|
|
45
45
|
/** DataControllerBase is the base class for all Data Controllers.
|
|
46
|
-
* @
|
|
46
|
+
* @public
|
|
47
47
|
*/
|
|
48
48
|
export declare abstract class DataControllerBase implements DataController {
|
|
49
49
|
commitValue(_newValue: PropertyValue, _record: PropertyRecord): Promise<AsyncValueProcessingResult>;
|
|
50
50
|
validateValue(_newValue: PropertyValue, _record: PropertyRecord): Promise<AsyncValueProcessingResult>;
|
|
51
51
|
}
|
|
52
52
|
/** Manages Property Editors. Property Editors are registered with and created by the manager.
|
|
53
|
-
* @
|
|
53
|
+
* @public
|
|
54
54
|
*/
|
|
55
55
|
export declare class PropertyEditorManager {
|
|
56
56
|
private static _editors;
|
|
@@ -65,7 +65,7 @@ export declare class PropertyEditorManager {
|
|
|
65
65
|
}
|
|
66
66
|
/** Basic Property Editor registered for the "text" and "string" type names.
|
|
67
67
|
* It uses the [[TextEditor]] React component.
|
|
68
|
-
* @
|
|
68
|
+
* @public
|
|
69
69
|
*/
|
|
70
70
|
export declare class BasicPropertyEditor extends PropertyEditorBase {
|
|
71
71
|
get reactNode(): React.ReactNode;
|
|
@@ -31,7 +31,7 @@ const React = __importStar(require("react"));
|
|
|
31
31
|
const TextEditor_1 = require("./TextEditor");
|
|
32
32
|
const appui_abstract_1 = require("@itwin/appui-abstract");
|
|
33
33
|
/** PropertyEditor is the base class for all property editors.
|
|
34
|
-
* @
|
|
34
|
+
* @public
|
|
35
35
|
*/
|
|
36
36
|
class PropertyEditorBase {
|
|
37
37
|
constructor() {
|
|
@@ -66,7 +66,7 @@ class PropertyEditorBase {
|
|
|
66
66
|
}
|
|
67
67
|
exports.PropertyEditorBase = PropertyEditorBase;
|
|
68
68
|
/** DataControllerBase is the base class for all Data Controllers.
|
|
69
|
-
* @
|
|
69
|
+
* @public
|
|
70
70
|
*/
|
|
71
71
|
class DataControllerBase {
|
|
72
72
|
async commitValue(_newValue, _record) {
|
|
@@ -78,7 +78,7 @@ class DataControllerBase {
|
|
|
78
78
|
}
|
|
79
79
|
exports.DataControllerBase = DataControllerBase;
|
|
80
80
|
/** Manages Property Editors. Property Editors are registered with and created by the manager.
|
|
81
|
-
* @
|
|
81
|
+
* @public
|
|
82
82
|
*/
|
|
83
83
|
class PropertyEditorManager {
|
|
84
84
|
static registerEditor(editType, editor, editorName) {
|
|
@@ -135,7 +135,7 @@ PropertyEditorManager._editors = {};
|
|
|
135
135
|
PropertyEditorManager._dataControllers = {};
|
|
136
136
|
/** Basic Property Editor registered for the "text" and "string" type names.
|
|
137
137
|
* It uses the [[TextEditor]] React component.
|
|
138
|
-
* @
|
|
138
|
+
* @public
|
|
139
139
|
*/
|
|
140
140
|
class BasicPropertyEditor extends PropertyEditorBase {
|
|
141
141
|
get reactNode() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyEditorManager.js","sourceRoot":"","sources":["../../../src/components-react/editors/PropertyEditorManager.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAC/B,6CAA0C;AAC1C,0DAAmJ;AA6BnJ;;GAEG;AACH,MAAsB,kBAAkB;IAAxC;QAkBS,yBAAoB,GAA+B,SAAS,CAAC;IAoBtE,CAAC;IApCC,IAAW,oBAAoB;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAW,sBAAsB;QAC/B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAW,qBAAqB;QAC9B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAW,mBAAmB;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAW,gCAAgC;QACzC,OAAO,IAAI,CAAC;IACd,CAAC;IAMM,iBAAiB,CAAC,SAA8B,EAAE,OAAuB,IAAU,CAAC;IAEpF,KAAK,CAAC,WAAW,CAAC,QAAuB,EAAE,MAAsB;QACtE,IAAI,IAAI,CAAC,oBAAoB;YAC3B,OAAO,IAAI,CAAC,oBAAoB,CAAC,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAEjE,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,CAAC;IACrC,CAAC;IAEM,KAAK,CAAC,aAAa,CAAC,QAAuB,EAAE,MAAsB;QACxE,IAAI,IAAI,CAAC,oBAAoB;YAC3B,OAAO,IAAI,CAAC,oBAAoB,CAAC,aAAa,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAEnE,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,CAAC;IACrC,CAAC;CAEF;AAtCD,gDAsCC;AAED;;GA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B,CAAC,QAAQ,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC;IACvE,CAAC;;AA5DH,sDA6DC;AA5DgB,8BAAQ,GAAwD,EAAE,CAAC;AACnE,sCAAgB,GAAwD,EAAE,CAAC;AA6D5F;;;GAGG;AACH,MAAa,mBAAoB,SAAQ,kBAAkB;IACzD,IAAW,SAAS;QAClB,OAAO,oBAAC,uBAAU,OAAG,CAAC;IACxB,CAAC;CACF;AAJD,kDAIC;AAED,qBAAqB,CAAC,cAAc,CAAC,kCAAiB,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC;AAClF,qBAAqB,CAAC,cAAc,CAAC,kCAAiB,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module PropertyEditors\n */\n\nimport * as React from \"react\";\nimport { TextEditor } from \"./TextEditor\";\nimport { DisplayMessageType, MessageSeverity, PropertyDescription, PropertyRecord, PropertyValue, StandardTypeNames } from \"@itwin/appui-abstract\";\n\n/** Asynchronous Error Message returned as part of [[AsyncValueProcessingResult]]\n * @beta\n */\nexport interface AsyncErrorMessage {\n severity: MessageSeverity;\n briefMessage: string;\n detailedMessage?: string;\n messageType?: DisplayMessageType;\n}\n\n/** Asynchronous Value Process Result\n * @beta\n */\nexport interface AsyncValueProcessingResult {\n encounteredError: boolean;\n returnValue?: PropertyValue;\n errorMessage?: AsyncErrorMessage;\n}\n\n/** DataControllers can be implemented per typename to validate and commit values.\n * @beta\n */\nexport interface DataController {\n validateValue(newValue: PropertyValue, record: PropertyRecord): Promise<AsyncValueProcessingResult>;\n commitValue(newValue: PropertyValue, record: PropertyRecord): Promise<AsyncValueProcessingResult>;\n}\n\n/** PropertyEditor is the base class for all property editors.\n * @beta\n */\nexport abstract class PropertyEditorBase implements DataController {\n\n public get containerHandlesBlur(): boolean {\n return true;\n }\n public get containerHandlesEscape(): boolean {\n return true;\n }\n public get containerHandlesEnter(): boolean {\n return true;\n }\n public get containerHandlesTab(): boolean {\n return true;\n }\n public get containerStopsKeydownPropagation(): boolean {\n return true;\n }\n\n public customDataController: DataController | undefined = undefined;\n\n public abstract get reactNode(): React.ReactNode;\n\n public applyEditorParams(_property: PropertyDescription, _record: PropertyRecord): void { }\n\n public async commitValue(newValue: PropertyValue, record: PropertyRecord): Promise<AsyncValueProcessingResult> {\n if (this.customDataController)\n return this.customDataController.commitValue(newValue, record);\n\n return { encounteredError: false };\n }\n\n public async validateValue(newValue: PropertyValue, record: PropertyRecord): Promise<AsyncValueProcessingResult> {\n if (this.customDataController)\n return this.customDataController.validateValue(newValue, record);\n\n return { encounteredError: false };\n }\n\n}\n\n/** DataControllerBase is the base class for all Data Controllers.\n * @beta\n */\nexport abstract class DataControllerBase implements DataController {\n public async commitValue(_newValue: PropertyValue, _record: PropertyRecord): Promise<AsyncValueProcessingResult> {\n return { encounteredError: false };\n }\n\n public async validateValue(_newValue: PropertyValue, _record: PropertyRecord): Promise<AsyncValueProcessingResult> {\n return { encounteredError: false };\n }\n}\n\n/** Manages Property Editors. Property Editors are registered with and created by the manager.\n * @beta\n */\nexport class PropertyEditorManager {\n private static _editors: { [index: string]: (new () => PropertyEditorBase) } = {};\n private static _dataControllers: { [index: string]: (new () => DataControllerBase) } = {};\n\n public static registerEditor(editType: string, editor: new () => PropertyEditorBase, editorName?: string): void {\n const fullEditorName = PropertyEditorManager.getFullEditorName(editType, editorName);\n\n if (PropertyEditorManager._editors.hasOwnProperty(fullEditorName)) {\n const nameOfEditor = PropertyEditorManager._editors[fullEditorName].name;\n throw Error(`PropertyEditorManager.registerEditor error: type '${fullEditorName}' already registered to '${nameOfEditor}'`);\n }\n PropertyEditorManager._editors[fullEditorName] = editor;\n }\n\n private static getFullEditorName(editType: string, editorName?: string): string {\n let fullEditorName = editType;\n if (editorName)\n fullEditorName += `:${editorName}`;\n return fullEditorName;\n }\n\n public static registerDataController(controllerName: string, controller: new () => DataControllerBase): void {\n if (PropertyEditorManager._dataControllers.hasOwnProperty(controllerName)) {\n throw Error(`PropertyEditorManager.registerDataController error: type '${controllerName}' already registered to '${(typeof PropertyEditorManager._dataControllers[controllerName]).toString()}'`);\n }\n PropertyEditorManager._dataControllers[controllerName] = controller;\n }\n\n /** @internal */\n public static deregisterDataController(controllerName: string): void {\n // istanbul ignore else\n if (PropertyEditorManager._dataControllers.hasOwnProperty(controllerName)) {\n delete PropertyEditorManager._dataControllers[controllerName];\n }\n }\n\n public static createEditor(editType: string, editorName?: string, dataControllerName?: string): PropertyEditorBase {\n const fullEditorName = PropertyEditorManager.getFullEditorName(editType, editorName);\n\n let editor: PropertyEditorBase;\n if (PropertyEditorManager._editors.hasOwnProperty(fullEditorName))\n editor = new PropertyEditorManager._editors[fullEditorName]();\n else if (PropertyEditorManager._editors.hasOwnProperty(editType))\n editor = new PropertyEditorManager._editors[editType]();\n else\n editor = new BasicPropertyEditor();\n\n if (dataControllerName) {\n if (PropertyEditorManager._dataControllers.hasOwnProperty(dataControllerName))\n editor.customDataController = new PropertyEditorManager._dataControllers[dataControllerName]();\n else\n throw Error(`PropertyEditorManager.createEditor error: data controller '${dataControllerName}' is not registered`);\n }\n\n return editor;\n }\n\n public static hasCustomEditor(editType: string, editorName: string): boolean {\n const fullEditorName = PropertyEditorManager.getFullEditorName(editType, editorName);\n return PropertyEditorManager._editors.hasOwnProperty(fullEditorName);\n }\n}\n\n/** Basic Property Editor registered for the \"text\" and \"string\" type names.\n * It uses the [[TextEditor]] React component.\n * @beta\n */\nexport class BasicPropertyEditor extends PropertyEditorBase {\n public get reactNode(): React.ReactNode {\n return <TextEditor />;\n }\n}\n\nPropertyEditorManager.registerEditor(StandardTypeNames.Text, BasicPropertyEditor);\nPropertyEditorManager.registerEditor(StandardTypeNames.String, BasicPropertyEditor);\n"]}
|
|
1
|
+
{"version":3,"file":"PropertyEditorMan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C;AA6D5F;;;GAGG;AACH,MAAa,mBAAoB,SAAQ,kBAAkB;IACzD,IAAW,SAAS;QAClB,OAAO,oBAAC,uBAAU,OAAG,CAAC;IACxB,CAAC;CACF;AAJD,kDAIC;AAED,qBAAqB,CAAC,cAAc,CAAC,kCAAiB,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC;AAClF,qBAAqB,CAAC,cAAc,CAAC,kCAAiB,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module PropertyEditors\n */\n\nimport * as React from \"react\";\nimport { TextEditor } from \"./TextEditor\";\nimport { DisplayMessageType, MessageSeverity, PropertyDescription, PropertyRecord, PropertyValue, StandardTypeNames } from \"@itwin/appui-abstract\";\n\n/** Asynchronous Error Message returned as part of [[AsyncValueProcessingResult]]\n * @public\n */\nexport interface AsyncErrorMessage {\n severity: MessageSeverity;\n briefMessage: string;\n detailedMessage?: string;\n messageType?: DisplayMessageType;\n}\n\n/** Asynchronous Value Process Result\n * @public\n */\nexport interface AsyncValueProcessingResult {\n encounteredError: boolean;\n returnValue?: PropertyValue;\n errorMessage?: AsyncErrorMessage;\n}\n\n/** DataControllers can be implemented per typename to validate and commit values.\n * @public\n */\nexport interface DataController {\n validateValue(newValue: PropertyValue, record: PropertyRecord): Promise<AsyncValueProcessingResult>;\n commitValue(newValue: PropertyValue, record: PropertyRecord): Promise<AsyncValueProcessingResult>;\n}\n\n/** PropertyEditor is the base class for all property editors.\n * @public\n */\nexport abstract class PropertyEditorBase implements DataController {\n\n public get containerHandlesBlur(): boolean {\n return true;\n }\n public get containerHandlesEscape(): boolean {\n return true;\n }\n public get containerHandlesEnter(): boolean {\n return true;\n }\n public get containerHandlesTab(): boolean {\n return true;\n }\n public get containerStopsKeydownPropagation(): boolean {\n return true;\n }\n\n public customDataController: DataController | undefined = undefined;\n\n public abstract get reactNode(): React.ReactNode;\n\n public applyEditorParams(_property: PropertyDescription, _record: PropertyRecord): void { }\n\n public async commitValue(newValue: PropertyValue, record: PropertyRecord): Promise<AsyncValueProcessingResult> {\n if (this.customDataController)\n return this.customDataController.commitValue(newValue, record);\n\n return { encounteredError: false };\n }\n\n public async validateValue(newValue: PropertyValue, record: PropertyRecord): Promise<AsyncValueProcessingResult> {\n if (this.customDataController)\n return this.customDataController.validateValue(newValue, record);\n\n return { encounteredError: false };\n }\n\n}\n\n/** DataControllerBase is the base class for all Data Controllers.\n * @public\n */\nexport abstract class DataControllerBase implements DataController {\n public async commitValue(_newValue: PropertyValue, _record: PropertyRecord): Promise<AsyncValueProcessingResult> {\n return { encounteredError: false };\n }\n\n public async validateValue(_newValue: PropertyValue, _record: PropertyRecord): Promise<AsyncValueProcessingResult> {\n return { encounteredError: false };\n }\n}\n\n/** Manages Property Editors. Property Editors are registered with and created by the manager.\n * @public\n */\nexport class PropertyEditorManager {\n private static _editors: { [index: string]: (new () => PropertyEditorBase) } = {};\n private static _dataControllers: { [index: string]: (new () => DataControllerBase) } = {};\n\n public static registerEditor(editType: string, editor: new () => PropertyEditorBase, editorName?: string): void {\n const fullEditorName = PropertyEditorManager.getFullEditorName(editType, editorName);\n\n if (PropertyEditorManager._editors.hasOwnProperty(fullEditorName)) {\n const nameOfEditor = PropertyEditorManager._editors[fullEditorName].name;\n throw Error(`PropertyEditorManager.registerEditor error: type '${fullEditorName}' already registered to '${nameOfEditor}'`);\n }\n PropertyEditorManager._editors[fullEditorName] = editor;\n }\n\n private static getFullEditorName(editType: string, editorName?: string): string {\n let fullEditorName = editType;\n if (editorName)\n fullEditorName += `:${editorName}`;\n return fullEditorName;\n }\n\n public static registerDataController(controllerName: string, controller: new () => DataControllerBase): void {\n if (PropertyEditorManager._dataControllers.hasOwnProperty(controllerName)) {\n throw Error(`PropertyEditorManager.registerDataController error: type '${controllerName}' already registered to '${(typeof PropertyEditorManager._dataControllers[controllerName]).toString()}'`);\n }\n PropertyEditorManager._dataControllers[controllerName] = controller;\n }\n\n /** @internal */\n public static deregisterDataController(controllerName: string): void {\n // istanbul ignore else\n if (PropertyEditorManager._dataControllers.hasOwnProperty(controllerName)) {\n delete PropertyEditorManager._dataControllers[controllerName];\n }\n }\n\n public static createEditor(editType: string, editorName?: string, dataControllerName?: string): PropertyEditorBase {\n const fullEditorName = PropertyEditorManager.getFullEditorName(editType, editorName);\n\n let editor: PropertyEditorBase;\n if (PropertyEditorManager._editors.hasOwnProperty(fullEditorName))\n editor = new PropertyEditorManager._editors[fullEditorName]();\n else if (PropertyEditorManager._editors.hasOwnProperty(editType))\n editor = new PropertyEditorManager._editors[editType]();\n else\n editor = new BasicPropertyEditor();\n\n if (dataControllerName) {\n if (PropertyEditorManager._dataControllers.hasOwnProperty(dataControllerName))\n editor.customDataController = new PropertyEditorManager._dataControllers[dataControllerName]();\n else\n throw Error(`PropertyEditorManager.createEditor error: data controller '${dataControllerName}' is not registered`);\n }\n\n return editor;\n }\n\n public static hasCustomEditor(editType: string, editorName: string): boolean {\n const fullEditorName = PropertyEditorManager.getFullEditorName(editType, editorName);\n return PropertyEditorManager._editors.hasOwnProperty(fullEditorName);\n }\n}\n\n/** Basic Property Editor registered for the \"text\" and \"string\" type names.\n * It uses the [[TextEditor]] React component.\n * @public\n */\nexport class BasicPropertyEditor extends PropertyEditorBase {\n public get reactNode(): React.ReactNode {\n return <TextEditor />;\n }\n}\n\nPropertyEditorManager.registerEditor(StandardTypeNames.Text, BasicPropertyEditor);\nPropertyEditorManager.registerEditor(StandardTypeNames.String, BasicPropertyEditor);\n"]}
|
|
@@ -24,7 +24,7 @@ interface SliderEditorState {
|
|
|
24
24
|
tickLabels?: React.ReactNode;
|
|
25
25
|
}
|
|
26
26
|
/** SliderEditor React component that is a property editor with numeric input & up/down buttons
|
|
27
|
-
* @
|
|
27
|
+
* @public
|
|
28
28
|
*/
|
|
29
29
|
export declare class SliderEditor extends React.PureComponent<PropertyEditorProps, SliderEditorState> implements TypeEditor {
|
|
30
30
|
private _isMounted;
|
|
@@ -55,7 +55,7 @@ export declare class SliderEditor extends React.PureComponent<PropertyEditorProp
|
|
|
55
55
|
}
|
|
56
56
|
/** Slider Property Editor registered for the "number" type name and "slider" editor name.
|
|
57
57
|
* It uses the [[SliderEditor]] React component.
|
|
58
|
-
* @
|
|
58
|
+
* @public
|
|
59
59
|
*/
|
|
60
60
|
export declare class SliderPropertyEditor extends PropertyEditorBase {
|
|
61
61
|
get reactNode(): React.ReactNode;
|
|
@@ -39,7 +39,7 @@ const itwinui_react_1 = require("@itwin/itwinui-react");
|
|
|
39
39
|
const PropertyEditorManager_1 = require("./PropertyEditorManager");
|
|
40
40
|
const PopupButton_1 = require("./PopupButton");
|
|
41
41
|
/** SliderEditor React component that is a property editor with numeric input & up/down buttons
|
|
42
|
-
* @
|
|
42
|
+
* @public
|
|
43
43
|
*/
|
|
44
44
|
class SliderEditor extends React.PureComponent {
|
|
45
45
|
constructor() {
|
|
@@ -231,7 +231,7 @@ class SliderEditor extends React.PureComponent {
|
|
|
231
231
|
exports.SliderEditor = SliderEditor;
|
|
232
232
|
/** Slider Property Editor registered for the "number" type name and "slider" editor name.
|
|
233
233
|
* It uses the [[SliderEditor]] React component.
|
|
234
|
-
* @
|
|
234
|
+
* @public
|
|
235
235
|
*/
|
|
236
236
|
class SliderPropertyEditor extends PropertyEditorManager_1.PropertyEditorBase {
|
|
237
237
|
get reactNode() {
|