@itwin/components-react 5.3.1 → 5.5.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 (197) hide show
  1. package/CHANGELOG.md +356 -13
  2. package/lib/components-react/UiComponents.js +1 -1
  3. package/lib/components-react/UiComponents.js.map +1 -1
  4. package/lib/components-react/common/DisposePolyfill.d.ts +5 -0
  5. package/lib/components-react/common/DisposePolyfill.d.ts.map +1 -0
  6. package/lib/components-react/common/DisposePolyfill.js +14 -0
  7. package/lib/components-react/common/DisposePolyfill.js.map +1 -0
  8. package/lib/components-react/common/ImageRenderer.js +1 -1
  9. package/lib/components-react/common/ImageRenderer.js.map +1 -1
  10. package/lib/components-react/converters/PointTypeConverter.d.ts.map +1 -1
  11. package/lib/components-react/converters/PointTypeConverter.js +1 -0
  12. package/lib/components-react/converters/PointTypeConverter.js.map +1 -1
  13. package/lib/components-react/editors/CustomNumberEditor.d.ts +1 -1
  14. package/lib/components-react/editors/CustomNumberEditor.d.ts.map +1 -1
  15. package/lib/components-react/editors/CustomNumberEditor.js +5 -0
  16. package/lib/components-react/editors/CustomNumberEditor.js.map +1 -1
  17. package/lib/components-react/filter-builder/FilterBuilderRule.d.ts.map +1 -1
  18. package/lib/components-react/filter-builder/FilterBuilderRule.js +2 -5
  19. package/lib/components-react/filter-builder/FilterBuilderRule.js.map +1 -1
  20. package/lib/components-react/filter-builder/FilterBuilderRuleValue.d.ts +6 -0
  21. package/lib/components-react/filter-builder/FilterBuilderRuleValue.d.ts.map +1 -1
  22. package/lib/components-react/filter-builder/FilterBuilderRuleValue.js +3 -2
  23. package/lib/components-react/filter-builder/FilterBuilderRuleValue.js.map +1 -1
  24. package/lib/components-react/new-editors/EditorRenderer.d.ts +19 -0
  25. package/lib/components-react/new-editors/EditorRenderer.d.ts.map +1 -0
  26. package/lib/components-react/new-editors/EditorRenderer.js +25 -0
  27. package/lib/components-react/new-editors/EditorRenderer.js.map +1 -0
  28. package/lib/components-react/new-editors/Types.d.ts +46 -0
  29. package/lib/components-react/new-editors/Types.d.ts.map +1 -0
  30. package/lib/components-react/new-editors/Types.js +20 -0
  31. package/lib/components-react/new-editors/Types.js.map +1 -0
  32. package/lib/components-react/new-editors/UseCommittableValue.d.ts +51 -0
  33. package/lib/components-react/new-editors/UseCommittableValue.d.ts.map +1 -0
  34. package/lib/components-react/new-editors/UseCommittableValue.js +85 -0
  35. package/lib/components-react/new-editors/UseCommittableValue.js.map +1 -0
  36. package/lib/components-react/new-editors/editors/BooleanEditor.d.ts +10 -0
  37. package/lib/components-react/new-editors/editors/BooleanEditor.d.ts.map +1 -0
  38. package/lib/components-react/new-editors/editors/BooleanEditor.js +22 -0
  39. package/lib/components-react/new-editors/editors/BooleanEditor.js.map +1 -0
  40. package/lib/components-react/new-editors/editors/DateEditor.d.ts +10 -0
  41. package/lib/components-react/new-editors/editors/DateEditor.d.ts.map +1 -0
  42. package/lib/components-react/new-editors/editors/DateEditor.js +18 -0
  43. package/lib/components-react/new-editors/editors/DateEditor.js.map +1 -0
  44. package/lib/components-react/new-editors/editors/DateInput.d.ts +15 -0
  45. package/lib/components-react/new-editors/editors/DateInput.d.ts.map +1 -0
  46. package/lib/components-react/new-editors/editors/DateInput.js +23 -0
  47. package/lib/components-react/new-editors/editors/DateInput.js.map +1 -0
  48. package/lib/components-react/new-editors/editors/DateTimeEditor.d.ts +10 -0
  49. package/lib/components-react/new-editors/editors/DateTimeEditor.d.ts.map +1 -0
  50. package/lib/components-react/new-editors/editors/DateTimeEditor.js +18 -0
  51. package/lib/components-react/new-editors/editors/DateTimeEditor.js.map +1 -0
  52. package/lib/components-react/new-editors/editors/EnumEditor.d.ts +10 -0
  53. package/lib/components-react/new-editors/editors/EnumEditor.d.ts.map +1 -0
  54. package/lib/components-react/new-editors/editors/EnumEditor.js +30 -0
  55. package/lib/components-react/new-editors/editors/EnumEditor.js.map +1 -0
  56. package/lib/components-react/new-editors/editors/FallbackEditor.d.ts +8 -0
  57. package/lib/components-react/new-editors/editors/FallbackEditor.d.ts.map +1 -0
  58. package/lib/components-react/new-editors/editors/FallbackEditor.js +41 -0
  59. package/lib/components-react/new-editors/editors/FallbackEditor.js.map +1 -0
  60. package/lib/components-react/new-editors/editors/FormattedNumericInput.d.ts +24 -0
  61. package/lib/components-react/new-editors/editors/FormattedNumericInput.d.ts.map +1 -0
  62. package/lib/components-react/new-editors/editors/FormattedNumericInput.js +77 -0
  63. package/lib/components-react/new-editors/editors/FormattedNumericInput.js.map +1 -0
  64. package/lib/components-react/new-editors/editors/NumericEditor.d.ts +10 -0
  65. package/lib/components-react/new-editors/editors/NumericEditor.d.ts.map +1 -0
  66. package/lib/components-react/new-editors/editors/NumericEditor.js +28 -0
  67. package/lib/components-react/new-editors/editors/NumericEditor.js.map +1 -0
  68. package/lib/components-react/new-editors/editors/TextEditor.d.ts +10 -0
  69. package/lib/components-react/new-editors/editors/TextEditor.d.ts.map +1 -0
  70. package/lib/components-react/new-editors/editors/TextEditor.js +17 -0
  71. package/lib/components-react/new-editors/editors/TextEditor.js.map +1 -0
  72. package/lib/components-react/new-editors/editors/ToggleEditor.d.ts +10 -0
  73. package/lib/components-react/new-editors/editors/ToggleEditor.d.ts.map +1 -0
  74. package/lib/components-react/new-editors/editors/ToggleEditor.js +22 -0
  75. package/lib/components-react/new-editors/editors/ToggleEditor.js.map +1 -0
  76. package/lib/components-react/new-editors/editors-registry/DefaultEditors.d.ts +50 -0
  77. package/lib/components-react/new-editors/editors-registry/DefaultEditors.d.ts.map +1 -0
  78. package/lib/components-react/new-editors/editors-registry/DefaultEditors.js +117 -0
  79. package/lib/components-react/new-editors/editors-registry/DefaultEditors.js.map +1 -0
  80. package/lib/components-react/new-editors/editors-registry/EditorsRegistryContext.d.ts +12 -0
  81. package/lib/components-react/new-editors/editors-registry/EditorsRegistryContext.d.ts.map +1 -0
  82. package/lib/components-react/new-editors/editors-registry/EditorsRegistryContext.js +14 -0
  83. package/lib/components-react/new-editors/editors-registry/EditorsRegistryContext.js.map +1 -0
  84. package/lib/components-react/new-editors/editors-registry/EditorsRegistryProvider.d.ts +15 -0
  85. package/lib/components-react/new-editors/editors-registry/EditorsRegistryProvider.d.ts.map +1 -0
  86. package/lib/components-react/new-editors/editors-registry/EditorsRegistryProvider.js +25 -0
  87. package/lib/components-react/new-editors/editors-registry/EditorsRegistryProvider.js.map +1 -0
  88. package/lib/components-react/new-editors/editors-registry/UseEditor.d.ts +16 -0
  89. package/lib/components-react/new-editors/editors-registry/UseEditor.d.ts.map +1 -0
  90. package/lib/components-react/new-editors/editors-registry/UseEditor.js +36 -0
  91. package/lib/components-react/new-editors/editors-registry/UseEditor.js.map +1 -0
  92. package/lib/components-react/new-editors/interop/EditorInterop.d.ts +17 -0
  93. package/lib/components-react/new-editors/interop/EditorInterop.d.ts.map +1 -0
  94. package/lib/components-react/new-editors/interop/EditorInterop.js +146 -0
  95. package/lib/components-react/new-editors/interop/EditorInterop.js.map +1 -0
  96. package/lib/components-react/new-editors/interop/IconsRegistry.d.ts +6 -0
  97. package/lib/components-react/new-editors/interop/IconsRegistry.d.ts.map +1 -0
  98. package/lib/components-react/new-editors/interop/IconsRegistry.js +41 -0
  99. package/lib/components-react/new-editors/interop/IconsRegistry.js.map +1 -0
  100. package/lib/components-react/new-editors/interop/Metadata.d.ts +21 -0
  101. package/lib/components-react/new-editors/interop/Metadata.d.ts.map +1 -0
  102. package/lib/components-react/new-editors/interop/Metadata.js +13 -0
  103. package/lib/components-react/new-editors/interop/Metadata.js.map +1 -0
  104. package/lib/components-react/new-editors/interop/PropertyRecordEditor.d.ts +22 -0
  105. package/lib/components-react/new-editors/interop/PropertyRecordEditor.d.ts.map +1 -0
  106. package/lib/components-react/new-editors/interop/PropertyRecordEditor.js +41 -0
  107. package/lib/components-react/new-editors/interop/PropertyRecordEditor.js.map +1 -0
  108. package/lib/components-react/new-editors/interop/old-editors/Color.d.ts +7 -0
  109. package/lib/components-react/new-editors/interop/old-editors/Color.d.ts.map +1 -0
  110. package/lib/components-react/new-editors/interop/old-editors/Color.js +48 -0
  111. package/lib/components-react/new-editors/interop/old-editors/Color.js.map +1 -0
  112. package/lib/components-react/new-editors/interop/old-editors/CustomNumber.d.ts +3 -0
  113. package/lib/components-react/new-editors/interop/old-editors/CustomNumber.d.ts.map +1 -0
  114. package/lib/components-react/new-editors/interop/old-editors/CustomNumber.js +59 -0
  115. package/lib/components-react/new-editors/interop/old-editors/CustomNumber.js.map +1 -0
  116. package/lib/components-react/new-editors/interop/old-editors/Enum.d.ts +4 -0
  117. package/lib/components-react/new-editors/interop/old-editors/Enum.d.ts.map +1 -0
  118. package/lib/components-react/new-editors/interop/old-editors/Enum.js +23 -0
  119. package/lib/components-react/new-editors/interop/old-editors/Enum.js.map +1 -0
  120. package/lib/components-react/new-editors/interop/old-editors/EnumButtonGroup.d.ts +4 -0
  121. package/lib/components-react/new-editors/interop/old-editors/EnumButtonGroup.d.ts.map +1 -0
  122. package/lib/components-react/new-editors/interop/old-editors/EnumButtonGroup.js +50 -0
  123. package/lib/components-react/new-editors/interop/old-editors/EnumButtonGroup.js.map +1 -0
  124. package/lib/components-react/new-editors/interop/old-editors/NumericInput.d.ts +4 -0
  125. package/lib/components-react/new-editors/interop/old-editors/NumericInput.d.ts.map +1 -0
  126. package/lib/components-react/new-editors/interop/old-editors/NumericInput.js +86 -0
  127. package/lib/components-react/new-editors/interop/old-editors/NumericInput.js.map +1 -0
  128. package/lib/components-react/new-editors/interop/old-editors/Slider.d.ts +3 -0
  129. package/lib/components-react/new-editors/interop/old-editors/Slider.d.ts.map +1 -0
  130. package/lib/components-react/new-editors/interop/old-editors/Slider.js +66 -0
  131. package/lib/components-react/new-editors/interop/old-editors/Slider.js.map +1 -0
  132. package/lib/components-react/new-editors/interop/old-editors/TextArea.d.ts +3 -0
  133. package/lib/components-react/new-editors/interop/old-editors/TextArea.d.ts.map +1 -0
  134. package/lib/components-react/new-editors/interop/old-editors/TextArea.js +33 -0
  135. package/lib/components-react/new-editors/interop/old-editors/TextArea.js.map +1 -0
  136. package/lib/components-react/new-editors/interop/old-editors/UseEditorParams.d.ts +31 -0
  137. package/lib/components-react/new-editors/interop/old-editors/UseEditorParams.d.ts.map +1 -0
  138. package/lib/components-react/new-editors/interop/old-editors/UseEditorParams.js +52 -0
  139. package/lib/components-react/new-editors/interop/old-editors/UseEditorParams.js.map +1 -0
  140. package/lib/components-react/new-editors/interop/old-editors/UseEnumMetadata.d.ts +8 -0
  141. package/lib/components-react/new-editors/interop/old-editors/UseEnumMetadata.d.ts.map +1 -0
  142. package/lib/components-react/new-editors/interop/old-editors/UseEnumMetadata.js +41 -0
  143. package/lib/components-react/new-editors/interop/old-editors/UseEnumMetadata.js.map +1 -0
  144. package/lib/components-react/new-editors/values/Metadata.d.ts +35 -0
  145. package/lib/components-react/new-editors/values/Metadata.d.ts.map +1 -0
  146. package/lib/components-react/new-editors/values/Metadata.js +9 -0
  147. package/lib/components-react/new-editors/values/Metadata.js.map +1 -0
  148. package/lib/components-react/new-editors/values/ValueUtilities.d.ts +40 -0
  149. package/lib/components-react/new-editors/values/ValueUtilities.d.ts.map +1 -0
  150. package/lib/components-react/new-editors/values/ValueUtilities.js +84 -0
  151. package/lib/components-react/new-editors/values/ValueUtilities.js.map +1 -0
  152. package/lib/components-react/new-editors/values/Values.d.ts +58 -0
  153. package/lib/components-react/new-editors/values/Values.d.ts.map +1 -0
  154. package/lib/components-react/new-editors/values/Values.js +9 -0
  155. package/lib/components-react/new-editors/values/Values.js.map +1 -0
  156. package/lib/components-react/properties/IconNodeEditorParam.d.ts +16 -0
  157. package/lib/components-react/properties/IconNodeEditorParam.d.ts.map +1 -0
  158. package/lib/components-react/properties/IconNodeEditorParam.js +20 -0
  159. package/lib/components-react/properties/IconNodeEditorParam.js.map +1 -0
  160. package/lib/components-react/properties/renderers/PropertyGridColumns.d.ts.map +1 -1
  161. package/lib/components-react/properties/renderers/PropertyGridColumns.js +1 -1
  162. package/lib/components-react/properties/renderers/PropertyGridColumns.js.map +1 -1
  163. package/lib/components-react/propertygrid/component/VirtualizedPropertyGrid.d.ts +8 -1
  164. package/lib/components-react/propertygrid/component/VirtualizedPropertyGrid.d.ts.map +1 -1
  165. package/lib/components-react/propertygrid/component/VirtualizedPropertyGrid.js +2 -1
  166. package/lib/components-react/propertygrid/component/VirtualizedPropertyGrid.js.map +1 -1
  167. package/lib/components-react/propertygrid/component/VirtualizedPropertyGridWithDataProvider.d.ts +6 -0
  168. package/lib/components-react/propertygrid/component/VirtualizedPropertyGridWithDataProvider.d.ts.map +1 -1
  169. package/lib/components-react/propertygrid/component/VirtualizedPropertyGridWithDataProvider.js +1 -1
  170. package/lib/components-react/propertygrid/component/VirtualizedPropertyGridWithDataProvider.js.map +1 -1
  171. package/lib/components-react/propertygrid/dataproviders/FilteringDataProvider.d.ts +5 -2
  172. package/lib/components-react/propertygrid/dataproviders/FilteringDataProvider.d.ts.map +1 -1
  173. package/lib/components-react/propertygrid/dataproviders/FilteringDataProvider.js +7 -1
  174. package/lib/components-react/propertygrid/dataproviders/FilteringDataProvider.js.map +1 -1
  175. package/lib/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.d.ts.map +1 -1
  176. package/lib/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.js +1 -1
  177. package/lib/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.js.map +1 -1
  178. package/lib/components-react/propertygrid/internal/flat-items/MutableGridItemFactory.d.ts.map +1 -1
  179. package/lib/components-react/propertygrid/internal/flat-items/MutableGridItemFactory.js +1 -1
  180. package/lib/components-react/propertygrid/internal/flat-items/MutableGridItemFactory.js.map +1 -1
  181. package/lib/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.d.ts +2 -0
  182. package/lib/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.d.ts.map +1 -1
  183. package/lib/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.js +3 -3
  184. package/lib/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.js.map +1 -1
  185. package/lib/components-react/tree/controlled/TreeEventHandler.d.ts +7 -3
  186. package/lib/components-react/tree/controlled/TreeEventHandler.d.ts.map +1 -1
  187. package/lib/components-react/tree/controlled/TreeEventHandler.js +9 -2
  188. package/lib/components-react/tree/controlled/TreeEventHandler.js.map +1 -1
  189. package/lib/components-react.d.ts +9 -0
  190. package/lib/components-react.d.ts.map +1 -1
  191. package/lib/components-react.js +7 -0
  192. package/lib/components-react.js.map +1 -1
  193. package/lib/internal.d.ts +1 -0
  194. package/lib/internal.d.ts.map +1 -1
  195. package/lib/internal.js +1 -0
  196. package/lib/internal.js.map +1 -1
  197. package/package.json +16 -17
