@sps-woodland/sorting-header 8.34.12 → 8.34.14
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/lib/index.js +79 -80
- package/lib/index.umd.cjs +2 -2
- package/lib/style.css +1 -1
- package/package.json +9 -9
- package/vite.config.mjs +1 -1
package/lib/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as n from "react";
|
|
2
|
-
import { Metadata as
|
|
3
|
-
import { lockToAnimationFrames as
|
|
4
|
-
function
|
|
2
|
+
import { Metadata as V, cl as y, SortDirection as C, getScrollParent as M, selectChildren as G, modChildren as B } from "@sps-woodland/core";
|
|
3
|
+
import { lockToAnimationFrames as x, code as L } from "@spscommerce/utils";
|
|
4
|
+
function W(e, o, r) {
|
|
5
5
|
return o in e ? Object.defineProperty(e, o, {
|
|
6
6
|
value: r,
|
|
7
7
|
enumerable: !0,
|
|
@@ -9,7 +9,7 @@ function Y(e, o, r) {
|
|
|
9
9
|
writable: !0
|
|
10
10
|
}) : e[o] = r, e;
|
|
11
11
|
}
|
|
12
|
-
function
|
|
12
|
+
function D(e, o) {
|
|
13
13
|
var r = Object.keys(e);
|
|
14
14
|
if (Object.getOwnPropertySymbols) {
|
|
15
15
|
var t = Object.getOwnPropertySymbols(e);
|
|
@@ -19,43 +19,43 @@ function T(e, o) {
|
|
|
19
19
|
}
|
|
20
20
|
return r;
|
|
21
21
|
}
|
|
22
|
-
function
|
|
22
|
+
function O(e) {
|
|
23
23
|
for (var o = 1; o < arguments.length; o++) {
|
|
24
24
|
var r = arguments[o] != null ? arguments[o] : {};
|
|
25
|
-
o % 2 ?
|
|
26
|
-
|
|
27
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) :
|
|
25
|
+
o % 2 ? D(Object(r), !0).forEach(function(t) {
|
|
26
|
+
W(e, t, r[t]);
|
|
27
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : D(Object(r)).forEach(function(t) {
|
|
28
28
|
Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(r, t));
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
31
|
return e;
|
|
32
32
|
}
|
|
33
|
-
var
|
|
33
|
+
var z = (e, o, r) => {
|
|
34
34
|
for (var t of Object.keys(e)) {
|
|
35
35
|
var l;
|
|
36
36
|
if (e[t] !== ((l = o[t]) !== null && l !== void 0 ? l : r[t]))
|
|
37
37
|
return !1;
|
|
38
38
|
}
|
|
39
39
|
return !0;
|
|
40
|
-
},
|
|
41
|
-
var r = e.defaultClassName, t =
|
|
40
|
+
}, P = (e) => (o) => {
|
|
41
|
+
var r = e.defaultClassName, t = O(O({}, e.defaultVariants), o);
|
|
42
42
|
for (var l in t) {
|
|
43
43
|
var _, a = (_ = t[l]) !== null && _ !== void 0 ? _ : e.defaultVariants[l];
|
|
44
44
|
if (a != null) {
|
|
45
45
|
var u = a;
|
|
46
46
|
typeof u == "boolean" && (u = u === !0 ? "true" : "false");
|
|
47
|
-
var
|
|
47
|
+
var h = (
|
|
48
48
|
// @ts-expect-error
|
|
49
49
|
e.variantClassNames[l][u]
|
|
50
50
|
);
|
|
51
|
-
|
|
51
|
+
h && (r += " " + h);
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
for (var [i, p] of e.compoundVariants)
|
|
55
|
-
|
|
55
|
+
z(i, t, e.defaultVariants) && (r += " " + p);
|
|
56
56
|
return r;
|
|
57
|
-
},
|
|
58
|
-
function
|
|
57
|
+
}, H = P({ defaultClassName: "pkg_sps-woodland_sorting-header__version_8_34_14__hash_7ljhcs0", variantClassNames: { up: { true: "pkg_sps-woodland_sorting-header__version_8_34_14__hash_7ljhcs1" }, down: { true: "pkg_sps-woodland_sorting-header__version_8_34_14__hash_7ljhcs2" } }, defaultVariants: {}, compoundVariants: [] }), T = P({ defaultClassName: "pkg_sps-woodland_sorting-header__version_8_34_14__hash_1crs4gl0", variantClassNames: { disabled: { true: "pkg_sps-woodland_sorting-header__version_8_34_14__hash_1crs4gl1" }, active: { true: "pkg_sps-woodland_sorting-header__version_8_34_14__hash_1crs4gl2" }, __autoLayout: { true: "pkg_sps-woodland_sorting-header__version_8_34_14__hash_1crs4gl3", false: "pkg_sps-woodland_sorting-header__version_8_34_14__hash_1crs4gl4" } }, defaultVariants: { disabled: !1, active: !1, __autoLayout: !1 }, compoundVariants: [] });
|
|
58
|
+
function R({
|
|
59
59
|
className: e,
|
|
60
60
|
sortKey: o,
|
|
61
61
|
sort: r,
|
|
@@ -64,57 +64,57 @@ function O({
|
|
|
64
64
|
onClick: _,
|
|
65
65
|
children: a,
|
|
66
66
|
style: u,
|
|
67
|
-
widthPx:
|
|
67
|
+
widthPx: h,
|
|
68
68
|
widthRem: i,
|
|
69
69
|
__autoLayout: p = !1,
|
|
70
70
|
...d
|
|
71
71
|
}) {
|
|
72
72
|
const c = n.useMemo(() => {
|
|
73
|
-
const
|
|
74
|
-
return
|
|
75
|
-
}, [r, o, t]),
|
|
73
|
+
const v = !!o && !t && Array.isArray(r) && r.find((E) => E.key === o);
|
|
74
|
+
return v ? v.direction : void 0;
|
|
75
|
+
}, [r, o, t]), k = h ? h / 16 : i, g = k ? { ...u, width: `${k}rem` } : u, b = (v) => {
|
|
76
76
|
o && !t && l && l([
|
|
77
77
|
{
|
|
78
78
|
key: o,
|
|
79
|
-
direction: c ===
|
|
79
|
+
direction: c === C.ASCENDING ? C.DESCENDING : C.ASCENDING
|
|
80
80
|
}
|
|
81
|
-
]), _ && _(
|
|
81
|
+
]), _ && _(v);
|
|
82
82
|
};
|
|
83
83
|
return p ? /* @__PURE__ */ n.createElement(
|
|
84
84
|
"td",
|
|
85
85
|
{
|
|
86
|
-
className:
|
|
86
|
+
className: y(
|
|
87
87
|
e,
|
|
88
|
-
|
|
89
|
-
c &&
|
|
90
|
-
up: c ===
|
|
91
|
-
down: c ===
|
|
88
|
+
T({ disabled: t, active: !!c, __autoLayout: p }),
|
|
89
|
+
c && H({
|
|
90
|
+
up: c === C.ASCENDING,
|
|
91
|
+
down: c === C.DESCENDING
|
|
92
92
|
})
|
|
93
93
|
),
|
|
94
|
-
onClick:
|
|
95
|
-
style:
|
|
94
|
+
onClick: b,
|
|
95
|
+
style: g,
|
|
96
96
|
...d
|
|
97
97
|
},
|
|
98
98
|
a
|
|
99
99
|
) : /* @__PURE__ */ n.createElement(
|
|
100
100
|
"div",
|
|
101
101
|
{
|
|
102
|
-
className:
|
|
102
|
+
className: y(
|
|
103
103
|
e,
|
|
104
|
-
|
|
105
|
-
c &&
|
|
106
|
-
up: c ===
|
|
107
|
-
down: c ===
|
|
104
|
+
T({ disabled: t, active: !!c, __autoLayout: p }),
|
|
105
|
+
c && H({
|
|
106
|
+
up: c === C.ASCENDING,
|
|
107
|
+
down: c === C.DESCENDING
|
|
108
108
|
})
|
|
109
109
|
),
|
|
110
|
-
onClick:
|
|
111
|
-
style:
|
|
110
|
+
onClick: b,
|
|
111
|
+
style: g,
|
|
112
112
|
...d
|
|
113
113
|
},
|
|
114
114
|
a
|
|
115
115
|
);
|
|
116
116
|
}
|
|
117
|
-
|
|
117
|
+
V.set(R, {
|
|
118
118
|
name: "Sorting Header Cell",
|
|
119
119
|
props: {
|
|
120
120
|
sortKey: { type: "string" },
|
|
@@ -125,8 +125,8 @@ M.set(O, {
|
|
|
125
125
|
widthRem: { type: "number" }
|
|
126
126
|
}
|
|
127
127
|
});
|
|
128
|
-
var
|
|
129
|
-
function
|
|
128
|
+
var I = P({ defaultClassName: "pkg_sps-woodland_sorting-header__version_8_34_14__hash_sk81640", variantClassNames: { pinned: { true: "pkg_sps-woodland_sorting-header__version_8_34_14__hash_sk81641", false: "pkg_sps-woodland_sorting-header__version_8_34_14__hash_sk81642" }, scrollParentIsWindow: { true: "pkg_sps-woodland_sorting-header__version_8_34_14__hash_sk81643", false: "pkg_sps-woodland_sorting-header__version_8_34_14__hash_sk81644" }, __autoLayout: { true: "pkg_sps-woodland_sorting-header__version_8_34_14__hash_sk81645", false: "pkg_sps-woodland_sorting-header__version_8_34_14__hash_sk81646" } }, defaultVariants: { pinned: !1, scrollParentIsWindow: !1, __autoLayout: !1 }, compoundVariants: [[{ pinned: !0, scrollParentIsWindow: !0 }, "pkg_sps-woodland_sorting-header__version_8_34_14__hash_sk81647"]] }), F = "pkg_sps-woodland_sorting-header__version_8_34_14__hash_sk81648";
|
|
129
|
+
function K({
|
|
130
130
|
sort: e,
|
|
131
131
|
onSortChange: o,
|
|
132
132
|
children: r,
|
|
@@ -135,124 +135,123 @@ function G({
|
|
|
135
135
|
__autoLayout: _ = !1,
|
|
136
136
|
...a
|
|
137
137
|
}) {
|
|
138
|
-
const [u,
|
|
138
|
+
const [u, h] = n.useState(!1), i = n.useRef(null), p = n.useRef(null), d = n.useRef({
|
|
139
139
|
height: "",
|
|
140
140
|
width: "",
|
|
141
141
|
unpinAtTop: 0,
|
|
142
142
|
unpinAtBottom: 0,
|
|
143
143
|
cellWidths: []
|
|
144
|
-
}), c = n.useCallback(() => i.current &&
|
|
144
|
+
}), c = n.useCallback(() => i.current && M(i.current) || window, []), k = n.useCallback((s) => {
|
|
145
145
|
const m = s || c();
|
|
146
146
|
return m.scrollY || m.scrollTop || 0;
|
|
147
|
-
}, []),
|
|
147
|
+
}, []), g = n.useCallback(
|
|
148
148
|
(s) => {
|
|
149
|
-
var m, k, b;
|
|
150
149
|
if (l && i.current) {
|
|
151
|
-
const
|
|
152
|
-
if (
|
|
153
|
-
const
|
|
154
|
-
d.current.height = `${
|
|
155
|
-
|
|
150
|
+
const m = s || c(), S = k(m), w = _ ? i.current.parentElement?.parentElement?.getBoundingClientRect() : i.current.parentElement?.getBoundingClientRect();
|
|
151
|
+
if (w) {
|
|
152
|
+
const f = i.current.getBoundingClientRect();
|
|
153
|
+
d.current.height = `${f.height}px`, d.current.width = `${f.width}px`, m === window ? (d.current.unpinAtBottom = w.bottom + S - f.height * 2, d.current.unpinAtTop = f.top + S - f.height) : (d.current.unpinAtBottom = w.bottom + S - f.height * 2, d.current.unpinAtTop = w.top + S), d.current.cellWidths = [], i.current.childNodes.forEach((A, j) => {
|
|
154
|
+
A instanceof HTMLElement && (d.current.cellWidths[j] = `${A.getBoundingClientRect().width}px`);
|
|
156
155
|
});
|
|
157
156
|
}
|
|
158
157
|
}
|
|
159
158
|
},
|
|
160
159
|
[l]
|
|
161
|
-
),
|
|
160
|
+
), b = n.useCallback(() => {
|
|
162
161
|
p.current && (p.current.style.width = d.current.width, p.current.style.height = d.current.height, p.current.childNodes.forEach((s, m) => {
|
|
163
162
|
s instanceof HTMLElement && (s.style.width = d.current.cellWidths[m] || "");
|
|
164
163
|
}));
|
|
165
164
|
}, []);
|
|
166
165
|
n.useLayoutEffect(() => {
|
|
167
|
-
|
|
166
|
+
g();
|
|
168
167
|
}), n.useLayoutEffect(() => {
|
|
169
168
|
let s;
|
|
170
169
|
const m = c();
|
|
171
|
-
return l ? (s =
|
|
172
|
-
|
|
173
|
-
const { unpinAtTop:
|
|
174
|
-
|
|
170
|
+
return l ? (s = x(() => {
|
|
171
|
+
g(m);
|
|
172
|
+
const { unpinAtTop: S, unpinAtBottom: w } = d.current, f = k(m);
|
|
173
|
+
S && w && (f >= S && f <= w ? (h(!0), i.current && (i.current.style.visibility = "hidden")) : (h(!1), i.current && (i.current.style.visibility = "visible")));
|
|
175
174
|
}), m.addEventListener("scroll", s), s()) : i.current && (i.current.style.visibility = "visible"), () => {
|
|
176
175
|
s && m.removeEventListener("scroll", s);
|
|
177
176
|
};
|
|
178
|
-
}, [l,
|
|
177
|
+
}, [l, g]), n.useLayoutEffect(() => {
|
|
179
178
|
let s;
|
|
180
179
|
return u && (s = () => {
|
|
181
|
-
|
|
180
|
+
g(), b();
|
|
182
181
|
}, window.addEventListener("resize", s), s()), () => {
|
|
183
182
|
s && window.removeEventListener("resize", s);
|
|
184
183
|
};
|
|
185
|
-
}, [u,
|
|
186
|
-
const [
|
|
184
|
+
}, [u, g, b]);
|
|
185
|
+
const [v] = G(r, [{ type: R }]), E = B(v, () => [{ sort: e, onSortChange: o }]), N = c() === window;
|
|
187
186
|
if (_) {
|
|
188
|
-
const s = /* @__PURE__ */ n.createElement("tr", null, /* @__PURE__ */ n.createElement("td", { className:
|
|
187
|
+
const s = /* @__PURE__ */ n.createElement("tr", null, /* @__PURE__ */ n.createElement("td", { className: y(F), colSpan: 100 }));
|
|
189
188
|
return /* @__PURE__ */ n.createElement(n.Fragment, null, /* @__PURE__ */ n.createElement(
|
|
190
189
|
"tr",
|
|
191
190
|
{
|
|
192
191
|
ref: i,
|
|
193
|
-
className:
|
|
194
|
-
|
|
192
|
+
className: y(
|
|
193
|
+
I({ pinned: !1, scrollParentIsWindow: N, __autoLayout: _ }),
|
|
195
194
|
t
|
|
196
195
|
),
|
|
197
196
|
...a
|
|
198
197
|
},
|
|
199
|
-
|
|
198
|
+
E
|
|
200
199
|
), s, u && /* @__PURE__ */ n.createElement(
|
|
201
200
|
"tr",
|
|
202
201
|
{
|
|
203
202
|
ref: p,
|
|
204
|
-
className:
|
|
203
|
+
className: y(
|
|
205
204
|
t,
|
|
206
|
-
|
|
205
|
+
I({ pinned: !0, scrollParentIsWindow: N, __autoLayout: _ })
|
|
207
206
|
),
|
|
208
207
|
...a,
|
|
209
208
|
id: a.id ? `pinned-${a.id}` : void 0,
|
|
210
209
|
"data-testid": a["data-testid"] ? `pinned-${a["data-testid"]}` : void 0
|
|
211
210
|
},
|
|
212
|
-
|
|
211
|
+
E
|
|
213
212
|
));
|
|
214
213
|
}
|
|
215
214
|
return /* @__PURE__ */ n.createElement(n.Fragment, null, /* @__PURE__ */ n.createElement(
|
|
216
215
|
"div",
|
|
217
216
|
{
|
|
218
217
|
ref: i,
|
|
219
|
-
className:
|
|
218
|
+
className: y(
|
|
220
219
|
t,
|
|
221
|
-
|
|
220
|
+
I({ pinned: !1, scrollParentIsWindow: N, __autoLayout: _ })
|
|
222
221
|
),
|
|
223
222
|
...a
|
|
224
223
|
},
|
|
225
|
-
|
|
224
|
+
E
|
|
226
225
|
), u && /* @__PURE__ */ n.createElement(
|
|
227
226
|
"div",
|
|
228
227
|
{
|
|
229
228
|
ref: p,
|
|
230
|
-
className:
|
|
229
|
+
className: y(
|
|
231
230
|
t,
|
|
232
|
-
|
|
231
|
+
I({ pinned: !0, scrollParentIsWindow: N, __autoLayout: _ })
|
|
233
232
|
),
|
|
234
233
|
...a,
|
|
235
234
|
id: a.id ? `pinned-${a.id}` : void 0,
|
|
236
235
|
"data-testid": a["data-testid"] ? `pinned-${a["data-testid"]}` : void 0
|
|
237
236
|
},
|
|
238
|
-
|
|
237
|
+
E
|
|
239
238
|
));
|
|
240
239
|
}
|
|
241
|
-
|
|
240
|
+
V.set(K, {
|
|
242
241
|
name: "Sorting Header",
|
|
243
242
|
props: {
|
|
244
243
|
sort: { type: "SortedColumn[]" },
|
|
245
244
|
onSortChange: { type: "SortChangeHandler" }
|
|
246
245
|
}
|
|
247
246
|
});
|
|
248
|
-
const
|
|
249
|
-
components: [
|
|
247
|
+
const Y = {
|
|
248
|
+
components: [K, R],
|
|
250
249
|
examples: {
|
|
251
250
|
basic: {
|
|
252
251
|
label: "Sorting Header",
|
|
253
252
|
examples: {
|
|
254
253
|
basic: {
|
|
255
|
-
react:
|
|
254
|
+
react: L`
|
|
256
255
|
import { SortingHeader, SortingHeaderCell } from "@sps-woodland/sorting-header";
|
|
257
256
|
import { Icon } from "@sps-woodland/core";
|
|
258
257
|
import { ContentRow } from "@sps-woodland/content-row";
|
|
@@ -351,11 +350,11 @@ const J = {
|
|
|
351
350
|
}
|
|
352
351
|
}
|
|
353
352
|
}
|
|
354
|
-
},
|
|
355
|
-
"Sorting Header":
|
|
353
|
+
}, J = {
|
|
354
|
+
"Sorting Header": Y
|
|
356
355
|
};
|
|
357
356
|
export {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
357
|
+
J as MANIFEST,
|
|
358
|
+
K as SortingHeader,
|
|
359
|
+
R as SortingHeaderCell
|
|
361
360
|
};
|
package/lib/index.umd.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(h,
|
|
1
|
+
(function(h,b){typeof exports=="object"&&typeof module<"u"?b(exports,require("react"),require("@sps-woodland/core"),require("@spscommerce/utils")):typeof define=="function"&&define.amd?define(["exports","react","@sps-woodland/core","@spscommerce/utils"],b):(h=typeof globalThis<"u"?globalThis:h||self,b(h.SortingHeader={},h.React,h.core,h.utils))})(this,function(h,b,s,T){"use strict";function K(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const t=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,t.get?t:{enumerable:!0,get:()=>e[n]})}}return r.default=e,Object.freeze(r)}const o=K(b);function G(e,r,n){return r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function A(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r&&(t=t.filter(function(d){return Object.getOwnPropertyDescriptor(e,d).enumerable})),n.push.apply(n,t)}return n}function H(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?A(Object(n),!0).forEach(function(t){G(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):A(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var B=(e,r,n)=>{for(var t of Object.keys(e)){var d;if(e[t]!==((d=r[t])!==null&&d!==void 0?d:n[t]))return!1}return!0},O=e=>r=>{var n=e.defaultClassName,t=H(H({},e.defaultVariants),r);for(var d in t){var p,l=(p=t[d])!==null&&p!==void 0?p:e.defaultVariants[d];if(l!=null){var _=l;typeof _=="boolean"&&(_=_===!0?"true":"false");var S=e.variantClassNames[d][_];S&&(n+=" "+S)}}for(var[a,m]of e.compoundVariants)B(a,t,e.defaultVariants)&&(n+=" "+m);return n},V=O({defaultClassName:"pkg_sps-woodland_sorting-header__version_8_34_14__hash_7ljhcs0",variantClassNames:{up:{true:"pkg_sps-woodland_sorting-header__version_8_34_14__hash_7ljhcs1"},down:{true:"pkg_sps-woodland_sorting-header__version_8_34_14__hash_7ljhcs2"}},defaultVariants:{},compoundVariants:[]}),j=O({defaultClassName:"pkg_sps-woodland_sorting-header__version_8_34_14__hash_1crs4gl0",variantClassNames:{disabled:{true:"pkg_sps-woodland_sorting-header__version_8_34_14__hash_1crs4gl1"},active:{true:"pkg_sps-woodland_sorting-header__version_8_34_14__hash_1crs4gl2"},__autoLayout:{true:"pkg_sps-woodland_sorting-header__version_8_34_14__hash_1crs4gl3",false:"pkg_sps-woodland_sorting-header__version_8_34_14__hash_1crs4gl4"}},defaultVariants:{disabled:!1,active:!1,__autoLayout:!1},compoundVariants:[]});function P({className:e,sortKey:r,sort:n,sortDisabled:t,onSortChange:d,onClick:p,children:l,style:_,widthPx:S,widthRem:a,__autoLayout:m=!1,...c}){const u=o.useMemo(()=>{const v=!!r&&!t&&Array.isArray(n)&&n.find(E=>E.key===r);return v?v.direction:void 0},[n,r,t]),k=S?S/16:a,w=k?{..._,width:`${k}rem`}:_,N=v=>{r&&!t&&d&&d([{key:r,direction:u===s.SortDirection.ASCENDING?s.SortDirection.DESCENDING:s.SortDirection.ASCENDING}]),p&&p(v)};return m?o.createElement("td",{className:s.cl(e,j({disabled:t,active:!!u,__autoLayout:m}),u&&V({up:u===s.SortDirection.ASCENDING,down:u===s.SortDirection.DESCENDING})),onClick:N,style:w,...c},l):o.createElement("div",{className:s.cl(e,j({disabled:t,active:!!u,__autoLayout:m}),u&&V({up:u===s.SortDirection.ASCENDING,down:u===s.SortDirection.DESCENDING})),onClick:N,style:w,...c},l)}s.Metadata.set(P,{name:"Sorting Header Cell",props:{sortKey:{type:"string"},sort:{type:"SortedColumn[]"},sortDisabled:{type:"boolean"},onSortChange:{type:"SortChangeHandler"},widthPx:{type:"number"},widthRem:{type:"number"}}});var D=O({defaultClassName:"pkg_sps-woodland_sorting-header__version_8_34_14__hash_sk81640",variantClassNames:{pinned:{true:"pkg_sps-woodland_sorting-header__version_8_34_14__hash_sk81641",false:"pkg_sps-woodland_sorting-header__version_8_34_14__hash_sk81642"},scrollParentIsWindow:{true:"pkg_sps-woodland_sorting-header__version_8_34_14__hash_sk81643",false:"pkg_sps-woodland_sorting-header__version_8_34_14__hash_sk81644"},__autoLayout:{true:"pkg_sps-woodland_sorting-header__version_8_34_14__hash_sk81645",false:"pkg_sps-woodland_sorting-header__version_8_34_14__hash_sk81646"}},defaultVariants:{pinned:!1,scrollParentIsWindow:!1,__autoLayout:!1},compoundVariants:[[{pinned:!0,scrollParentIsWindow:!0},"pkg_sps-woodland_sorting-header__version_8_34_14__hash_sk81647"]]}),x="pkg_sps-woodland_sorting-header__version_8_34_14__hash_sk81648";function R({sort:e,onSortChange:r,children:n,className:t,pinSortingHeader:d=!1,__autoLayout:p=!1,...l}){const[_,S]=o.useState(!1),a=o.useRef(null),m=o.useRef(null),c=o.useRef({height:"",width:"",unpinAtTop:0,unpinAtBottom:0,cellWidths:[]}),u=o.useCallback(()=>a.current&&s.getScrollParent(a.current)||window,[]),k=o.useCallback(i=>{const f=i||u();return f.scrollY||f.scrollTop||0},[]),w=o.useCallback(i=>{if(d&&a.current){const f=i||u(),y=k(f),C=p?a.current.parentElement?.parentElement?.getBoundingClientRect():a.current.parentElement?.getBoundingClientRect();if(C){const g=a.current.getBoundingClientRect();c.current.height=`${g.height}px`,c.current.width=`${g.width}px`,f===window?(c.current.unpinAtBottom=C.bottom+y-g.height*2,c.current.unpinAtTop=g.top+y-g.height):(c.current.unpinAtBottom=C.bottom+y-g.height*2,c.current.unpinAtTop=C.top+y),c.current.cellWidths=[],a.current.childNodes.forEach((M,W)=>{M instanceof HTMLElement&&(c.current.cellWidths[W]=`${M.getBoundingClientRect().width}px`)})}}},[d]),N=o.useCallback(()=>{m.current&&(m.current.style.width=c.current.width,m.current.style.height=c.current.height,m.current.childNodes.forEach((i,f)=>{i instanceof HTMLElement&&(i.style.width=c.current.cellWidths[f]||"")}))},[]);o.useLayoutEffect(()=>{w()}),o.useLayoutEffect(()=>{let i;const f=u();return d?(i=T.lockToAnimationFrames(()=>{w(f);const{unpinAtTop:y,unpinAtBottom:C}=c.current,g=k(f);y&&C&&(g>=y&&g<=C?(S(!0),a.current&&(a.current.style.visibility="hidden")):(S(!1),a.current&&(a.current.style.visibility="visible")))}),f.addEventListener("scroll",i),i()):a.current&&(a.current.style.visibility="visible"),()=>{i&&f.removeEventListener("scroll",i)}},[d,w]),o.useLayoutEffect(()=>{let i;return _&&(i=()=>{w(),N()},window.addEventListener("resize",i),i()),()=>{i&&window.removeEventListener("resize",i)}},[_,w,N]);const[v]=s.selectChildren(n,[{type:P}]),E=s.modChildren(v,()=>[{sort:e,onSortChange:r}]),I=u()===window;if(p){const i=o.createElement("tr",null,o.createElement("td",{className:s.cl(x),colSpan:100}));return o.createElement(o.Fragment,null,o.createElement("tr",{ref:a,className:s.cl(D({pinned:!1,scrollParentIsWindow:I,__autoLayout:p}),t),...l},E),i,_&&o.createElement("tr",{ref:m,className:s.cl(t,D({pinned:!0,scrollParentIsWindow:I,__autoLayout:p})),...l,id:l.id?`pinned-${l.id}`:void 0,"data-testid":l["data-testid"]?`pinned-${l["data-testid"]}`:void 0},E))}return o.createElement(o.Fragment,null,o.createElement("div",{ref:a,className:s.cl(t,D({pinned:!1,scrollParentIsWindow:I,__autoLayout:p})),...l},E),_&&o.createElement("div",{ref:m,className:s.cl(t,D({pinned:!0,scrollParentIsWindow:I,__autoLayout:p})),...l,id:l.id?`pinned-${l.id}`:void 0,"data-testid":l["data-testid"]?`pinned-${l["data-testid"]}`:void 0},E))}s.Metadata.set(R,{name:"Sorting Header",props:{sort:{type:"SortedColumn[]"},onSortChange:{type:"SortChangeHandler"}}});const L={"Sorting Header":{components:[R,P],examples:{basic:{label:"Sorting Header",examples:{basic:{react:T.code`
|
|
2
2
|
import { SortingHeader, SortingHeaderCell } from "@sps-woodland/sorting-header";
|
|
3
3
|
import { Icon } from "@sps-woodland/core";
|
|
4
4
|
import { ContentRow } from "@sps-woodland/content-row";
|
|
@@ -92,4 +92,4 @@
|
|
|
92
92
|
</>
|
|
93
93
|
);
|
|
94
94
|
}
|
|
95
|
-
`}}}}}};h.MANIFEST=
|
|
95
|
+
`}}}}}};h.MANIFEST=L,h.SortingHeader=R,h.SortingHeaderCell=P,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
|
package/lib/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.pkg_sps-woodland_sorting-
|
|
1
|
+
.pkg_sps-woodland_sorting-header__version_8_34_14__hash_7ljhcs0:after{content:"";border-left-color:transparent;border-right-color:transparent;border-style:solid;border-width:.375rem .25rem;height:0;position:absolute;right:.5rem}.pkg_sps-woodland_sorting-header__version_8_34_14__hash_7ljhcs1:after{border-bottom-color:#1f282c;border-top-color:transparent;top:calc(50% - 9px)}.pkg_sps-woodland_sorting-header__version_8_34_14__hash_7ljhcs2:after{border-top-color:#1f282c;border-bottom-color:transparent;top:calc(50% - 3px)}.pkg_sps-woodland_sorting-header__version_8_34_14__hash_1crs4gl0{display:table-cell;vertical-align:middle;color:#4b5356;font-size:.75rem;font-weight:600;line-height:1.25rem;padding:.5rem;position:relative}.pkg_sps-woodland_sorting-header__version_8_34_14__hash_1crs4gl0:hover{background-color:#f3f4f4}.pkg_sps-woodland_sorting-header__version_8_34_14__hash_1crs4gl1{cursor:default}.pkg_sps-woodland_sorting-header__version_8_34_14__hash_1crs4gl1:hover{background-color:#e9e9ea}.pkg_sps-woodland_sorting-header__version_8_34_14__hash_1crs4gl2{color:#1f282c;background-color:#d2d4d4}.pkg_sps-woodland_sorting-header__version_8_34_14__hash_1crs4gl3{text-align:left}.pkg_sps-woodland_sorting-header__version_8_34_14__hash_1crs4gl3:first-child{border-top-left-radius:.25rem;border-bottom-left-radius:.25rem}.pkg_sps-woodland_sorting-header__version_8_34_14__hash_1crs4gl3:last-child{border-top-right-radius:.25rem;border-bottom-right-radius:.25rem}.pkg_sps-woodland_sorting-header__version_8_34_14__hash_sk81640{padding:0;border-radius:.25rem;vertical-align:bottom;cursor:pointer;background-color:#e9e9ea}.pkg_sps-woodland_sorting-header__version_8_34_14__hash_sk81641{border-radius:0;position:fixed;top:0;z-index:999}.pkg_sps-woodland_sorting-header__version_8_34_14__hash_sk81641:after{content:"";background:linear-gradient(180deg,rgba(0,0,0,.1),transparent);display:block;height:.625rem;position:absolute;top:100%;left:-.0625rem;width:100%}.pkg_sps-woodland_sorting-header__version_8_34_14__hash_sk81645{display:table-row}.pkg_sps-woodland_sorting-header__version_8_34_14__hash_sk81646{display:table;table-layout:fixed;width:100%}.pkg_sps-woodland_sorting-header__version_8_34_14__hash_sk81647{top:3.75rem}.pkg_sps-woodland_sorting-header__version_8_34_14__hash_sk81648{height:1rem;background:transparent;border:0}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sps-woodland/sorting-header",
|
|
3
3
|
"description": "SPS Woodland Design System sorting-header and sorting-header cell components",
|
|
4
|
-
"version": "8.34.
|
|
4
|
+
"version": "8.34.14",
|
|
5
5
|
"author": "SPS Commerce",
|
|
6
6
|
"license": "UNLICENSED",
|
|
7
7
|
"repository": "https://github.com/SPSCommerce/woodland/tree/main/packages/@sps-woodland/sorting-header",
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
"types": "./lib/index.d.ts",
|
|
13
13
|
"exports": {
|
|
14
14
|
".": {
|
|
15
|
+
"types": "./lib/index.d.ts",
|
|
15
16
|
"require": "./lib/index.umd.cjs",
|
|
16
17
|
"import": "./lib/index.js",
|
|
17
|
-
"default": "./lib/index.js"
|
|
18
|
-
"types": "./lib/index.d.ts"
|
|
18
|
+
"default": "./lib/index.js"
|
|
19
19
|
},
|
|
20
20
|
"./lib/style.css": {
|
|
21
21
|
"import": "./lib/style.css",
|
|
@@ -29,18 +29,18 @@
|
|
|
29
29
|
"@spscommerce/utils": "^7.0.0",
|
|
30
30
|
"react": "^16.14.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
31
31
|
"react-dom": "^16.14.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
32
|
-
"@sps-woodland/core": "8.34.
|
|
33
|
-
"@sps-woodland/tokens": "8.34.
|
|
32
|
+
"@sps-woodland/core": "8.34.14",
|
|
33
|
+
"@sps-woodland/tokens": "8.34.14"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@spscommerce/utils": "^
|
|
37
|
-
"@vanilla-extract/css": "^1.
|
|
36
|
+
"@spscommerce/utils": "^8.1.1",
|
|
37
|
+
"@vanilla-extract/css": "^1.17.4",
|
|
38
38
|
"@vanilla-extract/css-utils": "^0.1.3",
|
|
39
39
|
"@vanilla-extract/recipes": "^0.2.5",
|
|
40
40
|
"react": "^16.14.0",
|
|
41
41
|
"react-dom": "^16.14.0",
|
|
42
|
-
"@sps-woodland/core": "8.34.
|
|
43
|
-
"@sps-woodland/tokens": "8.34.
|
|
42
|
+
"@sps-woodland/core": "8.34.14",
|
|
43
|
+
"@sps-woodland/tokens": "8.34.14"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "pnpm run build:js && pnpm run build:types",
|
package/vite.config.mjs
CHANGED