@talxis/base-controls 1.2502.1 → 1.2503.2

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 (283) hide show
  1. package/dist/components/DatasetControl/DatasetControl.js +21 -34
  2. package/dist/components/DatasetControl/DatasetControl.js.map +1 -1
  3. package/dist/components/DatasetControl/ErrorBoundary.js +33 -0
  4. package/dist/components/DatasetControl/ErrorBoundary.js.map +1 -0
  5. package/dist/components/DatasetControl/QuickFind/QuickFind.d.ts +10 -0
  6. package/dist/components/DatasetControl/QuickFind/QuickFind.js +38 -0
  7. package/dist/components/DatasetControl/QuickFind/QuickFind.js.map +1 -0
  8. package/dist/components/DatasetControl/styles.d.ts +3 -1
  9. package/dist/components/DatasetControl/styles.js +2 -2
  10. package/dist/components/DatasetControl/styles.js.map +1 -1
  11. package/dist/components/DatasetControl/translations.d.ts +8 -0
  12. package/dist/components/DatasetControl/translations.js +3 -1
  13. package/dist/components/DatasetControl/translations.js.map +1 -1
  14. package/dist/components/DateTime/DateTime.js +2 -1
  15. package/dist/components/DateTime/DateTime.js.map +1 -1
  16. package/dist/components/DateTime/components/Calendar.d.ts +2 -1
  17. package/dist/components/DateTime/components/Calendar.js +4 -4
  18. package/dist/components/DateTime/components/Calendar.js.map +1 -1
  19. package/dist/components/DateTime/hooks/useDateTime.js +18 -17
  20. package/dist/components/DateTime/hooks/useDateTime.js.map +1 -1
  21. package/dist/components/Decimal/Decimal.js +5 -1
  22. package/dist/components/Decimal/Decimal.js.map +1 -1
  23. package/dist/components/Duration/Duration.js +49 -26
  24. package/dist/components/Duration/Duration.js.map +1 -1
  25. package/dist/components/Grid/Grid.js +1 -1
  26. package/dist/components/Grid/Grid.js.map +1 -1
  27. package/dist/components/Grid/core/components/AgGrid/AgGrid.js +78 -174
  28. package/dist/components/Grid/core/components/AgGrid/AgGrid.js.map +1 -1
  29. package/dist/components/Grid/core/components/AgGrid/context.d.ts +3 -0
  30. package/dist/components/Grid/core/components/AgGrid/context.js +6 -0
  31. package/dist/components/Grid/core/components/AgGrid/context.js.map +1 -0
  32. package/dist/components/Grid/core/components/AgGrid/model/AgGrid.d.ts +40 -5
  33. package/dist/components/Grid/core/components/AgGrid/model/AgGrid.js +235 -49
  34. package/dist/components/Grid/core/components/AgGrid/model/AgGrid.js.map +1 -1
  35. package/dist/components/Grid/core/components/AgGrid/model/Comparator.d.ts +9 -0
  36. package/dist/components/Grid/core/components/AgGrid/model/Comparator.js +86 -0
  37. package/dist/components/Grid/core/components/AgGrid/model/Comparator.js.map +1 -0
  38. package/dist/components/Grid/core/components/AgGrid/styles.d.ts +28 -32
  39. package/dist/components/Grid/core/components/AgGrid/styles.js +31 -35
  40. package/dist/components/Grid/core/components/AgGrid/styles.js.map +1 -1
  41. package/dist/components/Grid/core/components/Cell/Cell.d.ts +13 -0
  42. package/dist/components/Grid/core/components/Cell/Cell.js +145 -0
  43. package/dist/components/Grid/core/components/Cell/Cell.js.map +1 -0
  44. package/dist/components/Grid/core/components/Cell/CellContent/CellContent.d.ts +3 -0
  45. package/dist/components/Grid/core/components/Cell/CellContent/CellContent.js +212 -0
  46. package/dist/components/Grid/core/components/Cell/CellContent/CellContent.js.map +1 -0
  47. package/dist/components/Grid/core/components/Cell/CellContent/styles.d.ts +33 -0
  48. package/dist/components/Grid/core/components/Cell/CellContent/styles.js +39 -0
  49. package/dist/components/Grid/core/components/Cell/CellContent/styles.js.map +1 -0
  50. package/dist/components/Grid/core/components/Cell/Commands/Commands.js.map +1 -1
  51. package/dist/components/Grid/core/components/Cell/Notifications/Notifications.d.ts +12 -0
  52. package/dist/components/Grid/core/components/Cell/Notifications/Notifications.js +112 -0
  53. package/dist/components/Grid/core/components/Cell/Notifications/Notifications.js.map +1 -0
  54. package/dist/components/Grid/core/components/Cell/Notifications/styles.d.ts +39 -0
  55. package/dist/components/Grid/core/components/Cell/Notifications/styles.js +46 -0
  56. package/dist/components/Grid/core/components/Cell/Notifications/styles.js.map +1 -0
  57. package/dist/components/Grid/core/components/Cell/styles.d.ts +40 -0
  58. package/dist/components/Grid/core/components/Cell/styles.js +59 -0
  59. package/dist/components/Grid/core/components/Cell/styles.js.map +1 -0
  60. package/dist/components/Grid/core/components/ColumnHeader/ColumnHeader.js +3 -2
  61. package/dist/components/Grid/core/components/ColumnHeader/ColumnHeader.js.map +1 -1
  62. package/dist/components/Grid/core/components/ColumnHeader/components/GlobalCheckbox/GlobalCheckbox.js +31 -13
  63. package/dist/components/Grid/core/components/ColumnHeader/components/GlobalCheckbox/GlobalCheckbox.js.map +1 -1
  64. package/dist/components/Grid/core/components/ColumnHeader/components/GlobalCheckbox/styles.d.ts +3 -2
  65. package/dist/components/Grid/core/components/ColumnHeader/components/GlobalCheckbox/styles.js +5 -4
  66. package/dist/components/Grid/core/components/ColumnHeader/components/GlobalCheckbox/styles.js.map +1 -1
  67. package/dist/components/Grid/core/components/ColumnHeader/styles.d.ts +3 -1
  68. package/dist/components/Grid/core/components/ColumnHeader/styles.js +4 -2
  69. package/dist/components/Grid/core/components/ColumnHeader/styles.js.map +1 -1
  70. package/dist/components/Grid/core/components/Save/Save.js +5 -6
  71. package/dist/components/Grid/core/components/Save/Save.js.map +1 -1
  72. package/dist/components/Grid/core/components/Save/components/ChangeEditor/ChangeEditor.js +10 -7
  73. package/dist/components/Grid/core/components/Save/components/ChangeEditor/ChangeEditor.js.map +1 -1
  74. package/dist/components/Grid/core/components/Save/components/ChangeEditor/components/ChangeGrid/ChangeGrid.d.ts +1 -0
  75. package/dist/components/Grid/core/components/Save/components/ChangeEditor/components/ChangeGrid/ChangeGrid.js +26 -7
  76. package/dist/components/Grid/core/components/Save/components/ChangeEditor/components/ChangeGrid/ChangeGrid.js.map +1 -1
  77. package/dist/components/Grid/core/controllers/useGridController.js +8 -2
  78. package/dist/components/Grid/core/controllers/useGridController.js.map +1 -1
  79. package/dist/components/Grid/core/interfaces/IGridColumn.d.ts +2 -0
  80. package/dist/components/Grid/core/model/Grid.d.ts +16 -7
  81. package/dist/components/Grid/core/model/Grid.js +230 -45
  82. package/dist/components/Grid/core/model/Grid.js.map +1 -1
  83. package/dist/components/Grid/core/model/Metadata.d.ts +2 -1
  84. package/dist/components/Grid/core/services/KeyListener.d.ts +2 -0
  85. package/dist/components/Grid/core/services/KeyListener.js +6 -3
  86. package/dist/components/Grid/core/services/KeyListener.js.map +1 -1
  87. package/dist/components/Grid/filtering/components/FilterCallout/components/ConditionValue/ConditionValue.js +3 -3
  88. package/dist/components/Grid/filtering/components/FilterCallout/components/ConditionValue/ConditionValue.js.map +1 -1
  89. package/dist/components/Grid/filtering/components/FilterCallout/components/ConditionValue/model/ConditionComponentValue.d.ts +19 -7
  90. package/dist/components/Grid/{core/components/Component → filtering/components/FilterCallout/components/LegacyControlRendering}/Component.d.ts +2 -2
  91. package/dist/components/Grid/{core/components/Component → filtering/components/FilterCallout/components/LegacyControlRendering}/Component.js +9 -9
  92. package/dist/components/Grid/filtering/components/FilterCallout/components/LegacyControlRendering/Component.js.map +1 -0
  93. package/dist/components/Grid/{core/components/Component → filtering/components/FilterCallout/components/LegacyControlRendering}/controller/useComponentController.d.ts +2 -2
  94. package/dist/components/Grid/{core/components/Component → filtering/components/FilterCallout/components/LegacyControlRendering}/controller/useComponentController.js +1 -1
  95. package/dist/components/Grid/filtering/components/FilterCallout/components/LegacyControlRendering/controller/useComponentController.js.map +1 -0
  96. package/dist/components/Grid/{core/components/Component → filtering/components/FilterCallout/components/LegacyControlRendering}/model/Component.d.ts +2 -2
  97. package/dist/components/Grid/{core/components/Component → filtering/components/FilterCallout/components/LegacyControlRendering}/model/Component.js +15 -19
  98. package/dist/components/Grid/filtering/components/FilterCallout/components/LegacyControlRendering/model/Component.js.map +1 -0
  99. package/dist/components/Grid/filtering/model/Condition.js +1 -1
  100. package/dist/components/Grid/filtering/model/Condition.js.map +1 -1
  101. package/dist/components/Grid/selection/model/Selection.d.ts +3 -4
  102. package/dist/components/Grid/selection/model/Selection.js +8 -26
  103. package/dist/components/Grid/selection/model/Selection.js.map +1 -1
  104. package/dist/components/Grid/sorting/components/SortingContextualMenu/SortingContextualMenu.js +1 -1
  105. package/dist/components/Grid/sorting/components/SortingContextualMenu/SortingContextualMenu.js.map +1 -1
  106. package/dist/components/GridCellRenderer/DefaultContentRenderer/DefaultContentRenderer.d.ts +2 -0
  107. package/dist/components/GridCellRenderer/DefaultContentRenderer/DefaultContentRenderer.js +11 -0
  108. package/dist/components/GridCellRenderer/DefaultContentRenderer/DefaultContentRenderer.js.map +1 -0
  109. package/dist/components/GridCellRenderer/DefaultContentRenderer/index.d.ts +1 -0
  110. package/dist/components/GridCellRenderer/DefaultContentRenderer/index.js +2 -0
  111. package/dist/components/GridCellRenderer/DefaultContentRenderer/index.js.map +1 -0
  112. package/dist/components/GridCellRenderer/GridCellRenderer.d.ts +3 -0
  113. package/dist/components/GridCellRenderer/GridCellRenderer.js +252 -0
  114. package/dist/components/GridCellRenderer/GridCellRenderer.js.map +1 -0
  115. package/dist/components/GridCellRenderer/OptionSet/OptionSet.d.ts +5 -0
  116. package/dist/components/GridCellRenderer/OptionSet/OptionSet.js +69 -0
  117. package/dist/components/GridCellRenderer/OptionSet/OptionSet.js.map +1 -0
  118. package/dist/components/GridCellRenderer/OptionSet/index.d.ts +1 -0
  119. package/dist/components/GridCellRenderer/OptionSet/index.js +2 -0
  120. package/dist/components/GridCellRenderer/OptionSet/index.js.map +1 -0
  121. package/dist/components/{Grid/core/components/Cell/ReadOnlyCell/ReadOnlyOptionSet → GridCellRenderer/OptionSet}/styles.d.ts +10 -12
  122. package/dist/components/GridCellRenderer/OptionSet/styles.js +29 -0
  123. package/dist/components/GridCellRenderer/OptionSet/styles.js.map +1 -0
  124. package/dist/components/GridCellRenderer/index.d.ts +1 -0
  125. package/dist/components/GridCellRenderer/index.js +2 -0
  126. package/dist/components/GridCellRenderer/index.js.map +1 -0
  127. package/dist/components/GridCellRenderer/interfaces.d.ts +53 -0
  128. package/dist/components/GridCellRenderer/styles.d.ts +72 -0
  129. package/dist/components/GridCellRenderer/styles.js +105 -0
  130. package/dist/components/GridCellRenderer/styles.js.map +1 -0
  131. package/dist/components/GridCellRenderer/translations.d.ts +6 -0
  132. package/dist/components/GridCellRenderer/translations.js +11 -0
  133. package/dist/components/GridCellRenderer/translations.js.map +1 -0
  134. package/dist/components/GridCellRenderer/useComponentProps.d.ts +6 -0
  135. package/dist/components/GridCellRenderer/useComponentProps.js +10 -0
  136. package/dist/components/GridCellRenderer/useComponentProps.js.map +1 -0
  137. package/dist/components/Lookup/Lookup.js +8 -3
  138. package/dist/components/Lookup/Lookup.js.map +1 -1
  139. package/dist/components/Lookup/styles.d.ts +19 -7
  140. package/dist/components/Lookup/styles.js +22 -8
  141. package/dist/components/Lookup/styles.js.map +1 -1
  142. package/dist/components/MultiSelectOptionSet/MultiSelectOptionSet.js +51 -28
  143. package/dist/components/MultiSelectOptionSet/MultiSelectOptionSet.js.map +1 -1
  144. package/dist/components/NestedControlRenderer/NestedControl.d.ts +86 -0
  145. package/dist/components/NestedControlRenderer/NestedControl.js +456 -0
  146. package/dist/components/NestedControlRenderer/NestedControl.js.map +1 -0
  147. package/dist/components/NestedControlRenderer/NestedControlError.d.ts +4 -0
  148. package/dist/components/NestedControlRenderer/NestedControlError.js +13 -0
  149. package/dist/components/NestedControlRenderer/NestedControlError.js.map +1 -0
  150. package/dist/components/NestedControlRenderer/NestedControlRenderer.d.ts +3 -0
  151. package/dist/components/NestedControlRenderer/NestedControlRenderer.js +194 -0
  152. package/dist/components/NestedControlRenderer/NestedControlRenderer.js.map +1 -0
  153. package/dist/components/NestedControlRenderer/index.d.ts +1 -0
  154. package/dist/components/NestedControlRenderer/index.js +2 -0
  155. package/dist/components/NestedControlRenderer/index.js.map +1 -0
  156. package/dist/components/NestedControlRenderer/interfaces.d.ts +122 -0
  157. package/dist/components/NestedControlRenderer/manifest/Control.d.ts +16 -0
  158. package/dist/components/NestedControlRenderer/manifest/Control.js +40 -0
  159. package/dist/components/NestedControlRenderer/manifest/Control.js.map +1 -0
  160. package/dist/components/NestedControlRenderer/manifest/Manifest.d.ts +5 -0
  161. package/dist/components/NestedControlRenderer/manifest/Manifest.js +12 -0
  162. package/dist/components/NestedControlRenderer/manifest/Manifest.js.map +1 -0
  163. package/dist/components/NestedControlRenderer/manifest/TypeGroup.d.ts +6 -0
  164. package/dist/components/NestedControlRenderer/manifest/TypeGroup.js +13 -0
  165. package/dist/components/NestedControlRenderer/manifest/TypeGroup.js.map +1 -0
  166. package/dist/components/NestedControlRenderer/manifest/index.d.ts +1 -0
  167. package/dist/components/NestedControlRenderer/manifest/index.js +2 -0
  168. package/dist/components/NestedControlRenderer/manifest/index.js.map +1 -0
  169. package/dist/components/NestedControlRenderer/manifest/property/Property.d.ts +16 -0
  170. package/dist/components/NestedControlRenderer/manifest/property/Property.js +34 -0
  171. package/dist/components/NestedControlRenderer/manifest/property/Property.js.map +1 -0
  172. package/dist/components/NestedControlRenderer/manifest/property/Value.d.ts +8 -0
  173. package/dist/components/NestedControlRenderer/manifest/property/Value.js +12 -0
  174. package/dist/components/NestedControlRenderer/manifest/property/Value.js.map +1 -0
  175. package/dist/components/NestedControlRenderer/properties/DateProperty.d.ts +5 -0
  176. package/dist/components/NestedControlRenderer/properties/DateProperty.js +20 -0
  177. package/dist/components/NestedControlRenderer/properties/DateProperty.js.map +1 -0
  178. package/dist/components/NestedControlRenderer/properties/FileProperty.d.ts +5 -0
  179. package/dist/components/NestedControlRenderer/properties/FileProperty.js +14 -0
  180. package/dist/components/NestedControlRenderer/properties/FileProperty.js.map +1 -0
  181. package/dist/components/NestedControlRenderer/properties/LookupProperty.d.ts +6 -0
  182. package/dist/components/NestedControlRenderer/properties/LookupProperty.js +35 -0
  183. package/dist/components/NestedControlRenderer/properties/LookupProperty.js.map +1 -0
  184. package/dist/components/NestedControlRenderer/properties/NumberProperty.d.ts +5 -0
  185. package/dist/components/NestedControlRenderer/properties/NumberProperty.js +15 -0
  186. package/dist/components/NestedControlRenderer/properties/NumberProperty.js.map +1 -0
  187. package/dist/components/NestedControlRenderer/properties/OptionSetProperty.d.ts +5 -0
  188. package/dist/components/NestedControlRenderer/properties/OptionSetProperty.js +22 -0
  189. package/dist/components/NestedControlRenderer/properties/OptionSetProperty.js.map +1 -0
  190. package/dist/components/NestedControlRenderer/properties/Property.d.ts +17 -0
  191. package/dist/components/NestedControlRenderer/properties/Property.js +46 -0
  192. package/dist/components/NestedControlRenderer/properties/Property.js.map +1 -0
  193. package/dist/components/NestedControlRenderer/properties/TextProperty.d.ts +5 -0
  194. package/dist/components/NestedControlRenderer/properties/TextProperty.js +15 -0
  195. package/dist/components/NestedControlRenderer/properties/TextProperty.js.map +1 -0
  196. package/dist/components/NestedControlRenderer/styles.d.ts +14 -0
  197. package/dist/components/NestedControlRenderer/styles.js +21 -0
  198. package/dist/components/NestedControlRenderer/styles.js.map +1 -0
  199. package/dist/components/NestedControlRenderer/translations.d.ts +14 -0
  200. package/dist/components/NestedControlRenderer/translations.js +19 -0
  201. package/dist/components/NestedControlRenderer/translations.js.map +1 -0
  202. package/dist/components/OptionSet/OptionSet.js +3 -3
  203. package/dist/components/OptionSet/OptionSet.js.map +1 -1
  204. package/dist/components/OptionSet/useComboBoxTheme.js +17 -17
  205. package/dist/components/OptionSet/useComboBoxTheme.js.map +1 -1
  206. package/dist/components/TextField/TextField.js.map +1 -1
  207. package/dist/components/TextField/interfaces.d.ts +2 -2
  208. package/dist/components/TwoOptions/TwoOptions.js +2 -1
  209. package/dist/components/TwoOptions/TwoOptions.js.map +1 -1
  210. package/dist/components/index.d.ts +13 -0
  211. package/dist/components/index.js +15 -0
  212. package/dist/components/index.js.map +1 -0
  213. package/dist/hooks/index.d.ts +1 -0
  214. package/dist/hooks/index.js +1 -0
  215. package/dist/hooks/index.js.map +1 -1
  216. package/dist/hooks/useControl.d.ts +1 -7
  217. package/dist/hooks/useControl.js +12 -40
  218. package/dist/hooks/useControl.js.map +1 -1
  219. package/dist/hooks/useControlLabels.d.ts +14 -0
  220. package/dist/hooks/useControlLabels.js +47 -0
  221. package/dist/hooks/useControlLabels.js.map +1 -0
  222. package/dist/hooks/useInputBasedControl.d.ts +2 -1
  223. package/dist/hooks/useInputBasedControl.js +3 -5
  224. package/dist/hooks/useInputBasedControl.js.map +1 -1
  225. package/dist/hooks/usePrevious.d.ts +1 -0
  226. package/dist/index.d.ts +456 -140
  227. package/dist/index.js +7 -2
  228. package/dist/index.js.map +1 -1
  229. package/dist/interfaces/context.d.ts +2 -1
  230. package/dist/interfaces/index.d.ts +1 -1
  231. package/dist/interfaces/property.d.ts +5 -0
  232. package/dist/utils/BaseControls.d.ts +16 -0
  233. package/dist/utils/BaseControls.js +82 -0
  234. package/dist/utils/BaseControls.js.map +1 -0
  235. package/dist/utils/index.d.ts +1 -0
  236. package/dist/utils/index.js +2 -0
  237. package/dist/utils/index.js.map +1 -1
  238. package/dist/utils/theme/ControlTheme.d.ts +1 -1
  239. package/dist/utils/theme/ControlTheme.js +1 -1
  240. package/dist/utils/theme/ControlTheme.js.map +1 -1
  241. package/dist/utils/theme/components/ThemeWrapper.d.ts +9 -0
  242. package/dist/utils/theme/components/ThemeWrapper.js +11 -0
  243. package/dist/utils/theme/components/ThemeWrapper.js.map +1 -0
  244. package/dist/utils/theme/components/index.d.ts +1 -0
  245. package/dist/utils/theme/components/index.js +2 -0
  246. package/dist/utils/theme/components/index.js.map +1 -0
  247. package/dist/utils/theme/hooks/useControlTheme.d.ts +1 -1
  248. package/dist/utils/theme/hooks/useControlTheme.js.map +1 -1
  249. package/dist/utils/theme/index.d.ts +1 -0
  250. package/dist/utils/theme/index.js +1 -0
  251. package/dist/utils/theme/index.js.map +1 -1
  252. package/package.json +3 -3
  253. package/dist/components/Grid/core/components/Cell/EditableCell/EditableCell.d.ts +0 -10
  254. package/dist/components/Grid/core/components/Cell/EditableCell/EditableCell.js +0 -82
  255. package/dist/components/Grid/core/components/Cell/EditableCell/EditableCell.js.map +0 -1
  256. package/dist/components/Grid/core/components/Cell/ReadOnlyCell/Notifications/Notifications.d.ts +0 -11
  257. package/dist/components/Grid/core/components/Cell/ReadOnlyCell/Notifications/Notifications.js +0 -93
  258. package/dist/components/Grid/core/components/Cell/ReadOnlyCell/Notifications/Notifications.js.map +0 -1
  259. package/dist/components/Grid/core/components/Cell/ReadOnlyCell/Notifications/styles.d.ts +0 -36
  260. package/dist/components/Grid/core/components/Cell/ReadOnlyCell/Notifications/styles.js +0 -42
  261. package/dist/components/Grid/core/components/Cell/ReadOnlyCell/Notifications/styles.js.map +0 -1
  262. package/dist/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyCell.d.ts +0 -11
  263. package/dist/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyCell.js +0 -221
  264. package/dist/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyCell.js.map +0 -1
  265. package/dist/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyOptionSet/ReadOnlyOptionSet.d.ts +0 -10
  266. package/dist/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyOptionSet/ReadOnlyOptionSet.js +0 -49
  267. package/dist/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyOptionSet/ReadOnlyOptionSet.js.map +0 -1
  268. package/dist/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyOptionSet/styles.js +0 -27
  269. package/dist/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyOptionSet/styles.js.map +0 -1
  270. package/dist/components/Grid/core/components/Cell/ReadOnlyCell/styles.d.ts +0 -99
  271. package/dist/components/Grid/core/components/Cell/ReadOnlyCell/styles.js +0 -123
  272. package/dist/components/Grid/core/components/Cell/ReadOnlyCell/styles.js.map +0 -1
  273. package/dist/components/Grid/core/components/Component/Component.js.map +0 -1
  274. package/dist/components/Grid/core/components/Component/controller/useComponentController.js.map +0 -1
  275. package/dist/components/Grid/core/components/Component/model/Component.js.map +0 -1
  276. package/dist/components/Grid/core/model/Metadata.js +0 -26
  277. package/dist/components/Grid/core/model/Metadata.js.map +0 -1
  278. package/dist/components/Grid/selection/controllers/useSelectionController.d.ts +0 -11
  279. package/dist/components/Grid/selection/controllers/useSelectionController.js +0 -21
  280. package/dist/components/Grid/selection/controllers/useSelectionController.js.map +0 -1
  281. package/dist/hooks/useRerender.d.ts +0 -1
  282. package/dist/hooks/useRerender.js +0 -9
  283. package/dist/hooks/useRerender.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"Decimal.js","sources":["../../../src/components/Decimal/Decimal.tsx"],"sourcesContent":["import { TextField } from \"@talxis/react-components\";\nimport { useInputBasedControl } from \"../../hooks/useInputBasedControl\";\nimport { IDecimal, IDecimalOutputs, IDecimalParameters } from \"./interfaces\";\nimport React, { useEffect, useMemo, useRef } from \"react\";\nimport numeral from \"numeral\";\nimport { CURRENCY_NEGATIVE_PATTERN, CURRENCY_POSITIVE_PATTERN, NUMBER_NEGATIVE_PATTERN } from \"../../constants\";\nimport { ICommandBarItemProps, ThemeProvider } from \"@fluentui/react\";\nimport { ArrowButtons, IArrowButtons } from \"./components/ArrowButtons\";\nimport { Numeral } from \"@talxis/client-libraries\";\n\nexport const Decimal = (props: IDecimal) => {\n const arrowButtonsRef = useRef<IArrowButtons>(null);\n const context = props.context;\n const parameters = props.parameters;\n const boundValue = parameters.value;\n const numberFormatting = context.userSettings.numberFormattingInfo;\n const onOverrideComponentProps = props.onOverrideComponentProps ?? ((props) => props);\n\n const formatter = (value: string | number | null): string | undefined | null => {\n if (typeof value === 'number') {\n if (props.parameters.value.type === 'Decimal') {\n return context.formatting.formatDecimal(value, boundValue.attributes?.Precision);\n }\n if (props.parameters.value.type === 'Currency') {\n //the layer above has information about the symbol, so we can use the formatted string\n if (props.parameters.value.formatted) {\n return props.parameters.value.formatted;\n }\n return context.formatting.formatCurrency(value, boundValue.attributes?.Precision);\n }\n return context.formatting.formatInteger(value);\n }\n return value;\n };\n\n const createNumberPattern = (pattern: string, numberPattern: string) => {\n return new RegExp(`^${escapeRegExp(pattern).replace('n', numberPattern)}$`.replace(/\\s/g, ''));\n };\n\n const createCurrencyPattern = (pattern: string, numberPattern: string) => {\n const escapedPattern = escapeRegExp(pattern);\n const escapedCurrencySymbolPattern = `(${escapeRegExp(numberFormatting.currencySymbol)})?`;\n const finalPattern = escapedPattern.replace('\\\\$', escapedCurrencySymbolPattern).replace('n', numberPattern);\n return new RegExp(`^${finalPattern.replace(/\\s/g, '')}$`);\n };\n\n const escapeRegExp = (string: string) => {\n return string.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n };\n\n const extractNumericPart = (value: any): number | undefined => {\n // Currency control just sends the string up and lets the framework decide whether the value is correct\n // It only tries to parse the number based on the current user format\n // This means that the value will also pass if the user inputs his own currency even though\n // the currency is different on the field\n if (typeof value === 'number') {\n return value\n }\n const str = value?.replace(/\\s/g, '');\n Numeral.decimal(numberFormatting);\n let positivePattern: any;\n let negativePattern: any;\n\n switch (props.parameters.value.type) {\n case 'Whole.None': {\n const numberPattern = `\\\\d{1,}(${numberFormatting.numberGroupSeparator}\\\\d{1,})*`;\n positivePattern = createNumberPattern('n', numberPattern);\n negativePattern = createNumberPattern(NUMBER_NEGATIVE_PATTERN[numberFormatting.numberNegativePattern], numberPattern);\n break;\n }\n case 'Decimal': {\n const numberPattern = `\\\\d{1,}(${numberFormatting.numberGroupSeparator}\\\\d{1,})*(\\\\${numberFormatting.numberDecimalSeparator}\\\\d+)?`;\n positivePattern = createNumberPattern('n', numberPattern);\n negativePattern = createNumberPattern(NUMBER_NEGATIVE_PATTERN[numberFormatting.numberNegativePattern], numberPattern);\n break;\n }\n case 'Currency': {\n Numeral.currency(numberFormatting);\n const numberPattern = `\\\\d{1,}(${numberFormatting.currencyGroupSeparator}\\\\d{1,})*(\\\\${numberFormatting.currencyDecimalSeparator}\\\\d+)?`;\n positivePattern = createCurrencyPattern(CURRENCY_POSITIVE_PATTERN[numberFormatting.currencyPositivePattern], numberPattern);\n negativePattern = createCurrencyPattern(CURRENCY_NEGATIVE_PATTERN[numberFormatting.currencyNegativePattern], numberPattern);\n break;\n }\n }\n if (positivePattern.test(str)) {\n return numeral(str).value() ?? undefined;\n }\n if (negativePattern.test(str)) {\n const value = numeral(str).value()!;\n if (value > 0) {\n return value * -1;\n }\n return value;\n }\n return value;\n };\n\n const { value, sizing, theme, setValue, onNotifyOutputChanged } = useInputBasedControl<string | undefined, IDecimalParameters, IDecimalOutputs, any>('Decimal', props, {\n formatter: formatter,\n valueExtractor: extractNumericPart\n });\n\n const getSuffixItems = (): ICommandBarItemProps[] | undefined => {\n if (context.mode.isControlDisabled || !parameters.EnableSpinButton?.raw) {\n return undefined;\n }\n return [\n {\n key: 'arrows',\n onRender: () => <ArrowButtons\n ref={arrowButtonsRef}\n onDecrement={() => makeStep('decrement')}\n onIncrement={() => makeStep('increment')} />\n }\n ]\n }\n\n const makeStep = (type: 'increment' | 'decrement') => {\n const value = boundValue.raw ?? 0;\n if (typeof value !== 'number') {\n return;\n }\n const precision = Math.pow(10, boundValue.attributes?.Precision ?? 0);\n const adjustment = type === 'increment' ? 1 : -1;\n const newValue = parseFloat(((value) + adjustment / precision).toFixed(boundValue.attributes?.Precision ?? 0));\n onNotifyOutputChanged({ value: newValue });\n\n }\n\n const onKeyDown = (e: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n if (context.mode.isControlDisabled) {\n return;\n }\n switch (e.key) {\n case 'ArrowDown': {\n e.preventDefault();\n makeStep('decrement');\n arrowButtonsRef.current?.setActiveBtn('down');\n break;\n }\n case 'ArrowUp': {\n e.preventDefault();\n makeStep('increment');\n arrowButtonsRef.current?.setActiveBtn('up');\n break;\n }\n }\n }\n\n const getInputMode = () => {\n switch (props.parameters.value.type) {\n case 'Whole.None': {\n return 'numeric';\n }\n case 'Decimal':\n case 'Currency': {\n return 'decimal';\n }\n }\n }\n useEffect(() => {\n if (boundValue.type === 'Currency') {\n setValue(boundValue.formatted);\n }\n }, [boundValue.formatted]);\n\n const componentProps = onOverrideComponentProps({\n hideErrorMessage: !parameters.ShowErrorMessage?.raw,\n readOnly: context.mode.isControlDisabled,\n inputMode: useMemo(() => getInputMode(), [props.parameters.value.type]),\n suffixItems: getSuffixItems(),\n autoFocus: parameters.AutoFocus?.raw,\n errorMessage: boundValue.errorMessage,\n styles: {\n fieldGroup: {\n height: sizing.height,\n width: sizing.width\n }\n },\n deleteButtonProps: parameters.EnableDeleteButton?.raw === true\n ? {\n key: \"delete\",\n showOnlyOnHover: true,\n iconProps: {\n iconName: \"Cancel\",\n },\n onClick: () => setValue(undefined),\n }\n : undefined,\n clickToCopyProps: parameters.EnableCopyButton?.raw === true\n ? {\n key: \"copy\",\n showOnlyOnHover: true,\n iconProps: {\n iconName: \"Copy\",\n },\n }\n : undefined,\n value: value ?? \"\",\n onBlur: (event) => {\n onNotifyOutputChanged({\n value: extractNumericPart(event.target.value)\n });\n },\n onChange: (e, value) => {\n setValue(value);\n },\n onKeyDown: onKeyDown,\n });\n return (\n <ThemeProvider theme={theme} applyTo=\"none\">\n <TextField {...componentProps} />\n </ThemeProvider>\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;;;;;;AAUa,MAAA,OAAO,GAAG,CAAC,KAAe,KAAI;AACvC,IAAA,MAAM,eAAe,GAAG,MAAM,CAAgB,IAAI,CAAC,CAAC;AACpD,IAAA,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;AAC9B,IAAA,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC;AACpC,IAAA,MAAM,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC;AACpC,IAAA,MAAM,gBAAgB,GAAG,OAAO,CAAC,YAAY,CAAC,oBAAoB,CAAC;AACnE,IAAA,MAAM,wBAAwB,GAAG,KAAK,CAAC,wBAAwB,KAAK,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC;AAEtF,IAAA,MAAM,SAAS,GAAG,CAAC,KAA6B,KAA+B;AAC3E,QAAA,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC3B,IAAI,K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A,QACIA,GAAC,CAAA,aAAa,IAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAC,MAAM,EAAA,QAAA,EACvCA,IAAC,SAAS,EAAA,EAAA,GAAK,cAAc,EAAI,CAAA,EAAA,CACrB,EAClB;AACN;;;;"}
