@sps-woodland/sorting-header 8.24.0 → 8.24.2
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 +56 -56
- package/lib/index.umd.cjs +1 -1
- package/lib/style.css +1 -1
- package/package.json +5 -5
package/lib/index.js
CHANGED
|
@@ -1,86 +1,86 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as n from "react";
|
|
2
2
|
import { Metadata as M, cl as S, SortDirection as g, getScrollParent as x, selectChildren as L, modChildren as W } from "@sps-woodland/core";
|
|
3
3
|
import { lockToAnimationFrames as z, code as F } from "@spscommerce/utils";
|
|
4
|
-
function Y(e, o,
|
|
4
|
+
function Y(e, o, r) {
|
|
5
5
|
return o in e ? Object.defineProperty(e, o, {
|
|
6
|
-
value:
|
|
6
|
+
value: r,
|
|
7
7
|
enumerable: !0,
|
|
8
8
|
configurable: !0,
|
|
9
9
|
writable: !0
|
|
10
|
-
}) : e[o] =
|
|
10
|
+
}) : e[o] = r, e;
|
|
11
11
|
}
|
|
12
12
|
function T(e, o) {
|
|
13
|
-
var
|
|
13
|
+
var r = Object.keys(e);
|
|
14
14
|
if (Object.getOwnPropertySymbols) {
|
|
15
15
|
var t = Object.getOwnPropertySymbols(e);
|
|
16
16
|
o && (t = t.filter(function(l) {
|
|
17
17
|
return Object.getOwnPropertyDescriptor(e, l).enumerable;
|
|
18
|
-
})),
|
|
18
|
+
})), r.push.apply(r, t);
|
|
19
19
|
}
|
|
20
|
-
return
|
|
20
|
+
return r;
|
|
21
21
|
}
|
|
22
22
|
function V(e) {
|
|
23
23
|
for (var o = 1; o < arguments.length; o++) {
|
|
24
|
-
var
|
|
25
|
-
o % 2 ? T(Object(
|
|
26
|
-
Y(e, t,
|
|
27
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(
|
|
28
|
-
Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(
|
|
24
|
+
var r = arguments[o] != null ? arguments[o] : {};
|
|
25
|
+
o % 2 ? T(Object(r), !0).forEach(function(t) {
|
|
26
|
+
Y(e, t, r[t]);
|
|
27
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : T(Object(r)).forEach(function(t) {
|
|
28
|
+
Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(r, t));
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
31
|
return e;
|
|
32
32
|
}
|
|
33
|
-
var $ = (e, o,
|
|
33
|
+
var $ = (e, o, r) => {
|
|
34
34
|
for (var t of Object.keys(e)) {
|
|
35
35
|
var l;
|
|
36
|
-
if (e[t] !== ((l = o[t]) !== null && l !== void 0 ? l :
|
|
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
40
|
}, D = (e) => (o) => {
|
|
41
|
-
var
|
|
41
|
+
var r = e.defaultClassName, t = V(V({}, e.defaultVariants), o);
|
|
42
42
|
for (var l in t) {
|
|
43
|
-
var
|
|
43
|
+
var _, a = (_ = t[l]) !== null && _ !== void 0 ? _ : e.defaultVariants[l];
|
|
44
44
|
if (a != null) {
|
|
45
|
-
var
|
|
46
|
-
typeof
|
|
45
|
+
var u = a;
|
|
46
|
+
typeof u == "boolean" && (u = u === !0 ? "true" : "false");
|
|
47
47
|
var f = (
|
|
48
48
|
// @ts-expect-error
|
|
49
|
-
e.variantClassNames[l][
|
|
49
|
+
e.variantClassNames[l][u]
|
|
50
50
|
);
|
|
51
|
-
f && (
|
|
51
|
+
f && (r += " " + f);
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
for (var [i, p] of e.compoundVariants)
|
|
55
|
-
$(i, t, e.defaultVariants) && (
|
|
56
|
-
return
|
|
57
|
-
}, K = D({ defaultClassName: "pkg_sps-woodland_sorting-
|
|
55
|
+
$(i, t, e.defaultVariants) && (r += " " + p);
|
|
56
|
+
return r;
|
|
57
|
+
}, K = D({ defaultClassName: "pkg_sps-woodland_sorting-header__version_8_24_2__hash_7ljhcs0", variantClassNames: { up: { true: "pkg_sps-woodland_sorting-header__version_8_24_2__hash_7ljhcs1" }, down: { true: "pkg_sps-woodland_sorting-header__version_8_24_2__hash_7ljhcs2" } }, defaultVariants: {}, compoundVariants: [] }), j = D({ defaultClassName: "pkg_sps-woodland_sorting-header__version_8_24_2__hash_1crs4gl0", variantClassNames: { disabled: { true: "pkg_sps-woodland_sorting-header__version_8_24_2__hash_1crs4gl1" }, active: { true: "pkg_sps-woodland_sorting-header__version_8_24_2__hash_1crs4gl2" }, __autoLayout: { true: "pkg_sps-woodland_sorting-header__version_8_24_2__hash_1crs4gl3", false: "pkg_sps-woodland_sorting-header__version_8_24_2__hash_1crs4gl4" } }, defaultVariants: { disabled: !1, active: !1, __autoLayout: !1 }, compoundVariants: [] });
|
|
58
58
|
function O({
|
|
59
59
|
className: e,
|
|
60
60
|
sortKey: o,
|
|
61
|
-
sort:
|
|
61
|
+
sort: r,
|
|
62
62
|
sortDisabled: t,
|
|
63
63
|
onSortChange: l,
|
|
64
|
-
onClick:
|
|
64
|
+
onClick: _,
|
|
65
65
|
children: a,
|
|
66
|
-
style:
|
|
66
|
+
style: u,
|
|
67
67
|
widthPx: f,
|
|
68
68
|
widthRem: i,
|
|
69
69
|
__autoLayout: p = !1,
|
|
70
70
|
...d
|
|
71
71
|
}) {
|
|
72
|
-
const c =
|
|
73
|
-
const w = !!o && !t && Array.isArray(
|
|
72
|
+
const c = n.useMemo(() => {
|
|
73
|
+
const w = !!o && !t && Array.isArray(r) && r.find((C) => C.key === o);
|
|
74
74
|
return w ? w.direction : void 0;
|
|
75
|
-
}, [
|
|
75
|
+
}, [r, o, t]), v = f ? f / 16 : i, h = v ? { ...u, width: `${v}rem` } : u, E = (w) => {
|
|
76
76
|
o && !t && l && l([
|
|
77
77
|
{
|
|
78
78
|
key: o,
|
|
79
79
|
direction: c === g.ASCENDING ? g.DESCENDING : g.ASCENDING
|
|
80
80
|
}
|
|
81
|
-
]),
|
|
81
|
+
]), _ && _(w);
|
|
82
82
|
};
|
|
83
|
-
return p ? /* @__PURE__ */
|
|
83
|
+
return p ? /* @__PURE__ */ n.createElement(
|
|
84
84
|
"td",
|
|
85
85
|
{
|
|
86
86
|
className: S(
|
|
@@ -96,7 +96,7 @@ function O({
|
|
|
96
96
|
...d
|
|
97
97
|
},
|
|
98
98
|
a
|
|
99
|
-
) : /* @__PURE__ */
|
|
99
|
+
) : /* @__PURE__ */ n.createElement(
|
|
100
100
|
"div",
|
|
101
101
|
{
|
|
102
102
|
className: S(
|
|
@@ -125,30 +125,30 @@ M.set(O, {
|
|
|
125
125
|
widthRem: { type: "number" }
|
|
126
126
|
}
|
|
127
127
|
});
|
|
128
|
-
var A = D({ defaultClassName: "pkg_sps-woodland_sorting-
|
|
128
|
+
var A = D({ defaultClassName: "pkg_sps-woodland_sorting-header__version_8_24_2__hash_sk81640", variantClassNames: { pinned: { true: "pkg_sps-woodland_sorting-header__version_8_24_2__hash_sk81641", false: "pkg_sps-woodland_sorting-header__version_8_24_2__hash_sk81642" }, scrollParentIsWindow: { true: "pkg_sps-woodland_sorting-header__version_8_24_2__hash_sk81643", false: "pkg_sps-woodland_sorting-header__version_8_24_2__hash_sk81644" }, __autoLayout: { true: "pkg_sps-woodland_sorting-header__version_8_24_2__hash_sk81645", false: "pkg_sps-woodland_sorting-header__version_8_24_2__hash_sk81646" } }, defaultVariants: { pinned: !1, scrollParentIsWindow: !1, __autoLayout: !1 }, compoundVariants: [[{ pinned: !0, scrollParentIsWindow: !0 }, "pkg_sps-woodland_sorting-header__version_8_24_2__hash_sk81647"]] }), U = "pkg_sps-woodland_sorting-header__version_8_24_2__hash_sk81648";
|
|
129
129
|
function G({
|
|
130
130
|
sort: e,
|
|
131
131
|
onSortChange: o,
|
|
132
|
-
children:
|
|
132
|
+
children: r,
|
|
133
133
|
className: t,
|
|
134
134
|
pinSortingHeader: l = !1,
|
|
135
|
-
__autoLayout:
|
|
135
|
+
__autoLayout: _ = !1,
|
|
136
136
|
...a
|
|
137
137
|
}) {
|
|
138
|
-
const [
|
|
138
|
+
const [u, f] = 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 =
|
|
144
|
+
}), c = n.useCallback(() => i.current && x(i.current) || window, []), v = n.useCallback((s) => {
|
|
145
145
|
const m = s || c();
|
|
146
146
|
return m.scrollY || m.scrollTop || 0;
|
|
147
|
-
}, []), h =
|
|
147
|
+
}, []), h = n.useCallback(
|
|
148
148
|
(s) => {
|
|
149
149
|
var m, k, b;
|
|
150
150
|
if (l && i.current) {
|
|
151
|
-
const N = s || c(), P = v(N), R =
|
|
151
|
+
const N = s || c(), P = v(N), R = _ ? (k = (m = i.current.parentElement) == null ? void 0 : m.parentElement) == null ? void 0 : k.getBoundingClientRect() : (b = i.current.parentElement) == null ? void 0 : b.getBoundingClientRect();
|
|
152
152
|
if (R) {
|
|
153
153
|
const y = i.current.getBoundingClientRect();
|
|
154
154
|
d.current.height = `${y.height}px`, d.current.width = `${y.width}px`, N === window ? (d.current.unpinAtBottom = R.bottom + P - y.height * 2, d.current.unpinAtTop = y.top + P - y.height) : (d.current.unpinAtBottom = R.bottom + P - y.height * 2, d.current.unpinAtTop = R.top + P), d.current.cellWidths = [], i.current.childNodes.forEach((H, B) => {
|
|
@@ -158,14 +158,14 @@ function G({
|
|
|
158
158
|
}
|
|
159
159
|
},
|
|
160
160
|
[l]
|
|
161
|
-
), E =
|
|
161
|
+
), E = n.useCallback(() => {
|
|
162
162
|
p.current && (p.current.style.width = d.current.width, p.current.style.height = d.current.height, p.current.childNodes.forEach((s, m) => {
|
|
163
163
|
s instanceof HTMLElement && (s.style.width = d.current.cellWidths[m] || "");
|
|
164
164
|
}));
|
|
165
165
|
}, []);
|
|
166
|
-
|
|
166
|
+
n.useLayoutEffect(() => {
|
|
167
167
|
h();
|
|
168
|
-
}),
|
|
168
|
+
}), n.useLayoutEffect(() => {
|
|
169
169
|
let s;
|
|
170
170
|
const m = c();
|
|
171
171
|
return l ? (s = z(() => {
|
|
@@ -175,35 +175,35 @@ function G({
|
|
|
175
175
|
}), m.addEventListener("scroll", s), s()) : i.current && (i.current.style.visibility = "visible"), () => {
|
|
176
176
|
s && m.removeEventListener("scroll", s);
|
|
177
177
|
};
|
|
178
|
-
}, [l, h]),
|
|
178
|
+
}, [l, h]), n.useLayoutEffect(() => {
|
|
179
179
|
let s;
|
|
180
|
-
return
|
|
180
|
+
return u && (s = () => {
|
|
181
181
|
h(), E();
|
|
182
182
|
}, window.addEventListener("resize", s), s()), () => {
|
|
183
183
|
s && window.removeEventListener("resize", s);
|
|
184
184
|
};
|
|
185
|
-
}, [
|
|
186
|
-
const [w] = L(
|
|
187
|
-
if (
|
|
188
|
-
const s = /* @__PURE__ */
|
|
189
|
-
return /* @__PURE__ */
|
|
185
|
+
}, [u, h, E]);
|
|
186
|
+
const [w] = L(r, [{ type: O }]), C = W(w, () => [{ sort: e, onSortChange: o }]), I = c() === window;
|
|
187
|
+
if (_) {
|
|
188
|
+
const s = /* @__PURE__ */ n.createElement("tr", null, /* @__PURE__ */ n.createElement("td", { className: S(U), colSpan: 100 }));
|
|
189
|
+
return /* @__PURE__ */ n.createElement(n.Fragment, null, /* @__PURE__ */ n.createElement(
|
|
190
190
|
"tr",
|
|
191
191
|
{
|
|
192
192
|
ref: i,
|
|
193
193
|
className: S(
|
|
194
|
-
A({ pinned: !1, scrollParentIsWindow: I, __autoLayout:
|
|
194
|
+
A({ pinned: !1, scrollParentIsWindow: I, __autoLayout: _ }),
|
|
195
195
|
t
|
|
196
196
|
),
|
|
197
197
|
...a
|
|
198
198
|
},
|
|
199
199
|
C
|
|
200
|
-
), s,
|
|
200
|
+
), s, u && /* @__PURE__ */ n.createElement(
|
|
201
201
|
"tr",
|
|
202
202
|
{
|
|
203
203
|
ref: p,
|
|
204
204
|
className: S(
|
|
205
205
|
t,
|
|
206
|
-
A({ pinned: !0, scrollParentIsWindow: I, __autoLayout:
|
|
206
|
+
A({ pinned: !0, scrollParentIsWindow: I, __autoLayout: _ })
|
|
207
207
|
),
|
|
208
208
|
...a,
|
|
209
209
|
id: a.id ? `pinned-${a.id}` : void 0,
|
|
@@ -212,24 +212,24 @@ function G({
|
|
|
212
212
|
C
|
|
213
213
|
));
|
|
214
214
|
}
|
|
215
|
-
return /* @__PURE__ */
|
|
215
|
+
return /* @__PURE__ */ n.createElement(n.Fragment, null, /* @__PURE__ */ n.createElement(
|
|
216
216
|
"div",
|
|
217
217
|
{
|
|
218
218
|
ref: i,
|
|
219
219
|
className: S(
|
|
220
220
|
t,
|
|
221
|
-
A({ pinned: !1, scrollParentIsWindow: I, __autoLayout:
|
|
221
|
+
A({ pinned: !1, scrollParentIsWindow: I, __autoLayout: _ })
|
|
222
222
|
),
|
|
223
223
|
...a
|
|
224
224
|
},
|
|
225
225
|
C
|
|
226
|
-
),
|
|
226
|
+
), u && /* @__PURE__ */ n.createElement(
|
|
227
227
|
"div",
|
|
228
228
|
{
|
|
229
229
|
ref: p,
|
|
230
230
|
className: S(
|
|
231
231
|
t,
|
|
232
|
-
A({ pinned: !0, scrollParentIsWindow: I, __autoLayout:
|
|
232
|
+
A({ pinned: !0, scrollParentIsWindow: I, __autoLayout: _ })
|
|
233
233
|
),
|
|
234
234
|
...a,
|
|
235
235
|
id: a.id ? `pinned-${a.id}` : void 0,
|
package/lib/index.umd.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(h,v){typeof exports=="object"&&typeof module<"u"?v(exports,require("react"),require("@sps-woodland/core"),require("@spscommerce/utils")):typeof define=="function"&&define.amd?define(["exports","react","@sps-woodland/core","@spscommerce/utils"],v):(h=typeof globalThis<"u"?globalThis:h||self,v(h.SortingHeader={},h.React,h.core,h.utils))})(this,function(h,v,s,V){"use strict";function x(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
|
|
1
|
+
(function(h,v){typeof exports=="object"&&typeof module<"u"?v(exports,require("react"),require("@sps-woodland/core"),require("@spscommerce/utils")):typeof define=="function"&&define.amd?define(["exports","react","@sps-woodland/core","@spscommerce/utils"],v):(h=typeof globalThis<"u"?globalThis:h||self,v(h.SortingHeader={},h.React,h.core,h.utils))})(this,function(h,v,s,V){"use strict";function x(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=x(v);function L(e,r,n){return r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function j(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 M(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?j(Object(n),!0).forEach(function(t){L(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):j(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var W=(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},A=e=>r=>{var n=e.defaultClassName,t=M(M({},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 g=e.variantClassNames[d][_];g&&(n+=" "+g)}}for(var[a,m]of e.compoundVariants)W(a,t,e.defaultVariants)&&(n+=" "+m);return n},K=A({defaultClassName:"pkg_sps-woodland_sorting-header__version_8_24_2__hash_7ljhcs0",variantClassNames:{up:{true:"pkg_sps-woodland_sorting-header__version_8_24_2__hash_7ljhcs1"},down:{true:"pkg_sps-woodland_sorting-header__version_8_24_2__hash_7ljhcs2"}},defaultVariants:{},compoundVariants:[]}),G=A({defaultClassName:"pkg_sps-woodland_sorting-header__version_8_24_2__hash_1crs4gl0",variantClassNames:{disabled:{true:"pkg_sps-woodland_sorting-header__version_8_24_2__hash_1crs4gl1"},active:{true:"pkg_sps-woodland_sorting-header__version_8_24_2__hash_1crs4gl2"},__autoLayout:{true:"pkg_sps-woodland_sorting-header__version_8_24_2__hash_1crs4gl3",false:"pkg_sps-woodland_sorting-header__version_8_24_2__hash_1crs4gl4"}},defaultVariants:{disabled:!1,active:!1,__autoLayout:!1},compoundVariants:[]});function D({className:e,sortKey:r,sort:n,sortDisabled:t,onSortChange:d,onClick:p,children:l,style:_,widthPx:g,widthRem:a,__autoLayout:m=!1,...c}){const u=o.useMemo(()=>{const w=!!r&&!t&&Array.isArray(n)&&n.find(y=>y.key===r);return w?w.direction:void 0},[n,r,t]),E=g?g/16:a,S=E?{..._,width:`${E}rem`}:_,b=w=>{r&&!t&&d&&d([{key:r,direction:u===s.SortDirection.ASCENDING?s.SortDirection.DESCENDING:s.SortDirection.ASCENDING}]),p&&p(w)};return m?o.createElement("td",{className:s.cl(e,G({disabled:t,active:!!u,__autoLayout:m}),u&&K({up:u===s.SortDirection.ASCENDING,down:u===s.SortDirection.DESCENDING})),onClick:b,style:S,...c},l):o.createElement("div",{className:s.cl(e,G({disabled:t,active:!!u,__autoLayout:m}),u&&K({up:u===s.SortDirection.ASCENDING,down:u===s.SortDirection.DESCENDING})),onClick:b,style:S,...c},l)}s.Metadata.set(D,{name:"Sorting Header Cell",props:{sortKey:{type:"string"},sort:{type:"SortedColumn[]"},sortDisabled:{type:"boolean"},onSortChange:{type:"SortChangeHandler"},widthPx:{type:"number"},widthRem:{type:"number"}}});var I=A({defaultClassName:"pkg_sps-woodland_sorting-header__version_8_24_2__hash_sk81640",variantClassNames:{pinned:{true:"pkg_sps-woodland_sorting-header__version_8_24_2__hash_sk81641",false:"pkg_sps-woodland_sorting-header__version_8_24_2__hash_sk81642"},scrollParentIsWindow:{true:"pkg_sps-woodland_sorting-header__version_8_24_2__hash_sk81643",false:"pkg_sps-woodland_sorting-header__version_8_24_2__hash_sk81644"},__autoLayout:{true:"pkg_sps-woodland_sorting-header__version_8_24_2__hash_sk81645",false:"pkg_sps-woodland_sorting-header__version_8_24_2__hash_sk81646"}},defaultVariants:{pinned:!1,scrollParentIsWindow:!1,__autoLayout:!1},compoundVariants:[[{pinned:!0,scrollParentIsWindow:!0},"pkg_sps-woodland_sorting-header__version_8_24_2__hash_sk81647"]]}),z="pkg_sps-woodland_sorting-header__version_8_24_2__hash_sk81648";function H({sort:e,onSortChange:r,children:n,className:t,pinSortingHeader:d=!1,__autoLayout:p=!1,...l}){const[_,g]=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,[]),E=o.useCallback(i=>{const f=i||u();return f.scrollY||f.scrollTop||0},[]),S=o.useCallback(i=>{var f,k,N;if(d&&a.current){const P=i||u(),R=E(P),T=p?(k=(f=a.current.parentElement)==null?void 0:f.parentElement)==null?void 0:k.getBoundingClientRect():(N=a.current.parentElement)==null?void 0:N.getBoundingClientRect();if(T){const C=a.current.getBoundingClientRect();c.current.height=`${C.height}px`,c.current.width=`${C.width}px`,P===window?(c.current.unpinAtBottom=T.bottom+R-C.height*2,c.current.unpinAtTop=C.top+R-C.height):(c.current.unpinAtBottom=T.bottom+R-C.height*2,c.current.unpinAtTop=T.top+R),c.current.cellWidths=[],a.current.childNodes.forEach((B,Y)=>{B instanceof HTMLElement&&(c.current.cellWidths[Y]=`${B.getBoundingClientRect().width}px`)})}}},[d]),b=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(()=>{S()}),o.useLayoutEffect(()=>{let i;const f=u();return d?(i=V.lockToAnimationFrames(()=>{S(f);const{unpinAtTop:k,unpinAtBottom:N}=c.current,P=E(f);k&&N&&(P>=k&&P<=N?(g(!0),a.current&&(a.current.style.visibility="hidden")):(g(!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,S]),o.useLayoutEffect(()=>{let i;return _&&(i=()=>{S(),b()},window.addEventListener("resize",i),i()),()=>{i&&window.removeEventListener("resize",i)}},[_,S,b]);const[w]=s.selectChildren(n,[{type:D}]),y=s.modChildren(w,()=>[{sort:e,onSortChange:r}]),O=u()===window;if(p){const i=o.createElement("tr",null,o.createElement("td",{className:s.cl(z),colSpan:100}));return o.createElement(o.Fragment,null,o.createElement("tr",{ref:a,className:s.cl(I({pinned:!1,scrollParentIsWindow:O,__autoLayout:p}),t),...l},y),i,_&&o.createElement("tr",{ref:m,className:s.cl(t,I({pinned:!0,scrollParentIsWindow:O,__autoLayout:p})),...l,id:l.id?`pinned-${l.id}`:void 0,"data-testid":l["data-testid"]?`pinned-${l["data-testid"]}`:void 0},y))}return o.createElement(o.Fragment,null,o.createElement("div",{ref:a,className:s.cl(t,I({pinned:!1,scrollParentIsWindow:O,__autoLayout:p})),...l},y),_&&o.createElement("div",{ref:m,className:s.cl(t,I({pinned:!0,scrollParentIsWindow:O,__autoLayout:p})),...l,id:l.id?`pinned-${l.id}`:void 0,"data-testid":l["data-testid"]?`pinned-${l["data-testid"]}`:void 0},y))}s.Metadata.set(H,{name:"Sorting Header",props:{sort:{type:"SortedColumn[]"},onSortChange:{type:"SortChangeHandler"}}});const F={"Sorting Header":{components:[H,D],examples:{basic:{label:"Sorting Header",examples:{basic:{react:V.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";
|
package/lib/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.pkg_sps-woodland_sorting-
|
|
1
|
+
.pkg_sps-woodland_sorting-header__version_8_24_2__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_24_2__hash_7ljhcs1:after{border-bottom-color:#1f282c;border-top-color:transparent;top:calc(50% - 9px)}.pkg_sps-woodland_sorting-header__version_8_24_2__hash_7ljhcs2:after{border-top-color:#1f282c;border-bottom-color:transparent;top:calc(50% - 3px)}.pkg_sps-woodland_sorting-header__version_8_24_2__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_24_2__hash_1crs4gl0:hover{background-color:#f3f4f4}.pkg_sps-woodland_sorting-header__version_8_24_2__hash_1crs4gl1{cursor:default}.pkg_sps-woodland_sorting-header__version_8_24_2__hash_1crs4gl1:hover{background-color:#e9e9ea}.pkg_sps-woodland_sorting-header__version_8_24_2__hash_1crs4gl2{color:#1f282c;background-color:#d2d4d4}.pkg_sps-woodland_sorting-header__version_8_24_2__hash_1crs4gl3{text-align:left}.pkg_sps-woodland_sorting-header__version_8_24_2__hash_1crs4gl3:first-child{border-top-left-radius:.25rem;border-bottom-left-radius:.25rem}.pkg_sps-woodland_sorting-header__version_8_24_2__hash_1crs4gl3:last-child{border-top-right-radius:.25rem;border-bottom-right-radius:.25rem}.pkg_sps-woodland_sorting-header__version_8_24_2__hash_sk81640{padding:0;border-radius:.25rem;vertical-align:bottom;cursor:pointer;background-color:#e9e9ea}.pkg_sps-woodland_sorting-header__version_8_24_2__hash_sk81641{border-radius:0;position:fixed;top:0;z-index:999}.pkg_sps-woodland_sorting-header__version_8_24_2__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_24_2__hash_sk81645{display:table-row}.pkg_sps-woodland_sorting-header__version_8_24_2__hash_sk81646{display:table;table-layout:fixed;width:100%}.pkg_sps-woodland_sorting-header__version_8_24_2__hash_sk81647{top:3.75rem}.pkg_sps-woodland_sorting-header__version_8_24_2__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.24.
|
|
4
|
+
"version": "8.24.2",
|
|
5
5
|
"author": "SPS Commerce",
|
|
6
6
|
"license": "UNLICENSED",
|
|
7
7
|
"repository": "https://github.com/SPSCommerce/woodland/tree/main/packages/@sps-woodland/sorting-header",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"@spscommerce/utils": "^7.0.0",
|
|
30
30
|
"react": "^16.14.0",
|
|
31
31
|
"react-dom": "^16.14.0",
|
|
32
|
-
"@sps-woodland/core": "8.24.
|
|
33
|
-
"@sps-woodland/tokens": "8.24.
|
|
32
|
+
"@sps-woodland/core": "8.24.2",
|
|
33
|
+
"@sps-woodland/tokens": "8.24.2"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@spscommerce/utils": "^7.0.0",
|
|
@@ -39,8 +39,8 @@
|
|
|
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.24.
|
|
43
|
-
"@sps-woodland/tokens": "8.24.
|
|
42
|
+
"@sps-woodland/core": "8.24.2",
|
|
43
|
+
"@sps-woodland/tokens": "8.24.2"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "pnpm run build:js && pnpm run build:types",
|