@itwin/components-react 5.28.0 → 5.29.0
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 +24 -0
- package/lib/components-react/UiComponents.json +0 -1
- package/lib/components-react/editors/BooleanEditor.d.ts.map +1 -1
- package/lib/components-react/editors/BooleanEditor.js +1 -1
- package/lib/components-react/editors/BooleanEditor.js.map +1 -1
- package/lib/components-react/editors/DateTimeEditor.d.ts.map +1 -1
- package/lib/components-react/editors/DateTimeEditor.js +1 -1
- package/lib/components-react/editors/DateTimeEditor.js.map +1 -1
- package/lib/components-react/editors/EnumButtonGroupEditor.d.ts.map +1 -1
- package/lib/components-react/editors/EnumButtonGroupEditor.js +1 -1
- package/lib/components-react/editors/EnumButtonGroupEditor.js.map +1 -1
- package/lib/components-react/editors/EnumEditor.d.ts.map +1 -1
- package/lib/components-react/editors/EnumEditor.js +1 -0
- package/lib/components-react/editors/EnumEditor.js.map +1 -1
- package/lib/components-react/editors/IconEditor.d.ts.map +1 -1
- package/lib/components-react/editors/IconEditor.js +1 -1
- package/lib/components-react/editors/IconEditor.js.map +1 -1
- package/lib/components-react/editors/ImageCheckBoxEditor.d.ts.map +1 -1
- package/lib/components-react/editors/ImageCheckBoxEditor.js +1 -1
- package/lib/components-react/editors/ImageCheckBoxEditor.js.map +1 -1
- package/lib/components-react/editors/NumericInputEditor.d.ts.map +1 -1
- package/lib/components-react/editors/NumericInputEditor.js +1 -1
- package/lib/components-react/editors/NumericInputEditor.js.map +1 -1
- package/lib/components-react/editors/PopupButton.d.ts +2 -0
- package/lib/components-react/editors/PopupButton.d.ts.map +1 -1
- package/lib/components-react/editors/PopupButton.js +1 -1
- package/lib/components-react/editors/PopupButton.js.map +1 -1
- package/lib/components-react/editors/SliderEditor.d.ts.map +1 -1
- package/lib/components-react/editors/SliderEditor.js +1 -1
- package/lib/components-react/editors/SliderEditor.js.map +1 -1
- package/lib/components-react/editors/TextEditor.d.ts +2 -0
- package/lib/components-react/editors/TextEditor.d.ts.map +1 -1
- package/lib/components-react/editors/TextEditor.js +12 -1
- package/lib/components-react/editors/TextEditor.js.map +1 -1
- package/lib/components-react/editors/TextareaEditor.d.ts.map +1 -1
- package/lib/components-react/editors/TextareaEditor.js +1 -1
- package/lib/components-react/editors/TextareaEditor.js.map +1 -1
- package/lib/components-react/editors/ToggleEditor.d.ts.map +1 -1
- package/lib/components-react/editors/ToggleEditor.js +1 -1
- package/lib/components-react/editors/ToggleEditor.js.map +1 -1
- package/lib/components-react/new-editors/ConstraintUtils.d.ts +62 -0
- package/lib/components-react/new-editors/ConstraintUtils.d.ts.map +1 -0
- package/lib/components-react/new-editors/ConstraintUtils.js +49 -0
- package/lib/components-react/new-editors/ConstraintUtils.js.map +1 -0
- package/lib/components-react/new-editors/Types.d.ts +6 -0
- package/lib/components-react/new-editors/Types.d.ts.map +1 -1
- package/lib/components-react/new-editors/Types.js.map +1 -1
- package/lib/components-react/new-editors/UseCommittableValue.d.ts +2 -5
- package/lib/components-react/new-editors/UseCommittableValue.d.ts.map +1 -1
- package/lib/components-react/new-editors/UseCommittableValue.js +4 -1
- package/lib/components-react/new-editors/UseCommittableValue.js.map +1 -1
- package/lib/components-react/new-editors/editors/BooleanEditor.d.ts +1 -1
- package/lib/components-react/new-editors/editors/BooleanEditor.d.ts.map +1 -1
- package/lib/components-react/new-editors/editors/BooleanEditor.js +2 -2
- package/lib/components-react/new-editors/editors/BooleanEditor.js.map +1 -1
- package/lib/components-react/new-editors/editors/DateEditor.d.ts +1 -1
- package/lib/components-react/new-editors/editors/DateEditor.d.ts.map +1 -1
- package/lib/components-react/new-editors/editors/DateEditor.js +2 -2
- package/lib/components-react/new-editors/editors/DateEditor.js.map +1 -1
- package/lib/components-react/new-editors/editors/DateInput.d.ts +2 -1
- package/lib/components-react/new-editors/editors/DateInput.d.ts.map +1 -1
- package/lib/components-react/new-editors/editors/DateInput.js +2 -2
- package/lib/components-react/new-editors/editors/DateInput.js.map +1 -1
- package/lib/components-react/new-editors/editors/DateTimeEditor.d.ts +1 -1
- package/lib/components-react/new-editors/editors/DateTimeEditor.d.ts.map +1 -1
- package/lib/components-react/new-editors/editors/DateTimeEditor.js +2 -2
- package/lib/components-react/new-editors/editors/DateTimeEditor.js.map +1 -1
- package/lib/components-react/new-editors/editors/EnumEditor.d.ts +1 -1
- package/lib/components-react/new-editors/editors/EnumEditor.d.ts.map +1 -1
- package/lib/components-react/new-editors/editors/EnumEditor.js +2 -2
- package/lib/components-react/new-editors/editors/EnumEditor.js.map +1 -1
- package/lib/components-react/new-editors/editors/FallbackEditor.d.ts +1 -1
- package/lib/components-react/new-editors/editors/FallbackEditor.d.ts.map +1 -1
- package/lib/components-react/new-editors/editors/FallbackEditor.js +2 -2
- package/lib/components-react/new-editors/editors/FallbackEditor.js.map +1 -1
- package/lib/components-react/new-editors/editors/NumericEditor.d.ts +2 -2
- package/lib/components-react/new-editors/editors/NumericEditor.d.ts.map +1 -1
- package/lib/components-react/new-editors/editors/NumericEditor.js +7 -3
- package/lib/components-react/new-editors/editors/NumericEditor.js.map +1 -1
- package/lib/components-react/new-editors/editors/TextEditor.d.ts +2 -2
- package/lib/components-react/new-editors/editors/TextEditor.d.ts.map +1 -1
- package/lib/components-react/new-editors/editors/TextEditor.js +4 -2
- package/lib/components-react/new-editors/editors/TextEditor.js.map +1 -1
- package/lib/components-react/new-editors/editors/ToggleEditor.d.ts +1 -1
- package/lib/components-react/new-editors/editors/ToggleEditor.d.ts.map +1 -1
- package/lib/components-react/new-editors/editors/ToggleEditor.js +2 -2
- package/lib/components-react/new-editors/editors/ToggleEditor.js.map +1 -1
- package/lib/components-react/new-editors/editors-registry/DefaultEditors.d.ts.map +1 -1
- package/lib/components-react/new-editors/editors-registry/DefaultEditors.js.map +1 -1
- package/lib/components-react/new-editors/interop/EditorInterop.d.ts +4 -3
- package/lib/components-react/new-editors/interop/EditorInterop.d.ts.map +1 -1
- package/lib/components-react/new-editors/interop/EditorInterop.js +1 -0
- package/lib/components-react/new-editors/interop/EditorInterop.js.map +1 -1
- package/lib/components-react/new-editors/interop/PropertyRecordEditor.d.ts +14 -0
- package/lib/components-react/new-editors/interop/PropertyRecordEditor.d.ts.map +1 -1
- package/lib/components-react/new-editors/interop/PropertyRecordEditor.js +4 -3
- package/lib/components-react/new-editors/interop/PropertyRecordEditor.js.map +1 -1
- package/lib/components-react/new-editors/interop/old-editors/Color.js +2 -2
- package/lib/components-react/new-editors/interop/old-editors/Color.js.map +1 -1
- package/lib/components-react/new-editors/interop/old-editors/CustomNumber.d.ts +3 -2
- package/lib/components-react/new-editors/interop/old-editors/CustomNumber.d.ts.map +1 -1
- package/lib/components-react/new-editors/interop/old-editors/CustomNumber.js +9 -3
- package/lib/components-react/new-editors/interop/old-editors/CustomNumber.js.map +1 -1
- package/lib/components-react/new-editors/interop/old-editors/EnumButtonGroup.js +2 -2
- package/lib/components-react/new-editors/interop/old-editors/EnumButtonGroup.js.map +1 -1
- package/lib/components-react/new-editors/interop/old-editors/NumericInput.d.ts +7 -1
- package/lib/components-react/new-editors/interop/old-editors/NumericInput.d.ts.map +1 -1
- package/lib/components-react/new-editors/interop/old-editors/NumericInput.js +19 -4
- package/lib/components-react/new-editors/interop/old-editors/NumericInput.js.map +1 -1
- package/lib/components-react/new-editors/interop/old-editors/Slider.js +2 -2
- package/lib/components-react/new-editors/interop/old-editors/Slider.js.map +1 -1
- package/lib/components-react/new-editors/interop/old-editors/TextArea.js +2 -2
- package/lib/components-react/new-editors/interop/old-editors/TextArea.js.map +1 -1
- package/lib/components-react/new-editors/values/Metadata.d.ts +22 -0
- package/lib/components-react/new-editors/values/Metadata.d.ts.map +1 -1
- package/lib/components-react/new-editors/values/Metadata.js.map +1 -1
- package/lib/components-react/properties/renderers/value/MergedPropertyValueRenderer.d.ts +1 -1
- package/lib/components-react/properties/renderers/value/MergedPropertyValueRenderer.d.ts.map +1 -1
- package/lib/components-react/properties/renderers/value/MergedPropertyValueRenderer.js +4 -7
- package/lib/components-react/properties/renderers/value/MergedPropertyValueRenderer.js.map +1 -1
- package/lib/components-react.d.ts +1 -1
- package/lib/components-react.d.ts.map +1 -1
- package/lib/components-react.js.map +1 -1
- package/lib/internal.d.ts +1 -0
- package/lib/internal.d.ts.map +1 -1
- package/lib/internal.js +1 -0
- package/lib/internal.js.map +1 -1
- package/lib/public/locales/en/UiComponents.json +0 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumericInputEditor.js","sourceRoot":"","sources":["../../../src/components-react/editors/NumericInputEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,2BAA2B,CAAC;AACnC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAO/B,OAAO,EACL,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAMhD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAe5D;;GAEG;AACH,MAAM,OAAO,kBACX,SAAQ,KAAK,CAAC,aAA2D;IAGjE,UAAU,GAAG,KAAK,CAAC;IACnB,aAAa,GACnB,KAAK,CAAC,SAAS,EAAE,CAAC;IACb,QAAQ,GAAG,KAAK,CAAC,CAAC,gDAAgD;IAEhD,KAAK,GAAsC;QAClE,KAAK,EAAE,CAAC;KACT,CAAC;IAEK,KAAK,CAAC,gBAAgB;QAC3B,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC;QACzC,IAAI,aAAwC,CAAC;QAE7C,IAAI,MAAM,IAAI,MAAM,CAAC,KAAK,CAAC,WAAW,KAAK,mBAAmB,CAAC,SAAS,EAAE,CAAC;YACzE,aAAa,GAAG;gBACd,WAAW,EAAE,mBAAmB,CAA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AAE,YAAY,EACjB,UAAU,EAAE,UAAU,GACtB,CACH,CAAC;IACJ,CAAC;IAED,OAAO;IACL,4DAA4D;IAC5D,oBAAC,WAAW,IAAC,GAAG,EAAE,YAAY,KAAM,IAAI,GAAI,CAC7C,CAAC;AACJ,CAAC,CACF,CAAC;AAMF,MAAM,iBAAiB,GAAG,KAAK,CAAC,UAAU,CAGxC,SAAS,iBAAiB,CAAC,KAAK,EAAE,YAAY;IAC9C,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IAEzE,MAAM,YAAY,GAAG,CAAC,KAA0C,EAAE,EAAE;QAClE,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;QACjC,QAAQ,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC;IACnC,CAAC,CAAC;IACF,OAAO,CACL,oBAAC,oBAAoB,IAAC,IAAI,EAAC,OAAO;QAChC,oBAAC,oBAAoB,CAAC,KAAK,OACrB,IAAI,EACR,GAAG,EAAE,YAAY,EACjB,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAE,YAAY,EACtB,IAAI,EAAC,OAAO,GACZ;QACD,UAAU,CACU,CACxB,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module PropertyEditors\n */\n\nimport \"./NumericInputEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type {\n InputEditorSizeParams,\n PropertyEditorParams,\n PropertyValue,\n RangeEditorParams,\n} from \"@itwin/appui-abstract\";\nimport {\n PropertyEditorParamTypes,\n PropertyValueFormat,\n} from \"@itwin/appui-abstract\";\nimport { NumberInput } from \"@itwin/core-react\";\nimport type {\n InternalInputEditorProps,\n PropertyEditorProps,\n TypeEditor,\n} from \"./EditorContainer.js\";\nimport { PropertyEditorBase } from \"./PropertyEditorManager.js\";\nimport { InputWithDecorations } from \"@itwin/itwinui-react\";\n\n/** @internal */\ninterface NumericInputEditorState {\n value: number;\n size?: number;\n maxSize?: number;\n maxLength?: number;\n\n min?: number;\n max?: number;\n step?: number;\n precision?: number;\n}\n\n/** NumericInputEditor React component that is a property editor with numeric input & up/down buttons\n * @public\n */\nexport class NumericInputEditor\n extends React.PureComponent<PropertyEditorProps, NumericInputEditorState>\n implements TypeEditor\n{\n private _isMounted = false;\n private _inputElement: React.RefObject<HTMLInputElement | null> =\n React.createRef();\n public hasFocus = false; // hot used since containerHandlesEnter is false\n\n public override readonly state: Readonly<NumericInputEditorState> = {\n value: 0,\n };\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n propertyValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: this.state.value,\n displayValue: \"\",\n };\n }\n\n return propertyValue;\n }\n\n public get htmlElement(): HTMLElement | null {\n return this._inputElement.current;\n }\n\n private _handleCommit = async (): Promise<void> => {\n if (this.props.propertyRecord && this.props.onCommit) {\n const propertyValue = await this.getPropertyValue();\n if (propertyValue !== undefined) {\n this.props.onCommit({\n propertyRecord: this.props.propertyRecord,\n newValue: propertyValue,\n });\n }\n }\n };\n\n private _updateValue = (\n value: number | undefined,\n _stringValue: string\n ): void => {\n const newValue = value !== undefined ? value : 0;\n\n if (this._isMounted)\n this.setState(\n {\n value: newValue,\n },\n async () => {\n await this._handleCommit();\n }\n );\n };\n\n public override componentDidMount() {\n this._isMounted = true;\n void this.setStateFromProps();\n }\n\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 void this.setStateFromProps();\n }\n }\n\n private async setStateFromProps() {\n const record = this.props.propertyRecord;\n let initialValue = 0;\n\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n initialValue = record.value.value as number;\n }\n\n let size: number | undefined;\n let maxSize: number | undefined;\n let maxLength: number | undefined;\n let min: number | undefined;\n let max: number | undefined;\n let step: number | undefined;\n let precision: number | undefined;\n\n if (\n record &&\n record.property &&\n record.property.editor &&\n record.property.editor.params\n ) {\n const editorSizeParams = record.property.editor.params.find(\n (param: PropertyEditorParams) =>\n param.type === PropertyEditorParamTypes.InputEditorSize.valueOf()\n ) as InputEditorSizeParams;\n if (editorSizeParams) {\n if (editorSizeParams.size) size = editorSizeParams.size;\n if (editorSizeParams.maxSize) maxSize = editorSizeParams.maxSize;\n if (editorSizeParams.maxLength) maxLength = editorSizeParams.maxLength;\n }\n\n const rangeParams = record.property.editor.params.find(\n (param: PropertyEditorParams) =>\n param.type === PropertyEditorParamTypes.Range.valueOf()\n ) as RangeEditorParams;\n if (rangeParams) {\n min = rangeParams.minimum;\n max = rangeParams.maximum;\n step = rangeParams.step;\n precision = rangeParams.precision;\n }\n }\n\n if (this._isMounted)\n this.setState({\n value: initialValue,\n size,\n maxSize,\n maxLength,\n min,\n max,\n step,\n precision,\n });\n }\n\n public override render(): React.ReactNode {\n const { decoration } = this.props as InternalInputEditorProps;\n const className = classnames(\n \"components-cell-editor\",\n \"components-numeric-input-editor\",\n this.props.className\n );\n const minSize = this.state.size ? this.state.size : 8;\n const style: React.CSSProperties = {\n ...this.props.style,\n minWidth: `${minSize * 0.75}em`,\n maxWidth: this.state.maxSize\n ? `${this.state.maxSize * 0.75}em`\n : undefined,\n };\n\n return (\n <NumericEditor\n ref={this._inputElement}\n className={className}\n style={style}\n value={this.state.value}\n min={this.state.min}\n max={this.state.max}\n step={this.state.step}\n precision={this.state.precision}\n readOnly={this.props.propertyRecord?.isReadonly}\n disabled={this.props.propertyRecord?.isDisabled}\n maxLength={this.state.maxLength}\n onBlur={this.props.onBlur}\n onChange={this._updateValue}\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={\n this.props.setFocus && !this.props.propertyRecord?.isDisabled\n }\n isControlled={this.props.shouldCommitOnChange}\n decoration={decoration}\n />\n );\n }\n}\n\n/** Numeric Input Property Editor registered for the \"number\" type name and \"numeric-input\" editor name.\n * It uses the [[NumericInputEditor]] React component.\n * @public\n */\nexport class NumericInputPropertyEditor extends PropertyEditorBase {\n public get reactNode(): React.ReactNode {\n return <NumericInputEditor />;\n }\n public override get containerHandlesEnter(): boolean {\n // let input editor process enter key\n return false;\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-deprecated\ntype NumberInputProps = React.ComponentProps<typeof NumberInput>;\n\ninterface NumericEditorProps extends Omit<NumberInputProps, \"step\"> {\n decoration?: React.ReactNode;\n step?: number;\n}\n\nconst NumericEditor = React.forwardRef<HTMLInputElement, NumericEditorProps>(\n function NumericEditor(props, forwardedRef) {\n const { decoration, ...rest } = props;\n if (decoration) {\n return (\n <LockNumericEditor\n {...rest}\n ref={forwardedRef}\n decoration={decoration}\n />\n );\n }\n\n return (\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n <NumberInput ref={forwardedRef} {...rest} />\n );\n }\n);\n\ninterface LockNumericEditorProps extends NumericEditorProps {\n decoration: React.ReactNode;\n}\n\nconst LockNumericEditor = React.forwardRef<\n HTMLInputElement,\n LockNumericEditorProps\n>(function LockNumericEditor(props, forwardedRef) {\n const { decoration, precision, onChange, isControlled, ...rest } = props;\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n const value = event.target.value;\n onChange?.(Number(value), value);\n };\n return (\n <InputWithDecorations size=\"small\">\n <InputWithDecorations.Input\n {...rest}\n ref={forwardedRef}\n type=\"number\"\n onChange={handleChange}\n size=\"small\"\n />\n {decoration}\n </InputWithDecorations>\n );\n});\n"]}
|
|
1
|
+
{"version":3,"file":"NumericInputEditor.js","sourceRoot":"","sources":["../../../src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KAAK,EAAE,YAAY;IAC9C,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IAEzE,MAAM,YAAY,GAAG,CAAC,KAA0C,EAAE,EAAE;QAClE,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;QACjC,QAAQ,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC;IACnC,CAAC,CAAC;IACF,OAAO,CACL,oBAAC,oBAAoB,IAAC,IAAI,EAAC,OAAO;QAChC,oBAAC,oBAAoB,CAAC,KAAK,OACrB,IAAI,EACR,GAAG,EAAE,YAAY,EACjB,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAE,YAAY,EACtB,IAAI,EAAC,OAAO,GACZ;QACD,UAAU,CACU,CACxB,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module PropertyEditors\n */\n\nimport \"./NumericInputEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type {\n InputEditorSizeParams,\n PropertyEditorParams,\n PropertyValue,\n RangeEditorParams,\n} from \"@itwin/appui-abstract\";\nimport {\n PropertyEditorParamTypes,\n PropertyValueFormat,\n} from \"@itwin/appui-abstract\";\nimport { NumberInput } from \"@itwin/core-react\";\nimport type {\n InternalInputEditorProps,\n PropertyEditorProps,\n TypeEditor,\n} from \"./EditorContainer.js\";\nimport { PropertyEditorBase } from \"./PropertyEditorManager.js\";\nimport { InputWithDecorations } from \"@itwin/itwinui-react\";\n\n/** @internal */\ninterface NumericInputEditorState {\n value: number;\n size?: number;\n maxSize?: number;\n maxLength?: number;\n\n min?: number;\n max?: number;\n step?: number;\n precision?: number;\n}\n\n/** NumericInputEditor React component that is a property editor with numeric input & up/down buttons\n * @public\n */\nexport class NumericInputEditor\n extends React.PureComponent<PropertyEditorProps, NumericInputEditorState>\n implements TypeEditor\n{\n private _isMounted = false;\n private _inputElement: React.RefObject<HTMLInputElement | null> =\n React.createRef();\n public hasFocus = false; // hot used since containerHandlesEnter is false\n\n public override readonly state: Readonly<NumericInputEditorState> = {\n value: 0,\n };\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n propertyValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: this.state.value,\n displayValue: \"\",\n };\n }\n\n return propertyValue;\n }\n\n public get htmlElement(): HTMLElement | null {\n return this._inputElement.current;\n }\n\n private _handleCommit = async (): Promise<void> => {\n if (this.props.propertyRecord && this.props.onCommit) {\n const propertyValue = await this.getPropertyValue();\n if (propertyValue !== undefined) {\n this.props.onCommit({\n propertyRecord: this.props.propertyRecord,\n newValue: propertyValue,\n });\n }\n }\n };\n\n private _updateValue = (\n value: number | undefined,\n _stringValue: string\n ): void => {\n const newValue = value !== undefined ? value : 0;\n\n if (this._isMounted)\n this.setState(\n {\n value: newValue,\n },\n async () => {\n await this._handleCommit();\n }\n );\n };\n\n public override componentDidMount() {\n this._isMounted = true;\n void this.setStateFromProps();\n }\n\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 void this.setStateFromProps();\n }\n }\n\n private async setStateFromProps() {\n const record = this.props.propertyRecord;\n let initialValue = 0;\n\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n initialValue = record.value.value as number;\n }\n\n let size: number | undefined;\n let maxSize: number | undefined;\n let maxLength: number | undefined;\n let min: number | undefined;\n let max: number | undefined;\n let step: number | undefined;\n let precision: number | undefined;\n\n if (\n record &&\n record.property &&\n record.property.editor &&\n record.property.editor.params\n ) {\n const editorSizeParams = record.property.editor.params.find(\n (param: PropertyEditorParams) =>\n param.type === PropertyEditorParamTypes.InputEditorSize.valueOf()\n ) as InputEditorSizeParams;\n if (editorSizeParams) {\n if (editorSizeParams.size) size = editorSizeParams.size;\n if (editorSizeParams.maxSize) maxSize = editorSizeParams.maxSize;\n if (editorSizeParams.maxLength) maxLength = editorSizeParams.maxLength;\n }\n\n const rangeParams = record.property.editor.params.find(\n (param: PropertyEditorParams) =>\n param.type === PropertyEditorParamTypes.Range.valueOf()\n ) as RangeEditorParams;\n if (rangeParams) {\n min = rangeParams.minimum;\n max = rangeParams.maximum;\n step = rangeParams.step;\n precision = rangeParams.precision;\n }\n }\n\n if (this._isMounted)\n this.setState({\n value: initialValue,\n size,\n maxSize,\n maxLength,\n min,\n max,\n step,\n precision,\n });\n }\n\n public override render(): React.ReactNode {\n const { decoration } = this.props as InternalInputEditorProps;\n const className = classnames(\n \"components-cell-editor\",\n \"components-numeric-input-editor\",\n this.props.className\n );\n const minSize = this.state.size ? this.state.size : 8;\n const style: React.CSSProperties = {\n ...this.props.style,\n minWidth: `${minSize * 0.75}em`,\n maxWidth: this.state.maxSize\n ? `${this.state.maxSize * 0.75}em`\n : undefined,\n };\n\n return (\n <NumericEditor\n ref={this._inputElement}\n id={this.props.propertyRecord?.property.name}\n className={className}\n style={style}\n value={this.state.value}\n min={this.state.min}\n max={this.state.max}\n step={this.state.step}\n precision={this.state.precision}\n readOnly={this.props.propertyRecord?.isReadonly}\n disabled={this.props.propertyRecord?.isDisabled}\n maxLength={this.state.maxLength}\n onBlur={this.props.onBlur}\n onChange={this._updateValue}\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={\n this.props.setFocus && !this.props.propertyRecord?.isDisabled\n }\n isControlled={this.props.shouldCommitOnChange}\n decoration={decoration}\n />\n );\n }\n}\n\n/** Numeric Input Property Editor registered for the \"number\" type name and \"numeric-input\" editor name.\n * It uses the [[NumericInputEditor]] React component.\n * @public\n */\nexport class NumericInputPropertyEditor extends PropertyEditorBase {\n public get reactNode(): React.ReactNode {\n return <NumericInputEditor />;\n }\n public override get containerHandlesEnter(): boolean {\n // let input editor process enter key\n return false;\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-deprecated\ntype NumberInputProps = React.ComponentProps<typeof NumberInput>;\n\ninterface NumericEditorProps extends Omit<NumberInputProps, \"step\"> {\n decoration?: React.ReactNode;\n step?: number;\n}\n\nconst NumericEditor = React.forwardRef<HTMLInputElement, NumericEditorProps>(\n function NumericEditor(props, forwardedRef) {\n const { decoration, ...rest } = props;\n if (decoration) {\n return (\n <LockNumericEditor\n {...rest}\n ref={forwardedRef}\n decoration={decoration}\n />\n );\n }\n\n return (\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n <NumberInput ref={forwardedRef} {...rest} />\n );\n }\n);\n\ninterface LockNumericEditorProps extends NumericEditorProps {\n decoration: React.ReactNode;\n}\n\nconst LockNumericEditor = React.forwardRef<\n HTMLInputElement,\n LockNumericEditorProps\n>(function LockNumericEditor(props, forwardedRef) {\n const { decoration, precision, onChange, isControlled, ...rest } = props;\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n const value = event.target.value;\n onChange?.(Number(value), value);\n };\n return (\n <InputWithDecorations size=\"small\">\n <InputWithDecorations.Input\n {...rest}\n ref={forwardedRef}\n type=\"number\"\n onChange={handleChange}\n size=\"small\"\n />\n {decoration}\n </InputWithDecorations>\n );\n});\n"]}
|
|
@@ -37,6 +37,8 @@ export interface PopupButtonProps extends CommonProps {
|
|
|
37
37
|
onClose?: () => void;
|
|
38
38
|
/** Listens for Enter key in popup */
|
|
39
39
|
onEnter?: () => void;
|
|
40
|
+
/** Identifier applied to the focusable button element so a `<label htmlFor>` can reference it. */
|
|
41
|
+
id?: string;
|
|
40
42
|
}
|
|
41
43
|
/** @internal */
|
|
42
44
|
interface PopupButtonState {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PopupButton.d.ts","sourceRoot":"","sources":["../../../src/components-react/editors/PopupButton.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,oBAAoB,CAAC;AAE5B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAUrE;;GAEG;AAEH,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,sCAAsC;IACtC,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC;IAEjC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4BAA4B;IAC5B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,mCAAmC;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,mDAAmD;IACnD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,wKAAwK;IACxK,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,MAAM,CAAC;IAE3D,sDAAsD;IACtD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,iDAAiD;IACjD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,oFAAoF;IACpF,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,sBAAsB;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,sBAAsB;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,8CAA8C;IAC9C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;IAC5C,qCAAqC;IACrC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,qCAAqC;IACrC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"PopupButton.d.ts","sourceR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AU,gBAAgB;IACxB,SAAS,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,qBAAa,WAAY,SAAQ,KAAK,CAAC,aAAa,CAClD,gBAAgB,EAChB,gBAAgB,CACjB;IACC,OAAO,CAAC,UAAU,CAAqC;IAEvD,SAAyB,KAAK,EAAE,QAAQ,CAAC,gBAAgB,CAAC,CAExD;IAEc,iBAAiB;IAKjC,OAAO,CAAC,YAAY,CAOlB;IAEK,UAAU;IAIjB,OAAO,CAAC,WAAW,CAMjB;IAEF,OAAO,CAAC,cAAc,CAWpB;IAEc,MAAM,IAAI,KAAK,CAAC,SAAS;CAwE1C;AAED;;GAEG;AAEH,wBAAgB,YAAY,CAAC,KAAK,EAAE,cAAc,qBAGjD;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;IACxC,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;CAC7C;AAED;;GAEG;AAEH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,aAAa,qBA+BxD"}
|
|
@@ -59,7 +59,7 @@ export class PopupButton extends React.PureComponent {
|
|
|
59
59
|
const classNames = classnames("components-popup-button", this.state.showPopup && "components-popup-expanded", this.props.readonly && "components-readonly", this.props.disabled && "components-disabled");
|
|
60
60
|
const valueClassNames = classnames("components-popup-button-value", showPlaceholder && "components-popup-button-placeholder");
|
|
61
61
|
return (React.createElement("div", { className: this.props.className },
|
|
62
|
-
React.createElement("div", { className: classNames, onClick: this._togglePopup, onKeyDown: this._handleKeyDown, "data-testid": "components-popup-button", tabIndex: 0, ref: this._buttonRef, title: this.props.title, "aria-disabled": this.props.disabled, role: "button" },
|
|
62
|
+
React.createElement("div", { className: classNames, onClick: this._togglePopup, onKeyDown: this._handleKeyDown, "data-testid": "components-popup-button", tabIndex: 0, ref: this._buttonRef, title: this.props.title, "aria-disabled": this.props.disabled, role: "button", id: this.props.id },
|
|
63
63
|
React.createElement("div", { className: valueClassNames }, this.props.label || this.props.placeholder),
|
|
64
64
|
React.createElement("div", { className: "components-popup-button-arrow" },
|
|
65
65
|
React.createElement("div", { className: classnames("components-popup-button-arrow-icon", "icon") },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PopupButton.js","sourceRoot":"","sources":["../../../src/components-react/editors/PopupButton.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,oBAAoB,CAAC;AAC5B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EACL,YAAY,EACZ,cAAc,EACd,SAAS,GACV,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AA+C3D;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,KAAK,CAAC,aAGtC;IACS,UAAU,GAAG,KAAK,CAAC,SAAS,EAAkB,CAAC;IAE9B,KAAK,GAA+B;QAC3D,SAAS,EAAE,KAAK;KACjB,CAAC;IAEc,iBAAiB;QAC/B,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO;YAChD,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACpC,CAAC;IAEO,YAAY,GAAG,CAAC,KAAuB,EAAE,EAAE;QACjD,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,IAAI,CAAC,KAAK,CAAC,QAA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BAA+B,EAC/B,gCAAgC,CACjC,iBACW,gCAAgC,EAC5C,KAAK,EAAE,SAAS,CAAC,eAAe,CAAC,EACjC,OAAO,EAAE,KAAK,CAAC,QAAQ;YAGvB,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 { Key } from \"ts-key-enum\";\nimport { RelativePosition } from \"@itwin/appui-abstract\";\nimport type { CommonDivProps, CommonProps } from \"@itwin/core-react\";\nimport { Div, Icon, Popup } from \"@itwin/core-react\";\nimport { Button } from \"@itwin/itwinui-react\";\nimport {\n SvgCheckmark,\n SvgChevronDown,\n SvgRemove,\n} from \"@itwin/itwinui-icons-react\";\nimport { useTranslation } from \"../l10n/useTranslation.js\";\n\n/** Properties for [[PopupButton]] component\n * @alpha\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\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 | null> | 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 /** Disabled or not */\n disabled?: boolean;\n /** Readonly or not */\n readonly?: 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<\n PopupButtonProps,\n PopupButtonState\n> {\n private _buttonRef = React.createRef<HTMLDivElement>();\n\n public override readonly state: Readonly<PopupButtonState> = {\n showPopup: false,\n };\n\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 if (this.props.readonly || this.props.disabled) return;\n\n this.setState(\n (prevState) => ({ showPopup: !prevState.showPopup }),\n () => this.props.onClick && this.props.onClick(event)\n );\n };\n\n public closePopup() {\n this._closePopup();\n }\n\n private _closePopup = () => {\n this.setState({ showPopup: false }, () => {\n this.props.onClose && this.props.onClose();\n\n if (this._buttonRef.current) this._buttonRef.current.focus();\n });\n };\n\n private _handleKeyDown = (event: React.KeyboardEvent) => {\n if (\n (event.key === Key.ArrowDown.valueOf() ||\n event.key === \" \" ||\n event.key === Key.Enter.valueOf()) &&\n !this.state.showPopup\n ) {\n event.preventDefault();\n event.stopPropagation();\n this.setState({ showPopup: true });\n }\n };\n\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 =\n 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 this.props.readonly && \"components-readonly\",\n this.props.disabled && \"components-disabled\"\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\n 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 aria-disabled={this.props.disabled}\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\n className={classnames(\n \"components-popup-button-arrow-icon\",\n \"icon\"\n )}\n >\n {/* eslint-disable-next-line @typescript-eslint/no-deprecated */}\n <Icon iconSpec={<SvgChevronDown />} />\n </div>\n </div>\n </div>\n {/* eslint-disable-next-line @typescript-eslint/no-deprecated */}\n <Popup\n className=\"components-popup-button-popup\"\n isOpen={this.state.showPopup}\n position={RelativePosition.Bottom}\n onClose={this._closePopup}\n onEnter={this.props.onEnter}\n closeOnEnter={this.props.closeOnEnter}\n target={this._buttonRef.current}\n showArrow={showArrow}\n showShadow={showShadow}\n moveFocus={moveFocus}\n focusTarget={this.props.focusTarget}\n portalTarget={\n this._buttonRef.current?.ownerDocument.querySelector(\n \".uifw-configurableui-portalContainer\"\n ) ?? undefined\n }\n >\n {this.props.children}\n </Popup>\n </div>\n );\n }\n}\n\n/** Popup content with padding\n * @alpha\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport function PopupContent(props: CommonDivProps) {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n return <Div {...props} mainClassName=\"components-editor-popup-content\" />;\n}\n\n/** Properties for [[PopupOkCancelButtons]] component\n * @alpha\n * @deprecated in 4.17.0. Use `React.ComponentProps<typeof PopupOkCancelButtons>`\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 */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport function PopupOkCancelButtons(props: OkCancelProps) {\n const { translate } = useTranslation();\n return (\n <div className=\"components-popup-bottom-buttons\">\n <Button\n className={classnames(\n \"components-popup-large-button\",\n \"components-popup-ok-button\"\n )}\n data-testid=\"components-popup-ok-button\"\n styleType=\"cta\"\n title={translate(\"dialog.ok\")}\n onClick={props.onOk}\n >\n {/* eslint-disable-next-line @typescript-eslint/no-deprecated */}\n <Icon iconSpec={<SvgCheckmark />} />\n </Button>\n <Button\n className={classnames(\n \"components-popup-large-button\",\n \"components-popup-cancel-button\"\n )}\n data-testid=\"components-popup-cancel-button\"\n title={translate(\"dialog.cancel\")}\n onClick={props.onCancel}\n >\n {/* eslint-disable-next-line @typescript-eslint/no-deprecated */}\n <Icon iconSpec={<SvgRemove />} />\n </Button>\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"PopupButton.js","sourceRoot":"","sources":["../../../src/components-react/editors/PopupButton.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,oBAAoB,CAAC;AAC5B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EACL,YAAY,EACZ,cAAc,EACd,SAAS,GACV,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAiD3D;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,KAAK,CAAC,aAGtC;IACS,UAAU,GAAG,KAAK,CAAC,SAAS,EAAkB,CAAC;IAE9B,KAAK,GAA+B;QAC3D,SAAS,EAAE,KAAK;KACjB,CAAC;IAEc,iBAAiB;QAC/B,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,IAAI,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A+B,EAC/B,4BAA4B,CAC7B,iBACW,4BAA4B,EACxC,SAAS,EAAC,KAAK,EACf,KAAK,EAAE,SAAS,CAAC,WAAW,CAAC,EAC7B,OAAO,EAAE,KAAK,CAAC,IAAI;YAGnB,oBAAC,IAAI,IAAC,QAAQ,EAAE,oBAAC,YAAY,OAAG,GAAI,CAC7B;QACT,oBAAC,MAAM,IACL,SAAS,EAAE,UAAU,CACnB,+BAA+B,EAC/B,gCAAgC,CACjC,iBACW,gCAAgC,EAC5C,KAAK,EAAE,SAAS,CAAC,eAAe,CAAC,EACjC,OAAO,EAAE,KAAK,CAAC,QAAQ;YAGvB,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 { Key } from \"ts-key-enum\";\nimport { RelativePosition } from \"@itwin/appui-abstract\";\nimport type { CommonDivProps, CommonProps } from \"@itwin/core-react\";\nimport { Div, Icon, Popup } from \"@itwin/core-react\";\nimport { Button } from \"@itwin/itwinui-react\";\nimport {\n SvgCheckmark,\n SvgChevronDown,\n SvgRemove,\n} from \"@itwin/itwinui-icons-react\";\nimport { useTranslation } from \"../l10n/useTranslation.js\";\n\n/** Properties for [[PopupButton]] component\n * @alpha\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\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 | null> | 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 /** Disabled or not */\n disabled?: boolean;\n /** Readonly or not */\n readonly?: 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 /** Identifier applied to the focusable button element so a `<label htmlFor>` can reference it. */\n id?: string;\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<\n PopupButtonProps,\n PopupButtonState\n> {\n private _buttonRef = React.createRef<HTMLDivElement>();\n\n public override readonly state: Readonly<PopupButtonState> = {\n showPopup: false,\n };\n\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 if (this.props.readonly || this.props.disabled) return;\n\n this.setState(\n (prevState) => ({ showPopup: !prevState.showPopup }),\n () => this.props.onClick && this.props.onClick(event)\n );\n };\n\n public closePopup() {\n this._closePopup();\n }\n\n private _closePopup = () => {\n this.setState({ showPopup: false }, () => {\n this.props.onClose && this.props.onClose();\n\n if (this._buttonRef.current) this._buttonRef.current.focus();\n });\n };\n\n private _handleKeyDown = (event: React.KeyboardEvent) => {\n if (\n (event.key === Key.ArrowDown.valueOf() ||\n event.key === \" \" ||\n event.key === Key.Enter.valueOf()) &&\n !this.state.showPopup\n ) {\n event.preventDefault();\n event.stopPropagation();\n this.setState({ showPopup: true });\n }\n };\n\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 =\n 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 this.props.readonly && \"components-readonly\",\n this.props.disabled && \"components-disabled\"\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\n 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 aria-disabled={this.props.disabled}\n role=\"button\"\n id={this.props.id}\n >\n <div className={valueClassNames}>\n {this.props.label || this.props.placeholder}\n </div>\n <div className={\"components-popup-button-arrow\"}>\n <div\n className={classnames(\n \"components-popup-button-arrow-icon\",\n \"icon\"\n )}\n >\n {/* eslint-disable-next-line @typescript-eslint/no-deprecated */}\n <Icon iconSpec={<SvgChevronDown />} />\n </div>\n </div>\n </div>\n {/* eslint-disable-next-line @typescript-eslint/no-deprecated */}\n <Popup\n className=\"components-popup-button-popup\"\n isOpen={this.state.showPopup}\n position={RelativePosition.Bottom}\n onClose={this._closePopup}\n onEnter={this.props.onEnter}\n closeOnEnter={this.props.closeOnEnter}\n target={this._buttonRef.current}\n showArrow={showArrow}\n showShadow={showShadow}\n moveFocus={moveFocus}\n focusTarget={this.props.focusTarget}\n portalTarget={\n this._buttonRef.current?.ownerDocument.querySelector(\n \".uifw-configurableui-portalContainer\"\n ) ?? undefined\n }\n >\n {this.props.children}\n </Popup>\n </div>\n );\n }\n}\n\n/** Popup content with padding\n * @alpha\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport function PopupContent(props: CommonDivProps) {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n return <Div {...props} mainClassName=\"components-editor-popup-content\" />;\n}\n\n/** Properties for [[PopupOkCancelButtons]] component\n * @alpha\n * @deprecated in 4.17.0. Use `React.ComponentProps<typeof PopupOkCancelButtons>`\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 */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport function PopupOkCancelButtons(props: OkCancelProps) {\n const { translate } = useTranslation();\n return (\n <div className=\"components-popup-bottom-buttons\">\n <Button\n className={classnames(\n \"components-popup-large-button\",\n \"components-popup-ok-button\"\n )}\n data-testid=\"components-popup-ok-button\"\n styleType=\"cta\"\n title={translate(\"dialog.ok\")}\n onClick={props.onOk}\n >\n {/* eslint-disable-next-line @typescript-eslint/no-deprecated */}\n <Icon iconSpec={<SvgCheckmark />} />\n </Button>\n <Button\n className={classnames(\n \"components-popup-large-button\",\n \"components-popup-cancel-button\"\n )}\n data-testid=\"components-popup-cancel-button\"\n title={translate(\"dialog.cancel\")}\n onClick={props.onCancel}\n >\n {/* eslint-disable-next-line @typescript-eslint/no-deprecated */}\n <Icon iconSpec={<SvgRemove />} />\n </Button>\n </div>\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliderEditor.d.ts","sourceRoot":"","sources":["../../../src/components-react/editors/SliderEditor.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,qBAAqB,CAAC;AAE7B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAEV,aAAa,EAEd,MAAM,uBAAuB,CAAC;AAQ/B,OAAO,KAAK,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAShE,gBAAgB;AAChB,UAAU,iBAAiB;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,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AW,CAAqC;IAExD,SAAyB,KAAK,EAAE,QAAQ,CAAC,iBAAiB,CAAC,CAIzD;IAEW,gBAAgB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;IAenE,IAAW,WAAW,IAAI,WAAW,GAAG,IAAI,CAE3C;IAED,IAAW,QAAQ,IAAI,OAAO,CAK7B;IAED,OAAO,CAAC,aAAa,CAOnB;IAEc,iBAAiB;IAKjB,oBAAoB;IAIpC,gBAAgB;IACA,kBAAkB,CAAC,SAAS,EAAE,mBAAmB;IAMjE,OAAO,CAAC,qBAAqB,CAO3B;YAEY,iBAAiB;IA8G/B,OAAO,CAAC,YAAY,CAGlB;IAEF,OAAO,CAAC,YAAY,CAMlB;IAEF,OAAO,CAAC,SAAS,CAEf;IAEF,OAAO,CAAC,aAAa,CAInB;IAEF,OAAO,CAAC,aAAa,CAUnB;IAEF,OAAO,CAAC,YAAY,CASlB;IAEc,MAAM,IAAI,KAAK,CAAC,SAAS;CAyD1C;AAED;;;GAGG;AACH,qBAAa,oBAAqB,SAAQ,kBAAkB;IAC1D,IAAW,SAAS,IAAI,KAAK,CAAC,SAAS,CAEtC;CACF"}
|
|
@@ -215,7 +215,7 @@ export class SliderEditor extends React.PureComponent {
|
|
|
215
215
|
};
|
|
216
216
|
const popupContent = (React.createElement(Slider, { className: "components-slider-editor-slider", style: style, values: [this.state.value], min: this.state.min, max: this.state.max, step: this.state.step, thumbMode: this.state.thumbMode, trackDisplayMode: this.state.trackDisplayMode, disabled: this.props.propertyRecord?.isDisabled, minLabel: this.state.minLabel, maxLabel: this.state.maxLabel, tooltipProps: this.tooltipProps, tickLabels: this.state.tickLabels, tickProps: tickProps, onChange: this._handleChange }));
|
|
217
217
|
return (React.createElement("div", { className: className, ref: this._divElement },
|
|
218
|
-
React.createElement(PopupButton, { label: this.state.value, onClose: this._handleClose, onEnter: this._handleEnter, setFocus: this.props.setFocus, disabled: this.props.propertyRecord?.isDisabled, readonly: this.props.propertyRecord?.isReadonly },
|
|
218
|
+
React.createElement(PopupButton, { id: this.props.propertyRecord?.property.name, label: this.state.value, onClose: this._handleClose, onEnter: this._handleEnter, setFocus: this.props.setFocus, disabled: this.props.propertyRecord?.isDisabled, readonly: this.props.propertyRecord?.isReadonly },
|
|
219
219
|
React.createElement(PopupContent, null,
|
|
220
220
|
popupContent,
|
|
221
221
|
React.createElement(PopupOkCancelButtons, { onOk: this._handleOk, onCancel: this._handleCancel })))));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliderEditor.js","sourceRoot":"","sources":["../../../src/components-react/editors/SliderEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,qBAAqB,CAAC;AAC7B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,OAAO,EACL,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EACL,WAAW,EACX,YAAY,EACZ,oBAAoB,GACrB,MAAM,kBAAkB,CAAC;AAqB1B;;GAEG;AACH,MAAM,OAAO,YACX,SAAQ,KAAK,CAAC,aAAqD;IAG3D,UAAU,GAAG,KAAK,CAAC;IACnB,SAAS,GAAG,KAAK,CAAC;IAClB,WAAW,GAAG,KAAK,CAAC,SAAS,EAAkB,CAAC;IAE/B,KAAK,GAAgC;QAC5D,KAAK,EAAE,CAAC;QACR,GAAG,EAAE,CAAC;QACN,GAAG,EAAE,GAAG;KACT,CAAC;IAEK,KAAK,CAAC,gBAAgB;QAC3B,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC;QACzC,IAAI,aAAwC,CAAC;QAE7C,IAAI,MAAM,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C,KAAK,CAAC,SAAS,EAC/B,gBAAgB,EAAE,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAC7C,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,UAAU,EAC/C,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAC7B,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAC7B,YAAY,EAAE,IAAI,CAAC,YAAY,EAC/B,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EACjC,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,IAAI,CAAC,aAAa,GAC5B,CACH,CAAC;QAEF,OAAO,CACL,6BAAK,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,IAAI,CAAC,WAAW;YAC9C,oBAAC,WAAW,IACV,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,OAAO,EAAE,IAAI,CAAC,YAAY,EAC1B,OAAO,EAAE,IAAI,CAAC,YAAY,EAC1B,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAC7B,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,UAAU,EAC/C,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,UAAU;gBAE/C,oBAAC,YAAY;oBACV,YAAY;oBACb,oBAAC,oBAAoB,IACnB,IAAI,EAAE,IAAI,CAAC,SAAS,EACpB,QAAQ,EAAE,IAAI,CAAC,aAAa,GAC5B,CACW,CACH,CACV,CACP,CAAC;IACJ,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,oBAAqB,SAAQ,kBAAkB;IAC1D,IAAW,SAAS;QAClB,OAAO,oBAAC,YAAY,OAAG,CAAC;IAC1B,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 \"./SliderEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type {\n PropertyEditorParams,\n PropertyValue,\n SliderEditorParams,\n} from \"@itwin/appui-abstract\";\nimport {\n PropertyEditorParamTypes,\n PropertyValueFormat,\n} from \"@itwin/appui-abstract\";\nimport { Icon } from \"@itwin/core-react\";\nimport type { Tooltip } from \"@itwin/itwinui-react\";\nimport { Slider } from \"@itwin/itwinui-react\";\nimport type { PropertyEditorProps, TypeEditor } from \"./EditorContainer.js\";\nimport { PropertyEditorBase } from \"./PropertyEditorManager.js\";\nimport {\n PopupButton,\n PopupContent,\n PopupOkCancelButtons,\n} from \"./PopupButton.js\";\n\ntype TooltipProps = React.ComponentPropsWithoutRef<typeof Tooltip>;\n\n/** @internal */\ninterface SliderEditorState {\n value: number;\n min: number;\n max: number;\n size?: number;\n step?: number;\n showTooltip?: boolean;\n tooltipBelow?: boolean;\n formatTooltip?: (value: number) => string;\n thumbMode?: \"allow-crossing\" | \"inhibit-crossing\";\n trackDisplayMode?: \"auto\" | \"none\" | \"odd-segments\" | \"even-segments\";\n minLabel?: React.ReactNode;\n maxLabel?: React.ReactNode;\n tickLabels?: React.ReactNode;\n}\n\n/** SliderEditor React component that is a property editor with numeric input & up/down buttons\n * @public\n */\nexport class SliderEditor\n extends React.PureComponent<PropertyEditorProps, SliderEditorState>\n implements TypeEditor\n{\n private _isMounted = false;\n private _enterKey = false;\n private _divElement = React.createRef<HTMLDivElement>();\n\n public override readonly state: Readonly<SliderEditorState> = {\n value: 0,\n min: 0,\n max: 100,\n };\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n propertyValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: this.state.value,\n displayValue: \"\",\n };\n }\n\n return propertyValue;\n }\n\n public get htmlElement(): HTMLElement | null {\n return this._divElement.current;\n }\n\n public get hasFocus(): boolean {\n let containsFocus = false;\n if (this.htmlElement)\n containsFocus = this.htmlElement.contains(document.activeElement);\n return containsFocus;\n }\n\n private _handleChange = (values: readonly number[]): void => {\n const newValue = values[0];\n\n if (this._isMounted)\n this.setState({\n value: newValue,\n });\n };\n\n public override componentDidMount() {\n this._isMounted = true;\n void this.setStateFromProps();\n }\n\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 void this.setStateFromProps();\n }\n }\n\n private internalFormatTooltip = (value: number, step = 1) => {\n if (Number.isInteger(step)) return value.toFixed(0);\n\n const stepString = step.toString();\n const decimalIndex = stepString.indexOf(\".\");\n const numDecimals = step.toString().length - (decimalIndex + 1);\n return value.toFixed(numDecimals);\n };\n\n private async setStateFromProps() {\n const record = this.props.propertyRecord;\n let initialValue = 0;\n\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n initialValue = record.value.value as number;\n }\n\n let size: number | undefined;\n let min = 0;\n let max = 100;\n let step: number | undefined;\n let showTooltip: boolean | undefined;\n let tooltipBelow: boolean | undefined;\n let formatTooltip: ((value: number) => string) | undefined;\n let tickLabels: string[] | undefined;\n let minLabel: React.ReactNode | undefined;\n let maxLabel: React.ReactNode | undefined;\n let trackDisplayMode:\n | \"auto\"\n | \"none\"\n | \"odd-segments\"\n | \"even-segments\"\n | undefined;\n let thumbMode: \"allow-crossing\" | \"inhibit-crossing\" | undefined;\n\n if (\n record &&\n record.property &&\n record.property.editor &&\n record.property.editor.params\n ) {\n const sliderParams = record.property.editor.params.find(\n (param: PropertyEditorParams) =>\n param.type === PropertyEditorParamTypes.Slider.valueOf()\n ) as SliderEditorParams;\n if (sliderParams) {\n min = sliderParams.minimum;\n max = sliderParams.maximum;\n size = sliderParams.size;\n step = sliderParams.step;\n thumbMode =\n 1 === sliderParams.mode ? \"allow-crossing\" : \"inhibit-crossing\";\n trackDisplayMode = !sliderParams.reversed ? \"auto\" : \"odd-segments\";\n showTooltip = sliderParams.showTooltip;\n tooltipBelow = sliderParams.tooltipBelow;\n formatTooltip = sliderParams.formatTooltip;\n\n minLabel = !sliderParams.showMinMax ? (\n \"\"\n ) : sliderParams.minIconSpec ? (\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n <Icon iconSpec={sliderParams.minIconSpec} />\n ) : undefined;\n maxLabel = !sliderParams.showMinMax ? (\n \"\"\n ) : sliderParams.maxIconSpec ? (\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n <Icon iconSpec={sliderParams.maxIconSpec} />\n ) : undefined;\n\n if (sliderParams.showTicks) {\n const count = sliderParams.getTickCount\n ? sliderParams.getTickCount()\n : 0;\n if (count) {\n tickLabels = [];\n const increment = (max - min) / count;\n for (let i = 0; i <= count; i++) {\n const value = i * increment + min;\n if (sliderParams.showTickLabels) {\n const label = sliderParams.formatTick\n ? sliderParams.formatTick(value)\n : this.internalFormatTooltip(value, step);\n tickLabels.push(label);\n } else {\n tickLabels.push(\"\");\n }\n }\n } else if (sliderParams.getTickValues) {\n tickLabels = sliderParams\n .getTickValues()\n .map((val: number) =>\n sliderParams.formatTick\n ? sliderParams.formatTick(val)\n : this.internalFormatTooltip(val, step)\n );\n }\n }\n }\n }\n\n if (this._isMounted)\n this.setState({\n value: initialValue,\n size,\n min,\n max,\n step,\n trackDisplayMode,\n showTooltip,\n tooltipBelow,\n formatTooltip,\n minLabel,\n maxLabel,\n tickLabels,\n thumbMode,\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 if (this.props.onCancel) 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 if (this.props.onCancel) {\n this.props.onCancel();\n }\n };\n\n private _handleCommit = async (): Promise<void> => {\n if (this.props.propertyRecord && this.props.onCommit) {\n const propertyValue = await this.getPropertyValue();\n if (propertyValue !== undefined) {\n this.props.onCommit({\n propertyRecord: this.props.propertyRecord,\n newValue: propertyValue,\n });\n }\n }\n };\n\n private tooltipProps = (_index: number, val: number) => {\n const content = this.state.formatTooltip\n ? this.state.formatTooltip(val)\n : this.internalFormatTooltip(val, this.state.step);\n return {\n placement: this.state.tooltipBelow ? \"bottom\" : \"top\",\n content,\n visible: this.state.showTooltip,\n } as Partial<Omit<TooltipProps, \"children\">>;\n };\n\n public override render(): React.ReactNode {\n const className = classnames(\n \"components-cell-editor\",\n \"components-slider-editor\",\n this.props.className\n );\n const minSize = this.state.size ? this.state.size : 100;\n const style: React.CSSProperties = {\n ...this.props.style,\n minWidth: `${minSize}px`,\n };\n\n const tickProps = {\n \"data-testid\": \"components-tick\",\n } as React.ComponentProps<\"span\">;\n const popupContent = (\n <Slider\n className=\"components-slider-editor-slider\"\n style={style}\n values={[this.state.value]}\n min={this.state.min}\n max={this.state.max}\n step={this.state.step}\n thumbMode={this.state.thumbMode}\n trackDisplayMode={this.state.trackDisplayMode}\n disabled={this.props.propertyRecord?.isDisabled}\n minLabel={this.state.minLabel}\n maxLabel={this.state.maxLabel}\n tooltipProps={this.tooltipProps}\n tickLabels={this.state.tickLabels}\n tickProps={tickProps}\n onChange={this._handleChange}\n />\n );\n\n return (\n <div className={className} ref={this._divElement}>\n <PopupButton\n label={this.state.value}\n onClose={this._handleClose}\n onEnter={this._handleEnter}\n setFocus={this.props.setFocus}\n disabled={this.props.propertyRecord?.isDisabled}\n readonly={this.props.propertyRecord?.isReadonly}\n >\n <PopupContent>\n {popupContent}\n <PopupOkCancelButtons\n onOk={this._handleOk}\n onCancel={this._handleCancel}\n />\n </PopupContent>\n </PopupButton>\n </div>\n );\n }\n}\n\n/** Slider Property Editor registered for the \"number\" type name and \"slider\" editor name.\n * It uses the [[SliderEditor]] React component.\n * @public\n */\nexport class SliderPropertyEditor extends PropertyEditorBase {\n public get reactNode(): React.ReactNode {\n return <SliderEditor />;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"SliderEditor.js","sourceRoot":"","sources":["../../../src/components-react/editors/SliderEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,qBAAqB,CAAC;AAC7B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,OAAO,EACL,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EACL,WAAW,EACX,YAAY,EACZ,oBAAoB,GACrB,MAAM,kBAAkB,CAAC;AAqB1B;;GAEG;AACH,MAAM,OAAO,YACX,SAAQ,KAAK,CAAC,aAAqD;IAG3D,UAAU,GAAG,KAAK,CAAC;IACnB,SAAS,GAAG,KAAK,CAAC;IAClB,WAAW,GAAG,KAAK,CAAC,SAAS,EAAkB,CAAC;IAE/B,KAAK,GAAgC;QAC5D,KAAK,EAAE,CAAC;QACR,GAAG,EAAE,CAAC;QACN,GAAG,EAAE,GAAG;KACT,CAAC;IAEK,KAAK,CAAC,gBAAgB;QAC3B,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC;QACzC,IAAI,aAAwC,CAAC;QAE7C,IAAI,MAAM,IAAI,MAAM,CAAC,KAAK,CAAC,WAAW,KAAK,mBAAmB,CAAC,SAAS,EAAE,CAAC;YACzE,aAAa,GAAG;gBACd,WAAW,EAAE,mBAAmB,CAAC,SAAS;gBAC1C,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK;gBACvB,YA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C7B,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAC7B,YAAY,EAAE,IAAI,CAAC,YAAY,EAC/B,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EACjC,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,IAAI,CAAC,aAAa,GAC5B,CACH,CAAC;QAEF,OAAO,CACL,6BAAK,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,IAAI,CAAC,WAAW;YAC9C,oBAAC,WAAW,IACV,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,QAAQ,CAAC,IAAI,EAC5C,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,OAAO,EAAE,IAAI,CAAC,YAAY,EAC1B,OAAO,EAAE,IAAI,CAAC,YAAY,EAC1B,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAC7B,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,UAAU,EAC/C,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,UAAU;gBAE/C,oBAAC,YAAY;oBACV,YAAY;oBACb,oBAAC,oBAAoB,IACnB,IAAI,EAAE,IAAI,CAAC,SAAS,EACpB,QAAQ,EAAE,IAAI,CAAC,aAAa,GAC5B,CACW,CACH,CACV,CACP,CAAC;IACJ,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,oBAAqB,SAAQ,kBAAkB;IAC1D,IAAW,SAAS;QAClB,OAAO,oBAAC,YAAY,OAAG,CAAC;IAC1B,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 \"./SliderEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type {\n PropertyEditorParams,\n PropertyValue,\n SliderEditorParams,\n} from \"@itwin/appui-abstract\";\nimport {\n PropertyEditorParamTypes,\n PropertyValueFormat,\n} from \"@itwin/appui-abstract\";\nimport { Icon } from \"@itwin/core-react\";\nimport type { Tooltip } from \"@itwin/itwinui-react\";\nimport { Slider } from \"@itwin/itwinui-react\";\nimport type { PropertyEditorProps, TypeEditor } from \"./EditorContainer.js\";\nimport { PropertyEditorBase } from \"./PropertyEditorManager.js\";\nimport {\n PopupButton,\n PopupContent,\n PopupOkCancelButtons,\n} from \"./PopupButton.js\";\n\ntype TooltipProps = React.ComponentPropsWithoutRef<typeof Tooltip>;\n\n/** @internal */\ninterface SliderEditorState {\n value: number;\n min: number;\n max: number;\n size?: number;\n step?: number;\n showTooltip?: boolean;\n tooltipBelow?: boolean;\n formatTooltip?: (value: number) => string;\n thumbMode?: \"allow-crossing\" | \"inhibit-crossing\";\n trackDisplayMode?: \"auto\" | \"none\" | \"odd-segments\" | \"even-segments\";\n minLabel?: React.ReactNode;\n maxLabel?: React.ReactNode;\n tickLabels?: React.ReactNode;\n}\n\n/** SliderEditor React component that is a property editor with numeric input & up/down buttons\n * @public\n */\nexport class SliderEditor\n extends React.PureComponent<PropertyEditorProps, SliderEditorState>\n implements TypeEditor\n{\n private _isMounted = false;\n private _enterKey = false;\n private _divElement = React.createRef<HTMLDivElement>();\n\n public override readonly state: Readonly<SliderEditorState> = {\n value: 0,\n min: 0,\n max: 100,\n };\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n propertyValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: this.state.value,\n displayValue: \"\",\n };\n }\n\n return propertyValue;\n }\n\n public get htmlElement(): HTMLElement | null {\n return this._divElement.current;\n }\n\n public get hasFocus(): boolean {\n let containsFocus = false;\n if (this.htmlElement)\n containsFocus = this.htmlElement.contains(document.activeElement);\n return containsFocus;\n }\n\n private _handleChange = (values: readonly number[]): void => {\n const newValue = values[0];\n\n if (this._isMounted)\n this.setState({\n value: newValue,\n });\n };\n\n public override componentDidMount() {\n this._isMounted = true;\n void this.setStateFromProps();\n }\n\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 void this.setStateFromProps();\n }\n }\n\n private internalFormatTooltip = (value: number, step = 1) => {\n if (Number.isInteger(step)) return value.toFixed(0);\n\n const stepString = step.toString();\n const decimalIndex = stepString.indexOf(\".\");\n const numDecimals = step.toString().length - (decimalIndex + 1);\n return value.toFixed(numDecimals);\n };\n\n private async setStateFromProps() {\n const record = this.props.propertyRecord;\n let initialValue = 0;\n\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n initialValue = record.value.value as number;\n }\n\n let size: number | undefined;\n let min = 0;\n let max = 100;\n let step: number | undefined;\n let showTooltip: boolean | undefined;\n let tooltipBelow: boolean | undefined;\n let formatTooltip: ((value: number) => string) | undefined;\n let tickLabels: string[] | undefined;\n let minLabel: React.ReactNode | undefined;\n let maxLabel: React.ReactNode | undefined;\n let trackDisplayMode:\n | \"auto\"\n | \"none\"\n | \"odd-segments\"\n | \"even-segments\"\n | undefined;\n let thumbMode: \"allow-crossing\" | \"inhibit-crossing\" | undefined;\n\n if (\n record &&\n record.property &&\n record.property.editor &&\n record.property.editor.params\n ) {\n const sliderParams = record.property.editor.params.find(\n (param: PropertyEditorParams) =>\n param.type === PropertyEditorParamTypes.Slider.valueOf()\n ) as SliderEditorParams;\n if (sliderParams) {\n min = sliderParams.minimum;\n max = sliderParams.maximum;\n size = sliderParams.size;\n step = sliderParams.step;\n thumbMode =\n 1 === sliderParams.mode ? \"allow-crossing\" : \"inhibit-crossing\";\n trackDisplayMode = !sliderParams.reversed ? \"auto\" : \"odd-segments\";\n showTooltip = sliderParams.showTooltip;\n tooltipBelow = sliderParams.tooltipBelow;\n formatTooltip = sliderParams.formatTooltip;\n\n minLabel = !sliderParams.showMinMax ? (\n \"\"\n ) : sliderParams.minIconSpec ? (\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n <Icon iconSpec={sliderParams.minIconSpec} />\n ) : undefined;\n maxLabel = !sliderParams.showMinMax ? (\n \"\"\n ) : sliderParams.maxIconSpec ? (\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n <Icon iconSpec={sliderParams.maxIconSpec} />\n ) : undefined;\n\n if (sliderParams.showTicks) {\n const count = sliderParams.getTickCount\n ? sliderParams.getTickCount()\n : 0;\n if (count) {\n tickLabels = [];\n const increment = (max - min) / count;\n for (let i = 0; i <= count; i++) {\n const value = i * increment + min;\n if (sliderParams.showTickLabels) {\n const label = sliderParams.formatTick\n ? sliderParams.formatTick(value)\n : this.internalFormatTooltip(value, step);\n tickLabels.push(label);\n } else {\n tickLabels.push(\"\");\n }\n }\n } else if (sliderParams.getTickValues) {\n tickLabels = sliderParams\n .getTickValues()\n .map((val: number) =>\n sliderParams.formatTick\n ? sliderParams.formatTick(val)\n : this.internalFormatTooltip(val, step)\n );\n }\n }\n }\n }\n\n if (this._isMounted)\n this.setState({\n value: initialValue,\n size,\n min,\n max,\n step,\n trackDisplayMode,\n showTooltip,\n tooltipBelow,\n formatTooltip,\n minLabel,\n maxLabel,\n tickLabels,\n thumbMode,\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 if (this.props.onCancel) 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 if (this.props.onCancel) {\n this.props.onCancel();\n }\n };\n\n private _handleCommit = async (): Promise<void> => {\n if (this.props.propertyRecord && this.props.onCommit) {\n const propertyValue = await this.getPropertyValue();\n if (propertyValue !== undefined) {\n this.props.onCommit({\n propertyRecord: this.props.propertyRecord,\n newValue: propertyValue,\n });\n }\n }\n };\n\n private tooltipProps = (_index: number, val: number) => {\n const content = this.state.formatTooltip\n ? this.state.formatTooltip(val)\n : this.internalFormatTooltip(val, this.state.step);\n return {\n placement: this.state.tooltipBelow ? \"bottom\" : \"top\",\n content,\n visible: this.state.showTooltip,\n } as Partial<Omit<TooltipProps, \"children\">>;\n };\n\n public override render(): React.ReactNode {\n const className = classnames(\n \"components-cell-editor\",\n \"components-slider-editor\",\n this.props.className\n );\n const minSize = this.state.size ? this.state.size : 100;\n const style: React.CSSProperties = {\n ...this.props.style,\n minWidth: `${minSize}px`,\n };\n\n const tickProps = {\n \"data-testid\": \"components-tick\",\n } as React.ComponentProps<\"span\">;\n const popupContent = (\n <Slider\n className=\"components-slider-editor-slider\"\n style={style}\n values={[this.state.value]}\n min={this.state.min}\n max={this.state.max}\n step={this.state.step}\n thumbMode={this.state.thumbMode}\n trackDisplayMode={this.state.trackDisplayMode}\n disabled={this.props.propertyRecord?.isDisabled}\n minLabel={this.state.minLabel}\n maxLabel={this.state.maxLabel}\n tooltipProps={this.tooltipProps}\n tickLabels={this.state.tickLabels}\n tickProps={tickProps}\n onChange={this._handleChange}\n />\n );\n\n return (\n <div className={className} ref={this._divElement}>\n <PopupButton\n id={this.props.propertyRecord?.property.name}\n label={this.state.value}\n onClose={this._handleClose}\n onEnter={this._handleEnter}\n setFocus={this.props.setFocus}\n disabled={this.props.propertyRecord?.isDisabled}\n readonly={this.props.propertyRecord?.isReadonly}\n >\n <PopupContent>\n {popupContent}\n <PopupOkCancelButtons\n onOk={this._handleOk}\n onCancel={this._handleCancel}\n />\n </PopupContent>\n </PopupButton>\n </div>\n );\n }\n}\n\n/** Slider Property Editor registered for the \"number\" type name and \"slider\" editor name.\n * It uses the [[SliderEditor]] React component.\n * @public\n */\nexport class SliderPropertyEditor extends PropertyEditorBase {\n public get reactNode(): React.ReactNode {\n return <SliderEditor />;\n }\n}\n"]}
|
|
@@ -8,6 +8,7 @@ import type { PropertyEditorProps, TypeEditor } from "./EditorContainer.js";
|
|
|
8
8
|
/** @internal */
|
|
9
9
|
interface TextEditorState {
|
|
10
10
|
inputValue: string;
|
|
11
|
+
originalValue: string;
|
|
11
12
|
size?: number;
|
|
12
13
|
maxSize?: number;
|
|
13
14
|
maxLength?: number;
|
|
@@ -23,6 +24,7 @@ export declare class TextEditor extends React.PureComponent<PropertyEditorProps,
|
|
|
23
24
|
getPropertyValue(): Promise<PropertyValue | undefined>;
|
|
24
25
|
get htmlElement(): HTMLElement | null;
|
|
25
26
|
get hasFocus(): boolean;
|
|
27
|
+
private _onFocus;
|
|
26
28
|
private _updateInputValue;
|
|
27
29
|
componentDidMount(): void;
|
|
28
30
|
componentWillUnmount(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextEditor.d.ts","sourceRoot":"","sources":["../../../src/components-react/editors/TextEditor.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,mBAAmB,CAAC;AAE3B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAKV,aAAa,EACd,MAAM,uBAAuB,CAAC;AAQ/B,OAAO,KAAK,EAEV,mBAAmB,EACnB,UAAU,EACX,MAAM,sBAAsB,CAAC;AAK9B,gBAAgB;AAChB,UAAU,eAAe;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,qBAAa,UACX,SAAQ,KAAK,CAAC,aAAa,CAAC,mBAAmB,EAAE,eAAe,CAChE,YAAW,UAAU;IAErB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,aAAa,CAAuC;IAE5D,SAAyB,KAAK,EAAE,QAAQ,CAAC,eAAe,CAAC,
|
|
1
|
+
{"version":3,"file":"TextEditor.d.ts","sourceRoot":"","sources":["../../../src/components-react/editors/TextEditor.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,mBAAmB,CAAC;AAE3B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAKV,aAAa,EACd,MAAM,uBAAuB,CAAC;AAQ/B,OAAO,KAAK,EAEV,mBAAmB,EACnB,UAAU,EACX,MAAM,sBAAsB,CAAC;AAK9B,gBAAgB;AAChB,UAAU,eAAe;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,qBAAa,UACX,SAAQ,KAAK,CAAC,aAAa,CAAC,mBAAmB,EAAE,eAAe,CAChE,YAAW,UAAU;IAErB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,aAAa,CAAuC;IAE5D,SAAyB,KAAK,EAAE,QAAQ,CAAC,eAAe,CAAC,CAGvD;IAEW,gBAAgB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;IAenE,IAAW,WAAW,IAAI,WAAW,GAAG,IAAI,CAE3C;IAED,IAAW,QAAQ,IAAI,OAAO,CAE7B;IAED,OAAO,CAAC,QAAQ,CAOd;IAEF,OAAO,CAAC,iBAAiB,CAqBvB;IAEc,iBAAiB;IAKjB,oBAAoB;IAIpC,gBAAgB;IACA,kBAAkB,CAAC,SAAS,EAAE,mBAAmB;YAMnD,iBAAiB;IAqDf,MAAM,IAAI,KAAK,CAAC,SAAS;CA2C1C"}
|
|
@@ -21,6 +21,7 @@ export class TextEditor extends React.PureComponent {
|
|
|
21
21
|
_inputElement = React.createRef();
|
|
22
22
|
state = {
|
|
23
23
|
inputValue: "",
|
|
24
|
+
originalValue: "",
|
|
24
25
|
};
|
|
25
26
|
async getPropertyValue() {
|
|
26
27
|
const record = this.props.propertyRecord;
|
|
@@ -37,6 +38,14 @@ export class TextEditor extends React.PureComponent {
|
|
|
37
38
|
get hasFocus() {
|
|
38
39
|
return document.activeElement === this._inputElement.current;
|
|
39
40
|
}
|
|
41
|
+
_onFocus = () => {
|
|
42
|
+
if (this._isMounted && this.props.propertyRecord?.isMerged) {
|
|
43
|
+
this.setState((prevState) => ({
|
|
44
|
+
...prevState,
|
|
45
|
+
inputValue: prevState.originalValue,
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
48
|
+
};
|
|
40
49
|
_updateInputValue = (e) => {
|
|
41
50
|
if (this._isMounted)
|
|
42
51
|
this.setState({
|
|
@@ -98,7 +107,8 @@ export class TextEditor extends React.PureComponent {
|
|
|
98
107
|
}
|
|
99
108
|
if (this._isMounted)
|
|
100
109
|
this.setState({
|
|
101
|
-
inputValue: initialValue,
|
|
110
|
+
inputValue: record?.isMerged && !this.hasFocus ? "--" : initialValue,
|
|
111
|
+
originalValue: initialValue,
|
|
102
112
|
size,
|
|
103
113
|
maxSize,
|
|
104
114
|
maxLength,
|
|
@@ -124,6 +134,7 @@ export class TextEditor extends React.PureComponent {
|
|
|
124
134
|
maxLength: this.state.maxLength,
|
|
125
135
|
value: this.state.inputValue,
|
|
126
136
|
onBlur: this.props.onBlur,
|
|
137
|
+
onFocus: this._onFocus,
|
|
127
138
|
onChange: this._updateInputValue,
|
|
128
139
|
autoFocus: this.props.setFocus && !this.props.propertyRecord?.isDisabled,
|
|
129
140
|
"aria-label": UiComponents.translate("editor.text"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextEditor.js","sourceRoot":"","sources":["../../../src/components-react/editors/TextEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,mBAAmB,CAAC;AAC3B,OAAO,U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,EACjB,IAAI,EAAE,IAAI,iBACE,wBAAwB,GACpC,CACH,CAAC;IACJ,CAAC;IACD,OAAO,CACL,oBAAC,KAAK,OACA,IAAI,EACR,GAAG,EAAE,YAAY,iBACL,wBAAwB,EACpC,IAAI,EAAC,OAAO,GACZ,CACH,CAAC;AACJ,CAAC,CACF,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 \"./TextEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type {\n IconEditorParams,\n InputEditorSizeParams,\n PrimitiveValue,\n PropertyEditorParams,\n PropertyValue,\n} from \"@itwin/appui-abstract\";\nimport {\n PropertyEditorParamTypes,\n PropertyValueFormat,\n} from \"@itwin/appui-abstract\";\nimport { Icon, IconInput } from \"@itwin/core-react\";\nimport { Input, InputWithDecorations } from \"@itwin/itwinui-react\";\nimport { TypeConverterManager } from \"../converters/TypeConverterManager.js\";\nimport type {\n InternalInputEditorProps,\n PropertyEditorProps,\n TypeEditor,\n} from \"./EditorContainer.js\";\nimport { UiComponents } from \"../UiComponents.js\";\n\ntype InputProps = React.ComponentPropsWithoutRef<typeof Input>;\n\n/** @internal */\ninterface TextEditorState {\n inputValue: string;\n size?: number;\n maxSize?: 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\n extends React.PureComponent<PropertyEditorProps, TextEditorState>\n implements TypeEditor\n{\n private _isMounted = false;\n private _inputElement = React.createRef<HTMLInputElement>();\n\n public override readonly state: Readonly<TextEditorState> = {\n inputValue: \"\",\n };\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n propertyValue = await TypeConverterManager.getConverter(\n record.property.typename,\n record.property.converter?.name\n ).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 if (this._isMounted)\n this.setState(\n {\n inputValue: e.target.value,\n },\n async () => {\n if (\n this.props.shouldCommitOnChange &&\n this.props.onCommit &&\n this.props.propertyRecord\n ) {\n const newValue = await this.getPropertyValue();\n if (newValue)\n this.props.onCommit({\n propertyRecord: this.props.propertyRecord,\n newValue,\n });\n }\n }\n );\n };\n\n public override componentDidMount() {\n this._isMounted = true;\n void this.setStateFromProps();\n }\n\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 void this.setStateFromProps();\n }\n }\n\n private async setStateFromProps() {\n const record = this.props.propertyRecord;\n let initialValue = \"\";\n\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n const value = record.value.value;\n initialValue = await TypeConverterManager.getConverter(\n record.property.typename,\n record.property.converter?.name\n ).convertPropertyToString(record.property, value);\n }\n\n let size: number | undefined;\n let maxSize: number | undefined;\n let maxLength: number | undefined;\n let iconSpec: string | undefined;\n\n if (\n record &&\n record.property &&\n record.property.editor &&\n record.property.editor.params\n ) {\n const editorSizeParams = record.property.editor.params.find(\n (param: PropertyEditorParams) =>\n param.type === PropertyEditorParamTypes.InputEditorSize.valueOf()\n ) as InputEditorSizeParams;\n if (editorSizeParams) {\n if (editorSizeParams.size) size = editorSizeParams.size;\n if (editorSizeParams.maxSize) maxSize = editorSizeParams.maxSize;\n if (editorSizeParams.maxLength) maxLength = editorSizeParams.maxLength;\n }\n\n const iconParams = record.property.editor.params.find(\n (param: PropertyEditorParams) =>\n param.type === PropertyEditorParamTypes.Icon.valueOf()\n ) as IconEditorParams;\n if (iconParams) {\n iconSpec = iconParams.definition.iconSpec;\n }\n }\n\n if (this._isMounted)\n this.setState({\n inputValue: initialValue,\n size,\n maxSize,\n maxLength,\n iconSpec,\n });\n }\n\n public override render(): React.ReactNode {\n const { decoration } = this.props as InternalInputEditorProps;\n const className = classnames(\n \"components-cell-editor\",\n \"components-text-editor\",\n this.props.className\n );\n const minSize = this.state.size ? this.state.size : 8;\n const style: React.CSSProperties = {\n minWidth: `${minSize * 0.75}em`,\n maxWidth: this.state.maxSize\n ? `${this.state.maxSize * 0.75}em`\n : undefined,\n };\n const inputProps: InputProps = {\n type: \"text\",\n className,\n style: this.props.style ? this.props.style : style,\n readOnly: this.props.propertyRecord?.isReadonly,\n disabled: this.props.propertyRecord?.isDisabled,\n maxLength: this.state.maxLength,\n value: this.state.inputValue,\n onBlur: this.props.onBlur,\n onChange: this._updateInputValue,\n autoFocus: this.props.setFocus && !this.props.propertyRecord?.isDisabled,\n \"aria-label\": UiComponents.translate(\"editor.text\"),\n };\n\n const icon = this.state.iconSpec ? (\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n <Icon iconSpec={this.state.iconSpec} />\n ) : undefined;\n return (\n <LockTextEditor\n {...inputProps}\n ref={this._inputElement}\n id={this.props.propertyRecord?.property.name}\n icon={icon}\n decoration={decoration}\n />\n );\n }\n}\n\ninterface LockTextEditorProps extends InputProps {\n icon?: React.ReactNode;\n decoration?: React.ReactNode;\n}\n\nconst LockTextEditor = React.forwardRef<HTMLInputElement, LockTextEditorProps>(\n function LockTextEditor(props, forwardedRef) {\n const { icon, decoration, ...rest } = props;\n if (decoration) {\n return (\n <InputWithDecorations size=\"small\">\n {icon && (\n <InputWithDecorations.Icon size=\"small\">\n {icon}\n </InputWithDecorations.Icon>\n )}\n <InputWithDecorations.Input\n {...rest}\n ref={forwardedRef}\n data-testid=\"components-text-editor\"\n size=\"small\"\n />\n {decoration}\n </InputWithDecorations>\n );\n }\n\n if (icon) {\n return (\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n <IconInput\n {...rest}\n ref={forwardedRef}\n icon={icon}\n data-testid=\"components-text-editor\"\n />\n );\n }\n return (\n <Input\n {...rest}\n ref={forwardedRef}\n data-testid=\"components-text-editor\"\n size=\"small\"\n />\n );\n }\n);\n"]}
|
|
1
|
+
{"version":3,"file":"TextEditor.js","sourceRoot":"","sources":["../../../src/components-react/editors/TextEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,mBAAmB,CAAC;AAC3B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAQ/B,OAAO,EACL,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAM7E,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAclD;;GAEG;AACH,MAAM,OAAO,UACX,SAAQ,KAAK,CAAC,aAAmD;IAGzD,UAAU,GAAG,KAAK,CAAC;IACnB,aAAa,GAAG,KAAK,CAAC,SAAS,EAAoB,CAAC;IAEnC,KAAK,GAA8B;QAC1D,UAAU,EAAE,EAAE;QACd,aAAa,EAAE,EAAE;KAClB,CAAC;IAEK,KAAK,CAAC,gBAAgB;QAC3B,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC;QACzC,IAAI,aAAwC,CAAC;QAE7C,IAAI,MAAM,IAAI,MAAM,CAAC,KAAK,CAAC,WAAW,KAAK,mBAAmB,CAAC,SAAS,EAAE,CAAC;YACzE,aAAa,GAAG,MAAM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CAAC,QAAQ,GAAI,CACxC,CAAC,CAAC,CAAC,SAAS,CAAC;QACd,OAAO,CACL,oBAAC,cAAc,OACT,UAAU,EACd,GAAG,EAAE,IAAI,CAAC,aAAa,EACvB,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,QAAQ,CAAC,IAAI,EAC5C,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,UAAU,GACtB,CACH,CAAC;IACJ,CAAC;CACF;AAOD,MAAM,cAAc,GAAG,KAAK,CAAC,UAAU,CACrC,SAAS,cAAc,CAAC,KAAK,EAAE,YAAY;IACzC,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IAC5C,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,CACL,oBAAC,oBAAoB,IAAC,IAAI,EAAC,OAAO;YAC/B,IAAI,IAAI,CACP,oBAAC,oBAAoB,CAAC,IAAI,IAAC,IAAI,EAAC,OAAO,IACpC,IAAI,CACqB,CAC7B;YACD,oBAAC,oBAAoB,CAAC,KAAK,OACrB,IAAI,EACR,GAAG,EAAE,YAAY,iBACL,wBAAwB,EACpC,IAAI,EAAC,OAAO,GACZ;YACD,UAAU,CACU,CACxB,CAAC;IACJ,CAAC;IAED,IAAI,IAAI,EAAE,CAAC;QACT,OAAO;QACL,4DAA4D;QAC5D,oBAAC,SAAS,OACJ,IAAI,EACR,GAAG,EAAE,YAAY,EACjB,IAAI,EAAE,IAAI,iBACE,wBAAwB,GACpC,CACH,CAAC;IACJ,CAAC;IACD,OAAO,CACL,oBAAC,KAAK,OACA,IAAI,EACR,GAAG,EAAE,YAAY,iBACL,wBAAwB,EACpC,IAAI,EAAC,OAAO,GACZ,CACH,CAAC;AACJ,CAAC,CACF,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 \"./TextEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type {\n IconEditorParams,\n InputEditorSizeParams,\n PrimitiveValue,\n PropertyEditorParams,\n PropertyValue,\n} from \"@itwin/appui-abstract\";\nimport {\n PropertyEditorParamTypes,\n PropertyValueFormat,\n} from \"@itwin/appui-abstract\";\nimport { Icon, IconInput } from \"@itwin/core-react\";\nimport { Input, InputWithDecorations } from \"@itwin/itwinui-react\";\nimport { TypeConverterManager } from \"../converters/TypeConverterManager.js\";\nimport type {\n InternalInputEditorProps,\n PropertyEditorProps,\n TypeEditor,\n} from \"./EditorContainer.js\";\nimport { UiComponents } from \"../UiComponents.js\";\n\ntype InputProps = React.ComponentPropsWithoutRef<typeof Input>;\n\n/** @internal */\ninterface TextEditorState {\n inputValue: string;\n originalValue: string;\n size?: number;\n maxSize?: 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\n extends React.PureComponent<PropertyEditorProps, TextEditorState>\n implements TypeEditor\n{\n private _isMounted = false;\n private _inputElement = React.createRef<HTMLInputElement>();\n\n public override readonly state: Readonly<TextEditorState> = {\n inputValue: \"\",\n originalValue: \"\",\n };\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n propertyValue = await TypeConverterManager.getConverter(\n record.property.typename,\n record.property.converter?.name\n ).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 _onFocus = () => {\n if (this._isMounted && this.props.propertyRecord?.isMerged) {\n this.setState((prevState) => ({\n ...prevState,\n inputValue: prevState.originalValue,\n }));\n }\n };\n\n private _updateInputValue = (e: React.ChangeEvent<HTMLInputElement>) => {\n if (this._isMounted)\n this.setState(\n {\n inputValue: e.target.value,\n },\n async () => {\n if (\n this.props.shouldCommitOnChange &&\n this.props.onCommit &&\n this.props.propertyRecord\n ) {\n const newValue = await this.getPropertyValue();\n if (newValue)\n this.props.onCommit({\n propertyRecord: this.props.propertyRecord,\n newValue,\n });\n }\n }\n );\n };\n\n public override componentDidMount() {\n this._isMounted = true;\n void this.setStateFromProps();\n }\n\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 void this.setStateFromProps();\n }\n }\n\n private async setStateFromProps() {\n const record = this.props.propertyRecord;\n let initialValue = \"\";\n\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n const value = record.value.value;\n initialValue = await TypeConverterManager.getConverter(\n record.property.typename,\n record.property.converter?.name\n ).convertPropertyToString(record.property, value);\n }\n\n let size: number | undefined;\n let maxSize: number | undefined;\n let maxLength: number | undefined;\n let iconSpec: string | undefined;\n\n if (\n record &&\n record.property &&\n record.property.editor &&\n record.property.editor.params\n ) {\n const editorSizeParams = record.property.editor.params.find(\n (param: PropertyEditorParams) =>\n param.type === PropertyEditorParamTypes.InputEditorSize.valueOf()\n ) as InputEditorSizeParams;\n if (editorSizeParams) {\n if (editorSizeParams.size) size = editorSizeParams.size;\n if (editorSizeParams.maxSize) maxSize = editorSizeParams.maxSize;\n if (editorSizeParams.maxLength) maxLength = editorSizeParams.maxLength;\n }\n\n const iconParams = record.property.editor.params.find(\n (param: PropertyEditorParams) =>\n param.type === PropertyEditorParamTypes.Icon.valueOf()\n ) as IconEditorParams;\n if (iconParams) {\n iconSpec = iconParams.definition.iconSpec;\n }\n }\n\n if (this._isMounted)\n this.setState({\n inputValue: record?.isMerged && !this.hasFocus ? \"--\" : initialValue,\n originalValue: initialValue,\n size,\n maxSize,\n maxLength,\n iconSpec,\n });\n }\n\n public override render(): React.ReactNode {\n const { decoration } = this.props as InternalInputEditorProps;\n const className = classnames(\n \"components-cell-editor\",\n \"components-text-editor\",\n this.props.className\n );\n const minSize = this.state.size ? this.state.size : 8;\n const style: React.CSSProperties = {\n minWidth: `${minSize * 0.75}em`,\n maxWidth: this.state.maxSize\n ? `${this.state.maxSize * 0.75}em`\n : undefined,\n };\n const inputProps: InputProps = {\n type: \"text\",\n className,\n style: this.props.style ? this.props.style : style,\n readOnly: this.props.propertyRecord?.isReadonly,\n disabled: this.props.propertyRecord?.isDisabled,\n maxLength: this.state.maxLength,\n value: this.state.inputValue,\n onBlur: this.props.onBlur,\n onFocus: this._onFocus,\n onChange: this._updateInputValue,\n autoFocus: this.props.setFocus && !this.props.propertyRecord?.isDisabled,\n \"aria-label\": UiComponents.translate(\"editor.text\"),\n };\n\n const icon = this.state.iconSpec ? (\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n <Icon iconSpec={this.state.iconSpec} />\n ) : undefined;\n return (\n <LockTextEditor\n {...inputProps}\n ref={this._inputElement}\n id={this.props.propertyRecord?.property.name}\n icon={icon}\n decoration={decoration}\n />\n );\n }\n}\n\ninterface LockTextEditorProps extends InputProps {\n icon?: React.ReactNode;\n decoration?: React.ReactNode;\n}\n\nconst LockTextEditor = React.forwardRef<HTMLInputElement, LockTextEditorProps>(\n function LockTextEditor(props, forwardedRef) {\n const { icon, decoration, ...rest } = props;\n if (decoration) {\n return (\n <InputWithDecorations size=\"small\">\n {icon && (\n <InputWithDecorations.Icon size=\"small\">\n {icon}\n </InputWithDecorations.Icon>\n )}\n <InputWithDecorations.Input\n {...rest}\n ref={forwardedRef}\n data-testid=\"components-text-editor\"\n size=\"small\"\n />\n {decoration}\n </InputWithDecorations>\n );\n }\n\n if (icon) {\n return (\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n <IconInput\n {...rest}\n ref={forwardedRef}\n icon={icon}\n data-testid=\"components-text-editor\"\n />\n );\n }\n return (\n <Input\n {...rest}\n ref={forwardedRef}\n data-testid=\"components-text-editor\"\n size=\"small\"\n />\n );\n }\n);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextareaEditor.d.ts","sourceRoot":"","sources":["../../../src/components-react/editors/TextareaEditor.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,uBAAuB,CAAC;AAE/B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAKV,aAAa,EACd,MAAM,uBAAuB,CAAC;AAO/B,OAAO,KAAK,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAUhE,gBAAgB;AAChB,UAAU,mBAAmB;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CACd;AAID;;GAEG;AACH,qBAAa,cACX,SAAQ,KAAK,CAAC,aAAa,CAAC,mBAAmB,EAAE,mBAAmB,CACpE,YAAW,UAAU;IAErB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,WAAW,CAAqC;IACxD,OAAO,CAAC,gBAAgB,CAA0C;IAElE,SAAyB,KAAK,EAAE,QAAQ,CAAC,mBAAmB,CAAC,CAG3D;IAEW,gBAAgB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;IAcnE,IAAW,WAAW,IAAI,WAAW,GAAG,IAAI,CAE3C;IAED,IAAW,QAAQ,IAAI,OAAO,CAK7B;IAED,OAAO,CAAC,oBAAoB,CAO1B;IAEc,iBAAiB;IAKjB,oBAAoB;IAIpC,gBAAgB;IACA,kBAAkB,CAAC,SAAS,EAAE,mBAAmB;YAMnD,iB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AC,SAAS,CAUf;IAEF,OAAO,CAAC,aAAa,CAInB;IAEc,MAAM,IAAI,KAAK,CAAC,SAAS;CAoD1C;AAED;;;GAGG;AACH,qBAAa,sBAAuB,SAAQ,kBAAkB;IAC5D,IAAoB,oBAAoB,IAAI,OAAO,CAElD;IACD,IAAoB,qBAAqB,IAAI,OAAO,CAEnD;IACD,IAAoB,mBAAmB,IAAI,OAAO,CAEjD;IAED,IAAW,SAAS,IAAI,KAAK,CAAC,SAAS,CAEtC;CACF"}
|
|
@@ -140,7 +140,7 @@ export class TextareaEditor extends React.PureComponent {
|
|
|
140
140
|
};
|
|
141
141
|
textareaProps["aria-label"] = UiComponents.translate("editor.textarea");
|
|
142
142
|
return (React.createElement("div", { className: className, ref: this._divElement },
|
|
143
|
-
React.createElement(PopupButton, { label: this.state.inputValue, closeOnEnter: false, setFocus: this.props.setFocus, focusTarget: this._textAreaElement },
|
|
143
|
+
React.createElement(PopupButton, { id: this.props.propertyRecord?.property.name, label: this.state.inputValue, closeOnEnter: false, setFocus: this.props.setFocus, focusTarget: this._textAreaElement },
|
|
144
144
|
React.createElement(PopupContent, null,
|
|
145
145
|
React.createElement(Textarea, { ...textareaProps, "data-testid": "components-textarea-editor", ref: this._textAreaElement }),
|
|
146
146
|
React.createElement(PopupOkCancelButtons, { onOk: this._handleOk, onCancel: this._handleCancel })))));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextareaEditor.js","sourceRoot":"","sources":["../../../src/components-react/editors/TextareaEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,uBAAuB,CAAC;AAC/B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAQ/B,OAAO,EACL,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,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AS;YAC/B,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU;YAC5B,QAAQ,EAAE,IAAI,CAAC,oBAAoB;YACnC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,UAAU;SACzE,CAAC;QAEF,aAAa,CAAC,YAAY,CAAC,GAAG,YAAY,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;QAExE,OAAO,CACL,6BAAK,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,IAAI,CAAC,WAAW;YAC9C,oBAAC,WAAW,IACV,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EAC5B,YAAY,EAAE,KAAK,EACnB,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAC7B,WAAW,EAAE,IAAI,CAAC,gBAAgB;gBAElC,oBAAC,YAAY;oBACX,oBAAC,QAAQ,OACH,aAAa,iBACL,4BAA4B,EACxC,GAAG,EAAE,IAAI,CAAC,gBAAgB,GAC1B;oBACF,oBAAC,oBAAoB,IACnB,IAAI,EAAE,IAAI,CAAC,SAAS,EACpB,QAAQ,EAAE,IAAI,CAAC,aAAa,GAC5B,CACW,CACH,CACV,CACP,CAAC;IACJ,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,sBAAuB,SAAQ,kBAAkB;IAC5D,IAAoB,oBAAoB;QACtC,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAoB,qBAAqB;QACvC,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAoB,mBAAmB;QACrC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAW,SAAS;QAClB,OAAO,oBAAC,cAAc,OAAG,CAAC;IAC5B,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 \"./TextareaEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type {\n InputEditorSizeParams,\n MultilineTextEditorParams,\n PrimitiveValue,\n PropertyEditorParams,\n PropertyValue,\n} from \"@itwin/appui-abstract\";\nimport {\n PropertyEditorParamTypes,\n PropertyValueFormat,\n} from \"@itwin/appui-abstract\";\nimport { Textarea } from \"@itwin/itwinui-react\";\nimport { TypeConverterManager } from \"../converters/TypeConverterManager.js\";\nimport type { PropertyEditorProps, TypeEditor } from \"./EditorContainer.js\";\nimport { PropertyEditorBase } from \"./PropertyEditorManager.js\";\nimport {\n PopupButton,\n PopupContent,\n PopupOkCancelButtons,\n} from \"./PopupButton.js\";\nimport { UiComponents } from \"../UiComponents.js\";\n\ntype TextareaProps = React.ComponentPropsWithoutRef<typeof Textarea>;\n\n/** @internal */\ninterface TextareaEditorState {\n inputValue: string;\n size?: number;\n maxSize?: number;\n maxLength?: number;\n rows: number;\n}\n\nconst DEFAULT_ROWS = 3;\n\n/** TextareaEditor React component that is a property editor with text input\n * @public\n */\nexport class TextareaEditor\n extends React.PureComponent<PropertyEditorProps, TextareaEditorState>\n implements TypeEditor\n{\n private _isMounted = false;\n private _divElement = React.createRef<HTMLDivElement>();\n private _textAreaElement = React.createRef<HTMLTextAreaElement>();\n\n public override readonly state: Readonly<TextareaEditorState> = {\n inputValue: \"\",\n rows: DEFAULT_ROWS,\n };\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n propertyValue = await TypeConverterManager.getConverter(\n record.property.typename\n ).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._divElement.current;\n }\n\n public get hasFocus(): boolean {\n let containsFocus = false;\n if (this._divElement.current)\n containsFocus = this._divElement.current.contains(document.activeElement);\n return containsFocus;\n }\n\n private _updateTextareaValue = (\n e: React.ChangeEvent<HTMLTextAreaElement>\n ) => {\n if (this._isMounted)\n this.setState({\n inputValue: e.target.value,\n });\n };\n\n public override componentDidMount() {\n this._isMounted = true;\n void this.setStateFromProps();\n }\n\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 void this.setStateFromProps();\n }\n }\n\n private async setStateFromProps() {\n const record = this.props.propertyRecord;\n let initialValue = \"\";\n\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n const value = record.value.value;\n initialValue = await TypeConverterManager.getConverter(\n record.property.typename\n ).convertPropertyToString(record.property, value);\n }\n\n let size: number | undefined;\n let maxSize: number | undefined;\n let maxLength: number | undefined;\n let rows: number = DEFAULT_ROWS;\n\n if (\n record &&\n record.property &&\n record.property.editor &&\n record.property.editor.params\n ) {\n const editorSizeParams = record.property.editor.params.find(\n (param: PropertyEditorParams) =>\n param.type === PropertyEditorParamTypes.InputEditorSize.valueOf()\n ) as InputEditorSizeParams;\n if (editorSizeParams) {\n if (editorSizeParams.size) size = editorSizeParams.size;\n if (editorSizeParams.maxSize) maxSize = editorSizeParams.maxSize;\n if (editorSizeParams.maxLength) maxLength = editorSizeParams.maxLength;\n }\n\n const multilineParams = record.property.editor.params.find(\n (param: PropertyEditorParams) =>\n param.type === PropertyEditorParamTypes.MultilineText.valueOf()\n ) as MultilineTextEditorParams;\n if (multilineParams) {\n rows = multilineParams.rows;\n }\n }\n\n if (this._isMounted)\n this.setState({\n inputValue: initialValue,\n size,\n maxSize,\n maxLength,\n rows,\n });\n }\n\n private _handleOk = async (_event: React.MouseEvent): Promise<void> => {\n if (this.props.propertyRecord && this.props.onCommit) {\n const propertyValue = await this.getPropertyValue();\n if (propertyValue !== undefined) {\n this.props.onCommit({\n propertyRecord: this.props.propertyRecord,\n newValue: propertyValue,\n });\n }\n }\n };\n\n private _handleCancel = (_event: React.MouseEvent): void => {\n if (this.props.onCancel) {\n this.props.onCancel();\n }\n };\n\n public override render(): React.ReactNode {\n const className = classnames(\n \"components-cell-editor\",\n \"components-textarea-editor\",\n this.props.className\n );\n const minSize = this.state.size ? this.state.size : 8;\n const style: React.CSSProperties = {\n ...this.props.style,\n minWidth: `${minSize * 0.75}em`,\n maxWidth: this.state.maxSize\n ? `${this.state.maxSize * 0.75}em`\n : undefined,\n };\n const textareaProps: TextareaProps = {\n className: \"components-textarea-editor-textarea\",\n style,\n rows: this.state.rows,\n readOnly: this.props.propertyRecord?.isReadonly,\n disabled: this.props.propertyRecord?.isDisabled,\n maxLength: this.state.maxLength,\n value: this.state.inputValue,\n onChange: this._updateTextareaValue,\n autoFocus: this.props.setFocus && !this.props.propertyRecord?.isDisabled,\n };\n\n textareaProps[\"aria-label\"] = UiComponents.translate(\"editor.textarea\");\n\n return (\n <div className={className} ref={this._divElement}>\n <PopupButton\n label={this.state.inputValue}\n closeOnEnter={false}\n setFocus={this.props.setFocus}\n focusTarget={this._textAreaElement}\n >\n <PopupContent>\n <Textarea\n {...textareaProps}\n data-testid=\"components-textarea-editor\"\n ref={this._textAreaElement}\n />\n <PopupOkCancelButtons\n onOk={this._handleOk}\n onCancel={this._handleCancel}\n />\n </PopupContent>\n </PopupButton>\n </div>\n );\n }\n}\n\n/** Textarea Property Editor registered for the \"text\" and \"string\" type names and \"multi-line\" editor name.\n * It uses the [[TextareaEditor]] React component.\n * @public\n */\nexport class TextareaPropertyEditor extends PropertyEditorBase {\n public override get containerHandlesBlur(): boolean {\n return false;\n }\n public override get containerHandlesEnter(): boolean {\n return false;\n }\n public override get containerHandlesTab(): boolean {\n return false;\n }\n\n public get reactNode(): React.ReactNode {\n return <TextareaEditor />;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TextareaEditor.js","sourceRoot":"","sources":["../../../src/components-react/editors/Text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AAkB;IAC5D,IAAoB,oBAAoB;QACtC,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAoB,qBAAqB;QACvC,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAoB,mBAAmB;QACrC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAW,SAAS;QAClB,OAAO,oBAAC,cAAc,OAAG,CAAC;IAC5B,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 \"./TextareaEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type {\n InputEditorSizeParams,\n MultilineTextEditorParams,\n PrimitiveValue,\n PropertyEditorParams,\n PropertyValue,\n} from \"@itwin/appui-abstract\";\nimport {\n PropertyEditorParamTypes,\n PropertyValueFormat,\n} from \"@itwin/appui-abstract\";\nimport { Textarea } from \"@itwin/itwinui-react\";\nimport { TypeConverterManager } from \"../converters/TypeConverterManager.js\";\nimport type { PropertyEditorProps, TypeEditor } from \"./EditorContainer.js\";\nimport { PropertyEditorBase } from \"./PropertyEditorManager.js\";\nimport {\n PopupButton,\n PopupContent,\n PopupOkCancelButtons,\n} from \"./PopupButton.js\";\nimport { UiComponents } from \"../UiComponents.js\";\n\ntype TextareaProps = React.ComponentPropsWithoutRef<typeof Textarea>;\n\n/** @internal */\ninterface TextareaEditorState {\n inputValue: string;\n size?: number;\n maxSize?: number;\n maxLength?: number;\n rows: number;\n}\n\nconst DEFAULT_ROWS = 3;\n\n/** TextareaEditor React component that is a property editor with text input\n * @public\n */\nexport class TextareaEditor\n extends React.PureComponent<PropertyEditorProps, TextareaEditorState>\n implements TypeEditor\n{\n private _isMounted = false;\n private _divElement = React.createRef<HTMLDivElement>();\n private _textAreaElement = React.createRef<HTMLTextAreaElement>();\n\n public override readonly state: Readonly<TextareaEditorState> = {\n inputValue: \"\",\n rows: DEFAULT_ROWS,\n };\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n propertyValue = await TypeConverterManager.getConverter(\n record.property.typename\n ).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._divElement.current;\n }\n\n public get hasFocus(): boolean {\n let containsFocus = false;\n if (this._divElement.current)\n containsFocus = this._divElement.current.contains(document.activeElement);\n return containsFocus;\n }\n\n private _updateTextareaValue = (\n e: React.ChangeEvent<HTMLTextAreaElement>\n ) => {\n if (this._isMounted)\n this.setState({\n inputValue: e.target.value,\n });\n };\n\n public override componentDidMount() {\n this._isMounted = true;\n void this.setStateFromProps();\n }\n\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 void this.setStateFromProps();\n }\n }\n\n private async setStateFromProps() {\n const record = this.props.propertyRecord;\n let initialValue = \"\";\n\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n const value = record.value.value;\n initialValue = await TypeConverterManager.getConverter(\n record.property.typename\n ).convertPropertyToString(record.property, value);\n }\n\n let size: number | undefined;\n let maxSize: number | undefined;\n let maxLength: number | undefined;\n let rows: number = DEFAULT_ROWS;\n\n if (\n record &&\n record.property &&\n record.property.editor &&\n record.property.editor.params\n ) {\n const editorSizeParams = record.property.editor.params.find(\n (param: PropertyEditorParams) =>\n param.type === PropertyEditorParamTypes.InputEditorSize.valueOf()\n ) as InputEditorSizeParams;\n if (editorSizeParams) {\n if (editorSizeParams.size) size = editorSizeParams.size;\n if (editorSizeParams.maxSize) maxSize = editorSizeParams.maxSize;\n if (editorSizeParams.maxLength) maxLength = editorSizeParams.maxLength;\n }\n\n const multilineParams = record.property.editor.params.find(\n (param: PropertyEditorParams) =>\n param.type === PropertyEditorParamTypes.MultilineText.valueOf()\n ) as MultilineTextEditorParams;\n if (multilineParams) {\n rows = multilineParams.rows;\n }\n }\n\n if (this._isMounted)\n this.setState({\n inputValue: initialValue,\n size,\n maxSize,\n maxLength,\n rows,\n });\n }\n\n private _handleOk = async (_event: React.MouseEvent): Promise<void> => {\n if (this.props.propertyRecord && this.props.onCommit) {\n const propertyValue = await this.getPropertyValue();\n if (propertyValue !== undefined) {\n this.props.onCommit({\n propertyRecord: this.props.propertyRecord,\n newValue: propertyValue,\n });\n }\n }\n };\n\n private _handleCancel = (_event: React.MouseEvent): void => {\n if (this.props.onCancel) {\n this.props.onCancel();\n }\n };\n\n public override render(): React.ReactNode {\n const className = classnames(\n \"components-cell-editor\",\n \"components-textarea-editor\",\n this.props.className\n );\n const minSize = this.state.size ? this.state.size : 8;\n const style: React.CSSProperties = {\n ...this.props.style,\n minWidth: `${minSize * 0.75}em`,\n maxWidth: this.state.maxSize\n ? `${this.state.maxSize * 0.75}em`\n : undefined,\n };\n const textareaProps: TextareaProps = {\n className: \"components-textarea-editor-textarea\",\n style,\n rows: this.state.rows,\n readOnly: this.props.propertyRecord?.isReadonly,\n disabled: this.props.propertyRecord?.isDisabled,\n maxLength: this.state.maxLength,\n value: this.state.inputValue,\n onChange: this._updateTextareaValue,\n autoFocus: this.props.setFocus && !this.props.propertyRecord?.isDisabled,\n };\n\n textareaProps[\"aria-label\"] = UiComponents.translate(\"editor.textarea\");\n\n return (\n <div className={className} ref={this._divElement}>\n <PopupButton\n id={this.props.propertyRecord?.property.name}\n label={this.state.inputValue}\n closeOnEnter={false}\n setFocus={this.props.setFocus}\n focusTarget={this._textAreaElement}\n >\n <PopupContent>\n <Textarea\n {...textareaProps}\n data-testid=\"components-textarea-editor\"\n ref={this._textAreaElement}\n />\n <PopupOkCancelButtons\n onOk={this._handleOk}\n onCancel={this._handleCancel}\n />\n </PopupContent>\n </PopupButton>\n </div>\n );\n }\n}\n\n/** Textarea Property Editor registered for the \"text\" and \"string\" type names and \"multi-line\" editor name.\n * It uses the [[TextareaEditor]] React component.\n * @public\n */\nexport class TextareaPropertyEditor extends PropertyEditorBase {\n public override get containerHandlesBlur(): boolean {\n return false;\n }\n public override get containerHandlesEnter(): boolean {\n return false;\n }\n public override get containerHandlesTab(): boolean {\n return false;\n }\n\n public get reactNode(): React.ReactNode {\n return <TextareaEditor />;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToggleEditor.d.ts","sourceRoot":"","sources":["../../../src/components-react/editors/ToggleEditor.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,qBAAqB,CAAC;AAE7B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,KAAK,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAGhE,gBAAgB;AAChB,UAAU,iBAAiB;IACzB,WAAW,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,qBAAa,YACX,SAAQ,KAAK,CAAC,aAAa,CAAC,mBAAmB,EAAE,iBAAiB,CAClE,YAAW,UAAU;IAErB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,aAAa,CAAuC;IAE5D,SAAyB,KAAK,EAAE,QAAQ,CAAC,iBAAiB,CAAC,CAGzD;IAEW,gBAAgB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;IAcnE,IAAW,WAAW,IAAI,WAAW,GAAG,IAAI,CAE3C;IAED,IAAW,QAAQ,IAAI,OAAO,CAE7B;IAED,OAAO,CAAC,kBAAkB,CAyBxB;IAEc,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AS,CAEtC;CACF"}
|
|
@@ -93,7 +93,7 @@ export class ToggleEditor extends React.PureComponent {
|
|
|
93
93
|
}
|
|
94
94
|
const className = classnames("components-cell-editor", "components-toggle-editor", this.props.className);
|
|
95
95
|
const isChecked = this.state.toggleValue;
|
|
96
|
-
return (React.createElement(ToggleSwitch, { ref: this._inputElement, onBlur: this.props.onBlur, className: className, style: this.props.style, checked: isChecked, readOnly: this.props.propertyRecord?.isReadonly, disabled: this.props.propertyRecord?.isDisabled, onChange: this._updateToggleValue, "data-testid": "components-toggle-editor", autoFocus: this.props.setFocus }));
|
|
96
|
+
return (React.createElement(ToggleSwitch, { ref: this._inputElement, onBlur: this.props.onBlur, className: className, style: this.props.style, checked: isChecked, readOnly: this.props.propertyRecord?.isReadonly, disabled: this.props.propertyRecord?.isDisabled, onChange: this._updateToggleValue, "data-testid": "components-toggle-editor", id: this.props.propertyRecord?.property.name, autoFocus: this.props.setFocus }));
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
/** Toggle Property Editor registered for the "bool" and "boolean" type names and "toggle" editor name.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToggleEditor.js","sourceRoot":"","sources":["../../../src/components-react/editors/ToggleEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,qBAAqB,CAAC;AAC7B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAQpD;;GAEG;AACH,MAAM,OAAO,YACX,SAAQ,KAAK,CAAC,aAAqD;IAG3D,UAAU,GAAG,KAAK,CAAC;IACnB,aAAa,GAAG,KAAK,CAAC,SAAS,EAAoB,CAAC;IAEnC,K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QAEzC,OAAO,CACL,oBAAC,YAAY,IACX,GAAG,EAAE,IAAI,CAAC,aAAa,EACvB,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,EACzB,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,OAAO,EAAE,SAAS,EAClB,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,UAAU,EAC/C,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,UAAU,EAC/C,QAAQ,EAAE,IAAI,CAAC,kBAAkB,iBACrB,0BAA0B,EACtC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,GAC9B,CACH,CAAC;IACJ,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,oBAAqB,SAAQ,kBAAkB;IAC1D,IAAoB,oBAAoB;QACtC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAW,SAAS;QAClB,OAAO,oBAAC,YAAY,OAAG,CAAC;IAC1B,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 \"./ToggleEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type { PropertyValue } from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport type { PropertyEditorProps, TypeEditor } from \"./EditorContainer.js\";\nimport { PropertyEditorBase } from \"./PropertyEditorManager.js\";\nimport { ToggleSwitch } from \"@itwin/itwinui-react\";\n\n/** @internal */\ninterface ToggleEditorState {\n toggleValue: boolean;\n isLoaded: boolean;\n}\n\n/** ToggleEditor React component that is a property editor with checkbox input\n * @public\n */\nexport class ToggleEditor\n extends React.PureComponent<PropertyEditorProps, ToggleEditorState>\n implements TypeEditor\n{\n private _isMounted = false;\n private _inputElement = React.createRef<HTMLInputElement>();\n\n public override readonly state: Readonly<ToggleEditorState> = {\n toggleValue: false,\n isLoaded: false,\n };\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n propertyValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: this.state.toggleValue,\n displayValue: \"\",\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 _updateToggleValue = (\n e: React.ChangeEvent<HTMLInputElement>\n ): any => {\n if (this._isMounted) {\n if (this._isMounted) {\n const toggleValue = !!e.target.checked;\n\n this.setState(\n {\n toggleValue,\n },\n async () => {\n if (this.props.propertyRecord && this.props.onCommit) {\n const propertyValue = await this.getPropertyValue();\n if (propertyValue !== undefined) {\n this.props.onCommit({\n propertyRecord: this.props.propertyRecord,\n newValue: propertyValue,\n });\n }\n }\n }\n );\n }\n }\n };\n\n public override componentDidMount() {\n this._isMounted = true;\n void this.setStateFromProps();\n }\n\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 void this.setStateFromProps();\n }\n }\n\n private async setStateFromProps() {\n const { propertyRecord } = this.props;\n let toggleValue = false;\n\n if (\n propertyRecord &&\n propertyRecord.value.valueFormat === PropertyValueFormat.Primitive\n ) {\n const primitiveValue = propertyRecord.value.value;\n toggleValue = primitiveValue as boolean;\n }\n\n if (this._isMounted)\n this.setState({\n toggleValue,\n isLoaded: true,\n });\n }\n\n public override render() {\n // Don't render until the value is loaded to avoid showing false briefly\n if (!this.state.isLoaded) {\n return null;\n }\n\n const className = classnames(\n \"components-cell-editor\",\n \"components-toggle-editor\",\n this.props.className\n );\n const isChecked = this.state.toggleValue;\n\n return (\n <ToggleSwitch\n ref={this._inputElement}\n onBlur={this.props.onBlur}\n className={className}\n style={this.props.style}\n checked={isChecked}\n readOnly={this.props.propertyRecord?.isReadonly}\n disabled={this.props.propertyRecord?.isDisabled}\n onChange={this._updateToggleValue}\n data-testid=\"components-toggle-editor\"\n autoFocus={this.props.setFocus} // eslint-disable-line jsx-a11y/no-autofocus\n />\n );\n }\n}\n\n/** Toggle Property Editor registered for the \"bool\" and \"boolean\" type names and \"toggle\" editor name.\n * It uses the [[ToggleEditor]] React component.\n * @public\n */\nexport class TogglePropertyEditor extends PropertyEditorBase {\n public override get containerHandlesBlur(): boolean {\n return false;\n }\n\n public get reactNode(): React.ReactNode {\n return <ToggleEditor />;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ToggleEditor.js","sourceRoot":"","sources":["../../../src/components-react/editors/ToggleEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,qBAAqB,CAAC;AAC7B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAQpD;;GAEG;AACH,MAAM,OAAO,YACX,SAAQ,KAAK,CAAC,aAAqD;IAG3D,UAAU,GAAG,KAAK,CAAC;IACnB,aAAa,GAAG,KAAK,CAAC,SAAS,EAAoB,CAAC;IAEnC,KAAK,GAAgC;QAC5D,WAAW,EAAE,KAAK;QAClB,QAAQ,EAAE,KAAK;KAChB,CAAC;IAEK,KAAK,CAAC,gBAAgB;QAC3B,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC;QACzC,IAAI,aAAwC,CAAC;QAE7C,IAA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EAAE,SAAS,EAClB,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,UAAU,EAC/C,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,UAAU,EAC/C,QAAQ,EAAE,IAAI,CAAC,kBAAkB,iBACrB,0BAA0B,EACtC,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,QAAQ,CAAC,IAAI,EAC5C,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,GAC9B,CACH,CAAC;IACJ,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,oBAAqB,SAAQ,kBAAkB;IAC1D,IAAoB,oBAAoB;QACtC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAW,SAAS;QAClB,OAAO,oBAAC,YAAY,OAAG,CAAC;IAC1B,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 \"./ToggleEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type { PropertyValue } from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport type { PropertyEditorProps, TypeEditor } from \"./EditorContainer.js\";\nimport { PropertyEditorBase } from \"./PropertyEditorManager.js\";\nimport { ToggleSwitch } from \"@itwin/itwinui-react\";\n\n/** @internal */\ninterface ToggleEditorState {\n toggleValue: boolean;\n isLoaded: boolean;\n}\n\n/** ToggleEditor React component that is a property editor with checkbox input\n * @public\n */\nexport class ToggleEditor\n extends React.PureComponent<PropertyEditorProps, ToggleEditorState>\n implements TypeEditor\n{\n private _isMounted = false;\n private _inputElement = React.createRef<HTMLInputElement>();\n\n public override readonly state: Readonly<ToggleEditorState> = {\n toggleValue: false,\n isLoaded: false,\n };\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n propertyValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: this.state.toggleValue,\n displayValue: \"\",\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 _updateToggleValue = (\n e: React.ChangeEvent<HTMLInputElement>\n ): any => {\n if (this._isMounted) {\n if (this._isMounted) {\n const toggleValue = !!e.target.checked;\n\n this.setState(\n {\n toggleValue,\n },\n async () => {\n if (this.props.propertyRecord && this.props.onCommit) {\n const propertyValue = await this.getPropertyValue();\n if (propertyValue !== undefined) {\n this.props.onCommit({\n propertyRecord: this.props.propertyRecord,\n newValue: propertyValue,\n });\n }\n }\n }\n );\n }\n }\n };\n\n public override componentDidMount() {\n this._isMounted = true;\n void this.setStateFromProps();\n }\n\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 void this.setStateFromProps();\n }\n }\n\n private async setStateFromProps() {\n const { propertyRecord } = this.props;\n let toggleValue = false;\n\n if (\n propertyRecord &&\n propertyRecord.value.valueFormat === PropertyValueFormat.Primitive\n ) {\n const primitiveValue = propertyRecord.value.value;\n toggleValue = primitiveValue as boolean;\n }\n\n if (this._isMounted)\n this.setState({\n toggleValue,\n isLoaded: true,\n });\n }\n\n public override render() {\n // Don't render until the value is loaded to avoid showing false briefly\n if (!this.state.isLoaded) {\n return null;\n }\n\n const className = classnames(\n \"components-cell-editor\",\n \"components-toggle-editor\",\n this.props.className\n );\n const isChecked = this.state.toggleValue;\n\n return (\n <ToggleSwitch\n ref={this._inputElement}\n onBlur={this.props.onBlur}\n className={className}\n style={this.props.style}\n checked={isChecked}\n readOnly={this.props.propertyRecord?.isReadonly}\n disabled={this.props.propertyRecord?.isDisabled}\n onChange={this._updateToggleValue}\n data-testid=\"components-toggle-editor\"\n id={this.props.propertyRecord?.property.name}\n autoFocus={this.props.setFocus} // eslint-disable-line jsx-a11y/no-autofocus\n />\n );\n }\n}\n\n/** Toggle Property Editor registered for the \"bool\" and \"boolean\" type names and \"toggle\" editor name.\n * It uses the [[ToggleEditor]] React component.\n * @public\n */\nexport class TogglePropertyEditor extends PropertyEditorBase {\n public override get containerHandlesBlur(): boolean {\n return false;\n }\n\n public get reactNode(): React.ReactNode {\n return <ToggleEditor />;\n }\n}\n"]}
|