@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,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,UAAU,mBAAmB,CAAC,EAClC,YAAY,EACZ,QAAQ,EACR,QAAQ,GACiB;IACzB,MAAM,eAAe,GAAG,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IACnD,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,KAAK,CAAC,QAAQ,CACpD,YAAY,CACb,CAAC;IACF,MAAM,eAAe,GAAG,KAAK,CAAC,MAAM,CAGjC;QACD,KAAK,EAAE,SAAS;QAChB,KAAK,EAAE,YAAY;KACpB,CAAC,CAAC;IAEH,MAAM,YAAY,GAAG,CAAC,QAAgB,EAAE,EAAE;QACxC,eAAe,CAAC,OAAO,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;QAChE,eAAe,CAAC,QAAQ,CAAC,CAAC;IAC5B,CAAC,CAAC;IAEF,MAAM,YAAY,GAAG,GAAG,EAAE;QACxB,IACE,eAAe,CAAC,OAAO,CAAC,KAAK,KAAK,SAAS;YAC3C,CAAC,QAAQ,CAAC,eAAe,CAAC,OAAO,CAAC,KAAK,EAAE,eAAe,CAAC,OAAO,CAAC,EACjE,CAAC;YACD,QAAQ,CAAC,eAAe,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YACxC,OAAO;QACT,CAAC;QACD,IAAI,eAAe,CAAC,OAAO,CAAC,KAAK,KAAK,WAAW,EAAE,CAAC;YAClD,OAAO;QACT,CAAC;QACD,QAAQ,EAAE,EAAE,CAAC;IACf,CAAC,CAAC;IAEF,MAAM,YAAY,GAAG,GAAG,EAAE;QACxB,eAAe,CAAC,OAAO,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC;QACjD,QAAQ,EAAE,EAAE,CAAC;IACf,CAAC,CAAC;IAEF,MAAM,aAAa,GAAG,CAAC,CAAsB,EAAE,EAAE;QAC/C,CAAC,CAAC,eAAe,EAAE,CAAC;QAEpB,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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DateTimeEditor.js","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors/DateTimeEditor.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,cAAc,CAAC,EAC7B,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,EAClB,cAAc,EAAE,IAAI,GACpB,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 time value editor that render `DatePicker` component with time selector for changing value.\n * @internal\n */\nexport function DateTimeEditor({\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 showTimePicker={true}\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 { EnumValueMetadata } from "../values/Metadata.js";
4
+ import type { EnumValue } from "../values/Values.js";
5
+ /**
6
+ * Enum value editor that renders `Select` component for changing value.
7
+ * @internal
8
+ */
9
+ export declare function EnumEditor({ metadata, value, onChange, commit, size, disabled, }: EditorProps<EnumValueMetadata, EnumValue>): React.JSX.Element;
10
+ //# sourceMappingURL=EnumEditor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EnumEditor.d.ts","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors/EnumEditor.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAc,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC3E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAIrD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,EACzB,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,QAAQ,GACT,EAAE,WAAW,CAAC,iBAAiB,EAAE,SAAS,CAAC,qBAoB3C"}
@@ -0,0 +1,30 @@
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 { Select } from "@itwin/itwinui-react";
7
+ /* v8 ignore start */
8
+ /**
9
+ * Enum value editor that renders `Select` component for changing value.
10
+ * @internal
11
+ */
12
+ export function EnumEditor({ metadata, value, onChange, commit, size, disabled, }) {
13
+ const choices = metadata.choices;
14
+ const currentValue = getEnumValue(value, choices);
15
+ const handleChange = (newChoice) => {
16
+ const choice = choices.find((c) => c.value === newChoice);
17
+ const newValue = { choice: newChoice, label: choice?.label ?? "" };
18
+ onChange(newValue);
19
+ commit?.();
20
+ };
21
+ return (React.createElement(Select, { size: size, value: currentValue.choice, onChange: handleChange, options: choices.map((c) => ({ value: c.value, label: c.label })), disabled: disabled }));
22
+ }
23
+ function getEnumValue(value, choices) {
24
+ const defaultValue = choices.length > 0
25
+ ? { choice: choices[0].value, label: choices[0].label }
26
+ : { choice: "", label: "" };
27
+ return value ? value : defaultValue;
28
+ }
29
+ /* v8 ignore stop */
30
+ //# sourceMappingURL=EnumEditor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EnumEditor.js","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors/EnumEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAK9C,qBAAqB;AAErB;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,EACzB,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,QAAQ,GACkC;IAC1C,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC;IACjC,MAAM,YAAY,GAAG,YAAY,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAElD,MAAM,YAAY,GAAG,CAAC,SAA0B,EAAE,EAAE;QAClD,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC;QAC1D,MAAM,QAAQ,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,EAAE,EAAE,CAAC;QACnE,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACnB,MAAM,EAAE,EAAE,CAAC;IACb,CAAC,CAAC;IAEF,OAAO,CACL,oBAAC,MAAM,IACL,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,YAAY,CAAC,MAAM,EAC1B,QAAQ,EAAE,YAAY,EACtB,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,EACjE,QAAQ,EAAE,QAAQ,GAClB,CACH,CAAC;AACJ,CAAC;AAED,SAAS,YAAY,CACnB,KAA4B,EAC5B,OAAqB;IAErB,MAAM,YAAY,GAChB,OAAO,CAAC,MAAM,GAAG,CAAC;QAChB,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE;QACvD,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IAChC,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC;AACtC,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 { Select } from \"@itwin/itwinui-react\";\nimport type { EditorProps } from \"../Types.js\";\nimport type { EnumChoice, EnumValueMetadata } from \"../values/Metadata.js\";\nimport type { EnumValue } from \"../values/Values.js\";\n\n/* v8 ignore start */\n\n/**\n * Enum value editor that renders `Select` component for changing value.\n * @internal\n */\nexport function EnumEditor({\n metadata,\n value,\n onChange,\n commit,\n size,\n disabled,\n}: EditorProps<EnumValueMetadata, EnumValue>) {\n const choices = metadata.choices;\n const currentValue = getEnumValue(value, choices);\n\n const handleChange = (newChoice: number | string) => {\n const choice = choices.find((c) => c.value === newChoice);\n const newValue = { choice: newChoice, label: choice?.label ?? \"\" };\n onChange(newValue);\n commit?.();\n };\n\n return (\n <Select\n size={size}\n value={currentValue.choice}\n onChange={handleChange}\n options={choices.map((c) => ({ value: c.value, label: c.label }))}\n disabled={disabled}\n />\n );\n}\n\nfunction getEnumValue(\n value: EnumValue | undefined,\n choices: EnumChoice[]\n): EnumValue {\n const defaultValue =\n choices.length > 0\n ? { choice: choices[0].value, label: choices[0].label }\n : { choice: \"\", label: \"\" };\n return value ? value : defaultValue;\n}\n\n/* v8 ignore stop */\n"]}
@@ -0,0 +1,8 @@
1
+ import * as React from "react";
2
+ import type { EditorProps } from "../Types.js";
3
+ /**
4
+ * Fallback editor that renders readonly value if no editor is found.
5
+ * @internal
6
+ */
7
+ export declare function FallbackEditor({ value, size }: EditorProps): React.JSX.Element;
8
+ //# sourceMappingURL=FallbackEditor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FallbackEditor.d.ts","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors/FallbackEditor.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAa/C;;;GAGG;AACH,wBAAgB,cAAc,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,WAAW,qBAE1D"}
@@ -0,0 +1,41 @@
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
+ import { isBoolean, isDate, isEnum, isInstanceKey, isNumeric, isText, } from "../values/ValueUtilities.js";
8
+ /* v8 ignore start */
9
+ /**
10
+ * Fallback editor that renders readonly value if no editor is found.
11
+ * @internal
12
+ */
13
+ export function FallbackEditor({ value, size }) {
14
+ return React.createElement(Input, { readOnly: true, value: getTextValue(value), size: size });
15
+ }
16
+ function getTextValue(value) {
17
+ if (value === undefined) {
18
+ return value;
19
+ }
20
+ if (isBoolean(value)) {
21
+ return value.value ? "true" : "false";
22
+ }
23
+ if (isDate(value)) {
24
+ return value.value.toDateString();
25
+ }
26
+ if (isEnum(value)) {
27
+ return value.choice;
28
+ }
29
+ if (isNumeric(value)) {
30
+ return value.displayValue;
31
+ }
32
+ if (isText(value)) {
33
+ return value.value;
34
+ }
35
+ if (isInstanceKey(value)) {
36
+ return value.label;
37
+ }
38
+ return "";
39
+ }
40
+ /* v8 ignore stop */
41
+ //# sourceMappingURL=FallbackEditor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FallbackEditor.js","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors/FallbackEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAG7C,OAAO,EACL,SAAS,EACT,MAAM,EACN,MAAM,EACN,aAAa,EACb,SAAS,EACT,MAAM,GACP,MAAM,6BAA6B,CAAC;AAErC,qBAAqB;AAErB;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,EAAE,KAAK,EAAE,IAAI,EAAe;IACzD,OAAO,oBAAC,KAAK,IAAC,QAAQ,QAAC,KAAK,EAAE,YAAY,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,IAAI,GAAI,CAAC;AACpE,CAAC;AAED,SAAS,YAAY,CAAC,KAAa;IACjC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;IACxC,CAAC;IACD,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QAClB,OAAO,KAAK,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC;IACpC,CAAC;IACD,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QAClB,OAAO,KAAK,CAAC,MAAM,CAAC;IACtB,CAAC;IACD,IAAI,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO,KAAK,CAAC,YAAY,CAAC;IAC5B,CAAC;IACD,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QAClB,OAAO,KAAK,CAAC,KAAK,CAAC;IACrB,CAAC;IACD,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC,KAAK,CAAC;IACrB,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,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 { Value } from \"../values/Values.js\";\nimport {\n isBoolean,\n isDate,\n isEnum,\n isInstanceKey,\n isNumeric,\n isText,\n} from \"../values/ValueUtilities.js\";\n\n/* v8 ignore start */\n\n/**\n * Fallback editor that renders readonly value if no editor is found.\n * @internal\n */\nexport function FallbackEditor({ value, size }: EditorProps) {\n return <Input readOnly value={getTextValue(value)} size={size} />;\n}\n\nfunction getTextValue(value?: Value) {\n if (value === undefined) {\n return value;\n }\n if (isBoolean(value)) {\n return value.value ? \"true\" : \"false\";\n }\n if (isDate(value)) {\n return value.value.toDateString();\n }\n if (isEnum(value)) {\n return value.choice;\n }\n if (isNumeric(value)) {\n return value.displayValue;\n }\n if (isText(value)) {\n return value.value;\n }\n if (isInstanceKey(value)) {\n return value.label;\n }\n return \"\";\n}\n\n/* v8 ignore stop */\n"]}
@@ -0,0 +1,24 @@
1
+ /** @packageDocumentation
2
+ * @module PropertyEditors
3
+ */
4
+ import * as React from "react";
5
+ import type { NumericValue } from "../values/Values.js";
6
+ /**
7
+ * Props for FormattedNumericInput component.
8
+ * @beta
9
+ */
10
+ interface FormattedNumericInputProps {
11
+ value: NumericValue;
12
+ onChange: (value: NumericValue) => void;
13
+ parseValue: (value: string) => number | undefined;
14
+ formatValue: (num: number) => string;
15
+ disabled?: boolean;
16
+ size?: "small" | "large";
17
+ }
18
+ /**
19
+ * A numeric input that allows to pass custom parsing/formatting logic to handle values with units etc.
20
+ * @beta
21
+ */
22
+ export declare function FormattedNumericInput({ onChange, value, parseValue, formatValue, disabled, size, }: FormattedNumericInputProps): React.JSX.Element;
23
+ export {};
24
+ //# sourceMappingURL=FormattedNumericInput.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormattedNumericInput.d.ts","sourceRoot":"","sources":["../../../../src/components-react/new-editors/editors/FormattedNumericInput.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAIxD;;;GAGG;AACH,UAAU,0BAA0B;IAClC,KAAK,EAAE,YAAY,CAAC;IACpB,QAAQ,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IACxC,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;IAClD,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;IACrC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;CAC1B;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,QAAQ,EACR,KAAK,EACL,UAAU,EACV,WAAW,EACX,QAAQ,EACR,IAAI,GACL,EAAE,0BAA0B,qBAgB5B"}