@linzjs/step-ag-grid 23.0.1 → 25.0.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 (292) hide show
  1. package/dist/GridTheme.scss +1 -1
  2. package/dist/index.css +0 -13
  3. package/dist/src/components/ComponentLoadingWrapper.d.ts +1 -1
  4. package/dist/src/components/Grid.d.ts +17 -17
  5. package/dist/src/components/GridCell.d.ts +9 -9
  6. package/dist/src/components/GridCellFiller.d.ts +2 -2
  7. package/dist/src/components/GridCellMultiEditor.d.ts +6 -6
  8. package/dist/src/components/GridCellMultiSelectClassRules.d.ts +1 -1
  9. package/dist/src/components/GridIcon.d.ts +2 -2
  10. package/dist/src/components/GridNoRowsOverlay.d.ts +1 -1
  11. package/dist/src/components/GridPopoverHook.d.ts +2 -2
  12. package/dist/src/components/GridWrapper.d.ts +1 -1
  13. package/dist/src/components/PostSortRowsHook.d.ts +1 -1
  14. package/dist/src/components/clickInputWhenContainingCellClicked.d.ts +1 -1
  15. package/dist/src/components/gridFilter/GridFilterButtons.d.ts +5 -5
  16. package/dist/src/components/gridFilter/GridFilterColumnsToggle.d.ts +1 -1
  17. package/dist/src/components/gridFilter/GridFilterDownloadCsvButton.d.ts +1 -1
  18. package/dist/src/components/gridFilter/GridFilterHeaderIconButton.d.ts +2 -2
  19. package/dist/src/components/gridFilter/GridFilters.d.ts +1 -1
  20. package/dist/src/components/gridFilter/index.d.ts +7 -7
  21. package/dist/src/components/gridFilter/useGridFilter.d.ts +2 -2
  22. package/dist/src/components/gridForm/GridFormDropDown.d.ts +8 -8
  23. package/dist/src/components/gridForm/GridFormEditBearing.d.ts +2 -2
  24. package/dist/src/components/gridForm/GridFormMessage.d.ts +3 -3
  25. package/dist/src/components/gridForm/GridFormMultiSelect.d.ts +4 -4
  26. package/dist/src/components/gridForm/GridFormMultiSelectGrid.d.ts +4 -4
  27. package/dist/src/components/gridForm/GridFormPopoverMenu.d.ts +5 -5
  28. package/dist/src/components/gridForm/GridFormSubComponentTextArea.d.ts +4 -4
  29. package/dist/src/components/gridForm/GridFormSubComponentTextInput.d.ts +4 -4
  30. package/dist/src/components/gridForm/GridFormTextArea.d.ts +4 -4
  31. package/dist/src/components/gridForm/GridFormTextInput.d.ts +3 -3
  32. package/dist/src/components/gridForm/index.d.ts +10 -10
  33. package/dist/src/components/gridHeader/GridHeaderSelect.d.ts +1 -1
  34. package/dist/src/components/gridHeader/index.d.ts +1 -1
  35. package/dist/src/components/gridHook/index.d.ts +1 -1
  36. package/dist/src/components/gridHook/useGridContextMenu.d.ts +4 -4
  37. package/dist/src/components/gridPopoverEdit/GridButton.d.ts +5 -5
  38. package/dist/src/components/gridPopoverEdit/GridEditBoolean.d.ts +4 -4
  39. package/dist/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.d.ts +4 -4
  40. package/dist/src/components/gridPopoverEdit/GridPopoutEditMultiSelectGrid.d.ts +4 -4
  41. package/dist/src/components/gridPopoverEdit/GridPopoverEditBearing.d.ts +4 -4
  42. package/dist/src/components/gridPopoverEdit/GridPopoverEditDropDown.d.ts +4 -4
  43. package/dist/src/components/gridPopoverEdit/GridPopoverMenu.d.ts +4 -4
  44. package/dist/src/components/gridPopoverEdit/GridPopoverMessage.d.ts +4 -4
  45. package/dist/src/components/gridPopoverEdit/GridPopoverTextArea.d.ts +4 -4
  46. package/dist/src/components/gridPopoverEdit/GridPopoverTextInput.d.ts +4 -4
  47. package/dist/src/components/gridPopoverEdit/index.d.ts +11 -11
  48. package/dist/src/components/gridRender/GridRenderGenericCell.d.ts +5 -5
  49. package/dist/src/components/gridRender/GridRenderPopoutMenuCell.d.ts +1 -1
  50. package/dist/src/components/gridRender/index.d.ts +2 -2
  51. package/dist/src/components/gridUtil.d.ts +1 -1
  52. package/dist/src/components/index.d.ts +19 -19
  53. package/dist/src/contexts/GridContext.d.ts +4 -4
  54. package/dist/src/contexts/GridContextProvider.d.ts +3 -3
  55. package/dist/src/contexts/GridPopoverContext.d.ts +3 -3
  56. package/dist/src/contexts/GridPopoverContextProvider.d.ts +4 -4
  57. package/dist/src/contexts/GridUpdatingContextProvider.d.ts +1 -1
  58. package/dist/src/index.d.ts +19 -17
  59. package/dist/src/lui/ActionButton.d.ts +9 -9
  60. package/dist/src/lui/FormError.d.ts +2 -2
  61. package/dist/src/lui/TextAreaInput.d.ts +1 -1
  62. package/dist/src/lui/TextInputFormatted.d.ts +2 -2
  63. package/dist/src/lui/reactUtils.d.ts +1 -1
  64. package/dist/src/lui/stateDeferredHook.d.ts +1 -1
  65. package/dist/src/react-menu3/components/ControlledMenu.d.ts +2 -2
  66. package/dist/src/react-menu3/components/FocusableItem.d.ts +3 -3
  67. package/dist/src/react-menu3/components/Menu.d.ts +3 -3
  68. package/dist/src/react-menu3/components/MenuButton.d.ts +2 -2
  69. package/dist/src/react-menu3/components/MenuDivider.d.ts +1 -1
  70. package/dist/src/react-menu3/components/MenuGroup.d.ts +2 -2
  71. package/dist/src/react-menu3/components/MenuHeader.d.ts +2 -2
  72. package/dist/src/react-menu3/components/MenuItem.d.ts +3 -3
  73. package/dist/src/react-menu3/components/MenuList.d.ts +1 -1
  74. package/dist/src/react-menu3/components/MenuRadioGroup.d.ts +2 -2
  75. package/dist/src/react-menu3/components/SubMenu.d.ts +5 -5
  76. package/dist/src/react-menu3/contexts/EventHandlersContext.d.ts +1 -1
  77. package/dist/src/react-menu3/contexts/MenuListContext.d.ts +2 -2
  78. package/dist/src/react-menu3/contexts/MenuListItemContext.d.ts +1 -1
  79. package/dist/src/react-menu3/contexts/RadioGroupContext.d.ts +1 -1
  80. package/dist/src/react-menu3/contexts/SettingsContext.d.ts +2 -2
  81. package/dist/src/react-menu3/hooks/index.d.ts +9 -9
  82. package/dist/src/react-menu3/hooks/useBEM.d.ts +1 -1
  83. package/dist/src/react-menu3/hooks/useCombinedRef.d.ts +1 -1
  84. package/dist/src/react-menu3/hooks/useIsomorphicLayoutEffect.d.ts +1 -1
  85. package/dist/src/react-menu3/hooks/useItemEffect.d.ts +1 -1
  86. package/dist/src/react-menu3/hooks/useItemState.d.ts +1 -1
  87. package/dist/src/react-menu3/hooks/useItems.d.ts +2 -2
  88. package/dist/src/react-menu3/hooks/useMenuChange.d.ts +1 -1
  89. package/dist/src/react-menu3/hooks/useMenuState.d.ts +1 -1
  90. package/dist/src/react-menu3/hooks/useMenuStateAndFocus.d.ts +1 -1
  91. package/dist/src/react-menu3/index.d.ts +11 -11
  92. package/dist/src/react-menu3/positionUtils/getPositionHelpers.d.ts +1 -1
  93. package/dist/src/react-menu3/positionUtils/index.d.ts +3 -3
  94. package/dist/src/react-menu3/positionUtils/placeArrowHorizontal.d.ts +1 -1
  95. package/dist/src/react-menu3/positionUtils/placeArrowVertical.d.ts +1 -1
  96. package/dist/src/react-menu3/positionUtils/placeLeftorRight.d.ts +4 -4
  97. package/dist/src/react-menu3/positionUtils/placeToporBottom.d.ts +5 -5
  98. package/dist/src/react-menu3/positionUtils/positionContextMenu.d.ts +2 -2
  99. package/dist/src/react-menu3/positionUtils/positionMenu.d.ts +5 -5
  100. package/dist/src/react-menu3/style-utils/index.d.ts +1 -1
  101. package/dist/src/react-menu3/types.d.ts +15 -15
  102. package/dist/src/react-menu3/utils/constants.d.ts +1 -1
  103. package/dist/src/react-menu3/utils/index.d.ts +3 -3
  104. package/dist/src/react-menu3/utils/utils.d.ts +5 -5
  105. package/dist/src/react-menu3/utils/withHovering.d.ts +1 -1
  106. package/{src/utils → dist/src/utils/__tests__}/storybookTestUtil.ts +2 -2
  107. package/{src/utils → dist/src/utils/__tests__}/testQuick.ts +15 -14
  108. package/{src/utils → dist/src/utils/__tests__}/testUtil.ts +31 -36
  109. package/dist/src/utils/__tests__/vitestUtil.ts +295 -0
  110. package/dist/src/utils/textValidator.d.ts +2 -2
  111. package/dist/{step-ag-grid.cjs.js → step-ag-grid.cjs} +969 -955
  112. package/dist/step-ag-grid.cjs.map +1 -0
  113. package/dist/step-ag-grid.esm.js +970 -958
  114. package/dist/step-ag-grid.esm.js.map +1 -1
  115. package/dist/vite.config.d.ts +1 -1
  116. package/package.json +38 -57
  117. package/src/components/ComponentLoadingWrapper.tsx +5 -6
  118. package/src/components/Grid.tsx +85 -83
  119. package/src/components/GridCell.test.tsx +17 -15
  120. package/src/components/GridCell.tsx +46 -44
  121. package/src/components/GridCellFiller.tsx +5 -4
  122. package/src/components/GridCellMultiEditor.tsx +7 -7
  123. package/src/components/GridCellMultiSelectClassRules.tsx +3 -3
  124. package/src/components/GridIcon.tsx +6 -7
  125. package/src/components/GridLoadableCell.tsx +2 -2
  126. package/src/components/GridNoRowsOverlay.tsx +8 -8
  127. package/src/components/GridPopoverHook.tsx +16 -16
  128. package/src/components/GridWrapper.tsx +2 -2
  129. package/src/components/PostSortRowsHook.ts +11 -11
  130. package/src/components/clickInputWhenContainingCellClicked.tsx +5 -5
  131. package/src/components/gridFilter/GridFilterButtons.tsx +8 -9
  132. package/src/components/gridFilter/GridFilterColumnsToggle.tsx +25 -26
  133. package/src/components/gridFilter/GridFilterDownloadCsvButton.tsx +12 -13
  134. package/src/components/gridFilter/GridFilterHeaderIconButton.tsx +9 -10
  135. package/src/components/gridFilter/GridFilterQuick.tsx +6 -6
  136. package/src/components/gridFilter/GridFilters.tsx +1 -1
  137. package/src/components/gridFilter/index.ts +7 -7
  138. package/src/components/gridFilter/useGridFilter.ts +3 -3
  139. package/src/components/gridForm/GridFormDropDown.tsx +56 -52
  140. package/src/components/gridForm/GridFormEditBearing.tsx +12 -12
  141. package/src/components/gridForm/GridFormMessage.tsx +10 -10
  142. package/src/components/gridForm/GridFormMultiSelect.tsx +53 -51
  143. package/src/components/gridForm/GridFormMultiSelectGrid.tsx +25 -26
  144. package/src/components/gridForm/GridFormPopoverMenu.tsx +32 -29
  145. package/src/components/gridForm/GridFormSubComponentTextArea.tsx +10 -10
  146. package/src/components/gridForm/GridFormSubComponentTextInput.tsx +8 -8
  147. package/src/components/gridForm/GridFormTextArea.tsx +11 -11
  148. package/src/components/gridForm/GridFormTextInput.tsx +11 -11
  149. package/src/components/gridForm/index.ts +10 -10
  150. package/src/components/gridHeader/GridHeaderSelect.tsx +9 -9
  151. package/src/components/gridHeader/index.ts +1 -1
  152. package/src/components/gridHook/index.ts +1 -1
  153. package/src/components/gridHook/useGridContextMenu.tsx +7 -7
  154. package/src/components/gridPopoverEdit/GridButton.tsx +13 -12
  155. package/src/components/gridPopoverEdit/GridEditBoolean.tsx +19 -18
  156. package/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.ts +7 -6
  157. package/src/components/gridPopoverEdit/GridPopoutEditMultiSelectGrid.ts +7 -6
  158. package/src/components/gridPopoverEdit/GridPopoverEditBearing.ts +9 -9
  159. package/src/components/gridPopoverEdit/GridPopoverEditDropDown.ts +8 -7
  160. package/src/components/gridPopoverEdit/GridPopoverMenu.tsx +6 -6
  161. package/src/components/gridPopoverEdit/GridPopoverMessage.ts +4 -4
  162. package/src/components/gridPopoverEdit/GridPopoverTextArea.ts +4 -4
  163. package/src/components/gridPopoverEdit/GridPopoverTextInput.ts +4 -4
  164. package/src/components/gridPopoverEdit/index.ts +11 -11
  165. package/src/components/gridRender/GridRenderGenericCell.tsx +5 -5
  166. package/src/components/gridRender/GridRenderPopoutMenuCell.tsx +8 -9
  167. package/src/components/gridRender/index.ts +2 -2
  168. package/src/components/gridUtil.ts +3 -3
  169. package/src/components/index.ts +19 -19
  170. package/src/contexts/GridContext.tsx +52 -46
  171. package/src/contexts/GridContextProvider.test.tsx +15 -14
  172. package/src/contexts/GridContextProvider.tsx +42 -42
  173. package/src/contexts/GridPopoverContext.tsx +10 -7
  174. package/src/contexts/GridPopoverContextProvider.tsx +12 -10
  175. package/src/contexts/GridSubComponentContext.ts +6 -5
  176. package/src/contexts/GridUpdatingContext.tsx +5 -4
  177. package/src/contexts/GridUpdatingContextProvider.tsx +3 -3
  178. package/src/index.ts +19 -21
  179. package/src/lui/ActionButton.scss +2 -2
  180. package/src/lui/ActionButton.tsx +42 -41
  181. package/src/lui/FormError.scss +3 -4
  182. package/src/lui/FormError.tsx +4 -4
  183. package/src/lui/TextAreaInput.tsx +9 -9
  184. package/src/lui/TextInputFormatted.scss +1 -1
  185. package/src/lui/TextInputFormatted.tsx +11 -11
  186. package/src/lui/reactUtils.test.tsx +9 -8
  187. package/src/lui/reactUtils.tsx +2 -2
  188. package/src/lui/stateDeferredHook.tsx +3 -5
  189. package/src/lui/timeoutHook.test.tsx +12 -11
  190. package/src/lui/timeoutHook.tsx +1 -1
  191. package/src/react-app-env.d.ts +1 -1
  192. package/src/react-menu3/components/ControlledMenu.tsx +48 -48
  193. package/src/react-menu3/components/FocusableItem.tsx +7 -7
  194. package/src/react-menu3/components/Menu.tsx +11 -11
  195. package/src/react-menu3/components/MenuButton.tsx +4 -4
  196. package/src/react-menu3/components/MenuDivider.tsx +4 -4
  197. package/src/react-menu3/components/MenuGroup.tsx +5 -5
  198. package/src/react-menu3/components/MenuHeader.tsx +4 -4
  199. package/src/react-menu3/components/MenuItem.tsx +14 -14
  200. package/src/react-menu3/components/MenuList.tsx +55 -55
  201. package/src/react-menu3/components/MenuRadioGroup.tsx +7 -7
  202. package/src/react-menu3/components/SubMenu.tsx +24 -24
  203. package/src/react-menu3/contexts/EventHandlersContext.ts +2 -2
  204. package/src/react-menu3/contexts/HoverItemContext.ts +1 -1
  205. package/src/react-menu3/contexts/ItemSettingsContext.ts +1 -1
  206. package/src/react-menu3/contexts/MenuListContext.ts +2 -2
  207. package/src/react-menu3/contexts/MenuListItemContext.ts +2 -2
  208. package/src/react-menu3/contexts/RadioGroupContext.ts +2 -2
  209. package/src/react-menu3/contexts/SettingsContext.ts +2 -2
  210. package/src/react-menu3/hooks/index.ts +9 -9
  211. package/src/react-menu3/hooks/useBEM.ts +4 -4
  212. package/src/react-menu3/hooks/useCombinedRef.ts +2 -2
  213. package/src/react-menu3/hooks/useIsomorphicLayoutEffect.ts +4 -4
  214. package/src/react-menu3/hooks/useItemEffect.ts +3 -3
  215. package/src/react-menu3/hooks/useItemState.ts +5 -5
  216. package/src/react-menu3/hooks/useItems.ts +8 -8
  217. package/src/react-menu3/hooks/useMenuChange.ts +3 -3
  218. package/src/react-menu3/hooks/useMenuState.ts +5 -5
  219. package/src/react-menu3/hooks/useMenuStateAndFocus.ts +4 -4
  220. package/src/react-menu3/index.ts +11 -11
  221. package/src/react-menu3/positionUtils/getPositionHelpers.ts +2 -2
  222. package/src/react-menu3/positionUtils/index.ts +3 -3
  223. package/src/react-menu3/positionUtils/placeArrowHorizontal.ts +1 -1
  224. package/src/react-menu3/positionUtils/placeArrowVertical.ts +1 -1
  225. package/src/react-menu3/positionUtils/placeLeftorRight.ts +13 -13
  226. package/src/react-menu3/positionUtils/placeToporBottom.ts +15 -15
  227. package/src/react-menu3/positionUtils/positionContextMenu.ts +4 -4
  228. package/src/react-menu3/positionUtils/positionMenu.ts +14 -14
  229. package/src/react-menu3/style-utils/index.ts +24 -24
  230. package/src/react-menu3/types.ts +15 -15
  231. package/src/react-menu3/utils/constants.ts +33 -33
  232. package/src/react-menu3/utils/index.ts +3 -4
  233. package/src/react-menu3/utils/propTypes2.ts +10 -10
  234. package/src/react-menu3/utils/utils.ts +14 -14
  235. package/src/react-menu3/utils/withHovering.tsx +3 -3
  236. package/src/stories/components/ActionButton.stories.tsx +23 -24
  237. package/src/stories/grid/FormTest.tsx +15 -16
  238. package/src/stories/grid/GridDragRow.stories.tsx +33 -34
  239. package/src/stories/grid/GridFilterButtons.stories.tsx +32 -33
  240. package/src/stories/grid/GridNoRowsOverlay.stories.tsx +9 -10
  241. package/src/stories/grid/GridNonEditableRow.stories.tsx +40 -41
  242. package/src/stories/grid/GridPinnedRow.stories.tsx +25 -26
  243. package/src/stories/grid/GridPopoutContextMenu.stories.tsx +33 -32
  244. package/src/stories/grid/GridPopoutEditBoolean.stories.tsx +21 -22
  245. package/src/stories/grid/GridPopoutEditGeneric.stories.tsx +18 -19
  246. package/src/stories/grid/GridPopoutEditGenericTextArea.stories.tsx +50 -49
  247. package/src/stories/grid/GridPopoverEditBearing.stories.tsx +25 -26
  248. package/src/stories/grid/GridPopoverEditDropDown.stories.tsx +93 -94
  249. package/src/stories/grid/GridPopoverEditMultiSelect.stories.tsx +62 -63
  250. package/src/stories/grid/GridPopoverEditMultiSelectGrid.stories.tsx +28 -28
  251. package/src/stories/grid/GridReadOnly.stories.tsx +66 -67
  252. package/src/stories/grid/GridViewList.stories.tsx +37 -38
  253. package/src/stories/grid/gridFormInteraction/GridFormDropDownInteraction.stories.tsx +37 -38
  254. package/src/stories/grid/gridFormInteraction/GridFormEditBearingCorrectionInteraction.stories.tsx +25 -26
  255. package/src/stories/grid/gridFormInteraction/GridFormEditBearingInteraction.stories.tsx +25 -26
  256. package/src/stories/grid/gridFormInteraction/GridFormMultiSelectGridInteraction.stories.tsx +31 -31
  257. package/src/stories/grid/gridFormInteraction/GridFormMultiSelectInteraction.stories.tsx +47 -48
  258. package/src/stories/grid/gridFormInteraction/GridFormPopoverMenuInteraction.stories.tsx +44 -45
  259. package/src/stories/grid/gridFormInteraction/GridFormTextAreaInteraction.stories.tsx +19 -20
  260. package/src/stories/grid/gridFormInteraction/GridFormTextInputInteraction.stories.tsx +21 -22
  261. package/src/stories/grid/gridFormStatic/GridFormDropDown.stories.tsx +40 -41
  262. package/src/stories/grid/gridFormStatic/GridFormEditBearing.stories.tsx +14 -15
  263. package/src/stories/grid/gridFormStatic/GridFormEditBearingCorrection.stories.tsx +14 -15
  264. package/src/stories/grid/gridFormStatic/GridFormMessage.stories.tsx +10 -11
  265. package/src/stories/grid/gridFormStatic/GridFormMultiSelect.stories.tsx +20 -21
  266. package/src/stories/grid/gridFormStatic/GridFormPopoverMenu.stories.tsx +16 -17
  267. package/src/stories/grid/gridFormStatic/GridFormTextArea.stories.tsx +13 -14
  268. package/src/stories/grid/gridFormStatic/GridFormTextInput.stories.tsx +13 -14
  269. package/src/stories/grid/interactions/GridKeyboardInteractions.stories.tsx +68 -71
  270. package/src/stories/react-menu/ReactMenu.stories.tsx +26 -26
  271. package/src/styles/Grid.scss +9 -9
  272. package/src/styles/GridIcon.scss +6 -6
  273. package/src/styles/GridPopoverMenu.scss +3 -3
  274. package/src/styles/GridTheme.scss +1 -1
  275. package/src/styles/react-menu-customisations.scss +26 -41
  276. package/src/utils/__tests__/storybookTestUtil.ts +4 -0
  277. package/src/utils/__tests__/testQuick.ts +157 -0
  278. package/src/utils/__tests__/testUtil.ts +294 -0
  279. package/src/utils/__tests__/vitestUtil.ts +295 -0
  280. package/src/utils/bearing.test.ts +47 -45
  281. package/src/utils/bearing.ts +20 -20
  282. package/src/utils/deferredPromise.ts +1 -1
  283. package/src/utils/textMatcher.test.ts +10 -9
  284. package/src/utils/textMatcher.ts +8 -8
  285. package/src/utils/textValidator.test.ts +61 -62
  286. package/src/utils/textValidator.ts +11 -11
  287. package/src/utils/util.test.ts +21 -20
  288. package/src/utils/util.ts +7 -7
  289. package/dist/src/utils/storybookTestUtil.d.ts +0 -3
  290. package/dist/src/utils/testQuick.d.ts +0 -62
  291. package/dist/src/utils/testUtil.d.ts +0 -46
  292. package/dist/step-ag-grid.cjs.js.map +0 -1
