@itwin/components-react 5.27.0 → 5.28.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.
Files changed (122) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/lib/cjs/components-react/common/HighlightedText.scss +8 -0
  3. package/lib/components-react/abstract-types.d.ts +8 -0
  4. package/lib/components-react/abstract-types.d.ts.map +1 -0
  5. package/lib/components-react/abstract-types.js +6 -0
  6. package/lib/components-react/abstract-types.js.map +1 -0
  7. package/lib/components-react/common/HighlightedText.d.ts +6 -0
  8. package/lib/components-react/common/HighlightedText.d.ts.map +1 -1
  9. package/lib/components-react/common/HighlightedText.js +7 -4
  10. package/lib/components-react/common/HighlightedText.js.map +1 -1
  11. package/lib/components-react/common/HighlightedText.scss +8 -0
  12. package/lib/components-react/common/selection/SelectionHandler.d.ts +3 -0
  13. package/lib/components-react/common/selection/SelectionHandler.d.ts.map +1 -1
  14. package/lib/components-react/common/selection/SelectionHandler.js.map +1 -1
  15. package/lib/components-react/common/selection/SelectionModes.d.ts +3 -0
  16. package/lib/components-react/common/selection/SelectionModes.d.ts.map +1 -1
  17. package/lib/components-react/common/selection/SelectionModes.js +4 -0
  18. package/lib/components-react/common/selection/SelectionModes.js.map +1 -1
  19. package/lib/components-react/editors/CustomNumberEditor.d.ts +1 -0
  20. package/lib/components-react/editors/CustomNumberEditor.d.ts.map +1 -1
  21. package/lib/components-react/editors/CustomNumberEditor.js +9 -2
  22. package/lib/components-react/editors/CustomNumberEditor.js.map +1 -1
  23. package/lib/components-react/editors/NumericInputEditor.d.ts +1 -0
  24. package/lib/components-react/editors/NumericInputEditor.d.ts.map +1 -1
  25. package/lib/components-react/editors/NumericInputEditor.js +7 -0
  26. package/lib/components-react/editors/NumericInputEditor.js.map +1 -1
  27. package/lib/components-react/editors/TextEditor.d.ts +1 -0
  28. package/lib/components-react/editors/TextEditor.d.ts.map +1 -1
  29. package/lib/components-react/editors/TextEditor.js +9 -2
  30. package/lib/components-react/editors/TextEditor.js.map +1 -1
  31. package/lib/components-react/editors/TextareaEditor.d.ts +1 -0
  32. package/lib/components-react/editors/TextareaEditor.d.ts.map +1 -1
  33. package/lib/components-react/editors/TextareaEditor.js +7 -0
  34. package/lib/components-react/editors/TextareaEditor.js.map +1 -1
  35. package/lib/components-react/new-editors/interop/old-editors/CustomNumber.d.ts.map +1 -1
  36. package/lib/components-react/new-editors/interop/old-editors/CustomNumber.js +3 -0
  37. package/lib/components-react/new-editors/interop/old-editors/CustomNumber.js.map +1 -1
  38. package/lib/components-react/new-editors/interop/old-editors/NumericInput.js +3 -0
  39. package/lib/components-react/new-editors/interop/old-editors/NumericInput.js.map +1 -1
  40. package/lib/components-react/tree/HighlightingEngine.d.ts +5 -0
  41. package/lib/components-react/tree/HighlightingEngine.d.ts.map +1 -1
  42. package/lib/components-react/tree/HighlightingEngine.js +3 -0
  43. package/lib/components-react/tree/HighlightingEngine.js.map +1 -1
  44. package/lib/components-react/tree/ImageLoader.d.ts +2 -0
  45. package/lib/components-react/tree/ImageLoader.d.ts.map +1 -1
  46. package/lib/components-react/tree/ImageLoader.js +1 -0
  47. package/lib/components-react/tree/ImageLoader.js.map +1 -1
  48. package/lib/components-react/tree/SimpleTreeDataProvider.d.ts +2 -0
  49. package/lib/components-react/tree/SimpleTreeDataProvider.d.ts.map +1 -1
  50. package/lib/components-react/tree/SimpleTreeDataProvider.js +1 -0
  51. package/lib/components-react/tree/SimpleTreeDataProvider.js.map +1 -1
  52. package/lib/components-react/tree/TreeDataProvider.d.ts +14 -0
  53. package/lib/components-react/tree/TreeDataProvider.d.ts.map +1 -1
  54. package/lib/components-react/tree/TreeDataProvider.js +5 -0
  55. package/lib/components-react/tree/TreeDataProvider.js.map +1 -1
  56. package/lib/components-react/tree/controlled/Observable.d.ts +9 -0
  57. package/lib/components-react/tree/controlled/Observable.d.ts.map +1 -1
  58. package/lib/components-react/tree/controlled/Observable.js +2 -0
  59. package/lib/components-react/tree/controlled/Observable.js.map +1 -1
  60. package/lib/components-react/tree/controlled/TreeActions.d.ts +1 -0
  61. package/lib/components-react/tree/controlled/TreeActions.d.ts.map +1 -1
  62. package/lib/components-react/tree/controlled/TreeActions.js.map +1 -1
  63. package/lib/components-react/tree/controlled/TreeEventDispatcher.d.ts.map +1 -1
  64. package/lib/components-react/tree/controlled/TreeEventDispatcher.js.map +1 -1
  65. package/lib/components-react/tree/controlled/TreeEventHandler.d.ts +3 -0
  66. package/lib/components-react/tree/controlled/TreeEventHandler.d.ts.map +1 -1
  67. package/lib/components-react/tree/controlled/TreeEventHandler.js +2 -0
  68. package/lib/components-react/tree/controlled/TreeEventHandler.js.map +1 -1
  69. package/lib/components-react/tree/controlled/TreeEvents.d.ts +7 -0
  70. package/lib/components-react/tree/controlled/TreeEvents.d.ts.map +1 -1
  71. package/lib/components-react/tree/controlled/TreeEvents.js.map +1 -1
  72. package/lib/components-react/tree/controlled/TreeHooks.d.ts +5 -0
  73. package/lib/components-react/tree/controlled/TreeHooks.d.ts.map +1 -1
  74. package/lib/components-react/tree/controlled/TreeHooks.js +6 -2
  75. package/lib/components-react/tree/controlled/TreeHooks.js.map +1 -1
  76. package/lib/components-react/tree/controlled/TreeModel.d.ts +18 -0
  77. package/lib/components-react/tree/controlled/TreeModel.d.ts.map +1 -1
  78. package/lib/components-react/tree/controlled/TreeModel.js +7 -0
  79. package/lib/components-react/tree/controlled/TreeModel.js.map +1 -1
  80. package/lib/components-react/tree/controlled/TreeModelSource.d.ts +2 -0
  81. package/lib/components-react/tree/controlled/TreeModelSource.d.ts.map +1 -1
  82. package/lib/components-react/tree/controlled/TreeModelSource.js +1 -0
  83. package/lib/components-react/tree/controlled/TreeModelSource.js.map +1 -1
  84. package/lib/components-react/tree/controlled/TreeNodeLoader.d.ts +9 -0
  85. package/lib/components-react/tree/controlled/TreeNodeLoader.d.ts.map +1 -1
  86. package/lib/components-react/tree/controlled/TreeNodeLoader.js +4 -1
  87. package/lib/components-react/tree/controlled/TreeNodeLoader.js.map +1 -1
  88. package/lib/components-react/tree/controlled/component/ControlledTree.d.ts +3 -0
  89. package/lib/components-react/tree/controlled/component/ControlledTree.d.ts.map +1 -1
  90. package/lib/components-react/tree/controlled/component/ControlledTree.js +4 -3
  91. package/lib/components-react/tree/controlled/component/ControlledTree.js.map +1 -1
  92. package/lib/components-react/tree/controlled/component/NodeContent.d.ts +2 -1
  93. package/lib/components-react/tree/controlled/component/NodeContent.d.ts.map +1 -1
  94. package/lib/components-react/tree/controlled/component/NodeContent.js +3 -4
  95. package/lib/components-react/tree/controlled/component/NodeContent.js.map +1 -1
  96. package/lib/components-react/tree/controlled/component/TreeNodeEditor.d.ts +3 -0
  97. package/lib/components-react/tree/controlled/component/TreeNodeEditor.d.ts.map +1 -1
  98. package/lib/components-react/tree/controlled/component/TreeNodeEditor.js +2 -0
  99. package/lib/components-react/tree/controlled/component/TreeNodeEditor.js.map +1 -1
  100. package/lib/components-react/tree/controlled/component/TreeNodeRenderer.d.ts +3 -0
  101. package/lib/components-react/tree/controlled/component/TreeNodeRenderer.d.ts.map +1 -1
  102. package/lib/components-react/tree/controlled/component/TreeNodeRenderer.js +5 -7
  103. package/lib/components-react/tree/controlled/component/TreeNodeRenderer.js.map +1 -1
  104. package/lib/components-react/tree/controlled/component/TreeRenderer.d.ts +4 -0
  105. package/lib/components-react/tree/controlled/component/TreeRenderer.d.ts.map +1 -1
  106. package/lib/components-react/tree/controlled/component/TreeRenderer.js +3 -6
  107. package/lib/components-react/tree/controlled/component/TreeRenderer.js.map +1 -1
  108. package/lib/components-react/tree/controlled/internal/SparseTree.d.ts +1 -0
  109. package/lib/components-react/tree/controlled/internal/SparseTree.d.ts.map +1 -1
  110. package/lib/components-react/tree/controlled/internal/SparseTree.js +2 -0
  111. package/lib/components-react/tree/controlled/internal/SparseTree.js.map +1 -1
  112. package/lib/components-react/tree/controlled/internal/TreeModelMutator.d.ts.map +1 -1
  113. package/lib/components-react/tree/controlled/internal/TreeModelMutator.js +1 -0
  114. package/lib/components-react/tree/controlled/internal/TreeModelMutator.js.map +1 -1
  115. package/lib/components-react/tree/controlled/internal/TreeSelectionManager.d.ts.map +1 -1
  116. package/lib/components-react/tree/controlled/internal/TreeSelectionManager.js.map +1 -1
  117. package/lib/components-react.d.ts +2 -0
  118. package/lib/components-react.d.ts.map +1 -1
  119. package/lib/components-react.js +1 -0
  120. package/lib/components-react.js.map +1 -1
  121. package/lib/esm/components-react/common/HighlightedText.scss +8 -0
  122. package/package.json +41 -38
