@linzjs/step-ag-grid 30.4.3 → 31.1.1
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 +12 -7
- package/dist/index.css +6 -3
- package/dist/src/utils/__tests__/testQuick.ts +7 -7
- package/dist/src/utils/__tests__/testUtil.ts +3 -1
- package/dist/src/utils/__tests__/vitestUtil.ts +3 -1
- package/dist/src/utils/storybook.d.ts +4 -0
- package/dist/src/utils/useInterval.d.ts +17 -0
- package/dist/src/utils/useIsomorphicLayoutEffect.d.ts +17 -0
- package/dist/step-ag-grid.cjs +310 -214
- package/dist/step-ag-grid.cjs.map +1 -1
- package/dist/step-ag-grid.esm.js +310 -214
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +26 -52
- package/src/components/Grid.tsx +6 -3
- package/src/components/PostSortRowsHook.ts +3 -1
- package/src/components/gridFilter/GridFilterColumnsMultiSelect.scss +18 -20
- package/src/components/gridFilter/GridFilterColumnsToggle.tsx +3 -4
- package/src/components/gridFilter/useGridFilter.ts +2 -2
- package/src/components/gridForm/GridFormDropDown.tsx +1 -1
- package/src/components/gridForm/GridFormInlineTextInput.tsx +1 -2
- package/src/components/gridForm/GridFormMultiSelect.tsx +10 -4
- package/src/components/gridForm/GridFormSubComponentTextArea.tsx +1 -2
- package/src/components/gridForm/GridFormSubComponentTextInput.tsx +1 -2
- package/src/components/gridForm/GridFormTextArea.tsx +1 -2
- package/src/components/gridForm/GridFormTextInput.tsx +1 -2
- package/src/components/gridHeader/GridHeaderSelect.tsx +3 -1
- package/src/components/gridHook/useGridCopy.ts +13 -3
- package/src/components/gridHook/useGridRangeSelection.ts +29 -16
- package/src/contexts/GridContextProvider.tsx +18 -7
- package/src/lui/ActionButton.scss +1 -1
- package/src/lui/ActionButton.tsx +5 -1
- package/src/lui/FormError.scss +1 -1
- package/src/lui/TextAreaInput.tsx +1 -1
- package/src/lui/TextInputFormatted.scss +13 -13
- package/src/lui/TextInputFormatted.tsx +1 -1
- package/src/react-menu3/README.md +66 -67
- package/src/react-menu3/components/ControlledMenu.tsx +2 -2
- package/src/react-menu3/components/Menu.tsx +1 -1
- package/src/react-menu3/components/MenuItem.tsx +1 -1
- package/src/react-menu3/components/MenuList.tsx +8 -2
- package/src/react-menu3/components/SubMenu.tsx +6 -6
- package/src/react-menu3/hooks/useBEM.ts +2 -1
- package/src/react-menu3/hooks/useItemState.ts +8 -4
- package/src/react-menu3/styles/_var.scss +1 -1
- package/src/react-menu3/styles/core.scss +6 -6
- package/src/react-menu3/styles/index.scss +11 -8
- package/src/react-menu3/styles/theme-dark.scss +1 -1
- package/src/react-menu3/styles/transitions/slide.scss +8 -8
- package/src/react-menu3/utils/utils.ts +2 -1
- package/src/stories/grid/FormTest.scss +13 -13
- package/src/stories/grid/GridInlineText.stories.tsx +2 -2
- package/src/stories/grid/GridSorting.stories.tsx +6 -2
- package/src/stories/grid/GridViewSelectableList.stories.tsx +121 -0
- package/src/styles/ComponentLoadingWrapper.scss +1 -1
- package/src/styles/ContextMenu.scss +1 -1
- package/src/styles/Grid.scss +11 -9
- package/src/styles/GridCell.scss +1 -1
- package/src/styles/GridFilterColumnsToggle.scss +1 -1
- package/src/styles/GridFormInlineTextInput.scss +7 -7
- package/src/styles/GridFormMultiSelectGrid.scss +1 -1
- package/src/styles/GridFormSubComponentTextInput.scss +4 -4
- package/src/styles/GridIcon.scss +1 -1
- package/src/styles/GridPopoverMenu.scss +1 -1
- package/src/styles/GridTheme.scss +12 -7
- package/src/styles/index.scss +16 -16
- package/src/styles/react-menu-customisations.scss +119 -120
- package/src/utils/__tests__/testQuick.ts +7 -7
- package/src/utils/__tests__/testUtil.ts +3 -1
- package/src/utils/__tests__/vitestUtil.ts +3 -1
- package/src/utils/deferredPromise.ts +1 -1
- package/src/utils/storybook.ts +5 -0
- package/src/utils/useInterval.ts +44 -0
- package/src/utils/useIsomorphicLayoutEffect.ts +18 -0
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@linzjs/step-ag-grid",
|
|
3
3
|
"repository": "github:linz/step-ag-grid.git",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "
|
|
5
|
+
"version": "31.1.1",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"aggrid",
|
|
8
8
|
"ag-grid",
|
|
@@ -40,21 +40,21 @@
|
|
|
40
40
|
"matcher": "^5.0.0",
|
|
41
41
|
"natsort": "^2.0.3",
|
|
42
42
|
"react-transition-state": "^2.3.1",
|
|
43
|
-
"usehooks-ts": "^3.1.1"
|
|
44
|
-
"uuid": "^13.0.0"
|
|
43
|
+
"usehooks-ts": "^3.1.1"
|
|
45
44
|
},
|
|
46
45
|
"scripts": {
|
|
47
|
-
"build": "run-s clean
|
|
46
|
+
"build": "node --eval \"fs.mkdirSync('./dist', { recursive: true })\" && run-s clean lintall css bundle",
|
|
48
47
|
"yalc": "run-s clean css bundle && yalc push",
|
|
49
|
-
"clean": "
|
|
48
|
+
"clean": "node -e \"fs.rmSync('dist', { recursive: true, force: true })\"",
|
|
50
49
|
"bundle": "rollup -c",
|
|
51
50
|
"css": "sass ./src/styles/index.scss:dist/index.css --no-source-map",
|
|
52
|
-
"test": "cross-env
|
|
51
|
+
"test": "cross-env vitest run",
|
|
53
52
|
"test:watch": "vitest --watch",
|
|
54
|
-
"
|
|
55
|
-
"lint:
|
|
56
|
-
"lint:
|
|
57
|
-
"
|
|
53
|
+
"lintall": "run-s lint:oxlint",
|
|
54
|
+
"lint:oxlint": "oxlint ./src",
|
|
55
|
+
"lint:fix": "oxlint ./src --fix",
|
|
56
|
+
"format": "oxfmt --write ./src",
|
|
57
|
+
"format:check": "oxfmt --check ./src",
|
|
58
58
|
"storybook": "storybook dev -p 6006",
|
|
59
59
|
"build-storybook": "storybook build",
|
|
60
60
|
"deploy-storybook": "npx --yes -p @storybook/storybook-deployer storybook-to-ghpages",
|
|
@@ -62,11 +62,6 @@
|
|
|
62
62
|
"upgrade": "npx ncu -i --format group",
|
|
63
63
|
"prepare": "husky"
|
|
64
64
|
},
|
|
65
|
-
"eslintConfig": {
|
|
66
|
-
"extends": [
|
|
67
|
-
"react-app"
|
|
68
|
-
]
|
|
69
|
-
},
|
|
70
65
|
"browserslist": {
|
|
71
66
|
"production": [
|
|
72
67
|
">0.2%",
|
|
@@ -79,74 +74,53 @@
|
|
|
79
74
|
"last 1 safari version"
|
|
80
75
|
]
|
|
81
76
|
},
|
|
82
|
-
"optionalDependencies": {
|
|
83
|
-
"@rollup/rollup-linux-x64-gnu": "^4.53.3",
|
|
84
|
-
"@swc/core-linux-x64-gnu": "^1.15.3"
|
|
85
|
-
},
|
|
86
77
|
"devDependencies": {
|
|
87
78
|
"@chromatic-com/storybook": "^4.1.3",
|
|
88
79
|
"@linzjs/lui": "^24.3.1",
|
|
89
|
-
"@linzjs/
|
|
90
|
-
"@linzjs/windows": "^8.6.3",
|
|
80
|
+
"@linzjs/windows": "^9.5.6",
|
|
91
81
|
"@rollup/plugin-commonjs": "^28.0.9",
|
|
92
82
|
"@rollup/plugin-json": "^6.1.0",
|
|
93
83
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
94
|
-
"@storybook/addon-docs": "^9.1.
|
|
95
|
-
"@storybook/addon-links": "^9.1.
|
|
96
|
-
"@storybook/react": "^9.1.
|
|
97
|
-
"@storybook/react-vite": "^9.1.
|
|
84
|
+
"@storybook/addon-docs": "^9.1.20",
|
|
85
|
+
"@storybook/addon-links": "^9.1.20",
|
|
86
|
+
"@storybook/react": "^9.1.20",
|
|
87
|
+
"@storybook/react-vite": "^9.1.20",
|
|
98
88
|
"@testing-library/dom": "^10.4.1",
|
|
99
89
|
"@testing-library/react": "^16.3.0",
|
|
100
90
|
"@testing-library/user-event": "^14.6.1",
|
|
101
91
|
"@types/debounce-promise": "^3.1.9",
|
|
102
|
-
"@types/
|
|
92
|
+
"@types/jest": "^30.0.0",
|
|
93
|
+
"@types/jsdom": "^28.0.1",
|
|
103
94
|
"@types/lodash-es": "^4.17.12",
|
|
104
95
|
"@types/node": "^22.19.2",
|
|
105
96
|
"@types/react": "^18.3.27",
|
|
106
97
|
"@types/react-dom": "^18.3.7",
|
|
107
|
-
"@types/uuid": "^11.0.0",
|
|
108
98
|
"@vitejs/plugin-react-swc": "^3.11.0",
|
|
109
99
|
"@vitest/ui": "^3.2.4",
|
|
110
|
-
"babel-preset-react-app": "^10.1.0",
|
|
111
|
-
"canvas": "^3.2.0",
|
|
112
100
|
"chromatic": "^13.3.4",
|
|
113
101
|
"cross-env": "^10.1.0",
|
|
114
|
-
"css-loader": "^7.1.2",
|
|
115
|
-
"eslint-plugin-react": "^7.37.5",
|
|
116
|
-
"eslint-plugin-storybook": "^9.1.17",
|
|
117
102
|
"husky": "^9.1.7",
|
|
118
|
-
"jsdom": "
|
|
119
|
-
"lodash-es": "^4.
|
|
120
|
-
"mkdirp": "^3.0.1",
|
|
103
|
+
"jsdom": "28.1.0",
|
|
104
|
+
"lodash-es": "^4.18.1",
|
|
121
105
|
"npm-run-all": "^4.1.5",
|
|
122
|
-
"
|
|
123
|
-
"
|
|
106
|
+
"oxfmt": "^0.44.0",
|
|
107
|
+
"oxlint": "^1.59.0",
|
|
108
|
+
"postcss": "^8.5.8",
|
|
124
109
|
"postcss-scss": "^4.0.9",
|
|
125
110
|
"react": ">=18",
|
|
126
|
-
"react-app-polyfill": "^3.0.0",
|
|
127
111
|
"react-dom": "^18.3.1",
|
|
128
|
-
"
|
|
129
|
-
"rollup": "^4.53.3",
|
|
112
|
+
"rollup": "^4.60.1",
|
|
130
113
|
"rollup-plugin-copy": "^3.5.0",
|
|
131
114
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
132
115
|
"rollup-plugin-postcss": "^4.0.2",
|
|
133
|
-
"rollup-plugin-typescript2": "^0.
|
|
116
|
+
"rollup-plugin-typescript2": "^0.37.0",
|
|
134
117
|
"sass": "^1.96.0",
|
|
135
|
-
"
|
|
136
|
-
"storybook": "^9.1.17",
|
|
137
|
-
"storybook-css-modules-preset": "^1.1.1",
|
|
138
|
-
"style-loader": "^4.0.0",
|
|
118
|
+
"storybook": "^9.1.20",
|
|
139
119
|
"typescript": "^5.9.3",
|
|
140
|
-
"vite": "^7.2
|
|
141
|
-
"vite-plugin-html": "^3.2.2",
|
|
120
|
+
"vite": "^7.3.2",
|
|
142
121
|
"vite-tsconfig-paths": "^5.1.4",
|
|
143
122
|
"vitest": "^3.2.4"
|
|
144
123
|
},
|
|
145
|
-
"babel": {
|
|
146
|
-
"presets": [
|
|
147
|
-
"react-app"
|
|
148
|
-
]
|
|
149
|
-
},
|
|
150
124
|
"husky": {
|
|
151
125
|
"hooks": {
|
|
152
126
|
"pre-commit": "npm run lint"
|
package/src/components/Grid.tsx
CHANGED
|
@@ -31,10 +31,11 @@ import { AgGridReact } from 'ag-grid-react';
|
|
|
31
31
|
import clsx from 'clsx';
|
|
32
32
|
import { defer, delay, difference, isEmpty, last, omit, xorBy } from 'lodash-es';
|
|
33
33
|
import { ReactElement, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
34
|
-
import { useInterval } from 'usehooks-ts';
|
|
35
34
|
|
|
36
35
|
import { AutoSizeColumnsResult, StartCellEditingProps, useGridContext } from '../contexts/GridContext';
|
|
37
36
|
import { GridUpdatingContext } from '../contexts/GridUpdatingContext';
|
|
37
|
+
import { isStorybook } from '../utils/storybook';
|
|
38
|
+
import { useInterval } from '../utils/useInterval';
|
|
38
39
|
import { compareNaturalInsensitive, fnOrVar, isNotEmpty } from '../utils/util';
|
|
39
40
|
import { clickInputWhenContainingCellClicked } from './clickInputWhenContainingCellClicked';
|
|
40
41
|
import { GridHeaderSelect } from './gridHeader';
|
|
@@ -353,7 +354,9 @@ export const Grid = <TData extends GridBaseRow = GridBaseRow>({
|
|
|
353
354
|
if (autoSelectFirstRow && selectable) {
|
|
354
355
|
selectRowsById([firstRowId]);
|
|
355
356
|
} else {
|
|
356
|
-
|
|
357
|
+
if (!isStorybook) {
|
|
358
|
+
focusByRowById(firstRowId, true);
|
|
359
|
+
}
|
|
357
360
|
}
|
|
358
361
|
}
|
|
359
362
|
}, [
|
|
@@ -777,7 +780,7 @@ export const Grid = <TData extends GridBaseRow = GridBaseRow>({
|
|
|
777
780
|
const adjustedColDef = {
|
|
778
781
|
...colDef,
|
|
779
782
|
// You cannot pass a width to a flex
|
|
780
|
-
width:
|
|
783
|
+
width: colDef.flex ? undefined : colDef.width,
|
|
781
784
|
...(!!colDef.flex && { flexAutoSizeWidth: colDef.width }),
|
|
782
785
|
// If this is allowed flex columns don't size based on flex
|
|
783
786
|
suppressSizeToFit: true,
|
|
@@ -160,7 +160,9 @@ export const usePostSortRowsHook = ({ setStaleGrid }: PostSortRowsHookProps) =>
|
|
|
160
160
|
};
|
|
161
161
|
wasStale = true;
|
|
162
162
|
// For some reason AgGrid mis-positions the inserted row.
|
|
163
|
-
|
|
163
|
+
if (lastNewNode) {
|
|
164
|
+
redrawRows();
|
|
165
|
+
}
|
|
164
166
|
} else if (changedRowCount == 1 && newRowCount === 0) {
|
|
165
167
|
// User edited one row so, do nothing, retain sort
|
|
166
168
|
wasStale = true;
|
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
@use
|
|
1
|
+
@use '@linzjs/lui/dist/scss/Core' as lui;
|
|
2
2
|
|
|
3
3
|
.GridFilterColsMultiSelect {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
background: #fff;
|
|
5
|
+
padding: 8px;
|
|
6
|
+
@include lui.font-semibold();
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
.LuiSelect-label-text {
|
|
9
|
+
color: lui.$fuscous;
|
|
10
|
+
display: inline-block;
|
|
11
|
+
}
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
}
|
|
13
|
+
.LuiCheckboxInput-selectAll,
|
|
14
|
+
.LuiCheckboxInput-item {
|
|
15
|
+
color: lui.$charcoal;
|
|
16
|
+
margin-bottom: 0;
|
|
17
|
+
font-weight: 600;
|
|
18
|
+
font-size: 16px;
|
|
19
|
+
line-height: 24px;
|
|
20
|
+
letter-spacing: 0;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -45,7 +45,7 @@ export const GridFilterColumnsToggle = ({ saveState = true }: GridFilterColumnsT
|
|
|
45
45
|
} else if (!invisibleIds.every((id) => typeof id === 'string')) {
|
|
46
46
|
console.error(`stored invisible ids not strings: ${stored}`);
|
|
47
47
|
} else {
|
|
48
|
-
invisibleIds
|
|
48
|
+
if (invisibleIds) setInvisibleColumnIds(invisibleIds);
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
} catch (ex) {
|
|
@@ -57,10 +57,9 @@ export const GridFilterColumnsToggle = ({ saveState = true }: GridFilterColumnsT
|
|
|
57
57
|
|
|
58
58
|
// Save state on column visibility change
|
|
59
59
|
useEffect(() => {
|
|
60
|
-
loaded &&
|
|
61
|
-
columnStorageKey &&
|
|
62
|
-
saveState &&
|
|
60
|
+
if (loaded && columnStorageKey && saveState) {
|
|
63
61
|
window.localStorage.setItem(columnStorageKey, JSON.stringify(invisibleColumnIds));
|
|
62
|
+
}
|
|
64
63
|
}, [columnStorageKey, invisibleColumnIds, loaded, saveState]);
|
|
65
64
|
|
|
66
65
|
const toggleColumn = useCallback(
|
|
@@ -8,9 +8,9 @@ export const useGridFilter = <TData extends GridBaseRow>(filter: GridFilterExter
|
|
|
8
8
|
|
|
9
9
|
useEffect(() => {
|
|
10
10
|
const thisFilter = filter;
|
|
11
|
-
thisFilter
|
|
11
|
+
if (thisFilter) addExternalFilter(thisFilter);
|
|
12
12
|
return () => {
|
|
13
|
-
thisFilter
|
|
13
|
+
if (thisFilter) removeExternalFilter(thisFilter);
|
|
14
14
|
};
|
|
15
15
|
}, [addExternalFilter, filter, removeExternalFilter]);
|
|
16
16
|
};
|
|
@@ -50,7 +50,7 @@ export type SelectOption<TOptionValue = any> = FinalSelectOption<TOptionValue>;
|
|
|
50
50
|
export interface GridFormDropDownProps<TData extends GridBaseRow, TOptionValue> extends CellEditorCommon {
|
|
51
51
|
// This overrides CellEditorCommon to provide some common class options
|
|
52
52
|
className?: // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
|
53
|
-
|
|
53
|
+
| 'GridPopoverEditDropDown-containerSmall'
|
|
54
54
|
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
|
55
55
|
| 'GridPopoverEditDropDown-containerMedium'
|
|
56
56
|
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
|
@@ -11,8 +11,7 @@ import { useGridPopoverHook } from '../GridPopoverHook';
|
|
|
11
11
|
import { GridBaseRow } from '../types';
|
|
12
12
|
|
|
13
13
|
export interface GridFormInlineTextInput<TData extends GridBaseRow>
|
|
14
|
-
extends TextInputValidatorProps<TData>,
|
|
15
|
-
CellEditorCommon {
|
|
14
|
+
extends TextInputValidatorProps<TData>, CellEditorCommon {
|
|
16
15
|
placeholder?: string;
|
|
17
16
|
units?: string;
|
|
18
17
|
onSave?: (props: { selectedRows: TData[]; selectedRowIds: TData['id'][]; value: string }) => MaybePromise<boolean>;
|
|
@@ -51,7 +51,7 @@ export interface GridFormMultiSelectSaveProps<TData extends GridBaseRow> {
|
|
|
51
51
|
|
|
52
52
|
export interface GridFormMultiSelectProps<TData extends GridBaseRow> extends CellEditorCommon {
|
|
53
53
|
className?: // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
|
54
|
-
|
|
54
|
+
| 'GridMultiSelect-containerSmall'
|
|
55
55
|
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
|
56
56
|
| 'GridMultiSelect-containerMedium'
|
|
57
57
|
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
|
@@ -322,11 +322,15 @@ const FilterInput = (props: {
|
|
|
322
322
|
void triggerSave();
|
|
323
323
|
return;
|
|
324
324
|
}
|
|
325
|
-
|
|
325
|
+
if (onSelectFilter) {
|
|
326
|
+
addCustomFilterValue();
|
|
327
|
+
}
|
|
326
328
|
}
|
|
327
329
|
lastKeyWasEnter.current = true;
|
|
328
330
|
} else if (e.key === 'Control') {
|
|
329
|
-
lastKeyWasEnter.current
|
|
331
|
+
if (lastKeyWasEnter.current) {
|
|
332
|
+
setFilter('');
|
|
333
|
+
}
|
|
330
334
|
lastKeyWasEnter.current = false;
|
|
331
335
|
} else {
|
|
332
336
|
lastKeyWasEnter.current = false;
|
|
@@ -392,7 +396,9 @@ const MenuRadioItem = (props: {
|
|
|
392
396
|
e.keepOpen = true;
|
|
393
397
|
toggleValue(item);
|
|
394
398
|
}
|
|
395
|
-
item.checked
|
|
399
|
+
if (item.checked) {
|
|
400
|
+
props.onChecked?.();
|
|
401
|
+
}
|
|
396
402
|
}}
|
|
397
403
|
>
|
|
398
404
|
<LuiCheckboxInput
|
|
@@ -8,8 +8,7 @@ import { CellEditorCommon } from '../GridCell';
|
|
|
8
8
|
import { GridBaseRow } from '../types';
|
|
9
9
|
|
|
10
10
|
export interface GridSubComponentTextAreaProps<TData extends GridBaseRow>
|
|
11
|
-
extends TextInputValidatorProps<TData>,
|
|
12
|
-
CellEditorCommon {
|
|
11
|
+
extends TextInputValidatorProps<TData>, CellEditorCommon {
|
|
13
12
|
placeholder?: string;
|
|
14
13
|
width?: string | number;
|
|
15
14
|
defaultValue: string;
|
|
@@ -7,8 +7,7 @@ import { CellEditorCommon } from '../GridCell';
|
|
|
7
7
|
import { GridBaseRow } from '../types';
|
|
8
8
|
|
|
9
9
|
export interface GridFormSubComponentTextInputProps<TData extends GridBaseRow>
|
|
10
|
-
extends TextInputValidatorProps<TData>,
|
|
11
|
-
CellEditorCommon {
|
|
10
|
+
extends TextInputValidatorProps<TData>, CellEditorCommon {
|
|
12
11
|
placeholder?: string;
|
|
13
12
|
width?: string | number;
|
|
14
13
|
defaultValue: string;
|
|
@@ -8,8 +8,7 @@ import { useGridPopoverHook } from '../GridPopoverHook';
|
|
|
8
8
|
import { GridBaseRow } from '../types';
|
|
9
9
|
|
|
10
10
|
export interface GridFormTextAreaProps<TData extends GridBaseRow>
|
|
11
|
-
extends TextInputValidatorProps<TData>,
|
|
12
|
-
CellEditorCommon {
|
|
11
|
+
extends TextInputValidatorProps<TData>, CellEditorCommon {
|
|
13
12
|
placeholder?: string;
|
|
14
13
|
width?: string | number;
|
|
15
14
|
onSave?: (props: { selectedRows: TData[]; value: string }) => Promise<boolean>;
|
|
@@ -8,8 +8,7 @@ import { useGridPopoverHook } from '../GridPopoverHook';
|
|
|
8
8
|
import { GridBaseRow } from '../types';
|
|
9
9
|
|
|
10
10
|
export interface GridFormTextInputProps<TData extends GridBaseRow>
|
|
11
|
-
extends TextInputValidatorProps<TData>,
|
|
12
|
-
CellEditorCommon {
|
|
11
|
+
extends TextInputValidatorProps<TData>, CellEditorCommon {
|
|
13
12
|
placeholder?: string;
|
|
14
13
|
units?: string;
|
|
15
14
|
width?: string | number;
|
|
@@ -19,7 +19,9 @@ export const GridHeaderSelect = ({ api }: IHeaderParams) => {
|
|
|
19
19
|
|
|
20
20
|
api.addEventListener('selectionChanged', clickHandler);
|
|
21
21
|
return () => {
|
|
22
|
-
!api.isDestroyed()
|
|
22
|
+
if (!api.isDestroyed()) {
|
|
23
|
+
api.removeEventListener('selectionChanged', clickHandler);
|
|
24
|
+
}
|
|
23
25
|
};
|
|
24
26
|
}, [api, updateCounter]);
|
|
25
27
|
|
|
@@ -219,7 +219,17 @@ export const useGridCopy = <TData extends GridBaseRow>({
|
|
|
219
219
|
void navigator.clipboard.writeText(result).catch((err) => console.error('Failed to copy: ', err));
|
|
220
220
|
}
|
|
221
221
|
},
|
|
222
|
-
[
|
|
222
|
+
[
|
|
223
|
+
getCellValue,
|
|
224
|
+
ranges,
|
|
225
|
+
copyType,
|
|
226
|
+
rangeStartRef,
|
|
227
|
+
hasSelectedMoreThanOneCellRef,
|
|
228
|
+
rangeEndRef,
|
|
229
|
+
showToast,
|
|
230
|
+
getColDef,
|
|
231
|
+
getSelectedRowIds,
|
|
232
|
+
],
|
|
223
233
|
);
|
|
224
234
|
|
|
225
235
|
const onCopyEvent = useCallback(
|
|
@@ -240,7 +250,7 @@ export const useGridCopy = <TData extends GridBaseRow>({
|
|
|
240
250
|
|
|
241
251
|
onCopy();
|
|
242
252
|
},
|
|
243
|
-
[onCopy],
|
|
253
|
+
[onCopy, rangeStartRef, rangeEndRef, hasSelectedMoreThanOneCellRef],
|
|
244
254
|
);
|
|
245
255
|
|
|
246
256
|
const { cellContextMenu: rangeSelectContextMenu, contextMenuComponent: rangeSelectContextMenuComponent } =
|
|
@@ -255,7 +265,7 @@ export const useGridCopy = <TData extends GridBaseRow>({
|
|
|
255
265
|
? rangeSelectContextMenu(event)
|
|
256
266
|
: cellContextMenu(event);
|
|
257
267
|
},
|
|
258
|
-
[cellContextMenu, rangeSelectContextMenu],
|
|
268
|
+
[cellContextMenu, rangeSelectContextMenu, rangeStartRef, hasSelectedMoreThanOneCellRef],
|
|
259
269
|
);
|
|
260
270
|
|
|
261
271
|
return {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CellMouseDownEvent, CellMouseOverEvent, IRowNode } from 'ag-grid-community';
|
|
2
2
|
import { MutableRefObject, RefObject, useCallback, useEffect, useRef, useState } from 'react';
|
|
3
|
-
import { useInterval } from 'usehooks-ts';
|
|
4
3
|
|
|
4
|
+
import { useInterval } from '../../utils/useInterval';
|
|
5
5
|
import { GridBaseRow } from '../types';
|
|
6
6
|
|
|
7
7
|
export interface CellLocation {
|
|
@@ -79,7 +79,7 @@ export const useGridRangeSelection = <TData extends GridBaseRow>({
|
|
|
79
79
|
);
|
|
80
80
|
|
|
81
81
|
return { selectedColIds, selectedNodes };
|
|
82
|
-
}, []);
|
|
82
|
+
}, [gridDivRef, rangeSortedNodesRef, rangeStartRef, rangeEndRef]);
|
|
83
83
|
|
|
84
84
|
const redrawSelectedRanges = useCallback(() => {
|
|
85
85
|
const gridElement = gridDivRef.current!;
|
|
@@ -106,7 +106,7 @@ export const useGridRangeSelection = <TData extends GridBaseRow>({
|
|
|
106
106
|
}
|
|
107
107
|
});
|
|
108
108
|
});
|
|
109
|
-
}, []);
|
|
109
|
+
}, [ranges, gridDivRef]);
|
|
110
110
|
|
|
111
111
|
const updateRangeSelectionCellClasses = useCallback(
|
|
112
112
|
(justRefresh?: boolean) => {
|
|
@@ -158,7 +158,7 @@ export const useGridRangeSelection = <TData extends GridBaseRow>({
|
|
|
158
158
|
|
|
159
159
|
redrawSelectedRanges();
|
|
160
160
|
},
|
|
161
|
-
[
|
|
161
|
+
[redrawSelectedRanges, rangeStartRef, rangeEndRef, gridDivRef, hasSelectedMoreThanOneCellRef, rangeSortedNodesRef],
|
|
162
162
|
);
|
|
163
163
|
|
|
164
164
|
// Handle updates after scroll / grid refresh
|
|
@@ -178,18 +178,24 @@ export const useGridRangeSelection = <TData extends GridBaseRow>({
|
|
|
178
178
|
rangeEndRef.current = null;
|
|
179
179
|
|
|
180
180
|
updateRangeSelectionCellClasses();
|
|
181
|
-
}, [updateRangeSelectionCellClasses]);
|
|
181
|
+
}, [updateRangeSelectionCellClasses, hasSelectedMoreThanOneCellRef, rangeStartRef, rangeEndRef]);
|
|
182
182
|
|
|
183
183
|
const mouseDownRef = useRef<[number, number]>([0, 0]);
|
|
184
|
-
const trackMouseDown = useCallback(
|
|
185
|
-
|
|
186
|
-
|
|
184
|
+
const trackMouseDown = useCallback(
|
|
185
|
+
(e: MouseEvent) => {
|
|
186
|
+
mouseDownRef.current = [e.screenX, e.screenY];
|
|
187
|
+
},
|
|
188
|
+
[mouseDownRef],
|
|
189
|
+
);
|
|
187
190
|
|
|
188
|
-
const trackMouseUp = useCallback(
|
|
189
|
-
|
|
190
|
-
rangeEndRef.current
|
|
191
|
-
|
|
192
|
-
|
|
191
|
+
const trackMouseUp = useCallback(
|
|
192
|
+
(e: MouseEvent) => {
|
|
193
|
+
if (rangeEndRef.current) {
|
|
194
|
+
rangeEndRef.current.clickLocation = [e.screenX, e.screenY];
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
[rangeEndRef],
|
|
198
|
+
);
|
|
193
199
|
|
|
194
200
|
useEffect(() => {
|
|
195
201
|
document.addEventListener('mousedown', trackMouseDown, { capture: true });
|
|
@@ -198,7 +204,7 @@ export const useGridRangeSelection = <TData extends GridBaseRow>({
|
|
|
198
204
|
document.removeEventListener('mousemove', trackMouseDown, { capture: true });
|
|
199
205
|
document.removeEventListener('mouseup', trackMouseUp, { capture: true });
|
|
200
206
|
};
|
|
201
|
-
}, []);
|
|
207
|
+
}, [trackMouseDown, trackMouseUp]);
|
|
202
208
|
|
|
203
209
|
const onCellMouseOver = useCallback(
|
|
204
210
|
(e: CellMouseOverEvent, mouseDown?: boolean) => {
|
|
@@ -238,7 +244,14 @@ export const useGridRangeSelection = <TData extends GridBaseRow>({
|
|
|
238
244
|
|
|
239
245
|
updateRangeSelectionCellClasses();
|
|
240
246
|
},
|
|
241
|
-
[
|
|
247
|
+
[
|
|
248
|
+
enableRangeSelection,
|
|
249
|
+
updateRangeSelectionCellClasses,
|
|
250
|
+
hasSelectedMoreThanOneCellRef,
|
|
251
|
+
rangeEndRef,
|
|
252
|
+
rangeSortedNodesRef,
|
|
253
|
+
rangeStartRef,
|
|
254
|
+
],
|
|
242
255
|
);
|
|
243
256
|
|
|
244
257
|
const onCellMouseDown = useCallback(
|
|
@@ -249,7 +262,7 @@ export const useGridRangeSelection = <TData extends GridBaseRow>({
|
|
|
249
262
|
}
|
|
250
263
|
onCellMouseOver(e as unknown as CellMouseOverEvent, true);
|
|
251
264
|
},
|
|
252
|
-
[onCellMouseOver],
|
|
265
|
+
[onCellMouseOver, clearRangeSelection],
|
|
253
266
|
);
|
|
254
267
|
|
|
255
268
|
return { clearRangeSelection, ranges, onCellMouseDown, onCellMouseOver };
|
|
@@ -122,7 +122,7 @@ export const GridContextProvider = <TData extends GridBaseRow>(props: PropsWithC
|
|
|
122
122
|
// this is the only way to get out of the loop
|
|
123
123
|
throw 'expected exception - exit_loop';
|
|
124
124
|
});
|
|
125
|
-
} catch
|
|
125
|
+
} catch {
|
|
126
126
|
// ignore
|
|
127
127
|
}
|
|
128
128
|
return id;
|
|
@@ -312,7 +312,7 @@ export const GridContextProvider = <TData extends GridBaseRow>(props: PropsWithC
|
|
|
312
312
|
const colId = col.colId;
|
|
313
313
|
// We need to make sure we aren't currently editing a cell otherwise tests will fail
|
|
314
314
|
// as they will start to edit the cell before this stuff has a chance to run
|
|
315
|
-
colId
|
|
315
|
+
if (colId) {
|
|
316
316
|
delay(() => {
|
|
317
317
|
if (
|
|
318
318
|
!gridApi.isDestroyed() &&
|
|
@@ -326,6 +326,7 @@ export const GridContextProvider = <TData extends GridBaseRow>(props: PropsWithC
|
|
|
326
326
|
gridApi.setFocusedCell(rowIndex, agGridSelectRowColId);
|
|
327
327
|
}
|
|
328
328
|
}, 100);
|
|
329
|
+
}
|
|
329
330
|
}
|
|
330
331
|
}
|
|
331
332
|
}
|
|
@@ -342,7 +343,9 @@ export const GridContextProvider = <TData extends GridBaseRow>(props: PropsWithC
|
|
|
342
343
|
if (flash) {
|
|
343
344
|
delay(() => {
|
|
344
345
|
try {
|
|
345
|
-
!gridApi.isDestroyed()
|
|
346
|
+
if (!gridApi.isDestroyed()) {
|
|
347
|
+
gridApi.flashCells({ rowNodes });
|
|
348
|
+
}
|
|
346
349
|
} catch {
|
|
347
350
|
// ignore, flash cells sometimes throws errors as nodes have gone out of scope
|
|
348
351
|
}
|
|
@@ -749,7 +752,9 @@ export const GridContextProvider = <TData extends GridBaseRow>(props: PropsWithC
|
|
|
749
752
|
// }
|
|
750
753
|
|
|
751
754
|
// This is needed to trigger postSortRowsHook
|
|
752
|
-
!gridApi.isDestroyed
|
|
755
|
+
if (!gridApi.isDestroyed) {
|
|
756
|
+
gridApi.refreshClientSideRowModel();
|
|
757
|
+
}
|
|
753
758
|
}
|
|
754
759
|
|
|
755
760
|
void (async () => {
|
|
@@ -782,7 +787,9 @@ export const GridContextProvider = <TData extends GridBaseRow>(props: PropsWithC
|
|
|
782
787
|
() =>
|
|
783
788
|
debounce((rowNodes?: IRowNode[]) => {
|
|
784
789
|
try {
|
|
785
|
-
|
|
790
|
+
if (gridApi) {
|
|
791
|
+
gridApi.redrawRows(rowNodes ? { rowNodes } : undefined);
|
|
792
|
+
}
|
|
786
793
|
} catch (ex) {
|
|
787
794
|
console.error(ex);
|
|
788
795
|
}
|
|
@@ -812,7 +819,9 @@ export const GridContextProvider = <TData extends GridBaseRow>(props: PropsWithC
|
|
|
812
819
|
const postHash = hasFocusedCell && getDisplayedRowsHash();
|
|
813
820
|
// Ag-grid has a bug where if a focused cell comes into view after a filter the filter loses focus
|
|
814
821
|
// So the focus is cleared to prevent this
|
|
815
|
-
preHash !== postHash
|
|
822
|
+
if (preHash !== postHash) {
|
|
823
|
+
gridApi.clearFocusedCell();
|
|
824
|
+
}
|
|
816
825
|
}
|
|
817
826
|
}, 200),
|
|
818
827
|
[gridApi],
|
|
@@ -864,7 +873,9 @@ export const GridContextProvider = <TData extends GridBaseRow>(props: PropsWithC
|
|
|
864
873
|
const visibleColumnsContainsAFlex = newVisibleColumns.some(isFlexColumn);
|
|
865
874
|
if (!visibleColumnsContainsAFlex) {
|
|
866
875
|
const fillerColumn = getColumns(isGridCellFiller)[0];
|
|
867
|
-
|
|
876
|
+
if (fillerColumn) {
|
|
877
|
+
newVisibleColumns.push(fillerColumn);
|
|
878
|
+
}
|
|
868
879
|
}
|
|
869
880
|
gridApi.setColumnsVisible(compact(newVisibleColumns.map(getColId)), true);
|
|
870
881
|
|
package/src/lui/ActionButton.tsx
CHANGED
|
@@ -50,7 +50,11 @@ export const ActionButton = ({
|
|
|
50
50
|
|
|
51
51
|
useEffect(() => {
|
|
52
52
|
if (inProgress == lastInProgress) return;
|
|
53
|
-
|
|
53
|
+
if (inProgress) {
|
|
54
|
+
setLocalInProgress(true);
|
|
55
|
+
} else {
|
|
56
|
+
setLocalInProgressDeferred(false, minimumInProgressTimeMs);
|
|
57
|
+
}
|
|
54
58
|
}, [inProgress, lastInProgress, setLocalInProgress, setLocalInProgressDeferred]);
|
|
55
59
|
|
|
56
60
|
const buttonText = (
|
package/src/lui/FormError.scss
CHANGED
|
@@ -45,7 +45,7 @@ export const TextAreaInput = (props: LuiTextAreaInputProps) => {
|
|
|
45
45
|
e.currentTarget.focus();
|
|
46
46
|
e.currentTarget.selectionStart = e.currentTarget.value.length;
|
|
47
47
|
}
|
|
48
|
-
props.onMouseEnter
|
|
48
|
+
props.onMouseEnter?.(e);
|
|
49
49
|
}}
|
|
50
50
|
data-allowtabtosave={props.allowTabToSave}
|
|
51
51
|
>
|