1
+ {"version":3,"file":"Decimal.js","sources":["../../../src/components/Decimal/Decimal.tsx"],"sourcesContent":["import { TextField } from \"@talxis/react-components\";\nimport { useInputBasedControl } from \"../../hooks/useInputBasedControl\";\nimport { IDecimal, IDecimalOutputs, IDecimalParameters } from \"./interfaces\";\nimport React, { useEffect, useMemo, useRef } from \"react\";\nimport numeral from \"numeral\";\nimport { CURRENCY_NEGATIVE_PATTERN, CURRENCY_POSITIVE_PATTERN, NUMBER_NEGATIVE_PATTERN } from \"../../constants\";\nimport { ICommandBarItemProps, ThemeProvider } from \"@fluentui/react\";\nimport { ArrowButtons, IArrowButtons } from \"./components/ArrowButtons\";\nimport { Numeral } from \"@talxis/client-libraries\";\n\nexport const Decimal = (props: IDecimal) => {\n const arrowButtonsRef = useRef<IArrowButtons>(null);\n const context = props.context;\n const parameters = props.parameters;\n const boundValue = parameters.value;\n const numberFormatting = context.userSettings.numberFormattingInfo;\n const onOverrideComponentProps = props.onOverrideComponentProps ?? ((props) => props);\n\n const formatter = (value: string | number | null): string | undefined | null => {\n if (typeof value === 'number') {\n if (props.parameters.value.type === 'Decimal') {\n return context.formatting.formatDecimal(value, boundValue.attributes?.Precision);\n }\n if (props.parameters.value.type === 'Currency') {\n //the layer above has information about the symbol, so we can use the formatted string\n if (props.parameters.value.formatted) {\n return props.parameters.value.formatted;\n }\n return context.formatting.formatCurrency(value, boundValue.attributes?.Precision);\n }\n return context.formatting.formatInteger(value);\n }\n return value;\n };\n\n const createNumberPattern = (pattern: string, numberPattern: string) => {\n return new RegExp(`^${escapeRegExp(pattern).replace('n', numberPattern)}$`.replace(/\\s/g, ''));\n };\n\n const createCurrencyPattern = (pattern: string, numberPattern: string) => {\n const escapedPattern = escapeRegExp(pattern);\n const escapedCurrencySymbolPattern = `(${escapeRegExp(numberFormatting.currencySymbol)})?`;\n const finalPattern = escapedPattern.replace('\\\\$', escapedCurrencySymbolPattern).replace('n', numberPattern);\n return new RegExp(`^${finalPattern.replace(/\\s/g, '')}$`);\n };\n\n const escapeRegExp = (string: string) => {\n return string.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n };\n\n const extractNumericPart = (value: any): number | undefined => {\n // Currency control just sends the string up and lets the framework decide whether the value is correct\n // It only tries to parse the number based on the current user format\n // This means that the value will also pass if the user inputs his own currency even though\n // the currency is different on the field\n if (typeof value === 'number') {\n return value\n }\n if(value === initialFormattedValue) {\n return boundValue.raw as number;\n }\n const str = value?.replace(/\\s/g, '');\n Numeral.decimal(numberFormatting);\n let positivePattern: any;\n let negativePattern: any;\n\n switch (props.parameters.value.type) {\n case 'Whole.None': {\n const numberPattern = `\\\\d{1,}(${numberFormatting.numberGroupSeparator}\\\\d{1,})*`;\n positivePattern = createNumberPattern('n', numberPattern);\n negativePattern = createNumberPattern(NUMBER_NEGATIVE_PATTERN[numberFormatting.numberNegativePattern], numberPattern);\n break;\n }\n case 'Decimal': {\n const numberPattern = `\\\\d{1,}(${numberFormatting.numberGroupSeparator}\\\\d{1,})*(\\\\${numberFormatting.numberDecimalSeparator}\\\\d+)?`;\n positivePattern = createNumberPattern('n', numberPattern);\n negativePattern = createNumberPattern(NUMBER_NEGATIVE_PATTERN[numberFormatting.numberNegativePattern], numberPattern);\n break;\n }\n case 'Currency': {\n Numeral.currency(numberFormatting);\n const numberPattern = `\\\\d{1,}(${numberFormatting.currencyGroupSeparator}\\\\d{1,})*(\\\\${numberFormatting.currencyDecimalSeparator}\\\\d+)?`;\n positivePattern = createCurrencyPattern(CURRENCY_POSITIVE_PATTERN[numberFormatting.currencyPositivePattern], numberPattern);\n negativePattern = createCurrencyPattern(CURRENCY_NEGATIVE_PATTERN[numberFormatting.currencyNegativePattern], numberPattern);\n break;\n }\n }\n if (positivePattern.test(str)) {\n return numeral(str).value() ?? undefined;\n }\n if (negativePattern.test(str)) {\n const value = numeral(str).value()!;\n if (value > 0) {\n return value * -1;\n }\n return value;\n }\n return value;\n };\n\n const { value, sizing, theme, setValue, onNotifyOutputChanged } = useInputBasedControl<string | undefined, IDecimalParameters, IDecimalOutputs, any>('Decimal', props, {\n formatter: formatter,\n valueExtractor: extractNumericPart\n });\n const initialFormattedValue = useMemo(() => value, []);\n\n const getSuffixItems = (): ICommandBarItemProps[] | undefined => {\n if (context.mode.isControlDisabled || !parameters.EnableSpinButton?.raw) {\n return undefined;\n }\n return [\n {\n key: 'arrows',\n onRender: () => <ArrowButtons\n ref={arrowButtonsRef}\n onDecrement={() => makeStep('decrement')}\n onIncrement={() => makeStep('increment')} />\n }\n ]\n }\n\n const makeStep = (type: 'increment' | 'decrement') => {\n const value = boundValue.raw ?? 0;\n if (typeof value !== 'number') {\n return;\n }\n const precision = Math.pow(10, boundValue.attributes?.Precision ?? 0);\n const adjustment = type === 'increment' ? 1 : -1;\n const newValue = parseFloat(((value) + adjustment / precision).toFixed(boundValue.attributes?.Precision ?? 0));\n onNotifyOutputChanged({ value: newValue });\n\n }\n\n const onKeyDown = (e: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n if (context.mode.isControlDisabled) {\n return;\n }\n switch (e.key) {\n case 'ArrowDown': {\n e.preventDefault();\n makeStep('decrement');\n arrowButtonsRef.current?.setActiveBtn('down');\n break;\n }\n case 'ArrowUp': {\n e.preventDefault();\n makeStep('increment');\n arrowButtonsRef.current?.setActiveBtn('up');\n break;\n }\n }\n }\n\n const getInputMode = () => {\n switch (props.parameters.value.type) {\n case 'Whole.None': {\n return 'numeric';\n }\n case 'Decimal':\n case 'Currency': {\n return 'decimal';\n }\n }\n }\n useEffect(() => {\n if (boundValue.type === 'Currency') {\n setValue(boundValue.formatted);\n }\n }, [boundValue.formatted]);\n\n const componentProps = onOverrideComponentProps({\n hideErrorMessage: !parameters.ShowErrorMessage?.raw,\n readOnly: context.mode.isControlDisabled,\n inputMode: useMemo(() => getInputMode(), [props.parameters.value.type]),\n suffixItems: getSuffixItems(),\n autoFocus: parameters.AutoFocus?.raw,\n errorMessage: boundValue.errorMessage,\n styles: {\n fieldGroup: {\n height: sizing.height,\n width: sizing.width\n }\n },\n deleteButtonProps: parameters.EnableDeleteButton?.raw === true\n ? {\n key: \"delete\",\n showOnlyOnHover: true,\n iconProps: {\n iconName: \"Cancel\",\n },\n onClick: () => setValue(undefined),\n }\n : undefined,\n clickToCopyProps: parameters.EnableCopyButton?.raw === true\n ? {\n key: \"copy\",\n showOnlyOnHover: true,\n iconProps: {\n iconName: \"Copy\",\n },\n }\n : undefined,\n value: value ?? \"\",\n onBlur: (event) => {\n onNotifyOutputChanged({\n value: extractNumericPart(event.target.value)\n });\n },\n onChange: (e, value) => {\n setValue(value);\n },\n onKeyDown: onKeyDown,\n });\n return (\n <ThemeProvider theme={theme} applyTo=\"none\">\n <TextField {...componentProps} />\n </ThemeProvider>\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;;;;;;AAUa,MAAA,OAAO,GAAG,CAAC,KAAe,KAAI;AACvC,IAAA,MAAM,eAAe,GAAG,MAAM,CAAgB,IAAI,CAAC,CAAC;AACpD,IAAA,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;AAC9B,IAAA,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC;AACpC,IAAA,MAAM,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC;AACpC,IAAA,MAAM,gBAAgB,GAAG,OAAO,CAAC,YAAY,CAAC,oBAAoB,CAAC;AACnE,IAAA,MAAM,wBAAwB,GAAG,KAAK,CAAC,wBAAwB,KAAK,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC;AAEtF,IAAA,MAAM,SAAS,GAAG,CAAC,KAA6B,KAA+B;AAC3E,QAAA,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC3B,IAAI,KAAK,CAA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AA,QAAQ,EAAE,CAAC,CAAC,EAAE,KAAK,KAAI;YACnB,QAAQ,CAAC,KAAK,CAAC,CAAC;SACnB;AACD,QAAA,SAAS,EAAE,SAAS;AACvB,KAAA,CAAC,CAAC;AACH,IAAA,QACIA,GAAC,CAAA,aAAa,IAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAC,MAAM,EAAA,QAAA,EACvCA,IAAC,SAAS,EAAA,EAAA,GAAK,cAAc,EAAI,CAAA,EAAA,CACrB,EAClB;AACN;;;;"}
@@ -1,6 +1,6 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
2
  import { ComboBox } from '@talxis/react-components';
3
- import { useRef, useEffect } from 'react';
3
+ import { useRef, useMemo, useEffect } from 'react';
4
4
  import { useInputBasedControl } from '../../hooks/useInputBasedControl.js';
5
5
  import { ThemeProvider } from '@fluentui/react';
6
6
  import numeral from 'numeral';
@@ -18,6 +18,7 @@ const Duration = (props) => {
18
18
  //@ts-ignore - locale is part of UserSettings
19
19
  const language = formattingInfo.locale;
20
20
  const numberFormatting = context.userSettings.numberFormattingInfo;
21
+ const onOverrideComponentProps = props.onOverrideComponentProps ?? ((props) => props);
21
22
  const formatter = (value) => {
22
23
  //all duration formatting should happen here
23
24
  if (typeof value === 'number') {
@@ -37,6 +38,9 @@ const Duration = (props) => {
37
38
  const valueExtractor = (str) => {
38
39
  //extraction of number of minutes from formatted string should happen here
39
40
  // parsing because labels are string that represent array of strings
41
+ if (initialFormattedValue === str) {
42
+ return boundValue.raw;
43
+ }
40
44
  const minuteLabels = JSON.parse(labels.minute());
41
45
  const minutesLabels = JSON.parse(labels.minutes());
42
46
  const hourLabels = JSON.parse(labels.hour());
@@ -96,36 +100,55 @@ const Duration = (props) => {
96
100
  valueExtractor: valueExtractor,
97
101
  defaultTranslations: getDefaultDurationTranslations(),
98
102
  });
103
+ const initialFormattedValue = useMemo(() => value, []);
99
104
  useEffect(() => {
100
105
  if (parameters.AutoFocus?.raw) {
101
106
  componentRef.current?.focus(true);
102
107
  }
103
108
  }, []);
104
- return (jsx(ThemeProvider, { theme: theme, applyTo: "none", children: jsx(ComboBox, { componentRef: componentRef, options: comboBoxOptions, hideErrorMessage: !parameters.ShowErrorMessage?.raw, allowFreeInput: true, autoComplete: 'on', autofill: parameters.AutoFocus?.raw === true ? {
105
- autoFocus: true
106
- } : undefined, readOnly: context.mode.isControlDisabled, useComboBoxAsMenuWidth: true, errorMessage: boundValue.errorMessage, text: value ?? '', styles: {
107
- root: {
108
- height: sizing.height,
109
- width: sizing.width,
110
- display: 'flex',
111
- alignItems: 'center',
112
- },
113
- callout: {
114
- height: 300
115
- }
116
- }, onInputValueChange: (text) => {
117
- setValue(text ?? '');
118
- }, onBlur: (event) => {
119
- onNotifyOutputChanged({
120
- //any is needed here because we can return string in case of error values
121
- value: valueExtractor(value)
122
- });
123
- }, onChange: (e, value) => {
124
- onNotifyOutputChanged({
125
- //any is needed here because we can return string in case of error values
126
- value: valueExtractor(value?.text ?? '')
127
- });
128
- } }) }));
109
+ const componentProps = onOverrideComponentProps({
110
+ componentRef,
111
+ options: comboBoxOptions,
112
+ hideErrorMessage: !parameters.ShowErrorMessage?.raw,
113
+ allowFreeInput: true,
114
+ autoComplete: 'on',
115
+ autofill: parameters.AutoFocus?.raw === true ? { autoFocus: true } : undefined,
116
+ readOnly: context.mode.isControlDisabled,
117
+ useComboBoxAsMenuWidth: true,
118
+ errorMessage: boundValue.errorMessage,
119
+ text: value ?? '',
120
+ styles: {
121
+ root: {
122
+ height: sizing.height,
123
+ width: sizing.width,
124
+ display: 'flex',
125
+ alignItems: 'center',
126
+ },
127
+ callout: {
128
+ height: 300
129
+ }
130
+ },
131
+ calloutProps: {
132
+ theme: props.context.fluentDesignLanguage?.applicationTheme ?? theme
133
+ },
134
+ onRenderContainer: (containerProps, defaultRender) => jsx(ThemeProvider, { theme: props.context.fluentDesignLanguage?.applicationTheme, children: defaultRender?.(containerProps) }),
135
+ onInputValueChange: (text) => {
136
+ setValue(text ?? '');
137
+ },
138
+ onBlur: (event) => {
139
+ onNotifyOutputChanged({
140
+ //any is needed here because we can return string in case of error values
141
+ value: valueExtractor(value)
142
+ });
143
+ },
144
+ onChange: (e, value) => {
145
+ onNotifyOutputChanged({
146
+ //any is needed here because we can return string in case of error values
147
+ value: valueExtractor(value?.text ?? '')
148
+ });
149
+ }
150
+ });
151
+ return (jsx(ThemeProvider, { theme: theme, applyTo: "none", children: jsx(ComboBox, { ...componentProps }) }));
129
152
  };
130
153
 
131
154
  export { Duration };
@@ -1 +1 @@
1
- {"version":3,"file":"Duration.js","sources":["../../../src/components/Duration/Duration.tsx"],"sourcesContent":["import { ComboBox } from \"@talxis/react-components\";\nimport React, { useEffect, useRef } from 'react';\nimport { useInputBasedControl } from '../../hooks/useInputBasedControl';\nimport { IDuration, IDurationOutputs, IDurationParameters } from './interfaces';\nimport { IComboBox, IComboBoxOption, ThemeProvider } from '@fluentui/react';\nimport numeral from \"numeral\";\nimport { getDefaultDurationTranslations } from './translations';\nimport { durationOptions } from \"./durationOptions\";\nimport humanizeDuration, { Unit } from \"humanize-duration\";\nimport { Numeral } from \"@talxis/client-libraries\";\n\nexport const Duration = (props: IDuration) => {\n const parameters = props.parameters;\n const boundValue = parameters.value;\n const componentRef = useRef<IComboBox>(null);\n const context = props.context;\n const formattingInfo = context.userSettings;\n //@ts-ignore - locale is part of UserSettings\n const language = formattingInfo.locale;\n const numberFormatting = context.userSettings.numberFormattingInfo;\n\n const formatter = (value: number | null) => {\n //all duration formatting should happen here\n if (typeof value === 'number') {\n const durationInMilliseconds = value * 60000;\n const units: Unit[] = value < 60 ? ['m'] : value >= 1440 ? ['d'] : ['h'];\n const options = {\n units: units,\n maxDecimalPoints: 2,\n language: language.slice(0, language.indexOf(\"-\")),\n decimal: context.userSettings.numberFormattingInfo.numberDecimalSeparator,\n fallbacks: [\"en\"]\n };\n return humanizeDuration(durationInMilliseconds, options);\n }\n return value;\n };\n\n const valueExtractor = (str: string | null): number | undefined | string => {\n //extraction of number of minutes from formatted string should happen here\n // parsing because labels are string that represent array of strings\n const minuteLabels = JSON.parse(labels.minute());\n const minutesLabels = JSON.parse(labels.minutes());\n const hourLabels = JSON.parse(labels.hour());\n const hoursLabels = JSON.parse(labels.hours());\n const dayLabels = JSON.parse(labels.day());\n const daysLabels = JSON.parse(labels.days());\n const minuteRegex = new RegExp(\"^(\" + minuteLabels.join('|') + \")\\\\s|\\\\s(\" + minuteLabels.join('|') + \")$|^(\" + minutesLabels.join('|') + \")\\\\s|\\\\s(\" + minutesLabels.join('|') + \")$\", \"i\");\n const hourRegex = new RegExp(\"^(\" + hourLabels.join('|') + \")\\\\s|\\\\s(\" + hourLabels.join('|') + \")$|^(\" + hoursLabels.join('|') + \")\\\\s|\\\\s(\" + hoursLabels.join('|') + \")$\", \"i\");\n const dayRegex = new RegExp(\"^(\" + dayLabels.join('|') + \")\\\\s|\\\\s(\" + dayLabels.join('|') + \")$|^(\" + daysLabels.join('|') + \")\\\\s|\\\\s(\" + daysLabels.join('|') + \")$\", \"i\");\n\n if (str && str.trim()) {\n let input = str.trim().toLowerCase();\n let unit = 'minute';\n\n if (minuteRegex.test(input)) {\n input = input.replace(minuteRegex, \"\").trim();\n } else if (hourRegex.test(input)) {\n input = input.replace(hourRegex, \"\").trim();\n unit = 'hour';\n } else if (dayRegex.test(input)) {\n input = input.replace(dayRegex, \"\").trim();\n unit = 'day';\n }\n const parsedNumber = parseNumber(input);\n if (parsedNumber && !isNaN(parsedNumber)) {\n return getDurationInMinutes(parsedNumber, unit);\n }\n return str;\n }\n return undefined;\n };\n\n const parseNumber = (input: string): number | undefined => {\n Numeral.decimal(numberFormatting);\n return numeral(input).value() ?? undefined;\n };\n\n const getDurationInMinutes = (value: number, unit: string): number => {\n switch (unit) {\n case 'hour':\n return 60 * value;\n case 'day':\n return 60 * value * 24;\n case 'minute':\n default:\n return value;\n }\n };\n\n const presetOptions = (): IComboBoxOption[] => {\n const formattedOptions = durationOptions.map(option => ({\n key: option.Value.toString(),\n text: formatter(parseInt(option.Label)) ?? \"\",\n }));\n return formattedOptions;\n };\n\n const comboBoxOptions: IComboBoxOption[] = presetOptions();\n\n const { value, labels, sizing, setValue, onNotifyOutputChanged, theme } = useInputBasedControl<string | null, IDurationParameters, IDurationOutputs, Required<IDuration>['translations']>('Duration', props, {\n formatter: formatter,\n valueExtractor: valueExtractor,\n defaultTranslations: getDefaultDurationTranslations(),\n });\n\n useEffect(() => {\n if (parameters.AutoFocus?.raw) {\n componentRef.current?.focus(true);\n }\n }, []);\n\n return (\n <ThemeProvider theme={theme} applyTo=\"none\">\n <ComboBox\n componentRef={componentRef}\n options={comboBoxOptions}\n hideErrorMessage={!parameters.ShowErrorMessage?.raw}\n allowFreeInput={true}\n autoComplete='on'\n autofill={parameters.AutoFocus?.raw === true ? {\n autoFocus: true\n } : undefined}\n readOnly={context.mode.isControlDisabled}\n useComboBoxAsMenuWidth\n errorMessage={boundValue.errorMessage}\n text={value ?? ''}\n styles={{\n root: {\n height: sizing.height,\n width: sizing.width,\n display: 'flex',\n alignItems: 'center',\n },\n callout: {\n height: 300\n }\n }}\n onInputValueChange={(text) => {\n setValue(text ?? '');\n }}\n onBlur={(event) => {\n onNotifyOutputChanged({\n //any is needed here because we can return string in case of error values\n value: valueExtractor(value) as any\n });\n }}\n onChange={(e, value) => {\n onNotifyOutputChanged({\n //any is needed here because we can return string in case of error values\n value: valueExtractor(value?.text ?? '') as any\n });\n }}\n />\n </ThemeProvider>\n );\n};"],"names":["_jsx"],"mappings":";;;;;;;;;;;AAWa,MAAA,QAAQ,GAAG,CAAC,KAAgB,KAAI;AACzC,IAAA,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC;AACpC,IAAA,MAAM,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC;AACpC,IAAA,MAAM,YAAY,GAAG,MAAM,CAAY,IAAI,CAAC,CAAC;AAC7C,IAAA,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;AAC9B,IAAA,MAA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EAAE,CAAC,UAAU,CAAC,gBAAgB,EAAE,GAAG,EACnD,cAAc,EAAE,IAAI,EACpB,YAAY,EAAC,IAAI,EACjB,QAAQ,EAAE,UAAU,CAAC,SAAS,EAAE,GAAG,KAAK,IAAI,GAAG;AAC3C,gBAAA,SAAS,EAAE,IAAI;aAClB,GAAG,SAAS,EACb,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,iBAAiB,EACxC,sBAAsB,EACtB,IAAA,EAAA,YAAY,EAAE,UAAU,CAAC,YAAY,EACrC,IAAI,EAAE,KAAK,IAAI,EAAE,EACjB,MAAM,EAAE;AACJ,gBAAA,IAAI,EAAE;oBACF,MAAM,EAAE,MAAM,CAAC,MAAM;oBACrB,KAAK,EAAE,MAAM,CAAC,KAAK;AACnB,oBAAA,OAAO,EAAE,MAAM;AACf,oBAAA,UAAU,EAAE,QAAQ;AACvB,iBAAA;AACD,gBAAA,OAAO,EAAE;AACL,oBAAA,MAAM,EAAE,GAAG;AACd,iBAAA;AACJ,aAAA,EACD,kBAAkB,EAAE,CAAC,IAAI,KAAI;AACzB,gBAAA,QAAQ,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;AACzB,aAAC,EACD,MAAM,EAAE,CAAC,KAAK,KAAI;AACd,gBAAA,qBAAqB,CAAC;;AAElB,oBAAA,KAAK,EAAE,cAAc,CAAC,KAAK,CAAQ;AACtC,iBAAA,CAAC,CAAC;aACN,EACD,QAAQ,EAAE,CAAC,CAAC,EAAE,KAAK,KAAI;AACnB,gBAAA,qBAAqB,CAAC;;oBAElB,KAAK,EAAE,cAAc,CAAC,KAAK,EAAE,IAAI,IAAI,EAAE,CAAQ;AAClD,iBAAA,CAAC,CAAC;aACN,EAAA,CACH,EACc,CAAA,EAClB;AACN;;;;"}
1
+ {"version":3,"file":"Duration.js","sources":["../../../src/components/Duration/Duration.tsx"],"sourcesContent":["import { ComboBox } from \"@talxis/react-components\";\nimport { useEffect, useMemo, useRef } from 'react';\nimport { useInputBasedControl } from '../../hooks/useInputBasedControl';\nimport { IDuration, IDurationOutputs, IDurationParameters } from './interfaces';\nimport { IComboBox, IComboBoxOption, ThemeProvider } from '@fluentui/react';\nimport numeral from \"numeral\";\nimport { getDefaultDurationTranslations } from './translations';\nimport { durationOptions } from \"./durationOptions\";\nimport humanizeDuration, { Unit } from \"humanize-duration\";\nimport { Numeral } from \"@talxis/client-libraries\";\n\nexport const Duration = (props: IDuration) => {\n const parameters = props.parameters;\n const boundValue = parameters.value;\n const componentRef = useRef<IComboBox>(null);\n const context = props.context;\n const formattingInfo = context.userSettings;\n //@ts-ignore - locale is part of UserSettings\n const language = formattingInfo.locale;\n const numberFormatting = context.userSettings.numberFormattingInfo;\n const onOverrideComponentProps = props.onOverrideComponentProps ?? ((props) => props);\n\n const formatter = (value: number | null) => {\n //all duration formatting should happen here\n if (typeof value === 'number') {\n const durationInMilliseconds = value * 60000;\n const units: Unit[] = value < 60 ? ['m'] : value >= 1440 ? ['d'] : ['h'];\n const options = {\n units: units,\n maxDecimalPoints: 2,\n language: language.slice(0, language.indexOf(\"-\")),\n decimal: context.userSettings.numberFormattingInfo.numberDecimalSeparator,\n fallbacks: [\"en\"]\n };\n return humanizeDuration(durationInMilliseconds, options);\n }\n return value;\n };\n\n const valueExtractor = (str: string | null): number | undefined | string => {\n //extraction of number of minutes from formatted string should happen here\n // parsing because labels are string that represent array of strings\n if(initialFormattedValue === str) {\n return boundValue.raw as number;\n }\n const minuteLabels = JSON.parse(labels.minute());\n const minutesLabels = JSON.parse(labels.minutes());\n const hourLabels = JSON.parse(labels.hour());\n const hoursLabels = JSON.parse(labels.hours());\n const dayLabels = JSON.parse(labels.day());\n const daysLabels = JSON.parse(labels.days());\n const minuteRegex = new RegExp(\"^(\" + minuteLabels.join('|') + \")\\\\s|\\\\s(\" + minuteLabels.join('|') + \")$|^(\" + minutesLabels.join('|') + \")\\\\s|\\\\s(\" + minutesLabels.join('|') + \")$\", \"i\");\n const hourRegex = new RegExp(\"^(\" + hourLabels.join('|') + \")\\\\s|\\\\s(\" + hourLabels.join('|') + \")$|^(\" + hoursLabels.join('|') + \")\\\\s|\\\\s(\" + hoursLabels.join('|') + \")$\", \"i\");\n const dayRegex = new RegExp(\"^(\" + dayLabels.join('|') + \")\\\\s|\\\\s(\" + dayLabels.join('|') + \")$|^(\" + daysLabels.join('|') + \")\\\\s|\\\\s(\" + daysLabels.join('|') + \")$\", \"i\");\n\n if (str && str.trim()) {\n let input = str.trim().toLowerCase();\n let unit = 'minute';\n\n if (minuteRegex.test(input)) {\n input = input.replace(minuteRegex, \"\").trim();\n } else if (hourRegex.test(input)) {\n input = input.replace(hourRegex, \"\").trim();\n unit = 'hour';\n } else if (dayRegex.test(input)) {\n input = input.replace(dayRegex, \"\").trim();\n unit = 'day';\n }\n const parsedNumber = parseNumber(input);\n if (parsedNumber && !isNaN(parsedNumber)) {\n return getDurationInMinutes(parsedNumber, unit);\n }\n return str;\n }\n return undefined;\n };\n\n const parseNumber = (input: string): number | undefined => {\n Numeral.decimal(numberFormatting);\n return numeral(input).value() ?? undefined;\n };\n\n const getDurationInMinutes = (value: number, unit: string): number => {\n switch (unit) {\n case 'hour':\n return 60 * value;\n case 'day':\n return 60 * value * 24;\n case 'minute':\n default:\n return value;\n }\n };\n\n const presetOptions = (): IComboBoxOption[] => {\n const formattedOptions = durationOptions.map(option => ({\n key: option.Value.toString(),\n text: formatter(parseInt(option.Label)) ?? \"\",\n }));\n return formattedOptions;\n };\n\n const comboBoxOptions: IComboBoxOption[] = presetOptions();\n\n const { value, labels, sizing, setValue, onNotifyOutputChanged, theme } = useInputBasedControl<string | null, IDurationParameters, IDurationOutputs, Required<IDuration>['translations']>('Duration', props, {\n formatter: formatter,\n valueExtractor: valueExtractor,\n defaultTranslations: getDefaultDurationTranslations(),\n });\n\n const initialFormattedValue = useMemo(() => value, [])\n\n useEffect(() => {\n if (parameters.AutoFocus?.raw) {\n componentRef.current?.focus(true);\n }\n }, []);\n\n const componentProps = onOverrideComponentProps({\n componentRef,\n options: comboBoxOptions,\n hideErrorMessage: !parameters.ShowErrorMessage?.raw,\n\n allowFreeInput: true,\n autoComplete: 'on',\n autofill: parameters.AutoFocus?.raw === true ? { autoFocus: true } : undefined,\n readOnly: context.mode.isControlDisabled,\n useComboBoxAsMenuWidth: true,\n errorMessage: boundValue.errorMessage,\n text: value ?? '',\n styles: {\n root: {\n height: sizing.height,\n width: sizing.width,\n display: 'flex',\n alignItems: 'center',\n },\n callout: {\n height: 300\n }\n },\n calloutProps: {\n theme: props.context.fluentDesignLanguage?.applicationTheme ?? theme\n },\n onRenderContainer: (containerProps, defaultRender) => <ThemeProvider theme={props.context.fluentDesignLanguage?.applicationTheme}>{defaultRender?.(containerProps)}</ThemeProvider>,\n onInputValueChange: (text) => {\n setValue(text ?? '');\n },\n onBlur: (event) => {\n onNotifyOutputChanged({\n //any is needed here because we can return string in case of error values\n value: valueExtractor(value) as any\n });\n },\n onChange: (e, value) => {\n onNotifyOutputChanged({\n //any is needed here because we can return string in case of error values\n value: valueExtractor(value?.text ?? '') as any\n });\n }\n });\n\n return (\n <ThemeProvider theme={theme} applyTo=\"none\">\n <ComboBox {...componentProps} />\n </ThemeProvider>\n );\n};"],"names":["_jsx"],"mappings":";;;;;;;;;;;AAWa,MAAA,QAAQ,GAAG,CAAC,KAAgB,KAAI;AACzC,IAAA,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC;AACpC,IAAA,MAAM,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC;AACpC,IAAA,MAAM,YAAY,GAAG,MAAM,CAAY,IAAI,CAAC,CAAC;AAC7C,IAAA,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;AAC9B,IAAA,MAAM,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC;;AAE5C,IAAA,MAAM,QAAQ,GAAG,cAAc,CAAC,MAAM,CAAC;AACvC,IAAA,MAAM,gBAAgB,GAAG,OAAO,CAAC,YAAY,CAAC,oBAAoB,CAAC;AACnE,IA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AA,QAAQ,EAAE,CAAC,CAAC,EAAE,KAAK,KAAI;AACnB,YAAA,qBAAqB,CAAC;;gBAElB,KAAK,EAAE,cAAc,CAAC,KAAK,EAAE,IAAI,IAAI,EAAE,CAAQ;AAClD,aAAA,CAAC,CAAC;SACN;AACJ,KAAA,CAAC,CAAC;AAEH,IAAA,QACIA,GAAC,CAAA,aAAa,IAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAC,MAAM,EAAA,QAAA,EACvCA,IAAC,QAAQ,EAAA,EAAA,GAAK,cAAc,EAAI,CAAA,EAAA,CACpB,EAClB;AACN;;;;"}
@@ -27,7 +27,7 @@ const Grid = (props) => {
27
27
  const theme = useControlTheme(props.context.fluentDesignLanguage);
28
28
  useEffect(() => {
29
29
  return () => {
30
- keyHoldListener.destroy();
30
+ providerValue.gridInstance.destroy();
31
31
  };
32
32
  }, []);
33
33
  return (jsx(GridContext.Provider, { value: providerValue, children: jsx(ThemeProvider, { className: `talxis__gridControl ${styles.root}`, theme: theme, applyTo: 'none', children: jsx(AgGrid, {}) }) }));
@@ -1 +1 @@
1
- {"version":3,"file":"Grid.js","sources":["../../../src/components/Grid/Grid.tsx"],"sourcesContent":["import { useEffect, useMemo } from \"react\";\nimport { useControl, useControlTheme } from \"../../hooks\"\nimport { IGridContext } from \"./core/interfaces/IGridContext\";\nimport { Grid as GridModel } from \"./core/model/Grid\";\nimport { IGrid } from \"./interfaces\";\nimport { AgGrid } from './core/components/AgGrid/AgGrid';\nimport React from 'react';\nimport { gridTranslations } from './translations';\nimport { GridContext } from \"./GridContext\";\nimport { mergeStyleSets, ThemeProvider } from \"@fluentui/react\";\nimport { KeyHoldListener } from \"./core/services/KeyListener\";\n\nconst styles = mergeStyleSets({\n root: {\n displayName: 'talxis__gridControl',\n height: '100%'\n }\n});\n\nexport const Grid = (props: IGrid) => {\n const { labels } = useControl('Grid', props, gridTranslations);\n const keyHoldListener = useMemo(() => new KeyHoldListener(), []);\n const providerValue: IGridContext = useMemo(() => {\n return {\n gridInstance: new GridModel(props, labels, keyHoldListener)\n }\n }, [])\n \n providerValue.gridInstance.updateDependencies(props);\n const theme = useControlTheme(props.context.fluentDesignLanguage);\n\n useEffect(() => {\n return () => {\n keyHoldListener.destroy();\n }\n }, []);\n return (\n <GridContext.Provider value={providerValue}>\n <ThemeProvider className={`talxis__gridControl ${styles.root}`} theme={theme} applyTo='none'>\n <AgGrid />\n </ThemeProvider>\n </GridContext.Provider>\n )\n}"],"names":["GridModel","_jsx"],"mappings":";;;;;;;;;;;AAYA,MAAM,MAAM,GAAG,cAAc,CAAC;AAC1B,IAAA,IAAI,EAAE;AACF,QAAA,WAAW,EAAE,qBAAqB;AAClC,QAAA,MAAM,EAAE,MAAM;AACjB,KAAA;AACJ,CAAA,CAAC,CAAC;AAEU,MAAA,IAAI,GAAG,CAAC,KAAY,KAAI;AACjC,IAAA,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,MAAM,EAAE,KAAK,EAAE,gBAAgB,CAAC,CAAC;AAC/D,IAAA,MAAM,eAAe,GAAG,OAAO,CAAC,MAAM,IAAI,eAAe,EAAE,EAAE,EAAE,CAAC,CAAC;AACjE,IAAA,MAAM,aAAa,GAAiB,OAAO,CAAC,MAAK;QAC7C,OAAO;YACH,YAAY,EAAE,IAAIA,MAAS,CAAC,KAAK,EAAE,MAAM,EAAE,eAAe,CAAC;SAC9D,CAAA;KACJ,EAAE,EAAE,CAAC,CAAA;AAEN,IAAA,aAAa,CAAC,YAAY,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;IACrD,MAAM,KAAK,GAAG,eAAe,CAAC,KAAK,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAElE,SAAS,CAAC,MAAK;AACX,QAAA,OAAO,MAAK;YACR,eAAe,CAAC,OAAO,EAAE,CAAC;AAC9B,SAAC,CAAA;KACJ,EAAE,EAAE,CAAC,CAAC;AACP,IAAA,QACIC,GAAA,CAAC,WAAW,CAAC,QAAQ,EAAC,EAAA,KAAK,EAAE,aAAa,YACtCA,GAAC,CAAA,aAAa,EAAC,EAAA,SAAS,EAAE,CAAuB,oBAAA,EAAA,MAAM,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAC,MAAM,EAAA,QAAA,EACxFA,IAAC,MAAM,EAAA,EAAA,CAAG,EACE,CAAA,EAAA,CACG,EAC1B;AACL;;;;"}
1
+ {"version":3,"file":"Grid.js","sources":["../../../src/components/Grid/Grid.tsx"],"sourcesContent":["import { useEffect, useMemo } from \"react\";\nimport { useControl, useControlTheme } from \"../../hooks\"\nimport { IGridContext } from \"./core/interfaces/IGridContext\";\nimport { Grid as GridModel } from \"./core/model/Grid\";\nimport { IGrid } from \"./interfaces\";\nimport { AgGrid } from './core/components/AgGrid/AgGrid';\nimport { gridTranslations } from './translations';\nimport { GridContext } from \"./GridContext\";\nimport { mergeStyleSets, ThemeProvider } from \"@fluentui/react\";\nimport { KeyHoldListener } from \"./core/services/KeyListener\";\n\nconst styles = mergeStyleSets({\n root: {\n displayName: 'talxis__gridControl',\n height: '100%'\n }\n});\n\n\nexport const Grid = (props: IGrid) => {\n const { labels } = useControl('Grid', props, gridTranslations);\n const keyHoldListener = useMemo(() => new KeyHoldListener(), []);\n const providerValue: IGridContext = useMemo(() => {\n return {\n gridInstance: new GridModel(props, labels, keyHoldListener)\n }\n }, [])\n\n providerValue.gridInstance.updateDependencies(props);\n const theme = useControlTheme(props.context.fluentDesignLanguage);\n\n useEffect(() => {\n return () => {\n providerValue.gridInstance.destroy();\n }\n }, []);\n\n return (\n <GridContext.Provider value={providerValue}>\n <ThemeProvider className={`talxis__gridControl ${styles.root}`} theme={theme} applyTo='none'>\n <AgGrid />\n </ThemeProvider>\n </GridContext.Provider>\n\n )\n}"],"names":["GridModel","_jsx"],"mappings":";;;;;;;;;;;AAWA,MAAM,MAAM,GAAG,cAAc,CAAC;AAC1B,IAAA,IAAI,EAAE;AACF,QAAA,WAAW,EAAE,qBAAqB;AAClC,QAAA,MAAM,EAAE,MAAM;AACjB,KAAA;AACJ,CAAA,CAAC,CAAC;AAGU,MAAA,IAAI,GAAG,CAAC,KAAY,KAAI;AACjC,IAAA,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,MAAM,EAAE,KAAK,EAAE,gBAAgB,CAAC,CAAC;AAC/D,IAAA,MAAM,eAAe,GAAG,OAAO,CAAC,MAAM,IAAI,eAAe,EAAE,EAAE,EAAE,CAAC,CAAC;AACjE,IAAA,MAAM,aAAa,GAAiB,OAAO,CAAC,MAAK;QAC7C,OAAO;YACH,YAAY,EAAE,IAAIA,MAAS,CAAC,KAAK,EAAE,MAAM,EAAE,eAAe,CAAC;SAC9D,CAAA;KACJ,EAAE,EAAE,CAAC,CAAA;AAEN,IAAA,aAAa,CAAC,YAAY,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;IACrD,MAAM,KAAK,GAAG,eAAe,CAAC,KAAK,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAElE,SAAS,CAAC,MAAK;AACX,QAAA,OAAO,MAAK;AACR,YAAA,aAAa,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;AACzC,SAAC,CAAA;KACJ,EAAE,EAAE,CAAC,CAAC;AAEP,IAAA,QACIC,GAAA,CAAC,WAAW,CAAC,QAAQ,EAAC,EAAA,KAAK,EAAE,aAAa,YACtCA,GAAC,CAAA,aAAa,EAAC,EAAA,SAAS,EAAE,CAAuB,oBAAA,EAAA,MAAM,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAC,MAAM,EAAA,QAAA,EACxFA,IAAC,MAAM,EAAA,EAAA,CAAG,EACE,CAAA,EAAA,CACG,EAE1B;AACL;;;;"}
@@ -1,53 +1,60 @@
1
- import { jsxs, jsx } from 'react/jsx-runtime';
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
2
  import { AgGridReact } from '@ag-grid-community/react';
3
3
  import { useTheme, MessageBar, MessageBarType } from '@fluentui/react';
4
4
  import { ModuleRegistry } from '@ag-grid-community/core';
5
- import { useRef, useMemo, useState, useCallback, useEffect } from 'react';
6
- import { useSelectionController } from '../../../selection/controllers/useSelectionController.js';
5
+ import { useRef, useMemo, useState, useEffect } from 'react';
7
6
  import { useGridInstance } from '../../hooks/useGridInstance.js';
8
7
  import { getGridStyles } from './styles.js';
9
8
  import { Paging } from '../../../paging/components/Paging/Paging.js';
10
9
  import { EmptyRecords } from './components/EmptyRecordsOverlay/EmptyRecords.js';
11
10
  import { Save } from '../Save/Save.js';
12
11
  import { LoadingOverlay } from './components/LoadingOverlay/LoadingOverlay.js';
13
- import { CHECKBOX_COLUMN_KEY } from '../../../constants.js';
14
12
  import { useDebounce, useDebouncedCallback } from 'use-debounce';
15
13
  import { useGridController } from '../../controllers/useGridController.js';
16
- import { useStateValues } from '@talxis/react-components';
14
+ import { useStateValues, useRerender } from '@talxis/react-components';
17
15
  import { AgGrid as AgGrid$1 } from './model/AgGrid.js';
18
16
  import { ClientSideRowModelModule } from '@ag-grid-community/client-side-row-model';
19
17
  import '@ag-grid-community/styles/ag-grid.css';
20
18
  import '@ag-grid-community/styles/ag-theme-balham.css';
19
+ import { AgGridContext } from './context.js';
20
+ import { CHECKBOX_COLUMN_KEY } from '../../../constants.js';
21
21
 
22
22
  ModuleRegistry.registerModules([ClientSideRowModelModule]);
23
23
  const AgGrid = () => {
24
24
  const grid = useGridInstance();
25
- const selection = useSelectionController();
26
25
  const gridApiRef = useRef();
27
26
  const containerWidthRef = useRef(0);
28
27
  const containerRef = useRef(null);
29
28
  const theme = useTheme();
30
- const styles = getGridStyles(theme, grid.height);
29
+ const styles = useMemo(() => getGridStyles(theme, grid.height), [theme, grid.height]);
31
30
  const agGridReadyRef = useRef(false);
32
- const agGrid = useMemo(() => new AgGrid$1(grid, gridApiRef), []);
31
+ const agGrid = useMemo(() => new AgGrid$1(grid, gridApiRef, theme), []);
32
+ const agGridProviderValue = useMemo(() => agGrid, []);
33
33
  const { columns } = useGridController();
34
34
  const [agColumns, setAgColumns] = useState([]);
35
35
  const [stateValuesRef, getNewStateValues, setDefaultStateValues] = useStateValues(grid.state);
36
- //this is to prevent AgGrid from throwing errors in some rerender edge cases - https://github.com/ag-grid/ag-grid/issues/6013
36
+ //this is to prevent AgGrid from throwing errors in some rerender edge cases - https://github.com/ag-gid/ag-grid/issues/6013
37
37
  const [records] = useDebounce(grid.records, 0);
38
38
  const userChangedColumnSizeRef = useRef(false);
39
+ const rerender = useRerender();
40
+ const innerRerenderRef = useRef(true);
39
41
  const debouncedRefresh = useDebouncedCallback(() => {
40
- gridApiRef.current?.refreshCells({
41
- rowNodes: gridApiRef.current?.getRenderedNodes(),
42
- force: true
43
- });
44
- grid.refreshGlobalCheckBox();
45
- agGrid.selectRows();
42
+ agGrid.refresh();
46
43
  }, 0);
47
44
  const debouncedSetAgColumns = useDebouncedCallback(() => {
48
- setAgColumns(agGrid.columns);
45
+ innerRerenderRef.current = true;
46
+ setAgColumns(agGrid.getColumns());
49
47
  }, 0);
50
- debouncedRefresh();
48
+ const debounceUpdateVisualSizeFactor = useDebouncedCallback((e) => {
49
+ if (e.source !== 'uiColumnResized') {
50
+ return;
51
+ }
52
+ userChangedColumnSizeRef.current = true;
53
+ agGrid.updateColumnVisualSizeFactor(e);
54
+ }, 200);
55
+ if (!innerRerenderRef.current) {
56
+ debouncedRefresh();
57
+ }
51
58
  const onGridReady = () => {
52
59
  agGridReadyRef.current = true;
53
60
  setDefaultStateValues({
@@ -57,7 +64,6 @@ const AgGrid = () => {
57
64
  },
58
65
  ...gridApiRef.current.getState(),
59
66
  });
60
- agGrid.selectRows();
61
67
  };
62
68
  const sizeColumnsIfSpaceAvailable = () => {
63
69
  //do not autosize if user manually adjusted the column width
@@ -68,179 +74,77 @@ const AgGrid = () => {
68
74
  gridApiRef.current.sizeColumnsToFit();
69
75
  }
70
76
  };
71
- const updateColumnOrder = async (e) => {
72
- if (e.type === 'gridOptionsChanged') {
73
- return;
74
- }
75
- const sortedIds = e.api.getState().columnOrder?.orderedColIds;
76
- if (!sortedIds) {
77
- return;
78
- }
79
- const idIndexMap = new Map();
80
- sortedIds.forEach((id, index) => {
81
- idIndexMap.set(id, index);
82
- });
83
- const orderedColumns = [...grid.dataset.columns].sort((a, b) => {
84
- const aIndex = idIndexMap.has(a.name) ? idIndexMap.get(a.name) : sortedIds.length;
85
- const bIndex = idIndexMap.has(b.name) ? idIndexMap.get(b.name) : sortedIds.length;
86
- return aIndex - bIndex;
87
- });
88
- grid.dataset.setColumns?.(orderedColumns);
89
- grid.pcfContext.factory.requestRender();
90
- };
91
- const globalClickHandler = useCallback((e) => {
92
- const hasAncestorWithClass = (element, className) => {
93
- let parent = element;
94
- while (!parent.classList.contains('ag-theme-balham')) {
95
- if (parent.classList.contains(className)) {
96
- return true;
97
- }
98
- if (parent.tagName === 'HTML') {
99
- return false;
100
- }
101
- parent = parent.parentElement;
102
- if (!parent) {
103
- return true;
104
- }
105
- }
106
- return false;
107
- };
108
- try {
109
- if (!hasAncestorWithClass(e.target, 'ag-cell')) {
110
- gridApiRef.current?.stopEditing();
111
- }
112
- }
113
- catch (err) {
114
- }
115
- }, []);
116
- const copyCellValue = useCallback((event) => {
117
- if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === 'c') {
118
- const cell = gridApiRef.current?.getFocusedCell();
119
- if (!cell) {
120
- return;
121
- }
122
- const row = gridApiRef.current?.getDisplayedRowAtIndex(cell.rowIndex);
123
- const formattedValue = gridApiRef.current?.getCellValue({
124
- rowNode: row,
125
- colKey: cell.column.getColId(),
126
- useFormatter: true
127
- });
128
- navigator.clipboard.writeText(formattedValue ?? "");
129
- }
130
- }, []);
131
- const toggleOverlay = () => {
132
- if (!gridApiRef.current) {
133
- return;
134
- }
135
- if (grid.loading) {
136
- gridApiRef.current.showLoadingOverlay();
137
- return;
138
- }
139
- gridApiRef.current.hideOverlay();
140
- setTimeout(() => {
141
- if (grid.records.length === 0) {
142
- gridApiRef.current?.showNoRowsOverlay();
143
- }
144
- }, 0);
145
- };
146
77
  const getCurrentContainerWidth = () => {
147
78
  return containerWidthRef.current ?? containerRef.current?.clientWidth;
148
79
  };
149
- const updateColumnVisualSizeFactor = useDebouncedCallback((e) => {
150
- if (e.source !== 'uiColumnResized') {
151
- return;
152
- }
153
- const resizedColumnKey = grid.dataset.columns.find(x => x.name === e.column?.getId())?.name;
154
- if (!resizedColumnKey) {
155
- return;
156
- }
157
- const columns = grid.dataset.columns;
158
- for (let i = 0; i < columns.length; i++) {
159
- if (columns[i].name === resizedColumnKey) {
160
- columns[i].visualSizeFactor = e.column?.getActualWidth();
161
- }
162
- }
163
- userChangedColumnSizeRef.current = true;
164
- grid.dataset.setColumns?.(columns);
165
- gridApiRef.current?.resetRowHeights();
166
- grid.pcfContext.factory.requestRender();
167
- }, 200);
168
- //TODO: find a better way to achieve this
169
- useEffect(() => {
170
- document.addEventListener('click', globalClickHandler);
171
- return () => {
172
- document.removeEventListener('click', globalClickHandler);
173
- };
174
- }, []);
175
80
  useEffect(() => {
176
- toggleOverlay();
177
- if (records.length > 0) {
178
- gridApiRef.current?.ensureIndexVisible(0);
179
- }
81
+ agGrid.toggleOverlay();
180
82
  }, [grid.loading]);
181
83
  useEffect(() => {
182
84
  //this can be replaced with native functionality if we decide to use ag grid enterprise
183
- grid.keyHoldListener.addOnKeyDownHandler((event) => copyCellValue(event));
85
+ grid.keyHoldListener.addOnKeyDownHandler((event) => agGrid.copyCellValue(event));
86
+ agGrid.setRerenderCallback(() => {
87
+ innerRerenderRef.current = true;
88
+ rerender();
89
+ });
184
90
  return () => {
185
91
  grid.pcfContext.mode.setControlState(getNewStateValues());
186
92
  };
187
93
  }, []);
188
- useEffect(() => {
189
- agGrid.selectRows();
190
- }, [records]);
191
94
  useEffect(() => {
192
95
  debouncedSetAgColumns();
193
96
  }, [columns]);
194
97
  useEffect(() => {
195
98
  sizeColumnsIfSpaceAvailable();
196
99
  }, [agColumns]);
197
- return (jsxs("div", { ref: containerRef, className: `${styles.root} ag-theme-balham`, children: [grid.isEditable && grid.dataset.isDirty?.() &&
198
- jsx(Save, {}), grid.error &&
199
- jsx(MessageBar, { messageBarType: MessageBarType.error, children: jsx("span", { dangerouslySetInnerHTML: {
200
- __html: grid.errorMessage
201
- } }) }), jsx(AgGridReact, { animateRows: true, rowSelection: grid.selection.type, noRowsOverlayComponent: Object.keys(grid.dataset.sortedRecordIds.length === 0) && !grid.loading ? EmptyRecords : undefined, loadingOverlayComponent: grid.loading ? LoadingOverlay : undefined, suppressDragLeaveHidesColumns: true, onColumnResized: (e) => updateColumnVisualSizeFactor(e), onColumnMoved: (e) => {
202
- if (e.finished) {
203
- updateColumnOrder(e);
204
- }
205
- }, reactiveCustomComponents: true, onRowSelected: (e) => {
206
- //prevent infinite loop since we are also setting the rows
207
- //when the selection comes from above
208
- if (e.source.includes('api') || e.source === 'gridInitializing') {
209
- return;
210
- }
211
- selection.toggle(e.data, e.node.isSelected());
212
- }, onCellDoubleClicked: (e) => {
213
- if (grid.isNavigationEnabled && !grid.isEditable) {
214
- grid.openDatasetItem(e.data.getNamedReference());
215
- }
216
- }, onCellMouseOver: (e) => {
217
- if (e.colDef.colId === CHECKBOX_COLUMN_KEY) {
218
- gridApiRef.current?.setGridOption('suppressRowClickSelection', true);
219
- }
220
- }, onCellMouseOut: (e) => {
221
- gridApiRef.current?.setGridOption('suppressRowClickSelection', false);
222
- }, getRowId: (params) => params.data.getRecordId(), onGridReady: (e) => {
223
- gridApiRef.current = e.api;
224
- if (grid.loading) {
225
- gridApiRef.current?.showLoadingOverlay();
226
- }
227
- onGridReady();
228
- }, onGridSizeChanged: (e) => {
229
- containerWidthRef.current = e.clientWidth;
230
- sizeColumnsIfSpaceAvailable();
231
- }, onFirstDataRendered: (e) => {
232
- sizeColumnsIfSpaceAvailable();
233
- }, initialState: stateValuesRef.current, onStateUpdated: (e) => stateValuesRef.current = {
234
- ...stateValuesRef.current,
235
- ...e.state
236
- }, suppressAnimationFrame: true, columnDefs: agColumns, rowData: records, getRowHeight: (params) => {
237
- const columnWidths = {};
238
- params.api.getAllGridColumns().map(col => {
239
- columnWidths[col.getColId()] = col.getActualWidth();
240
- });
241
- return params?.data?.ui?.getHeight(columnWidths, grid.rowHeight);
242
- } }), grid.paging.isEnabled &&
243
- jsx(Paging, {})] }));
100
+ innerRerenderRef.current = false;
101
+ return (jsx(AgGridContext.Provider, { value: agGridProviderValue, children: jsxs("div", { ref: containerRef, className: `${styles.root} ag-theme-balham`, children: [grid.isEditable && grid.dataset.isDirty?.() &&
102
+ jsx(Save, {}), grid.error &&
103
+ jsx(MessageBar, { messageBarType: MessageBarType.error, children: jsx("span", { dangerouslySetInnerHTML: {
104
+ __html: grid.errorMessage
105
+ } }) }), jsx(AgGridReact, { animateRows: false, rowSelection: grid.selection.type, noRowsOverlayComponent: Object.keys(grid.dataset.sortedRecordIds.length === 0) && !grid.loading ? EmptyRecords : undefined, loadingOverlayComponent: grid.loading ? LoadingOverlay : undefined, suppressDragLeaveHidesColumns: true, onColumnResized: (e) => debounceUpdateVisualSizeFactor(e), onColumnMoved: (e) => agGrid.updateColumnOrder(e), reactiveCustomComponents: true, onSelectionChanged: (e) => {
106
+ if (e.source.includes('api')) {
107
+ return;
108
+ }
109
+ const cell = e.api.getFocusedCell();
110
+ if (cell.column.getColId() === CHECKBOX_COLUMN_KEY) {
111
+ const node = e.api.getSelectedNodes().find(node => node.rowIndex === cell.rowIndex);
112
+ grid.selection.toggle(node.id);
113
+ }
114
+ else {
115
+ grid.dataset.setSelectedRecordIds(e.api.getSelectedNodes().map(node => node.data.getRecordId()));
116
+ }
117
+ agGrid.refreshRowSelection();
118
+ }, gridOptions: {
119
+ getRowStyle: (params) => {
120
+ const theme = params.rowIndex % 2 === 0 ? agGrid.evenRowCellTheme : agGrid.oddRowCellTheme;
121
+ return {
122
+ backgroundColor: theme.semanticColors.bodyBackground
123
+ };
124
+ },
125
+ }, onCellDoubleClicked: (e) => {
126
+ if (grid.isNavigationEnabled && !grid.isEditable) {
127
+ grid.dataset.openDatasetItem(e.data.getNamedReference());
128
+ }
129
+ }, getRowId: (params) => params.data.getRecordId(), onGridReady: (e) => {
130
+ gridApiRef.current = e.api;
131
+ if (grid.loading) {
132
+ gridApiRef.current?.showLoadingOverlay();
133
+ }
134
+ onGridReady();
135
+ }, onGridSizeChanged: (e) => {
136
+ containerWidthRef.current = e.clientWidth;
137
+ sizeColumnsIfSpaceAvailable();
138
+ }, onFirstDataRendered: (e) => {
139
+ sizeColumnsIfSpaceAvailable();
140
+ agGrid.refreshRowSelection();
141
+ }, onCellEditingStopped: () => {
142
+ grid.pcfContext.factory.requestRender();
143
+ }, initialState: stateValuesRef.current, onStateUpdated: (e) => stateValuesRef.current = {
144
+ ...stateValuesRef.current,
145
+ ...e.state
146
+ }, columnDefs: agColumns, rowData: records, getRowHeight: (params) => agGrid.getRowHeight(params.data) }), grid.paging.isEnabled &&
147
+ jsx(Paging, {})] }) }));
244
148
  };
245
149
 
246
150
  export { AgGrid };