@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.
@@ -1,22 +1,22 @@
1
- import { jsxs as X, jsx as u } from "react/jsx-runtime";
2
- import $, { useRef as Z, useState as bt, useCallback as L, useLayoutEffect as F } from "react";
3
- import Ft from "./CustomIcons/ArrowLeftIcon.js";
4
- import Ht from "./CustomIcons/ForwardArrowIcon.js";
5
- import Xt from "./CustomIcons/PlusIcon.js";
6
- import { CONTENT_INSET as mt } from "./PageLayout/constants.js";
7
- import { CARD_FLARE_PX as m, STRIP_RULE_PX as Wt, CARD_FLARE_TIP_PX as tt, CARD_WIDTH_PX as Mt, FLARE_CLASS as Yt } from "./SelectableCard.js";
8
- import { CardStripSlotContext as Rt, PINNED_SLOT as Vt, SCROLLED_SLOT as zt } from "./cardStripSlot.js";
9
- import { FOCUS_RING as Kt } from "./focusRing.js";
10
- import { useAdoptedStyleSheet as jt } from "./useAdoptedStyleSheet.js";
11
- const qt = /* @__PURE__ */ new Set(["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "Home", "End"]), I = '[role="radio"]', Zt = "data-card-strip-scroller", Jt = "data-card-strip-trough", W = "malachite-card-strip", R = "malachite-card-strip-scroller", Dt = "malachite-card-strip-fade", x = "malachite-card-strip-add-tile", Ot = "[data-selectable-card-actions]", Qt = 'a[href], area[href], button, input, select, textarea, iframe, [contenteditable="true"], [tabindex]', w = "data-card-strip-prev-tabindex", J = 1, te = 0.8, ee = (t) => {
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 * te : Math.max(1, Math.floor(i / s)) * s;
14
- }, re = 80, ne = 20, gt = 11, T = 12, P = 52, oe = (P + ne) / 2, Ct = "var(--malachite-shadow-default)", ae = "var(--malachite-card-strip-arrow-background, var(--malachite-card-background, #ffffff))", ce = "var(--malachite-card-strip-arrow-border, #e8e8e8)", et = "var(--malachite-card-strip-background, #f1f1f1)", _t = "var(--malachite-radius-xxl, 14px)", se = `${_t} ${_t} 0 0`, At = "var(--malachite-radius-xxxl, 16px)", ie = `${At} ${At} 0 0`, M = 4, xt = re + (m - M), le = Mt, de = "var(--malachite-card-strip-divider, #dddddd)", St = "var(--malachite-card-strip-fade, transparent)", ue = "var(--malachite-selectable-card-hover-background, #e8e8e8)", fe = "var(--malachite-card-strip-arrow-border, #e8e8e8)", Et = "var(--malachite-selectable-card-hover-rule, #bbbbbb)", Lt = "0px 1px 0px 0px rgba(0, 0, 0, 0.4)", pe = "var(--malachite-card-background, #ffffff)", he = "var(--malachite-text-primary, #0a0a0a)", be = "var(--malachite-card-strip-add-primary-background, var(--malachite-text-primary, #0a0a0a))", me = "var(--malachite-card-strip-add-primary-foreground, var(--malachite-card-background, #ffffff))", Re = "0px 1px 0px 0px rgba(10, 10, 10, 0.7)", nt = Wt, $t = 16, H = 9999, ge = 4, _e = `
15
- .${W} {
16
- clip-path: inset(-${H}px -${H}px 0);
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
- .${W}:has(:focus-visible) {
19
- clip-path: inset(-${H}px -${H}px -${ge}px);
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: ${$t}px;
30
- margin-block: -${$t}px;
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
- .${W}:has(:focus-visible) .${Dt} {
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: ${et};
47
- border-radius: ${se};
46
+ background: ${rt};
47
+ border-radius: ${le};
48
48
  }
49
49
  .${x}:hover:not(:has(button:disabled)) > * {
50
- background: ${ue};
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: ${et};
56
+ background: ${rt};
57
57
  }
58
58
  .${x}[data-emphasis='secondary'] button {
59
- border-color: ${fe};
60
- box-shadow: ${Ct};
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: ${Et};
64
- box-shadow: ${Lt};
63
+ border-color: ${Lt};
64
+ box-shadow: ${$t};
65
65
  }
66
66
  .${x}[data-emphasis='secondary'] button:active:not(:disabled) {
67
- border-color: ${Et};
68
- box-shadow: ${Lt};
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: ${Re};
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 ${de};
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
- }`, Ae = "malachite-card-strip-style", xe = () => typeof window > "u" || typeof window.matchMedia != "function" ? !0 : window.matchMedia("(prefers-reduced-motion: reduce)").matches, A = (t) => t.dataset.value ?? t.getAttribute("value"), Q = (t) => t.hasAttribute("disabled") || t.getAttribute("aria-disabled") === "true", Se = (t) => {
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(Ot);
100
- }, Ee = (t, r) => {
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(Ot))
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
- t.hasAttribute(w) || t.setAttribute(w, t.getAttribute("tabindex") ?? ""), t.setAttribute("tabindex", "-1");
115
+ const r = Ee(t);
116
+ return r ? Array.from(r.querySelectorAll(ee)) : [];
119
117
  }, Te = (t) => {
120
- if (!t.hasAttribute(w))
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(w);
123
- t.removeAttribute(w), r ? t.setAttribute("tabindex", r) : t.removeAttribute("tabindex");
124
- }, ve = {
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
- }, ye = {
128
+ }, De = {
129
129
  backgroundRepeat: "no-repeat",
130
130
  backgroundPosition: "left bottom",
131
- backgroundSize: `100% ${nt}px`
132
- }, Tt = 0.5, vt = m - tt, De = (t) => {
133
- const r = t.querySelector(`:scope > .${Yt}`);
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 + vt, right: s - vt };
138
- }, Oe = (t, r, c, s) => {
137
+ return { left: c + Dt, right: s - Dt };
138
+ }, we = (t, r, c, s) => {
139
139
  if (!t)
140
140
  return;
141
- const i = ve[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 ? De(c) : null, V = (g == null ? void 0 : g.left) ?? (E ? E.left - tt : 0), z = (g == null ? void 0 : g.right) ?? (E ? E.right + tt : 0), y = E ? Math.max(V, k.left) + Tt - v : 0, b = E ? Math.min(z, k.right) - Tt - v : 0;
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(${mt} * -1)`,
145
- paddingInline: mt
146
- }, Y = {
147
- background: et,
148
- borderRadius: ie,
149
- paddingTop: `${M}px`,
150
- paddingInline: `${M}px`,
151
- marginBottom: `${nt}px`
152
- }, we = {
153
- ...Y,
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
- }, Ie = Object.fromEntries(
155
+ }, Pe = Object.fromEntries(
156
156
  [T, P].flatMap(
157
157
  (t) => [T, P].map((r) => [
158
158
  `${t}:${r}`,
159
- { ...Y, marginInline: `${t}px ${r}px` }
159
+ { ...z, marginInline: `${t}px ${r}px` }
160
160
  ])
161
161
  )
162
- ), Pe = Y, ke = Y, Ne = {
162
+ ), ke = z, Ne = z, Ue = {
163
163
  marginInlineStart: `${T}px`
164
- }, Ue = {
164
+ }, Be = {
165
165
  primary: {
166
- backgroundColor: be,
167
- color: me
166
+ backgroundColor: Re,
167
+ color: ge
168
168
  },
169
- secondary: { backgroundColor: pe, color: he }
170
- }, wt = ({
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
- ...Pe,
184
- width: `${le}px`,
185
- height: `calc(100% - ${nt}px)`
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__ */ X(
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: Ue[i],
194
- className: `${Kt} 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}`,
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(Xt, { size: 13 }) }),
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
- ), rt = (t) => $.isValidElement(t) && t.type === wt, Be = (t) => $.isValidElement(t) && t.type === $.Fragment && $.Children.toArray(t.props.children).some(rt), yt = ({ side: t, onClick: r }) => /* @__PURE__ */ u(
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]: `-${oe}px`,
213
- background: ae,
214
- border: `1px solid ${ce}`,
215
- boxShadow: Ct
212
+ [t]: `-${ce}px`,
213
+ background: se,
214
+ border: `1px solid ${ie}`,
215
+ boxShadow: It
216
216
  },
217
- children: t === "left" ? /* @__PURE__ */ u(Ft, { size: gt }) : /* @__PURE__ */ u(Ht, { size: gt })
217
+ children: t === "left" ? /* @__PURE__ */ u(Xt, { size: _t }) : /* @__PURE__ */ u(Wt, { size: _t })
218
218
  }
219
- ), Ge = ({
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": V,
231
- "aria-labelledby": z,
230
+ "aria-label": K,
231
+ "aria-labelledby": j,
232
232
  className: y = "",
233
233
  style: b
234
234
  }) => {
235
- const D = Z(null), O = Z(null), [N, It] = bt({ canScrollLeft: !1, canScrollRight: !1 });
236
- jt(D, _e, Ae);
237
- const K = $.Children.toArray(s), j = K.filter((e) => !rt(e)), Pt = j.some(Be), U = j.length > 0, ot = K.filter(rt).map(
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
- ), at = K.length, _ = L(() => {
239
+ ), st = q.length, _ = L(() => {
240
240
  const e = D.current;
241
241
  return e ? Array.from(e.querySelectorAll(I)) : [];
242
- }, []), q = L(
242
+ }, []), J = L(
243
243
  () => _().filter((e) => A(e) !== null),
244
244
  [_]
245
- ), ct = Z(/* @__PURE__ */ new Set()), C = L((e, n) => {
246
- ct.current.has(e) || (ct.current.add(e), console.warn(n));
247
- }, []), [kt, Nt] = bt("profile");
248
- F(() => {
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") && Nt(e);
252
- }, [_, t]), F(() => {
253
- const e = _(), n = q(), d = n.find((o) => A(o) === t) ?? n.find((o) => !Q(o)) ?? null;
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 ht of Le(o))
258
- h ? Te(ht) : $e(ht);
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 && C(
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) && C(
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) && C(
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 && C(
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
- ), Pt && C(
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
- }), F(() => {
288
+ }), X(() => {
289
289
  if (!g)
290
290
  return;
291
- const e = O.current, n = _().find((G) => A(G) === t);
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 || e.scrollTo({
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, at]);
300
- const st = r ?? kt, it = (b == null ? void 0 : b.background) !== void 0 || (b == null ? void 0 : b.backgroundImage) !== void 0, B = L(() => {
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 (it || Oe(
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
- st
307
+ lt
308
308
  ), !e)
309
309
  return;
310
- const { scrollWidth: n, clientWidth: a, scrollLeft: d } = e, l = n > a + J, p = {
311
- canScrollLeft: l && d > J,
312
- canScrollRight: l && d + a < n - J
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
- It(
314
+ kt(
315
315
  (o) => o.canScrollLeft === p.canScrollLeft && o.canScrollRight === p.canScrollRight ? o : p
316
316
  );
317
- }, [it, _, st, t]);
318
- F(() => {
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, at]);
330
- const lt = L((e) => {
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 * ee(n),
334
- behavior: xe() ? "auto" : "smooth"
333
+ left: e * ne(n),
334
+ behavior: vt() ? "auto" : "smooth"
335
335
  });
336
- }, []), Ut = L(
336
+ }, []), Gt = L(
337
337
  (e) => {
338
- if (!qt.has(e.key))
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 = q().filter((o) => !Q(o));
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
- [q, c, t]
361
- ), Bt = L(
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 = Ee(n, a);
370
- if (!d || Q(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
- ), dt = S && N.canScrollLeft, ut = S && N.canScrollRight, ft = v && N.canScrollLeft, pt = v && N.canScrollRight, Gt = S ? Ie[`${dt ? P : T}:${ut ? P : T}`] : we;
377
- return /* @__PURE__ */ X(
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: Ut,
382
- onClick: Bt,
383
- className: `${W} flex items-stretch ${y}`,
381
+ onKeyDown: Gt,
382
+ onClick: Ft,
383
+ className: `${Y} flex items-stretch ${y}`,
384
384
  style: {
385
- ...ye,
385
+ ...De,
386
386
  ...E ? Ce : null,
387
387
  ...b
388
388
  },
389
389
  children: [
390
- /* @__PURE__ */ X(
390
+ /* @__PURE__ */ M(
391
391
  "div",
392
392
  {
393
393
  role: "radiogroup",
394
- "aria-label": V,
395
- "aria-labelledby": z,
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(Rt.Provider, { value: Vt, children: /* @__PURE__ */ u("div", { className: "shrink-0", style: ke, children: i }) }) : null,
399
- U ? /* @__PURE__ */ X(
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
- [Jt]: "",
402
+ [te]: "",
403
403
  className: "relative min-w-0 shrink basis-auto",
404
- style: Gt,
404
+ style: Ht,
405
405
  children: [
406
406
  /* @__PURE__ */ u(
407
407
  "div",
408
408
  {
409
409
  ref: O,
410
410
  tabIndex: -1,
411
- [Zt]: "",
411
+ [Qt]: "",
412
412
  "data-snap": k ? "true" : "false",
413
413
  className: R,
414
- children: /* @__PURE__ */ u(Rt.Provider, { value: zt, children: j })
414
+ children: /* @__PURE__ */ u(gt.Provider, { value: jt, children: Z })
415
415
  }
416
416
  ),
417
- dt ? /* @__PURE__ */ u(yt, { side: "left", onClick: () => lt(-1) }) : null,
418
- ut ? /* @__PURE__ */ u(yt, { side: "right", onClick: () => lt(1) }) : null,
419
- ft || pt ? /* @__PURE__ */ u(
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: `${Dt} absolute pointer-events-none`,
424
+ className: `${wt} absolute pointer-events-none`,
425
425
  style: {
426
- inset: `-${M}px -${m}px 0`,
427
- background: `linear-gradient(to right, ${ft ? St : "transparent"} 0, transparent ${xt}px, transparent calc(100% - ${xt}px), ${pt ? St : "transparent"} 100%)`
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
- ot.length > 0 ? /* @__PURE__ */ u(
437
+ ct.length > 0 ? /* @__PURE__ */ u(
438
438
  "div",
439
439
  {
440
440
  className: "shrink-0",
441
- style: !U && i ? Ne : void 0,
442
- children: ot
441
+ style: !U && i ? Ue : void 0,
442
+ children: ct
443
443
  }
444
444
  ) : null
445
445
  ]
446
446
  }
447
447
  );
448
448
  };
449
- Ge.AddTile = wt;
449
+ Fe.AddTile = Pt;
450
450
  export {
451
- Ge as CardStrip,
452
- Ge as default
451
+ Fe as CardStrip,
452
+ Fe as default
453
453
  };
454
454
  //# sourceMappingURL=CardStrip.js.map