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