@stackone/malachite 2.33.1 → 2.34.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/COMPONENTS.md +3 -3
- package/dist/components/Alert.js +77 -72
- package/dist/components/Alert.js.map +1 -1
- package/dist/components/Button.js +27 -30
- package/dist/components/Button.js.map +1 -1
- package/dist/components/CardStrip.js +366 -301
- package/dist/components/CardStrip.js.map +1 -1
- package/dist/components/Input/Input.js +47 -46
- package/dist/components/Input/Input.js.map +1 -1
- package/dist/components/PillButton.js +52 -33
- package/dist/components/PillButton.js.map +1 -1
- package/dist/components/Surface.js +100 -94
- package/dist/components/Surface.js.map +1 -1
- package/dist/components/cardStripGeometry.js +47 -0
- package/dist/components/cardStripGeometry.js.map +1 -0
- package/dist/components/linkRel.js +9 -0
- package/dist/components/linkRel.js.map +1 -0
- package/dist/index.d.ts +9 -1
- package/dist/tailwind.css.js +1 -1
- package/package.json +1 -1
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { CONTENT_INSET as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
.${Y} {
|
|
16
|
-
clip-path: inset(-${W}px -${W}px 0);
|
|
1
|
+
import { jsxs as U, jsx as h } from "react/jsx-runtime";
|
|
2
|
+
import C, { useRef as O, useState as nt, useLayoutEffect as w, useCallback as S } from "react";
|
|
3
|
+
import re from "./CustomIcons/ArrowLeftIcon.js";
|
|
4
|
+
import ne from "./CustomIcons/ForwardArrowIcon.js";
|
|
5
|
+
import oe from "./CustomIcons/PlusIcon.js";
|
|
6
|
+
import { CONTENT_INSET as $t } from "./PageLayout/constants.js";
|
|
7
|
+
import { STRIP_RULE_PX as ae, CARD_FLARE_TIP_PX as ct, CARD_WIDTH_PX as ce, FLARE_CLASS as se, CARD_FLARE_PX as q } from "./SelectableCard.js";
|
|
8
|
+
import { revealTargetFor as Dt, pageTargetFor as ie, EDGE_EPSILON_PX as ot, isCardInView as le } from "./cardStripGeometry.js";
|
|
9
|
+
import { CardStripSlotContext as yt, PINNED_SLOT as de, SCROLLED_SLOT as ue } from "./cardStripSlot.js";
|
|
10
|
+
import { FOCUS_RING as fe } from "./focusRing.js";
|
|
11
|
+
import { useAdoptedStyleSheet as Ot } from "./useAdoptedStyleSheet.js";
|
|
12
|
+
const pe = /* @__PURE__ */ new Set(["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "Home", "End"]), G = '[role="radio"]', he = "data-card-strip-scroller", me = "data-card-strip-trough", K = "malachite-card-strip", g = "malachite-card-strip-scroller", Xt = "malachite-card-strip-fade", R = "malachite-card-strip-add-tile", st = "data-card-strip-add-slot", Wt = "[data-selectable-card-actions]", be = 'a[href], area[href], button, input, select, textarea, iframe, [contenteditable="true"], [tabindex]', B = "data-card-strip-prev-tabindex", ge = 80, vt = 11, H = 12, zt = "var(--malachite-shadow-default)", Re = "var(--malachite-card-strip-arrow-background, var(--malachite-card-background, #ffffff))", _e = "var(--malachite-card-strip-arrow-border, #e8e8e8)", it = "var(--malachite-card-strip-background, #f1f1f1)", wt = "var(--malachite-radius-xxl, 14px)", Ae = `${wt} ${wt} 0 0`, Ct = "var(--malachite-radius-xxxl, 16px)", Se = `${Ct} ${Ct} 0 0`, v = 4, xe = H + v, Yt = H, It = ge + (Yt - v), dt = ce, Le = 2 * (H + v) + dt, Ee = "var(--malachite-card-strip-divider, #dddddd)", Pt = "var(--malachite-card-strip-fade, transparent)", Te = "var(--malachite-selectable-card-hover-background, #e8e8e8)", $e = "var(--malachite-card-strip-arrow-border, #e8e8e8)", kt = "var(--malachite-selectable-card-hover-rule, #bbbbbb)", Nt = "0px 1px 0px 0px rgba(0, 0, 0, 0.4)", De = "var(--malachite-card-background, #ffffff)", ye = "var(--malachite-text-primary, #0a0a0a)", Oe = "var(--malachite-card-strip-add-primary-background, var(--malachite-text-primary, #0a0a0a))", ve = "var(--malachite-card-strip-add-primary-foreground, var(--malachite-card-background, #ffffff))", we = "0px 1px 0px 0px rgba(10, 10, 10, 0.7)", ut = ae, Ft = 16, M = 9999, Ce = 4, Ie = `
|
|
13
|
+
.${K} {
|
|
14
|
+
clip-path: inset(-${M}px -${M}px 0);
|
|
17
15
|
}
|
|
18
|
-
.${
|
|
19
|
-
clip-path: inset(-${
|
|
16
|
+
.${K}:has(:focus-visible) {
|
|
17
|
+
clip-path: inset(-${M}px -${M}px -${Ce}px);
|
|
20
18
|
}
|
|
21
|
-
.${
|
|
19
|
+
.${g} {
|
|
22
20
|
display: flex;
|
|
23
21
|
flex-wrap: nowrap;
|
|
24
22
|
overflow-x: auto;
|
|
@@ -26,405 +24,471 @@ const Jt = /* @__PURE__ */ new Set(["ArrowLeft", "ArrowRight", "ArrowUp", "Arrow
|
|
|
26
24
|
scroll-behavior: smooth;
|
|
27
25
|
scrollbar-width: none;
|
|
28
26
|
-ms-overflow-style: none;
|
|
29
|
-
padding-block: ${
|
|
30
|
-
margin-block: -${
|
|
27
|
+
padding-block: ${Ft}px;
|
|
28
|
+
margin-block: -${Ft}px;
|
|
31
29
|
/* overflow-x clips both axes, so the end cards would lose a flare; the negative margin trades
|
|
32
30
|
the padding back out and scroll-padding keeps the rest position at zero. */
|
|
33
|
-
padding-inline: ${
|
|
34
|
-
margin-inline: -${
|
|
35
|
-
scroll-padding-inline: ${
|
|
31
|
+
padding-inline: ${q}px;
|
|
32
|
+
margin-inline: -${q}px;
|
|
33
|
+
scroll-padding-inline: ${q}px;
|
|
36
34
|
}
|
|
37
35
|
/* A card focused at a faded edge has to stay readable, so the fade lifts entirely. */
|
|
38
|
-
.${
|
|
36
|
+
.${K}:has(:focus-visible) .${Xt} {
|
|
39
37
|
display: none;
|
|
40
38
|
}
|
|
41
|
-
.${
|
|
39
|
+
.${g}::-webkit-scrollbar {
|
|
42
40
|
display: none;
|
|
43
41
|
}
|
|
44
42
|
/* No bottom edge: the strip's rule is the baseline for the add tile as much as for a card. */
|
|
45
|
-
.${
|
|
46
|
-
background: ${
|
|
47
|
-
border-radius: ${
|
|
43
|
+
.${R} > * {
|
|
44
|
+
background: ${it};
|
|
45
|
+
border-radius: ${Ae};
|
|
48
46
|
}
|
|
49
|
-
.${
|
|
50
|
-
background: ${
|
|
47
|
+
.${R}:hover:not(:has(button:disabled)) > * {
|
|
48
|
+
background: ${Te};
|
|
51
49
|
}
|
|
52
|
-
.${
|
|
50
|
+
.${R} button:active:not(:disabled) {
|
|
53
51
|
opacity: 0.8;
|
|
54
52
|
}
|
|
55
|
-
.${
|
|
56
|
-
background: ${
|
|
53
|
+
.${R}:has(button:active) > * {
|
|
54
|
+
background: ${it};
|
|
57
55
|
}
|
|
58
|
-
.${
|
|
59
|
-
border-color: ${
|
|
60
|
-
box-shadow: ${
|
|
56
|
+
.${R}[data-emphasis='secondary'] button {
|
|
57
|
+
border-color: ${$e};
|
|
58
|
+
box-shadow: ${zt};
|
|
61
59
|
}
|
|
62
|
-
.${
|
|
63
|
-
border-color: ${
|
|
64
|
-
box-shadow: ${
|
|
60
|
+
.${R}[data-emphasis='secondary']:hover:not(:has(button:disabled)) button {
|
|
61
|
+
border-color: ${kt};
|
|
62
|
+
box-shadow: ${Nt};
|
|
65
63
|
}
|
|
66
|
-
.${
|
|
67
|
-
border-color: ${
|
|
68
|
-
box-shadow: ${
|
|
64
|
+
.${R}[data-emphasis='secondary'] button:active:not(:disabled) {
|
|
65
|
+
border-color: ${kt};
|
|
66
|
+
box-shadow: ${Nt};
|
|
69
67
|
}
|
|
70
|
-
.${
|
|
68
|
+
.${R}[data-emphasis='primary'] button {
|
|
71
69
|
border-color: transparent;
|
|
72
|
-
box-shadow: ${
|
|
70
|
+
box-shadow: ${we};
|
|
73
71
|
}
|
|
74
|
-
.${
|
|
72
|
+
.${g} > * {
|
|
75
73
|
flex: 0 0 auto;
|
|
76
74
|
min-width: 0;
|
|
77
75
|
}
|
|
78
|
-
.${
|
|
79
|
-
border-left: 1px solid ${
|
|
76
|
+
.${g} > * + * {
|
|
77
|
+
border-left: 1px solid ${Ee};
|
|
80
78
|
}
|
|
81
|
-
.${
|
|
79
|
+
.${g}[data-snap='true'] {
|
|
82
80
|
scroll-snap-type: x proximity;
|
|
83
81
|
}
|
|
84
|
-
.${
|
|
82
|
+
.${g}[data-snap='true'] > * {
|
|
85
83
|
scroll-snap-align: start;
|
|
86
84
|
}
|
|
87
85
|
@media (prefers-reduced-motion: reduce) {
|
|
88
|
-
.${
|
|
86
|
+
.${g} {
|
|
89
87
|
scroll-behavior: auto;
|
|
90
88
|
}
|
|
91
|
-
.${
|
|
89
|
+
.${g}[data-snap='true'] {
|
|
92
90
|
scroll-snap-type: none;
|
|
93
91
|
}
|
|
94
|
-
.${
|
|
92
|
+
.${g}[data-snap='true'] > * {
|
|
95
93
|
scroll-snap-align: none;
|
|
96
94
|
}
|
|
97
|
-
}`,
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
95
|
+
}`, Pe = "malachite-card-strip-style", ke = "malachite-card-strip-add-slot", Ne = `
|
|
96
|
+
.${g} > [${st}] {
|
|
97
|
+
display: flex;
|
|
98
|
+
border-left: none;
|
|
99
|
+
}
|
|
100
|
+
[${st}] > .${R} {
|
|
101
|
+
height: 100% !important;
|
|
102
|
+
padding: 0 !important;
|
|
103
|
+
}
|
|
104
|
+
`, Ut = () => typeof window > "u" || typeof window.matchMedia != "function" ? !0 : window.matchMedia("(prefers-reduced-motion: reduce)").matches, x = (e) => e.dataset.value ?? e.getAttribute("value"), at = (e) => e.hasAttribute("disabled") || e.getAttribute("aria-disabled") === "true", Fe = (e) => {
|
|
105
|
+
const a = e.parentElement;
|
|
106
|
+
return !a || a.querySelectorAll(G).length !== 1 ? null : a.querySelector(Wt);
|
|
107
|
+
}, Ue = (e, a) => {
|
|
108
|
+
const l = e.closest(G);
|
|
109
|
+
if (l)
|
|
110
|
+
return l;
|
|
111
|
+
if (e.closest(Wt))
|
|
105
112
|
return null;
|
|
106
|
-
let
|
|
107
|
-
for (;
|
|
108
|
-
const
|
|
109
|
-
if (
|
|
110
|
-
return
|
|
111
|
-
|
|
113
|
+
let u = e;
|
|
114
|
+
for (; u && a.contains(u); ) {
|
|
115
|
+
const f = u.querySelectorAll(G);
|
|
116
|
+
if (f.length === 1 && f[0].parentElement === u)
|
|
117
|
+
return f[0];
|
|
118
|
+
u = u.parentElement;
|
|
112
119
|
}
|
|
113
120
|
return null;
|
|
114
|
-
},
|
|
115
|
-
const
|
|
116
|
-
return
|
|
117
|
-
},
|
|
118
|
-
|
|
119
|
-
},
|
|
120
|
-
if (!
|
|
121
|
+
}, Be = (e) => {
|
|
122
|
+
const a = Fe(e);
|
|
123
|
+
return a ? Array.from(a.querySelectorAll(be)) : [];
|
|
124
|
+
}, Ge = (e) => {
|
|
125
|
+
e.hasAttribute(B) || e.setAttribute(B, e.getAttribute("tabindex") ?? ""), e.setAttribute("tabindex", "-1");
|
|
126
|
+
}, He = (e) => {
|
|
127
|
+
if (!e.hasAttribute(B))
|
|
121
128
|
return;
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
},
|
|
129
|
+
const a = e.getAttribute(B);
|
|
130
|
+
e.removeAttribute(B), a ? e.setAttribute("tabindex", a) : e.removeAttribute("tabindex");
|
|
131
|
+
}, Xe = {
|
|
125
132
|
profile: "var(--malachite-selectable-card-selected-border, #047b43)",
|
|
126
133
|
library: "var(--malachite-selectable-card-library-selected-border, #bbbbbb)",
|
|
127
134
|
editing: "var(--malachite-selectable-card-pending-foreground, #96580a)"
|
|
128
|
-
},
|
|
135
|
+
}, We = {
|
|
129
136
|
backgroundRepeat: "no-repeat",
|
|
130
137
|
backgroundPosition: "left bottom",
|
|
131
|
-
backgroundSize: `100% ${
|
|
132
|
-
},
|
|
133
|
-
const
|
|
134
|
-
if (!
|
|
138
|
+
backgroundSize: `100% ${ut}px`
|
|
139
|
+
}, Bt = 0.5, Gt = q - ct, ze = (e) => {
|
|
140
|
+
const a = e.querySelector(`:scope > .${se}`);
|
|
141
|
+
if (!a)
|
|
135
142
|
return null;
|
|
136
|
-
const { left:
|
|
137
|
-
return { left:
|
|
138
|
-
},
|
|
139
|
-
if (!
|
|
143
|
+
const { left: l, right: u } = a.getBoundingClientRect();
|
|
144
|
+
return { left: l + Gt, right: u - Gt };
|
|
145
|
+
}, Ye = (e, a, l, u) => {
|
|
146
|
+
if (!e)
|
|
140
147
|
return;
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
},
|
|
144
|
-
marginInline: `calc(${
|
|
145
|
-
paddingInline:
|
|
146
|
-
},
|
|
147
|
-
background:
|
|
148
|
-
borderRadius:
|
|
149
|
-
paddingTop: `${
|
|
150
|
-
paddingInline: `${
|
|
151
|
-
marginBottom: `${
|
|
152
|
-
},
|
|
153
|
-
...
|
|
154
|
-
marginInline: `${
|
|
155
|
-
},
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
`${t}:${r}`,
|
|
159
|
-
{ ...z, marginInline: `${t}px ${r}px` }
|
|
160
|
-
])
|
|
161
|
-
)
|
|
162
|
-
), ke = z, Ne = z, Ue = {
|
|
163
|
-
marginInlineStart: `${T}px`
|
|
164
|
-
}, Be = {
|
|
148
|
+
const f = Xe[u], T = e.getBoundingClientRect(), I = T.left, _ = l && (a != null && a.contains(l)) ? a.getBoundingClientRect() : T, L = l == null ? void 0 : l.getBoundingClientRect(), m = l ? ze(l) : null, j = (m == null ? void 0 : m.left) ?? (L ? L.left - ct : 0), J = (m == null ? void 0 : m.right) ?? (L ? L.right + ct : 0), P = L ? Math.max(j, _.left) + Bt - I : 0, b = L ? Math.min(J, _.right) - Bt - I : 0;
|
|
149
|
+
e.style.backgroundImage = b > P ? `linear-gradient(to right, ${f} 0 ${P}px, transparent ${P}px ${b}px, ${f} ${b}px 100%)` : `linear-gradient(to right, ${f} 0 100%)`;
|
|
150
|
+
}, Ve = {
|
|
151
|
+
marginInline: `calc(${$t} * -1)`,
|
|
152
|
+
paddingInline: $t
|
|
153
|
+
}, ft = {
|
|
154
|
+
background: it,
|
|
155
|
+
borderRadius: Se,
|
|
156
|
+
paddingTop: `${v}px`,
|
|
157
|
+
paddingInline: `${v}px`,
|
|
158
|
+
marginBottom: `${ut}px`
|
|
159
|
+
}, Me = {
|
|
160
|
+
...ft,
|
|
161
|
+
marginInline: `${H}px`
|
|
162
|
+
}, qe = ft, Ke = ft, je = {
|
|
163
|
+
marginInlineStart: `${H}px`
|
|
164
|
+
}, Je = {
|
|
165
165
|
primary: {
|
|
166
|
-
backgroundColor:
|
|
167
|
-
color:
|
|
166
|
+
backgroundColor: Oe,
|
|
167
|
+
color: ve
|
|
168
168
|
},
|
|
169
|
-
secondary: { backgroundColor:
|
|
170
|
-
},
|
|
171
|
-
label:
|
|
172
|
-
icon:
|
|
173
|
-
onClick:
|
|
174
|
-
disabled:
|
|
175
|
-
emphasis:
|
|
176
|
-
className:
|
|
177
|
-
}) => /* @__PURE__ */
|
|
169
|
+
secondary: { backgroundColor: De, color: ye }
|
|
170
|
+
}, Vt = ({
|
|
171
|
+
label: e,
|
|
172
|
+
icon: a,
|
|
173
|
+
onClick: l,
|
|
174
|
+
disabled: u = !1,
|
|
175
|
+
emphasis: f = "secondary",
|
|
176
|
+
className: T = ""
|
|
177
|
+
}) => /* @__PURE__ */ h(
|
|
178
178
|
"div",
|
|
179
179
|
{
|
|
180
|
-
className:
|
|
181
|
-
"data-emphasis":
|
|
180
|
+
className: R,
|
|
181
|
+
"data-emphasis": f,
|
|
182
182
|
style: {
|
|
183
|
-
...
|
|
184
|
-
width: `${
|
|
185
|
-
height: `calc(100% - ${
|
|
183
|
+
...qe,
|
|
184
|
+
width: `${dt}px`,
|
|
185
|
+
height: `calc(100% - ${ut}px)`
|
|
186
186
|
},
|
|
187
|
-
children: /* @__PURE__ */
|
|
187
|
+
children: /* @__PURE__ */ h("div", { className: "flex h-full items-center justify-center px-4", children: /* @__PURE__ */ U(
|
|
188
188
|
"button",
|
|
189
189
|
{
|
|
190
190
|
type: "button",
|
|
191
|
-
onClick:
|
|
192
|
-
disabled:
|
|
193
|
-
style:
|
|
194
|
-
className: `${
|
|
191
|
+
onClick: l,
|
|
192
|
+
disabled: u,
|
|
193
|
+
style: Je[f],
|
|
194
|
+
className: `${fe} inline-flex items-center justify-center gap-1.5 h-[var(--malachite-control-height-medium,32px)] w-[108px] px-2.5 rounded-xl border border-solid text-[length:var(--malachite-font-size-small,13px)] font-medium whitespace-nowrap ${u ? "opacity-50 cursor-not-allowed" : "cursor-pointer"} ${T}`,
|
|
195
195
|
children: [
|
|
196
|
-
/* @__PURE__ */
|
|
197
|
-
|
|
196
|
+
/* @__PURE__ */ h("span", { className: "inline-flex h-[13px] w-[13px] shrink-0 items-center justify-center", children: a ?? /* @__PURE__ */ h(oe, { size: 13 }) }),
|
|
197
|
+
e
|
|
198
198
|
]
|
|
199
199
|
}
|
|
200
200
|
) })
|
|
201
201
|
}
|
|
202
|
-
),
|
|
202
|
+
), lt = (e) => C.isValidElement(e) && e.type === Vt, Qe = (e) => C.isValidElement(e) && e.type === C.Fragment && C.Children.toArray(e.props.children).some(lt), Ht = ({ side: e, onClick: a }) => /* @__PURE__ */ h(
|
|
203
203
|
"button",
|
|
204
204
|
{
|
|
205
205
|
type: "button",
|
|
206
206
|
tabIndex: -1,
|
|
207
207
|
"aria-hidden": "true",
|
|
208
|
-
"aria-label":
|
|
209
|
-
onClick:
|
|
208
|
+
"aria-label": e === "left" ? "Scroll left" : "Scroll right",
|
|
209
|
+
onClick: a,
|
|
210
210
|
className: "absolute top-1/2 -translate-y-1/2 z-10 inline-flex items-center justify-center w-5 h-5 rounded-lg cursor-pointer text-[var(--malachite-text-secondary)]",
|
|
211
211
|
style: {
|
|
212
|
-
[
|
|
213
|
-
background:
|
|
214
|
-
border: `1px solid ${
|
|
215
|
-
boxShadow:
|
|
212
|
+
[e]: `-${xe}px`,
|
|
213
|
+
background: Re,
|
|
214
|
+
border: `1px solid ${_e}`,
|
|
215
|
+
boxShadow: zt
|
|
216
216
|
},
|
|
217
|
-
children:
|
|
217
|
+
children: e === "left" ? /* @__PURE__ */ h(re, { size: vt }) : /* @__PURE__ */ h(ne, { size: vt })
|
|
218
218
|
}
|
|
219
|
-
),
|
|
220
|
-
value:
|
|
221
|
-
tone:
|
|
222
|
-
onChange:
|
|
223
|
-
children:
|
|
224
|
-
leading:
|
|
225
|
-
arrows:
|
|
226
|
-
fadeEdges:
|
|
227
|
-
snap:
|
|
228
|
-
bleed:
|
|
229
|
-
scrollSelectedIntoView:
|
|
230
|
-
"aria-label":
|
|
231
|
-
"aria-labelledby":
|
|
232
|
-
className:
|
|
219
|
+
), Ze = ({
|
|
220
|
+
value: e,
|
|
221
|
+
tone: a,
|
|
222
|
+
onChange: l,
|
|
223
|
+
children: u,
|
|
224
|
+
leading: f,
|
|
225
|
+
arrows: T = !0,
|
|
226
|
+
fadeEdges: I = !0,
|
|
227
|
+
snap: _ = !0,
|
|
228
|
+
bleed: L = !1,
|
|
229
|
+
scrollSelectedIntoView: m = !0,
|
|
230
|
+
"aria-label": j,
|
|
231
|
+
"aria-labelledby": J,
|
|
232
|
+
className: P = "",
|
|
233
233
|
style: b
|
|
234
234
|
}) => {
|
|
235
|
-
const
|
|
236
|
-
|
|
237
|
-
const
|
|
238
|
-
(
|
|
239
|
-
),
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
const
|
|
254
|
-
|
|
255
|
-
const
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
235
|
+
const $ = O(null), pt = O(null), k = O(null), ht = O(!1), [X, Mt] = nt({ canScrollLeft: !1, canScrollRight: !1 }), [qt, mt] = nt(!1), W = O(null), bt = O(!1);
|
|
236
|
+
Ot($, Ie, Pe), Ot($, Ne, ke);
|
|
237
|
+
const Q = C.Children.toArray(u), Z = Q.filter((t) => !lt(t)), Kt = Z.some(Qe), D = Z.length > 0, z = Q.filter(lt).map(
|
|
238
|
+
(t) => t.props.emphasis === void 0 ? C.cloneElement(t, { emphasis: D ? "secondary" : "primary" }) : t
|
|
239
|
+
), gt = Q.length, tt = z.length;
|
|
240
|
+
w(() => {
|
|
241
|
+
const t = $.current;
|
|
242
|
+
if (!t || !D || tt === 0) {
|
|
243
|
+
mt(!1);
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
const r = pt.current, { paddingLeft: o, paddingRight: s } = getComputedStyle(t), i = (parseFloat(o) || 0) + (parseFloat(s) || 0);
|
|
247
|
+
let d = t.clientWidth - i, p = (r == null ? void 0 : r.offsetWidth) ?? 0;
|
|
248
|
+
const n = () => {
|
|
249
|
+
const y = p + tt * dt + Le;
|
|
250
|
+
mt(d > 0 && d < y);
|
|
251
|
+
};
|
|
252
|
+
n();
|
|
253
|
+
const c = typeof ResizeObserver < "u" ? new ResizeObserver((y) => {
|
|
254
|
+
var E, Tt;
|
|
255
|
+
for (const V of y ?? [])
|
|
256
|
+
V.target === t ? d = V.contentRect.width : p = ((Tt = (E = V.borderBoxSize) == null ? void 0 : E[0]) == null ? void 0 : Tt.inlineSize) ?? V.contentRect.width + 2 * v;
|
|
257
|
+
n();
|
|
258
|
+
}) : null;
|
|
259
|
+
return c == null || c.observe(t), r && (c == null || c.observe(r)), () => c == null ? void 0 : c.disconnect();
|
|
260
|
+
}, [D, tt, !!f]);
|
|
261
|
+
const et = qt && D, Rt = S((t) => {
|
|
262
|
+
var o;
|
|
263
|
+
const r = t.type === "focus" ? t.target : t.relatedTarget;
|
|
264
|
+
bt.current = !!(r instanceof Node && ((o = W.current) != null && o.contains(r)));
|
|
265
|
+
}, []);
|
|
266
|
+
w(() => {
|
|
267
|
+
var o;
|
|
268
|
+
const t = W.current, r = t ? t.getRootNode().activeElement : null;
|
|
269
|
+
bt.current && t && !(r && t.contains(r)) && ((o = t.querySelector("button")) == null || o.focus({ preventScroll: !0 }));
|
|
270
|
+
}, [et]);
|
|
271
|
+
const A = S(() => {
|
|
272
|
+
const t = $.current;
|
|
273
|
+
return t ? Array.from(t.querySelectorAll(G)) : [];
|
|
274
|
+
}, []), rt = S(
|
|
275
|
+
() => A().filter((t) => x(t) !== null),
|
|
276
|
+
[A]
|
|
277
|
+
), _t = O(/* @__PURE__ */ new Set()), N = S((t, r) => {
|
|
278
|
+
_t.current.has(t) || (_t.current.add(t), console.warn(r));
|
|
279
|
+
}, []), [jt, Jt] = nt("profile");
|
|
280
|
+
w(() => {
|
|
281
|
+
var r, o;
|
|
282
|
+
const t = (o = (r = A().find((s) => x(s) === e)) == null ? void 0 : r.parentElement) == null ? void 0 : o.getAttribute("data-variant");
|
|
283
|
+
(t === "profile" || t === "library" || t === "editing") && Jt(t);
|
|
284
|
+
}, [A, e]), w(() => {
|
|
285
|
+
const t = A(), r = rt(), s = r.find((n) => x(n) === e) ?? r.find((n) => !at(n)) ?? null;
|
|
286
|
+
if (t.forEach((n) => {
|
|
287
|
+
const c = n === s, y = c ? 0 : -1;
|
|
288
|
+
n.tabIndex !== y && (n.tabIndex = y);
|
|
289
|
+
for (const E of Be(n))
|
|
290
|
+
c ? He(E) : Ge(E);
|
|
259
291
|
}), process.env.NODE_ENV === "production")
|
|
260
292
|
return;
|
|
261
|
-
|
|
293
|
+
r.length !== t.length && N(
|
|
262
294
|
"missing-value",
|
|
263
295
|
'CardStrip: a child with role="radio" has no `data-value`. It cannot be selected or reached by arrow keys, so it is excluded from the radio set. Give every card a `data-value`.'
|
|
264
296
|
);
|
|
265
|
-
const
|
|
266
|
-
for (const
|
|
267
|
-
const
|
|
268
|
-
|
|
269
|
-
`duplicate:${
|
|
270
|
-
`CardStrip: two cards share the data-value "${
|
|
271
|
-
),
|
|
297
|
+
const i = /* @__PURE__ */ new Set();
|
|
298
|
+
for (const n of r) {
|
|
299
|
+
const c = x(n);
|
|
300
|
+
c !== null && (i.has(c) && N(
|
|
301
|
+
`duplicate:${c}`,
|
|
302
|
+
`CardStrip: two cards share the data-value "${c}". Both will read as checked and only the first is selectable — data-value must be unique.`
|
|
303
|
+
), i.add(c));
|
|
272
304
|
}
|
|
273
|
-
const
|
|
274
|
-
|
|
275
|
-
`unmatched:${
|
|
276
|
-
`CardStrip: value "${
|
|
305
|
+
const d = e !== "";
|
|
306
|
+
t.length > 0 && d && !i.has(e) && N(
|
|
307
|
+
`unmatched:${e}`,
|
|
308
|
+
`CardStrip: value "${e}" matches no card's data-value, so the group reports no selection.`
|
|
277
309
|
);
|
|
278
|
-
const
|
|
279
|
-
(
|
|
310
|
+
const p = t.filter(
|
|
311
|
+
(n) => n.getAttribute("aria-checked") === "true"
|
|
280
312
|
).length;
|
|
281
|
-
|
|
282
|
-
`checked:${
|
|
283
|
-
`CardStrip: ${
|
|
284
|
-
),
|
|
313
|
+
t.length > 0 && d && p !== 1 && N(
|
|
314
|
+
`checked:${p}`,
|
|
315
|
+
`CardStrip: ${p} cards are aria-checked, but a radiogroup has exactly one. Drive each card's checked state from the strip's \`value\`.`
|
|
316
|
+
), Kt && N(
|
|
285
317
|
"wrapped-add-tile",
|
|
286
318
|
"CardStrip: a CardStrip.AddTile inside a fragment is treated as a card and scrolls with them. The add tile must be a direct child of CardStrip."
|
|
287
319
|
);
|
|
288
|
-
})
|
|
289
|
-
|
|
320
|
+
});
|
|
321
|
+
const F = S(() => {
|
|
322
|
+
const t = A().find((r) => x(r) === e);
|
|
323
|
+
return t ? t.closest('[role="radio"]') ?? t : null;
|
|
324
|
+
}, [A, e]);
|
|
325
|
+
w(() => {
|
|
326
|
+
if (!m)
|
|
290
327
|
return;
|
|
291
|
-
const
|
|
292
|
-
if (!
|
|
328
|
+
const t = k.current, r = F();
|
|
329
|
+
if (!t || !r || typeof t.scrollTo != "function")
|
|
293
330
|
return;
|
|
294
|
-
const
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
331
|
+
const o = ht.current;
|
|
332
|
+
ht.current = !0;
|
|
333
|
+
const s = Dt(t, r, _);
|
|
334
|
+
s !== null && t.scrollTo({
|
|
335
|
+
left: s,
|
|
336
|
+
behavior: o && !Ut() ? "smooth" : "instant"
|
|
298
337
|
});
|
|
299
|
-
}, [
|
|
300
|
-
const
|
|
301
|
-
var
|
|
302
|
-
const
|
|
303
|
-
if (
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
(
|
|
307
|
-
|
|
308
|
-
), !
|
|
338
|
+
}, [F, m, _, gt]);
|
|
339
|
+
const At = a ?? jt, St = (b == null ? void 0 : b.background) !== void 0 || (b == null ? void 0 : b.backgroundImage) !== void 0, Y = S(() => {
|
|
340
|
+
var p;
|
|
341
|
+
const t = k.current;
|
|
342
|
+
if (St || Ye(
|
|
343
|
+
$.current,
|
|
344
|
+
t,
|
|
345
|
+
(p = A().find((n) => x(n) === e)) == null ? void 0 : p.parentElement,
|
|
346
|
+
At
|
|
347
|
+
), !t)
|
|
309
348
|
return;
|
|
310
|
-
const { scrollWidth:
|
|
311
|
-
canScrollLeft:
|
|
312
|
-
canScrollRight:
|
|
349
|
+
const { scrollWidth: r, clientWidth: o, scrollLeft: s } = t, i = r > o + ot, d = {
|
|
350
|
+
canScrollLeft: i && s > ot,
|
|
351
|
+
canScrollRight: i && s + o < r - ot
|
|
313
352
|
};
|
|
314
|
-
|
|
315
|
-
(
|
|
353
|
+
Mt(
|
|
354
|
+
(n) => n.canScrollLeft === d.canScrollLeft && n.canScrollRight === d.canScrollRight ? n : d
|
|
316
355
|
);
|
|
317
|
-
}, [
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
const
|
|
321
|
-
if (!
|
|
356
|
+
}, [St, A, At, e]);
|
|
357
|
+
w(() => {
|
|
358
|
+
Y();
|
|
359
|
+
const t = k.current;
|
|
360
|
+
if (!t)
|
|
322
361
|
return;
|
|
323
|
-
const
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
return a == null || a.observe(e), () => {
|
|
327
|
-
e.removeEventListener("scroll", n), a == null || a.disconnect();
|
|
362
|
+
const r = () => {
|
|
363
|
+
const c = F();
|
|
364
|
+
return c !== null && le(t, c);
|
|
328
365
|
};
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
366
|
+
let o = r();
|
|
367
|
+
const s = () => {
|
|
368
|
+
Y(), o = r();
|
|
369
|
+
};
|
|
370
|
+
t.addEventListener("scroll", s, { passive: !0 });
|
|
371
|
+
let i = 0;
|
|
372
|
+
const d = () => {
|
|
373
|
+
const c = F(), E = m && o && typeof t.scrollTo == "function" && c ? Dt(t, c, _) : null;
|
|
374
|
+
E !== null && t.scrollTo({ left: E, behavior: "instant" }), o = r();
|
|
375
|
+
}, p = () => {
|
|
376
|
+
if (Y(), typeof requestAnimationFrame != "function") {
|
|
377
|
+
d();
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
cancelAnimationFrame(i), i = requestAnimationFrame(d);
|
|
381
|
+
}, n = typeof ResizeObserver < "u" ? new ResizeObserver(p) : null;
|
|
382
|
+
return n == null || n.observe(t), () => {
|
|
383
|
+
t.removeEventListener("scroll", s), n == null || n.disconnect(), typeof cancelAnimationFrame == "function" && cancelAnimationFrame(i);
|
|
384
|
+
};
|
|
385
|
+
}, [Y, F, m, _, gt]);
|
|
386
|
+
const xt = S(
|
|
387
|
+
(t) => {
|
|
388
|
+
const r = k.current;
|
|
389
|
+
!r || typeof r.scrollBy != "function" || r.scrollBy({
|
|
390
|
+
left: ie(r, t, _) - r.scrollLeft,
|
|
391
|
+
behavior: Ut() ? "auto" : "smooth"
|
|
392
|
+
});
|
|
393
|
+
},
|
|
394
|
+
[_]
|
|
395
|
+
), Qt = S(
|
|
396
|
+
(t) => {
|
|
397
|
+
if (!pe.has(t.key))
|
|
339
398
|
return;
|
|
340
|
-
const
|
|
341
|
-
if (!(
|
|
399
|
+
const r = t.target;
|
|
400
|
+
if (!(r instanceof Element) || !r.closest(G))
|
|
342
401
|
return;
|
|
343
|
-
const
|
|
344
|
-
if (
|
|
402
|
+
const o = rt().filter((n) => !at(n));
|
|
403
|
+
if (o.length === 0)
|
|
345
404
|
return;
|
|
346
|
-
|
|
347
|
-
const
|
|
348
|
-
let
|
|
349
|
-
if (
|
|
350
|
-
|
|
351
|
-
else if (
|
|
352
|
-
|
|
405
|
+
t.preventDefault();
|
|
406
|
+
const s = o.findIndex((n) => x(n) === e);
|
|
407
|
+
let i;
|
|
408
|
+
if (t.key === "Home")
|
|
409
|
+
i = 0;
|
|
410
|
+
else if (t.key === "End")
|
|
411
|
+
i = o.length - 1;
|
|
353
412
|
else {
|
|
354
|
-
const
|
|
355
|
-
|
|
413
|
+
const n = t.key === "ArrowLeft" || t.key === "ArrowUp" ? -1 : 1;
|
|
414
|
+
i = ((s === -1 ? 0 : s) + n + o.length) % o.length;
|
|
356
415
|
}
|
|
357
|
-
const
|
|
358
|
-
|
|
416
|
+
const d = o[i], p = x(d);
|
|
417
|
+
p !== null && p !== e && l(p), d.focus();
|
|
359
418
|
},
|
|
360
|
-
[
|
|
361
|
-
),
|
|
362
|
-
(
|
|
363
|
-
const
|
|
364
|
-
if (!(
|
|
419
|
+
[rt, l, e]
|
|
420
|
+
), Zt = S(
|
|
421
|
+
(t) => {
|
|
422
|
+
const r = t.target;
|
|
423
|
+
if (!(r instanceof Element) || r.closest(`.${R}`))
|
|
365
424
|
return;
|
|
366
|
-
const
|
|
367
|
-
if (!
|
|
425
|
+
const o = $.current;
|
|
426
|
+
if (!o)
|
|
368
427
|
return;
|
|
369
|
-
const
|
|
370
|
-
if (!
|
|
428
|
+
const s = Ue(r, o);
|
|
429
|
+
if (!s || at(s))
|
|
371
430
|
return;
|
|
372
|
-
const
|
|
373
|
-
|
|
431
|
+
const i = x(s);
|
|
432
|
+
i !== null && i !== e && l(i);
|
|
374
433
|
},
|
|
375
|
-
[
|
|
376
|
-
),
|
|
377
|
-
return /* @__PURE__ */
|
|
434
|
+
[l, e]
|
|
435
|
+
), te = T && X.canScrollLeft, ee = T && X.canScrollRight, Lt = I && X.canScrollLeft, Et = I && X.canScrollRight;
|
|
436
|
+
return /* @__PURE__ */ U(
|
|
378
437
|
"div",
|
|
379
438
|
{
|
|
380
|
-
ref:
|
|
381
|
-
onKeyDown:
|
|
382
|
-
|
|
383
|
-
|
|
439
|
+
ref: $,
|
|
440
|
+
onKeyDown: Qt,
|
|
441
|
+
onFocus: Rt,
|
|
442
|
+
onBlur: Rt,
|
|
443
|
+
onClick: Zt,
|
|
444
|
+
className: `${K} flex items-stretch ${P}`,
|
|
384
445
|
style: {
|
|
385
|
-
...
|
|
386
|
-
...
|
|
446
|
+
...We,
|
|
447
|
+
...L ? Ve : null,
|
|
387
448
|
...b
|
|
388
449
|
},
|
|
389
450
|
children: [
|
|
390
|
-
/* @__PURE__ */
|
|
451
|
+
/* @__PURE__ */ U(
|
|
391
452
|
"div",
|
|
392
453
|
{
|
|
393
454
|
role: "radiogroup",
|
|
394
|
-
"aria-label":
|
|
395
|
-
"aria-labelledby":
|
|
396
|
-
className:
|
|
455
|
+
"aria-label": j,
|
|
456
|
+
"aria-labelledby": J,
|
|
457
|
+
className: D ? "flex items-stretch min-w-0" : "flex items-stretch",
|
|
397
458
|
children: [
|
|
398
|
-
|
|
399
|
-
|
|
459
|
+
f ? /* @__PURE__ */ h(yt.Provider, { value: de, children: /* @__PURE__ */ h("div", { ref: pt, className: "shrink-0", style: Ke, children: f }) }) : null,
|
|
460
|
+
D ? /* @__PURE__ */ U(
|
|
400
461
|
"div",
|
|
401
462
|
{
|
|
402
|
-
[
|
|
463
|
+
[me]: "",
|
|
403
464
|
className: "relative min-w-0 shrink basis-auto",
|
|
404
|
-
style:
|
|
465
|
+
style: Me,
|
|
405
466
|
children: [
|
|
406
|
-
/* @__PURE__ */
|
|
467
|
+
/* @__PURE__ */ U(
|
|
407
468
|
"div",
|
|
408
469
|
{
|
|
409
|
-
ref:
|
|
470
|
+
ref: k,
|
|
410
471
|
tabIndex: -1,
|
|
411
|
-
[
|
|
412
|
-
"data-snap":
|
|
413
|
-
className:
|
|
414
|
-
children:
|
|
472
|
+
[he]: "",
|
|
473
|
+
"data-snap": _ ? "true" : "false",
|
|
474
|
+
className: g,
|
|
475
|
+
children: [
|
|
476
|
+
/* @__PURE__ */ h(yt.Provider, { value: ue, children: Z }),
|
|
477
|
+
et ? /* @__PURE__ */ h("div", { ref: W, [st]: "", children: z }) : null
|
|
478
|
+
]
|
|
415
479
|
}
|
|
416
480
|
),
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
481
|
+
te ? /* @__PURE__ */ h(Ht, { side: "left", onClick: () => xt(-1) }) : null,
|
|
482
|
+
ee ? /* @__PURE__ */ h(Ht, { side: "right", onClick: () => xt(1) }) : null,
|
|
483
|
+
Lt || Et ? /* @__PURE__ */ h(
|
|
420
484
|
"div",
|
|
421
485
|
{
|
|
422
486
|
"aria-hidden": !0,
|
|
423
487
|
"data-card-strip-fade": "",
|
|
424
|
-
className: `${
|
|
488
|
+
className: `${Xt} absolute pointer-events-none`,
|
|
425
489
|
style: {
|
|
426
|
-
inset: `-${
|
|
427
|
-
background: `linear-gradient(to right, ${
|
|
490
|
+
inset: `-${v}px -${Yt}px 0`,
|
|
491
|
+
background: `linear-gradient(to right, ${Lt ? Pt : "transparent"} 0, transparent ${It}px, transparent calc(100% - ${It}px), ${Et ? Pt : "transparent"} 100%)`
|
|
428
492
|
}
|
|
429
493
|
}
|
|
430
494
|
) : null
|
|
@@ -434,21 +498,22 @@ const Jt = /* @__PURE__ */ new Set(["ArrowLeft", "ArrowRight", "ArrowUp", "Arrow
|
|
|
434
498
|
]
|
|
435
499
|
}
|
|
436
500
|
),
|
|
437
|
-
|
|
501
|
+
z.length > 0 && !et ? /* @__PURE__ */ h(
|
|
438
502
|
"div",
|
|
439
503
|
{
|
|
504
|
+
ref: W,
|
|
440
505
|
className: "shrink-0",
|
|
441
|
-
style: !
|
|
442
|
-
children:
|
|
506
|
+
style: !D && f ? je : void 0,
|
|
507
|
+
children: z
|
|
443
508
|
}
|
|
444
509
|
) : null
|
|
445
510
|
]
|
|
446
511
|
}
|
|
447
512
|
);
|
|
448
513
|
};
|
|
449
|
-
|
|
514
|
+
Ze.AddTile = Vt;
|
|
450
515
|
export {
|
|
451
|
-
|
|
452
|
-
|
|
516
|
+
Ze as CardStrip,
|
|
517
|
+
Ze as default
|
|
453
518
|
};
|
|
454
519
|
//# sourceMappingURL=CardStrip.js.map
|