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