@itwin/components-react 5.18.0 → 5.20.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 (140) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/lib/components-react/UiComponents.js +2 -1
  3. package/lib/components-react/UiComponents.js.map +1 -1
  4. package/lib/components-react/common/ImageRenderer.js +1 -1
  5. package/lib/components-react/common/ImageRenderer.js.map +1 -1
  6. package/lib/components-react/common/SubscriptionScheduler.js +1 -1
  7. package/lib/components-react/common/SubscriptionScheduler.js.map +1 -1
  8. package/lib/components-react/common/selection/SelectionHandler.js +20 -2
  9. package/lib/components-react/common/selection/SelectionHandler.js.map +1 -1
  10. package/lib/components-react/converters/BooleanTypeConverter.js +4 -4
  11. package/lib/components-react/converters/BooleanTypeConverter.js.map +1 -1
  12. package/lib/components-react/converters/PointTypeConverter.js +1 -0
  13. package/lib/components-react/converters/PointTypeConverter.js.map +1 -1
  14. package/lib/components-react/converters/TypeConverterManager.js +2 -1
  15. package/lib/components-react/converters/TypeConverterManager.js.map +1 -1
  16. package/lib/components-react/datepicker/IntlFormatter.js +1 -0
  17. package/lib/components-react/datepicker/IntlFormatter.js.map +1 -1
  18. package/lib/components-react/editors/BooleanEditor.js +23 -26
  19. package/lib/components-react/editors/BooleanEditor.js.map +1 -1
  20. package/lib/components-react/editors/CustomNumberEditor.js +92 -97
  21. package/lib/components-react/editors/CustomNumberEditor.js.map +1 -1
  22. package/lib/components-react/editors/DateTimeEditor.js +60 -63
  23. package/lib/components-react/editors/DateTimeEditor.js.map +1 -1
  24. package/lib/components-react/editors/EnumButtonGroupEditor.js +23 -26
  25. package/lib/components-react/editors/EnumButtonGroupEditor.js.map +1 -1
  26. package/lib/components-react/editors/EnumEditor.js +30 -33
  27. package/lib/components-react/editors/EnumEditor.js.map +1 -1
  28. package/lib/components-react/editors/IconEditor.js +16 -16
  29. package/lib/components-react/editors/IconEditor.js.map +1 -1
  30. package/lib/components-react/editors/ImageCheckBoxEditor.js +22 -25
  31. package/lib/components-react/editors/ImageCheckBoxEditor.js.map +1 -1
  32. package/lib/components-react/editors/NumericInputEditor.js +26 -29
  33. package/lib/components-react/editors/NumericInputEditor.js.map +1 -1
  34. package/lib/components-react/editors/PopupButton.js +26 -29
  35. package/lib/components-react/editors/PopupButton.js.map +1 -1
  36. package/lib/components-react/editors/PropertyEditorManager.js +2 -4
  37. package/lib/components-react/editors/PropertyEditorManager.js.map +1 -1
  38. package/lib/components-react/editors/SliderEditor.js +65 -68
  39. package/lib/components-react/editors/SliderEditor.js.map +1 -1
  40. package/lib/components-react/editors/TextEditor.js +22 -25
  41. package/lib/components-react/editors/TextEditor.js.map +1 -1
  42. package/lib/components-react/editors/TextareaEditor.js +29 -32
  43. package/lib/components-react/editors/TextareaEditor.js.map +1 -1
  44. package/lib/components-react/editors/ToggleEditor.js +26 -29
  45. package/lib/components-react/editors/ToggleEditor.js.map +1 -1
  46. package/lib/components-react/filter-builder/FilterBuilderState.js +1 -0
  47. package/lib/components-react/filter-builder/FilterBuilderState.js.map +1 -1
  48. package/lib/components-react/filtering/FilteringInput.js +36 -36
  49. package/lib/components-react/filtering/FilteringInput.js.map +1 -1
  50. package/lib/components-react/filtering/ResultSelector.js +50 -50
  51. package/lib/components-react/filtering/ResultSelector.js.map +1 -1
  52. package/lib/components-react/iconpicker/IconPickerButton.js +18 -18
  53. package/lib/components-react/iconpicker/IconPickerButton.js.map +1 -1
  54. package/lib/components-react/properties/ValueRendererManager.js +6 -7
  55. package/lib/components-react/properties/ValueRendererManager.js.map +1 -1
  56. package/lib/components-react/properties/renderers/NonPrimitivePropertyRenderer.js +17 -17
  57. package/lib/components-react/properties/renderers/NonPrimitivePropertyRenderer.js.map +1 -1
  58. package/lib/components-react/properties/renderers/PropertyGridColumns.js +4 -3
  59. package/lib/components-react/properties/renderers/PropertyGridColumns.js.map +1 -1
  60. package/lib/components-react/properties/renderers/PropertyView.js +23 -23
  61. package/lib/components-react/properties/renderers/PropertyView.js.map +1 -1
  62. package/lib/components-react/properties/renderers/label/NonPrimitivePropertyLabelRenderer.js +6 -9
  63. package/lib/components-react/properties/renderers/label/NonPrimitivePropertyLabelRenderer.js.map +1 -1
  64. package/lib/components-react/properties/renderers/value/table/NonPrimitiveValueRenderer.js +9 -12
  65. package/lib/components-react/properties/renderers/value/table/NonPrimitiveValueRenderer.js.map +1 -1
  66. package/lib/components-react/propertygrid/MergingPropertyDataProvider.js +2 -1
  67. package/lib/components-react/propertygrid/MergingPropertyDataProvider.js.map +1 -1
  68. package/lib/components-react/propertygrid/PropertyCategoryRendererManager.js +2 -4
  69. package/lib/components-react/propertygrid/PropertyCategoryRendererManager.js.map +1 -1
  70. package/lib/components-react/propertygrid/SimplePropertyDataProvider.js +6 -4
  71. package/lib/components-react/propertygrid/SimplePropertyDataProvider.js.map +1 -1
  72. package/lib/components-react/propertygrid/component/ColumnResizingPropertyListPropsSupplier.js +26 -29
  73. package/lib/components-react/propertygrid/component/ColumnResizingPropertyListPropsSupplier.js.map +1 -1
  74. package/lib/components-react/propertygrid/component/PropertyCategoryBlock.js +3 -3
  75. package/lib/components-react/propertygrid/component/PropertyCategoryBlock.js.map +1 -1
  76. package/lib/components-react/propertygrid/component/PropertyGridCommons.js +9 -9
  77. package/lib/components-react/propertygrid/component/PropertyGridCommons.js.map +1 -1
  78. package/lib/components-react/propertygrid/component/PropertyGridEventsRelatedPropsSupplier.js +22 -22
  79. package/lib/components-react/propertygrid/component/PropertyGridEventsRelatedPropsSupplier.js.map +1 -1
  80. package/lib/components-react/propertygrid/component/PropertyList.js +5 -5
  81. package/lib/components-react/propertygrid/component/PropertyList.js.map +1 -1
  82. package/lib/components-react/propertygrid/component/VirtualizedPropertyGrid.js +29 -29
  83. package/lib/components-react/propertygrid/component/VirtualizedPropertyGrid.js.map +1 -1
  84. package/lib/components-react/propertygrid/dataproviders/FilteringDataProvider.js +12 -14
  85. package/lib/components-react/propertygrid/dataproviders/FilteringDataProvider.js.map +1 -1
  86. package/lib/components-react/propertygrid/dataproviders/filterers/CompositePropertyDataFilterer.js +3 -0
  87. package/lib/components-react/propertygrid/dataproviders/filterers/CompositePropertyDataFilterer.js.map +1 -1
  88. package/lib/components-react/propertygrid/dataproviders/filterers/DisplayValuePropertyDataFilterer.js +1 -1
  89. package/lib/components-react/propertygrid/dataproviders/filterers/DisplayValuePropertyDataFilterer.js.map +1 -1
  90. package/lib/components-react/propertygrid/dataproviders/filterers/LabelPropertyDataFilterer.js +1 -1
  91. package/lib/components-react/propertygrid/dataproviders/filterers/LabelPropertyDataFilterer.js.map +1 -1
  92. package/lib/components-react/propertygrid/dataproviders/filterers/PropertyCategoryLabelFilterer.js +1 -1
  93. package/lib/components-react/propertygrid/dataproviders/filterers/PropertyCategoryLabelFilterer.js.map +1 -1
  94. package/lib/components-react/propertygrid/dataproviders/filterers/PropertyDataFiltererBase.js +1 -3
  95. package/lib/components-react/propertygrid/dataproviders/filterers/PropertyDataFiltererBase.js.map +1 -1
  96. package/lib/components-react/propertygrid/internal/PropertyGridEventHandler.js +11 -10
  97. package/lib/components-react/propertygrid/internal/PropertyGridEventHandler.js.map +1 -1
  98. package/lib/components-react/propertygrid/internal/PropertyGridModel.js +3 -3
  99. package/lib/components-react/propertygrid/internal/PropertyGridModel.js.map +1 -1
  100. package/lib/components-react/propertygrid/internal/PropertyGridModelSource.js +4 -2
  101. package/lib/components-react/propertygrid/internal/PropertyGridModelSource.js.map +1 -1
  102. package/lib/components-react/propertygrid/internal/flat-items/MutableCategorizedArrayProperty.js +2 -0
  103. package/lib/components-react/propertygrid/internal/flat-items/MutableCategorizedArrayProperty.js.map +1 -1
  104. package/lib/components-react/propertygrid/internal/flat-items/MutableCategorizedStructProperty.js +2 -0
  105. package/lib/components-react/propertygrid/internal/flat-items/MutableCategorizedStructProperty.js.map +1 -1
  106. package/lib/components-react/propertygrid/internal/flat-items/MutableCustomGridCategory.js +6 -1
  107. package/lib/components-react/propertygrid/internal/flat-items/MutableCustomGridCategory.js.map +1 -1
  108. package/lib/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.js +10 -7
  109. package/lib/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.js.map +1 -1
  110. package/lib/components-react/propertygrid/internal/flat-items/MutableGridCategory.js +3 -0
  111. package/lib/components-react/propertygrid/internal/flat-items/MutableGridCategory.js.map +1 -1
  112. package/lib/components-react/propertygrid/internal/flat-properties/FlatNonPrimitivePropertyRenderer.js +8 -8
  113. package/lib/components-react/propertygrid/internal/flat-properties/FlatNonPrimitivePropertyRenderer.js.map +1 -1
  114. package/lib/components-react/toolbar/InternalToolbarComponent.js +4 -4
  115. package/lib/components-react/toolbar/InternalToolbarComponent.js.map +1 -1
  116. package/lib/components-react/toolbar/utilities/Direction.js +12 -12
  117. package/lib/components-react/toolbar/utilities/Direction.js.map +1 -1
  118. package/lib/components-react/tree/HighlightingEngine.js +3 -1
  119. package/lib/components-react/tree/HighlightingEngine.js.map +1 -1
  120. package/lib/components-react/tree/SimpleTreeDataProvider.js +1 -0
  121. package/lib/components-react/tree/SimpleTreeDataProvider.js.map +1 -1
  122. package/lib/components-react/tree/controlled/TreeEventDispatcher.js +5 -1
  123. package/lib/components-react/tree/controlled/TreeEventDispatcher.js.map +1 -1
  124. package/lib/components-react/tree/controlled/TreeEventHandler.js +10 -14
  125. package/lib/components-react/tree/controlled/TreeEventHandler.js.map +1 -1
  126. package/lib/components-react/tree/controlled/TreeModel.js +7 -9
  127. package/lib/components-react/tree/controlled/TreeModel.js.map +1 -1
  128. package/lib/components-react/tree/controlled/TreeModelSource.js +3 -2
  129. package/lib/components-react/tree/controlled/TreeModelSource.js.map +1 -1
  130. package/lib/components-react/tree/controlled/TreeNodeLoader.js +11 -3
  131. package/lib/components-react/tree/controlled/TreeNodeLoader.js.map +1 -1
  132. package/lib/components-react/tree/controlled/component/TreeRenderer.js +1 -4
  133. package/lib/components-react/tree/controlled/component/TreeRenderer.js.map +1 -1
  134. package/lib/components-react/tree/controlled/internal/SparseTree.js +7 -5
  135. package/lib/components-react/tree/controlled/internal/SparseTree.js.map +1 -1
  136. package/lib/components-react/tree/controlled/internal/TreeModelMutator.js +3 -0
  137. package/lib/components-react/tree/controlled/internal/TreeModelMutator.js.map +1 -1
  138. package/lib/components-react/tree/controlled/internal/TreeSelectionManager.js +56 -51
  139. package/lib/components-react/tree/controlled/internal/TreeSelectionManager.js.map +1 -1
  140. package/package.json +6 -7
