@stackone/malachite 2.37.0 → 2.38.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 +7 -2
- package/dist/assets/icons/account.svg.js +2 -2
- package/dist/assets/icons/account.svg.js.map +1 -1
- package/dist/assets/icons/building.svg.js +6 -0
- package/dist/assets/icons/building.svg.js.map +1 -0
- package/dist/assets/icons/chevrons_up_down.svg.js +6 -0
- package/dist/assets/icons/chevrons_up_down.svg.js.map +1 -0
- package/dist/assets/icons/connector.svg.js +6 -0
- package/dist/assets/icons/connector.svg.js.map +1 -0
- package/dist/assets/icons/external_link.svg.js +6 -0
- package/dist/assets/icons/external_link.svg.js.map +1 -0
- package/dist/assets/icons/field_coverage.svg.js +6 -0
- package/dist/assets/icons/field_coverage.svg.js.map +1 -0
- package/dist/assets/icons/layout.svg.js +6 -0
- package/dist/assets/icons/layout.svg.js.map +1 -0
- package/dist/assets/icons/link.svg.js +6 -0
- package/dist/assets/icons/link.svg.js.map +1 -0
- package/dist/assets/icons/playground.svg.js +6 -0
- package/dist/assets/icons/playground.svg.js.map +1 -0
- package/dist/components/ActionMenu.js +139 -170
- package/dist/components/ActionMenu.js.map +1 -1
- package/dist/components/CardStrip.js +195 -190
- package/dist/components/CardStrip.js.map +1 -1
- package/dist/components/Chat/ChatModelPicker.js +64 -60
- package/dist/components/Chat/ChatModelPicker.js.map +1 -1
- package/dist/components/CustomIcons/BuildingIcon.js +16 -0
- package/dist/components/CustomIcons/BuildingIcon.js.map +1 -0
- package/dist/components/CustomIcons/ChevronsUpDownIcon.js +16 -0
- package/dist/components/CustomIcons/ChevronsUpDownIcon.js.map +1 -0
- package/dist/components/CustomIcons/ConnectorIcon.js +16 -0
- package/dist/components/CustomIcons/ConnectorIcon.js.map +1 -0
- package/dist/components/CustomIcons/ExternalLinkIcon.js +16 -0
- package/dist/components/CustomIcons/ExternalLinkIcon.js.map +1 -0
- package/dist/components/CustomIcons/FieldCoverageIcon.js +16 -0
- package/dist/components/CustomIcons/FieldCoverageIcon.js.map +1 -0
- package/dist/components/CustomIcons/LayoutIcon.js +16 -0
- package/dist/components/CustomIcons/LayoutIcon.js.map +1 -0
- package/dist/components/CustomIcons/LinkIcon.js +16 -0
- package/dist/components/CustomIcons/LinkIcon.js.map +1 -0
- package/dist/components/CustomIcons/PlaygroundIcon.js +16 -0
- package/dist/components/CustomIcons/PlaygroundIcon.js.map +1 -0
- package/dist/components/CustomIcons/index.js +303 -279
- package/dist/components/CustomIcons/index.js.map +1 -1
- package/dist/components/NavItem.js +158 -0
- package/dist/components/NavItem.js.map +1 -0
- package/dist/components/Popover.js +262 -0
- package/dist/components/Popover.js.map +1 -0
- package/dist/components/PopoverParts.js +46 -0
- package/dist/components/PopoverParts.js.map +1 -0
- package/dist/components/QueryInput.js +103 -97
- package/dist/components/QueryInput.js.map +1 -1
- package/dist/components/SearchTrigger.js +37 -0
- package/dist/components/SearchTrigger.js.map +1 -0
- package/dist/components/Sidebar.js +174 -0
- package/dist/components/Sidebar.js.map +1 -0
- package/dist/components/Tooltip.js +97 -92
- package/dist/components/Tooltip.js.map +1 -1
- package/dist/components/UsageCard.js +44 -0
- package/dist/components/UsageCard.js.map +1 -0
- package/dist/components/actionMenuKeyboard.js +23 -0
- package/dist/components/actionMenuKeyboard.js.map +1 -0
- package/dist/components/actionMenuStyles.js +83 -0
- package/dist/components/actionMenuStyles.js.map +1 -0
- package/dist/components/ariaState.js +5 -0
- package/dist/components/ariaState.js.map +1 -0
- package/dist/components/chromeStyles.js +6 -0
- package/dist/components/chromeStyles.js.map +1 -0
- package/dist/components/composeRefs.js +27 -0
- package/dist/components/composeRefs.js.map +1 -0
- package/dist/components/floatingMenuGeometry.js +74 -35
- package/dist/components/floatingMenuGeometry.js.map +1 -1
- package/dist/components/overlayBehaviour.js +90 -84
- package/dist/components/overlayBehaviour.js.map +1 -1
- package/dist/components/popoverTree.js +14 -0
- package/dist/components/popoverTree.js.map +1 -0
- package/dist/components/portalOverlay.js +28 -22
- package/dist/components/portalOverlay.js.map +1 -1
- package/dist/components/sidebarContext.js +9 -0
- package/dist/components/sidebarContext.js.map +1 -0
- package/dist/components/topLayer.js +18 -18
- package/dist/components/topLayer.js.map +1 -1
- package/dist/components/useActionMenuPosition.js +73 -0
- package/dist/components/useActionMenuPosition.js.map +1 -0
- package/dist/components/useHoverClose.js +18 -0
- package/dist/components/useHoverClose.js.map +1 -0
- package/dist/components/useLatestRef.js +11 -0
- package/dist/components/useLatestRef.js.map +1 -0
- package/dist/components/usePopoverPosition.js +62 -0
- package/dist/components/usePopoverPosition.js.map +1 -0
- package/dist/components/usePopoverTree.js +34 -0
- package/dist/components/usePopoverTree.js.map +1 -0
- package/dist/index.d.ts +387 -100
- package/dist/index.js +365 -335
- package/dist/index.js.map +1 -1
- package/dist/tailwind.css.js +1 -1
- package/package.json +1 -1
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { jsxs as U, jsx as h } from "react/jsx-runtime";
|
|
2
|
-
import C, { useRef as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { CONTENT_INSET as
|
|
7
|
-
import { STRIP_RULE_PX as
|
|
8
|
-
import { revealTargetFor as
|
|
9
|
-
import { CardStripSlotContext as
|
|
10
|
-
import { FOCUS_RING as
|
|
11
|
-
import { useAdoptedStyleSheet as
|
|
12
|
-
const
|
|
13
|
-
.${
|
|
14
|
-
clip-path: inset(-${
|
|
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
|
-
.${
|
|
17
|
-
clip-path: inset(-${
|
|
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: ${
|
|
28
|
-
margin-block: -${
|
|
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: ${
|
|
32
|
-
margin-inline: -${
|
|
33
|
-
scroll-padding-inline: ${
|
|
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
|
-
.${
|
|
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: ${
|
|
45
|
-
border-radius: ${
|
|
44
|
+
background: ${lt};
|
|
45
|
+
border-radius: ${Le};
|
|
46
46
|
}
|
|
47
47
|
.${R}:hover:not(:has(button:disabled)) > * {
|
|
48
|
-
background: ${
|
|
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: ${
|
|
54
|
+
background: ${lt};
|
|
55
55
|
}
|
|
56
56
|
.${R}[data-emphasis='secondary'] button {
|
|
57
|
-
border-color: ${
|
|
58
|
-
box-shadow: ${
|
|
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: ${
|
|
62
|
-
box-shadow: ${
|
|
61
|
+
border-color: ${Ft};
|
|
62
|
+
box-shadow: ${Ut};
|
|
63
63
|
}
|
|
64
64
|
.${R}[data-emphasis='secondary'] button:active:not(:disabled) {
|
|
65
|
-
border-color: ${
|
|
66
|
-
box-shadow: ${
|
|
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: ${
|
|
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 ${
|
|
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
|
-
}`,
|
|
96
|
-
.${g} > [${
|
|
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
|
-
[${
|
|
100
|
+
[${it}] > .${R} {
|
|
101
101
|
height: 100% !important;
|
|
102
102
|
padding: 0 !important;
|
|
103
103
|
}
|
|
104
|
-
`,
|
|
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(
|
|
107
|
-
},
|
|
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(
|
|
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
|
-
},
|
|
122
|
-
const a =
|
|
123
|
-
return a ? Array.from(a.querySelectorAll(
|
|
124
|
-
},
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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
|
-
},
|
|
135
|
+
}, Ve = {
|
|
136
136
|
backgroundRepeat: "no-repeat",
|
|
137
137
|
backgroundPosition: "left bottom",
|
|
138
|
-
backgroundSize: `100% ${
|
|
139
|
-
},
|
|
140
|
-
const a = e.querySelector(`:scope > .${
|
|
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 +
|
|
145
|
-
},
|
|
144
|
+
return { left: l + Xt, right: u - Xt };
|
|
145
|
+
}, qe = (e, a, l, u) => {
|
|
146
146
|
if (!e)
|
|
147
147
|
return;
|
|
148
|
-
const f =
|
|
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
|
-
},
|
|
151
|
-
marginInline: `calc(${
|
|
152
|
-
paddingInline:
|
|
153
|
-
},
|
|
154
|
-
background:
|
|
155
|
-
borderRadius:
|
|
156
|
-
paddingTop: `${
|
|
157
|
-
paddingInline: `${
|
|
158
|
-
marginBottom: `${
|
|
159
|
-
},
|
|
160
|
-
...
|
|
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
|
-
},
|
|
162
|
+
}, Je = pt, Qe = pt, Ze = {
|
|
163
163
|
marginInlineStart: `${H}px`
|
|
164
|
-
},
|
|
164
|
+
}, tr = {
|
|
165
165
|
primary: {
|
|
166
|
-
backgroundColor:
|
|
167
|
-
color:
|
|
166
|
+
backgroundColor: Ce,
|
|
167
|
+
color: Ie
|
|
168
168
|
},
|
|
169
|
-
secondary: { backgroundColor:
|
|
170
|
-
},
|
|
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:
|
|
176
|
+
className: $ = ""
|
|
177
177
|
}) => /* @__PURE__ */ h(
|
|
178
178
|
"div",
|
|
179
179
|
{
|
|
180
180
|
className: R,
|
|
181
181
|
"data-emphasis": f,
|
|
182
182
|
style: {
|
|
183
|
-
...
|
|
184
|
-
width: `${
|
|
185
|
-
height: `calc(100% - ${
|
|
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:
|
|
194
|
-
className: `${
|
|
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(
|
|
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
|
-
),
|
|
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]: `-${
|
|
213
|
-
background:
|
|
214
|
-
border: `1px solid ${
|
|
215
|
-
boxShadow:
|
|
212
|
+
[e]: `-${Te}px`,
|
|
213
|
+
background: Se,
|
|
214
|
+
border: `1px solid ${xe}`,
|
|
215
|
+
boxShadow: Vt
|
|
216
216
|
},
|
|
217
|
-
children: e === "left" ? /* @__PURE__ */ h(
|
|
217
|
+
children: e === "left" ? /* @__PURE__ */ h(ae, { size: Ct }) : /* @__PURE__ */ h(ce, { size: Ct })
|
|
218
218
|
}
|
|
219
|
-
),
|
|
219
|
+
), rr = ({
|
|
220
220
|
value: e,
|
|
221
221
|
tone: a,
|
|
222
222
|
onChange: l,
|
|
223
223
|
children: u,
|
|
224
224
|
leading: f,
|
|
225
|
-
arrows:
|
|
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":
|
|
231
|
-
"aria-labelledby":
|
|
230
|
+
"aria-label": J,
|
|
231
|
+
"aria-labelledby": Q,
|
|
232
232
|
className: P = "",
|
|
233
233
|
style: b
|
|
234
234
|
}) => {
|
|
235
|
-
const
|
|
236
|
-
|
|
237
|
-
const
|
|
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
|
-
),
|
|
240
|
-
|
|
241
|
-
const t =
|
|
242
|
-
if (!t || !D ||
|
|
243
|
-
|
|
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 =
|
|
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
|
|
250
|
-
|
|
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((
|
|
254
|
-
var E,
|
|
255
|
-
for (const V of
|
|
256
|
-
V.target === t ? d = V.contentRect.width : p = ((
|
|
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,
|
|
261
|
-
const
|
|
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
|
-
|
|
264
|
+
gt.current = !!(r instanceof Node && ((o = W.current) != null && o.contains(r)));
|
|
265
265
|
}, []);
|
|
266
|
-
|
|
266
|
+
v(() => {
|
|
267
267
|
var o;
|
|
268
268
|
const t = W.current, r = t ? t.getRootNode().activeElement : null;
|
|
269
|
-
|
|
270
|
-
}, [
|
|
271
|
-
const A =
|
|
272
|
-
const t =
|
|
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
|
-
}, []),
|
|
275
|
-
|
|
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
|
-
),
|
|
278
|
-
|
|
279
|
-
}, []), [
|
|
280
|
-
|
|
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) =>
|
|
283
|
-
(t === "profile" || t === "library" || t === "editing") &&
|
|
284
|
-
}, [A, e]),
|
|
285
|
-
const t = A(), r =
|
|
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,
|
|
288
|
-
n.tabIndex !==
|
|
289
|
-
for (const E of
|
|
290
|
-
c ?
|
|
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 =
|
|
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
|
-
),
|
|
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 =
|
|
322
|
-
const t = A().find((r) =>
|
|
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
|
-
|
|
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 =
|
|
332
|
-
|
|
333
|
-
const s =
|
|
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 && !
|
|
341
|
+
behavior: o && !Gt() ? "smooth" : "instant"
|
|
337
342
|
});
|
|
338
|
-
}, [F, m, _,
|
|
339
|
-
const
|
|
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 (
|
|
343
|
-
|
|
347
|
+
if (Lt || qe(
|
|
348
|
+
y.current,
|
|
344
349
|
t,
|
|
345
|
-
(p = A().find((n) =>
|
|
346
|
-
|
|
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 +
|
|
350
|
-
canScrollLeft: i && s >
|
|
351
|
-
canScrollRight: i && s + o < r -
|
|
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
|
-
|
|
358
|
+
Kt(
|
|
354
359
|
(n) => n.canScrollLeft === d.canScrollLeft && n.canScrollRight === d.canScrollRight ? n : d
|
|
355
360
|
);
|
|
356
|
-
}, [
|
|
357
|
-
|
|
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 &&
|
|
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 ?
|
|
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, _,
|
|
386
|
-
const
|
|
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:
|
|
391
|
-
behavior:
|
|
395
|
+
left: ue(r, t, _) - r.scrollLeft,
|
|
396
|
+
behavior: Gt() ? "auto" : "smooth"
|
|
392
397
|
});
|
|
393
398
|
},
|
|
394
399
|
[_]
|
|
395
|
-
),
|
|
400
|
+
), ee = x(
|
|
396
401
|
(t) => {
|
|
397
|
-
if (!
|
|
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 =
|
|
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) =>
|
|
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 =
|
|
421
|
+
const d = o[i], p = S(d);
|
|
417
422
|
p !== null && p !== e && l(p), d.focus();
|
|
418
423
|
},
|
|
419
|
-
[
|
|
420
|
-
),
|
|
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 =
|
|
430
|
+
const o = y.current;
|
|
426
431
|
if (!o)
|
|
427
432
|
return;
|
|
428
|
-
const s =
|
|
429
|
-
if (!s ||
|
|
433
|
+
const s = He(r, o);
|
|
434
|
+
if (!s || ct(s))
|
|
430
435
|
return;
|
|
431
|
-
const i =
|
|
436
|
+
const i = S(s);
|
|
432
437
|
i !== null && i !== e && l(i);
|
|
433
438
|
},
|
|
434
439
|
[l, e]
|
|
435
|
-
),
|
|
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:
|
|
441
|
-
onFocus:
|
|
442
|
-
onBlur:
|
|
443
|
-
onClick:
|
|
444
|
-
className: `${
|
|
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
|
-
...
|
|
447
|
-
...L ?
|
|
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":
|
|
456
|
-
"aria-labelledby":
|
|
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(
|
|
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
|
-
[
|
|
468
|
+
[Re]: "",
|
|
464
469
|
className: "relative min-w-0 shrink basis-auto",
|
|
465
|
-
style:
|
|
470
|
+
style: je,
|
|
466
471
|
children: [
|
|
467
472
|
/* @__PURE__ */ U(
|
|
468
473
|
"div",
|
|
469
474
|
{
|
|
470
475
|
ref: k,
|
|
471
476
|
tabIndex: -1,
|
|
472
|
-
[
|
|
477
|
+
[ge]: "",
|
|
473
478
|
"data-snap": _ ? "true" : "false",
|
|
474
479
|
className: g,
|
|
475
480
|
children: [
|
|
476
|
-
/* @__PURE__ */ h(
|
|
477
|
-
|
|
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
|
-
|
|
482
|
-
|
|
483
|
-
|
|
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: `${
|
|
493
|
+
className: `${zt} absolute pointer-events-none`,
|
|
489
494
|
style: {
|
|
490
|
-
inset: `-${
|
|
491
|
-
background: `linear-gradient(to right, ${
|
|
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 && !
|
|
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 ?
|
|
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
|
-
|
|
519
|
+
rr.AddTile = qt;
|
|
515
520
|
export {
|
|
516
|
-
|
|
517
|
-
|
|
521
|
+
rr as CardStrip,
|
|
522
|
+
rr as default
|
|
518
523
|
};
|
|
519
524
|
//# sourceMappingURL=CardStrip.js.map
|