@itwin/components-react 5.28.1 → 5.30.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 +144 -0
  2. package/lib/components-react/editors/BooleanEditor.d.ts +2 -0
  3. package/lib/components-react/editors/BooleanEditor.d.ts.map +1 -1
  4. package/lib/components-react/editors/BooleanEditor.js +3 -1
  5. package/lib/components-react/editors/BooleanEditor.js.map +1 -1
  6. package/lib/components-react/editors/CustomNumberEditor.d.ts +2 -0
  7. package/lib/components-react/editors/CustomNumberEditor.d.ts.map +1 -1
  8. package/lib/components-react/editors/CustomNumberEditor.js +4 -6
  9. package/lib/components-react/editors/CustomNumberEditor.js.map +1 -1
  10. package/lib/components-react/editors/DateTimeEditor.d.ts.map +1 -1
  11. package/lib/components-react/editors/DateTimeEditor.js +2 -3
  12. package/lib/components-react/editors/DateTimeEditor.js.map +1 -1
  13. package/lib/components-react/editors/EditorContainer.d.ts +5 -1
  14. package/lib/components-react/editors/EditorContainer.d.ts.map +1 -1
  15. package/lib/components-react/editors/EditorContainer.js +1 -1
  16. package/lib/components-react/editors/EditorContainer.js.map +1 -1
  17. package/lib/components-react/editors/EnumButtonGroupEditor.d.ts +2 -0
  18. package/lib/components-react/editors/EnumButtonGroupEditor.d.ts.map +1 -1
  19. package/lib/components-react/editors/EnumButtonGroupEditor.js +3 -1
  20. package/lib/components-react/editors/EnumButtonGroupEditor.js.map +1 -1
  21. package/lib/components-react/editors/EnumEditor.d.ts +2 -0
  22. package/lib/components-react/editors/EnumEditor.d.ts.map +1 -1
  23. package/lib/components-react/editors/EnumEditor.js +3 -0
  24. package/lib/components-react/editors/EnumEditor.js.map +1 -1
  25. package/lib/components-react/editors/IconEditor.d.ts +2 -0
  26. package/lib/components-react/editors/IconEditor.d.ts.map +1 -1
  27. package/lib/components-react/editors/IconEditor.js +3 -1
  28. package/lib/components-react/editors/IconEditor.js.map +1 -1
  29. package/lib/components-react/editors/ImageCheckBoxEditor.d.ts +2 -0
  30. package/lib/components-react/editors/ImageCheckBoxEditor.d.ts.map +1 -1
  31. package/lib/components-react/editors/ImageCheckBoxEditor.js +3 -3
  32. package/lib/components-react/editors/ImageCheckBoxEditor.js.map +1 -1
  33. package/lib/components-react/editors/NumericInputEditor.d.ts +2 -0
  34. package/lib/components-react/editors/NumericInputEditor.d.ts.map +1 -1
  35. package/lib/components-react/editors/NumericInputEditor.js +4 -4
  36. package/lib/components-react/editors/NumericInputEditor.js.map +1 -1
  37. package/lib/components-react/editors/PopupButton.d.ts +2 -0
  38. package/lib/components-react/editors/PopupButton.d.ts.map +1 -1
  39. package/lib/components-react/editors/PopupButton.js +1 -1
  40. package/lib/components-react/editors/PopupButton.js.map +1 -1
  41. package/lib/components-react/editors/PropertyEditorManager.d.ts +11 -2
  42. package/lib/components-react/editors/PropertyEditorManager.d.ts.map +1 -1
  43. package/lib/components-react/editors/PropertyEditorManager.js +6 -1
  44. package/lib/components-react/editors/PropertyEditorManager.js.map +1 -1
  45. package/lib/components-react/editors/SliderEditor.d.ts +4 -1
  46. package/lib/components-react/editors/SliderEditor.d.ts.map +1 -1
  47. package/lib/components-react/editors/SliderEditor.js +7 -8
  48. package/lib/components-react/editors/SliderEditor.js.map +1 -1
  49. package/lib/components-react/editors/TextEditor.d.ts +1 -0
  50. package/lib/components-react/editors/TextEditor.d.ts.map +1 -1
  51. package/lib/components-react/editors/TextEditor.js +3 -6
  52. package/lib/components-react/editors/TextEditor.js.map +1 -1
  53. package/lib/components-react/editors/TextareaEditor.d.ts +2 -0
  54. package/lib/components-react/editors/TextareaEditor.d.ts.map +1 -1
  55. package/lib/components-react/editors/TextareaEditor.js +3 -1
  56. package/lib/components-react/editors/TextareaEditor.js.map +1 -1
  57. package/lib/components-react/editors/ToggleEditor.d.ts +2 -0
  58. package/lib/components-react/editors/ToggleEditor.d.ts.map +1 -1
  59. package/lib/components-react/editors/ToggleEditor.js +3 -1
  60. package/lib/components-react/editors/ToggleEditor.js.map +1 -1
  61. package/lib/components-react/editors/registerEditors.d.ts.map +1 -1
  62. package/lib/components-react/editors/registerEditors.js +1 -0
  63. package/lib/components-react/editors/registerEditors.js.map +1 -1
  64. package/lib/components-react/favorite/FavoritePropertyList.d.ts.map +1 -1
  65. package/lib/components-react/favorite/FavoritePropertyList.js +4 -1
  66. package/lib/components-react/favorite/FavoritePropertyList.js.map +1 -1
  67. package/lib/components-react/filter-builder/FilterBuilderRule.d.ts +1 -0
  68. package/lib/components-react/filter-builder/FilterBuilderRule.d.ts.map +1 -1
  69. package/lib/components-react/filter-builder/FilterBuilderRule.js +5 -3
  70. package/lib/components-react/filter-builder/FilterBuilderRule.js.map +1 -1
  71. package/lib/components-react/filter-builder/FilterBuilderRuleGroup.d.ts +1 -0
  72. package/lib/components-react/filter-builder/FilterBuilderRuleGroup.d.ts.map +1 -1
  73. package/lib/components-react/filter-builder/FilterBuilderRuleGroup.js +5 -5
  74. package/lib/components-react/filter-builder/FilterBuilderRuleGroup.js.map +1 -1
  75. package/lib/components-react/filter-builder/FilterBuilderRuleValue.d.ts +45 -8
  76. package/lib/components-react/filter-builder/FilterBuilderRuleValue.d.ts.map +1 -1
  77. package/lib/components-react/filter-builder/FilterBuilderRuleValue.js +17 -8
  78. package/lib/components-react/filter-builder/FilterBuilderRuleValue.js.map +1 -1
  79. package/lib/components-react/new-editors/ConstraintUtils.d.ts +62 -0
  80. package/lib/components-react/new-editors/ConstraintUtils.d.ts.map +1 -0
  81. package/lib/components-react/new-editors/ConstraintUtils.js +49 -0
  82. package/lib/components-react/new-editors/ConstraintUtils.js.map +1 -0
  83. package/lib/components-react/new-editors/Types.d.ts +6 -0
  84. package/lib/components-react/new-editors/Types.d.ts.map +1 -1
  85. package/lib/components-react/new-editors/Types.js.map +1 -1
  86. package/lib/components-react/new-editors/UseCommittableValue.d.ts +2 -5
  87. package/lib/components-react/new-editors/UseCommittableValue.d.ts.map +1 -1
  88. package/lib/components-react/new-editors/UseCommittableValue.js +4 -1
  89. package/lib/components-react/new-editors/UseCommittableValue.js.map +1 -1
  90. package/lib/components-react/new-editors/editors/BooleanEditor.d.ts +1 -1
  91. package/lib/components-react/new-editors/editors/BooleanEditor.d.ts.map +1 -1
  92. package/lib/components-react/new-editors/editors/BooleanEditor.js +2 -2
  93. package/lib/components-react/new-editors/editors/BooleanEditor.js.map +1 -1
  94. package/lib/components-react/new-editors/editors/DateEditor.d.ts +1 -1
  95. package/lib/components-react/new-editors/editors/DateEditor.d.ts.map +1 -1
  96. package/lib/components-react/new-editors/editors/DateEditor.js +2 -2
  97. package/lib/components-react/new-editors/editors/DateEditor.js.map +1 -1
  98. package/lib/components-react/new-editors/editors/DateInput.d.ts +2 -1
  99. package/lib/components-react/new-editors/editors/DateInput.d.ts.map +1 -1
  100. package/lib/components-react/new-editors/editors/DateInput.js +2 -2
  101. package/lib/components-react/new-editors/editors/DateInput.js.map +1 -1
  102. package/lib/components-react/new-editors/editors/DateTimeEditor.d.ts +1 -1
  103. package/lib/components-react/new-editors/editors/DateTimeEditor.d.ts.map +1 -1
  104. package/lib/components-react/new-editors/editors/DateTimeEditor.js +2 -2
  105. package/lib/components-react/new-editors/editors/DateTimeEditor.js.map +1 -1
  106. package/lib/components-react/new-editors/editors/EnumEditor.d.ts +1 -1
  107. package/lib/components-react/new-editors/editors/EnumEditor.d.ts.map +1 -1
  108. package/lib/components-react/new-editors/editors/EnumEditor.js +2 -2
  109. package/lib/components-react/new-editors/editors/EnumEditor.js.map +1 -1
  110. package/lib/components-react/new-editors/editors/FallbackEditor.d.ts +1 -1
  111. package/lib/components-react/new-editors/editors/FallbackEditor.d.ts.map +1 -1
  112. package/lib/components-react/new-editors/editors/FallbackEditor.js +2 -2
  113. package/lib/components-react/new-editors/editors/FallbackEditor.js.map +1 -1
  114. package/lib/components-react/new-editors/editors/NumericEditor.d.ts +2 -2
  115. package/lib/components-react/new-editors/editors/NumericEditor.d.ts.map +1 -1
  116. package/lib/components-react/new-editors/editors/NumericEditor.js +7 -3
  117. package/lib/components-react/new-editors/editors/NumericEditor.js.map +1 -1
  118. package/lib/components-react/new-editors/editors/TextEditor.d.ts +2 -2
  119. package/lib/components-react/new-editors/editors/TextEditor.d.ts.map +1 -1
  120. package/lib/components-react/new-editors/editors/TextEditor.js +4 -2
  121. package/lib/components-react/new-editors/editors/TextEditor.js.map +1 -1
  122. package/lib/components-react/new-editors/editors/ToggleEditor.d.ts +1 -1
  123. package/lib/components-react/new-editors/editors/ToggleEditor.d.ts.map +1 -1
  124. package/lib/components-react/new-editors/editors/ToggleEditor.js +2 -2
  125. package/lib/components-react/new-editors/editors/ToggleEditor.js.map +1 -1
  126. package/lib/components-react/new-editors/editors-registry/DefaultEditors.d.ts.map +1 -1
  127. package/lib/components-react/new-editors/editors-registry/DefaultEditors.js.map +1 -1
  128. package/lib/components-react/new-editors/interop/EditorInterop.d.ts +5 -4
  129. package/lib/components-react/new-editors/interop/EditorInterop.d.ts.map +1 -1
  130. package/lib/components-react/new-editors/interop/EditorInterop.js +1 -0
  131. package/lib/components-react/new-editors/interop/EditorInterop.js.map +1 -1
  132. package/lib/components-react/new-editors/interop/Metadata.d.ts +9 -6
  133. package/lib/components-react/new-editors/interop/Metadata.d.ts.map +1 -1
  134. package/lib/components-react/new-editors/interop/Metadata.js +6 -3
  135. package/lib/components-react/new-editors/interop/Metadata.js.map +1 -1
  136. package/lib/components-react/new-editors/interop/PropertyRecordEditor.d.ts +42 -3
  137. package/lib/components-react/new-editors/interop/PropertyRecordEditor.d.ts.map +1 -1
  138. package/lib/components-react/new-editors/interop/PropertyRecordEditor.js +11 -6
  139. package/lib/components-react/new-editors/interop/PropertyRecordEditor.js.map +1 -1
  140. package/lib/components-react/new-editors/interop/old-editors/Color.js +4 -4
  141. package/lib/components-react/new-editors/interop/old-editors/Color.js.map +1 -1
  142. package/lib/components-react/new-editors/interop/old-editors/CustomNumber.d.ts +4 -3
  143. package/lib/components-react/new-editors/interop/old-editors/CustomNumber.d.ts.map +1 -1
  144. package/lib/components-react/new-editors/interop/old-editors/CustomNumber.js +11 -5
  145. package/lib/components-react/new-editors/interop/old-editors/CustomNumber.js.map +1 -1
  146. package/lib/components-react/new-editors/interop/old-editors/Enum.js +2 -2
  147. package/lib/components-react/new-editors/interop/old-editors/Enum.js.map +1 -1
  148. package/lib/components-react/new-editors/interop/old-editors/EnumButtonGroup.js +4 -4
  149. package/lib/components-react/new-editors/interop/old-editors/EnumButtonGroup.js.map +1 -1
  150. package/lib/components-react/new-editors/interop/old-editors/NumericInput.d.ts +7 -1
  151. package/lib/components-react/new-editors/interop/old-editors/NumericInput.d.ts.map +1 -1
  152. package/lib/components-react/new-editors/interop/old-editors/NumericInput.js +21 -6
  153. package/lib/components-react/new-editors/interop/old-editors/NumericInput.js.map +1 -1
  154. package/lib/components-react/new-editors/interop/old-editors/Slider.js +4 -4
  155. package/lib/components-react/new-editors/interop/old-editors/Slider.js.map +1 -1
  156. package/lib/components-react/new-editors/interop/old-editors/TextArea.d.ts.map +1 -1
  157. package/lib/components-react/new-editors/interop/old-editors/TextArea.js +4 -4
  158. package/lib/components-react/new-editors/interop/old-editors/TextArea.js.map +1 -1
  159. package/lib/components-react/new-editors/interop/old-editors/UseEditorParams.d.ts +8 -8
  160. package/lib/components-react/new-editors/interop/old-editors/UseEditorParams.d.ts.map +1 -1
  161. package/lib/components-react/new-editors/interop/old-editors/UseEditorParams.js.map +1 -1
  162. package/lib/components-react/new-editors/interop/old-editors/UseEnumMetadata.d.ts +2 -2
  163. package/lib/components-react/new-editors/interop/old-editors/UseEnumMetadata.d.ts.map +1 -1
  164. package/lib/components-react/new-editors/interop/old-editors/UseEnumMetadata.js.map +1 -1
  165. package/lib/components-react/new-editors/values/Metadata.d.ts +22 -0
  166. package/lib/components-react/new-editors/values/Metadata.d.ts.map +1 -1
  167. package/lib/components-react/new-editors/values/Metadata.js.map +1 -1
  168. package/lib/components-react/properties/renderers/NonPrimitivePropertyRenderer.d.ts.map +1 -1
  169. package/lib/components-react/properties/renderers/NonPrimitivePropertyRenderer.js +4 -1
  170. package/lib/components-react/properties/renderers/NonPrimitivePropertyRenderer.js.map +1 -1
  171. package/lib/components-react/properties/renderers/PropertyRenderer.d.ts +45 -7
  172. package/lib/components-react/properties/renderers/PropertyRenderer.d.ts.map +1 -1
  173. package/lib/components-react/properties/renderers/PropertyRenderer.js +13 -5
  174. package/lib/components-react/properties/renderers/PropertyRenderer.js.map +1 -1
  175. package/lib/components-react/propertygrid/component/PropertyList.d.ts +40 -10
  176. package/lib/components-react/propertygrid/component/PropertyList.d.ts.map +1 -1
  177. package/lib/components-react/propertygrid/component/PropertyList.js +7 -2
  178. package/lib/components-react/propertygrid/component/PropertyList.js.map +1 -1
  179. package/lib/components-react/propertygrid/component/VirtualizedPropertyGrid.d.ts +37 -33
  180. package/lib/components-react/propertygrid/component/VirtualizedPropertyGrid.d.ts.map +1 -1
  181. package/lib/components-react/propertygrid/component/VirtualizedPropertyGrid.js +10 -4
  182. package/lib/components-react/propertygrid/component/VirtualizedPropertyGrid.js.map +1 -1
  183. package/lib/components-react/propertygrid/component/VirtualizedPropertyGridWithDataProvider.d.ts +41 -5
  184. package/lib/components-react/propertygrid/component/VirtualizedPropertyGridWithDataProvider.d.ts.map +1 -1
  185. package/lib/components-react/propertygrid/component/VirtualizedPropertyGridWithDataProvider.js +6 -4
  186. package/lib/components-react/propertygrid/component/VirtualizedPropertyGridWithDataProvider.js.map +1 -1
  187. package/lib/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.js +3 -1
  188. package/lib/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.js.map +1 -1
  189. package/lib/components-react.d.ts +2 -1
  190. package/lib/components-react.d.ts.map +1 -1
  191. package/lib/components-react.js +1 -0
  192. package/lib/components-react.js.map +1 -1
  193. package/lib/internal.d.ts +1 -1
  194. package/lib/internal.d.ts.map +1 -1
  195. package/lib/internal.js +1 -1
  196. package/lib/internal.js.map +1 -1
  197. package/package.json +3 -3
