@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.
- package/dist/GridTheme.scss +1 -1
- package/dist/index.css +0 -13
- package/dist/src/components/ComponentLoadingWrapper.d.ts +1 -1
- package/dist/src/components/Grid.d.ts +17 -17
- package/dist/src/components/GridCell.d.ts +9 -9
- package/dist/src/components/GridCellFiller.d.ts +2 -2
- package/dist/src/components/GridCellMultiEditor.d.ts +6 -6
- package/dist/src/components/GridCellMultiSelectClassRules.d.ts +1 -1
- package/dist/src/components/GridIcon.d.ts +2 -2
- package/dist/src/components/GridNoRowsOverlay.d.ts +1 -1
- package/dist/src/components/GridPopoverHook.d.ts +2 -2
- package/dist/src/components/GridWrapper.d.ts +1 -1
- package/dist/src/components/PostSortRowsHook.d.ts +1 -1
- package/dist/src/components/clickInputWhenContainingCellClicked.d.ts +1 -1
- package/dist/src/components/gridFilter/GridFilterButtons.d.ts +5 -5
- package/dist/src/components/gridFilter/GridFilterColumnsToggle.d.ts +1 -1
- package/dist/src/components/gridFilter/GridFilterDownloadCsvButton.d.ts +1 -1
- package/dist/src/components/gridFilter/GridFilterHeaderIconButton.d.ts +2 -2
- package/dist/src/components/gridFilter/GridFilters.d.ts +1 -1
- package/dist/src/components/gridFilter/index.d.ts +7 -7
- package/dist/src/components/gridFilter/useGridFilter.d.ts +2 -2
- package/dist/src/components/gridForm/GridFormDropDown.d.ts +8 -8
- package/dist/src/components/gridForm/GridFormEditBearing.d.ts +2 -2
- package/dist/src/components/gridForm/GridFormMessage.d.ts +3 -3
- package/dist/src/components/gridForm/GridFormMultiSelect.d.ts +4 -4
- package/dist/src/components/gridForm/GridFormMultiSelectGrid.d.ts +4 -4
- package/dist/src/components/gridForm/GridFormPopoverMenu.d.ts +5 -5
- package/dist/src/components/gridForm/GridFormSubComponentTextArea.d.ts +4 -4
- package/dist/src/components/gridForm/GridFormSubComponentTextInput.d.ts +4 -4
- package/dist/src/components/gridForm/GridFormTextArea.d.ts +4 -4
- package/dist/src/components/gridForm/GridFormTextInput.d.ts +3 -3
- package/dist/src/components/gridForm/index.d.ts +10 -10
- package/dist/src/components/gridHeader/GridHeaderSelect.d.ts +1 -1
- package/dist/src/components/gridHeader/index.d.ts +1 -1
- package/dist/src/components/gridHook/index.d.ts +1 -1
- package/dist/src/components/gridHook/useGridContextMenu.d.ts +4 -4
- package/dist/src/components/gridPopoverEdit/GridButton.d.ts +5 -5
- package/dist/src/components/gridPopoverEdit/GridEditBoolean.d.ts +4 -4
- package/dist/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.d.ts +4 -4
- package/dist/src/components/gridPopoverEdit/GridPopoutEditMultiSelectGrid.d.ts +4 -4
- package/dist/src/components/gridPopoverEdit/GridPopoverEditBearing.d.ts +4 -4
- package/dist/src/components/gridPopoverEdit/GridPopoverEditDropDown.d.ts +4 -4
- package/dist/src/components/gridPopoverEdit/GridPopoverMenu.d.ts +4 -4
- package/dist/src/components/gridPopoverEdit/GridPopoverMessage.d.ts +4 -4
- package/dist/src/components/gridPopoverEdit/GridPopoverTextArea.d.ts +4 -4
- package/dist/src/components/gridPopoverEdit/GridPopoverTextInput.d.ts +4 -4
- package/dist/src/components/gridPopoverEdit/index.d.ts +11 -11
- package/dist/src/components/gridRender/GridRenderGenericCell.d.ts +5 -5
- package/dist/src/components/gridRender/GridRenderPopoutMenuCell.d.ts +1 -1
- package/dist/src/components/gridRender/index.d.ts +2 -2
- package/dist/src/components/gridUtil.d.ts +1 -1
- package/dist/src/components/index.d.ts +19 -19
- package/dist/src/contexts/GridContext.d.ts +4 -4
- package/dist/src/contexts/GridContextProvider.d.ts +3 -3
- package/dist/src/contexts/GridPopoverContext.d.ts +3 -3
- package/dist/src/contexts/GridPopoverContextProvider.d.ts +4 -4
- package/dist/src/contexts/GridUpdatingContextProvider.d.ts +1 -1
- package/dist/src/index.d.ts +19 -17
- package/dist/src/lui/ActionButton.d.ts +9 -9
- package/dist/src/lui/FormError.d.ts +2 -2
- package/dist/src/lui/TextAreaInput.d.ts +1 -1
- package/dist/src/lui/TextInputFormatted.d.ts +2 -2
- package/dist/src/lui/reactUtils.d.ts +1 -1
- package/dist/src/lui/stateDeferredHook.d.ts +1 -1
- package/dist/src/react-menu3/components/ControlledMenu.d.ts +2 -2
- package/dist/src/react-menu3/components/FocusableItem.d.ts +3 -3
- package/dist/src/react-menu3/components/Menu.d.ts +3 -3
- package/dist/src/react-menu3/components/MenuButton.d.ts +2 -2
- package/dist/src/react-menu3/components/MenuDivider.d.ts +1 -1
- package/dist/src/react-menu3/components/MenuGroup.d.ts +2 -2
- package/dist/src/react-menu3/components/MenuHeader.d.ts +2 -2
- package/dist/src/react-menu3/components/MenuItem.d.ts +3 -3
- package/dist/src/react-menu3/components/MenuList.d.ts +1 -1
- package/dist/src/react-menu3/components/MenuRadioGroup.d.ts +2 -2
- package/dist/src/react-menu3/components/SubMenu.d.ts +5 -5
- package/dist/src/react-menu3/contexts/EventHandlersContext.d.ts +1 -1
- package/dist/src/react-menu3/contexts/MenuListContext.d.ts +2 -2
- package/dist/src/react-menu3/contexts/MenuListItemContext.d.ts +1 -1
- package/dist/src/react-menu3/contexts/RadioGroupContext.d.ts +1 -1
- package/dist/src/react-menu3/contexts/SettingsContext.d.ts +2 -2
- package/dist/src/react-menu3/hooks/index.d.ts +9 -9
- package/dist/src/react-menu3/hooks/useBEM.d.ts +1 -1
- package/dist/src/react-menu3/hooks/useCombinedRef.d.ts +1 -1
- package/dist/src/react-menu3/hooks/useIsomorphicLayoutEffect.d.ts +1 -1
- package/dist/src/react-menu3/hooks/useItemEffect.d.ts +1 -1
- package/dist/src/react-menu3/hooks/useItemState.d.ts +1 -1
- package/dist/src/react-menu3/hooks/useItems.d.ts +2 -2
- package/dist/src/react-menu3/hooks/useMenuChange.d.ts +1 -1
- package/dist/src/react-menu3/hooks/useMenuState.d.ts +1 -1
- package/dist/src/react-menu3/hooks/useMenuStateAndFocus.d.ts +1 -1
- package/dist/src/react-menu3/index.d.ts +11 -11
- package/dist/src/react-menu3/positionUtils/getPositionHelpers.d.ts +1 -1
- package/dist/src/react-menu3/positionUtils/index.d.ts +3 -3
- package/dist/src/react-menu3/positionUtils/placeArrowHorizontal.d.ts +1 -1
- package/dist/src/react-menu3/positionUtils/placeArrowVertical.d.ts +1 -1
- package/dist/src/react-menu3/positionUtils/placeLeftorRight.d.ts +4 -4
- package/dist/src/react-menu3/positionUtils/placeToporBottom.d.ts +5 -5
- package/dist/src/react-menu3/positionUtils/positionContextMenu.d.ts +2 -2
- package/dist/src/react-menu3/positionUtils/positionMenu.d.ts +5 -5
- package/dist/src/react-menu3/style-utils/index.d.ts +1 -1
- package/dist/src/react-menu3/types.d.ts +15 -15
- package/dist/src/react-menu3/utils/constants.d.ts +1 -1
- package/dist/src/react-menu3/utils/index.d.ts +3 -3
- package/dist/src/react-menu3/utils/utils.d.ts +5 -5
- package/dist/src/react-menu3/utils/withHovering.d.ts +1 -1
- package/{src/utils → dist/src/utils/__tests__}/storybookTestUtil.ts +2 -2
- package/{src/utils → dist/src/utils/__tests__}/testQuick.ts +15 -14
- package/{src/utils → dist/src/utils/__tests__}/testUtil.ts +31 -36
- package/dist/src/utils/__tests__/vitestUtil.ts +295 -0
- package/dist/src/utils/textValidator.d.ts +2 -2
- package/dist/{step-ag-grid.cjs.js → step-ag-grid.cjs} +969 -955
- package/dist/step-ag-grid.cjs.map +1 -0
- package/dist/step-ag-grid.esm.js +970 -958
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/dist/vite.config.d.ts +1 -1
- package/package.json +38 -57
- package/src/components/ComponentLoadingWrapper.tsx +5 -6
- package/src/components/Grid.tsx +85 -83
- package/src/components/GridCell.test.tsx +17 -15
- package/src/components/GridCell.tsx +46 -44
- package/src/components/GridCellFiller.tsx +5 -4
- package/src/components/GridCellMultiEditor.tsx +7 -7
- package/src/components/GridCellMultiSelectClassRules.tsx +3 -3
- package/src/components/GridIcon.tsx +6 -7
- package/src/components/GridLoadableCell.tsx +2 -2
- package/src/components/GridNoRowsOverlay.tsx +8 -8
- package/src/components/GridPopoverHook.tsx +16 -16
- package/src/components/GridWrapper.tsx +2 -2
- package/src/components/PostSortRowsHook.ts +11 -11
- package/src/components/clickInputWhenContainingCellClicked.tsx +5 -5
- package/src/components/gridFilter/GridFilterButtons.tsx +8 -9
- package/src/components/gridFilter/GridFilterColumnsToggle.tsx +25 -26
- package/src/components/gridFilter/GridFilterDownloadCsvButton.tsx +12 -13
- package/src/components/gridFilter/GridFilterHeaderIconButton.tsx +9 -10
- package/src/components/gridFilter/GridFilterQuick.tsx +6 -6
- package/src/components/gridFilter/GridFilters.tsx +1 -1
- package/src/components/gridFilter/index.ts +7 -7
- package/src/components/gridFilter/useGridFilter.ts +3 -3
- package/src/components/gridForm/GridFormDropDown.tsx +56 -52
- package/src/components/gridForm/GridFormEditBearing.tsx +12 -12
- package/src/components/gridForm/GridFormMessage.tsx +10 -10
- package/src/components/gridForm/GridFormMultiSelect.tsx +53 -51
- package/src/components/gridForm/GridFormMultiSelectGrid.tsx +25 -26
- package/src/components/gridForm/GridFormPopoverMenu.tsx +32 -29
- package/src/components/gridForm/GridFormSubComponentTextArea.tsx +10 -10
- package/src/components/gridForm/GridFormSubComponentTextInput.tsx +8 -8
- package/src/components/gridForm/GridFormTextArea.tsx +11 -11
- package/src/components/gridForm/GridFormTextInput.tsx +11 -11
- package/src/components/gridForm/index.ts +10 -10
- package/src/components/gridHeader/GridHeaderSelect.tsx +9 -9
- package/src/components/gridHeader/index.ts +1 -1
- package/src/components/gridHook/index.ts +1 -1
- package/src/components/gridHook/useGridContextMenu.tsx +7 -7
- package/src/components/gridPopoverEdit/GridButton.tsx +13 -12
- package/src/components/gridPopoverEdit/GridEditBoolean.tsx +19 -18
- package/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.ts +7 -6
- package/src/components/gridPopoverEdit/GridPopoutEditMultiSelectGrid.ts +7 -6
- package/src/components/gridPopoverEdit/GridPopoverEditBearing.ts +9 -9
- package/src/components/gridPopoverEdit/GridPopoverEditDropDown.ts +8 -7
- package/src/components/gridPopoverEdit/GridPopoverMenu.tsx +6 -6
- package/src/components/gridPopoverEdit/GridPopoverMessage.ts +4 -4
- package/src/components/gridPopoverEdit/GridPopoverTextArea.ts +4 -4
- package/src/components/gridPopoverEdit/GridPopoverTextInput.ts +4 -4
- package/src/components/gridPopoverEdit/index.ts +11 -11
- package/src/components/gridRender/GridRenderGenericCell.tsx +5 -5
- package/src/components/gridRender/GridRenderPopoutMenuCell.tsx +8 -9
- package/src/components/gridRender/index.ts +2 -2
- package/src/components/gridUtil.ts +3 -3
- package/src/components/index.ts +19 -19
- package/src/contexts/GridContext.tsx +52 -46
- package/src/contexts/GridContextProvider.test.tsx +15 -14
- package/src/contexts/GridContextProvider.tsx +42 -42
- package/src/contexts/GridPopoverContext.tsx +10 -7
- package/src/contexts/GridPopoverContextProvider.tsx +12 -10
- package/src/contexts/GridSubComponentContext.ts +6 -5
- package/src/contexts/GridUpdatingContext.tsx +5 -4
- package/src/contexts/GridUpdatingContextProvider.tsx +3 -3
- package/src/index.ts +19 -21
- package/src/lui/ActionButton.scss +2 -2
- package/src/lui/ActionButton.tsx +42 -41
- package/src/lui/FormError.scss +3 -4
- package/src/lui/FormError.tsx +4 -4
- package/src/lui/TextAreaInput.tsx +9 -9
- package/src/lui/TextInputFormatted.scss +1 -1
- package/src/lui/TextInputFormatted.tsx +11 -11
- package/src/lui/reactUtils.test.tsx +9 -8
- package/src/lui/reactUtils.tsx +2 -2
- package/src/lui/stateDeferredHook.tsx +3 -5
- package/src/lui/timeoutHook.test.tsx +12 -11
- package/src/lui/timeoutHook.tsx +1 -1
- package/src/react-app-env.d.ts +1 -1
- package/src/react-menu3/components/ControlledMenu.tsx +48 -48
- package/src/react-menu3/components/FocusableItem.tsx +7 -7
- package/src/react-menu3/components/Menu.tsx +11 -11
- package/src/react-menu3/components/MenuButton.tsx +4 -4
- package/src/react-menu3/components/MenuDivider.tsx +4 -4
- package/src/react-menu3/components/MenuGroup.tsx +5 -5
- package/src/react-menu3/components/MenuHeader.tsx +4 -4
- package/src/react-menu3/components/MenuItem.tsx +14 -14
- package/src/react-menu3/components/MenuList.tsx +55 -55
- package/src/react-menu3/components/MenuRadioGroup.tsx +7 -7
- package/src/react-menu3/components/SubMenu.tsx +24 -24
- package/src/react-menu3/contexts/EventHandlersContext.ts +2 -2
- package/src/react-menu3/contexts/HoverItemContext.ts +1 -1
- package/src/react-menu3/contexts/ItemSettingsContext.ts +1 -1
- package/src/react-menu3/contexts/MenuListContext.ts +2 -2
- package/src/react-menu3/contexts/MenuListItemContext.ts +2 -2
- package/src/react-menu3/contexts/RadioGroupContext.ts +2 -2
- package/src/react-menu3/contexts/SettingsContext.ts +2 -2
- package/src/react-menu3/hooks/index.ts +9 -9
- package/src/react-menu3/hooks/useBEM.ts +4 -4
- package/src/react-menu3/hooks/useCombinedRef.ts +2 -2
- package/src/react-menu3/hooks/useIsomorphicLayoutEffect.ts +4 -4
- package/src/react-menu3/hooks/useItemEffect.ts +3 -3
- package/src/react-menu3/hooks/useItemState.ts +5 -5
- package/src/react-menu3/hooks/useItems.ts +8 -8
- package/src/react-menu3/hooks/useMenuChange.ts +3 -3
- package/src/react-menu3/hooks/useMenuState.ts +5 -5
- package/src/react-menu3/hooks/useMenuStateAndFocus.ts +4 -4
- package/src/react-menu3/index.ts +11 -11
- package/src/react-menu3/positionUtils/getPositionHelpers.ts +2 -2
- package/src/react-menu3/positionUtils/index.ts +3 -3
- package/src/react-menu3/positionUtils/placeArrowHorizontal.ts +1 -1
- package/src/react-menu3/positionUtils/placeArrowVertical.ts +1 -1
- package/src/react-menu3/positionUtils/placeLeftorRight.ts +13 -13
- package/src/react-menu3/positionUtils/placeToporBottom.ts +15 -15
- package/src/react-menu3/positionUtils/positionContextMenu.ts +4 -4
- package/src/react-menu3/positionUtils/positionMenu.ts +14 -14
- package/src/react-menu3/style-utils/index.ts +24 -24
- package/src/react-menu3/types.ts +15 -15
- package/src/react-menu3/utils/constants.ts +33 -33
- package/src/react-menu3/utils/index.ts +3 -4
- package/src/react-menu3/utils/propTypes2.ts +10 -10
- package/src/react-menu3/utils/utils.ts +14 -14
- package/src/react-menu3/utils/withHovering.tsx +3 -3
- package/src/stories/components/ActionButton.stories.tsx +23 -24
- package/src/stories/grid/FormTest.tsx +15 -16
- package/src/stories/grid/GridDragRow.stories.tsx +33 -34
- package/src/stories/grid/GridFilterButtons.stories.tsx +32 -33
- package/src/stories/grid/GridNoRowsOverlay.stories.tsx +9 -10
- package/src/stories/grid/GridNonEditableRow.stories.tsx +40 -41
- package/src/stories/grid/GridPinnedRow.stories.tsx +25 -26
- package/src/stories/grid/GridPopoutContextMenu.stories.tsx +33 -32
- package/src/stories/grid/GridPopoutEditBoolean.stories.tsx +21 -22
- package/src/stories/grid/GridPopoutEditGeneric.stories.tsx +18 -19
- package/src/stories/grid/GridPopoutEditGenericTextArea.stories.tsx +50 -49
- package/src/stories/grid/GridPopoverEditBearing.stories.tsx +25 -26
- package/src/stories/grid/GridPopoverEditDropDown.stories.tsx +93 -94
- package/src/stories/grid/GridPopoverEditMultiSelect.stories.tsx +62 -63
- package/src/stories/grid/GridPopoverEditMultiSelectGrid.stories.tsx +28 -28
- package/src/stories/grid/GridReadOnly.stories.tsx +66 -67
- package/src/stories/grid/GridViewList.stories.tsx +37 -38
- package/src/stories/grid/gridFormInteraction/GridFormDropDownInteraction.stories.tsx +37 -38
- package/src/stories/grid/gridFormInteraction/GridFormEditBearingCorrectionInteraction.stories.tsx +25 -26
- package/src/stories/grid/gridFormInteraction/GridFormEditBearingInteraction.stories.tsx +25 -26
- package/src/stories/grid/gridFormInteraction/GridFormMultiSelectGridInteraction.stories.tsx +31 -31
- package/src/stories/grid/gridFormInteraction/GridFormMultiSelectInteraction.stories.tsx +47 -48
- package/src/stories/grid/gridFormInteraction/GridFormPopoverMenuInteraction.stories.tsx +44 -45
- package/src/stories/grid/gridFormInteraction/GridFormTextAreaInteraction.stories.tsx +19 -20
- package/src/stories/grid/gridFormInteraction/GridFormTextInputInteraction.stories.tsx +21 -22
- package/src/stories/grid/gridFormStatic/GridFormDropDown.stories.tsx +40 -41
- package/src/stories/grid/gridFormStatic/GridFormEditBearing.stories.tsx +14 -15
- package/src/stories/grid/gridFormStatic/GridFormEditBearingCorrection.stories.tsx +14 -15
- package/src/stories/grid/gridFormStatic/GridFormMessage.stories.tsx +10 -11
- package/src/stories/grid/gridFormStatic/GridFormMultiSelect.stories.tsx +20 -21
- package/src/stories/grid/gridFormStatic/GridFormPopoverMenu.stories.tsx +16 -17
- package/src/stories/grid/gridFormStatic/GridFormTextArea.stories.tsx +13 -14
- package/src/stories/grid/gridFormStatic/GridFormTextInput.stories.tsx +13 -14
- package/src/stories/grid/interactions/GridKeyboardInteractions.stories.tsx +68 -71
- package/src/stories/react-menu/ReactMenu.stories.tsx +26 -26
- package/src/styles/Grid.scss +9 -9
- package/src/styles/GridIcon.scss +6 -6
- package/src/styles/GridPopoverMenu.scss +3 -3
- package/src/styles/GridTheme.scss +1 -1
- package/src/styles/react-menu-customisations.scss +26 -41
- package/src/utils/__tests__/storybookTestUtil.ts +4 -0
- package/src/utils/__tests__/testQuick.ts +157 -0
- package/src/utils/__tests__/testUtil.ts +294 -0
- package/src/utils/__tests__/vitestUtil.ts +295 -0
- package/src/utils/bearing.test.ts +47 -45
- package/src/utils/bearing.ts +20 -20
- package/src/utils/deferredPromise.ts +1 -1
- package/src/utils/textMatcher.test.ts +10 -9
- package/src/utils/textMatcher.ts +8 -8
- package/src/utils/textValidator.test.ts +61 -62
- package/src/utils/textValidator.ts +11 -11
- package/src/utils/util.test.ts +21 -20
- package/src/utils/util.ts +7 -7
- package/dist/src/utils/storybookTestUtil.d.ts +0 -3
- package/dist/src/utils/testQuick.d.ts +0 -62
- package/dist/src/utils/testUtil.d.ts +0 -46
- package/dist/step-ag-grid.cjs.js.map +0 -1
|
@@ -1,118 +1,117 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { TextInputValidator, TextInputValidatorProps } from "./textValidator";
|
|
1
|
+
import { describe, expect, test, vi } from 'vitest';
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import { GridBaseRow } from '../components/Grid';
|
|
4
|
+
import { TextInputValidator, TextInputValidatorProps } from './textValidator';
|
|
5
|
+
|
|
6
|
+
describe('TextInputValidator', () => {
|
|
7
|
+
test('number format', () => {
|
|
6
8
|
const validate = [
|
|
7
9
|
{
|
|
8
10
|
numberFormat: {},
|
|
9
11
|
tests: [
|
|
10
|
-
[
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
16
|
-
[
|
|
17
|
-
[
|
|
18
|
-
[
|
|
12
|
+
['x', 'Must be a valid number'],
|
|
13
|
+
['1.2e6', 'Must be a valid number'],
|
|
14
|
+
['', null],
|
|
15
|
+
['1', null],
|
|
16
|
+
['1.2', null],
|
|
17
|
+
['.2', null],
|
|
18
|
+
['-1.2', null],
|
|
19
|
+
['-.2', null],
|
|
20
|
+
['-.2', null],
|
|
19
21
|
],
|
|
20
22
|
},
|
|
21
23
|
{
|
|
22
24
|
numberFormat: { geMin: 0, leMax: 10 },
|
|
23
25
|
tests: [
|
|
24
|
-
[
|
|
25
|
-
[
|
|
26
|
-
[
|
|
27
|
-
[
|
|
28
|
-
[
|
|
29
|
-
[
|
|
30
|
-
[
|
|
26
|
+
['x', 'Must be a valid number'],
|
|
27
|
+
['', null],
|
|
28
|
+
['1', null],
|
|
29
|
+
['0', null],
|
|
30
|
+
['-1', 'Must not be less than 0'],
|
|
31
|
+
['10', null],
|
|
32
|
+
['10.1', 'Must not be greater than 10'],
|
|
31
33
|
],
|
|
32
34
|
},
|
|
33
35
|
{
|
|
34
36
|
numberFormat: { gtMin: 0, ltMax: 10 },
|
|
35
37
|
tests: [
|
|
36
|
-
[
|
|
37
|
-
[
|
|
38
|
-
[
|
|
39
|
-
[
|
|
40
|
-
[
|
|
38
|
+
['x', 'Must be a valid number'],
|
|
39
|
+
['', null],
|
|
40
|
+
['1', null],
|
|
41
|
+
['0', 'Must be greater than 0'],
|
|
42
|
+
['10', 'Must be less than 10'],
|
|
41
43
|
],
|
|
42
44
|
},
|
|
43
45
|
{
|
|
44
46
|
numberFormat: { precision: 3 },
|
|
45
47
|
tests: [
|
|
46
|
-
[
|
|
47
|
-
[
|
|
48
|
-
[
|
|
49
|
-
[
|
|
50
|
-
[
|
|
51
|
-
[
|
|
48
|
+
['x', 'Must be a valid number'],
|
|
49
|
+
['', null],
|
|
50
|
+
['1.22', null],
|
|
51
|
+
['0.122', null],
|
|
52
|
+
['1.123', 'Must have no more than 3 digits precision'],
|
|
53
|
+
['0.1234', 'Must have no more than 3 digits precision'],
|
|
52
54
|
],
|
|
53
55
|
},
|
|
54
56
|
{
|
|
55
57
|
numberFormat: { scale: 2 },
|
|
56
58
|
tests: [
|
|
57
|
-
[
|
|
58
|
-
[
|
|
59
|
-
[
|
|
60
|
-
[
|
|
61
|
-
[
|
|
59
|
+
['x', 'Must be a valid number'],
|
|
60
|
+
['', null],
|
|
61
|
+
['1.22', null],
|
|
62
|
+
['0.122', 'Must have no more than 2 decimal places'],
|
|
63
|
+
['1.123', 'Must have no more than 2 decimal places'],
|
|
62
64
|
],
|
|
63
65
|
},
|
|
64
66
|
{
|
|
65
67
|
numberFormat: { scale: 0 },
|
|
66
68
|
tests: [
|
|
67
|
-
[
|
|
68
|
-
[
|
|
69
|
+
['1', null],
|
|
70
|
+
['1.1', 'Must be a whole number'],
|
|
69
71
|
],
|
|
70
72
|
},
|
|
71
73
|
{
|
|
72
74
|
numberFormat: { notZero: true },
|
|
73
75
|
tests: [
|
|
74
|
-
[
|
|
75
|
-
[
|
|
76
|
+
['1', null],
|
|
77
|
+
['0', 'Must not be 0'],
|
|
76
78
|
],
|
|
77
79
|
},
|
|
78
80
|
{
|
|
79
81
|
required: true,
|
|
80
82
|
tests: [
|
|
81
|
-
[
|
|
82
|
-
[
|
|
83
|
-
[
|
|
84
|
-
[
|
|
85
|
-
[
|
|
86
|
-
[
|
|
83
|
+
['xx', null],
|
|
84
|
+
['', 'Must not be empty'],
|
|
85
|
+
['\t', 'Must not be empty'],
|
|
86
|
+
['\n', 'Must not be empty'],
|
|
87
|
+
['\r', 'Must not be empty'],
|
|
88
|
+
[' ', 'Must not be empty'],
|
|
87
89
|
],
|
|
88
90
|
},
|
|
89
91
|
] as (TextInputValidatorProps<GridBaseRow> & { tests: [string, string | undefined][] })[];
|
|
90
92
|
|
|
91
|
-
validate.forEach((v
|
|
93
|
+
validate.forEach((v) => {
|
|
92
94
|
for (const test of v.tests) {
|
|
93
|
-
expect(
|
|
94
|
-
TextInputValidator(v, test[0], { id: 0 }, {}),
|
|
95
|
-
`Test ${i}: "${test[0]}" should return "${test[1]}"`,
|
|
96
|
-
).toBe(test[1]);
|
|
95
|
+
expect(TextInputValidator(v, test[0], { id: 0 }, {})).toBe(test[1]);
|
|
97
96
|
}
|
|
98
97
|
});
|
|
99
98
|
});
|
|
100
99
|
|
|
101
|
-
test(
|
|
102
|
-
const fn =
|
|
103
|
-
TextInputValidator({ invalid: fn },
|
|
100
|
+
test('validator is called', () => {
|
|
101
|
+
const fn = vi.fn();
|
|
102
|
+
TextInputValidator({ invalid: fn }, '', { id: 0 }, {});
|
|
104
103
|
expect(fn).toHaveBeenCalled();
|
|
105
104
|
});
|
|
106
105
|
|
|
107
|
-
test(
|
|
108
|
-
expect(TextInputValidator({ maxLength: 2 },
|
|
109
|
-
expect(TextInputValidator({ maxLength: 2 },
|
|
110
|
-
expect(TextInputValidator({ maxLength: 2 },
|
|
106
|
+
test('maxLength', () => {
|
|
107
|
+
expect(TextInputValidator({ maxLength: 2 }, '', { id: 0 }, {})).toBeNull();
|
|
108
|
+
expect(TextInputValidator({ maxLength: 2 }, 'aa', { id: 0 }, {})).toBeNull();
|
|
109
|
+
expect(TextInputValidator({ maxLength: 2 }, 'aaa', { id: 0 }, {})).toBe('Must be no longer than 2 characters');
|
|
111
110
|
});
|
|
112
111
|
|
|
113
|
-
test(
|
|
114
|
-
expect(TextInputValidator({ maxBytes: 2 },
|
|
115
|
-
expect(TextInputValidator({ maxBytes: 2 },
|
|
116
|
-
expect(TextInputValidator({ maxBytes: 2 },
|
|
112
|
+
test('maxBytes', () => {
|
|
113
|
+
expect(TextInputValidator({ maxBytes: 2 }, '', { id: 0 }, {})).toBeNull();
|
|
114
|
+
expect(TextInputValidator({ maxBytes: 2 }, 'aa', { id: 0 }, {})).toBeNull();
|
|
115
|
+
expect(TextInputValidator({ maxBytes: 2 }, 'a–', { id: 0 }, {})).toBe('Must be no longer than 2 bytes');
|
|
117
116
|
});
|
|
118
117
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ReactElement } from
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
2
|
|
|
3
|
-
import { GridBaseRow } from
|
|
4
|
-
import { isFloat, stringByteLengthIsInvalid } from
|
|
3
|
+
import { GridBaseRow } from '../components/Grid';
|
|
4
|
+
import { isFloat, stringByteLengthIsInvalid } from './util';
|
|
5
5
|
|
|
6
6
|
export interface TextInputValidatorProps<TData extends GridBaseRow> {
|
|
7
7
|
required?: boolean;
|
|
@@ -28,11 +28,11 @@ export const TextInputValidator = <TData extends GridBaseRow>(
|
|
|
28
28
|
if (value == null) return null;
|
|
29
29
|
|
|
30
30
|
// This can happen because subcomponent is invoked without type safety
|
|
31
|
-
if (typeof value !==
|
|
32
|
-
return
|
|
31
|
+
if (typeof value !== 'string') {
|
|
32
|
+
return 'Value is not a string';
|
|
33
33
|
}
|
|
34
|
-
if (props.required && value.trim() ==
|
|
35
|
-
return
|
|
34
|
+
if (props.required && value.trim() == '') {
|
|
35
|
+
return 'Must not be empty';
|
|
36
36
|
}
|
|
37
37
|
if (props.maxLength && value.length > props.maxLength) {
|
|
38
38
|
return `Must be no longer than ${props.maxLength} characters`;
|
|
@@ -42,10 +42,10 @@ export const TextInputValidator = <TData extends GridBaseRow>(
|
|
|
42
42
|
}
|
|
43
43
|
const nf = props.numberFormat;
|
|
44
44
|
if (nf) {
|
|
45
|
-
if (value !=
|
|
45
|
+
if (value != '' && !isFloat(value)) {
|
|
46
46
|
return `Must be a valid number`;
|
|
47
47
|
}
|
|
48
|
-
if (value !=
|
|
48
|
+
if (value != '') {
|
|
49
49
|
const number = parseFloat(value);
|
|
50
50
|
if (nf.notZero && number === 0) {
|
|
51
51
|
return `Must not be 0`;
|
|
@@ -63,13 +63,13 @@ export const TextInputValidator = <TData extends GridBaseRow>(
|
|
|
63
63
|
return `Must not be greater than ${nf.leMax.toLocaleString()}`;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
if (nf.precision != null && value !=
|
|
66
|
+
if (nf.precision != null && value != '') {
|
|
67
67
|
if (parseFloat(number.toPrecision(nf.precision)) != number) {
|
|
68
68
|
return `Must have no more than ${nf.precision} digits precision`;
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
if (nf.scale != null && value !=
|
|
72
|
+
if (nf.scale != null && value != '') {
|
|
73
73
|
if (parseFloat(number.toFixed(nf.scale)) != number) {
|
|
74
74
|
return nf.scale == 0 ? `Must be a whole number` : `Must have no more than ${nf.scale} decimal places`;
|
|
75
75
|
}
|
package/src/utils/util.test.ts
CHANGED
|
@@ -1,29 +1,30 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { describe, expect, test } from 'vitest';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
expect(isFloat(
|
|
7
|
-
expect(isFloat(
|
|
8
|
-
expect(isFloat(
|
|
9
|
-
expect(isFloat(
|
|
10
|
-
expect(isFloat(
|
|
11
|
-
expect(isFloat(
|
|
12
|
-
expect(isFloat(
|
|
13
|
-
expect(isFloat(
|
|
3
|
+
import { isFloat, sanitiseFileName } from './util';
|
|
4
|
+
describe('sanitiseFileName', () => {
|
|
5
|
+
test('isFloat', () => {
|
|
6
|
+
expect(isFloat('')).toBe(false);
|
|
7
|
+
expect(isFloat('x')).toBe(false);
|
|
8
|
+
expect(isFloat('1e10')).toBe(false);
|
|
9
|
+
expect(isFloat('1x')).toBe(false);
|
|
10
|
+
expect(isFloat('1.x')).toBe(false);
|
|
11
|
+
expect(isFloat('x.1')).toBe(false);
|
|
12
|
+
expect(isFloat('1')).toBe(true);
|
|
13
|
+
expect(isFloat('1.')).toBe(true);
|
|
14
|
+
expect(isFloat('.1')).toBe(true);
|
|
14
15
|
});
|
|
15
|
-
test(
|
|
16
|
-
expect(sanitiseFileName(
|
|
17
|
-
expect(sanitiseFileName(
|
|
16
|
+
test('sanitiseFileName', () => {
|
|
17
|
+
expect(sanitiseFileName(' LT 1235/543 &%//*$.csv ')).toBe('LT_1235-543_-.csv');
|
|
18
|
+
expect(sanitiseFileName(' @filename here!!!.csv ')).toBe('filename_here.csv');
|
|
18
19
|
// Trim to 64 char max for non extension part
|
|
19
|
-
expect(sanitiseFileName(
|
|
20
|
-
|
|
20
|
+
expect(sanitiseFileName('long_long_long_long_long_long_long_long_long_long_long_long_long_long_.csv')).toBe(
|
|
21
|
+
'long_long_long_long_long_long_long_long_long_long_long_long_long.csv',
|
|
21
22
|
);
|
|
22
23
|
// Test with no extension
|
|
23
|
-
expect(sanitiseFileName(
|
|
24
|
-
|
|
24
|
+
expect(sanitiseFileName('long_long_long_long_long_long_long_long_long_long_long_long_long_long_')).toBe(
|
|
25
|
+
'long_long_long_long_long_long_long_long_long_long_long_long_long',
|
|
25
26
|
);
|
|
26
27
|
// Test with no name
|
|
27
|
-
expect(sanitiseFileName(
|
|
28
|
+
expect(sanitiseFileName('.csv')).toBe('.csv');
|
|
28
29
|
});
|
|
29
30
|
});
|
package/src/utils/util.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isEmpty, negate } from
|
|
1
|
+
import { isEmpty, negate } from 'lodash-es';
|
|
2
2
|
|
|
3
3
|
export const isNotEmpty = negate(isEmpty);
|
|
4
4
|
|
|
@@ -44,17 +44,17 @@ export const hasParentClass = function (className: string, child: Node) {
|
|
|
44
44
|
export const stringByteLengthIsInvalid = (str: string, maxBytes: number) =>
|
|
45
45
|
new TextEncoder().encode(str).length > maxBytes;
|
|
46
46
|
|
|
47
|
-
export const fnOrVar = (fn: any, param?: any) => (typeof fn ===
|
|
47
|
+
export const fnOrVar = (fn: any, param?: any) => (typeof fn === 'function' ? fn(param) : fn);
|
|
48
48
|
|
|
49
49
|
export const sanitiseFileName = (filename: string): string => {
|
|
50
50
|
const valid = filename
|
|
51
51
|
.trim()
|
|
52
|
-
.replaceAll(/(\/|\\)+/g,
|
|
53
|
-
.replaceAll(/\s+/g,
|
|
54
|
-
.replaceAll(/[^\w\-āēīōūĀĒĪŌŪ.]/g,
|
|
55
|
-
const parts = valid.split(
|
|
52
|
+
.replaceAll(/(\/|\\)+/g, '-')
|
|
53
|
+
.replaceAll(/\s+/g, '_')
|
|
54
|
+
.replaceAll(/[^\w\-āēīōūĀĒĪŌŪ.]/g, '');
|
|
55
|
+
const parts = valid.split('.');
|
|
56
56
|
const fileExt = parts.length > 1 ? parts.pop() : undefined;
|
|
57
57
|
// Arbitrary max filename length of 64 chars + extension
|
|
58
58
|
if (!fileExt) return valid.slice().slice(0, 64);
|
|
59
|
-
return valid.slice(0, -fileExt.length - 1).slice(0, 64) +
|
|
59
|
+
return valid.slice(0, -fileExt.length - 1).slice(0, 64) + '.' + fileExt;
|
|
60
60
|
};
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* General query all by selected. Internal use, use quick operations instead.
|
|
3
|
-
*
|
|
4
|
-
* @param selector Selector to use
|
|
5
|
-
* @param container Optional container
|
|
6
|
-
* @return HTMLElement array
|
|
7
|
-
*/
|
|
8
|
-
import { IconName } from "@linzjs/lui/dist/components/LuiIcon/LuiIcon";
|
|
9
|
-
/**
|
|
10
|
-
* Filters for query quick operations.
|
|
11
|
-
*/
|
|
12
|
-
export interface IQueryQuick {
|
|
13
|
-
testId?: string;
|
|
14
|
-
tagName?: "button" | "span" | "div" | "input" | "textarea" | any;
|
|
15
|
-
text?: string | RegExp;
|
|
16
|
-
icon?: IconName;
|
|
17
|
-
ariaLabel?: string;
|
|
18
|
-
role?: string;
|
|
19
|
-
classes?: string;
|
|
20
|
-
child?: IQueryQuick;
|
|
21
|
-
}
|
|
22
|
-
export declare const getMatcher: (matcherText: string | RegExp) => (e: HTMLElement) => boolean;
|
|
23
|
-
/**
|
|
24
|
-
* Query by filter.
|
|
25
|
-
*
|
|
26
|
-
* @param filter Filter
|
|
27
|
-
* @param container Optional container to look in
|
|
28
|
-
* @return HTMLElement if found else null
|
|
29
|
-
*/
|
|
30
|
-
export declare const queryQuick: <T extends HTMLElement>(filter: IQueryQuick, container?: HTMLElement) => T | null;
|
|
31
|
-
/**
|
|
32
|
-
* Query all by filter.
|
|
33
|
-
*
|
|
34
|
-
* @param filter Filter
|
|
35
|
-
* @param container Optional container to look in
|
|
36
|
-
* @return HTMLElement array
|
|
37
|
-
*/
|
|
38
|
-
export declare const queryAllQuick: <T extends HTMLElement>(filter: IQueryQuick, container?: HTMLElement) => T[];
|
|
39
|
-
/**
|
|
40
|
-
* Get all by filter.
|
|
41
|
-
*
|
|
42
|
-
* @param filter Filter
|
|
43
|
-
* @param container Optional container to look in
|
|
44
|
-
* @return HTMLElement array. Throws exception if nothing is found.
|
|
45
|
-
*/
|
|
46
|
-
export declare const getAllQuick: <T extends HTMLElement>(filter: IQueryQuick, container?: HTMLElement) => T[];
|
|
47
|
-
/**
|
|
48
|
-
* Get by filter.
|
|
49
|
-
*
|
|
50
|
-
* @param filter Filter
|
|
51
|
-
* @param container Optional container to look in
|
|
52
|
-
* @return HTMLElement. Throws exception if not found.
|
|
53
|
-
*/
|
|
54
|
-
export declare const getQuick: (filter: IQueryQuick, container?: HTMLElement) => HTMLElement;
|
|
55
|
-
/**
|
|
56
|
-
* Find by filter. Waits up to 5 seconds to find filter.
|
|
57
|
-
*
|
|
58
|
-
* @param filter Filter
|
|
59
|
-
* @param container Optional container to look in
|
|
60
|
-
* @return HTMLElement. Throws exception if not found.
|
|
61
|
-
*/
|
|
62
|
-
export declare const findQuick: <T extends HTMLElement>(filter: IQueryQuick, container?: HTMLElement) => Promise<T>;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* allow external userEvent to be used
|
|
3
|
-
* @param customisedUserEvent
|
|
4
|
-
*/
|
|
5
|
-
export declare const setUpUserEvent: (customisedUserEvent: any) => void;
|
|
6
|
-
export declare const countRows: (within?: HTMLElement) => Promise<number>;
|
|
7
|
-
export declare const findRowByIndex: (rowIndex: number | string, within?: HTMLElement) => Promise<HTMLDivElement>;
|
|
8
|
-
export declare const findRow: (rowId: number | string, within?: HTMLElement) => Promise<HTMLDivElement>;
|
|
9
|
-
export declare const queryRow: (rowId: number | string, within?: HTMLElement) => Promise<HTMLDivElement | null>;
|
|
10
|
-
export declare const selectRow: (rowId: string | number, within?: HTMLElement) => Promise<void>;
|
|
11
|
-
export declare const deselectRow: (rowId: string | number, within?: HTMLElement) => Promise<void>;
|
|
12
|
-
export declare const findCell: (rowId: number | string, colId: string, within?: HTMLElement) => Promise<HTMLElement>;
|
|
13
|
-
export declare const findCellContains: (rowId: number | string, colId: string, text: string | RegExp, within?: HTMLElement) => Promise<HTMLElement>;
|
|
14
|
-
export declare const selectCell: (rowId: string | number, colId: string, within?: HTMLElement) => Promise<void>;
|
|
15
|
-
export declare const editCell: (rowId: number | string, colId: string, within?: HTMLElement) => Promise<void>;
|
|
16
|
-
export declare const isCellReadOnly: (rowId: number | string, colId: string, within?: HTMLElement) => Promise<boolean>;
|
|
17
|
-
export declare const findOpenPopover: () => Promise<HTMLElement>;
|
|
18
|
-
export declare const queryMenuOption: (menuOptionText: string | RegExp) => Promise<HTMLElement | null>;
|
|
19
|
-
export declare const findMenuOption: (menuOptionText: string | RegExp) => Promise<HTMLElement>;
|
|
20
|
-
export declare const validateMenuOptions: (rowId: number | string, colId: string, expectedMenuOptions: Array<string>) => Promise<boolean>;
|
|
21
|
-
export declare const clickMenuOption: (menuOptionText: string | RegExp) => Promise<void>;
|
|
22
|
-
export declare const openAndClickMenuOption: (rowId: number | string, colId: string, menuOptionText: string | RegExp, within?: HTMLElement) => Promise<void>;
|
|
23
|
-
export declare const openAndFindMenuOption: (rowId: number | string, colId: string, menuOptionText: string | RegExp, within?: HTMLElement) => Promise<HTMLElement>;
|
|
24
|
-
export declare const getMultiSelectOptions: () => Promise<{
|
|
25
|
-
v: string;
|
|
26
|
-
c: boolean;
|
|
27
|
-
}[]>;
|
|
28
|
-
export declare const findMultiSelectOption: (value: string) => Promise<HTMLElement>;
|
|
29
|
-
export declare const clickMultiSelectOption: (value: string) => Promise<void>;
|
|
30
|
-
export declare const typeOnlyInput: (value: string) => Promise<void>;
|
|
31
|
-
export declare const typeInputByLabel: (value: string, labelText: string) => Promise<void>;
|
|
32
|
-
export declare const typeInputByPlaceholder: (value: string, placeholder: string) => Promise<void>;
|
|
33
|
-
export declare const typeOtherInput: (value: string) => Promise<void>;
|
|
34
|
-
export declare const typeOtherTextArea: (value: string) => Promise<void>;
|
|
35
|
-
export declare const closeMenu: () => Promise<void>;
|
|
36
|
-
export declare const closePopover: () => Promise<void>;
|
|
37
|
-
export declare const findActionButton: (text: string, container?: HTMLElement) => Promise<HTMLElement>;
|
|
38
|
-
export declare const clickActionButton: (text: string, container?: HTMLElement) => Promise<void>;
|
|
39
|
-
export declare const waitForGridReady: (props?: {
|
|
40
|
-
grid?: HTMLElement;
|
|
41
|
-
timeout?: number;
|
|
42
|
-
}) => Promise<void>;
|
|
43
|
-
export declare const waitForGridRows: (props?: {
|
|
44
|
-
grid?: HTMLElement;
|
|
45
|
-
timeout?: number;
|
|
46
|
-
}) => Promise<void>;
|