@itwin/components-react 4.0.0 → 4.0.1
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/CHANGELOG.md +6 -1
- package/lib/cjs/components-react/common/DelayedSpinner.js +2 -3
- package/lib/cjs/components-react/common/DelayedSpinner.js.map +1 -1
- package/lib/cjs/components-react/common/UseDebouncedAsyncValue.js +1 -2
- package/lib/cjs/components-react/common/UseDebouncedAsyncValue.js.map +1 -1
- package/lib/cjs/components-react/converters/NumericTypeConverter.js +2 -4
- package/lib/cjs/components-react/converters/NumericTypeConverter.js.map +1 -1
- package/lib/cjs/components-react/converters/TypeConverter.js +1 -2
- package/lib/cjs/components-react/converters/TypeConverter.js.map +1 -1
- package/lib/cjs/components-react/editors/CustomNumberEditor.js +2 -4
- package/lib/cjs/components-react/editors/CustomNumberEditor.js.map +1 -1
- package/lib/cjs/components-react/editors/DateTimeEditor.js +2 -3
- package/lib/cjs/components-react/editors/DateTimeEditor.js.map +1 -1
- package/lib/cjs/components-react/editors/PopupButton.js +3 -4
- package/lib/cjs/components-react/editors/PopupButton.js.map +1 -1
- package/lib/cjs/components-react/editors/TextEditor.js +2 -4
- package/lib/cjs/components-react/editors/TextEditor.js.map +1 -1
- package/lib/cjs/components-react/favorite/FavoritePropertyList.js +2 -3
- package/lib/cjs/components-react/favorite/FavoritePropertyList.js.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleOperator.js +1 -2
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleOperator.js.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleProperty.js +3 -3
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleProperty.js.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleValue.js +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleValue.js.map +1 -1
- package/lib/cjs/components-react/properties/renderers/CommonPropertyRenderer.js +3 -4
- package/lib/cjs/components-react/properties/renderers/CommonPropertyRenderer.js.map +1 -1
- package/lib/cjs/components-react/properties/renderers/NonPrimitivePropertyRenderer.js +1 -1
- package/lib/cjs/components-react/properties/renderers/NonPrimitivePropertyRenderer.js.map +1 -1
- package/lib/cjs/components-react/properties/renderers/PrimitivePropertyRenderer.js +2 -3
- package/lib/cjs/components-react/properties/renderers/PrimitivePropertyRenderer.js.map +1 -1
- package/lib/cjs/components-react/properties/renderers/label/PropertyLabelRenderer.js +1 -2
- package/lib/cjs/components-react/properties/renderers/label/PropertyLabelRenderer.js.map +1 -1
- package/lib/cjs/components-react/properties/renderers/value/DoublePropertyValueRenderer.js +1 -2
- package/lib/cjs/components-react/properties/renderers/value/DoublePropertyValueRenderer.js.map +1 -1
- package/lib/cjs/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.js +3 -6
- package/lib/cjs/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.js.map +1 -1
- package/lib/cjs/components-react/properties/renderers/value/NavigationPropertyValueRenderer.js +1 -2
- package/lib/cjs/components-react/properties/renderers/value/NavigationPropertyValueRenderer.js.map +1 -1
- package/lib/cjs/components-react/properties/renderers/value/PrimitivePropertyValueRenderer.js +4 -7
- package/lib/cjs/components-react/properties/renderers/value/PrimitivePropertyValueRenderer.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/PropertyCategoryRendererManager.js +1 -2
- package/lib/cjs/components-react/propertygrid/PropertyCategoryRendererManager.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/component/PropertyCategoryBlock.js +1 -2
- package/lib/cjs/components-react/propertygrid/component/PropertyCategoryBlock.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/component/PropertyGridCommons.js +2 -2
- package/lib/cjs/components-react/propertygrid/component/PropertyGridCommons.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/component/VirtualizedPropertyGrid.js +46 -51
- package/lib/cjs/components-react/propertygrid/component/VirtualizedPropertyGrid.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/dataproviders/FilteringDataProvider.js +11 -13
- package/lib/cjs/components-react/propertygrid/dataproviders/FilteringDataProvider.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/dataproviders/filterers/CompositePropertyDataFilterer.js +2 -2
- package/lib/cjs/components-react/propertygrid/dataproviders/filterers/CompositePropertyDataFilterer.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/dataproviders/filterers/DisplayValuePropertyDataFilterer.js +1 -2
- package/lib/cjs/components-react/propertygrid/dataproviders/filterers/DisplayValuePropertyDataFilterer.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableCustomGridCategory.js +1 -2
- package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableCustomGridCategory.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.js +2 -2
- package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableGridCategory.js +2 -3
- package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableGridCategory.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableGridItemFactory.js +1 -1
- package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableGridItemFactory.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/internal/flat-properties/FlatNonPrimitivePropertyRenderer.js +1 -1
- package/lib/cjs/components-react/propertygrid/internal/flat-properties/FlatNonPrimitivePropertyRenderer.js.map +1 -1
- package/lib/cjs/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.js +5 -7
- package/lib/cjs/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.js.map +1 -1
- package/lib/cjs/components-react/selectable-content/SelectableContent.js +2 -3
- package/lib/cjs/components-react/selectable-content/SelectableContent.js.map +1 -1
- package/lib/cjs/components-react/toolbar/ToolbarWithOverflow.d.ts.map +1 -1
- package/lib/cjs/components-react/toolbar/ToolbarWithOverflow.js +8 -4
- package/lib/cjs/components-react/toolbar/ToolbarWithOverflow.js.map +1 -1
- package/lib/cjs/components-react/toolbar/groupPanel/tool/Tool.d.ts.map +1 -1
- package/lib/cjs/components-react/toolbar/groupPanel/tool/Tool.js +3 -1
- package/lib/cjs/components-react/toolbar/groupPanel/tool/Tool.js.map +1 -1
- package/lib/cjs/components-react/tree/controlled/TreeModel.js +4 -7
- package/lib/cjs/components-react/tree/controlled/TreeModel.js.map +1 -1
- package/lib/cjs/components-react/tree/controlled/TreeNodeLoader.js +6 -8
- package/lib/cjs/components-react/tree/controlled/TreeNodeLoader.js.map +1 -1
- package/lib/cjs/components-react/tree/controlled/internal/SparseTree.js +1 -2
- package/lib/cjs/components-react/tree/controlled/internal/SparseTree.js.map +1 -1
- package/lib/cjs/components-react/tree/controlled/internal/TreeSelectionManager.js +2 -4
- package/lib/cjs/components-react/tree/controlled/internal/TreeSelectionManager.js.map +1 -1
- package/lib/esm/components-react/common/DelayedSpinner.js +2 -3
- package/lib/esm/components-react/common/DelayedSpinner.js.map +1 -1
- package/lib/esm/components-react/common/UseDebouncedAsyncValue.js +1 -2
- package/lib/esm/components-react/common/UseDebouncedAsyncValue.js.map +1 -1
- package/lib/esm/components-react/converters/NumericTypeConverter.js +2 -4
- package/lib/esm/components-react/converters/NumericTypeConverter.js.map +1 -1
- package/lib/esm/components-react/converters/TypeConverter.js +1 -2
- package/lib/esm/components-react/converters/TypeConverter.js.map +1 -1
- package/lib/esm/components-react/editors/CustomNumberEditor.js +2 -4
- package/lib/esm/components-react/editors/CustomNumberEditor.js.map +1 -1
- package/lib/esm/components-react/editors/DateTimeEditor.js +2 -3
- package/lib/esm/components-react/editors/DateTimeEditor.js.map +1 -1
- package/lib/esm/components-react/editors/PopupButton.js +3 -4
- package/lib/esm/components-react/editors/PopupButton.js.map +1 -1
- package/lib/esm/components-react/editors/TextEditor.js +2 -4
- package/lib/esm/components-react/editors/TextEditor.js.map +1 -1
- package/lib/esm/components-react/favorite/FavoritePropertyList.js +2 -3
- package/lib/esm/components-react/favorite/FavoritePropertyList.js.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleOperator.js +1 -2
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleOperator.js.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleProperty.js +3 -3
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleProperty.js.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleValue.js +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleValue.js.map +1 -1
- package/lib/esm/components-react/properties/renderers/CommonPropertyRenderer.js +3 -4
- package/lib/esm/components-react/properties/renderers/CommonPropertyRenderer.js.map +1 -1
- package/lib/esm/components-react/properties/renderers/NonPrimitivePropertyRenderer.js +1 -1
- package/lib/esm/components-react/properties/renderers/NonPrimitivePropertyRenderer.js.map +1 -1
- package/lib/esm/components-react/properties/renderers/PrimitivePropertyRenderer.js +2 -3
- package/lib/esm/components-react/properties/renderers/PrimitivePropertyRenderer.js.map +1 -1
- package/lib/esm/components-react/properties/renderers/label/PropertyLabelRenderer.js +1 -2
- package/lib/esm/components-react/properties/renderers/label/PropertyLabelRenderer.js.map +1 -1
- package/lib/esm/components-react/properties/renderers/value/DoublePropertyValueRenderer.js +1 -2
- package/lib/esm/components-react/properties/renderers/value/DoublePropertyValueRenderer.js.map +1 -1
- package/lib/esm/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.js +3 -6
- package/lib/esm/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.js.map +1 -1
- package/lib/esm/components-react/properties/renderers/value/NavigationPropertyValueRenderer.js +1 -2
- package/lib/esm/components-react/properties/renderers/value/NavigationPropertyValueRenderer.js.map +1 -1
- package/lib/esm/components-react/properties/renderers/value/PrimitivePropertyValueRenderer.js +4 -7
- package/lib/esm/components-react/properties/renderers/value/PrimitivePropertyValueRenderer.js.map +1 -1
- package/lib/esm/components-react/propertygrid/PropertyCategoryRendererManager.js +1 -2
- package/lib/esm/components-react/propertygrid/PropertyCategoryRendererManager.js.map +1 -1
- package/lib/esm/components-react/propertygrid/component/PropertyCategoryBlock.js +1 -2
- package/lib/esm/components-react/propertygrid/component/PropertyCategoryBlock.js.map +1 -1
- package/lib/esm/components-react/propertygrid/component/PropertyGridCommons.js +2 -2
- package/lib/esm/components-react/propertygrid/component/PropertyGridCommons.js.map +1 -1
- package/lib/esm/components-react/propertygrid/component/VirtualizedPropertyGrid.js +46 -51
- package/lib/esm/components-react/propertygrid/component/VirtualizedPropertyGrid.js.map +1 -1
- package/lib/esm/components-react/propertygrid/dataproviders/FilteringDataProvider.js +11 -13
- package/lib/esm/components-react/propertygrid/dataproviders/FilteringDataProvider.js.map +1 -1
- package/lib/esm/components-react/propertygrid/dataproviders/filterers/CompositePropertyDataFilterer.js +2 -2
- package/lib/esm/components-react/propertygrid/dataproviders/filterers/CompositePropertyDataFilterer.js.map +1 -1
- package/lib/esm/components-react/propertygrid/dataproviders/filterers/DisplayValuePropertyDataFilterer.js +1 -2
- package/lib/esm/components-react/propertygrid/dataproviders/filterers/DisplayValuePropertyDataFilterer.js.map +1 -1
- package/lib/esm/components-react/propertygrid/internal/flat-items/MutableCustomGridCategory.js +1 -2
- package/lib/esm/components-react/propertygrid/internal/flat-items/MutableCustomGridCategory.js.map +1 -1
- package/lib/esm/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.js +2 -2
- package/lib/esm/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.js.map +1 -1
- package/lib/esm/components-react/propertygrid/internal/flat-items/MutableGridCategory.js +2 -3
- package/lib/esm/components-react/propertygrid/internal/flat-items/MutableGridCategory.js.map +1 -1
- package/lib/esm/components-react/propertygrid/internal/flat-items/MutableGridItemFactory.js +1 -1
- package/lib/esm/components-react/propertygrid/internal/flat-items/MutableGridItemFactory.js.map +1 -1
- package/lib/esm/components-react/propertygrid/internal/flat-properties/FlatNonPrimitivePropertyRenderer.js +1 -1
- package/lib/esm/components-react/propertygrid/internal/flat-properties/FlatNonPrimitivePropertyRenderer.js.map +1 -1
- package/lib/esm/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.js +5 -7
- package/lib/esm/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.js.map +1 -1
- package/lib/esm/components-react/selectable-content/SelectableContent.js +2 -3
- package/lib/esm/components-react/selectable-content/SelectableContent.js.map +1 -1
- package/lib/esm/components-react/toolbar/ToolbarWithOverflow.d.ts.map +1 -1
- package/lib/esm/components-react/toolbar/ToolbarWithOverflow.js +8 -4
- package/lib/esm/components-react/toolbar/ToolbarWithOverflow.js.map +1 -1
- package/lib/esm/components-react/toolbar/groupPanel/tool/Tool.d.ts.map +1 -1
- package/lib/esm/components-react/toolbar/groupPanel/tool/Tool.js +3 -1
- package/lib/esm/components-react/toolbar/groupPanel/tool/Tool.js.map +1 -1
- package/lib/esm/components-react/tree/controlled/TreeModel.js +4 -7
- package/lib/esm/components-react/tree/controlled/TreeModel.js.map +1 -1
- package/lib/esm/components-react/tree/controlled/TreeNodeLoader.js +6 -8
- package/lib/esm/components-react/tree/controlled/TreeNodeLoader.js.map +1 -1
- package/lib/esm/components-react/tree/controlled/internal/SparseTree.js +1 -2
- package/lib/esm/components-react/tree/controlled/internal/SparseTree.js.map +1 -1
- package/lib/esm/components-react/tree/controlled/internal/TreeSelectionManager.js +2 -4
- package/lib/esm/components-react/tree/controlled/internal/TreeSelectionManager.js.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomNumberEditor.js","sourceRoot":"","sources":["../../../../src/components-react/editors/CustomNumberEditor.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,oCAAoC;AAEpC,OAAO,2BAA2B,CAAC;AACnC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EACiE,e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KAAK,CAAC,QAAQ,GAAI,CAAC;YACrD,SAAS,GAAG,CACV,oBAAC,SAAS,OACJ,UAAU,EACd,GAAG,EAAE,IAAI,CAAC,aAAa,EACvB,IAAI,EAAE,IAAI,iBACE,gCAAgC,GAC5C,CACH,CAAC;SACH;aAAM;YACL,uFAAuF;YACvF,SAAS,GAAG,CACV,oBAAC,KAAK,OACA,UAAU,EACd,GAAG,EAAE,IAAI,CAAC,aAAa,iBACX,gCAAgC,EAC5C,IAAI,EAAC,OAAO,GACZ,CACH,CAAC;SACH;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,0BAA2B,SAAQ,kBAAkB;IAChE,IAAW,SAAS;QAClB,OAAO,oBAAC,kBAAkB,OAAG,CAAC;IAChC,CAAC;IACD,IAAoB,sBAAsB;QACxC,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AACD,qBAAqB,CAAC,cAAc,CAAC,iBAAiB,CAAC,MAAM,EAAE,0BAA0B,EAAE,mBAAmB,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\n// cSpell:ignore customnumber testid\n\nimport \"./CustomNumberEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { Logger } from \"@itwin/core-bentley\";\nimport {\n CustomFormattedNumberParams, IconEditorParams, InputEditorSizeParams, MessageSeverity, PrimitiveValue, PropertyEditorParams, PropertyEditorParamTypes,\n PropertyRecord, PropertyValue, PropertyValueFormat, SpecialKey, StandardEditorNames, StandardTypeNames, UiAdmin,\n} from \"@itwin/appui-abstract\";\nimport { Icon, IconInput } from \"@itwin/core-react\";\nimport { Input, InputProps } from \"@itwin/itwinui-react\";\n\nimport { UiComponents } from \"../UiComponents\";\nimport { PropertyEditorProps, TypeEditor } from \"./EditorContainer\";\nimport { PropertyEditorBase, PropertyEditorManager } from \"./PropertyEditorManager\";\n\n/** @internal */\ninterface CustomNumberEditorState {\n inputValue: string;\n size?: number;\n maxLength?: number;\n iconSpec?: string;\n}\n\n/** CustomNumberEditor is a React component that is a property editor for numbers that specify custom formatting and parsing functions.\n * @alpha\n */\nexport class CustomNumberEditor extends React.PureComponent<PropertyEditorProps, CustomNumberEditorState> implements TypeEditor {\n private _isMounted = false;\n private _formatParams: CustomFormattedNumberParams | undefined;\n private _inputElement = React.createRef<HTMLInputElement>();\n private _lastValidValue: PropertyValue | undefined;\n\n /** @internal */\n public override readonly state: Readonly<CustomNumberEditorState> = {\n inputValue: \"\",\n };\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord as PropertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n if (record.isReadonly) {\n return {\n valueFormat: PropertyValueFormat.Primitive,\n value: (record.value as PrimitiveValue).value,\n displayValue: (record.value as PrimitiveValue).displayValue,\n };\n }\n\n // istanbul ignore else\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n const parseResults = (this._formatParams as CustomFormattedNumberParams).parseFunction(this.state.inputValue);\n if (!parseResults.parseError && undefined !== parseResults.value) {\n const newDisplayValue = (this._formatParams as CustomFormattedNumberParams).formatFunction(parseResults.value as number);\n propertyValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: parseResults.value,\n displayValue: newDisplayValue,\n };\n this._lastValidValue = { ...propertyValue };\n // make sure the text in the input item matches the latest formatted text... this could get out if the input string say 1.5 === the display string of 1'-6\"\n // istanbul ignore else\n if (newDisplayValue !== this.state.inputValue) {\n this.setState({ inputValue: newDisplayValue });\n }\n } else {\n // istanbul ignore else\n if (this.htmlElement) {\n UiAdmin.messagePresenter.displayInputFieldMessage(this.htmlElement, MessageSeverity.Error, parseResults.parseError ? parseResults.parseError : /* istanbul ignore next */ UiComponents.translate(\"errors.unable-to-parse-quantity\"));\n this.htmlElement.focus();\n } else {\n UiAdmin.messagePresenter.displayMessage(MessageSeverity.Error, parseResults.parseError ? parseResults.parseError : /* istanbul ignore next */ UiComponents.translate(\"errors.unable-to-parse-quantity\"));\n }\n\n const displayValue = (record.value.displayValue && record.value.displayValue.length > 0) ? record.value.displayValue : /* istanbul ignore next */ (this._formatParams as CustomFormattedNumberParams).formatFunction(record.value.value as number);\n propertyValue = this._lastValidValue ? { ...this._lastValidValue } : /* istanbul ignore next */ {\n valueFormat: PropertyValueFormat.Primitive,\n value: record.value.value,\n displayValue,\n };\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 private shouldSetFocus(): boolean {\n if (!this.props.setFocus)\n return false;\n\n const record = this.props.propertyRecord as PropertyRecord;\n const disabled = (record && !record.isDisabled) ? false : true;\n const readonly = (record && !record.isReadonly) ? false : true;\n\n return (!disabled && !readonly);\n }\n\n private _applyUpdatedValue(userInput: string) {\n const record = this.props.propertyRecord as PropertyRecord;\n const readonly = (record && !record.isReadonly) ? false : true;\n const disabled = (record && !record.isDisabled) ? false : true;\n\n if (readonly || disabled)\n return;\n\n // istanbul ignore else\n if (this._isMounted)\n this.setState({\n inputValue: userInput,\n });\n }\n\n private _updateInputValue = (e: React.ChangeEvent<HTMLInputElement>) => {\n this._applyUpdatedValue(e.target.value);\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 _getInitialDisplayValue(): string {\n const record = this.props.propertyRecord;\n let initialDisplayValue = \"\";\n let numberValue = 0;\n // istanbul ignore else\n if (record) {\n // istanbul ignore else\n if (record.value.valueFormat === PropertyValueFormat.Primitive) {\n const primitiveValue = record.value;\n numberValue = (undefined !== primitiveValue.value) ? primitiveValue.value as number : /* istanbul ignore next */ 0;\n // istanbul ignore else\n if (primitiveValue.displayValue)\n initialDisplayValue = primitiveValue.displayValue;\n else\n initialDisplayValue = (this._formatParams as CustomFormattedNumberParams).formatFunction(numberValue);\n }\n }\n\n return initialDisplayValue;\n }\n\n private async setStateFromProps() {\n const record = this.props.propertyRecord;\n // istanbul ignore next\n if (!record || !record.property) {\n Logger.logError(UiComponents.loggerCategory(this), \"PropertyRecord must be defined to use CustomNumberPropertyEditor\");\n // eslint-disable-next-line no-console\n // console.log(\"PropertyRecord must be defined to use CustomNumberPropertyEditor\");\n return;\n }\n // istanbul ignore else\n if (record.property && record.property.editor && record.property.editor.params) {\n this._formatParams = record.property.editor.params.find((param: PropertyEditorParams) => param.type === PropertyEditorParamTypes.CustomFormattedNumber) as CustomFormattedNumberParams;\n }\n\n if (!this._formatParams) {\n Logger.logError(UiComponents.loggerCategory(this), `CustomFormattedNumberParams must be defined for property ${record.property.name}`);\n // eslint-disable-next-line no-console\n // console.log(`CustomFormattedNumberParams must be defined for property ${record!.property!.name}`);\n return;\n }\n\n const initialDisplayValue = this._getInitialDisplayValue();\n this._lastValidValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: (record.value as PrimitiveValue).value,\n displayValue: initialDisplayValue,\n };\n let size: number | undefined;\n let maxLength: number | undefined;\n let iconSpec: string | undefined;\n\n // istanbul ignore else\n if (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 // istanbul ignore else\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 iconParams = record.property.editor.params.find((param: PropertyEditorParams) => param.type === PropertyEditorParamTypes.Icon) as IconEditorParams;\n if (iconParams) {\n iconSpec = iconParams.definition.iconSpec;\n }\n }\n\n // istanbul ignore else\n if (this._isMounted)\n this.setState({ inputValue: initialDisplayValue, size, maxLength, iconSpec });\n }\n\n private _resetToLastValidDisplayValue() {\n const initialDisplayValue = (this._lastValidValue && (this._lastValidValue as PrimitiveValue).displayValue) ?? (/* istanbul ignore next */ this._getInitialDisplayValue());\n this.setState({ inputValue: initialDisplayValue });\n }\n\n private _onKeyPress = (e: React.KeyboardEvent<HTMLInputElement>) => {\n // istanbul ignore else\n if (e.key === SpecialKey.Escape) {\n const initialDisplayValue = (this._lastValidValue && (this._lastValidValue as PrimitiveValue).displayValue) ?? (/* istanbul ignore next */ this._getInitialDisplayValue());\n if (initialDisplayValue !== this.state.inputValue) {\n e.preventDefault();\n e.stopPropagation();\n this._resetToLastValidDisplayValue();\n } else {\n // istanbul ignore else\n if (this.props.onCancel)\n this.props.onCancel();\n }\n }\n\n // istanbul ignore else\n if (e.key !== SpecialKey.Enter) {\n UiAdmin.messagePresenter.closeInputFieldMessage();\n }\n };\n\n // istanbul ignore next\n private _onFocus = (e: React.FocusEvent<HTMLInputElement>) => {\n e.target.select();\n };\n\n /** @internal */\n public override render(): React.ReactNode {\n const minSize = this.state.size ? this.state.size : 8;\n const minWidthStyle: React.CSSProperties = {\n minWidth: `${minSize * 0.75}em`,\n };\n const record = this.props.propertyRecord as PropertyRecord;\n if (!record || !this._formatParams)\n return null;\n\n const readOnly = !record.isReadonly ? false : true;\n const disabled = !record.isDisabled ? false : true;\n\n const className = classnames(\"components-cell-editor\", \"components-customnumber-editor\", this.props.className);\n\n const inputProps: Omit<InputProps, \"size\"> = { // eslint-disable-line deprecation/deprecation\n className,\n style: this.props.style ? this.props.style : minWidthStyle,\n readOnly,\n disabled,\n maxLength: this.state.maxLength,\n value: this.state.inputValue,\n onChange: this._updateInputValue,\n onBlur: this.props.onBlur,\n onFocus: this._onFocus,\n setFocus: this.shouldSetFocus(),\n onKeyDown: this._onKeyPress,\n };\n\n let reactNode: React.ReactNode;\n if (this.state.iconSpec) {\n const icon = <Icon iconSpec={this.state.iconSpec} />;\n reactNode = (\n <IconInput\n {...inputProps}\n ref={this._inputElement}\n icon={icon}\n data-testid=\"components-customnumber-editor\"\n />\n );\n } else {\n // NEEDSWORK: still using core-react Input component because of `nativeKeyHandler` prop\n reactNode = (\n <Input\n {...inputProps}\n ref={this._inputElement}\n data-testid=\"components-customnumber-editor\"\n size=\"small\"\n />\n );\n }\n\n return reactNode;\n }\n}\n\n/** Custom Property Editor registered for the \"number\" type name and the \"number-custom\" editor name.\n * It uses the [[CustomNumberEditor]] React component.\n * @alpha\n */\nexport class CustomNumberPropertyEditor extends PropertyEditorBase {\n public get reactNode(): React.ReactNode {\n return <CustomNumberEditor />;\n }\n public override get containerHandlesEscape(): boolean {\n return false;\n }\n}\nPropertyEditorManager.registerEditor(StandardTypeNames.Number, CustomNumberPropertyEditor, StandardEditorNames.NumberCustom);\n"]}
|
|
1
|
+
{"version":3,"file":"CustomNumberEditor.js","sourceRoot":"","sources":["../../../../src/components-react/editors/CustomNumberEditor.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,oCAAoC;AAEpC,OAAO,2BAA2B,CAAC;AACnC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EACiE,eAAe,EAAwC,wBAAwB,EACtH,mBAAmB,EAAE,UAAU,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,OAAO,GAChH,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAc,MAAM,sBAAsB,CAAC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d,GAAG,EAAE,IAAI,CAAC,aAAa,iBACX,gCAAgC,EAC5C,IAAI,EAAC,OAAO,GACZ,CACH,CAAC;SACH;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,0BAA2B,SAAQ,kBAAkB;IAChE,IAAW,SAAS;QAClB,OAAO,oBAAC,kBAAkB,OAAG,CAAC;IAChC,CAAC;IACD,IAAoB,sBAAsB;QACxC,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AACD,qBAAqB,CAAC,cAAc,CAAC,iBAAiB,CAAC,MAAM,EAAE,0BAA0B,EAAE,mBAAmB,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\n// cSpell:ignore customnumber testid\n\nimport \"./CustomNumberEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { Logger } from \"@itwin/core-bentley\";\nimport {\n CustomFormattedNumberParams, IconEditorParams, InputEditorSizeParams, MessageSeverity, PrimitiveValue, PropertyEditorParams, PropertyEditorParamTypes,\n PropertyRecord, PropertyValue, PropertyValueFormat, SpecialKey, StandardEditorNames, StandardTypeNames, UiAdmin,\n} from \"@itwin/appui-abstract\";\nimport { Icon, IconInput } from \"@itwin/core-react\";\nimport { Input, InputProps } from \"@itwin/itwinui-react\";\n\nimport { UiComponents } from \"../UiComponents\";\nimport { PropertyEditorProps, TypeEditor } from \"./EditorContainer\";\nimport { PropertyEditorBase, PropertyEditorManager } from \"./PropertyEditorManager\";\n\n/** @internal */\ninterface CustomNumberEditorState {\n inputValue: string;\n size?: number;\n maxLength?: number;\n iconSpec?: string;\n}\n\n/** CustomNumberEditor is a React component that is a property editor for numbers that specify custom formatting and parsing functions.\n * @alpha\n */\nexport class CustomNumberEditor extends React.PureComponent<PropertyEditorProps, CustomNumberEditorState> implements TypeEditor {\n private _isMounted = false;\n private _formatParams: CustomFormattedNumberParams | undefined;\n private _inputElement = React.createRef<HTMLInputElement>();\n private _lastValidValue: PropertyValue | undefined;\n\n /** @internal */\n public override readonly state: Readonly<CustomNumberEditorState> = {\n inputValue: \"\",\n };\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord as PropertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n if (record.isReadonly) {\n return {\n valueFormat: PropertyValueFormat.Primitive,\n value: (record.value as PrimitiveValue).value,\n displayValue: (record.value as PrimitiveValue).displayValue,\n };\n }\n\n // istanbul ignore else\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n const parseResults = (this._formatParams as CustomFormattedNumberParams).parseFunction(this.state.inputValue);\n if (!parseResults.parseError && undefined !== parseResults.value) {\n const newDisplayValue = (this._formatParams as CustomFormattedNumberParams).formatFunction(parseResults.value as number);\n propertyValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: parseResults.value,\n displayValue: newDisplayValue,\n };\n this._lastValidValue = { ...propertyValue };\n // make sure the text in the input item matches the latest formatted text... this could get out if the input string say 1.5 === the display string of 1'-6\"\n // istanbul ignore else\n if (newDisplayValue !== this.state.inputValue) {\n this.setState({ inputValue: newDisplayValue });\n }\n } else {\n // istanbul ignore else\n if (this.htmlElement) {\n UiAdmin.messagePresenter.displayInputFieldMessage(this.htmlElement, MessageSeverity.Error, parseResults.parseError ? parseResults.parseError : /* istanbul ignore next */ UiComponents.translate(\"errors.unable-to-parse-quantity\"));\n this.htmlElement.focus();\n } else {\n UiAdmin.messagePresenter.displayMessage(MessageSeverity.Error, parseResults.parseError ? parseResults.parseError : /* istanbul ignore next */ UiComponents.translate(\"errors.unable-to-parse-quantity\"));\n }\n\n const displayValue = (record.value.displayValue && record.value.displayValue.length > 0) ? record.value.displayValue : /* istanbul ignore next */ (this._formatParams as CustomFormattedNumberParams).formatFunction(record.value.value as number);\n propertyValue = this._lastValidValue ? { ...this._lastValidValue } : /* istanbul ignore next */ {\n valueFormat: PropertyValueFormat.Primitive,\n value: record.value.value,\n displayValue,\n };\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 private shouldSetFocus(): boolean {\n if (!this.props.setFocus)\n return false;\n\n const record = this.props.propertyRecord as PropertyRecord;\n const disabled = (record && !record.isDisabled) ? false : true;\n const readonly = (record && !record.isReadonly) ? false : true;\n\n return (!disabled && !readonly);\n }\n\n private _applyUpdatedValue(userInput: string) {\n const record = this.props.propertyRecord as PropertyRecord;\n const readonly = (record && !record.isReadonly) ? false : true;\n const disabled = (record && !record.isDisabled) ? false : true;\n\n if (readonly || disabled)\n return;\n\n // istanbul ignore else\n if (this._isMounted)\n this.setState({\n inputValue: userInput,\n });\n }\n\n private _updateInputValue = (e: React.ChangeEvent<HTMLInputElement>) => {\n this._applyUpdatedValue(e.target.value);\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 _getInitialDisplayValue(): string {\n const record = this.props.propertyRecord;\n let initialDisplayValue = \"\";\n let numberValue = 0;\n // istanbul ignore else\n if (record) {\n // istanbul ignore else\n if (record.value.valueFormat === PropertyValueFormat.Primitive) {\n const primitiveValue = record.value;\n numberValue = (undefined !== primitiveValue.value) ? primitiveValue.value as number : /* istanbul ignore next */ 0;\n // istanbul ignore else\n if (primitiveValue.displayValue)\n initialDisplayValue = primitiveValue.displayValue;\n else\n initialDisplayValue = (this._formatParams as CustomFormattedNumberParams).formatFunction(numberValue);\n }\n }\n\n return initialDisplayValue;\n }\n\n private async setStateFromProps() {\n const record = this.props.propertyRecord;\n // istanbul ignore next\n if (!record || !record.property) {\n Logger.logError(UiComponents.loggerCategory(this), \"PropertyRecord must be defined to use CustomNumberPropertyEditor\");\n // eslint-disable-next-line no-console\n // console.log(\"PropertyRecord must be defined to use CustomNumberPropertyEditor\");\n return;\n }\n // istanbul ignore else\n if (record.property && record.property.editor && record.property.editor.params) {\n this._formatParams = record.property.editor.params.find((param: PropertyEditorParams) => param.type === PropertyEditorParamTypes.CustomFormattedNumber) as CustomFormattedNumberParams;\n }\n\n if (!this._formatParams) {\n Logger.logError(UiComponents.loggerCategory(this), `CustomFormattedNumberParams must be defined for property ${record.property.name}`);\n // eslint-disable-next-line no-console\n // console.log(`CustomFormattedNumberParams must be defined for property ${record!.property!.name}`);\n return;\n }\n\n const initialDisplayValue = this._getInitialDisplayValue();\n this._lastValidValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: (record.value as PrimitiveValue).value,\n displayValue: initialDisplayValue,\n };\n let size: number | undefined;\n let maxLength: number | undefined;\n let iconSpec: string | undefined;\n\n // istanbul ignore else\n if (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 // istanbul ignore else\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 iconParams = record.property.editor.params.find((param: PropertyEditorParams) => param.type === PropertyEditorParamTypes.Icon) as IconEditorParams;\n if (iconParams) {\n iconSpec = iconParams.definition.iconSpec;\n }\n }\n\n // istanbul ignore else\n if (this._isMounted)\n this.setState({ inputValue: initialDisplayValue, size, maxLength, iconSpec });\n }\n\n private _resetToLastValidDisplayValue() {\n const initialDisplayValue = (this._lastValidValue && (this._lastValidValue as PrimitiveValue).displayValue) ?? (/* istanbul ignore next */ this._getInitialDisplayValue());\n this.setState({ inputValue: initialDisplayValue });\n }\n\n private _onKeyPress = (e: React.KeyboardEvent<HTMLInputElement>) => {\n // istanbul ignore else\n if (e.key === SpecialKey.Escape) {\n const initialDisplayValue = (this._lastValidValue && (this._lastValidValue as PrimitiveValue).displayValue) ?? (/* istanbul ignore next */ this._getInitialDisplayValue());\n if (initialDisplayValue !== this.state.inputValue) {\n e.preventDefault();\n e.stopPropagation();\n this._resetToLastValidDisplayValue();\n } else {\n // istanbul ignore else\n if (this.props.onCancel)\n this.props.onCancel();\n }\n }\n\n // istanbul ignore else\n if (e.key !== SpecialKey.Enter) {\n UiAdmin.messagePresenter.closeInputFieldMessage();\n }\n };\n\n // istanbul ignore next\n private _onFocus = (e: React.FocusEvent<HTMLInputElement>) => {\n e.target.select();\n };\n\n /** @internal */\n public override render(): React.ReactNode {\n const minSize = this.state.size ? this.state.size : 8;\n const minWidthStyle: React.CSSProperties = {\n minWidth: `${minSize * 0.75}em`,\n };\n const record = this.props.propertyRecord as PropertyRecord;\n if (!record || !this._formatParams)\n return null;\n\n const readOnly = !record.isReadonly ? false : true;\n const disabled = !record.isDisabled ? false : true;\n\n const className = classnames(\"components-cell-editor\", \"components-customnumber-editor\", this.props.className);\n\n const inputProps: Omit<InputProps, \"size\"> = { // eslint-disable-line deprecation/deprecation\n className,\n style: this.props.style ? this.props.style : minWidthStyle,\n readOnly,\n disabled,\n maxLength: this.state.maxLength,\n value: this.state.inputValue,\n onChange: this._updateInputValue,\n onBlur: this.props.onBlur,\n onFocus: this._onFocus,\n setFocus: this.shouldSetFocus(),\n onKeyDown: this._onKeyPress,\n };\n\n let reactNode: React.ReactNode;\n if (this.state.iconSpec) {\n const icon = <Icon iconSpec={this.state.iconSpec} />;\n reactNode = (\n <IconInput\n {...inputProps}\n ref={this._inputElement}\n icon={icon}\n data-testid=\"components-customnumber-editor\"\n />\n );\n } else {\n // NEEDSWORK: still using core-react Input component because of `nativeKeyHandler` prop\n reactNode = (\n <Input\n {...inputProps}\n ref={this._inputElement}\n data-testid=\"components-customnumber-editor\"\n size=\"small\"\n />\n );\n }\n\n return reactNode;\n }\n}\n\n/** Custom Property Editor registered for the \"number\" type name and the \"number-custom\" editor name.\n * It uses the [[CustomNumberEditor]] React component.\n * @alpha\n */\nexport class CustomNumberPropertyEditor extends PropertyEditorBase {\n public get reactNode(): React.ReactNode {\n return <CustomNumberEditor />;\n }\n public override get containerHandlesEscape(): boolean {\n return false;\n }\n}\nPropertyEditorManager.registerEditor(StandardTypeNames.Number, CustomNumberPropertyEditor, StandardEditorNames.NumberCustom);\n"]}
|
|
@@ -138,7 +138,6 @@ export class DateTimeEditor extends React.PureComponent {
|
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
async setStateFromProps() {
|
|
141
|
-
var _a, _b;
|
|
142
141
|
const record = this.props.propertyRecord;
|
|
143
142
|
let initialValue;
|
|
144
143
|
let typeConverter;
|
|
@@ -157,8 +156,8 @@ export class DateTimeEditor extends React.PureComponent {
|
|
|
157
156
|
initialValue = new Date(record.value.value);
|
|
158
157
|
else if (record.value.value === undefined)
|
|
159
158
|
initialValue = new Date();
|
|
160
|
-
typeConverter = TypeConverterManager.getConverter(record.property.typename,
|
|
161
|
-
const options =
|
|
159
|
+
typeConverter = TypeConverterManager.getConverter(record.property.typename, record.property.converter?.name);
|
|
160
|
+
const options = record.property.converter?.options;
|
|
162
161
|
if (options) {
|
|
163
162
|
// istanbul ignore else
|
|
164
163
|
if ("alternateDateFormat" in options) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateTimeEditor.js","sourceRoot":"","sources":["../../../../src/components-react/editors/DateTimeEditor.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,uBAAuB,CAAC;AAC/B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KA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AAgB;oCAC7B,oBAAC,IAAI,IAAC,OAAO,EAAC,MAAM,EAAC,SAAS,EAAC,YAAY,IAAE,MAAM,CAAQ;oCAC3D,oBAAC,SAAS,IAAC,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,YAAY,EAAE,IAAI,CAAC,iBAAiB,GAAI,CACpG,CAEJ,CACL;oBACH,oBAAC,oBAAoB,IAAC,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE,QAAQ,EAAE,IAAI,CAAC,aAAa,GAAI,CAC/D,CACH,CACV,CACP,CAAC;IACJ,CAAC;CACF;AAED;;;IAGI;AACJ,MAAM,OAAO,2BAA4B,SAAQ,kBAAkB;IACjE,IAAW,SAAS;QAClB,OAAO,oBAAC,cAAc,IAAC,QAAQ,EAAE,KAAK,GAAI,CAAC;IAC7C,CAAC;IACD,uBAAuB;IACvB,IAAoB,mBAAmB;QACrC,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAED;;;IAGI;AACJ,MAAM,OAAO,sBAAuB,SAAQ,kBAAkB;IAC5D,IAAW,SAAS;QAClB,OAAO,oBAAC,cAAc,IAAC,QAAQ,EAAE,IAAI,GAAI,CAAC;IAC5C,CAAC;IACD,uBAAuB;IACvB,IAAoB,mBAAmB;QACrC,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAED,qBAAqB,CAAC,cAAc,CAAC,iBAAiB,CAAC,SAAS,EAAE,2BAA2B,CAAC,CAAC;AAC/F,qBAAqB,CAAC,cAAc,CAAC,iBAAiB,CAAC,QAAQ,EAAE,sBAAsB,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 \"./DateTimeEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport {\n AlternateDateFormats, PropertyValue, PropertyValueFormat, StandardTypeNames, TimeDisplay,\n} from \"@itwin/appui-abstract\";\nimport { PropertyEditorProps, TypeEditor } from \"./EditorContainer\";\nimport { PropertyEditorBase, PropertyEditorManager } from \"./PropertyEditorManager\";\nimport { PopupButton, PopupContent, PopupOkCancelButtons } from \"./PopupButton\";\nimport { TimeField, TimeSpec } from \"../datepicker/TimeField\";\nimport { TypeConverter } from \"../converters/TypeConverter\";\nimport { DatePicker } from \"../datepicker/DatePicker\";\nimport { TypeConverterManager } from \"../converters/TypeConverterManager\";\nimport { DateTimeTypeConverterBase } from \"../converters/DateTimeTypeConverter\";\nimport { Text } from \"@itwin/itwinui-react\";\nimport { adjustDateToTimezone } from \"../common/DateUtils\";\n\n// cSpell:ignore datepicker\n\n/** @internal */\ninterface DateTimeEditorState {\n value: Date;\n displayValue?: string;\n timeDisplay?: TimeDisplay;\n isDisabled?: boolean;\n typeConverter?: TypeConverter;\n editInUtc: boolean;\n}\n\n/** @internal */\ninterface DateTimeEditorProps extends PropertyEditorProps {\n showTime?: boolean;\n}\n\n/** DateTimeEditor React component that is a property editor for selection of date and time.\n * @internal\n */\nexport class DateTimeEditor extends React.PureComponent<DateTimeEditorProps, DateTimeEditorState> implements TypeEditor {\n private _isMounted = false;\n private _enterKey = false;\n private _divElement = React.createRef<HTMLDivElement>();\n\n /** @internal */\n public override readonly state: Readonly<DateTimeEditorState> = {\n value: new Date(),\n editInUtc: 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: this.state.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.htmlElement)\n containsFocus = this.htmlElement.contains(document.activeElement);\n return containsFocus;\n }\n\n public async processDateChange(typeConverter: TypeConverter, newValue: Date): Promise<void> {\n // istanbul ignore else\n if (this.props.propertyRecord) {\n const displayValue = await typeConverter.convertPropertyToString(this.props.propertyRecord.property, newValue);\n this.setState({\n value: newValue,\n displayValue,\n });\n }\n }\n\n private _handleChange = (newValue: Date): void => {\n // istanbul ignore else\n if (this._isMounted && this.state.typeConverter) {\n // istanbul ignore else\n if (this.state.editInUtc) {\n newValue = adjustDateToTimezone(newValue, newValue.getTimezoneOffset() * -1);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.processDateChange(this.state.typeConverter, newValue);\n }\n };\n\n private _handleTimeChange = (time: TimeSpec): void => {\n // Combine new time into selected Date\n if (this.state.editInUtc) {\n const newWorkingDate = adjustDateToTimezone(this.state.value, 0);\n newWorkingDate.setUTCHours(time.hours, time.minutes, time.seconds);\n this._handleChange(newWorkingDate);\n } else {\n const newWorkingDate = new Date(this.state.value.getTime());\n newWorkingDate.setHours(time.hours, time.minutes, time.seconds);\n this._handleChange(newWorkingDate);\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: Date | undefined;\n let typeConverter: TypeConverter | undefined;\n let timeDisplay: TimeDisplay | undefined;\n let alternateDateFormat = AlternateDateFormats.None;\n let editInUtc = false;\n\n // istanbul ignore else\n if (this.props.showTime)\n timeDisplay = TimeDisplay.H12MC;\n\n // istanbul ignore else\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n // istanbul ignore else\n if (record.value.value instanceof Date)\n initialValue = new Date(record.value.value);\n else if (typeof record.value.value === \"string\")\n initialValue = new Date(record.value.value);\n else if (record.value.value === undefined)\n initialValue = new Date();\n\n typeConverter = TypeConverterManager.getConverter(record.property.typename, record.property.converter?.name);\n\n const options = record.property.converter?.options;\n if (options) {\n // istanbul ignore else\n if (\"alternateDateFormat\" in options) {\n // istanbul ignore else\n if (DateTimeTypeConverterBase.isAlternateDateFormats(options.alternateDateFormat)) {\n timeDisplay = TimeDisplay.H24MS;\n alternateDateFormat = options.alternateDateFormat;\n }\n }\n\n if (\"timeDisplay\" in options && this.props.showTime) {\n timeDisplay = options.timeDisplay;\n // use 24 hr time display if alternateDateFormat is defined\n // istanbul ignore next\n if (alternateDateFormat && timeDisplay !== TimeDisplay.H24MS && timeDisplay !== TimeDisplay.H24M)\n timeDisplay = TimeDisplay.H24MS;\n }\n\n // istanbul ignore else\n if (alternateDateFormat) {\n editInUtc = true;\n\n if (this.props.showTime) {\n if (alternateDateFormat === AlternateDateFormats.IsoShort) {\n alternateDateFormat = AlternateDateFormats.IsoDateTime;\n }\n if (alternateDateFormat === AlternateDateFormats.UtcShort) {\n alternateDateFormat = AlternateDateFormats.UtcDateTime;\n }\n if (alternateDateFormat === AlternateDateFormats.UtcShortWithDay) {\n alternateDateFormat = AlternateDateFormats.UtcDateTimeWithDay;\n }\n } else {\n timeDisplay = undefined;\n if (alternateDateFormat === AlternateDateFormats.IsoDateTime)\n alternateDateFormat = AlternateDateFormats.IsoShort;\n if (alternateDateFormat === AlternateDateFormats.UtcDateTime)\n alternateDateFormat = AlternateDateFormats.UtcShort;\n if (alternateDateFormat === AlternateDateFormats.UtcDateTimeWithDay)\n alternateDateFormat = AlternateDateFormats.UtcShortWithDay;\n }\n }\n }\n }\n\n // istanbul ignore next\n if (!initialValue) {\n throw new Error(\"Bad Value\");\n }\n\n // istanbul ignore next\n if (!typeConverter) {\n throw new Error(\"Unable to determine TypeConverter\");\n }\n\n const isDisabled = record && !!record.isDisabled;\n const displayValue = await typeConverter.convertPropertyToString(record!.property, initialValue);\n\n // istanbul ignore else\n if (this._isMounted)\n this.setState({\n value: initialValue,\n isDisabled,\n timeDisplay,\n typeConverter,\n displayValue,\n editInUtc,\n });\n }\n\n private _handleEnter = async (): Promise<void> => {\n this._enterKey = true;\n await this._handleCommit();\n };\n\n private _handleClose = async (): Promise<void> => {\n if (this._enterKey) {\n this._enterKey = false;\n } else {\n // istanbul ignore next\n if (this.props.onCancel)\n this.props.onCancel();\n }\n };\n\n private _handleOk = async (_event: React.MouseEvent): Promise<void> => {\n await this._handleCommit();\n };\n\n private _handleCancel = (_event: React.MouseEvent): void => {\n // istanbul ignore else\n if (this.props.onCancel) {\n this.props.onCancel();\n }\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 /** @internal */\n public override render(): React.ReactNode {\n const date = this.state.editInUtc ? adjustDateToTimezone(this.state.value, 0) : this.state.value;\n const timeSpec: TimeSpec = {\n hours: date.getHours(),\n minutes: date.getMinutes(),\n seconds: date.getSeconds(),\n };\n\n const className = classnames(\"components-cell-editor\", \"components-datetime-editor\", this.props.className);\n\n return (\n <div className={className} ref={this._divElement}>\n <PopupButton label={this.state.displayValue} onClose={this._handleClose} onEnter={this._handleEnter}\n setFocus={this.props.setFocus}>\n <PopupContent>\n <>\n <div className=\"components-date-picker-calendar-popup-panel\" data-testid=\"components-date-picker-calendar-popup-panel\">\n <DatePicker selected={date} onDateChange={this._handleChange} showFocusOutline={false} />\n {this.state.timeDisplay &&\n <div className=\"time-container\">\n <Text variant=\"body\" className=\"time-label\">{\"Time\"}</Text>\n <TimeField time={timeSpec} timeDisplay={this.state.timeDisplay} onTimeChange={this._handleTimeChange} />\n </div>\n }\n </div>\n </>\n <PopupOkCancelButtons onOk={this._handleOk} onCancel={this._handleCancel} />\n </PopupContent>\n </PopupButton>\n </div>\n );\n }\n}\n\n/** DateTime Property Editor registered for the \"number\" type name and \"DateTime\" editor name.\n * It uses the [[DateTimeEditor]] React component.\n * @internal\n */\nexport class ShortDateTimePropertyEditor extends PropertyEditorBase {\n public get reactNode(): React.ReactNode {\n return <DateTimeEditor showTime={false} />;\n }\n // istanbul ignore next\n public override get containerHandlesTab(): boolean {\n return false;\n }\n}\n\n/** DateTime Property Editor registered for the \"number\" type name and \"DateTime\" editor name.\n * It uses the [[DateTimeEditor]] React component.\n * @internal\n */\nexport class DateTimePropertyEditor extends PropertyEditorBase {\n public get reactNode(): React.ReactNode {\n return <DateTimeEditor showTime={true} />;\n }\n // istanbul ignore next\n public override get containerHandlesTab(): boolean {\n return false;\n }\n}\n\nPropertyEditorManager.registerEditor(StandardTypeNames.ShortDate, ShortDateTimePropertyEditor);\nPropertyEditorManager.registerEditor(StandardTypeNames.DateTime, DateTimePropertyEditor);\n"]}
|
|
1
|
+
{"version":3,"file":"DateTimeEditor.js","sourceRoot":"","sources":["../../../../src/components-react/editors/DateTimeEditor.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,uBAAuB,CAAC;AAC/B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,oBAAoB,EAAiB,mBAAmB,EAAE,iBAAiB,EAAE,WAAW,GACzF,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACpF,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,SAAS,EAAY,MAAM,yBAAyB,CAAC;AAE9D,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,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ACP,CAAC;IACJ,CAAC;CACF;AAED;;;IAGI;AACJ,MAAM,OAAO,2BAA4B,SAAQ,kBAAkB;IACjE,IAAW,SAAS;QAClB,OAAO,oBAAC,cAAc,IAAC,QAAQ,EAAE,KAAK,GAAI,CAAC;IAC7C,CAAC;IACD,uBAAuB;IACvB,IAAoB,mBAAmB;QACrC,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAED;;;IAGI;AACJ,MAAM,OAAO,sBAAuB,SAAQ,kBAAkB;IAC5D,IAAW,SAAS;QAClB,OAAO,oBAAC,cAAc,IAAC,QAAQ,EAAE,IAAI,GAAI,CAAC;IAC5C,CAAC;IACD,uBAAuB;IACvB,IAAoB,mBAAmB;QACrC,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAED,qBAAqB,CAAC,cAAc,CAAC,iBAAiB,CAAC,SAAS,EAAE,2BAA2B,CAAC,CAAC;AAC/F,qBAAqB,CAAC,cAAc,CAAC,iBAAiB,CAAC,QAAQ,EAAE,sBAAsB,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 \"./DateTimeEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport {\n AlternateDateFormats, PropertyValue, PropertyValueFormat, StandardTypeNames, TimeDisplay,\n} from \"@itwin/appui-abstract\";\nimport { PropertyEditorProps, TypeEditor } from \"./EditorContainer\";\nimport { PropertyEditorBase, PropertyEditorManager } from \"./PropertyEditorManager\";\nimport { PopupButton, PopupContent, PopupOkCancelButtons } from \"./PopupButton\";\nimport { TimeField, TimeSpec } from \"../datepicker/TimeField\";\nimport { TypeConverter } from \"../converters/TypeConverter\";\nimport { DatePicker } from \"../datepicker/DatePicker\";\nimport { TypeConverterManager } from \"../converters/TypeConverterManager\";\nimport { DateTimeTypeConverterBase } from \"../converters/DateTimeTypeConverter\";\nimport { Text } from \"@itwin/itwinui-react\";\nimport { adjustDateToTimezone } from \"../common/DateUtils\";\n\n// cSpell:ignore datepicker\n\n/** @internal */\ninterface DateTimeEditorState {\n value: Date;\n displayValue?: string;\n timeDisplay?: TimeDisplay;\n isDisabled?: boolean;\n typeConverter?: TypeConverter;\n editInUtc: boolean;\n}\n\n/** @internal */\ninterface DateTimeEditorProps extends PropertyEditorProps {\n showTime?: boolean;\n}\n\n/** DateTimeEditor React component that is a property editor for selection of date and time.\n * @internal\n */\nexport class DateTimeEditor extends React.PureComponent<DateTimeEditorProps, DateTimeEditorState> implements TypeEditor {\n private _isMounted = false;\n private _enterKey = false;\n private _divElement = React.createRef<HTMLDivElement>();\n\n /** @internal */\n public override readonly state: Readonly<DateTimeEditorState> = {\n value: new Date(),\n editInUtc: 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: this.state.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.htmlElement)\n containsFocus = this.htmlElement.contains(document.activeElement);\n return containsFocus;\n }\n\n public async processDateChange(typeConverter: TypeConverter, newValue: Date): Promise<void> {\n // istanbul ignore else\n if (this.props.propertyRecord) {\n const displayValue = await typeConverter.convertPropertyToString(this.props.propertyRecord.property, newValue);\n this.setState({\n value: newValue,\n displayValue,\n });\n }\n }\n\n private _handleChange = (newValue: Date): void => {\n // istanbul ignore else\n if (this._isMounted && this.state.typeConverter) {\n // istanbul ignore else\n if (this.state.editInUtc) {\n newValue = adjustDateToTimezone(newValue, newValue.getTimezoneOffset() * -1);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.processDateChange(this.state.typeConverter, newValue);\n }\n };\n\n private _handleTimeChange = (time: TimeSpec): void => {\n // Combine new time into selected Date\n if (this.state.editInUtc) {\n const newWorkingDate = adjustDateToTimezone(this.state.value, 0);\n newWorkingDate.setUTCHours(time.hours, time.minutes, time.seconds);\n this._handleChange(newWorkingDate);\n } else {\n const newWorkingDate = new Date(this.state.value.getTime());\n newWorkingDate.setHours(time.hours, time.minutes, time.seconds);\n this._handleChange(newWorkingDate);\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: Date | undefined;\n let typeConverter: TypeConverter | undefined;\n let timeDisplay: TimeDisplay | undefined;\n let alternateDateFormat = AlternateDateFormats.None;\n let editInUtc = false;\n\n // istanbul ignore else\n if (this.props.showTime)\n timeDisplay = TimeDisplay.H12MC;\n\n // istanbul ignore else\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n // istanbul ignore else\n if (record.value.value instanceof Date)\n initialValue = new Date(record.value.value);\n else if (typeof record.value.value === \"string\")\n initialValue = new Date(record.value.value);\n else if (record.value.value === undefined)\n initialValue = new Date();\n\n typeConverter = TypeConverterManager.getConverter(record.property.typename, record.property.converter?.name);\n\n const options = record.property.converter?.options;\n if (options) {\n // istanbul ignore else\n if (\"alternateDateFormat\" in options) {\n // istanbul ignore else\n if (DateTimeTypeConverterBase.isAlternateDateFormats(options.alternateDateFormat)) {\n timeDisplay = TimeDisplay.H24MS;\n alternateDateFormat = options.alternateDateFormat;\n }\n }\n\n if (\"timeDisplay\" in options && this.props.showTime) {\n timeDisplay = options.timeDisplay;\n // use 24 hr time display if alternateDateFormat is defined\n // istanbul ignore next\n if (alternateDateFormat && timeDisplay !== TimeDisplay.H24MS && timeDisplay !== TimeDisplay.H24M)\n timeDisplay = TimeDisplay.H24MS;\n }\n\n // istanbul ignore else\n if (alternateDateFormat) {\n editInUtc = true;\n\n if (this.props.showTime) {\n if (alternateDateFormat === AlternateDateFormats.IsoShort) {\n alternateDateFormat = AlternateDateFormats.IsoDateTime;\n }\n if (alternateDateFormat === AlternateDateFormats.UtcShort) {\n alternateDateFormat = AlternateDateFormats.UtcDateTime;\n }\n if (alternateDateFormat === AlternateDateFormats.UtcShortWithDay) {\n alternateDateFormat = AlternateDateFormats.UtcDateTimeWithDay;\n }\n } else {\n timeDisplay = undefined;\n if (alternateDateFormat === AlternateDateFormats.IsoDateTime)\n alternateDateFormat = AlternateDateFormats.IsoShort;\n if (alternateDateFormat === AlternateDateFormats.UtcDateTime)\n alternateDateFormat = AlternateDateFormats.UtcShort;\n if (alternateDateFormat === AlternateDateFormats.UtcDateTimeWithDay)\n alternateDateFormat = AlternateDateFormats.UtcShortWithDay;\n }\n }\n }\n }\n\n // istanbul ignore next\n if (!initialValue) {\n throw new Error(\"Bad Value\");\n }\n\n // istanbul ignore next\n if (!typeConverter) {\n throw new Error(\"Unable to determine TypeConverter\");\n }\n\n const isDisabled = record && !!record.isDisabled;\n const displayValue = await typeConverter.convertPropertyToString(record!.property, initialValue);\n\n // istanbul ignore else\n if (this._isMounted)\n this.setState({\n value: initialValue,\n isDisabled,\n timeDisplay,\n typeConverter,\n displayValue,\n editInUtc,\n });\n }\n\n private _handleEnter = async (): Promise<void> => {\n this._enterKey = true;\n await this._handleCommit();\n };\n\n private _handleClose = async (): Promise<void> => {\n if (this._enterKey) {\n this._enterKey = false;\n } else {\n // istanbul ignore next\n if (this.props.onCancel)\n this.props.onCancel();\n }\n };\n\n private _handleOk = async (_event: React.MouseEvent): Promise<void> => {\n await this._handleCommit();\n };\n\n private _handleCancel = (_event: React.MouseEvent): void => {\n // istanbul ignore else\n if (this.props.onCancel) {\n this.props.onCancel();\n }\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 /** @internal */\n public override render(): React.ReactNode {\n const date = this.state.editInUtc ? adjustDateToTimezone(this.state.value, 0) : this.state.value;\n const timeSpec: TimeSpec = {\n hours: date.getHours(),\n minutes: date.getMinutes(),\n seconds: date.getSeconds(),\n };\n\n const className = classnames(\"components-cell-editor\", \"components-datetime-editor\", this.props.className);\n\n return (\n <div className={className} ref={this._divElement}>\n <PopupButton label={this.state.displayValue} onClose={this._handleClose} onEnter={this._handleEnter}\n setFocus={this.props.setFocus}>\n <PopupContent>\n <>\n <div className=\"components-date-picker-calendar-popup-panel\" data-testid=\"components-date-picker-calendar-popup-panel\">\n <DatePicker selected={date} onDateChange={this._handleChange} showFocusOutline={false} />\n {this.state.timeDisplay &&\n <div className=\"time-container\">\n <Text variant=\"body\" className=\"time-label\">{\"Time\"}</Text>\n <TimeField time={timeSpec} timeDisplay={this.state.timeDisplay} onTimeChange={this._handleTimeChange} />\n </div>\n }\n </div>\n </>\n <PopupOkCancelButtons onOk={this._handleOk} onCancel={this._handleCancel} />\n </PopupContent>\n </PopupButton>\n </div>\n );\n }\n}\n\n/** DateTime Property Editor registered for the \"number\" type name and \"DateTime\" editor name.\n * It uses the [[DateTimeEditor]] React component.\n * @internal\n */\nexport class ShortDateTimePropertyEditor extends PropertyEditorBase {\n public get reactNode(): React.ReactNode {\n return <DateTimeEditor showTime={false} />;\n }\n // istanbul ignore next\n public override get containerHandlesTab(): boolean {\n return false;\n }\n}\n\n/** DateTime Property Editor registered for the \"number\" type name and \"DateTime\" editor name.\n * It uses the [[DateTimeEditor]] React component.\n * @internal\n */\nexport class DateTimePropertyEditor extends PropertyEditorBase {\n public get reactNode(): React.ReactNode {\n return <DateTimeEditor showTime={true} />;\n }\n // istanbul ignore next\n public override get containerHandlesTab(): boolean {\n return false;\n }\n}\n\nPropertyEditorManager.registerEditor(StandardTypeNames.ShortDate, ShortDateTimePropertyEditor);\nPropertyEditorManager.registerEditor(StandardTypeNames.DateTime, DateTimePropertyEditor);\n"]}
|
|
@@ -53,10 +53,9 @@ export class PopupButton extends React.PureComponent {
|
|
|
53
53
|
}
|
|
54
54
|
/** @internal */
|
|
55
55
|
render() {
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
const
|
|
59
|
-
const moveFocus = (_c = this.props.moveFocus) !== null && _c !== void 0 ? _c : true;
|
|
56
|
+
const showArrow = this.props.showArrow ?? false;
|
|
57
|
+
const showShadow = this.props.showShadow ?? false;
|
|
58
|
+
const moveFocus = this.props.moveFocus ?? true;
|
|
60
59
|
const showPlaceholder = this.props.label === undefined && this.props.placeholder !== undefined;
|
|
61
60
|
const classNames = classnames("components-popup-button", this.state.showPopup && "components-popup-expanded");
|
|
62
61
|
const valueClassNames = classnames("components-popup-button-value", showPlaceholder && "components-popup-button-placeholder");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PopupButton.js","sourceRoot":"","sources":["../../../../src/components-react/editors/PopupButton.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,oBAAoB,CAAC;AAC5B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAA+B,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC1F,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;A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AAE,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,EACpC,OAAO,EAAE,KAAK,CAAC,IAAI;YAEnB,oBAAC,IAAI,IAAC,QAAQ,EAAE,oBAAC,YAAY,OAAG,GAAI,CAC7B;QACT,oBAAC,MAAM,IACL,SAAS,EAAE,UAAU,CAAC,+BAA+B,EAAE,gCAAgC,CAAC,iBAC5E,gCAAgC,EAC5C,KAAK,EAAE,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC,EACxC,OAAO,EAAE,KAAK,CAAC,QAAQ;YAEvB,oBAAC,IAAI,IAAC,QAAQ,EAAE,oBAAC,SAAS,OAAG,GAAI,CAC1B,CACL,CACP,CAAC;AACJ,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 \"./PopupButton.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { RelativePosition, SpecialKey } from \"@itwin/appui-abstract\";\nimport { CommonDivProps, CommonProps, Div, Icon, Popup, UiCore } from \"@itwin/core-react\";\nimport { Button } from \"@itwin/itwinui-react\";\nimport { SvgCheckmark, SvgChevronDown, SvgRemove } from \"@itwin/itwinui-icons-react\";\n\n/** Properties for [[PopupButton]] component\n * @alpha\n */\nexport interface PopupButtonProps extends CommonProps {\n /** Label to display in click area. */\n label?: string | React.ReactNode;\n /* Placeholder text used when there is no label yet */\n placeholder?: string;\n /** Contents of the popup */\n children: React.ReactNode;\n /** Title to display as tooltip. */\n title?: string;\n\n /** Set focus to popup - default is to set focus */\n moveFocus?: boolean;\n /** Element to receive focus, specified by React.RefObject or CSS selector string. If undefined and moveFocus is true then focus is moved to first focusable element. */\n focusTarget?: React.RefObject<HTMLElement> | string;\n\n /** Show or hide the box shadow (defaults to false) */\n showShadow?: boolean;\n /** Show or hide the arrow (defaults to false) */\n showArrow?: boolean;\n /** Indicates whether to set focus to the input element */\n setFocus?: boolean;\n /** Indicates whether to close the popup when Enter is pressed (defaults to true) */\n closeOnEnter?: boolean;\n\n /** Listens for click events on button area */\n onClick?: (event: React.MouseEvent) => void;\n /** Listens for popup close events */\n onClose?: () => void;\n /** Listens for Enter key in popup */\n onEnter?: () => void;\n}\n\n/** @internal */\ninterface PopupButtonState {\n showPopup: boolean;\n}\n\n/** PopupButton React component that is a button and property editor popup host\n * @alpha\n */\nexport class PopupButton extends React.PureComponent<PopupButtonProps, PopupButtonState> {\n private _buttonRef = React.createRef<HTMLDivElement>();\n\n /** @internal */\n public override readonly state: Readonly<PopupButtonState> = {\n showPopup: false,\n };\n\n /** @internal */\n public override componentDidMount() {\n if (this.props.setFocus && this._buttonRef.current)\n this._buttonRef.current.focus();\n }\n\n private _togglePopup = (event: React.MouseEvent) => {\n this.setState(\n (prevState) => ({ showPopup: !prevState.showPopup }),\n () => this.props.onClick && this.props.onClick(event));\n };\n\n public closePopup() {\n this._closePopup();\n }\n\n private _closePopup = () => {\n this.setState(\n { showPopup: false },\n () => {\n this.props.onClose && this.props.onClose();\n\n // istanbul ignore else\n if (this._buttonRef.current)\n this._buttonRef.current.focus();\n });\n };\n\n private _handleKeyDown = (event: React.KeyboardEvent) => {\n // istanbul ignore else\n if ((event.key === SpecialKey.ArrowDown || event.key === SpecialKey.Space || event.key === SpecialKey.Enter) && !this.state.showPopup) {\n event.preventDefault();\n event.stopPropagation();\n this.setState({ showPopup: true });\n }\n };\n\n /** @internal */\n public override render(): React.ReactNode {\n const showArrow = this.props.showArrow ?? false;\n const showShadow = this.props.showShadow ?? false;\n const moveFocus = this.props.moveFocus ?? true;\n const showPlaceholder = this.props.label === undefined && this.props.placeholder !== undefined;\n\n const classNames = classnames(\n \"components-popup-button\",\n this.state.showPopup && \"components-popup-expanded\",\n );\n\n const valueClassNames = classnames(\n \"components-popup-button-value\",\n showPlaceholder && \"components-popup-button-placeholder\",\n );\n\n return (\n <div className={this.props.className}>\n <div className={classNames}\n onClick={this._togglePopup}\n onKeyDown={this._handleKeyDown}\n data-testid=\"components-popup-button\"\n tabIndex={0}\n ref={this._buttonRef}\n title={this.props.title}\n role=\"button\"\n >\n <div className={valueClassNames}>\n {this.props.label || this.props.placeholder}\n </div>\n <div className={\"components-popup-button-arrow\"}>\n <div className={classnames(\"components-popup-button-arrow-icon\", \"icon\")}><Icon iconSpec={<SvgChevronDown />} /></div>\n </div>\n </div>\n <Popup className=\"components-popup-button-popup\" isOpen={this.state.showPopup} position={RelativePosition.Bottom}\n onClose={this._closePopup} onEnter={this.props.onEnter} closeOnEnter={this.props.closeOnEnter} target={this._buttonRef.current}\n showArrow={showArrow} showShadow={showShadow}\n moveFocus={moveFocus} focusTarget={this.props.focusTarget}\n >\n {this.props.children}\n </Popup>\n </div>\n\n );\n }\n}\n\n/** Popup content with padding\n * @alpha\n */\nexport function PopupContent(props: CommonDivProps) {\n return <Div {...props} mainClassName=\"components-editor-popup-content\" />;\n}\n\n/** Properties for [[PopupOkCancelButtons]] component\n * @alpha\n */\nexport interface OkCancelProps {\n onOk: (event: React.MouseEvent) => void;\n onCancel: (event: React.MouseEvent) => void;\n}\n\n/** OK/Cancel Buttons\n * @alpha\n */\nexport function PopupOkCancelButtons(props: OkCancelProps) {\n return (\n <div className=\"components-popup-bottom-buttons\">\n <Button\n className={classnames(\"components-popup-large-button\", \"components-popup-ok-button\")}\n data-testid=\"components-popup-ok-button\"\n styleType=\"cta\"\n title={UiCore.translate(\"dialog.ok\")}\n onClick={props.onOk}\n >\n <Icon iconSpec={<SvgCheckmark />} />\n </Button>\n <Button\n className={classnames(\"components-popup-large-button\", \"components-popup-cancel-button\")}\n data-testid=\"components-popup-cancel-button\"\n title={UiCore.translate(\"dialog.cancel\")}\n onClick={props.onCancel}\n >\n <Icon iconSpec={<SvgRemove />} />\n </Button>\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"PopupButton.js","sourceRoot":"","sources":["../../../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;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,KAAqB;IAChD,OAAO,oBAAC,GAAG,OAAK,KAAK,EAAE,aAAa,EAAC,iCAAiC,GAAG,CAAC;AAC5E,CAAC;AAUD;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAoB;IACvD,OAAO,CACL,6BAAK,SAAS,EAAC,iCAAiC;QAC9C,oBAAC,MAAM,IACL,SAAS,EAAE,UAAU,CAAC,+BAA+B,EAAE,4BAA4B,CAAC,iBACxE,4BAA4B,EACxC,SAAS,EAAC,KAAK,EACf,KAAK,EAAE,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,EACpC,OAAO,EAAE,KAAK,CAAC,IAAI;YAEnB,oBAAC,IAAI,IAAC,QAAQ,EAAE,oBAAC,YAAY,OAAG,GAAI,CAC7B;QACT,oBAAC,MAAM,IACL,SAAS,EAAE,UAAU,CAAC,+BAA+B,EAAE,gCAAgC,CAAC,iBAC5E,gCAAgC,EAC5C,KAAK,EAAE,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC,EACxC,OAAO,EAAE,KAAK,CAAC,QAAQ;YAEvB,oBAAC,IAAI,IAAC,QAAQ,EAAE,oBAAC,SAAS,OAAG,GAAI,CAC1B,CACL,CACP,CAAC;AACJ,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 \"./PopupButton.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { RelativePosition, SpecialKey } from \"@itwin/appui-abstract\";\nimport { CommonDivProps, CommonProps, Div, Icon, Popup, UiCore } from \"@itwin/core-react\";\nimport { Button } from \"@itwin/itwinui-react\";\nimport { SvgCheckmark, SvgChevronDown, SvgRemove } from \"@itwin/itwinui-icons-react\";\n\n/** Properties for [[PopupButton]] component\n * @alpha\n */\nexport interface PopupButtonProps extends CommonProps {\n /** Label to display in click area. */\n label?: string | React.ReactNode;\n /* Placeholder text used when there is no label yet */\n placeholder?: string;\n /** Contents of the popup */\n children: React.ReactNode;\n /** Title to display as tooltip. */\n title?: string;\n\n /** Set focus to popup - default is to set focus */\n moveFocus?: boolean;\n /** Element to receive focus, specified by React.RefObject or CSS selector string. If undefined and moveFocus is true then focus is moved to first focusable element. */\n focusTarget?: React.RefObject<HTMLElement> | string;\n\n /** Show or hide the box shadow (defaults to false) */\n showShadow?: boolean;\n /** Show or hide the arrow (defaults to false) */\n showArrow?: boolean;\n /** Indicates whether to set focus to the input element */\n setFocus?: boolean;\n /** Indicates whether to close the popup when Enter is pressed (defaults to true) */\n closeOnEnter?: boolean;\n\n /** Listens for click events on button area */\n onClick?: (event: React.MouseEvent) => void;\n /** Listens for popup close events */\n onClose?: () => void;\n /** Listens for Enter key in popup */\n onEnter?: () => void;\n}\n\n/** @internal */\ninterface PopupButtonState {\n showPopup: boolean;\n}\n\n/** PopupButton React component that is a button and property editor popup host\n * @alpha\n */\nexport class PopupButton extends React.PureComponent<PopupButtonProps, PopupButtonState> {\n private _buttonRef = React.createRef<HTMLDivElement>();\n\n /** @internal */\n public override readonly state: Readonly<PopupButtonState> = {\n showPopup: false,\n };\n\n /** @internal */\n public override componentDidMount() {\n if (this.props.setFocus && this._buttonRef.current)\n this._buttonRef.current.focus();\n }\n\n private _togglePopup = (event: React.MouseEvent) => {\n this.setState(\n (prevState) => ({ showPopup: !prevState.showPopup }),\n () => this.props.onClick && this.props.onClick(event));\n };\n\n public closePopup() {\n this._closePopup();\n }\n\n private _closePopup = () => {\n this.setState(\n { showPopup: false },\n () => {\n this.props.onClose && this.props.onClose();\n\n // istanbul ignore else\n if (this._buttonRef.current)\n this._buttonRef.current.focus();\n });\n };\n\n private _handleKeyDown = (event: React.KeyboardEvent) => {\n // istanbul ignore else\n if ((event.key === SpecialKey.ArrowDown || event.key === SpecialKey.Space || event.key === SpecialKey.Enter) && !this.state.showPopup) {\n event.preventDefault();\n event.stopPropagation();\n this.setState({ showPopup: true });\n }\n };\n\n /** @internal */\n public override render(): React.ReactNode {\n const showArrow = this.props.showArrow ?? false;\n const showShadow = this.props.showShadow ?? false;\n const moveFocus = this.props.moveFocus ?? true;\n const showPlaceholder = this.props.label === undefined && this.props.placeholder !== undefined;\n\n const classNames = classnames(\n \"components-popup-button\",\n this.state.showPopup && \"components-popup-expanded\",\n );\n\n const valueClassNames = classnames(\n \"components-popup-button-value\",\n showPlaceholder && \"components-popup-button-placeholder\",\n );\n\n return (\n <div className={this.props.className}>\n <div className={classNames}\n onClick={this._togglePopup}\n onKeyDown={this._handleKeyDown}\n data-testid=\"components-popup-button\"\n tabIndex={0}\n ref={this._buttonRef}\n title={this.props.title}\n role=\"button\"\n >\n <div className={valueClassNames}>\n {this.props.label || this.props.placeholder}\n </div>\n <div className={\"components-popup-button-arrow\"}>\n <div className={classnames(\"components-popup-button-arrow-icon\", \"icon\")}><Icon iconSpec={<SvgChevronDown />} /></div>\n </div>\n </div>\n <Popup className=\"components-popup-button-popup\" isOpen={this.state.showPopup} position={RelativePosition.Bottom}\n onClose={this._closePopup} onEnter={this.props.onEnter} closeOnEnter={this.props.closeOnEnter} target={this._buttonRef.current}\n showArrow={showArrow} showShadow={showShadow}\n moveFocus={moveFocus} focusTarget={this.props.focusTarget}\n >\n {this.props.children}\n </Popup>\n </div>\n\n );\n }\n}\n\n/** Popup content with padding\n * @alpha\n */\nexport function PopupContent(props: CommonDivProps) {\n return <Div {...props} mainClassName=\"components-editor-popup-content\" />;\n}\n\n/** Properties for [[PopupOkCancelButtons]] component\n * @alpha\n */\nexport interface OkCancelProps {\n onOk: (event: React.MouseEvent) => void;\n onCancel: (event: React.MouseEvent) => void;\n}\n\n/** OK/Cancel Buttons\n * @alpha\n */\nexport function PopupOkCancelButtons(props: OkCancelProps) {\n return (\n <div className=\"components-popup-bottom-buttons\">\n <Button\n className={classnames(\"components-popup-large-button\", \"components-popup-ok-button\")}\n data-testid=\"components-popup-ok-button\"\n styleType=\"cta\"\n title={UiCore.translate(\"dialog.ok\")}\n onClick={props.onOk}\n >\n <Icon iconSpec={<SvgCheckmark />} />\n </Button>\n <Button\n className={classnames(\"components-popup-large-button\", \"components-popup-cancel-button\")}\n data-testid=\"components-popup-cancel-button\"\n title={UiCore.translate(\"dialog.cancel\")}\n onClick={props.onCancel}\n >\n <Icon iconSpec={<SvgRemove />} />\n </Button>\n </div>\n );\n}\n"]}
|
|
@@ -43,12 +43,11 @@ export class TextEditor extends React.PureComponent {
|
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
45
|
async getPropertyValue() {
|
|
46
|
-
var _a;
|
|
47
46
|
const record = this.props.propertyRecord;
|
|
48
47
|
let propertyValue;
|
|
49
48
|
// istanbul ignore else
|
|
50
49
|
if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {
|
|
51
|
-
propertyValue = await TypeConverterManager.getConverter(record.property.typename,
|
|
50
|
+
propertyValue = await TypeConverterManager.getConverter(record.property.typename, record.property.converter?.name).convertFromStringToPropertyValue(this.state.inputValue, record);
|
|
52
51
|
propertyValue.displayValue = this.state.inputValue;
|
|
53
52
|
}
|
|
54
53
|
return propertyValue;
|
|
@@ -75,13 +74,12 @@ export class TextEditor extends React.PureComponent {
|
|
|
75
74
|
}
|
|
76
75
|
}
|
|
77
76
|
async setStateFromProps() {
|
|
78
|
-
var _a;
|
|
79
77
|
const record = this.props.propertyRecord;
|
|
80
78
|
let initialValue = "";
|
|
81
79
|
// istanbul ignore else
|
|
82
80
|
if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {
|
|
83
81
|
const value = record.value.value;
|
|
84
|
-
initialValue = await TypeConverterManager.getConverter(record.property.typename,
|
|
82
|
+
initialValue = await TypeConverterManager.getConverter(record.property.typename, record.property.converter?.name).convertPropertyToString(record.property, value);
|
|
85
83
|
}
|
|
86
84
|
const readonly = record && undefined !== record.isReadonly ? record.isReadonly : false;
|
|
87
85
|
let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C,CAAC,aAAa;YAC1D,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ;YAC7B,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU;YAC/B,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS;YAC/B,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU;YAC5B,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM;YACzB,QAAQ,EAAE,IAAI,CAAC,iBAAiB;YAChC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU;SACxD,CAAC;QAEF,UAAU,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC;QAE3C,IAAI,SAA0B,CAAC;QAC/B,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;YACvB,MAAM,IAAI,GAAG,oBAAC,IAAI,IAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAI,CAAC;YACrD,SAAS,GAAG,CACV,oBAAC,SAAS,OACJ,UAAU,EACd,GAAG,EAAE,IAAI,CAAC,aAAa,EACvB,IAAI,EAAE,IAAI,iBACE,wBAAwB,GACpC,CACH,CAAC;SACH;aAAM;YACL,SAAS,GAAG,CACV,oBAAC,KAAK,OACA,UAAU,EACd,GAAG,EAAE,IAAI,CAAC,aAAa,iBACX,wBAAwB,EACpC,IAAI,EAAC,OAAO,GACZ,CACH,CAAC;SACH;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF","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 \"./TextEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport {\n IconEditorParams, InputEditorSizeParams, PrimitiveValue, PropertyEditorParams, PropertyEditorParamTypes, PropertyValue, PropertyValueFormat,\n} from \"@itwin/appui-abstract\";\nimport { Icon, IconInput } from \"@itwin/core-react\";\nimport { Input, InputProps } from \"@itwin/itwinui-react\";\nimport { TypeConverterManager } from \"../converters/TypeConverterManager\";\nimport { PropertyEditorProps, TypeEditor } from \"./EditorContainer\";\nimport { UiComponents } from \"../UiComponents\";\n\n/** @internal */\ninterface TextEditorState {\n inputValue: string;\n readonly: boolean;\n isDisabled?: boolean;\n size?: number;\n maxLength?: number;\n iconSpec?: string;\n}\n\n/** TextEditor React component that is a property editor with text input\n * @public\n */\nexport class TextEditor extends React.PureComponent<PropertyEditorProps, TextEditorState> implements TypeEditor {\n private _isMounted = false;\n private _ariaLabel = UiComponents.translate(\"editor.text\");\n private _inputElement = React.createRef<HTMLInputElement>();\n\n /** @internal */\n public override readonly state: Readonly<TextEditorState> = {\n inputValue: \"\",\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 = await TypeConverterManager.getConverter(record.property.typename, record.property.converter?.name).convertFromStringToPropertyValue(this.state.inputValue, record);\n (propertyValue as PrimitiveValue).displayValue = this.state.inputValue;\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 private _updateInputValue = (e: React.ChangeEvent<HTMLInputElement>) => {\n // istanbul ignore else\n if (this._isMounted)\n this.setState({\n inputValue: e.target.value,\n }, async () => {\n if (this.props.shouldCommitOnChange && this.props.onCommit && this.props.propertyRecord) {\n const newValue = await this.getPropertyValue();\n // istanbul ignore else\n if (newValue)\n this.props.onCommit({ propertyRecord: this.props.propertyRecord, newValue });\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 record = this.props.propertyRecord;\n let initialValue = \"\";\n\n // istanbul ignore else\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n const value = record.value.value;\n initialValue = await TypeConverterManager.getConverter(record.property.typename, record.property.converter?.name).convertPropertyToString(record.property, value);\n }\n\n const readonly = record && undefined !== record.isReadonly ? record.isReadonly : false;\n let size: number | undefined;\n let maxLength: number | undefined;\n let iconSpec: string | 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 iconParams = record.property.editor.params.find((param: PropertyEditorParams) => param.type === PropertyEditorParamTypes.Icon) as IconEditorParams;\n if (iconParams) {\n iconSpec = iconParams.definition.iconSpec;\n }\n }\n\n // istanbul ignore else\n if (this._isMounted)\n this.setState({ inputValue: initialValue, readonly, size, maxLength, isDisabled, iconSpec });\n }\n\n /** @internal */\n public override render(): React.ReactNode {\n const className = classnames(\"components-cell-editor\", \"components-text-editor\", this.props.className);\n const minSize = this.state.size ? this.state.size : 8;\n const minWidthStyle: React.CSSProperties = {\n minWidth: `${minSize * 0.75}em`,\n };\n const inputProps: InputProps = {\n type: \"text\",\n className,\n style: this.props.style ? this.props.style : minWidthStyle,\n readOnly: this.state.readonly,\n disabled: this.state.isDisabled,\n maxLength: this.state.maxLength,\n value: this.state.inputValue,\n onBlur: this.props.onBlur,\n onChange: this._updateInputValue,\n setFocus: this.props.setFocus && !this.state.isDisabled,\n };\n\n inputProps[\"aria-label\"] = this._ariaLabel;\n\n let reactNode: React.ReactNode;\n if (this.state.iconSpec) {\n const icon = <Icon iconSpec={this.state.iconSpec} />;\n reactNode = (\n <IconInput\n {...inputProps}\n ref={this._inputElement}\n icon={icon}\n data-testid=\"components-text-editor\"\n />\n );\n } else {\n reactNode = (\n <Input\n {...inputProps}\n ref={this._inputElement}\n data-testid=\"components-text-editor\"\n size=\"small\"\n />\n );\n }\n\n return reactNode;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TextEditor.js","sourceRoot":"","sources":["../../../../src/components-react/editors/TextEditor.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,mBAAmB,CAAC;AAC3B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAC0E,wBAAwB,EAAiB,mBAAmB,GAC5I,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAc,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAE1E,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAY/C;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,KAAK,CAAC,aAAmD;IAAzF;;QACU,eAAU,GAAG,KAAK,CAAC;QACnB,eAAU,GAAG,YAAY,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;QACnD,kBAAa,GAAG,KAAK,CAAC,SAAS,EAAoB,CAAC;QAE5D,gBAAgB;QACS,UAAK,GAA8B;YAC1D,UAAU,EAAE,EAAE;YACd,QAAQ,EAA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AG,EAAE,IAAI,CAAC,aAAa,iBACX,wBAAwB,EACpC,IAAI,EAAC,OAAO,GACZ,CACH,CAAC;SACH;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF","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 \"./TextEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport {\n IconEditorParams, InputEditorSizeParams, PrimitiveValue, PropertyEditorParams, PropertyEditorParamTypes, PropertyValue, PropertyValueFormat,\n} from \"@itwin/appui-abstract\";\nimport { Icon, IconInput } from \"@itwin/core-react\";\nimport { Input, InputProps } from \"@itwin/itwinui-react\";\nimport { TypeConverterManager } from \"../converters/TypeConverterManager\";\nimport { PropertyEditorProps, TypeEditor } from \"./EditorContainer\";\nimport { UiComponents } from \"../UiComponents\";\n\n/** @internal */\ninterface TextEditorState {\n inputValue: string;\n readonly: boolean;\n isDisabled?: boolean;\n size?: number;\n maxLength?: number;\n iconSpec?: string;\n}\n\n/** TextEditor React component that is a property editor with text input\n * @public\n */\nexport class TextEditor extends React.PureComponent<PropertyEditorProps, TextEditorState> implements TypeEditor {\n private _isMounted = false;\n private _ariaLabel = UiComponents.translate(\"editor.text\");\n private _inputElement = React.createRef<HTMLInputElement>();\n\n /** @internal */\n public override readonly state: Readonly<TextEditorState> = {\n inputValue: \"\",\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 = await TypeConverterManager.getConverter(record.property.typename, record.property.converter?.name).convertFromStringToPropertyValue(this.state.inputValue, record);\n (propertyValue as PrimitiveValue).displayValue = this.state.inputValue;\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 private _updateInputValue = (e: React.ChangeEvent<HTMLInputElement>) => {\n // istanbul ignore else\n if (this._isMounted)\n this.setState({\n inputValue: e.target.value,\n }, async () => {\n if (this.props.shouldCommitOnChange && this.props.onCommit && this.props.propertyRecord) {\n const newValue = await this.getPropertyValue();\n // istanbul ignore else\n if (newValue)\n this.props.onCommit({ propertyRecord: this.props.propertyRecord, newValue });\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 record = this.props.propertyRecord;\n let initialValue = \"\";\n\n // istanbul ignore else\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n const value = record.value.value;\n initialValue = await TypeConverterManager.getConverter(record.property.typename, record.property.converter?.name).convertPropertyToString(record.property, value);\n }\n\n const readonly = record && undefined !== record.isReadonly ? record.isReadonly : false;\n let size: number | undefined;\n let maxLength: number | undefined;\n let iconSpec: string | 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 iconParams = record.property.editor.params.find((param: PropertyEditorParams) => param.type === PropertyEditorParamTypes.Icon) as IconEditorParams;\n if (iconParams) {\n iconSpec = iconParams.definition.iconSpec;\n }\n }\n\n // istanbul ignore else\n if (this._isMounted)\n this.setState({ inputValue: initialValue, readonly, size, maxLength, isDisabled, iconSpec });\n }\n\n /** @internal */\n public override render(): React.ReactNode {\n const className = classnames(\"components-cell-editor\", \"components-text-editor\", this.props.className);\n const minSize = this.state.size ? this.state.size : 8;\n const minWidthStyle: React.CSSProperties = {\n minWidth: `${minSize * 0.75}em`,\n };\n const inputProps: InputProps = {\n type: \"text\",\n className,\n style: this.props.style ? this.props.style : minWidthStyle,\n readOnly: this.state.readonly,\n disabled: this.state.isDisabled,\n maxLength: this.state.maxLength,\n value: this.state.inputValue,\n onBlur: this.props.onBlur,\n onChange: this._updateInputValue,\n setFocus: this.props.setFocus && !this.state.isDisabled,\n };\n\n inputProps[\"aria-label\"] = this._ariaLabel;\n\n let reactNode: React.ReactNode;\n if (this.state.iconSpec) {\n const icon = <Icon iconSpec={this.state.iconSpec} />;\n reactNode = (\n <IconInput\n {...inputProps}\n ref={this._inputElement}\n icon={icon}\n data-testid=\"components-text-editor\"\n />\n );\n } else {\n reactNode = (\n <Input\n {...inputProps}\n ref={this._inputElement}\n data-testid=\"components-text-editor\"\n size=\"small\"\n />\n );\n }\n\n return reactNode;\n }\n}\n"]}
|
|
@@ -13,12 +13,11 @@ import { PropertyList } from "../propertygrid/component/PropertyList";
|
|
|
13
13
|
* @alpha
|
|
14
14
|
*/
|
|
15
15
|
export function FavoritePropertyList(props) {
|
|
16
|
-
var _a, _b;
|
|
17
16
|
const [listWidth, setListWidth] = React.useState();
|
|
18
17
|
const onListResize = React.useCallback(setListWidth, [setListWidth]);
|
|
19
18
|
if (props.propertyData.records.Favorite !== undefined) {
|
|
20
|
-
const propertyValueRendererManager =
|
|
21
|
-
const orientation =
|
|
19
|
+
const propertyValueRendererManager = props.propertyValueRendererManager ?? PropertyValueRendererManager.defaultManager;
|
|
20
|
+
const orientation = props.orientation ?? Orientation.Horizontal;
|
|
22
21
|
return (React.createElement("div", { className: "components-favorite-property-list" },
|
|
23
22
|
React.createElement(ResizableContainerObserver, { onResize: onListResize }),
|
|
24
23
|
listWidth ?
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FavoritePropertyList.js","sourceRoot":"","sources":["../../../../src/components-react/favorite/FavoritePropertyList.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,4BAA4B,EAAE,MAAM,oCAAoC,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AAYtE;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAgC
|
|
1
|
+
{"version":3,"file":"FavoritePropertyList.js","sourceRoot":"","sources":["../../../../src/components-react/favorite/FavoritePropertyList.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,4BAA4B,EAAE,MAAM,oCAAoC,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AAYtE;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAgC;IACnE,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,KAAK,CAAC,QAAQ,EAAsB,CAAC;IACvE,MAAM,YAAY,GAAG,KAAK,CAAC,WAAW,CAAC,YAAY,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;IACrE,IAAI,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,QAAQ,KAAK,SAAS,EAAE;QACrD,MAAM,4BAA4B,GAAG,KAAK,CAAC,4BAA4B,IAAI,4BAA4B,CAAC,cAAc,CAAC;QACvH,MAAM,WAAW,GAAG,KAAK,CAAC,WAAW,IAAI,WAAW,CAAC,UAAU,CAAC;QAChE,OAAO,CACL,6BAAK,SAAS,EAAC,mCAAmC;YAChD,oBAAC,0BAA0B,IAAC,QAAQ,EAAE,YAAY,GAAI;YACrD,SAAS,CAAC,CAAC;gBACV,oBAAC,YAAY,IACX,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,SAAS,EAChB,UAAU,EAAE,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,QAAQ,EAC/C,WAAW,EAAE,CAAC,GAAG,CAAC,EAClB,4BAA4B,EAAE,4BAA4B,GAC1D,CAAC,CAAC,CAAC,IAAI,CACP,CACP,CAAC;KACH;IACD,OAAO,IAAI,CAAC;AACd,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 Favorite\n */\n\nimport * as React from \"react\";\nimport { Orientation, ResizableContainerObserver } from \"@itwin/core-react\";\nimport { PropertyValueRendererManager } from \"../properties/ValueRendererManager\";\nimport { PropertyList } from \"../propertygrid/component/PropertyList\";\nimport { PropertyData } from \"../propertygrid/PropertyDataProvider\";\n\n/** Properties for [[FavoritePropertyList]] React component\n * @alpha\n */\nexport interface FavoritePropertyListProps {\n propertyData: PropertyData;\n propertyValueRendererManager?: PropertyValueRendererManager;\n orientation?: Orientation;\n}\n\n/** Favorite Property List React component\n * @alpha\n */\nexport function FavoritePropertyList(props: FavoritePropertyListProps) {\n const [listWidth, setListWidth] = React.useState<number | undefined>();\n const onListResize = React.useCallback(setListWidth, [setListWidth]);\n if (props.propertyData.records.Favorite !== undefined) {\n const propertyValueRendererManager = props.propertyValueRendererManager ?? PropertyValueRendererManager.defaultManager;\n const orientation = props.orientation ?? Orientation.Horizontal;\n return (\n <div className=\"components-favorite-property-list\">\n <ResizableContainerObserver onResize={onListResize} />\n {listWidth ?\n <PropertyList\n orientation={orientation}\n width={listWidth}\n properties={props.propertyData.records.Favorite}\n columnRatio={1 / 3}\n propertyValueRendererManager={propertyValueRendererManager}\n /> : null}\n </div>\n );\n }\n return null;\n}\n"]}
|
|
@@ -13,10 +13,9 @@ import { getPropertyFilterOperatorLabel, getPropertyFilterOperators } from "./Op
|
|
|
13
13
|
* @internal
|
|
14
14
|
*/
|
|
15
15
|
export function PropertyFilterBuilderRuleOperator(props) {
|
|
16
|
-
var _a;
|
|
17
16
|
const { operator, property, onChange } = props;
|
|
18
17
|
const availableOperators = React.useMemo(() => getPropertyFilterOperators(property), [property]);
|
|
19
|
-
const selectedOperator =
|
|
18
|
+
const selectedOperator = availableOperators.find((op) => op === operator) ?? availableOperators[0];
|
|
20
19
|
React.useEffect(() => {
|
|
21
20
|
onChange(selectedOperator);
|
|
22
21
|
}, [onChange, selectedOperator]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterBuilderRuleOperator.js","sourceRoot":"","sources":["../../../../src/components-react/filter-builder/FilterBuilderRuleOperator.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,8BAA8B,EAAE,0BAA0B,EAA8B,MAAM,aAAa,CAAC;AAerH;;;GAGG;AACH,MAAM,UAAU,iCAAiC,CAAC,KAA6C
|
|
1
|
+
{"version":3,"file":"FilterBuilderRuleOperator.js","sourceRoot":"","sources":["../../../../src/components-react/filter-builder/FilterBuilderRuleOperator.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,8BAA8B,EAAE,0BAA0B,EAA8B,MAAM,aAAa,CAAC;AAerH;;;GAGG;AACH,MAAM,UAAU,iCAAiC,CAAC,KAA6C;IAC7F,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAE/C,MAAM,kBAAkB,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,0BAA0B,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IACjG,MAAM,gBAAgB,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,QAAQ,CAAC,IAAI,kBAAkB,CAAC,CAAC,CAAC,CAAC;IAEnG,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,QAAQ,CAAC,gBAAgB,CAAC,CAAC;IAC7B,CAAC,EAAE,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAEjC,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QAC3E,KAAK,EAAE,EAAE;QACT,KAAK,EAAE,8BAA8B,CAAC,EAAE,CAAC;KAC1C,CAAC,CAAC,EAAE,CAAC,kBAAkB,CAAC,CAAC,CAAC;IAE3B,OAAO,6BAAK,SAAS,EAAC,eAAe;QACnC,oBAAC,MAAM,IAAC,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAC,OAAO,GAAG,CAC3F,CAAC;AACT,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 PropertyFilterBuilder\n */\n\nimport * as React from \"react\";\nimport { PropertyDescription } from \"@itwin/appui-abstract\";\nimport { Select } from \"@itwin/itwinui-react\";\nimport { getPropertyFilterOperatorLabel, getPropertyFilterOperators, PropertyFilterRuleOperator } from \"./Operators\";\n\n/**\n * Props for [[PropertyFilterBuilderRuleOperator]] component.\n * @internal\n */\nexport interface PropertyFilterBuilderRuleOperatorProps {\n /** Currently selected operator. */\n operator?: PropertyFilterRuleOperator;\n /** Property used in rule for which this operator will be used. */\n property: PropertyDescription;\n /** Callback that is invoked when selected operator changes. */\n onChange: (operator: PropertyFilterRuleOperator) => void;\n}\n\n/**\n * Component that renders [[PropertyFilterBuilderRuleRenderer]] operator selector.\n * @internal\n */\nexport function PropertyFilterBuilderRuleOperator(props: PropertyFilterBuilderRuleOperatorProps) {\n const { operator, property, onChange } = props;\n\n const availableOperators = React.useMemo(() => getPropertyFilterOperators(property), [property]);\n const selectedOperator = availableOperators.find((op) => op === operator) ?? availableOperators[0];\n\n React.useEffect(() => {\n onChange(selectedOperator);\n }, [onChange, selectedOperator]);\n\n const availableOptions = React.useMemo(() => availableOperators.map((op) => ({\n value: op,\n label: getPropertyFilterOperatorLabel(op),\n })), [availableOperators]);\n\n return <div className=\"rule-operator\">\n <Select options={availableOptions} value={selectedOperator} onChange={onChange} size=\"small\" />\n </div>;\n}\n"]}
|
|
@@ -23,15 +23,15 @@ export function PropertyFilterBuilderRuleProperty(props) {
|
|
|
23
23
|
onSelectedPropertyChanged(properties.find((property) => property.name === name));
|
|
24
24
|
}, [properties, onSelectedPropertyChanged]);
|
|
25
25
|
React.useEffect(() => {
|
|
26
|
-
const currentSelectedProperty = properties.find((property) => property.name ===
|
|
27
|
-
if (
|
|
26
|
+
const currentSelectedProperty = properties.find((property) => property.name === selectedProperty?.name);
|
|
27
|
+
if (currentSelectedProperty?.name !== selectedProperty?.name)
|
|
28
28
|
onSelectedPropertyChanged(currentSelectedProperty);
|
|
29
29
|
}, [properties, selectedProperty, onSelectedPropertyChanged]);
|
|
30
30
|
const itemRenderer = React.useCallback((selectOption, { isSelected, id }) => {
|
|
31
31
|
return React.createElement(MenuItem, { key: id, id: id, isSelected: isSelected }, propertyRenderer ? propertyRenderer(selectOption.value) : selectOption.label);
|
|
32
32
|
}, [propertyRenderer]);
|
|
33
33
|
return React.createElement("div", { className: "rule-property" },
|
|
34
|
-
React.createElement(ComboBox, { options: selectOptions, onChange: onPropertyChanged, value: selectedProperty
|
|
34
|
+
React.createElement(ComboBox, { options: selectOptions, onChange: onPropertyChanged, value: selectedProperty?.name, inputProps: {
|
|
35
35
|
placeholder: UiComponents.translate("filterBuilder.chooseProperty"),
|
|
36
36
|
disabled: isDisabled,
|
|
37
37
|
size: "small",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterBuilderRuleProperty.js","sourceRoot":"","sources":["../../../../src/components-react/filter-builder/FilterBuilderRuleProperty.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,QAAQ,EAAiB,QAAQ,EAAgB,MAAM,sBAAsB,CAAC;AACvF,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAmB/C;;;GAGG;AACH,MAAM,UAAU,iCAAiC,CAAC,KAA6C;IAC7F,MAAM,EAAE,gBAAgB,EAAE,UAAU,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC;IAExG,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,CAAyB,GAAG,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QAC9F,EAAE,EAAE,QAAQ,CAAC,IAAI;QACjB,KAAK,EAAE,QAAQ,CAAC,YAAY;QAC5B,KAAK,EAAE,QAAQ,CAAC,IAAI;KACrB,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAEnB,MAAM,iBAAiB,G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1B,oBAAoB,EAAE,IAAI,GAC1B,CACE,CAAC;AACT,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 PropertyFilterBuilder\n */\n\nimport * as React from \"react\";\nimport { PropertyDescription } from \"@itwin/appui-abstract\";\nimport { ComboBox, ComboBoxProps, MenuItem, SelectOption } from \"@itwin/itwinui-react\";\nimport { UiComponents } from \"../UiComponents\";\n\n/**\n * Props for [[PropertyFilterBuilderRuleProperty]] component.\n * @internal\n */\nexport interface PropertyFilterBuilderRulePropertyProps {\n /** List of available properties. */\n properties: PropertyDescription[];\n /** Currently selected property. */\n selectedProperty?: PropertyDescription;\n /** Callback that is invoked when selected property changes. */\n onSelectedPropertyChanged: (property?: PropertyDescription) => void;\n /** Custom renderer for property item inside selector. */\n propertyRenderer?: (name: string) => React.ReactNode;\n /** Specifies whether selector should be disabled or not. */\n isDisabled?: boolean;\n}\n\n/**\n * Component that renders [[PropertyFilterBuilderRuleRenderer]] property selector.\n * @internal\n */\nexport function PropertyFilterBuilderRuleProperty(props: PropertyFilterBuilderRulePropertyProps) {\n const { selectedProperty, properties, onSelectedPropertyChanged, propertyRenderer, isDisabled } = props;\n\n const selectOptions = React.useMemo<SelectOption<string>[]>(() => properties.map((property) => ({\n id: property.name,\n label: property.displayLabel,\n value: property.name,\n })), [properties]);\n\n const onPropertyChanged = React.useCallback((name: string) => {\n onSelectedPropertyChanged(properties.find((property) => property.name === name));\n }, [properties, onSelectedPropertyChanged]);\n\n React.useEffect(() => {\n const currentSelectedProperty = properties.find((property) => property.name === selectedProperty?.name);\n if (currentSelectedProperty?.name !== selectedProperty?.name)\n onSelectedPropertyChanged(currentSelectedProperty);\n }, [properties, selectedProperty, onSelectedPropertyChanged]);\n\n const itemRenderer = React.useCallback<Required<ComboBoxProps<string>>[\"itemRenderer\"]>((selectOption, { isSelected, id }) => {\n return <MenuItem key={id} id={id} isSelected={isSelected}>\n {propertyRenderer ? propertyRenderer(selectOption.value) : selectOption.label}\n </MenuItem>;\n }, [propertyRenderer]);\n\n return <div className=\"rule-property\">\n <ComboBox\n options={selectOptions}\n onChange={onPropertyChanged}\n value={selectedProperty?.name}\n inputProps={{\n placeholder: UiComponents.translate(\"filterBuilder.chooseProperty\"),\n disabled: isDisabled,\n size: \"small\",\n }}\n itemRenderer={itemRenderer}\n enableVirtualization={true}\n />\n </div>;\n}\n"]}
|
|
@@ -15,7 +15,7 @@ import { EditorContainer } from "../editors/EditorContainer";
|
|
|
15
15
|
export function PropertyFilterBuilderRuleValue(props) {
|
|
16
16
|
const { value, property, onChange } = props;
|
|
17
17
|
const propertyRecord = React.useMemo(() => {
|
|
18
|
-
return new PropertyRecord(value
|
|
18
|
+
return new PropertyRecord(value ?? { valueFormat: PropertyValueFormat.Primitive }, property);
|
|
19
19
|
}, [value, property]);
|
|
20
20
|
const onValueChange = React.useCallback(({ newValue }) => {
|
|
21
21
|
onChange(newValue);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterBuilderRuleValue.js","sourceRoot":"","sources":["../../../../src/components-react/filter-builder/FilterBuilderRuleValue.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAuB,cAAc,EAAiB,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAChH,OAAO,EAAE,eAAe,EAAuB,MAAM,4BAA4B,CAAC;AAelF;;;GAGG;AACH,MAAM,UAAU,8BAA8B,CAAC,KAA0C;IACvF,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAE5C,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QACxC,OAAO,IAAI,cAAc,CAAC,KAAK,
|
|
1
|
+
{"version":3,"file":"FilterBuilderRuleValue.js","sourceRoot":"","sources":["../../../../src/components-react/filter-builder/FilterBuilderRuleValue.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAuB,cAAc,EAAiB,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAChH,OAAO,EAAE,eAAe,EAAuB,MAAM,4BAA4B,CAAC;AAelF;;;GAGG;AACH,MAAM,UAAU,8BAA8B,CAAC,KAA0C;IACvF,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAE5C,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QACxC,OAAO,IAAI,cAAc,CAAC,KAAK,IAAI,EAAE,WAAW,EAAE,mBAAmB,CAAC,SAAS,EAAE,EAAE,QAAQ,CAAC,CAAC;IAC/F,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;IAEtB,MAAM,aAAa,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,EAAE,QAAQ,EAAuB,EAAE,EAAE;QAC5E,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACrB,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEf,OAAO,6BAAK,SAAS,EAAC,YAAY;QAChC,oBAAC,eAAe,IACd,cAAc,EAAE,cAAc,EAC9B,QAAQ,EAAE,0BAA0B,CAAC,GAAG,EAAE,GAAG,CAAC,EAC9C,QAAQ,EAAE,aAAa,EACvB,QAAQ,EAAE,KAAK,EACf,oBAAoB,EAAE,IAAI,GAC1B,CACE,CAAC;AACT,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 PropertyFilterBuilder\n */\n\nimport * as React from \"react\";\nimport { PropertyDescription, PropertyRecord, PropertyValue, PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport { EditorContainer, PropertyUpdatedArgs } from \"../editors/EditorContainer\";\n\n/**\n * Props for [[PropertyFilterBuilderRuleValue]] component.\n * @internal\n */\nexport interface PropertyFilterBuilderRuleValueProps {\n /** Currently entered value. */\n value?: PropertyValue;\n /** Property used in rule to which this value will be compared to. */\n property: PropertyDescription;\n /** Callback that is invoked when value changes. */\n onChange: (value: PropertyValue) => void;\n}\n\n/**\n * Component that renders [[PropertyFilterBuilderRuleRenderer]] value input.\n * @internal\n */\nexport function PropertyFilterBuilderRuleValue(props: PropertyFilterBuilderRuleValueProps) {\n const { value, property, onChange } = props;\n\n const propertyRecord = React.useMemo(() => {\n return new PropertyRecord(value ?? { valueFormat: PropertyValueFormat.Primitive }, property);\n }, [value, property]);\n\n const onValueChange = React.useCallback(({ newValue }: PropertyUpdatedArgs) => {\n onChange(newValue);\n }, [onChange]);\n\n return <div className=\"rule-value\">\n <EditorContainer\n propertyRecord={propertyRecord}\n onCancel={/* istanbul ignore next */ () => { }}\n onCommit={onValueChange}\n setFocus={false}\n shouldCommitOnChange={true}\n />\n </div>;\n}\n"]}
|
|
@@ -31,7 +31,7 @@ export class CommonPropertyRenderer {
|
|
|
31
31
|
return currentSize - minColumnLabelWidth;
|
|
32
32
|
}
|
|
33
33
|
static createNewDisplayValue(orientation, propertyRecord, indentation, propertyValueRendererManager, isExpanded, onExpansionToggled, onHeightChanged, highlight) {
|
|
34
|
-
const highlightCallback =
|
|
34
|
+
const highlightCallback = highlight?.applyOnValue ? (CommonPropertyRenderer.createHighlightCallback(highlight, propertyRecord)) : undefined;
|
|
35
35
|
const rendererContext = {
|
|
36
36
|
orientation,
|
|
37
37
|
containerType: PropertyContainerType.PropertyPane,
|
|
@@ -51,10 +51,9 @@ export class CommonPropertyRenderer {
|
|
|
51
51
|
return displayValue;
|
|
52
52
|
}
|
|
53
53
|
static createHighlightCallback(highlight, propertyRecord) {
|
|
54
|
-
var _a;
|
|
55
54
|
const activeMatch = highlight.activeHighlight;
|
|
56
|
-
const propertyName = activeMatch
|
|
57
|
-
const matchIndex =
|
|
55
|
+
const propertyName = activeMatch?.highlightedItemIdentifier;
|
|
56
|
+
const matchIndex = activeMatch?.highlightIndex ?? 0;
|
|
58
57
|
let labelMatches;
|
|
59
58
|
if (highlight.applyOnLabel) {
|
|
60
59
|
labelMatches = countMatchesInString(propertyRecord.property.displayLabel.toLowerCase(), highlight.highlightedText);
|