@linzjs/step-ag-grid 31.2.5 → 32.1.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/index.css +5 -1
- package/dist/src/components/GridCell.d.ts +1 -1
- package/dist/src/components/GridLoadableCell.d.ts +1 -1
- package/dist/src/components/GridNoRowsOverlay.d.ts +1 -1
- package/dist/src/components/GridPopoverHook.d.ts +1 -1
- package/dist/src/components/gridFilter/GridFilterDownloadCsvButton.d.ts +1 -1
- package/dist/src/components/gridFilter/GridFilterQuick.d.ts +1 -1
- package/dist/src/components/gridFilter/GridFilters.d.ts +1 -1
- package/dist/src/components/gridForm/GridFormDropDown.d.ts +1 -1
- package/dist/src/components/gridForm/GridFormEditBearing.d.ts +1 -1
- package/dist/src/components/gridForm/GridFormInlineTextInput.d.ts +1 -1
- package/dist/src/components/gridForm/GridFormMultiSelect.d.ts +2 -2
- package/dist/src/components/gridForm/GridFormPopoverMenu.d.ts +1 -1
- package/dist/src/components/gridForm/GridFormTextInput.d.ts +1 -1
- package/dist/src/components/gridHeader/GridHeaderSelect.d.ts +1 -1
- package/dist/src/components/gridHook/useGridContextMenu.d.ts +1 -1
- package/dist/src/components/gridHook/useGridCopy.d.ts +1 -1
- package/dist/src/components/gridHook/useGridRangeSelection.d.ts +1 -1
- package/dist/src/components/gridRender/GridRenderPopoutMenuCell.d.ts +1 -1
- package/dist/src/components/types.d.ts +2 -0
- package/dist/src/contexts/GridPopoverContextProvider.d.ts +1 -1
- package/dist/src/contexts/GridUpdatingContextProvider.d.ts +1 -1
- package/dist/src/lui/FormError.d.ts +1 -1
- package/dist/src/lui/TextAreaInput.d.ts +1 -1
- package/dist/src/react-menu3/components/ControlledMenu.d.ts +1 -1
- package/dist/src/react-menu3/components/FocusableItem.d.ts +1 -1
- package/dist/src/react-menu3/components/Menu.d.ts +1 -1
- package/dist/src/react-menu3/components/MenuGroup.d.ts +1 -1
- package/dist/src/react-menu3/components/MenuHeader.d.ts +1 -1
- package/dist/src/react-menu3/components/MenuList.d.ts +1 -1
- package/dist/src/react-menu3/components/MenuRadioGroup.d.ts +1 -1
- package/dist/src/react-menu3/components/SubMenu.d.ts +1 -1
- package/dist/src/utils/useSharedInterval.d.ts +5 -0
- package/dist/step-ag-grid.cjs +259 -105
- package/dist/step-ag-grid.cjs.map +1 -1
- package/dist/step-ag-grid.esm.js +260 -106
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +29 -30
- package/src/components/Grid.tsx +6 -3
- package/src/components/gridForm/GridFormPopoverMenu.tsx +6 -2
- package/src/components/gridHook/useGridRangeSelection.ts +1 -1
- package/src/components/gridPopoverEdit/GridEditBoolean.tsx +64 -26
- package/src/components/gridPopoverEdit/GridPopoverMenu.tsx +3 -0
- package/src/components/types.ts +2 -0
- package/src/contexts/GridContextProvider.tsx +18 -5
- package/src/react-app-env.d.ts +4 -1
- package/src/stories/grid/GridFilterColumnsMultiSelect.stories.tsx +1 -1
- package/src/stories/grid/GridNonEditableRow.stories.tsx +2 -2
- package/src/stories/grid/GridPopoutEditBoolean.stories.tsx +48 -9
- package/src/stories/grid/GridReadOnly.stories.tsx +69 -0
- package/src/stories/grid/gridFormInteraction/GridFormDropDownInteraction.stories.tsx +1 -1
- package/src/stories/grid/gridFormInteraction/GridFormEditBearingCorrectionInteraction.stories.tsx +1 -1
- package/src/stories/grid/gridFormInteraction/GridFormEditBearingInteraction.stories.tsx +1 -1
- package/src/stories/grid/gridFormInteraction/GridFormMultiSelectGridInteraction.stories.tsx +1 -1
- package/src/stories/grid/gridFormInteraction/GridFormMultiSelectInteraction.stories.tsx +1 -1
- package/src/stories/grid/gridFormInteraction/GridFormPopoverMenuInteraction.stories.tsx +48 -1
- package/src/stories/grid/gridFormInteraction/GridFormTextAreaInteraction.stories.tsx +1 -1
- package/src/stories/grid/gridFormInteraction/GridFormTextInputInteraction.stories.tsx +1 -1
- package/src/stories/grid/gridFormStatic/GridFormDropDown.stories.tsx +1 -1
- package/src/stories/grid/gridFormStatic/GridFormEditBearing.stories.tsx +1 -1
- package/src/stories/grid/gridFormStatic/GridFormEditBearingCorrection.stories.tsx +1 -1
- package/src/stories/grid/gridFormStatic/GridFormMessage.stories.tsx +1 -1
- package/src/stories/grid/gridFormStatic/GridFormMultiSelect.stories.tsx +1 -1
- package/src/stories/grid/gridFormStatic/GridFormPopoverMenu.stories.tsx +1 -1
- package/src/stories/grid/gridFormStatic/GridFormTextArea.stories.tsx +1 -1
- package/src/stories/grid/gridFormStatic/GridFormTextInput.stories.tsx +1 -1
- package/src/styles/GridLoadableCell.scss +5 -1
- package/src/utils/useSharedInterval.ts +57 -0
- package/src/utils/util.ts +4 -2
|
@@ -4,7 +4,7 @@ import '@linzjs/lui/dist/scss/base.scss';
|
|
|
4
4
|
import '@linzjs/lui/dist/fonts';
|
|
5
5
|
|
|
6
6
|
import { StoryFn } from '@storybook/react-vite';
|
|
7
|
-
import { GridPopoverContext } from 'contexts/GridPopoverContext';
|
|
7
|
+
import { GridPopoverContext } from '../../../contexts/GridPopoverContext';
|
|
8
8
|
import { useRef } from 'react';
|
|
9
9
|
import * as test from 'storybook/test';
|
|
10
10
|
import { expect, userEvent, within } from 'storybook/test';
|
|
@@ -171,3 +171,50 @@ GridFormPopoverMenuInteractions_.play = async ({ canvasElement }) => {
|
|
|
171
171
|
await userEvent.type(textArea, '{Enter}');
|
|
172
172
|
expect(updateValue).not.toHaveBeenCalled();
|
|
173
173
|
};
|
|
174
|
+
|
|
175
|
+
const AllHiddenTemplate: StoryFn<typeof GridFormPopoverMenu> = (props: GridFormPopoverMenuProps<any>) => {
|
|
176
|
+
const anchorRef = useRef<HTMLHeadingElement>(null);
|
|
177
|
+
|
|
178
|
+
return (
|
|
179
|
+
<div className={'react-menu-inline-test'}>
|
|
180
|
+
<GridContextProvider>
|
|
181
|
+
<h6 ref={anchorRef}>Interaction Test</h6>
|
|
182
|
+
<GridPopoverContext.Provider
|
|
183
|
+
value={{
|
|
184
|
+
anchorRef,
|
|
185
|
+
value: null,
|
|
186
|
+
updateValue,
|
|
187
|
+
data: { value: '' },
|
|
188
|
+
colId: '',
|
|
189
|
+
field: 'value',
|
|
190
|
+
selectedRows: [],
|
|
191
|
+
saving: false,
|
|
192
|
+
setSaving: () => {},
|
|
193
|
+
formatValue: (value) => value,
|
|
194
|
+
stopEditing: () => {},
|
|
195
|
+
}}
|
|
196
|
+
>
|
|
197
|
+
<GridFormPopoverMenu
|
|
198
|
+
{...props}
|
|
199
|
+
options={() => [
|
|
200
|
+
{ label: 'Hidden one', value: 1, action: enabledAction, hidden: true },
|
|
201
|
+
{ label: 'Hidden two', value: 2, action: enabledAction, hidden: true },
|
|
202
|
+
]}
|
|
203
|
+
/>
|
|
204
|
+
</GridPopoverContext.Provider>
|
|
205
|
+
</GridContextProvider>
|
|
206
|
+
</div>
|
|
207
|
+
);
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
// Regression test: when every option resolves to hidden, the menu must show "No actions"
|
|
211
|
+
// rather than an empty menu body (isEmpty(options) alone doesn't catch this — the array is
|
|
212
|
+
// non-empty, just every item is hidden).
|
|
213
|
+
export const GridFormPopoverMenuAllOptionsHidden_ = AllHiddenTemplate.bind({});
|
|
214
|
+
GridFormPopoverMenuAllOptionsHidden_.play = async ({ canvasElement }) => {
|
|
215
|
+
const canvas = within(canvasElement);
|
|
216
|
+
|
|
217
|
+
expect(await canvas.findByText('No actions')).toBeInTheDocument();
|
|
218
|
+
expect(canvas.queryByRole('menuitem', { name: 'Hidden one' })).not.toBeInTheDocument();
|
|
219
|
+
expect(canvas.queryByRole('menuitem', { name: 'Hidden two' })).not.toBeInTheDocument();
|
|
220
|
+
};
|
|
@@ -4,7 +4,7 @@ import '@linzjs/lui/dist/scss/base.scss';
|
|
|
4
4
|
import '@linzjs/lui/dist/fonts';
|
|
5
5
|
|
|
6
6
|
import { StoryFn } from '@storybook/react-vite';
|
|
7
|
-
import { GridPopoverContext } from 'contexts/GridPopoverContext';
|
|
7
|
+
import { GridPopoverContext } from '../../../contexts/GridPopoverContext';
|
|
8
8
|
import { useRef } from 'react';
|
|
9
9
|
import { expect, fn, userEvent, within } from 'storybook/test';
|
|
10
10
|
|
|
@@ -4,7 +4,7 @@ import '@linzjs/lui/dist/scss/base.scss';
|
|
|
4
4
|
import '@linzjs/lui/dist/fonts';
|
|
5
5
|
|
|
6
6
|
import { StoryFn } from '@storybook/react-vite';
|
|
7
|
-
import { GridPopoverContext } from 'contexts/GridPopoverContext';
|
|
7
|
+
import { GridPopoverContext } from '../../../contexts/GridPopoverContext';
|
|
8
8
|
import { useRef } from 'react';
|
|
9
9
|
import { expect, fn, userEvent, within } from 'storybook/test';
|
|
10
10
|
|
|
@@ -4,7 +4,7 @@ import '@linzjs/lui/dist/scss/base.scss';
|
|
|
4
4
|
import '@linzjs/lui/dist/fonts';
|
|
5
5
|
|
|
6
6
|
import { Meta, StoryFn } from '@storybook/react-vite';
|
|
7
|
-
import { GridPopoverContext, GridPopoverContextType } from 'contexts/GridPopoverContext';
|
|
7
|
+
import { GridPopoverContext, GridPopoverContextType } from '../../../contexts/GridPopoverContext';
|
|
8
8
|
import { useRef } from 'react';
|
|
9
9
|
|
|
10
10
|
import { GridBaseRow, GridContextProvider, GridFormDropDown, GridFormDropDownProps, MenuHeaderItem } from '../../..';
|
|
@@ -4,7 +4,7 @@ import '@linzjs/lui/dist/scss/base.scss';
|
|
|
4
4
|
import '@linzjs/lui/dist/fonts';
|
|
5
5
|
|
|
6
6
|
import { Meta, StoryFn } from '@storybook/react-vite';
|
|
7
|
-
import { GridPopoverContext, GridPopoverContextType } from 'contexts/GridPopoverContext';
|
|
7
|
+
import { GridPopoverContext, GridPopoverContextType } from '../../../contexts/GridPopoverContext';
|
|
8
8
|
import { useRef } from 'react';
|
|
9
9
|
|
|
10
10
|
import {
|
|
@@ -4,7 +4,7 @@ import '@linzjs/lui/dist/scss/base.scss';
|
|
|
4
4
|
import '@linzjs/lui/dist/fonts';
|
|
5
5
|
|
|
6
6
|
import { Meta, StoryFn } from '@storybook/react-vite';
|
|
7
|
-
import { GridPopoverContext, GridPopoverContextType } from 'contexts/GridPopoverContext';
|
|
7
|
+
import { GridPopoverContext, GridPopoverContextType } from '../../../contexts/GridPopoverContext';
|
|
8
8
|
import { useRef } from 'react';
|
|
9
9
|
|
|
10
10
|
import {
|
|
@@ -4,7 +4,7 @@ import '@linzjs/lui/dist/scss/base.scss';
|
|
|
4
4
|
import '@linzjs/lui/dist/fonts';
|
|
5
5
|
|
|
6
6
|
import { Meta, StoryFn } from '@storybook/react-vite';
|
|
7
|
-
import { GridPopoverContext, GridPopoverContextType } from 'contexts/GridPopoverContext';
|
|
7
|
+
import { GridPopoverContext, GridPopoverContextType } from '../../../contexts/GridPopoverContext';
|
|
8
8
|
import { useRef } from 'react';
|
|
9
9
|
|
|
10
10
|
import { GridContextProvider, GridFormMessage, GridFormMessageProps } from '../../..';
|
|
@@ -4,7 +4,7 @@ import '@linzjs/lui/dist/scss/base.scss';
|
|
|
4
4
|
import '@linzjs/lui/dist/fonts';
|
|
5
5
|
|
|
6
6
|
import { Meta, StoryFn } from '@storybook/react-vite';
|
|
7
|
-
import { GridPopoverContext, GridPopoverContextType } from 'contexts/GridPopoverContext';
|
|
7
|
+
import { GridPopoverContext, GridPopoverContextType } from '../../../contexts/GridPopoverContext';
|
|
8
8
|
import { useRef } from 'react';
|
|
9
9
|
|
|
10
10
|
import { GridBaseRow, GridContextProvider, GridFormMultiSelect, GridFormMultiSelectProps } from '../../..';
|
|
@@ -4,7 +4,7 @@ import '@linzjs/lui/dist/scss/base.scss';
|
|
|
4
4
|
import '@linzjs/lui/dist/fonts';
|
|
5
5
|
|
|
6
6
|
import { Meta, StoryFn } from '@storybook/react-vite';
|
|
7
|
-
import { GridPopoverContext, GridPopoverContextType } from 'contexts/GridPopoverContext';
|
|
7
|
+
import { GridPopoverContext, GridPopoverContextType } from '../../../contexts/GridPopoverContext';
|
|
8
8
|
import { useRef } from 'react';
|
|
9
9
|
|
|
10
10
|
import {
|
|
@@ -4,7 +4,7 @@ import '@linzjs/lui/dist/scss/base.scss';
|
|
|
4
4
|
import '@linzjs/lui/dist/fonts';
|
|
5
5
|
|
|
6
6
|
import { Meta, StoryFn } from '@storybook/react-vite';
|
|
7
|
-
import { GridPopoverContext, GridPopoverContextType } from 'contexts/GridPopoverContext';
|
|
7
|
+
import { GridPopoverContext, GridPopoverContextType } from '../../../contexts/GridPopoverContext';
|
|
8
8
|
import { useRef } from 'react';
|
|
9
9
|
|
|
10
10
|
import { GridBaseRow, GridContextProvider, GridFormTextArea, GridFormTextAreaProps } from '../../..';
|
|
@@ -4,7 +4,7 @@ import '@linzjs/lui/dist/scss/base.scss';
|
|
|
4
4
|
import '@linzjs/lui/dist/fonts';
|
|
5
5
|
|
|
6
6
|
import { Meta, StoryFn } from '@storybook/react-vite';
|
|
7
|
-
import { GridPopoverContext, GridPopoverContextType } from 'contexts/GridPopoverContext';
|
|
7
|
+
import { GridPopoverContext, GridPopoverContextType } from '../../../contexts/GridPopoverContext';
|
|
8
8
|
import { useRef } from 'react';
|
|
9
9
|
|
|
10
10
|
import { GridBaseRow, GridContextProvider, GridFormTextInput, GridFormTextInputProps } from '../../..';
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
import { useIsomorphicLayoutEffect } from 'usehooks-ts';
|
|
3
|
+
|
|
4
|
+
type Callback = () => void;
|
|
5
|
+
|
|
6
|
+
const isNode = typeof process !== 'undefined' && process.env.NODE_ENV === 'test';
|
|
7
|
+
|
|
8
|
+
let sharedIntervalId: ReturnType<typeof setInterval> | null = null;
|
|
9
|
+
const callbacks = new Set<Callback>();
|
|
10
|
+
|
|
11
|
+
const startSharedInterval = () => {
|
|
12
|
+
if (isNode || sharedIntervalId !== null) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
sharedIntervalId = setInterval(() => {
|
|
16
|
+
callbacks.forEach((cb) => {
|
|
17
|
+
try {
|
|
18
|
+
cb();
|
|
19
|
+
} catch (e) {
|
|
20
|
+
console.error(e);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}, 100);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const stopSharedInterval = () => {
|
|
27
|
+
if (sharedIntervalId === null) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
clearInterval(sharedIntervalId);
|
|
31
|
+
sharedIntervalId = null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Like useInterval, but all callers share a single 100ms interval.
|
|
36
|
+
* Each callback is isolated in a try/catch so a throwing callback won't prevent others from running.
|
|
37
|
+
*/
|
|
38
|
+
export const useSharedInterval = (callback: () => void) => {
|
|
39
|
+
const savedCallback = useRef(callback);
|
|
40
|
+
|
|
41
|
+
useIsomorphicLayoutEffect(() => {
|
|
42
|
+
savedCallback.current = callback;
|
|
43
|
+
}, [callback]);
|
|
44
|
+
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
const cb = () => savedCallback.current();
|
|
47
|
+
callbacks.add(cb);
|
|
48
|
+
startSharedInterval();
|
|
49
|
+
|
|
50
|
+
return () => {
|
|
51
|
+
callbacks.delete(cb);
|
|
52
|
+
if (callbacks.size === 0) {
|
|
53
|
+
stopSharedInterval();
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}, []);
|
|
57
|
+
}
|
package/src/utils/util.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { isEmpty, negate } from 'lodash-es';
|
|
2
|
-
import
|
|
2
|
+
import natsortModule from 'natsort';
|
|
3
|
+
// natsort is a CJS module that sets exports.default, so interop wraps it in an extra layer
|
|
4
|
+
const natsort: typeof natsortModule = (natsortModule as any).default ?? natsortModule;
|
|
3
5
|
|
|
4
6
|
export type MaybePromise<T> = T | Promise<T>;
|
|
5
7
|
|
|
@@ -52,7 +54,7 @@ export const fnOrVar = (fn: any, param?: any) => (typeof fn === 'function' ? fn(
|
|
|
52
54
|
export const sanitiseFileName = (filename: string): string => {
|
|
53
55
|
const valid = filename
|
|
54
56
|
.trim()
|
|
55
|
-
.replaceAll(/(
|
|
57
|
+
.replaceAll(/([\/\\])+/g, '-')
|
|
56
58
|
.replaceAll(/\s+/g, '_')
|
|
57
59
|
.replaceAll(/[^\w\-āēīōūĀĒĪŌŪ.]/g, '');
|
|
58
60
|
const parts = valid.split('.');
|