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