@itwin/components-react 4.10.0 → 4.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (323) hide show
  1. package/CHANGELOG.md +14 -1
  2. package/lib/cjs/components-react/UiComponents.d.ts +1 -1
  3. package/lib/cjs/components-react/UiComponents.js +2 -4
  4. package/lib/cjs/components-react/UiComponents.js.map +1 -1
  5. package/lib/cjs/components-react/common/DelayedSpinner.js +3 -2
  6. package/lib/cjs/components-react/common/DelayedSpinner.js.map +1 -1
  7. package/lib/cjs/components-react/common/UseDebouncedAsyncValue.js +2 -1
  8. package/lib/cjs/components-react/common/UseDebouncedAsyncValue.js.map +1 -1
  9. package/lib/cjs/components-react/converters/NumericTypeConverter.js +4 -2
  10. package/lib/cjs/components-react/converters/NumericTypeConverter.js.map +1 -1
  11. package/lib/cjs/components-react/converters/TypeConverter.js +2 -1
  12. package/lib/cjs/components-react/converters/TypeConverter.js.map +1 -1
  13. package/lib/cjs/components-react/datepicker/DatePicker.d.ts +2 -0
  14. package/lib/cjs/components-react/datepicker/DatePicker.d.ts.map +1 -1
  15. package/lib/cjs/components-react/datepicker/DatePicker.js +43 -40
  16. package/lib/cjs/components-react/datepicker/DatePicker.js.map +1 -1
  17. package/lib/cjs/components-react/datepicker/DatePickerPopupButton.d.ts +5 -2
  18. package/lib/cjs/components-react/datepicker/DatePickerPopupButton.d.ts.map +1 -1
  19. package/lib/cjs/components-react/datepicker/DatePickerPopupButton.js +8 -7
  20. package/lib/cjs/components-react/datepicker/DatePickerPopupButton.js.map +1 -1
  21. package/lib/cjs/components-react/datepicker/IntlFormatter.d.ts +1 -0
  22. package/lib/cjs/components-react/datepicker/IntlFormatter.d.ts.map +1 -1
  23. package/lib/cjs/components-react/datepicker/IntlFormatter.js +1 -0
  24. package/lib/cjs/components-react/datepicker/IntlFormatter.js.map +1 -1
  25. package/lib/cjs/components-react/datepicker/TimeField.d.ts.map +1 -1
  26. package/lib/cjs/components-react/datepicker/TimeField.js +28 -30
  27. package/lib/cjs/components-react/datepicker/TimeField.js.map +1 -1
  28. package/lib/cjs/components-react/editors/CustomNumberEditor.js +8 -6
  29. package/lib/cjs/components-react/editors/CustomNumberEditor.js.map +1 -1
  30. package/lib/cjs/components-react/editors/DateTimeEditor.js +5 -3
  31. package/lib/cjs/components-react/editors/DateTimeEditor.js.map +1 -1
  32. package/lib/cjs/components-react/editors/EnumEditor.d.ts +0 -1
  33. package/lib/cjs/components-react/editors/EnumEditor.d.ts.map +1 -1
  34. package/lib/cjs/components-react/editors/EnumEditor.js +2 -3
  35. package/lib/cjs/components-react/editors/EnumEditor.js.map +1 -1
  36. package/lib/cjs/components-react/editors/PopupButton.d.ts.map +1 -1
  37. package/lib/cjs/components-react/editors/PopupButton.js +8 -5
  38. package/lib/cjs/components-react/editors/PopupButton.js.map +1 -1
  39. package/lib/cjs/components-react/editors/TextEditor.d.ts +0 -1
  40. package/lib/cjs/components-react/editors/TextEditor.d.ts.map +1 -1
  41. package/lib/cjs/components-react/editors/TextEditor.js +5 -4
  42. package/lib/cjs/components-react/editors/TextEditor.js.map +1 -1
  43. package/lib/cjs/components-react/editors/TextareaEditor.d.ts +0 -1
  44. package/lib/cjs/components-react/editors/TextareaEditor.d.ts.map +1 -1
  45. package/lib/cjs/components-react/editors/TextareaEditor.js +1 -2
  46. package/lib/cjs/components-react/editors/TextareaEditor.js.map +1 -1
  47. package/lib/cjs/components-react/favorite/FavoritePropertyList.js +3 -3
  48. package/lib/cjs/components-react/favorite/FavoritePropertyList.js.map +1 -1
  49. package/lib/cjs/components-react/filter-builder/FilterBuilderLogicalOperator.d.ts.map +1 -1
  50. package/lib/cjs/components-react/filter-builder/FilterBuilderLogicalOperator.js +4 -3
  51. package/lib/cjs/components-react/filter-builder/FilterBuilderLogicalOperator.js.map +1 -1
  52. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleOperator.js +2 -1
  53. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleOperator.js.map +1 -1
  54. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleProperty.d.ts.map +1 -1
  55. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleProperty.js +6 -5
  56. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleProperty.js.map +1 -1
  57. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleValue.js +4 -3
  58. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleValue.js.map +1 -1
  59. package/lib/cjs/components-react/filter-builder/FilterBuilderState.js +3 -3
  60. package/lib/cjs/components-react/filter-builder/FilterBuilderState.js.map +1 -1
  61. package/lib/cjs/components-react/filter-builder/FilterBuilderToolbar.d.ts.map +1 -1
  62. package/lib/cjs/components-react/filter-builder/FilterBuilderToolbar.js +4 -3
  63. package/lib/cjs/components-react/filter-builder/FilterBuilderToolbar.js.map +1 -1
  64. package/lib/cjs/components-react/filtering/FilteringInput.d.ts +0 -3
  65. package/lib/cjs/components-react/filtering/FilteringInput.d.ts.map +1 -1
  66. package/lib/cjs/components-react/filtering/FilteringInput.js +5 -7
  67. package/lib/cjs/components-react/filtering/FilteringInput.js.map +1 -1
  68. package/lib/cjs/components-react/filtering/ResultSelector.d.ts +0 -1
  69. package/lib/cjs/components-react/filtering/ResultSelector.d.ts.map +1 -1
  70. package/lib/cjs/components-react/filtering/ResultSelector.js +1 -2
  71. package/lib/cjs/components-react/filtering/ResultSelector.js.map +1 -1
  72. package/lib/cjs/components-react/properties/ValueRendererManager.d.ts +3 -0
  73. package/lib/cjs/components-react/properties/ValueRendererManager.d.ts.map +1 -1
  74. package/lib/cjs/components-react/properties/ValueRendererManager.js +12 -1
  75. package/lib/cjs/components-react/properties/ValueRendererManager.js.map +1 -1
  76. package/lib/cjs/components-react/properties/renderers/CommonPropertyRenderer.js +4 -3
  77. package/lib/cjs/components-react/properties/renderers/CommonPropertyRenderer.js.map +1 -1
  78. package/lib/cjs/components-react/properties/renderers/CustomizablePropertyRenderer.d.ts +25 -0
  79. package/lib/cjs/components-react/properties/renderers/CustomizablePropertyRenderer.d.ts.map +1 -0
  80. package/lib/cjs/components-react/properties/renderers/CustomizablePropertyRenderer.js +62 -0
  81. package/lib/cjs/components-react/properties/renderers/CustomizablePropertyRenderer.js.map +1 -0
  82. package/lib/cjs/components-react/properties/renderers/NonPrimitivePropertyRenderer.js +1 -1
  83. package/lib/cjs/components-react/properties/renderers/NonPrimitivePropertyRenderer.js.map +1 -1
  84. package/lib/cjs/components-react/properties/renderers/PrimitivePropertyRenderer.d.ts +3 -4
  85. package/lib/cjs/components-react/properties/renderers/PrimitivePropertyRenderer.d.ts.map +1 -1
  86. package/lib/cjs/components-react/properties/renderers/PrimitivePropertyRenderer.js +6 -44
  87. package/lib/cjs/components-react/properties/renderers/PrimitivePropertyRenderer.js.map +1 -1
  88. package/lib/cjs/components-react/properties/renderers/PropertyView.d.ts +1 -1
  89. package/lib/cjs/components-react/properties/renderers/PropertyView.d.ts.map +1 -1
  90. package/lib/cjs/components-react/properties/renderers/PropertyView.js +2 -3
  91. package/lib/cjs/components-react/properties/renderers/PropertyView.js.map +1 -1
  92. package/lib/cjs/components-react/properties/renderers/label/PropertyLabelRenderer.js +4 -4
  93. package/lib/cjs/components-react/properties/renderers/label/PropertyLabelRenderer.js.map +1 -1
  94. package/lib/cjs/components-react/properties/renderers/value/Common.js +2 -1
  95. package/lib/cjs/components-react/properties/renderers/value/Common.js.map +1 -1
  96. package/lib/cjs/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.d.ts.map +1 -1
  97. package/lib/cjs/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.js +8 -11
  98. package/lib/cjs/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.js.map +1 -1
  99. package/lib/cjs/components-react/properties/renderers/value/PrimitivePropertyValueRenderer.js +6 -3
  100. package/lib/cjs/components-react/properties/renderers/value/PrimitivePropertyValueRenderer.js.map +1 -1
  101. package/lib/cjs/components-react/propertygrid/PropertyCategoryRendererManager.js +2 -1
  102. package/lib/cjs/components-react/propertygrid/PropertyCategoryRendererManager.js.map +1 -1
  103. package/lib/cjs/components-react/propertygrid/component/ColumnResizingPropertyListPropsSupplier.js +2 -1
  104. package/lib/cjs/components-react/propertygrid/component/ColumnResizingPropertyListPropsSupplier.js.map +1 -1
  105. package/lib/cjs/components-react/propertygrid/component/PropertyCategoryBlock.js +2 -1
  106. package/lib/cjs/components-react/propertygrid/component/PropertyCategoryBlock.js.map +1 -1
  107. package/lib/cjs/components-react/propertygrid/component/PropertyGridCommons.js +2 -2
  108. package/lib/cjs/components-react/propertygrid/component/PropertyGridCommons.js.map +1 -1
  109. package/lib/cjs/components-react/propertygrid/component/PropertyGridEventsRelatedPropsSupplier.d.ts.map +1 -1
  110. package/lib/cjs/components-react/propertygrid/component/PropertyGridEventsRelatedPropsSupplier.js +1 -3
  111. package/lib/cjs/components-react/propertygrid/component/PropertyGridEventsRelatedPropsSupplier.js.map +1 -1
  112. package/lib/cjs/components-react/propertygrid/component/VirtualizedPropertyGrid.d.ts +1 -3
  113. package/lib/cjs/components-react/propertygrid/component/VirtualizedPropertyGrid.d.ts.map +1 -1
  114. package/lib/cjs/components-react/propertygrid/component/VirtualizedPropertyGrid.js +90 -80
  115. package/lib/cjs/components-react/propertygrid/component/VirtualizedPropertyGrid.js.map +1 -1
  116. package/lib/cjs/components-react/propertygrid/dataproviders/FilteringDataProvider.js +13 -11
  117. package/lib/cjs/components-react/propertygrid/dataproviders/FilteringDataProvider.js.map +1 -1
  118. package/lib/cjs/components-react/propertygrid/dataproviders/filterers/CompositePropertyDataFilterer.js +2 -2
  119. package/lib/cjs/components-react/propertygrid/dataproviders/filterers/CompositePropertyDataFilterer.js.map +1 -1
  120. package/lib/cjs/components-react/propertygrid/dataproviders/filterers/DisplayValuePropertyDataFilterer.js +2 -1
  121. package/lib/cjs/components-react/propertygrid/dataproviders/filterers/DisplayValuePropertyDataFilterer.js.map +1 -1
  122. package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableCustomGridCategory.js +2 -1
  123. package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableCustomGridCategory.js.map +1 -1
  124. package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.js +2 -2
  125. package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.js.map +1 -1
  126. package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableGridCategory.js +3 -2
  127. package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableGridCategory.js.map +1 -1
  128. package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableGridItemFactory.js +1 -1
  129. package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableGridItemFactory.js.map +1 -1
  130. package/lib/cjs/components-react/propertygrid/internal/flat-properties/FlatNonPrimitivePropertyRenderer.js +1 -1
  131. package/lib/cjs/components-react/propertygrid/internal/flat-properties/FlatNonPrimitivePropertyRenderer.js.map +1 -1
  132. package/lib/cjs/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.d.ts +1 -1
  133. package/lib/cjs/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.d.ts.map +1 -1
  134. package/lib/cjs/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.js +22 -12
  135. package/lib/cjs/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.js.map +1 -1
  136. package/lib/cjs/components-react/selectable-content/SelectableContent.js +3 -2
  137. package/lib/cjs/components-react/selectable-content/SelectableContent.js.map +1 -1
  138. package/lib/cjs/components-react/toolbar/InternalToolbarComponent.d.ts.map +1 -1
  139. package/lib/cjs/components-react/toolbar/InternalToolbarComponent.js +15 -14
  140. package/lib/cjs/components-react/toolbar/InternalToolbarComponent.js.map +1 -1
  141. package/lib/cjs/components-react/toolbar/useConditionalSynchedItems.js +6 -5
  142. package/lib/cjs/components-react/toolbar/useConditionalSynchedItems.js.map +1 -1
  143. package/lib/cjs/components-react/tree/controlled/TreeModel.js +8 -7
  144. package/lib/cjs/components-react/tree/controlled/TreeModel.js.map +1 -1
  145. package/lib/cjs/components-react/tree/controlled/TreeNodeLoader.js +8 -6
  146. package/lib/cjs/components-react/tree/controlled/TreeNodeLoader.js.map +1 -1
  147. package/lib/cjs/components-react/tree/controlled/component/ControlledTree.d.ts.map +1 -1
  148. package/lib/cjs/components-react/tree/controlled/component/ControlledTree.js +3 -2
  149. package/lib/cjs/components-react/tree/controlled/component/ControlledTree.js.map +1 -1
  150. package/lib/cjs/components-react/tree/controlled/internal/SparseTree.js +2 -1
  151. package/lib/cjs/components-react/tree/controlled/internal/SparseTree.js.map +1 -1
  152. package/lib/cjs/components-react/tree/controlled/internal/TreeSelectionManager.js +4 -2
  153. package/lib/cjs/components-react/tree/controlled/internal/TreeSelectionManager.js.map +1 -1
  154. package/lib/cjs/components-react/useTranslation.d.ts +10 -0
  155. package/lib/cjs/components-react/useTranslation.d.ts.map +1 -0
  156. package/lib/cjs/components-react/useTranslation.js +20 -0
  157. package/lib/cjs/components-react/useTranslation.js.map +1 -0
  158. package/lib/cjs/components-react.d.ts +1 -0
  159. package/lib/cjs/components-react.d.ts.map +1 -1
  160. package/lib/cjs/components-react.js +1 -0
  161. package/lib/cjs/components-react.js.map +1 -1
  162. package/lib/esm/components-react/UiComponents.d.ts +1 -1
  163. package/lib/esm/components-react/UiComponents.js +2 -4
  164. package/lib/esm/components-react/UiComponents.js.map +1 -1
  165. package/lib/esm/components-react/common/DelayedSpinner.js +3 -2
  166. package/lib/esm/components-react/common/DelayedSpinner.js.map +1 -1
  167. package/lib/esm/components-react/common/UseDebouncedAsyncValue.js +2 -1
  168. package/lib/esm/components-react/common/UseDebouncedAsyncValue.js.map +1 -1
  169. package/lib/esm/components-react/converters/NumericTypeConverter.js +4 -2
  170. package/lib/esm/components-react/converters/NumericTypeConverter.js.map +1 -1
  171. package/lib/esm/components-react/converters/TypeConverter.js +2 -1
  172. package/lib/esm/components-react/converters/TypeConverter.js.map +1 -1
  173. package/lib/esm/components-react/datepicker/DatePicker.d.ts +2 -0
  174. package/lib/esm/components-react/datepicker/DatePicker.d.ts.map +1 -1
  175. package/lib/esm/components-react/datepicker/DatePicker.js +43 -40
  176. package/lib/esm/components-react/datepicker/DatePicker.js.map +1 -1
  177. package/lib/esm/components-react/datepicker/DatePickerPopupButton.d.ts +5 -2
  178. package/lib/esm/components-react/datepicker/DatePickerPopupButton.d.ts.map +1 -1
  179. package/lib/esm/components-react/datepicker/DatePickerPopupButton.js +8 -7
  180. package/lib/esm/components-react/datepicker/DatePickerPopupButton.js.map +1 -1
  181. package/lib/esm/components-react/datepicker/IntlFormatter.d.ts +1 -0
  182. package/lib/esm/components-react/datepicker/IntlFormatter.d.ts.map +1 -1
  183. package/lib/esm/components-react/datepicker/IntlFormatter.js +1 -0
  184. package/lib/esm/components-react/datepicker/IntlFormatter.js.map +1 -1
  185. package/lib/esm/components-react/datepicker/TimeField.d.ts.map +1 -1
  186. package/lib/esm/components-react/datepicker/TimeField.js +28 -30
  187. package/lib/esm/components-react/datepicker/TimeField.js.map +1 -1
  188. package/lib/esm/components-react/editors/CustomNumberEditor.js +8 -6
  189. package/lib/esm/components-react/editors/CustomNumberEditor.js.map +1 -1
  190. package/lib/esm/components-react/editors/DateTimeEditor.js +5 -3
  191. package/lib/esm/components-react/editors/DateTimeEditor.js.map +1 -1
  192. package/lib/esm/components-react/editors/EnumEditor.d.ts +0 -1
  193. package/lib/esm/components-react/editors/EnumEditor.d.ts.map +1 -1
  194. package/lib/esm/components-react/editors/EnumEditor.js +2 -3
  195. package/lib/esm/components-react/editors/EnumEditor.js.map +1 -1
  196. package/lib/esm/components-react/editors/PopupButton.d.ts.map +1 -1
  197. package/lib/esm/components-react/editors/PopupButton.js +9 -6
  198. package/lib/esm/components-react/editors/PopupButton.js.map +1 -1
  199. package/lib/esm/components-react/editors/TextEditor.d.ts +0 -1
  200. package/lib/esm/components-react/editors/TextEditor.d.ts.map +1 -1
  201. package/lib/esm/components-react/editors/TextEditor.js +5 -4
  202. package/lib/esm/components-react/editors/TextEditor.js.map +1 -1
  203. package/lib/esm/components-react/editors/TextareaEditor.d.ts +0 -1
  204. package/lib/esm/components-react/editors/TextareaEditor.d.ts.map +1 -1
  205. package/lib/esm/components-react/editors/TextareaEditor.js +1 -2
  206. package/lib/esm/components-react/editors/TextareaEditor.js.map +1 -1
  207. package/lib/esm/components-react/favorite/FavoritePropertyList.js +3 -3
  208. package/lib/esm/components-react/favorite/FavoritePropertyList.js.map +1 -1
  209. package/lib/esm/components-react/filter-builder/FilterBuilderLogicalOperator.d.ts.map +1 -1
  210. package/lib/esm/components-react/filter-builder/FilterBuilderLogicalOperator.js +4 -3
  211. package/lib/esm/components-react/filter-builder/FilterBuilderLogicalOperator.js.map +1 -1
  212. package/lib/esm/components-react/filter-builder/FilterBuilderRuleOperator.js +2 -1
  213. package/lib/esm/components-react/filter-builder/FilterBuilderRuleOperator.js.map +1 -1
  214. package/lib/esm/components-react/filter-builder/FilterBuilderRuleProperty.d.ts.map +1 -1
  215. package/lib/esm/components-react/filter-builder/FilterBuilderRuleProperty.js +6 -5
  216. package/lib/esm/components-react/filter-builder/FilterBuilderRuleProperty.js.map +1 -1
  217. package/lib/esm/components-react/filter-builder/FilterBuilderRuleValue.js +4 -3
  218. package/lib/esm/components-react/filter-builder/FilterBuilderRuleValue.js.map +1 -1
  219. package/lib/esm/components-react/filter-builder/FilterBuilderState.js +3 -3
  220. package/lib/esm/components-react/filter-builder/FilterBuilderState.js.map +1 -1
  221. package/lib/esm/components-react/filter-builder/FilterBuilderToolbar.d.ts.map +1 -1
  222. package/lib/esm/components-react/filter-builder/FilterBuilderToolbar.js +4 -3
  223. package/lib/esm/components-react/filter-builder/FilterBuilderToolbar.js.map +1 -1
  224. package/lib/esm/components-react/filtering/FilteringInput.d.ts +0 -3
  225. package/lib/esm/components-react/filtering/FilteringInput.d.ts.map +1 -1
  226. package/lib/esm/components-react/filtering/FilteringInput.js +6 -8
  227. package/lib/esm/components-react/filtering/FilteringInput.js.map +1 -1
  228. package/lib/esm/components-react/filtering/ResultSelector.d.ts +0 -1
  229. package/lib/esm/components-react/filtering/ResultSelector.d.ts.map +1 -1
  230. package/lib/esm/components-react/filtering/ResultSelector.js +1 -2
  231. package/lib/esm/components-react/filtering/ResultSelector.js.map +1 -1
  232. package/lib/esm/components-react/properties/ValueRendererManager.d.ts +3 -0
  233. package/lib/esm/components-react/properties/ValueRendererManager.d.ts.map +1 -1
  234. package/lib/esm/components-react/properties/ValueRendererManager.js +12 -1
  235. package/lib/esm/components-react/properties/ValueRendererManager.js.map +1 -1
  236. package/lib/esm/components-react/properties/renderers/CommonPropertyRenderer.js +4 -3
  237. package/lib/esm/components-react/properties/renderers/CommonPropertyRenderer.js.map +1 -1
  238. package/lib/esm/components-react/properties/renderers/CustomizablePropertyRenderer.d.ts +25 -0
  239. package/lib/esm/components-react/properties/renderers/CustomizablePropertyRenderer.d.ts.map +1 -0
  240. package/lib/esm/components-react/properties/renderers/CustomizablePropertyRenderer.js +35 -0
  241. package/lib/esm/components-react/properties/renderers/CustomizablePropertyRenderer.js.map +1 -0
  242. package/lib/esm/components-react/properties/renderers/NonPrimitivePropertyRenderer.js +1 -1
  243. package/lib/esm/components-react/properties/renderers/NonPrimitivePropertyRenderer.js.map +1 -1
  244. package/lib/esm/components-react/properties/renderers/PrimitivePropertyRenderer.d.ts +3 -4
  245. package/lib/esm/components-react/properties/renderers/PrimitivePropertyRenderer.d.ts.map +1 -1
  246. package/lib/esm/components-react/properties/renderers/PrimitivePropertyRenderer.js +3 -21
  247. package/lib/esm/components-react/properties/renderers/PrimitivePropertyRenderer.js.map +1 -1
  248. package/lib/esm/components-react/properties/renderers/PropertyView.d.ts +1 -1
  249. package/lib/esm/components-react/properties/renderers/PropertyView.d.ts.map +1 -1
  250. package/lib/esm/components-react/properties/renderers/PropertyView.js +2 -3
  251. package/lib/esm/components-react/properties/renderers/PropertyView.js.map +1 -1
  252. package/lib/esm/components-react/properties/renderers/label/PropertyLabelRenderer.js +4 -4
  253. package/lib/esm/components-react/properties/renderers/label/PropertyLabelRenderer.js.map +1 -1
  254. package/lib/esm/components-react/properties/renderers/value/Common.js +2 -1
  255. package/lib/esm/components-react/properties/renderers/value/Common.js.map +1 -1
  256. package/lib/esm/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.d.ts.map +1 -1
  257. package/lib/esm/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.js +8 -11
  258. package/lib/esm/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.js.map +1 -1
  259. package/lib/esm/components-react/properties/renderers/value/PrimitivePropertyValueRenderer.js +6 -3
  260. package/lib/esm/components-react/properties/renderers/value/PrimitivePropertyValueRenderer.js.map +1 -1
  261. package/lib/esm/components-react/propertygrid/PropertyCategoryRendererManager.js +2 -1
  262. package/lib/esm/components-react/propertygrid/PropertyCategoryRendererManager.js.map +1 -1
  263. package/lib/esm/components-react/propertygrid/component/ColumnResizingPropertyListPropsSupplier.js +2 -1
  264. package/lib/esm/components-react/propertygrid/component/ColumnResizingPropertyListPropsSupplier.js.map +1 -1
  265. package/lib/esm/components-react/propertygrid/component/PropertyCategoryBlock.js +2 -1
  266. package/lib/esm/components-react/propertygrid/component/PropertyCategoryBlock.js.map +1 -1
  267. package/lib/esm/components-react/propertygrid/component/PropertyGridCommons.js +2 -2
  268. package/lib/esm/components-react/propertygrid/component/PropertyGridCommons.js.map +1 -1
  269. package/lib/esm/components-react/propertygrid/component/PropertyGridEventsRelatedPropsSupplier.d.ts.map +1 -1
  270. package/lib/esm/components-react/propertygrid/component/PropertyGridEventsRelatedPropsSupplier.js +1 -3
  271. package/lib/esm/components-react/propertygrid/component/PropertyGridEventsRelatedPropsSupplier.js.map +1 -1
  272. package/lib/esm/components-react/propertygrid/component/VirtualizedPropertyGrid.d.ts +1 -3
  273. package/lib/esm/components-react/propertygrid/component/VirtualizedPropertyGrid.d.ts.map +1 -1
  274. package/lib/esm/components-react/propertygrid/component/VirtualizedPropertyGrid.js +90 -80
  275. package/lib/esm/components-react/propertygrid/component/VirtualizedPropertyGrid.js.map +1 -1
  276. package/lib/esm/components-react/propertygrid/dataproviders/FilteringDataProvider.js +13 -11
  277. package/lib/esm/components-react/propertygrid/dataproviders/FilteringDataProvider.js.map +1 -1
  278. package/lib/esm/components-react/propertygrid/dataproviders/filterers/CompositePropertyDataFilterer.js +2 -2
  279. package/lib/esm/components-react/propertygrid/dataproviders/filterers/CompositePropertyDataFilterer.js.map +1 -1
  280. package/lib/esm/components-react/propertygrid/dataproviders/filterers/DisplayValuePropertyDataFilterer.js +2 -1
  281. package/lib/esm/components-react/propertygrid/dataproviders/filterers/DisplayValuePropertyDataFilterer.js.map +1 -1
  282. package/lib/esm/components-react/propertygrid/internal/flat-items/MutableCustomGridCategory.js +2 -1
  283. package/lib/esm/components-react/propertygrid/internal/flat-items/MutableCustomGridCategory.js.map +1 -1
  284. package/lib/esm/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.js +2 -2
  285. package/lib/esm/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.js.map +1 -1
  286. package/lib/esm/components-react/propertygrid/internal/flat-items/MutableGridCategory.js +3 -2
  287. package/lib/esm/components-react/propertygrid/internal/flat-items/MutableGridCategory.js.map +1 -1
  288. package/lib/esm/components-react/propertygrid/internal/flat-items/MutableGridItemFactory.js +1 -1
  289. package/lib/esm/components-react/propertygrid/internal/flat-items/MutableGridItemFactory.js.map +1 -1
  290. package/lib/esm/components-react/propertygrid/internal/flat-properties/FlatNonPrimitivePropertyRenderer.js +1 -1
  291. package/lib/esm/components-react/propertygrid/internal/flat-properties/FlatNonPrimitivePropertyRenderer.js.map +1 -1
  292. package/lib/esm/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.d.ts +1 -1
  293. package/lib/esm/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.d.ts.map +1 -1
  294. package/lib/esm/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.js +22 -12
  295. package/lib/esm/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.js.map +1 -1
  296. package/lib/esm/components-react/selectable-content/SelectableContent.js +3 -2
  297. package/lib/esm/components-react/selectable-content/SelectableContent.js.map +1 -1
  298. package/lib/esm/components-react/toolbar/InternalToolbarComponent.d.ts.map +1 -1
  299. package/lib/esm/components-react/toolbar/InternalToolbarComponent.js +15 -14
  300. package/lib/esm/components-react/toolbar/InternalToolbarComponent.js.map +1 -1
  301. package/lib/esm/components-react/toolbar/useConditionalSynchedItems.js +6 -5
  302. package/lib/esm/components-react/toolbar/useConditionalSynchedItems.js.map +1 -1
  303. package/lib/esm/components-react/tree/controlled/TreeModel.js +8 -7
  304. package/lib/esm/components-react/tree/controlled/TreeModel.js.map +1 -1
  305. package/lib/esm/components-react/tree/controlled/TreeNodeLoader.js +8 -6
  306. package/lib/esm/components-react/tree/controlled/TreeNodeLoader.js.map +1 -1
  307. package/lib/esm/components-react/tree/controlled/component/ControlledTree.d.ts.map +1 -1
  308. package/lib/esm/components-react/tree/controlled/component/ControlledTree.js +3 -2
  309. package/lib/esm/components-react/tree/controlled/component/ControlledTree.js.map +1 -1
  310. package/lib/esm/components-react/tree/controlled/internal/SparseTree.js +2 -1
  311. package/lib/esm/components-react/tree/controlled/internal/SparseTree.js.map +1 -1
  312. package/lib/esm/components-react/tree/controlled/internal/TreeSelectionManager.js +4 -2
  313. package/lib/esm/components-react/tree/controlled/internal/TreeSelectionManager.js.map +1 -1
  314. package/lib/esm/components-react/useTranslation.d.ts +10 -0
  315. package/lib/esm/components-react/useTranslation.d.ts.map +1 -0
  316. package/lib/esm/components-react/useTranslation.js +16 -0
  317. package/lib/esm/components-react/useTranslation.js.map +1 -0
  318. package/lib/esm/components-react.d.ts +1 -0
  319. package/lib/esm/components-react.d.ts.map +1 -1
  320. package/lib/esm/components-react.js +1 -0
  321. package/lib/esm/components-react.js.map +1 -1
  322. package/lib/public/locales/en/UiComponents.json +7 -1
  323. package/package.json +4 -4
