@slotted/react 0.1.0-beta.42 → 0.1.0-beta.43
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/{app-shell-D54YkU7E.js → app-shell-DsWhsSMU.js} +3 -2
- package/dist/app-shell.js +1 -1
- package/dist/attachment-TZykYNu5.js +300 -0
- package/dist/attachment.js +2 -2
- package/dist/{avatar-group-bJaZE1_C.js → avatar-group-Bzmmj2HI.js} +2 -1
- package/dist/avatar-group.js +1 -1
- package/dist/{carousel-B9nMK7Yf.js → carousel-CRNz-T3g.js} +1 -1
- package/dist/carousel.js +1 -1
- package/dist/{command-palette-C90CzfQi.js → command-palette-Bgf5tfCI.js} +160 -156
- package/dist/command-palette.js +1 -1
- package/dist/{data-grid-D106baPp.js → data-grid-DUft3rJb.js} +1 -1
- package/dist/data-grid.js +1 -1
- package/dist/{data-list-BA0xrySM.js → data-list-Dv3orBtf.js} +15 -15
- package/dist/data-list.js +1 -1
- package/dist/detail-panel-Cke3ZFU3.js +342 -0
- package/dist/detail-panel.js +2 -2
- package/dist/docs/action-bar.examples.md +768 -0
- package/dist/docs/action-bar.json +74 -50
- package/dist/docs/action-bar.md +49 -311
- package/dist/docs/app-shell.examples.md +1221 -64
- package/dist/docs/app-shell.json +92 -60
- package/dist/docs/app-shell.md +92 -57
- package/dist/docs/attachment.examples.md +689 -0
- package/dist/docs/attachment.json +69 -37
- package/dist/docs/attachment.md +44 -203
- package/dist/docs/avatar-group.json +111 -23
- package/dist/docs/avatar-group.md +487 -28
- package/dist/docs/button-group.json +98 -2
- package/dist/docs/button-group.md +411 -8
- package/dist/docs/calendar.examples.md +512 -0
- package/dist/docs/calendar.json +72 -24
- package/dist/docs/calendar.md +18 -147
- package/dist/docs/carousel.examples.md +868 -0
- package/dist/docs/carousel.json +58 -50
- package/dist/docs/carousel.md +66 -300
- package/dist/docs/cascader.examples.md +1269 -0
- package/dist/docs/cascader.json +72 -16
- package/dist/docs/cascader.md +78 -154
- package/dist/docs/chart.examples.md +734 -24
- package/dist/docs/chart.json +93 -13
- package/dist/docs/chart.md +28 -7
- package/dist/docs/clock.json +71 -15
- package/dist/docs/clock.md +326 -21
- package/dist/docs/code-block.json +79 -55
- package/dist/docs/code-block.md +417 -74
- package/dist/docs/color-picker.json +60 -12
- package/dist/docs/color-picker.md +245 -22
- package/dist/docs/column-manager.examples.md +764 -0
- package/dist/docs/column-manager.json +68 -12
- package/dist/docs/column-manager.md +44 -203
- package/dist/docs/command-palette.examples.md +747 -0
- package/dist/docs/command-palette.json +48 -24
- package/dist/docs/command-palette.md +60 -339
- package/dist/docs/currency-field.examples.md +355 -73
- package/dist/docs/currency-field.json +96 -64
- package/dist/docs/currency-field.md +57 -50
- package/dist/docs/dashboard-grid.examples.md +629 -0
- package/dist/docs/dashboard-grid.json +64 -16
- package/dist/docs/dashboard-grid.md +34 -152
- package/dist/docs/data-list.examples.md +1556 -0
- package/dist/docs/data-list.json +58 -18
- package/dist/docs/data-list.md +139 -224
- package/dist/docs/date-field.examples.md +543 -0
- package/dist/docs/date-field.json +64 -24
- package/dist/docs/date-field.md +22 -168
- package/dist/docs/datetime-field.examples.md +699 -0
- package/dist/docs/datetime-field.json +79 -31
- package/dist/docs/datetime-field.md +24 -269
- package/dist/docs/datetime-range-picker.examples.md +682 -0
- package/dist/docs/datetime-range-picker.json +117 -61
- package/dist/docs/datetime-range-picker.md +59 -224
- package/dist/docs/description-list.examples.md +652 -0
- package/dist/docs/description-list.json +49 -25
- package/dist/docs/description-list.md +33 -188
- package/dist/docs/detail-panel.examples.md +1177 -0
- package/dist/docs/detail-panel.json +69 -53
- package/dist/docs/detail-panel.md +114 -324
- package/dist/docs/entity-picker.examples.md +1037 -0
- package/dist/docs/entity-picker.json +66 -18
- package/dist/docs/entity-picker.md +56 -246
- package/dist/docs/event-calendar.examples.md +749 -49
- package/dist/docs/event-calendar.json +46 -22
- package/dist/docs/event-calendar.md +81 -11
- package/dist/docs/field-group.examples.md +554 -0
- package/dist/docs/field-group.json +98 -34
- package/dist/docs/field-group.md +55 -133
- package/dist/docs/filter-bar.examples.md +772 -0
- package/dist/docs/filter-bar.json +41 -25
- package/dist/docs/filter-bar.md +42 -246
- package/dist/docs/form.examples.md +579 -0
- package/dist/docs/form.json +87 -39
- package/dist/docs/form.md +53 -177
- package/dist/docs/fullscreen.examples.md +558 -0
- package/dist/docs/fullscreen.json +58 -18
- package/dist/docs/fullscreen.md +50 -169
- package/dist/docs/highlight.json +57 -25
- package/dist/docs/highlight.md +402 -50
- package/dist/docs/icon.json +85 -5
- package/dist/docs/icon.md +401 -10
- package/dist/docs/image.examples.md +670 -0
- package/dist/docs/image.json +44 -28
- package/dist/docs/image.md +24 -176
- package/dist/docs/import-export-center.examples.md +1280 -0
- package/dist/docs/import-export-center.json +67 -27
- package/dist/docs/import-export-center.md +121 -226
- package/dist/docs/list-item.examples.md +769 -0
- package/dist/docs/list-item.json +110 -38
- package/dist/docs/list-item.md +84 -201
- package/dist/docs/listbox.examples.md +858 -0
- package/dist/docs/listbox.json +76 -28
- package/dist/docs/listbox.md +41 -263
- package/dist/docs/markdown.json +79 -55
- package/dist/docs/markdown.md +581 -85
- package/dist/docs/media-viewer.examples.md +1038 -0
- package/dist/docs/media-viewer.json +70 -15
- package/dist/docs/media-viewer.md +84 -135
- package/dist/docs/message-scroller.examples.md +1193 -0
- package/dist/docs/message-scroller.json +41 -17
- package/dist/docs/message-scroller.md +80 -134
- package/dist/docs/message.examples.md +944 -0
- package/dist/docs/message.json +64 -16
- package/dist/docs/message.md +34 -326
- package/dist/docs/meter.json +58 -26
- package/dist/docs/meter.md +312 -32
- package/dist/docs/navigation-menu.examples.md +1107 -0
- package/dist/docs/navigation-menu.json +57 -41
- package/dist/docs/navigation-menu.md +105 -298
- package/dist/docs/notification-center.examples.md +1045 -0
- package/dist/docs/notification-center.json +71 -15
- package/dist/docs/notification-center.md +76 -266
- package/dist/docs/otp-input.examples.md +490 -0
- package/dist/docs/otp-input.json +65 -25
- package/dist/docs/otp-input.md +20 -191
- package/dist/docs/page-header.examples.md +1041 -0
- package/dist/docs/page-header.json +75 -43
- package/dist/docs/page-header.md +79 -291
- package/dist/docs/page.examples.md +633 -0
- package/dist/docs/page.json +48 -16
- package/dist/docs/page.md +62 -129
- package/dist/docs/prompt-composer.examples.md +630 -0
- package/dist/docs/prompt-composer.json +66 -18
- package/dist/docs/prompt-composer.md +35 -161
- package/dist/docs/prose.json +69 -37
- package/dist/docs/prose.md +393 -75
- package/dist/docs/rating.examples.md +525 -0
- package/dist/docs/rating.json +92 -28
- package/dist/docs/rating.md +27 -241
- package/dist/docs/saved-views.examples.md +1108 -0
- package/dist/docs/saved-views.json +53 -21
- package/dist/docs/saved-views.md +86 -171
- package/dist/docs/scroll-area.examples.md +837 -0
- package/dist/docs/scroll-area.json +64 -24
- package/dist/docs/scroll-area.md +57 -140
- package/dist/docs/section.examples.md +676 -0
- package/dist/docs/section.json +68 -20
- package/dist/docs/section.md +39 -162
- package/dist/docs/segmented-control.examples.md +480 -0
- package/dist/docs/segmented-control.json +76 -28
- package/dist/docs/segmented-control.md +20 -191
- package/dist/docs/side-navigation.examples.md +1468 -0
- package/dist/docs/side-navigation.json +53 -53
- package/dist/docs/side-navigation.md +79 -354
- package/dist/docs/slider.examples.md +505 -0
- package/dist/docs/slider.json +91 -51
- package/dist/docs/slider.md +47 -212
- package/dist/docs/sparkline.json +60 -36
- package/dist/docs/sparkline.md +447 -71
- package/dist/docs/split-button.examples.md +509 -0
- package/dist/docs/split-button.json +73 -41
- package/dist/docs/split-button.md +64 -194
- package/dist/docs/splitter.examples.md +921 -0
- package/dist/docs/splitter.json +94 -46
- package/dist/docs/splitter.md +75 -182
- package/dist/docs/stat-card.examples.md +725 -0
- package/dist/docs/stat-card.json +89 -41
- package/dist/docs/stat-card.md +55 -227
- package/dist/docs/status-indicator.json +80 -32
- package/dist/docs/status-indicator.md +409 -65
- package/dist/docs/stepper.json +53 -21
- package/dist/docs/stepper.md +369 -48
- package/dist/docs/table-of-contents.examples.md +550 -0
- package/dist/docs/table-of-contents.json +60 -28
- package/dist/docs/table-of-contents.md +70 -205
- package/dist/docs/tags-input.examples.md +541 -0
- package/dist/docs/tags-input.json +64 -16
- package/dist/docs/tags-input.md +15 -262
- package/dist/docs/time-field.examples.md +587 -0
- package/dist/docs/time-field.json +69 -29
- package/dist/docs/time-field.md +21 -223
- package/dist/docs/time-picker.json +117 -53
- package/dist/docs/time-picker.md +499 -54
- package/dist/docs/time-range-picker.examples.md +750 -0
- package/dist/docs/time-range-picker.json +139 -75
- package/dist/docs/time-range-picker.md +63 -225
- package/dist/docs/timeline.examples.md +617 -0
- package/dist/docs/timeline.json +44 -28
- package/dist/docs/timeline.md +34 -208
- package/dist/docs/toolbar.json +56 -16
- package/dist/docs/toolbar.md +357 -63
- package/dist/docs/top-navigation.examples.md +1206 -140
- package/dist/docs/top-navigation.json +49 -33
- package/dist/docs/top-navigation.md +87 -36
- package/dist/docs/tour.examples.md +960 -0
- package/dist/docs/tour.json +57 -25
- package/dist/docs/tour.md +60 -244
- package/dist/docs/transfer.examples.md +631 -0
- package/dist/docs/transfer.json +80 -16
- package/dist/docs/transfer.md +41 -170
- package/dist/docs/typography.json +96 -0
- package/dist/docs/typography.md +352 -4
- package/dist/docs/upload.examples.md +555 -53
- package/dist/docs/upload.json +62 -30
- package/dist/docs/upload.md +46 -11
- package/dist/docs/wizard.examples.md +1389 -0
- package/dist/docs/wizard.json +89 -49
- package/dist/docs/wizard.md +122 -263
- package/dist/{entity-picker-CC4VoC3p.js → entity-picker-C78f3Z0o.js} +9 -6
- package/dist/entity-picker.js +1 -1
- package/dist/{event-calendar-CjmF_e0H.js → event-calendar-DJPoCi-O.js} +1 -1
- package/dist/event-calendar.js +1 -1
- package/dist/{filter-bar-B3QJD7SZ.js → filter-bar-D61wiQFP.js} +1 -1
- package/dist/filter-bar.js +1 -1
- package/dist/{import-export-center-CW8YVZev.js → import-export-center-mqvmlzwB.js} +44 -36
- package/dist/import-export-center.js +1 -1
- package/dist/index.js +58 -58
- package/dist/{markdown-BdskE4-L.js → markdown-8CtV4k44.js} +2 -2
- package/dist/markdown.js +1 -1
- package/dist/{media-viewer-zEXcwfEY.js → media-viewer-C_cbuAq-.js} +64 -60
- package/dist/media-viewer.js +2 -2
- package/dist/message-P91bEGyV.js +455 -0
- package/dist/message.js +2 -2
- package/dist/{page-header-DmwBGwlm.js → page-header-jeAIQSZM.js} +103 -108
- package/dist/page-header.js +1 -1
- package/dist/section-CVTQdWBl.js +216 -0
- package/dist/section.js +2 -2
- package/dist/{segmented-control-CbK7SurB.js → segmented-control-BSMVjukr.js} +1 -1
- package/dist/segmented-control.js +1 -1
- package/dist/{side-navigation-CKRETc8E.js → side-navigation-BQzBxz2B.js} +179 -179
- package/dist/side-navigation.js +1 -1
- package/dist/{stat-card-CL3Xe6pV.js → stat-card-BpGZiFbG.js} +12 -14
- package/dist/stat-card.js +1 -1
- package/dist/{stepper-DHdrANZI.js → stepper-Cxb_tHnA.js} +130 -127
- package/dist/stepper.js +2 -2
- package/dist/styles/carousel.css +1 -1
- package/dist/styles/index.css +1 -1
- package/dist/styles.css +1 -1
- package/dist/{timeline-BiL2CXfn.js → timeline-ZngK6zLC.js} +9 -6
- package/dist/timeline.js +1 -1
- package/dist/top-navigation-YSEQzBhD.js +744 -0
- package/dist/top-navigation.js +2 -2
- package/dist/{transfer-sKUvmEKe.js → transfer-Cv5yQuTN.js} +1 -1
- package/dist/transfer.js +1 -1
- package/dist/types/attachment/attachment-parts.d.ts +24 -11
- package/dist/types/attachment/attachment-parts.d.ts.map +1 -1
- package/dist/types/attachment/attachment.d.ts +3 -3
- package/dist/types/attachment/attachment.d.ts.map +1 -1
- package/dist/types/avatar-group/avatar-group.d.ts.map +1 -1
- package/dist/types/carousel/carousel-parts.d.ts +2 -2
- package/dist/types/command-palette/command-palette.d.ts.map +1 -1
- package/dist/types/data-list/data-list.d.ts.map +1 -1
- package/dist/types/detail-panel/detail-panel-parts.d.ts +10 -3
- package/dist/types/detail-panel/detail-panel-parts.d.ts.map +1 -1
- package/dist/types/detail-panel/detail-panel.d.ts.map +1 -1
- package/dist/types/detail-panel/detail-panel.types.d.ts +7 -0
- package/dist/types/detail-panel/detail-panel.types.d.ts.map +1 -1
- package/dist/types/entity-picker/entity-picker.d.ts.map +1 -1
- package/dist/types/import-export-center/import-export-center.d.ts.map +1 -1
- package/dist/types/media-viewer/index.d.ts +2 -2
- package/dist/types/media-viewer/index.d.ts.map +1 -1
- package/dist/types/media-viewer/media-viewer-bar.d.ts +3 -1
- package/dist/types/media-viewer/media-viewer-bar.d.ts.map +1 -1
- package/dist/types/media-viewer/media-viewer.types.d.ts +1 -0
- package/dist/types/media-viewer/media-viewer.types.d.ts.map +1 -1
- package/dist/types/message/message-parts.d.ts +7 -0
- package/dist/types/message/message-parts.d.ts.map +1 -1
- package/dist/types/message/message.d.ts.map +1 -1
- package/dist/types/page-header/page-header-parts.d.ts.map +1 -1
- package/dist/types/section/section-parts.d.ts +16 -8
- package/dist/types/section/section-parts.d.ts.map +1 -1
- package/dist/types/section/section.d.ts.map +1 -1
- package/dist/types/segmented-control/segmented-control-parts.d.ts.map +1 -1
- package/dist/types/side-navigation/side-navigation-parts.d.ts.map +1 -1
- package/dist/types/stat-card/stat-card-delta.d.ts.map +1 -1
- package/dist/types/stat-card/stat-card-parts.d.ts +3 -3
- package/dist/types/stat-card/stat-card-parts.d.ts.map +1 -1
- package/dist/types/stepper/stepper-parts.d.ts +11 -2
- package/dist/types/stepper/stepper-parts.d.ts.map +1 -1
- package/dist/types/stepper/stepper.d.ts.map +1 -1
- package/dist/types/timeline/timeline-parts.d.ts.map +1 -1
- package/dist/types/top-navigation/top-navigation.d.ts.map +1 -1
- package/dist/{wizard-4c0X7Bx_.js → wizard-Dfryz1id.js} +214 -214
- package/dist/wizard.js +1 -1
- package/package.json +6 -6
- package/dist/attachment-MqczA38F.js +0 -292
- package/dist/detail-panel-EImAtksY.js +0 -327
- package/dist/message-D1Dd6Y2k.js +0 -452
- package/dist/section-D_qOfdxR.js +0 -213
- package/dist/top-navigation-D8IHPOmm.js +0 -744
|
@@ -0,0 +1,764 @@
|
|
|
1
|
+
<!-- index: ./index.md -->
|
|
2
|
+
# column-manager
|
|
3
|
+
|
|
4
|
+
`data-ui="column-manager"` · Shows, hides, orders and pins table columns.
|
|
5
|
+
|
|
6
|
+
## Examples
|
|
7
|
+
|
|
8
|
+
### Playground
|
|
9
|
+
|
|
10
|
+
An orders listing’s nine columns behind a trigger. Hide one and watch the count on the trigger; switch presentation and apply in the controls below.
|
|
11
|
+
|
|
12
|
+
Excerpt — not a complete module
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
const manager = useRef<ColumnManagerHandle>(null);
|
|
16
|
+
|
|
17
|
+
<ColumnManagerTrigger manager={manager}>Columns</ColumnManagerTrigger>;
|
|
18
|
+
<ColumnManager
|
|
19
|
+
columnState={state}
|
|
20
|
+
columns={columns}
|
|
21
|
+
onColumnStateChange={(next) => setState(next)}
|
|
22
|
+
ref={manager}
|
|
23
|
+
/>;
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### In a popover on the trigger
|
|
27
|
+
|
|
28
|
+
The default presentation: a popover anchored on the trigger, 22rem wide, the search focused on open. Escape and a press outside close it and focus returns to the trigger.
|
|
29
|
+
|
|
30
|
+
Excerpt — not a complete module
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
<ColumnManager columns={columns} presentation="popover" ref={manager} />;
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### In a drawer at the end
|
|
37
|
+
|
|
38
|
+
The same panel as the drawer family at side end, size sm, for a grid with many columns: the list takes the drawer’s height and is not capped.
|
|
39
|
+
|
|
40
|
+
Example
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
import type { GridColumn } from '@slotted/core/grid';
|
|
44
|
+
import { ColumnManager, ColumnManagerTrigger } from '@slotted/react/column-manager';
|
|
45
|
+
import type { ColumnManagerHandle } from '@slotted/react/column-manager';
|
|
46
|
+
import { Inline } from '@slotted/react/inline';
|
|
47
|
+
import { Stack } from '@slotted/react/stack';
|
|
48
|
+
import { Text } from '@slotted/react/typography';
|
|
49
|
+
import { useRef, useState } from 'react';
|
|
50
|
+
|
|
51
|
+
const COLUMNS: GridColumn[] = [
|
|
52
|
+
{ id: 'number', label: 'Order', hideable: false },
|
|
53
|
+
{ id: 'customer', label: 'Customer' },
|
|
54
|
+
{
|
|
55
|
+
id: 'status',
|
|
56
|
+
label: 'Status',
|
|
57
|
+
description: 'Fulfilment stage, updated when the ship date is confirmed',
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
id: 'total',
|
|
61
|
+
label: 'Total',
|
|
62
|
+
kind: 'number',
|
|
63
|
+
description: 'Order value with tax, in the order currency',
|
|
64
|
+
},
|
|
65
|
+
{ id: 'due', label: 'Due date', description: 'The date promised to the customer' },
|
|
66
|
+
{ id: 'owner', label: 'Owner' },
|
|
67
|
+
{ id: 'notes', label: 'Notes' },
|
|
68
|
+
{ id: 'actions', label: 'Actions', kind: 'actions', reorderable: false },
|
|
69
|
+
];
|
|
70
|
+
|
|
71
|
+
export default function ColumnManagerDrawerExample() {
|
|
72
|
+
const manager = useRef<ColumnManagerHandle>(null);
|
|
73
|
+
const [open, setOpen] = useState(false);
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<Stack gap={3}>
|
|
77
|
+
<Inline>
|
|
78
|
+
<ColumnManagerTrigger manager={manager}>Columns</ColumnManagerTrigger>
|
|
79
|
+
</Inline>
|
|
80
|
+
<Text size="sm" tone="muted">
|
|
81
|
+
{open ? 'The drawer is open.' : 'The drawer is closed.'}
|
|
82
|
+
</Text>
|
|
83
|
+
|
|
84
|
+
<ColumnManager
|
|
85
|
+
columns={COLUMNS}
|
|
86
|
+
onOpenChange={setOpen}
|
|
87
|
+
open={open}
|
|
88
|
+
presentation="drawer"
|
|
89
|
+
ref={manager}
|
|
90
|
+
/>
|
|
91
|
+
</Stack>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Apply once
|
|
97
|
+
|
|
98
|
+
Under apply="confirm" every action edits a draft: hide two columns and move one, and the log stays empty until Apply asks once with the reason submit and every key that moved. Cancel discards the draft.
|
|
99
|
+
|
|
100
|
+
Example
|
|
101
|
+
|
|
102
|
+
```tsx
|
|
103
|
+
import type { GridColumn, GridColumnState } from '@slotted/core/grid';
|
|
104
|
+
import { ColumnManager } from '@slotted/react/column-manager';
|
|
105
|
+
import type { ColumnManagerRequest } from '@slotted/react/column-manager';
|
|
106
|
+
import { Stack } from '@slotted/react/stack';
|
|
107
|
+
import { Text } from '@slotted/react/typography';
|
|
108
|
+
import { useState } from 'react';
|
|
109
|
+
|
|
110
|
+
const COLUMNS: GridColumn[] = [
|
|
111
|
+
{ id: 'number', label: 'Order', hideable: false },
|
|
112
|
+
{ id: 'customer', label: 'Customer' },
|
|
113
|
+
{
|
|
114
|
+
id: 'status',
|
|
115
|
+
label: 'Status',
|
|
116
|
+
description: 'Fulfilment stage, updated when the ship date is confirmed',
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
id: 'total',
|
|
120
|
+
label: 'Total',
|
|
121
|
+
kind: 'number',
|
|
122
|
+
description: 'Order value with tax, in the order currency',
|
|
123
|
+
},
|
|
124
|
+
{ id: 'due', label: 'Due date', description: 'The date promised to the customer' },
|
|
125
|
+
{ id: 'owner', label: 'Owner' },
|
|
126
|
+
{ id: 'notes', label: 'Notes' },
|
|
127
|
+
{ id: 'actions', label: 'Actions', kind: 'actions', reorderable: false },
|
|
128
|
+
];
|
|
129
|
+
|
|
130
|
+
export default function ColumnManagerConfirmExample() {
|
|
131
|
+
const [last, setLast] = useState('Nothing applied yet.');
|
|
132
|
+
|
|
133
|
+
function handleChange(_next: GridColumnState, request: ColumnManagerRequest) {
|
|
134
|
+
setLast(`Applied: ${request.changes.join(', ')}. Reason: ${request.reason}.`);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return (
|
|
138
|
+
<Stack gap={4}>
|
|
139
|
+
<ColumnManager
|
|
140
|
+
apply="confirm"
|
|
141
|
+
columns={COLUMNS}
|
|
142
|
+
onColumnStateChange={handleChange}
|
|
143
|
+
presentation="inline"
|
|
144
|
+
/>
|
|
145
|
+
<Text size="sm" tone="muted">
|
|
146
|
+
{last}
|
|
147
|
+
</Text>
|
|
148
|
+
</Stack>
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Search by name and description
|
|
154
|
+
|
|
155
|
+
Type “date”: Due date matches by its name and Status by its description. “regiao” finds Região — case and accents fall away. While a query stands every grip is disabled, because a place in a subset is not a place in the list.
|
|
156
|
+
|
|
157
|
+
Example
|
|
158
|
+
|
|
159
|
+
```tsx
|
|
160
|
+
import type { GridColumn } from '@slotted/core/grid';
|
|
161
|
+
import { ColumnManager } from '@slotted/react/column-manager';
|
|
162
|
+
|
|
163
|
+
const COLUMNS: GridColumn[] = [
|
|
164
|
+
{ id: 'number', label: 'Order', hideable: false },
|
|
165
|
+
{ id: 'customer', label: 'Customer', description: 'The account that placed the order' },
|
|
166
|
+
{
|
|
167
|
+
id: 'status',
|
|
168
|
+
label: 'Status',
|
|
169
|
+
description: 'Fulfilment stage, updated when the ship date is confirmed',
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
id: 'total',
|
|
173
|
+
label: 'Total',
|
|
174
|
+
kind: 'number',
|
|
175
|
+
description: 'Order value with tax, in the order currency',
|
|
176
|
+
},
|
|
177
|
+
{ id: 'due', label: 'Due date', description: 'The date promised to the customer' },
|
|
178
|
+
{ id: 'shipped', label: 'Shipped', description: 'The date the carrier collected the parcel' },
|
|
179
|
+
{ id: 'owner', label: 'Owner', description: 'The sales representative who owns the account' },
|
|
180
|
+
{ id: 'carrier', label: 'Carrier' },
|
|
181
|
+
];
|
|
182
|
+
|
|
183
|
+
export default function ColumnManagerSearchExample() {
|
|
184
|
+
return <ColumnManager columns={COLUMNS} presentation="inline" />;
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Required, and the last shown column
|
|
189
|
+
|
|
190
|
+
Order is hideable: false — ticked, disabled and marked Required. With every other column hidden, the last shown one is disabled too: the manager never asks for a grid with no column.
|
|
191
|
+
|
|
192
|
+
Excerpt — not a complete module
|
|
193
|
+
|
|
194
|
+
```tsx
|
|
195
|
+
const columns = [{ id: 'number', label: 'Order', hideable: false }, ...rest];
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Hidden for space, shown in row
|
|
199
|
+
|
|
200
|
+
The grid moved Owner into its rows’ pop-in and hid Região for room. Their boxes keep the reader’s value and their status says where they are; the sets never enter the state.
|
|
201
|
+
|
|
202
|
+
Excerpt — not a complete module
|
|
203
|
+
|
|
204
|
+
```tsx
|
|
205
|
+
<DataGrid columns={columns} onOutOfSpaceChange={setOutOfSpace} rows={orders} />;
|
|
206
|
+
<ColumnManager columns={columns} outOfSpace={outOfSpace} />;
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Reorder by pointer and by keyboard
|
|
210
|
+
|
|
211
|
+
Drag a grip: the row dims and a line marks where it lands, inside its zone only. Or focus a grip and press Alt+ArrowDown: the column moves one place, “Customer moved to position 3” is announced, and focus stays on the grip.
|
|
212
|
+
|
|
213
|
+
Example
|
|
214
|
+
|
|
215
|
+
```tsx
|
|
216
|
+
import type { GridColumn, GridColumnState } from '@slotted/core/grid';
|
|
217
|
+
import { normalizeColumnState } from '@slotted/core/grid';
|
|
218
|
+
import { ColumnManager } from '@slotted/react/column-manager';
|
|
219
|
+
import type { ColumnManagerRequest } from '@slotted/react/column-manager';
|
|
220
|
+
import { Stack } from '@slotted/react/stack';
|
|
221
|
+
import { Text } from '@slotted/react/typography';
|
|
222
|
+
import { useState } from 'react';
|
|
223
|
+
|
|
224
|
+
const COLUMNS: GridColumn[] = [
|
|
225
|
+
{ id: 'number', label: 'Order', hideable: false },
|
|
226
|
+
{ id: 'customer', label: 'Customer' },
|
|
227
|
+
{
|
|
228
|
+
id: 'status',
|
|
229
|
+
label: 'Status',
|
|
230
|
+
description: 'Fulfilment stage, updated when the ship date is confirmed',
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
id: 'total',
|
|
234
|
+
label: 'Total',
|
|
235
|
+
kind: 'number',
|
|
236
|
+
description: 'Order value with tax, in the order currency',
|
|
237
|
+
},
|
|
238
|
+
{ id: 'due', label: 'Due date', description: 'The date promised to the customer' },
|
|
239
|
+
{ id: 'owner', label: 'Owner' },
|
|
240
|
+
{ id: 'notes', label: 'Notes' },
|
|
241
|
+
{ id: 'actions', label: 'Actions', kind: 'actions', reorderable: false },
|
|
242
|
+
];
|
|
243
|
+
|
|
244
|
+
const START = { pinned: { start: ['number'], end: ['actions'] } };
|
|
245
|
+
|
|
246
|
+
export default function ColumnManagerReorderExample() {
|
|
247
|
+
const [state, setState] = useState(() => normalizeColumnState(START, COLUMNS));
|
|
248
|
+
const [last, setLast] = useState('No request yet.');
|
|
249
|
+
|
|
250
|
+
function handleChange(next: GridColumnState, request: ColumnManagerRequest) {
|
|
251
|
+
setState(next);
|
|
252
|
+
setLast(`change: ${request.change}, reason: ${request.reason}`);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
return (
|
|
256
|
+
<Stack gap={4}>
|
|
257
|
+
<ColumnManager
|
|
258
|
+
columnState={state}
|
|
259
|
+
columns={COLUMNS}
|
|
260
|
+
onColumnStateChange={handleChange}
|
|
261
|
+
presentation="inline"
|
|
262
|
+
/>
|
|
263
|
+
<Text size="sm" tone="muted">
|
|
264
|
+
{last}
|
|
265
|
+
</Text>
|
|
266
|
+
</Stack>
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
### Pinning
|
|
272
|
+
|
|
273
|
+
Order is pinned to the start and Actions to the end, each in its section. Open a row’s pin to move it between zones; a pinned column’s pin is in the accent ink, and a move never crosses a zone.
|
|
274
|
+
|
|
275
|
+
Example
|
|
276
|
+
|
|
277
|
+
```tsx
|
|
278
|
+
import type { GridColumn } from '@slotted/core/grid';
|
|
279
|
+
import { ColumnManager } from '@slotted/react/column-manager';
|
|
280
|
+
|
|
281
|
+
const COLUMNS: GridColumn[] = [
|
|
282
|
+
{ id: 'number', label: 'Order', hideable: false },
|
|
283
|
+
{ id: 'customer', label: 'Customer' },
|
|
284
|
+
{
|
|
285
|
+
id: 'status',
|
|
286
|
+
label: 'Status',
|
|
287
|
+
description: 'Fulfilment stage, updated when the ship date is confirmed',
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
id: 'total',
|
|
291
|
+
label: 'Total',
|
|
292
|
+
kind: 'number',
|
|
293
|
+
description: 'Order value with tax, in the order currency',
|
|
294
|
+
},
|
|
295
|
+
{ id: 'due', label: 'Due date', description: 'The date promised to the customer' },
|
|
296
|
+
{ id: 'owner', label: 'Owner' },
|
|
297
|
+
{ id: 'notes', label: 'Notes' },
|
|
298
|
+
{ id: 'actions', label: 'Actions', kind: 'actions', reorderable: false },
|
|
299
|
+
];
|
|
300
|
+
|
|
301
|
+
const START = { pinned: { start: ['number', 'customer'], end: ['actions'] } };
|
|
302
|
+
|
|
303
|
+
export default function ColumnManagerPinningExample() {
|
|
304
|
+
return <ColumnManager columns={COLUMNS} defaultColumnState={START} presentation="inline" />;
|
|
305
|
+
}
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
### Show all and Restore defaults
|
|
309
|
+
|
|
310
|
+
Four columns hidden against a default of one. Show all asks for none hidden; Restore defaults asks for defaultColumnState with the reason clear. Each is disabled while it would change nothing.
|
|
311
|
+
|
|
312
|
+
Excerpt — not a complete module
|
|
313
|
+
|
|
314
|
+
```tsx
|
|
315
|
+
<ColumnManager
|
|
316
|
+
columnState={state}
|
|
317
|
+
columns={columns}
|
|
318
|
+
defaultColumnState={defaults}
|
|
319
|
+
onColumnStateChange={(next, request) => {
|
|
320
|
+
if (request.reason === 'clear') toast('Columns restored');
|
|
321
|
+
setState(next);
|
|
322
|
+
}}
|
|
323
|
+
/>;
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
### The count on the trigger
|
|
327
|
+
|
|
328
|
+
No count at zero, a chip at one and at twelve. The chip is aria-hidden and a visually hidden sentence names the trigger — “Columns 12 hidden columns” — so the number is heard once, as words.
|
|
329
|
+
|
|
330
|
+
Excerpt — not a complete module
|
|
331
|
+
|
|
332
|
+
```tsx
|
|
333
|
+
<ColumnManagerTrigger
|
|
334
|
+
manager={manager}
|
|
335
|
+
render={({ children, ...props }) => (
|
|
336
|
+
<Button {...props} size="sm" variant="ghost">
|
|
337
|
+
{children}
|
|
338
|
+
</Button>
|
|
339
|
+
)}
|
|
340
|
+
>
|
|
341
|
+
Columns
|
|
342
|
+
</ColumnManagerTrigger>;
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
### With the data grid
|
|
346
|
+
|
|
347
|
+
The grid and the manager share one column state. Manage columns… in any column menu opens the manager the toolbar trigger opens; narrow the room and the grid’s outOfSpace reaches the list as Shown in row and Hidden for space.
|
|
348
|
+
|
|
349
|
+
Excerpt — not a complete module
|
|
350
|
+
|
|
351
|
+
```tsx
|
|
352
|
+
<>
|
|
353
|
+
<ColumnManagerTrigger manager={manager}>Columns</ColumnManagerTrigger>
|
|
354
|
+
<DataGrid
|
|
355
|
+
columnState={state}
|
|
356
|
+
columns={columns}
|
|
357
|
+
onColumnStateChange={(next) => setState(next)}
|
|
358
|
+
onManageColumns={() => manager.current?.show()}
|
|
359
|
+
onOutOfSpaceChange={setOutOfSpace}
|
|
360
|
+
rowKey="id"
|
|
361
|
+
rows={orders}
|
|
362
|
+
/>
|
|
363
|
+
<ColumnManager
|
|
364
|
+
columnState={state}
|
|
365
|
+
columns={columns}
|
|
366
|
+
onColumnStateChange={(next) => setState(next)}
|
|
367
|
+
outOfSpace={outOfSpace}
|
|
368
|
+
ref={manager}
|
|
369
|
+
/>
|
|
370
|
+
</>;
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
### Keyboard
|
|
374
|
+
|
|
375
|
+
Tab walks the search, then each row’s checkbox, grip and pin, then the footer. Space toggles a box; Alt+ArrowUp/Down on a grip moves the column; Enter on a pin opens its menu; Escape during a drag cancels it.
|
|
376
|
+
|
|
377
|
+
Excerpt — not a complete module
|
|
378
|
+
|
|
379
|
+
```tsx
|
|
380
|
+
<ColumnManager columns={columns} presentation="inline" />;
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
### Names, descriptions and announcements
|
|
384
|
+
|
|
385
|
+
The panel is a group named Columns and each zone a group named by its label. A box is named by the column and its status and described by its description; a keyboard move is announced politely with the new position.
|
|
386
|
+
|
|
387
|
+
Excerpt — not a complete module
|
|
388
|
+
|
|
389
|
+
```tsx
|
|
390
|
+
<SlottedProvider catalogs={{ 'pt-BR': PT_BR }} locale="pt-BR">
|
|
391
|
+
<App />
|
|
392
|
+
</SlottedProvider>;
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
### count.tsx
|
|
396
|
+
|
|
397
|
+
Example
|
|
398
|
+
|
|
399
|
+
```tsx
|
|
400
|
+
import type { GridColumn } from '@slotted/core/grid';
|
|
401
|
+
import { ColumnManager, ColumnManagerTrigger } from '@slotted/react/column-manager';
|
|
402
|
+
import type { ColumnManagerHandle } from '@slotted/react/column-manager';
|
|
403
|
+
import { Inline } from '@slotted/react/inline';
|
|
404
|
+
import { useRef } from 'react';
|
|
405
|
+
|
|
406
|
+
const COLUMNS: GridColumn[] = [
|
|
407
|
+
{ id: 'number', label: 'Order', hideable: false },
|
|
408
|
+
{ id: 'customer', label: 'Customer' },
|
|
409
|
+
{
|
|
410
|
+
id: 'status',
|
|
411
|
+
label: 'Status',
|
|
412
|
+
description: 'Fulfilment stage, updated when the ship date is confirmed',
|
|
413
|
+
},
|
|
414
|
+
{
|
|
415
|
+
id: 'total',
|
|
416
|
+
label: 'Total',
|
|
417
|
+
kind: 'number',
|
|
418
|
+
description: 'Order value with tax, in the order currency',
|
|
419
|
+
},
|
|
420
|
+
{ id: 'due', label: 'Due date', description: 'The date promised to the customer' },
|
|
421
|
+
{ id: 'owner', label: 'Owner' },
|
|
422
|
+
{ id: 'notes', label: 'Notes' },
|
|
423
|
+
{ id: 'actions', label: 'Actions', kind: 'actions', reorderable: false },
|
|
424
|
+
];
|
|
425
|
+
|
|
426
|
+
const ORDERS = { hidden: [] };
|
|
427
|
+
const SHIPMENTS = { hidden: ['notes'] };
|
|
428
|
+
const INVOICES = { hidden: ['customer', 'status', 'owner', 'notes'] };
|
|
429
|
+
|
|
430
|
+
export default function ColumnManagerCountExample() {
|
|
431
|
+
const orders = useRef<ColumnManagerHandle>(null);
|
|
432
|
+
const shipments = useRef<ColumnManagerHandle>(null);
|
|
433
|
+
const invoices = useRef<ColumnManagerHandle>(null);
|
|
434
|
+
|
|
435
|
+
return (
|
|
436
|
+
<>
|
|
437
|
+
<Inline gap={3}>
|
|
438
|
+
<ColumnManagerTrigger manager={orders}>Orders</ColumnManagerTrigger>
|
|
439
|
+
<ColumnManagerTrigger manager={shipments}>Shipments</ColumnManagerTrigger>
|
|
440
|
+
<ColumnManagerTrigger manager={invoices}>Invoices</ColumnManagerTrigger>
|
|
441
|
+
</Inline>
|
|
442
|
+
|
|
443
|
+
<ColumnManager columns={COLUMNS} defaultColumnState={ORDERS} ref={orders} />
|
|
444
|
+
<ColumnManager columns={COLUMNS} defaultColumnState={SHIPMENTS} ref={shipments} />
|
|
445
|
+
<ColumnManager columns={COLUMNS} defaultColumnState={INVOICES} ref={invoices} />
|
|
446
|
+
</>
|
|
447
|
+
);
|
|
448
|
+
}
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
### data-grid.tsx
|
|
452
|
+
|
|
453
|
+
Example
|
|
454
|
+
|
|
455
|
+
```tsx
|
|
456
|
+
import type { GridColumn, GridColumnState, GridOutOfSpace } from '@slotted/core/grid';
|
|
457
|
+
import { normalizeColumnState } from '@slotted/core/grid';
|
|
458
|
+
import { ColumnManager, ColumnManagerTrigger } from '@slotted/react/column-manager';
|
|
459
|
+
import type { ColumnManagerHandle } from '@slotted/react/column-manager';
|
|
460
|
+
import { DataGrid } from '@slotted/react/data-grid';
|
|
461
|
+
import { Inline } from '@slotted/react/inline';
|
|
462
|
+
import { Stack } from '@slotted/react/stack';
|
|
463
|
+
import { useRef, useState } from 'react';
|
|
464
|
+
|
|
465
|
+
interface Order {
|
|
466
|
+
id: string;
|
|
467
|
+
number: string;
|
|
468
|
+
customer: string;
|
|
469
|
+
status: string;
|
|
470
|
+
total: number;
|
|
471
|
+
due: string;
|
|
472
|
+
owner: string;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
const ROWS: Order[] = [
|
|
476
|
+
{
|
|
477
|
+
id: 'o1',
|
|
478
|
+
number: 'SO-2026-01842',
|
|
479
|
+
customer: 'Northwind Fabrication',
|
|
480
|
+
status: 'Partial',
|
|
481
|
+
total: 12480,
|
|
482
|
+
due: '2026-09-24',
|
|
483
|
+
owner: 'Marta Silva',
|
|
484
|
+
},
|
|
485
|
+
{
|
|
486
|
+
id: 'o2',
|
|
487
|
+
number: 'SO-2026-01843',
|
|
488
|
+
customer: 'Helios Automation',
|
|
489
|
+
status: 'Approval',
|
|
490
|
+
total: 4120,
|
|
491
|
+
due: '2026-09-26',
|
|
492
|
+
owner: 'Daniel Okafor',
|
|
493
|
+
},
|
|
494
|
+
{
|
|
495
|
+
id: 'o3',
|
|
496
|
+
number: 'SO-2026-01844',
|
|
497
|
+
customer: 'Pacific Rail Supply',
|
|
498
|
+
status: 'Shipped',
|
|
499
|
+
total: 31900,
|
|
500
|
+
due: '2026-09-19',
|
|
501
|
+
owner: 'Ana Ribeiro',
|
|
502
|
+
},
|
|
503
|
+
{
|
|
504
|
+
id: 'o4',
|
|
505
|
+
number: 'SO-2026-01845',
|
|
506
|
+
customer: 'Tannery Row Leather',
|
|
507
|
+
status: 'Draft',
|
|
508
|
+
total: 860,
|
|
509
|
+
due: '2026-10-02',
|
|
510
|
+
owner: 'Marta Silva',
|
|
511
|
+
},
|
|
512
|
+
{
|
|
513
|
+
id: 'o5',
|
|
514
|
+
number: 'SO-2026-01846',
|
|
515
|
+
customer: 'Lumen Optics',
|
|
516
|
+
status: 'Delivered',
|
|
517
|
+
total: 15230,
|
|
518
|
+
due: '2026-09-12',
|
|
519
|
+
owner: 'Kenji Mori',
|
|
520
|
+
},
|
|
521
|
+
];
|
|
522
|
+
|
|
523
|
+
const USD = new Intl.NumberFormat('en-US', { currency: 'USD', style: 'currency' });
|
|
524
|
+
|
|
525
|
+
const COLUMNS: GridColumn<Order>[] = [
|
|
526
|
+
{
|
|
527
|
+
id: 'number',
|
|
528
|
+
label: 'Order',
|
|
529
|
+
accessor: 'number',
|
|
530
|
+
hideable: false,
|
|
531
|
+
rowHeader: true,
|
|
532
|
+
width: 140,
|
|
533
|
+
},
|
|
534
|
+
{ id: 'customer', label: 'Customer', accessor: 'customer', width: 190 },
|
|
535
|
+
{ id: 'status', label: 'Status', accessor: 'status', width: 110 },
|
|
536
|
+
{
|
|
537
|
+
id: 'total',
|
|
538
|
+
label: 'Total',
|
|
539
|
+
accessor: 'total',
|
|
540
|
+
kind: 'number',
|
|
541
|
+
width: 110,
|
|
542
|
+
format: (value) => (typeof value === 'number' ? USD.format(value) : ''),
|
|
543
|
+
},
|
|
544
|
+
{ id: 'due', label: 'Due date', accessor: 'due', width: 120 },
|
|
545
|
+
{ id: 'owner', label: 'Owner', accessor: 'owner', width: 140 },
|
|
546
|
+
];
|
|
547
|
+
|
|
548
|
+
const NO_ROOM_LOST: GridOutOfSpace = { popin: [], hidden: [] };
|
|
549
|
+
|
|
550
|
+
export default function ColumnManagerDataGridExample() {
|
|
551
|
+
const manager = useRef<ColumnManagerHandle>(null);
|
|
552
|
+
const [state, setState] = useState(() => normalizeColumnState({}, COLUMNS));
|
|
553
|
+
const [outOfSpace, setOutOfSpace] = useState(NO_ROOM_LOST);
|
|
554
|
+
|
|
555
|
+
function handleChange(next: GridColumnState) {
|
|
556
|
+
setState(next);
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
function handleManage() {
|
|
560
|
+
manager.current?.show();
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
return (
|
|
564
|
+
<Stack gap={4}>
|
|
565
|
+
<Inline>
|
|
566
|
+
<ColumnManagerTrigger manager={manager}>Columns</ColumnManagerTrigger>
|
|
567
|
+
</Inline>
|
|
568
|
+
|
|
569
|
+
<DataGrid
|
|
570
|
+
aria-label="Orders"
|
|
571
|
+
columnState={state}
|
|
572
|
+
columns={COLUMNS}
|
|
573
|
+
height="16rem"
|
|
574
|
+
onColumnStateChange={handleChange}
|
|
575
|
+
onManageColumns={handleManage}
|
|
576
|
+
onOutOfSpaceChange={setOutOfSpace}
|
|
577
|
+
rowKey="id"
|
|
578
|
+
rows={ROWS}
|
|
579
|
+
/>
|
|
580
|
+
|
|
581
|
+
<ColumnManager
|
|
582
|
+
columnState={state}
|
|
583
|
+
columns={COLUMNS}
|
|
584
|
+
onColumnStateChange={handleChange}
|
|
585
|
+
outOfSpace={outOfSpace}
|
|
586
|
+
ref={manager}
|
|
587
|
+
/>
|
|
588
|
+
</Stack>
|
|
589
|
+
);
|
|
590
|
+
}
|
|
591
|
+
```
|
|
592
|
+
|
|
593
|
+
### defaults.tsx
|
|
594
|
+
|
|
595
|
+
Example
|
|
596
|
+
|
|
597
|
+
```tsx
|
|
598
|
+
import type { GridColumn } from '@slotted/core/grid';
|
|
599
|
+
import {
|
|
600
|
+
ColumnManager,
|
|
601
|
+
ColumnManagerProvider,
|
|
602
|
+
ColumnManagerTrigger,
|
|
603
|
+
} from '@slotted/react/column-manager';
|
|
604
|
+
import type { ColumnManagerHandle } from '@slotted/react/column-manager';
|
|
605
|
+
import { Inline } from '@slotted/react/inline';
|
|
606
|
+
import { useRef } from 'react';
|
|
607
|
+
|
|
608
|
+
const COLUMNS: GridColumn[] = [
|
|
609
|
+
{ id: 'number', label: 'Order', hideable: false },
|
|
610
|
+
{ id: 'customer', label: 'Customer' },
|
|
611
|
+
{
|
|
612
|
+
id: 'status',
|
|
613
|
+
label: 'Status',
|
|
614
|
+
description: 'Fulfilment stage, updated when the ship date is confirmed',
|
|
615
|
+
},
|
|
616
|
+
{
|
|
617
|
+
id: 'total',
|
|
618
|
+
label: 'Total',
|
|
619
|
+
kind: 'number',
|
|
620
|
+
description: 'Order value with tax, in the order currency',
|
|
621
|
+
},
|
|
622
|
+
{ id: 'due', label: 'Due date', description: 'The date promised to the customer' },
|
|
623
|
+
{ id: 'owner', label: 'Owner' },
|
|
624
|
+
{ id: 'notes', label: 'Notes' },
|
|
625
|
+
{ id: 'actions', label: 'Actions', kind: 'actions', reorderable: false },
|
|
626
|
+
];
|
|
627
|
+
|
|
628
|
+
export default function ColumnManagerDefaultsExample() {
|
|
629
|
+
const orders = useRef<ColumnManagerHandle>(null);
|
|
630
|
+
const shipments = useRef<ColumnManagerHandle>(null);
|
|
631
|
+
|
|
632
|
+
return (
|
|
633
|
+
<ColumnManagerProvider apply="confirm" presentation="drawer">
|
|
634
|
+
<Inline gap={3}>
|
|
635
|
+
<ColumnManagerTrigger manager={orders}>Orders</ColumnManagerTrigger>
|
|
636
|
+
<ColumnManagerTrigger manager={shipments}>Shipments</ColumnManagerTrigger>
|
|
637
|
+
</Inline>
|
|
638
|
+
|
|
639
|
+
<ColumnManager columns={COLUMNS} ref={orders} />
|
|
640
|
+
<ColumnManager columns={COLUMNS} presentation="popover" ref={shipments} />
|
|
641
|
+
</ColumnManagerProvider>
|
|
642
|
+
);
|
|
643
|
+
}
|
|
644
|
+
```
|
|
645
|
+
|
|
646
|
+
### required.tsx
|
|
647
|
+
|
|
648
|
+
Example
|
|
649
|
+
|
|
650
|
+
```tsx
|
|
651
|
+
import type { GridColumn } from '@slotted/core/grid';
|
|
652
|
+
import { ColumnManager } from '@slotted/react/column-manager';
|
|
653
|
+
|
|
654
|
+
const COLUMNS: GridColumn[] = [
|
|
655
|
+
{ id: 'number', label: 'Order', hideable: false },
|
|
656
|
+
{ id: 'customer', label: 'Customer' },
|
|
657
|
+
{ id: 'status', label: 'Status' },
|
|
658
|
+
{ id: 'total', label: 'Total', kind: 'number' },
|
|
659
|
+
{ id: 'due', label: 'Due date' },
|
|
660
|
+
];
|
|
661
|
+
|
|
662
|
+
const START = { hidden: ['status', 'total', 'due'] };
|
|
663
|
+
|
|
664
|
+
export default function ColumnManagerRequiredExample() {
|
|
665
|
+
return <ColumnManager columns={COLUMNS} defaultColumnState={START} presentation="inline" />;
|
|
666
|
+
}
|
|
667
|
+
```
|
|
668
|
+
|
|
669
|
+
### restore.tsx
|
|
670
|
+
|
|
671
|
+
Example
|
|
672
|
+
|
|
673
|
+
```tsx
|
|
674
|
+
import type { GridColumn, GridColumnState } from '@slotted/core/grid';
|
|
675
|
+
import { normalizeColumnState } from '@slotted/core/grid';
|
|
676
|
+
import { ColumnManager } from '@slotted/react/column-manager';
|
|
677
|
+
import type { ColumnManagerRequest } from '@slotted/react/column-manager';
|
|
678
|
+
import { Stack } from '@slotted/react/stack';
|
|
679
|
+
import { Text } from '@slotted/react/typography';
|
|
680
|
+
import { useState } from 'react';
|
|
681
|
+
|
|
682
|
+
const COLUMNS: GridColumn[] = [
|
|
683
|
+
{ id: 'number', label: 'Order', hideable: false },
|
|
684
|
+
{ id: 'customer', label: 'Customer' },
|
|
685
|
+
{
|
|
686
|
+
id: 'status',
|
|
687
|
+
label: 'Status',
|
|
688
|
+
description: 'Fulfilment stage, updated when the ship date is confirmed',
|
|
689
|
+
},
|
|
690
|
+
{
|
|
691
|
+
id: 'total',
|
|
692
|
+
label: 'Total',
|
|
693
|
+
kind: 'number',
|
|
694
|
+
description: 'Order value with tax, in the order currency',
|
|
695
|
+
},
|
|
696
|
+
{ id: 'due', label: 'Due date', description: 'The date promised to the customer' },
|
|
697
|
+
{ id: 'owner', label: 'Owner' },
|
|
698
|
+
{ id: 'notes', label: 'Notes' },
|
|
699
|
+
{ id: 'actions', label: 'Actions', kind: 'actions', reorderable: false },
|
|
700
|
+
];
|
|
701
|
+
|
|
702
|
+
const DEFAULTS = { hidden: ['notes'], pinned: { start: ['number'], end: ['actions'] } };
|
|
703
|
+
const START = { ...DEFAULTS, hidden: ['notes', 'owner', 'due', 'total'] };
|
|
704
|
+
|
|
705
|
+
export default function ColumnManagerRestoreExample() {
|
|
706
|
+
const [state, setState] = useState(() => normalizeColumnState(START, COLUMNS));
|
|
707
|
+
const [last, setLast] = useState('No request yet.');
|
|
708
|
+
|
|
709
|
+
function handleChange(next: GridColumnState, request: ColumnManagerRequest) {
|
|
710
|
+
setState(next);
|
|
711
|
+
setLast(`change: ${request.change}, reason: ${request.reason}`);
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
return (
|
|
715
|
+
<Stack gap={4}>
|
|
716
|
+
<ColumnManager
|
|
717
|
+
columnState={state}
|
|
718
|
+
columns={COLUMNS}
|
|
719
|
+
defaultColumnState={DEFAULTS}
|
|
720
|
+
onColumnStateChange={handleChange}
|
|
721
|
+
presentation="inline"
|
|
722
|
+
/>
|
|
723
|
+
<Text size="sm" tone="muted">
|
|
724
|
+
{last}
|
|
725
|
+
</Text>
|
|
726
|
+
</Stack>
|
|
727
|
+
);
|
|
728
|
+
}
|
|
729
|
+
```
|
|
730
|
+
|
|
731
|
+
### space.tsx
|
|
732
|
+
|
|
733
|
+
Example
|
|
734
|
+
|
|
735
|
+
```tsx
|
|
736
|
+
import type { GridColumn, GridOutOfSpace } from '@slotted/core/grid';
|
|
737
|
+
import { ColumnManager } from '@slotted/react/column-manager';
|
|
738
|
+
|
|
739
|
+
const COLUMNS: GridColumn[] = [
|
|
740
|
+
{ id: 'number', label: 'Order', hideable: false },
|
|
741
|
+
{ id: 'customer', label: 'Customer' },
|
|
742
|
+
{
|
|
743
|
+
id: 'status',
|
|
744
|
+
label: 'Status',
|
|
745
|
+
description: 'Fulfilment stage, updated when the ship date is confirmed',
|
|
746
|
+
},
|
|
747
|
+
{
|
|
748
|
+
id: 'total',
|
|
749
|
+
label: 'Total',
|
|
750
|
+
kind: 'number',
|
|
751
|
+
description: 'Order value with tax, in the order currency',
|
|
752
|
+
},
|
|
753
|
+
{ id: 'due', label: 'Due date', description: 'The date promised to the customer' },
|
|
754
|
+
{ id: 'owner', label: 'Owner' },
|
|
755
|
+
{ id: 'notes', label: 'Notes' },
|
|
756
|
+
{ id: 'actions', label: 'Actions', kind: 'actions', reorderable: false },
|
|
757
|
+
];
|
|
758
|
+
|
|
759
|
+
const OUT_OF_SPACE: GridOutOfSpace = { popin: ['owner'], hidden: ['notes'] };
|
|
760
|
+
|
|
761
|
+
export default function ColumnManagerSpaceExample() {
|
|
762
|
+
return <ColumnManager columns={COLUMNS} outOfSpace={OUT_OF_SPACE} presentation="inline" />;
|
|
763
|
+
}
|
|
764
|
+
```
|