@itwin/components-react 4.6.4 → 4.7.1

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 (160) hide show
  1. package/CHANGELOG.md +26 -4
  2. package/lib/cjs/components-react/UiComponents.d.ts.map +1 -1
  3. package/lib/cjs/components-react/UiComponents.js +3 -2
  4. package/lib/cjs/components-react/UiComponents.js.map +1 -1
  5. package/lib/cjs/components-react/common/ImageRenderer.d.ts.map +1 -1
  6. package/lib/cjs/components-react/common/ImageRenderer.js +2 -3
  7. package/lib/cjs/components-react/common/ImageRenderer.js.map +1 -1
  8. package/lib/cjs/components-react/common/UseAsyncValue.d.ts.map +1 -1
  9. package/lib/cjs/components-react/common/UseAsyncValue.js +7 -17
  10. package/lib/cjs/components-react/common/UseAsyncValue.js.map +1 -1
  11. package/lib/cjs/components-react/common/UseContextWithMandatoryProvider.d.ts.map +1 -1
  12. package/lib/cjs/components-react/common/UseContextWithMandatoryProvider.js +2 -1
  13. package/lib/cjs/components-react/common/UseContextWithMandatoryProvider.js.map +1 -1
  14. package/lib/cjs/components-react/common/UseDebouncedAsyncValue.d.ts.map +1 -1
  15. package/lib/cjs/components-react/common/UseDebouncedAsyncValue.js +22 -16
  16. package/lib/cjs/components-react/common/UseDebouncedAsyncValue.js.map +1 -1
  17. package/lib/cjs/components-react/datepicker/DatePicker.d.ts.map +1 -1
  18. package/lib/cjs/components-react/datepicker/DatePicker.js +6 -6
  19. package/lib/cjs/components-react/datepicker/DatePicker.js.map +1 -1
  20. package/lib/cjs/components-react/datepicker/DatePickerPopupButton.js +1 -1
  21. package/lib/cjs/components-react/datepicker/DatePickerPopupButton.js.map +1 -1
  22. package/lib/cjs/components-react/datepicker/TimeField.d.ts.map +1 -1
  23. package/lib/cjs/components-react/datepicker/TimeField.js +19 -22
  24. package/lib/cjs/components-react/datepicker/TimeField.js.map +1 -1
  25. package/lib/cjs/components-react/editors/CustomNumberEditor.d.ts.map +1 -1
  26. package/lib/cjs/components-react/editors/CustomNumberEditor.js +3 -2
  27. package/lib/cjs/components-react/editors/CustomNumberEditor.js.map +1 -1
  28. package/lib/cjs/components-react/editors/EditorContainer.d.ts.map +1 -1
  29. package/lib/cjs/components-react/editors/EditorContainer.js +4 -3
  30. package/lib/cjs/components-react/editors/EditorContainer.js.map +1 -1
  31. package/lib/cjs/components-react/editors/EnumButtonGroupEditor.d.ts +0 -1
  32. package/lib/cjs/components-react/editors/EnumButtonGroupEditor.d.ts.map +1 -1
  33. package/lib/cjs/components-react/editors/EnumButtonGroupEditor.js +1 -2
  34. package/lib/cjs/components-react/editors/EnumButtonGroupEditor.js.map +1 -1
  35. package/lib/cjs/components-react/editors/PopupButton.d.ts.map +1 -1
  36. package/lib/cjs/components-react/editors/PopupButton.js +4 -3
  37. package/lib/cjs/components-react/editors/PopupButton.js.map +1 -1
  38. package/lib/cjs/components-react/filter-builder/FilterBuilderState.d.ts.map +1 -1
  39. package/lib/cjs/components-react/filter-builder/FilterBuilderState.js +1 -0
  40. package/lib/cjs/components-react/filter-builder/FilterBuilderState.js.map +1 -1
  41. package/lib/cjs/components-react/filtering/FilteringInput.d.ts.map +1 -1
  42. package/lib/cjs/components-react/filtering/FilteringInput.js +2 -2
  43. package/lib/cjs/components-react/filtering/FilteringInput.js.map +1 -1
  44. package/lib/cjs/components-react/filtering/ResultSelector.js +2 -2
  45. package/lib/cjs/components-react/filtering/ResultSelector.js.map +1 -1
  46. package/lib/cjs/components-react/inputs/ParsedInput.d.ts.map +1 -1
  47. package/lib/cjs/components-react/inputs/ParsedInput.js +3 -3
  48. package/lib/cjs/components-react/inputs/ParsedInput.js.map +1 -1
  49. package/lib/cjs/components-react/properties/renderers/value/Common.d.ts +4 -0
  50. package/lib/cjs/components-react/properties/renderers/value/Common.d.ts.map +1 -0
  51. package/lib/cjs/components-react/properties/renderers/value/Common.js +12 -0
  52. package/lib/cjs/components-react/properties/renderers/value/Common.js.map +1 -0
  53. package/lib/cjs/components-react/properties/renderers/value/DoublePropertyValueRenderer.d.ts.map +1 -1
  54. package/lib/cjs/components-react/properties/renderers/value/DoublePropertyValueRenderer.js +2 -8
  55. package/lib/cjs/components-react/properties/renderers/value/DoublePropertyValueRenderer.js.map +1 -1
  56. package/lib/cjs/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.d.ts.map +1 -1
  57. package/lib/cjs/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.js +2 -5
  58. package/lib/cjs/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.js.map +1 -1
  59. package/lib/cjs/components-react/properties/renderers/value/NavigationPropertyValueRenderer.d.ts.map +1 -1
  60. package/lib/cjs/components-react/properties/renderers/value/NavigationPropertyValueRenderer.js +2 -8
  61. package/lib/cjs/components-react/properties/renderers/value/NavigationPropertyValueRenderer.js.map +1 -1
  62. package/lib/cjs/components-react/propertygrid/dataproviders/filterers/DisplayValuePropertyDataFilterer.d.ts.map +1 -1
  63. package/lib/cjs/components-react/propertygrid/dataproviders/filterers/DisplayValuePropertyDataFilterer.js +1 -1
  64. package/lib/cjs/components-react/propertygrid/dataproviders/filterers/DisplayValuePropertyDataFilterer.js.map +1 -1
  65. package/lib/cjs/components-react/propertygrid/dataproviders/filterers/LabelPropertyDataFilterer.d.ts.map +1 -1
  66. package/lib/cjs/components-react/propertygrid/dataproviders/filterers/LabelPropertyDataFilterer.js +1 -1
  67. package/lib/cjs/components-react/propertygrid/dataproviders/filterers/LabelPropertyDataFilterer.js.map +1 -1
  68. package/lib/cjs/components-react/propertygrid/dataproviders/filterers/PropertyCategoryLabelFilterer.d.ts.map +1 -1
  69. package/lib/cjs/components-react/propertygrid/dataproviders/filterers/PropertyCategoryLabelFilterer.js +1 -1
  70. package/lib/cjs/components-react/propertygrid/dataproviders/filterers/PropertyCategoryLabelFilterer.js.map +1 -1
  71. package/lib/cjs/components-react/tree/controlled/TreeEventDispatcher.d.ts.map +1 -1
  72. package/lib/cjs/components-react/tree/controlled/TreeEventDispatcher.js +10 -2
  73. package/lib/cjs/components-react/tree/controlled/TreeEventDispatcher.js.map +1 -1
  74. package/lib/cjs/components-react/tree/controlled/TreeEventHandler.d.ts +2 -0
  75. package/lib/cjs/components-react/tree/controlled/TreeEventHandler.d.ts.map +1 -1
  76. package/lib/cjs/components-react/tree/controlled/TreeEventHandler.js +2 -0
  77. package/lib/cjs/components-react/tree/controlled/TreeEventHandler.js.map +1 -1
  78. package/lib/cjs/components-react/tree/controlled/TreeEvents.d.ts +2 -0
  79. package/lib/cjs/components-react/tree/controlled/TreeEvents.d.ts.map +1 -1
  80. package/lib/cjs/components-react/tree/controlled/TreeEvents.js.map +1 -1
  81. package/lib/esm/components-react/UiComponents.d.ts.map +1 -1
  82. package/lib/esm/components-react/UiComponents.js +3 -2
  83. package/lib/esm/components-react/UiComponents.js.map +1 -1
  84. package/lib/esm/components-react/common/ImageRenderer.d.ts.map +1 -1
  85. package/lib/esm/components-react/common/ImageRenderer.js +2 -3
  86. package/lib/esm/components-react/common/ImageRenderer.js.map +1 -1
  87. package/lib/esm/components-react/common/UseAsyncValue.d.ts.map +1 -1
  88. package/lib/esm/components-react/common/UseAsyncValue.js +9 -19
  89. package/lib/esm/components-react/common/UseAsyncValue.js.map +1 -1
  90. package/lib/esm/components-react/common/UseContextWithMandatoryProvider.d.ts.map +1 -1
  91. package/lib/esm/components-react/common/UseContextWithMandatoryProvider.js +3 -2
  92. package/lib/esm/components-react/common/UseContextWithMandatoryProvider.js.map +1 -1
  93. package/lib/esm/components-react/common/UseDebouncedAsyncValue.d.ts.map +1 -1
  94. package/lib/esm/components-react/common/UseDebouncedAsyncValue.js +23 -17
  95. package/lib/esm/components-react/common/UseDebouncedAsyncValue.js.map +1 -1
  96. package/lib/esm/components-react/datepicker/DatePicker.d.ts.map +1 -1
  97. package/lib/esm/components-react/datepicker/DatePicker.js +6 -6
  98. package/lib/esm/components-react/datepicker/DatePicker.js.map +1 -1
  99. package/lib/esm/components-react/datepicker/DatePickerPopupButton.js +2 -2
  100. package/lib/esm/components-react/datepicker/DatePickerPopupButton.js.map +1 -1
  101. package/lib/esm/components-react/datepicker/TimeField.d.ts.map +1 -1
  102. package/lib/esm/components-react/datepicker/TimeField.js +19 -22
  103. package/lib/esm/components-react/datepicker/TimeField.js.map +1 -1
  104. package/lib/esm/components-react/editors/CustomNumberEditor.d.ts.map +1 -1
  105. package/lib/esm/components-react/editors/CustomNumberEditor.js +4 -3
  106. package/lib/esm/components-react/editors/CustomNumberEditor.js.map +1 -1
  107. package/lib/esm/components-react/editors/EditorContainer.d.ts.map +1 -1
  108. package/lib/esm/components-react/editors/EditorContainer.js +5 -4
  109. package/lib/esm/components-react/editors/EditorContainer.js.map +1 -1
  110. package/lib/esm/components-react/editors/EnumButtonGroupEditor.d.ts +0 -1
  111. package/lib/esm/components-react/editors/EnumButtonGroupEditor.d.ts.map +1 -1
  112. package/lib/esm/components-react/editors/EnumButtonGroupEditor.js +2 -3
  113. package/lib/esm/components-react/editors/EnumButtonGroupEditor.js.map +1 -1
  114. package/lib/esm/components-react/editors/PopupButton.d.ts.map +1 -1
  115. package/lib/esm/components-react/editors/PopupButton.js +5 -4
  116. package/lib/esm/components-react/editors/PopupButton.js.map +1 -1
  117. package/lib/esm/components-react/filter-builder/FilterBuilderState.d.ts.map +1 -1
  118. package/lib/esm/components-react/filter-builder/FilterBuilderState.js +1 -0
  119. package/lib/esm/components-react/filter-builder/FilterBuilderState.js.map +1 -1
  120. package/lib/esm/components-react/filtering/FilteringInput.d.ts.map +1 -1
  121. package/lib/esm/components-react/filtering/FilteringInput.js +2 -2
  122. package/lib/esm/components-react/filtering/FilteringInput.js.map +1 -1
  123. package/lib/esm/components-react/filtering/ResultSelector.js +2 -2
  124. package/lib/esm/components-react/filtering/ResultSelector.js.map +1 -1
  125. package/lib/esm/components-react/inputs/ParsedInput.d.ts.map +1 -1
  126. package/lib/esm/components-react/inputs/ParsedInput.js +3 -3
  127. package/lib/esm/components-react/inputs/ParsedInput.js.map +1 -1
  128. package/lib/esm/components-react/properties/renderers/value/Common.d.ts +4 -0
  129. package/lib/esm/components-react/properties/renderers/value/Common.d.ts.map +1 -0
  130. package/lib/esm/components-react/properties/renderers/value/Common.js +8 -0
  131. package/lib/esm/components-react/properties/renderers/value/Common.js.map +1 -0
  132. package/lib/esm/components-react/properties/renderers/value/DoublePropertyValueRenderer.d.ts.map +1 -1
  133. package/lib/esm/components-react/properties/renderers/value/DoublePropertyValueRenderer.js +1 -7
  134. package/lib/esm/components-react/properties/renderers/value/DoublePropertyValueRenderer.js.map +1 -1
  135. package/lib/esm/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.d.ts.map +1 -1
  136. package/lib/esm/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.js +2 -5
  137. package/lib/esm/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.js.map +1 -1
  138. package/lib/esm/components-react/properties/renderers/value/NavigationPropertyValueRenderer.d.ts.map +1 -1
  139. package/lib/esm/components-react/properties/renderers/value/NavigationPropertyValueRenderer.js +1 -7
  140. package/lib/esm/components-react/properties/renderers/value/NavigationPropertyValueRenderer.js.map +1 -1
  141. package/lib/esm/components-react/propertygrid/dataproviders/filterers/DisplayValuePropertyDataFilterer.d.ts.map +1 -1
  142. package/lib/esm/components-react/propertygrid/dataproviders/filterers/DisplayValuePropertyDataFilterer.js +1 -1
  143. package/lib/esm/components-react/propertygrid/dataproviders/filterers/DisplayValuePropertyDataFilterer.js.map +1 -1
  144. package/lib/esm/components-react/propertygrid/dataproviders/filterers/LabelPropertyDataFilterer.d.ts.map +1 -1
  145. package/lib/esm/components-react/propertygrid/dataproviders/filterers/LabelPropertyDataFilterer.js +1 -1
  146. package/lib/esm/components-react/propertygrid/dataproviders/filterers/LabelPropertyDataFilterer.js.map +1 -1
  147. package/lib/esm/components-react/propertygrid/dataproviders/filterers/PropertyCategoryLabelFilterer.d.ts.map +1 -1
  148. package/lib/esm/components-react/propertygrid/dataproviders/filterers/PropertyCategoryLabelFilterer.js +1 -1
  149. package/lib/esm/components-react/propertygrid/dataproviders/filterers/PropertyCategoryLabelFilterer.js.map +1 -1
  150. package/lib/esm/components-react/tree/controlled/TreeEventDispatcher.d.ts.map +1 -1
  151. package/lib/esm/components-react/tree/controlled/TreeEventDispatcher.js +10 -2
  152. package/lib/esm/components-react/tree/controlled/TreeEventDispatcher.js.map +1 -1
  153. package/lib/esm/components-react/tree/controlled/TreeEventHandler.d.ts +2 -0
  154. package/lib/esm/components-react/tree/controlled/TreeEventHandler.d.ts.map +1 -1
  155. package/lib/esm/components-react/tree/controlled/TreeEventHandler.js +2 -0
  156. package/lib/esm/components-react/tree/controlled/TreeEventHandler.js.map +1 -1
  157. package/lib/esm/components-react/tree/controlled/TreeEvents.d.ts +2 -0
  158. package/lib/esm/components-react/tree/controlled/TreeEvents.d.ts.map +1 -1
  159. package/lib/esm/components-react/tree/controlled/TreeEvents.js.map +1 -1
  160. package/package.json +7 -6