@@ -5,12 +5,6 @@
5
5
  /** @packageDocumentation
6
6
  * @module PropertyEditors
7
7
  */
8
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
- };
13
- var _CustomNumberEditor_instances, _CustomNumberEditor_getPropertyValue;
14
8
  import "./CustomNumberEditor.scss";
15
9
  import classnames from "classnames";
16
10
  import * as React from "react";
@@ -25,45 +19,21 @@ import { PropertyEditorBase } from "./PropertyEditorManager.js";
25
19
  * @alpha
26
20
  */
27
21
  export class CustomNumberEditor extends React.PureComponent {
28
- constructor() {
29
- super(...arguments);
30
- _CustomNumberEditor_instances.add(this);
31
- this._isMounted = false;
32
- this._inputElement = React.createRef();
33
- this.state = {
34
- inputValue: "",
35
- };
36
- this._updateInputValue = (e) => {
37
- this._applyUpdatedValue(e.target.value);
38
- };
39
- this._onKeyPress = (e) => {
40
- if (e.key === Key.Escape.valueOf()) {
41
- const initialDisplayValue = (this._lastValidValue &&
42
- this._lastValidValue.displayValue) ??
43
- this._getInitialDisplayValue();
44
- if (initialDisplayValue !== this.state.inputValue) {
45
- e.preventDefault();
46
- e.stopPropagation();
47
- this._resetToLastValidDisplayValue();
48
- }
49
- else {
50
- if (this.props.onCancel)
51
- this.props.onCancel();
52
- }
53
- }
54
- if (e.key !== Key.Enter.valueOf()) {
55
- UiAdmin.messagePresenter.closeInputFieldMessage();
56
- }
57
- };
58
- this._onFocus = (e) => {
59
- e.target.select();
60
- };
61
- }
22
+ _isMounted = false;
23
+ _formatParams;
24
+ _inputElement = React.createRef();
25
+ _lastValidValue;
26
+ // Used to track the last user typed value.
27
+ _lastInputValue;
28
+ _lastValue;
29
+ state = {
30
+ inputValue: "",
31
+ };
62
32
  async getPropertyValue() {
63
33
  // This is called by the container to commit the value. Format the value.
64
34
  this._lastInputValue = undefined;
65
35
  this._lastValue = undefined;
66
- const value = await __classPrivateFieldGet(this, _CustomNumberEditor_instances, "m", _CustomNumberEditor_getPropertyValue).call(this);
36
+ const value = await this.#getPropertyValue();
67
37
  if (this.props.shouldCommitOnChange &&
68
38
  this._formatParams &&
69
39
  isPrimitiveValue(value) &&
@@ -75,6 +45,61 @@ export class CustomNumberEditor extends React.PureComponent {
75
45
  }
76
46
  return value;
77
47
  }
48
+ async #getPropertyValue() {
49
+ // This is called by the editor to get the current input value as a PropertyValue.
50
+ const record = this.props.propertyRecord;
51
+ let propertyValue;
52
+ if (record.isReadonly) {
53
+ return {
54
+ valueFormat: PropertyValueFormat.Primitive,
55
+ value: record.value.value,
56
+ displayValue: record.value.displayValue,
57
+ };
58
+ }
59
+ if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {
60
+ const parseResults = this._formatParams.parseFunction(this.state.inputValue);
61
+ if (!parseResults.parseError && undefined !== parseResults.value) {
62
+ const newDisplayValue = this._formatParams.formatFunction(parseResults.value);
63
+ propertyValue = {
64
+ valueFormat: PropertyValueFormat.Primitive,
65
+ value: parseResults.value,
66
+ displayValue: newDisplayValue,
67
+ };
68
+ this._lastValidValue = { ...propertyValue };
69
+ // make sure the text in the input item matches the latest formatted text... this could get out if the input string say 1.5 === the display string of 1'-6"
70
+ if (
71
+ // This should not happen in a getter, for now fix only if shouldCommitOnChange is true.
72
+ !this.props.shouldCommitOnChange &&
73
+ newDisplayValue !== this.state.inputValue) {
74
+ this.setState({ inputValue: newDisplayValue });
75
+ }
76
+ }
77
+ else {
78
+ if (this.htmlElement) {
79
+ UiAdmin.messagePresenter.displayInputFieldMessage(this.htmlElement, MessageSeverity.Error, parseResults.parseError
80
+ ? parseResults.parseError
81
+ : UiComponents.translate("errors.unable-to-parse-quantity"));
82
+ this.htmlElement.focus();
83
+ }
84
+ else {
85
+ UiAdmin.messagePresenter.displayMessage(MessageSeverity.Error, parseResults.parseError
86
+ ? parseResults.parseError
87
+ : UiComponents.translate("errors.unable-to-parse-quantity"));
88
+ }
89
+ const displayValue = record.value.displayValue && record.value.displayValue.length > 0
90
+ ? record.value.displayValue
91
+ : this._formatParams.formatFunction(record.value.value);
92
+ propertyValue = this._lastValidValue
93
+ ? { ...this._lastValidValue }
94
+ : {
95
+ valueFormat: PropertyValueFormat.Primitive,
96
+ value: record.value.value,
97
+ displayValue,
98
+ };
99
+ }
100
+ }
101
+ return propertyValue;
102
+ }
78
103
  get htmlElement() {
79
104
  return this._inputElement.current;
80
105
  }
@@ -105,7 +130,7 @@ export class CustomNumberEditor extends React.PureComponent {
105
130
  return;
106
131
  if (!this.props.propertyRecord)
107
132
  return;
108
- const newValue = await __classPrivateFieldGet(this, _CustomNumberEditor_instances, "m", _CustomNumberEditor_getPropertyValue).call(this);
133
+ const newValue = await this.#getPropertyValue();
109
134
  if (!newValue)
110
135
  return;
111
136
  this._lastInputValue = this.state.inputValue;
@@ -116,6 +141,9 @@ export class CustomNumberEditor extends React.PureComponent {
116
141
  });
117
142
  });
118
143
  }
