@linzjs/step-ag-grid 29.10.0 → 29.11.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/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": "29.10.0",
5
+ "version": "29.11.1",
6
6
  "keywords": [
7
7
  "aggrid",
8
8
  "ag-grid",
@@ -28,8 +28,8 @@
28
28
  },
29
29
  "peerDependencies": {
30
30
  "@linzjs/lui": ">=21",
31
- "ag-grid-community": "^34.2.0",
32
- "ag-grid-react": "^34.2.0",
31
+ "ag-grid-community": "~34.2.0",
32
+ "ag-grid-react": "~34.2.0",
33
33
  "lodash-es": ">=4",
34
34
  "react": ">=18",
35
35
  "react-dom": ">=18"
@@ -39,7 +39,8 @@
39
39
  "debounce-promise": "^3.1.2",
40
40
  "matcher": "^5.0.0",
41
41
  "react-transition-state": "^2.3.1",
42
- "usehooks-ts": "^3.1.1"
42
+ "usehooks-ts": "^3.1.1",
43
+ "uuid": "^13.0.0"
43
44
  },
44
45
  "scripts": {
45
46
  "build": "run-s clean lint css bundle",
@@ -76,14 +77,14 @@
76
77
  ]
77
78
  },
78
79
  "optionalDependencies": {
79
- "@rollup/rollup-linux-x64-gnu": "^4.52.4",
80
- "@swc/core-linux-x64-gnu": "^1.13.20"
80
+ "@rollup/rollup-linux-x64-gnu": "^4.53.2",
81
+ "@swc/core-linux-x64-gnu": "^1.15.1"
81
82
  },
