@linzjs/step-ag-grid 23.0.1 → 24.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/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 +17 -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/dist/src/utils/testQuick.d.ts +2 -2
- package/dist/src/utils/testUtil.d.ts +2 -2
- package/dist/src/utils/textValidator.d.ts +2 -2
- package/dist/step-ag-grid.cjs.js +966 -952
- package/dist/step-ag-grid.cjs.js.map +1 -1
- package/dist/step-ag-grid.esm.js +968 -954
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +26 -41
- package/src/components/ComponentLoadingWrapper.tsx +5 -6
- package/src/components/Grid.tsx +85 -83
- package/src/components/GridCell.test.tsx +15 -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 +14 -14
- package/src/contexts/GridContextProvider.tsx +42 -41
- 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 +17 -21
- package/src/lui/ActionButton.tsx +42 -41
- package/src/lui/FormError.tsx +4 -4
- package/src/lui/TextAreaInput.tsx +9 -9
- package/src/lui/TextInputFormatted.tsx +11 -11
- package/src/lui/reactUtils.test.tsx +8 -8
- package/src/lui/reactUtils.tsx +2 -2
- package/src/lui/stateDeferredHook.tsx +3 -5
- package/src/lui/timeoutHook.test.tsx +5 -5
- 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/utils/bearing.test.ts +44 -44
- package/src/utils/bearing.ts +20 -20
- package/src/utils/deferredPromise.ts +1 -1
- package/src/utils/storybookTestUtil.ts +2 -2
- package/src/utils/testQuick.ts +15 -14
- package/src/utils/testUtil.ts +31 -36
- package/src/utils/textMatcher.test.ts +9 -9
- package/src/utils/textMatcher.ts +8 -8
- package/src/utils/textValidator.test.ts +56 -56
- package/src/utils/textValidator.ts +11 -11
- package/src/utils/util.test.ts +20 -20
- package/src/utils/util.ts +7 -7
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import '../../../styles/GridTheme.scss';
|
|
2
|
+
import '../../../styles/index.scss';
|
|
3
|
+
import '@linzjs/lui/dist/scss/base.scss';
|
|
4
|
+
import '@linzjs/lui/dist/fonts';
|
|
4
5
|
|
|
5
|
-
import { Meta, StoryFn } from
|
|
6
|
-
import { expect } from
|
|
7
|
-
import { fn } from
|
|
8
|
-
import { userEvent, waitFor } from
|
|
9
|
-
import { useMemo, useState } from
|
|
10
|
-
|
|
11
|
-
import "@linzjs/lui/dist/fonts";
|
|
6
|
+
import { Meta, StoryFn } from '@storybook/react';
|
|
7
|
+
import { expect } from '@storybook/test';
|
|
8
|
+
import { fn } from '@storybook/test';
|
|
9
|
+
import { userEvent, waitFor } from '@storybook/test';
|
|
10
|
+
import { useMemo, useState } from 'react';
|
|
12
11
|
|
|
13
12
|
import {
|
|
14
13
|
ColDefT,
|
|
@@ -24,24 +23,24 @@ import {
|
|
|
24
23
|
GridUpdatingContextProvider,
|
|
25
24
|
MenuOption,
|
|
26
25
|
wait,
|
|
27
|
-
} from
|
|
28
|
-
import { waitForGridReady } from
|
|
26
|
+
} from '../../../';
|
|
27
|
+
import { waitForGridReady } from '../../../utils/storybookTestUtil';
|
|
29
28
|
|
|
30
29
|
export default {
|
|
31
|
-
title:
|
|
30
|
+
title: 'Components / Grids',
|
|
32
31
|
component: Grid,
|
|
33
32
|
args: {
|
|
34
33
|
quickFilter: true,
|
|
35
|
-
quickFilterValue:
|
|
36
|
-
quickFilterPlaceholder:
|
|
34
|
+
quickFilterValue: '',
|
|
35
|
+
quickFilterPlaceholder: 'Quick filter...',
|
|
37
36
|
selectable: false,
|
|
38
|
-
rowSelection:
|
|
37
|
+
rowSelection: 'single',
|
|
39
38
|
},
|
|
40
39
|
// Storybook hangs otherwise
|
|
41
40
|
parameters: {
|
|
42
41
|
docs: {
|
|
43
42
|
source: {
|
|
44
|
-
type:
|
|
43
|
+
type: 'code',
|
|
45
44
|
},
|
|
46
45
|
},
|
|
47
46
|
},
|
|
@@ -79,28 +78,28 @@ const GridKeyboardInteractionsTemplate: StoryFn<typeof Grid> = (props: GridProps
|
|
|
79
78
|
const columnDefs: ColDefT<ITestRow>[] = useMemo(
|
|
80
79
|
() => [
|
|
81
80
|
GridCell({
|
|
82
|
-
field:
|
|
83
|
-
headerName:
|
|
81
|
+
field: 'id',
|
|
82
|
+
headerName: 'Id',
|
|
84
83
|
}),
|
|
85
|
-
GridCell<ITestRow, ITestRow[
|
|
86
|
-
field:
|
|
87
|
-
headerName:
|
|
84
|
+
GridCell<ITestRow, ITestRow['position']>({
|
|
85
|
+
field: 'position',
|
|
86
|
+
headerName: 'Position',
|
|
88
87
|
cellRendererParams: {
|
|
89
|
-
warning: ({ value }) => value ===
|
|
90
|
-
info: ({ value }) => value ===
|
|
88
|
+
warning: ({ value }) => value === 'Tester' && 'Testers are testing',
|
|
89
|
+
info: ({ value }) => value === 'Developer' && 'Developers are awesome',
|
|
91
90
|
},
|
|
92
91
|
}),
|
|
93
92
|
GridCell({
|
|
94
|
-
field:
|
|
95
|
-
headerName:
|
|
93
|
+
field: 'age',
|
|
94
|
+
headerName: 'Age',
|
|
96
95
|
}),
|
|
97
96
|
GridCell({
|
|
98
|
-
field:
|
|
99
|
-
headerName:
|
|
97
|
+
field: 'desc',
|
|
98
|
+
headerName: 'Description',
|
|
100
99
|
}),
|
|
101
100
|
GridPopoverMessage(
|
|
102
101
|
{
|
|
103
|
-
headerName:
|
|
102
|
+
headerName: 'Popout message',
|
|
104
103
|
maxWidth: 150,
|
|
105
104
|
cellRenderer: () => <>Single Click me!</>,
|
|
106
105
|
},
|
|
@@ -115,13 +114,13 @@ const GridKeyboardInteractionsTemplate: StoryFn<typeof Grid> = (props: GridProps
|
|
|
115
114
|
},
|
|
116
115
|
),
|
|
117
116
|
GridCell({
|
|
118
|
-
headerName:
|
|
117
|
+
headerName: 'Custom edit',
|
|
119
118
|
maxWidth: 100,
|
|
120
119
|
editable: true,
|
|
121
|
-
valueFormatter: () =>
|
|
120
|
+
valueFormatter: () => 'Press E',
|
|
122
121
|
cellRendererParams: {
|
|
123
122
|
rightHoverElement: (
|
|
124
|
-
<GridIcon icon={
|
|
123
|
+
<GridIcon icon={'ic_launch_modal'} title={'Title text'} className={'GridCell-editableIcon'} />
|
|
125
124
|
),
|
|
126
125
|
editAction: () => {
|
|
127
126
|
//
|
|
@@ -136,51 +135,51 @@ const GridKeyboardInteractionsTemplate: StoryFn<typeof Grid> = (props: GridProps
|
|
|
136
135
|
{
|
|
137
136
|
multiEdit: true,
|
|
138
137
|
editorParams: {
|
|
139
|
-
defaultAction:
|
|
138
|
+
defaultAction: ({ menuOption }) => {
|
|
140
139
|
// eslint-disable-next-line no-console
|
|
141
|
-
console.log(
|
|
140
|
+
console.log('clicked', { menuOption });
|
|
142
141
|
},
|
|
143
142
|
options: async (selectedItems) => {
|
|
144
143
|
// Just doing a timeout here to demonstrate deferred loading
|
|
145
144
|
await wait(500);
|
|
146
145
|
return [
|
|
147
146
|
{
|
|
148
|
-
label:
|
|
147
|
+
label: 'Single edit only',
|
|
149
148
|
action: async () => {
|
|
150
149
|
//
|
|
151
150
|
},
|
|
152
151
|
disabled: selectedItems.length > 1,
|
|
153
152
|
},
|
|
154
153
|
{
|
|
155
|
-
label:
|
|
154
|
+
label: 'Multi-edit',
|
|
156
155
|
action: multiEditAction,
|
|
157
156
|
},
|
|
158
157
|
{
|
|
159
|
-
label:
|
|
160
|
-
disabled:
|
|
158
|
+
label: 'Disabled item',
|
|
159
|
+
disabled: 'Disabled for test',
|
|
161
160
|
},
|
|
162
161
|
{
|
|
163
|
-
label:
|
|
164
|
-
hidden: selectedItems.some((x) => x.position !=
|
|
162
|
+
label: 'Developer Only',
|
|
163
|
+
hidden: selectedItems.some((x) => x.position != 'Developer'),
|
|
165
164
|
},
|
|
166
165
|
{
|
|
167
|
-
label:
|
|
166
|
+
label: 'Other (TextInput)',
|
|
168
167
|
action: async () => {
|
|
169
168
|
//
|
|
170
169
|
},
|
|
171
170
|
subComponent: () => (
|
|
172
|
-
<GridFormSubComponentTextInput placeholder={
|
|
171
|
+
<GridFormSubComponentTextInput placeholder={'Other'} maxLength={5} required defaultValue={''} />
|
|
173
172
|
),
|
|
174
173
|
},
|
|
175
174
|
{
|
|
176
|
-
label:
|
|
175
|
+
label: 'Other (TextArea)',
|
|
177
176
|
action: async ({ menuOption }) => {
|
|
178
177
|
// eslint-disable-next-line no-console
|
|
179
178
|
console.log(`Sub selected value was ${JSON.stringify(menuOption.subValue)}`);
|
|
180
179
|
await wait(500);
|
|
181
180
|
},
|
|
182
181
|
subComponent: () => (
|
|
183
|
-
<GridFormSubComponentTextArea placeholder={
|
|
182
|
+
<GridFormSubComponentTextArea placeholder={'Other'} maxLength={5} required defaultValue={''} />
|
|
184
183
|
),
|
|
185
184
|
},
|
|
186
185
|
] as MenuOption<ITestRow>[];
|
|
@@ -194,9 +193,7 @@ const GridKeyboardInteractionsTemplate: StoryFn<typeof Grid> = (props: GridProps
|
|
|
194
193
|
},
|
|
195
194
|
{
|
|
196
195
|
editorParams: {
|
|
197
|
-
options:
|
|
198
|
-
return [];
|
|
199
|
-
},
|
|
196
|
+
options: () => [],
|
|
200
197
|
},
|
|
201
198
|
},
|
|
202
199
|
),
|
|
@@ -205,9 +202,9 @@ const GridKeyboardInteractionsTemplate: StoryFn<typeof Grid> = (props: GridProps
|
|
|
205
202
|
);
|
|
206
203
|
|
|
207
204
|
const [rowData] = useState([
|
|
208
|
-
{ id: 1000, position:
|
|
209
|
-
{ id: 1001, position:
|
|
210
|
-
{ id: 1002, position:
|
|
205
|
+
{ id: 1000, position: 'Tester', age: 30, desc: 'Tests application', dd: '1' },
|
|
206
|
+
{ id: 1001, position: 'Developer', age: 12, desc: 'Develops application', dd: '2' },
|
|
207
|
+
{ id: 1002, position: 'Manager', age: 65, desc: 'Manages', dd: '3' },
|
|
211
208
|
]);
|
|
212
209
|
|
|
213
210
|
return (
|
|
@@ -218,7 +215,7 @@ const GridKeyboardInteractionsTemplate: StoryFn<typeof Grid> = (props: GridProps
|
|
|
218
215
|
setExternalSelectedItems={setExternalSelectedItems}
|
|
219
216
|
columnDefs={columnDefs}
|
|
220
217
|
rowData={rowData}
|
|
221
|
-
domLayout={
|
|
218
|
+
domLayout={'autoHeight'}
|
|
222
219
|
autoSelectFirstRow={true}
|
|
223
220
|
/>
|
|
224
221
|
);
|
|
@@ -232,47 +229,47 @@ GridKeyboardInteractions.play = async ({ canvasElement }) => {
|
|
|
232
229
|
await waitForGridReady({ canvasElement });
|
|
233
230
|
|
|
234
231
|
// Ensure first row/cell is selected on render
|
|
235
|
-
await waitFor(
|
|
232
|
+
await waitFor(() => {
|
|
236
233
|
const activeCell = canvasElement.ownerDocument.activeElement;
|
|
237
|
-
expect(activeCell).toHaveClass(
|
|
238
|
-
expect(activeCell).toHaveAttribute(
|
|
239
|
-
expect(activeCell?.parentElement).toHaveAttribute(
|
|
234
|
+
expect(activeCell).toHaveClass('ag-cell-focus');
|
|
235
|
+
expect(activeCell).toHaveAttribute('aria-colindex', '1');
|
|
236
|
+
expect(activeCell?.parentElement).toHaveAttribute('row-index', '0');
|
|
240
237
|
});
|
|
241
|
-
await userEvent.keyboard(
|
|
242
|
-
await userEvent.keyboard(
|
|
238
|
+
await userEvent.keyboard('{arrowdown}{arrowdown}');
|
|
239
|
+
await userEvent.keyboard('{arrowright}{arrowright}{arrowright}{arrowright}{arrowright}{arrowright}{arrowright}');
|
|
243
240
|
|
|
244
241
|
// Test enter post focus
|
|
245
242
|
const test = async (fn: () => any, colId: string, rowId: string) => {
|
|
246
|
-
await userEvent.keyboard(
|
|
243
|
+
await userEvent.keyboard('{Enter}');
|
|
247
244
|
await wait(1000);
|
|
248
|
-
await userEvent.keyboard(
|
|
245
|
+
await userEvent.keyboard('{arrowdown}{arrowdown}');
|
|
249
246
|
fn();
|
|
250
|
-
await waitFor(
|
|
247
|
+
await waitFor(() => {
|
|
251
248
|
expect(multiEditAction).toHaveBeenCalled();
|
|
252
249
|
});
|
|
253
250
|
|
|
254
|
-
await waitFor(
|
|
251
|
+
await waitFor(() => {
|
|
255
252
|
const activeCell = canvasElement.ownerDocument.activeElement;
|
|
256
|
-
expect(activeCell).toHaveClass(
|
|
257
|
-
expect(activeCell).toHaveAttribute(
|
|
258
|
-
expect(activeCell?.parentElement).toHaveAttribute(
|
|
253
|
+
expect(activeCell).toHaveClass('ag-cell-focus');
|
|
254
|
+
expect(activeCell).toHaveAttribute('aria-colindex', colId);
|
|
255
|
+
expect(activeCell?.parentElement).toHaveAttribute('row-index', rowId);
|
|
259
256
|
});
|
|
260
257
|
await wait(1000);
|
|
261
258
|
};
|
|
262
259
|
|
|
263
|
-
await test(() => userEvent.keyboard(
|
|
264
|
-
await test(() => userEvent.tab(),
|
|
260
|
+
await test(() => userEvent.keyboard('{Enter}'), '8', '2');
|
|
261
|
+
await test(() => userEvent.tab(), '9', '2');
|
|
265
262
|
await userEvent.tab({ shift: true });
|
|
266
|
-
await test(() => userEvent.tab({ shift: true }),
|
|
267
|
-
await userEvent.keyboard(
|
|
263
|
+
await test(() => userEvent.tab({ shift: true }), '6', '2');
|
|
264
|
+
await userEvent.keyboard('{Esc}');
|
|
268
265
|
await userEvent.tab();
|
|
269
266
|
|
|
270
|
-
await userEvent.keyboard(
|
|
267
|
+
await userEvent.keyboard('{Enter}');
|
|
271
268
|
await wait(250);
|
|
272
269
|
expect(eAction).not.toHaveBeenCalled();
|
|
273
270
|
|
|
274
|
-
await userEvent.keyboard(
|
|
275
|
-
await waitFor(
|
|
271
|
+
await userEvent.keyboard('e');
|
|
272
|
+
await waitFor(() => {
|
|
276
273
|
expect(eAction).toHaveBeenCalled();
|
|
277
274
|
});
|
|
278
275
|
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import '../../react-menu3/styles/index.scss';
|
|
2
2
|
|
|
3
|
-
import { Meta, StoryFn } from
|
|
4
|
-
import { expect } from
|
|
5
|
-
import * as test from
|
|
6
|
-
import { userEvent, within } from
|
|
3
|
+
import { Meta, StoryFn } from '@storybook/react';
|
|
4
|
+
import { expect } from '@storybook/test';
|
|
5
|
+
import * as test from '@storybook/test';
|
|
6
|
+
import { userEvent, within } from '@storybook/test';
|
|
7
7
|
|
|
8
|
-
import { Grid } from
|
|
9
|
-
import { Menu, MenuButton, MenuDivider, MenuItem, SubMenu } from
|
|
10
|
-
import { wait } from
|
|
8
|
+
import { Grid } from '../../components/Grid';
|
|
9
|
+
import { Menu, MenuButton, MenuDivider, MenuItem, SubMenu } from '../../react-menu3';
|
|
10
|
+
import { wait } from '../../utils/util';
|
|
11
11
|
|
|
12
12
|
export default {
|
|
13
|
-
title:
|
|
13
|
+
title: 'Components / React-menu',
|
|
14
14
|
component: Grid,
|
|
15
15
|
args: {
|
|
16
16
|
externalSelectedItems: [],
|
|
@@ -49,40 +49,40 @@ ReactMenuControlled.play = async ({ canvasElement }) => {
|
|
|
49
49
|
await wait(100); // Wait for debounce
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
-
const menuButton = await canvas.findByRole(
|
|
52
|
+
const menuButton = await canvas.findByRole('button');
|
|
53
53
|
expect(menuButton).toBeInTheDocument();
|
|
54
54
|
|
|
55
55
|
const openMenu = async () => {
|
|
56
56
|
await wait(500); // Wait for debounce
|
|
57
57
|
await userEvent.click(menuButton);
|
|
58
|
-
expect(await canvas.findByRole(
|
|
58
|
+
expect(await canvas.findByRole('menuitem', { name: 'New File' })).toBeInTheDocument();
|
|
59
59
|
};
|
|
60
60
|
|
|
61
61
|
// Check menu closes on click outside
|
|
62
62
|
await openMenu();
|
|
63
63
|
await userEvent.click(menuButton.parentElement as Element);
|
|
64
|
-
expect(canvas.queryByRole(
|
|
64
|
+
expect(canvas.queryByRole('menuitem', { name: 'New File' })).not.toBeInTheDocument();
|
|
65
65
|
|
|
66
66
|
// Test arrow down/up
|
|
67
67
|
await openMenu();
|
|
68
|
-
await keyboard(
|
|
69
|
-
await keyboard(
|
|
70
|
-
await keyboard(
|
|
71
|
-
await keyboard(
|
|
72
|
-
await keyboard(
|
|
73
|
-
expect(document.activeElement?.innerHTML).toBe(
|
|
68
|
+
await keyboard('{arrowdown}');
|
|
69
|
+
await keyboard('{arrowdown}');
|
|
70
|
+
await keyboard('{arrowdown}');
|
|
71
|
+
await keyboard('{arrowdown}');
|
|
72
|
+
await keyboard('{arrowdown}');
|
|
73
|
+
expect(document.activeElement?.innerHTML).toBe('Exit');
|
|
74
74
|
|
|
75
|
-
await keyboard(
|
|
76
|
-
expect(document.activeElement?.innerHTML).toBe(
|
|
75
|
+
await keyboard('{arrowup}');
|
|
76
|
+
expect(document.activeElement?.innerHTML).toBe('Print...');
|
|
77
77
|
|
|
78
78
|
// Escape close
|
|
79
|
-
await userEvent.type(menuButton.parentElement as Element,
|
|
80
|
-
expect(canvas.queryByRole(
|
|
79
|
+
await userEvent.type(menuButton.parentElement as Element, '{Escape}');
|
|
80
|
+
expect(canvas.queryByRole('menuitem', { name: 'New File' })).not.toBeInTheDocument();
|
|
81
81
|
|
|
82
82
|
// Test enter to select
|
|
83
83
|
await openMenu();
|
|
84
|
-
await keyboard(
|
|
85
|
-
await keyboard(
|
|
84
|
+
await keyboard('{arrowdown}');
|
|
85
|
+
await keyboard('{enter}');
|
|
86
86
|
expect(menuItemClickAction).toHaveBeenCalled();
|
|
87
87
|
expect(newFileAction).toHaveBeenCalled();
|
|
88
88
|
|
|
@@ -91,10 +91,10 @@ ReactMenuControlled.play = async ({ canvasElement }) => {
|
|
|
91
91
|
|
|
92
92
|
// Test tab to select
|
|
93
93
|
await openMenu();
|
|
94
|
-
await keyboard(
|
|
94
|
+
await keyboard('{arrowdown}');
|
|
95
95
|
// For some reason arrow down takes a little time to activate
|
|
96
96
|
await wait(10);
|
|
97
|
-
await keyboard(
|
|
97
|
+
await keyboard('{Tab}');
|
|
98
98
|
expect(menuItemClickAction).toHaveBeenCalled();
|
|
99
99
|
expect(newFileAction).toHaveBeenCalled();
|
|
100
100
|
|
|
@@ -3,53 +3,53 @@ import {
|
|
|
3
3
|
bearingRangeValidator,
|
|
4
4
|
bearingStringValidator,
|
|
5
5
|
convertDDToDMS,
|
|
6
|
-
} from
|
|
6
|
+
} from './bearing';
|
|
7
7
|
|
|
8
|
-
describe(
|
|
9
|
-
test(
|
|
10
|
-
expect(convertDDToDMS(-0.001, false)).toBe(
|
|
11
|
-
expect(convertDDToDMS(-10.001, false)).toBe(
|
|
12
|
-
expect(convertDDToDMS(-370.001, false)).toBe(
|
|
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"');
|
|
13
13
|
expect(convertDDToDMS(359.595999, false, 2)).toBe("0° 00'");
|
|
14
|
-
expect(convertDDToDMS(359.595999, false, 4)).toBe(
|
|
15
|
-
expect(convertDDToDMS(359.595999, false, 5)).toBe(
|
|
16
|
-
expect(convertDDToDMS(369.696999, false)).toBe(
|
|
17
|
-
expect(convertDDToDMS(369.696999, false, 4)).toBe(
|
|
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"');
|
|
18
18
|
expect(convertDDToDMS(221.555999, false, 2)).toBe("221° 56'");
|
|
19
|
-
expect(convertDDToDMS(221.555999, false, 5)).toBe(
|
|
20
|
-
expect(convertDDToDMS(5, true, 5)).toBe(
|
|
21
|
-
expect(convertDDToDMS(5.0, true, 5)).toBe(
|
|
22
|
-
expect(convertDDToDMS(5.00001, true, 5)).toBe(
|
|
23
|
-
expect(convertDDToDMS(5.1, true, 5)).toBe(
|
|
24
|
-
expect(convertDDToDMS(5.12345)).toBe(
|
|
25
|
-
expect(convertDDToDMS(5.12345, false)).toBe(
|
|
26
|
-
expect(convertDDToDMS(5.12345, false, 2)).toBe(
|
|
27
|
-
expect(convertDDToDMS(300, true, 5)).toBe(
|
|
28
|
-
expect(convertDDToDMS(300.0, true, 5)).toBe(
|
|
29
|
-
expect(convertDDToDMS(300.00001)).toBe(
|
|
30
|
-
expect(convertDDToDMS(300.1, true, 5)).toBe(
|
|
31
|
-
expect(convertDDToDMS(300.12345)).toBe(
|
|
32
|
-
expect(convertDDToDMS(300.12345, false)).toBe(
|
|
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"');
|
|
33
33
|
expect(convertDDToDMS(300, false, 2)).toBe("300° 00'");
|
|
34
34
|
expect(convertDDToDMS(300.1, false, 2)).toBe("300° 10'");
|
|
35
35
|
expect(convertDDToDMS(0, false, 2)).toBe("0° 00'");
|
|
36
36
|
expect(convertDDToDMS(0.0, false)).toBe("0° 00'");
|
|
37
|
-
expect(convertDDToDMS(0.0, false, 4)).toBe(
|
|
38
|
-
expect(convertDDToDMS(0.0, false, 5)).toBe(
|
|
37
|
+
expect(convertDDToDMS(0.0, false, 4)).toBe('0° 00\' 00"');
|
|
38
|
+
expect(convertDDToDMS(0.0, false, 5)).toBe('0° 00\' 00.0"');
|
|
39
39
|
});
|
|
40
40
|
|
|
41
|
-
test(
|
|
41
|
+
test('bearingStringValidator', () => {
|
|
42
42
|
const tests: [string, string | null][] = [
|
|
43
|
-
[
|
|
44
|
-
[
|
|
45
|
-
[
|
|
46
|
-
[
|
|
47
|
-
[
|
|
48
|
-
[
|
|
49
|
-
[
|
|
50
|
-
[
|
|
51
|
-
[
|
|
52
|
-
[
|
|
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'],
|
|
53
53
|
];
|
|
54
54
|
|
|
55
55
|
tests.forEach((test, i) => {
|
|
@@ -58,21 +58,21 @@ describe("bearing", () => {
|
|
|
58
58
|
|
|
59
59
|
// calls custom invalid
|
|
60
60
|
const fn = jest.fn();
|
|
61
|
-
bearingStringValidator(
|
|
61
|
+
bearingStringValidator('1.2', fn);
|
|
62
62
|
expect(fn).toHaveBeenCalledWith(1.2);
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
-
test(
|
|
65
|
+
test('bearingRangeValidator', () => {
|
|
66
66
|
expect(bearingRangeValidator(0)).toBeNull();
|
|
67
67
|
expect(bearingRangeValidator(359.595999)).toBeNull();
|
|
68
|
-
expect(bearingRangeValidator(-0.00001)).toBe(
|
|
69
|
-
expect(bearingRangeValidator(360)).toBe(
|
|
68
|
+
expect(bearingRangeValidator(-0.00001)).toBe('Bearing must not be negative');
|
|
69
|
+
expect(bearingRangeValidator(360)).toBe('Bearing must be less than 360 degrees');
|
|
70
70
|
});
|
|
71
71
|
|
|
72
|
-
test(
|
|
72
|
+
test('bearingCorrectionRangeValidator', () => {
|
|
73
73
|
expect(bearingCorrectionRangeValidator(-179.59999)).toBeNull();
|
|
74
74
|
expect(bearingCorrectionRangeValidator(359.59999)).toBeNull();
|
|
75
|
-
expect(bearingCorrectionRangeValidator(-180)).toBe(
|
|
76
|
-
expect(bearingCorrectionRangeValidator(360)).toBe(
|
|
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
77
|
});
|
|
78
78
|
});
|
package/src/utils/bearing.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const bearingValueFormatter = (value: any): string => {
|
|
2
|
-
const safeValue = typeof 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 ===
|
|
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 ===
|
|
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 ===
|
|
31
|
+
if (value === '') return null;
|
|
32
32
|
const match = value.match(validMaskForDmsBearing);
|
|
33
|
-
if (!match) return
|
|
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
|
|
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,
|
|
79
|
-
const secString = secNumeric.toString().padStart(2,
|
|
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 ?
|
|
83
|
-
if (trailingZeroDp === 5 || deciSecString !=
|
|
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
|
|
95
|
-
if (value >= 360) return
|
|
96
|
-
if (value < 0) return
|
|
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
|
|
102
|
-
if (value >= 360) return
|
|
103
|
-
if (value <= -180) return
|
|
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 { expect, waitFor } from
|
|
1
|
+
import { expect, waitFor } from '@storybook/test';
|
|
2
2
|
|
|
3
3
|
export const waitForGridReady = ({ canvasElement }: { canvasElement: HTMLElement }) =>
|
|
4
|
-
waitFor(() => expect(canvasElement.querySelector(
|
|
4
|
+
waitFor(() => expect(canvasElement.querySelector('.Grid-ready')).toBeInTheDocument(), { timeout: 5000 });
|