@@ -4,35 +4,72 @@
4
4
  import * as React from "react";
5
5
  import type { PropertyDescription, PropertyValue } from "@itwin/appui-abstract";
6
6
  import type { PropertyFilterBuilderRuleOperator } from "./Operators.js";
7
- /**
8
- * Props for [[PropertyFilterBuilderRuleValue]] component.
9
- * @beta
10
- */
11
- export interface PropertyFilterBuilderRuleValueProps {
7
+ /** @beta */
8
+ interface PropertyFilterBuilderRuleValueBaseProps {
12
9
  /** Currently entered value. */
13
10
  value?: PropertyValue;
14
11
  /** Property used in rule to which this value will be compared to. */
15
12
  property: PropertyDescription;
16
13
  /** Callback that is invoked when value changes. */
17
14
  onChange: (value: PropertyValue) => void;
15
+ }
16
+ /** @beta */
17
+ interface PropertyFilterBuilderRuleValueLegacyProps extends PropertyFilterBuilderRuleValueBaseProps {
18
+ /**
19
+ * Specifies which editors system should be used: legacy or the new one.
20
+ * @default "legacy"
21
+ * @beta
22
+ * @deprecated in 5.30. Legacy editors system is deprecated. Use `editorSystem: "new"`.
23
+ */
24
+ editorSystem?: "legacy";
25
+ }
26
+ /** @beta */
27
+ interface PropertyFilterBuilderRuleValueNewProps extends PropertyFilterBuilderRuleValueBaseProps {
18
28
  /**
19
29
  * Specifies which editors system should be used: legacy or the new one.
20
30
  * @default "legacy"
21
31
  * @beta
22
32
  */
23
- editorSystem?: "legacy" | "new";
33
+ editorSystem: "new";
24
34
  }
35
+ /**
36
+ * Props for [[PropertyFilterBuilderRuleValue]] component.
37
+ * @beta
38
+ * @deprecated in 5.30.0. Use `React.ComponentProps<typeof PropertyFilterBuilderRuleValue>` instead.
39
+ */
40
+ export type PropertyFilterBuilderRuleValueProps = PropertyFilterBuilderRuleValueLegacyProps | PropertyFilterBuilderRuleValueNewProps;
25
41
  /**
26
42
  * Props for custom [[PropertyFilterBuilderRuleValue]] renderer.
27
43
  * @beta
28
44
  */
29
- export interface PropertyFilterBuilderRuleValueRendererProps extends PropertyFilterBuilderRuleValueProps {
45
+ export type PropertyFilterBuilderRuleValueRendererProps = PropertyFilterBuilderRuleValueProps & {
30
46
  /** Current operator. */
31
47
  operator: PropertyFilterBuilderRuleOperator;
48
+ };
49
+ interface PropertyFilterBuilderRuleValueComponent {
50
+ /**
51
+ * Component that renders [[PropertyFilterBuilderRuleRenderer]] value input.
52
+ * @beta
53
+ */
54
+ (props: PropertyFilterBuilderRuleValueNewProps & {
55
+ /** Current operator. */
56
+ operator: PropertyFilterBuilderRuleOperator;
57
+ }): React.JSX.Element;
58
+ /**
59
+ * @deprecated in 5.30. Use `PropertyFilterBuilderRuleValue` with `editorSystem="new"` instead.
60
+ * @beta
61
+ */
62
+ (props: PropertyFilterBuilderRuleValueLegacyProps & {
63
+ /** Current operator. */
64
+ operator: PropertyFilterBuilderRuleOperator;
65
+ }): React.JSX.Element;
66
+ /** @beta */
67
+ (props: PropertyFilterBuilderRuleValueRendererProps): React.JSX.Element;
32
68
  }
33
69
  /**
34
70
  * Component that renders [[PropertyFilterBuilderRuleRenderer]] value input.
35
71
  * @beta
36
72
  */
37
- export declare function PropertyFilterBuilderRuleValue(props: PropertyFilterBuilderRuleValueRendererProps): React.JSX.Element;
73
+ export declare const PropertyFilterBuilderRuleValue: PropertyFilterBuilderRuleValueComponent;
74
+ export {};
38
75
  //# sourceMappingURL=FilterBuilderRuleValue.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FilterBuilderRuleValue.d.ts","sourceRoot":"","sources":["../../../src/components-react/filter-builder/FilterBuilderRuleValue.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAMhF,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,gBAAgB,CAAC;AAIxE;;;GAGG;AACH,MAAM,WAAW,mCAAmC;IAClD,+BAA+B;IAC/B,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,qEAAqE;IACrE,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,mDAAmD;IACnD,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC;;;;OAIG;IACH,YAAY,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAC;CACjC;AAED;;;GAGG;AACH,MAAM,WAAW,2CACf,SAAQ,mCAAmC;IAC3C,wBAAwB;IACxB,QAAQ,EAAE,iCAAiC,CAAC;CAC7C;AAED;;;GAGG;AACH,wBAAgB,8BAA8B,CAC5C,KAAK,EAAE,2CAA2C,qBASnD"}
1
+ {"version":3,"file":"FilterBuilderRuleValue.d.ts","sourceRoot":"","sources":["../../../src/components-react/filter-builder/FilterBuilderRuleValue.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAKhF,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,gBAAgB,CAAC;AAIxE,YAAY;AACZ,UAAU,uCAAuC;IAC/C,+BAA+B;IAC/B,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,qEAAqE;IACrE,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,mDAAmD;IACnD,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;CAC1C;AAED,YAAY;AACZ,UAAU,yCACR,SAAQ,uCAAuC;IAC/C;;;;;OAKG;IACH,YAAY,CAAC,EAAE,QAAQ,CAAC;CACzB;AAED,YAAY;AACZ,UAAU,sCACR,SAAQ,uCAAuC;IAC/C;;;;OAIG;IACH,YAAY,EAAE,KAAK,CAAC;CACrB;AAED;;;;GAIG;AACH,MAAM,MAAM,mCAAmC,GAC3C,yCAAyC,GACzC,sCAAsC,CAAC;AAE3C;;;GAGG;AACH,MAAM,MAAM,2CAA2C,GAErD,mCAAmC,GAAG;IACpC,wBAAwB;IACxB,QAAQ,EAAE,iCAAiC,CAAC;CAC7C,CAAC;AAEJ,UAAU,uCAAuC;IAC/C;;;OAGG;IACH,CACE,KAAK,EAAE,sCAAsC,GAAG;QAC9C,wBAAwB;QACxB,QAAQ,EAAE,iCAAiC,CAAC;KAC7C,GACA,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC;IACrB;;;OAGG;IACH,CACE,KAAK,EAAE,yCAAyC,GAAG;QACjD,wBAAwB;QACxB,QAAQ,EAAE,iCAAiC,CAAC;KAC7C,GACA,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC;IACrB,YAAY;IACZ,CAAC,KAAK,EAAE,2CAA2C,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC;CACzE;AAED;;;GAGG;AACH,eAAO,MAAM,8BAA8B,EAAE,uCAS1C,CAAC"}
@@ -7,7 +7,6 @@
7
7
  */
8
8
  import * as React from "react";
9
9
  import { PropertyRecord, PropertyValueFormat } from "@itwin/appui-abstract";
10
- import { EditorContainer } from "../editors/EditorContainer.js";
11
10
  import { Flex, Text } from "@itwin/itwinui-react";
12
11
  import { PropertyFilterBuilderRuleRangeValue } from "./FilterBuilderRangeValue.js";
13
12
  import { useTranslation } from "../l10n/useTranslation.js";
@@ -16,20 +15,26 @@ import { PropertyRecordEditor } from "../new-editors/interop/PropertyRecordEdito
16
15
  * Component that renders [[PropertyFilterBuilderRuleRenderer]] value input.
17
16
  * @beta
18
17
  */
19
- export function PropertyFilterBuilderRuleValue(props) {
18
+ export const PropertyFilterBuilderRuleValue = (props) => {
20
19
  const { operator, ...restProps } = props;
21
20
  return operator === "between" || operator === "not-between" ? (React.createElement(FilterBuilderRuleRangeValueRenderer, { ...restProps })) : (React.createElement(FilterBuilderRulePrimitiveValueRenderer, { ...restProps }));
22
- }
23
- function FilterBuilderRulePrimitiveValueRenderer({ property, value, onChange, editorSystem, }) {
21
+ };
22
+ function FilterBuilderRulePrimitiveValueRenderer({ property, value, onChange,
23
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
24
+ editorSystem, }) {
24
25
  const propertyRecord = React.useMemo(() => {
25
26
  return new PropertyRecord(value ?? { valueFormat: PropertyValueFormat.Primitive }, property);
26
27
  }, [value, property]);
27
28
  const onValueChange = React.useCallback(({ newValue }) => {
28
29
  onChange(newValue);
29
30
  }, [onChange]);
30
- return (React.createElement(PropertyRecordEditor, { propertyRecord: propertyRecord, onCancel: () => { }, onCommit: onValueChange, size: "small", editorSystem: editorSystem }));
31
+ return (React.createElement(PropertyRecordEditor, { propertyRecord: propertyRecord, onCancel: () => { }, onCommit: onValueChange, size: "small",
32
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
33
+ editorSystem: editorSystem }));
31
34
  }
32
- function FilterBuilderRuleRangeValueRenderer({ property, value, onChange, }) {
35
+ function FilterBuilderRuleRangeValueRenderer({ property, value, onChange,
36
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
37
+ editorSystem, }) {
33
38
  const { translate } = useTranslation();
34
39
  const { from, to } = React.useMemo(() => {
35
40
  const rangeValue = PropertyFilterBuilderRuleRangeValue.parse(value);
@@ -46,10 +51,14 @@ function FilterBuilderRuleRangeValueRenderer({ property, value, onChange, }) {
46
51
  }, [onChange, from]);
47
52
  return (React.createElement(Flex, { className: "rule-value-range", display: "inline-flex", flexDirection: "row" },
48
53
  React.createElement(Flex.Item, null,
49
- React.createElement(EditorContainer, { propertyRecord: from, onCancel: () => { }, onCommit: handleFromValue, setFocus: false, shouldCommitOnChange: false })),
54
+ React.createElement(PropertyRecordEditor, { propertyRecord: from, onCancel: () => { }, onCommit: handleFromValue,
55
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
56
+ editorSystem: editorSystem })),
50
57
  React.createElement(Text, null, translate("filterBuilder.operators.and").toLowerCase()),
51
58
  React.createElement(Flex.Item, null,
52
- React.createElement(EditorContainer, { propertyRecord: to, onCancel: () => { }, onCommit: handleToValue, setFocus: false, shouldCommitOnChange: false }))));
59
+ React.createElement(PropertyRecordEditor, { propertyRecord: to, onCancel: () => { }, onCommit: handleToValue,
60
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
61
+ editorSystem: editorSystem }))));
53
62
  }
54
63
  function getSerializedRangeValue(from, to) {
55
64
  return PropertyFilterBuilderRuleRangeValue.serialize({
@@ -1 +1 @@
1
- {"version":3,"file":"FilterBuilderRuleValue.js","sourceRoot":"","sources":["../../../src/components-react/filter-builder/FilterBuilderRuleValue.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5E,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,mCAAmC,EAAE,MAAM,8BAA8B,CAAC;AAEnF,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,gDAAgD,CAAC;AA+BtF;;;GAGG;AACH,MAAM,UAAU,8BAA8B,CAC5C,KAAkD;IAElD,MAAM,EAAE,QAAQ,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC;IAEzC,OAAO,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,aAAa,CAAC,CAAC,CAAC,CAC5D,oBAAC,mCAAmC,OAAK,SAAS,GAAI,CACvD,CAAC,CAAC,CAAC,CACF,oBAAC,uCAAuC,OAAK,SAAS,GAAI,CAC3D,CAAC;AACJ,CAAC;AAED,SAAS,uCAAuC,CAAC,EAC/C,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,YAAY,GACwB;IACpC,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QACxC,OAAO,IAAI,cAAc,CACvB,KAAK,IAAI,EAAE,WAAW,EAAE,mBAAmB,CAAC,SAAS,EAAE,EACvD,QAAQ,C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------------------------------------------------------------------\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 PropertyFilterBuilder\n */\n\nimport * as React from \"react\";\nimport type { PropertyDescription, PropertyValue } from \"@itwin/appui-abstract\";\nimport { PropertyRecord, PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport type { PropertyUpdatedArgs } from \"../editors/EditorContainer.js\";\nimport { EditorContainer } from \"../editors/EditorContainer.js\";\nimport { Flex, Text } from \"@itwin/itwinui-react\";\nimport { PropertyFilterBuilderRuleRangeValue } from \"./FilterBuilderRangeValue.js\";\nimport type { PropertyFilterBuilderRuleOperator } from \"./Operators.js\";\nimport { useTranslation } from \"../l10n/useTranslation.js\";\nimport { PropertyRecordEditor } from \"../new-editors/interop/PropertyRecordEditor.js\";\n\n/**\n * Props for [[PropertyFilterBuilderRuleValue]] component.\n * @beta\n */\nexport interface PropertyFilterBuilderRuleValueProps {\n /** Currently entered value. */\n value?: PropertyValue;\n /** Property used in rule to which this value will be compared to. */\n property: PropertyDescription;\n /** Callback that is invoked when value changes. */\n onChange: (value: PropertyValue) => void;\n /**\n * Specifies which editors system should be used: legacy or the new one.\n * @default \"legacy\"\n * @beta\n */\n editorSystem?: \"legacy\" | \"new\";\n}\n\n/**\n * Props for custom [[PropertyFilterBuilderRuleValue]] renderer.\n * @beta\n */\nexport interface PropertyFilterBuilderRuleValueRendererProps\n extends PropertyFilterBuilderRuleValueProps {\n /** Current operator. */\n operator: PropertyFilterBuilderRuleOperator;\n}\n\n/**\n * Component that renders [[PropertyFilterBuilderRuleRenderer]] value input.\n * @beta\n */\nexport function PropertyFilterBuilderRuleValue(\n props: PropertyFilterBuilderRuleValueRendererProps\n) {\n const { operator, ...restProps } = props;\n\n return operator === \"between\" || operator === \"not-between\" ? (\n <FilterBuilderRuleRangeValueRenderer {...restProps} />\n ) : (\n <FilterBuilderRulePrimitiveValueRenderer {...restProps} />\n );\n}\n\nfunction FilterBuilderRulePrimitiveValueRenderer({\n property,\n value,\n onChange,\n editorSystem,\n}: PropertyFilterBuilderRuleValueProps) {\n const propertyRecord = React.useMemo(() => {\n return new PropertyRecord(\n value ?? { valueFormat: PropertyValueFormat.Primitive },\n property\n );\n }, [value, property]);\n\n const onValueChange = React.useCallback(\n ({ newValue }: PropertyUpdatedArgs) => {\n onChange(newValue);\n },\n [onChange]\n );\n\n return (\n <PropertyRecordEditor\n propertyRecord={propertyRecord}\n onCancel={() => {}}\n onCommit={onValueChange}\n size=\"small\"\n editorSystem={editorSystem}\n />\n );\n}\n\nfunction FilterBuilderRuleRangeValueRenderer({\n property,\n value,\n onChange,\n}: PropertyFilterBuilderRuleValueProps) {\n const { translate } = useTranslation();\n const { from, to } = React.useMemo(() => {\n const rangeValue = PropertyFilterBuilderRuleRangeValue.parse(value);\n return {\n from: new PropertyRecord(rangeValue.from, property),\n to: new PropertyRecord(rangeValue.to, property),\n };\n }, [property, value]);\n\n const handleFromValue = React.useCallback(\n ({ newValue }: PropertyUpdatedArgs) => {\n onChange(getSerializedRangeValue(newValue, to.value));\n },\n [onChange, to]\n );\n\n const handleToValue = React.useCallback(\n ({ newValue }: PropertyUpdatedArgs) => {\n onChange(getSerializedRangeValue(from.value, newValue));\n },\n [onChange, from]\n );\n\n return (\n <Flex\n className=\"rule-value-range\"\n display=\"inline-flex\"\n flexDirection=\"row\"\n >\n <Flex.Item>\n <EditorContainer\n propertyRecord={from}\n onCancel={() => {}}\n onCommit={handleFromValue}\n setFocus={false}\n shouldCommitOnChange={false}\n />\n </Flex.Item>\n <Text>{translate(\"filterBuilder.operators.and\").toLowerCase()}</Text>\n <Flex.Item>\n <EditorContainer\n propertyRecord={to}\n onCancel={() => {}}\n onCommit={handleToValue}\n setFocus={false}\n shouldCommitOnChange={false}\n />\n </Flex.Item>\n </Flex>\n );\n}\n\nfunction getSerializedRangeValue(from: PropertyValue, to: PropertyValue) {\n return PropertyFilterBuilderRuleRangeValue.serialize({\n from:\n from.valueFormat === PropertyValueFormat.Primitive\n ? from\n : { valueFormat: PropertyValueFormat.Primitive },\n to:\n to.valueFormat === PropertyValueFormat.Primitive\n ? to\n : { valueFormat: PropertyValueFormat.Primitive },\n });\n}\n"]}
1
+ {"version":3,"file":"FilterBuilderRuleValue.js","sourceRoot":"","sources":["../../../src/components-react/filter-builder/FilterBuilderRuleValue.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5E,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,mCAAmC,EAAE,MAAM,8BAA8B,CAAC;AAEnF,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,gDAAgD,CAAC;AAgFtF;;;GAGG;AACH,MAAM,CAAC,MAAM,8BAA8B,GACzC,CAAC,KAAkD,EAAE,EAAE;IACrD,MAAM,EAAE,QAAQ,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC;IAEzC,OAAO,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,aAAa,CAAC,CAAC,CAAC,CAC5D,oBAAC,mCAAmC,OAAK,SAAS,GAAI,CACvD,CAAC,CAAC,CAAC,CACF,oBAAC,uCAAuC,OAAK,SAAS,GAAI,CAC3D,CAAC;AACJ,CAAC,CAAC;AAEJ,SAAS,uCAAuC,CAAC,EAC/C,QAAQ,EACR,KAAK,EACL,QAAQ;AACR,4DAA4D;AAC5D,YAAY,GAEqB;IACjC,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QACxC,OAAO,IAAI,cAAc,CACvB,KAAK,IAAI,EAAE,WAAW,EAAE,mBAAmB,CAAC,SAAS,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EAAE;KACrD,CAAC,CAAC;AACL,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 PropertyFilterBuilder\n */\n\nimport * as React from \"react\";\nimport type { PropertyDescription, PropertyValue } from \"@itwin/appui-abstract\";\nimport { PropertyRecord, PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport type { PropertyUpdatedArgs } from \"../editors/EditorContainer.js\";\nimport { Flex, Text } from \"@itwin/itwinui-react\";\nimport { PropertyFilterBuilderRuleRangeValue } from \"./FilterBuilderRangeValue.js\";\nimport type { PropertyFilterBuilderRuleOperator } from \"./Operators.js\";\nimport { useTranslation } from \"../l10n/useTranslation.js\";\nimport { PropertyRecordEditor } from \"../new-editors/interop/PropertyRecordEditor.js\";\n\n/** @beta */\ninterface PropertyFilterBuilderRuleValueBaseProps {\n /** Currently entered value. */\n value?: PropertyValue;\n /** Property used in rule to which this value will be compared to. */\n property: PropertyDescription;\n /** Callback that is invoked when value changes. */\n onChange: (value: PropertyValue) => void;\n}\n\n/** @beta */\ninterface PropertyFilterBuilderRuleValueLegacyProps\n extends PropertyFilterBuilderRuleValueBaseProps {\n /**\n * Specifies which editors system should be used: legacy or the new one.\n * @default \"legacy\"\n * @beta\n * @deprecated in 5.30. Legacy editors system is deprecated. Use `editorSystem: \"new\"`.\n */\n editorSystem?: \"legacy\";\n}\n\n/** @beta */\ninterface PropertyFilterBuilderRuleValueNewProps\n extends PropertyFilterBuilderRuleValueBaseProps {\n /**\n * Specifies which editors system should be used: legacy or the new one.\n * @default \"legacy\"\n * @beta\n */\n editorSystem: \"new\";\n}\n\n/**\n * Props for [[PropertyFilterBuilderRuleValue]] component.\n * @beta\n * @deprecated in 5.30.0. Use `React.ComponentProps<typeof PropertyFilterBuilderRuleValue>` instead.\n */\nexport type PropertyFilterBuilderRuleValueProps =\n | PropertyFilterBuilderRuleValueLegacyProps\n | PropertyFilterBuilderRuleValueNewProps;\n\n/**\n * Props for custom [[PropertyFilterBuilderRuleValue]] renderer.\n * @beta\n */\nexport type PropertyFilterBuilderRuleValueRendererProps =\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n PropertyFilterBuilderRuleValueProps & {\n /** Current operator. */\n operator: PropertyFilterBuilderRuleOperator;\n };\n\ninterface PropertyFilterBuilderRuleValueComponent {\n /**\n * Component that renders [[PropertyFilterBuilderRuleRenderer]] value input.\n * @beta\n */\n (\n props: PropertyFilterBuilderRuleValueNewProps & {\n /** Current operator. */\n operator: PropertyFilterBuilderRuleOperator;\n }\n ): React.JSX.Element;\n /**\n * @deprecated in 5.30. Use `PropertyFilterBuilderRuleValue` with `editorSystem=\"new\"` instead.\n * @beta\n */\n (\n props: PropertyFilterBuilderRuleValueLegacyProps & {\n /** Current operator. */\n operator: PropertyFilterBuilderRuleOperator;\n }\n ): React.JSX.Element;\n /** @beta */\n (props: PropertyFilterBuilderRuleValueRendererProps): React.JSX.Element;\n}\n\n/**\n * Component that renders [[PropertyFilterBuilderRuleRenderer]] value input.\n * @beta\n */\nexport const PropertyFilterBuilderRuleValue: PropertyFilterBuilderRuleValueComponent =\n (props: PropertyFilterBuilderRuleValueRendererProps) => {\n const { operator, ...restProps } = props;\n\n return operator === \"between\" || operator === \"not-between\" ? (\n <FilterBuilderRuleRangeValueRenderer {...restProps} />\n ) : (\n <FilterBuilderRulePrimitiveValueRenderer {...restProps} />\n );\n };\n\nfunction FilterBuilderRulePrimitiveValueRenderer({\n property,\n value,\n onChange,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n editorSystem,\n}: // eslint-disable-next-line @typescript-eslint/no-deprecated\nPropertyFilterBuilderRuleValueProps) {\n const propertyRecord = React.useMemo(() => {\n return new PropertyRecord(\n value ?? { valueFormat: PropertyValueFormat.Primitive },\n property\n );\n }, [value, property]);\n\n const onValueChange = React.useCallback(\n ({ newValue }: PropertyUpdatedArgs) => {\n onChange(newValue);\n },\n [onChange]\n );\n\n return (\n <PropertyRecordEditor\n propertyRecord={propertyRecord}\n onCancel={() => {}}\n onCommit={onValueChange}\n size=\"small\"\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n editorSystem={editorSystem}\n />\n );\n}\n\nfunction FilterBuilderRuleRangeValueRenderer({\n property,\n value,\n onChange,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n editorSystem,\n}: // eslint-disable-next-line @typescript-eslint/no-deprecated\nPropertyFilterBuilderRuleValueProps) {\n const { translate } = useTranslation();\n const { from, to } = React.useMemo(() => {\n const rangeValue = PropertyFilterBuilderRuleRangeValue.parse(value);\n return {\n from: new PropertyRecord(rangeValue.from, property),\n to: new PropertyRecord(rangeValue.to, property),\n };\n }, [property, value]);\n\n const handleFromValue = React.useCallback(\n ({ newValue }: PropertyUpdatedArgs) => {\n onChange(getSerializedRangeValue(newValue, to.value));\n },\n [onChange, to]\n );\n\n const handleToValue = React.useCallback(\n ({ newValue }: PropertyUpdatedArgs) => {\n onChange(getSerializedRangeValue(from.value, newValue));\n },\n [onChange, from]\n );\n\n return (\n <Flex\n className=\"rule-value-range\"\n display=\"inline-flex\"\n flexDirection=\"row\"\n >\n <Flex.Item>\n <PropertyRecordEditor\n propertyRecord={from}\n onCancel={() => {}}\n onCommit={handleFromValue}\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n editorSystem={editorSystem}\n />\n </Flex.Item>\n <Text>{translate(\"filterBuilder.operators.and\").toLowerCase()}</Text>\n <Flex.Item>\n <PropertyRecordEditor\n propertyRecord={to}\n onCancel={() => {}}\n onCommit={handleToValue}\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n editorSystem={editorSystem}\n />\n </Flex.Item>\n </Flex>\n );\n}\n\nfunction getSerializedRangeValue(from: PropertyValue, to: PropertyValue) {\n return PropertyFilterBuilderRuleRangeValue.serialize({\n from:\n from.valueFormat === PropertyValueFormat.Primitive\n ? from\n : { valueFormat: PropertyValueFormat.Primitive },\n to:\n to.valueFormat === PropertyValueFormat.Primitive\n ? to\n : { valueFormat: PropertyValueFormat.Primitive },\n });\n}\n"]}
@@ -0,0 +1,62 @@
1
+ import type { PropertyRecord } from "@itwin/appui-abstract";
2
+ import type { NumericValueMetadata } from "./values/Metadata.js";
3
+ /** @internal */
4
+ export interface StringPropertyValueConstraints {
5
+ minimumLength?: number;
6
+ maximumLength?: number;
7
+ }
8
+ /** @internal */
9
+ export type NumericPropertyValueConstraints = Required<NumericValueMetadata>["constraints"];
10
+ /** @internal */
11
+ export interface ArrayPropertyValueConstraints {
12
+ minOccurs?: number;
13
+ maxOccurs?: number;
14
+ }
15
+ /**
16
+ * Copy of `PropertyValueConstraints` from @itwin/presentation-common package to support pre-5.0 version.
17
+ * @internal
18
+ */
19
+ export type PropertyValueConstraints = StringPropertyValueConstraints | NumericPropertyValueConstraints | ArrayPropertyValueConstraints;
20
+ /**
21
+ * Expands specified type with additional constraints property.
22
+ * @internal
23
+ */
24
+ export type WithConstraints<T extends object> = T & {
25
+ constraints?: PropertyValueConstraints;
26
+ };
27
+ /**
28
+ * `PropertyRecord` with `constraints` on its `property` field.
29
+ *
30
+ * @internal
31
+ */
32
+ export type PropertyRecordWithConstraints = Omit<PropertyRecord, "property"> & {
33
+ property: WithConstraints<PropertyRecord["property"]>;
34
+ };
35
+ /**
36
+ * Extracts `minimumValue`/`maximumValue` from a `PropertyValueConstraints` object.
37
+ * Returns `{ min: undefined, max: undefined }` if the constraint object doesn't have those keys.
38
+ * @internal
39
+ */
40
+ export declare function getNumericConstraints(constraints: PropertyValueConstraints | undefined): {
41
+ min?: number;
42
+ max?: number;
43
+ };
44
+ /**
45
+ * Clamps `value` to `[min, max]`.
46
+ * @internal
47
+ */
48
+ export declare function applyNumericConstraints({ value, min, max, }: {
49
+ value: number;
50
+ min?: number;
51
+ max?: number;
52
+ }): number;
53
+ /**
54
+ * Extracts `minimumLength`/`maximumLength` from a `PropertyValueConstraints` object.
55
+ * Returns `{ minLength: undefined, maxLength: undefined }` if the constraint object doesn't have those keys.
56
+ * @internal
57
+ */
58
+ export declare function getStringConstraints(constraints: PropertyValueConstraints | undefined): {
59
+ minLength?: number;
60
+ maxLength?: number;
61
+ };
62
+ //# sourceMappingURL=ConstraintUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConstraintUtils.d.ts","sourceRoot":"","sources":["../../../src/components-react/new-editors/ConstraintUtils.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEjE,gBAAgB;AAChB,MAAM,WAAW,8BAA8B;IAC7C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,gBAAgB;AAChB,MAAM,MAAM,+BAA+B,GACzC,QAAQ,CAAC,oBAAoB,CAAC,CAAC,aAAa,CAAC,CAAC;AAEhD,gBAAgB;AAChB,MAAM,WAAW,6BAA6B;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GAChC,8BAA8B,GAC9B,+BAA+B,GAC/B,6BAA6B,CAAC;AAElC;;;GAGG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,GAAG;IAClD,WAAW,CAAC,EAAE,wBAAwB,CAAC;CACxC,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,6BAA6B,GAAG,IAAI,CAAC,cAAc,EAAE,UAAU,CAAC,GAAG;IAC7E,QAAQ,EAAE,eAAe,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC;CACvD,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,wBAAwB,GAAG,SAAS,GAChD;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,CAWhC;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,EACtC,KAAK,EACL,GAAG,EACH,GAAG,GACJ,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,GAAG,MAAM,CAST;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,wBAAwB,GAAG,SAAS,GAChD;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAW5C"}
@@ -0,0 +1,49 @@
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
+ /**
6
+ * Extracts `minimumValue`/`maximumValue` from a `PropertyValueConstraints` object.
7
+ * Returns `{ min: undefined, max: undefined }` if the constraint object doesn't have those keys.
8
+ * @internal
9
+ */
10
+ export function getNumericConstraints(constraints) {
11
+ if (constraints &&
12
+ ("minimumValue" in constraints || "maximumValue" in constraints)) {
13
+ return {
14
+ min: constraints.minimumValue,
15
+ max: constraints.maximumValue,
16
+ };
17
+ }
18
+ return { min: undefined, max: undefined };
19
+ }
20
+ /**
21
+ * Clamps `value` to `[min, max]`.
22
+ * @internal
23
+ */
24
+ export function applyNumericConstraints({ value, min, max, }) {
25
+ let clamped = value;
26
+ if (min !== undefined) {
27
+ clamped = Math.max(clamped, min);
28
+ }
29
+ if (max !== undefined) {
30
+ clamped = Math.min(clamped, max);
31
+ }
32
+ return clamped;
33
+ }
34
+ /**
35
+ * Extracts `minimumLength`/`maximumLength` from a `PropertyValueConstraints` object.
36
+ * Returns `{ minLength: undefined, maxLength: undefined }` if the constraint object doesn't have those keys.
37
+ * @internal
38
+ */
39
+ export function getStringConstraints(constraints) {
40
+ if (constraints &&
41
+ ("minimumLength" in constraints || "maximumLength" in constraints)) {
42
+ return {
43
+ minLength: constraints.minimumLength,
44
+ maxLength: constraints.maximumLength,
45
+ };
46
+ }
47
+ return { minLength: undefined, maxLength: undefined };
48
+ }
49
+ //# sourceMappingURL=ConstraintUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConstraintUtils.js","sourceRoot":"","sources":["../../../src/components-react/new-editors/ConstraintUtils.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AA+ChG;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CACnC,WAAiD;IAEjD,IACE,WAAW;QACX,CAAC,cAAc,IAAI,WAAW,IAAI,cAAc,IAAI,WAAW,CAAC,EAChE,CAAC;QACD,OAAO;YACL,GAAG,EAAE,WAAW,CAAC,YAAY;YAC7B,GAAG,EAAE,WAAW,CAAC,YAAY;SAC9B,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC;AAC5C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAAC,EACtC,KAAK,EACL,GAAG,EACH,GAAG,GAKJ;IACC,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACtB,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IACnC,CAAC;IACD,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACtB,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IACnC,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAClC,WAAiD;IAEjD,IACE,WAAW;QACX,CAAC,eAAe,IAAI,WAAW,IAAI,eAAe,IAAI,WAAW,CAAC,EAClE,CAAC;QACD,OAAO;YACL,SAAS,EAAE,WAAW,CAAC,aAAa;YACpC,SAAS,EAAE,WAAW,CAAC,aAAa;SACrC,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;AACxD,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 type { PropertyRecord } from \"@itwin/appui-abstract\";\nimport type { NumericValueMetadata } from \"./values/Metadata.js\";\n\n/** @internal */\nexport interface StringPropertyValueConstraints {\n minimumLength?: number;\n maximumLength?: number;\n}\n\n/** @internal */\nexport type NumericPropertyValueConstraints =\n Required<NumericValueMetadata>[\"constraints\"];\n\n/** @internal */\nexport interface ArrayPropertyValueConstraints {\n minOccurs?: number;\n maxOccurs?: number;\n}\n\n/**\n * Copy of `PropertyValueConstraints` from @itwin/presentation-common package to support pre-5.0 version.\n * @internal\n */\nexport type PropertyValueConstraints =\n | StringPropertyValueConstraints\n | NumericPropertyValueConstraints\n | ArrayPropertyValueConstraints;\n\n/**\n * Expands specified type with additional constraints property.\n * @internal\n */\nexport type WithConstraints<T extends object> = T & {\n constraints?: PropertyValueConstraints;\n};\n\n/**\n * `PropertyRecord` with `constraints` on its `property` field.\n *\n * @internal\n */\nexport type PropertyRecordWithConstraints = Omit<PropertyRecord, \"property\"> & {\n property: WithConstraints<PropertyRecord[\"property\"]>;\n};\n\n/**\n * Extracts `minimumValue`/`maximumValue` from a `PropertyValueConstraints` object.\n * Returns `{ min: undefined, max: undefined }` if the constraint object doesn't have those keys.\n * @internal\n */\nexport function getNumericConstraints(\n constraints: PropertyValueConstraints | undefined\n): { min?: number; max?: number } {\n if (\n constraints &&\n (\"minimumValue\" in constraints || \"maximumValue\" in constraints)\n ) {\n return {\n min: constraints.minimumValue,\n max: constraints.maximumValue,\n };\n }\n return { min: undefined, max: undefined };\n}\n\n/**\n * Clamps `value` to `[min, max]`.\n * @internal\n */\nexport function applyNumericConstraints({\n value,\n min,\n max,\n}: {\n value: number;\n min?: number;\n max?: number;\n}): number {\n let clamped = value;\n if (min !== undefined) {\n clamped = Math.max(clamped, min);\n }\n if (max !== undefined) {\n clamped = Math.min(clamped, max);\n }\n return clamped;\n}\n\n/**\n * Extracts `minimumLength`/`maximumLength` from a `PropertyValueConstraints` object.\n * Returns `{ minLength: undefined, maxLength: undefined }` if the constraint object doesn't have those keys.\n * @internal\n */\nexport function getStringConstraints(\n constraints: PropertyValueConstraints | undefined\n): { minLength?: number; maxLength?: number } {\n if (\n constraints &&\n (\"minimumLength\" in constraints || \"maximumLength\" in constraints)\n ) {\n return {\n minLength: constraints.minimumLength,\n maxLength: constraints.maximumLength,\n };\n }\n return { minLength: undefined, maxLength: undefined };\n}\n"]}
@@ -33,6 +33,12 @@ export interface EditorProps<TMetadata = ValueMetadata, TValue = Value> {
33
33
  cancel?: () => void;
34
34
  disabled?: boolean;
35
35
  size?: "small" | "large";
36
+ /**
37
+ * HTML `id` attribute forwarded to the interactive element. Used to associate
38
+ * the editor with a `<label htmlFor>` so that `getByLabelText` queries work and
39
+ * the UI meets accessibility requirements.
40
+ */
41
+ id?: string;
36
42
  }
37
43
  /**
38
44
  * Utility function to create an editor spec for editor with concrete metadata and value types.
@@ -1 +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,EA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ACxE,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;IACzB;;;;OAIG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;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"}
@@ -1 +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"]}
1
+ {"version":3,"file":"Types.js","sourceRoot":"","sources":["../../../src/components-react/new-editors/Types.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AA4CH;;;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 * HTML `id` attribute forwarded to the interactive element. Used to associate\n * the editor with a `<label htmlFor>` so that `getByLabelText` queries work and\n * the UI meets accessibility requirements.\n */\n id?: string;\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"]}
@@ -3,6 +3,7 @@
3
3
  */
4
4
  import * as React from "react";
5
5
  import type { Value } from "./values/Values.js";
6
+ import type { EditorProps } from "./Types.js";
6
7
  interface UseCommittableValueProps {
7
8
  initialValue?: Value;
8
9
  onCommit: (value?: Value) => void;
@@ -40,12 +41,8 @@ interface UseCommittableValueProps {
40
41
  *
41
42
  * @beta
42
43
  */
43
- export declare function useCommittableValue({ initialValue, onCancel, onCommit, }: UseCommittableValueProps): {
44
- onChange: (newValue?: Value) => void;
44
+ export declare function useCommittableValue({ initialValue, onCancel, onCommit, }: UseCommittableValueProps): Pick<EditorProps, "commit" | "value" | "onChange" | "cancel"> & {
45
45
  onKeydown: (e: React.KeyboardEvent) => void;
46
- commit: () => void;
47
- cancel: () => void;
48
- value: Value | undefined;
49
46
  };
50
47
  export {};
51
48
  //# sourceMappingURL=UseCommittableValue.d.ts.map
@@ -1 +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"}
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;AAEhD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,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,GAAG,IAAI,CAChC,WAAW,EACX,QAAQ,GAAG,OAAO,GAAG,UAAU,GAAG,QAAQ,CAC3C,GAAG;IAAE,SAAS,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,aAAa,KAAK,IAAI,CAAA;CAAE,CAyDlD"}
@@ -47,7 +47,10 @@ export function useCommittableValue({ initialValue, onCancel, onCommit, }) {
47
47
  value: initialValue,
48
48
  });
49
49
  const handleChange = (newValue) => {
50
- currentValueRef.current = { state: "changed", value: newValue };
50
+ currentValueRef.current = {
51
+ state: "changed",
52
+ value: newValue,
53
+ };
51
54
  setCurrentValue(newValue);
52
55
  };
53
56
  const handleCommit = () => {
@@ -1 +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"]}
1
+ {"version":3,"file":"UseCommittableValue.js","source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AC,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\";\nimport type { EditorProps } from \"./Types.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): Pick<\n EditorProps,\n \"commit\" | \"value\" | \"onChange\" | \"cancel\"\n> & { onKeydown: (e: React.KeyboardEvent) => void } {\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: EditorProps[\"onChange\"] = (newValue?: Value) => {\n currentValueRef.current = {\n state: \"changed\",\n value: newValue,\n };\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"]}
@@ -6,5 +6,5 @@ import type { BooleanValue } from "../values/Values.js";
6
6
  * Boolean value editor that renders `Checkbox` component for changing value.
7
7
  * @internal
8
8
  */
9
- export declare function BooleanEditor({ value, onChange, commit, disabled, }: EditorProps<ValueMetadata, BooleanValue>): React.JSX.Element;
9
+ export declare function BooleanEditor({ value, onChange, commit, disabled, id, }: EditorProps<ValueMetadata, BooleanValue>): React.JSX.Element;
10
10
  //# sourceMappingURL=BooleanEditor.d.ts.map
@@ -1 +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"}
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,EACR,EAAE,GACH,EAAE,WAAW,CAAC,aAAa,EAAE,YAAY,CAAC,qBAgB1C"}
@@ -9,14 +9,14 @@ import { Checkbox } from "@itwin/itwinui-react";
9
9
  * Boolean value editor that renders `Checkbox` component for changing value.
10
10
  * @internal
11
11
  */
12
- export function BooleanEditor({ value, onChange, commit, disabled, }) {
12
+ export function BooleanEditor({ value, onChange, commit, disabled, id, }) {
13
13
  const currentValue = value?.value ?? false;
14
14
  const handleChange = (e) => {
15
15
  const newValue = { value: e.target.checked };
16
16
  onChange(newValue);
17
17
  commit?.();
18
18
  };
19
- return (React.createElement(Checkbox, { checked: currentValue, onChange: handleChange, disabled: disabled }));
19
+ return (React.createElement(Checkbox, { id: id, checked: currentValue, onChange: handleChange, disabled: disabled }));
20
20
  }
21
21
  /* v8 ignore stop */
22
22
  //# sourceMappingURL=BooleanEditor.js.map
@@ -1 +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"]}
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,EACR,EAAE,GACuC;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,EAAE,EAAE,EAAE,EACN,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 id,\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 id={id}\n checked={currentValue}\n onChange={handleChange}\n disabled={disabled}\n />\n );\n}\n\n/* v8 ignore stop */\n"]}
@@ -6,5 +6,5 @@ import type { DateValue } from "../values/Values.js";
6
6
  * Date value editor that render `DatePicker` component for changing value.
7
7
  * @internal
8
8
  */
9
- export declare function DateEditor({ value, onChange, commit, size, disabled, }: EditorProps<ValueMetadata, DateValue>): React.JSX.Element;
9
+ export declare function DateEditor({ value, onChange, commit, size, disabled, id, }: EditorProps<ValueMetadata, DateValue>): React.JSX.Element;
10
10
  //# sourceMappingURL=DateEditor.d.ts.map
@@ -1 +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"}
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,EACR,EAAE,GACH,EAAE,WAAW,CAAC,aAAa,EAAE,SAAS,CAAC,qBAavC"}
@@ -9,10 +9,10 @@ import { DateInput } from "./DateInput.js";
9
9
  * Date value editor that render `DatePicker` component for changing value.
10
10
  * @internal
11
11
  */
12
- export function DateEditor({ value, onChange, commit, size, disabled, }) {
12
+ export function DateEditor({ value, onChange, commit, size, disabled, id, }) {
13
13
  return (React.createElement(DateInput, { value: value?.value, onChange: (newValue) => {
14
14
  onChange({ value: newValue });
15
- }, onClose: commit, size: size, disabled: disabled }));
15
+ }, onClose: commit, size: size, disabled: disabled, id: id }));
16
16
  }
17
17
  /* v8 ignore stop */
18
18
  //# sourceMappingURL=DateEditor.js.map
@@ -1 +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"]}
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,EACR,EAAE,GACoC;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,EAAE,EAAE,EAAE,GACN,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 id,\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 id={id}\n />\n );\n}\n\n/* v8 ignore stop */\n"]}
@@ -6,10 +6,11 @@ interface DateInputProps {
6
6
  size?: "small" | "large";
7
7
  disabled?: boolean;
8
8
  showTimePicker?: boolean;
9
+ id?: string;
9
10
  }
10
11
  /**
11
12
  * @internal
12
13
  */
13
- export declare function DateInput({ value, onChange, onClose, size, showTimePicker, disabled, }: DateInputProps): React.JSX.Element;
14
+ export declare function DateInput({ value, onChange, onClose, size, showTimePicker, disabled, id, }: DateInputProps): React.JSX.Element;
14
15
  export {};
15
16
  //# sourceMappingURL=DateInput.d.ts.map
@@ -1 +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"}
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;IACzB,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,QAAQ,EACR,OAAO,EACP,IAAI,EACJ,cAAc,EACd,QAAQ,EACR,EAAE,GACH,EAAE,cAAc,qBA4BhB"}
@@ -7,7 +7,7 @@ import { Button, DatePicker, Popover } from "@itwin/itwinui-react";
7
7
  /**
8
8
  * @internal
9
9
  */
10
- export function DateInput({ value, onChange, onClose, size, showTimePicker, disabled, }) {
10
+ export function DateInput({ value, onChange, onClose, size, showTimePicker, disabled, id, }) {
11
11
  const currentValue = value ?? new Date();
12
12
  const dateStr = showTimePicker
13
13
  ? currentValue.toLocaleString()
@@ -17,7 +17,7 @@ export function DateInput({ value, onChange, onClose, size, showTimePicker, disa
17
17
  onClose?.();
18
18
  }
19
19
  } },
20
- React.createElement(Button, { style: { width: "100%" }, size: size, disabled: disabled }, dateStr)));
20
+ React.createElement(Button, { id: id, style: { width: "100%" }, size: size, disabled: disabled }, dateStr)));
21
21
  }
