@sps-woodland/sorting-header 8.7.7 → 8.8.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/lib/index.cjs.js +2 -2
- package/lib/index.es.js +174 -123
- package/lib/sorting-header/SortingHeader.css.d.ts +16 -1
- package/lib/sorting-header/SortingHeader.d.ts +2 -1
- package/lib/sorting-header-cell/SortingHeaderCell.css.d.ts +16 -0
- package/lib/sorting-header-cell/SortingHeaderCell.d.ts +2 -1
- package/lib/style.css +1 -1
- package/package.json +5 -5
package/lib/index.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("react"),a=require("@sps-woodland/core"),G=require("@spscommerce/utils");function x(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const t=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,t.get?t:{enumerable:!0,get:()=>e[r]})}}return n.default=e,Object.freeze(n)}const i=x(L);function W(e,n,r){return n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function V(e,n){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);n&&(t=t.filter(function(c){return Object.getOwnPropertyDescriptor(e,c).enumerable})),r.push.apply(r,t)}return r}function j(e){for(var n=1;n<arguments.length;n++){var r=arguments[n]!=null?arguments[n]:{};n%2?V(Object(r),!0).forEach(function(t){W(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):V(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var _=(e,n,r)=>{for(var t of Object.keys(e)){var c;if(e[t]!==((c=n[t])!==null&&c!==void 0?c:r[t]))return!1}return!0},A=e=>n=>{var r=e.defaultClassName,t=j(j({},e.defaultVariants),n);for(var c in t){var p,s=(p=t[c])!==null&&p!==void 0?p:e.defaultVariants[c];if(s!=null){var m=s;typeof m=="boolean"&&(m=m===!0?"true":"false");var y=e.variantClassNames[c][m];y&&(r+=" "+y)}}for(var[l,f]of e.compoundVariants)_(l,t,e.defaultVariants)&&(r+=" "+f);return r},M=A({defaultClassName:"_7ljhcs0",variantClassNames:{up:{true:"_7ljhcs1"},down:{true:"_7ljhcs2"}},defaultVariants:{},compoundVariants:[]}),K=A({defaultClassName:"_1crs4gl0",variantClassNames:{disabled:{true:"_1crs4gl1"},active:{true:"_1crs4gl2"},__autoLayout:{true:"_1crs4gl3",false:"_1crs4gl4"}},defaultVariants:{disabled:!1,active:!1,__autoLayout:!1},compoundVariants:[]});function k({className:e,sortKey:n,sort:r,sortDisabled:t,onSortChange:c,onClick:p,children:s,style:m,widthPx:y,widthRem:l,__autoLayout:f=!1,...d}){const u=i.useMemo(()=>{const g=!!n&&!t&&Array.isArray(r)&&r.find(w=>w.key===n);return g?g.direction:void 0},[r,n,t]),E=y?y/16:l,C=E?{...m,width:`${E}rem`}:m,v=g=>{n&&!t&&c&&c([{key:n,direction:u===a.SortDirection.ASCENDING?a.SortDirection.DESCENDING:a.SortDirection.ASCENDING}]),p&&p(g)};return f?i.createElement("td",{className:a.cl(e,K({disabled:t,active:!!u,__autoLayout:f}),u&&M({up:u===a.SortDirection.ASCENDING,down:u===a.SortDirection.DESCENDING})),onClick:v,style:C,...d},s):i.createElement("div",{className:a.cl(e,K({disabled:t,active:!!u,__autoLayout:f}),u&&M({up:u===a.SortDirection.ASCENDING,down:u===a.SortDirection.DESCENDING})),onClick:v,style:C,...d},s)}a.Metadata.set(k,{name:"Sorting Header Cell",props:{sortKey:{type:"string"},sort:{type:"SortedColumn[]"},sortDisabled:{type:"boolean"},onSortChange:{type:"SortChangeHandler"},widthPx:{type:"number"},widthRem:{type:"number"}}});var R=A({defaultClassName:"sk81640",variantClassNames:{pinned:{true:"sk81641",false:"sk81642"},scrollParentIsWindow:{true:"sk81643",false:"sk81644"},__autoLayout:{true:"sk81645",false:"sk81646"}},defaultVariants:{pinned:!1,scrollParentIsWindow:!1,__autoLayout:!1},compoundVariants:[[{pinned:!0,scrollParentIsWindow:!0},"sk81647"]]}),z="sk81648";function T({sort:e,onSortChange:n,children:r,className:t,pinSortingHeader:c=!1,__autoLayout:p=!1,...s}){const[m,y]=i.useState(!1),l=i.useRef(null),f=i.useRef(null),d=i.useRef({height:"",width:"",unpinAtTop:0,unpinAtBottom:0,cellWidths:[]}),u=i.useCallback(()=>l.current&&a.getScrollParent(l.current)||window,[]),E=i.useCallback(o=>{const S=o||u();return S.scrollY||S.scrollTop||0},[]),C=i.useCallback(o=>{var S,b,N;if(c&&l.current){const P=o||u(),I=E(P),O=p?(b=(S=l.current.parentElement)==null?void 0:S.parentElement)==null?void 0:b.getBoundingClientRect():(N=l.current.parentElement)==null?void 0:N.getBoundingClientRect();if(O){const h=l.current.getBoundingClientRect();d.current.height=`${h.height}px`,d.current.width=`${h.width}px`,P===window?(d.current.unpinAtBottom=O.bottom+I-h.height*2,d.current.unpinAtTop=h.top+I-h.height):(d.current.unpinAtBottom=O.bottom+I-h.height*2,d.current.unpinAtTop=O.top+I),d.current.cellWidths=[],l.current.childNodes.forEach((H,B)=>{H instanceof HTMLElement&&(d.current.cellWidths[B]=`${H.getBoundingClientRect().width}px`)})}}},[c]),v=i.useCallback(()=>{f.current&&(f.current.style.width=d.current.width,f.current.style.height=d.current.height,f.current.childNodes.forEach((o,S)=>{o instanceof HTMLElement&&(o.style.width=d.current.cellWidths[S]||"")}))},[]);i.useLayoutEffect(()=>{C()}),i.useLayoutEffect(()=>{let o;const S=u();return c?(o=G.lockToAnimationFrames(()=>{C(S);const{unpinAtTop:b,unpinAtBottom:N}=d.current,P=E(S);b&&N&&(P>=b&&P<=N?(y(!0),l.current&&(l.current.style.visibility="hidden")):(y(!1),l.current&&(l.current.style.visibility="visible")))}),S.addEventListener("scroll",o),o()):l.current&&(l.current.style.visibility="visible"),()=>{o&&S.removeEventListener("scroll",o)}},[c,C]),i.useLayoutEffect(()=>{let o;return m&&(o=()=>{C(),v()},window.addEventListener("resize",o),o()),()=>{o&&window.removeEventListener("resize",o)}},[m,C,v]);const[g]=a.selectChildren(r,[{type:k}]),w=a.modChildren(g,()=>[{sort:e,onSortChange:n}]),D=u()===window;if(p){const o=i.createElement("tr",null,i.createElement("td",{className:a.cl(z),colSpan:100}));return i.createElement(i.Fragment,null,i.createElement("tr",{ref:l,className:a.cl(R({pinned:!1,scrollParentIsWindow:D,__autoLayout:p}),t),...s},w),o,m&&i.createElement("tr",{ref:f,className:a.cl(t,R({pinned:!0,scrollParentIsWindow:D,__autoLayout:p})),...s,id:s.id?`pinned-${s.id}`:void 0,"data-testid":s["data-testid"]?`pinned-${s["data-testid"]}`:void 0},w))}return i.createElement(i.Fragment,null,i.createElement("div",{ref:l,className:a.cl(t,R({pinned:!1,scrollParentIsWindow:D,__autoLayout:p})),...s},w),m&&i.createElement("div",{ref:f,className:a.cl(t,R({pinned:!0,scrollParentIsWindow:D,__autoLayout:p})),...s,id:s.id?`pinned-${s.id}`:void 0,"data-testid":s["data-testid"]?`pinned-${s["data-testid"]}`:void 0},w))}a.Metadata.set(T,{name:"Sorting Header",props:{sort:{type:"SortedColumn[]"},onSortChange:{type:"SortChangeHandler"}}});const F={components:[T,k],examples:{basic:{label:"Sorting Header",examples:{basic:{react:G.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
|
-
`}}}}},
|
|
95
|
+
`}}}}},Y={"Sorting Header":F};exports.MANIFEST=Y;exports.SortingHeader=T;exports.SortingHeaderCell=k;
|
package/lib/index.es.js
CHANGED
|
@@ -1,107 +1,120 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { Metadata as
|
|
3
|
-
import { lockToAnimationFrames as
|
|
4
|
-
function
|
|
5
|
-
return
|
|
1
|
+
import * as n from "react";
|
|
2
|
+
import { Metadata as G, cl as g, SortDirection as y, getScrollParent as L, selectChildren as W, modChildren as z } from "@sps-woodland/core";
|
|
3
|
+
import { lockToAnimationFrames as F, code as Y } from "@spscommerce/utils";
|
|
4
|
+
function _(e, i, r) {
|
|
5
|
+
return i in e ? Object.defineProperty(e, i, {
|
|
6
6
|
value: r,
|
|
7
7
|
enumerable: !0,
|
|
8
8
|
configurable: !0,
|
|
9
9
|
writable: !0
|
|
10
|
-
}) : e[
|
|
10
|
+
}) : e[i] = r, e;
|
|
11
11
|
}
|
|
12
|
-
function
|
|
12
|
+
function V(e, i) {
|
|
13
13
|
var r = Object.keys(e);
|
|
14
14
|
if (Object.getOwnPropertySymbols) {
|
|
15
15
|
var t = Object.getOwnPropertySymbols(e);
|
|
16
|
-
|
|
17
|
-
return Object.getOwnPropertyDescriptor(e,
|
|
16
|
+
i && (t = t.filter(function(s) {
|
|
17
|
+
return Object.getOwnPropertyDescriptor(e, s).enumerable;
|
|
18
18
|
})), r.push.apply(r, t);
|
|
19
19
|
}
|
|
20
20
|
return r;
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
for (var
|
|
24
|
-
var r = arguments[
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) :
|
|
22
|
+
function K(e) {
|
|
23
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
24
|
+
var r = arguments[i] != null ? arguments[i] : {};
|
|
25
|
+
i % 2 ? V(Object(r), !0).forEach(function(t) {
|
|
26
|
+
_(e, t, r[t]);
|
|
27
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : V(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 $ = (e, i, r) => {
|
|
34
34
|
for (var t of Object.keys(e)) {
|
|
35
|
-
var
|
|
36
|
-
if (e[t] !== ((
|
|
35
|
+
var s;
|
|
36
|
+
if (e[t] !== ((s = i[t]) !== null && s !== void 0 ? s : r[t]))
|
|
37
37
|
return !1;
|
|
38
38
|
}
|
|
39
39
|
return !0;
|
|
40
|
-
},
|
|
41
|
-
var r = e.defaultClassName, t =
|
|
42
|
-
for (var
|
|
43
|
-
var
|
|
44
|
-
if (
|
|
45
|
-
var
|
|
46
|
-
typeof
|
|
47
|
-
var
|
|
40
|
+
}, O = (e) => (i) => {
|
|
41
|
+
var r = e.defaultClassName, t = K(K({}, e.defaultVariants), i);
|
|
42
|
+
for (var s in t) {
|
|
43
|
+
var u, a = (u = t[s]) !== null && u !== void 0 ? u : e.defaultVariants[s];
|
|
44
|
+
if (a != null) {
|
|
45
|
+
var m = a;
|
|
46
|
+
typeof m == "boolean" && (m = m === !0 ? "true" : "false");
|
|
47
|
+
var S = (
|
|
48
48
|
// @ts-expect-error
|
|
49
|
-
e.variantClassNames[
|
|
49
|
+
e.variantClassNames[s][m]
|
|
50
50
|
);
|
|
51
|
-
|
|
51
|
+
S && (r += " " + S);
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
for (var [
|
|
55
|
-
|
|
54
|
+
for (var [l, p] of e.compoundVariants)
|
|
55
|
+
$(l, t, e.defaultVariants) && (r += " " + p);
|
|
56
56
|
return r;
|
|
57
|
-
}, j =
|
|
58
|
-
function
|
|
57
|
+
}, j = O({ defaultClassName: "_7ljhcs0", variantClassNames: { up: { true: "_7ljhcs1" }, down: { true: "_7ljhcs2" } }, defaultVariants: {}, compoundVariants: [] }), M = O({ defaultClassName: "_1crs4gl0", variantClassNames: { disabled: { true: "_1crs4gl1" }, active: { true: "_1crs4gl2" }, __autoLayout: { true: "_1crs4gl3", false: "_1crs4gl4" } }, defaultVariants: { disabled: !1, active: !1, __autoLayout: !1 }, compoundVariants: [] });
|
|
58
|
+
function H({
|
|
59
59
|
className: e,
|
|
60
|
-
sortKey:
|
|
60
|
+
sortKey: i,
|
|
61
61
|
sort: r,
|
|
62
62
|
sortDisabled: t,
|
|
63
|
-
onSortChange:
|
|
64
|
-
onClick:
|
|
65
|
-
children:
|
|
66
|
-
style:
|
|
67
|
-
widthPx:
|
|
68
|
-
widthRem:
|
|
69
|
-
|
|
63
|
+
onSortChange: s,
|
|
64
|
+
onClick: u,
|
|
65
|
+
children: a,
|
|
66
|
+
style: m,
|
|
67
|
+
widthPx: S,
|
|
68
|
+
widthRem: l,
|
|
69
|
+
__autoLayout: p = !1,
|
|
70
|
+
...c
|
|
70
71
|
}) {
|
|
71
|
-
const
|
|
72
|
-
const
|
|
73
|
-
return
|
|
74
|
-
}, [
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
72
|
+
const d = n.useMemo(() => {
|
|
73
|
+
const w = !!i && !t && Array.isArray(r) && r.find((h) => h.key === i);
|
|
74
|
+
return w ? w.direction : void 0;
|
|
75
|
+
}, [r, i, t]), v = S ? S / 16 : l, C = v ? { ...m, width: `${v}rem` } : m, b = (w) => {
|
|
76
|
+
i && !t && s && s([
|
|
77
|
+
{
|
|
78
|
+
key: i,
|
|
79
|
+
direction: d === y.ASCENDING ? y.DESCENDING : y.ASCENDING
|
|
80
|
+
}
|
|
81
|
+
]), u && u(w);
|
|
82
|
+
};
|
|
83
|
+
return p ? /* @__PURE__ */ n.createElement(
|
|
84
|
+
"td",
|
|
85
|
+
{
|
|
86
|
+
className: g(
|
|
87
|
+
e,
|
|
88
|
+
M({ disabled: t, active: !!d, __autoLayout: p }),
|
|
89
|
+
d && j({
|
|
90
|
+
up: d === y.ASCENDING,
|
|
91
|
+
down: d === y.DESCENDING
|
|
92
|
+
})
|
|
93
|
+
),
|
|
94
|
+
onClick: b,
|
|
95
|
+
style: C,
|
|
96
|
+
...c
|
|
97
|
+
},
|
|
98
|
+
a
|
|
99
|
+
) : /* @__PURE__ */ n.createElement(
|
|
80
100
|
"div",
|
|
81
101
|
{
|
|
82
102
|
className: g(
|
|
83
103
|
e,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
up:
|
|
87
|
-
down:
|
|
104
|
+
M({ disabled: t, active: !!d, __autoLayout: p }),
|
|
105
|
+
d && j({
|
|
106
|
+
up: d === y.ASCENDING,
|
|
107
|
+
down: d === y.DESCENDING
|
|
88
108
|
})
|
|
89
109
|
),
|
|
90
|
-
onClick:
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
key: n,
|
|
94
|
-
direction: c === w.ASCENDING ? w.DESCENDING : w.ASCENDING
|
|
95
|
-
}
|
|
96
|
-
]), l && l(S);
|
|
97
|
-
},
|
|
98
|
-
style: h,
|
|
99
|
-
...s
|
|
110
|
+
onClick: b,
|
|
111
|
+
style: C,
|
|
112
|
+
...c
|
|
100
113
|
},
|
|
101
|
-
|
|
114
|
+
a
|
|
102
115
|
);
|
|
103
116
|
}
|
|
104
|
-
|
|
117
|
+
G.set(H, {
|
|
105
118
|
name: "Sorting Header Cell",
|
|
106
119
|
props: {
|
|
107
120
|
sortKey: { type: "string" },
|
|
@@ -112,96 +125,134 @@ D.set(v, {
|
|
|
112
125
|
widthRem: { type: "number" }
|
|
113
126
|
}
|
|
114
127
|
});
|
|
115
|
-
var
|
|
116
|
-
function
|
|
128
|
+
var D = O({ defaultClassName: "sk81640", variantClassNames: { pinned: { true: "sk81641", false: "sk81642" }, scrollParentIsWindow: { true: "sk81643", false: "sk81644" }, __autoLayout: { true: "sk81645", false: "sk81646" } }, defaultVariants: { pinned: !1, scrollParentIsWindow: !1, __autoLayout: !1 }, compoundVariants: [[{ pinned: !0, scrollParentIsWindow: !0 }, "sk81647"]] }), U = "sk81648";
|
|
129
|
+
function B({
|
|
117
130
|
sort: e,
|
|
118
|
-
onSortChange:
|
|
131
|
+
onSortChange: i,
|
|
119
132
|
children: r,
|
|
120
133
|
className: t,
|
|
121
|
-
pinSortingHeader:
|
|
122
|
-
|
|
134
|
+
pinSortingHeader: s = !1,
|
|
135
|
+
__autoLayout: u = !1,
|
|
136
|
+
...a
|
|
123
137
|
}) {
|
|
124
|
-
const [
|
|
138
|
+
const [m, S] = n.useState(!1), l = n.useRef(null), p = n.useRef(null), c = n.useRef({
|
|
125
139
|
height: "",
|
|
126
140
|
width: "",
|
|
127
141
|
unpinAtTop: 0,
|
|
128
142
|
unpinAtBottom: 0,
|
|
129
143
|
cellWidths: []
|
|
130
|
-
}),
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
144
|
+
}), d = n.useCallback(() => l.current && L(l.current) || window, []), v = n.useCallback((o) => {
|
|
145
|
+
const f = o || d();
|
|
146
|
+
return f.scrollY || f.scrollTop || 0;
|
|
147
|
+
}, []), C = n.useCallback(
|
|
148
|
+
(o) => {
|
|
149
|
+
var f, N, I;
|
|
150
|
+
if (s && l.current) {
|
|
151
|
+
const P = o || d(), k = v(P), A = u ? (N = (f = l.current.parentElement) == null ? void 0 : f.parentElement) == null ? void 0 : N.getBoundingClientRect() : (I = l.current.parentElement) == null ? void 0 : I.getBoundingClientRect();
|
|
152
|
+
if (A) {
|
|
153
|
+
const E = l.current.getBoundingClientRect();
|
|
154
|
+
c.current.height = `${E.height}px`, c.current.width = `${E.width}px`, P === window ? (c.current.unpinAtBottom = A.bottom + k - E.height * 2, c.current.unpinAtTop = E.top + k - E.height) : (c.current.unpinAtBottom = A.bottom + k - E.height * 2, c.current.unpinAtTop = A.top + k), c.current.cellWidths = [], l.current.childNodes.forEach((T, x) => {
|
|
155
|
+
T instanceof HTMLElement && (c.current.cellWidths[x] = `${T.getBoundingClientRect().width}px`);
|
|
156
|
+
});
|
|
157
|
+
}
|
|
139
158
|
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
159
|
+
},
|
|
160
|
+
[s]
|
|
161
|
+
), b = n.useCallback(() => {
|
|
162
|
+
p.current && (p.current.style.width = c.current.width, p.current.style.height = c.current.height, p.current.childNodes.forEach((o, f) => {
|
|
163
|
+
o instanceof HTMLElement && (o.style.width = c.current.cellWidths[f] || "");
|
|
144
164
|
}));
|
|
145
165
|
}, []);
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}),
|
|
166
|
+
n.useLayoutEffect(() => {
|
|
167
|
+
C();
|
|
168
|
+
}), n.useLayoutEffect(() => {
|
|
149
169
|
let o;
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
170
|
+
const f = d();
|
|
171
|
+
return s ? (o = F(() => {
|
|
172
|
+
C(f);
|
|
173
|
+
const { unpinAtTop: N, unpinAtBottom: I } = c.current, P = v(f);
|
|
174
|
+
N && I && (P >= N && P <= I ? (S(!0), l.current && (l.current.style.visibility = "hidden")) : (S(!1), l.current && (l.current.style.visibility = "visible")));
|
|
175
|
+
}), f.addEventListener("scroll", o), o()) : l.current && (l.current.style.visibility = "visible"), () => {
|
|
176
|
+
o && f.removeEventListener("scroll", o);
|
|
156
177
|
};
|
|
157
|
-
}, [
|
|
178
|
+
}, [s, C]), n.useLayoutEffect(() => {
|
|
158
179
|
let o;
|
|
159
|
-
return
|
|
160
|
-
|
|
180
|
+
return m && (o = () => {
|
|
181
|
+
C(), b();
|
|
161
182
|
}, window.addEventListener("resize", o), o()), () => {
|
|
162
183
|
o && window.removeEventListener("resize", o);
|
|
163
184
|
};
|
|
164
|
-
}, [
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
185
|
+
}, [m, C, b]);
|
|
186
|
+
const [w] = W(r, [{ type: H }]), h = z(w, () => [{ sort: e, onSortChange: i }]), R = d() === window;
|
|
187
|
+
if (u) {
|
|
188
|
+
const o = /* @__PURE__ */ n.createElement("tr", null, /* @__PURE__ */ n.createElement("td", { className: g(U), colSpan: 100 }));
|
|
189
|
+
return /* @__PURE__ */ n.createElement(n.Fragment, null, /* @__PURE__ */ n.createElement(
|
|
190
|
+
"tr",
|
|
191
|
+
{
|
|
192
|
+
ref: l,
|
|
193
|
+
className: g(
|
|
194
|
+
D({ pinned: !1, scrollParentIsWindow: R, __autoLayout: u }),
|
|
195
|
+
t
|
|
196
|
+
),
|
|
197
|
+
...a
|
|
198
|
+
},
|
|
199
|
+
h
|
|
200
|
+
), o, m && /* @__PURE__ */ n.createElement(
|
|
201
|
+
"tr",
|
|
202
|
+
{
|
|
203
|
+
ref: p,
|
|
204
|
+
className: g(
|
|
205
|
+
t,
|
|
206
|
+
D({ pinned: !0, scrollParentIsWindow: R, __autoLayout: u })
|
|
207
|
+
),
|
|
208
|
+
...a,
|
|
209
|
+
id: a.id ? `pinned-${a.id}` : void 0,
|
|
210
|
+
"data-testid": a["data-testid"] ? `pinned-${a["data-testid"]}` : void 0
|
|
211
|
+
},
|
|
212
|
+
h
|
|
213
|
+
));
|
|
214
|
+
}
|
|
215
|
+
return /* @__PURE__ */ n.createElement(n.Fragment, null, /* @__PURE__ */ n.createElement(
|
|
171
216
|
"div",
|
|
172
217
|
{
|
|
173
|
-
ref:
|
|
174
|
-
className: g(
|
|
175
|
-
|
|
218
|
+
ref: l,
|
|
219
|
+
className: g(
|
|
220
|
+
t,
|
|
221
|
+
D({ pinned: !1, scrollParentIsWindow: R, __autoLayout: u })
|
|
222
|
+
),
|
|
223
|
+
...a
|
|
176
224
|
},
|
|
177
|
-
|
|
178
|
-
),
|
|
225
|
+
h
|
|
226
|
+
), m && /* @__PURE__ */ n.createElement(
|
|
179
227
|
"div",
|
|
180
228
|
{
|
|
181
|
-
ref:
|
|
182
|
-
className: g(
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
229
|
+
ref: p,
|
|
230
|
+
className: g(
|
|
231
|
+
t,
|
|
232
|
+
D({ pinned: !0, scrollParentIsWindow: R, __autoLayout: u })
|
|
233
|
+
),
|
|
234
|
+
...a,
|
|
235
|
+
id: a.id ? `pinned-${a.id}` : void 0,
|
|
236
|
+
"data-testid": a["data-testid"] ? `pinned-${a["data-testid"]}` : void 0
|
|
186
237
|
},
|
|
187
|
-
|
|
238
|
+
h
|
|
188
239
|
));
|
|
189
240
|
}
|
|
190
|
-
|
|
241
|
+
G.set(B, {
|
|
191
242
|
name: "Sorting Header",
|
|
192
243
|
props: {
|
|
193
244
|
sort: { type: "SortedColumn[]" },
|
|
194
245
|
onSortChange: { type: "SortChangeHandler" }
|
|
195
246
|
}
|
|
196
247
|
});
|
|
197
|
-
const
|
|
198
|
-
components: [
|
|
248
|
+
const J = {
|
|
249
|
+
components: [B, H],
|
|
199
250
|
examples: {
|
|
200
251
|
basic: {
|
|
201
252
|
label: "Sorting Header",
|
|
202
253
|
examples: {
|
|
203
254
|
basic: {
|
|
204
|
-
react:
|
|
255
|
+
react: Y`
|
|
205
256
|
import { SortingHeader, SortingHeaderCell } from "@sps-woodland/sorting-header";
|
|
206
257
|
import { Icon } from "@sps-woodland/core";
|
|
207
258
|
import { ContentRow } from "@sps-woodland/content-row";
|
|
@@ -300,11 +351,11 @@ const M = {
|
|
|
300
351
|
}
|
|
301
352
|
}
|
|
302
353
|
}
|
|
303
|
-
},
|
|
304
|
-
"Sorting Header":
|
|
354
|
+
}, X = {
|
|
355
|
+
"Sorting Header": J
|
|
305
356
|
};
|
|
306
357
|
export {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
358
|
+
X as MANIFEST,
|
|
359
|
+
B as SortingHeader,
|
|
360
|
+
H as SortingHeaderCell
|
|
310
361
|
};
|
|
@@ -3,7 +3,7 @@ export declare const sortingHeader: import("@vanilla-extract/recipes/dist/declar
|
|
|
3
3
|
true: {
|
|
4
4
|
borderRadius: number;
|
|
5
5
|
position: "fixed";
|
|
6
|
-
top:
|
|
6
|
+
top: "0";
|
|
7
7
|
zIndex: number;
|
|
8
8
|
selectors: {
|
|
9
9
|
"&:after": {
|
|
@@ -20,4 +20,19 @@ export declare const sortingHeader: import("@vanilla-extract/recipes/dist/declar
|
|
|
20
20
|
};
|
|
21
21
|
false: {};
|
|
22
22
|
};
|
|
23
|
+
scrollParentIsWindow: {
|
|
24
|
+
true: {};
|
|
25
|
+
false: {};
|
|
26
|
+
};
|
|
27
|
+
__autoLayout: {
|
|
28
|
+
true: {
|
|
29
|
+
display: "table-row";
|
|
30
|
+
};
|
|
31
|
+
false: {
|
|
32
|
+
display: "table";
|
|
33
|
+
tableLayout: "fixed";
|
|
34
|
+
width: string;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
23
37
|
}>;
|
|
38
|
+
export declare const sortingHeaderSpacer: string;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import type { ComponentProps, SortChangeHandler, SortedColumn } from "@sps-woodland/core";
|
|
3
|
-
export declare function SortingHeader({ sort, onSortChange, children, className, pinSortingHeader, ...rest }: ComponentProps<{
|
|
3
|
+
export declare function SortingHeader({ sort, onSortChange, children, className, pinSortingHeader, __autoLayout, ...rest }: ComponentProps<{
|
|
4
4
|
sort: SortedColumn[];
|
|
5
5
|
onSortChange: SortChangeHandler;
|
|
6
6
|
pinSortingHeader?: boolean;
|
|
7
|
+
__autoLayout?: boolean;
|
|
7
8
|
}, HTMLDivElement>): React.ReactElement;
|
|
@@ -10,4 +10,20 @@ export declare const headerCell: import("@vanilla-extract/recipes/dist/declarati
|
|
|
10
10
|
backgroundColor: string;
|
|
11
11
|
};
|
|
12
12
|
};
|
|
13
|
+
__autoLayout: {
|
|
14
|
+
true: {
|
|
15
|
+
textAlign: "left";
|
|
16
|
+
selectors: {
|
|
17
|
+
"&:first-child": {
|
|
18
|
+
borderTopLeftRadius: string;
|
|
19
|
+
borderBottomLeftRadius: string;
|
|
20
|
+
};
|
|
21
|
+
"&:last-child": {
|
|
22
|
+
borderTopRightRadius: string;
|
|
23
|
+
borderBottomRightRadius: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
false: {};
|
|
28
|
+
};
|
|
13
29
|
}>;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
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<{
|
|
3
|
+
export declare function SortingHeaderCell({ className, sortKey, sort, sortDisabled, onSortChange, onClick, children, style, widthPx, widthRem, __autoLayout, ...rest }: ComponentProps<{
|
|
4
4
|
sortKey?: string;
|
|
5
5
|
sortDisabled?: boolean;
|
|
6
6
|
sort?: SortedColumn[];
|
|
7
7
|
onSortChange?: SortChangeHandler;
|
|
8
8
|
widthPx?: number;
|
|
9
9
|
widthRem?: number;
|
|
10
|
+
__autoLayout?: boolean;
|
|
10
11
|
}, HTMLDivElement>): React.ReactElement;
|
package/lib/style.css
CHANGED
|
@@ -1 +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}.
|
|
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}._1crs4gl3{text-align:left}._1crs4gl3:first-child{border-top-left-radius:.25rem;border-bottom-left-radius:.25rem}._1crs4gl3:last-child{border-top-right-radius:.25rem;border-bottom-right-radius:.25rem}.sk81640{padding:0;border-radius:.25rem;vertical-align:bottom;cursor:pointer;background-color:#e9e9ea}.sk81641{border-radius:0;position:fixed;top:0;z-index:999}.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%}.sk81645{display:table-row}.sk81646{display:table;table-layout:fixed;width:100%}.sk81647{top:3.75rem}.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.
|
|
4
|
+
"version": "8.8.0",
|
|
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": "^6.12.1",
|
|
30
30
|
"react": "^16.14.0",
|
|
31
31
|
"react-dom": "^16.14.0",
|
|
32
|
-
"@sps-woodland/core": "8.
|
|
33
|
-
"@sps-woodland/tokens": "8.
|
|
32
|
+
"@sps-woodland/core": "8.8.0",
|
|
33
|
+
"@sps-woodland/tokens": "8.8.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@spscommerce/utils": "^6.12.1",
|
|
@@ -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.
|
|
43
|
-
"@sps-woodland/tokens": "8.
|
|
42
|
+
"@sps-woodland/core": "8.8.0",
|
|
43
|
+
"@sps-woodland/tokens": "8.8.0"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "pnpm run build:js && pnpm run build:types",
|