package/CHANGELOG.md CHANGED
@@ -1,11 +1,33 @@
1
1
  # Change Log - @itwin/components-react
2
2
 
3
- This log was last generated on Mon, 20 Nov 2023 19:07:50 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 07 Dec 2023 19:40:17 GMT and should not be manually modified.
4
4
 
5
- ## 4.6.4
6
- Mon, 20 Nov 2023 19:07:50 GMT
5
+ ## 4.7.1
6
+ Thu, 07 Dec 2023 19:40:17 GMT
7
7
 
8
- _Version update only_
8
+ ### Minor changes
9
+
10
+ - Reset operator when property of rule item is changed in FilterBuilderState.
11
+
12
+ ### Updates
13
+
14
+ - Set filterText to lowercase in constructors of filterers.
15
+
16
+ ## 4.7.0
17
+ Fri, 01 Dec 2023 20:01:16 GMT
18
+
19
+ ### Minor changes
20
+
21
+ - Add support for double-clicking tree nodes.
22
+
23
+ ### Patches
24
+
25
+ - Fix bug where multiline value renderer would not support certain properties.
26
+
27
+ ### Updates
28
+
29
+ - No longer consume deprecated appui-abstract types: getObjectClassName, SpecialKey; use icon path directly instead of IconSpecUtilities
30
+ - Fixed `useAsyncValue` hook to work in React 18 strict mode.
9
31
 
10
32
  ## 4.6.3
11
33
  Wed, 25 Oct 2023 09:39:22 GMT
