@sps-woodland/column-manager 8.51.3 → 8.52.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/README.md +0 -19
- package/lib/column-manager/ColumnManager.d.ts +22 -0
- package/lib/column-manager/useColumnManager.d.ts +26 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +166 -12
- package/lib/index.umd.cjs +5 -5
- package/package.json +20 -5
- package/vite.config.mjs +13 -5
package/README.md
CHANGED
|
@@ -1,22 +1,3 @@
|
|
|
1
1
|
## [@sps-woodland/column-manager](https://github.com/SPSCommerce/woodland/tree/master/packages/@sps-woodland/column-manager#readme)
|
|
2
2
|
|
|
3
3
|
SPS Woodland Design System Column Manager
|
|
4
|
-
|
|
5
|
-
### Imports
|
|
6
|
-
|
|
7
|
-
Prefer the mono-package subpath (single shared peer-dep declaration, deterministic tree-shaking):
|
|
8
|
-
|
|
9
|
-
```ts
|
|
10
|
-
import { ColumnManager, useColumnManager } from "@sps-woodland/core/column-manager";
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
`ColumnManager` styles come from `@sps-woodland/tokens` sprinkles — there is no separate
|
|
14
|
-
`column-manager/style.css` to import. Make sure your app already loads `@sps-woodland/tokens`
|
|
15
|
-
CSS, and you are set.
|
|
16
|
-
|
|
17
|
-
The legacy wrapper import still works during the transition (it re-exports from
|
|
18
|
-
`@sps-woodland/core/column-manager`):
|
|
19
|
-
|
|
20
|
-
```ts
|
|
21
|
-
import { ColumnManager, useColumnManager } from "@sps-woodland/column-manager";
|
|
22
|
-
```
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ComponentProps } from "@sps-woodland/core";
|
|
2
|
+
import type { ItemProps } from "@sps-woodland/add-to-list";
|
|
3
|
+
export type ColumnmanagerProps = ComponentProps<{
|
|
4
|
+
isOpen?: boolean;
|
|
5
|
+
title?: string;
|
|
6
|
+
visibleColumnsHeader?: string;
|
|
7
|
+
hiddenColumnsHeader?: string;
|
|
8
|
+
visibleColumns: ItemProps[];
|
|
9
|
+
hiddenColumns: ItemProps[];
|
|
10
|
+
manualSort?: boolean;
|
|
11
|
+
maxDisplayedItems?: number;
|
|
12
|
+
showIcons?: boolean;
|
|
13
|
+
showCount?: boolean;
|
|
14
|
+
showFilter?: boolean;
|
|
15
|
+
showMoveAllLinks?: boolean;
|
|
16
|
+
cancelButtonText?: string;
|
|
17
|
+
saveButtonText?: string;
|
|
18
|
+
onSave?: (visibleColumns: ItemProps[], hiddenColumns: ItemProps[]) => void;
|
|
19
|
+
onClose?: () => void;
|
|
20
|
+
onOpen?: () => void;
|
|
21
|
+
}>;
|
|
22
|
+
export declare function ColumnManager({ isOpen: isOpenProp, title, visibleColumnsHeader, hiddenColumnsHeader, visibleColumns, hiddenColumns, maxDisplayedItems, manualSort, showIcons, showCount, showFilter, showMoveAllLinks, cancelButtonText, saveButtonText, onSave, onOpen, onClose, "data-testid": dataTestId, }: ColumnmanagerProps): JSX.Element | null;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ItemProps } from "@sps-woodland/add-to-list";
|
|
2
|
+
export interface UseColumnManagerArgs {
|
|
3
|
+
visibleColumns: ItemProps[];
|
|
4
|
+
hiddenColumns: ItemProps[];
|
|
5
|
+
isOpen?: boolean;
|
|
6
|
+
onClose?: () => void;
|
|
7
|
+
onOpen?: () => void;
|
|
8
|
+
onSave?: (visibleColumns: ItemProps[], hiddenColumns: ItemProps[]) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare const useColumnManager: ({ isOpen: isOpenArg, visibleColumns, hiddenColumns, onClose, onOpen, onSave, }: UseColumnManagerArgs) => {
|
|
11
|
+
visibleColumns: ItemProps[];
|
|
12
|
+
hiddenColumns: ItemProps[];
|
|
13
|
+
isOpen: boolean;
|
|
14
|
+
columnManagerProps: {
|
|
15
|
+
visibleColumns: ItemProps[];
|
|
16
|
+
hiddenColumns: ItemProps[];
|
|
17
|
+
isOpen: boolean;
|
|
18
|
+
onClose: () => void;
|
|
19
|
+
onSave: (visible: ItemProps[], hidden: ItemProps[]) => void;
|
|
20
|
+
};
|
|
21
|
+
triggerProps: {
|
|
22
|
+
onClick: () => void;
|
|
23
|
+
};
|
|
24
|
+
setColumns: (visible: ItemProps[], hidden: ItemProps[]) => void;
|
|
25
|
+
setOpen: (open: boolean) => void;
|
|
26
|
+
};
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -1,15 +1,167 @@
|
|
|
1
|
-
import { ColumnManager as n } from "@sps-woodland/core/column-manager";
|
|
2
|
-
export * from "@sps-woodland/core/column-manager";
|
|
3
1
|
import * as e from "react";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import { Metadata as R, useChildTestIdAttrBuilder as A } from "@sps-woodland/core";
|
|
3
|
+
import { AddToList as I } from "@sps-woodland/add-to-list";
|
|
4
|
+
import { sprinkles as L } from "@sps-woodland/tokens";
|
|
5
|
+
import { SpsModal as V, SpsModalFooter as x, SpsButton as H } from "@spscommerce/ds-react";
|
|
6
|
+
import { ModalSize as F, ModalKind as j, ButtonKind as P } from "@spscommerce/ds-shared";
|
|
7
|
+
import { useWoodlandLanguage as q } from "@spscommerce/i18n";
|
|
8
|
+
import { code as m } from "@spscommerce/utils";
|
|
9
|
+
function y({
|
|
10
|
+
isOpen: a,
|
|
11
|
+
title: d,
|
|
12
|
+
visibleColumnsHeader: c,
|
|
13
|
+
hiddenColumnsHeader: p,
|
|
14
|
+
visibleColumns: s,
|
|
15
|
+
hiddenColumns: i,
|
|
16
|
+
maxDisplayedItems: l,
|
|
17
|
+
manualSort: t = !0,
|
|
18
|
+
showIcons: h = !0,
|
|
19
|
+
showCount: C = !0,
|
|
20
|
+
showFilter: b = !0,
|
|
21
|
+
showMoveAllLinks: f = !0,
|
|
22
|
+
cancelButtonText: g,
|
|
23
|
+
saveButtonText: n,
|
|
24
|
+
onSave: o,
|
|
25
|
+
onOpen: v,
|
|
26
|
+
onClose: B,
|
|
27
|
+
"data-testid": w
|
|
28
|
+
}) {
|
|
29
|
+
const [E, O] = e.useState(!!a), { t: r } = q(), M = A({ "data-testid": w }), [u, S] = e.useState({
|
|
30
|
+
visibleColumns: s,
|
|
31
|
+
hiddenColumns: i
|
|
32
|
+
}), k = () => {
|
|
33
|
+
O(!1), B?.();
|
|
34
|
+
};
|
|
35
|
+
return e.useEffect(() => {
|
|
36
|
+
E && (S({ visibleColumns: s, hiddenColumns: i }), v?.());
|
|
37
|
+
}, [E]), e.useEffect(() => {
|
|
38
|
+
O(!!a);
|
|
39
|
+
}, [a]), E ? /* @__PURE__ */ e.createElement(
|
|
40
|
+
V,
|
|
41
|
+
{
|
|
42
|
+
title: d || r("columnManager.title", { defaultValue: "Manage Table Columns" }),
|
|
43
|
+
kind: j.GENERAL,
|
|
44
|
+
size: F.LARGE,
|
|
45
|
+
"data-testid": w,
|
|
46
|
+
onClose: k
|
|
47
|
+
},
|
|
48
|
+
/* @__PURE__ */ e.createElement(
|
|
49
|
+
I,
|
|
50
|
+
{
|
|
51
|
+
onHeader: c || r("columnManager.onListHeader", { defaultValue: "Visible Columns" }),
|
|
52
|
+
offHeader: p || r("columnManager.offListHeader", { defaultValue: "Hidden Columns" }),
|
|
53
|
+
onList: u.visibleColumns,
|
|
54
|
+
offList: u.hiddenColumns,
|
|
55
|
+
onChange: (T) => {
|
|
56
|
+
S({ visibleColumns: T.onList, hiddenColumns: T.offList });
|
|
57
|
+
},
|
|
58
|
+
manualSort: t,
|
|
59
|
+
maxDisplayedItems: l,
|
|
60
|
+
showIcons: h,
|
|
61
|
+
showCount: C,
|
|
62
|
+
showFilter: b,
|
|
63
|
+
showMoveAllLinks: f,
|
|
64
|
+
...M("add-to-list")
|
|
65
|
+
}
|
|
66
|
+
),
|
|
67
|
+
/* @__PURE__ */ e.createElement(x, null, /* @__PURE__ */ e.createElement(
|
|
68
|
+
H,
|
|
69
|
+
{
|
|
70
|
+
kind: P.DEFAULT,
|
|
71
|
+
onClick: () => {
|
|
72
|
+
S({ visibleColumns: s, hiddenColumns: i }), k();
|
|
73
|
+
},
|
|
74
|
+
className: L({ mr: "sm" }),
|
|
75
|
+
...M("cancel-button")
|
|
76
|
+
},
|
|
77
|
+
g || r("columnManager.cancelButton", { defaultValue: "Cancel" })
|
|
78
|
+
), /* @__PURE__ */ e.createElement(
|
|
79
|
+
H,
|
|
80
|
+
{
|
|
81
|
+
kind: P.KEY,
|
|
82
|
+
onClick: () => {
|
|
83
|
+
o?.(u.visibleColumns, u.hiddenColumns), k();
|
|
84
|
+
},
|
|
85
|
+
...M("save-button")
|
|
86
|
+
},
|
|
87
|
+
n || r("columnManager.saveButton", { defaultValue: "Save" })
|
|
88
|
+
))
|
|
89
|
+
) : null;
|
|
90
|
+
}
|
|
91
|
+
R.set(y, {
|
|
92
|
+
name: "Column Manager",
|
|
93
|
+
props: {
|
|
94
|
+
isOpen: { type: "boolean", required: !0 },
|
|
95
|
+
title: { type: "string" },
|
|
96
|
+
visibleColumnsHeader: { type: "string" },
|
|
97
|
+
hiddenColumnsHeader: { type: "string" },
|
|
98
|
+
visibleColumns: { type: "ItemProps[]", required: !0 },
|
|
99
|
+
hiddenColumns: { type: "ItemProps[]", required: !0 },
|
|
100
|
+
manualSort: { type: "boolean" },
|
|
101
|
+
maxDisplayedItems: { type: "number" },
|
|
102
|
+
showIcons: { type: "boolean" },
|
|
103
|
+
showCount: { type: "boolean" },
|
|
104
|
+
showFilter: { type: "boolean" },
|
|
105
|
+
showMoveAllLinks: { type: "boolean" },
|
|
106
|
+
cancelButtonText: { type: "string" },
|
|
107
|
+
saveButtonText: { type: "string" },
|
|
108
|
+
onSave: { type: "(visibleColumns: ItemProps[], hiddenColumns: ItemProps[]) => void" },
|
|
109
|
+
onClose: { type: "() => void" },
|
|
110
|
+
onOpen: { type: "() => void" }
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
const Y = ({
|
|
114
|
+
isOpen: a,
|
|
115
|
+
visibleColumns: d,
|
|
116
|
+
hiddenColumns: c,
|
|
117
|
+
onClose: p,
|
|
118
|
+
onOpen: s,
|
|
119
|
+
onSave: i
|
|
120
|
+
}) => {
|
|
121
|
+
const [l, t] = e.useState({
|
|
122
|
+
isOpen: !!a,
|
|
123
|
+
visibleColumns: d,
|
|
124
|
+
hiddenColumns: c
|
|
125
|
+
});
|
|
126
|
+
e.useEffect(() => {
|
|
127
|
+
t((n) => ({ ...n, isOpen: !!a }));
|
|
128
|
+
}, [a]);
|
|
129
|
+
const h = () => {
|
|
130
|
+
t((n) => ({ ...n, isOpen: !0 })), s?.();
|
|
131
|
+
}, C = () => {
|
|
132
|
+
t((n) => ({ ...n, isOpen: !1 })), p?.();
|
|
133
|
+
}, b = (n, o) => {
|
|
134
|
+
t({ isOpen: !1, visibleColumns: n, hiddenColumns: o }), i?.(n, o);
|
|
135
|
+
}, f = e.useCallback((n, o) => {
|
|
136
|
+
t((v) => ({ ...v, visibleColumns: n, hiddenColumns: o }));
|
|
137
|
+
}, []), g = e.useCallback((n) => {
|
|
138
|
+
t((o) => ({ ...o, isOpen: n }));
|
|
139
|
+
}, []);
|
|
140
|
+
return {
|
|
141
|
+
visibleColumns: l.visibleColumns,
|
|
142
|
+
hiddenColumns: l.hiddenColumns,
|
|
143
|
+
isOpen: l.isOpen,
|
|
144
|
+
columnManagerProps: {
|
|
145
|
+
visibleColumns: l.visibleColumns,
|
|
146
|
+
hiddenColumns: l.hiddenColumns,
|
|
147
|
+
isOpen: l.isOpen,
|
|
148
|
+
onClose: C,
|
|
149
|
+
onSave: b
|
|
150
|
+
},
|
|
151
|
+
triggerProps: {
|
|
152
|
+
onClick: h
|
|
153
|
+
},
|
|
154
|
+
setColumns: f,
|
|
155
|
+
setOpen: g
|
|
156
|
+
};
|
|
157
|
+
}, J = {
|
|
158
|
+
components: [y],
|
|
7
159
|
examples: {
|
|
8
160
|
basic: {
|
|
9
161
|
label: "Basic Usage",
|
|
10
162
|
examples: {
|
|
11
163
|
basic: {
|
|
12
|
-
react:
|
|
164
|
+
react: m`
|
|
13
165
|
import { ColumnManager } from "@sps-woodland/column-manager";
|
|
14
166
|
import { SpsButton } from "@spscommerce/ds-react";
|
|
15
167
|
|
|
@@ -74,7 +226,7 @@ const o = {
|
|
|
74
226
|
examples: {
|
|
75
227
|
basic: {
|
|
76
228
|
description: "Minimal API Reference",
|
|
77
|
-
react:
|
|
229
|
+
react: m`
|
|
78
230
|
import { ColumnManager, useColumnManager } from "@sps-woodland/column-manager";
|
|
79
231
|
import { SpsButton } from "@spscommerce/ds-react";
|
|
80
232
|
|
|
@@ -113,7 +265,7 @@ const o = {
|
|
|
113
265
|
},
|
|
114
266
|
complete: {
|
|
115
267
|
description: "Complete API Reference",
|
|
116
|
-
react:
|
|
268
|
+
react: m`
|
|
117
269
|
import { ColumnManager, useColumnManager } from "@sps-woodland/column-manager";
|
|
118
270
|
import { SpsButton } from "@spscommerce/ds-react";
|
|
119
271
|
|
|
@@ -173,7 +325,7 @@ const o = {
|
|
|
173
325
|
examples: {
|
|
174
326
|
basic: {
|
|
175
327
|
description: "This is the minimal visual interface for the ColumnManager component",
|
|
176
|
-
react:
|
|
328
|
+
react: m`
|
|
177
329
|
import { ColumnManager, useColumnManager } from "@sps-woodland/column-manager";
|
|
178
330
|
import { SpsButton } from "@spscommerce/ds-react";
|
|
179
331
|
|
|
@@ -218,9 +370,11 @@ const o = {
|
|
|
218
370
|
}
|
|
219
371
|
}
|
|
220
372
|
}
|
|
221
|
-
},
|
|
222
|
-
"Column Manager":
|
|
373
|
+
}, Q = {
|
|
374
|
+
"Column Manager": J
|
|
223
375
|
};
|
|
224
376
|
export {
|
|
225
|
-
|
|
377
|
+
y as ColumnManager,
|
|
378
|
+
Q as MANIFEST,
|
|
379
|
+
Y as useColumnManager
|
|
226
380
|
};
|
package/lib/index.umd.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(n,
|
|
1
|
+
(function(n,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("react"),require("@sps-woodland/core"),require("@sps-woodland/add-to-list"),require("@sps-woodland/tokens"),require("@spscommerce/ds-react"),require("@spscommerce/ds-shared"),require("@spscommerce/i18n"),require("@spscommerce/utils")):typeof define=="function"&&define.amd?define(["exports","react","@sps-woodland/core","@sps-woodland/add-to-list","@sps-woodland/tokens","@spscommerce/ds-react","@spscommerce/ds-shared","@spscommerce/i18n","@spscommerce/utils"],d):(n=typeof globalThis<"u"?globalThis:n||self,d(n.ColumnManager={},n.React,n.core,n.addToList,n.tokens,n.dsReact,n.dsShared,n.i18n,n.utils))})(this,(function(n,d,H,R,L,h,C,q,b){"use strict";function j(t){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const o in t)if(o!=="default"){const u=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(r,o,u.get?u:{enumerable:!0,get:()=>t[o]})}}return r.default=t,Object.freeze(r)}const e=j(d);function g({isOpen:t,title:r,visibleColumnsHeader:o,hiddenColumnsHeader:u,visibleColumns:m,hiddenColumns:c,maxDisplayedItems:s,manualSort:a=!0,showIcons:v=!0,showCount:E=!0,showFilter:M=!0,showMoveAllLinks:S=!0,cancelButtonText:k,saveButtonText:l,onSave:i,onOpen:w,onClose:F,"data-testid":B}){const[O,A]=e.useState(!!t),{t:p}=q.useWoodlandLanguage(),T=H.useChildTestIdAttrBuilder({"data-testid":B}),[f,P]=e.useState({visibleColumns:m,hiddenColumns:c}),y=()=>{A(!1),F?.()};return e.useEffect(()=>{O&&(P({visibleColumns:m,hiddenColumns:c}),w?.())},[O]),e.useEffect(()=>{A(!!t)},[t]),O?e.createElement(h.SpsModal,{title:r||p("columnManager.title",{defaultValue:"Manage Table Columns"}),kind:C.ModalKind.GENERAL,size:C.ModalSize.LARGE,"data-testid":B,onClose:y},e.createElement(R.AddToList,{onHeader:o||p("columnManager.onListHeader",{defaultValue:"Visible Columns"}),offHeader:u||p("columnManager.offListHeader",{defaultValue:"Hidden Columns"}),onList:f.visibleColumns,offList:f.hiddenColumns,onChange:I=>{P({visibleColumns:I.onList,hiddenColumns:I.offList})},manualSort:a,maxDisplayedItems:s,showIcons:v,showCount:E,showFilter:M,showMoveAllLinks:S,...T("add-to-list")}),e.createElement(h.SpsModalFooter,null,e.createElement(h.SpsButton,{kind:C.ButtonKind.DEFAULT,onClick:()=>{P({visibleColumns:m,hiddenColumns:c}),y()},className:L.sprinkles({mr:"sm"}),...T("cancel-button")},k||p("columnManager.cancelButton",{defaultValue:"Cancel"})),e.createElement(h.SpsButton,{kind:C.ButtonKind.KEY,onClick:()=>{i?.(f.visibleColumns,f.hiddenColumns),y()},...T("save-button")},l||p("columnManager.saveButton",{defaultValue:"Save"})))):null}H.Metadata.set(g,{name:"Column Manager",props:{isOpen:{type:"boolean",required:!0},title:{type:"string"},visibleColumnsHeader:{type:"string"},hiddenColumnsHeader:{type:"string"},visibleColumns:{type:"ItemProps[]",required:!0},hiddenColumns:{type:"ItemProps[]",required:!0},manualSort:{type:"boolean"},maxDisplayedItems:{type:"number"},showIcons:{type:"boolean"},showCount:{type:"boolean"},showFilter:{type:"boolean"},showMoveAllLinks:{type:"boolean"},cancelButtonText:{type:"string"},saveButtonText:{type:"string"},onSave:{type:"(visibleColumns: ItemProps[], hiddenColumns: ItemProps[]) => void"},onClose:{type:"() => void"},onOpen:{type:"() => void"}}});const V=({isOpen:t,visibleColumns:r,hiddenColumns:o,onClose:u,onOpen:m,onSave:c})=>{const[s,a]=e.useState({isOpen:!!t,visibleColumns:r,hiddenColumns:o});e.useEffect(()=>{a(l=>({...l,isOpen:!!t}))},[t]);const v=()=>{a(l=>({...l,isOpen:!0})),m?.()},E=()=>{a(l=>({...l,isOpen:!1})),u?.()},M=(l,i)=>{a({isOpen:!1,visibleColumns:l,hiddenColumns:i}),c?.(l,i)},S=e.useCallback((l,i)=>{a(w=>({...w,visibleColumns:l,hiddenColumns:i}))},[]),k=e.useCallback(l=>{a(i=>({...i,isOpen:l}))},[]);return{visibleColumns:s.visibleColumns,hiddenColumns:s.hiddenColumns,isOpen:s.isOpen,columnManagerProps:{visibleColumns:s.visibleColumns,hiddenColumns:s.hiddenColumns,isOpen:s.isOpen,onClose:E,onSave:M},triggerProps:{onClick:v},setColumns:S,setOpen:k}},x={"Column Manager":{components:[g],examples:{basic:{label:"Basic Usage",examples:{basic:{react:b.code`
|
|
2
2
|
import { ColumnManager } from "@sps-woodland/column-manager";
|
|
3
3
|
import { SpsButton } from "@spscommerce/ds-react";
|
|
4
4
|
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
</div>
|
|
51
51
|
)
|
|
52
52
|
}
|
|
53
|
-
`}}},hooks:{label:"useColumnManager hook",description:()=>e.createElement(e.Fragment,null,e.createElement("h5",null,"Arguments"),e.createElement("p",null,"The column manager comes with a ",e.createElement("code",null,"useColumnManager")," hook that implements the default behavior. Arguments for this hook include:"),e.createElement("dl",null,e.createElement("dt",null,e.createElement("code",null,"visibleColumns"),": ItemProps[] (required)"),e.createElement("dd",null,"The initial visible columns state"),e.createElement("dt",null,e.createElement("code",null,"hiddenColumns"),": ItemProps[] (required)"),e.createElement("dd",null,"The initial hidden columns state"),e.createElement("dt",null,e.createElement("code",null,"isOpen"),": boolean (optional)"),e.createElement("dd",null,"Whether the column manager is open by default"),e.createElement("dt",null,e.createElement("code",null,"onOpen"),": function (optional)"),e.createElement("dd",null,"Handler that is called when the column manager opens",e.createElement("code",null,"() => void")),e.createElement("dt",null,e.createElement("code",null,"onClose"),": function (optional)"),e.createElement("dd",null,"Handler that is called when the column manager closes",e.createElement("code",null,"() => void")),e.createElement("dt",null,e.createElement("code",null,"onSave"),": function (optional)"),e.createElement("dd",null,"Handler that is called when the column manager saves",e.createElement("code",null,"(visibleColumns: ItemProps[], hiddenColumns: ItemProps[]) => void"))),e.createElement("h5",null,"Return value"),e.createElement("p",null,"The ",e.createElement("code",null,"useColumnManager")," hook returns an object with"," ",e.createElement("code",null,"visibleColumns"),", ",e.createElement("code",null,"hiddenColumns"),", ",e.createElement("code",null,"columnManagerProps"),", ",e.createElement("code",null,"triggerProps")," ,",e.createElement("code",null,"setColumns")," and ",e.createElement("code",null,"setOpen")),e.createElement("p",null,e.createElement("code",null,"triggerProps"),": needs to be spread on the element that triggers the modal."),e.createElement("p",null,e.createElement("code",null,"columnManagerProps"),": needs to be spread on the ",e.createElement("code",null,"ColumnManager")," ","component"),e.createElement("p",null,e.createElement("code",null,"visibleColumns"),": the current state of the visible columns"),e.createElement("p",null,e.createElement("code",null,"hiddenColumns"),": the current state of the hidden columns"),e.createElement("p",null,e.createElement("code",null,"setColumns"),": function that allows programmatically setting the current state of the visible and hidden columns. This function is safe to use in effects."),e.createElement("p",null,e.createElement("code",null,"setOpen"),": function that allows programmatically setting the current isOpen state. This function is safe to use in effects."),e.createElement("p",null,"Please refer to the examples to see its implementation"))},hooksExamples:{label:"Hook Usage",examples:{basic:{description:"Minimal API Reference",react:
|
|
53
|
+
`}}},hooks:{label:"useColumnManager hook",description:()=>e.createElement(e.Fragment,null,e.createElement("h5",null,"Arguments"),e.createElement("p",null,"The column manager comes with a ",e.createElement("code",null,"useColumnManager")," hook that implements the default behavior. Arguments for this hook include:"),e.createElement("dl",null,e.createElement("dt",null,e.createElement("code",null,"visibleColumns"),": ItemProps[] (required)"),e.createElement("dd",null,"The initial visible columns state"),e.createElement("dt",null,e.createElement("code",null,"hiddenColumns"),": ItemProps[] (required)"),e.createElement("dd",null,"The initial hidden columns state"),e.createElement("dt",null,e.createElement("code",null,"isOpen"),": boolean (optional)"),e.createElement("dd",null,"Whether the column manager is open by default"),e.createElement("dt",null,e.createElement("code",null,"onOpen"),": function (optional)"),e.createElement("dd",null,"Handler that is called when the column manager opens",e.createElement("code",null,"() => void")),e.createElement("dt",null,e.createElement("code",null,"onClose"),": function (optional)"),e.createElement("dd",null,"Handler that is called when the column manager closes",e.createElement("code",null,"() => void")),e.createElement("dt",null,e.createElement("code",null,"onSave"),": function (optional)"),e.createElement("dd",null,"Handler that is called when the column manager saves",e.createElement("code",null,"(visibleColumns: ItemProps[], hiddenColumns: ItemProps[]) => void"))),e.createElement("h5",null,"Return value"),e.createElement("p",null,"The ",e.createElement("code",null,"useColumnManager")," hook returns an object with"," ",e.createElement("code",null,"visibleColumns"),", ",e.createElement("code",null,"hiddenColumns"),", ",e.createElement("code",null,"columnManagerProps"),", ",e.createElement("code",null,"triggerProps")," ,",e.createElement("code",null,"setColumns")," and ",e.createElement("code",null,"setOpen")),e.createElement("p",null,e.createElement("code",null,"triggerProps"),": needs to be spread on the element that triggers the modal."),e.createElement("p",null,e.createElement("code",null,"columnManagerProps"),": needs to be spread on the ",e.createElement("code",null,"ColumnManager")," ","component"),e.createElement("p",null,e.createElement("code",null,"visibleColumns"),": the current state of the visible columns"),e.createElement("p",null,e.createElement("code",null,"hiddenColumns"),": the current state of the hidden columns"),e.createElement("p",null,e.createElement("code",null,"setColumns"),": function that allows programmatically setting the current state of the visible and hidden columns. This function is safe to use in effects."),e.createElement("p",null,e.createElement("code",null,"setOpen"),": function that allows programmatically setting the current isOpen state. This function is safe to use in effects."),e.createElement("p",null,"Please refer to the examples to see its implementation"))},hooksExamples:{label:"Hook Usage",examples:{basic:{description:"Minimal API Reference",react:b.code`
|
|
54
54
|
import { ColumnManager, useColumnManager } from "@sps-woodland/column-manager";
|
|
55
55
|
import { SpsButton } from "@spscommerce/ds-react";
|
|
56
56
|
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
</div>
|
|
86
86
|
)
|
|
87
87
|
}
|
|
88
|
-
`},complete:{description:"Complete API Reference",react:
|
|
88
|
+
`},complete:{description:"Complete API Reference",react:b.code`
|
|
89
89
|
import { ColumnManager, useColumnManager } from "@sps-woodland/column-manager";
|
|
90
90
|
import { SpsButton } from "@spscommerce/ds-react";
|
|
91
91
|
|
|
@@ -136,7 +136,7 @@
|
|
|
136
136
|
</div>
|
|
137
137
|
)
|
|
138
138
|
}
|
|
139
|
-
`}}},minimalInterface:{label:"Minimal Interface",examples:{basic:{description:"This is the minimal visual interface for the ColumnManager component",react:
|
|
139
|
+
`}}},minimalInterface:{label:"Minimal Interface",examples:{basic:{description:"This is the minimal visual interface for the ColumnManager component",react:b.code`
|
|
140
140
|
import { ColumnManager, useColumnManager } from "@sps-woodland/column-manager";
|
|
141
141
|
import { SpsButton } from "@spscommerce/ds-react";
|
|
142
142
|
|
|
@@ -176,4 +176,4 @@
|
|
|
176
176
|
</div>
|
|
177
177
|
)
|
|
178
178
|
}
|
|
179
|
-
`}}}}}};n.MANIFEST=
|
|
179
|
+
`}}}}}};n.ColumnManager=g,n.MANIFEST=x,n.useColumnManager=V,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sps-woodland/column-manager",
|
|
3
3
|
"description": "SPS Woodland Design System column manager component",
|
|
4
|
-
"version": "8.
|
|
4
|
+
"version": "8.52.1",
|
|
5
5
|
"author": "SPS Commerce",
|
|
6
6
|
"license": "UNLICENSED",
|
|
7
7
|
"repository": "https://github.com/SPSCommerce/woodland/tree/main/packages/@sps-woodland/column-manager",
|
|
@@ -23,17 +23,32 @@
|
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"@spscommerce/utils": "^7.0.0 || ^8.0.0 || ^9.0.0",
|
|
26
|
+
"@vanilla-extract/css-utils": "^0.1.3",
|
|
26
27
|
"react": "^16.14.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
27
28
|
"react-dom": "^16.14.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
28
|
-
"@sps-woodland/
|
|
29
|
-
"@
|
|
29
|
+
"@sps-woodland/add-to-list": "8.52.1",
|
|
30
|
+
"@sps-woodland/core": "8.52.1",
|
|
31
|
+
"@sps-woodland/tokens": "8.52.1",
|
|
32
|
+
"@spscommerce/ds-react": "8.52.1",
|
|
33
|
+
"@spscommerce/ds-shared": "8.52.1",
|
|
34
|
+
"@spscommerce/i18n": "8.52.1"
|
|
30
35
|
},
|
|
31
36
|
"devDependencies": {
|
|
32
37
|
"@spscommerce/utils": "9.0.3",
|
|
38
|
+
"@vanilla-extract/css": "1.17.4",
|
|
39
|
+
"@vanilla-extract/css-utils": "0.1.3",
|
|
40
|
+
"@vanilla-extract/recipes": "0.2.5",
|
|
33
41
|
"react": "16.14.0",
|
|
34
42
|
"react-dom": "16.14.0",
|
|
35
|
-
"@sps-woodland/
|
|
36
|
-
"@
|
|
43
|
+
"@sps-woodland/add-to-list": "8.52.1",
|
|
44
|
+
"@sps-woodland/core": "8.52.1",
|
|
45
|
+
"@sps-woodland/tokens": "8.52.1",
|
|
46
|
+
"@spscommerce/ds-react": "8.52.1",
|
|
47
|
+
"@spscommerce/ds-shared": "8.52.1",
|
|
48
|
+
"@spscommerce/i18n": "8.52.1"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"nanoid": "5.1.5"
|
|
37
52
|
},
|
|
38
53
|
"scripts": {
|
|
39
54
|
"build": "pnpm run build:js && pnpm run build:types",
|
package/vite.config.mjs
CHANGED
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
+
import { vanillaExtractPlugin } from "@vanilla-extract/vite-plugin";
|
|
2
3
|
import { defineConfig } from "vite";
|
|
4
|
+
import { getVanillaExtractPluginProps } from "../../../scripts/vanilla-extract-plugin-props.mjs";
|
|
3
5
|
import pkg from "./package.json";
|
|
4
6
|
|
|
7
|
+
const packageVersion = process.env.PREDICTED_VERSION || pkg.version;
|
|
8
|
+
|
|
5
9
|
export default defineConfig({
|
|
10
|
+
plugins: [
|
|
11
|
+
vanillaExtractPlugin(
|
|
12
|
+
getVanillaExtractPluginProps({
|
|
13
|
+
packageName: pkg.name,
|
|
14
|
+
packageVersion,
|
|
15
|
+
})
|
|
16
|
+
),
|
|
17
|
+
],
|
|
6
18
|
build: {
|
|
7
19
|
lib: {
|
|
8
20
|
entry: path.resolve(__dirname, "src/index.ts"),
|
|
@@ -12,11 +24,7 @@ export default defineConfig({
|
|
|
12
24
|
outDir: path.resolve(__dirname, "./lib"),
|
|
13
25
|
emptyOutDir: false,
|
|
14
26
|
rollupOptions: {
|
|
15
|
-
|
|
16
|
-
external: (id) => {
|
|
17
|
-
const peerDeps = pkg.peerDependencies ? Object.keys(pkg.peerDependencies) : [];
|
|
18
|
-
return peerDeps.some((dep) => id === dep || id.startsWith(dep + "/"));
|
|
19
|
-
},
|
|
27
|
+
external: pkg.peerDependencies ? Object.keys(pkg.peerDependencies) : [],
|
|
20
28
|
},
|
|
21
29
|
},
|
|
22
30
|
});
|