@stackone/malachite 2.26.0 → 2.27.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.
- package/COMPONENTS.md +1 -1
- package/dist/components/ChangeReview/ChangeReviewItem.js +96 -88
- package/dist/components/ChangeReview/ChangeReviewItem.js.map +1 -1
- package/dist/components/Chat/ChatMessage.js +11 -11
- package/dist/components/Chat/ChatMessage.js.map +1 -1
- package/dist/components/Dropdown.js +188 -195
- package/dist/components/Dropdown.js.map +1 -1
- package/dist/components/MultiSelect.js +412 -382
- package/dist/components/MultiSelect.js.map +1 -1
- package/dist/components/truncatedLines.js +16 -0
- package/dist/components/truncatedLines.js.map +1 -0
- package/dist/index.d.ts +13 -1
- package/dist/tailwind.css.js +1 -1
- package/package.json +1 -1
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { jsx as t, jsxs as b, Fragment as ye } from "react/jsx-runtime";
|
|
2
|
-
import He, { useState as j, useRef as
|
|
2
|
+
import He, { useState as j, useRef as g, useEffect as Le, useCallback as Ce, useLayoutEffect as Qe, useInsertionEffect as Ye, useId as Je } from "react";
|
|
3
3
|
import { createPortal as et } from "react-dom";
|
|
4
4
|
import tt, { useFormFieldIds as rt } from "./BaseFormComponent.js";
|
|
5
5
|
import ze from "./CustomIcons/CaretDownIcon.js";
|
|
6
6
|
import je from "./CustomIcons/CloseIcon.js";
|
|
7
7
|
import { FieldMessage as nt } from "./FieldMessage.js";
|
|
8
|
-
import
|
|
8
|
+
import Pe from "./LoadingInput.js";
|
|
9
9
|
import it from "./Spinner.js";
|
|
10
10
|
import be from "./Tooltip.js";
|
|
11
|
-
import { CONTROL_TEXT_SIZE_CLASS as
|
|
12
|
-
import { controlWidthStyle as
|
|
11
|
+
import { CONTROL_TEXT_SIZE_CLASS as Y, CONTROL_TEXT_SIZE as at } from "./controlTextSize.js";
|
|
12
|
+
import { controlWidthStyle as We } from "./controlWidth.js";
|
|
13
13
|
import { getTriggerVisual as ot, DROPDOWN_TRIGGER_ATTR as Me } from "./dropdownTriggerStyle.js";
|
|
14
14
|
import { pushEscapeLayer as lt } from "./escapeLayers.js";
|
|
15
15
|
import { measureMenuGeometry as st, isTriggerOffscreen as ct, rectSignature as dt, MENU_MAX_HEIGHT_PX as ut, MENU_SPECS as oe } from "./floatingMenuGeometry.js";
|
|
16
16
|
import { ensureDropdownPanelStyles as pt } from "./optionRowStyles.js";
|
|
17
17
|
import { overlayIdentity as ft } from "./portalOverlay.js";
|
|
18
18
|
import { useTopLayer as ht } from "./topLayer.js";
|
|
19
|
+
import { tooltipLines as Ze, isCut as le } from "./truncatedLines.js";
|
|
19
20
|
const Fe = {
|
|
20
21
|
display: "flex",
|
|
21
22
|
alignItems: "center",
|
|
@@ -23,21 +24,21 @@ const Fe = {
|
|
|
23
24
|
gap: 8,
|
|
24
25
|
padding: "24px 16px",
|
|
25
26
|
color: "var(--malachite-text-dimmed, rgb(161, 161, 161))"
|
|
26
|
-
},
|
|
27
|
-
const r = i.toLowerCase(),
|
|
28
|
-
return
|
|
29
|
-
},
|
|
27
|
+
}, Re = "var(--malachite-font-size-xsmall, 11px)", gt = "[data-dropdown-option]", Ne = (e) => Array.from((e == null ? void 0 : e.querySelectorAll(gt)) ?? []), mt = (e, i) => {
|
|
28
|
+
const r = i.toLowerCase(), m = e.label.toLowerCase().includes(r), c = e.subtitle ? e.subtitle.toLowerCase().includes(r) : !1, y = e.rightSideText ? e.rightSideText.toLowerCase().includes(r) : !1;
|
|
29
|
+
return m || c || y;
|
|
30
|
+
}, se = {
|
|
30
31
|
small: "h-[var(--malachite-control-height-small,28px)]",
|
|
31
32
|
medium: "h-[var(--malachite-control-height-medium,32px)]",
|
|
32
33
|
large: "h-[var(--malachite-control-height-large,42px)]"
|
|
33
34
|
}, xt = {
|
|
34
|
-
small: `${
|
|
35
|
-
medium: `${
|
|
36
|
-
large: `${
|
|
35
|
+
small: `${se.small} px-2.5 py-1.5 ${Y.small}`,
|
|
36
|
+
medium: `${se.medium} px-3 py-1.5 ${Y.medium}`,
|
|
37
|
+
large: `${se.large} px-4 py-2.5 ${Y.large}`
|
|
37
38
|
}, vt = {
|
|
38
|
-
small: `min-h-[var(--malachite-control-height-small,28px)] px-2.5 py-1.5 ${
|
|
39
|
-
medium: `min-h-[var(--malachite-control-height-medium,32px)] px-3 py-1.5 ${
|
|
40
|
-
large: `min-h-[var(--malachite-control-height-large,42px)] px-4 py-2.5 ${
|
|
39
|
+
small: `min-h-[var(--malachite-control-height-small,28px)] px-2.5 py-1.5 ${Y.small}`,
|
|
40
|
+
medium: `min-h-[var(--malachite-control-height-medium,32px)] px-3 py-1.5 ${Y.medium}`,
|
|
41
|
+
large: `min-h-[var(--malachite-control-height-large,42px)] px-4 py-2.5 ${Y.large}`
|
|
41
42
|
}, bt = {
|
|
42
43
|
small: "right-[26px] size-4",
|
|
43
44
|
medium: "right-[30px] size-4",
|
|
@@ -50,69 +51,61 @@ const Fe = {
|
|
|
50
51
|
small: "rounded-[var(--malachite-radius-10,10px)]",
|
|
51
52
|
medium: "rounded-xl",
|
|
52
53
|
large: "rounded-[var(--malachite-radius-xxl,14px)]"
|
|
53
|
-
}, Ge = () => !1,
|
|
54
|
-
display: "flex",
|
|
55
|
-
flexDirection: "column",
|
|
56
|
-
gap: 4
|
|
57
|
-
}, Ze = (e) => {
|
|
58
|
-
var r;
|
|
59
|
-
const i = e.filter(([, d]) => !!d);
|
|
60
|
-
return i.length < 2 ? (r = i[0]) == null ? void 0 : r[1] : /* @__PURE__ */ t("span", { style: St, children: i.map(([d, l]) => /* @__PURE__ */ t("span", { children: l }, d)) });
|
|
61
|
-
}, Tt = ({
|
|
54
|
+
}, Ge = () => !1, St = ({
|
|
62
55
|
wrap: e,
|
|
63
56
|
id: i,
|
|
64
57
|
children: r
|
|
65
|
-
}) => e ? /* @__PURE__ */ t("span", { id: i, className: "min-w-0 flex items-center gap-2", children: r }) : /* @__PURE__ */ t(ye, { children: r }),
|
|
58
|
+
}) => e ? /* @__PURE__ */ t("span", { id: i, className: "min-w-0 flex items-center gap-2", children: r }) : /* @__PURE__ */ t(ye, { children: r }), Tt = ({ row: e, children: i }) => e ? /* @__PURE__ */ t("span", { style: { display: "flex", alignItems: "center", gap: 8, minWidth: 0 }, children: i }) : /* @__PURE__ */ t(ye, { children: i }), Ke = He.forwardRef(
|
|
66
59
|
({
|
|
67
60
|
isOpen: e,
|
|
68
61
|
onClick: i,
|
|
69
62
|
selectedItem: r,
|
|
70
|
-
disabled:
|
|
71
|
-
error:
|
|
63
|
+
disabled: m = !1,
|
|
64
|
+
error: c = !1,
|
|
72
65
|
tone: y,
|
|
73
66
|
placeholder: N,
|
|
74
67
|
search: x = !1,
|
|
75
68
|
showSubtitleInTrigger: w = !1,
|
|
76
69
|
searchQuery: k = "",
|
|
77
70
|
onSearchChange: E,
|
|
78
|
-
onFocusOpen:
|
|
71
|
+
onFocusOpen: R,
|
|
79
72
|
onArrowDown: S,
|
|
80
73
|
size: v = "large",
|
|
81
74
|
hasClear: $ = !1,
|
|
82
75
|
onClear: a,
|
|
83
|
-
clearLabel:
|
|
84
|
-
controlId:
|
|
76
|
+
clearLabel: f,
|
|
77
|
+
controlId: s,
|
|
85
78
|
labelId: o,
|
|
86
79
|
describedBy: C,
|
|
87
|
-
required:
|
|
80
|
+
required: l = !1,
|
|
88
81
|
ariaLabel: D,
|
|
89
82
|
ariaLabelledBy: ce,
|
|
90
83
|
hasCallerId: we = !1
|
|
91
84
|
}, _) => {
|
|
92
|
-
const Z = w && !x && !!(r != null && r.subtitle),
|
|
93
|
-
|
|
94
|
-
},
|
|
95
|
-
const
|
|
96
|
-
return !
|
|
85
|
+
const Z = w && !x && !!(r != null && r.subtitle), K = Z ? vt[v] : xt[v], J = wt[v], O = `${s}-value`, de = `${s}-subtitle`, Se = !o && !D && !we && Z, ue = ce ?? (o && !D ? `${o} ${O}` : void 0) ?? (Se ? O : void 0), ee = (d) => {
|
|
86
|
+
d.key === "ArrowDown" && (d.preventDefault(), S == null || S());
|
|
87
|
+
}, q = g(null), te = g(null), B = ot({ disabled: m, error: c, tone: y, open: e }), L = !e && !!r, h = (r == null ? void 0 : r.triggerLabel) ?? (r == null ? void 0 : r.label), T = Z ? r == null ? void 0 : r.subtitle : void 0, z = () => le(q.current), [V, P] = j({ value: !1, subtitle: !0 }), pe = () => {
|
|
88
|
+
const d = z(), re = le(te.current);
|
|
89
|
+
return !d && !re ? !1 : (P({ value: d, subtitle: re }), !0);
|
|
97
90
|
};
|
|
98
|
-
if (x && !
|
|
91
|
+
if (x && !m)
|
|
99
92
|
return /* @__PURE__ */ b(
|
|
100
93
|
"div",
|
|
101
94
|
{
|
|
102
95
|
ref: _,
|
|
103
96
|
className: `
|
|
104
|
-
relative w-full ${
|
|
97
|
+
relative w-full ${K} ${J}
|
|
105
98
|
border border-solid
|
|
106
99
|
transition-all duration-200
|
|
107
100
|
flex items-center
|
|
108
101
|
`,
|
|
109
|
-
style:
|
|
102
|
+
style: B,
|
|
110
103
|
[Me]: "",
|
|
111
|
-
onClick: (
|
|
104
|
+
onClick: (d) => d.stopPropagation(),
|
|
112
105
|
children: [
|
|
113
106
|
(r == null ? void 0 : r.icon) && /* @__PURE__ */ t("span", { className: "flex shrink-0 items-center justify-center pr-2", children: r.icon }),
|
|
114
|
-
/* @__PURE__ */ t(be, { text:
|
|
115
|
-
|
|
107
|
+
/* @__PURE__ */ t(be, { text: h, shouldShow: z, isShrinkable: !0, fill: !0, children: /* @__PURE__ */ b("div", { className: "relative flex-1 flex items-center min-w-0", children: [
|
|
108
|
+
L && /* @__PURE__ */ t(
|
|
116
109
|
"span",
|
|
117
110
|
{
|
|
118
111
|
"aria-hidden": "true",
|
|
@@ -120,10 +113,10 @@ const Fe = {
|
|
|
120
113
|
children: /* @__PURE__ */ t(
|
|
121
114
|
"span",
|
|
122
115
|
{
|
|
123
|
-
ref:
|
|
116
|
+
ref: q,
|
|
124
117
|
className: `min-w-0 block truncate text-[length:inherit]
|
|
125
118
|
text-[var(--malachite-text-primary)]`,
|
|
126
|
-
children:
|
|
119
|
+
children: h
|
|
127
120
|
}
|
|
128
121
|
)
|
|
129
122
|
}
|
|
@@ -131,25 +124,25 @@ const Fe = {
|
|
|
131
124
|
/* @__PURE__ */ t(
|
|
132
125
|
"input",
|
|
133
126
|
{
|
|
134
|
-
id:
|
|
127
|
+
id: s,
|
|
135
128
|
type: "text",
|
|
136
129
|
"aria-label": D,
|
|
137
130
|
"aria-labelledby": ce,
|
|
138
|
-
"aria-invalid":
|
|
139
|
-
"aria-required":
|
|
131
|
+
"aria-invalid": c || void 0,
|
|
132
|
+
"aria-required": l || void 0,
|
|
140
133
|
"aria-describedby": C,
|
|
141
134
|
value: e ? k : (r == null ? void 0 : r.label) ?? "",
|
|
142
|
-
onChange: (
|
|
143
|
-
|
|
135
|
+
onChange: (d) => {
|
|
136
|
+
d.stopPropagation(), E == null || E(d.target.value), e || i();
|
|
144
137
|
},
|
|
145
138
|
onFocus: () => {
|
|
146
|
-
|
|
139
|
+
R == null || R();
|
|
147
140
|
},
|
|
148
141
|
onKeyDown: ee,
|
|
149
142
|
placeholder: N ?? "Select Field",
|
|
150
143
|
className: `flex-1 min-w-0 bg-transparent outline-none
|
|
151
144
|
text-[length:inherit] font-normal
|
|
152
|
-
placeholder:text-[var(--malachite-text-dimmed)] ${
|
|
145
|
+
placeholder:text-[var(--malachite-text-dimmed)] ${L ? "text-transparent" : "text-[var(--malachite-text-primary)]"}`
|
|
153
146
|
}
|
|
154
147
|
)
|
|
155
148
|
] }) }),
|
|
@@ -157,7 +150,7 @@ const Fe = {
|
|
|
157
150
|
"button",
|
|
158
151
|
{
|
|
159
152
|
type: "button",
|
|
160
|
-
"aria-label":
|
|
153
|
+
"aria-label": f,
|
|
161
154
|
onClick: a,
|
|
162
155
|
className: `flex shrink-0 items-center justify-center pl-2 cursor-pointer
|
|
163
156
|
bg-transparent border-none p-0 text-[var(--malachite-text-placeholder)]
|
|
@@ -172,8 +165,8 @@ const Fe = {
|
|
|
172
165
|
type: "button",
|
|
173
166
|
tabIndex: -1,
|
|
174
167
|
"aria-label": e ? "Close options" : "Open options",
|
|
175
|
-
onClick: (
|
|
176
|
-
|
|
168
|
+
onClick: (d) => {
|
|
169
|
+
d.stopPropagation(), i();
|
|
177
170
|
},
|
|
178
171
|
className: "flex items-center justify-center cursor-pointer bg-transparent border-none p-0",
|
|
179
172
|
children: /* @__PURE__ */ t(
|
|
@@ -196,22 +189,22 @@ const Fe = {
|
|
|
196
189
|
"button",
|
|
197
190
|
{
|
|
198
191
|
ref: _,
|
|
199
|
-
id:
|
|
192
|
+
id: s,
|
|
200
193
|
type: "button",
|
|
201
194
|
"aria-label": D,
|
|
202
195
|
"aria-labelledby": ue,
|
|
203
|
-
"aria-invalid":
|
|
204
|
-
"aria-required":
|
|
196
|
+
"aria-invalid": c || void 0,
|
|
197
|
+
"aria-required": l || void 0,
|
|
205
198
|
"aria-describedby": [C, T ? de : void 0].filter(Boolean).join(" ") || void 0,
|
|
206
|
-
onClick: (
|
|
207
|
-
|
|
199
|
+
onClick: (d) => {
|
|
200
|
+
d.stopPropagation(), i();
|
|
208
201
|
},
|
|
209
202
|
onKeyDown: ee,
|
|
210
|
-
disabled:
|
|
211
|
-
style:
|
|
203
|
+
disabled: m,
|
|
204
|
+
style: B,
|
|
212
205
|
[Me]: "",
|
|
213
206
|
className: `
|
|
214
|
-
relative w-full ${
|
|
207
|
+
relative w-full ${K} ${J}
|
|
215
208
|
border border-solid
|
|
216
209
|
transition-all duration-200
|
|
217
210
|
flex ${Z ? "items-start" : "items-center"} gap-3
|
|
@@ -225,21 +218,21 @@ const Fe = {
|
|
|
225
218
|
id: T ? void 0 : O,
|
|
226
219
|
className: `text-left flex-1 min-w-0 flex ${T ? "flex-col gap-1" : "items-center gap-2"}`,
|
|
227
220
|
children: r ? /* @__PURE__ */ b(ye, { children: [
|
|
228
|
-
/* @__PURE__ */ b(
|
|
221
|
+
/* @__PURE__ */ b(St, { wrap: !!T, id: O, children: [
|
|
229
222
|
r.icon && /* @__PURE__ */ t("span", { className: "flex items-center justify-center shrink-0", children: r.icon }),
|
|
230
223
|
/* @__PURE__ */ t(
|
|
231
224
|
be,
|
|
232
225
|
{
|
|
233
|
-
text:
|
|
226
|
+
text: h,
|
|
234
227
|
shouldShow: T ? Ge : z,
|
|
235
228
|
triggerAs: T ? "span" : "div",
|
|
236
229
|
isShrinkable: !0,
|
|
237
230
|
children: /* @__PURE__ */ t(
|
|
238
231
|
"span",
|
|
239
232
|
{
|
|
240
|
-
ref:
|
|
241
|
-
className: `min-w-0 block truncate text-[length:inherit] ${
|
|
242
|
-
children:
|
|
233
|
+
ref: q,
|
|
234
|
+
className: `min-w-0 block truncate text-[length:inherit] ${m ? "text-[var(--malachite-text-placeholder)]" : "text-[var(--malachite-text-primary)]"}`,
|
|
235
|
+
children: h
|
|
243
236
|
}
|
|
244
237
|
)
|
|
245
238
|
}
|
|
@@ -257,7 +250,7 @@ const Fe = {
|
|
|
257
250
|
] }) : /* @__PURE__ */ t(
|
|
258
251
|
"span",
|
|
259
252
|
{
|
|
260
|
-
className: `flex-1 min-w-0 truncate text-[length:inherit] ${
|
|
253
|
+
className: `flex-1 min-w-0 truncate text-[length:inherit] ${m ? "text-[var(--malachite-text-placeholder)]" : "text-[var(--malachite-text-dimmed)]"}`,
|
|
261
254
|
children: N ?? "Select Field"
|
|
262
255
|
}
|
|
263
256
|
)
|
|
@@ -282,8 +275,8 @@ const Fe = {
|
|
|
282
275
|
be,
|
|
283
276
|
{
|
|
284
277
|
text: Ze([
|
|
285
|
-
["value",
|
|
286
|
-
["subtitle",
|
|
278
|
+
["value", V.value && h],
|
|
279
|
+
["subtitle", V.subtitle && T]
|
|
287
280
|
]),
|
|
288
281
|
shouldShow: T ? pe : Ge,
|
|
289
282
|
fill: !0,
|
|
@@ -293,17 +286,17 @@ const Fe = {
|
|
|
293
286
|
) : fe;
|
|
294
287
|
}
|
|
295
288
|
);
|
|
296
|
-
|
|
297
|
-
const
|
|
289
|
+
Ke.displayName = "DropdownTrigger";
|
|
290
|
+
const Et = ({
|
|
298
291
|
item: e,
|
|
299
292
|
selected: i,
|
|
300
293
|
subtitleLayout: r,
|
|
301
|
-
onItemSelected:
|
|
294
|
+
onItemSelected: m
|
|
302
295
|
}) => {
|
|
303
|
-
const
|
|
304
|
-
const o =
|
|
305
|
-
return !o && !C && !
|
|
306
|
-
}, a = e.rightSideTextVariant === "primary" ? "var(--malachite-text-right-side-text-primary, rgb(10, 10, 10))" : "var(--malachite-text-right-side-text-muted, rgb(123, 123, 123))",
|
|
296
|
+
const c = i ? "var(--malachite-accent-foreground, rgb(2, 122, 66))" : "var(--malachite-text-primary, rgb(10, 10, 10))", y = r === "stacked" && !!e.subtitle, N = `mal-${Je().replace(/[^a-zA-Z0-9_-]/g, "")}`, x = `${N}-label`, w = `${N}-subtitle`, k = g(null), E = g(null), R = g(null), [S, v] = j({ label: !0, subtitle: !0, rightSide: !0 }), $ = () => {
|
|
297
|
+
const o = le(k.current), C = le(E.current), l = le(R.current);
|
|
298
|
+
return !o && !C && !l ? !1 : (v({ label: o, subtitle: C, rightSide: l }), !0);
|
|
299
|
+
}, a = e.rightSideTextVariant === "primary" ? "var(--malachite-text-right-side-text-primary, rgb(10, 10, 10))" : "var(--malachite-text-right-side-text-muted, rgb(123, 123, 123))", f = e.rightSideTextAlignment === "left" ? "flex-start" : "flex-end", s = (
|
|
307
300
|
// `role="option"` would be invalid — nothing here declares a `listbox`, and an
|
|
308
301
|
// orphaned option is dropped from the a11y tree. `aria-current`, not
|
|
309
302
|
// `aria-pressed`: these are one-of-many choices, not toggles. tabIndex={-1}
|
|
@@ -320,7 +313,7 @@ const Ct = ({
|
|
|
320
313
|
"aria-describedby": e.subtitle ? w : void 0,
|
|
321
314
|
tabIndex: -1,
|
|
322
315
|
onClick: (o) => {
|
|
323
|
-
o.stopPropagation(),
|
|
316
|
+
o.stopPropagation(), m(e);
|
|
324
317
|
},
|
|
325
318
|
className: "malachite-dropdown-option",
|
|
326
319
|
style: {
|
|
@@ -355,7 +348,7 @@ const Ct = ({
|
|
|
355
348
|
{
|
|
356
349
|
style: y ? { display: "flex", flexDirection: "column", gap: 2 } : { display: "flex", alignItems: "center", gap: 8 },
|
|
357
350
|
children: [
|
|
358
|
-
/* @__PURE__ */ b(
|
|
351
|
+
/* @__PURE__ */ b(Tt, { row: y && !!e.icon, children: [
|
|
359
352
|
e.icon && /* @__PURE__ */ t(
|
|
360
353
|
"span",
|
|
361
354
|
{
|
|
@@ -375,7 +368,7 @@ const Ct = ({
|
|
|
375
368
|
ref: k,
|
|
376
369
|
style: {
|
|
377
370
|
fontWeight: 400,
|
|
378
|
-
color:
|
|
371
|
+
color: c,
|
|
379
372
|
whiteSpace: "nowrap",
|
|
380
373
|
overflow: "hidden",
|
|
381
374
|
textOverflow: "ellipsis",
|
|
@@ -391,10 +384,10 @@ const Ct = ({
|
|
|
391
384
|
id: w,
|
|
392
385
|
ref: E,
|
|
393
386
|
style: {
|
|
394
|
-
fontSize:
|
|
387
|
+
fontSize: Re,
|
|
395
388
|
fontWeight: 400,
|
|
396
389
|
lineHeight: 1.4,
|
|
397
|
-
color: i ?
|
|
390
|
+
color: i ? c : "var(--malachite-text-dimmed, rgb(161, 161, 161))",
|
|
398
391
|
whiteSpace: "nowrap",
|
|
399
392
|
overflow: "hidden",
|
|
400
393
|
textOverflow: "ellipsis"
|
|
@@ -419,7 +412,7 @@ const Ct = ({
|
|
|
419
412
|
"span",
|
|
420
413
|
{
|
|
421
414
|
style: {
|
|
422
|
-
fontSize:
|
|
415
|
+
fontSize: Re,
|
|
423
416
|
fontWeight: 400,
|
|
424
417
|
color: "var(--malachite-text-secondary, rgb(123, 123, 123))",
|
|
425
418
|
flexShrink: 0
|
|
@@ -433,7 +426,7 @@ const Ct = ({
|
|
|
433
426
|
id: w,
|
|
434
427
|
ref: E,
|
|
435
428
|
style: {
|
|
436
|
-
fontSize:
|
|
429
|
+
fontSize: Re,
|
|
437
430
|
fontWeight: 400,
|
|
438
431
|
color: "var(--malachite-text-secondary, rgb(123, 123, 123))",
|
|
439
432
|
whiteSpace: "nowrap",
|
|
@@ -459,12 +452,12 @@ const Ct = ({
|
|
|
459
452
|
minWidth: e.rightSideText ? "var(--malachite-text-right-side-text-min-width, 80px)" : 0,
|
|
460
453
|
flexShrink: 1,
|
|
461
454
|
display: "flex",
|
|
462
|
-
justifyContent:
|
|
455
|
+
justifyContent: f
|
|
463
456
|
},
|
|
464
457
|
children: e.rightSideText && /* @__PURE__ */ t(
|
|
465
458
|
"span",
|
|
466
459
|
{
|
|
467
|
-
ref:
|
|
460
|
+
ref: R,
|
|
468
461
|
style: {
|
|
469
462
|
fontSize: "var(--malachite-text-right-side-text-font-size, 12px)",
|
|
470
463
|
fontWeight: 400,
|
|
@@ -496,31 +489,31 @@ const Ct = ({
|
|
|
496
489
|
shouldShow: $,
|
|
497
490
|
isShrinkable: !0,
|
|
498
491
|
describesTrigger: !1,
|
|
499
|
-
children:
|
|
492
|
+
children: s
|
|
500
493
|
}
|
|
501
494
|
);
|
|
502
|
-
},
|
|
495
|
+
}, qe = He.forwardRef((e, i) => {
|
|
503
496
|
const {
|
|
504
497
|
items: r,
|
|
505
|
-
onItemSelected:
|
|
506
|
-
selectedItem:
|
|
498
|
+
onItemSelected: m,
|
|
499
|
+
selectedItem: c,
|
|
507
500
|
menuLoading: y,
|
|
508
501
|
emptyMessage: N,
|
|
509
502
|
autoFocus: x,
|
|
510
503
|
positioned: w,
|
|
511
504
|
onDismiss: k,
|
|
512
505
|
subtitleLayout: E,
|
|
513
|
-
size:
|
|
506
|
+
size: R,
|
|
514
507
|
style: S
|
|
515
|
-
} = e, v =
|
|
516
|
-
|
|
508
|
+
} = e, v = g(null);
|
|
509
|
+
Ye(() => {
|
|
517
510
|
pt();
|
|
518
|
-
}, []), ht(v, !0),
|
|
519
|
-
var
|
|
511
|
+
}, []), ht(v, !0), Le(() => {
|
|
512
|
+
var s;
|
|
520
513
|
if (!x || !w)
|
|
521
514
|
return;
|
|
522
515
|
const a = Ne(v.current);
|
|
523
|
-
(
|
|
516
|
+
(s = a.find((o) => o.dataset.selected === "true") ?? a[0] ?? v.current) == null || s.focus();
|
|
524
517
|
}, [x, w]);
|
|
525
518
|
const $ = (a) => {
|
|
526
519
|
var C;
|
|
@@ -528,16 +521,16 @@ const Ct = ({
|
|
|
528
521
|
k();
|
|
529
522
|
return;
|
|
530
523
|
}
|
|
531
|
-
const
|
|
532
|
-
if (
|
|
524
|
+
const f = Ne(v.current);
|
|
525
|
+
if (f.length === 0)
|
|
533
526
|
return;
|
|
534
|
-
const
|
|
535
|
-
ArrowDown:
|
|
536
|
-
ArrowUp:
|
|
527
|
+
const s = f.indexOf(document.activeElement), o = {
|
|
528
|
+
ArrowDown: s + 1,
|
|
529
|
+
ArrowUp: s - 1,
|
|
537
530
|
Home: 0,
|
|
538
|
-
End:
|
|
531
|
+
End: f.length - 1
|
|
539
532
|
}[a.key];
|
|
540
|
-
o !== void 0 && (a.preventDefault(), (C =
|
|
533
|
+
o !== void 0 && (a.preventDefault(), (C = f[Math.min(Math.max(o, 0), f.length - 1)]) == null || C.focus());
|
|
541
534
|
};
|
|
542
535
|
return /* @__PURE__ */ t(
|
|
543
536
|
"div",
|
|
@@ -557,7 +550,7 @@ const Ct = ({
|
|
|
557
550
|
overflow: "hidden",
|
|
558
551
|
display: "flex",
|
|
559
552
|
flexDirection: "column",
|
|
560
|
-
fontSize: at[
|
|
553
|
+
fontSize: at[R],
|
|
561
554
|
...S
|
|
562
555
|
},
|
|
563
556
|
children: y ? /* @__PURE__ */ b("div", { style: Fe, children: [
|
|
@@ -575,8 +568,8 @@ const Ct = ({
|
|
|
575
568
|
scrollbarWidth: "thin",
|
|
576
569
|
scrollbarColor: "var(--malachite-text-placeholder, rgb(187, 187, 187)) transparent"
|
|
577
570
|
},
|
|
578
|
-
children: r.map((a,
|
|
579
|
-
const
|
|
571
|
+
children: r.map((a, f) => {
|
|
572
|
+
const s = r[f - 1], o = !!a.group && (!s || s.group !== a.group);
|
|
580
573
|
return /* @__PURE__ */ b("div", { style: { flexShrink: 0 }, children: [
|
|
581
574
|
o && /* @__PURE__ */ t(
|
|
582
575
|
"div",
|
|
@@ -593,12 +586,12 @@ const Ct = ({
|
|
|
593
586
|
}
|
|
594
587
|
),
|
|
595
588
|
/* @__PURE__ */ t(
|
|
596
|
-
|
|
589
|
+
Et,
|
|
597
590
|
{
|
|
598
591
|
item: a,
|
|
599
|
-
onItemSelected:
|
|
592
|
+
onItemSelected: m,
|
|
600
593
|
subtitleLayout: E,
|
|
601
|
-
selected: a.id === (
|
|
594
|
+
selected: a.id === (c == null ? void 0 : c.id) || !1
|
|
602
595
|
}
|
|
603
596
|
)
|
|
604
597
|
] }, a.id);
|
|
@@ -608,61 +601,61 @@ const Ct = ({
|
|
|
608
601
|
}
|
|
609
602
|
);
|
|
610
603
|
});
|
|
611
|
-
|
|
612
|
-
const
|
|
604
|
+
qe.displayName = "DropdownPanel";
|
|
605
|
+
const Kt = ({
|
|
613
606
|
items: e,
|
|
614
607
|
onItemSelected: i,
|
|
615
608
|
defaultValue: r,
|
|
616
|
-
value:
|
|
617
|
-
disabled:
|
|
609
|
+
value: m,
|
|
610
|
+
disabled: c = !1,
|
|
618
611
|
error: y,
|
|
619
612
|
tone: N,
|
|
620
613
|
label: x,
|
|
621
614
|
hint: w,
|
|
622
615
|
rightSideContent: k,
|
|
623
616
|
tooltip: E,
|
|
624
|
-
name:
|
|
617
|
+
name: R,
|
|
625
618
|
required: S = !1,
|
|
626
619
|
requiredIndicator: v,
|
|
627
620
|
loading: $,
|
|
628
621
|
menuLoading: a,
|
|
629
|
-
formControl:
|
|
630
|
-
description:
|
|
622
|
+
formControl: f,
|
|
623
|
+
description: s,
|
|
631
624
|
helperText: o,
|
|
632
625
|
placeholder: C,
|
|
633
|
-
search:
|
|
626
|
+
search: l = !1,
|
|
634
627
|
showSubtitleInTrigger: D = !1,
|
|
635
628
|
subtitleLayout: ce = "inline",
|
|
636
629
|
clearable: we = !1,
|
|
637
630
|
size: _ = "large",
|
|
638
631
|
fullWidth: Z = !1,
|
|
639
|
-
width:
|
|
632
|
+
width: K,
|
|
640
633
|
minWidth: J,
|
|
641
634
|
id: O,
|
|
642
635
|
"aria-label": de,
|
|
643
636
|
"aria-labelledby": Se
|
|
644
637
|
}) => {
|
|
645
|
-
const { controlId: ue, labelId: ee, descriptionId:
|
|
638
|
+
const { controlId: ue, labelId: ee, descriptionId: q, hintId: te, helperTextId: B } = rt({
|
|
646
639
|
id: O,
|
|
647
640
|
label: x,
|
|
648
|
-
description:
|
|
641
|
+
description: s,
|
|
649
642
|
hint: w,
|
|
650
643
|
helperText: !0
|
|
651
|
-
}), [
|
|
652
|
-
|
|
644
|
+
}), [L, h] = j(!1), [T, z] = j(r), V = m ?? T, P = e.find((n) => n.id === V), pe = we && V !== void 0 && V !== "" && !c, fe = D && !l && !!(P != null && P.subtitle), d = `Clear ${x ?? C ?? "selection"}`, re = g(r);
|
|
645
|
+
Le(() => {
|
|
653
646
|
re.current !== r && (re.current = r, z(r));
|
|
654
647
|
}, [r]);
|
|
655
|
-
const [Te,
|
|
656
|
-
var
|
|
648
|
+
const [Te, I] = j(""), [Be, _e] = j(!1), ke = g(null), he = g(null), U = g(null), [u, $e] = j(null), ge = g(!0), X = Ce(() => {
|
|
649
|
+
var p;
|
|
657
650
|
const n = he.current;
|
|
658
|
-
n && ((
|
|
651
|
+
n && ((p = n instanceof HTMLButtonElement ? n : n.querySelector("input")) == null || p.focus());
|
|
659
652
|
}, []), Ae = Ce(
|
|
660
653
|
(n) => {
|
|
661
|
-
var
|
|
662
|
-
n.stopPropagation(), z(void 0), (
|
|
654
|
+
var p;
|
|
655
|
+
n.stopPropagation(), z(void 0), (p = M.current) == null || p.call(M, Ee.current), i == null || i(void 0), l && (ge.current = !1), X();
|
|
663
656
|
},
|
|
664
|
-
[i,
|
|
665
|
-
),
|
|
657
|
+
[i, l, X]
|
|
658
|
+
), W = Ce(() => {
|
|
666
659
|
const n = he.current;
|
|
667
660
|
n && $e(
|
|
668
661
|
st(U.current, {
|
|
@@ -674,59 +667,59 @@ const Bt = ({
|
|
|
674
667
|
})
|
|
675
668
|
);
|
|
676
669
|
}, [J]);
|
|
677
|
-
|
|
678
|
-
if (!
|
|
670
|
+
Le(() => {
|
|
671
|
+
if (!L) {
|
|
679
672
|
$e(null), _e(!1);
|
|
680
673
|
return;
|
|
681
674
|
}
|
|
682
|
-
|
|
675
|
+
W();
|
|
683
676
|
const n = (G) => {
|
|
684
677
|
var ae;
|
|
685
678
|
const A = G.composedPath(), H = ke.current, ie = U.current, ve = !!H && A.includes(H), De = !!ie && A.includes(ie);
|
|
686
|
-
!ve && !De && (
|
|
687
|
-
},
|
|
688
|
-
|
|
689
|
-
}),
|
|
679
|
+
!ve && !De && (h(!1), l && I(""), (ae = F.current) == null || ae.call(F));
|
|
680
|
+
}, p = lt(() => {
|
|
681
|
+
h(!1), l && I(""), X();
|
|
682
|
+
}), Q = () => W();
|
|
690
683
|
let ne = 0, me = "";
|
|
691
684
|
const xe = () => {
|
|
692
685
|
const G = he.current;
|
|
693
686
|
if (G) {
|
|
694
687
|
const A = G.getBoundingClientRect();
|
|
695
688
|
if (ct(A, window.innerWidth, window.innerHeight)) {
|
|
696
|
-
|
|
689
|
+
h(!1), l && I("");
|
|
697
690
|
return;
|
|
698
691
|
}
|
|
699
692
|
const H = dt(A);
|
|
700
|
-
H !== me && (me = H,
|
|
693
|
+
H !== me && (me = H, W());
|
|
701
694
|
}
|
|
702
695
|
ne = requestAnimationFrame(xe);
|
|
703
696
|
};
|
|
704
|
-
return ne = requestAnimationFrame(xe), document.addEventListener("mousedown", n), window.addEventListener("scroll",
|
|
705
|
-
cancelAnimationFrame(ne), document.removeEventListener("mousedown", n),
|
|
697
|
+
return ne = requestAnimationFrame(xe), document.addEventListener("mousedown", n), window.addEventListener("scroll", Q, !0), window.addEventListener("resize", Q), () => {
|
|
698
|
+
cancelAnimationFrame(ne), document.removeEventListener("mousedown", n), p(), window.removeEventListener("scroll", Q, !0), window.removeEventListener("resize", Q);
|
|
706
699
|
};
|
|
707
|
-
}, [
|
|
708
|
-
if (!
|
|
700
|
+
}, [L, l, W, X]), Qe(() => {
|
|
701
|
+
if (!L)
|
|
709
702
|
return;
|
|
710
|
-
|
|
703
|
+
W();
|
|
711
704
|
const n = U.current;
|
|
712
705
|
if (!n || typeof ResizeObserver > "u")
|
|
713
706
|
return;
|
|
714
|
-
const
|
|
715
|
-
return
|
|
716
|
-
}, [
|
|
717
|
-
const M =
|
|
718
|
-
var
|
|
719
|
-
z(n == null ? void 0 : n.id), (
|
|
720
|
-
},
|
|
721
|
-
|
|
707
|
+
const p = new ResizeObserver(() => W());
|
|
708
|
+
return p.observe(n), () => p.disconnect();
|
|
709
|
+
}, [L, W]);
|
|
710
|
+
const M = g(void 0), F = g(void 0), Ee = g(""), Ve = (n) => {
|
|
711
|
+
var p;
|
|
712
|
+
z(n == null ? void 0 : n.id), (p = M.current) == null || p.call(M, (n == null ? void 0 : n.id) ?? Ee.current), h(!1), l && (I(""), ge.current = !1), i == null || i(n == null ? void 0 : n.id), X();
|
|
713
|
+
}, Ie = () => {
|
|
714
|
+
h(!1), l && I(""), X();
|
|
722
715
|
}, Ue = () => {
|
|
723
716
|
const n = Ne(U.current)[0];
|
|
724
717
|
if (n) {
|
|
725
718
|
n.focus();
|
|
726
719
|
return;
|
|
727
720
|
}
|
|
728
|
-
_e(!0),
|
|
729
|
-
}, Xe =
|
|
721
|
+
_e(!0), h(!0);
|
|
722
|
+
}, Xe = l && Te ? e.filter((n) => mt(n, Te)) : e;
|
|
730
723
|
return /* @__PURE__ */ t(
|
|
731
724
|
tt,
|
|
732
725
|
{
|
|
@@ -735,37 +728,37 @@ const Bt = ({
|
|
|
735
728
|
hint: w,
|
|
736
729
|
rightSideContent: k,
|
|
737
730
|
tooltip: E,
|
|
738
|
-
name:
|
|
731
|
+
name: R,
|
|
739
732
|
required: S,
|
|
740
733
|
requiredIndicator: v,
|
|
741
734
|
loading: $,
|
|
742
|
-
formControl:
|
|
743
|
-
description:
|
|
735
|
+
formControl: f,
|
|
736
|
+
description: s,
|
|
744
737
|
controlId: ue,
|
|
745
738
|
labelId: ee,
|
|
746
|
-
descriptionId:
|
|
739
|
+
descriptionId: q,
|
|
747
740
|
hintId: te,
|
|
748
|
-
loadingComponent:
|
|
749
|
-
|
|
741
|
+
loadingComponent: K === void 0 ? /* @__PURE__ */ t(
|
|
742
|
+
Pe,
|
|
750
743
|
{
|
|
751
|
-
heightClass:
|
|
744
|
+
heightClass: se[_],
|
|
752
745
|
helperText: !!o,
|
|
753
746
|
helperTextMarginTop: !0
|
|
754
747
|
}
|
|
755
|
-
) : /* @__PURE__ */ t("div", { style:
|
|
756
|
-
|
|
748
|
+
) : /* @__PURE__ */ t("div", { style: We(K), children: /* @__PURE__ */ t(
|
|
749
|
+
Pe,
|
|
757
750
|
{
|
|
758
|
-
heightClass:
|
|
751
|
+
heightClass: se[_],
|
|
759
752
|
helperText: !!o,
|
|
760
753
|
helperTextMarginTop: !0
|
|
761
754
|
}
|
|
762
755
|
) }),
|
|
763
|
-
children: ({ error: n, message:
|
|
764
|
-
M.current =
|
|
765
|
-
const xe = y ?? n, G = y === !1 ? void 0 :
|
|
766
|
-
|
|
756
|
+
children: ({ error: n, message: p, onFieldChange: Q, onFieldBlur: ne, emptyValue: me }) => {
|
|
757
|
+
M.current = Q, F.current = ne, Ee.current = me;
|
|
758
|
+
const xe = y ?? n, G = y === !1 ? void 0 : p, A = `${B}-error`, H = [
|
|
759
|
+
q,
|
|
767
760
|
te,
|
|
768
|
-
o ?
|
|
761
|
+
o ? B : void 0,
|
|
769
762
|
G ? A : void 0
|
|
770
763
|
].filter(Boolean).join(" ") || void 0;
|
|
771
764
|
return /* @__PURE__ */ b(ye, { children: [
|
|
@@ -774,19 +767,19 @@ const Bt = ({
|
|
|
774
767
|
{
|
|
775
768
|
ref: ke,
|
|
776
769
|
className: "relative w-full",
|
|
777
|
-
style:
|
|
770
|
+
style: We(K),
|
|
778
771
|
onBlur: (ie) => {
|
|
779
772
|
var ae, Oe;
|
|
780
773
|
const ve = ie.relatedTarget;
|
|
781
774
|
ie.currentTarget.contains(ve) || ((ae = U.current) == null ? void 0 : ae.contains(ve)) === !0 || (Oe = F.current) == null || Oe.call(F);
|
|
782
775
|
},
|
|
783
776
|
children: [
|
|
784
|
-
pe && !
|
|
777
|
+
pe && !l && /* @__PURE__ */ t(
|
|
785
778
|
"button",
|
|
786
779
|
{
|
|
787
780
|
type: "button",
|
|
788
781
|
onClick: Ae,
|
|
789
|
-
"aria-label":
|
|
782
|
+
"aria-label": d,
|
|
790
783
|
className: `absolute ${fe ? yt[_] : "top-1/2 -translate-y-1/2"} z-10 flex items-center
|
|
791
784
|
justify-center rounded-full text-[var(--malachite-text-placeholder)]
|
|
792
785
|
hover:text-[var(--malachite-text-primary)] transition-colors
|
|
@@ -795,32 +788,32 @@ const Bt = ({
|
|
|
795
788
|
}
|
|
796
789
|
),
|
|
797
790
|
/* @__PURE__ */ t(
|
|
798
|
-
|
|
791
|
+
Ke,
|
|
799
792
|
{
|
|
800
793
|
hasClear: pe,
|
|
801
794
|
onClear: Ae,
|
|
802
|
-
clearLabel:
|
|
795
|
+
clearLabel: d,
|
|
803
796
|
ref: he,
|
|
804
|
-
isOpen:
|
|
805
|
-
onClick: () => !
|
|
806
|
-
selectedItem:
|
|
807
|
-
disabled:
|
|
797
|
+
isOpen: L,
|
|
798
|
+
onClick: () => !c && h(!L),
|
|
799
|
+
selectedItem: P,
|
|
800
|
+
disabled: c,
|
|
808
801
|
error: xe,
|
|
809
802
|
tone: N,
|
|
810
803
|
placeholder: C,
|
|
811
|
-
search:
|
|
804
|
+
search: l,
|
|
812
805
|
showSubtitleInTrigger: D,
|
|
813
806
|
searchQuery: Te,
|
|
814
|
-
onSearchChange:
|
|
807
|
+
onSearchChange: I,
|
|
815
808
|
onFocusOpen: () => {
|
|
816
809
|
if (!ge.current) {
|
|
817
810
|
ge.current = !0;
|
|
818
811
|
return;
|
|
819
812
|
}
|
|
820
|
-
|
|
813
|
+
h(!0);
|
|
821
814
|
},
|
|
822
815
|
onArrowDown: () => {
|
|
823
|
-
|
|
816
|
+
c || Ue();
|
|
824
817
|
},
|
|
825
818
|
size: _,
|
|
826
819
|
controlId: ue,
|
|
@@ -832,30 +825,30 @@ const Bt = ({
|
|
|
832
825
|
ariaLabelledBy: Se
|
|
833
826
|
}
|
|
834
827
|
),
|
|
835
|
-
|
|
828
|
+
L && et(
|
|
836
829
|
/* @__PURE__ */ t(
|
|
837
|
-
|
|
830
|
+
qe,
|
|
838
831
|
{
|
|
839
832
|
ref: U,
|
|
840
833
|
style: {
|
|
841
834
|
position: "fixed",
|
|
842
|
-
top: (
|
|
843
|
-
left: (
|
|
844
|
-
width:
|
|
845
|
-
maxHeight:
|
|
846
|
-
visibility:
|
|
847
|
-
opacity:
|
|
835
|
+
top: (u == null ? void 0 : u.top) ?? 0,
|
|
836
|
+
left: (u == null ? void 0 : u.left) ?? 0,
|
|
837
|
+
width: u == null ? void 0 : u.width,
|
|
838
|
+
maxHeight: u == null ? void 0 : u.maxHeight,
|
|
839
|
+
visibility: u ? "visible" : "hidden",
|
|
840
|
+
opacity: u ? 1 : 0
|
|
848
841
|
},
|
|
849
842
|
items: Xe,
|
|
850
|
-
onItemSelected:
|
|
851
|
-
selectedItem:
|
|
843
|
+
onItemSelected: Ve,
|
|
844
|
+
selectedItem: P,
|
|
852
845
|
menuLoading: a,
|
|
853
846
|
emptyMessage: e.length === 0 ? "No options available" : "No results found",
|
|
854
847
|
subtitleLayout: ce,
|
|
855
848
|
size: _,
|
|
856
|
-
autoFocus: !
|
|
857
|
-
positioned:
|
|
858
|
-
onDismiss:
|
|
849
|
+
autoFocus: !l || Be,
|
|
850
|
+
positioned: u !== null,
|
|
851
|
+
onDismiss: Ie
|
|
859
852
|
}
|
|
860
853
|
),
|
|
861
854
|
document.body
|
|
@@ -866,7 +859,7 @@ const Bt = ({
|
|
|
866
859
|
o && /* @__PURE__ */ t(
|
|
867
860
|
"div",
|
|
868
861
|
{
|
|
869
|
-
id:
|
|
862
|
+
id: B,
|
|
870
863
|
className: "mt-1 text-[length:var(--malachite-font-size-small,13px)] text-left pl-2 text-[var(--malachite-text-dimmed,rgb(161,161,161))]",
|
|
871
864
|
children: o
|
|
872
865
|
}
|
|
@@ -878,6 +871,6 @@ const Bt = ({
|
|
|
878
871
|
);
|
|
879
872
|
};
|
|
880
873
|
export {
|
|
881
|
-
|
|
874
|
+
Kt as Dropdown
|
|
882
875
|
};
|
|
883
876
|
//# sourceMappingURL=Dropdown.js.map
|