@@ -1 +1 @@
1
- {"version":3,"file":"NumericInputEditor.d.ts","sourceRoot":"","sources":["../../../src/components-react/editors/NumericInputEditor.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,2BAA2B,CAAC;AAEnC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAGV,aAAa,EAEd,MAAM,uBAAuB,CAAC;AAM/B,OAAO,KAAK,EAEV,mBAAmB,EACnB,UAAU,EACX,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAGhE,gBAAgB;AAChB,UAAU,uBAAuB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,qBAAa,kBACX,SAAQ,KAAK,CAAC,aAAa,CAAC,mBAAmB,EAAE,uBAAuB,CACxE,YAAW,UAAU;IAErB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,aAAa,CACD;IACb,QAAQ,UAAS;IAExB,SAAyB,KAAK,EAAE,QAAQ,CAAC,uBAAuB,CAAC,CAE/D;IAEW,gBAAgB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;IAenE,IAAW,WAAW,IAAI,WAAW,GAAG,IAAI,CAE3C;IAED,OAAO,CAAC,aAAa,CAUnB;IAEF,OAAO,CAAC,YAAY,CAelB;IAEc,iBAAiB;IAKjB,oBAAoB;IAIpC,gBAAgB;IACA,kBAAkB,CAAC,SAAS,EAAE,mBAAmB;YAMnD,iBAAiB;IAsDf,MAAM,IAAI,KAAK,CAAC,SAAS;CAqC1C;AAED;;;GAGG;AACH,qBAAa,0BAA2B,SAAQ,kBAAkB;IAChE,IAAW,SAAS,IAAI,KAAK,CAAC,SAAS,CAEtC;IACD,IAAoB,qBAAqB,IAAI,OAAO,CAGnD;CACF"}
1
+ {"version":3,"file":"NumericInputEditor.d.ts","sourceRoot":"","sources":["../../../src/components-react/editors/NumericInputEditor.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,2BAA2B,CAAC;AAEnC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAGV,aAAa,EAEd,MAAM,uBAAuB,CAAC;AAM/B,OAAO,KAAK,EAEV,mBAAmB,EACnB,UAAU,EACX,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAGhE,gBAAgB;AAChB,UAAU,uBAAuB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,qBAAa,kBACX,SAAQ,KAAK,CAAC,aAAa,CAAC,mBAAmB,EAAE,uBAAuB,CACxE,YAAW,UAAU;IAErB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,aAAa,CACD;IACb,QAAQ,UAAS;IAExB,SAAyB,KAAK,EAAE,QAAQ,CAAC,uBAAuB,CAAC,CAE/D;IAEW,gBAAgB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;IAenE,IAAW,WAAW,IAAI,WAAW,GAAG,IAAI,CAE3C;IAED,OAAO,CAAC,aAAa,CAUnB;IAEF,OAAO,CAAC,YAAY,CAelB;IAEc,iBAAiB;IAKjB,oBAAoB;IAIpC,gBAAgB;IACA,kBAAkB,CAAC,SAAS,EAAE,mBAAmB;YAMnD,iBAAiB;IAyDf,MAAM,IAAI,KAAK,CAAC,SAAS;CAwC1C;AAED;;;GAGG;AACH,qBAAa,0BAA2B,SAAQ,kBAAkB;IAChE,IAAW,SAAS,IAAI,KAAK,CAAC,SAAS,CAEtC;IACD,IAAoB,qBAAqB,IAAI,OAAO,CAGnD;CACF"}
@@ -77,6 +77,7 @@ export class NumericInputEditor extends React.PureComponent {
77
77
  initialValue = record.value.value;
78
78
  }
79
79
  let size;
80
+ let maxSize;
80
81
  let maxLength;
81
82
  let min;
82
83
  let max;
@@ -90,6 +91,8 @@ export class NumericInputEditor extends React.PureComponent {
90
91
  if (editorSizeParams) {
91
92
  if (editorSizeParams.size)
92
93
  size = editorSizeParams.size;
94
+ if (editorSizeParams.maxSize)
95
+ maxSize = editorSizeParams.maxSize;
93
96
  if (editorSizeParams.maxLength)
94
97
  maxLength = editorSizeParams.maxLength;
95
98
  }
@@ -105,6 +108,7 @@ export class NumericInputEditor extends React.PureComponent {
105
108
  this.setState({
106
109
  value: initialValue,
107
110
  size,
111
+ maxSize,
108
112
  maxLength,
109
113
  min,
110
114
  max,
@@ -119,6 +123,9 @@ export class NumericInputEditor extends React.PureComponent {
119
123
  const style = {
120
124
  ...this.props.style,
121
125
  minWidth: `${minSize * 0.75}em`,
126
+ maxWidth: this.state.maxSize
127
+ ? `${this.state.maxSize * 0.75}em`
128
+ : undefined,
122
129
  };
123
130
  return (React.createElement(NumericEditor, { ref: this._inputElement, className: className, style: style, value: this.state.value, min: this.state.min, max: this.state.max, step: this.state.step, precision: this.state.precision, readOnly: this.props.propertyRecord?.isReadonly, disabled: this.props.propertyRecord?.isDisabled, maxLength: this.state.maxLength, onBlur: this.props.onBlur, onChange: this._updateValue,
124
131
  // eslint-disable-next-line jsx-a11y/no-autofocus
@@ -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;AAc5D;;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,CAAC,SAAS;gBAC1C,KAAK,EAA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AE,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 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 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.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 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 };\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/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,k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I,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"]}
@@ -9,6 +9,7 @@ import type { PropertyEditorProps, TypeEditor } from "./EditorContainer.js";
9
9
  interface TextEditorState {
10
10
  inputValue: string;
11
11
  size?: number;
12
+ maxSize?: number;
12
13
  maxLength?: number;
13
14
  iconSpec?: string;
14
15
  }
@@ -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,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,S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,IAAI,OAAO,CAE7B;IAED,OAAO,CAAC,iBAAiB,CAqBvB;IAEc,iBAAiB;IAKjB,oBAAoB;IAIpC,gBAAgB;IACA,kBAAkB,CAAC,SAAS,EAAE,mBAAmB;YAMnD,iBAAiB;IAoDf,MAAM,IAAI,KAAK,CAAC,SAAS;CA0C1C"}
@@ -75,6 +75,7 @@ export class TextEditor extends React.PureComponent {
75
75
  initialValue = await TypeConverterManager.getConverter(record.property.typename, record.property.converter?.name).convertPropertyToString(record.property, value);
76
76
  }
77
77
  let size;
78
+ let maxSize;
78
79
  let maxLength;
79
80
  let iconSpec;
80
81
  if (record &&
@@ -85,6 +86,8 @@ export class TextEditor extends React.PureComponent {
85
86
  if (editorSizeParams) {
86
87
  if (editorSizeParams.size)
87
88
  size = editorSizeParams.size;
89
+ if (editorSizeParams.maxSize)
90
+ maxSize = editorSizeParams.maxSize;
88
91
  if (editorSizeParams.maxLength)
89
92
  maxLength = editorSizeParams.maxLength;
90
93
  }
@@ -97,6 +100,7 @@ export class TextEditor extends React.PureComponent {
97
100
  this.setState({
98
101
  inputValue: initialValue,
99
102
  size,
103
+ maxSize,
100
104
  maxLength,
101
105
  iconSpec,
102
106
  });
@@ -105,13 +109,16 @@ export class TextEditor extends React.PureComponent {
105
109
  const { decoration } = this.props;
106
110
  const className = classnames("components-cell-editor", "components-text-editor", this.props.className);
107
111
  const minSize = this.state.size ? this.state.size : 8;
108
- const minWidthStyle = {
112
+ const style = {
109
113
  minWidth: `${minSize * 0.75}em`,
114
+ maxWidth: this.state.maxSize
115
+ ? `${this.state.maxSize * 0.75}em`
116
+ : undefined,
110
117
  };
111
118
  const inputProps = {
112
119
  type: "text",
113
120
  className,
114
- style: this.props.style ? this.props.style : minWidthStyle,
121
+ style: this.props.style ? this.props.style : style,
115
122
  readOnly: this.props.propertyRecord?.isReadonly,
116
123
  disabled: this.props.propertyRecord?.isDisabled,
117
124
  maxLength: this.state.maxLength,
@@ -1 +1 @@
1
- {"version":3,"file":"TextEdit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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 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 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.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 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 minWidthStyle: React.CSSProperties = {\n minWidth: `${minSize * 0.75}em`,\n };\n const inputProps: InputProps = {\n type: \"text\",\n className,\n style: this.props.style ? this.props.style : minWidthStyle,\n readOnly: this.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"]}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O,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 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"]}
@@ -10,6 +10,7 @@ import { PropertyEditorBase } from "./PropertyEditorManager.js";
10
10
  interface TextareaEditorState {
11
11
  inputValue: string;
12
12
  size?: number;
13
+ maxSize?: number;
13
14
  maxLength?: number;
14
15
  rows: number;
15
16
  }
@@ -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,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,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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,iBAAiB;IAmD/B,OAAO,CAAC,SAAS,CAUf;IAEF,OAAO,CAAC,aAAa,CAInB;IAEc,MAAM,IAAI,KAAK,CAAC,SAAS;CAmD1C;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"}
@@ -71,6 +71,7 @@ export class TextareaEditor extends React.PureComponent {
71
71
  initialValue = await TypeConverterManager.getConverter(record.property.typename).convertPropertyToString(record.property, value);
72
72
  }
73
73
  let size;
74
+ let maxSize;
74
75
  let maxLength;
75
76
  let rows = DEFAULT_ROWS;
76
77
  if (record &&
@@ -81,6 +82,8 @@ export class TextareaEditor extends React.PureComponent {
81
82
  if (editorSizeParams) {
82
83
  if (editorSizeParams.size)
83
84
  size = editorSizeParams.size;
85
+ if (editorSizeParams.maxSize)
86
+ maxSize = editorSizeParams.maxSize;
84
87
  if (editorSizeParams.maxLength)
85
88
  maxLength = editorSizeParams.maxLength;
86
89
  }
@@ -93,6 +96,7 @@ export class TextareaEditor extends React.PureComponent {
93
96
  this.setState({
94
97
  inputValue: initialValue,
95
98
  size,
99
+ maxSize,
96
100
  maxLength,
97
101
  rows,
98
102
  });
@@ -119,6 +123,9 @@ export class TextareaEditor extends React.PureComponent {
119
123
  const style = {
120
124
  ...this.props.style,
121
125
  minWidth: `${minSize * 0.75}em`,
126
+ maxWidth: this.state.maxSize
127
+ ? `${this.state.maxSize * 0.75}em`
128
+ : undefined,
122
129
  };
123
130
  const textareaProps = {
124
131
  className: "components-textarea-editor-textarea",
@@ -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,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAE7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EACL,WAAW,EACX,YAAY,EACZ,oBAAoB,GACrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAYlD,MAAM,YAAY,GAAG,CAAC,CAAC;AAEvB;;GAEG;AACH,MAAM,OAAO,cACX,SAAQ,KAAK,CAAC,aAAuD;IAG7D,UAAU,GAAG,KAAK,CAAC;IACnB,WAAW,GAAG,KAAK,CAAC,SAAS,EA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AAgB,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 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 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.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 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 };\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/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,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAE7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EACL,WAAW,EACX,YAAY,EACZ,oBAAoB,GACrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAalD,MAAM,YAAY,GAAG,CAAC,CAAC;AAEvB;;GAEG;AACH,MAAM,OAAO,cACX,SAAQ,KAAK,CAAC,aAAuD;IAG7D,UAAU,GAAG,KAAK,CAAC;IACnB,WAAW,GAAG,KAAK,CAAC,SAAS,EAAkB,CAAC;IAChD,gBAAgB,GAAG,KAAK,CAAC,SAAS,EAAuB,CAAC;IAEzC,KAAK,GAAkC;QAC9D,UAAU,EAAE,EA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AC,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 +1 @@
1
- {"version":3,"file":"CustomNumber.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/new-editors/interop/old-editors/CustomNumber.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAW3D,gBAAgB;AAChB,eAAO,MAAM,sBAAsB,qCAWjC,CAAC;AAEH,UAAU,uBACR,SAAQ,WAAW,CAAC,iBAAiB,EAAE,YAAY,CAAC;IACpD,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC9B;AAED,gBAAgB;AAChB,wBAAgB,kBAAkB,CAAC,EACjC,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,UAAU,GACX,EAAE,uBAAuB,4BAuDzB"}
1
+ {"version":3,"file":"CustomNumber.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/new-editors/interop/old-editors/CustomNumber.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAW3D,gBAAgB;AAChB,eAAO,MAAM,sBAAsB,qCAWjC,CAAC;AAEH,UAAU,uBACR,SAAQ,WAAW,CAAC,iBAAiB,EAAE,YAAY,CAAC;IACpD,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC9B;AAED,gBAAgB;AAChB,wBAAgB,kBAAkB,CAAC,EACjC,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,UAAU,GACX,EAAE,uBAAuB,4BA2DzB"}
@@ -37,6 +37,9 @@ export function CustomNumberEditor({ metadata, value, onChange, size, disabled,
37
37
  const style = sizeParams?.size !== undefined
38
38
  ? {
39
39
  minWidth: `${sizeParams?.size * 0.75}em`,
40
+ maxWidth: sizeParams?.maxSize !== undefined
41
+ ? `${sizeParams?.maxSize * 0.75}em`
42
+ : undefined,
40
43
  }
41
44
  : undefined;
42
45
  const icon = iconParams?.definition?.iconSpec !== undefined
@@ -1 +1 @@
1
- {"version":3,"file":"CustomNumber.js","sourceRoot":"","sources":["../../../../../src/components-react/new-editors/interop/old-editors/CustomNumber.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,uBAAuB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I,CAA6B,CAC9D,CAAC,CAAC,CAAC,IAAI;QACR,oBAAC,oBAAoB,CAAC,KAAK,IACzB,GAAG,EAAE,QAAQ,EACb,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,YAAY,EACtB,KAAK,EAAE,UAAU,GACjB;QACD,UAAU,CACU,CACxB,CAAC;AACJ,CAAC;AAED,oBAAoB","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\nimport * as React from \"react\";\nimport {\n PropertyEditorParamTypes,\n StandardEditorNames,\n} from \"@itwin/appui-abstract\";\nimport { InputWithDecorations } from \"@itwin/itwinui-react\";\nimport type { EditorProps } from \"../../Types.js\";\nimport { createEditorSpec } from \"../../Types.js\";\nimport type { OldEditorMetadata } from \"../Metadata.js\";\nimport { isOldEditorMetadata } from \"../Metadata.js\";\nimport type { NumericValue } from \"../../values/Values.js\";\nimport {\n useCustomFormattedNumberParams,\n useIconEditorParams,\n useInputEditorSizeParams,\n} from \"./UseEditorParams.js\";\nimport { findIcon } from \"../IconsRegistry.js\";\nimport { isNumeric } from \"../../values/ValueUtilities.js\";\n\n/* v8 ignore start */\n\n/** @internal */\nexport const CustomNumberEditorSpec = createEditorSpec({\n isMetadataSupported: (metadata): metadata is OldEditorMetadata =>\n isOldEditorMetadata(metadata) &&\n metadata.type === \"number\" &&\n !!metadata.params?.find(\n (param) =>\n param.type === PropertyEditorParamTypes.CustomFormattedNumber.valueOf()\n ) &&\n metadata.preferredEditor === StandardEditorNames.NumberCustom,\n isValueSupported: isNumeric,\n Editor: CustomNumberEditor,\n});\n\ninterface CustomNumberEditorProps\n extends EditorProps<OldEditorMetadata, NumericValue> {\n decoration?: React.ReactNode;\n}\n\n/** @internal */\nexport function CustomNumberEditor({\n metadata,\n value,\n onChange,\n size,\n disabled,\n decoration,\n}: CustomNumberEditorProps) {\n const formatParams = useCustomFormattedNumberParams(metadata);\n const sizeParams = useInputEditorSizeParams(metadata);\n const iconParams = useIconEditorParams(metadata);\n const inputRef = React.useRef<HTMLInputElement>(null);\n const [inputValue, setInputValue] = React.useState(() => {\n return value?.rawValue !== undefined && formatParams\n ? formatParams.formatFunction(value.rawValue)\n : \"\";\n });\n\n if (!formatParams) {\n return null;\n }\n\n const style: React.CSSProperties | undefined =\n sizeParams?.size !== undefined\n ? {\n minWidth: `${sizeParams?.size * 0.75}em`,\n }\n : undefined;\n const icon =\n iconParams?.definition?.iconSpec !== undefined\n ? findIcon(iconParams.definition.iconSpec)\n : undefined;\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const currentValue = e.target.value;\n const result = formatParams.parseFunction(currentValue);\n const parsedValue =\n typeof result.value === \"number\" ? result.value : undefined;\n\n setInputValue(currentValue);\n\n onChange({\n rawValue: parsedValue,\n displayValue: currentValue,\n });\n };\n\n return (\n <InputWithDecorations size={size}>\n {icon !== undefined ? (\n <InputWithDecorations.Icon>{icon}</InputWithDecorations.Icon>\n ) : null}\n <InputWithDecorations.Input\n ref={inputRef}\n style={style}\n disabled={disabled}\n onChange={handleChange}\n value={inputValue}\n />\n {decoration}\n </InputWithDecorations>\n );\n}\n\n/* v8 ignore stop */\n"]}
1
+ {"version":3,"file":"CustomNumber.js","sourceRoot":"","sources":["../../../../../src/components-react/new-editors/interop/old-editors/CustomNumber.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,EACL,8BAA8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AAoB,CAAC,KAAK,IACzB,GAAG,EAAE,QAAQ,EACb,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,YAAY,EACtB,KAAK,EAAE,UAAU,GACjB;QACD,UAAU,CACU,CACxB,CAAC;AACJ,CAAC;AAED,oBAAoB","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\nimport * as React from \"react\";\nimport {\n PropertyEditorParamTypes,\n StandardEditorNames,\n} from \"@itwin/appui-abstract\";\nimport { InputWithDecorations } from \"@itwin/itwinui-react\";\nimport type { EditorProps } from \"../../Types.js\";\nimport { createEditorSpec } from \"../../Types.js\";\nimport type { OldEditorMetadata } from \"../Metadata.js\";\nimport { isOldEditorMetadata } from \"../Metadata.js\";\nimport type { NumericValue } from \"../../values/Values.js\";\nimport {\n useCustomFormattedNumberParams,\n useIconEditorParams,\n useInputEditorSizeParams,\n} from \"./UseEditorParams.js\";\nimport { findIcon } from \"../IconsRegistry.js\";\nimport { isNumeric } from \"../../values/ValueUtilities.js\";\n\n/* v8 ignore start */\n\n/** @internal */\nexport const CustomNumberEditorSpec = createEditorSpec({\n isMetadataSupported: (metadata): metadata is OldEditorMetadata =>\n isOldEditorMetadata(metadata) &&\n metadata.type === \"number\" &&\n !!metadata.params?.find(\n (param) =>\n param.type === PropertyEditorParamTypes.CustomFormattedNumber.valueOf()\n ) &&\n metadata.preferredEditor === StandardEditorNames.NumberCustom,\n isValueSupported: isNumeric,\n Editor: CustomNumberEditor,\n});\n\ninterface CustomNumberEditorProps\n extends EditorProps<OldEditorMetadata, NumericValue> {\n decoration?: React.ReactNode;\n}\n\n/** @internal */\nexport function CustomNumberEditor({\n metadata,\n value,\n onChange,\n size,\n disabled,\n decoration,\n}: CustomNumberEditorProps) {\n const formatParams = useCustomFormattedNumberParams(metadata);\n const sizeParams = useInputEditorSizeParams(metadata);\n const iconParams = useIconEditorParams(metadata);\n const inputRef = React.useRef<HTMLInputElement>(null);\n const [inputValue, setInputValue] = React.useState(() => {\n return value?.rawValue !== undefined && formatParams\n ? formatParams.formatFunction(value.rawValue)\n : \"\";\n });\n\n if (!formatParams) {\n return null;\n }\n\n const style: React.CSSProperties | undefined =\n sizeParams?.size !== undefined\n ? {\n minWidth: `${sizeParams?.size * 0.75}em`,\n maxWidth:\n sizeParams?.maxSize !== undefined\n ? `${sizeParams?.maxSize * 0.75}em`\n : undefined,\n }\n : undefined;\n const icon =\n iconParams?.definition?.iconSpec !== undefined\n ? findIcon(iconParams.definition.iconSpec)\n : undefined;\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const currentValue = e.target.value;\n const result = formatParams.parseFunction(currentValue);\n const parsedValue =\n typeof result.value === \"number\" ? result.value : undefined;\n\n setInputValue(currentValue);\n\n onChange({\n rawValue: parsedValue,\n displayValue: currentValue,\n });\n };\n\n return (\n <InputWithDecorations size={size}>\n {icon !== undefined ? (\n <InputWithDecorations.Icon>{icon}</InputWithDecorations.Icon>\n ) : null}\n <InputWithDecorations.Input\n ref={inputRef}\n style={style}\n disabled={disabled}\n onChange={handleChange}\n value={inputValue}\n />\n {decoration}\n </InputWithDecorations>\n );\n}\n\n/* v8 ignore stop */\n"]}
@@ -30,6 +30,9 @@ function NumericInputEditor({ metadata, value, onChange, size, disabled, }) {
30
30
  const style = sizeParams?.size !== undefined
31
31
  ? {
32
32
  minWidth: `${sizeParams?.size * 0.75}em`,
33
+ maxWidth: sizeParams?.maxSize !== undefined
34
+ ? `${sizeParams?.maxSize * 0.75}em`
35
+ : undefined,
33
36
  }
34
37
  : undefined;
35
38
  const inputProps = useNumericInput({
@@ -1 +1 @@
1
- {"version":3,"file":"NumericInput.js","sourceRoot":"","sources":["../../../../../src/components-react/new-editors/interop/old-editors/NumericInput.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,KAA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AAC,CAAC,CAAC;IAEH,MAAM,YAAY,GAAG,CAAC,KAA0C,EAAE,EAAE;QAClE,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;QACxC,IAAI,SAAS,IAAI,YAAY,CAAC,MAAM,GAAG,SAAS,EAAE,CAAC;YACjD,OAAO;QACT,CAAC;QACD,iBAAiB,CAAC,YAAY,CAAC,CAAC;QAChC,QAAQ,CAAC,YAAY,CAAC,CAAC;IACzB,CAAC,CAAC;IAEF,MAAM,UAAU,GAAG,GAAG,EAAE;QACtB,IAAI,SAAS,EAAE,CAAC;YACd,MAAM,iBAAiB,GAAG,WAAW,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC;YAC9D,IAAI,iBAAiB,KAAK,cAAc,EAAE,CAAC;gBACzC,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;gBACrC,QAAQ,CAAC,iBAAiB,CAAC,CAAC;YAC9B,CAAC;QACH,CAAC;IACH,CAAC,CAAC;IAEF,OAAO;QACL,IAAI,EAAE,QAAQ;QACd,GAAG;QACH,GAAG;QACH,IAAI;QACJ,KAAK,EAAE,cAAc;QACrB,QAAQ,EAAE,YAAY;QACtB,MAAM,EAAE,UAAU;KACnB,CAAC;AACJ,CAAC;AAED,oBAAoB","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\nimport * as React from \"react\";\nimport { StandardEditorNames } from \"@itwin/appui-abstract\";\nimport type { EditorProps, EditorSpec } from \"../../Types.js\";\nimport { createEditorSpec } from \"../../Types.js\";\nimport type { OldEditorMetadata } from \"../Metadata.js\";\nimport { isOldEditorMetadata } from \"../Metadata.js\";\nimport type { NumericValue } from \"../../values/Values.js\";\nimport {\n useInputEditorSizeParams,\n useRangeEditorParams,\n} from \"./UseEditorParams.js\";\nimport { Input } from \"@itwin/itwinui-react\";\nimport { isNumeric } from \"../../values/ValueUtilities.js\";\n\n/* v8 ignore start */\n\n/** @internal */\nexport const NumericInputEditorSpec: EditorSpec = createEditorSpec({\n isMetadataSupported: (metadata): metadata is OldEditorMetadata =>\n isOldEditorMetadata(metadata) &&\n metadata.type === \"number\" &&\n metadata.preferredEditor === StandardEditorNames.NumericInput,\n isValueSupported: isNumeric,\n Editor: NumericInputEditor,\n});\n\nfunction NumericInputEditor({\n metadata,\n value,\n onChange,\n size,\n disabled,\n}: EditorProps<OldEditorMetadata, NumericValue>) {\n const sizeParams = useInputEditorSizeParams(metadata);\n const rangeParams = useRangeEditorParams(metadata);\n const handleChange = (newValue: string) => {\n onChange({\n displayValue: newValue,\n rawValue: parseFloat(newValue),\n });\n };\n\n const style: React.CSSProperties | undefined =\n sizeParams?.size !== undefined\n ? {\n minWidth: `${sizeParams?.size * 0.75}em`,\n }\n : undefined;\n\n const inputProps = useNumericInput({\n min: rangeParams?.minimum,\n max: rangeParams?.maximum,\n precision: rangeParams?.precision,\n step: rangeParams?.step,\n maxLength: sizeParams?.maxLength,\n onChange: handleChange,\n value: value?.displayValue ?? \"\",\n });\n\n return (\n <Input style={style} size={size} disabled={disabled} {...inputProps} />\n );\n}\n\ninterface UseNumericInputProps {\n min?: number;\n max?: number;\n step?: number;\n precision?: number;\n maxLength?: number;\n value: string;\n onChange: (newValue: string) => void;\n}\n\nfunction useNumericInput({\n min,\n max,\n step,\n precision,\n maxLength,\n value,\n onChange,\n}: UseNumericInputProps) {\n const formatValue = (val: number) => {\n const appliedMin = min ?? Number.MIN_VALUE;\n const appliedMax = max ?? Number.MAX_VALUE;\n const valueInRange = Math.min(appliedMax, Math.max(appliedMin, val));\n\n return precision\n ? valueInRange.toFixed(precision)\n : valueInRange.toString();\n };\n\n const [formattedValue, setFormattedValue] = React.useState(() => {\n return value.length !== 0 ? formatValue(Number(value)) : value;\n });\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n const currentValue = event.target.value;\n if (maxLength && currentValue.length > maxLength) {\n return;\n }\n setFormattedValue(currentValue);\n onChange(currentValue);\n };\n\n const handleBlur = () => {\n if (precision) {\n const newFormattedValue = formatValue(Number(formattedValue));\n if (newFormattedValue !== formattedValue) {\n setFormattedValue(newFormattedValue);\n onChange(newFormattedValue);\n }\n }\n };\n\n return {\n type: \"number\",\n min,\n max,\n step,\n value: formattedValue,\n onChange: handleChange,\n onBlur: handleBlur,\n };\n}\n\n/* v8 ignore stop */\n"]}
1
+ {"version":3,"file":"NumericInput.js","sourceRoot":"","sources":["../../../../../src/components-react/new-editors/interop/old-editors/NumericInput.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,EACL,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAE3D,qBAAqB;AAErB,gBAAgB;AAChB,MAAM,CAAC,MAAM,sBAAsB,GAAe,gBAAgB,CAAC;IACjE,mBAAmB,EAAE,CAAC,QAAQ,EAAiC,EAAE,CAC/D,mBAAmB,CAAC,QAAQ,CAAC;QAC7B,QAAQ,CAAC,IAAI,KAAK,QAAQ;QAC1B,QAAQ,CAAC,eAAe,KAAK,mBAAmB,CAAC,YAAY;IAC/D,gBAAgB,EAAE,SAAS;IAC3B,MAAM,EAAE,kBAAkB;CAC3B,CAAC,CAAC;AAEH,SAAS,kBAAkB,CAAC,EAC1B,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,QAAQ,GACqC;IAC7C,MAAM,UAAU,GAA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AAG;QACH,IAAI;QACJ,KAAK,EAAE,cAAc;QACrB,QAAQ,EAAE,YAAY;QACtB,MAAM,EAAE,UAAU;KACnB,CAAC;AACJ,CAAC;AAED,oBAAoB","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\nimport * as React from \"react\";\nimport { StandardEditorNames } from \"@itwin/appui-abstract\";\nimport type { EditorProps, EditorSpec } from \"../../Types.js\";\nimport { createEditorSpec } from \"../../Types.js\";\nimport type { OldEditorMetadata } from \"../Metadata.js\";\nimport { isOldEditorMetadata } from \"../Metadata.js\";\nimport type { NumericValue } from \"../../values/Values.js\";\nimport {\n useInputEditorSizeParams,\n useRangeEditorParams,\n} from \"./UseEditorParams.js\";\nimport { Input } from \"@itwin/itwinui-react\";\nimport { isNumeric } from \"../../values/ValueUtilities.js\";\n\n/* v8 ignore start */\n\n/** @internal */\nexport const NumericInputEditorSpec: EditorSpec = createEditorSpec({\n isMetadataSupported: (metadata): metadata is OldEditorMetadata =>\n isOldEditorMetadata(metadata) &&\n metadata.type === \"number\" &&\n metadata.preferredEditor === StandardEditorNames.NumericInput,\n isValueSupported: isNumeric,\n Editor: NumericInputEditor,\n});\n\nfunction NumericInputEditor({\n metadata,\n value,\n onChange,\n size,\n disabled,\n}: EditorProps<OldEditorMetadata, NumericValue>) {\n const sizeParams = useInputEditorSizeParams(metadata);\n const rangeParams = useRangeEditorParams(metadata);\n const handleChange = (newValue: string) => {\n onChange({\n displayValue: newValue,\n rawValue: parseFloat(newValue),\n });\n };\n\n const style: React.CSSProperties | undefined =\n sizeParams?.size !== undefined\n ? {\n minWidth: `${sizeParams?.size * 0.75}em`,\n maxWidth:\n sizeParams?.maxSize !== undefined\n ? `${sizeParams?.maxSize * 0.75}em`\n : undefined,\n }\n : undefined;\n\n const inputProps = useNumericInput({\n min: rangeParams?.minimum,\n max: rangeParams?.maximum,\n precision: rangeParams?.precision,\n step: rangeParams?.step,\n maxLength: sizeParams?.maxLength,\n onChange: handleChange,\n value: value?.displayValue ?? \"\",\n });\n\n return (\n <Input style={style} size={size} disabled={disabled} {...inputProps} />\n );\n}\n\ninterface UseNumericInputProps {\n min?: number;\n max?: number;\n step?: number;\n precision?: number;\n maxLength?: number;\n value: string;\n onChange: (newValue: string) => void;\n}\n\nfunction useNumericInput({\n min,\n max,\n step,\n precision,\n maxLength,\n value,\n onChange,\n}: UseNumericInputProps) {\n const formatValue = (val: number) => {\n const appliedMin = min ?? Number.MIN_VALUE;\n const appliedMax = max ?? Number.MAX_VALUE;\n const valueInRange = Math.min(appliedMax, Math.max(appliedMin, val));\n\n return precision\n ? valueInRange.toFixed(precision)\n : valueInRange.toString();\n };\n\n const [formattedValue, setFormattedValue] = React.useState(() => {\n return value.length !== 0 ? formatValue(Number(value)) : value;\n });\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n const currentValue = event.target.value;\n if (maxLength && currentValue.length > maxLength) {\n return;\n }\n setFormattedValue(currentValue);\n onChange(currentValue);\n };\n\n const handleBlur = () => {\n if (precision) {\n const newFormattedValue = formatValue(Number(formattedValue));\n if (newFormattedValue !== formattedValue) {\n setFormattedValue(newFormattedValue);\n onChange(newFormattedValue);\n }\n }\n };\n\n return {\n type: \"number\",\n min,\n max,\n step,\n value: formattedValue,\n onChange: handleChange,\n onBlur: handleBlur,\n };\n}\n\n/* v8 ignore stop */\n"]}
@@ -7,6 +7,7 @@ import * as React from "react";
7
7
  * Properties for identifying an active highlight on a node in a tree.
8
8
  * @see [[HighlightableTreeProps.activeMatch]]
9
9
  * @public
10
+ * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.
10
11
  */
11
12
  export interface ActiveMatchInfo {
12
13
  nodeId: string;
@@ -16,6 +17,7 @@ export interface ActiveMatchInfo {
16
17
  * Properties for highlighting nodes in a tree.
17
18
  * @see [[ControlledTreeProps.nodeHighlightingProps]]
18
19
  * @public
20
+ * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.
19
21
  */
20
22
  export interface HighlightableTreeProps {
21
23
  searchText: string;
@@ -24,6 +26,7 @@ export interface HighlightableTreeProps {
24
26
  /**
25
27
  * Properties for a highlightable [[TreeNode]]
26
28
  * @public
29
+ * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.
27
30
  */
28
31
  export interface HighlightableTreeNodeProps {
29
32
  searchText: string;
@@ -32,10 +35,12 @@ export interface HighlightableTreeNodeProps {
32
35
  /**
33
36
  * Tree highlighting engine
34
37
  * @public
38
+ * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.
35
39
  */
36
40
  export declare class HighlightingEngine {
37
41
  private _searchText;
38
42
  private _activeMatch?;
43
+ /** @deprecated in 5.28.0. Use `HIGHLIGHT_ACTIVE_CLASS_NAME` instead. */
39
44
  static readonly ACTIVE_CLASS_NAME = "components-activehighlight";
40
45
  constructor(props: HighlightableTreeProps);
41
46
  isNodeActive(node: {
@@ -1 +1 @@
1
- {"version":3,"file":"HighlightingEngine.d.ts","sourceRoot":"","sources":["../../../src/components-react/tree/HighlightingEngine.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,2BAA2B,CAAC;AACnC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,eAAe,CAAC;CAC/B;AAED;;;GAGG;AACH,MAAM,WAAW,0BAA0B;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;GAGG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,WAAW,CAAS;IAC5B,O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EAAE,CAAC,EAAE,MAAM,CAAA;KAAE;IAIzC,iBAAiB,CAAC,IAAI,EAAE;QAAE,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,0BAA0B;WAO7D,eAAe,CAC3B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,0BAA0B,GAChC,KAAK,CAAC,SAAS;CAInB"}
@@ -5,16 +5,19 @@
5
5
  /** @packageDocumentation
6
6
  * @module Tree
7
7
  */
8
+ /* eslint-disable @typescript-eslint/no-deprecated */
8
9
  import "./HighlightingEngine.scss";
9
10
  import * as React from "react";
10
11
  import { HighlightedText } from "../common/HighlightedText.js";
11
12
  /**
12
13
  * Tree highlighting engine
13
14
  * @public
15
+ * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.
14
16
  */
15
17
  export class HighlightingEngine {
16
18
  _searchText;
17
19
  _activeMatch;
20
+ /** @deprecated in 5.28.0. Use `HIGHLIGHT_ACTIVE_CLASS_NAME` instead. */
18
21
  static ACTIVE_CLASS_NAME = "components-activehighlight";
19
22
  constructor(props) {
20
23
  this._searchText = props.searchText;
@@ -1 +1 @@
1
- {"version":3,"file":"HighlightingEngine.js","sourceRoot":"","sources":["../../../src/components-react/tree/HighlightingEngine.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,2BAA2B,CAAC;AACnC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AA+B/D;;;GAGG;AACH,MAAM,OAAO,kBAAkB;IACrB,WAAW,CAAS;IACpB,YAAY,CAAmB;IAChC,MAAM,CAAU,iBAAiB,GAAG,4BAA4B,CAAC;IAExE,YAAY,KAA6B;QACvC,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,UAAU,CAAC;QACpC,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,WAAW,CAAC;IACxC,CAAC;IAEM,YAAY,CAAC,IAAqB;QACvC,OAAO,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC;IACnE,CAAC;IAEM,mBAAmB,CAAC,IAAqB;QAC9C,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,YAAa,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;IAC7E,CAAC;IAEM,iBAAiB,CAAC,IAAqB;QAC5C,OAAO;YACL,UAAU,EAAE,IAAI,CAAC,WAAW;YAC5B,gBAAgB,EAAE,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC;SACjD,CAAC;IACJ,CAAC;IAEM,MAAM,CAAC,eAAe,CAC3B,IAAY,EACZ,KAAiC;QAEjC,IAAI,KAAK,CAAC,UAAU;YAAE,OAAO,oBAAC,eAAe,IAAC,IAAI,EAAE,IAAI,KAAM,KAAK,GAAI,CAAC;QACxE,OAAO,IAAI,CAAC;IACd,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 Tree\n */\n\nimport \"./HighlightingEngine.scss\";\nimport * as React from \"react\";\nimport { HighlightedText } from \"../common/HighlightedText.js\";\n\n/**\n * Properties for identifying an active highlight on a node in a tree.\n * @see [[HighlightableTreeProps.activeMatch]]\n * @public\n */\nexport interface ActiveMatchInfo {\n nodeId: string;\n matchIndex: number;\n}\n\n/**\n * Properties for highlighting nodes in a tree.\n * @see [[ControlledTreeProps.nodeHighlightingProps]]\n * @public\n */\nexport interface HighlightableTreeProps {\n searchText: string;\n activeMatch?: ActiveMatchInfo;\n}\n\n/**\n * Properties for a highlightable [[TreeNode]]\n * @public\n */\nexport interface HighlightableTreeNodeProps {\n searchText: string;\n activeMatchIndex?: number;\n}\n\n/**\n * Tree highlighting engine\n * @public\n */\nexport class HighlightingEngine {\n private _searchText: string;\n private _activeMatch?: ActiveMatchInfo;\n public static readonly ACTIVE_CLASS_NAME = \"components-activehighlight\";\n\n constructor(props: HighlightableTreeProps) {\n this._searchText = props.searchText;\n this._activeMatch = props.activeMatch;\n }\n\n public isNodeActive(node: { id?: string }) {\n return this._activeMatch && node.id === this._activeMatch.nodeId;\n }\n\n public getActiveMatchIndex(node: { id?: string }) {\n return this.isNodeActive(node) ? this._activeMatch!.matchIndex : undefined;\n }\n\n public createRenderProps(node: { id?: string }): HighlightableTreeNodeProps {\n return {\n searchText: this._searchText,\n activeMatchIndex: this.getActiveMatchIndex(node),\n };\n }\n\n public static renderNodeLabel(\n text: string,\n props: HighlightableTreeNodeProps\n ): React.ReactNode {\n if (props.searchText) return <HighlightedText text={text} {...props} />;\n return text;\n }\n}\n"]}
1
+ {"version":3,"file":"HighlightingEngine.js","sourceRoot":"","sources":["../../../src/components-react/tree/HighlightingEngine.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,qDAAqD;AAErD,OAAO,2BAA2B,CAAC;AACnC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAkC/D;;;;GAIG;AACH,MAAM,OAAO,kBAAkB;IACrB,WAAW,CAAS;IACpB,YAAY,CAAmB;IACvC,wEAAwE;IACjE,MAAM,CAAU,iBAAiB,GAAG,4BAA4B,CAAC;IAExE,YAAY,KAA6B;QACvC,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,UAAU,CAAC;QACpC,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,WAAW,CAAC;IACxC,CAAC;IAEM,YAAY,CAAC,IAAqB;QACvC,OAAO,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC;IACnE,CAAC;IAEM,mBAAmB,CAAC,IAAqB;QAC9C,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,YAAa,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;IAC7E,CAAC;IAEM,iBAAiB,CAAC,IAAqB;QAC5C,OAAO;YACL,UAAU,EAAE,IAAI,CAAC,WAAW;YAC5B,gBAAgB,EAAE,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC;SACjD,CAAC;IACJ,CAAC;IAEM,MAAM,CAAC,eAAe,CAC3B,IAAY,EACZ,KAAiC;QAEjC,IAAI,KAAK,CAAC,UAAU;YAAE,OAAO,oBAAC,eAAe,IAAC,IAAI,EAAE,IAAI,KAAM,KAAK,GAAI,CAAC;QACxE,OAAO,IAAI,CAAC;IACd,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 Tree\n */\n\n/* eslint-disable @typescript-eslint/no-deprecated */\n\nimport \"./HighlightingEngine.scss\";\nimport * as React from \"react\";\nimport { HighlightedText } from \"../common/HighlightedText.js\";\n\n/**\n * Properties for identifying an active highlight on a node in a tree.\n * @see [[HighlightableTreeProps.activeMatch]]\n * @public\n * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.\n */\nexport interface ActiveMatchInfo {\n nodeId: string;\n matchIndex: number;\n}\n\n/**\n * Properties for highlighting nodes in a tree.\n * @see [[ControlledTreeProps.nodeHighlightingProps]]\n * @public\n * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.\n */\nexport interface HighlightableTreeProps {\n searchText: string;\n activeMatch?: ActiveMatchInfo;\n}\n\n/**\n * Properties for a highlightable [[TreeNode]]\n * @public\n * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.\n */\nexport interface HighlightableTreeNodeProps {\n searchText: string;\n activeMatchIndex?: number;\n}\n\n/**\n * Tree highlighting engine\n * @public\n * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.\n */\nexport class HighlightingEngine {\n private _searchText: string;\n private _activeMatch?: ActiveMatchInfo;\n /** @deprecated in 5.28.0. Use `HIGHLIGHT_ACTIVE_CLASS_NAME` instead. */\n public static readonly ACTIVE_CLASS_NAME = \"components-activehighlight\";\n\n constructor(props: HighlightableTreeProps) {\n this._searchText = props.searchText;\n this._activeMatch = props.activeMatch;\n }\n\n public isNodeActive(node: { id?: string }) {\n return this._activeMatch && node.id === this._activeMatch.nodeId;\n }\n\n public getActiveMatchIndex(node: { id?: string }) {\n return this.isNodeActive(node) ? this._activeMatch!.matchIndex : undefined;\n }\n\n public createRenderProps(node: { id?: string }): HighlightableTreeNodeProps {\n return {\n searchText: this._searchText,\n activeMatchIndex: this.getActiveMatchIndex(node),\n };\n }\n\n public static renderNodeLabel(\n text: string,\n props: HighlightableTreeNodeProps\n ): React.ReactNode {\n if (props.searchText) return <HighlightedText text={text} {...props} />;\n return text;\n }\n}\n"]}
@@ -5,12 +5,14 @@ import type { IImageLoader, LoadedImage } from "../common/IImageLoader.js";
5
5
  import type { TreeNodeItem } from "./TreeDataProvider.js";
6
6
  /** Interface for a tree image loader
7
7
  * @public
8
+ * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.
8
9
  */
9
10
  export interface ITreeImageLoader extends IImageLoader {
10
11
  load: (item: TreeNodeItem) => LoadedImage | undefined;
11
12
  }
12
13
  /** Default image loader for the tree
13
14
  * @public
15
+ * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.
14
16
  */
15
17
  export declare class TreeImageLoader implements ITreeImageLoader {
16
18
  /** Loads image data from either [[TreeNodeItem]] */
@@ -1 +1 @@
1
- {"version":3,"file":"ImageLoader.d.ts","sourceRoot":"","sources":["../../../src/components-react/tree/ImageLoader.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC3E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D;;GAEG;AACH,MAAM,WAAW,gBAAiB,SAAQ,YAAY;IACpD,IAAI,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,WAAW,GAAG,SAAS,CAAC;CACvD;AAED;;GAEG;AACH,qBAAa,eAAgB,YAAW,gBAAgB;IACtD,oDAAoD;IAC7C,IAAI,CAAC,IAAI,EAAE,YAAY,GAAG,WAAW,GAAG,SAAS;CAQzD"}
1
+ {"version":3,"file":"ImageLoader.d.ts","sourceRoot":"","sources":["../../../src/components-react/tree/ImageLoader.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC3E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D;;;GAGG;AACH,MAAM,WAAW,gBAAiB,SAAQ,YAAY;IACpD,IAAI,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,WAAW,GAAG,SAAS,CAAC;CACvD;AAED;;;GAGG;AACH,qBAAa,eAAgB,YAAW,gBAAgB;IACtD,oDAAoD;IAC7C,IAAI,CAAC,IAAI,EAAE,YAAY,GAAG,WAAW,GAAG,SAAS;CAQzD"}
@@ -7,6 +7,7 @@
7
7
  */
8
8
  /** Default image loader for the tree
9
9
  * @public
10
+ * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.
10
11
  */
11
12
  export class TreeImageLoader {
12
13
  /** Loads image data from either [[TreeNodeItem]] */
@@ -1 +1 @@
1
- {"version":3,"file":"ImageLoader.js","sourceRoot":"","sources":["../../../src/components-react/tree/ImageLoader.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAYH;;GAEG;AACH,MAAM,OAAO,eAAe;IAC1B,oDAAoD;IAC7C,IAAI,CAAC,IAAkB;QAC5B,IAAI,CAAC,IAAI,CAAC,IAAI;YAAE,OAAO,SAAS,CAAC;QAEjC,OAAO;YACL,UAAU,EAAE,cAAc;YAC1B,KAAK,EAAE,IAAI,CAAC,IAAI;SACjB,CAAC;IACJ,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 Tree\n */\n\nimport type { IImageLoader, LoadedImage } from \"../common/IImageLoader.js\";\nimport type { TreeNodeItem } from \"./TreeDataProvider.js\";\n\n/** Interface for a tree image loader\n * @public\n */\nexport interface ITreeImageLoader extends IImageLoader {\n load: (item: TreeNodeItem) => LoadedImage | undefined;\n}\n\n/** Default image loader for the tree\n * @public\n */\nexport class TreeImageLoader implements ITreeImageLoader {\n /** Loads image data from either [[TreeNodeItem]] */\n public load(item: TreeNodeItem): LoadedImage | undefined {\n if (!item.icon) return undefined;\n\n return {\n sourceType: \"webfont-icon\",\n value: item.icon,\n };\n }\n}\n"]}
1
+ {"version":3,"file":"ImageLoader.js","sourceRoot":"","sources":["../../../src/components-react/tree/ImageLoader.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAeH;;;GAGG;AACH,MAAM,OAAO,eAAe;IAC1B,oDAAoD;IAC7C,IAAI,CAAC,IAAkB;QAC5B,IAAI,CAAC,IAAI,CAAC,IAAI;YAAE,OAAO,SAAS,CAAC;QAEjC,OAAO;YACL,UAAU,EAAE,cAAc;YAC1B,KAAK,EAAE,IAAI,CAAC,IAAI;SACjB,CAAC;IACJ,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 Tree\n */\n\n/* eslint-disable @typescript-eslint/no-deprecated */\n\nimport type { IImageLoader, LoadedImage } from \"../common/IImageLoader.js\";\nimport type { TreeNodeItem } from \"./TreeDataProvider.js\";\n\n/** Interface for a tree image loader\n * @public\n * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.\n */\nexport interface ITreeImageLoader extends IImageLoader {\n load: (item: TreeNodeItem) => LoadedImage | undefined;\n}\n\n/** Default image loader for the tree\n * @public\n * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.\n */\nexport class TreeImageLoader implements ITreeImageLoader {\n /** Loads image data from either [[TreeNodeItem]] */\n public load(item: TreeNodeItem): LoadedImage | undefined {\n if (!item.icon) return undefined;\n\n return {\n sourceType: \"webfont-icon\",\n value: item.icon,\n };\n }\n}\n"]}