144
+ _updateInputValue = (e) => {
145
+ this._applyUpdatedValue(e.target.value);
146
+ };
119
147
  componentDidMount() {
120
148
  this._isMounted = true;
121
149
  this.setStateFromProps();
@@ -216,6 +244,28 @@ export class CustomNumberEditor extends React.PureComponent {
216
244
  this._getInitialDisplayValue();
217
245
  this.setState({ inputValue: initialDisplayValue });
218
246
  }
247
+ _onKeyPress = (e) => {
248
+ if (e.key === Key.Escape.valueOf()) {
249
+ const initialDisplayValue = (this._lastValidValue &&
250
+ this._lastValidValue.displayValue) ??
251
+ this._getInitialDisplayValue();
252
+ if (initialDisplayValue !== this.state.inputValue) {
253
+ e.preventDefault();
254
+ e.stopPropagation();
255
+ this._resetToLastValidDisplayValue();
256
+ }
257
+ else {
258
+ if (this.props.onCancel)
259
+ this.props.onCancel();
260
+ }
261
+ }
262
+ if (e.key !== Key.Enter.valueOf()) {
263
+ UiAdmin.messagePresenter.closeInputFieldMessage();
264
+ }
265
+ };
266
+ _onFocus = (e) => {
267
+ e.target.select();
268
+ };
219
269
  render() {
220
270
  const { decoration } = this.props;
221
271
  const minSize = this.state.size ? this.state.size : 8;
@@ -247,61 +297,6 @@ export class CustomNumberEditor extends React.PureComponent {
247
297
  return (React.createElement(LockNumberEditor, { ...inputProps, ref: this._inputElement, id: this.props.propertyRecord?.property.name, icon: icon, decoration: decoration }));
248
298
  }
249
299
  }
250
- _CustomNumberEditor_instances = new WeakSet(), _CustomNumberEditor_getPropertyValue = async function _CustomNumberEditor_getPropertyValue() {
251
- // This is called by the editor to get the current input value as a PropertyValue.
252
- const record = this.props.propertyRecord;
253
- let propertyValue;
254
- if (record.isReadonly) {
255
- return {
256
- valueFormat: PropertyValueFormat.Primitive,
257
- value: record.value.value,
258
- displayValue: record.value.displayValue,
259
- };
260
- }
261
- if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {
262
- const parseResults = this._formatParams.parseFunction(this.state.inputValue);
263
- if (!parseResults.parseError && undefined !== parseResults.value) {
264
- const newDisplayValue = this._formatParams.formatFunction(parseResults.value);
265
- propertyValue = {
266
- valueFormat: PropertyValueFormat.Primitive,
267
- value: parseResults.value,
268
- displayValue: newDisplayValue,
269
- };
270
- this._lastValidValue = { ...propertyValue };
271
- // make sure the text in the input item matches the latest formatted text... this could get out if the input string say 1.5 === the display string of 1'-6"
272
- if (
273
- // This should not happen in a getter, for now fix only if shouldCommitOnChange is true.
274
- !this.props.shouldCommitOnChange &&
275
- newDisplayValue !== this.state.inputValue) {
276
- this.setState({ inputValue: newDisplayValue });
277
- }
278
- }
279
- else {
280
- if (this.htmlElement) {
281
- UiAdmin.messagePresenter.displayInputFieldMessage(this.htmlElement, MessageSeverity.Error, parseResults.parseError
282
- ? parseResults.parseError
283
- : UiComponents.translate("errors.unable-to-parse-quantity"));
284
- this.htmlElement.focus();
285
- }
286
- else {
287
- UiAdmin.messagePresenter.displayMessage(MessageSeverity.Error, parseResults.parseError
288
- ? parseResults.parseError
289
- : UiComponents.translate("errors.unable-to-parse-quantity"));
290
- }
291
- const displayValue = record.value.displayValue && record.value.displayValue.length > 0
292
- ? record.value.displayValue
293
- : this._formatParams.formatFunction(record.value.value);
294
- propertyValue = this._lastValidValue
295
- ? { ...this._lastValidValue }
296
- : {
297
- valueFormat: PropertyValueFormat.Primitive,
298
- value: record.value.value,
299
- displayValue,
300
- };
301
- }
302
- }
303
- return propertyValue;
304
- };
305
300
  /** Custom Property Editor registered for the "number" type name and the "number-custom" editor name.
306
301
  * It uses the [[CustomNumberEditor]] React component.
307
302
  * @alpha
@@ -1 +1 @@
1
- {"version":3,"file":"CustomNumberEditor.js","sourceRoot":"","sources":["../../../src/components-react/editors/CustomNumberEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;AAEH,OAAO,2BAA2B,CAAC;AACnC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAU7C,OAAO,EACL,eAAe,EACf,wBAAwB,EACxB,mBAAmB,EACnB,OAAO,GACR,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACn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AAgC,GAC5C,CACH,CAAC;IACJ,CAAC;IACD,OAAO,CACL,oBAAC,KAAK,OACA,IAAI,EACR,GAAG,EAAE,YAAY,iBACL,gCAAgC,EAC5C,IAAI,EAAC,OAAO,GACZ,CACH,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,SAAS,gBAAgB,CAAC,KAAqB;IAC7C,OAAO,KAAK,EAAE,WAAW,KAAK,mBAAmB,CAAC,SAAS,CAAC;AAC9D,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 \"./CustomNumberEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { Key } from \"ts-key-enum\";\nimport { Logger } from \"@itwin/core-bentley\";\nimport type {\n CustomFormattedNumberParams,\n IconEditorParams,\n InputEditorSizeParams,\n PrimitiveValue,\n PropertyEditorParams,\n PropertyRecord,\n PropertyValue,\n} from \"@itwin/appui-abstract\";\nimport {\n MessageSeverity,\n PropertyEditorParamTypes,\n PropertyValueFormat,\n UiAdmin,\n} from \"@itwin/appui-abstract\";\nimport { Icon, IconInput } from \"@itwin/core-react\";\nimport { Input, InputWithDecorations } from \"@itwin/itwinui-react\";\nimport { UiComponents } from \"../UiComponents.js\";\nimport type {\n InternalInputEditorProps,\n PropertyEditorProps,\n TypeEditor,\n} from \"./EditorContainer.js\";\nimport { PropertyEditorBase } from \"./PropertyEditorManager.js\";\nimport type { IconNodeEditorParams } from \"../../internal.js\";\n\ntype InputProps = React.ComponentPropsWithoutRef<typeof Input>;\n\ninterface CustomNumberEditorState {\n inputValue: string;\n size?: number;\n maxLength?: number;\n iconSpec?: React.ReactNode;\n}\n\n/** CustomNumberEditor is a React component that is a property editor for numbers that specify custom formatting and parsing functions.\n * @alpha\n */\nexport class CustomNumberEditor\n extends React.PureComponent<PropertyEditorProps, CustomNumberEditorState>\n implements TypeEditor\n{\n private _isMounted = false;\n private _formatParams: CustomFormattedNumberParams | undefined;\n private _inputElement = React.createRef<HTMLInputElement>();\n private _lastValidValue: PropertyValue | undefined;\n\n // Used to track the last user typed value.\n private _lastInputValue: string | undefined;\n private _lastValue: PropertyValue | undefined;\n\n public override readonly state: Readonly<CustomNumberEditorState> = {\n inputValue: \"\",\n };\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n // This is called by the container to commit the value. Format the value.\n this._lastInputValue = undefined;\n this._lastValue = undefined;\n\n const value = await this.#getPropertyValue();\n\n if (\n this.props.shouldCommitOnChange &&\n this._formatParams &&\n isPrimitiveValue(value) &&\n typeof value.value === \"number\"\n ) {\n const newDisplayValue = this._formatParams.formatFunction(value.value);\n this.setState({\n inputValue: newDisplayValue,\n });\n }\n return value;\n }\n\n async #getPropertyValue(): Promise<PropertyValue | undefined> {\n // This is called by the editor to get the current input value as a PropertyValue.\n const record = this.props.propertyRecord as PropertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n if (record.isReadonly) {\n return {\n valueFormat: PropertyValueFormat.Primitive,\n value: (record.value as PrimitiveValue).value,\n displayValue: (record.value as PrimitiveValue).displayValue,\n };\n }\n\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n const parseResults = (\n this._formatParams as CustomFormattedNumberParams\n ).parseFunction(this.state.inputValue);\n if (!parseResults.parseError && undefined !== parseResults.value) {\n const newDisplayValue = (\n this._formatParams as CustomFormattedNumberParams\n ).formatFunction(parseResults.value as number);\n propertyValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: parseResults.value,\n displayValue: newDisplayValue,\n };\n this._lastValidValue = { ...propertyValue };\n // make sure the text in the input item matches the latest formatted text... this could get out if the input string say 1.5 === the display string of 1'-6\"\n if (\n // This should not happen in a getter, for now fix only if shouldCommitOnChange is true.\n !this.props.shouldCommitOnChange &&\n newDisplayValue !== this.state.inputValue\n ) {\n this.setState({ inputValue: newDisplayValue });\n }\n } else {\n if (this.htmlElement) {\n UiAdmin.messagePresenter.displayInputFieldMessage(\n this.htmlElement,\n MessageSeverity.Error,\n parseResults.parseError\n ? parseResults.parseError\n : UiComponents.translate(\"errors.unable-to-parse-quantity\")\n );\n this.htmlElement.focus();\n } else {\n UiAdmin.messagePresenter.displayMessage(\n MessageSeverity.Error,\n parseResults.parseError\n ? parseResults.parseError\n : UiComponents.translate(\"errors.unable-to-parse-quantity\")\n );\n }\n\n const displayValue =\n record.value.displayValue && record.value.displayValue.length > 0\n ? record.value.displayValue\n : (\n this._formatParams as CustomFormattedNumberParams\n ).formatFunction(record.value.value as number);\n propertyValue = this._lastValidValue\n ? { ...this._lastValidValue }\n : {\n valueFormat: PropertyValueFormat.Primitive,\n value: record.value.value,\n displayValue,\n };\n }\n }\n\n return propertyValue;\n }\n\n public get htmlElement(): HTMLElement | null {\n return this._inputElement.current;\n }\n\n public get hasFocus(): boolean {\n return document.activeElement === this._inputElement.current;\n }\n\n private shouldSetFocus(): boolean {\n if (!this.props.setFocus) return false;\n\n const record = this.props.propertyRecord as PropertyRecord;\n const disabled = record && !record.isDisabled ? false : true;\n const readonly = record && !record.isReadonly ? false : true;\n\n return !disabled && !readonly;\n }\n\n private _applyUpdatedValue(userInput: string) {\n const record = this.props.propertyRecord as PropertyRecord;\n const readonly = record && !record.isReadonly ? false : true;\n const disabled = record && !record.isDisabled ? false : true;\n\n if (readonly || disabled) return;\n\n if (this._isMounted)\n this.setState(\n {\n inputValue: userInput,\n },\n async () => {\n if (!this.props.shouldCommitOnChange) return;\n if (!this.props.onCommit) return;\n if (!this.props.propertyRecord) return;\n\n const newValue = await this.#getPropertyValue();\n if (!newValue) return;\n\n this._lastInputValue = this.state.inputValue;\n this._lastValue = newValue;\n this.props.onCommit({\n propertyRecord: this.props.propertyRecord,\n newValue,\n });\n }\n );\n }\n\n private _updateInputValue = (e: React.ChangeEvent<HTMLInputElement>) => {\n this._applyUpdatedValue(e.target.value);\n };\n\n public override componentDidMount() {\n this._isMounted = true;\n this.setStateFromProps();\n }\n\n public override componentWillUnmount() {\n this._isMounted = false;\n }\n\n public override componentDidUpdate(prevProps: PropertyEditorProps) {\n if (this.props.propertyRecord !== prevProps.propertyRecord) {\n this.setStateFromProps();\n }\n }\n\n private _getInitialDisplayValue(): string {\n const record = this.props.propertyRecord;\n let initialDisplayValue = \"\";\n let numberValue = 0;\n if (record) {\n if (record.value.valueFormat === PropertyValueFormat.Primitive) {\n const primitiveValue = record.value;\n numberValue =\n undefined !== primitiveValue.value\n ? (primitiveValue.value as number)\n : 0;\n if (primitiveValue.displayValue)\n initialDisplayValue = primitiveValue.displayValue;\n else\n initialDisplayValue = (\n this._formatParams as CustomFormattedNumberParams\n ).formatFunction(numberValue);\n }\n }\n\n return initialDisplayValue;\n }\n\n private setStateFromProps() {\n if (!this._isMounted) return;\n\n const record = this.props.propertyRecord;\n if (!record || !record.property) {\n Logger.logError(\n UiComponents.loggerCategory(\"CustomNumberEditor\"),\n \"PropertyRecord must be defined to use CustomNumberPropertyEditor\"\n );\n return;\n }\n if (\n record.property &&\n record.property.editor &&\n record.property.editor.params\n ) {\n this._formatParams = record.property.editor.params.find(\n (param: PropertyEditorParams) =>\n param.type ===\n PropertyEditorParamTypes.CustomFormattedNumber.valueOf()\n ) as CustomFormattedNumberParams;\n }\n\n if (!this._formatParams) {\n Logger.logError(\n UiComponents.loggerCategory(\"CustomNumberEditor\"),\n `CustomFormattedNumberParams must be defined for property ${record.property.name}`\n );\n return;\n }\n\n const initialDisplayValue = this._getInitialDisplayValue();\n this._lastValidValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: (record.value as PrimitiveValue).value,\n displayValue: initialDisplayValue,\n };\n let size: number | undefined;\n let maxLength: number | undefined;\n let iconSpec: React.ReactNode | undefined;\n\n if (\n record.property &&\n record.property.editor &&\n record.property.editor.params\n ) {\n const editorSizeParams = record.property.editor.params.find(\n (param: PropertyEditorParams) =>\n param.type === PropertyEditorParamTypes.InputEditorSize.valueOf()\n ) as InputEditorSizeParams;\n if (editorSizeParams) {\n if (editorSizeParams.size) size = editorSizeParams.size;\n if (editorSizeParams.maxLength) maxLength = editorSizeParams.maxLength;\n }\n\n const iconParams = record.property.editor.params.find(\n (param: PropertyEditorParams) =>\n param.type === PropertyEditorParamTypes.Icon.valueOf()\n ) as IconEditorParams;\n if (iconParams) {\n iconSpec = iconParams.definition.iconSpec;\n }\n\n const iconNodeParam = record.property.editor.params.find(\n (param): param is IconNodeEditorParams =>\n param.type ===\n (\"appui-icon-node\" satisfies IconNodeEditorParams[\"type\"])\n );\n if (iconNodeParam) {\n iconSpec = iconNodeParam.icon;\n }\n }\n\n let inputValue = initialDisplayValue;\n if (\n this.props.shouldCommitOnChange &&\n this._lastInputValue &&\n isPrimitiveValue(this._lastValue) &&\n isPrimitiveValue(this.props.propertyRecord?.value) &&\n this._lastValue.value === this.props.propertyRecord.value.value\n ) {\n // If the value matches the user-entered value - keep it unformatted.\n inputValue = this._lastInputValue;\n }\n\n this.setState({\n inputValue,\n size,\n maxLength,\n iconSpec,\n });\n }\n\n private _resetToLastValidDisplayValue() {\n const initialDisplayValue =\n (this._lastValidValue &&\n (this._lastValidValue as PrimitiveValue).displayValue) ??\n this._getInitialDisplayValue();\n this.setState({ inputValue: initialDisplayValue });\n }\n\n private _onKeyPress = (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (e.key === Key.Escape.valueOf()) {\n const initialDisplayValue =\n (this._lastValidValue &&\n (this._lastValidValue as PrimitiveValue).displayValue) ??\n this._getInitialDisplayValue();\n if (initialDisplayValue !== this.state.inputValue) {\n e.preventDefault();\n e.stopPropagation();\n this._resetToLastValidDisplayValue();\n } else {\n if (this.props.onCancel) this.props.onCancel();\n }\n }\n\n if (e.key !== Key.Enter.valueOf()) {\n UiAdmin.messagePresenter.closeInputFieldMessage();\n }\n };\n\n private _onFocus = (e: React.FocusEvent<HTMLInputElement>) => {\n e.target.select();\n };\n\n public override render(): React.ReactNode {\n const { decoration } = this.props as InternalInputEditorProps;\n const minSize = this.state.size ? this.state.size : 8;\n const minWidthStyle: React.CSSProperties = {\n minWidth: `${minSize * 0.75}em`,\n };\n const record = this.props.propertyRecord as PropertyRecord;\n if (!record || !this._formatParams) return null;\n\n const readOnly = !record.isReadonly ? false : true;\n const disabled = !record.isDisabled ? false : true;\n\n const className = classnames(\n \"components-cell-editor\",\n \"components-customnumber-editor\",\n this.props.className\n );\n\n const inputProps: Omit<InputProps, \"size\"> = {\n className,\n style: this.props.style ? this.props.style : minWidthStyle,\n readOnly,\n disabled,\n maxLength: this.state.maxLength,\n value: this.state.inputValue,\n onChange: this._updateInputValue,\n onBlur: this.props.onBlur,\n onFocus: this._onFocus,\n autoFocus: this.shouldSetFocus(),\n onKeyDown: this._onKeyPress,\n };\n\n const icon = this.state.iconSpec ? (\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n <Icon iconSpec={this.state.iconSpec} />\n ) : undefined;\n\n return (\n <LockNumberEditor\n {...inputProps}\n ref={this._inputElement}\n id={this.props.propertyRecord?.property.name}\n icon={icon}\n decoration={decoration}\n />\n );\n }\n}\n\n/** Custom Property Editor registered for the \"number\" type name and the \"number-custom\" editor name.\n * It uses the [[CustomNumberEditor]] React component.\n * @alpha\n */\nexport class CustomNumberPropertyEditor extends PropertyEditorBase {\n public get reactNode(): React.ReactNode {\n return <CustomNumberEditor />;\n }\n public override get containerHandlesEscape(): boolean {\n return false;\n }\n}\n\ninterface LockNumberEditorProps extends InputProps {\n icon?: React.ReactNode;\n decoration?: React.ReactNode;\n}\n\nconst LockNumberEditor = React.forwardRef<\n HTMLInputElement,\n LockNumberEditorProps\n>(function LockNumberEditor(props, forwardedRef) {\n const { icon, decoration, ...rest } = props;\n if (decoration) {\n return (\n <InputWithDecorations size=\"small\">\n {icon && (\n <InputWithDecorations.Icon size=\"small\">\n {icon}\n </InputWithDecorations.Icon>\n )}\n <InputWithDecorations.Input\n {...rest}\n ref={forwardedRef}\n data-testid=\"components-customnumber-editor\"\n size=\"small\"\n />\n {decoration}\n </InputWithDecorations>\n );\n }\n\n if (icon) {\n return (\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n <IconInput\n {...rest}\n ref={forwardedRef}\n icon={icon}\n data-testid=\"components-customnumber-editor\"\n />\n );\n }\n return (\n <Input\n {...rest}\n ref={forwardedRef}\n data-testid=\"components-customnumber-editor\"\n size=\"small\"\n />\n );\n});\n\nfunction isPrimitiveValue(value?: PropertyValue): value is PrimitiveValue {\n return value?.valueFormat === PropertyValueFormat.Primitive;\n}\n"]}
1
+ {"version":3,"file":"CustomNumberEditor.js","sourceRoot":"","sources":["../../../src/components-react/editors/CustomNumberEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,2BAA2B,CAAC;AACnC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAU7C,OAAO,EACL,eAAe,EACf,wBAAwB,EACxB,mBAAmB,EACnB,OAAO,GACR,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAMlD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAYhE;;GAEG;AACH,MAAM,OAAO,kBACX,SAAQ,KAAK,CAAC,aAA2D;IAGjE,UAAU,GAAG,KAAK,CAAC;IACnB,aAAa,CAA0C;IACvD,aAAa,GAAG,KAAK,CAAC,SAAS,EAAoB,CAAC;IACpD,eAAe,CAA4B;IAEnD,2CAA2C;IACnC,eAAe,CAAqB;IACpC,UAAU,CAA4B;IAErB,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cesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module PropertyEditors\n */\n\nimport \"./CustomNumberEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { Key } from \"ts-key-enum\";\nimport { Logger } from \"@itwin/core-bentley\";\nimport type {\n CustomFormattedNumberParams,\n IconEditorParams,\n InputEditorSizeParams,\n PrimitiveValue,\n PropertyEditorParams,\n PropertyRecord,\n PropertyValue,\n} from \"@itwin/appui-abstract\";\nimport {\n MessageSeverity,\n PropertyEditorParamTypes,\n PropertyValueFormat,\n UiAdmin,\n} from \"@itwin/appui-abstract\";\nimport { Icon, IconInput } from \"@itwin/core-react\";\nimport { Input, InputWithDecorations } from \"@itwin/itwinui-react\";\nimport { UiComponents } from \"../UiComponents.js\";\nimport type {\n InternalInputEditorProps,\n PropertyEditorProps,\n TypeEditor,\n} from \"./EditorContainer.js\";\nimport { PropertyEditorBase } from \"./PropertyEditorManager.js\";\nimport type { IconNodeEditorParams } from \"../../internal.js\";\n\ntype InputProps = React.ComponentPropsWithoutRef<typeof Input>;\n\ninterface CustomNumberEditorState {\n inputValue: string;\n size?: number;\n maxLength?: number;\n iconSpec?: React.ReactNode;\n}\n\n/** CustomNumberEditor is a React component that is a property editor for numbers that specify custom formatting and parsing functions.\n * @alpha\n */\nexport class CustomNumberEditor\n extends React.PureComponent<PropertyEditorProps, CustomNumberEditorState>\n implements TypeEditor\n{\n private _isMounted = false;\n private _formatParams: CustomFormattedNumberParams | undefined;\n private _inputElement = React.createRef<HTMLInputElement>();\n private _lastValidValue: PropertyValue | undefined;\n\n // Used to track the last user typed value.\n private _lastInputValue: string | undefined;\n private _lastValue: PropertyValue | undefined;\n\n public override readonly state: Readonly<CustomNumberEditorState> = {\n inputValue: \"\",\n };\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n // This is called by the container to commit the value. Format the value.\n this._lastInputValue = undefined;\n this._lastValue = undefined;\n\n const value = await this.#getPropertyValue();\n\n if (\n this.props.shouldCommitOnChange &&\n this._formatParams &&\n isPrimitiveValue(value) &&\n typeof value.value === \"number\"\n ) {\n const newDisplayValue = this._formatParams.formatFunction(value.value);\n this.setState({\n inputValue: newDisplayValue,\n });\n }\n return value;\n }\n\n async #getPropertyValue(): Promise<PropertyValue | undefined> {\n // This is called by the editor to get the current input value as a PropertyValue.\n const record = this.props.propertyRecord as PropertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n if (record.isReadonly) {\n return {\n valueFormat: PropertyValueFormat.Primitive,\n value: (record.value as PrimitiveValue).value,\n displayValue: (record.value as PrimitiveValue).displayValue,\n };\n }\n\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n const parseResults = (\n this._formatParams as CustomFormattedNumberParams\n ).parseFunction(this.state.inputValue);\n if (!parseResults.parseError && undefined !== parseResults.value) {\n const newDisplayValue = (\n this._formatParams as CustomFormattedNumberParams\n ).formatFunction(parseResults.value as number);\n propertyValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: parseResults.value,\n displayValue: newDisplayValue,\n };\n this._lastValidValue = { ...propertyValue };\n // make sure the text in the input item matches the latest formatted text... this could get out if the input string say 1.5 === the display string of 1'-6\"\n if (\n // This should not happen in a getter, for now fix only if shouldCommitOnChange is true.\n !this.props.shouldCommitOnChange &&\n newDisplayValue !== this.state.inputValue\n ) {\n this.setState({ inputValue: newDisplayValue });\n }\n } else {\n if (this.htmlElement) {\n UiAdmin.messagePresenter.displayInputFieldMessage(\n this.htmlElement,\n MessageSeverity.Error,\n parseResults.parseError\n ? parseResults.parseError\n : UiComponents.translate(\"errors.unable-to-parse-quantity\")\n );\n this.htmlElement.focus();\n } else {\n UiAdmin.messagePresenter.displayMessage(\n MessageSeverity.Error,\n parseResults.parseError\n ? parseResults.parseError\n : UiComponents.translate(\"errors.unable-to-parse-quantity\")\n );\n }\n\n const displayValue =\n record.value.displayValue && record.value.displayValue.length > 0\n ? record.value.displayValue\n : (\n this._formatParams as CustomFormattedNumberParams\n ).formatFunction(record.value.value as number);\n propertyValue = this._lastValidValue\n ? { ...this._lastValidValue }\n : {\n valueFormat: PropertyValueFormat.Primitive,\n value: record.value.value,\n displayValue,\n };\n }\n }\n\n return propertyValue;\n }\n\n public get htmlElement(): HTMLElement | null {\n return this._inputElement.current;\n }\n\n public get hasFocus(): boolean {\n return document.activeElement === this._inputElement.current;\n }\n\n private shouldSetFocus(): boolean {\n if (!this.props.setFocus) return false;\n\n const record = this.props.propertyRecord as PropertyRecord;\n const disabled = record && !record.isDisabled ? false : true;\n const readonly = record && !record.isReadonly ? false : true;\n\n return !disabled && !readonly;\n }\n\n private _applyUpdatedValue(userInput: string) {\n const record = this.props.propertyRecord as PropertyRecord;\n const readonly = record && !record.isReadonly ? false : true;\n const disabled = record && !record.isDisabled ? false : true;\n\n if (readonly || disabled) return;\n\n if (this._isMounted)\n this.setState(\n {\n inputValue: userInput,\n },\n async () => {\n if (!this.props.shouldCommitOnChange) return;\n if (!this.props.onCommit) return;\n if (!this.props.propertyRecord) return;\n\n const newValue = await this.#getPropertyValue();\n if (!newValue) return;\n\n this._lastInputValue = this.state.inputValue;\n this._lastValue = newValue;\n this.props.onCommit({\n propertyRecord: this.props.propertyRecord,\n newValue,\n });\n }\n );\n }\n\n private _updateInputValue = (e: React.ChangeEvent<HTMLInputElement>) => {\n this._applyUpdatedValue(e.target.value);\n };\n\n public override componentDidMount() {\n this._isMounted = true;\n this.setStateFromProps();\n }\n\n public override componentWillUnmount() {\n this._isMounted = false;\n }\n\n public override componentDidUpdate(prevProps: PropertyEditorProps) {\n if (this.props.propertyRecord !== prevProps.propertyRecord) {\n this.setStateFromProps();\n }\n }\n\n private _getInitialDisplayValue(): string {\n const record = this.props.propertyRecord;\n let initialDisplayValue = \"\";\n let numberValue = 0;\n if (record) {\n if (record.value.valueFormat === PropertyValueFormat.Primitive) {\n const primitiveValue = record.value;\n numberValue =\n undefined !== primitiveValue.value\n ? (primitiveValue.value as number)\n : 0;\n if (primitiveValue.displayValue)\n initialDisplayValue = primitiveValue.displayValue;\n else\n initialDisplayValue = (\n this._formatParams as CustomFormattedNumberParams\n ).formatFunction(numberValue);\n }\n }\n\n return initialDisplayValue;\n }\n\n private setStateFromProps() {\n if (!this._isMounted) return;\n\n const record = this.props.propertyRecord;\n if (!record || !record.property) {\n Logger.logError(\n UiComponents.loggerCategory(\"CustomNumberEditor\"),\n \"PropertyRecord must be defined to use CustomNumberPropertyEditor\"\n );\n return;\n }\n if (\n record.property &&\n record.property.editor &&\n record.property.editor.params\n ) {\n this._formatParams = record.property.editor.params.find(\n (param: PropertyEditorParams) =>\n param.type ===\n PropertyEditorParamTypes.CustomFormattedNumber.valueOf()\n ) as CustomFormattedNumberParams;\n }\n\n if (!this._formatParams) {\n Logger.logError(\n UiComponents.loggerCategory(\"CustomNumberEditor\"),\n `CustomFormattedNumberParams must be defined for property ${record.property.name}`\n );\n return;\n }\n\n const initialDisplayValue = this._getInitialDisplayValue();\n this._lastValidValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: (record.value as PrimitiveValue).value,\n displayValue: initialDisplayValue,\n };\n let size: number | undefined;\n let maxLength: number | undefined;\n let iconSpec: React.ReactNode | undefined;\n\n if (\n record.property &&\n record.property.editor &&\n record.property.editor.params\n ) {\n const editorSizeParams = record.property.editor.params.find(\n (param: PropertyEditorParams) =>\n param.type === PropertyEditorParamTypes.InputEditorSize.valueOf()\n ) as InputEditorSizeParams;\n if (editorSizeParams) {\n if (editorSizeParams.size) size = editorSizeParams.size;\n if (editorSizeParams.maxLength) maxLength = editorSizeParams.maxLength;\n }\n\n const iconParams = record.property.editor.params.find(\n (param: PropertyEditorParams) =>\n param.type === PropertyEditorParamTypes.Icon.valueOf()\n ) as IconEditorParams;\n if (iconParams) {\n iconSpec = iconParams.definition.iconSpec;\n }\n\n const iconNodeParam = record.property.editor.params.find(\n (param): param is IconNodeEditorParams =>\n param.type ===\n (\"appui-icon-node\" satisfies IconNodeEditorParams[\"type\"])\n );\n if (iconNodeParam) {\n iconSpec = iconNodeParam.icon;\n }\n }\n\n let inputValue = initialDisplayValue;\n if (\n this.props.shouldCommitOnChange &&\n this._lastInputValue &&\n isPrimitiveValue(this._lastValue) &&\n isPrimitiveValue(this.props.propertyRecord?.value) &&\n this._lastValue.value === this.props.propertyRecord.value.value\n ) {\n // If the value matches the user-entered value - keep it unformatted.\n inputValue = this._lastInputValue;\n }\n\n this.setState({\n inputValue,\n size,\n maxLength,\n iconSpec,\n });\n }\n\n private _resetToLastValidDisplayValue() {\n const initialDisplayValue =\n (this._lastValidValue &&\n (this._lastValidValue as PrimitiveValue).displayValue) ??\n this._getInitialDisplayValue();\n this.setState({ inputValue: initialDisplayValue });\n }\n\n private _onKeyPress = (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (e.key === Key.Escape.valueOf()) {\n const initialDisplayValue =\n (this._lastValidValue &&\n (this._lastValidValue as PrimitiveValue).displayValue) ??\n this._getInitialDisplayValue();\n if (initialDisplayValue !== this.state.inputValue) {\n e.preventDefault();\n e.stopPropagation();\n this._resetToLastValidDisplayValue();\n } else {\n if (this.props.onCancel) this.props.onCancel();\n }\n }\n\n if (e.key !== Key.Enter.valueOf()) {\n UiAdmin.messagePresenter.closeInputFieldMessage();\n }\n };\n\n private _onFocus = (e: React.FocusEvent<HTMLInputElement>) => {\n e.target.select();\n };\n\n public override render(): React.ReactNode {\n const { decoration } = this.props as InternalInputEditorProps;\n const minSize = this.state.size ? this.state.size : 8;\n const minWidthStyle: React.CSSProperties = {\n minWidth: `${minSize * 0.75}em`,\n };\n const record = this.props.propertyRecord as PropertyRecord;\n if (!record || !this._formatParams) return null;\n\n const readOnly = !record.isReadonly ? false : true;\n const disabled = !record.isDisabled ? false : true;\n\n const className = classnames(\n \"components-cell-editor\",\n \"components-customnumber-editor\",\n this.props.className\n );\n\n const inputProps: Omit<InputProps, \"size\"> = {\n className,\n style: this.props.style ? this.props.style : minWidthStyle,\n readOnly,\n disabled,\n maxLength: this.state.maxLength,\n value: this.state.inputValue,\n onChange: this._updateInputValue,\n onBlur: this.props.onBlur,\n onFocus: this._onFocus,\n autoFocus: this.shouldSetFocus(),\n onKeyDown: this._onKeyPress,\n };\n\n const icon = this.state.iconSpec ? (\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n <Icon iconSpec={this.state.iconSpec} />\n ) : undefined;\n\n return (\n <LockNumberEditor\n {...inputProps}\n ref={this._inputElement}\n id={this.props.propertyRecord?.property.name}\n icon={icon}\n decoration={decoration}\n />\n );\n }\n}\n\n/** Custom Property Editor registered for the \"number\" type name and the \"number-custom\" editor name.\n * It uses the [[CustomNumberEditor]] React component.\n * @alpha\n */\nexport class CustomNumberPropertyEditor extends PropertyEditorBase {\n public get reactNode(): React.ReactNode {\n return <CustomNumberEditor />;\n }\n public override get containerHandlesEscape(): boolean {\n return false;\n }\n}\n\ninterface LockNumberEditorProps extends InputProps {\n icon?: React.ReactNode;\n decoration?: React.ReactNode;\n}\n\nconst LockNumberEditor = React.forwardRef<\n HTMLInputElement,\n LockNumberEditorProps\n>(function LockNumberEditor(props, forwardedRef) {\n const { icon, decoration, ...rest } = props;\n if (decoration) {\n return (\n <InputWithDecorations size=\"small\">\n {icon && (\n <InputWithDecorations.Icon size=\"small\">\n {icon}\n </InputWithDecorations.Icon>\n )}\n <InputWithDecorations.Input\n {...rest}\n ref={forwardedRef}\n data-testid=\"components-customnumber-editor\"\n size=\"small\"\n />\n {decoration}\n </InputWithDecorations>\n );\n }\n\n if (icon) {\n return (\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n <IconInput\n {...rest}\n ref={forwardedRef}\n icon={icon}\n data-testid=\"components-customnumber-editor\"\n />\n );\n }\n return (\n <Input\n {...rest}\n ref={forwardedRef}\n data-testid=\"components-customnumber-editor\"\n size=\"small\"\n />\n );\n});\n\nfunction isPrimitiveValue(value?: PropertyValue): value is PrimitiveValue {\n return value?.valueFormat === PropertyValueFormat.Primitive;\n}\n"]}
@@ -21,69 +21,13 @@ import { adjustDateToTimezone } from "../common/DateUtils.js";
21
21
  * @internal
22
22
  */
23
23
  export class DateTimeEditor extends React.PureComponent {
24
- constructor() {
25
- super(...arguments);
26
- this._isMounted = false;
27
- this._enterKey = false;
28
- this._divElement = React.createRef();
29
- this.state = {
30
- value: new Date(),
31
- editInUtc: false,
32
- };
33
- this._handleChange = (newValue) => {
34
- if (this._isMounted && this.state.typeConverter) {
35
- if (this.state.editInUtc) {
36
- newValue = adjustDateToTimezone(newValue, newValue.getTimezoneOffset() * -1);
37
- }
38
- void this.processDateChange(this.state.typeConverter, newValue);
39
- }
40
- };
41
- this._handleTimeChange = (time) => {
42
- // Combine new time into selected Date
43
- if (this.state.editInUtc) {
44
- const newWorkingDate = adjustDateToTimezone(this.state.value, 0);
45
- newWorkingDate.setUTCHours(time.hours, time.minutes, time.seconds);
46
- this._handleChange(newWorkingDate);
47
- }
48
- else {
49
- const newWorkingDate = new Date(this.state.value.getTime());
50
- newWorkingDate.setHours(time.hours, time.minutes, time.seconds);
51
- this._handleChange(newWorkingDate);
52
- }
53
- };
54
- this._handleEnter = async () => {
55
- this._enterKey = true;
56
- await this._handleCommit();
57
- };
58
- this._handleClose = async () => {
59
- if (this._enterKey) {
60
- this._enterKey = false;
61
- }
62
- else {
63
- if (this.props.onCancel)
64
- this.props.onCancel();
65
- }
66
- };
67
- this._handleOk = async (_event) => {
68
- await this._handleCommit();
69
- };
70
- this._handleCancel = (_event) => {
71
- if (this.props.onCancel) {
72
- this.props.onCancel();
73
- }
74
- };
75
- this._handleCommit = async () => {
76
- if (this.props.propertyRecord && this.props.onCommit) {
77
- const propertyValue = await this.getPropertyValue();
78
- if (propertyValue !== undefined) {
79
- this.props.onCommit({
80
- propertyRecord: this.props.propertyRecord,
81
- newValue: propertyValue,
82
- });
83
- }
84
- }
85
- };
86
- }
24
+ _isMounted = false;
25
+ _enterKey = false;
26
+ _divElement = React.createRef();
27
+ state = {
28
+ value: new Date(),
29
+ editInUtc: false,
30
+ };
87
31
  async getPropertyValue() {
88
32
  const record = this.props.propertyRecord;
89
33
  let propertyValue;
@@ -114,6 +58,27 @@ export class DateTimeEditor extends React.PureComponent {
114
58
  });
115
59
  }
116
60
  }
61
+ _handleChange = (newValue) => {
62
+ if (this._isMounted && this.state.typeConverter) {
63
+ if (this.state.editInUtc) {
64
+ newValue = adjustDateToTimezone(newValue, newValue.getTimezoneOffset() * -1);
65
+ }
66
+ void this.processDateChange(this.state.typeConverter, newValue);
67
+ }
68
+ };
69
+ _handleTimeChange = (time) => {
70
+ // Combine new time into selected Date
71
+ if (this.state.editInUtc) {
72
+ const newWorkingDate = adjustDateToTimezone(this.state.value, 0);
73
+ newWorkingDate.setUTCHours(time.hours, time.minutes, time.seconds);
74
+ this._handleChange(newWorkingDate);
75
+ }
76
+ else {
77
+ const newWorkingDate = new Date(this.state.value.getTime());
78
+ newWorkingDate.setHours(time.hours, time.minutes, time.seconds);
79
+ this._handleChange(newWorkingDate);
80
+ }
81
+ };
117
82
  componentDidMount() {
118
83
  this._isMounted = true;
119
84
  void this.setStateFromProps();
@@ -200,6 +165,38 @@ export class DateTimeEditor extends React.PureComponent {
200
165
  editInUtc,
201
166
  });
202
167
  }