@@ -0,0 +1,77 @@
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 { Input } from "@itwin/itwinui-react";
10
+ /**
11
+ * A numeric input that allows to pass custom parsing/formatting logic to handle values with units etc.
12
+ * @beta
13
+ */
14
+ export function FormattedNumericInput({ onChange, value, parseValue, formatValue, disabled, size, }) {
15
+ const { currentValue, inputProps } = useParsedNumberInput({
16
+ initialValue: value.rawValue,
17
+ parseValue,
18
+ formatValue,
19
+ });
20
+ const onChangeRef = React.useRef(onChange);
21
+ React.useEffect(() => {
22
+ onChangeRef.current = onChange;
23
+ }, [onChange]);
24
+ React.useEffect(() => {
25
+ onChangeRef.current(currentValue);
26
+ }, [currentValue]);
27
+ return React.createElement(Input, { disabled: disabled, size: size, ...inputProps });
28
+ }
29
+ function useParsedNumberInput({ initialValue, formatValue, parseValue, }) {
30
+ const [state, setState] = React.useState(() => {
31
+ return {
32
+ value: {
33
+ rawValue: initialValue,
34
+ displayValue: initialValue !== undefined ? formatValue(initialValue) : "",
35
+ },
36
+ placeholder: formatValue(initialValue ?? 123.45),
37
+ };
38
+ });
39
+ React.useEffect(() => {
40
+ setState((prevState) => {
41
+ return {
42
+ ...prevState,
43
+ value: {
44
+ ...prevState.value,
45
+ displayValue: prevState.value.rawValue !== undefined
46
+ ? formatValue(prevState.value.rawValue)
47
+ : "",
48
+ },
49
+ placeholder: formatValue(123.45),
50
+ };
51
+ });
52
+ }, [formatValue]);
53
+ const handleChange = (e) => {
54
+ const newValue = e.target.value;
55
+ const rawValue = parseValue(newValue);
56
+ setState((prevState) => {
57
+ return {
58
+ ...prevState,
59
+ value: {
60
+ ...prevState.value,
61
+ rawValue,
62
+ displayValue: newValue,
63
+ },
64
+ };
65
+ });
66
+ };
67
+ return {
68
+ currentValue: state.value,
69
+ inputProps: {
70
+ value: state.value.displayValue,
71
+ placeholder: state.placeholder,
72
+ onChange: handleChange,
73
+ },
74
+ };
75
+ }
76
+ /* v8 ignore stop */
77
+ //# sourceMappingURL=FormattedNumericInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormattedNumericInput.js","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors/FormattedNumericInput.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAkB7C;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,EACpC,QAAQ,EACR,KAAK,EACL,UAAU,EACV,WAAW,EACX,QAAQ,EACR,IAAI,GACuB;IAC3B,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,GAAG,oBAAoB,CAAC;QACxD,YAAY,EAAE,KAAK,CAAC,QAAQ;QAC5B,UAAU;QACV,WAAW;KACZ,CAAC,CAAC;IACH,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC3C,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,WAAW,CAAC,OAAO,GAAG,QAAQ,CAAC;IACjC,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEf,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,WAAW,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IACpC,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;IAEnB,OAAO,oBAAC,KAAK,IAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,KAAM,UAAU,GAAI,CAAC;AACnE,CAAC;AAED,SAAS,oBAAoB,CAAC,EAC5B,YAAY,EACZ,WAAW,EACX,UAAU,GAKX;IAMC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAQ,GAAG,EAAE;QACnD,OAAO;YACL,KAAK,EAAE;gBACL,QAAQ,EAAE,YAAY;gBACtB,YAAY,EACV,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE;aAC9D;YACD,WAAW,EAAE,WAAW,CAAC,YAAY,IAAI,MAAM,CAAC;SACjD,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,QAAQ,CAAC,CAAC,SAAS,EAAE,EAAE;YACrB,OAAO;gBACL,GAAG,SAAS;gBACZ,KAAK,EAAE;oBACL,GAAG,SAAS,CAAC,KAAK;oBAClB,YAAY,EACV,SAAS,CAAC,KAAK,CAAC,QAAQ,KAAK,SAAS;wBACpC,CAAC,CAAC,WAAW,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC;wBACvC,CAAC,CAAC,EAAE;iBACT;gBACD,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC;aACjC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAElB,MAAM,YAAY,GAAG,CAAC,CAAsC,EAAE,EAAE;QAC9D,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;QAChC,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;QAEtC,QAAQ,CAAC,CAAC,SAAS,EAAE,EAAE;YACrB,OAAO;gBACL,GAAG,SAAS;gBACZ,KAAK,EAAE;oBACL,GAAG,SAAS,CAAC,KAAK;oBAClB,QAAQ;oBACR,YAAY,EAAE,QAAQ;iBACvB;aACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,OAAO;QACL,YAAY,EAAE,KAAK,CAAC,KAAK;QACzB,UAAU,EAAE;YACV,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,YAAY;YAC/B,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,QAAQ,EAAE,YAAY;SACvB;KACF,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/** @packageDocumentation\n * @module PropertyEditors\n */\n\nimport * as React from \"react\";\nimport { Input } from \"@itwin/itwinui-react\";\nimport type { NumericValue } from \"../values/Values.js\";\n\n/* v8 ignore start */\n\n/**\n * Props for FormattedNumericInput component.\n * @beta\n */\ninterface FormattedNumericInputProps {\n value: NumericValue;\n onChange: (value: NumericValue) => void;\n parseValue: (value: string) => number | undefined;\n formatValue: (num: number) => string;\n disabled?: boolean;\n size?: \"small\" | \"large\";\n}\n\n/**\n * A numeric input that allows to pass custom parsing/formatting logic to handle values with units etc.\n * @beta\n */\nexport function FormattedNumericInput({\n onChange,\n value,\n parseValue,\n formatValue,\n disabled,\n size,\n}: FormattedNumericInputProps) {\n const { currentValue, inputProps } = useParsedNumberInput({\n initialValue: value.rawValue,\n parseValue,\n formatValue,\n });\n const onChangeRef = React.useRef(onChange);\n React.useEffect(() => {\n onChangeRef.current = onChange;\n }, [onChange]);\n\n React.useEffect(() => {\n onChangeRef.current(currentValue);\n }, [currentValue]);\n\n return <Input disabled={disabled} size={size} {...inputProps} />;\n}\n\nfunction useParsedNumberInput({\n initialValue,\n formatValue,\n parseValue,\n}: {\n initialValue: number | undefined;\n parseValue: (value: string) => number | undefined;\n formatValue: (num: number) => string;\n}) {\n interface State {\n value: NumericValue;\n placeholder: string;\n }\n\n const [state, setState] = React.useState<State>(() => {\n return {\n value: {\n rawValue: initialValue,\n displayValue:\n initialValue !== undefined ? formatValue(initialValue) : \"\",\n },\n placeholder: formatValue(initialValue ?? 123.45),\n };\n });\n\n React.useEffect(() => {\n setState((prevState) => {\n return {\n ...prevState,\n value: {\n ...prevState.value,\n displayValue:\n prevState.value.rawValue !== undefined\n ? formatValue(prevState.value.rawValue)\n : \"\",\n },\n placeholder: formatValue(123.45),\n };\n });\n }, [formatValue]);\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const newValue = e.target.value;\n const rawValue = parseValue(newValue);\n\n setState((prevState) => {\n return {\n ...prevState,\n value: {\n ...prevState.value,\n rawValue,\n displayValue: newValue,\n },\n };\n });\n };\n\n return {\n currentValue: state.value,\n inputProps: {\n value: state.value.displayValue,\n placeholder: state.placeholder,\n onChange: handleChange,\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 { NumericValue } from "../values/Values.js";
5
+ /**
6
+ * Numeric value editor that renders `Input` components for changing value.
7
+ * @internal
8
+ */
9
+ export declare function NumericEditor({ value, onChange, size, disabled, }: EditorProps<ValueMetadata, NumericValue>): React.JSX.Element;
10
+ //# sourceMappingURL=NumericEditor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NumericEditor.d.ts","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors/NumericEditor.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,IAAI,EACJ,QAAQ,GACT,EAAE,WAAW,CAAC,aAAa,EAAE,YAAY,CAAC,qBAkB1C"}
@@ -0,0 +1,28 @@
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 { Input } from "@itwin/itwinui-react";
7
+ /* v8 ignore start */
8
+ /**
9
+ * Numeric value editor that renders `Input` components for changing value.
10
+ * @internal
11
+ */
12
+ export function NumericEditor({ value, onChange, size, disabled, }) {
13
+ const currentValue = getNumericValue(value);
14
+ return (React.createElement(Input, { value: currentValue.displayValue, onChange: (e) => {
15
+ const parsedValue = parseFloat(e.target.value);
16
+ onChange({
17
+ rawValue: Number.isNaN(parsedValue)
18
+ ? undefined
19
+ : parseFloat(e.target.value),
20
+ displayValue: e.target.value,
21
+ });
22
+ }, size: size, disabled: disabled }));
23
+ }
24
+ function getNumericValue(value) {
25
+ return value ? value : { rawValue: undefined, displayValue: "" };
26
+ }
27
+ /* v8 ignore stop */
28
+ //# sourceMappingURL=NumericEditor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NumericEditor.js","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors/NumericEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAK7C,qBAAqB;AAErB;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,EAC5B,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,QAAQ,GACiC;IACzC,MAAM,YAAY,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;IAC5C,OAAO,CACL,oBAAC,KAAK,IACJ,KAAK,EAAE,YAAY,CAAC,YAAY,EAChC,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE;YACd,MAAM,WAAW,GAAG,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC/C,QAAQ,CAAC;gBACP,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC;oBACjC,CAAC,CAAC,SAAS;oBACX,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;gBAC9B,YAAY,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK;aAC7B,CAAC,CAAC;QACL,CAAC,EACD,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,QAAQ,GAClB,CACH,CAAC;AACJ,CAAC;AAED,SAAS,eAAe,CAAC,KAA+B;IACtD,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC;AACnE,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 { Input } from \"@itwin/itwinui-react\";\nimport type { EditorProps } from \"../Types.js\";\nimport type { ValueMetadata } from \"../values/Metadata.js\";\nimport type { NumericValue } from \"../values/Values.js\";\n\n/* v8 ignore start */\n\n/**\n * Numeric value editor that renders `Input` components for changing value.\n * @internal\n */\nexport function NumericEditor({\n value,\n onChange,\n size,\n disabled,\n}: EditorProps<ValueMetadata, NumericValue>) {\n const currentValue = getNumericValue(value);\n return (\n <Input\n value={currentValue.displayValue}\n onChange={(e) => {\n const parsedValue = parseFloat(e.target.value);\n onChange({\n rawValue: Number.isNaN(parsedValue)\n ? undefined\n : parseFloat(e.target.value),\n displayValue: e.target.value,\n });\n }}\n size={size}\n disabled={disabled}\n />\n );\n}\n\nfunction getNumericValue(value: NumericValue | undefined): NumericValue {\n return value ? value : { rawValue: undefined, displayValue: \"\" };\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 { TextValue } from "../values/Values.js";
5
+ /**
6
+ * Text value editor that renders `Input` component for changing value.
7
+ * @internal
8
+ */
9
+ export declare function TextEditor({ value, onChange, size, disabled, }: EditorProps<ValueMetadata, TextValue>): React.JSX.Element;
10
+ //# sourceMappingURL=TextEditor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextEditor.d.ts","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors/TextEditor.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,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAIrD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,QAAQ,GACT,EAAE,WAAW,CAAC,aAAa,EAAE,SAAS,CAAC,qBAWvC"}
@@ -0,0 +1,17 @@
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 { Input } from "@itwin/itwinui-react";
7
+ /* v8 ignore start */
8
+ /**
9
+ * Text value editor that renders `Input` component for changing value.
10
+ * @internal
11
+ */
12
+ export function TextEditor({ value, onChange, size, disabled, }) {
13
+ const currentValue = value ? value : { value: "" };
14
+ return (React.createElement(Input, { value: currentValue.value, onChange: (e) => onChange({ value: e.target.value }), size: size, disabled: disabled }));
15
+ }
16
+ /* v8 ignore stop */
17
+ //# sourceMappingURL=TextEditor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextEditor.js","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors/TextEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAK7C,qBAAqB;AAErB;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,EACzB,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,QAAQ,GAC8B;IACtC,MAAM,YAAY,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IAEnD,OAAO,CACL,oBAAC,KAAK,IACJ,KAAK,EAAE,YAAY,CAAC,KAAK,EACzB,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,EACpD,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 { Input } from \"@itwin/itwinui-react\";\nimport type { EditorProps } from \"../Types.js\";\nimport type { ValueMetadata } from \"../values/Metadata.js\";\nimport type { TextValue } from \"../values/Values.js\";\n\n/* v8 ignore start */\n\n/**\n * Text value editor that renders `Input` component for changing value.\n * @internal\n */\nexport function TextEditor({\n value,\n onChange,\n size,\n disabled,\n}: EditorProps<ValueMetadata, TextValue>) {\n const currentValue = value ? value : { value: \"\" };\n\n return (\n <Input\n value={currentValue.value}\n onChange={(e) => onChange({ value: e.target.value })}\n size={size}\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 { ValueMetadata } from "../values/Metadata.js";
3
+ import type { BooleanValue } from "../values/Values.js";
4
+ import type { EditorProps } from "../Types.js";
5
+ /**
6
+ * Boolean value editor that renders `ToggleSwitch` component for changing value.
7
+ * @internal
8
+ */
9
+ export declare function ToggleEditor({ value, onChange, commit, disabled, size, }: EditorProps<ValueMetadata, BooleanValue>): React.JSX.Element;
10
+ //# sourceMappingURL=ToggleEditor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToggleEditor.d.ts","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors/ToggleEditor.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAK/C;;;GAGG;AACH,wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,IAAI,GACL,EAAE,WAAW,CAAC,aAAa,EAAE,YAAY,CAAC,qBAgB1C"}
@@ -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 { ToggleSwitch } from "@itwin/itwinui-react";
7
+ /* v8 ignore start */
8
+ /**
9
+ * Boolean value editor that renders `ToggleSwitch` component for changing value.
10
+ * @internal
11
+ */
12
+ export function ToggleEditor({ value, onChange, commit, disabled, size, }) {
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(ToggleSwitch, { checked: currentValue.value, onChange: handleChange, disabled: disabled, size: size === "small" ? "small" : undefined }));
20
+ }
21
+ /* v8 ignore stop */
22
+ //# sourceMappingURL=ToggleEditor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToggleEditor.js","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors/ToggleEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,qBAAqB;AAErB;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,EAC3B,KAAK,EACL,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,IAAI,GACqC;IACzC,MAAM,YAAY,GAAG,KAAK,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;IAC/C,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,YAAY,IACX,OAAO,EAAE,YAAY,CAAC,KAAK,EAC3B,QAAQ,EAAE,YAAY,EACtB,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,GAC5C,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 { ValueMetadata } from \"../values/Metadata.js\";\nimport type { BooleanValue } from \"../values/Values.js\";\nimport type { EditorProps } from \"../Types.js\";\nimport { ToggleSwitch } from \"@itwin/itwinui-react\";\n\n/* v8 ignore start */\n\n/**\n * Boolean value editor that renders `ToggleSwitch` component for changing value.\n * @internal\n */\nexport function ToggleEditor({\n value,\n onChange,\n commit,\n disabled,\n size,\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 <ToggleSwitch\n checked={currentValue.value}\n onChange={handleChange}\n disabled={disabled}\n size={size === \"small\" ? \"small\" : undefined}\n />\n );\n}\n\n/* v8 ignore stop */\n"]}
@@ -0,0 +1,50 @@
1
+ import { type EditorSpec } from "../Types.js";
2
+ /** v8 ignore start */
3
+ /**
4
+ * Specification for default text editor. It applies for values whose type is "string".
5
+ * @internal
6
+ */
7
+ export declare const TextEditorSpec: EditorSpec;
8
+ /**
9
+ * Specification for default date editor. It applies for values whose type is "date".
10
+ * @internal
11
+ */
12
+ export declare const DateEditorSpec: EditorSpec;
13
+ /**
14
+ * Specification for default date time editor. It applies for values whose type is "dateTime".
15
+ * @internal
16
+ */
17
+ export declare const DateTimeEditorSpec: EditorSpec;
18
+ /**
19
+ * Specification for default boolean editor. It applies for values whose type is "bool".
20
+ * @internal
21
+ */
22
+ export declare const BoolEditorSpec: EditorSpec;
23
+ /**
24
+ * Specification for default numeric editor. It applies for values whose type is "number".
25
+ * @internal
26
+ */
27
+ export declare const NumericEditorSpec: EditorSpec;
28
+ /**
29
+ * Specification for default toggle editor. It applies for values whose type is "bool" when preferred editor set to `toggle`.
30
+ * @internal
31
+ */
32
+ export declare const EnumEditorSpec: EditorSpec;
33
+ /**
34
+ * Specification for default enum editor. It applies for values whose type is "enum".
35
+ * @internal
36
+ */
37
+ export declare const ToggleEditorSpec: EditorSpec;
38
+ /**
39
+ * List of default editor specifications that are used as fallback if EditorRegistry does not provide a custom editor.
40
+ * @internal
41
+ */
42
+ export declare const defaultEditorSpecs: EditorSpec[];
43
+ /**
44
+ * List of editor specifications that are rewritten based on the old version that accepts editor params from `PropertyRecord`. Needed to support
45
+ * editing customizations used through `PropertyRecord`.
46
+ * @internal
47
+ */
48
+ export declare const interopEditorSpecs: EditorSpec[];
49
+ /** v8 ignore stop */
50
+ //# sourceMappingURL=DefaultEditors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DefaultEditors.d.ts","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors-registry/DefaultEditors.tsx"],"names":[],"mappings":"AAoBA,OAAO,EAAoB,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAYhE,sBAAsB;AAEtB;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,UAK3B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,UAK3B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,UAK/B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,UAK3B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,UAK9B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,UAK3B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,UAM7B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,UAAU,EAW1C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,EAAE,UAAU,EAS1C,CAAC;AAEF,qBAAqB"}
@@ -0,0 +1,117 @@
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 { StandardEditorNames } from "@itwin/appui-abstract";
6
+ import { BooleanEditor } from "../editors/BooleanEditor.js";
7
+ import { DateTimeEditor } from "../editors/DateTimeEditor.js";
8
+ import { EnumEditor } from "../editors/EnumEditor.js";
9
+ import { NumericEditor } from "../editors/NumericEditor.js";
10
+ import { TextEditor } from "../editors/TextEditor.js";
11
+ import { ColorEditorSpec as InteropColorEditorSpec } from "../interop/old-editors/Color.js";
12
+ import { CustomNumberEditorSpec as InteropCustomNumberEditorSpec } from "../interop/old-editors/CustomNumber.js";
13
+ import { EnumEditorSpec as InteropEnumEditorSpec } from "../interop/old-editors/Enum.js";
14
+ import { EnumButtonGroupEditorSpec as InteropEnumButtonGroupEditorSpec } from "../interop/old-editors/EnumButtonGroup.js";
15
+ import { MultilineEditorSpec as InteropMultilineEditorSpec } from "../interop/old-editors/TextArea.js";
16
+ import { SliderEditorSpec as InteropSliderEditorSpec } from "../interop/old-editors/Slider.js";
17
+ import { NumericInputEditorSpec as InteropNumericInputEditorSpec } from "../interop/old-editors/NumericInput.js";
18
+ import { createEditorSpec } from "../Types.js";
19
+ import { ToggleEditor } from "../editors/ToggleEditor.js";
20
+ import { DateEditor } from "../editors/DateEditor.js";
21
+ import { isBoolean, isDate, isEnum, isNumeric, isText, } from "../values/ValueUtilities.js";
22
+ /** v8 ignore start */
23
+ /**
24
+ * Specification for default text editor. It applies for values whose type is "string".
25
+ * @internal
26
+ */
27
+ export const TextEditorSpec = createEditorSpec({
28
+ isMetadataSupported: (metadata) => metadata.type === "string",
29
+ isValueSupported: isText,
30
+ Editor: TextEditor,
31
+ });
32
+ /**
33
+ * Specification for default date editor. It applies for values whose type is "date".
34
+ * @internal
35
+ */
36
+ export const DateEditorSpec = createEditorSpec({
37
+ isMetadataSupported: (metadata) => metadata.type === "date",
38
+ isValueSupported: isDate,
39
+ Editor: DateEditor,
40
+ });
41
+ /**
42
+ * Specification for default date time editor. It applies for values whose type is "dateTime".
43
+ * @internal
44
+ */
45
+ export const DateTimeEditorSpec = createEditorSpec({
46
+ isMetadataSupported: (metadata) => metadata.type === "dateTime",
47
+ isValueSupported: isDate,
48
+ Editor: DateTimeEditor,
49
+ });
50
+ /**
51
+ * Specification for default boolean editor. It applies for values whose type is "bool".
52
+ * @internal
53
+ */
54
+ export const BoolEditorSpec = createEditorSpec({
55
+ isMetadataSupported: (metadata) => metadata.type === "bool",
56
+ isValueSupported: isBoolean,
57
+ Editor: BooleanEditor,
58
+ });
59
+ /**
60
+ * Specification for default numeric editor. It applies for values whose type is "number".
61
+ * @internal
62
+ */
63
+ export const NumericEditorSpec = createEditorSpec({
64
+ isMetadataSupported: (metadata) => metadata.type === "number",
65
+ isValueSupported: isNumeric,
66
+ Editor: NumericEditor,
67
+ });
68
+ /**
69
+ * Specification for default toggle editor. It applies for values whose type is "bool" when preferred editor set to `toggle`.
70
+ * @internal
71
+ */
72
+ export const EnumEditorSpec = createEditorSpec({
73
+ isMetadataSupported: (metadata) => metadata.type === "enum",
74
+ isValueSupported: isEnum,
75
+ Editor: EnumEditor,
76
+ });
77
+ /**
78
+ * Specification for default enum editor. It applies for values whose type is "enum".
79
+ * @internal
80
+ */
81
+ export const ToggleEditorSpec = createEditorSpec({
82
+ isMetadataSupported: (metadata) => metadata.type === "bool" &&
83
+ metadata.preferredEditor === StandardEditorNames.Toggle,
84
+ isValueSupported: isBoolean,
85
+ Editor: ToggleEditor,
86
+ });
87
+ /**
88
+ * List of default editor specifications that are used as fallback if EditorRegistry does not provide a custom editor.
89
+ * @internal
90
+ */
91
+ export const defaultEditorSpecs = [
92
+ // list editors with preferred editor check first
93
+ ToggleEditorSpec,
94
+ // list editors that checks only value type
95
+ TextEditorSpec,
96
+ BoolEditorSpec,
97
+ NumericEditorSpec,
98
+ DateEditorSpec,
99
+ DateTimeEditorSpec,
100
+ EnumEditorSpec,
101
+ ];
102
+ /**
103
+ * List of editor specifications that are rewritten based on the old version that accepts editor params from `PropertyRecord`. Needed to support
104
+ * editing customizations used through `PropertyRecord`.
105
+ * @internal
106
+ */
107
+ export const interopEditorSpecs = [
108
+ InteropSliderEditorSpec,
109
+ InteropEnumButtonGroupEditorSpec,
110
+ InteropNumericInputEditorSpec,
111
+ InteropCustomNumberEditorSpec,
112
+ InteropColorEditorSpec,
113
+ InteropMultilineEditorSpec,
114
+ InteropEnumEditorSpec,
115
+ ];
116
+ /** v8 ignore stop */
117
+ //# sourceMappingURL=DefaultEditors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DefaultEditors.js","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors-registry/DefaultEditors.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,OAAO,EAAE,eAAe,IAAI,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAC5F,OAAO,EAAE,sBAAsB,IAAI,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AACjH,OAAO,EAAE,cAAc,IAAI,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACzF,OAAO,EAAE,yBAAyB,IAAI,gCAAgC,EAAE,MAAM,2CAA2C,CAAC;AAC1H,OAAO,EAAE,mBAAmB,IAAI,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AACvG,OAAO,EAAE,gBAAgB,IAAI,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC/F,OAAO,EAAE,sBAAsB,IAAI,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AAEjH,OAAO,EAAE,gBAAgB,EAAmB,MAAM,aAAa,CAAC;AAEhE,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EACL,SAAS,EACT,MAAM,EACN,MAAM,EACN,SAAS,EACT,MAAM,GACP,MAAM,6BAA6B,CAAC;AAErC,sBAAsB;AAEtB;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAe,gBAAgB,CAAC;IACzD,mBAAmB,EAAE,CAAC,QAAQ,EAA6B,EAAE,CAC3D,QAAQ,CAAC,IAAI,KAAK,QAAQ;IAC5B,gBAAgB,EAAE,MAAM;IACxB,MAAM,EAAE,UAAU;CACnB,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAe,gBAAgB,CAAC;IACzD,mBAAmB,EAAE,CAAC,QAAQ,EAA6B,EAAE,CAC3D,QAAQ,CAAC,IAAI,KAAK,MAAM;IAC1B,gBAAgB,EAAE,MAAM;IACxB,MAAM,EAAE,UAAU;CACnB,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAe,gBAAgB,CAAC;IAC7D,mBAAmB,EAAE,CAAC,QAAQ,EAA6B,EAAE,CAC3D,QAAQ,CAAC,IAAI,KAAK,UAAU;IAC9B,gBAAgB,EAAE,MAAM;IACxB,MAAM,EAAE,cAAc;CACvB,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAe,gBAAgB,CAAC;IACzD,mBAAmB,EAAE,CAAC,QAAQ,EAA6B,EAAE,CAC3D,QAAQ,CAAC,IAAI,KAAK,MAAM;IAC1B,gBAAgB,EAAE,SAAS;IAC3B,MAAM,EAAE,aAAa;CACtB,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAe,gBAAgB,CAAC;IAC5D,mBAAmB,EAAE,CAAC,QAAQ,EAA6B,EAAE,CAC3D,QAAQ,CAAC,IAAI,KAAK,QAAQ;IAC5B,gBAAgB,EAAE,SAAS;IAC3B,MAAM,EAAE,aAAa;CACtB,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAe,gBAAgB,CAAC;IACzD,mBAAmB,EAAE,CAAC,QAAQ,EAAiC,EAAE,CAC/D,QAAQ,CAAC,IAAI,KAAK,MAAM;IAC1B,gBAAgB,EAAE,MAAM;IACxB,MAAM,EAAE,UAAU;CACnB,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAe,gBAAgB,CAAC;IAC3D,mBAAmB,EAAE,CAAC,QAAQ,EAA6B,EAAE,CAC3D,QAAQ,CAAC,IAAI,KAAK,MAAM;QACxB,QAAQ,CAAC,eAAe,KAAK,mBAAmB,CAAC,MAAM;IACzD,gBAAgB,EAAE,SAAS;IAC3B,MAAM,EAAE,YAAY;CACrB,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAiB;IAC9C,iDAAiD;IACjD,gBAAgB;IAEhB,2CAA2C;IAC3C,cAAc;IACd,cAAc;IACd,iBAAiB;IACjB,cAAc;IACd,kBAAkB;IAClB,cAAc;CACf,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAiB;IAC9C,uBAAuB;IACvB,gCAAgC;IAChC,6BAA6B;IAC7B,6BAA6B;IAC7B,sBAAsB;IACtB,0BAA0B;IAE1B,qBAAqB;CACtB,CAAC;AAEF,qBAAqB","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 { StandardEditorNames } from \"@itwin/appui-abstract\";\nimport { BooleanEditor } from \"../editors/BooleanEditor.js\";\nimport { DateTimeEditor } from \"../editors/DateTimeEditor.js\";\nimport { EnumEditor } from \"../editors/EnumEditor.js\";\nimport { NumericEditor } from \"../editors/NumericEditor.js\";\nimport { TextEditor } from \"../editors/TextEditor.js\";\n\nimport { ColorEditorSpec as InteropColorEditorSpec } from \"../interop/old-editors/Color.js\";\nimport { CustomNumberEditorSpec as InteropCustomNumberEditorSpec } from \"../interop/old-editors/CustomNumber.js\";\nimport { EnumEditorSpec as InteropEnumEditorSpec } from \"../interop/old-editors/Enum.js\";\nimport { EnumButtonGroupEditorSpec as InteropEnumButtonGroupEditorSpec } from \"../interop/old-editors/EnumButtonGroup.js\";\nimport { MultilineEditorSpec as InteropMultilineEditorSpec } from \"../interop/old-editors/TextArea.js\";\nimport { SliderEditorSpec as InteropSliderEditorSpec } from \"../interop/old-editors/Slider.js\";\nimport { NumericInputEditorSpec as InteropNumericInputEditorSpec } from \"../interop/old-editors/NumericInput.js\";\n\nimport { createEditorSpec, type EditorSpec } from \"../Types.js\";\nimport type { EnumValueMetadata, ValueMetadata } from \"../values/Metadata.js\";\nimport { ToggleEditor } from \"../editors/ToggleEditor.js\";\nimport { DateEditor } from \"../editors/DateEditor.js\";\nimport {\n isBoolean,\n isDate,\n isEnum,\n isNumeric,\n isText,\n} from \"../values/ValueUtilities.js\";\n\n/** v8 ignore start */\n\n/**\n * Specification for default text editor. It applies for values whose type is \"string\".\n * @internal\n */\nexport const TextEditorSpec: EditorSpec = createEditorSpec({\n isMetadataSupported: (metadata): metadata is ValueMetadata =>\n metadata.type === \"string\",\n isValueSupported: isText,\n Editor: TextEditor,\n});\n\n/**\n * Specification for default date editor. It applies for values whose type is \"date\".\n * @internal\n */\nexport const DateEditorSpec: EditorSpec = createEditorSpec({\n isMetadataSupported: (metadata): metadata is ValueMetadata =>\n metadata.type === \"date\",\n isValueSupported: isDate,\n Editor: DateEditor,\n});\n\n/**\n * Specification for default date time editor. It applies for values whose type is \"dateTime\".\n * @internal\n */\nexport const DateTimeEditorSpec: EditorSpec = createEditorSpec({\n isMetadataSupported: (metadata): metadata is ValueMetadata =>\n metadata.type === \"dateTime\",\n isValueSupported: isDate,\n Editor: DateTimeEditor,\n});\n\n/**\n * Specification for default boolean editor. It applies for values whose type is \"bool\".\n * @internal\n */\nexport const BoolEditorSpec: EditorSpec = createEditorSpec({\n isMetadataSupported: (metadata): metadata is ValueMetadata =>\n metadata.type === \"bool\",\n isValueSupported: isBoolean,\n Editor: BooleanEditor,\n});\n\n/**\n * Specification for default numeric editor. It applies for values whose type is \"number\".\n * @internal\n */\nexport const NumericEditorSpec: EditorSpec = createEditorSpec({\n isMetadataSupported: (metadata): metadata is ValueMetadata =>\n metadata.type === \"number\",\n isValueSupported: isNumeric,\n Editor: NumericEditor,\n});\n\n/**\n * Specification for default toggle editor. It applies for values whose type is \"bool\" when preferred editor set to `toggle`.\n * @internal\n */\nexport const EnumEditorSpec: EditorSpec = createEditorSpec({\n isMetadataSupported: (metadata): metadata is EnumValueMetadata =>\n metadata.type === \"enum\",\n isValueSupported: isEnum,\n Editor: EnumEditor,\n});\n\n/**\n * Specification for default enum editor. It applies for values whose type is \"enum\".\n * @internal\n */\nexport const ToggleEditorSpec: EditorSpec = createEditorSpec({\n isMetadataSupported: (metadata): metadata is ValueMetadata =>\n metadata.type === \"bool\" &&\n metadata.preferredEditor === StandardEditorNames.Toggle,\n isValueSupported: isBoolean,\n Editor: ToggleEditor,\n});\n\n/**\n * List of default editor specifications that are used as fallback if EditorRegistry does not provide a custom editor.\n * @internal\n */\nexport const defaultEditorSpecs: EditorSpec[] = [\n // list editors with preferred editor check first\n ToggleEditorSpec,\n\n // list editors that checks only value type\n TextEditorSpec,\n BoolEditorSpec,\n NumericEditorSpec,\n DateEditorSpec,\n DateTimeEditorSpec,\n EnumEditorSpec,\n];\n\n/**\n * List of editor specifications that are rewritten based on the old version that accepts editor params from `PropertyRecord`. Needed to support\n * editing customizations used through `PropertyRecord`.\n * @internal\n */\nexport const interopEditorSpecs: EditorSpec[] = [\n InteropSliderEditorSpec,\n InteropEnumButtonGroupEditorSpec,\n InteropNumericInputEditorSpec,\n InteropCustomNumberEditorSpec,\n InteropColorEditorSpec,\n InteropMultilineEditorSpec,\n\n InteropEnumEditorSpec,\n];\n\n/** v8 ignore stop */\n"]}
@@ -0,0 +1,12 @@
1
+ import * as React from "react";
2
+ import type { EditorSpec } from "../Types.js";
3
+ interface EditorsRegistry {
4
+ editors: EditorSpec[];
5
+ }
6
+ /**
7
+ * Context for storing registered editors.
8
+ * @internal
9
+ */
10
+ export declare const EditorsRegistryContext: React.Context<EditorsRegistry>;
11
+ export {};
12
+ //# sourceMappingURL=EditorsRegistryContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EditorsRegistryContext.d.ts","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors-registry/EditorsRegistryContext.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,UAAU,eAAe;IACvB,OAAO,EAAE,UAAU,EAAE,CAAC;CACvB;AAED;;;GAGG;AACH,eAAO,MAAM,sBAAsB,gCAEjC,CAAC"}
@@ -0,0 +1,14 @@
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
+ /**
7
+ * Context for storing registered editors.
8
+ * @internal
9
+ */
10
+ export const EditorsRegistryContext = React.createContext({
11
+ editors: [],
12
+ });
13
+ EditorsRegistryContext.displayName = "uifw:EditorsRegistryContext";
14
+ //# sourceMappingURL=EditorsRegistryContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EditorsRegistryContext.js","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors-registry/EditorsRegistryContext.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAO/B;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,CAAC,aAAa,CAAkB;IACzE,OAAO,EAAE,EAAE;CACZ,CAAC,CAAC;AACH,sBAAsB,CAAC,WAAW,GAAG,6BAA6B,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\nimport * as React from \"react\";\nimport type { EditorSpec } from \"../Types.js\";\n\ninterface EditorsRegistry {\n editors: EditorSpec[];\n}\n\n/**\n * Context for storing registered editors.\n * @internal\n */\nexport const EditorsRegistryContext = React.createContext<EditorsRegistry>({\n editors: [],\n});\nEditorsRegistryContext.displayName = \"uifw:EditorsRegistryContext\";\n"]}
@@ -0,0 +1,15 @@
1
+ /** @packageDocumentation
2
+ * @module PropertyEditors
3
+ */
4
+ import * as React from "react";
5
+ import type { EditorSpec } from "../Types.js";
6
+ /**
7
+ * Provider that adds supplied editors into `EditorsRegistry`. Multiple providers can be nested together.
8
+ * Editors added through the lowest level provider will have the highest priority.
9
+ * @beta
10
+ */
11
+ export declare function EditorsRegistryProvider({ children, editors, }: {
12
+ children: React.ReactNode;
13
+ editors: EditorSpec[];
14
+ }): React.JSX.Element;
15
+ //# sourceMappingURL=EditorsRegistryProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EditorsRegistryProvider.d.ts","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors-registry/EditorsRegistryProvider.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG9C;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,EACtC,QAAQ,EACR,OAAO,GACR,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,OAAO,EAAE,UAAU,EAAE,CAAC;CACvB,qBAcA"}
@@ -0,0 +1,25 @@
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 { useContext, useMemo } from "react";
10
+ import { EditorsRegistryContext } from "./EditorsRegistryContext.js";
11
+ /**
12
+ * Provider that adds supplied editors into `EditorsRegistry`. Multiple providers can be nested together.
13
+ * Editors added through the lowest level provider will have the highest priority.
14
+ * @beta
15
+ */
16
+ export function EditorsRegistryProvider({ children, editors, }) {
17
+ const parentContext = useContext(EditorsRegistryContext);
18
+ const value = useMemo(() => {
19
+ return {
20
+ editors: [...editors, ...parentContext.editors],
21
+ };
22
+ }, [parentContext, editors]);
23
+ return (React.createElement(EditorsRegistryContext.Provider, { value: value }, children));
24
+ }
25
+ //# sourceMappingURL=EditorsRegistryProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EditorsRegistryProvider.js","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors-registry/EditorsRegistryProvider.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,EACtC,QAAQ,EACR,OAAO,GAIR;IACC,MAAM,aAAa,GAAG,UAAU,CAAC,sBAAsB,CAAC,CAAC;IAEzD,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,EAAE;QACzB,OAAO;YACL,OAAO,EAAE,CAAC,GAAG,OAAO,EAAE,GAAG,aAAa,CAAC,OAAO,CAAC;SAChD,CAAC;IACJ,CAAC,EAAE,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC,CAAC;IAE7B,OAAO,CACL,oBAAC,sBAAsB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,IAC1C,QAAQ,CACuB,CACnC,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 { useContext, useMemo } from \"react\";\nimport type { EditorSpec } from \"../Types.js\";\nimport { EditorsRegistryContext } from \"./EditorsRegistryContext.js\";\n\n/**\n * Provider that adds supplied editors into `EditorsRegistry`. Multiple providers can be nested together.\n * Editors added through the lowest level provider will have the highest priority.\n * @beta\n */\nexport function EditorsRegistryProvider({\n children,\n editors,\n}: {\n children: React.ReactNode;\n editors: EditorSpec[];\n}) {\n const parentContext = useContext(EditorsRegistryContext);\n\n const value = useMemo(() => {\n return {\n editors: [...editors, ...parentContext.editors],\n };\n }, [parentContext, editors]);\n\n return (\n <EditorsRegistryContext.Provider value={value}>\n {children}\n </EditorsRegistryContext.Provider>\n );\n}\n"]}
@@ -0,0 +1,16 @@
1
+ /** @packageDocumentation
2
+ * @module PropertyEditors
3
+ */
4
+ import type { EditorSpec } from "../Types.js";
5
+ import type { ValueMetadata } from "../values/Metadata.js";
6
+ import type { Value } from "../values/Values.js";
7
+ /** v8 ignore start */
8
+ /**
9
+ * Custom React hook that returns editor for specified metadata and value. It uses `EditorsRegistry` context to find registered editors.
10
+ * If no registered editor is found, it will use applicable default editor.
11
+ *
12
+ * @beta
13
+ */
14
+ export declare function useEditor(metadata: ValueMetadata, value: Value | undefined): EditorSpec["Editor"] | undefined;
15
+ /** v8 ignore stop */
16
+ //# sourceMappingURL=UseEditor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UseEditor.d.ts","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors-registry/UseEditor.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAKjD,sBAAsB;AAEtB;;;;;GAKG;AACH,wBAAgB,SAAS,CACvB,QAAQ,EAAE,aAAa,EACvB,KAAK,EAAE,KAAK,GAAG,SAAS,GACvB,UAAU,CAAC,QAAQ,CAAC,GAAG,SAAS,CAyBlC;AAED,qBAAqB"}
@@ -0,0 +1,36 @@
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 { defaultEditorSpecs, interopEditorSpecs } from "./DefaultEditors.js";
10
+ import { EditorsRegistryContext } from "./EditorsRegistryContext.js";
11
+ import { FallbackEditor } from "../editors/FallbackEditor.js";
12
+ /** v8 ignore start */
13
+ /**
14
+ * Custom React hook that returns editor for specified metadata and value. It uses `EditorsRegistry` context to find registered editors.
15
+ * If no registered editor is found, it will use applicable default editor.
16
+ *
17
+ * @beta
18
+ */
19
+ export function useEditor(metadata, value) {
20
+ const { editors } = React.useContext(EditorsRegistryContext);
21
+ const registeredEditor = editors.find((editor) => editor.applies(metadata, value))?.Editor;
22
+ if (registeredEditor) {
23
+ return registeredEditor;
24
+ }
25
+ const oldEditor = interopEditorSpecs.find((editor) => editor.applies(metadata, value))?.Editor;
26
+ if (oldEditor) {
27
+ return oldEditor;
28
+ }
29
+ const defaultEditor = defaultEditorSpecs.find((editor) => editor.applies(metadata, value))?.Editor;
30
+ if (defaultEditor) {
31
+ return defaultEditor;
32
+ }
33
+ return FallbackEditor;
34
+ }
35
+ /** v8 ignore stop */
36
+ //# sourceMappingURL=UseEditor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UseEditor.js","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors-registry/UseEditor.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC7E,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,sBAAsB;AAEtB;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CACvB,QAAuB,EACvB,KAAwB;IAExB,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC,UAAU,CAAC,sBAAsB,CAAC,CAAC;IAE7D,MAAM,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAC/C,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,CAChC,EAAE,MAAM,CAAC;IACV,IAAI,gBAAgB,EAAE,CAAC;QACrB,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAED,MAAM,SAAS,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CACnD,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,CAChC,EAAE,MAAM,CAAC;IACV,IAAI,SAAS,EAAE,CAAC;QACd,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,aAAa,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CACvD,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,CAChC,EAAE,MAAM,CAAC;IACV,IAAI,aAAa,EAAE,CAAC;QAClB,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,OAAO,cAAc,CAAC;AACxB,CAAC;AAED,qBAAqB","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 { EditorSpec } from \"../Types.js\";\nimport type { ValueMetadata } from \"../values/Metadata.js\";\nimport type { Value } from \"../values/Values.js\";\nimport { defaultEditorSpecs, interopEditorSpecs } from \"./DefaultEditors.js\";\nimport { EditorsRegistryContext } from \"./EditorsRegistryContext.js\";\nimport { FallbackEditor } from \"../editors/FallbackEditor.js\";\n\n/** v8 ignore start */\n\n/**\n * Custom React hook that returns editor for specified metadata and value. It uses `EditorsRegistry` context to find registered editors.\n * If no registered editor is found, it will use applicable default editor.\n *\n * @beta\n */\nexport function useEditor(\n metadata: ValueMetadata,\n value: Value | undefined\n): EditorSpec[\"Editor\"] | undefined {\n const { editors } = React.useContext(EditorsRegistryContext);\n\n const registeredEditor = editors.find((editor) =>\n editor.applies(metadata, value)\n )?.Editor;\n if (registeredEditor) {\n return registeredEditor;\n }\n\n const oldEditor = interopEditorSpecs.find((editor) =>\n editor.applies(metadata, value)\n )?.Editor;\n if (oldEditor) {\n return oldEditor;\n }\n\n const defaultEditor = defaultEditorSpecs.find((editor) =>\n editor.applies(metadata, value)\n )?.Editor;\n if (defaultEditor) {\n return defaultEditor;\n }\n\n return FallbackEditor;\n}\n\n/** v8 ignore stop */\n"]}
@@ -0,0 +1,17 @@
1
+ import type { PrimitiveValue, PropertyRecord } from "@itwin/appui-abstract";
2
+ import type { Value as NewEditorValue } from "../values/Values.js";
3
+ import type { OldEditorMetadata } from "./Metadata.js";
4
+ /**
5
+ * Interop utilities for converting between old and new editor values.
6
+ * @internal
7
+ */
8
+ export declare namespace EditorInterop {
9
+ /** Attempts to convert `PropertyRecord` into `ValueMetadata` and `Value`. */
10
+ function getMetadataAndValue(propertyRecord: PropertyRecord): {
11
+ metadata: OldEditorMetadata | undefined;
12
+ value: NewEditorValue | undefined;
13
+ };
14
+ /** Converts new editors system `Value` into old `PrimitiveValue` */
15
+ function convertToPrimitiveValue(newValue: NewEditorValue): PrimitiveValue;
16
+ }
17
+ //# sourceMappingURL=EditorInterop.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EditorInterop.d.ts","sourceRoot":"","sources":["../../../../src/components-react/new-editors/interop/EditorInterop.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAEV,cAAc,EACd,cAAc,EACf,MAAM,uBAAuB,CAAC;AAU/B,OAAO,KAAK,EAAE,KAAK,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AASvD;;;GAGG;AACH,yBAAiB,aAAa,CAAC;IAC7B,6EAA6E;IAC7E,SAAgB,mBAAmB,CAAC,cAAc,EAAE,cAAc,GAAG;QACnE,QAAQ,EAAE,iBAAiB,GAAG,SAAS,CAAC;QACxC,KAAK,EAAE,cAAc,GAAG,SAAS,CAAC;KACnC,CA6FA;IAED,oEAAoE;IACpE,SAAgB,uBAAuB,CACrC,QAAQ,EAAE,cAAc,GACvB,cAAc,CAsChB;CACF"}