@sps-woodland/sorting-header 7.0.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/README.md +3 -0
- package/lib/SortingHeader.examples.d.ts +2 -0
- package/lib/caret/caret.css.d.ts +20 -0
- package/lib/index.cjs.js +95 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.es.js +243 -0
- package/lib/manifest.d.ts +2 -0
- package/lib/sorting-header/SortingHeader.css.d.ts +1 -0
- package/lib/sorting-header/SortingHeader.d.ts +6 -0
- package/lib/sorting-header-cell/SortingHeaderCell.css.d.ts +13 -0
- package/lib/sorting-header-cell/SortingHeaderCell.d.ts +10 -0
- package/lib/style.css +1 -0
- package/package.json +40 -0
- package/vite.config.js +21 -0
package/README.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare const headerCaret: import("@vanilla-extract/recipes/dist/declarations/src/types").RuntimeFn<{
|
|
2
|
+
up: {
|
|
3
|
+
true: {
|
|
4
|
+
":after": {
|
|
5
|
+
borderBottomColor: string;
|
|
6
|
+
borderTopColor: "transparent";
|
|
7
|
+
top: string;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
down: {
|
|
12
|
+
true: {
|
|
13
|
+
":after": {
|
|
14
|
+
borderTopColor: string;
|
|
15
|
+
borderBottomColor: "transparent";
|
|
16
|
+
top: string;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
}>;
|
package/lib/index.cjs.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const O=require("react"),a=require("@sps-woodland/core"),D=require("@spscommerce/utils");function H(e){if(e&&e.__esModule)return e;const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,o.get?o:{enumerable:!0,get:()=>e[t]})}}return r.default=e,Object.freeze(r)}const f=H(O);function _(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function g(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),t.push.apply(t,o)}return t}function b(e){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};r%2?g(Object(t),!0).forEach(function(o){_(e,o,t[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):g(Object(t)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(t,o))})}return e}var h=(e,r,t)=>{for(var o of Object.keys(e)){var n;if(e[o]!==((n=r[o])!==null&&n!==void 0?n:t[o]))return!1}return!0},v=e=>r=>{var t=e.defaultClassName,o=b(b({},e.defaultVariants),r);for(var n in o){var i,l=(i=o[n])!==null&&i!==void 0?i:e.defaultVariants[n];if(l!=null){var s=l;typeof s=="boolean"&&(s=s===!0?"true":"false");var c=e.variantClassNames[n][s];c&&(t+=" "+c)}}for(var[p,S]of e.compoundVariants)h(p,o,e.defaultVariants)&&(t+=" "+S);return t},E=v({defaultClassName:"_7ljhcs0",variantClassNames:{up:{true:"_7ljhcs1"},down:{true:"_7ljhcs2"}},defaultVariants:{},compoundVariants:[]});var I=v({defaultClassName:"_1crs4gl0",variantClassNames:{disabled:{true:"_1crs4gl1"},active:{true:"_1crs4gl2"}},defaultVariants:{disabled:!1,active:!1},compoundVariants:[]});function m({className:e,sortKey:r,sort:t,sortDisabled:o,onSortChange:n,onClick:i,children:l,style:s,widthPx:c,widthRem:p,...S}){const d=f.useMemo(()=>{const u=!!r&&!o&&Array.isArray(t)&&t.find(N=>N.key===r);return u?u.direction:void 0},[t,r,o]),C=c?c/16:p,w=C?{...s,width:`${C}rem`}:s;return f.createElement("div",{className:a.cl(e,I({disabled:o,active:!!d}),d&&E({up:d===a.SortDirection.ASCENDING,down:d===a.SortDirection.DESCENDING})),onClick:u=>{r&&!o&&n&&n([{key:r,direction:d===a.SortDirection.ASCENDING?a.SortDirection.DESCENDING:a.SortDirection.ASCENDING}]),i&&i(u)},style:w,...S},l)}a.Metadata.set(m,{name:"Sorting Header Cell",props:{sortKey:{type:"string"},sort:{type:"SortedColumn[]"},sortDisabled:{type:"boolean"},onSortChange:{type:"SortChangeHandler"},widthPx:{type:"number"},widthRem:{type:"number"}}});var P="sk81640";function y({sort:e,onSortChange:r,children:t,className:o,...n}){const[i]=a.selectChildren(t,[{type:m}]),l=a.modChildren(i,()=>[{sort:e,onSortChange:r}]);return f.createElement("div",{className:a.cl(o,P),...n},l)}a.Metadata.set(y,{name:"Sorting Header",props:{sort:{type:"SortedColumn[]"},onSortChange:{type:"SortChangeHandler"}}});const R={components:[y,m],examples:{basic:{label:"Sorting Header",examples:{basic:{react:D.code`
|
|
2
|
+
import { SortingHeader, SortingHeaderCell } from "@sps-woodland/sorting-header";
|
|
3
|
+
import { Icon } from "@sps-woodland/core";
|
|
4
|
+
import { ContentRow } from "@sps-woodland/content-row";
|
|
5
|
+
import { KeyValueSet, KeyValueSetItem } from "@sps-woodland/key-value-set";
|
|
6
|
+
import { sprinkles, grid } from "@sps-woodland/tokens";
|
|
7
|
+
function MyComponent() {
|
|
8
|
+
const [sort, setSort] = React.useState([
|
|
9
|
+
{ key: "id", direction: SortDirection.DESCENDING },
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
const items = React.useMemo(
|
|
13
|
+
() =>
|
|
14
|
+
[
|
|
15
|
+
{
|
|
16
|
+
id: "9712323",
|
|
17
|
+
icon: SpsIcon.STATUS_IN_PROCESS,
|
|
18
|
+
color: "purple-medium",
|
|
19
|
+
type: "850",
|
|
20
|
+
timestamp: "July 21, 2021 @ 4:40 PM",
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: "8712378",
|
|
24
|
+
icon: SpsIcon.STATUS_OK,
|
|
25
|
+
color: "green-medium",
|
|
26
|
+
type: "810",
|
|
27
|
+
timestamp: "May 24, 2021 @ 4:39 PM",
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: "8912389",
|
|
31
|
+
icon: SpsIcon.STATUS_REJECTED,
|
|
32
|
+
color: "red-medium",
|
|
33
|
+
type: "850",
|
|
34
|
+
timestamp: "May 23, 2021 @ 4:38 PM",
|
|
35
|
+
},
|
|
36
|
+
].sort((a, b) => {
|
|
37
|
+
if (!sort.length) {
|
|
38
|
+
return 0;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const [{ key, direction }] = sort;
|
|
42
|
+
if (a[key] < b[key]) {
|
|
43
|
+
return direction === SortDirection.ASCENDING ? -1 : 1;
|
|
44
|
+
} else if (a[key] > b[key]) {
|
|
45
|
+
return direction === SortDirection.ASCENDING ? 1 : -1;
|
|
46
|
+
} else {
|
|
47
|
+
return 0;
|
|
48
|
+
}
|
|
49
|
+
}),
|
|
50
|
+
[sort]
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<div className={grid.root}>
|
|
55
|
+
<SortingHeader sort={sort} onSortChange={setSort} className={grid[12]}>
|
|
56
|
+
<SortingHeaderCell sortKey="id">ID</SortingHeaderCell>
|
|
57
|
+
<SortingHeaderCell sortKey="type">Type</SortingHeaderCell>
|
|
58
|
+
<SortingHeaderCell sortKey="timestamp" widthPx={150}>
|
|
59
|
+
Timestamp
|
|
60
|
+
</SortingHeaderCell>
|
|
61
|
+
</SortingHeader>
|
|
62
|
+
|
|
63
|
+
{items.map((item) => {
|
|
64
|
+
return (
|
|
65
|
+
<ContentRow key={item.id} className={grid[12]}>
|
|
66
|
+
<ContentRowCol>
|
|
67
|
+
<Icon
|
|
68
|
+
icon={item.icon}
|
|
69
|
+
color={item.color}
|
|
70
|
+
size={SpsIconSize.LARGE}
|
|
71
|
+
className={sprinkles({ mr: "sm" })}
|
|
72
|
+
/>
|
|
73
|
+
<a href="#">
|
|
74
|
+
{item.id}
|
|
75
|
+
</a>
|
|
76
|
+
</ContentRowCol>
|
|
77
|
+
<ContentRowCol>
|
|
78
|
+
<KeyValueSet>
|
|
79
|
+
<KeyValueSetItem itemKey="Type">{item.type}</KeyValueSetItem>
|
|
80
|
+
</KeyValueSet>
|
|
81
|
+
</ContentRowCol>
|
|
82
|
+
<ContentRowCol widthPx={250}>
|
|
83
|
+
<KeyValueSet>
|
|
84
|
+
<KeyValueSetItem itemKey="Timestamp">
|
|
85
|
+
{item.timestamp}
|
|
86
|
+
</KeyValueSetItem>
|
|
87
|
+
</KeyValueSet>
|
|
88
|
+
</ContentRowCol>
|
|
89
|
+
</ContentRow>
|
|
90
|
+
);
|
|
91
|
+
})}
|
|
92
|
+
</>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
`}}}}},V={"Sorting Header":R};exports.MANIFEST=V;exports.SortingHeader=y;exports.SortingHeaderCell=m;
|
package/lib/index.d.ts
ADDED
package/lib/index.es.js
ADDED
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import * as S from "react";
|
|
2
|
+
import { Metadata as v, cl as w, SortDirection as m, selectChildren as H, modChildren as I } from "@sps-woodland/core";
|
|
3
|
+
import { code as D } from "@spscommerce/utils";
|
|
4
|
+
function O(e, o, t) {
|
|
5
|
+
return o in e ? Object.defineProperty(e, o, {
|
|
6
|
+
value: t,
|
|
7
|
+
enumerable: !0,
|
|
8
|
+
configurable: !0,
|
|
9
|
+
writable: !0
|
|
10
|
+
}) : e[o] = t, e;
|
|
11
|
+
}
|
|
12
|
+
function C(e, o) {
|
|
13
|
+
var t = Object.keys(e);
|
|
14
|
+
if (Object.getOwnPropertySymbols) {
|
|
15
|
+
var r = Object.getOwnPropertySymbols(e);
|
|
16
|
+
o && (r = r.filter(function(n) {
|
|
17
|
+
return Object.getOwnPropertyDescriptor(e, n).enumerable;
|
|
18
|
+
})), t.push.apply(t, r);
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
}
|
|
22
|
+
function g(e) {
|
|
23
|
+
for (var o = 1; o < arguments.length; o++) {
|
|
24
|
+
var t = arguments[o] != null ? arguments[o] : {};
|
|
25
|
+
o % 2 ? C(Object(t), !0).forEach(function(r) {
|
|
26
|
+
O(e, r, t[r]);
|
|
27
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : C(Object(t)).forEach(function(r) {
|
|
28
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return e;
|
|
32
|
+
}
|
|
33
|
+
var V = (e, o, t) => {
|
|
34
|
+
for (var r of Object.keys(e)) {
|
|
35
|
+
var n;
|
|
36
|
+
if (e[r] !== ((n = o[r]) !== null && n !== void 0 ? n : t[r]))
|
|
37
|
+
return !1;
|
|
38
|
+
}
|
|
39
|
+
return !0;
|
|
40
|
+
}, N = (e) => (o) => {
|
|
41
|
+
var t = e.defaultClassName, r = g(g({}, e.defaultVariants), o);
|
|
42
|
+
for (var n in r) {
|
|
43
|
+
var a, s = (a = r[n]) !== null && a !== void 0 ? a : e.defaultVariants[n];
|
|
44
|
+
if (s != null) {
|
|
45
|
+
var i = s;
|
|
46
|
+
typeof i == "boolean" && (i = i === !0 ? "true" : "false");
|
|
47
|
+
var l = e.variantClassNames[n][i];
|
|
48
|
+
l && (t += " " + l);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
for (var [p, u] of e.compoundVariants)
|
|
52
|
+
V(p, r, e.defaultVariants) && (t += " " + u);
|
|
53
|
+
return t;
|
|
54
|
+
}, R = N({ defaultClassName: "_7ljhcs0", variantClassNames: { up: { true: "_7ljhcs1" }, down: { true: "_7ljhcs2" } }, defaultVariants: {}, compoundVariants: [] });
|
|
55
|
+
var _ = N({ defaultClassName: "_1crs4gl0", variantClassNames: { disabled: { true: "_1crs4gl1" }, active: { true: "_1crs4gl2" } }, defaultVariants: { disabled: !1, active: !1 }, compoundVariants: [] });
|
|
56
|
+
function f({
|
|
57
|
+
className: e,
|
|
58
|
+
sortKey: o,
|
|
59
|
+
sort: t,
|
|
60
|
+
sortDisabled: r,
|
|
61
|
+
onSortChange: n,
|
|
62
|
+
onClick: a,
|
|
63
|
+
children: s,
|
|
64
|
+
style: i,
|
|
65
|
+
widthPx: l,
|
|
66
|
+
widthRem: p,
|
|
67
|
+
...u
|
|
68
|
+
}) {
|
|
69
|
+
const d = S.useMemo(() => {
|
|
70
|
+
const c = !!o && !r && Array.isArray(t) && t.find((E) => E.key === o);
|
|
71
|
+
return c ? c.direction : void 0;
|
|
72
|
+
}, [
|
|
73
|
+
t,
|
|
74
|
+
o,
|
|
75
|
+
r
|
|
76
|
+
]), y = l ? l / 16 : p, h = y ? { ...i, width: `${y}rem` } : i;
|
|
77
|
+
return /* @__PURE__ */ S.createElement("div", {
|
|
78
|
+
className: w(
|
|
79
|
+
e,
|
|
80
|
+
_({ disabled: r, active: !!d }),
|
|
81
|
+
d && R({
|
|
82
|
+
up: d === m.ASCENDING,
|
|
83
|
+
down: d === m.DESCENDING
|
|
84
|
+
})
|
|
85
|
+
),
|
|
86
|
+
onClick: (c) => {
|
|
87
|
+
o && !r && n && n([
|
|
88
|
+
{
|
|
89
|
+
key: o,
|
|
90
|
+
direction: d === m.ASCENDING ? m.DESCENDING : m.ASCENDING
|
|
91
|
+
}
|
|
92
|
+
]), a && a(c);
|
|
93
|
+
},
|
|
94
|
+
style: h,
|
|
95
|
+
...u
|
|
96
|
+
}, s);
|
|
97
|
+
}
|
|
98
|
+
v.set(f, {
|
|
99
|
+
name: "Sorting Header Cell",
|
|
100
|
+
props: {
|
|
101
|
+
sortKey: { type: "string" },
|
|
102
|
+
sort: { type: "SortedColumn[]" },
|
|
103
|
+
sortDisabled: { type: "boolean" },
|
|
104
|
+
onSortChange: { type: "SortChangeHandler" },
|
|
105
|
+
widthPx: { type: "number" },
|
|
106
|
+
widthRem: { type: "number" }
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
var P = "sk81640";
|
|
110
|
+
function b({
|
|
111
|
+
sort: e,
|
|
112
|
+
onSortChange: o,
|
|
113
|
+
children: t,
|
|
114
|
+
className: r,
|
|
115
|
+
...n
|
|
116
|
+
}) {
|
|
117
|
+
const [a] = H(t, [{ type: f }]), s = I(a, () => [{ sort: e, onSortChange: o }]);
|
|
118
|
+
return /* @__PURE__ */ S.createElement("div", {
|
|
119
|
+
className: w(r, P),
|
|
120
|
+
...n
|
|
121
|
+
}, s);
|
|
122
|
+
}
|
|
123
|
+
v.set(b, {
|
|
124
|
+
name: "Sorting Header",
|
|
125
|
+
props: {
|
|
126
|
+
sort: { type: "SortedColumn[]" },
|
|
127
|
+
onSortChange: { type: "SortChangeHandler" }
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
const K = {
|
|
131
|
+
components: [b, f],
|
|
132
|
+
examples: {
|
|
133
|
+
basic: {
|
|
134
|
+
label: "Sorting Header",
|
|
135
|
+
examples: {
|
|
136
|
+
basic: {
|
|
137
|
+
react: D`
|
|
138
|
+
import { SortingHeader, SortingHeaderCell } from "@sps-woodland/sorting-header";
|
|
139
|
+
import { Icon } from "@sps-woodland/core";
|
|
140
|
+
import { ContentRow } from "@sps-woodland/content-row";
|
|
141
|
+
import { KeyValueSet, KeyValueSetItem } from "@sps-woodland/key-value-set";
|
|
142
|
+
import { sprinkles, grid } from "@sps-woodland/tokens";
|
|
143
|
+
function MyComponent() {
|
|
144
|
+
const [sort, setSort] = React.useState([
|
|
145
|
+
{ key: "id", direction: SortDirection.DESCENDING },
|
|
146
|
+
]);
|
|
147
|
+
|
|
148
|
+
const items = React.useMemo(
|
|
149
|
+
() =>
|
|
150
|
+
[
|
|
151
|
+
{
|
|
152
|
+
id: "9712323",
|
|
153
|
+
icon: SpsIcon.STATUS_IN_PROCESS,
|
|
154
|
+
color: "purple-medium",
|
|
155
|
+
type: "850",
|
|
156
|
+
timestamp: "July 21, 2021 @ 4:40 PM",
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
id: "8712378",
|
|
160
|
+
icon: SpsIcon.STATUS_OK,
|
|
161
|
+
color: "green-medium",
|
|
162
|
+
type: "810",
|
|
163
|
+
timestamp: "May 24, 2021 @ 4:39 PM",
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
id: "8912389",
|
|
167
|
+
icon: SpsIcon.STATUS_REJECTED,
|
|
168
|
+
color: "red-medium",
|
|
169
|
+
type: "850",
|
|
170
|
+
timestamp: "May 23, 2021 @ 4:38 PM",
|
|
171
|
+
},
|
|
172
|
+
].sort((a, b) => {
|
|
173
|
+
if (!sort.length) {
|
|
174
|
+
return 0;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const [{ key, direction }] = sort;
|
|
178
|
+
if (a[key] < b[key]) {
|
|
179
|
+
return direction === SortDirection.ASCENDING ? -1 : 1;
|
|
180
|
+
} else if (a[key] > b[key]) {
|
|
181
|
+
return direction === SortDirection.ASCENDING ? 1 : -1;
|
|
182
|
+
} else {
|
|
183
|
+
return 0;
|
|
184
|
+
}
|
|
185
|
+
}),
|
|
186
|
+
[sort]
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
return (
|
|
190
|
+
<div className={grid.root}>
|
|
191
|
+
<SortingHeader sort={sort} onSortChange={setSort} className={grid[12]}>
|
|
192
|
+
<SortingHeaderCell sortKey="id">ID</SortingHeaderCell>
|
|
193
|
+
<SortingHeaderCell sortKey="type">Type</SortingHeaderCell>
|
|
194
|
+
<SortingHeaderCell sortKey="timestamp" widthPx={150}>
|
|
195
|
+
Timestamp
|
|
196
|
+
</SortingHeaderCell>
|
|
197
|
+
</SortingHeader>
|
|
198
|
+
|
|
199
|
+
{items.map((item) => {
|
|
200
|
+
return (
|
|
201
|
+
<ContentRow key={item.id} className={grid[12]}>
|
|
202
|
+
<ContentRowCol>
|
|
203
|
+
<Icon
|
|
204
|
+
icon={item.icon}
|
|
205
|
+
color={item.color}
|
|
206
|
+
size={SpsIconSize.LARGE}
|
|
207
|
+
className={sprinkles({ mr: "sm" })}
|
|
208
|
+
/>
|
|
209
|
+
<a href="#">
|
|
210
|
+
{item.id}
|
|
211
|
+
</a>
|
|
212
|
+
</ContentRowCol>
|
|
213
|
+
<ContentRowCol>
|
|
214
|
+
<KeyValueSet>
|
|
215
|
+
<KeyValueSetItem itemKey="Type">{item.type}</KeyValueSetItem>
|
|
216
|
+
</KeyValueSet>
|
|
217
|
+
</ContentRowCol>
|
|
218
|
+
<ContentRowCol widthPx={250}>
|
|
219
|
+
<KeyValueSet>
|
|
220
|
+
<KeyValueSetItem itemKey="Timestamp">
|
|
221
|
+
{item.timestamp}
|
|
222
|
+
</KeyValueSetItem>
|
|
223
|
+
</KeyValueSet>
|
|
224
|
+
</ContentRowCol>
|
|
225
|
+
</ContentRow>
|
|
226
|
+
);
|
|
227
|
+
})}
|
|
228
|
+
</>
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
`
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}, T = {
|
|
237
|
+
"Sorting Header": K
|
|
238
|
+
};
|
|
239
|
+
export {
|
|
240
|
+
T as MANIFEST,
|
|
241
|
+
b as SortingHeader,
|
|
242
|
+
f as SortingHeaderCell
|
|
243
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const sortingHeader: string;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { ComponentProps, SortChangeHandler, SortedColumn } from "@sps-woodland/core";
|
|
3
|
+
export declare function SortingHeader({ sort, onSortChange, children, className, ...rest }: ComponentProps<{
|
|
4
|
+
sort: SortedColumn[];
|
|
5
|
+
onSortChange: SortChangeHandler;
|
|
6
|
+
}, HTMLDivElement>): React.ReactElement;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { SortedColumn, SortChangeHandler, ComponentProps } from "@sps-woodland/core";
|
|
3
|
+
export declare function SortingHeaderCell({ className, sortKey, sort, sortDisabled, onSortChange, onClick, children, style, widthPx, widthRem, ...rest }: ComponentProps<{
|
|
4
|
+
sortKey?: string;
|
|
5
|
+
sortDisabled?: boolean;
|
|
6
|
+
sort?: SortedColumn[];
|
|
7
|
+
onSortChange?: SortChangeHandler;
|
|
8
|
+
widthPx?: number;
|
|
9
|
+
widthRem?: number;
|
|
10
|
+
}, HTMLDivElement>): React.ReactElement;
|
package/lib/style.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
._7ljhcs0:after{content:"";border-left-color:transparent;border-right-color:transparent;border-style:solid;border-width:.375rem .25rem;height:0;position:absolute;right:.5rem}._7ljhcs1:after{border-bottom-color:#1f282c;border-top-color:transparent;top:calc(50% - 9px)}._7ljhcs2:after{border-top-color:#1f282c;border-bottom-color:transparent;top:calc(50% - 3px)}._1crs4gl0{display:table-cell;vertical-align:middle;color:#4b5356;font-size:.75rem;font-weight:600;line-height:1.25rem;padding:.5rem;position:relative}._1crs4gl0:hover{background-color:#f3f4f4}._1crs4gl1{cursor:default}._1crs4gl2{color:#1f282c;background-color:#d2d4d4}.sk81640{display:table;table-layout:fixed;width:100%;padding:0;border-radius:.25rem;vertical-align:bottom;cursor:pointer;background-color:#e9e9ea}
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sps-woodland/sorting-header",
|
|
3
|
+
"description": "SPS Woodland Design System sorting-header and sorting-header cell components",
|
|
4
|
+
"version": "7.0.0",
|
|
5
|
+
"author": "SPS Commerce",
|
|
6
|
+
"license": "UNLICENSED",
|
|
7
|
+
"repository": "https://github.com/SPSCommerce/woodland/tree/main/packages/@sps-woodland/sorting-header",
|
|
8
|
+
"homepage": "https://github.com/SPSCommerce/woodland/tree/master/packages/@sps-woodland/sorting-header#readme",
|
|
9
|
+
"main": "./lib/index.es.js",
|
|
10
|
+
"module": "./lib/index.es.js",
|
|
11
|
+
"types": "./lib/index.d.ts",
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"peerDependencies": {
|
|
16
|
+
"@sps-woodland/core": "7.0.0",
|
|
17
|
+
"@sps-woodland/tokens": "7.0.0",
|
|
18
|
+
"@spscommerce/utils": "^6.12.1",
|
|
19
|
+
"react": "^16.9.0",
|
|
20
|
+
"react-dom": "^16.9.0"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@sps-woodland/core": "7.0.0",
|
|
24
|
+
"@sps-woodland/tokens": "7.0.0",
|
|
25
|
+
"@spscommerce/utils": "^6.12.1",
|
|
26
|
+
"@vanilla-extract/css": "^1.9.1",
|
|
27
|
+
"@vanilla-extract/recipes": "^0.2.5",
|
|
28
|
+
"@vanilla-extract/css-utils": "^0.1.3",
|
|
29
|
+
"react": "^16.9.0",
|
|
30
|
+
"react-dom": "^16.9.0"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "pnpm run build:js && pnpm run build:types",
|
|
34
|
+
"build:js": "vite build",
|
|
35
|
+
"build:types": "tsc --emitDeclarationOnly --declaration --declarationDir lib",
|
|
36
|
+
"watch": "vite build --watch",
|
|
37
|
+
"clean": "git clean -fdX",
|
|
38
|
+
"pub": "node ../../../scripts/publish-package.js"
|
|
39
|
+
}
|
|
40
|
+
}
|
package/vite.config.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import { vanillaExtractPlugin } from "@vanilla-extract/vite-plugin";
|
|
3
|
+
import { defineConfig } from "vite";
|
|
4
|
+
|
|
5
|
+
import pkg from "./package.json";
|
|
6
|
+
|
|
7
|
+
export default defineConfig({
|
|
8
|
+
plugins: [vanillaExtractPlugin()],
|
|
9
|
+
build: {
|
|
10
|
+
lib: {
|
|
11
|
+
entry: path.resolve(__dirname, "src/index.ts"),
|
|
12
|
+
formats: ["es", "cjs"],
|
|
13
|
+
fileName: (format) => `index.${format}.js`,
|
|
14
|
+
},
|
|
15
|
+
outDir: path.resolve(__dirname, "./lib"),
|
|
16
|
+
emptyOutDir: false,
|
|
17
|
+
rollupOptions: {
|
|
18
|
+
external: pkg.peerDependencies ? Object.keys(pkg.peerDependencies) : [],
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
});
|