@itwin/components-react 5.3.0 → 5.4.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 (162) hide show
  1. package/CHANGELOG.md +14 -1
  2. package/lib/components-react/editors/CustomNumberEditor.d.ts +1 -1
  3. package/lib/components-react/editors/CustomNumberEditor.d.ts.map +1 -1
  4. package/lib/components-react/editors/CustomNumberEditor.js +5 -0
  5. package/lib/components-react/editors/CustomNumberEditor.js.map +1 -1
  6. package/lib/components-react/new-editors/EditorRenderer.d.ts +11 -0
  7. package/lib/components-react/new-editors/EditorRenderer.d.ts.map +1 -0
  8. package/lib/components-react/new-editors/EditorRenderer.js +22 -0
  9. package/lib/components-react/new-editors/EditorRenderer.js.map +1 -0
  10. package/lib/components-react/new-editors/Types.d.ts +46 -0
  11. package/lib/components-react/new-editors/Types.d.ts.map +1 -0
  12. package/lib/components-react/new-editors/Types.js +20 -0
  13. package/lib/components-react/new-editors/Types.js.map +1 -0
  14. package/lib/components-react/new-editors/UseCommittableValue.d.ts +51 -0
  15. package/lib/components-react/new-editors/UseCommittableValue.d.ts.map +1 -0
  16. package/lib/components-react/new-editors/UseCommittableValue.js +85 -0
  17. package/lib/components-react/new-editors/UseCommittableValue.js.map +1 -0
  18. package/lib/components-react/new-editors/editors/BooleanEditor.d.ts +10 -0
  19. package/lib/components-react/new-editors/editors/BooleanEditor.d.ts.map +1 -0
  20. package/lib/components-react/new-editors/editors/BooleanEditor.js +22 -0
  21. package/lib/components-react/new-editors/editors/BooleanEditor.js.map +1 -0
  22. package/lib/components-react/new-editors/editors/DateEditor.d.ts +10 -0
  23. package/lib/components-react/new-editors/editors/DateEditor.d.ts.map +1 -0
  24. package/lib/components-react/new-editors/editors/DateEditor.js +18 -0
  25. package/lib/components-react/new-editors/editors/DateEditor.js.map +1 -0
  26. package/lib/components-react/new-editors/editors/DateInput.d.ts +15 -0
  27. package/lib/components-react/new-editors/editors/DateInput.d.ts.map +1 -0
  28. package/lib/components-react/new-editors/editors/DateInput.js +23 -0
  29. package/lib/components-react/new-editors/editors/DateInput.js.map +1 -0
  30. package/lib/components-react/new-editors/editors/DateTimeEditor.d.ts +10 -0
  31. package/lib/components-react/new-editors/editors/DateTimeEditor.d.ts.map +1 -0
  32. package/lib/components-react/new-editors/editors/DateTimeEditor.js +18 -0
  33. package/lib/components-react/new-editors/editors/DateTimeEditor.js.map +1 -0
  34. package/lib/components-react/new-editors/editors/EnumEditor.d.ts +10 -0
  35. package/lib/components-react/new-editors/editors/EnumEditor.d.ts.map +1 -0
  36. package/lib/components-react/new-editors/editors/EnumEditor.js +30 -0
  37. package/lib/components-react/new-editors/editors/EnumEditor.js.map +1 -0
  38. package/lib/components-react/new-editors/editors/FallbackEditor.d.ts +8 -0
  39. package/lib/components-react/new-editors/editors/FallbackEditor.d.ts.map +1 -0
  40. package/lib/components-react/new-editors/editors/FallbackEditor.js +41 -0
  41. package/lib/components-react/new-editors/editors/FallbackEditor.js.map +1 -0
  42. package/lib/components-react/new-editors/editors/FormattedNumericInput.d.ts +24 -0
  43. package/lib/components-react/new-editors/editors/FormattedNumericInput.d.ts.map +1 -0
  44. package/lib/components-react/new-editors/editors/FormattedNumericInput.js +77 -0
  45. package/lib/components-react/new-editors/editors/FormattedNumericInput.js.map +1 -0
  46. package/lib/components-react/new-editors/editors/NumericEditor.d.ts +10 -0
  47. package/lib/components-react/new-editors/editors/NumericEditor.d.ts.map +1 -0
  48. package/lib/components-react/new-editors/editors/NumericEditor.js +23 -0
  49. package/lib/components-react/new-editors/editors/NumericEditor.js.map +1 -0
  50. package/lib/components-react/new-editors/editors/TextEditor.d.ts +10 -0
  51. package/lib/components-react/new-editors/editors/TextEditor.d.ts.map +1 -0
  52. package/lib/components-react/new-editors/editors/TextEditor.js +17 -0
  53. package/lib/components-react/new-editors/editors/TextEditor.js.map +1 -0
  54. package/lib/components-react/new-editors/editors/ToggleEditor.d.ts +10 -0
  55. package/lib/components-react/new-editors/editors/ToggleEditor.d.ts.map +1 -0
  56. package/lib/components-react/new-editors/editors/ToggleEditor.js +22 -0
  57. package/lib/components-react/new-editors/editors/ToggleEditor.js.map +1 -0
  58. package/lib/components-react/new-editors/editors-registry/DefaultEditors.d.ts +50 -0
  59. package/lib/components-react/new-editors/editors-registry/DefaultEditors.d.ts.map +1 -0
  60. package/lib/components-react/new-editors/editors-registry/DefaultEditors.js +117 -0
  61. package/lib/components-react/new-editors/editors-registry/DefaultEditors.js.map +1 -0
  62. package/lib/components-react/new-editors/editors-registry/EditorsRegistryContext.d.ts +12 -0
  63. package/lib/components-react/new-editors/editors-registry/EditorsRegistryContext.d.ts.map +1 -0
  64. package/lib/components-react/new-editors/editors-registry/EditorsRegistryContext.js +14 -0
  65. package/lib/components-react/new-editors/editors-registry/EditorsRegistryContext.js.map +1 -0
  66. package/lib/components-react/new-editors/editors-registry/EditorsRegistryProvider.d.ts +15 -0
  67. package/lib/components-react/new-editors/editors-registry/EditorsRegistryProvider.d.ts.map +1 -0
  68. package/lib/components-react/new-editors/editors-registry/EditorsRegistryProvider.js +25 -0
  69. package/lib/components-react/new-editors/editors-registry/EditorsRegistryProvider.js.map +1 -0
  70. package/lib/components-react/new-editors/editors-registry/UseEditor.d.ts +16 -0
  71. package/lib/components-react/new-editors/editors-registry/UseEditor.d.ts.map +1 -0
  72. package/lib/components-react/new-editors/editors-registry/UseEditor.js +36 -0
  73. package/lib/components-react/new-editors/editors-registry/UseEditor.js.map +1 -0
  74. package/lib/components-react/new-editors/interop/EditorInterop.d.ts +17 -0
  75. package/lib/components-react/new-editors/interop/EditorInterop.d.ts.map +1 -0
  76. package/lib/components-react/new-editors/interop/EditorInterop.js +146 -0
  77. package/lib/components-react/new-editors/interop/EditorInterop.js.map +1 -0
  78. package/lib/components-react/new-editors/interop/IconsRegistry.d.ts +6 -0
  79. package/lib/components-react/new-editors/interop/IconsRegistry.d.ts.map +1 -0
  80. package/lib/components-react/new-editors/interop/IconsRegistry.js +41 -0
  81. package/lib/components-react/new-editors/interop/IconsRegistry.js.map +1 -0
  82. package/lib/components-react/new-editors/interop/Metadata.d.ts +21 -0
  83. package/lib/components-react/new-editors/interop/Metadata.d.ts.map +1 -0
  84. package/lib/components-react/new-editors/interop/Metadata.js +13 -0
  85. package/lib/components-react/new-editors/interop/Metadata.js.map +1 -0
  86. package/lib/components-react/new-editors/interop/PropertyRecordEditor.d.ts +22 -0
  87. package/lib/components-react/new-editors/interop/PropertyRecordEditor.d.ts.map +1 -0
  88. package/lib/components-react/new-editors/interop/PropertyRecordEditor.js +41 -0
  89. package/lib/components-react/new-editors/interop/PropertyRecordEditor.js.map +1 -0
  90. package/lib/components-react/new-editors/interop/old-editors/Color.d.ts +7 -0
  91. package/lib/components-react/new-editors/interop/old-editors/Color.d.ts.map +1 -0
  92. package/lib/components-react/new-editors/interop/old-editors/Color.js +48 -0
  93. package/lib/components-react/new-editors/interop/old-editors/Color.js.map +1 -0
  94. package/lib/components-react/new-editors/interop/old-editors/CustomNumber.d.ts +3 -0
  95. package/lib/components-react/new-editors/interop/old-editors/CustomNumber.d.ts.map +1 -0
  96. package/lib/components-react/new-editors/interop/old-editors/CustomNumber.js +59 -0
  97. package/lib/components-react/new-editors/interop/old-editors/CustomNumber.js.map +1 -0
  98. package/lib/components-react/new-editors/interop/old-editors/Enum.d.ts +4 -0
  99. package/lib/components-react/new-editors/interop/old-editors/Enum.d.ts.map +1 -0
  100. package/lib/components-react/new-editors/interop/old-editors/Enum.js +23 -0
  101. package/lib/components-react/new-editors/interop/old-editors/Enum.js.map +1 -0
  102. package/lib/components-react/new-editors/interop/old-editors/EnumButtonGroup.d.ts +4 -0
  103. package/lib/components-react/new-editors/interop/old-editors/EnumButtonGroup.d.ts.map +1 -0
  104. package/lib/components-react/new-editors/interop/old-editors/EnumButtonGroup.js +50 -0
  105. package/lib/components-react/new-editors/interop/old-editors/EnumButtonGroup.js.map +1 -0
  106. package/lib/components-react/new-editors/interop/old-editors/NumericInput.d.ts +4 -0
  107. package/lib/components-react/new-editors/interop/old-editors/NumericInput.d.ts.map +1 -0
  108. package/lib/components-react/new-editors/interop/old-editors/NumericInput.js +86 -0
  109. package/lib/components-react/new-editors/interop/old-editors/NumericInput.js.map +1 -0
  110. package/lib/components-react/new-editors/interop/old-editors/Slider.d.ts +3 -0
  111. package/lib/components-react/new-editors/interop/old-editors/Slider.d.ts.map +1 -0
  112. package/lib/components-react/new-editors/interop/old-editors/Slider.js +66 -0
  113. package/lib/components-react/new-editors/interop/old-editors/Slider.js.map +1 -0
  114. package/lib/components-react/new-editors/interop/old-editors/TextArea.d.ts +3 -0
  115. package/lib/components-react/new-editors/interop/old-editors/TextArea.d.ts.map +1 -0
  116. package/lib/components-react/new-editors/interop/old-editors/TextArea.js +33 -0
  117. package/lib/components-react/new-editors/interop/old-editors/TextArea.js.map +1 -0
  118. package/lib/components-react/new-editors/interop/old-editors/UseEditorParams.d.ts +31 -0
  119. package/lib/components-react/new-editors/interop/old-editors/UseEditorParams.d.ts.map +1 -0
  120. package/lib/components-react/new-editors/interop/old-editors/UseEditorParams.js +52 -0
  121. package/lib/components-react/new-editors/interop/old-editors/UseEditorParams.js.map +1 -0
  122. package/lib/components-react/new-editors/interop/old-editors/UseEnumMetadata.d.ts +8 -0
  123. package/lib/components-react/new-editors/interop/old-editors/UseEnumMetadata.d.ts.map +1 -0
  124. package/lib/components-react/new-editors/interop/old-editors/UseEnumMetadata.js +41 -0
  125. package/lib/components-react/new-editors/interop/old-editors/UseEnumMetadata.js.map +1 -0
  126. package/lib/components-react/new-editors/values/Metadata.d.ts +35 -0
  127. package/lib/components-react/new-editors/values/Metadata.d.ts.map +1 -0
  128. package/lib/components-react/new-editors/values/Metadata.js +9 -0
  129. package/lib/components-react/new-editors/values/Metadata.js.map +1 -0
  130. package/lib/components-react/new-editors/values/ValueUtilities.d.ts +40 -0
  131. package/lib/components-react/new-editors/values/ValueUtilities.d.ts.map +1 -0
  132. package/lib/components-react/new-editors/values/ValueUtilities.js +84 -0
  133. package/lib/components-react/new-editors/values/ValueUtilities.js.map +1 -0
  134. package/lib/components-react/new-editors/values/Values.d.ts +58 -0
  135. package/lib/components-react/new-editors/values/Values.d.ts.map +1 -0
  136. package/lib/components-react/new-editors/values/Values.js +9 -0
  137. package/lib/components-react/new-editors/values/Values.js.map +1 -0
  138. package/lib/components-react/properties/IconNodeEditorParam.d.ts +16 -0
  139. package/lib/components-react/properties/IconNodeEditorParam.d.ts.map +1 -0
  140. package/lib/components-react/properties/IconNodeEditorParam.js +20 -0
  141. package/lib/components-react/properties/IconNodeEditorParam.js.map +1 -0
  142. package/lib/components-react/propertygrid/component/VirtualizedPropertyGrid.d.ts +7 -0
  143. package/lib/components-react/propertygrid/component/VirtualizedPropertyGrid.d.ts.map +1 -1
  144. package/lib/components-react/propertygrid/component/VirtualizedPropertyGrid.js +2 -1
  145. package/lib/components-react/propertygrid/component/VirtualizedPropertyGrid.js.map +1 -1
  146. package/lib/components-react/propertygrid/component/VirtualizedPropertyGridWithDataProvider.d.ts +6 -0
  147. package/lib/components-react/propertygrid/component/VirtualizedPropertyGridWithDataProvider.d.ts.map +1 -1
  148. package/lib/components-react/propertygrid/component/VirtualizedPropertyGridWithDataProvider.js +1 -1
  149. package/lib/components-react/propertygrid/component/VirtualizedPropertyGridWithDataProvider.js.map +1 -1
  150. package/lib/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.d.ts +2 -0
  151. package/lib/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.d.ts.map +1 -1
  152. package/lib/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.js +3 -3
  153. package/lib/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.js.map +1 -1
  154. package/lib/components-react.d.ts +9 -0
  155. package/lib/components-react.d.ts.map +1 -1
  156. package/lib/components-react.js +7 -0
  157. package/lib/components-react.js.map +1 -1
  158. package/lib/internal.d.ts +1 -0
  159. package/lib/internal.d.ts.map +1 -1
  160. package/lib/internal.js +1 -0
  161. package/lib/internal.js.map +1 -1
  162. package/package.json +4 -6
