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