82
83
  "devDependencies": {
83
- "@chromatic-com/storybook": "^4.1.1",
84
+ "@chromatic-com/storybook": "^4.1.2",
84
85
  "@linzjs/lui": "^23.14.2",
85
86
  "@linzjs/style": "^5.4.0",
86
- "@linzjs/windows": "^5.7.0",
87
+ "@linzjs/windows": "^8.1.0",
87
88
  "@rollup/plugin-commonjs": "^28.0.8",
88
89
  "@rollup/plugin-json": "^6.1.0",
89
90
  "@rollup/plugin-node-resolve": "^16.0.3",
@@ -101,13 +102,14 @@
101
102
  "@types/node": "^22.17.0",
102
103
  "@types/react": "^18.3.23",
103
104
  "@types/react-dom": "^18.3.7",
105
+ "@types/uuid": "^11.0.0",
104
106
  "@vitejs/plugin-react-swc": "^3.11.0",
105
107
  "@vitest/ui": "^3.2.4",
106
- "ag-grid-community": "^34.2.0",
107
- "ag-grid-react": "^34.2.0",
108
+ "ag-grid-community": "34.2.0",
109
+ "ag-grid-react": "34.2.0",
108
110
  "babel-preset-react-app": "^10.1.0",
109
111
  "canvas": "^3.2.0",
110
- "chromatic": "^13.3.0",
112
+ "chromatic": "^13.3.3",
111
113
  "cross-env": "^10.1.0",
112
114
  "css-loader": "^7.1.2",
113
115
  "eslint-plugin-react": "^7.37.5",
@@ -122,20 +124,20 @@
122
124
  "react": ">=18",
123
125
  "react-app-polyfill": "^3.0.0",
124
126
  "react-dom": "^18.3.1",
125
- "rimraf": "^6.0.1",
126
- "rollup": "^4.52.4",
127
+ "rimraf": "^6.1.0",
128
+ "rollup": "^4.53.2",
127
129
  "rollup-plugin-copy": "^3.5.0",
128
130
  "rollup-plugin-peer-deps-external": "^2.2.4",
129
131
  "rollup-plugin-postcss": "^4.0.2",
130
132
  "rollup-plugin-typescript2": "^0.36.0",
131
- "sass": "^1.93.2",
132
- "sass-loader": "^16.0.5",
133
+ "sass": "^1.94.0",
134
+ "sass-loader": "^16.0.6",
133
135
  "semantic-release": "^24.2.9",
134
136
  "storybook": "^9.1.12",
135
137
  "storybook-css-modules-preset": "^1.1.1",
136
138
  "style-loader": "^4.0.0",
137
139
  "typescript": "^5.9.3",
138
- "vite": "^7.1.10",
140
+ "vite": "^7.2.2",
139
141
  "vite-plugin-html": "^3.2.2",
140
142
  "vite-tsconfig-paths": "^5.1.4",
141
143
  "vitest": "^3.2.4"
@@ -235,7 +235,6 @@ export const Grid = <TData extends GridBaseRow = GridBaseRow>({
235
235
  autoSizeColumns({
236
236
  skipHeader,
237
237
  userSizedColIds: new Set(userSizedColIds.current.keys()),
238
- includeFlex: true,
239
238
  });
240
239
  // Auto-size failed retry later
241
240
  if (!autoSizeResult) {
@@ -10,7 +10,6 @@ export interface AutoSizeColumnsProps {
10
10
  skipHeader?: boolean;
11
11
  colIds?: Set<string> | string[];
12
12
  userSizedColIds?: Set<string>;
13
- includeFlex?: boolean;
14
13
  }
15
14
 
16
15
  export type AutoSizeColumnsResult = { width: number } | null;
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  CellPosition,
3
3
  ColDef,
4
+ ColumnState,
4
5
  CsvExportParams,
5
6
  GridApi,
6
7
  IRowNode,
@@ -9,7 +10,20 @@ import {
9
10
  RowNode,
10
11
  } from 'ag-grid-community';
11
12
  import debounce from 'debounce-promise';
12
- import { compact, defer, delay, difference, filter, isEmpty, last, pull, remove, sortBy, sumBy } from 'lodash-es';
13
+ import {
14
+ compact,
15
+ defer,
16
+ delay,
17
+ difference,
18
+ filter,
19
+ isEmpty,
20
+ last,
21
+ partition,
22
+ pull,
23
+ remove,
24
+ sortBy,
25
+ sumBy,
26
+ } from 'lodash-es';
13
27
  import { PropsWithChildren, ReactElement, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
14
28
 
15
29
  import { ColDefT, GridBaseRow } from '../components';
@@ -20,6 +34,9 @@ import { waitForCondition } from '../utils/waitForCondition';
20
34
  import { AutoSizeColumnsProps, AutoSizeColumnsResult, GridContext, GridFilterExternal } from './GridContext';
21
35
  import { GridUpdatingContext } from './GridUpdatingContext';
22
36
 
37
+ const colStateId = (colState: ColumnState) => colState.colId;
38
+ const colStateFlexed = (colState: ColumnState) => !!colState.flex;
39
+
23
40
  /**
24
41
  * Context for AgGrid operations.
25
42
  * Make sure you wrap AgGrid in this.
@@ -422,26 +439,33 @@ export const GridContextProvider = <TData extends GridBaseRow>(props: PropsWithC
422
439
 
423
440
  /**
424
441
  * Resize columns to fit container
442
+ *
443
+ * This is used to calculate the preferred size of columns.
444
+ * It sizes the flex columns first and then clears the calculated width.
445
+ * If you don't clear flex column widths ag-grid gets confused and does random sizing's.
446
+ * Then we size the flexed columns.
425
447
  */
426
448
  const autoSizeColumns = useCallback(
427
- ({ skipHeader, colIds, userSizedColIds, includeFlex }: AutoSizeColumnsProps = {}): AutoSizeColumnsResult => {
449
+ ({ skipHeader, colIds, userSizedColIds }: AutoSizeColumnsProps = {}): AutoSizeColumnsResult => {
428
450
  if (!gridApi || !gridApi.getColumnState()) {
429
451
  return null;
430
452
  }
431
453
  const colIdsSet = colIds instanceof Set ? colIds : new Set(colIds);
432
- const colsToResize = gridApi.getColumnState()?.filter?.((colState) => {
454
+ const colStates = gridApi.getColumnState();
455
+
456
+ const relevantCols = colStates?.filter((colState) => {
433
457
  const colId = colState.colId;
434
- return (
435
- (isEmpty(colIdsSet) || colIdsSet.has(colId)) &&
436
- !userSizedColIds?.has(colId) &&
437
- (includeFlex || !colState.flex)
438
- );
458
+ return (isEmpty(colIdsSet) || colIdsSet.has(colId)) && !userSizedColIds?.has(colId);
439
459
  });
440
- if (!isEmpty(colsToResize)) {
441
- gridApi.autoSizeColumns(
442
- colsToResize.map((colState) => colState.colId),
443
- skipHeader,
444
- );
460
+ const [flexColumns, nonFlexColumns] = partition(relevantCols, colStateFlexed);
461
+ // If we don't reset the flex columns auto size it causes issues with random resizing of flex columns
462
+ if (!isEmpty(flexColumns)) {
463
+ gridApi.autoSizeColumns(flexColumns.map(colStateId), skipHeader);
464
+ gridApi.resetColumnState();
465
+ }
466
+
467
+ if (!isEmpty(nonFlexColumns)) {
468
+ gridApi.autoSizeColumns(nonFlexColumns.map(colStateId), skipHeader);
445
469
  }
446
470
  return {
447
471
  width: sumBy(
@@ -37,11 +37,13 @@ const GridPopoutEditGenericTemplate: StoryFn<typeof Grid<IFormTestRow>> = (props
37
37
  GridCell({
38
38
  field: 'id',
39
39
  headerName: 'Id',
40
+ flex: 2,
40
41
  }),
41
42
  GridCell(
42
43
  {
43
44
  field: 'name',
44
45
  headerName: 'Popout Generic Edit',
46
+ flex: 1,
45
47
  },
46
48
  {
47
49
  multiEdit: true,
@@ -144,7 +144,7 @@ $grid-base-font-size: calc(#{lui.$base-font-size} - 1px);
144
144
  }
145
145
 
146
146
  .ag-icon-filter {
147
- background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%232A292C'%3E%3Cpath d='M6 12.984v-1.969h12v1.969zM3 6h18v2.016H3zm6.984 12v-2.016h4.031V18z'/%3E%3C/svg%3E") !important;
147
+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23007198'%3E%3Cpath d='M6 12.984v-1.969h12v1.969zM3 6h18v2.016H3zm6.984 12v-2.016h4.031V18z'/%3E%3C/svg%3E") !important;
148
148
  background-repeat: no-repeat;
149
149
  background-position: center;
150
150
  background-size: contain;
@@ -154,6 +154,12 @@ $grid-base-font-size: calc(#{lui.$base-font-size} - 1px);
154
154
  content: none !important;
155
155
  }
156
156
  }
157
+
158
+ .ag-header-cell-filter-button.ag-has-popup-positioned-under .ag-icon-filter {
159
+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23ffffff'%3E%3Cpath d='M6 12.984v-1.969h12v1.969zM3 6h18v2.016H3zm6.984 12v-2.016h4.031V18z'/%3E%3C/svg%3E") !important;
160
+ background-color: #007198;
161
+ border-radius: 2px;
162
+ }
157
163
 
158
164
  .ag-header-group-cell {
159
165
  text-transform: uppercase;