@linzjs/step-ag-grid 30.4.2 → 30.4.4

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": "30.4.2",
5
+ "version": "30.4.4",
6
6
  "keywords": [
7
7
  "aggrid",
8
8
  "ag-grid",
@@ -771,8 +771,7 @@ export const Grid = <TData extends GridBaseRow = GridBaseRow>({
771
771
  } else {
772
772
  r = compareNaturalInsensitive(value1, value2);
773
773
  }
774
- // secondary compare as primary sort column rows are equal
775
- return r === 0 ? compareNaturalInsensitive(node1.data?.id, node2.data?.id) : r;
774
+ return r;
776
775
  };
777
776
  }
778
777
  const adjustedColDef = {
@@ -82,14 +82,14 @@ const GridReadOnlyTemplate: StoryFn<typeof Grid<ITestRow>> = (props: GridProps<I
82
82
  colId: 'customComparatorText',
83
83
  headerName: 'Cust. comp. id as text',
84
84
  valueFormatter: ({ data }) => data?.text ?? '',
85
- comparator: (_v1, _v2, n1, n2) => compareNaturalInsensitive(String(n1.data?.id), String(n2.data?.id)) ?? 0,
85
+ comparator: (_v1, _v2, n1, n2) => compareNaturalInsensitive(String(n1.data?.id), String(n2.data?.id)),
86
86
  }),
87
87
  GridCell({
88
88
  colId: 'customComparatorNumeric',
89
- headerName: 'Cust. comp. abs number',
89
+ headerName: 'Cust. comp. number',
90
90
  valueFormatter: ({ data }) => String(data?.numeric ?? ''),
91
91
  comparator: (_v1, _v2, n1, n2) => {
92
- return compareNaturalInsensitive(n1.data?.numeric, n2.data?.numeric) ?? 0;
92
+ return compareNaturalInsensitive(n1.data?.numeric, n2.data?.numeric);
93
93
  },
94
94
  }),
95
95
  ],