@@ -8,10 +8,10 @@
8
8
  import * as React from "react";
9
9
  import classnames from "classnames";
10
10
  import { Key } from "ts-key-enum";
11
- import { UiComponents } from "../UiComponents";
12
11
  import { Icon } from "@itwin/core-react";
13
12
  import { SvgChevronLeft, SvgChevronRight } from "@itwin/itwinui-icons-react";
14
13
  import "./DatePicker.scss";
14
+ import { useTranslation } from "../useTranslation";
15
15
  function isSameDay(a, b) {
16
16
  return (a &&
17
17
  b &&
@@ -21,42 +21,45 @@ function isSameDay(a, b) {
21
21
  }
22
22
  /** DatePicker component. Show a month selector and a day calendar to select a specific date.
23
23
  * @alpha
24
+ * @deprecated in 4.11.x. Use {@link https://itwinui.bentley.com/docs/datepicker iTwinUI date picker} instead.
24
25
  */
26
+ // eslint-disable-next-line deprecation/deprecation
25
27
  export function DatePicker(props) {
26
- const previousMonthLabel = React.useRef(UiComponents.localization.getLocalizedString("UiComponents:datepicker.previousMonth"));
27
- const nextMonthLabel = React.useRef(UiComponents.localization.getLocalizedString("UiComponents:datepicker.nextMonth"));
28
- const monthsLong = React.useRef([
29
- UiComponents.localization.getLocalizedString("UiComponents:month.long.january"),
30
- UiComponents.localization.getLocalizedString("UiComponents:month.long.february"),
31
- UiComponents.localization.getLocalizedString("UiComponents:month.long.march"),
32
- UiComponents.localization.getLocalizedString("UiComponents:month.long.april"),
33
- UiComponents.localization.getLocalizedString("UiComponents:month.long.may"),
34
- UiComponents.localization.getLocalizedString("UiComponents:month.long.june"),
35
- UiComponents.localization.getLocalizedString("UiComponents:month.long.july"),
36
- UiComponents.localization.getLocalizedString("UiComponents:month.long.august"),
37
- UiComponents.localization.getLocalizedString("UiComponents:month.long.september"),
38
- UiComponents.localization.getLocalizedString("UiComponents:month.long.october"),
39
- UiComponents.localization.getLocalizedString("UiComponents:month.long.november"),
40
- UiComponents.localization.getLocalizedString("UiComponents:month.long.december"),
41
- ]);
42
- const daysLong = React.useRef([
43
- UiComponents.localization.getLocalizedString("UiComponents:days.long.sunday"),
44
- UiComponents.localization.getLocalizedString("UiComponents:days.long.monday"),
45
- UiComponents.localization.getLocalizedString("UiComponents:days.long.tuesday"),
46
- UiComponents.localization.getLocalizedString("UiComponents:days.long.wednesday"),
47
- UiComponents.localization.getLocalizedString("UiComponents:days.long.thursday"),
48
- UiComponents.localization.getLocalizedString("UiComponents:days.long.friday"),
49
- UiComponents.localization.getLocalizedString("UiComponents:days.long.saturday"),
50
- ]);
51
- const daysShort = React.useRef([
52
- UiComponents.localization.getLocalizedString("UiComponents:days.short.sunday"),
53
- UiComponents.localization.getLocalizedString("UiComponents:days.short.monday"),
54
- UiComponents.localization.getLocalizedString("UiComponents:days.short.tuesday"),
55
- UiComponents.localization.getLocalizedString("UiComponents:days.short.wednesday"),
56
- UiComponents.localization.getLocalizedString("UiComponents:days.short.thursday"),
57
- UiComponents.localization.getLocalizedString("UiComponents:days.short.friday"),
58
- UiComponents.localization.getLocalizedString("UiComponents:days.short.saturday"),
59
- ]);
28
+ const { translate } = useTranslation();
29
+ const previousMonthLabel = translate("datepicker.previousMonth");
30
+ const nextMonthLabel = translate("datepicker.nextMonth");
31
+ const monthsLong = [
32
+ translate("month.long.january"),
33
+ translate("month.long.february"),
34
+ translate("month.long.march"),
35
+ translate("month.long.april"),
36
+ translate("month.long.may"),
37
+ translate("month.long.june"),
38
+ translate("month.long.july"),
39
+ translate("month.long.august"),
40
+ translate("month.long.september"),
41
+ translate("month.long.october"),
42
+ translate("month.long.november"),
43
+ translate("month.long.december"),
44
+ ];
45
+ const daysLong = [
46
+ translate("days.long.sunday"),
47
+ translate("days.long.monday"),
48
+ translate("days.long.tuesday"),
49
+ translate("days.long.wednesday"),
50
+ translate("days.long.thursday"),
51
+ translate("days.long.friday"),
52
+ translate("days.long.saturday"),
53
+ ];
54
+ const daysShort = [
55
+ translate("days.short.sunday"),
56
+ translate("days.short.monday"),
57
+ translate("days.short.tuesday"),
58
+ translate("days.short.wednesday"),
59
+ translate("days.short.thursday"),
60
+ translate("days.short.friday"),
61
+ translate("days.short.saturday"),
62
+ ];
60
63
  const [selectedDay, setSelectedDay] = React.useState(new Date(props.selected.getTime()));
61
64
  const [displayedMonthIndex, setDisplayedMonthIndex] = React.useState(selectedDay.getMonth());
62
65
  const [displayedYear, setDisplayedYear] = React.useState(selectedDay.getFullYear());
@@ -159,16 +162,16 @@ export function DatePicker(props) {
159
162
  const calendarClass = classnames("components-date-picker-calendar-month", props.showFocusOutline && "showFocusOutline");
160
163
  return (React.createElement("div", { className: "components-date-picker-calendar" },
161
164
  React.createElement("div", { className: "components-date-picker-calendar-header-months" },
162
- React.createElement("button", { className: previousButtonClass, title: previousMonthLabel.current, onClick: handleMoveToPreviousMonth },
165
+ React.createElement("button", { className: previousButtonClass, title: previousMonthLabel, onClick: handleMoveToPreviousMonth },
163
166
  React.createElement(Icon, { iconSpec: React.createElement(SvgChevronLeft, null) })),
164
167
  React.createElement("span", { className: "components-month-year" },
165
- monthsLong.current[displayedMonthIndex],
168
+ monthsLong[displayedMonthIndex],
166
169
  " ",
167
170
  displayedYear),
168
- React.createElement("button", { className: nextButtonClass, title: nextMonthLabel.current, onClick: handleMoveToNextMonth },
171
+ React.createElement("button", { className: nextButtonClass, title: nextMonthLabel, onClick: handleMoveToNextMonth },
169
172
  React.createElement(Icon, { iconSpec: React.createElement(SvgChevronRight, null) }))),
170
- React.createElement("div", { className: "components-date-picker-calendar-header-weekdays" }, [0, 1, 2, 3, 4, 5, 6].map((dayOfWeek) => (React.createElement("div", { key: `day-${dayOfWeek}`, className: "components-date-picker-calendar-header-day-short", title: daysLong.current[dayOfWeek] },
171
- React.createElement("span", null, daysShort.current[dayOfWeek]))))),
173
+ React.createElement("div", { className: "components-date-picker-calendar-header-weekdays" }, [0, 1, 2, 3, 4, 5, 6].map((dayOfWeek) => (React.createElement("div", { key: `day-${dayOfWeek}`, className: "components-date-picker-calendar-header-day-short", title: daysLong[dayOfWeek] },
174
+ React.createElement("span", null, daysShort[dayOfWeek]))))),
172
175
  React.createElement("ul", { tabIndex: 0, onKeyDown: handleCalendarKeyDown, "data-testid": "components-date-picker-calendar-list", className: calendarClass, role: "listbox" }, weeks.map((weekdays, weekIndex) => (React.createElement(React.Fragment, { key: `week-${weekIndex}` }, weekdays.map((day, dayIndex) => {
173
176
  const isActive = selectedDay && day && isSameDay(selectedDay, day);
174
177
  const isFocused = focusedDay &&
@@ -1 +1 @@
1
- {"version":3,"file":"DatePicker.js","sourceRoot":"","sources":["../../../../src/components-react/datepicker/DatePicker.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7E,OAAO,mBAAmB,CAAC;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,MAAM,UAAU,UAAU,CAAC,KAAsB;IAC/C,MAAM,kBAAkB,GAAG,KAAK,CAAC,MAAM,CACrC,YAAY,CAAC,YAAY,CAAC,kBAAkB,CAC1C,uCAAuC,CACxC,CACF,CAAC;IACF,MAAM,cAAc,GAAG,KAAK,CAAC,MAAM,CACjC,YAAY,CAAC,YAAY,CAAC,kBAAkB,CAC1C,mCAAmC,CACpC,CACF,CAAC;IACF,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC;QAC9B,YAAY,CAAC,YA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,CAAC,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,UAAU,CAC3B,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","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.valueOf()) {\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.valueOf()) {\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.valueOf()) {\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.valueOf()) {\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.valueOf() || 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"]}
1
+ {"version":3,"file":"DatePicker.js","sourceRoot":"","sources":["../../../../src/components-react/datepicker/DatePicker.t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C;QACJ,CAAC,CAAC,CACa,CAClB,CAAC,CACC,CACD,CACP,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Date\n */\n\nimport * as React from \"react\";\nimport classnames from \"classnames\";\nimport { Key } from \"ts-key-enum\";\nimport { Icon } from \"@itwin/core-react\";\nimport { SvgChevronLeft, SvgChevronRight } from \"@itwin/itwinui-icons-react\";\nimport \"./DatePicker.scss\";\nimport { useTranslation } from \"../useTranslation\";\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 * @deprecated in 4.11.x. Props of deprecated component {@link DatePicker}.\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 * @deprecated in 4.11.x. Use {@link https://itwinui.bentley.com/docs/datepicker iTwinUI date picker} instead.\n */\n// eslint-disable-next-line deprecation/deprecation\nexport function DatePicker(props: DatePickerProps) {\n const { translate } = useTranslation();\n const previousMonthLabel = translate(\"datepicker.previousMonth\");\n const nextMonthLabel = translate(\"datepicker.nextMonth\");\n const monthsLong = [\n translate(\"month.long.january\"),\n translate(\"month.long.february\"),\n translate(\"month.long.march\"),\n translate(\"month.long.april\"),\n translate(\"month.long.may\"),\n translate(\"month.long.june\"),\n translate(\"month.long.july\"),\n translate(\"month.long.august\"),\n translate(\"month.long.september\"),\n translate(\"month.long.october\"),\n translate(\"month.long.november\"),\n translate(\"month.long.december\"),\n ];\n\n const daysLong = [\n translate(\"days.long.sunday\"),\n translate(\"days.long.monday\"),\n translate(\"days.long.tuesday\"),\n translate(\"days.long.wednesday\"),\n translate(\"days.long.thursday\"),\n translate(\"days.long.friday\"),\n translate(\"days.long.saturday\"),\n ];\n\n const daysShort = [\n translate(\"days.short.sunday\"),\n translate(\"days.short.monday\"),\n translate(\"days.short.tuesday\"),\n translate(\"days.short.wednesday\"),\n translate(\"days.short.thursday\"),\n translate(\"days.short.friday\"),\n translate(\"days.short.saturday\"),\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.valueOf()) {\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.valueOf()) {\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.valueOf()) {\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.valueOf()) {\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.valueOf() || 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}\n onClick={handleMoveToPreviousMonth}\n >\n <Icon iconSpec={<SvgChevronLeft />} />\n </button>\n <span className=\"components-month-year\">\n {monthsLong[displayedMonthIndex]} {displayedYear}\n </span>\n <button\n className={nextButtonClass}\n title={nextMonthLabel}\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[dayOfWeek]}\n >\n <span>{daysShort[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"]}
@@ -6,7 +6,9 @@ import type { DateFormatter, TimeDisplay } from "@itwin/appui-abstract";
6
6
  import type { CommonProps } from "@itwin/core-react";
7
7
  import "./DatePickerPopupButton.scss";
8
8
  /** Props used by [[DatePickerPopupButton]] component.
9
- * @alpha */
9
+ * @alpha
10
+ * @deprecated in 4.11.x. Props of deprecated component {@link DatePickerPopupButton}.
11
+ */
10
12
  export interface DatePickerPopupButtonProps extends CommonProps {
11
13
  /** Date to be shown as the selected date. */
12
14
  selected: Date;
@@ -25,6 +27,7 @@ export interface DatePickerPopupButtonProps extends CommonProps {
25
27
  }
26
28
  /** Component that displays a button used to pick a date and optionally a time.
27
29
  * @alpha
28
- * */
30
+ * @deprecated in 4.11.x. Use {@link https://itwinui.bentley.com/docs/datepicker iTwinUI date picker} instead.
31
+ */
29
32
  export declare function DatePickerPopupButton({ displayEditField, timeDisplay, selected, onDateChange, dateFormatter, buttonToolTip, fieldStyle, fieldClassName, style, }: DatePickerPopupButtonProps): React.JSX.Element;
30
33
  //# sourceMappingURL=DatePickerPopupButton.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DatePickerPopupButton.d.ts","sourceRoot":"","sources":["../../../../src/components-react/datepicker/DatePickerPopupButton.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAExE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAQrD,OAAO,8BAA8B,CAAC;AAEtC;YACY;AACZ,MAAM,WAAW,0BAA2B,SAAQ,WAAW;IAC7D,6CAA6C;IAC7C,QAAQ,EAAE,IAAI,CAAC;IACf,4EAA4E;IAC5E,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,yCAAyC;IACzC,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,IAAI,KAAK,IAAI,CAAC;IACnC,uBAAuB;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IAGvB,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,8CAA8C;IAC9C,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,yCAAyC;IACzC,UAAU,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAClC;AAED;;KAEK;AACL,wBAAgB,qBAAqB,CAAC,EACpC,gBAAgB,EAChB,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,aAAa,EACb,UAAU,EACV,cAAc,EACd,KAAK,GACN,EAAE,0BAA0B,qBAoI5B"}
1
+ {"version":3,"file":"DatePickerPopupButton.d.ts","sourceRoot":"","sources":["../../../../src/components-react/datepicker/DatePickerPopupButton.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAExE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAOrD,OAAO,8BAA8B,CAAC;AAGtC;;;GAGG;AACH,MAAM,WAAW,0BAA2B,SAAQ,WAAW;IAC7D,6CAA6C;IAC7C,QAAQ,EAAE,IAAI,CAAC;IACf,4EAA4E;IAC5E,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,yCAAyC;IACzC,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,IAAI,KAAK,IAAI,CAAC;IACnC,uBAAuB;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IAGvB,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,8CAA8C;IAC9C,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,yCAAyC;IACzC,UAAU,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAClC;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,gBAAgB,EAChB,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,aAAa,EACb,UAAU,EACV,cAAc,EACd,KAAK,GACN,EACD,0BAA0B,qBA8HzB"}
@@ -9,20 +9,20 @@ import * as React from "react";
9
9
  import { RelativePosition } from "@itwin/appui-abstract";
10
10
  import { Popup } from "@itwin/core-react";
11
11
  import { Text } from "@itwin/itwinui-react";
12
- import { UiComponents } from "../UiComponents";
13
12
  import { DatePicker } from "./DatePicker";
14
13
  import { DateField } from "./DateField";
15
14
  import { TimeField } from "./TimeField";
16
15
  import "./DatePickerPopupButton.scss";
16
+ import { useTranslation } from "../useTranslation";
17
17
  /** Component that displays a button used to pick a date and optionally a time.
18
18
  * @alpha
19
- * */
19
+ * @deprecated in 4.11.x. Use {@link https://itwinui.bentley.com/docs/datepicker iTwinUI date picker} instead.
20
+ */
20
21
  export function DatePickerPopupButton({ displayEditField, timeDisplay, selected, onDateChange, dateFormatter, buttonToolTip, fieldStyle, fieldClassName, style, }) {
22
+ const { translate } = useTranslation();
21
23
  const [workingDate, setWorkingDate] = React.useState(new Date(selected.getTime()));
22
24
  const [isSettingsOpen, setIsSettingsOpen] = React.useState(false);
23
- const timeLabelRef = React.useRef(UiComponents.translate("datepicker.time"));
24
- const toolTipLabelRef = React.useRef(UiComponents.translate("datepicker.selectDate"));
25
- const toolTipLabel = React.useMemo(() => (buttonToolTip ? buttonToolTip : toolTipLabelRef.current), [buttonToolTip]);
25
+ const toolTipLabel = buttonToolTip !== null && buttonToolTip !== void 0 ? buttonToolTip : translate("datepicker.selectDate");
26
26
  // See if props have changed since component mounted
27
27
  React.useEffect(() => {
28
28
  const newWorkingDate = new Date(selected.getTime());
@@ -71,9 +71,10 @@ export function DatePickerPopupButton({ displayEditField, timeDisplay, selected,
71
71
  React.createElement("path", { d: "M13,13H9V10h4ZM16,3V15a1,1,0,0,1-1,1H1a1,1,0,0,1-1-1V3A1,1,0,0,1,1,2H3V0H4V2h8V0h1V2h2A1,1,0,0,1,16,3ZM15,6H1v9H15Z" })))),
72
72
  React.createElement(Popup, { isOpen: isSettingsOpen, position: RelativePosition.BottomLeft, onClose: handleCloseSetting, target: buttonRef.current, closeOnEnter: false, moveFocus: showFocusOutline, closeOnNestedPopupOutsideClick: true },
73
73
  React.createElement("div", { className: "components-date-picker-calendar-popup-panel", "data-testid": "components-date-picker-calendar-popup-panel" },
74
- React.createElement(DatePicker, { selected: workingDate, onDateChange: handleOnDateChanged, showFocusOutline: showFocusOutline }),
74
+ React.createElement(DatePicker // eslint-disable-line deprecation/deprecation
75
+ , { selected: workingDate, onDateChange: handleOnDateChanged, showFocusOutline: showFocusOutline }),
75
76
  timeDisplay && (React.createElement("div", { className: "time-container" },
76
- React.createElement(Text, { variant: "body", className: "time-label" }, timeLabelRef.current),
77
+ React.createElement(Text, { variant: "body", className: "time-label" }, translate("datepicker.time")),
77
78
  React.createElement(TimeField, { time: timeSpec, timeDisplay: timeDisplay, onTimeChange: handleOnTimeChanged }))))),
78
79
  !!displayEditField && (React.createElement(DateField, { style: fieldStyle, className: fieldClassName, initialDate: workingDate, timeDisplay: timeDisplay, dateFormatter: dateFormatter, onDateChange: handleOnDateChanged }))));
79
80
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DatePickerPopupButton.js","sourceRoot":"","sources":["../../../../src/components-react/datepicker/DatePickerPopupButton.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,8BAA8B,CAAC;AAwBtC;;KAEK;AACL,MAAM,UAAU,qBAAqB,CAAC,EACpC,gBAAgB,EAChB,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,aAAa,EACb,UAAU,EACV,cAAc,EACd,KAAK,GACsB;IAC3B,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,KAAK,CAAC,QAAQ,CAClD,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAC7B,CAAC;IACF,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAClE,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAC7E,MAAM,eAAe,GAAG,KAAK,CAAC,MAAM,CAClC,YAAY,CAAC,SAAS,CAAC,uBAAuB,CAAC,CAChD,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ACzD,8BAAM,CAAC,EAAC,qHAAqH,GAAG,CAC5H,CACF,CACC;QACT,oBAAC,KAAK,IACJ,MAAM,EAAE,cAAc,EACtB,QAAQ,EAAE,gBAAgB,CAAC,UAAU,EACrC,OAAO,EAAE,kBAAkB,EAC3B,MAAM,EAAE,SAAS,CAAC,OAAO,EACzB,YAAY,EAAE,KAAK,EACnB,SAAS,EAAE,gBAAgB,EAC3B,8BAA8B;YAE9B,6BACE,SAAS,EAAC,6CAA6C,iBAC3C,6CAA6C;gBAEzD,oBAAC,UAAU,IACT,QAAQ,EAAE,WAAW,EACrB,YAAY,EAAE,mBAAmB,EACjC,gBAAgB,EAAE,gBAAgB,GAClC;gBACD,WAAW,IAAI,CACd,6BAAK,SAAS,EAAC,gBAAgB;oBAC7B,oBAAC,IAAI,IAAC,OAAO,EAAC,MAAM,EAAC,SAAS,EAAC,YAAY,IACxC,YAAY,CAAC,OAAO,CAChB;oBACP,oBAAC,SAAS,IACR,IAAI,EAAE,QAAQ,EACd,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,mBAAmB,GACjC,CACE,CACP,CACG,CACA;QACP,CAAC,CAAC,gBAAgB,IAAI,CACrB,oBAAC,SAAS,IACR,KAAK,EAAE,UAAU,EACjB,SAAS,EAAE,cAAc,EACzB,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,mBAAmB,GACjC,CACH,CACA,CACJ,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Date\n */\n\nimport * as React from \"react\";\nimport type { DateFormatter, TimeDisplay } from \"@itwin/appui-abstract\";\nimport { RelativePosition } from \"@itwin/appui-abstract\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { Popup } from \"@itwin/core-react\";\nimport { Text } from \"@itwin/itwinui-react\";\nimport { UiComponents } from \"../UiComponents\";\nimport { DatePicker } from \"./DatePicker\";\nimport { DateField } from \"./DateField\";\nimport type { TimeSpec } from \"./TimeField\";\nimport { TimeField } from \"./TimeField\";\nimport \"./DatePickerPopupButton.scss\";\n\n/** Props used by [[DatePickerPopupButton]] component.\n * @alpha */\nexport interface DatePickerPopupButtonProps extends CommonProps {\n /** Date to be shown as the selected date. */\n selected: Date;\n /** If true show the date (and optionally time) edit field next to button */\n displayEditField?: boolean;\n // If defined show time in popup and also display time if input field is shown\n timeDisplay?: TimeDisplay;\n /** Function called when Date changes. */\n onDateChange?: (day: Date) => void;\n /** Optional tooltip */\n buttonToolTip?: string;\n /* Custom date formatter. WARNING: if used values will only be shown in specified format and will not be based on locale.\n * If used the existence of a parseDate function will determine if the edit field allows editing. */\n dateFormatter?: DateFormatter;\n /** User defined class name for edit field. */\n fieldClassName?: string;\n /** User defined style for edit field. */\n fieldStyle?: React.CSSProperties;\n}\n\n/** Component that displays a button used to pick a date and optionally a time.\n * @alpha\n * */\nexport function DatePickerPopupButton({\n displayEditField,\n timeDisplay,\n selected,\n onDateChange,\n dateFormatter,\n buttonToolTip,\n fieldStyle,\n fieldClassName,\n style,\n}: DatePickerPopupButtonProps) {\n const [workingDate, setWorkingDate] = React.useState(\n new Date(selected.getTime())\n );\n const [isSettingsOpen, setIsSettingsOpen] = React.useState(false);\n const timeLabelRef = React.useRef(UiComponents.translate(\"datepicker.time\"));\n const toolTipLabelRef = React.useRef(\n UiComponents.translate(\"datepicker.selectDate\")\n );\n const toolTipLabel = React.useMemo(\n () => (buttonToolTip ? buttonToolTip : toolTipLabelRef.current),\n [buttonToolTip]\n );\n\n // See if props have changed since component mounted\n React.useEffect(() => {\n const newWorkingDate = new Date(selected.getTime());\n setWorkingDate(newWorkingDate);\n }, [selected]);\n\n const buttonRef = React.useRef<HTMLButtonElement>(null);\n const togglePopupDisplay = React.useCallback(\n (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {\n event.preventDefault();\n setShowFocusOutline(false);\n setIsSettingsOpen((prev) => !prev);\n },\n [setIsSettingsOpen]\n );\n\n const handleCloseSetting = React.useCallback(() => {\n setIsSettingsOpen(false);\n }, [setIsSettingsOpen]);\n\n const handleOnDateChanged = (day: Date) => {\n // combine current time into selected Date\n const newWorkingDate = new Date(day.getTime());\n newWorkingDate.setHours(\n workingDate.getHours(),\n workingDate.getMinutes(),\n workingDate.getSeconds()\n );\n onDateChange && onDateChange(newWorkingDate);\n !timeDisplay && setIsSettingsOpen(false);\n };\n\n const handleOnTimeChanged = (time: TimeSpec) => {\n // Combine new time into selected Date\n const newWorkingDate = new Date(workingDate.getTime());\n newWorkingDate.setHours(time.hours, time.minutes, time.seconds);\n setWorkingDate(newWorkingDate);\n onDateChange && onDateChange(newWorkingDate);\n };\n\n const [showFocusOutline, setShowFocusOutline] = React.useState(false);\n const handlePopupKeyDown = React.useCallback(\n (event: React.KeyboardEvent<HTMLButtonElement>) => {\n // istanbul ignore else\n if (event.key === \" \") {\n setShowFocusOutline(true);\n setIsSettingsOpen(true);\n }\n },\n []\n );\n\n const timeSpec: TimeSpec = {\n hours: workingDate.getHours(),\n minutes: workingDate.getMinutes(),\n seconds: workingDate.getSeconds(),\n };\n return (\n <>\n <button\n title={toolTipLabel}\n style={style}\n className=\"components-date-picker-calendar-popup-button\"\n onKeyDown={handlePopupKeyDown}\n data-testid=\"components-date-picker-calendar-popup-button\"\n onPointerDown={togglePopupDisplay}\n ref={buttonRef}\n >\n <div className=\"datepicker-button\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\">\n <path d=\"M13,13H9V10h4ZM16,3V15a1,1,0,0,1-1,1H1a1,1,0,0,1-1-1V3A1,1,0,0,1,1,2H3V0H4V2h8V0h1V2h2A1,1,0,0,1,16,3ZM15,6H1v9H15Z\" />\n </svg>\n </div>\n </button>\n <Popup\n isOpen={isSettingsOpen}\n position={RelativePosition.BottomLeft}\n onClose={handleCloseSetting}\n target={buttonRef.current}\n closeOnEnter={false}\n moveFocus={showFocusOutline}\n closeOnNestedPopupOutsideClick\n >\n <div\n className=\"components-date-picker-calendar-popup-panel\"\n data-testid=\"components-date-picker-calendar-popup-panel\"\n >\n <DatePicker\n selected={workingDate}\n onDateChange={handleOnDateChanged}\n showFocusOutline={showFocusOutline}\n />\n {timeDisplay && (\n <div className=\"time-container\">\n <Text variant=\"body\" className=\"time-label\">\n {timeLabelRef.current}\n </Text>\n <TimeField\n time={timeSpec}\n timeDisplay={timeDisplay}\n onTimeChange={handleOnTimeChanged}\n />\n </div>\n )}\n </div>\n </Popup>\n {!!displayEditField && (\n <DateField\n style={fieldStyle}\n className={fieldClassName}\n initialDate={workingDate}\n timeDisplay={timeDisplay}\n dateFormatter={dateFormatter}\n onDateChange={handleOnDateChanged}\n />\n )}\n </>\n );\n}\n"]}
1
+ {"version":3,"file":"DatePickerPopupButton.js","sourceRoot":"","sources":["../../../../src/components-react/datepicker/DatePickerPopupButton.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,8BAA8B,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AA0BnD;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,EACpC,gBAAgB,EAChB,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,aAAa,EACb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AAE,KAAK,EACZ,SAAS,EAAC,8CAA8C,EACxD,SAAS,EAAE,kBAAkB,iBACjB,8CAA8C,EAC1D,aAAa,EAAE,kBAAkB,EACjC,GAAG,EAAE,SAAS;YAEd,6BAAK,SAAS,EAAC,mBAAmB;gBAChC,6BAAK,KAAK,EAAC,4BAA4B,EAAC,OAAO,EAAC,WAAW;oBACzD,8BAAM,CAAC,EAAC,qHAAqH,GAAG,CAC5H,CACF,CACC;QACT,oBAAC,KAAK,IACJ,MAAM,EAAE,cAAc,EACtB,QAAQ,EAAE,gBAAgB,CAAC,UAAU,EACrC,OAAO,EAAE,kBAAkB,EAC3B,MAAM,EAAE,SAAS,CAAC,OAAO,EACzB,YAAY,EAAE,KAAK,EACnB,SAAS,EAAE,gBAAgB,EAC3B,8BAA8B;YAE9B,6BACE,SAAS,EAAC,6CAA6C,iBAC3C,6CAA6C;gBAEzD,oBAAC,UAAU,CAAC,8CAA8C;oBACxD,QAAQ,EAAE,WAAW,EACrB,YAAY,EAAE,mBAAmB,EACjC,gBAAgB,EAAE,gBAAgB,GAClC;gBACD,WAAW,IAAI,CACd,6BAAK,SAAS,EAAC,gBAAgB;oBAC7B,oBAAC,IAAI,IAAC,OAAO,EAAC,MAAM,EAAC,SAAS,EAAC,YAAY,IACxC,SAAS,CAAC,iBAAiB,CAAC,CACxB;oBACP,oBAAC,SAAS,IACR,IAAI,EAAE,QAAQ,EACd,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,mBAAmB,GACjC,CACE,CACP,CACG,CACA;QACP,CAAC,CAAC,gBAAgB,IAAI,CACrB,oBAAC,SAAS,IACR,KAAK,EAAE,UAAU,EACjB,SAAS,EAAE,cAAc,EACzB,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,mBAAmB,GACjC,CACH,CACA,CACJ,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Date\n */\n\nimport * as React from \"react\";\nimport type { DateFormatter, TimeDisplay } from \"@itwin/appui-abstract\";\nimport { RelativePosition } from \"@itwin/appui-abstract\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { Popup } from \"@itwin/core-react\";\nimport { Text } from \"@itwin/itwinui-react\";\nimport { DatePicker } from \"./DatePicker\";\nimport { DateField } from \"./DateField\";\nimport type { TimeSpec } from \"./TimeField\";\nimport { TimeField } from \"./TimeField\";\nimport \"./DatePickerPopupButton.scss\";\nimport { useTranslation } from \"../useTranslation\";\n\n/** Props used by [[DatePickerPopupButton]] component.\n * @alpha\n * @deprecated in 4.11.x. Props of deprecated component {@link DatePickerPopupButton}.\n */\nexport interface DatePickerPopupButtonProps extends CommonProps {\n /** Date to be shown as the selected date. */\n selected: Date;\n /** If true show the date (and optionally time) edit field next to button */\n displayEditField?: boolean;\n // If defined show time in popup and also display time if input field is shown\n timeDisplay?: TimeDisplay;\n /** Function called when Date changes. */\n onDateChange?: (day: Date) => void;\n /** Optional tooltip */\n buttonToolTip?: string;\n /* Custom date formatter. WARNING: if used values will only be shown in specified format and will not be based on locale.\n * If used the existence of a parseDate function will determine if the edit field allows editing. */\n dateFormatter?: DateFormatter;\n /** User defined class name for edit field. */\n fieldClassName?: string;\n /** User defined style for edit field. */\n fieldStyle?: React.CSSProperties;\n}\n\n/** Component that displays a button used to pick a date and optionally a time.\n * @alpha\n * @deprecated in 4.11.x. Use {@link https://itwinui.bentley.com/docs/datepicker iTwinUI date picker} instead.\n */\nexport function DatePickerPopupButton({\n displayEditField,\n timeDisplay,\n selected,\n onDateChange,\n dateFormatter,\n buttonToolTip,\n fieldStyle,\n fieldClassName,\n style,\n}: // eslint-disable-next-line deprecation/deprecation\nDatePickerPopupButtonProps) {\n const { translate } = useTranslation();\n const [workingDate, setWorkingDate] = React.useState(\n new Date(selected.getTime())\n );\n const [isSettingsOpen, setIsSettingsOpen] = React.useState(false);\n const toolTipLabel = buttonToolTip ?? translate(\"datepicker.selectDate\");\n\n // See if props have changed since component mounted\n React.useEffect(() => {\n const newWorkingDate = new Date(selected.getTime());\n setWorkingDate(newWorkingDate);\n }, [selected]);\n\n const buttonRef = React.useRef<HTMLButtonElement>(null);\n const togglePopupDisplay = React.useCallback(\n (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {\n event.preventDefault();\n setShowFocusOutline(false);\n setIsSettingsOpen((prev) => !prev);\n },\n [setIsSettingsOpen]\n );\n\n const handleCloseSetting = React.useCallback(() => {\n setIsSettingsOpen(false);\n }, [setIsSettingsOpen]);\n\n const handleOnDateChanged = (day: Date) => {\n // combine current time into selected Date\n const newWorkingDate = new Date(day.getTime());\n newWorkingDate.setHours(\n workingDate.getHours(),\n workingDate.getMinutes(),\n workingDate.getSeconds()\n );\n onDateChange && onDateChange(newWorkingDate);\n !timeDisplay && setIsSettingsOpen(false);\n };\n\n const handleOnTimeChanged = (time: TimeSpec) => {\n // Combine new time into selected Date\n const newWorkingDate = new Date(workingDate.getTime());\n newWorkingDate.setHours(time.hours, time.minutes, time.seconds);\n setWorkingDate(newWorkingDate);\n onDateChange && onDateChange(newWorkingDate);\n };\n\n const [showFocusOutline, setShowFocusOutline] = React.useState(false);\n const handlePopupKeyDown = React.useCallback(\n (event: React.KeyboardEvent<HTMLButtonElement>) => {\n // istanbul ignore else\n if (event.key === \" \") {\n setShowFocusOutline(true);\n setIsSettingsOpen(true);\n }\n },\n []\n );\n\n const timeSpec: TimeSpec = {\n hours: workingDate.getHours(),\n minutes: workingDate.getMinutes(),\n seconds: workingDate.getSeconds(),\n };\n return (\n <>\n <button\n title={toolTipLabel}\n style={style}\n className=\"components-date-picker-calendar-popup-button\"\n onKeyDown={handlePopupKeyDown}\n data-testid=\"components-date-picker-calendar-popup-button\"\n onPointerDown={togglePopupDisplay}\n ref={buttonRef}\n >\n <div className=\"datepicker-button\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\">\n <path d=\"M13,13H9V10h4ZM16,3V15a1,1,0,0,1-1,1H1a1,1,0,0,1-1-1V3A1,1,0,0,1,1,2H3V0H4V2h8V0h1V2h2A1,1,0,0,1,16,3ZM15,6H1v9H15Z\" />\n </svg>\n </div>\n </button>\n <Popup\n isOpen={isSettingsOpen}\n position={RelativePosition.BottomLeft}\n onClose={handleCloseSetting}\n target={buttonRef.current}\n closeOnEnter={false}\n moveFocus={showFocusOutline}\n closeOnNestedPopupOutsideClick\n >\n <div\n className=\"components-date-picker-calendar-popup-panel\"\n data-testid=\"components-date-picker-calendar-popup-panel\"\n >\n <DatePicker // eslint-disable-line deprecation/deprecation\n selected={workingDate}\n onDateChange={handleOnDateChanged}\n showFocusOutline={showFocusOutline}\n />\n {timeDisplay && (\n <div className=\"time-container\">\n <Text variant=\"body\" className=\"time-label\">\n {translate(\"datepicker.time\")}\n </Text>\n <TimeField\n time={timeSpec}\n timeDisplay={timeDisplay}\n onTimeChange={handleOnTimeChanged}\n />\n </div>\n )}\n </div>\n </Popup>\n {!!displayEditField && (\n <DateField\n style={fieldStyle}\n className={fieldClassName}\n initialDate={workingDate}\n timeDisplay={timeDisplay}\n dateFormatter={dateFormatter}\n onDateChange={handleOnDateChanged}\n />\n )}\n </>\n );\n}\n"]}
@@ -9,6 +9,7 @@ import type { DateFormatter } from "@itwin/appui-abstract";
9
9
  * support parsing, so when used by [[DatePickerPopup]] the edit field will be readonly. If
10
10
  * a parseData function is implemented then the edit field will be editable.
11
11
  * @alpha
12
+ * @deprecated in 4.11.x. Use {@link https://itwinui.bentley.com/docs/datepicker iTwinUI date picker} instead.
12
13
  */
13
14
  export declare class IntlFormatter implements DateFormatter {
14
15
  private _intlFormatter?;
@@ -1 +1 @@
1
- {"version":3,"file":"IntlFormatter.d.ts","sourceRoot":"","sources":["../../../../src/components-react/datepicker/IntlFormatter.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D;;;;;;;GAOG;AACH,qBAAa,aAAc,YAAW,aAAa;IACrC,OAAO,CAAC,cAAc,CAAC;gBAAf,cAAc,CAAC,iCAAqB;IAExD,IAAW,SAAS,IAAI,IAAI,CAAC,cAAc,CAgB1C;IAEM,WAAW,CAAC,GAAG,EAAE,IAAI;CAO7B"}
1
+ {"version":3,"file":"IntlFormatter.d.ts","sourceRoot":"","sources":["../../../../src/components-react/datepicker/IntlFormatter.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D;;;;;;;;GAQG;AACH,qBAAa,aAAc,YAAW,aAAa;IACrC,OAAO,CAAC,cAAc,CAAC;gBAAf,cAAc,CAAC,iCAAqB;IAExD,IAAW,SAAS,IAAI,IAAI,CAAC,cAAc,CAgB1C;IAEM,WAAW,CAAC,GAAG,EAAE,IAAI;CAO7B"}
@@ -12,6 +12,7 @@
12
12
  * support parsing, so when used by [[DatePickerPopup]] the edit field will be readonly. If
13
13
  * a parseData function is implemented then the edit field will be editable.
14
14
  * @alpha
15
+ * @deprecated in 4.11.x. Use {@link https://itwinui.bentley.com/docs/datepicker iTwinUI date picker} instead.
15
16
  */
16
17
  export class IntlFormatter {
17
18
  constructor(_intlFormatter) {
@@ -1 +1 @@
1
- {"version":3,"file":"IntlFormatter.js","sourceRoot":"","sources":["../../../../src/components-react/datepicker/IntlFormatter.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAIH;;;;;;;GAOG;AACH,MAAM,OAAO,aAAa;IACxB,YAAoB,cAAoC;QAApC,mBAAc,GAAd,cAAc,CAAsB;IAAG,CAAC;IAE5D,IAAW,SAAS;QAClB,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE;YACxB,+DAA+D;YAC/D,IAAI,CAAC,cAAc,GAAG,IAAI,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE;gBACvD,OAAO,EAAE,OAAO,CAAC,+BAA+B;gBAChD,IAAI,EAAE,SAAS,CAAC,0BAA0B;gBAC1C,KAAK,EAAE,SAAS,CAAC,qDAAqD;gBACtE,GAAG,EAAE,SAAS,CAAC,0BAA0B;gBACzC,IAAI,EAAE,SAAS,CAAC,0BAA0B;gBAC1C,MAAM,EAAE,IAAI;gBACZ,MAAM,EAAE,SAAS,CAAC,0BAA0B;gBAC5C,MAAM,EAAE,SAAS,CAAC,0BAA0B,CAAC,qBAAqB;gBAClE,4BAA4B;aAC7B,CAAC,CAAC;SACJ;QACD,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAEM,WAAW,CAAC,GAAS;QAC1B,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACpC,CAAC;CAKF","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 type { DateFormatter } from \"@itwin/appui-abstract\";\n\n/**\n * A basic class that allows user to provide an Intl.DateTimeFormat\n * that can be used to format the date and time display. If no format is\n * specified a default format will be used. This default implementation does not\n * support parsing, so when used by [[DatePickerPopup]] the edit field will be readonly. If\n * a parseData function is implemented then the edit field will be editable.\n * @alpha\n */\nexport class IntlFormatter implements DateFormatter {\n constructor(private _intlFormatter?: Intl.DateTimeFormat) {}\n\n public get formatter(): Intl.DateTimeFormat {\n if (!this._intlFormatter) {\n // https://tc39.es/ecma402/#sec-intl-datetimeformat-constructor\n this._intlFormatter = new Intl.DateTimeFormat(undefined, {\n weekday: \"short\" /* \"narrow\", \"short\", \"long\" */,\n year: \"numeric\" /* \"2-digit\", \"numeric\" */,\n month: \"2-digit\" /* \"2-digit\", \"numeric\", \"narrow\", \"short\", \"long\" */,\n day: \"2-digit\" /* \"2-digit\", \"numeric\" */,\n hour: \"numeric\" /* \"2-digit\", \"numeric\" */,\n hour12: true,\n minute: \"numeric\" /* \"2-digit\", \"numeric\" */,\n second: \"numeric\" /* \"2-digit\", \"numeric\" */ /* \"short\", \"long\" */,\n /* timeZoneName:\t\"short\", */\n });\n }\n return this._intlFormatter;\n }\n\n public formateDate(day: Date) {\n return this.formatter.format(day);\n }\n\n // The default implementation does not currently support parsing. If a derived class supports parsing then the\n // parseDate function must be implemented.\n // parseDate(dateString: string): Date|undefined {}\n}\n"]}
1
+ {"version":3,"file":"IntlFormatter.js","sourceRoot":"","sources":["../../../../src/components-react/datepicker/IntlFormatter.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAIH;;;;;;;;GAQG;AACH,MAAM,OAAO,aAAa;IACxB,YAAoB,cAAoC;QAApC,mBAAc,GAAd,cAAc,CAAsB;IAAG,CAAC;IAE5D,IAAW,SAAS;QAClB,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE;YACxB,+DAA+D;YAC/D,IAAI,CAAC,cAAc,GAAG,IAAI,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE;gBACvD,OAAO,EAAE,OAAO,CAAC,+BAA+B;gBAChD,IAAI,EAAE,SAAS,CAAC,0BAA0B;gBAC1C,KAAK,EAAE,SAAS,CAAC,qDAAqD;gBACtE,GAAG,EAAE,SAAS,CAAC,0BAA0B;gBACzC,IAAI,EAAE,SAAS,CAAC,0BAA0B;gBAC1C,MAAM,EAAE,IAAI;gBACZ,MAAM,EAAE,SAAS,CAAC,0BAA0B;gBAC5C,MAAM,EAAE,SAAS,CAAC,0BAA0B,CAAC,qBAAqB;gBAClE,4BAA4B;aAC7B,CAAC,CAAC;SACJ;QACD,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAEM,WAAW,CAAC,GAAS;QAC1B,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACpC,CAAC;CAKF","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 type { DateFormatter } from \"@itwin/appui-abstract\";\n\n/**\n * A basic class that allows user to provide an Intl.DateTimeFormat\n * that can be used to format the date and time display. If no format is\n * specified a default format will be used. This default implementation does not\n * support parsing, so when used by [[DatePickerPopup]] the edit field will be readonly. If\n * a parseData function is implemented then the edit field will be editable.\n * @alpha\n * @deprecated in 4.11.x. Use {@link https://itwinui.bentley.com/docs/datepicker iTwinUI date picker} instead.\n */\nexport class IntlFormatter implements DateFormatter {\n constructor(private _intlFormatter?: Intl.DateTimeFormat) {}\n\n public get formatter(): Intl.DateTimeFormat {\n if (!this._intlFormatter) {\n // https://tc39.es/ecma402/#sec-intl-datetimeformat-constructor\n this._intlFormatter = new Intl.DateTimeFormat(undefined, {\n weekday: \"short\" /* \"narrow\", \"short\", \"long\" */,\n year: \"numeric\" /* \"2-digit\", \"numeric\" */,\n month: \"2-digit\" /* \"2-digit\", \"numeric\", \"narrow\", \"short\", \"long\" */,\n day: \"2-digit\" /* \"2-digit\", \"numeric\" */,\n hour: \"numeric\" /* \"2-digit\", \"numeric\" */,\n hour12: true,\n minute: \"numeric\" /* \"2-digit\", \"numeric\" */,\n second: \"numeric\" /* \"2-digit\", \"numeric\" */ /* \"short\", \"long\" */,\n /* timeZoneName:\t\"short\", */\n });\n }\n return this._intlFormatter;\n }\n\n public formateDate(day: Date) {\n return this.formatter.format(day);\n }\n\n // The default implementation does not currently support parsing. If a derived class supports parsing then the\n // parseDate function must be implemented.\n // parseDate(dateString: string): Date|undefined {}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"TimeField.d.ts","sourceRoot":"","sources":["../../../../src/components-react/datepicker/TimeField.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK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AAE,cAAc,qBAgVhB"}
@@ -9,8 +9,8 @@ import * as React from "react";
9
9
  import classnames from "classnames";
10
10
  import { Key } from "ts-key-enum";
11
11
  import { Input } from "@itwin/itwinui-react";
12
- import { UiComponents } from "../UiComponents";
13
12
  import "./TimeField.scss";
13
+ import { useTranslation } from "../useTranslation";
14
14
  function getValidInt(intText, min, max, defaultValue) {
15
15
  try {
16
16
  const newValue = parseInt(intText, 10);
@@ -31,9 +31,10 @@ function isSameTime(a, b) {
31
31
  * @internal
32
32
  */
33
33
  export function TimeField({ time, timeDisplay, readOnly, onTimeChange, }) {
34
+ const { translate } = useTranslation();
34
35
  const initialDateRef = React.useRef(time);
35
- const amLabelRef = React.useRef(UiComponents.translate("timepicker.day-period-am"));
36
- const pmLabelRef = React.useRef(UiComponents.translate("timepicker.day-period-pm"));
36
+ const amLabel = translate("timepicker.day-period-am");
37
+ const pmLabel = translate("timepicker.day-period-pm");
37
38
  const [timeSpec, setTimeSpec] = React.useState(time);
38
39
  const { hours, minutes, seconds } = timeSpec;
39
40
  const showDayPeriod = -1 !== timeDisplay.search("aa");
@@ -52,11 +53,7 @@ export function TimeField({ time, timeDisplay, readOnly, onTimeChange, }) {
52
53
  }
53
54
  }, [time]);
54
55
  const displayHour = getDisplayHours(hours);
55
- const [dayPeriodText, setDayPeriodText] = React.useState(showDayPeriod
56
- ? hours >= 12
57
- ? pmLabelRef.current
58
- : amLabelRef.current
59
- : undefined);
56
+ const [dayPeriodText, setDayPeriodText] = React.useState(showDayPeriod ? (hours >= 12 ? pmLabel : amLabel) : undefined);
60
57
  const [hoursText, setHoursText] = React.useState(displayHour.toString().padStart(2, "0"));
61
58
  const [minutesText, setMinutesText] = React.useState(minutes.toString().padStart(2, "0"));
62
59
  const [secondsText, setSecondsText] = React.useState(seconds.toString().padStart(2, "0"));
@@ -84,12 +81,13 @@ export function TimeField({ time, timeDisplay, readOnly, onTimeChange, }) {
84
81
  const newHours = getValidInt(hoursText, 0, 24, hours);
85
82
  setHoursText(getDisplayHours(newHours).toString().padStart(2, "0"));
86
83
  updateTimeSpec({ ...timeSpec, hours: newHours });
87
- showDayPeriod &&
88
- setDayPeriodText(newHours >= 12 ? pmLabelRef.current : amLabelRef.current);
84
+ showDayPeriod && setDayPeriodText(newHours >= 12 ? pmLabel : amLabel);
89
85
  }, [
86
+ amLabel,
90
87
  getDisplayHours,
91
88
  hours,
92
89
  hoursText,
90
+ pmLabel,
93
91
  showDayPeriod,
94
92
  timeSpec,
95
93
  updateTimeSpec,
@@ -109,23 +107,23 @@ export function TimeField({ time, timeDisplay, readOnly, onTimeChange, }) {
109
107
  // istanbul ignore else
110
108
  if (dayPeriodText === "AM" ||
111
109
  dayPeriodText === "am" ||
112
- dayPeriodText === amLabelRef.current)
113
- newPeriodText = amLabelRef.current;
110
+ dayPeriodText === amLabel)
111
+ newPeriodText = amLabel;
114
112
  else if (dayPeriodText === "PM" ||
115
113
  dayPeriodText === "pm" ||
116
- dayPeriodText === pmLabelRef.current)
117
- newPeriodText = pmLabelRef.current;
114
+ dayPeriodText === pmLabel)
115
+ newPeriodText = pmLabel;
118
116
  // istanbul ignore else
119
117
  if (undefined !== newPeriodText) {
120
118
  setDayPeriodText(newPeriodText);
121
- if (newPeriodText === amLabelRef.current && hours > 12) {
119
+ if (newPeriodText === amLabel && hours > 12) {
122
120
  updateTimeSpec({ ...timeSpec, hours: hours - 12 });
123
121
  }
124
- else if (newPeriodText === pmLabelRef.current && hours <= 11) {
122
+ else if (newPeriodText === pmLabel && hours <= 11) {
125
123
  updateTimeSpec({ ...timeSpec, hours: hours + 12 });
126
124
  }
127
125
  }
128
- }, [dayPeriodText, hours, timeSpec, updateTimeSpec]);
126
+ }, [amLabel, dayPeriodText, hours, pmLabel, timeSpec, updateTimeSpec]);
129
127
  const handleHoursOnKeyDown = React.useCallback((event) => {
130
128
  // istanbul ignore else
131
129
  if (event.key === Key.ArrowDown.valueOf() ||
@@ -137,23 +135,23 @@ export function TimeField({ time, timeDisplay, readOnly, onTimeChange, }) {
137
135
  newHours = 0;
138
136
  setHoursText(getDisplayHours(newHours).toString().padStart(2, "0"));
139
137
  updateTimeSpec({ ...timeSpec, hours: newHours });
140
- showDayPeriod &&
141
- setDayPeriodText(newHours >= 12 ? pmLabelRef.current : amLabelRef.current);
138
+ showDayPeriod && setDayPeriodText(newHours >= 12 ? pmLabel : amLabel);
142
139
  event.preventDefault();
143
140
  }
144
141
  else if (event.key === Key.Enter.valueOf()) {
145
142
  const newHours = getValidInt(hoursText, 0, 24, hours);
146
143
  setHoursText(getDisplayHours(newHours).toString().padStart(2, "0"));
147
144
  updateTimeSpec({ ...timeSpec, hours: newHours });
148
- showDayPeriod &&
149
- setDayPeriodText(newHours >= 12 ? pmLabelRef.current : amLabelRef.current);
145
+ showDayPeriod && setDayPeriodText(newHours >= 12 ? pmLabel : amLabel);
150
146
  event.preventDefault();
151
147
  }
152
148
  }, [
149
+ amLabel,
153
150
  getDisplayHours,
154
151
  hours,
155
152
  hoursText,
156
153
  minutes,
154
+ pmLabel,
157
155
  seconds,
158
156
  showDayPeriod,
159
157
  timeSpec,
@@ -222,39 +220,39 @@ export function TimeField({ time, timeDisplay, readOnly, onTimeChange, }) {
222
220
  event.key === Key.Home.valueOf() ||
223
221
  event.key === "a" ||
224
222
  event.key === "A") {
225
- newPeriodText = amLabelRef.current;
223
+ newPeriodText = amLabel;
226
224
  event.preventDefault();
227
225
  }
228
226
  else if (event.key === Key.ArrowUp.valueOf() ||
229
227
  event.key === Key.End.valueOf() ||
230
228
  event.key === "p" ||
231
229
  event.key === "P") {
232
- newPeriodText = pmLabelRef.current;
230
+ newPeriodText = pmLabel;
233
231
  event.preventDefault();
234
232
  }
235
233
  else if (event.key === Key.Enter.valueOf()) {
236
234
  if (dayPeriodText === "AM" ||
237
235
  dayPeriodText === "am" ||
238
- dayPeriodText === amLabelRef.current)
239
- newPeriodText = amLabelRef.current;
236
+ dayPeriodText === amLabel)
237
+ newPeriodText = amLabel;
240
238
  else if (dayPeriodText === "PM" ||
241
239
  dayPeriodText === "pm" ||
242
- dayPeriodText === pmLabelRef.current)
243
- newPeriodText = pmLabelRef.current;
240
+ dayPeriodText === pmLabel)
241
+ newPeriodText = pmLabel;
244
242
  event.preventDefault();
245
243
  }
246
244
  // istanbul ignore else
247
245
  if (undefined !== newPeriodText) {
248
246
  setDayPeriodText(newPeriodText);
249
247
  /* istanbul ignore else */
250
- if (newPeriodText === amLabelRef.current && hours > 12) {
248
+ if (newPeriodText === amLabel && hours > 12) {
251
249
  updateTimeSpec({ ...timeSpec, hours: hours - 12 });
252
250
  }
253
- else if (newPeriodText === pmLabelRef.current && hours <= 11) {
251
+ else if (newPeriodText === pmLabel && hours <= 11) {
254
252
  updateTimeSpec({ ...timeSpec, hours: hours + 12 });
255
253
  }
256
254
  }
257
- }, [dayPeriodText, hours, timeSpec, updateTimeSpec]);
255
+ }, [amLabel, dayPeriodText, hours, pmLabel, timeSpec, updateTimeSpec]);
258
256
  const showSeconds = -1 !== timeDisplay.search(":ss");
259
257
  return (React.createElement("div", { "data-testid": "components-time-input", className: "components-time" },
260
258
  React.createElement(Input, { className: classnames("components-time-input", "components-input"), onKeyDown: handleHoursOnKeyDown, onBlur: handleHoursOnBlur, onChange: handleHoursChange, value: hoursText, disabled: readOnly, size: "small" }),