@@ -0,0 +1,295 @@
1
+ import { act, waitFor, within } from '@testing-library/react';
2
+ import userEvent from '@testing-library/user-event';
3
+ import { isEqual } from 'lodash-es';
4
+ import { expect } from 'vitest';
5
+
6
+ import { findQuick, getAllQuick, getMatcher, getQuick, IQueryQuick, queryQuick } from './testQuick';
7
+
8
+ let user = userEvent;
9
+ /**
10
+ * allow external userEvent to be used
11
+ * @param customisedUserEvent
12
+ */
13
+ export const setUpUserEvent = (customisedUserEvent: any) => {
14
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
15
+ user = customisedUserEvent;
16
+ };
17
+
18
+ export const countRows = (within?: HTMLElement): number => {
19
+ return getAllQuick({ tagName: `div[row-id]:not(:empty)` }, within).length;
20
+ };
21
+
22
+ export const findRowByIndex = async (rowIndex: number | string, within?: HTMLElement): Promise<HTMLDivElement> => {
23
+ await waitFor(() => {
24
+ expect(getAllQuick({ classes: '.ag-row' }).length > 0).toBe(true);
25
+ });
26
+ //if this is not wrapped in an act console errors are logged during testing
27
+ let row!: HTMLDivElement;
28
+ await act(async () => {
29
+ row = await findQuick<HTMLDivElement>(
30
+ { tagName: `.ag-center-cols-container div[row-index='${rowIndex}']:not(:empty)` },
31
+ within,
32
+ );
33
+ let combineChildren = [...Array.from(row.children)];
34
+
35
+ const leftCols = queryQuick<HTMLDivElement>(
36
+ { tagName: `.ag-pinned-left-cols-container div[row-index='${rowIndex}']` },
37
+ within,
38
+ );
39
+ if (leftCols) {
40
+ combineChildren = [...Array.from(leftCols.children), ...combineChildren];
41
+ }
42
+
43
+ const rightCols = queryQuick<HTMLDivElement>(
44
+ { tagName: `.ag-pinned-right-cols-container div[row-index='${rowIndex}']` },
45
+ within,
46
+ );
47
+ if (rightCols) {
48
+ combineChildren = [...Array.from(rightCols.children), ...combineChildren];
49
+ }
50
+
51
+ row.replaceChildren(...combineChildren);
52
+ });
53
+ return row;
54
+ };
55
+
56
+ export const findRow = async (rowId: number | string, within?: HTMLElement): Promise<HTMLDivElement> => {
57
+ await waitFor(() => {
58
+ expect(getAllQuick({ classes: '.ag-row' }).length > 0).toBe(true);
59
+ });
60
+ //if this is not wrapped in an act console errors are logged during testing
61
+ let row!: HTMLDivElement;
62
+ await act(async () => {
63
+ row = await findQuick<HTMLDivElement>(
64
+ { tagName: `.ag-center-cols-container div[row-id='${rowId}']:not(:empty)` },
65
+ within,
66
+ );
67
+ let combineChildren = [...Array.from(row.children)];
68
+
69
+ const leftCols = queryQuick<HTMLDivElement>(
70
+ { tagName: `.ag-pinned-left-cols-container div[row-id='${rowId}']` },
71
+ within,
72
+ );
73
+ if (leftCols) {
74
+ combineChildren = [...Array.from(leftCols.children), ...combineChildren];
75
+ }
76
+
77
+ const rightCols = queryQuick<HTMLDivElement>(
78
+ { tagName: `.ag-pinned-right-cols-container div[row-id='${rowId}']` },
79
+ within,
80
+ );
81
+ if (rightCols) {
82
+ combineChildren = [...Array.from(rightCols.children), ...combineChildren];
83
+ }
84
+
85
+ row.replaceChildren(...combineChildren);
86
+ });
87
+ return row;
88
+ };
89
+
90
+ export const queryRow = (rowId: number | string, within?: HTMLElement): HTMLDivElement | null => {
91
+ return queryQuick<HTMLDivElement>({ tagName: `div[row-id='${rowId}']:not(:empty)` }, within);
92
+ };
93
+
94
+ const _selectRow = async (
95
+ select: 'select' | 'deselect' | 'toggle',
96
+ rowId: string | number,
97
+ within?: HTMLElement,
98
+ ): Promise<void> => {
99
+ const row = await findRow(rowId, within);
100
+ const isSelected = row.className.includes('ag-row-selected');
101
+ if (select === 'toggle' || (select === 'select' && !isSelected) || (select === 'deselect' && isSelected)) {
102
+ const cell = await findCell(rowId, 'selection', within);
103
+ await user.click(cell);
104
+ await waitFor(async () => {
105
+ const row = await findRow(rowId, within);
106
+ const nowSelected = row.className.includes('ag-row-selected');
107
+ if (nowSelected === isSelected) throw `Row ${rowId} won't select`;
108
+ });
109
+ }
110
+ };
111
+
112
+ export const selectRow = async (rowId: string | number, within?: HTMLElement): Promise<void> =>
113
+ _selectRow('select', rowId, within);
114
+
115
+ export const deselectRow = async (rowId: string | number, within?: HTMLElement): Promise<void> =>
116
+ _selectRow('deselect', rowId, within);
117
+
118
+ export const findCell = async (rowId: number | string, colId: string, within?: HTMLElement): Promise<HTMLElement> => {
119
+ const row = await findRow(rowId, within);
120
+ return await findQuick({ tagName: `[col-id='${colId}']` }, row);
121
+ };
122
+
123
+ export const findCellContains = async (
124
+ rowId: number | string,
125
+ colId: string,
126
+ text: string | RegExp,
127
+ within?: HTMLElement,
128
+ ) => {
129
+ return await waitFor(
130
+ async () => {
131
+ const row = await findRow(rowId, within);
132
+ return getQuick({ tagName: `[col-id='${colId}']`, text }, row);
133
+ },
134
+ { timeout: 10000 },
135
+ );
136
+ };
137
+
138
+ export const selectCell = async (rowId: string | number, colId: string, within?: HTMLElement): Promise<void> => {
139
+ const cell = await findCell(rowId, colId, within);
140
+ await user.click(cell);
141
+ };
142
+
143
+ export const editCell = async (rowId: number | string, colId: string, within?: HTMLElement): Promise<void> => {
144
+ await waitFor(
145
+ async () => {
146
+ const cell = await findCell(rowId, colId, within);
147
+ await user.dblClick(cell);
148
+ await waitFor(findOpenPopover, { timeout: 1000 });
149
+ },
150
+ { timeout: 10000 },
151
+ );
152
+ };
153
+
154
+ export const isCellReadOnly = async (rowId: number | string, colId: string, within?: HTMLElement): Promise<boolean> => {
155
+ const cell = await findCell(rowId, colId, within);
156
+ return cell.className.includes('GridCell-readonly');
157
+ };
158
+
159
+ export const findOpenPopover = () => findQuick({ classes: '.szh-menu--state-open' });
160
+
161
+ export const queryMenuOption = async (menuOptionText: string | RegExp): Promise<HTMLElement | null> => {
162
+ const openMenu = await findOpenPopover();
163
+ const els = await within(openMenu).findAllByRole('menuitem');
164
+ const matcher = getMatcher(menuOptionText);
165
+ const result = els.find(matcher);
166
+ return result ?? null;
167
+ };
168
+
169
+ export const findMenuOption = async (menuOptionText: string | RegExp): Promise<HTMLElement> => {
170
+ return await waitFor(
171
+ async () => {
172
+ const menuOption = await queryMenuOption(menuOptionText);
173
+ if (menuOption == null) {
174
+ throw Error(`Unable to find menu option ${menuOptionText}`);
175
+ }
176
+ return menuOption;
177
+ },
178
+ { timeout: 5000 },
179
+ );
180
+ };
181
+
182
+ export const validateMenuOptions = async (
183
+ rowId: number | string,
184
+ colId: string,
185
+ expectedMenuOptions: Array<string>,
186
+ ): Promise<boolean> => {
187
+ await editCell(rowId, colId);
188
+ const openMenu = await findOpenPopover();
189
+ const actualOptions = (await within(openMenu).findAllByRole('menuitem')).map((menuItem) => menuItem.textContent);
190
+ return isEqual(actualOptions, expectedMenuOptions);
191
+ };
192
+
193
+ export const clickMenuOption = async (menuOptionText: string | RegExp): Promise<void> => {
194
+ const menuOption = await findMenuOption(menuOptionText);
195
+ await user.click(menuOption);
196
+ };
197
+
198
+ export const openAndClickMenuOption = async (
199
+ rowId: number | string,
200
+ colId: string,
201
+ menuOptionText: string | RegExp,
202
+ within?: HTMLElement,
203
+ ): Promise<void> => {
204
+ await editCell(rowId, colId, within);
205
+ await clickMenuOption(menuOptionText);
206
+ };
207
+
208
+ export const openAndFindMenuOption = async (
209
+ rowId: number | string,
210
+ colId: string,
211
+ menuOptionText: string | RegExp,
212
+ within?: HTMLElement,
213
+ ): Promise<HTMLElement> => {
214
+ await editCell(rowId, colId, within);
215
+ return await findMenuOption(menuOptionText);
216
+ };
217
+
218
+ export const getMultiSelectOptions = async () => {
219
+ const openMenu = await findOpenPopover();
220
+ return getAllQuick<HTMLInputElement>({ role: 'menuitem', child: { tagName: 'input,textarea' } }, openMenu).map(
221
+ (input) => {
222
+ return {
223
+ v: input.value,
224
+ c: input.checked ?? true,
225
+ };
226
+ },
227
+ );
228
+ };
229
+
230
+ export const findMultiSelectOption = async (value: string): Promise<HTMLElement> => {
231
+ const openMenu = await findOpenPopover();
232
+ return getQuick({ role: 'menuitem', child: { tagName: `input[value='${value}']` } }, openMenu);
233
+ };
234
+
235
+ export const clickMultiSelectOption = async (value: string): Promise<void> => {
236
+ const menuItem = await findMultiSelectOption(value);
237
+ menuItem.parentElement && (await user.click(menuItem.parentElement));
238
+ };
239
+
240
+ const typeInput = async (value: string, filter: IQueryQuick): Promise<void> => {
241
+ const openMenu = await findOpenPopover();
242
+ const input = await findQuick(filter, openMenu);
243
+ await user.clear(input);
244
+ //'typing' an empty string will cause a console error, and it's also unnecessary after the previous clear call
245
+ if (value.length > 0) {
246
+ await user.type(input, value);
247
+ }
248
+ };
249
+
250
+ export const typeOnlyInput = async (value: string): Promise<void> =>
251
+ typeInput(value, { child: { tagName: "input[type='text'], textarea" } });
252
+
253
+ export const typeInputByLabel = async (value: string, labelText: string): Promise<void> => {
254
+ const labels = getAllQuick({ child: { tagName: 'label' } }).filter((l) => l.textContent === labelText);
255
+ if (labels.length === 0) {
256
+ throw Error(`Label not found for text: ${labelText}`);
257
+ }
258
+ if (labels.length > 1) {
259
+ throw Error(`Multiple labels found for text: ${labelText}`);
260
+ }
261
+ const inputId = labels[0].getAttribute('for');
262
+ await typeInput(value, { child: { tagName: `input[id='${inputId}'], textarea[id='${inputId}']` } });
263
+ };
264
+
265
+ export const typeInputByPlaceholder = async (value: string, placeholder: string): Promise<void> =>
266
+ typeInput(value, {
267
+ child: { tagName: `input[placeholder='${placeholder}'], textarea[placeholder='${placeholder}']` },
268
+ });
269
+
270
+ export const typeOtherInput = async (value: string): Promise<void> =>
271
+ typeInput(value, { classes: '.subComponent', child: { tagName: "input[type='text']" } });
272
+
273
+ export const typeOtherTextArea = async (value: string): Promise<void> =>
274
+ typeInput(value, { classes: '.subComponent', child: { tagName: 'textarea' } });
275
+
276
+ export const closeMenu = () => user.click(document.body);
277
+ export const closePopover = () => user.click(document.body);
278
+
279
+ export const findActionButton = (text: string, container?: HTMLElement): Promise<HTMLElement> =>
280
+ findQuick({ tagName: 'button', child: { classes: '.ActionButton-minimalAreaDisplay', text: text } }, container);
281
+
282
+ export const clickActionButton = async (text: string, container?: HTMLElement): Promise<void> => {
283
+ const button = await findActionButton(text, container);
284
+ await user.click(button);
285
+ };
286
+
287
+ export const waitForGridReady = async (props?: { grid?: HTMLElement; timeout?: number }) =>
288
+ waitFor(() => expect(getAllQuick({ classes: '.Grid-ready' }, props?.grid)).toBeDefined(), {
289
+ timeout: props?.timeout ?? 5000,
290
+ });
291
+
292
+ export const waitForGridRows = async (props?: { grid?: HTMLElement; timeout?: number }) =>
293
+ waitFor(() => expect(getAllQuick({ classes: '.ag-row' }, props?.grid).length > 0).toBe(true), {
294
+ timeout: props?.timeout ?? 5000,
295
+ });
@@ -1,55 +1,57 @@
1
+ import { describe, expect, test, vi } from 'vitest';
2
+
1
3
  import {
2
4
  bearingCorrectionRangeValidator,
3
5
  bearingRangeValidator,
4
6
  bearingStringValidator,
5
7
  convertDDToDMS,
6
- } from "./bearing";
8
+ } from './bearing';
7
9
 