@@ -148,16 +148,8 @@ Sorting.play = async (context) => {
148
148
  await test('numeric', ['–', '-1.1', '1', '2.01', '2.1', '2.21', '3', '3', '11', '21']);
149
149
  await test('numeric', ['21', '11', '3', '3', '2.21', '2.1', '2.01', '1', '-1.1', '–']);
150
150
 
151
- await test(
152
- 'text',
153
- ['–', '2', '10', 'ade', 'ade', 'b', 'b', 'cdc', 'e', 'e'],
154
- ['1006', '1002', '1003', '1000', '1009', '1004', '1005', '1001', '1007', '1008'],
155
- );
156
- await test(
157
- 'text',
158
- ['e', 'e', 'cdc', 'b', 'b', 'ade', 'ade', '10', '2', '–'],
159
- ['1008', '1007', '1001', '1005', '1004', '1009', '1000', '1003', '1002', '1006'],
160
- );
151
+ await test('text', ['–', '2', '10', 'ade', 'ade', 'b', 'b', 'cdc', 'e', 'e']);
152
+ await test('text', ['e', 'e', 'cdc', 'b', 'b', 'ade', 'ade', '10', '2', '–']);
161
153
 
162
154
  await test('customComparatorText', null, [
163
155
  '1000',
@@ -0,0 +1,121 @@
1
+ import '../../styles/GridTheme.scss';
2
+ import '../../styles/index.scss';
3
+ import '@linzjs/lui/dist/scss/base.scss';
4
+ import '@linzjs/lui/dist/fonts';
5
+
6
+ import { Meta, StoryFn } from '@storybook/react-vite';
7
+ import { useMemo, useState } from 'react';
8
+
9
+ import {
10
+ ColDefT,
11
+ Grid,
12
+ GridCell,
13
+ GridContextProvider,
14
+ GridProps,
15
+ GridUpdatingContextProvider,
16
+ GridWrapper,
17
+ } from '../..';
18
+
19
+ export default {
20
+ title: 'Components / Grids',
21
+ component: Grid,
22
+ // Storybook hangs otherwise
23
+ parameters: {
24
+ docs: {
25
+ source: {
26
+ type: 'code',
27
+ },
28
+ },
29
+ },
30
+ decorators: [
31
+ (Story) => (
32
+ <div style={{ maxWidth: 1024, height: 400, display: 'flex', flexDirection: 'column' }}>
33
+ <GridUpdatingContextProvider>
34
+ <GridContextProvider>
35
+ <Story />
36
+ </GridContextProvider>
37
+ </GridUpdatingContextProvider>
38
+ </div>
39
+ ),
40
+ ],
41
+ } as Meta<typeof Grid>;
42
+
43
+ interface ITestRow {
44
+ id: number;
45
+ position: string;
46
+ age: number;
47
+ height: string;
48
+ desc: string;
49
+ dd: string;
50
+ }
51
+
52
+ const GridReadOnlyTemplate: StoryFn<typeof Grid<ITestRow>> = (props: GridProps<ITestRow>) => {
53
+ const [externalSelectedItems, setExternalSelectedItems] = useState<any[]>([]);
54
+ const columnDefs: ColDefT<ITestRow>[] = useMemo(
55
+ () => [
56
+ GridCell<ITestRow, ITestRow['id']>({
57
+ field: 'id',
58
+ headerName: 'Id',
59
+ lockVisible: true,
60
+ resizable: false,
61
+ lockPosition: 'left',
62
+ cellRenderer: ({ value }) => <a href={'#'}>{value}</a>,
63
+ }),
64
+ GridCell<ITestRow, ITestRow['position']>({
65
+ field: 'position',
66
+ headerName: 'Position',
67
+ resizable: false,
68
+ lockPosition: 'left',
69
+ cellRendererParams: {
70
+ warning: ({ value }) => value === 'Tester' && 'Testers are testing',
71
+ info: ({ value }) => value === 'Developer' && 'Developers are awesome',
72
+ },
73
+ }),
74
+ GridCell({
75
+ field: 'desc',
76
+ headerName: 'Description',
77
+ resizable: false,
78
+ lockPosition: 'left',
79
+ }),
80
+ GridCell({
81
+ field: 'age',
82
+ headerName: 'Age',
83
+ resizable: false,
84
+ lockPosition: 'left',
85
+ }),
86
+ GridCell({
87
+ field: 'height',
88
+ headerName: 'Height',
89
+ resizable: false,
90
+ lockPosition: 'left',
91
+ }),
92
+ ],
93
+ [],
94
+ );
95
+
96
+ const [rowData] = useState<ITestRow[]>([
97
+ { id: 1000, position: 'Tester', age: 30, height: `6'4"`, desc: 'Tests application', dd: '1' },
98
+ { id: 1001, position: 'Developer', age: 12, height: `5'3"`, desc: 'Develops application', dd: '2' },
99
+ { id: 1002, position: 'Manager', age: 65, height: `5'9"`, desc: 'Manages', dd: '3' },
100
+ ]);
101
+
102
+ return (
103
+ <GridWrapper maxHeight={400}>
104
+ <Grid
105
+ data-testid={'readonly'}
106
+ {...props}
107
+ selectable={true}
108
+ rowSelection={'multiple'}
109
+ externalSelectedItems={externalSelectedItems}
110
+ setExternalSelectedItems={setExternalSelectedItems}
111
+ columnDefs={columnDefs}
112
+ rowData={rowData}
113
+ sizeColumns={'fit'}
114
+ theme={'ag-theme-step-view-list-default'}
115
+ contextMenuSelectRow={false}
116
+ suppressCellFocus={true}
117
+ />
118
+ </GridWrapper>
119
+ );
120
+ };
121
+ export const SelectableListViewGrid = GridReadOnlyTemplate.bind({});
@@ -279,6 +279,10 @@ $grid-base-font-size: calc(#{lui.$base-font-size} - 1px);
279
279
 
280
280
  .ag-theme-step-view-list-default.theme-specific {
281
281
 
282
+ .ag-header-hide-default-select .ag-labeled {
283
+ display: none;
284
+ }
285
+
282
286
  .ag-header-cell {
283
287
  font-size: 14px;
284
288
  font-weight: 600;
@@ -295,4 +299,4 @@ $grid-base-font-size: calc(#{lui.$base-font-size} - 1px);
295
299
  .ag-header-cell {
296
300
  font-size: 14px;
297
301
  }
298
- }
302
+ }