168
+ _handleEnter = async () => {
169
+ this._enterKey = true;
170
+ await this._handleCommit();
171
+ };
172
+ _handleClose = async () => {
173
+ if (this._enterKey) {
174
+ this._enterKey = false;
175
+ }
176
+ else {
177
+ if (this.props.onCancel)
178
+ this.props.onCancel();
179
+ }
180
+ };
181
+ _handleOk = async (_event) => {
182
+ await this._handleCommit();
183
+ };
184
+ _handleCancel = (_event) => {
185
+ if (this.props.onCancel) {
186
+ this.props.onCancel();
187
+ }
188
+ };
189
+ _handleCommit = async () => {
190
+ if (this.props.propertyRecord && this.props.onCommit) {
191
+ const propertyValue = await this.getPropertyValue();
192
+ if (propertyValue !== undefined) {
193
+ this.props.onCommit({
194
+ propertyRecord: this.props.propertyRecord,
195
+ newValue: propertyValue,
196
+ });
197
+ }
198
+ }
199
+ };
203
200
  render() {
204
201
  const date = this.state.editInUtc
205
202
  ? adjustDateToTimezone(this.state.value, 0)
@@ -1 +1 @@
1
- {"version":3,"file":"DateTimeEditor.js","sourceRoot":"","sources":["../../../src/components-react/editors/DateTimeEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,uBAAuB,CAAC;AAC/B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,WAAW,GACZ,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EACL,WAAW,EACX,YAAY,EACZ,oBAAoB,GACrB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAEvD,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAC;AACnF,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAgB9D;;GAEG;AACH,MAAM,OAAO,cACX,SAAQ,KAAK,CAAC,aAAuD;IADvE;;QAIU,eAAU,GAAG,KAAK,CAAC;QACnB,cAAS,GAAG,KAAK,CAAC;QAClB,gBAAW,GAAG,KAAK,CAAC,SAAS,EAAkB,CAAC;QAE/B,UAAK,GAAkC;YAC9D,KAAK,EAAE,IAAI,IAAI,EAAE;YACjB,SAAS,EAAE,KAAK;SACjB,CAAC;QA4CM,kBAAa,GAAG,CAAC,QAAc,EAAQ,EAAE;YAC/C,IAAI,IAAI,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Ac,EAAE,UAAU;gBAE/C,oBAAC,YAAY;oBACX;wBACE,6BACE,SAAS,EAAC,6CAA6C,iBAC3C,6CAA6C;4BAEzD,oBAAC,UAAU,CAAC,uDAAuD;gCACjE,QAAQ,EAAE,IAAI,EACd,YAAY,EAAE,IAAI,CAAC,aAAa,EAChC,gBAAgB,EAAE,KAAK,GACvB;4BACD,IAAI,CAAC,KAAK,CAAC,WAAW,IAAI,CACzB,6BAAK,SAAS,EAAC,gBAAgB;gCAC7B,oBAAC,IAAI,IAAC,OAAO,EAAC,MAAM,EAAC,SAAS,EAAC,YAAY,IACxC,MAAM,CACF;gCACP,oBAAC,SAAS,IACR,IAAI,EAAE,QAAQ,EACd,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,EACnC,YAAY,EAAE,IAAI,CAAC,iBAAiB,GACpC,CACE,CACP,CACG,CACL;oBACH,oBAAC,oBAAoB,IACnB,IAAI,EAAE,IAAI,CAAC,SAAS,EACpB,QAAQ,EAAE,IAAI,CAAC,aAAa,GAC5B,CACW,CACH,CACV,CACP,CAAC;IACJ,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,2BAA4B,SAAQ,kBAAkB;IACjE,IAAW,SAAS;QAClB,OAAO,oBAAC,cAAc,IAAC,QAAQ,EAAE,KAAK,GAAI,CAAC;IAC7C,CAAC;IACD,IAAoB,mBAAmB;QACrC,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,sBAAuB,SAAQ,kBAAkB;IAC5D,IAAW,SAAS;QAClB,OAAO,oBAAC,cAAc,IAAC,QAAQ,EAAE,IAAI,GAAI,CAAC;IAC5C,CAAC;IACD,IAAoB,mBAAmB;QACrC,OAAO,KAAK,CAAC;IACf,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module PropertyEditors\n */\n\nimport \"./DateTimeEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type { PropertyValue } from \"@itwin/appui-abstract\";\nimport {\n AlternateDateFormats,\n PropertyValueFormat,\n TimeDisplay,\n} from \"@itwin/appui-abstract\";\nimport type { PropertyEditorProps, TypeEditor } from \"./EditorContainer.js\";\nimport { PropertyEditorBase } from \"./PropertyEditorManager.js\";\nimport {\n PopupButton,\n PopupContent,\n PopupOkCancelButtons,\n} from \"./PopupButton.js\";\nimport type { TimeSpec } from \"../datepicker/TimeField.js\";\nimport { TimeField } from \"../datepicker/TimeField.js\";\nimport type { TypeConverter } from \"../converters/TypeConverter.js\";\nimport { DatePicker } from \"../datepicker/DatePicker.js\";\nimport { TypeConverterManager } from \"../converters/TypeConverterManager.js\";\nimport { DateTimeTypeConverterBase } from \"../converters/DateTimeTypeConverter.js\";\nimport { Text } from \"@itwin/itwinui-react\";\nimport { adjustDateToTimezone } from \"../common/DateUtils.js\";\n\n/** @internal */\ninterface DateTimeEditorState {\n value: Date;\n displayValue?: string;\n timeDisplay?: TimeDisplay;\n typeConverter?: TypeConverter;\n editInUtc: boolean;\n}\n\n/** @internal */\ninterface DateTimeEditorProps extends PropertyEditorProps {\n showTime?: boolean;\n}\n\n/** DateTimeEditor React component that is a property editor for selection of date and time.\n * @internal\n */\nexport class DateTimeEditor\n extends React.PureComponent<DateTimeEditorProps, DateTimeEditorState>\n implements TypeEditor\n{\n private _isMounted = false;\n private _enterKey = false;\n private _divElement = React.createRef<HTMLDivElement>();\n\n public override readonly state: Readonly<DateTimeEditorState> = {\n value: new Date(),\n editInUtc: false,\n };\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n propertyValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: this.state.value,\n displayValue: this.state.displayValue,\n };\n }\n\n return propertyValue;\n }\n\n public get htmlElement(): HTMLElement | null {\n return this._divElement.current;\n }\n\n public get hasFocus(): boolean {\n let containsFocus = false;\n if (this.htmlElement)\n containsFocus = this.htmlElement.contains(document.activeElement);\n return containsFocus;\n }\n\n public async processDateChange(\n typeConverter: TypeConverter,\n newValue: Date\n ): Promise<void> {\n if (this.props.propertyRecord) {\n const displayValue = await typeConverter.convertPropertyToString(\n this.props.propertyRecord.property,\n newValue\n );\n this.setState({\n value: newValue,\n displayValue,\n });\n }\n }\n\n private _handleChange = (newValue: Date): void => {\n if (this._isMounted && this.state.typeConverter) {\n if (this.state.editInUtc) {\n newValue = adjustDateToTimezone(\n newValue,\n newValue.getTimezoneOffset() * -1\n );\n }\n\n void this.processDateChange(this.state.typeConverter, newValue);\n }\n };\n\n private _handleTimeChange = (time: TimeSpec): void => {\n // Combine new time into selected Date\n if (this.state.editInUtc) {\n const newWorkingDate = adjustDateToTimezone(this.state.value, 0);\n newWorkingDate.setUTCHours(time.hours, time.minutes, time.seconds);\n this._handleChange(newWorkingDate);\n } else {\n const newWorkingDate = new Date(this.state.value.getTime());\n newWorkingDate.setHours(time.hours, time.minutes, time.seconds);\n this._handleChange(newWorkingDate);\n }\n };\n\n public override componentDidMount() {\n this._isMounted = true;\n void this.setStateFromProps();\n }\n\n public override componentWillUnmount() {\n this._isMounted = false;\n }\n\n public override componentDidUpdate(prevProps: PropertyEditorProps) {\n if (this.props.propertyRecord !== prevProps.propertyRecord) {\n void this.setStateFromProps();\n }\n }\n\n private async setStateFromProps() {\n const record = this.props.propertyRecord;\n let initialValue: Date | undefined;\n let typeConverter: TypeConverter | undefined;\n let timeDisplay: TimeDisplay | undefined;\n let alternateDateFormat = AlternateDateFormats.None;\n let editInUtc = false;\n\n if (this.props.showTime) timeDisplay = TimeDisplay.H12MC;\n\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n if (record.value.value instanceof Date)\n initialValue = new Date(record.value.value);\n else if (typeof record.value.value === \"string\")\n initialValue = new Date(record.value.value);\n else if (record.value.value === undefined) initialValue = new Date();\n\n typeConverter = TypeConverterManager.getConverter(\n record.property.typename,\n record.property.converter?.name\n );\n\n const options = record.property.converter?.options;\n if (options) {\n if (\"alternateDateFormat\" in options) {\n if (\n DateTimeTypeConverterBase.isAlternateDateFormats(\n options.alternateDateFormat\n )\n ) {\n timeDisplay = TimeDisplay.H24MS;\n alternateDateFormat = options.alternateDateFormat;\n }\n }\n\n if (\"timeDisplay\" in options && this.props.showTime) {\n timeDisplay = options.timeDisplay;\n // use 24 hr time display if alternateDateFormat is defined\n if (\n alternateDateFormat &&\n timeDisplay !== TimeDisplay.H24MS &&\n timeDisplay !== TimeDisplay.H24M\n )\n timeDisplay = TimeDisplay.H24MS;\n }\n\n if (alternateDateFormat) {\n editInUtc = true;\n\n if (this.props.showTime) {\n if (alternateDateFormat === AlternateDateFormats.IsoShort) {\n alternateDateFormat = AlternateDateFormats.IsoDateTime;\n }\n if (alternateDateFormat === AlternateDateFormats.UtcShort) {\n alternateDateFormat = AlternateDateFormats.UtcDateTime;\n }\n if (alternateDateFormat === AlternateDateFormats.UtcShortWithDay) {\n alternateDateFormat = AlternateDateFormats.UtcDateTimeWithDay;\n }\n } else {\n timeDisplay = undefined;\n if (alternateDateFormat === AlternateDateFormats.IsoDateTime)\n alternateDateFormat = AlternateDateFormats.IsoShort;\n if (alternateDateFormat === AlternateDateFormats.UtcDateTime)\n alternateDateFormat = AlternateDateFormats.UtcShort;\n if (alternateDateFormat === AlternateDateFormats.UtcDateTimeWithDay)\n alternateDateFormat = AlternateDateFormats.UtcShortWithDay;\n }\n }\n }\n }\n\n if (!initialValue) {\n throw new Error(\"Bad Value\");\n }\n\n if (!typeConverter) {\n throw new Error(\"Unable to determine TypeConverter\");\n }\n\n const displayValue = await typeConverter.convertPropertyToString(\n record!.property,\n initialValue\n );\n\n if (this._isMounted)\n this.setState({\n value: initialValue,\n timeDisplay,\n typeConverter,\n displayValue,\n editInUtc,\n });\n }\n\n private _handleEnter = async (): Promise<void> => {\n this._enterKey = true;\n await this._handleCommit();\n };\n\n private _handleClose = async (): Promise<void> => {\n if (this._enterKey) {\n this._enterKey = false;\n } else {\n if (this.props.onCancel) this.props.onCancel();\n }\n };\n\n private _handleOk = async (_event: React.MouseEvent): Promise<void> => {\n await this._handleCommit();\n };\n\n private _handleCancel = (_event: React.MouseEvent): void => {\n if (this.props.onCancel) {\n this.props.onCancel();\n }\n };\n\n private _handleCommit = async (): Promise<void> => {\n if (this.props.propertyRecord && this.props.onCommit) {\n const propertyValue = await this.getPropertyValue();\n if (propertyValue !== undefined) {\n this.props.onCommit({\n propertyRecord: this.props.propertyRecord,\n newValue: propertyValue,\n });\n }\n }\n };\n\n public override render(): React.ReactNode {\n const date = this.state.editInUtc\n ? adjustDateToTimezone(this.state.value, 0)\n : this.state.value;\n const timeSpec: TimeSpec = {\n hours: date.getHours(),\n minutes: date.getMinutes(),\n seconds: date.getSeconds(),\n };\n\n const className = classnames(\n \"components-cell-editor\",\n \"components-datetime-editor\",\n this.props.className\n );\n\n return (\n <div className={className} ref={this._divElement}>\n <PopupButton\n label={this.state.displayValue}\n onClose={this._handleClose}\n onEnter={this._handleEnter}\n setFocus={this.props.setFocus}\n disabled={this.props.propertyRecord?.isDisabled}\n readonly={this.props.propertyRecord?.isReadonly}\n >\n <PopupContent>\n <>\n <div\n className=\"components-date-picker-calendar-popup-panel\"\n data-testid=\"components-date-picker-calendar-popup-panel\"\n >\n <DatePicker // eslint-disable-line @typescript-eslint/no-deprecated\n selected={date}\n onDateChange={this._handleChange}\n showFocusOutline={false}\n />\n {this.state.timeDisplay && (\n <div className=\"time-container\">\n <Text variant=\"body\" className=\"time-label\">\n {\"Time\"}\n </Text>\n <TimeField\n time={timeSpec}\n timeDisplay={this.state.timeDisplay}\n onTimeChange={this._handleTimeChange}\n />\n </div>\n )}\n </div>\n </>\n <PopupOkCancelButtons\n onOk={this._handleOk}\n onCancel={this._handleCancel}\n />\n </PopupContent>\n </PopupButton>\n </div>\n );\n }\n}\n\n/** DateTime Property Editor registered for the \"number\" type name and \"DateTime\" editor name.\n * It uses the [[DateTimeEditor]] React component.\n * @internal\n */\nexport class ShortDateTimePropertyEditor extends PropertyEditorBase {\n public get reactNode(): React.ReactNode {\n return <DateTimeEditor showTime={false} />;\n }\n public override get containerHandlesTab(): boolean {\n return false;\n }\n}\n\n/** DateTime Property Editor registered for the \"number\" type name and \"DateTime\" editor name.\n * It uses the [[DateTimeEditor]] React component.\n * @internal\n */\nexport class DateTimePropertyEditor extends PropertyEditorBase {\n public get reactNode(): React.ReactNode {\n return <DateTimeEditor showTime={true} />;\n }\n public override get containerHandlesTab(): boolean {\n return false;\n }\n}\n"]}
1
+ {"version":3,"file":"DateTimeEditor.js","sourceRoot":"","sources":["../../../src/components-react/editors/DateTimeEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,uBAAuB,CAAC;AAC/B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,WAAW,GACZ,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EACL,WAAW,EACX,YAAY,EACZ,oBAAoB,GACrB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAEvD,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAC;AACnF,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAgB9D;;GAEG;AACH,MAAM,OAAO,cACX,SAA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c,IAAC,QAAQ,EAAE,IAAI,GAAI,CAAC;IAC5C,CAAC;IACD,IAAoB,mBAAmB;QACrC,OAAO,KAAK,CAAC;IACf,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module PropertyEditors\n */\n\nimport \"./DateTimeEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type { PropertyValue } from \"@itwin/appui-abstract\";\nimport {\n AlternateDateFormats,\n PropertyValueFormat,\n TimeDisplay,\n} from \"@itwin/appui-abstract\";\nimport type { PropertyEditorProps, TypeEditor } from \"./EditorContainer.js\";\nimport { PropertyEditorBase } from \"./PropertyEditorManager.js\";\nimport {\n PopupButton,\n PopupContent,\n PopupOkCancelButtons,\n} from \"./PopupButton.js\";\nimport type { TimeSpec } from \"../datepicker/TimeField.js\";\nimport { TimeField } from \"../datepicker/TimeField.js\";\nimport type { TypeConverter } from \"../converters/TypeConverter.js\";\nimport { DatePicker } from \"../datepicker/DatePicker.js\";\nimport { TypeConverterManager } from \"../converters/TypeConverterManager.js\";\nimport { DateTimeTypeConverterBase } from \"../converters/DateTimeTypeConverter.js\";\nimport { Text } from \"@itwin/itwinui-react\";\nimport { adjustDateToTimezone } from \"../common/DateUtils.js\";\n\n/** @internal */\ninterface DateTimeEditorState {\n value: Date;\n displayValue?: string;\n timeDisplay?: TimeDisplay;\n typeConverter?: TypeConverter;\n editInUtc: boolean;\n}\n\n/** @internal */\ninterface DateTimeEditorProps extends PropertyEditorProps {\n showTime?: boolean;\n}\n\n/** DateTimeEditor React component that is a property editor for selection of date and time.\n * @internal\n */\nexport class DateTimeEditor\n extends React.PureComponent<DateTimeEditorProps, DateTimeEditorState>\n implements TypeEditor\n{\n private _isMounted = false;\n private _enterKey = false;\n private _divElement = React.createRef<HTMLDivElement>();\n\n public override readonly state: Readonly<DateTimeEditorState> = {\n value: new Date(),\n editInUtc: false,\n };\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n propertyValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: this.state.value,\n displayValue: this.state.displayValue,\n };\n }\n\n return propertyValue;\n }\n\n public get htmlElement(): HTMLElement | null {\n return this._divElement.current;\n }\n\n public get hasFocus(): boolean {\n let containsFocus = false;\n if (this.htmlElement)\n containsFocus = this.htmlElement.contains(document.activeElement);\n return containsFocus;\n }\n\n public async processDateChange(\n typeConverter: TypeConverter,\n newValue: Date\n ): Promise<void> {\n if (this.props.propertyRecord) {\n const displayValue = await typeConverter.convertPropertyToString(\n this.props.propertyRecord.property,\n newValue\n );\n this.setState({\n value: newValue,\n displayValue,\n });\n }\n }\n\n private _handleChange = (newValue: Date): void => {\n if (this._isMounted && this.state.typeConverter) {\n if (this.state.editInUtc) {\n newValue = adjustDateToTimezone(\n newValue,\n newValue.getTimezoneOffset() * -1\n );\n }\n\n void this.processDateChange(this.state.typeConverter, newValue);\n }\n };\n\n private _handleTimeChange = (time: TimeSpec): void => {\n // Combine new time into selected Date\n if (this.state.editInUtc) {\n const newWorkingDate = adjustDateToTimezone(this.state.value, 0);\n newWorkingDate.setUTCHours(time.hours, time.minutes, time.seconds);\n this._handleChange(newWorkingDate);\n } else {\n const newWorkingDate = new Date(this.state.value.getTime());\n newWorkingDate.setHours(time.hours, time.minutes, time.seconds);\n this._handleChange(newWorkingDate);\n }\n };\n\n public override componentDidMount() {\n this._isMounted = true;\n void this.setStateFromProps();\n }\n\n public override componentWillUnmount() {\n this._isMounted = false;\n }\n\n public override componentDidUpdate(prevProps: PropertyEditorProps) {\n if (this.props.propertyRecord !== prevProps.propertyRecord) {\n void this.setStateFromProps();\n }\n }\n\n private async setStateFromProps() {\n const record = this.props.propertyRecord;\n let initialValue: Date | undefined;\n let typeConverter: TypeConverter | undefined;\n let timeDisplay: TimeDisplay | undefined;\n let alternateDateFormat = AlternateDateFormats.None;\n let editInUtc = false;\n\n if (this.props.showTime) timeDisplay = TimeDisplay.H12MC;\n\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n if (record.value.value instanceof Date)\n initialValue = new Date(record.value.value);\n else if (typeof record.value.value === \"string\")\n initialValue = new Date(record.value.value);\n else if (record.value.value === undefined) initialValue = new Date();\n\n typeConverter = TypeConverterManager.getConverter(\n record.property.typename,\n record.property.converter?.name\n );\n\n const options = record.property.converter?.options;\n if (options) {\n if (\"alternateDateFormat\" in options) {\n if (\n DateTimeTypeConverterBase.isAlternateDateFormats(\n options.alternateDateFormat\n )\n ) {\n timeDisplay = TimeDisplay.H24MS;\n alternateDateFormat = options.alternateDateFormat;\n }\n }\n\n if (\"timeDisplay\" in options && this.props.showTime) {\n timeDisplay = options.timeDisplay;\n // use 24 hr time display if alternateDateFormat is defined\n if (\n alternateDateFormat &&\n timeDisplay !== TimeDisplay.H24MS &&\n timeDisplay !== TimeDisplay.H24M\n )\n timeDisplay = TimeDisplay.H24MS;\n }\n\n if (alternateDateFormat) {\n editInUtc = true;\n\n if (this.props.showTime) {\n if (alternateDateFormat === AlternateDateFormats.IsoShort) {\n alternateDateFormat = AlternateDateFormats.IsoDateTime;\n }\n if (alternateDateFormat === AlternateDateFormats.UtcShort) {\n alternateDateFormat = AlternateDateFormats.UtcDateTime;\n }\n if (alternateDateFormat === AlternateDateFormats.UtcShortWithDay) {\n alternateDateFormat = AlternateDateFormats.UtcDateTimeWithDay;\n }\n } else {\n timeDisplay = undefined;\n if (alternateDateFormat === AlternateDateFormats.IsoDateTime)\n alternateDateFormat = AlternateDateFormats.IsoShort;\n if (alternateDateFormat === AlternateDateFormats.UtcDateTime)\n alternateDateFormat = AlternateDateFormats.UtcShort;\n if (alternateDateFormat === AlternateDateFormats.UtcDateTimeWithDay)\n alternateDateFormat = AlternateDateFormats.UtcShortWithDay;\n }\n }\n }\n }\n\n if (!initialValue) {\n throw new Error(\"Bad Value\");\n }\n\n if (!typeConverter) {\n throw new Error(\"Unable to determine TypeConverter\");\n }\n\n const displayValue = await typeConverter.convertPropertyToString(\n record!.property,\n initialValue\n );\n\n if (this._isMounted)\n this.setState({\n value: initialValue,\n timeDisplay,\n typeConverter,\n displayValue,\n editInUtc,\n });\n }\n\n private _handleEnter = async (): Promise<void> => {\n this._enterKey = true;\n await this._handleCommit();\n };\n\n private _handleClose = async (): Promise<void> => {\n if (this._enterKey) {\n this._enterKey = false;\n } else {\n if (this.props.onCancel) this.props.onCancel();\n }\n };\n\n private _handleOk = async (_event: React.MouseEvent): Promise<void> => {\n await this._handleCommit();\n };\n\n private _handleCancel = (_event: React.MouseEvent): void => {\n if (this.props.onCancel) {\n this.props.onCancel();\n }\n };\n\n private _handleCommit = async (): Promise<void> => {\n if (this.props.propertyRecord && this.props.onCommit) {\n const propertyValue = await this.getPropertyValue();\n if (propertyValue !== undefined) {\n this.props.onCommit({\n propertyRecord: this.props.propertyRecord,\n newValue: propertyValue,\n });\n }\n }\n };\n\n public override render(): React.ReactNode {\n const date = this.state.editInUtc\n ? adjustDateToTimezone(this.state.value, 0)\n : this.state.value;\n const timeSpec: TimeSpec = {\n hours: date.getHours(),\n minutes: date.getMinutes(),\n seconds: date.getSeconds(),\n };\n\n const className = classnames(\n \"components-cell-editor\",\n \"components-datetime-editor\",\n this.props.className\n );\n\n return (\n <div className={className} ref={this._divElement}>\n <PopupButton\n label={this.state.displayValue}\n onClose={this._handleClose}\n onEnter={this._handleEnter}\n setFocus={this.props.setFocus}\n disabled={this.props.propertyRecord?.isDisabled}\n readonly={this.props.propertyRecord?.isReadonly}\n >\n <PopupContent>\n <>\n <div\n className=\"components-date-picker-calendar-popup-panel\"\n data-testid=\"components-date-picker-calendar-popup-panel\"\n >\n <DatePicker // eslint-disable-line @typescript-eslint/no-deprecated\n selected={date}\n onDateChange={this._handleChange}\n showFocusOutline={false}\n />\n {this.state.timeDisplay && (\n <div className=\"time-container\">\n <Text variant=\"body\" className=\"time-label\">\n {\"Time\"}\n </Text>\n <TimeField\n time={timeSpec}\n timeDisplay={this.state.timeDisplay}\n onTimeChange={this._handleTimeChange}\n />\n </div>\n )}\n </div>\n </>\n <PopupOkCancelButtons\n onOk={this._handleOk}\n onCancel={this._handleCancel}\n />\n </PopupContent>\n </PopupButton>\n </div>\n );\n }\n}\n\n/** DateTime Property Editor registered for the \"number\" type name and \"DateTime\" editor name.\n * It uses the [[DateTimeEditor]] React component.\n * @internal\n */\nexport class ShortDateTimePropertyEditor extends PropertyEditorBase {\n public get reactNode(): React.ReactNode {\n return <DateTimeEditor showTime={false} />;\n }\n public override get containerHandlesTab(): boolean {\n return false;\n }\n}\n\n/** DateTime Property Editor registered for the \"number\" type name and \"DateTime\" editor name.\n * It uses the [[DateTimeEditor]] React component.\n * @internal\n */\nexport class DateTimePropertyEditor extends PropertyEditorBase {\n public get reactNode(): React.ReactNode {\n return <DateTimeEditor showTime={true} />;\n }\n public override get containerHandlesTab(): boolean {\n return false;\n }\n}\n"]}