package/CHANGELOG.md CHANGED
@@ -1,6 +1,19 @@
1
1
  # Change Log - @itwin/components-react
2
2
 
3
- This log was last generated on Fri, 14 Mar 2025 17:37:48 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 17 Apr 2025 09:55:41 GMT and should not be manually modified.
4
+
5
+ ## 5.4.0
6
+ Thu, 17 Apr 2025 09:55:41 GMT
7
+
8
+ ### Updates
9
+
10
+ - `useCommittableValue`: Avoid invoking `commit` if value is the same as the initial.
11
+ - Added new system for rendering property value editor components.
12
+
13
+ ## 5.3.1
14
+ Thu, 20 Mar 2025 11:10:28 GMT
15
+
16
+ _Version update only_
4
17
 
5
18
  ## 5.3.0
6
19
  Fri, 14 Mar 2025 17:37:48 GMT
@@ -11,7 +11,7 @@ interface CustomNumberEditorState {
11
11
  inputValue: string;
12
12
  size?: number;
13
13
  maxLength?: number;
14
- iconSpec?: string;
14
+ iconSpec?: React.ReactNode;
15
15
  }
16
16
  /** CustomNumberEditor is a React component that is a property editor for numbers that specify custom formatting and parsing functions.
17
17
  * @alpha
@@ -1 +1 @@
1
- {"version":3,"file":"CustomNumberEditor.d.ts","sourceRoot":"","sources":["../../../src/components-react/editors/CustomNumberEditor.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,2BAA2B,CAAC;AAEnC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAOV,aAAa,EACd,MAAM,uBAAuB,CAAC;AAa/B,OAAO,KAAK,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,gBAAgB;AAChB,UAAU,uBAAuB;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;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
199
199
  iconSpec = iconParams.definition.iconSpec;
200
200
  }
201
+ const iconNodeParam = record.property.editor.params.find((param) => param.type ===
202
+ "appui-icon-node");
203
+ if (iconNodeParam) {
204
+ iconSpec = iconNodeParam.icon;
205
+ }
201
206
  }
202
207
  if (this._isMounted)
203
208
  this.setState({
@@ -1 +1 @@
1
- {"version":3,"file":"CustomNumberEditor.js","sourceRoot":"","sources":["../../../src/components-react/editors/CustomNumberEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,2BAA2B,CAAC;AACnC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAU7C,OAAO,EACL,eAAe,EACf,wBAAwB,EACxB,mBAAmB,EACnB,OAAO,GACR,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAI7C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAUhE;;GAEG;AACH,MAAM,OAAO,kBACX,SAAQ,KAAK,CAAC,aAA2D;IAD3E;;QAIU,eAAU,GAAG,KAAK,CAAC;QAEnB,kBAAa,GAAG,KAAK,CAAC,SAAS,EAAoB,CAAC;QAGnC,UAAK,GAAsC;YAClE,UAAU,EAAE,EAAE;SACf,CAAC;QAqGM,sBAAiB,GAAG,CAAC,CAAsC,EAAE,EAAE;YACrE,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC1C,CAAC,CAAC;QAuHM,gBAAW,GAAG,CAAC,CAAwC,EAAE,EAA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E;YAChC,SAAS,EAAE,IAAI,CAAC,WAAW;SAC5B,CAAC;QAEF,IAAI,SAA0B,CAAC;QAC/B,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;YACxB,4DAA4D;YAC5D,MAAM,IAAI,GAAG,oBAAC,IAAI,IAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAI,CAAC;YACrD,SAAS,GAAG;YACV,4DAA4D;YAC5D,oBAAC,SAAS,OACJ,UAAU,EACd,GAAG,EAAE,IAAI,CAAC,aAAa,EACvB,IAAI,EAAE,IAAI,iBACE,gCAAgC,GAC5C,CACH,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,SAAS,GAAG,CACV,oBAAC,KAAK,OACA,UAAU,EACd,GAAG,EAAE,IAAI,CAAC,aAAa,iBACX,gCAAgC,EAC5C,IAAI,EAAC,OAAO,EACZ,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,QAAQ,CAAC,IAAI,GAC5C,CACH,CAAC;QACJ,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,0BAA2B,SAAQ,kBAAkB;IAChE,IAAW,SAAS;QAClB,OAAO,oBAAC,kBAAkB,OAAG,CAAC;IAChC,CAAC;IACD,IAAoB,sBAAsB;QACxC,OAAO,KAAK,CAAC;IACf,CAAC;CACF","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 \"./CustomNumberEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { Key } from \"ts-key-enum\";\nimport { Logger } from \"@itwin/core-bentley\";\nimport type {\n CustomFormattedNumberParams,\n IconEditorParams,\n InputEditorSizeParams,\n PrimitiveValue,\n PropertyEditorParams,\n PropertyRecord,\n PropertyValue,\n} from \"@itwin/appui-abstract\";\nimport {\n MessageSeverity,\n PropertyEditorParamTypes,\n PropertyValueFormat,\n UiAdmin,\n} from \"@itwin/appui-abstract\";\nimport { Icon, IconInput } from \"@itwin/core-react\";\nimport { Input } from \"@itwin/itwinui-react\";\n\ntype InputProps = React.ComponentPropsWithoutRef<typeof Input>;\n\nimport { UiComponents } from \"../UiComponents.js\";\nimport type { PropertyEditorProps, TypeEditor } from \"./EditorContainer.js\";\nimport { PropertyEditorBase } from \"./PropertyEditorManager.js\";\n\n/** @internal */\ninterface CustomNumberEditorState {\n inputValue: string;\n size?: number;\n maxLength?: number;\n iconSpec?: string;\n}\n\n/** CustomNumberEditor is a React component that is a property editor for numbers that specify custom formatting and parsing functions.\n * @alpha\n */\nexport class CustomNumberEditor\n extends React.PureComponent<PropertyEditorProps, CustomNumberEditorState>\n implements TypeEditor\n{\n private _isMounted = false;\n private _formatParams: CustomFormattedNumberParams | undefined;\n private _inputElement = React.createRef<HTMLInputElement>();\n private _lastValidValue: PropertyValue | undefined;\n\n public override readonly state: Readonly<CustomNumberEditorState> = {\n inputValue: \"\",\n };\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord as PropertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n if (record.isReadonly) {\n return {\n valueFormat: PropertyValueFormat.Primitive,\n value: (record.value as PrimitiveValue).value,\n displayValue: (record.value as PrimitiveValue).displayValue,\n };\n }\n\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n const parseResults = (\n this._formatParams as CustomFormattedNumberParams\n ).parseFunction(this.state.inputValue);\n if (!parseResults.parseError && undefined !== parseResults.value) {\n const newDisplayValue = (\n this._formatParams as CustomFormattedNumberParams\n ).formatFunction(parseResults.value as number);\n propertyValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: parseResults.value,\n displayValue: newDisplayValue,\n };\n this._lastValidValue = { ...propertyValue };\n // make sure the text in the input item matches the latest formatted text... this could get out if the input string say 1.5 === the display string of 1'-6\"\n if (newDisplayValue !== this.state.inputValue) {\n this.setState({ inputValue: newDisplayValue });\n }\n } else {\n if (this.htmlElement) {\n UiAdmin.messagePresenter.displayInputFieldMessage(\n this.htmlElement,\n MessageSeverity.Error,\n parseResults.parseError\n ? parseResults.parseError\n : UiComponents.translate(\"errors.unable-to-parse-quantity\")\n );\n this.htmlElement.focus();\n } else {\n UiAdmin.messagePresenter.displayMessage(\n MessageSeverity.Error,\n parseResults.parseError\n ? parseResults.parseError\n : UiComponents.translate(\"errors.unable-to-parse-quantity\")\n );\n }\n\n const displayValue =\n record.value.displayValue && record.value.displayValue.length > 0\n ? record.value.displayValue\n : (\n this._formatParams as CustomFormattedNumberParams\n ).formatFunction(record.value.value as number);\n propertyValue = this._lastValidValue\n ? { ...this._lastValidValue }\n : {\n valueFormat: PropertyValueFormat.Primitive,\n value: record.value.value,\n displayValue,\n };\n }\n }\n\n return propertyValue;\n }\n\n public get htmlElement(): HTMLElement | null {\n return this._inputElement.current;\n }\n\n public get hasFocus(): boolean {\n return document.activeElement === this._inputElement.current;\n }\n\n private shouldSetFocus(): boolean {\n if (!this.props.setFocus) return false;\n\n const record = this.props.propertyRecord as PropertyRecord;\n const disabled = record && !record.isDisabled ? false : true;\n const readonly = record && !record.isReadonly ? false : true;\n\n return !disabled && !readonly;\n }\n\n private _applyUpdatedValue(userInput: string) {\n const record = this.props.propertyRecord as PropertyRecord;\n const readonly = record && !record.isReadonly ? false : true;\n const disabled = record && !record.isDisabled ? false : true;\n\n if (readonly || disabled) return;\n\n if (this._isMounted)\n this.setState({\n inputValue: userInput,\n });\n }\n\n private _updateInputValue = (e: React.ChangeEvent<HTMLInputElement>) => {\n this._applyUpdatedValue(e.target.value);\n };\n\n public override componentDidMount() {\n this._isMounted = true;\n void this.setStateFromProps();\n }\n\n public override componentWillUnmount() {\n this._isMounted = false;\n }\n\n public override componentDidUpdate(prevProps: PropertyEditorProps) {\n if (this.props.propertyRecord !== prevProps.propertyRecord) {\n void this.setStateFromProps();\n }\n }\n\n private _getInitialDisplayValue(): string {\n const record = this.props.propertyRecord;\n let initialDisplayValue = \"\";\n let numberValue = 0;\n if (record) {\n if (record.value.valueFormat === PropertyValueFormat.Primitive) {\n const primitiveValue = record.value;\n numberValue =\n undefined !== primitiveValue.value\n ? (primitiveValue.value as number)\n : 0;\n if (primitiveValue.displayValue)\n initialDisplayValue = primitiveValue.displayValue;\n else\n initialDisplayValue = (\n this._formatParams as CustomFormattedNumberParams\n ).formatFunction(numberValue);\n }\n }\n\n return initialDisplayValue;\n }\n\n private async setStateFromProps() {\n const record = this.props.propertyRecord;\n if (!record || !record.property) {\n Logger.logError(\n UiComponents.loggerCategory(\"CustomNumberEditor\"),\n \"PropertyRecord must be defined to use CustomNumberPropertyEditor\"\n );\n return;\n }\n if (\n record.property &&\n record.property.editor &&\n record.property.editor.params\n ) {\n this._formatParams = record.property.editor.params.find(\n (param: PropertyEditorParams) =>\n param.type ===\n PropertyEditorParamTypes.CustomFormattedNumber.valueOf()\n ) as CustomFormattedNumberParams;\n }\n\n if (!this._formatParams) {\n Logger.logError(\n UiComponents.loggerCategory(\"CustomNumberEditor\"),\n `CustomFormattedNumberParams must be defined for property ${record.property.name}`\n );\n return;\n }\n\n const initialDisplayValue = this._getInitialDisplayValue();\n this._lastValidValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: (record.value as PrimitiveValue).value,\n displayValue: initialDisplayValue,\n };\n let size: number | undefined;\n let maxLength: number | undefined;\n let iconSpec: string | undefined;\n\n if (\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: initialDisplayValue,\n size,\n maxLength,\n iconSpec,\n });\n }\n\n private _resetToLastValidDisplayValue() {\n const initialDisplayValue =\n (this._lastValidValue &&\n (this._lastValidValue as PrimitiveValue).displayValue) ??\n this._getInitialDisplayValue();\n this.setState({ inputValue: initialDisplayValue });\n }\n\n private _onKeyPress = (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (e.key === Key.Escape.valueOf()) {\n const initialDisplayValue =\n (this._lastValidValue &&\n (this._lastValidValue as PrimitiveValue).displayValue) ??\n this._getInitialDisplayValue();\n if (initialDisplayValue !== this.state.inputValue) {\n e.preventDefault();\n e.stopPropagation();\n this._resetToLastValidDisplayValue();\n } else {\n if (this.props.onCancel) this.props.onCancel();\n }\n }\n\n if (e.key !== Key.Enter.valueOf()) {\n UiAdmin.messagePresenter.closeInputFieldMessage();\n }\n };\n\n private _onFocus = (e: React.FocusEvent<HTMLInputElement>) => {\n e.target.select();\n };\n\n public override render(): React.ReactNode {\n const minSize = this.state.size ? this.state.size : 8;\n const minWidthStyle: React.CSSProperties = {\n minWidth: `${minSize * 0.75}em`,\n };\n const record = this.props.propertyRecord as PropertyRecord;\n if (!record || !this._formatParams) return null;\n\n const readOnly = !record.isReadonly ? false : true;\n const disabled = !record.isDisabled ? false : true;\n\n const className = classnames(\n \"components-cell-editor\",\n \"components-customnumber-editor\",\n this.props.className\n );\n\n const inputProps: Omit<InputProps, \"size\"> = {\n className,\n style: this.props.style ? this.props.style : minWidthStyle,\n readOnly,\n disabled,\n maxLength: this.state.maxLength,\n value: this.state.inputValue,\n onChange: this._updateInputValue,\n onBlur: this.props.onBlur,\n onFocus: this._onFocus,\n autoFocus: this.shouldSetFocus(),\n onKeyDown: this._onKeyPress,\n };\n\n let reactNode: React.ReactNode;\n if (this.state.iconSpec) {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const icon = <Icon iconSpec={this.state.iconSpec} />;\n reactNode = (\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n <IconInput\n {...inputProps}\n ref={this._inputElement}\n icon={icon}\n data-testid=\"components-customnumber-editor\"\n />\n );\n } else {\n reactNode = (\n <Input\n {...inputProps}\n ref={this._inputElement}\n data-testid=\"components-customnumber-editor\"\n size=\"small\"\n id={this.props.propertyRecord?.property.name}\n />\n );\n }\n\n return reactNode;\n }\n}\n\n/** Custom Property Editor registered for the \"number\" type name and the \"number-custom\" editor name.\n * It uses the [[CustomNumberEditor]] React component.\n * @alpha\n */\nexport class CustomNumberPropertyEditor extends PropertyEditorBase {\n public get reactNode(): React.ReactNode {\n return <CustomNumberEditor />;\n }\n public override get containerHandlesEscape(): boolean {\n return false;\n }\n}\n"]}
1
+ {"version":3,"file":"CustomNumberEditor.js","sourceRoot":"","sources":["../../../src/components-react/editors/CustomNumberEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,2BAA2B,CAAC;AACnC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAU7C,OAAO,EACL,eAAe,EACf,wBAAwB,EACxB,mBAAmB,EACnB,OAAO,GACR,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAI7C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAWhE;;GAEG;AACH,MAAM,OAAO,kBACX,SAAQ,KAAK,CAAC,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AC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,0BAA2B,SAAQ,kBAAkB;IAChE,IAAW,SAAS;QAClB,OAAO,oBAAC,kBAAkB,OAAG,CAAC;IAChC,CAAC;IACD,IAAoB,sBAAsB;QACxC,OAAO,KAAK,CAAC;IACf,CAAC;CACF","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 \"./CustomNumberEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { Key } from \"ts-key-enum\";\nimport { Logger } from \"@itwin/core-bentley\";\nimport type {\n CustomFormattedNumberParams,\n IconEditorParams,\n InputEditorSizeParams,\n PrimitiveValue,\n PropertyEditorParams,\n PropertyRecord,\n PropertyValue,\n} from \"@itwin/appui-abstract\";\nimport {\n MessageSeverity,\n PropertyEditorParamTypes,\n PropertyValueFormat,\n UiAdmin,\n} from \"@itwin/appui-abstract\";\nimport { Icon, IconInput } from \"@itwin/core-react\";\nimport { Input } from \"@itwin/itwinui-react\";\n\ntype InputProps = React.ComponentPropsWithoutRef<typeof Input>;\n\nimport { UiComponents } from \"../UiComponents.js\";\nimport type { PropertyEditorProps, TypeEditor } from \"./EditorContainer.js\";\nimport { PropertyEditorBase } from \"./PropertyEditorManager.js\";\nimport type { IconNodeEditorParams } from \"../../internal.js\";\n\n/** @internal */\ninterface CustomNumberEditorState {\n inputValue: string;\n size?: number;\n maxLength?: number;\n iconSpec?: React.ReactNode;\n}\n\n/** CustomNumberEditor is a React component that is a property editor for numbers that specify custom formatting and parsing functions.\n * @alpha\n */\nexport class CustomNumberEditor\n extends React.PureComponent<PropertyEditorProps, CustomNumberEditorState>\n implements TypeEditor\n{\n private _isMounted = false;\n private _formatParams: CustomFormattedNumberParams | undefined;\n private _inputElement = React.createRef<HTMLInputElement>();\n private _lastValidValue: PropertyValue | undefined;\n\n public override readonly state: Readonly<CustomNumberEditorState> = {\n inputValue: \"\",\n };\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord as PropertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n if (record.isReadonly) {\n return {\n valueFormat: PropertyValueFormat.Primitive,\n value: (record.value as PrimitiveValue).value,\n displayValue: (record.value as PrimitiveValue).displayValue,\n };\n }\n\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n const parseResults = (\n this._formatParams as CustomFormattedNumberParams\n ).parseFunction(this.state.inputValue);\n if (!parseResults.parseError && undefined !== parseResults.value) {\n const newDisplayValue = (\n this._formatParams as CustomFormattedNumberParams\n ).formatFunction(parseResults.value as number);\n propertyValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: parseResults.value,\n displayValue: newDisplayValue,\n };\n this._lastValidValue = { ...propertyValue };\n // make sure the text in the input item matches the latest formatted text... this could get out if the input string say 1.5 === the display string of 1'-6\"\n if (newDisplayValue !== this.state.inputValue) {\n this.setState({ inputValue: newDisplayValue });\n }\n } else {\n if (this.htmlElement) {\n UiAdmin.messagePresenter.displayInputFieldMessage(\n this.htmlElement,\n MessageSeverity.Error,\n parseResults.parseError\n ? parseResults.parseError\n : UiComponents.translate(\"errors.unable-to-parse-quantity\")\n );\n this.htmlElement.focus();\n } else {\n UiAdmin.messagePresenter.displayMessage(\n MessageSeverity.Error,\n parseResults.parseError\n ? parseResults.parseError\n : UiComponents.translate(\"errors.unable-to-parse-quantity\")\n );\n }\n\n const displayValue =\n record.value.displayValue && record.value.displayValue.length > 0\n ? record.value.displayValue\n : (\n this._formatParams as CustomFormattedNumberParams\n ).formatFunction(record.value.value as number);\n propertyValue = this._lastValidValue\n ? { ...this._lastValidValue }\n : {\n valueFormat: PropertyValueFormat.Primitive,\n value: record.value.value,\n displayValue,\n };\n }\n }\n\n return propertyValue;\n }\n\n public get htmlElement(): HTMLElement | null {\n return this._inputElement.current;\n }\n\n public get hasFocus(): boolean {\n return document.activeElement === this._inputElement.current;\n }\n\n private shouldSetFocus(): boolean {\n if (!this.props.setFocus) return false;\n\n const record = this.props.propertyRecord as PropertyRecord;\n const disabled = record && !record.isDisabled ? false : true;\n const readonly = record && !record.isReadonly ? false : true;\n\n return !disabled && !readonly;\n }\n\n private _applyUpdatedValue(userInput: string) {\n const record = this.props.propertyRecord as PropertyRecord;\n const readonly = record && !record.isReadonly ? false : true;\n const disabled = record && !record.isDisabled ? false : true;\n\n if (readonly || disabled) return;\n\n if (this._isMounted)\n this.setState({\n inputValue: userInput,\n });\n }\n\n private _updateInputValue = (e: React.ChangeEvent<HTMLInputElement>) => {\n this._applyUpdatedValue(e.target.value);\n };\n\n public override componentDidMount() {\n this._isMounted = true;\n void this.setStateFromProps();\n }\n\n public override componentWillUnmount() {\n this._isMounted = false;\n }\n\n public override componentDidUpdate(prevProps: PropertyEditorProps) {\n if (this.props.propertyRecord !== prevProps.propertyRecord) {\n void this.setStateFromProps();\n }\n }\n\n private _getInitialDisplayValue(): string {\n const record = this.props.propertyRecord;\n let initialDisplayValue = \"\";\n let numberValue = 0;\n if (record) {\n if (record.value.valueFormat === PropertyValueFormat.Primitive) {\n const primitiveValue = record.value;\n numberValue =\n undefined !== primitiveValue.value\n ? (primitiveValue.value as number)\n : 0;\n if (primitiveValue.displayValue)\n initialDisplayValue = primitiveValue.displayValue;\n else\n initialDisplayValue = (\n this._formatParams as CustomFormattedNumberParams\n ).formatFunction(numberValue);\n }\n }\n\n return initialDisplayValue;\n }\n\n private async setStateFromProps() {\n const record = this.props.propertyRecord;\n if (!record || !record.property) {\n Logger.logError(\n UiComponents.loggerCategory(\"CustomNumberEditor\"),\n \"PropertyRecord must be defined to use CustomNumberPropertyEditor\"\n );\n return;\n }\n if (\n record.property &&\n record.property.editor &&\n record.property.editor.params\n ) {\n this._formatParams = record.property.editor.params.find(\n (param: PropertyEditorParams) =>\n param.type ===\n PropertyEditorParamTypes.CustomFormattedNumber.valueOf()\n ) as CustomFormattedNumberParams;\n }\n\n if (!this._formatParams) {\n Logger.logError(\n UiComponents.loggerCategory(\"CustomNumberEditor\"),\n `CustomFormattedNumberParams must be defined for property ${record.property.name}`\n );\n return;\n }\n\n const initialDisplayValue = this._getInitialDisplayValue();\n this._lastValidValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: (record.value as PrimitiveValue).value,\n displayValue: initialDisplayValue,\n };\n let size: number | undefined;\n let maxLength: number | undefined;\n let iconSpec: React.ReactNode | undefined;\n\n if (\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 const iconNodeParam = record.property.editor.params.find(\n (param): param is IconNodeEditorParams =>\n param.type ===\n (\"appui-icon-node\" satisfies IconNodeEditorParams[\"type\"])\n );\n if (iconNodeParam) {\n iconSpec = iconNodeParam.icon;\n }\n }\n\n if (this._isMounted)\n this.setState({\n inputValue: initialDisplayValue,\n size,\n maxLength,\n iconSpec,\n });\n }\n\n private _resetToLastValidDisplayValue() {\n const initialDisplayValue =\n (this._lastValidValue &&\n (this._lastValidValue as PrimitiveValue).displayValue) ??\n this._getInitialDisplayValue();\n this.setState({ inputValue: initialDisplayValue });\n }\n\n private _onKeyPress = (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (e.key === Key.Escape.valueOf()) {\n const initialDisplayValue =\n (this._lastValidValue &&\n (this._lastValidValue as PrimitiveValue).displayValue) ??\n this._getInitialDisplayValue();\n if (initialDisplayValue !== this.state.inputValue) {\n e.preventDefault();\n e.stopPropagation();\n this._resetToLastValidDisplayValue();\n } else {\n if (this.props.onCancel) this.props.onCancel();\n }\n }\n\n if (e.key !== Key.Enter.valueOf()) {\n UiAdmin.messagePresenter.closeInputFieldMessage();\n }\n };\n\n private _onFocus = (e: React.FocusEvent<HTMLInputElement>) => {\n e.target.select();\n };\n\n public override render(): React.ReactNode {\n const minSize = this.state.size ? this.state.size : 8;\n const minWidthStyle: React.CSSProperties = {\n minWidth: `${minSize * 0.75}em`,\n };\n const record = this.props.propertyRecord as PropertyRecord;\n if (!record || !this._formatParams) return null;\n\n const readOnly = !record.isReadonly ? false : true;\n const disabled = !record.isDisabled ? false : true;\n\n const className = classnames(\n \"components-cell-editor\",\n \"components-customnumber-editor\",\n this.props.className\n );\n\n const inputProps: Omit<InputProps, \"size\"> = {\n className,\n style: this.props.style ? this.props.style : minWidthStyle,\n readOnly,\n disabled,\n maxLength: this.state.maxLength,\n value: this.state.inputValue,\n onChange: this._updateInputValue,\n onBlur: this.props.onBlur,\n onFocus: this._onFocus,\n autoFocus: this.shouldSetFocus(),\n onKeyDown: this._onKeyPress,\n };\n\n let reactNode: React.ReactNode;\n if (this.state.iconSpec) {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const icon = <Icon iconSpec={this.state.iconSpec} />;\n reactNode = (\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n <IconInput\n {...inputProps}\n ref={this._inputElement}\n icon={icon}\n data-testid=\"components-customnumber-editor\"\n />\n );\n } else {\n reactNode = (\n <Input\n {...inputProps}\n ref={this._inputElement}\n data-testid=\"components-customnumber-editor\"\n size=\"small\"\n id={this.props.propertyRecord?.property.name}\n />\n );\n }\n\n return reactNode;\n }\n}\n\n/** Custom Property Editor registered for the \"number\" type name and the \"number-custom\" editor name.\n * It uses the [[CustomNumberEditor]] React component.\n * @alpha\n */\nexport class CustomNumberPropertyEditor extends PropertyEditorBase {\n public get reactNode(): React.ReactNode {\n return <CustomNumberEditor />;\n }\n public override get containerHandlesEscape(): boolean {\n return false;\n }\n}\n"]}
@@ -0,0 +1,11 @@
1
+ /** @packageDocumentation
2
+ * @module PropertyEditors
3
+ */
4
+ import * as React from "react";
5
+ import type { EditorProps } from "./Types.js";
6
+ /**
7
+ * Editor component that renders an editor based on the metadata and value.
8
+ * @beta
9
+ */
10
+ export declare function EditorRenderer(props: EditorProps): React.JSX.Element | null;
11
+ //# sourceMappingURL=EditorRenderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EditorRenderer.d.ts","sourceRoot":"","sources":["../../../src/components-react/new-editors/EditorRenderer.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAG9C;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,WAAW,4BAShD"}
@@ -0,0 +1,22 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ /** @packageDocumentation
6
+ * @module PropertyEditors
7
+ */
8
+ import * as React from "react";
9
+ import { useEditor } from "./editors-registry/UseEditor.js";
10
+ /**
11
+ * Editor component that renders an editor based on the metadata and value.
12
+ * @beta
13
+ */
14
+ export function EditorRenderer(props) {
15
+ const { metadata, value } = props;
16
+ const TypeEditor = useEditor(metadata, value);
17
+ if (!TypeEditor) {
18
+ return null;
19
+ }
20
+ return React.createElement(TypeEditor, { ...props });
21
+ }
22
+ //# sourceMappingURL=EditorRenderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EditorRenderer.js","sourceRoot":"","sources":["../../../src/components-react/new-editors/EditorRenderer.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAE5D;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,KAAkB;IAC/C,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC;IAClC,MAAM,UAAU,GAAG,SAAS,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAE9C,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,oBAAC,UAAU,OAAK,KAAK,GAAI,CAAC;AACnC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module PropertyEditors\n */\n\nimport * as React from \"react\";\nimport type { EditorProps } from \"./Types.js\";\nimport { useEditor } from \"./editors-registry/UseEditor.js\";\n\n/**\n * Editor component that renders an editor based on the metadata and value.\n * @beta\n */\nexport function EditorRenderer(props: EditorProps) {\n const { metadata, value } = props;\n const TypeEditor = useEditor(metadata, value);\n\n if (!TypeEditor) {\n return null;\n }\n\n return <TypeEditor {...props} />;\n}\n"]}
@@ -0,0 +1,46 @@
1
+ /** @packageDocumentation
2
+ * @module PropertyEditors
3
+ */
4
+ import type { ValueMetadata } from "./values/Metadata.js";
5
+ import type { Value } from "./values/Values.js";
6
+ /**
7
+ * An editor specification defining single editor with a predicate that determines if the editor can be used for a given value.
8
+ * @beta
9
+ */
10
+ export interface EditorSpec {
11
+ applies: (metaData: ValueMetadata, value: Value | undefined) => boolean;
12
+ Editor: React.ComponentType<EditorProps>;
13
+ }
14
+ /**
15
+ * Generic editor props that are supplied to the editor for rendering.
16
+ * @beta
17
+ */
18
+ export interface EditorProps<TMetadata = ValueMetadata, TValue = Value> {
19
+ metadata: TMetadata;
20
+ value?: TValue;
21
+ onChange: (value?: TValue) => void;
22
+ /**
23
+ * Callback that allows editor implementation to indicate that editing is finished. This is useful if editor
24
+ * is rendered inside a container that waits for committing/cancelling action (like `ENTER` or `ESC` key press) but editor implementation
25
+ * has additional actions that should cause commit (closing popup, commit button, etc.).
26
+ */
27
+ commit?: () => void;
28
+ /**
29
+ * Callback that allows editor implementation to indicate that editing is cancelled. This is useful if editor
30
+ * is rendered inside a container that waits for committing/cancelling action (like `ENTER` or `ESC` key press) but editor implementation
31
+ * has additional actions that should cause cancellation (cancel button, etc).
32
+ */
33
+ cancel?: () => void;
34
+ disabled?: boolean;
35
+ size?: "small" | "large";
36
+ }
37
+ /**
38
+ * Utility function to create an editor spec for editor with concrete metadata and value types.
39
+ * @beta
40
+ */
41
+ export declare function createEditorSpec<TMetadata extends ValueMetadata, TValue extends Value>({ Editor, isMetadataSupported, isValueSupported, }: {
42
+ isMetadataSupported: (metadata: ValueMetadata) => metadata is TMetadata;
43
+ isValueSupported: (value: Value) => value is TValue;
44
+ Editor: React.ComponentType<EditorProps<TMetadata, TValue>>;
45
+ }): EditorSpec;
46
+ //# sourceMappingURL=Types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Types.d.ts","sourceRoot":"","sources":["../../../src/components-react/new-editors/Types.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAEhD;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,CAAC,QAAQ,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,GAAG,SAAS,KAAK,OAAO,CAAC;IACxE,MAAM,EAAE,KAAK,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;CAC1C;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW,CAAC,SAAS,GAAG,aAAa,EAAE,MAAM,GAAG,KAAK;IACpE,QAAQ,EAAE,SAAS,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;CAC1B;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,SAAS,aAAa,EAC/B,MAAM,SAAS,KAAK,EACpB,EACA,MAAM,EACN,mBAAmB,EACnB,gBAAgB,GACjB,EAAE;IACD,mBAAmB,EAAE,CAAC,QAAQ,EAAE,aAAa,KAAK,QAAQ,IAAI,SAAS,CAAC;IACxE,gBAAgB,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,KAAK,IAAI,MAAM,CAAC;IACpD,MAAM,EAAE,KAAK,CAAC,aAAa,CAAC,WAAW,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC;CAC7D,GAAG,UAAU,CAQb"}
@@ -0,0 +1,20 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ /** @packageDocumentation
6
+ * @module PropertyEditors
7
+ */
8
+ /**
9
+ * Utility function to create an editor spec for editor with concrete metadata and value types.
10
+ * @beta
11
+ */
12
+ export function createEditorSpec({ Editor, isMetadataSupported, isValueSupported, }) {
13
+ return {
14
+ applies: (metadata, value) => isMetadataSupported(metadata) &&
15
+ (value === undefined || isValueSupported(value)),
16
+ // typeguards in `applies` function will take care of casting
17
+ Editor: Editor,
18
+ };
19
+ }
20
+ //# sourceMappingURL=Types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Types.js","sourceRoot":"","sources":["../../../src/components-react/new-editors/Types.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAsCH;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAG9B,EACA,MAAM,EACN,mBAAmB,EACnB,gBAAgB,GAKjB;IACC,OAAO;QACL,OAAO,EAAE,CAAC,QAAuB,EAAE,KAAa,EAAE,EAAE,CAClD,mBAAmB,CAAC,QAAQ,CAAC;YAC7B,CAAC,KAAK,KAAK,SAAS,IAAI,gBAAgB,CAAC,KAAK,CAAC,CAAC;QAClD,6DAA6D;QAC7D,MAAM,EAAE,MAAqD;KAC9D,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module PropertyEditors\n */\n\nimport type { ValueMetadata } from \"./values/Metadata.js\";\nimport type { Value } from \"./values/Values.js\";\n\n/**\n * An editor specification defining single editor with a predicate that determines if the editor can be used for a given value.\n * @beta\n */\nexport interface EditorSpec {\n applies: (metaData: ValueMetadata, value: Value | undefined) => boolean;\n Editor: React.ComponentType<EditorProps>;\n}\n\n/**\n * Generic editor props that are supplied to the editor for rendering.\n * @beta\n */\nexport interface EditorProps<TMetadata = ValueMetadata, TValue = Value> {\n metadata: TMetadata;\n value?: TValue;\n onChange: (value?: TValue) => void;\n /**\n * Callback that allows editor implementation to indicate that editing is finished. This is useful if editor\n * is rendered inside a container that waits for committing/cancelling action (like `ENTER` or `ESC` key press) but editor implementation\n * has additional actions that should cause commit (closing popup, commit button, etc.).\n */\n commit?: () => void;\n /**\n * Callback that allows editor implementation to indicate that editing is cancelled. This is useful if editor\n * is rendered inside a container that waits for committing/cancelling action (like `ENTER` or `ESC` key press) but editor implementation\n * has additional actions that should cause cancellation (cancel button, etc).\n */\n cancel?: () => void;\n disabled?: boolean;\n size?: \"small\" | \"large\";\n}\n\n/**\n * Utility function to create an editor spec for editor with concrete metadata and value types.\n * @beta\n */\nexport function createEditorSpec<\n TMetadata extends ValueMetadata,\n TValue extends Value\n>({\n Editor,\n isMetadataSupported,\n isValueSupported,\n}: {\n isMetadataSupported: (metadata: ValueMetadata) => metadata is TMetadata;\n isValueSupported: (value: Value) => value is TValue;\n Editor: React.ComponentType<EditorProps<TMetadata, TValue>>;\n}): EditorSpec {\n return {\n applies: (metadata: ValueMetadata, value?: Value) =>\n isMetadataSupported(metadata) &&\n (value === undefined || isValueSupported(value)),\n // typeguards in `applies` function will take care of casting\n Editor: Editor as unknown as React.ComponentType<EditorProps>,\n };\n}\n"]}
@@ -0,0 +1,51 @@
1
+ /** @packageDocumentation
2
+ * @module PropertyEditors
3
+ */
4
+ import * as React from "react";
5
+ import type { Value } from "./values/Values.js";
6
+ interface UseCommittableValueProps {
7
+ initialValue?: Value;
8
+ onCommit: (value?: Value) => void;
9
+ onCancel?: () => void;
10
+ }
11
+ /**
12
+ * Custom React hook that provides to commit or cancel value changes by editor using
13
+ * `Enter` or `Escape` keys.
14
+ *
15
+ * Example usage:
16
+ *
17
+ * ```tsx
18
+ * function MyValueEditor({ initialValue, ...editorProps }: Props) {
19
+ * const { value, onChange, onKeyDown, commit, cancel } = useCommittableValue({
20
+ * initialValue,
21
+ * onCommit: (newValue) => {
22
+ * // commit new value
23
+ * }
24
+ * onCancel: () => {
25
+ * // restore to initial value or close editor
26
+ * }
27
+ * })
28
+ *
29
+ * return <div onKeyDown={onKeydown}>
30
+ * <Editor
31
+ * {...editorProps}
32
+ * value={value}
33
+ * onChange={onChange}
34
+ * commit={commit}
35
+ * cancel={cancel}
36
+ * />
37
+ * </div>
38
+ * }
39
+ * ```
40
+ *
41
+ * @beta
42
+ */
43
+ export declare function useCommittableValue({ initialValue, onCancel, onCommit, }: UseCommittableValueProps): {
44
+ onChange: (newValue?: Value) => void;
45
+ onKeydown: (e: React.KeyboardEvent) => void;
46
+ commit: () => void;
47
+ cancel: () => void;
48
+ value: Value | undefined;
49
+ };
50
+ export {};
51
+ //# sourceMappingURL=UseCommittableValue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UseCommittableValue.d.ts","sourceRoot":"","sources":["../../../src/components-react/new-editors/UseCommittableValue.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAGhD,UAAU,wBAAwB;IAChC,YAAY,CAAC,EAAE,KAAK,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC;IAClC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,YAAY,EACZ,QAAQ,EACR,QAAQ,GACT,EAAE,wBAAwB;0BAaQ,KAAK;mBAwBZ,KAAK,CAAC,aAAa;;;;EAiB9C"}
@@ -0,0 +1,85 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ /** @packageDocumentation
6
+ * @module PropertyEditors
7
+ */
8
+ import * as React from "react";
9
+ import { areEqual } from "./values/ValueUtilities.js";
10
+ /**
11
+ * Custom React hook that provides to commit or cancel value changes by editor using
12
+ * `Enter` or `Escape` keys.
13
+ *
14
+ * Example usage:
15
+ *
16
+ * ```tsx
17
+ * function MyValueEditor({ initialValue, ...editorProps }: Props) {
18
+ * const { value, onChange, onKeyDown, commit, cancel } = useCommittableValue({
19
+ * initialValue,
20
+ * onCommit: (newValue) => {
21
+ * // commit new value
22
+ * }
23
+ * onCancel: () => {
24
+ * // restore to initial value or close editor
25
+ * }
26
+ * })
27
+ *
28
+ * return <div onKeyDown={onKeydown}>
29
+ * <Editor
30
+ * {...editorProps}
31
+ * value={value}
32
+ * onChange={onChange}
33
+ * commit={commit}
34
+ * cancel={cancel}
35
+ * />
36
+ * </div>
37
+ * }
38
+ * ```
39
+ *
40
+ * @beta
41
+ */
42
+ export function useCommittableValue({ initialValue, onCancel, onCommit, }) {
43
+ const initialValueRef = React.useRef(initialValue);
44
+ const [currentValue, setCurrentValue] = React.useState(initialValue);
45
+ const currentValueRef = React.useRef({
46
+ state: "initial",
47
+ value: initialValue,
48
+ });
49
+ const handleChange = (newValue) => {
50
+ currentValueRef.current = { state: "changed", value: newValue };
51
+ setCurrentValue(newValue);
52
+ };
53
+ const handleCommit = () => {
54
+ if (currentValueRef.current.state === "changed" &&
55
+ !areEqual(currentValueRef.current.value, initialValueRef.current)) {
56
+ onCommit(currentValueRef.current.value);
57
+ return;
58
+ }
59
+ if (currentValueRef.current.state === "cancelled") {
60
+ return;
61
+ }
62
+ onCancel?.();
63
+ };
64
+ const handleCancel = () => {
65
+ currentValueRef.current = { state: "cancelled" };
66
+ onCancel?.();
67
+ };
68
+ const handleKeyDown = (e) => {
69
+ e.stopPropagation();
70
+ if (e.key === "Enter" || e.key === "Tab") {
71
+ handleCommit();
72
+ }
73
+ else if (e.key === "Escape") {
74
+ handleCancel();
75
+ }
76
+ };
77
+ return {
78
+ onChange: handleChange,
79
+ onKeydown: handleKeyDown,
80
+ commit: handleCommit,
81
+ cancel: handleCancel,
82
+ value: currentValue,
83
+ };
84
+ }
85
+ //# sourceMappingURL=UseCommittableValue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UseCommittableValue.js","sourceRoot":"","sources":["../../../src/components-react/new-editors/UseCommittableValue.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAQtD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pB,IAAI,CAAC,CAAC,GAAG,KAAK,OAAO,IAAI,CAAC,CAAC,GAAG,KAAK,KAAK,EAAE,CAAC;YACzC,YAAY,EAAE,CAAC;QACjB,CAAC;aAAM,IAAI,CAAC,CAAC,GAAG,KAAK,QAAQ,EAAE,CAAC;YAC9B,YAAY,EAAE,CAAC;QACjB,CAAC;IACH,CAAC,CAAC;IAEF,OAAO;QACL,QAAQ,EAAE,YAAY;QACtB,SAAS,EAAE,aAAa;QACxB,MAAM,EAAE,YAAY;QACpB,MAAM,EAAE,YAAY;QACpB,KAAK,EAAE,YAAY;KACpB,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module PropertyEditors\n */\n\nimport * as React from \"react\";\nimport type { Value } from \"./values/Values.js\";\nimport { areEqual } from \"./values/ValueUtilities.js\";\n\ninterface UseCommittableValueProps {\n initialValue?: Value;\n onCommit: (value?: Value) => void;\n onCancel?: () => void;\n}\n\n/**\n * Custom React hook that provides to commit or cancel value changes by editor using\n * `Enter` or `Escape` keys.\n *\n * Example usage:\n *\n * ```tsx\n * function MyValueEditor({ initialValue, ...editorProps }: Props) {\n * const { value, onChange, onKeyDown, commit, cancel } = useCommittableValue({\n * initialValue,\n * onCommit: (newValue) => {\n * // commit new value\n * }\n * onCancel: () => {\n * // restore to initial value or close editor\n * }\n * })\n *\n * return <div onKeyDown={onKeydown}>\n * <Editor\n * {...editorProps}\n * value={value}\n * onChange={onChange}\n * commit={commit}\n * cancel={cancel}\n * />\n * </div>\n * }\n * ```\n *\n * @beta\n */\nexport function useCommittableValue({\n initialValue,\n onCancel,\n onCommit,\n}: UseCommittableValueProps) {\n const initialValueRef = React.useRef(initialValue);\n const [currentValue, setCurrentValue] = React.useState<Value | undefined>(\n initialValue\n );\n const currentValueRef = React.useRef<{\n state: \"changed\" | \"cancelled\" | \"initial\";\n value?: Value;\n }>({\n state: \"initial\",\n value: initialValue,\n });\n\n const handleChange = (newValue?: Value) => {\n currentValueRef.current = { state: \"changed\", value: newValue };\n setCurrentValue(newValue);\n };\n\n const handleCommit = () => {\n if (\n currentValueRef.current.state === \"changed\" &&\n !areEqual(currentValueRef.current.value, initialValueRef.current)\n ) {\n onCommit(currentValueRef.current.value);\n return;\n }\n if (currentValueRef.current.state === \"cancelled\") {\n return;\n }\n onCancel?.();\n };\n\n const handleCancel = () => {\n currentValueRef.current = { state: \"cancelled\" };\n onCancel?.();\n };\n\n const handleKeyDown = (e: React.KeyboardEvent) => {\n e.stopPropagation();\n\n if (e.key === \"Enter\" || e.key === \"Tab\") {\n handleCommit();\n } else if (e.key === \"Escape\") {\n handleCancel();\n }\n };\n\n return {\n onChange: handleChange,\n onKeydown: handleKeyDown,\n commit: handleCommit,\n cancel: handleCancel,\n value: currentValue,\n };\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import * as React from "react";
2
+ import type { EditorProps } from "../Types.js";
3
+ import type { ValueMetadata } from "../values/Metadata.js";
4
+ import type { BooleanValue } from "../values/Values.js";
5
+ /**
6
+ * Boolean value editor that renders `Checkbox` component for changing value.
7
+ * @internal
8
+ */
9
+ export declare function BooleanEditor({ value, onChange, commit, disabled, }: EditorProps<ValueMetadata, BooleanValue>): React.JSX.Element;
10
+ //# sourceMappingURL=BooleanEditor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BooleanEditor.d.ts","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors/BooleanEditor.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAIxD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EACL,QAAQ,EACR,MAAM,EACN,QAAQ,GACT,EAAE,WAAW,CAAC,aAAa,EAAE,YAAY,CAAC,qBAe1C"}
@@ -0,0 +1,22 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ import * as React from "react";
6
+ import { Checkbox } from "@itwin/itwinui-react";
7
+ /* v8 ignore start */
8
+ /**
9
+ * Boolean value editor that renders `Checkbox` component for changing value.
10
+ * @internal
11
+ */
12
+ export function BooleanEditor({ value, onChange, commit, disabled, }) {
13
+ const currentValue = value?.value ?? false;
14
+ const handleChange = (e) => {
15
+ const newValue = { value: e.target.checked };
16
+ onChange(newValue);
17
+ commit?.();
18
+ };
19
+ return (React.createElement(Checkbox, { checked: currentValue, onChange: handleChange, disabled: disabled }));
20
+ }
21
+ /* v8 ignore stop */
22
+ //# sourceMappingURL=BooleanEditor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BooleanEditor.js","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors/BooleanEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAKhD,qBAAqB;AAErB;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,EAC5B,KAAK,EACL,QAAQ,EACR,MAAM,EACN,QAAQ,GACiC;IACzC,MAAM,YAAY,GAAG,KAAK,EAAE,KAAK,IAAI,KAAK,CAAC;IAC3C,MAAM,YAAY,GAAG,CAAC,CAAsC,EAAE,EAAE;QAC9D,MAAM,QAAQ,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QAC7C,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACnB,MAAM,EAAE,EAAE,CAAC;IACb,CAAC,CAAC;IAEF,OAAO,CACL,oBAAC,QAAQ,IACP,OAAO,EAAE,YAAY,EACrB,QAAQ,EAAE,YAAY,EACtB,QAAQ,EAAE,QAAQ,GAClB,CACH,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 { Checkbox } from \"@itwin/itwinui-react\";\nimport type { EditorProps } from \"../Types.js\";\nimport type { ValueMetadata } from \"../values/Metadata.js\";\nimport type { BooleanValue } from \"../values/Values.js\";\n\n/* v8 ignore start */\n\n/**\n * Boolean value editor that renders `Checkbox` component for changing value.\n * @internal\n */\nexport function BooleanEditor({\n value,\n onChange,\n commit,\n disabled,\n}: EditorProps<ValueMetadata, BooleanValue>) {\n const currentValue = value?.value ?? false;\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const newValue = { value: e.target.checked };\n onChange(newValue);\n commit?.();\n };\n\n return (\n <Checkbox\n checked={currentValue}\n onChange={handleChange}\n disabled={disabled}\n />\n );\n}\n\n/* v8 ignore stop */\n"]}
@@ -0,0 +1,10 @@
1
+ import * as React from "react";
2
+ import type { EditorProps } from "../Types.js";
3
+ import type { ValueMetadata } from "../values/Metadata.js";
4
+ import type { DateValue } from "../values/Values.js";
5
+ /**
6
+ * Date value editor that render `DatePicker` component for changing value.
7
+ * @internal
8
+ */
9
+ export declare function DateEditor({ value, onChange, commit, size, disabled, }: EditorProps<ValueMetadata, DateValue>): React.JSX.Element;
10
+ //# sourceMappingURL=DateEditor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DateEditor.d.ts","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors/DateEditor.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAKrD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,QAAQ,GACT,EAAE,WAAW,CAAC,aAAa,EAAE,SAAS,CAAC,qBAYvC"}
@@ -0,0 +1,18 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ import * as React from "react";
6
+ import { DateInput } from "./DateInput.js";
7
+ /* v8 ignore start */
8
+ /**
9
+ * Date value editor that render `DatePicker` component for changing value.
10
+ * @internal
11
+ */
12
+ export function DateEditor({ value, onChange, commit, size, disabled, }) {
13
+ return (React.createElement(DateInput, { value: value?.value, onChange: (newValue) => {
14
+ onChange({ value: newValue });
15
+ }, onClose: commit, size: size, disabled: disabled }));
16
+ }
17
+ /* v8 ignore stop */
18
+ //# sourceMappingURL=DateEditor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DateEditor.js","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors/DateEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,qBAAqB;AAErB;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,EACzB,KAAK,EACL,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,QAAQ,GAC8B;IACtC,OAAO,CACL,oBAAC,SAAS,IACR,KAAK,EAAE,KAAK,EAAE,KAAK,EACnB,QAAQ,EAAE,CAAC,QAAQ,EAAE,EAAE;YACrB,QAAQ,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QAChC,CAAC,EACD,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,QAAQ,GAClB,CACH,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 type { EditorProps } from \"../Types.js\";\nimport type { ValueMetadata } from \"../values/Metadata.js\";\nimport type { DateValue } from \"../values/Values.js\";\nimport { DateInput } from \"./DateInput.js\";\n\n/* v8 ignore start */\n\n/**\n * Date value editor that render `DatePicker` component for changing value.\n * @internal\n */\nexport function DateEditor({\n value,\n onChange,\n commit,\n size,\n disabled,\n}: EditorProps<ValueMetadata, DateValue>) {\n return (\n <DateInput\n value={value?.value}\n onChange={(newValue) => {\n onChange({ value: newValue });\n }}\n onClose={commit}\n size={size}\n disabled={disabled}\n />\n );\n}\n\n/* v8 ignore stop */\n"]}
@@ -0,0 +1,15 @@
1
+ import * as React from "react";
2
+ interface DateInputProps {
3
+ value?: Date;
4
+ onChange: (value: Date) => void;
5
+ onClose?: () => void;
6
+ size?: "small" | "large";
7
+ disabled?: boolean;
8
+ showTimePicker?: boolean;
9
+ }
10
+ /**
11
+ * @internal
12
+ */
13
+ export declare function DateInput({ value, onChange, onClose, size, showTimePicker, disabled, }: DateInputProps): React.JSX.Element;
14
+ export {};
15
+ //# sourceMappingURL=DateInput.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DateInput.d.ts","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors/DateInput.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,UAAU,cAAc;IACtB,KAAK,CAAC,EAAE,IAAI,CAAC;IACb,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,KAAK,IAAI,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,QAAQ,EACR,OAAO,EACP,IAAI,EACJ,cAAc,EACd,QAAQ,GACT,EAAE,cAAc,qBA4BhB"}
@@ -0,0 +1,23 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ import * as React from "react";
6
+ import { Button, DatePicker, Popover } from "@itwin/itwinui-react";
7
+ /**
8
+ * @internal
9
+ */
10
+ export function DateInput({ value, onChange, onClose, size, showTimePicker, disabled, }) {
11
+ const currentValue = value ?? new Date();
12
+ const dateStr = showTimePicker
13
+ ? currentValue.toLocaleString()
14
+ : currentValue.toLocaleDateString();
15
+ return (React.createElement(Popover, { placement: "bottom", content: React.createElement(DatePicker, { date: currentValue, onChange: onChange, showDatesOutsideMonth: false, showTime: showTimePicker }), onVisibleChange: (visible) => {
16
+ if (!visible) {
17
+ onClose?.();
18
+ }
19
+ } },
20
+ React.createElement(Button, { style: { width: "100%" }, size: size, disabled: disabled }, dateStr)));
21
+ }
22
+ /* v8 ignore stop */
23
+ //# sourceMappingURL=DateInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DateInput.js","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors/DateInput.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAanE;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,EACxB,KAAK,EACL,QAAQ,EACR,OAAO,EACP,IAAI,EACJ,cAAc,EACd,QAAQ,GACO;IACf,MAAM,YAAY,GAAG,KAAK,IAAI,IAAI,IAAI,EAAE,CAAC;IACzC,MAAM,OAAO,GAAG,cAAc;QAC5B,CAAC,CAAC,YAAY,CAAC,cAAc,EAAE;QAC/B,CAAC,CAAC,YAAY,CAAC,kBAAkB,EAAE,CAAC;IAEtC,OAAO,CACL,oBAAC,OAAO,IACN,SAAS,EAAC,QAAQ,EAClB,OAAO,EACL,oBAAC,UAAU,IACT,IAAI,EAAE,YAAY,EAClB,QAAQ,EAAE,QAAQ,EAClB,qBAAqB,EAAE,KAAK,EAC5B,QAAQ,EAAE,cAAc,GACxB,EAEJ,eAAe,EAAE,CAAC,OAAO,EAAE,EAAE;YAC3B,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,OAAO,EAAE,EAAE,CAAC;YACd,CAAC;QACH,CAAC;QAED,oBAAC,MAAM,IAAC,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,IAC7D,OAAO,CACD,CACD,CACX,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 { Button, DatePicker, Popover } from \"@itwin/itwinui-react\";\n\n/* v8 ignore start */\n\ninterface DateInputProps {\n value?: Date;\n onChange: (value: Date) => void;\n onClose?: () => void;\n size?: \"small\" | \"large\";\n disabled?: boolean;\n showTimePicker?: boolean;\n}\n\n/**\n * @internal\n */\nexport function DateInput({\n value,\n onChange,\n onClose,\n size,\n showTimePicker,\n disabled,\n}: DateInputProps) {\n const currentValue = value ?? new Date();\n const dateStr = showTimePicker\n ? currentValue.toLocaleString()\n : currentValue.toLocaleDateString();\n\n return (\n <Popover\n placement=\"bottom\"\n content={\n <DatePicker\n date={currentValue}\n onChange={onChange}\n showDatesOutsideMonth={false}\n showTime={showTimePicker}\n />\n }\n onVisibleChange={(visible) => {\n if (!visible) {\n onClose?.();\n }\n }}\n >\n <Button style={{ width: \"100%\" }} size={size} disabled={disabled}>\n {dateStr}\n </Button>\n </Popover>\n );\n}\n\n/* v8 ignore stop */\n"]}
@@ -0,0 +1,10 @@
1
+ import * as React from "react";
2
+ import type { EditorProps } from "../Types.js";
3
+ import type { ValueMetadata } from "../values/Metadata.js";
4
+ import type { DateValue } from "../values/Values.js";
5
+ /**
6
+ * Date time value editor that render `DatePicker` component with time selector for changing value.
7
+ * @internal
8
+ */
9
+ export declare function DateTimeEditor({ value, onChange, commit, size, disabled, }: EditorProps<ValueMetadata, DateValue>): React.JSX.Element;
10
+ //# sourceMappingURL=DateTimeEditor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DateTimeEditor.d.ts","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors/DateTimeEditor.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAKrD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,EAC7B,KAAK,EACL,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,QAAQ,GACT,EAAE,WAAW,CAAC,aAAa,EAAE,SAAS,CAAC,qBAavC"}
@@ -0,0 +1,18 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ import * as React from "react";
6
+ import { DateInput } from "./DateInput.js";
7
+ /* v8 ignore start */
8
+ /**
9
+ * Date time value editor that render `DatePicker` component with time selector for changing value.
10
+ * @internal
11
+ */
12
+ export function DateTimeEditor({ value, onChange, commit, size, disabled, }) {
13
+ return (React.createElement(DateInput, { value: value?.value, onChange: (newValue) => {
14
+ onChange({ value: newValue });
15
+ }, onClose: commit, size: size, disabled: disabled, showTimePicker: true }));
16
+ }
17
+ /* v8 ignore stop */
18
+ //# sourceMappingURL=DateTimeEditor.js.map