@purpurds/table 8.5.1 → 8.6.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/LICENSE.txt +16 -16
- package/dist/styles.css +1 -1
- package/dist/table-settings-drawer.d.ts +4 -1
- package/dist/table-settings-drawer.d.ts.map +1 -1
- package/dist/table.cjs.js +53 -53
- package/dist/table.cjs.js.map +1 -1
- package/dist/table.es.js +1104 -1107
- package/dist/table.es.js.map +1 -1
- package/dist/test-utils/helpers.d.ts +39 -0
- package/dist/test-utils/helpers.d.ts.map +1 -1
- package/package.json +23 -23
- package/src/table-settings-drawer.module.scss +1 -1
- package/src/table-settings-drawer.test.tsx +62 -0
- package/src/table-settings-drawer.tsx +16 -6
- package/src/table.stories.tsx +5 -1
- package/src/test-utils/helpers.ts +40 -0
|
@@ -108,6 +108,45 @@ export declare const copy: {
|
|
|
108
108
|
description: string;
|
|
109
109
|
};
|
|
110
110
|
};
|
|
111
|
+
settingsDrawerWithColumnDrag: {
|
|
112
|
+
buttons: {
|
|
113
|
+
closeDrawer: string;
|
|
114
|
+
resetSettings: string;
|
|
115
|
+
};
|
|
116
|
+
generalSettings: {
|
|
117
|
+
header: string;
|
|
118
|
+
toggles: {
|
|
119
|
+
lockFirstcolumn: string;
|
|
120
|
+
showFilters: string;
|
|
121
|
+
stickyHeader: string;
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
title: string;
|
|
125
|
+
visibleColumns: {
|
|
126
|
+
header: string;
|
|
127
|
+
description: string;
|
|
128
|
+
rearrangeDescription: string;
|
|
129
|
+
buttons: {
|
|
130
|
+
rearrange: string;
|
|
131
|
+
done: string;
|
|
132
|
+
};
|
|
133
|
+
ariaLabels: {
|
|
134
|
+
dragHandle: {
|
|
135
|
+
action: string;
|
|
136
|
+
instructions: string;
|
|
137
|
+
};
|
|
138
|
+
arrowButtons: {
|
|
139
|
+
move: string;
|
|
140
|
+
up: string;
|
|
141
|
+
down: string;
|
|
142
|
+
};
|
|
143
|
+
buttons: {
|
|
144
|
+
rearrange: string;
|
|
145
|
+
done: string;
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
};
|
|
111
150
|
sortingAriaLabels: {
|
|
112
151
|
asc: string;
|
|
113
152
|
default: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/test-utils/helpers.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,YAAY,GAAI,OAAO,WAAW,KAAG,WAIjD,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,OAAO,WAAW,KAAG,WAIjD,CAAC;AAEF,eAAO,MAAM,0BAA0B,GACrC,OAAO,WAAW,EAClB,cAAc,MAAM,KACnB,WAKF,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAC9B,OAAO,gBAAgB,EACvB,OAAO,MAAM,EACb,cAAc,MAAM,KACnB,oBAQF,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,OAAO,gBAAgB,EAAE,cAAS,KAAG,mBAEpE,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,OAAO,gBAAgB,EAAE,OAAO,MAAM,KAAG,mBAExE,CAAC;AAGF,eAAO,MAAM,0BAA0B,GACrC,OAAO,gBAAgB,EACvB,OAAO,MAAM,KACZ,iBAEF,CAAC;AAEF,eAAO,MAAM,6BAA6B,GACxC,OAAO,gBAAgB,EACvB,OAAO,MAAM,KACZ,iBAEF,CAAC;AAGF,eAAO,MAAM,4BAA4B,GACvC,OAAO,gBAAgB,EACvB,cAAS,KACR,iBAEF,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,OAAO,gBAAgB,EAAE,QAAQ,MAAM,gBAG9E,CAAC;AAEF,eAAO,MAAM,cAAc,GACzB,OAAO,gBAAgB,EACvB,QAAQ,MAAM,EACd,aAAa,MAAM,kBAOpB,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAI,OAAO,gBAAgB,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AEF,eAAO,MAAM,0BAA0B,GAAI,OAAO,gBAAgB,EAAE,QAAQ,MAAM,gBAGjF,CAAC;AAEF,eAAO,MAAM,cAAc,GACzB,OAAO,gBAAgB,EACvB,QAAQ,MAAM,EACd,aAAa,MAAM,kBAIpB,CAAC;AAEF,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kCA6CQ,MAAM;;;CAGnC,CAAC;AAEF,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqHhB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@purpurds/table",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.6.0",
|
|
4
4
|
"license": "AGPL-3.0-only",
|
|
5
5
|
"main": "./dist/table.cjs.js",
|
|
6
6
|
"types": "./dist/table.d.ts",
|
|
@@ -21,22 +21,22 @@
|
|
|
21
21
|
"@dnd-kit/utilities": "~3.2.2",
|
|
22
22
|
"@tanstack/react-table": "~8.21.2",
|
|
23
23
|
"classnames": "~2.5.0",
|
|
24
|
-
"@purpurds/
|
|
25
|
-
"@purpurds/
|
|
26
|
-
"@purpurds/
|
|
27
|
-
"@purpurds/
|
|
28
|
-
"@purpurds/
|
|
29
|
-
"@purpurds/
|
|
30
|
-
"@purpurds/
|
|
31
|
-
"@purpurds/
|
|
32
|
-
"@purpurds/
|
|
33
|
-
"@purpurds/
|
|
34
|
-
"@purpurds/
|
|
35
|
-
"@purpurds/
|
|
36
|
-
"@purpurds/
|
|
37
|
-
"@purpurds/
|
|
38
|
-
"@purpurds/
|
|
39
|
-
"@purpurds/
|
|
24
|
+
"@purpurds/heading": "8.6.0",
|
|
25
|
+
"@purpurds/button": "8.6.0",
|
|
26
|
+
"@purpurds/drawer": "8.6.0",
|
|
27
|
+
"@purpurds/icon": "8.6.0",
|
|
28
|
+
"@purpurds/link": "8.6.0",
|
|
29
|
+
"@purpurds/select": "8.6.0",
|
|
30
|
+
"@purpurds/text-field": "8.6.0",
|
|
31
|
+
"@purpurds/badge": "8.6.0",
|
|
32
|
+
"@purpurds/skeleton": "8.6.0",
|
|
33
|
+
"@purpurds/cta-link": "8.6.0",
|
|
34
|
+
"@purpurds/toggle": "8.6.0",
|
|
35
|
+
"@purpurds/tokens": "8.6.0",
|
|
36
|
+
"@purpurds/visually-hidden": "8.6.0",
|
|
37
|
+
"@purpurds/checkbox": "8.6.0",
|
|
38
|
+
"@purpurds/paragraph": "8.6.0",
|
|
39
|
+
"@purpurds/tooltip": "8.6.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@rushstack/eslint-patch": "~1.10.0",
|
|
@@ -60,13 +60,13 @@
|
|
|
60
60
|
"vitest-axe": "~0.1.0",
|
|
61
61
|
"vitest-canvas-mock": "~0.3.3",
|
|
62
62
|
"vitest": "^3.1.2",
|
|
63
|
-
"@purpurds/autocomplete": "8.
|
|
63
|
+
"@purpurds/autocomplete": "8.6.0",
|
|
64
|
+
"@purpurds/illustrative-icon": "8.6.0",
|
|
64
65
|
"@purpurds/component-rig": "1.0.0",
|
|
65
|
-
"@purpurds/grid": "8.
|
|
66
|
-
"@purpurds/
|
|
67
|
-
"@purpurds/
|
|
68
|
-
"@purpurds/
|
|
69
|
-
"@purpurds/label": "8.5.1"
|
|
66
|
+
"@purpurds/grid": "8.6.0",
|
|
67
|
+
"@purpurds/label": "8.6.0",
|
|
68
|
+
"@purpurds/pagination": "8.6.0",
|
|
69
|
+
"@purpurds/listbox": "8.6.0"
|
|
70
70
|
},
|
|
71
71
|
"scripts": {
|
|
72
72
|
"build:dev": "vite",
|
|
@@ -248,4 +248,66 @@ describe("Data Table - Settings drawer", () => {
|
|
|
248
248
|
});
|
|
249
249
|
});
|
|
250
250
|
});
|
|
251
|
+
|
|
252
|
+
describe("Column drag enabled", () => {
|
|
253
|
+
const onColumnOrderChangeMock = vi.fn();
|
|
254
|
+
let withinDrawerContent: ReturnType<typeof within>;
|
|
255
|
+
|
|
256
|
+
beforeEach(() => {
|
|
257
|
+
render(
|
|
258
|
+
<TableSettingsDrawer
|
|
259
|
+
id="purpur-table-settings-drawer"
|
|
260
|
+
isDrawerOpen={true}
|
|
261
|
+
showColumnFilters={true}
|
|
262
|
+
columnFiltersEnabled={true}
|
|
263
|
+
stickyFirstColumn={true}
|
|
264
|
+
stickyHeaders={true}
|
|
265
|
+
copy={copy.settingsDrawerWithColumnDrag}
|
|
266
|
+
setDrawerIsOpen={setDrawerIsOpenMock}
|
|
267
|
+
setShowColumnFiltersEnabled={setColumnFiltersEnabledMock}
|
|
268
|
+
setStickyFirstColumn={setStickyFirstColumnMock}
|
|
269
|
+
setStickyHeaders={setStickyHeadersMock}
|
|
270
|
+
getAllColumns={getAllColumnsMock}
|
|
271
|
+
onResetSettings={onResetSettingsMock}
|
|
272
|
+
enableColumnDrag={true}
|
|
273
|
+
onColumnOrderChange={onColumnOrderChangeMock}
|
|
274
|
+
columnOrder={["column_1", "column_2", "column_3"]}
|
|
275
|
+
/>
|
|
276
|
+
);
|
|
277
|
+
|
|
278
|
+
withinDrawerContent = within(screen.getByTestId(Selectors.SETTINGS_DRAWER.CONTENT));
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
describe("Visible columns with rearrange mode", () => {
|
|
282
|
+
let withinVisibleColumns: ReturnType<typeof within>;
|
|
283
|
+
|
|
284
|
+
beforeEach(() => {
|
|
285
|
+
withinVisibleColumns = within(
|
|
286
|
+
withinDrawerContent.getByTestId(Selectors.SETTINGS_DRAWER.VISIBLE_COLUMNS)
|
|
287
|
+
);
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
it("should have a rearrange button", () => {
|
|
291
|
+
const rearrangeButton = withinVisibleColumns.getByRole("button", {
|
|
292
|
+
name: copy.settingsDrawerWithColumnDrag.visibleColumns.ariaLabels.buttons.rearrange,
|
|
293
|
+
});
|
|
294
|
+
expect(rearrangeButton).toBeInTheDocument();
|
|
295
|
+
expect(rearrangeButton).toHaveTextContent(copy.settingsDrawerWithColumnDrag.visibleColumns.buttons.rearrange);
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
it("should update aria-label when entering rearrange mode", async () => {
|
|
299
|
+
const rearrangeButton = withinVisibleColumns.getByRole("button", {
|
|
300
|
+
name: copy.settingsDrawerWithColumnDrag.visibleColumns.ariaLabels.buttons.rearrange,
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
await userEvent.click(rearrangeButton);
|
|
304
|
+
|
|
305
|
+
const doneButton = withinVisibleColumns.getByRole("button", {
|
|
306
|
+
name: copy.settingsDrawerWithColumnDrag.visibleColumns.ariaLabels.buttons.done,
|
|
307
|
+
});
|
|
308
|
+
expect(doneButton).toBeInTheDocument();
|
|
309
|
+
expect(doneButton).toHaveTextContent(copy.settingsDrawerWithColumnDrag.visibleColumns.buttons.done);
|
|
310
|
+
});
|
|
311
|
+
});
|
|
312
|
+
});
|
|
251
313
|
});
|
|
@@ -34,6 +34,7 @@ import {
|
|
|
34
34
|
purpurMotionDuration150,
|
|
35
35
|
purpurMotionEasingEaseInOut,
|
|
36
36
|
} from "@purpurds/tokens/motion/variables";
|
|
37
|
+
import { VisuallyHidden } from "@purpurds/visually-hidden";
|
|
37
38
|
import { type Column, type RowData } from "@tanstack/react-table";
|
|
38
39
|
import c from "classnames/bind";
|
|
39
40
|
|
|
@@ -80,7 +81,10 @@ type VisibleColumnsWithColumnDragCopyProps = VisibleColumnsCopyBaseProps & {
|
|
|
80
81
|
up: string;
|
|
81
82
|
down: string;
|
|
82
83
|
};
|
|
83
|
-
|
|
84
|
+
buttons: {
|
|
85
|
+
rearrange: string;
|
|
86
|
+
done: string;
|
|
87
|
+
};
|
|
84
88
|
};
|
|
85
89
|
};
|
|
86
90
|
|
|
@@ -358,7 +362,11 @@ const VisibleColumns = <TData extends RowData>({
|
|
|
358
362
|
variant={isRearrangeMode ? "primary" : "tertiary-purple"}
|
|
359
363
|
onClick={() => setIsRearrangeMode((v) => !v)}
|
|
360
364
|
data-testid={`${rootTestId}-rearrange-button`}
|
|
361
|
-
aria-label={
|
|
365
|
+
aria-label={
|
|
366
|
+
isRearrangeMode
|
|
367
|
+
? copy.visibleColumns.ariaLabels.buttons.done
|
|
368
|
+
: copy.visibleColumns.ariaLabels.buttons.rearrange
|
|
369
|
+
}
|
|
362
370
|
>
|
|
363
371
|
<IconSorter size="xs" />
|
|
364
372
|
{isRearrangeMode
|
|
@@ -476,13 +484,15 @@ const DraggableColumnItem = ({
|
|
|
476
484
|
})}
|
|
477
485
|
{...listeners}
|
|
478
486
|
{...attributes}
|
|
487
|
+
aria-label={`${copy.visibleColumns.ariaLabels.dragHandle.action} ${label}`}
|
|
488
|
+
aria-describedby={`drag-instructions-${id}`}
|
|
479
489
|
>
|
|
480
|
-
<IconDragVertical
|
|
481
|
-
className={cx(`${rootClassName}__draggable-handle-icon`, "terre")}
|
|
482
|
-
size="sm"
|
|
483
|
-
/>
|
|
490
|
+
<IconDragVertical className={cx(`${rootClassName}__draggable-handle-icon`)} size="sm" />
|
|
484
491
|
</div>
|
|
485
492
|
<span>{label}</span>
|
|
493
|
+
<VisuallyHidden id={`drag-instructions-${id}`}>
|
|
494
|
+
{copy.visibleColumns.ariaLabels.dragHandle.instructions}
|
|
495
|
+
</VisuallyHidden>
|
|
486
496
|
</div>
|
|
487
497
|
|
|
488
498
|
<div className={cx(`${rootClassName}__draggable-item-buttons`)}>
|
package/src/table.stories.tsx
CHANGED
|
@@ -274,7 +274,10 @@ const commonSettingsDrawerCopyWithColumnDrag = {
|
|
|
274
274
|
up: "up",
|
|
275
275
|
down: "down",
|
|
276
276
|
},
|
|
277
|
-
|
|
277
|
+
buttons: {
|
|
278
|
+
rearrange: "Reorder columns",
|
|
279
|
+
done: "Save column order and exit reorder mode",
|
|
280
|
+
},
|
|
278
281
|
},
|
|
279
282
|
},
|
|
280
283
|
};
|
|
@@ -324,6 +327,7 @@ export const Showcase: StoryTableData = {
|
|
|
324
327
|
stickyHeaders: true,
|
|
325
328
|
enableColumnDrag: true,
|
|
326
329
|
onColumnOrderChange: () => {},
|
|
330
|
+
columnDragAriaLabelsCopy: commonColumnDragAriaLabels,
|
|
327
331
|
},
|
|
328
332
|
parameters: {
|
|
329
333
|
docs: {
|
|
@@ -199,6 +199,46 @@ export const copy = {
|
|
|
199
199
|
description: "Change general table settings",
|
|
200
200
|
},
|
|
201
201
|
},
|
|
202
|
+
settingsDrawerWithColumnDrag: {
|
|
203
|
+
buttons: {
|
|
204
|
+
closeDrawer: "Close drawer",
|
|
205
|
+
resetSettings: "Reset settings",
|
|
206
|
+
},
|
|
207
|
+
generalSettings: {
|
|
208
|
+
header: "General settings",
|
|
209
|
+
|
|
210
|
+
toggles: {
|
|
211
|
+
lockFirstcolumn: "Lock first column",
|
|
212
|
+
showFilters: "Show Filters",
|
|
213
|
+
stickyHeader: "Sticky header",
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
title: "Table settings",
|
|
217
|
+
visibleColumns: {
|
|
218
|
+
header: "Visible columns",
|
|
219
|
+
description: "Change general table settings",
|
|
220
|
+
rearrangeDescription: "Choose how you want to reorder the columns.",
|
|
221
|
+
buttons: {
|
|
222
|
+
rearrange: "Reorder",
|
|
223
|
+
done: "Done",
|
|
224
|
+
},
|
|
225
|
+
ariaLabels: {
|
|
226
|
+
dragHandle: {
|
|
227
|
+
action: "Drag to reorder column",
|
|
228
|
+
instructions: "(use space or enter to pick up, arrow keys to move, space or enter to drop)",
|
|
229
|
+
},
|
|
230
|
+
arrowButtons: {
|
|
231
|
+
move: "Move",
|
|
232
|
+
up: "up",
|
|
233
|
+
down: "down",
|
|
234
|
+
},
|
|
235
|
+
buttons: {
|
|
236
|
+
rearrange: "Reorder columns",
|
|
237
|
+
done: "Save column order and exit reorder mode",
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
},
|
|
241
|
+
},
|
|
202
242
|
sortingAriaLabels: {
|
|
203
243
|
asc: "Sort ascending",
|
|
204
244
|
default: "Sort column",
|