8
- describe("bearing", () => {
9
- test("convertDDToDMS converts decimal-ish degrees to DMS", () => {
10
- expect(convertDDToDMS(-0.001, false)).toBe("-0° 00' 10\"");
11
- expect(convertDDToDMS(-10.001, false)).toBe("-10° 00' 10\"");
12
- expect(convertDDToDMS(-370.001, false)).toBe("-10° 00' 10\"");
10
+ describe('bearing', () => {
11
+ test('convertDDToDMS converts decimal-ish degrees to DMS', () => {
12
+ expect(convertDDToDMS(-0.001, false)).toBe('-0° 00\' 10"');
13
+ expect(convertDDToDMS(-10.001, false)).toBe('-10° 00\' 10"');
14
+ expect(convertDDToDMS(-370.001, false)).toBe('-10° 00\' 10"');
13
15
  expect(convertDDToDMS(359.595999, false, 2)).toBe("0° 00'");
14
- expect(convertDDToDMS(359.595999, false, 4)).toBe("0° 00' 00\"");
15
- expect(convertDDToDMS(359.595999, false, 5)).toBe("0° 00' 00.0\"");
16
- expect(convertDDToDMS(369.696999, false)).toBe("10° 10' 10\"");
17
- expect(convertDDToDMS(369.696999, false, 4)).toBe("10° 10' 10\"");
16
+ expect(convertDDToDMS(359.595999, false, 4)).toBe('0° 00\' 00"');
17
+ expect(convertDDToDMS(359.595999, false, 5)).toBe('0° 00\' 00.0"');
18
+ expect(convertDDToDMS(369.696999, false)).toBe('10° 10\' 10"');
19
+ expect(convertDDToDMS(369.696999, false, 4)).toBe('10° 10\' 10"');
18
20
  expect(convertDDToDMS(221.555999, false, 2)).toBe("221° 56'");
19
- expect(convertDDToDMS(221.555999, false, 5)).toBe("221° 56' 00.0\"");
20
- expect(convertDDToDMS(5, true, 5)).toBe("+5° 00' 00.0\"");
21
- expect(convertDDToDMS(5.0, true, 5)).toBe("+5° 00' 00.0\"");
22
- expect(convertDDToDMS(5.00001, true, 5)).toBe("+5° 00' 00.1\"");
23
- expect(convertDDToDMS(5.1, true, 5)).toBe("+5° 10' 00.0\"");
24
- expect(convertDDToDMS(5.12345)).toBe("+5° 12' 34.5\"");
25
- expect(convertDDToDMS(5.12345, false)).toBe("5° 12' 34.5\"");
26
- expect(convertDDToDMS(5.12345, false, 2)).toBe("5° 12' 34.5\"");
27
- expect(convertDDToDMS(300, true, 5)).toBe("+300° 00' 00.0\"");
28
- expect(convertDDToDMS(300.0, true, 5)).toBe("+300° 00' 00.0\"");
29
- expect(convertDDToDMS(300.00001)).toBe("+300° 00' 00.1\"");
30
- expect(convertDDToDMS(300.1, true, 5)).toBe("+300° 10' 00.0\"");
31
- expect(convertDDToDMS(300.12345)).toBe("+300° 12' 34.5\"");
32
- expect(convertDDToDMS(300.12345, false)).toBe("300° 12' 34.5\"");
21
+ expect(convertDDToDMS(221.555999, false, 5)).toBe('221° 56\' 00.0"');
22
+ expect(convertDDToDMS(5, true, 5)).toBe('+5° 00\' 00.0"');
23
+ expect(convertDDToDMS(5.0, true, 5)).toBe('+5° 00\' 00.0"');
24
+ expect(convertDDToDMS(5.00001, true, 5)).toBe('+5° 00\' 00.1"');
25
+ expect(convertDDToDMS(5.1, true, 5)).toBe('+5° 10\' 00.0"');
26
+ expect(convertDDToDMS(5.12345)).toBe('+5° 12\' 34.5"');
27
+ expect(convertDDToDMS(5.12345, false)).toBe('5° 12\' 34.5"');
28
+ expect(convertDDToDMS(5.12345, false, 2)).toBe('5° 12\' 34.5"');
29
+ expect(convertDDToDMS(300, true, 5)).toBe('+300° 00\' 00.0"');
30
+ expect(convertDDToDMS(300.0, true, 5)).toBe('+300° 00\' 00.0"');
31
+ expect(convertDDToDMS(300.00001)).toBe('+300° 00\' 00.1"');
32
+ expect(convertDDToDMS(300.1, true, 5)).toBe('+300° 10\' 00.0"');
33
+ expect(convertDDToDMS(300.12345)).toBe('+300° 12\' 34.5"');
34
+ expect(convertDDToDMS(300.12345, false)).toBe('300° 12\' 34.5"');
33
35
  expect(convertDDToDMS(300, false, 2)).toBe("300° 00'");
34
36
  expect(convertDDToDMS(300.1, false, 2)).toBe("300° 10'");
35
37
  expect(convertDDToDMS(0, false, 2)).toBe("0° 00'");
36
38
  expect(convertDDToDMS(0.0, false)).toBe("0° 00'");
37
- expect(convertDDToDMS(0.0, false, 4)).toBe("0° 00' 00\"");
38
- expect(convertDDToDMS(0.0, false, 5)).toBe("0° 00' 00.0\"");
39
+ expect(convertDDToDMS(0.0, false, 4)).toBe('0° 00\' 00"');
40
+ expect(convertDDToDMS(0.0, false, 5)).toBe('0° 00\' 00.0"');
39
41
  });
40
42
 
41
- test("bearingStringValidator", () => {
43
+ test('bearingStringValidator', () => {
42
44
  const tests: [string, string | null][] = [
43
- ["", null],
44
- ["1", null],
45
- ["1.2345", null],
46
- ["-1.2345", null],
47
- ["360.2345", null],
48
- ["-360.2345", null],
49
- ["1.2e6", "Bearing must be a number in D.MMSSS format"],
50
- ["0.60000", "Bearing must be a number in D.MMSSS format"],
51
- ["0.00600", "Bearing must be a number in D.MMSSS format"],
52
- ["0.123456", "Bearing has a maximum of 5 decimal places"],
45
+ ['', null],
46
+ ['1', null],
47
+ ['1.2345', null],
48
+ ['-1.2345', null],
49
+ ['360.2345', null],
50
+ ['-360.2345', null],
51
+ ['1.2e6', 'Bearing must be a number in D.MMSSS format'],
52
+ ['0.60000', 'Bearing must be a number in D.MMSSS format'],
53
+ ['0.00600', 'Bearing must be a number in D.MMSSS format'],
54
+ ['0.123456', 'Bearing has a maximum of 5 decimal places'],
53
55
  ];
54
56
 
55
57
  tests.forEach((test, i) => {
@@ -57,22 +59,22 @@ describe("bearing", () => {
57
59
  });
58
60
 
59
61
  // calls custom invalid
60
- const fn = jest.fn();
61
- bearingStringValidator("1.2", fn);
62
+ const fn = vi.fn();
63
+ bearingStringValidator('1.2', fn);
62
64
  expect(fn).toHaveBeenCalledWith(1.2);
63
65
  });
64
66
 
65
- test("bearingRangeValidator", () => {
67
+ test('bearingRangeValidator', () => {
66
68
  expect(bearingRangeValidator(0)).toBeNull();
67
69
  expect(bearingRangeValidator(359.595999)).toBeNull();
68
- expect(bearingRangeValidator(-0.00001)).toBe("Bearing must not be negative");
69
- expect(bearingRangeValidator(360)).toBe("Bearing must be less than 360 degrees");
70
+ expect(bearingRangeValidator(-0.00001)).toBe('Bearing must not be negative');
71
+ expect(bearingRangeValidator(360)).toBe('Bearing must be less than 360 degrees');
70
72
  });
71
73
 
72
- test("bearingCorrectionRangeValidator", () => {
74
+ test('bearingCorrectionRangeValidator', () => {
73
75
  expect(bearingCorrectionRangeValidator(-179.59999)).toBeNull();
74
76
  expect(bearingCorrectionRangeValidator(359.59999)).toBeNull();
75
- expect(bearingCorrectionRangeValidator(-180)).toBe("Bearing correction must be greater then -180 degrees");
76
- expect(bearingCorrectionRangeValidator(360)).toBe("Bearing correction must be less than 360 degrees");
77
+ expect(bearingCorrectionRangeValidator(-180)).toBe('Bearing correction must be greater then -180 degrees');
78
+ expect(bearingCorrectionRangeValidator(360)).toBe('Bearing correction must be less than 360 degrees');
77
79
  });
78
80
  });
@@ -1,7 +1,7 @@
1
1
  export const bearingValueFormatter = (value: any): string => {
2
- const safeValue = typeof value == "string" ? parseFloat(value) : value;
2
+ const safeValue = typeof value === 'string' ? parseFloat(value) : value;
3
3
  if (safeValue == null) {
4
- return "";
4
+ return '';
5
5
  }
6
6
  return convertDDToDMS(safeValue, false);
7
7
  };
@@ -9,16 +9,16 @@ export const bearingValueFormatter = (value: any): string => {
9
9
  export const bearingCorrectionValueFormatter = (value: any): string => {
10
10
  const safeValue = value;
11
11
  if (safeValue == null) {
12
- return "";
12
+ return '';
13
13
  }
14
- if (typeof safeValue === "string") {
14
+ if (typeof safeValue === 'string') {
15
15
  return convertDDToDMS(bearingNumberParser(safeValue), true, 4);
16
16
  }
17
17
  return convertDDToDMS(safeValue, true, 4);
18
18
  };
19
19
 
20
20
  export const bearingNumberParser = (value: string): number | null => {
21
- if (value === "") return null;
21
+ if (value === '') return null;
22
22
  return parseFloat(value);
23
23
  };
24
24
 
@@ -28,12 +28,12 @@ export const bearingStringValidator = (
28
28
  customInvalid?: (value: number | null) => string | null,
29
29
  ): string | null => {
30
30
  value = value.trim();
31
- if (value === "") return null;
31
+ if (value === '') return null;
32
32
  const match = value.match(validMaskForDmsBearing);
33
- if (!match) return "Bearing must be a number in D.MMSSS format";
33
+ if (!match) return 'Bearing must be a number in D.MMSSS format';
34
34
  const decimalPart = match[4];
35
35
  if (decimalPart != null && decimalPart.length > 5) {
36
- return "Bearing has a maximum of 5 decimal places";
36
+ return 'Bearing has a maximum of 5 decimal places';
37
37
  }
38
38
 
39
39
  const bearing = parseFloat(value);
@@ -53,10 +53,10 @@ export const bearingStringValidator = (
53
53
  * @returns Degrees Minutes Seconds
54
54
  */
55
55
  export const convertDDToDMS = (dd: number | null, showPositiveSymbol = true, trailingZeroDp: 2 | 4 | 5 = 2): string => {
56
- if (dd == null) return "";
56
+ if (dd == null) return '';
57
57
 
58
58
  // toFixed rounds parts up greater than 60, which has to be corrected below
59
- const [bearingWholeString, bearingDecimalString] = dd.toFixed(5).split(".");
59
+ const [bearingWholeString, bearingDecimalString] = dd.toFixed(5).split('.');
60
60
 
61
61
  let bearingWhole = Math.abs(parseInt(bearingWholeString));
62
62
  let minNumeric = parseInt(bearingDecimalString?.substring(0, 2));
@@ -75,12 +75,12 @@ export const convertDDToDMS = (dd: number | null, showPositiveSymbol = true, tra
75
75
  bearingWhole -= 360;
76
76
  }
77
77
 
78
- const minString = minNumeric.toString().padStart(2, "0");
79
- const secString = secNumeric.toString().padStart(2, "0");
78
+ const minString = minNumeric.toString().padStart(2, '0');
79
+ const secString = secNumeric.toString().padStart(2, '0');
80
80
  const deciSecString = bearingDecimalString?.substring(4, 5);
81
81
 
82
- let dmsString = `${showPositiveSymbol && dd > 0 ? "+" : ""}${dd < 0 ? "-" : ""}${bearingWhole}°`;
83
- if (trailingZeroDp === 5 || deciSecString != "0") {
82
+ let dmsString = `${showPositiveSymbol && dd > 0 ? '+' : ''}${dd < 0 ? '-' : ''}${bearingWhole}°`;
83
+ if (trailingZeroDp === 5 || deciSecString != '0') {
84
84
  dmsString += `\xa0${minString}'\xa0${secString}.${deciSecString}"`; // "\xa0" is here for non-breaking space
85
85
  } else if (trailingZeroDp === 4 || secNumeric != 0) {
86
86
  dmsString += `\xa0${minString}'\xa0${secString}"`;
@@ -91,15 +91,15 @@ export const convertDDToDMS = (dd: number | null, showPositiveSymbol = true, tra
91
91
  };
92
92
 
93
93
  export const bearingRangeValidator = (value: number | null) => {
94
- if (value === null) return "Bearing is required";
95
- if (value >= 360) return "Bearing must be less than 360 degrees";
96
- if (value < 0) return "Bearing must not be negative";
94
+ if (value === null) return 'Bearing is required';
95
+ if (value >= 360) return 'Bearing must be less than 360 degrees';
96
+ if (value < 0) return 'Bearing must not be negative';
97
97
  return null;
98
98
  };
99
99
 
100
100
  export const bearingCorrectionRangeValidator = (value: number | null) => {
101
- if (value === null) return "Bearing correction is required";
102
- if (value >= 360) return "Bearing correction must be less than 360 degrees";
103
- if (value <= -180) return "Bearing correction must be greater then -180 degrees";
101
+ if (value === null) return 'Bearing correction is required';
102
+ if (value >= 360) return 'Bearing correction must be less than 360 degrees';
103
+ if (value <= -180) return 'Bearing correction must be greater then -180 degrees';
104
104
  return null;
105
105
  };
@@ -1,4 +1,4 @@
1
- import { useEffect, useRef } from "react";
1
+ import { useEffect, useRef } from 'react';
2
2
 
3
3
  export const useDeferredPromise = <T>() => {
4
4
  const promiseResolve = useRef<((value: T | PromiseLike<T>) => void) | undefined>();
@@ -1,5 +1,6 @@
1
- import { textMatch } from "./textMatcher";
1
+ import { describe, expect, test } from 'vitest';
2
2
 
3
+ import { textMatch } from './textMatcher';
3
4
  /**
4
5
  * "L" => L*
5
6
  * "=L" => L
@@ -11,18 +12,18 @@ import { textMatch } from "./textMatcher";
11
12
  * "=!A" => all values must not match exactly A
12
13
  * Returns true if there's a text match.
13
14
  */
14
- describe("textMatch", () => {
15
- test("textMatch", () => {
15
+ describe('textMatch', () => {
16
+ test('textMatch', () => {
16
17
  const validate = [
17
18
  {
18
- value: "",
19
- matched: [""],
20
- unmatched: ["a", "a*", "*a*"],
19
+ value: '',
20
+ matched: [''],
21
+ unmatched: ['a', 'a*', '*a*'],
21
22
  },
22
23
  {
23
- value: "two words",
24
- matched: ["", "*wo", "*or*", "tw", "two", "tw wo", "tw, rr", "=!tw"],
25
- unmatched: ["ds", "o", "=tw", "tw rr", "!two", "!tw*"],
24
+ value: 'two words',
25
+ matched: ['', '*wo', '*or*', 'tw', 'two', 'tw wo', 'tw, rr', '=!tw'],
26
+ unmatched: ['ds', 'o', '=tw', 'tw rr', '!two', '!tw*'],
26
27
  },
27
28
  ];
28
29
 
@@ -1,5 +1,5 @@
1
- import { isEmpty, partition } from "lodash-es";
2
- import { isMatch } from "matcher";
1
+ import { isEmpty, partition } from 'lodash-es';
2
+ import { isMatch } from 'matcher';
3
3
 
4
4
  /**
5
5
  * Text matching with wildcards and multiple matchers.
@@ -17,22 +17,22 @@ export const textMatch = (text: string | undefined | null, filter: string): bool
17
17
  if (text == null) return true;
18
18
 
19
19
  const superFilters = filter
20
- .split(",")
20
+ .split(',')
21
21
  .map((sf) => sf.trim())
22
22
  .filter((sf) => sf)
23
23
  .map((r) =>
24
24
  r
25
25
  .split(/\s+/)
26
- .map((f) => (f.startsWith("=") ? f.slice(1) : f + "*"))
27
- .join(" "),
26
+ .map((f) => (f.startsWith('=') ? f.slice(1) : f + '*'))
27
+ .join(' '),
28
28
  );
29
- const [negativeFilters, positiveFilters] = partition(superFilters, (superFilters) => superFilters.startsWith("!"));
29
+ const [negativeFilters, positiveFilters] = partition(superFilters, (superFilters) => superFilters.startsWith('!'));
30
30
 
31
- const values = text.replaceAll(",", " ").trim().split(/\s+/);
31
+ const values = text.replaceAll(',', ' ').trim().split(/\s+/);
32
32
  return (
33
33
  (isEmpty(positiveFilters) || // Not filtered
34
34
  positiveFilters.some((superFilter) => {
35
- const subFilters = superFilter.split(/\s+/).map((s) => s.replaceAll(/([!?])/g, "\\$1"));
35
+ const subFilters = superFilter.split(/\s+/).map((s) => s.replaceAll(/([!?])/g, '\\$1'));
36
36
  return subFilters.every((subFilter) => values.some((value) => isMatch(value, subFilter)));
37
37
  })) &&
38
38
  (isEmpty(negativeFilters) ||