@@ -1 +1 @@
1
- {"version":3,"file":"UiComponents.d.ts","sourceRoot":"","sources":["../../../src/components-react/UiComponents.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAIvD;;;GAGG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAC,YAAY,CAAS;IACpC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,CAAe;IAE5C;;;OAGG;WACiB,UAAU,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAmBzE,0DAA0D;WAC5C,SAAS;IAWvB,sDAAsD;IACtD,WAAkB,WAAW,IAAI,OAAO,CAEvC;IAED;;OAEG;IACH,WAAkB,YAAY,IAAI,YAAY,CAO7C;IAED,kDAAkD;IAClD,WAAkB,qBAAqB,IAAI,MAAM,CAEhD;IAED,gBAAgB;IAChB,WAAkB,WAAW,IAAI,MAAM,CAEtC;IAED;;OAEG;WACW,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM;IAavD,gBAAgB;WACF,cAAc,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM;CAM/C"}
1
+ {"version":3,"file":"UiComponents.d.ts","sourceRoot":"","sources":["../../../src/components-react/UiComponents.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAKvD;;;GAGG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAC,YAAY,CAAS;IACpC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,CAAe;IAE5C;;;OAGG;WACiB,UAAU,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAmBzE,0DAA0D;WAC5C,SAAS;IAWvB,sDAAsD;IACtD,WAAkB,WAAW,IAAI,OAAO,CAEvC;IAED;;OAEG;IACH,WAAkB,YAAY,IAAI,YAAY,CAO7C;IAED,kDAAkD;IAClD,WAAkB,qBAAqB,IAAI,MAAM,CAEhD;IAED,gBAAgB;IAChB,WAAkB,WAAW,IAAI,MAAM,CAEtC;IAED;;OAEG;WACW,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM;IAavD,gBAAgB;WACF,cAAc,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM;CAM/C"}
@@ -10,8 +10,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.UiComponents = void 0;
11
11
  const immer_1 = require("immer");
12
12
  const core_bentley_1 = require("@itwin/core-bentley");
13
- const appui_abstract_1 = require("@itwin/appui-abstract");
14
13
  const core_react_1 = require("@itwin/core-react");
14
+ const core_react_2 = require("@itwin/core-react");
15
+ const appui_abstract_1 = require("@itwin/appui-abstract");
15
16
  /**
16
17
  * Manages the localization service for the components-react package.
17
18
  * @public
@@ -74,7 +75,7 @@ class UiComponents {
74
75
  }
75
76
  /** @internal */
76
77
  static loggerCategory(obj) {
77
- const className = (0, appui_abstract_1.getClassName)(obj);
78
+ const className = (0, core_react_2.getObjectClassName)(obj);
78
79
  const category = UiComponents.packageName + (className ? `.${className}` : "");
79
80
  return category;
80
81
  }
@@ -1 +1 @@
1
- {"version":3,"file":"UiComponents.js","sourceRoot":"","sources":["../../../src/components-react/UiComponents.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,iCAAsC;AACtC,sDAA6C;AAE7C,0DAA8D;AAC9D,kDAA2C;AAE3C;;;GAGG;AACH,MAAa,YAAY;IAIvB;;;OAGG;IACI,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,YAA0B;QACvD,IAAI,YAAY,CAAC,YAAY,EAAE;YAC7B,qBAAM,CAAC,OAAO,CACZ,YAAY,CAAC,cAAc,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AC,EACjC,iFAAiF,CAClF,CAAC;YACF,OAAO,EAAE,CAAC;SACX;QACD,OAAO,YAAY,CAAC,YAAY,CAAC,kBAAkB,CAAC,GAAG,EAAE;YACvD,EAAE,EAAE,YAAY,CAAC,qBAAqB;SACvC,CAAC,CAAC;IACL,CAAC;IAED,gBAAgB;IACT,MAAM,CAAC,cAAc,CAAC,GAAQ;QACnC,MAAM,SAAS,GAAG,IAAA,6BAAY,EAAC,GAAG,CAAC,CAAC;QACpC,MAAM,QAAQ,GACZ,YAAY,CAAC,WAAW,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAChE,OAAO,QAAQ,CAAC;IAClB,CAAC;;AAvFc,yBAAY,GAAG,KAAK,CAAC;AADzB,oCAAY","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 Common\n */\n\nimport { enablePatches } from \"immer\";\nimport { Logger } from \"@itwin/core-bentley\";\nimport type { Localization } from \"@itwin/core-common\";\nimport { getClassName, UiError } from \"@itwin/appui-abstract\";\nimport { UiCore } from \"@itwin/core-react\";\n\n/**\n * Manages the localization service for the components-react package.\n * @public\n */\nexport class UiComponents {\n private static _initialized = false;\n private static _localization?: Localization;\n\n /**\n * Registers the localization service namespace for UiComponents. Also initializes UiCore.\n * @param localization The internationalization service created by the host application.\n */\n public static async initialize(localization: Localization): Promise<void> {\n if (UiComponents._initialized) {\n Logger.logInfo(\n UiComponents.loggerCategory(UiComponents),\n `UiComponents.initialize already called`\n );\n return;\n }\n\n enablePatches();\n UiComponents._localization = localization;\n await UiComponents._localization.registerNamespace(\n UiComponents.localizationNamespace\n );\n\n await UiCore.initialize(UiComponents._localization);\n UiComponents._initialized = true;\n }\n\n /** Unregisters the UiComponents localization namespace */\n public static terminate() {\n if (UiComponents._localization)\n UiComponents._localization.unregisterNamespace(\n UiComponents.localizationNamespace\n );\n UiComponents._localization = undefined;\n\n UiCore.terminate();\n UiComponents._initialized = false;\n }\n\n /** Determines if UiComponents has been initialized */\n public static get initialized(): boolean {\n return UiComponents._initialized;\n }\n\n /** The internationalization service created by the host application.\n * @internal\n */\n public static get localization(): Localization {\n if (!UiComponents._localization)\n throw new UiError(\n UiComponents.loggerCategory(this),\n \"_localization: UiComponents.initialize has not been called. Unable to return Localization object.\"\n );\n return UiComponents._localization;\n }\n\n /** The internationalization service namespace. */\n public static get localizationNamespace(): string {\n return \"UiComponents\";\n }\n\n /** @internal */\n public static get packageName(): string {\n return \"components-react\";\n }\n\n /** Calls localization.getLocalizedStringWithNamespace with the \"UiComponents\" namespace. Do NOT include the namespace in the key.\n * @internal\n */\n public static translate(key: string | string[]): string {\n if (!UiComponents.initialized) {\n Logger.logError(\n UiComponents.loggerCategory(this),\n `translate: UiComponents.initialize has not been called. Returning blank string.`\n );\n return \"\";\n }\n return UiComponents.localization.getLocalizedString(key, {\n ns: UiComponents.localizationNamespace,\n });\n }\n\n /** @internal */\n public static loggerCategory(obj: any): string {\n const className = getClassName(obj);\n const category =\n UiComponents.packageName + (className ? `.${className}` : \"\");\n return category;\n }\n}\n"]}
1
+ {"version":3,"file":"UiComponents.js","sourceRoot":"","sources":["../../../src/components-react/UiComponents.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,iCAAsC;AACtC,sDAA6C;AAE7C,kDAA2C;AAC3C,kDAAuD;AACvD,0DAAgD;AAEhD;;;GAGG;AACH,MAAa,YAAY;IAIvB;;;OAGG;IACI,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,YAA0B;QACvD,IAAI,YAAY,CAAC,YAAY,EAAE;YAC7B,qBAAM,CAAC,OAAO,CACZ,YAAY,CAAC,cAAc,CAAC,YAAY,CAAC,EACzC,wCAAwC,CACzC,CAAC;YACF,OAAO;SACR;Q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,OAAO,YAAY,CAAC,YAAY,CAAC,kBAAkB,CAAC,GAAG,EAAE;YACvD,EAAE,EAAE,YAAY,CAAC,qBAAqB;SACvC,CAAC,CAAC;IACL,CAAC;IAED,gBAAgB;IACT,MAAM,CAAC,cAAc,CAAC,GAAQ;QACnC,MAAM,SAAS,GAAG,IAAA,+BAAkB,EAAC,GAAG,CAAC,CAAC;QAC1C,MAAM,QAAQ,GACZ,YAAY,CAAC,WAAW,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAChE,OAAO,QAAQ,CAAC;IAClB,CAAC;;AAvFc,yBAAY,GAAG,KAAK,CAAC;AADzB,oCAAY","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 Common\n */\n\nimport { enablePatches } from \"immer\";\nimport { Logger } from \"@itwin/core-bentley\";\nimport type { Localization } from \"@itwin/core-common\";\nimport { UiCore } from \"@itwin/core-react\";\nimport { getObjectClassName } from \"@itwin/core-react\";\nimport { UiError } from \"@itwin/appui-abstract\";\n\n/**\n * Manages the localization service for the components-react package.\n * @public\n */\nexport class UiComponents {\n private static _initialized = false;\n private static _localization?: Localization;\n\n /**\n * Registers the localization service namespace for UiComponents. Also initializes UiCore.\n * @param localization The internationalization service created by the host application.\n */\n public static async initialize(localization: Localization): Promise<void> {\n if (UiComponents._initialized) {\n Logger.logInfo(\n UiComponents.loggerCategory(UiComponents),\n `UiComponents.initialize already called`\n );\n return;\n }\n\n enablePatches();\n UiComponents._localization = localization;\n await UiComponents._localization.registerNamespace(\n UiComponents.localizationNamespace\n );\n\n await UiCore.initialize(UiComponents._localization);\n UiComponents._initialized = true;\n }\n\n /** Unregisters the UiComponents localization namespace */\n public static terminate() {\n if (UiComponents._localization)\n UiComponents._localization.unregisterNamespace(\n UiComponents.localizationNamespace\n );\n UiComponents._localization = undefined;\n\n UiCore.terminate();\n UiComponents._initialized = false;\n }\n\n /** Determines if UiComponents has been initialized */\n public static get initialized(): boolean {\n return UiComponents._initialized;\n }\n\n /** The internationalization service created by the host application.\n * @internal\n */\n public static get localization(): Localization {\n if (!UiComponents._localization)\n throw new UiError(\n UiComponents.loggerCategory(this),\n \"_localization: UiComponents.initialize has not been called. Unable to return Localization object.\"\n );\n return UiComponents._localization;\n }\n\n /** The internationalization service namespace. */\n public static get localizationNamespace(): string {\n return \"UiComponents\";\n }\n\n /** @internal */\n public static get packageName(): string {\n return \"components-react\";\n }\n\n /** Calls localization.getLocalizedStringWithNamespace with the \"UiComponents\" namespace. Do NOT include the namespace in the key.\n * @internal\n */\n public static translate(key: string | string[]): string {\n if (!UiComponents.initialized) {\n Logger.logError(\n UiComponents.loggerCategory(this),\n `translate: UiComponents.initialize has not been called. Returning blank string.`\n );\n return \"\";\n }\n return UiComponents.localization.getLocalizedString(key, {\n ns: UiComponents.localizationNamespace,\n });\n }\n\n /** @internal */\n public static loggerCategory(obj: any): string {\n const className = getObjectClassName(obj);\n const category =\n UiComponents.packageName + (className ? `.${className}` : \"\");\n return category;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ImageRenderer.d.ts","sourceRoot":"","sources":["../../../../src/components-react/common/ImageRenderer.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,KAAK,EACV,KAAK,EAIN,MAAM,gBAAgB,CAAC;AAExB;;GAEG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAC,SAAS,CAAkC;IAE1D,OAAO,CAAC,WAAW;IAenB,8BAA8B;IAC9B,OAAO,CAAC,YAAY;IAMpB,OAAO,CAAC,KAAK;IAcb,OAAO,CAAC,mBAAmB;IAW3B,iCAAiC;IACjC,OAAO,CAAC,SAAS;IAgBjB,+BAA+B;IAC/B,OAAO,CAAC,SAAS;IAIjB,sCAAsC;IACtC,OAAO,CAAC,cAAc;IAItB,sDAAsD;IACtD,OAAO,CAAC,0BAA0B;IAIlC;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IAgB/B;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAKzB,yDAAyD;IAClD,MAAM,CAAC,WAAW,EAAE,KAAK,GAAG,KAAK,CAAC,SAAS;CA0BnD"}
1
+ {"version":3,"file":"ImageRenderer.d.ts","sourceRoot":"","sources":["../../../../src/components-react/common/ImageRenderer.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,KAAK,EACV,KAAK,EAIN,MAAM,gBAAgB,CAAC;AAGxB;;GAEG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAC,SAAS,CAAkC;IAE1D,OAAO,CAAC,WAAW;IAenB,8BAA8B;IAC9B,OAAO,CAAC,YAAY;IAMpB,OAAO,CAAC,KAAK;IAcb,OAAO,CAAC,mBAAmB;IAW3B,iCAAiC;IACjC,OAAO,CAAC,SAAS;IAejB,+BAA+B;IAC/B,OAAO,CAAC,SAAS;IAIjB,sCAAsC;IACtC,OAAO,CAAC,cAAc;IAItB,sDAAsD;IACtD,OAAO,CAAC,0BAA0B;IAIlC;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IAgB/B;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAKzB,yDAAyD;IAClD,MAAM,CAAC,WAAW,EAAE,KAAK,GAAG,KAAK,CAAC,SAAS;CA0BnD"}
@@ -32,9 +32,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
32
32
  Object.defineProperty(exports, "__esModule", { value: true });
33
33
  exports.ImageRenderer = void 0;
34
34
  const React = __importStar(require("react"));
35
- const appui_abstract_1 = require("@itwin/appui-abstract");
36
35
  const core_react_1 = require("@itwin/core-react");
37
36
  const UiComponents_1 = require("../UiComponents");
37
+ const appui_abstract_1 = require("@itwin/appui-abstract");
38
38
  /** A class that renders images from data provided by an image loader
39
39
  * @internal
40
40
  */
@@ -85,9 +85,8 @@ class ImageRenderer {
85
85
  svgAsDataUri = this.convertSvgToDataUri(svg.trim());
86
86
  ImageRenderer._svgCache.set(svg, svgAsDataUri);
87
87
  }
88
- const iconSpec = appui_abstract_1.IconSpecUtilities.createWebComponentIconSpec(svgAsDataUri);
89
88
  return (React.createElement("div", null,
90
- React.createElement(core_react_1.Icon, { iconSpec: iconSpec })));
89
+ React.createElement(core_react_1.Icon, { iconSpec: svgAsDataUri })));
91
90
  }
92
91
  /** Render image from an url */
93
92
  renderUrl(url) {
@@ -1 +1 @@
1
- {"version":3,"file":"ImageRenderer.js","sourceRoot":"","sources":["../../../../src/components-react/common/ImageRenderer.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAC/B,0DAAmE;AAEnE,kDAAsD;AACtD,kDAA+C;AAQ/C;;GAEG;AACH,MAAa,aAAa;IAGhB,WAAW,CAAC,SAAiB;QACnC,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QACxC,uBAAuB;QACvB,IAAI,CAAC,KAAK;YAAE,OAAO,EAAE,CAAC;QAEtB,mDAAmD;QACnD,OAAO,IAAI,CACT,KAAK;aACF,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;YACT,OAAO,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;QAC9C,CAAC,CAAC;aACD,IAAI,CAAC,EAAE,CAAC,CACZ,CAAC;IACJ,CAAC;IAED,8BAA8B;IACtB,YAAY,CAAC,IAAY,EAAE,MAAuB;QACxD,2BAA2B;QAC3B,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QAC5C,OAAO,6BAAK,GAAG,EA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AO,IAAI,CAAC,SAAS,CAAE,WAA2B,CAAC,KAAK,CAAC,CAAC;YAE5D,KAAK,KAAK;gBACR,OAAO,IAAI,CAAC,SAAS,CAAE,WAA2B,CAAC,KAAK,CAAC,CAAC;YAE5D,KAAK,WAAW;gBACd,OAAO,IAAI,CAAC,cAAc,CAAE,WAA2B,CAAC,KAAK,CAAC,CAAC;YAEjE,KAAK,cAAc;gBACjB,OAAO,IAAI,CAAC,iBAAiB,CAAE,WAA2B,CAAC,KAAK,CAAC,CAAC;YAEpE;gBACE,MAAM,mBAAmB,GAAU,WAAW,CAAC,UAAU,CAAC,CAAC,gDAAgD;gBAC3G,MAAM,IAAI,wBAAO,CACf,2BAAY,CAAC,cAAc,CAAC,IAAI,CAAC,EACjC,6BAA6B,mBAAmB,GAAG,CACpD,CAAC;SACL;IACH,CAAC;;AAxIc,uBAAS,GAAwB,IAAI,GAAG,EAAE,CAAC;AAD/C,sCAAa","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 Common\n */\n\nimport * as React from \"react\";\nimport { IconSpecUtilities, UiError } from \"@itwin/appui-abstract\";\nimport type { WebFontIconProps } from \"@itwin/core-react\";\nimport { Icon, WebFontIcon } from \"@itwin/core-react\";\nimport { UiComponents } from \"../UiComponents\";\nimport type {\n Image,\n ImageFileFormat,\n LoadedBinaryImage,\n LoadedImage,\n} from \"./IImageLoader\";\n\n/** A class that renders images from data provided by an image loader\n * @internal\n */\nexport class ImageRenderer {\n private static _svgCache: Map<string, string> = new Map();\n\n private hexToBase64(hexstring: string) {\n const match = hexstring.match(/\\w{2}/g);\n // istanbul ignore next\n if (!match) return \"\";\n\n // eslint-disable-next-line deprecation/deprecation\n return btoa(\n match\n .map((a) => {\n return String.fromCharCode(parseInt(a, 16));\n })\n .join(\"\")\n );\n }\n\n /** Render raw binary image */\n private renderBinary(data: string, format: ImageFileFormat) {\n // Convert binary to base64\n const dataAsBase64 = this.hexToBase64(data);\n return <img src={`data:image/${format};base64,${dataAsBase64}`} alt=\"\" />;\n }\n\n private isSvg(input: string): boolean {\n const parser = new DOMParser();\n const doc = parser.parseFromString(input, \"application/xml\");\n\n const errorNode = doc.querySelector(\"parsererror\");\n // istanbul ignore if\n if (errorNode) {\n return false;\n }\n\n const rootNode = doc.documentElement.nodeName.toLowerCase();\n return \"svg\" === rootNode;\n }\n\n private convertSvgToDataUri(svg: string) {\n // istanbul ignore if\n if (!this.isSvg(svg)) {\n return \"\";\n }\n\n // eslint-disable-next-line deprecation/deprecation\n const svgAsBase64 = btoa(svg);\n return `data:image/svg+xml;base64,${svgAsBase64}`;\n }\n\n /** Render svg string into JSX */\n private renderSvg(svg: string) {\n let svgAsDataUri = ImageRenderer._svgCache.get(svg);\n // istanbul ignore else\n if (undefined === svgAsDataUri) {\n svgAsDataUri = this.convertSvgToDataUri(svg.trim());\n ImageRenderer._svgCache.set(svg, svgAsDataUri);\n }\n\n const iconSpec = IconSpecUtilities.createWebComponentIconSpec(svgAsDataUri);\n return (\n <div>\n <Icon iconSpec={iconSpec} />\n </div>\n );\n }\n\n /** Render image from an url */\n private renderUrl(url: string) {\n return <img src={url} alt=\"\" />;\n }\n\n /** Render image as core-react icon */\n private renderCoreIcon(iconName: string) {\n return <WebFontIcon iconName={iconName} />;\n }\n\n /** Replaces the escaped instances of \"\\:\" with \":\" */\n private normalizeEscapedIconString(escapedIconString: string) {\n return escapedIconString.replace(/\\\\:/g, \":\");\n }\n\n /**\n * Extract class and name from icon name, if the name follows format \"{className}:{fontName}\".\n * className and fontName can be escaped using \\ if : is needed.\n */\n private extractIconClassAndName(\n iconName: string\n ): Pick<WebFontIconProps, \"iconClassName\" | \"iconName\"> {\n const matches = iconName.match(/(\\\\.|[^:])+/g);\n if (!matches || matches.length !== 2)\n return {\n iconClassName: undefined,\n iconName,\n };\n\n return {\n iconClassName: this.normalizeEscapedIconString(matches[0]),\n iconName: this.normalizeEscapedIconString(matches[1]),\n };\n }\n\n /**\n * Render image as provided webfont icon.\n * Defaults to core-react icon if iconName does not contain className.\n */\n private renderWebfontIcon(iconName: string) {\n const iconInfo = this.extractIconClassAndName(iconName);\n return <WebFontIcon {...iconInfo} />;\n }\n\n /** Render image from data provided by an image loader */\n public render(loadedImage: Image): React.ReactNode {\n switch (loadedImage.sourceType) {\n case \"binary\":\n const image = loadedImage as LoadedBinaryImage;\n return this.renderBinary(image.value, image.fileFormat);\n\n case \"url\":\n return this.renderUrl((loadedImage as LoadedImage).value);\n\n case \"svg\":\n return this.renderSvg((loadedImage as LoadedImage).value);\n\n case \"core-icon\":\n return this.renderCoreIcon((loadedImage as LoadedImage).value);\n\n case \"webfont-icon\":\n return this.renderWebfontIcon((loadedImage as LoadedImage).value);\n\n default:\n const unhandledSourceType: never = loadedImage.sourceType; // Compile time check that all cases are handled\n throw new UiError(\n UiComponents.loggerCategory(this),\n `Can't handle sourceType: \"${unhandledSourceType}\"`\n );\n }\n }\n}\n"]}
1
+ {"version":3,"file":"ImageRenderer.js","sourceRoot":"","sources":["../../../../src/components-react/common/ImageRenderer.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAE/B,kDAAsD;AACtD,kDAA+C;AAO/C,0DAAgD;AAEhD;;GAEG;AACH,MAAa,aAAa;IAGhB,WAAW,CAAC,SAAiB;QACnC,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QACxC,uBAAuB;QACvB,IAAI,CAAC,KAAK;YAAE,OAAO,EAAE,CAAC;QAEtB,mDAAmD;QACnD,OAAO,IAAI,CACT,KAAK;aACF,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;YACT,OAAO,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CA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AAQ;gBACX,MAAM,KAAK,GAAG,WAAgC,CAAC;gBAC/C,OAAO,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;YAE1D,KAAK,KAAK;gBACR,OAAO,IAAI,CAAC,SAAS,CAAE,WAA2B,CAAC,KAAK,CAAC,CAAC;YAE5D,KAAK,KAAK;gBACR,OAAO,IAAI,CAAC,SAAS,CAAE,WAA2B,CAAC,KAAK,CAAC,CAAC;YAE5D,KAAK,WAAW;gBACd,OAAO,IAAI,CAAC,cAAc,CAAE,WAA2B,CAAC,KAAK,CAAC,CAAC;YAEjE,KAAK,cAAc;gBACjB,OAAO,IAAI,CAAC,iBAAiB,CAAE,WAA2B,CAAC,KAAK,CAAC,CAAC;YAEpE;gBACE,MAAM,mBAAmB,GAAU,WAAW,CAAC,UAAU,CAAC,CAAC,gDAAgD;gBAC3G,MAAM,IAAI,wBAAO,CACf,2BAAY,CAAC,cAAc,CAAC,IAAI,CAAC,EACjC,6BAA6B,mBAAmB,GAAG,CACpD,CAAC;SACL;IACH,CAAC;;AAvIc,uBAAS,GAAwB,IAAI,GAAG,EAAE,CAAC;AAD/C,sCAAa","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 Common\n */\n\nimport * as React from \"react\";\nimport type { WebFontIconProps } from \"@itwin/core-react\";\nimport { Icon, WebFontIcon } from \"@itwin/core-react\";\nimport { UiComponents } from \"../UiComponents\";\nimport type {\n Image,\n ImageFileFormat,\n LoadedBinaryImage,\n LoadedImage,\n} from \"./IImageLoader\";\nimport { UiError } from \"@itwin/appui-abstract\";\n\n/** A class that renders images from data provided by an image loader\n * @internal\n */\nexport class ImageRenderer {\n private static _svgCache: Map<string, string> = new Map();\n\n private hexToBase64(hexstring: string) {\n const match = hexstring.match(/\\w{2}/g);\n // istanbul ignore next\n if (!match) return \"\";\n\n // eslint-disable-next-line deprecation/deprecation\n return btoa(\n match\n .map((a) => {\n return String.fromCharCode(parseInt(a, 16));\n })\n .join(\"\")\n );\n }\n\n /** Render raw binary image */\n private renderBinary(data: string, format: ImageFileFormat) {\n // Convert binary to base64\n const dataAsBase64 = this.hexToBase64(data);\n return <img src={`data:image/${format};base64,${dataAsBase64}`} alt=\"\" />;\n }\n\n private isSvg(input: string): boolean {\n const parser = new DOMParser();\n const doc = parser.parseFromString(input, \"application/xml\");\n\n const errorNode = doc.querySelector(\"parsererror\");\n // istanbul ignore if\n if (errorNode) {\n return false;\n }\n\n const rootNode = doc.documentElement.nodeName.toLowerCase();\n return \"svg\" === rootNode;\n }\n\n private convertSvgToDataUri(svg: string) {\n // istanbul ignore if\n if (!this.isSvg(svg)) {\n return \"\";\n }\n\n // eslint-disable-next-line deprecation/deprecation\n const svgAsBase64 = btoa(svg);\n return `data:image/svg+xml;base64,${svgAsBase64}`;\n }\n\n /** Render svg string into JSX */\n private renderSvg(svg: string) {\n let svgAsDataUri = ImageRenderer._svgCache.get(svg);\n // istanbul ignore else\n if (undefined === svgAsDataUri) {\n svgAsDataUri = this.convertSvgToDataUri(svg.trim());\n ImageRenderer._svgCache.set(svg, svgAsDataUri);\n }\n\n return (\n <div>\n <Icon iconSpec={svgAsDataUri} />\n </div>\n );\n }\n\n /** Render image from an url */\n private renderUrl(url: string) {\n return <img src={url} alt=\"\" />;\n }\n\n /** Render image as core-react icon */\n private renderCoreIcon(iconName: string) {\n return <WebFontIcon iconName={iconName} />;\n }\n\n /** Replaces the escaped instances of \"\\:\" with \":\" */\n private normalizeEscapedIconString(escapedIconString: string) {\n return escapedIconString.replace(/\\\\:/g, \":\");\n }\n\n /**\n * Extract class and name from icon name, if the name follows format \"{className}:{fontName}\".\n * className and fontName can be escaped using \\ if : is needed.\n */\n private extractIconClassAndName(\n iconName: string\n ): Pick<WebFontIconProps, \"iconClassName\" | \"iconName\"> {\n const matches = iconName.match(/(\\\\.|[^:])+/g);\n if (!matches || matches.length !== 2)\n return {\n iconClassName: undefined,\n iconName,\n };\n\n return {\n iconClassName: this.normalizeEscapedIconString(matches[0]),\n iconName: this.normalizeEscapedIconString(matches[1]),\n };\n }\n\n /**\n * Render image as provided webfont icon.\n * Defaults to core-react icon if iconName does not contain className.\n */\n private renderWebfontIcon(iconName: string) {\n const iconInfo = this.extractIconClassAndName(iconName);\n return <WebFontIcon {...iconInfo} />;\n }\n\n /** Render image from data provided by an image loader */\n public render(loadedImage: Image): React.ReactNode {\n switch (loadedImage.sourceType) {\n case \"binary\":\n const image = loadedImage as LoadedBinaryImage;\n return this.renderBinary(image.value, image.fileFormat);\n\n case \"url\":\n return this.renderUrl((loadedImage as LoadedImage).value);\n\n case \"svg\":\n return this.renderSvg((loadedImage as LoadedImage).value);\n\n case \"core-icon\":\n return this.renderCoreIcon((loadedImage as LoadedImage).value);\n\n case \"webfont-icon\":\n return this.renderWebfontIcon((loadedImage as LoadedImage).value);\n\n default:\n const unhandledSourceType: never = loadedImage.sourceType; // Compile time check that all cases are handled\n throw new UiError(\n UiComponents.loggerCategory(this),\n `Can't handle sourceType: \"${unhandledSourceType}\"`\n );\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"UseAsyncValue.d.ts","sourceRoot":"","sources":["../../../../src/components-react/common/UseAsyncValue.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAMH;;;GAGG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS,CAiCzE"}
1
+ {"version":3,"file":"UseAsyncValue.d.ts","sourceRoot":"","sources":["../../../../src/components-react/common/UseAsyncValue.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAMH;;;GAGG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS,CAqBzE"}
@@ -39,32 +39,22 @@ const core_react_1 = require("@itwin/core-react");
39
39
  * @public
40
40
  */
41
41
  function useAsyncValue(value) {
42
- const cancelled = React.useMemo(() => new rxjs_1.Subject(), []);
43
- // cancel any pending promises on unmount
44
- React.useEffect(() => () => cancelled.next(), [cancelled]);
45
42
  const [result, setResult] = React.useState(() => {
46
43
  if ((0, core_react_1.isPromiseLike)(value)) {
47
- (0, rxjs_1.from)(value)
48
- .pipe((0, rxjs_1.takeUntil)(cancelled))
49
- .subscribe({ next: (resolvedValue) => setResult(resolvedValue) });
50
44
  return undefined;
51
45
  }
52
46
  return value;
53
47
  });
54
- (0, core_react_1.useEffectSkipFirst)(() => {
55
- const updateValue = (newValue) => {
56
- cancelled.next();
57
- setResult(newValue);
58
- };
48
+ React.useEffect(() => {
59
49
  if ((0, core_react_1.isPromiseLike)(value)) {
60
- const subscription = (0, rxjs_1.from)(value)
61
- .pipe((0, rxjs_1.takeUntil)(cancelled))
62
- .subscribe({ next: (resolvedValue) => updateValue(resolvedValue) });
50
+ const subscription = (0, rxjs_1.from)(value).subscribe({
51
+ next: (resolvedValue) => setResult(resolvedValue),
52
+ });
63
53
  return () => subscription.unsubscribe();
64
54
  }
65
- updateValue(value);
66
- return undefined;
67
- }, [value, cancelled]);
55
+ setResult(value);
56
+ return;
57
+ }, [value]);
68
58
  return result;
69
59
  }
70
60
  exports.useAsyncValue = useAsyncValue;
@@ -1 +1 @@
1
- {"version":3,"file":"UseAsyncValue.js","sourceRoot":"","sources":["../../../../src/components-react/common/UseAsyncValue.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAC/B,+BAAgD;AAChD,kDAAsE;AAEtE;;;GAGG;AACH,SAAgB,aAAa,CAAI,KAAyB;IACxD,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC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AAC;IAEvB,OAAO,MAAM,CAAC;AAChB,CAAC;AAjCD,sCAiCC","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 Common\n */\n\nimport * as React from \"react\";\nimport { from, Subject, takeUntil } from \"rxjs\";\nimport { isPromiseLike, useEffectSkipFirst } from \"@itwin/core-react\";\n\n/**\n * Custom hook for working with possibly async values.\n * @public\n */\nexport function useAsyncValue<T>(value: T | PromiseLike<T>): T | undefined {\n const cancelled = React.useMemo(() => new Subject<void>(), []);\n // cancel any pending promises on unmount\n React.useEffect(() => () => cancelled.next(), [cancelled]);\n\n const [result, setResult] = React.useState(() => {\n if (isPromiseLike(value)) {\n from(value)\n .pipe(takeUntil(cancelled))\n .subscribe({ next: (resolvedValue) => setResult(resolvedValue) });\n return undefined;\n }\n return value;\n });\n\n useEffectSkipFirst(() => {\n const updateValue = (newValue: T) => {\n cancelled.next();\n setResult(newValue);\n };\n\n if (isPromiseLike(value)) {\n const subscription = from(value)\n .pipe(takeUntil(cancelled))\n .subscribe({ next: (resolvedValue) => updateValue(resolvedValue) });\n return () => subscription.unsubscribe();\n }\n\n updateValue(value);\n return undefined;\n }, [value, cancelled]);\n\n return result;\n}\n"]}
1
+ {"version":3,"file":"UseAsyncValue.js","sourceRoot":"","sources":["../../../../src/components-react/common/UseAsyncValue.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAC/B,+BAA4B;AAC5B,kDAAkD;AAElD;;;GAGG;AACH,SAAgB,aAAa,CAAI,KAAyB;IACxD,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE;QAC9C,IAAI,IAAA,0BAAa,EAAC,KAAK,CAAC,EAAE;YACxB,OAAO,SAAS,CAAC;SAClB;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;IAEH,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,IAAI,IAAA,0BAAa,EAAC,KAAK,CAAC,EAAE;YACxB,MAAM,YAAY,GAAG,IAAA,WAAI,EAAC,KAAK,CAAC,CAAC,SAAS,CAAC;gBACzC,IAAI,EAAE,CAAC,aAAa,EAAE,EAAE,CAAC,SAAS,CAAC,aAAa,CAAC;aAClD,CAAC,CAAC;YACH,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC;SACzC;QAED,SAAS,CAAC,KAAK,CAAC,CAAC;QACjB,OAAO;IACT,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,OAAO,MAAM,CAAC;AAChB,CAAC;AArBD,sCAqBC","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 Common\n */\n\nimport * as React from \"react\";\nimport { from } from \"rxjs\";\nimport { isPromiseLike } from \"@itwin/core-react\";\n\n/**\n * Custom hook for working with possibly async values.\n * @public\n */\nexport function useAsyncValue<T>(value: T | PromiseLike<T>): T | undefined {\n const [result, setResult] = React.useState(() => {\n if (isPromiseLike(value)) {\n return undefined;\n }\n return value;\n });\n\n React.useEffect(() => {\n if (isPromiseLike(value)) {\n const subscription = from(value).subscribe({\n next: (resolvedValue) => setResult(resolvedValue),\n });\n return () => subscription.unsubscribe();\n }\n\n setResult(value);\n return;\n }, [value]);\n\n return result;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"UseContextWithMandatoryProvider.d.ts","sourceRoot":"","sources":["../../../../src/components-react/common/UseContextWithMandatoryProvider.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,gBAAgB;AAChB,wBAAgB,kCAAkC,CAAC,CAAC,EAClD,WAAW,EAAE,MAAM,GAClB;IACD,KAAK,CAAC,uBAAuB,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IACrD,KAAK,CAAC,eAAe,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAC7C,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC;CAC5C,CAkBA"}
1
+ {"version":3,"file":"UseContextWithMandatoryProvider.d.ts","sourceRoot":"","sources":["../../../../src/components-react/common/UseContextWithMandatoryProvider.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,gBAAgB;AAChB,wBAAgB,kCAAkC,CAAC,CAAC,EAClD,WAAW,EAAE,MAAM,GAClB;IACD,KAAK,CAAC,uBAAuB,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IACrD,KAAK,CAAC,eAAe,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAC7C,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC;CAC5C,CAkBA"}
@@ -9,6 +9,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.createContextWithMandatoryProvider = void 0;
11
11
  const appui_abstract_1 = require("@itwin/appui-abstract");
12
+ const core_react_1 = require("@itwin/core-react");
12
13
  const UiComponents_1 = require("../UiComponents");
13
14
  const react_1 = __importDefault(require("react"));
14
15
  /** @internal */
@@ -18,7 +19,7 @@ function createContextWithMandatoryProvider(contextName) {
18
19
  const value = react_1.default.useContext(context);
19
20
  /* istanbul ignore if */
20
21
  if (value === undefined) {
21
- throw new appui_abstract_1.UiError(UiComponents_1.UiComponents.loggerCategory(ConsumingComponent), `'${(0, appui_abstract_1.getClassName)(ConsumingComponent)}' expects to be wrapped by a '${contextName}' provider.`);
22
+ throw new appui_abstract_1.UiError(UiComponents_1.UiComponents.loggerCategory(ConsumingComponent), `'${(0, core_react_1.getObjectClassName)(ConsumingComponent)}' expects to be wrapped by a '${contextName}' provider.`);
22
23
  }
23
24
  return value;
24
25
  }
@@ -1 +1 @@
1
- {"version":3,"file":"UseContextWithMandatoryProvider.js","sourceRoot":"","sources":["../../../../src/components-react/common/UseContextWithMandatoryProvider.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;;;;AAEhG,0DAA8D;AAC9D,kDAA+C;AAC/C,kDAA0B;AAE1B,gBAAgB;AAChB,SAAgB,kCAAkC,CAChD,WAAmB;IAMnB,MAAM,OAAO,GAAG,eAAK,CAAC,aAAa,CAAI,SAAqB,CAAC,CAAC;IAC9D,SAAS,6BAA6B,CACpC,kBAA0C;QAE1C,MAAM,KAAK,GAAG,eAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACxC,wBAAwB;QACxB,IAAI,KAAK,KAAK,SAAS,EAAE;YACvB,MAAM,IAAI,wBAAO,CACf,2BAAY,CAAC,cAAc,CAAC,kBAAkB,CAAC,EAC/C,IAAI,IAAA,6BAAY,EACd,kBAAkB,CACnB,iCAAiC,WAAW,aAAa,CAC3D,CAAC;SACH;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,6BAA6B,CAAC,CAAC;AAC7E,CAAC;AAxBD,gFAwBC","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 { getClassName, UiError } from \"@itwin/appui-abstract\";\nimport { UiComponents } from \"../UiComponents\";\nimport React from \"react\";\n\n/** @internal */\nexport function createContextWithMandatoryProvider<T>(\n contextName: string\n): [\n React.ProviderExoticComponent<React.ProviderProps<T>>,\n React.ExoticComponent<React.ConsumerProps<T>>,\n <P>(component: React.ComponentType<P>) => T\n] {\n const context = React.createContext<T>(undefined as any as T);\n function useContextWithoutDefaultValue<P>(\n ConsumingComponent: React.ComponentType<P>\n ) {\n const value = React.useContext(context);\n /* istanbul ignore if */\n if (value === undefined) {\n throw new UiError(\n UiComponents.loggerCategory(ConsumingComponent),\n `'${getClassName(\n ConsumingComponent\n )}' expects to be wrapped by a '${contextName}' provider.`\n );\n }\n return value;\n }\n return [context.Provider, context.Consumer, useContextWithoutDefaultValue];\n}\n"]}
1
+ {"version":3,"file":"UseContextWithMandatoryProvider.js","sourceRoot":"","sources":["../../../../src/components-react/common/UseContextWithMandatoryProvider.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;;;;AAEhG,0DAAgD;AAChD,kDAAuD;AACvD,kDAA+C;AAC/C,kDAA0B;AAE1B,gBAAgB;AAChB,SAAgB,kCAAkC,CAChD,WAAmB;IAMnB,MAAM,OAAO,GAAG,eAAK,CAAC,aAAa,CAAI,SAAqB,CAAC,CAAC;IAC9D,SAAS,6BAA6B,CACpC,kBAA0C;QAE1C,MAAM,KAAK,GAAG,eAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACxC,wBAAwB;QACxB,IAAI,KAAK,KAAK,SAAS,EAAE;YACvB,MAAM,IAAI,wBAAO,CACf,2BAAY,CAAC,cAAc,CAAC,kBAAkB,CAAC,EAC/C,IAAI,IAAA,+BAAkB,EACpB,kBAAkB,CACnB,iCAAiC,WAAW,aAAa,CAC3D,CAAC;SACH;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,6BAA6B,CAAC,CAAC;AAC7E,CAAC;AAxBD,gFAwBC","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 { UiError } from \"@itwin/appui-abstract\";\nimport { getObjectClassName } from \"@itwin/core-react\";\nimport { UiComponents } from \"../UiComponents\";\nimport React from \"react\";\n\n/** @internal */\nexport function createContextWithMandatoryProvider<T>(\n contextName: string\n): [\n React.ProviderExoticComponent<React.ProviderProps<T>>,\n React.ExoticComponent<React.ConsumerProps<T>>,\n <P>(component: React.ComponentType<P>) => T\n] {\n const context = React.createContext<T>(undefined as any as T);\n function useContextWithoutDefaultValue<P>(\n ConsumingComponent: React.ComponentType<P>\n ) {\n const value = React.useContext(context);\n /* istanbul ignore if */\n if (value === undefined) {\n throw new UiError(\n UiComponents.loggerCategory(ConsumingComponent),\n `'${getObjectClassName(\n ConsumingComponent\n )}' expects to be wrapped by a '${contextName}' provider.`\n );\n }\n return value;\n }\n return [context.Provider, context.Consumer, useContextWithoutDefaultValue];\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"UseDebouncedAsyncValue.d.ts","sourceRoot":"","sources":["../../../../src/components-react/common/UseDebouncedAsyncValue.ts"],"names":[],"mappings":"AAIA;;GAEG;AASH;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAC5C,iBAAiB,EAAE,SAAS,GAAG,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;;;EAsDxD"}
1
+ {"version":3,"file":"UseDebouncedAsyncValue.d.ts","sourceRoot":"","sources":["../../../../src/components-react/common/UseDebouncedAsyncValue.ts"],"names":[],"mappings":"AAIA;;GAEG;AASH;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAC5C,iBAAiB,EAAE,SAAS,GAAG,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;;;EAuDxD"}
@@ -21,20 +21,20 @@ const SubscriptionScheduler_1 = require("./SubscriptionScheduler");
21
21
  * @beta
22
22
  */
23
23
  function useDebouncedAsyncValue(valueToBeResolved) {
24
- const scheduler = (0, react_1.useMemo)(() => new SubscriptionScheduler_1.SubscriptionScheduler(), []);
25
- const [value, setValue] = (0, react_1.useState)();
26
- const [inProgress, setInProgress] = (0, react_1.useState)(false);
27
- const [errorState, setErrorState] = (0, react_1.useState)({
28
- error: undefined,
29
- hasError: false,
24
+ const [scheduler] = (0, react_1.useState)(() => new SubscriptionScheduler_1.SubscriptionScheduler());
25
+ const [{ result, inProgress }, setState] = (0, react_1.useState)({
26
+ result: undefined,
27
+ inProgress: false,
30
28
  });
31
29
  (0, react_1.useEffect)(() => {
32
30
  if (!valueToBeResolved) {
33
- setValue(undefined);
34
- setInProgress(false);
31
+ setState((prev) => ({ ...prev, result: undefined, inProgress: false }));
35
32
  return;
36
33
  }
37
- setInProgress(true);
34
+ setState((prev) => ({
35
+ ...prev,
36
+ inProgress: true,
37
+ }));
38
38
  // schedule and subscribe to the observable emitting value from valueToBeResolved promise
39
39
  const subscription = (0, rxjs_1.defer)(valueToBeResolved)
40
40
  .pipe((0, rxjs_1.share)({
@@ -44,21 +44,27 @@ function useDebouncedAsyncValue(valueToBeResolved) {
44
44
  }), (0, SubscriptionScheduler_1.scheduleSubscription)(scheduler))
45
45
  .subscribe({
46
46
  next: (data) => {
47
- setValue(data);
48
- setInProgress(false);
47
+ setState((prev) => ({ ...prev, result: data, inProgress: false }));
49
48
  },
50
49
  error: (err) => {
51
- setErrorState({ error: err, hasError: true });
52
- setInProgress(false);
50
+ setState((prev) => ({
51
+ ...prev,
52
+ result: { error: err, hasError: true },
53
+ inProgress: false,
54
+ }));
53
55
  },
54
56
  });
55
57
  return () => {
56
58
  subscription.unsubscribe();
57
59
  };
58
60
  }, [valueToBeResolved, scheduler]);
59
- if (errorState.hasError)
60
- throw (errorState.error ?? new Error("Exception in `useDebouncedAsyncValue`"));
61
- return { value, inProgress };
61
+ if (isErrorResult(result)) {
62
+ throw result.error ?? new Error("Exception in `useDebouncedAsyncValue`");
63
+ }
64
+ return { value: result, inProgress };
62
65
  }
63
66
  exports.useDebouncedAsyncValue = useDebouncedAsyncValue;
67
+ function isErrorResult(obj) {
68
+ return obj !== undefined && obj.hasError;
69
+ }
64
70
  //# sourceMappingURL=UseDebouncedAsyncValue.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"UseDebouncedAsyncValue.js","sourceRoot":"","sources":["../../../../src/components-react/common/UseDebouncedAsyncValue.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,iCAAqD;AACrD,+BAAoC;AACpC,mEAGiC;AAEjC;;;;;;;;GAQG;AACH,SAAgB,sBAAsB,CACpC,iBAAuD;IAEvD,MAAM,SAAS,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,IAAI,6CAAqB,EAAW,EAAE,EAAE,CAAC,CAAC;IAE1E,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,GAAW,CAAC;IAC9C,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IACpD,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,IAAA,gBAAQ,EAGzC;QACD,KAAK,EAAE,SAAS;QAChB,QAAQ,EAAE,KAAK;KAChB,CAAC,CAAC;IAEH,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,CAAC,iBAAiB,EAAE;YACtB,QAAQ,CAAC,SAAS,CAAC,CAAC;YACpB,aAAa,CAAC,KAAK,CAAC,CAAC;YACrB,OAAO;SACR;QAED,aAAa,CAAC,IAAI,CAAC,CAAC;QACpB,yFAAyF;QACzF,MAAM,YAAY,GAAG,IAAA,YAAK,EAAC,iBAAiB,CAAC;aAC1C,IAAI,CACH,IAAA,YAAK,EAAC;YACJ,YAAY,EAAE,KAAK;YACnB,eAAe,EAAE,KAAK;YACtB,mBAAmB,EAAE,IAAI;SAC1B,CAAC,EACF,IAAA,4CAAoB,EAAC,SAAS,CAAC,CAChC;aACA,SAAS,CAAC;YACT,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE;gBACb,QAAQ,CAAC,IAAI,CAAC,CAAC;gBACf,aAAa,CAAC,KAAK,CAAC,CAAC;YACvB,CAAC;YACD,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE;gBACb,aAAa,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;gBAC9C,aAAa,CAAC,KAAK,CAAC,CAAC;YACvB,CAAC;SACF,CAAC,CAAC;QAEL,OAAO,GAAG,EAAE;YACV,YAAY,CAAC,WAAW,EAAE,CAAC;QAC7B,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,iBAAiB,EAAE,SAAS,CAAC,CAAC,CAAC;IAEnC,IAAI,UAAU,CAAC,QAAQ;QACrB,MAAM,CACJ,UAAU,CAAC,KAAK,IAAI,IAAI,KAAK,CAAC,uCAAuC,CAAC,CACvE,CAAC;IAEJ,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;AAC/B,CAAC;AAvDD,wDAuDC","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 Common\n */\n\nimport { useEffect, useMemo, useState } from \"react\";\nimport { defer, share } from \"rxjs\";\nimport {\n scheduleSubscription,\n SubscriptionScheduler,\n} from \"./SubscriptionScheduler\";\n\n/**\n * Custom hook for working with promise values.\n * Promises are debounced using trailing and leading edge.\n * The first promise will always be executed.\n * Any promises following the first while it is executing will be scheduled (and unscheduled), leaving only the last promise to be resolved.\n * Once the first promise finishes resolving, the last passed promise starts resolving.\n * @throws if/when `valueToBeResolved` promise is rejected. The error is thrown in the React's render loop, so it can be caught using an error boundary.\n * @beta\n */\nexport function useDebouncedAsyncValue<TReturn>(\n valueToBeResolved: undefined | (() => Promise<TReturn>)\n) {\n const scheduler = useMemo(() => new SubscriptionScheduler<TReturn>(), []);\n\n const [value, setValue] = useState<TReturn>();\n const [inProgress, setInProgress] = useState(false);\n const [errorState, setErrorState] = useState<{\n error: Error | undefined;\n hasError: boolean;\n }>({\n error: undefined,\n hasError: false,\n });\n\n useEffect(() => {\n if (!valueToBeResolved) {\n setValue(undefined);\n setInProgress(false);\n return;\n }\n\n setInProgress(true);\n // schedule and subscribe to the observable emitting value from valueToBeResolved promise\n const subscription = defer(valueToBeResolved)\n .pipe(\n share({\n resetOnError: false,\n resetOnComplete: false,\n resetOnRefCountZero: true,\n }),\n scheduleSubscription(scheduler)\n )\n .subscribe({\n next: (data) => {\n setValue(data);\n setInProgress(false);\n },\n error: (err) => {\n setErrorState({ error: err, hasError: true });\n setInProgress(false);\n },\n });\n\n return () => {\n subscription.unsubscribe();\n };\n }, [valueToBeResolved, scheduler]);\n\n if (errorState.hasError)\n throw (\n errorState.error ?? new Error(\"Exception in `useDebouncedAsyncValue`\")\n );\n\n return { value, inProgress };\n}\n"]}
1
+ {"version":3,"file":"UseDebouncedAsyncValue.js","sourceRoot":"","sources":["../../../../src/components-react/common/UseDebouncedAsyncValue.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,iCAA4C;AAC5C,+BAAoC;AACpC,mEAGiC;AAEjC;;;;;;;;GAQG;AACH,SAAgB,sBAAsB,CACpC,iBAAuD;IAEvD,MAAM,CAAC,SAAS,CAAC,GAAG,IAAA,gBAAQ,EAAC,GAAG,EAAE,CAAC,IAAI,6CAAqB,EAAW,CAAC,CAAC;IAEzE,MAAM,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAGhD;QACD,MAAM,EAAE,SAAS;QACjB,UAAU,EAAE,KAAK;KAClB,CAAC,CAAC;IAEH,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,CAAC,iBAAiB,EAAE;YACtB,QAAQ,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,C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E,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;AACvC,CAAC;AAxDD,wDAwDC;AAOD,SAAS,aAAa,CACpB,GAA2B;IAE3B,OAAO,GAAG,KAAK,SAAS,IAAK,GAAmB,CAAC,QAAQ,CAAC;AAC5D,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 Common\n */\n\nimport { useEffect, useState } from \"react\";\nimport { defer, share } from \"rxjs\";\nimport {\n scheduleSubscription,\n SubscriptionScheduler,\n} from \"./SubscriptionScheduler\";\n\n/**\n * Custom hook for working with promise values.\n * Promises are debounced using trailing and leading edge.\n * The first promise will always be executed.\n * Any promises following the first while it is executing will be scheduled (and unscheduled), leaving only the last promise to be resolved.\n * Once the first promise finishes resolving, the last passed promise starts resolving.\n * @throws if/when `valueToBeResolved` promise is rejected. The error is thrown in the React's render loop, so it can be caught using an error boundary.\n * @beta\n */\nexport function useDebouncedAsyncValue<TReturn>(\n valueToBeResolved: undefined | (() => Promise<TReturn>)\n) {\n const [scheduler] = useState(() => new SubscriptionScheduler<TReturn>());\n\n const [{ result, inProgress }, setState] = useState<{\n result: TReturn | ErrorResult | undefined;\n inProgress: boolean;\n }>({\n result: undefined,\n inProgress: false,\n });\n\n useEffect(() => {\n if (!valueToBeResolved) {\n setState((prev) => ({ ...prev, result: undefined, inProgress: false }));\n return;\n }\n\n setState((prev) => ({\n ...prev,\n inProgress: true,\n }));\n // schedule and subscribe to the observable emitting value from valueToBeResolved promise\n const subscription = defer(valueToBeResolved)\n .pipe(\n share({\n resetOnError: false,\n resetOnComplete: false,\n resetOnRefCountZero: true,\n }),\n scheduleSubscription(scheduler)\n )\n .subscribe({\n next: (data) => {\n setState((prev) => ({ ...prev, result: data, inProgress: false }));\n },\n error: (err) => {\n setState((prev) => ({\n ...prev,\n result: { error: err, hasError: true },\n inProgress: false,\n }));\n },\n });\n\n return () => {\n subscription.unsubscribe();\n };\n }, [valueToBeResolved, scheduler]);\n\n if (isErrorResult(result)) {\n throw result.error ?? new Error(\"Exception in `useDebouncedAsyncValue`\");\n }\n\n return { value: result, inProgress };\n}\n\ninterface ErrorResult {\n error: Error | undefined;\n hasError: boolean;\n}\n\nfunction isErrorResult<TResult>(\n obj?: TResult | ErrorResult\n): obj is ErrorResult {\n return obj !== undefined && (obj as ErrorResult).hasError;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"DatePicker.d.ts","sourceRoot":"","sources":["../../../../src/components-react/datepicker/DatePicker.tsx"],"names":[],"mappings":"AAIA;;GAEG;;AASH,OAAO,mBAAmB,CAAC;AAY3B;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,iCAAiC;IACjC,QAAQ,EAAE,IAAI,CAAC;IACf,qDAAqD;IACrD,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,IAAI,KAAK,IAAI,CAAC;IACnC,0DAA0D;IAC1D,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,eA4ThD"}
1
+ {"version":3,"file":"DatePicker.d.ts","sourceRoot":"","sources":["../../../../src/components-react/datepicker/DatePicker.tsx"],"names":[],"mappings":"AAIA;;GAEG;;AAQH,OAAO,mBAAmB,CAAC;AAY3B;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,iCAAiC;IACjC,QAAQ,EAAE,IAAI,CAAC;IACf,qDAAqD;IACrD,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,IAAI,KAAK,IAAI,CAAC;IACnC,0DAA0D;IAC1D,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,eA4ThD"}
@@ -36,7 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.DatePicker = void 0;
37
37
  const React = __importStar(require("react"));
38
38
  const classnames_1 = __importDefault(require("classnames"));
39
- const appui_abstract_1 = require("@itwin/appui-abstract");
39
+ const ts_key_enum_1 = require("ts-key-enum");
40
40
  const UiComponents_1 = require("../UiComponents");
41
41
  const core_react_1 = require("@itwin/core-react");
42
42
  const itwinui_icons_react_1 = require("@itwin/itwinui-icons-react");
@@ -148,7 +148,7 @@ function DatePicker(props) {
148
148
  props.onDateChange && props.onDateChange(day);
149
149
  }, [props]);
150
150
  const handleCalendarKeyDown = React.useCallback((event) => {
151
- if (event.key === appui_abstract_1.SpecialKey.ArrowDown) {
151
+ if (event.key === ts_key_enum_1.Key.ArrowDown) {
152
152
  const focusedDayIndex = days.findIndex((day) => isSameDay(day, focusedDay));
153
153
  if (focusedDayIndex + 7 > 41)
154
154
  setFocusedDay(days[focusedDayIndex % 7]);
@@ -156,7 +156,7 @@ function DatePicker(props) {
156
156
  setFocusedDay(days[focusedDayIndex + 7]);
157
157
  event.preventDefault();
158
158
  }
159
- if (event.key === appui_abstract_1.SpecialKey.ArrowUp) {
159
+ if (event.key === ts_key_enum_1.Key.ArrowUp) {
160
160
  const focusedDayIndex = days.findIndex((day) => isSameDay(day, focusedDay));
161
161
  if (focusedDayIndex - 7 < 0)
162
162
  setFocusedDay(days[(focusedDayIndex % 7) + 35]);
@@ -164,21 +164,21 @@ function DatePicker(props) {
164
164
  setFocusedDay(days[focusedDayIndex - 7]);
165
165
  event.preventDefault();
166
166
  }
167
- if (event.key === appui_abstract_1.SpecialKey.ArrowLeft) {
167
+ if (event.key === ts_key_enum_1.Key.ArrowLeft) {
168
168
  const focusedDayIndex = days.findIndex((day) => isSameDay(day, focusedDay));
169
169
  // istanbul ignore else
170
170
  if (focusedDayIndex - 1 >= 0)
171
171
  setFocusedDay(days[focusedDayIndex - 1]);
172
172
  event.preventDefault();
173
173
  }
174
- if (event.key === appui_abstract_1.SpecialKey.ArrowRight) {
174
+ if (event.key === ts_key_enum_1.Key.ArrowRight) {
175
175
  const focusedDayIndex = days.findIndex((day) => isSameDay(day, focusedDay));
176
176
  // istanbul ignore else
177
177
  if (focusedDayIndex + 1 <= 41)
178
178
  setFocusedDay(days[focusedDayIndex + 1]);
179
179
  event.preventDefault();
180
180
  }
181
- if (event.key === appui_abstract_1.SpecialKey.Enter || event.key === appui_abstract_1.SpecialKey.Space) {
181
+ if (event.key === ts_key_enum_1.Key.Enter || event.key === " ") {
182
182
  handleOnDayChange(focusedDay)(); // NB: immediately call returned handler function
183
183
  event.preventDefault();
184
184
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DatePicker.js","sourceRoot":"","sources":["../../../../src/components-react/datepicker/DatePicker.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAC/B,4DAAoC;AACpC,0DAAmD;AACnD,kDAA+C;AAC/C,kDAAyC;AACzC,oEAA6E;AAE7E,6BAA2B;AAE3B,SAAS,SAAS,CAAC,CAAO,EAAE,CAAO;IACjC,OAAO,CACL,CAAC;QACD,CAAC;QACD,CAAC,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,WAAW,EAAE;QACnC,CAAC,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,QAAQ,EAAE;QAC7B,CAAC,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,OAAO,EAAE,CAC5B,CAAC;AACJ,CAAC;AAeD;;GAEG;AACH,SAAgB,UAAU,CAAC,KAAsB;IAC/C,MAAM,kBAAkB,GAAG,KAAK,CAAC,MAAM,CACrC,2BAAY,CAAC,YAAY,CAAC,kBAAkB,CAC1C,uCAAuC,CACxC,CACF,CAAC;IACF,MAAM,cAAc,GAAG,KAAK,CAAC,MAAM,CACjC,2BAAY,CAAC,YAAY,CAAC,kBAAkB,CAC1C,mCAAmC,CACpC,CACF,CAAC;IACF,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC;QAC9B,2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AAC,CACE;QACN,4BACE,QAAQ,EAAE,CAAC,EACX,SAAS,EAAE,qBAAqB,iBACpB,sCAAsC,EAClD,SAAS,EAAE,aAAa,EACxB,IAAI,EAAC,SAAS,IAEb,KAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,SAAS,EAAE,EAAE,CAAC,CAClC,oBAAC,KAAK,CAAC,QAAQ,IAAC,GAAG,EAAE,QAAQ,SAAS,EAAE,IACrC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAS,EAAE,QAAgB,EAAE,EAAE;YAC5C,MAAM,QAAQ,GACZ,WAAW,IAAI,GAAG,IAAI,SAAS,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC;YACpD,MAAM,SAAS,GACb,UAAU;gBACV,GAAG;gBACH,SAAS,CAAC,UAAU,EAAE,GAAG,CAAC;gBAC1B,KAAK,CAAC,gBAAgB,CAAC;YACzB,MAAM,cAAc,GAAG,GAAG,CAAC,QAAQ,EAAE,KAAK,mBAAmB,CAAC;YAC9D,MAAM,UAAU,GAAG,IAAA,oBAAU,EAC3B,qCAAqC,EACrC,QAAQ,IAAI,UAAU,EACtB,CAAC,cAAc,IAAI,iBAAiB,EACpC,SAAS,IAAI,SAAS,CACvB,CAAC;YACF,MAAM,SAAS,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC;YAChC,OAAO;YACL,oEAAoE;YACpE,4BACE,SAAS,EAAE,UAAU,EACrB,GAAG,EAAE,GAAG,aAAa,IAAI,mBAAmB,QAAQ,QAAQ,EAAE,EAC9D,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAC/B,IAAI,EAAC,QAAQ,mBACE,QAAQ,gBACX,GAAG,CAAC,OAAO,EAAE;gBAEzB,kCAAO,SAAS,CAAQ,CACrB,CACN,CAAC;QACJ,CAAC,CAAC,CACa,CAClB,CAAC,CACC,CACD,CACP,CAAC;AACJ,CAAC;AA5TD,gCA4TC","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 Date\n */\n\nimport * as React from \"react\";\nimport classnames from \"classnames\";\nimport { SpecialKey } from \"@itwin/appui-abstract\";\nimport { UiComponents } from \"../UiComponents\";\nimport { Icon } from \"@itwin/core-react\";\nimport { SvgChevronLeft, SvgChevronRight } from \"@itwin/itwinui-icons-react\";\n\nimport \"./DatePicker.scss\";\n\nfunction isSameDay(a: Date, b: Date) {\n return (\n a &&\n b &&\n a.getFullYear() === b.getFullYear() &&\n a.getMonth() === b.getMonth() &&\n a.getDate() === b.getDate()\n );\n}\n\n/**\n * Props for [[DatePicker]] component.\n * @alpha\n */\nexport interface DatePickerProps {\n /** defines both date and time */\n selected: Date;\n /** function to call when date or time has changed */\n onDateChange?: (day: Date) => void;\n /** show focus outlines, useful for keyboard navigation */\n showFocusOutline?: boolean;\n}\n\n/** DatePicker component. Show a month selector and a day calendar to select a specific date.\n * @alpha\n */\nexport function DatePicker(props: DatePickerProps) {\n const previousMonthLabel = React.useRef(\n UiComponents.localization.getLocalizedString(\n \"UiComponents:datepicker.previousMonth\"\n )\n );\n const nextMonthLabel = React.useRef(\n UiComponents.localization.getLocalizedString(\n \"UiComponents:datepicker.nextMonth\"\n )\n );\n const monthsLong = React.useRef([\n UiComponents.localization.getLocalizedString(\n \"UiComponents:month.long.january\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:month.long.february\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:month.long.march\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:month.long.april\"\n ),\n UiComponents.localization.getLocalizedString(\"UiComponents:month.long.may\"),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:month.long.june\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:month.long.july\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:month.long.august\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:month.long.september\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:month.long.october\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:month.long.november\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:month.long.december\"\n ),\n ]);\n\n const daysLong = React.useRef([\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.long.sunday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.long.monday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.long.tuesday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.long.wednesday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.long.thursday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.long.friday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.long.saturday\"\n ),\n ]);\n\n const daysShort = React.useRef([\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.short.sunday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.short.monday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.short.tuesday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.short.wednesday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.short.thursday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.short.friday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.short.saturday\"\n ),\n ]);\n\n const [selectedDay, setSelectedDay] = React.useState(\n new Date(props.selected.getTime())\n );\n const [displayedMonthIndex, setDisplayedMonthIndex] = React.useState(\n selectedDay.getMonth()\n );\n const [displayedYear, setDisplayedYear] = React.useState(\n selectedDay.getFullYear()\n );\n const [focusedDay, setFocusedDay] = React.useState(selectedDay);\n React.useEffect(() => {\n const newSelectedDay = new Date(props.selected);\n setSelectedDay(new Date(props.selected));\n setDisplayedMonthIndex(newSelectedDay.getMonth());\n setDisplayedYear(newSelectedDay.getFullYear());\n setFocusedDay(newSelectedDay);\n }, [props.selected]);\n const days = React.useMemo(() => {\n const msFirstDayOfMonth = new Date(\n displayedYear,\n displayedMonthIndex,\n 1\n ).getTime();\n let offsetToFirst = new Date(msFirstDayOfMonth).getDay();\n if (0 === offsetToFirst) offsetToFirst = 7;\n\n const daysInMonth: Date[] = [];\n // generate 6 weeks of dates\n for (let i = 0; i < 42; i++) {\n const adjustedDay = 1 + i - offsetToFirst;\n daysInMonth.push(\n new Date(displayedYear, displayedMonthIndex, adjustedDay)\n );\n }\n return daysInMonth;\n }, [displayedMonthIndex, displayedYear]);\n\n const weeks = React.useMemo(() => {\n const weeksInMonth = [];\n const weekCount = Math.ceil(days.length / 7);\n for (let i = 0; i < weekCount; i++) {\n weeksInMonth.push(days.slice(i * 7, (i + 1) * 7));\n }\n return weeksInMonth;\n }, [days]);\n\n const setMonthAndYear = React.useCallback(\n (newMonth: number, newYear: number) => {\n setDisplayedMonthIndex(newMonth);\n setDisplayedYear(newYear);\n if (\n selectedDay.getFullYear() === newYear &&\n selectedDay.getMonth() === newMonth\n ) {\n setFocusedDay(new Date(selectedDay.getTime()));\n } else {\n const newFocusDay = new Date(focusedDay.getTime());\n newFocusDay.setFullYear(newYear, newMonth, 1);\n setFocusedDay(newFocusDay);\n }\n },\n [focusedDay, selectedDay]\n );\n\n const handleMoveToPreviousMonth = React.useCallback(() => {\n const newMonth = displayedMonthIndex !== 0 ? displayedMonthIndex - 1 : 11;\n const newYear =\n displayedMonthIndex !== 0 ? displayedYear : displayedYear - 1;\n setMonthAndYear(newMonth, newYear);\n }, [displayedMonthIndex, displayedYear, setMonthAndYear]);\n\n const handleMoveToNextMonth = React.useCallback(() => {\n const newMonth = displayedMonthIndex !== 11 ? displayedMonthIndex + 1 : 0;\n const newYear =\n displayedMonthIndex !== 11 ? displayedYear : displayedYear + 1;\n setMonthAndYear(newMonth, newYear);\n }, [displayedMonthIndex, displayedYear, setMonthAndYear]);\n\n // when invoked, it will return another function which can be used for the onClick React listener.\n const handleOnDayChange = React.useCallback(\n (day: Date) => () => {\n setSelectedDay(day);\n setFocusedDay(day);\n props.onDateChange && props.onDateChange(day);\n },\n [props]\n );\n\n const handleCalendarKeyDown = React.useCallback(\n (event: React.KeyboardEvent<HTMLUListElement>) => {\n if (event.key === SpecialKey.ArrowDown) {\n const focusedDayIndex = days.findIndex((day) =>\n isSameDay(day, focusedDay)\n );\n if (focusedDayIndex + 7 > 41) setFocusedDay(days[focusedDayIndex % 7]);\n else setFocusedDay(days[focusedDayIndex + 7]);\n event.preventDefault();\n }\n if (event.key === SpecialKey.ArrowUp) {\n const focusedDayIndex = days.findIndex((day) =>\n isSameDay(day, focusedDay)\n );\n if (focusedDayIndex - 7 < 0)\n setFocusedDay(days[(focusedDayIndex % 7) + 35]);\n else setFocusedDay(days[focusedDayIndex - 7]);\n event.preventDefault();\n }\n if (event.key === SpecialKey.ArrowLeft) {\n const focusedDayIndex = days.findIndex((day) =>\n isSameDay(day, focusedDay)\n );\n // istanbul ignore else\n if (focusedDayIndex - 1 >= 0) setFocusedDay(days[focusedDayIndex - 1]);\n event.preventDefault();\n }\n if (event.key === SpecialKey.ArrowRight) {\n const focusedDayIndex = days.findIndex((day) =>\n isSameDay(day, focusedDay)\n );\n // istanbul ignore else\n if (focusedDayIndex + 1 <= 41) setFocusedDay(days[focusedDayIndex + 1]);\n event.preventDefault();\n }\n if (event.key === SpecialKey.Enter || event.key === SpecialKey.Space) {\n handleOnDayChange(focusedDay)(); // NB: immediately call returned handler function\n event.preventDefault();\n }\n },\n [days, focusedDay, handleOnDayChange]\n );\n\n const previousButtonClass = classnames(\n \"components-previous-month\",\n props.showFocusOutline && \"showFocusOutline\"\n );\n const nextButtonClass = classnames(\n \"components-next-month\",\n props.showFocusOutline && \"showFocusOutline\"\n );\n const calendarClass = classnames(\n \"components-date-picker-calendar-month\",\n props.showFocusOutline && \"showFocusOutline\"\n );\n\n return (\n <div className=\"components-date-picker-calendar\">\n <div className=\"components-date-picker-calendar-header-months\">\n <button\n className={previousButtonClass}\n title={previousMonthLabel.current}\n onClick={handleMoveToPreviousMonth}\n >\n <Icon iconSpec={<SvgChevronLeft />} />\n </button>\n <span className=\"components-month-year\">\n {monthsLong.current[displayedMonthIndex]} {displayedYear}\n </span>\n <button\n className={nextButtonClass}\n title={nextMonthLabel.current}\n onClick={handleMoveToNextMonth}\n >\n <Icon iconSpec={<SvgChevronRight />} />\n </button>\n </div>\n <div className=\"components-date-picker-calendar-header-weekdays\">\n {[0, 1, 2, 3, 4, 5, 6].map((dayOfWeek) => (\n <div\n key={`day-${dayOfWeek}`}\n className=\"components-date-picker-calendar-header-day-short\"\n title={daysLong.current[dayOfWeek]}\n >\n <span>{daysShort.current[dayOfWeek]}</span>\n </div>\n ))}\n </div>\n <ul\n tabIndex={0}\n onKeyDown={handleCalendarKeyDown}\n data-testid=\"components-date-picker-calendar-list\"\n className={calendarClass}\n role=\"listbox\"\n >\n {weeks.map((weekdays, weekIndex) => (\n <React.Fragment key={`week-${weekIndex}`}>\n {weekdays.map((day: Date, dayIndex: number) => {\n const isActive =\n selectedDay && day && isSameDay(selectedDay, day);\n const isFocused =\n focusedDay &&\n day &&\n isSameDay(focusedDay, day) &&\n props.showFocusOutline;\n const isCurrentMonth = day.getMonth() === displayedMonthIndex;\n const classNames = classnames(\n \"components-date-picker-calendar-day\",\n isActive && \"selected\",\n !isCurrentMonth && \"notCurrentMonth\",\n isFocused && \"focused\"\n );\n const dateValue = day.getDate();\n return (\n /* eslint-disable-next-line jsx-a11y/click-events-have-key-events */\n <li\n className={classNames}\n key={`${displayedYear}.${displayedMonthIndex}.day.${dayIndex}`}\n onClick={handleOnDayChange(day)}\n role=\"option\"\n aria-selected={isActive}\n data-value={day.getTime()}\n >\n <span>{dateValue}</span>\n </li>\n );\n })}\n </React.Fragment>\n ))}\n </ul>\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"DatePicker.js","sourceRoot":"","sources":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AE,GAAG,CAAC,CAAC;YACpD,MAAM,SAAS,GACb,UAAU;gBACV,GAAG;gBACH,SAAS,CAAC,UAAU,EAAE,GAAG,CAAC;gBAC1B,KAAK,CAAC,gBAAgB,CAAC;YACzB,MAAM,cAAc,GAAG,GAAG,CAAC,QAAQ,EAAE,KAAK,mBAAmB,CAAC;YAC9D,MAAM,UAAU,GAAG,IAAA,oBAAU,EAC3B,qCAAqC,EACrC,QAAQ,IAAI,UAAU,EACtB,CAAC,cAAc,IAAI,iBAAiB,EACpC,SAAS,IAAI,SAAS,CACvB,CAAC;YACF,MAAM,SAAS,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC;YAChC,OAAO;YACL,oEAAoE;YACpE,4BACE,SAAS,EAAE,UAAU,EACrB,GAAG,EAAE,GAAG,aAAa,IAAI,mBAAmB,QAAQ,QAAQ,EAAE,EAC9D,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAC/B,IAAI,EAAC,QAAQ,mBACE,QAAQ,gBACX,GAAG,CAAC,OAAO,EAAE;gBAEzB,kCAAO,SAAS,CAAQ,CACrB,CACN,CAAC;QACJ,CAAC,CAAC,CACa,CAClB,CAAC,CACC,CACD,CACP,CAAC;AACJ,CAAC;AA5TD,gCA4TC","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 Date\n */\n\nimport * as React from \"react\";\nimport classnames from \"classnames\";\nimport { Key } from \"ts-key-enum\";\nimport { UiComponents } from \"../UiComponents\";\nimport { Icon } from \"@itwin/core-react\";\nimport { SvgChevronLeft, SvgChevronRight } from \"@itwin/itwinui-icons-react\";\nimport \"./DatePicker.scss\";\n\nfunction isSameDay(a: Date, b: Date) {\n return (\n a &&\n b &&\n a.getFullYear() === b.getFullYear() &&\n a.getMonth() === b.getMonth() &&\n a.getDate() === b.getDate()\n );\n}\n\n/**\n * Props for [[DatePicker]] component.\n * @alpha\n */\nexport interface DatePickerProps {\n /** defines both date and time */\n selected: Date;\n /** function to call when date or time has changed */\n onDateChange?: (day: Date) => void;\n /** show focus outlines, useful for keyboard navigation */\n showFocusOutline?: boolean;\n}\n\n/** DatePicker component. Show a month selector and a day calendar to select a specific date.\n * @alpha\n */\nexport function DatePicker(props: DatePickerProps) {\n const previousMonthLabel = React.useRef(\n UiComponents.localization.getLocalizedString(\n \"UiComponents:datepicker.previousMonth\"\n )\n );\n const nextMonthLabel = React.useRef(\n UiComponents.localization.getLocalizedString(\n \"UiComponents:datepicker.nextMonth\"\n )\n );\n const monthsLong = React.useRef([\n UiComponents.localization.getLocalizedString(\n \"UiComponents:month.long.january\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:month.long.february\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:month.long.march\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:month.long.april\"\n ),\n UiComponents.localization.getLocalizedString(\"UiComponents:month.long.may\"),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:month.long.june\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:month.long.july\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:month.long.august\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:month.long.september\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:month.long.october\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:month.long.november\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:month.long.december\"\n ),\n ]);\n\n const daysLong = React.useRef([\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.long.sunday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.long.monday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.long.tuesday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.long.wednesday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.long.thursday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.long.friday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.long.saturday\"\n ),\n ]);\n\n const daysShort = React.useRef([\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.short.sunday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.short.monday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.short.tuesday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.short.wednesday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.short.thursday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.short.friday\"\n ),\n UiComponents.localization.getLocalizedString(\n \"UiComponents:days.short.saturday\"\n ),\n ]);\n\n const [selectedDay, setSelectedDay] = React.useState(\n new Date(props.selected.getTime())\n );\n const [displayedMonthIndex, setDisplayedMonthIndex] = React.useState(\n selectedDay.getMonth()\n );\n const [displayedYear, setDisplayedYear] = React.useState(\n selectedDay.getFullYear()\n );\n const [focusedDay, setFocusedDay] = React.useState(selectedDay);\n React.useEffect(() => {\n const newSelectedDay = new Date(props.selected);\n setSelectedDay(new Date(props.selected));\n setDisplayedMonthIndex(newSelectedDay.getMonth());\n setDisplayedYear(newSelectedDay.getFullYear());\n setFocusedDay(newSelectedDay);\n }, [props.selected]);\n const days = React.useMemo(() => {\n const msFirstDayOfMonth = new Date(\n displayedYear,\n displayedMonthIndex,\n 1\n ).getTime();\n let offsetToFirst = new Date(msFirstDayOfMonth).getDay();\n if (0 === offsetToFirst) offsetToFirst = 7;\n\n const daysInMonth: Date[] = [];\n // generate 6 weeks of dates\n for (let i = 0; i < 42; i++) {\n const adjustedDay = 1 + i - offsetToFirst;\n daysInMonth.push(\n new Date(displayedYear, displayedMonthIndex, adjustedDay)\n );\n }\n return daysInMonth;\n }, [displayedMonthIndex, displayedYear]);\n\n const weeks = React.useMemo(() => {\n const weeksInMonth = [];\n const weekCount = Math.ceil(days.length / 7);\n for (let i = 0; i < weekCount; i++) {\n weeksInMonth.push(days.slice(i * 7, (i + 1) * 7));\n }\n return weeksInMonth;\n }, [days]);\n\n const setMonthAndYear = React.useCallback(\n (newMonth: number, newYear: number) => {\n setDisplayedMonthIndex(newMonth);\n setDisplayedYear(newYear);\n if (\n selectedDay.getFullYear() === newYear &&\n selectedDay.getMonth() === newMonth\n ) {\n setFocusedDay(new Date(selectedDay.getTime()));\n } else {\n const newFocusDay = new Date(focusedDay.getTime());\n newFocusDay.setFullYear(newYear, newMonth, 1);\n setFocusedDay(newFocusDay);\n }\n },\n [focusedDay, selectedDay]\n );\n\n const handleMoveToPreviousMonth = React.useCallback(() => {\n const newMonth = displayedMonthIndex !== 0 ? displayedMonthIndex - 1 : 11;\n const newYear =\n displayedMonthIndex !== 0 ? displayedYear : displayedYear - 1;\n setMonthAndYear(newMonth, newYear);\n }, [displayedMonthIndex, displayedYear, setMonthAndYear]);\n\n const handleMoveToNextMonth = React.useCallback(() => {\n const newMonth = displayedMonthIndex !== 11 ? displayedMonthIndex + 1 : 0;\n const newYear =\n displayedMonthIndex !== 11 ? displayedYear : displayedYear + 1;\n setMonthAndYear(newMonth, newYear);\n }, [displayedMonthIndex, displayedYear, setMonthAndYear]);\n\n // when invoked, it will return another function which can be used for the onClick React listener.\n const handleOnDayChange = React.useCallback(\n (day: Date) => () => {\n setSelectedDay(day);\n setFocusedDay(day);\n props.onDateChange && props.onDateChange(day);\n },\n [props]\n );\n\n const handleCalendarKeyDown = React.useCallback(\n (event: React.KeyboardEvent<HTMLUListElement>) => {\n if (event.key === Key.ArrowDown) {\n const focusedDayIndex = days.findIndex((day) =>\n isSameDay(day, focusedDay)\n );\n if (focusedDayIndex + 7 > 41) setFocusedDay(days[focusedDayIndex % 7]);\n else setFocusedDay(days[focusedDayIndex + 7]);\n event.preventDefault();\n }\n if (event.key === Key.ArrowUp) {\n const focusedDayIndex = days.findIndex((day) =>\n isSameDay(day, focusedDay)\n );\n if (focusedDayIndex - 7 < 0)\n setFocusedDay(days[(focusedDayIndex % 7) + 35]);\n else setFocusedDay(days[focusedDayIndex - 7]);\n event.preventDefault();\n }\n if (event.key === Key.ArrowLeft) {\n const focusedDayIndex = days.findIndex((day) =>\n isSameDay(day, focusedDay)\n );\n // istanbul ignore else\n if (focusedDayIndex - 1 >= 0) setFocusedDay(days[focusedDayIndex - 1]);\n event.preventDefault();\n }\n if (event.key === Key.ArrowRight) {\n const focusedDayIndex = days.findIndex((day) =>\n isSameDay(day, focusedDay)\n );\n // istanbul ignore else\n if (focusedDayIndex + 1 <= 41) setFocusedDay(days[focusedDayIndex + 1]);\n event.preventDefault();\n }\n if (event.key === Key.Enter || event.key === \" \") {\n handleOnDayChange(focusedDay)(); // NB: immediately call returned handler function\n event.preventDefault();\n }\n },\n [days, focusedDay, handleOnDayChange]\n );\n\n const previousButtonClass = classnames(\n \"components-previous-month\",\n props.showFocusOutline && \"showFocusOutline\"\n );\n const nextButtonClass = classnames(\n \"components-next-month\",\n props.showFocusOutline && \"showFocusOutline\"\n );\n const calendarClass = classnames(\n \"components-date-picker-calendar-month\",\n props.showFocusOutline && \"showFocusOutline\"\n );\n\n return (\n <div className=\"components-date-picker-calendar\">\n <div className=\"components-date-picker-calendar-header-months\">\n <button\n className={previousButtonClass}\n title={previousMonthLabel.current}\n onClick={handleMoveToPreviousMonth}\n >\n <Icon iconSpec={<SvgChevronLeft />} />\n </button>\n <span className=\"components-month-year\">\n {monthsLong.current[displayedMonthIndex]} {displayedYear}\n </span>\n <button\n className={nextButtonClass}\n title={nextMonthLabel.current}\n onClick={handleMoveToNextMonth}\n >\n <Icon iconSpec={<SvgChevronRight />} />\n </button>\n </div>\n <div className=\"components-date-picker-calendar-header-weekdays\">\n {[0, 1, 2, 3, 4, 5, 6].map((dayOfWeek) => (\n <div\n key={`day-${dayOfWeek}`}\n className=\"components-date-picker-calendar-header-day-short\"\n title={daysLong.current[dayOfWeek]}\n >\n <span>{daysShort.current[dayOfWeek]}</span>\n </div>\n ))}\n </div>\n <ul\n tabIndex={0}\n onKeyDown={handleCalendarKeyDown}\n data-testid=\"components-date-picker-calendar-list\"\n className={calendarClass}\n role=\"listbox\"\n >\n {weeks.map((weekdays, weekIndex) => (\n <React.Fragment key={`week-${weekIndex}`}>\n {weekdays.map((day: Date, dayIndex: number) => {\n const isActive =\n selectedDay && day && isSameDay(selectedDay, day);\n const isFocused =\n focusedDay &&\n day &&\n isSameDay(focusedDay, day) &&\n props.showFocusOutline;\n const isCurrentMonth = day.getMonth() === displayedMonthIndex;\n const classNames = classnames(\n \"components-date-picker-calendar-day\",\n isActive && \"selected\",\n !isCurrentMonth && \"notCurrentMonth\",\n isFocused && \"focused\"\n );\n const dateValue = day.getDate();\n return (\n /* eslint-disable-next-line jsx-a11y/click-events-have-key-events */\n <li\n className={classNames}\n key={`${displayedYear}.${displayedMonthIndex}.day.${dayIndex}`}\n onClick={handleOnDayChange(day)}\n role=\"option\"\n aria-selected={isActive}\n data-value={day.getTime()}\n >\n <span>{dateValue}</span>\n </li>\n );\n })}\n </React.Fragment>\n ))}\n </ul>\n </div>\n );\n}\n"]}
@@ -80,7 +80,7 @@ function DatePickerPopupButton({ displayEditField, timeDisplay, selected, onDate
80
80
  const [showFocusOutline, setShowFocusOutline] = React.useState(false);
81
81
  const handlePopupKeyDown = React.useCallback((event) => {
82
82
  // istanbul ignore else
83
- if (event.key === appui_abstract_1.SpecialKey.Space) {
83
+ if (event.key === " ") {
84
84
  setShowFocusOutline(true);
85
85
  setIsSettingsOpen(true);
86
86
  }