22
22
  /* v8 ignore stop */
23
23
  //# sourceMappingURL=DateInput.js.map
@@ -1 +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"]}
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;AAcnE;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,EACxB,KAAK,EACL,QAAQ,EACR,OAAO,EACP,IAAI,EACJ,cAAc,EACd,QAAQ,EACR,EAAE,GACa;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,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,IACrE,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 id?: string;\n}\n\n/**\n * @internal\n */\nexport function DateInput({\n value,\n onChange,\n onClose,\n size,\n showTimePicker,\n disabled,\n id,\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 id={id} style={{ width: \"100%\" }} size={size} disabled={disabled}>\n {dateStr}\n </Button>\n </Popover>\n );\n}\n\n/* v8 ignore stop */\n"]}
@@ -6,5 +6,5 @@ import type { DateValue } from "../values/Values.js";
6
6
  * Date time value editor that render `DatePicker` component with time selector for changing value.
7
7
  * @internal
8
8
  */
9
- export declare function DateTimeEditor({ value, onChange, commit, size, disabled, }: EditorProps<ValueMetadata, DateValue>): React.JSX.Element;
9
+ export declare function DateTimeEditor({ value, onChange, commit, size, disabled, id, }: EditorProps<ValueMetadata, DateValue>): React.JSX.Element;
10
10
  //# sourceMappingURL=DateTimeEditor.d.ts.map
@@ -1 +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"}
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,EACR,EAAE,GACH,EAAE,WAAW,CAAC,aAAa,EAAE,SAAS,CAAC,qBAcvC"}
@@ -9,10 +9,10 @@ import { DateInput } from "./DateInput.js";
9
9
  * Date time value editor that render `DatePicker` component with time selector for changing value.
10
10
  * @internal
11
11
  */
12
- export function DateTimeEditor({ value, onChange, commit, size, disabled, }) {
12
+ export function DateTimeEditor({ value, onChange, commit, size, disabled, id, }) {
13
13
  return (React.createElement(DateInput, { value: value?.value, onChange: (newValue) => {
14
14
  onChange({ value: newValue });
15
- }, onClose: commit, size: size, disabled: disabled, showTimePicker: true }));
15
+ }, onClose: commit, size: size, disabled: disabled, showTimePicker: true, id: id }));
16
16
  }
17
17
  /* v8 ignore stop */
18
18
  //# sourceMappingURL=DateTimeEditor.js.map