@stackone/malachite 2.139.0 → 2.141.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 +1 -1
- package/dist/components/QueryInput.js +509 -228
- package/dist/components/QueryInput.js.map +1 -1
- package/dist/components/Surface.js +75 -74
- package/dist/components/Surface.js.map +1 -1
- package/dist/components/queryInputGeometry.js +9 -10
- package/dist/components/queryInputGeometry.js.map +1 -1
- package/dist/index.d.ts +44 -0
- package/dist/tailwind.css.js +1 -1
- package/package.json +1 -1
|
@@ -1,31 +1,75 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useId as
|
|
3
|
-
import { createPortal as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
import { jsxs as d, jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { useId as Zt, useState as $, useRef as u, useEffect as rt, useCallback as G, useLayoutEffect as O, useInsertionEffect as qt } from "react";
|
|
3
|
+
import { createPortal as Jt } from "react-dom";
|
|
4
|
+
import Qt from "./CustomIcons/DismissIcon.js";
|
|
5
|
+
import te from "./CustomIcons/SearchIcon.js";
|
|
6
|
+
import { Spinner as ee } from "./Spinner.js";
|
|
7
|
+
import re from "./Tooltip.js";
|
|
8
|
+
import { getVariantClasses as ae } from "./buttonStyles.js";
|
|
9
|
+
import { CODE_TOKEN_COLOR as wt } from "./codeBlockStyles.js";
|
|
10
|
+
import { CONTROL_TEXT_SIZE as K, CONTROL_TEXT_SIZE_CLASS as Et } from "./controlTextSize.js";
|
|
11
|
+
import { pushEscapeLayer as ne } from "./escapeLayers.js";
|
|
12
|
+
import { holdsFocus as oe } from "./collapseFocus.js";
|
|
13
|
+
import { FOCUS_RING_INSET as ie, FOCUS_RING as le } from "./focusRing.js";
|
|
14
|
+
import { MENU_VIEWPORT_PADDING_PX as _t } from "./floatingMenuGeometry.js";
|
|
15
|
+
import { ensureMultiSelectPanelStyles as ce } from "./optionRowStyles.js";
|
|
16
|
+
import { usePopupLayer as se } from "./overlayLayers.js";
|
|
17
|
+
import { useOwnedByPopover as de } from "./popoverTree.js";
|
|
18
|
+
import { computeCaretMenuGeometry as pe } from "./queryInputGeometry.js";
|
|
19
|
+
import { useFollowTrigger as me } from "./useFollowTrigger.js";
|
|
20
|
+
const ue = {
|
|
21
|
+
small: "px-[10px] rounded-[var(--malachite-radius-10,10px)]",
|
|
22
|
+
medium: "px-[10px] rounded-xl",
|
|
23
|
+
large: "px-[12px] rounded-[var(--malachite-radius-xxl,14px)]"
|
|
24
|
+
}, he = {
|
|
25
|
+
small: "h-[var(--malachite-control-height-small,28px)]",
|
|
26
|
+
medium: "h-[var(--malachite-control-height-medium,32px)]",
|
|
27
|
+
large: "h-[var(--malachite-control-height-large,42px)]"
|
|
28
|
+
}, fe = {
|
|
29
|
+
small: "min-h-[var(--malachite-control-height-small,28px)]",
|
|
30
|
+
medium: "min-h-[var(--malachite-control-height-medium,32px)]",
|
|
31
|
+
large: "min-h-[var(--malachite-control-height-large,42px)]"
|
|
32
|
+
}, xe = {
|
|
33
|
+
small: "flex-wrap gap-x-[6px] gap-y-[4px] py-[2px]",
|
|
34
|
+
medium: "flex-wrap gap-x-[6px] gap-y-[4px] py-[3px]",
|
|
35
|
+
large: "flex-wrap gap-x-[8px] gap-y-[4px] py-[5px]"
|
|
36
|
+
}, ge = {
|
|
37
|
+
small: "h-[22px]",
|
|
38
|
+
medium: "h-[24px]",
|
|
39
|
+
large: "h-[30px]"
|
|
40
|
+
}, be = {
|
|
41
|
+
small: "h-[20px] text-[length:var(--malachite-font-size-xsmall,11px)]",
|
|
42
|
+
medium: "h-[20px] text-[length:var(--malachite-font-size-xsmall,11px)]",
|
|
43
|
+
large: "h-[24px] text-xs"
|
|
44
|
+
}, ye = "inline-flex max-w-full items-center gap-[2px] rounded-[5px] pl-[7px] whitespace-nowrap font-mono text-[var(--malachite-text-primary,rgb(10,10,10))]", kt = "text-[var(--malachite-text-destructive,rgb(237,53,54))] supports-[color:color-mix(in_srgb,red,red)]:text-[color-mix(in_srgb,var(--malachite-text-destructive,rgb(237,53,54))_70%,var(--malachite-text-primary,rgb(10,10,10)))]", Se = {
|
|
45
|
+
include: {
|
|
46
|
+
chip: "bg-[var(--malachite-card-dimmed-background,rgb(247,247,247))]",
|
|
47
|
+
key: "text-[var(--malachite-text-secondary,rgb(123,123,123))]"
|
|
48
|
+
},
|
|
49
|
+
exclude: {
|
|
50
|
+
chip: "bg-[var(--malachite-error-background-glass,rgba(197,63,63,0.08))] supports-[color:color-mix(in_srgb,red,red)]:bg-[color-mix(in_srgb,var(--malachite-text-destructive,rgb(237,53,54))_10%,var(--malachite-card-background,rgb(255,255,255)))]",
|
|
51
|
+
key: kt
|
|
52
|
+
},
|
|
53
|
+
invalid: {
|
|
54
|
+
chip: "border border-dashed border-[var(--malachite-text-destructive,rgb(237,53,54))] bg-[var(--malachite-card-background,rgb(255,255,255))]",
|
|
55
|
+
key: kt
|
|
56
|
+
}
|
|
57
|
+
}, ve = {
|
|
58
|
+
include: "",
|
|
59
|
+
exclude: ", excluded",
|
|
60
|
+
invalid: ", invalid"
|
|
61
|
+
}, we = `inline-flex shrink-0 h-full items-center rounded-[4px] px-[4px] bg-transparent border-none cursor-pointer text-[var(--malachite-text-secondary,rgb(123,123,123))] enabled:hover:text-[var(--malachite-text-primary,rgb(10,10,10))] disabled:cursor-not-allowed ${le}`, Ee = `${ae("quiet", "rounded-md")} ml-auto shrink-0 h-[22px] px-[6px] text-xs whitespace-nowrap`, _e = 5e3, ot = (r) => `${r.label}${r.operator}${r.value}`, Tt = (r) => `Removed ${ot(r)} filter`, ke = {
|
|
62
|
+
key: wt.keyword,
|
|
63
|
+
value: wt.string,
|
|
20
64
|
operator: "var(--malachite-codeblock-type, rgb(12, 88, 174))",
|
|
21
65
|
negation: "var(--malachite-text-destructive, rgb(237, 53, 54))",
|
|
22
66
|
punctuation: "var(--malachite-codeblock-foreground, rgb(10, 10, 10))",
|
|
23
67
|
error: "var(--malachite-text-error, rgb(237, 53, 54))",
|
|
24
68
|
plain: "var(--malachite-text-primary, rgb(10, 10, 10))"
|
|
25
|
-
},
|
|
69
|
+
}, Te = {
|
|
26
70
|
small: {
|
|
27
71
|
fontFamily: "inherit",
|
|
28
|
-
fontSize:
|
|
72
|
+
fontSize: K.small,
|
|
29
73
|
fontWeight: 500,
|
|
30
74
|
letterSpacing: "normal",
|
|
31
75
|
lineHeight: "normal",
|
|
@@ -33,7 +77,7 @@ const Dt = {
|
|
|
33
77
|
},
|
|
34
78
|
medium: {
|
|
35
79
|
fontFamily: "inherit",
|
|
36
|
-
fontSize:
|
|
80
|
+
fontSize: K.medium,
|
|
37
81
|
fontWeight: 500,
|
|
38
82
|
letterSpacing: "normal",
|
|
39
83
|
lineHeight: "normal",
|
|
@@ -41,13 +85,63 @@ const Dt = {
|
|
|
41
85
|
},
|
|
42
86
|
large: {
|
|
43
87
|
fontFamily: "inherit",
|
|
44
|
-
fontSize:
|
|
88
|
+
fontSize: K.large,
|
|
45
89
|
fontWeight: 500,
|
|
46
90
|
letterSpacing: "normal",
|
|
47
91
|
lineHeight: "normal",
|
|
48
92
|
padding: 0
|
|
49
93
|
}
|
|
50
|
-
},
|
|
94
|
+
}, It = 220, Ie = 360, at = 4, Ne = /* @__PURE__ */ new Set(["Shift", "Control", "Alt", "Meta"]), Le = 420, $e = {
|
|
95
|
+
position: "sticky",
|
|
96
|
+
top: -4,
|
|
97
|
+
zIndex: 1,
|
|
98
|
+
margin: "-4px -4px 0",
|
|
99
|
+
padding: "8px 12px 6px",
|
|
100
|
+
fontSize: "var(--malachite-font-size-xsmall, 11px)",
|
|
101
|
+
color: "var(--malachite-text-dimmed, rgb(161, 161, 161))",
|
|
102
|
+
background: "var(--malachite-card-background, rgb(255, 255, 255))",
|
|
103
|
+
borderBottom: "1px solid var(--malachite-card-subtle-divider, rgb(241, 241, 241))",
|
|
104
|
+
whiteSpace: "nowrap",
|
|
105
|
+
overflow: "hidden",
|
|
106
|
+
textOverflow: "ellipsis",
|
|
107
|
+
flexShrink: 0
|
|
108
|
+
}, Me = {
|
|
109
|
+
position: "sticky",
|
|
110
|
+
bottom: -4,
|
|
111
|
+
zIndex: 1,
|
|
112
|
+
margin: "0 -4px -4px",
|
|
113
|
+
padding: "8px 12px",
|
|
114
|
+
display: "flex",
|
|
115
|
+
flexWrap: "wrap",
|
|
116
|
+
columnGap: 14,
|
|
117
|
+
rowGap: 4,
|
|
118
|
+
fontSize: "var(--malachite-font-size-xsmall, 11px)",
|
|
119
|
+
color: "var(--malachite-text-secondary, rgb(123, 123, 123))",
|
|
120
|
+
background: "var(--malachite-card-sunken-background, rgb(250, 250, 250))",
|
|
121
|
+
borderTop: "1px solid var(--malachite-card-subtle-divider, rgb(241, 241, 241))",
|
|
122
|
+
flexShrink: 0
|
|
123
|
+
}, Re = {
|
|
124
|
+
display: "inline-flex",
|
|
125
|
+
alignItems: "center",
|
|
126
|
+
justifyContent: "center",
|
|
127
|
+
minWidth: 18,
|
|
128
|
+
height: 18,
|
|
129
|
+
padding: "0 5px",
|
|
130
|
+
marginRight: 5,
|
|
131
|
+
boxSizing: "border-box",
|
|
132
|
+
borderRadius: 6,
|
|
133
|
+
border: "1px solid var(--malachite-card-border, rgb(232, 232, 232))",
|
|
134
|
+
background: "var(--malachite-card-background, rgb(255, 255, 255))",
|
|
135
|
+
boxShadow: "var(--malachite-shadow-default, 0px 1px 0px 0px rgba(0, 0, 0, 0.15))",
|
|
136
|
+
fontFamily: "var(--malachite-font-mono, monospace)",
|
|
137
|
+
fontSize: 10,
|
|
138
|
+
color: "var(--malachite-text-secondary, rgb(123, 123, 123))"
|
|
139
|
+
}, nt = {
|
|
140
|
+
minWidth: 0,
|
|
141
|
+
overflow: "hidden",
|
|
142
|
+
textOverflow: "ellipsis",
|
|
143
|
+
whiteSpace: "nowrap"
|
|
144
|
+
}, Nt = {
|
|
51
145
|
display: "flex",
|
|
52
146
|
alignItems: "center",
|
|
53
147
|
justifyContent: "center",
|
|
@@ -55,159 +149,214 @@ const Dt = {
|
|
|
55
149
|
padding: "10px 12px",
|
|
56
150
|
color: "var(--malachite-text-dimmed, rgb(161, 161, 161))",
|
|
57
151
|
whiteSpace: "nowrap"
|
|
58
|
-
},
|
|
152
|
+
}, Ae = (r) => {
|
|
59
153
|
r.preventDefault();
|
|
60
|
-
},
|
|
61
|
-
const
|
|
62
|
-
(
|
|
63
|
-
)].sort((
|
|
64
|
-
let
|
|
65
|
-
for (const
|
|
66
|
-
|
|
67
|
-
return
|
|
68
|
-
},
|
|
69
|
-
const
|
|
70
|
-
let
|
|
71
|
-
for (const
|
|
72
|
-
|
|
73
|
-
return
|
|
74
|
-
},
|
|
154
|
+
}, De = (r, k) => {
|
|
155
|
+
const c = [...k.filter(
|
|
156
|
+
(i) => i.start >= 0 && i.end <= r.length && i.start < i.end
|
|
157
|
+
)].sort((i, H) => i.start - H.start), h = [];
|
|
158
|
+
let T = 0;
|
|
159
|
+
for (const i of c)
|
|
160
|
+
i.start < T || (h.push(i), T = i.end);
|
|
161
|
+
return h;
|
|
162
|
+
}, Oe = (r, k) => {
|
|
163
|
+
const v = [];
|
|
164
|
+
let c = 0;
|
|
165
|
+
for (const h of De(r, k))
|
|
166
|
+
h.start > c && v.push({ start: c, end: h.start, kind: "plain" }), v.push(h), c = h.end;
|
|
167
|
+
return c < r.length && v.push({ start: c, end: r.length, kind: "plain" }), v;
|
|
168
|
+
}, nr = ({
|
|
75
169
|
value: r,
|
|
76
|
-
onChange:
|
|
77
|
-
tokens:
|
|
78
|
-
suggestions:
|
|
79
|
-
activeRange:
|
|
80
|
-
onAccept:
|
|
81
|
-
onQueryContextChange:
|
|
82
|
-
onSubmit:
|
|
83
|
-
placeholder:
|
|
84
|
-
size:
|
|
85
|
-
disabled:
|
|
86
|
-
loading:
|
|
87
|
-
emptyMessage:
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
170
|
+
onChange: k,
|
|
171
|
+
tokens: v = [],
|
|
172
|
+
suggestions: c,
|
|
173
|
+
activeRange: h,
|
|
174
|
+
onAccept: T,
|
|
175
|
+
onQueryContextChange: i,
|
|
176
|
+
onSubmit: H,
|
|
177
|
+
placeholder: it,
|
|
178
|
+
size: s = "large",
|
|
179
|
+
disabled: x = !1,
|
|
180
|
+
loading: C = !1,
|
|
181
|
+
emptyMessage: P,
|
|
182
|
+
chips: Y,
|
|
183
|
+
onChipRemove: g,
|
|
184
|
+
onClear: M,
|
|
185
|
+
searchIcon: j = !1,
|
|
186
|
+
menuTitle: W,
|
|
187
|
+
menuHints: B,
|
|
188
|
+
className: Lt = "",
|
|
189
|
+
style: $t,
|
|
190
|
+
"aria-label": Mt,
|
|
191
|
+
"aria-labelledby": lt
|
|
92
192
|
}) => {
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
193
|
+
const V = `${Zt()}-listbox`, ct = (t) => `${V}-option-${t}`, [Z, st] = $(!1), [dt, q] = $(() => r.length), [Rt, J] = $(0), [At, F] = $(!1), [b, pt] = $(null), [U, mt] = $({ message: "", count: 0 }), I = u(null), z = u(null), p = u(null), ut = u(null), ht = u(null), N = u(null), ft = u(null), xt = u(null), gt = u([]), Q = u(null), w = Y ?? [], E = Y !== void 0 || j || M !== void 0, Dt = !!M && w.length > 0, bt = `${s}${!!g}${w.map((t) => `${t.id}\0${t.tone ?? ""}\0${ot(t)}`).join("")}`, Ot = `${Array.isArray(c)}${(c ?? []).map(
|
|
194
|
+
(t) => [t.id, t.label, t.description, t.detail].join(
|
|
195
|
+
"\0"
|
|
196
|
+
)
|
|
197
|
+
).join("")}`, Ht = (B ?? []).map((t) => `${t.keys}\0${t.label}`).join("");
|
|
198
|
+
rt(() => {
|
|
199
|
+
if (!U.message)
|
|
200
|
+
return;
|
|
201
|
+
const t = window.setTimeout(
|
|
202
|
+
() => mt((e) => ({ ...e, message: "" })),
|
|
203
|
+
_e
|
|
204
|
+
);
|
|
205
|
+
return () => window.clearTimeout(t);
|
|
206
|
+
}, [U]), rt(() => {
|
|
207
|
+
I.current = null;
|
|
208
|
+
}, [bt]);
|
|
209
|
+
const tt = (t) => {
|
|
210
|
+
mt((e) => ({ message: t, count: e.count + 1 }));
|
|
211
|
+
}, Ct = Array.isArray(c), L = c ?? [], R = L.length > 0, l = Z && (C || R || Ct && !R && !!P) && !At && !x, Pt = se("dropdown", l, N);
|
|
212
|
+
de(
|
|
213
|
+
G(() => N.current, []),
|
|
214
|
+
l
|
|
97
215
|
);
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
216
|
+
const A = l && R && !C, f = R ? Math.min(Rt, L.length - 1) : -1;
|
|
217
|
+
O(() => {
|
|
218
|
+
q((t) => Math.min(t, r.length));
|
|
101
219
|
}, [r]);
|
|
102
|
-
const
|
|
103
|
-
const t =
|
|
220
|
+
const X = G(() => {
|
|
221
|
+
const t = p.current, e = ut.current;
|
|
104
222
|
t && e && (e.style.transform = `translateX(${-t.scrollLeft}px)`);
|
|
105
223
|
}, []);
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}, [r,
|
|
109
|
-
const
|
|
110
|
-
var
|
|
111
|
-
const t =
|
|
224
|
+
O(() => {
|
|
225
|
+
X();
|
|
226
|
+
}, [r, X]);
|
|
227
|
+
const _ = G(() => {
|
|
228
|
+
var m, y, S, D;
|
|
229
|
+
const t = p.current;
|
|
112
230
|
if (!t)
|
|
113
231
|
return;
|
|
114
|
-
const e = (((
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
inputRect:
|
|
232
|
+
const e = (((m = ht.current) == null ? void 0 : m.offsetWidth) ?? 0) - t.scrollLeft, a = t.getBoundingClientRect(), o = E ? (y = z.current) == null ? void 0 : y.getBoundingClientRect() : void 0;
|
|
233
|
+
pt(
|
|
234
|
+
pe({
|
|
235
|
+
inputRect: o ? {
|
|
236
|
+
left: a.left,
|
|
237
|
+
right: a.right,
|
|
238
|
+
top: o.top,
|
|
239
|
+
bottom: o.bottom
|
|
240
|
+
} : a,
|
|
118
241
|
caretOffsetPx: e,
|
|
119
|
-
menuWidth: ((
|
|
120
|
-
menuHeight: ((D =
|
|
242
|
+
menuWidth: ((S = N.current) == null ? void 0 : S.offsetWidth) ?? It,
|
|
243
|
+
menuHeight: ((D = N.current) == null ? void 0 : D.offsetHeight) ?? 0,
|
|
121
244
|
viewportWidth: window.innerWidth,
|
|
122
245
|
viewportHeight: window.innerHeight
|
|
123
246
|
})
|
|
124
247
|
);
|
|
125
|
-
}, []);
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}, [
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
248
|
+
}, [E]);
|
|
249
|
+
O(() => {
|
|
250
|
+
l ? _() : pt(null);
|
|
251
|
+
}, [
|
|
252
|
+
l,
|
|
253
|
+
r,
|
|
254
|
+
dt,
|
|
255
|
+
Ot,
|
|
256
|
+
C,
|
|
257
|
+
P,
|
|
258
|
+
bt,
|
|
259
|
+
j,
|
|
260
|
+
W,
|
|
261
|
+
Ht,
|
|
262
|
+
_
|
|
263
|
+
]);
|
|
264
|
+
const Wt = G(() => F(!0), []);
|
|
265
|
+
me(l, E ? z : p, _, Wt), rt(() => {
|
|
266
|
+
if (!l)
|
|
132
267
|
return;
|
|
133
|
-
const t = () =>
|
|
268
|
+
const t = () => _();
|
|
134
269
|
window.addEventListener("resize", t);
|
|
135
|
-
const e =
|
|
270
|
+
const e = ne(() => F(!0));
|
|
136
271
|
return () => {
|
|
137
272
|
window.removeEventListener("resize", t), e();
|
|
138
273
|
};
|
|
139
|
-
}, [
|
|
140
|
-
const t =
|
|
274
|
+
}, [l, _]), O(() => {
|
|
275
|
+
const t = Q.current;
|
|
141
276
|
if (t === null)
|
|
142
277
|
return;
|
|
143
|
-
|
|
144
|
-
const e =
|
|
145
|
-
!e || t.value !== r || (e.setSelectionRange(t.caret, t.caret),
|
|
146
|
-
}, [r]),
|
|
147
|
-
|
|
278
|
+
Q.current = null;
|
|
279
|
+
const e = p.current;
|
|
280
|
+
!e || t.value !== r || (e.setSelectionRange(t.caret, t.caret), q(t.caret), i == null || i({ value: r, caret: t.caret }), X(), _());
|
|
281
|
+
}, [r]), O(() => {
|
|
282
|
+
var y, S;
|
|
283
|
+
if (!A)
|
|
148
284
|
return;
|
|
149
|
-
const t =
|
|
285
|
+
const t = gt.current[f], e = N.current;
|
|
150
286
|
if (!t || !e)
|
|
151
287
|
return;
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
},
|
|
288
|
+
const a = Math.max(0, (((y = ft.current) == null ? void 0 : y.offsetHeight) ?? 0) - at), o = Math.max(
|
|
289
|
+
0,
|
|
290
|
+
(((S = xt.current) == null ? void 0 : S.offsetHeight) ?? 0) - at
|
|
291
|
+
), m = t.offsetTop + t.offsetHeight;
|
|
292
|
+
m > e.scrollTop + e.clientHeight - o ? e.scrollTop = m - e.clientHeight + o : t.offsetTop - a < e.scrollTop && (e.scrollTop = t.offsetTop - a);
|
|
293
|
+
}, [f, A]), qt(() => {
|
|
294
|
+
l && ce();
|
|
295
|
+
}, [l]);
|
|
296
|
+
const yt = (t, e) => {
|
|
297
|
+
q(e), i == null || i({ value: t, caret: e });
|
|
298
|
+
}, Bt = (t) => {
|
|
160
299
|
const e = t.target.value;
|
|
161
|
-
|
|
162
|
-
},
|
|
300
|
+
F(!1), J(0), k(e), yt(e, t.target.selectionStart ?? e.length);
|
|
301
|
+
}, Ft = (t) => {
|
|
163
302
|
const e = t.currentTarget;
|
|
164
|
-
|
|
165
|
-
},
|
|
166
|
-
var
|
|
167
|
-
const e = ((
|
|
168
|
-
|
|
169
|
-
},
|
|
170
|
-
if (
|
|
303
|
+
yt(e.value, e.selectionStart ?? e.value.length);
|
|
304
|
+
}, et = (t) => {
|
|
305
|
+
var D;
|
|
306
|
+
const e = ((D = p.current) == null ? void 0 : D.selectionStart) ?? r.length, a = h ?? { start: e, end: e }, o = Math.max(0, Math.min(a.start, r.length)), m = Math.max(o, Math.min(a.end, r.length)), y = t.insertText ?? t.label, S = r.slice(0, o) + y + r.slice(m);
|
|
307
|
+
Q.current = { value: S, caret: o + y.length }, k(S), T == null || T(t);
|
|
308
|
+
}, Ut = (t) => {
|
|
309
|
+
if (t.key !== "Backspace" && !Ne.has(t.key) && (I.current = null), t.nativeEvent.isComposing || t.keyCode === 229 && t.key !== "Backspace")
|
|
310
|
+
return;
|
|
311
|
+
if (t.key === "Backspace" && g && w.length > 0 && r === "" && !t.repeat) {
|
|
171
312
|
t.preventDefault();
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
|
|
313
|
+
const a = w[w.length - 1];
|
|
314
|
+
if (I.current === a.id)
|
|
315
|
+
return;
|
|
316
|
+
I.current = a.id, tt(Tt(a)), g(a.id);
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
if (A && (t.key === "ArrowDown" || t.key === "ArrowUp")) {
|
|
320
|
+
t.preventDefault();
|
|
321
|
+
const a = L.length;
|
|
322
|
+
J(
|
|
323
|
+
t.key === "ArrowDown" ? (f + 1) % a : (f - 1 + a) % a
|
|
175
324
|
);
|
|
176
325
|
return;
|
|
177
326
|
}
|
|
178
|
-
const e =
|
|
327
|
+
const e = A && f >= 0 ? L[f] : void 0;
|
|
179
328
|
if (t.key === "Enter") {
|
|
180
329
|
if (e) {
|
|
181
|
-
t.preventDefault(),
|
|
330
|
+
t.preventDefault(), et(e);
|
|
182
331
|
return;
|
|
183
332
|
}
|
|
184
|
-
|
|
333
|
+
H && (t.preventDefault(), H(r));
|
|
185
334
|
return;
|
|
186
335
|
}
|
|
187
|
-
t.key === "Tab" && e && (t.preventDefault(),
|
|
188
|
-
},
|
|
336
|
+
t.key === "Tab" && e && (t.preventDefault(), et(e));
|
|
337
|
+
}, zt = Oe(r, v), St = Te[s], Xt = C ? (
|
|
189
338
|
// `role="listbox"` admits only option/group children.
|
|
190
|
-
/* @__PURE__ */
|
|
191
|
-
/* @__PURE__ */
|
|
192
|
-
/* @__PURE__ */
|
|
339
|
+
/* @__PURE__ */ d("div", { role: "presentation", style: Nt, children: [
|
|
340
|
+
/* @__PURE__ */ n(ee, { size: "xxxsmall" }),
|
|
341
|
+
/* @__PURE__ */ n("span", { children: "Loading…" })
|
|
193
342
|
] })
|
|
194
|
-
) :
|
|
195
|
-
const
|
|
196
|
-
return /* @__PURE__ */
|
|
343
|
+
) : R ? L.map((t, e) => {
|
|
344
|
+
const a = e === f;
|
|
345
|
+
return /* @__PURE__ */ d(
|
|
197
346
|
"button",
|
|
198
347
|
{
|
|
199
|
-
ref: (
|
|
200
|
-
|
|
348
|
+
ref: (o) => {
|
|
349
|
+
gt.current[e] = o;
|
|
201
350
|
},
|
|
202
351
|
type: "button",
|
|
203
|
-
id:
|
|
352
|
+
id: ct(e),
|
|
204
353
|
role: "option",
|
|
205
|
-
"aria-selected":
|
|
354
|
+
"aria-selected": a,
|
|
206
355
|
tabIndex: -1,
|
|
207
|
-
onClick: () =>
|
|
208
|
-
onMouseEnter: () =>
|
|
356
|
+
onClick: () => et(t),
|
|
357
|
+
onMouseEnter: () => J(e),
|
|
209
358
|
className: "malachite-multiselect-option",
|
|
210
|
-
"data-highlighted":
|
|
359
|
+
"data-highlighted": a,
|
|
211
360
|
style: {
|
|
212
361
|
display: "flex",
|
|
213
362
|
alignItems: "center",
|
|
@@ -223,20 +372,33 @@ const Dt = {
|
|
|
223
372
|
color: "var(--malachite-text-primary, rgb(10, 10, 10))"
|
|
224
373
|
},
|
|
225
374
|
children: [
|
|
226
|
-
/* @__PURE__ */ d(
|
|
375
|
+
t.description ? /* @__PURE__ */ d(
|
|
227
376
|
"span",
|
|
228
377
|
{
|
|
229
378
|
style: {
|
|
230
379
|
flex: 1,
|
|
231
380
|
minWidth: 0,
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
381
|
+
display: "flex",
|
|
382
|
+
flexDirection: "column",
|
|
383
|
+
gap: 1
|
|
235
384
|
},
|
|
236
|
-
children:
|
|
385
|
+
children: [
|
|
386
|
+
/* @__PURE__ */ n("span", { style: nt, children: t.label }),
|
|
387
|
+
/* @__PURE__ */ n(
|
|
388
|
+
"span",
|
|
389
|
+
{
|
|
390
|
+
style: {
|
|
391
|
+
...nt,
|
|
392
|
+
fontSize: "var(--malachite-font-size-xsmall, 11px)",
|
|
393
|
+
color: "var(--malachite-text-secondary, rgb(123, 123, 123))"
|
|
394
|
+
},
|
|
395
|
+
children: t.description
|
|
396
|
+
}
|
|
397
|
+
)
|
|
398
|
+
]
|
|
237
399
|
}
|
|
238
|
-
),
|
|
239
|
-
t.detail && /* @__PURE__ */
|
|
400
|
+
) : /* @__PURE__ */ n("span", { style: { flex: 1, ...nt }, children: t.label }),
|
|
401
|
+
t.detail && /* @__PURE__ */ n(
|
|
240
402
|
"span",
|
|
241
403
|
{
|
|
242
404
|
style: {
|
|
@@ -251,120 +413,239 @@ const Dt = {
|
|
|
251
413
|
},
|
|
252
414
|
t.id
|
|
253
415
|
);
|
|
254
|
-
}) :
|
|
255
|
-
|
|
416
|
+
}) : P ? /* @__PURE__ */ n("div", { role: "presentation", style: Nt, children: P }) : null, Gt = x ? "" : "hover:border-[var(--malachite-text-placeholder)]", Kt = L.some((t) => t.description) ? Le : Ie, Yt = (t) => {
|
|
417
|
+
var a;
|
|
418
|
+
const e = vt();
|
|
419
|
+
tt(Tt(t)), g == null || g(t.id), e && ((a = p.current) == null || a.focus());
|
|
420
|
+
}, vt = () => {
|
|
421
|
+
const t = z.current;
|
|
422
|
+
return !!t && oe(t, t.getRootNode());
|
|
423
|
+
}, jt = (t) => {
|
|
424
|
+
var m;
|
|
425
|
+
I.current = null;
|
|
426
|
+
const e = t.currentTarget, a = t.target;
|
|
427
|
+
if (x || t.button !== 0 || !e.contains(a) || a === p.current)
|
|
428
|
+
return;
|
|
429
|
+
t.preventDefault();
|
|
430
|
+
const o = a.closest("button");
|
|
431
|
+
(!o || !e.contains(o)) && ((m = p.current) == null || m.focus());
|
|
432
|
+
}, Vt = () => {
|
|
433
|
+
var e;
|
|
434
|
+
const t = vt();
|
|
435
|
+
tt("Removed all filters"), M == null || M(), t && ((e = p.current) == null || e.focus());
|
|
436
|
+
};
|
|
437
|
+
return /* @__PURE__ */ d(
|
|
256
438
|
"div",
|
|
257
439
|
{
|
|
258
|
-
|
|
440
|
+
ref: z,
|
|
441
|
+
className: `relative w-full ${ue[s]} ${E ? `${fe[s]} ${xe[s]}` : he[s]} bg-[var(--malachite-card-background)] border border-solid border-[var(--malachite-card-border)] ${Gt} transition-colors flex items-center ${x ? "opacity-60 cursor-not-allowed" : E ? "cursor-text" : ""} ${Lt}`,
|
|
259
442
|
style: {
|
|
260
|
-
boxShadow:
|
|
261
|
-
borderColor:
|
|
262
|
-
|
|
443
|
+
boxShadow: Z ? "var(--malachite-shadow-accent, 0px 1px 0px 0px rgba(0, 175, 102, 0.15))" : "0px 1px 1px 0px rgba(0, 0, 0, 0.15)",
|
|
444
|
+
borderColor: Z ? "var(--malachite-control-border-hover, rgba(0, 175, 102, 0.4))" : void 0,
|
|
445
|
+
...$t
|
|
263
446
|
},
|
|
447
|
+
onMouseDown: E ? jt : void 0,
|
|
264
448
|
children: [
|
|
265
|
-
/* @__PURE__ */
|
|
266
|
-
|
|
267
|
-
|
|
449
|
+
j && /* @__PURE__ */ n(
|
|
450
|
+
te,
|
|
451
|
+
{
|
|
452
|
+
size: 14,
|
|
453
|
+
className: "shrink-0 pointer-events-none text-[var(--malachite-text-secondary,rgb(123,123,123))]"
|
|
454
|
+
}
|
|
455
|
+
),
|
|
456
|
+
w.length > 0 && // `contents` lets each chip wrap in the bar's own row beside the text.
|
|
457
|
+
// role: WebKit drops the list role from an unstyled list, and from display: contents.
|
|
458
|
+
/* @__PURE__ */ n("ul", { role: "list", "aria-label": "Filters", className: "contents", children: w.map((t) => {
|
|
459
|
+
const e = t.tone ?? "include", a = Se[e], o = /* @__PURE__ */ d(
|
|
460
|
+
"span",
|
|
268
461
|
{
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
className: `absolute inset-0 flex items-center pointer-events-none ${nt[w]}`,
|
|
272
|
-
style: { ...J, whiteSpace: "pre" },
|
|
462
|
+
tabIndex: t.tooltip && !x ? 0 : void 0,
|
|
463
|
+
className: `inline-flex min-w-0 items-center gap-[2px] rounded-[3px] ${ie}`,
|
|
273
464
|
children: [
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
465
|
+
/* @__PURE__ */ n("span", { className: `min-w-0 truncate ${a.key}`, children: t.label }),
|
|
466
|
+
/* @__PURE__ */ n("span", { className: "text-[var(--malachite-text-dimmed,rgb(161,161,161))]", children: t.operator }),
|
|
467
|
+
/* @__PURE__ */ n("span", { className: "min-w-0 truncate", children: t.value }),
|
|
468
|
+
/* @__PURE__ */ d("span", { className: "sr-only", children: [
|
|
469
|
+
ve[e],
|
|
470
|
+
t.tooltip ? `, ${t.tooltip}` : ""
|
|
471
|
+
] })
|
|
472
|
+
]
|
|
473
|
+
}
|
|
474
|
+
);
|
|
475
|
+
return /* @__PURE__ */ d(
|
|
476
|
+
"li",
|
|
477
|
+
{
|
|
478
|
+
"data-tone": e,
|
|
479
|
+
className: `${ye} ${g ? "pr-[2px]" : "pr-[7px]"} ${be[s]} ${a.chip}`,
|
|
480
|
+
children: [
|
|
481
|
+
t.tooltip ? (
|
|
482
|
+
// The sr-only copy above already carries the text.
|
|
483
|
+
/* @__PURE__ */ n(
|
|
484
|
+
re,
|
|
485
|
+
{
|
|
486
|
+
text: t.tooltip,
|
|
487
|
+
inline: !0,
|
|
488
|
+
isShrinkable: !0,
|
|
489
|
+
describesTrigger: !1,
|
|
490
|
+
children: o
|
|
491
|
+
}
|
|
492
|
+
)
|
|
493
|
+
) : o,
|
|
494
|
+
g && /* @__PURE__ */ n(
|
|
495
|
+
"button",
|
|
287
496
|
{
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
497
|
+
type: "button",
|
|
498
|
+
"aria-label": `Remove ${ot(t)} filter`,
|
|
499
|
+
onClick: () => Yt(t),
|
|
500
|
+
disabled: x,
|
|
501
|
+
className: we,
|
|
502
|
+
children: /* @__PURE__ */ n(Qt, { size: 8 })
|
|
291
503
|
}
|
|
292
504
|
)
|
|
293
505
|
]
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
506
|
+
},
|
|
507
|
+
t.id
|
|
508
|
+
);
|
|
509
|
+
}) }),
|
|
510
|
+
/* @__PURE__ */ d(
|
|
511
|
+
"div",
|
|
512
|
+
{
|
|
513
|
+
className: `relative flex-1 overflow-hidden ${E ? `min-w-[min(160px,100%)] ${ge[s]}` : "min-w-0 self-stretch"}`,
|
|
514
|
+
children: [
|
|
515
|
+
/* @__PURE__ */ d(
|
|
516
|
+
"div",
|
|
517
|
+
{
|
|
518
|
+
ref: ut,
|
|
519
|
+
"aria-hidden": "true",
|
|
520
|
+
className: `absolute inset-0 flex items-center pointer-events-none ${Et[s]}`,
|
|
521
|
+
style: { ...St, whiteSpace: "pre" },
|
|
522
|
+
children: [
|
|
523
|
+
zt.map((t) => /* @__PURE__ */ n(
|
|
524
|
+
"span",
|
|
525
|
+
{
|
|
526
|
+
style: {
|
|
527
|
+
color: ke[t.kind],
|
|
528
|
+
...t.kind === "error" ? { textDecoration: "underline wavy" } : {}
|
|
529
|
+
},
|
|
530
|
+
children: r.slice(t.start, t.end)
|
|
531
|
+
},
|
|
532
|
+
t.start
|
|
533
|
+
)),
|
|
534
|
+
/* @__PURE__ */ n(
|
|
535
|
+
"span",
|
|
536
|
+
{
|
|
537
|
+
ref: ht,
|
|
538
|
+
style: { position: "absolute", top: 0, left: 0, visibility: "hidden" },
|
|
539
|
+
children: r.slice(0, dt)
|
|
540
|
+
}
|
|
541
|
+
)
|
|
542
|
+
]
|
|
543
|
+
}
|
|
544
|
+
),
|
|
545
|
+
/* @__PURE__ */ n(
|
|
546
|
+
"input",
|
|
547
|
+
{
|
|
548
|
+
ref: p,
|
|
549
|
+
type: "text",
|
|
550
|
+
role: "combobox",
|
|
551
|
+
"aria-expanded": l,
|
|
552
|
+
"aria-controls": l ? V : void 0,
|
|
553
|
+
"aria-activedescendant": A && f >= 0 ? ct(f) : void 0,
|
|
554
|
+
"aria-autocomplete": "list",
|
|
555
|
+
autoComplete: "off",
|
|
556
|
+
spellCheck: !1,
|
|
557
|
+
"aria-labelledby": lt,
|
|
558
|
+
"aria-label": lt ? void 0 : Mt ?? it,
|
|
559
|
+
value: r,
|
|
560
|
+
onChange: Bt,
|
|
561
|
+
onSelect: Ft,
|
|
562
|
+
onScroll: () => {
|
|
563
|
+
X(), l && _();
|
|
564
|
+
},
|
|
565
|
+
onKeyDown: Ut,
|
|
566
|
+
onFocus: () => {
|
|
567
|
+
I.current = null, st(!0), F(!1);
|
|
568
|
+
},
|
|
569
|
+
onBlur: () => st(!1),
|
|
570
|
+
placeholder: it,
|
|
571
|
+
disabled: x,
|
|
572
|
+
className: `absolute inset-0 w-full h-full bg-transparent border-none outline-none ${Et[s]} placeholder:text-[var(--malachite-text-placeholder)] placeholder:font-medium disabled:cursor-not-allowed`,
|
|
573
|
+
style: {
|
|
574
|
+
...St,
|
|
575
|
+
color: "transparent",
|
|
576
|
+
caretColor: "var(--malachite-text-primary, rgb(10, 10, 10))"
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
)
|
|
580
|
+
]
|
|
581
|
+
}
|
|
582
|
+
),
|
|
583
|
+
Y !== void 0 && // Not role="status": one per bar would collide with a page's own status queries.
|
|
584
|
+
/* @__PURE__ */ n("span", { "aria-live": "polite", className: "sr-only", children: /* @__PURE__ */ n("span", { children: U.message }, U.count) }),
|
|
585
|
+
Dt && // Not for text alone: typing then never changes the bar's layout.
|
|
586
|
+
/* @__PURE__ */ n(
|
|
587
|
+
"button",
|
|
588
|
+
{
|
|
589
|
+
type: "button",
|
|
590
|
+
onClick: Vt,
|
|
591
|
+
disabled: x,
|
|
592
|
+
className: Ee,
|
|
593
|
+
children: "Clear All"
|
|
594
|
+
}
|
|
595
|
+
),
|
|
596
|
+
l && Jt(
|
|
333
597
|
/* @__PURE__ */ d(
|
|
334
598
|
"div",
|
|
335
599
|
{
|
|
336
|
-
ref:
|
|
337
|
-
id:
|
|
600
|
+
ref: N,
|
|
601
|
+
id: V,
|
|
338
602
|
role: "listbox",
|
|
339
|
-
|
|
340
|
-
|
|
603
|
+
"aria-label": W,
|
|
604
|
+
...Pt,
|
|
605
|
+
onMouseDown: Ae,
|
|
341
606
|
style: {
|
|
342
607
|
position: "fixed",
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
)
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
),
|
|
608
|
+
// Its own width, not what is left right of `left`: positioning reads
|
|
609
|
+
// the width, so it must not depend on the position it produces.
|
|
610
|
+
width: "max-content",
|
|
611
|
+
top: (b == null ? void 0 : b.top) ?? 0,
|
|
612
|
+
left: (b == null ? void 0 : b.left) ?? 0,
|
|
613
|
+
minWidth: `min(${It}px, calc(100vw - ${_t * 2}px))`,
|
|
614
|
+
// Capped by the viewport, not the last measured width, which would
|
|
615
|
+
// keep a menu that narrowed for short rows from widening again.
|
|
616
|
+
maxWidth: `min(${Kt}px, calc(100vw - ${_t * 2}px))`,
|
|
353
617
|
background: "var(--malachite-card-background, rgb(255, 255, 255))",
|
|
354
618
|
border: "1px solid var(--malachite-card-border, rgb(232, 232, 232))",
|
|
355
619
|
borderRadius: 12,
|
|
356
620
|
boxShadow: "0px 2px 5px 0px rgba(0, 0, 0, 0.1)",
|
|
357
|
-
padding:
|
|
621
|
+
padding: at,
|
|
358
622
|
display: "flex",
|
|
359
623
|
flexDirection: "column",
|
|
360
624
|
gap: 2,
|
|
361
625
|
maxHeight: 320,
|
|
362
626
|
overflowY: "auto",
|
|
363
|
-
fontSize:
|
|
364
|
-
visibility:
|
|
365
|
-
opacity:
|
|
627
|
+
fontSize: K[s],
|
|
628
|
+
visibility: b ? "visible" : "hidden",
|
|
629
|
+
opacity: b ? 1 : 0
|
|
366
630
|
},
|
|
367
|
-
children:
|
|
631
|
+
children: [
|
|
632
|
+
W && // aria-hidden: a listbox admits only options. The title is the
|
|
633
|
+
// listbox's own label instead.
|
|
634
|
+
/* @__PURE__ */ n("div", { ref: ft, "aria-hidden": "true", style: $e, children: W }),
|
|
635
|
+
Xt,
|
|
636
|
+
B && B.length > 0 && // Pointer and keyboard both already work without reading these.
|
|
637
|
+
/* @__PURE__ */ n("div", { ref: xt, "aria-hidden": "true", style: Me, children: B.map((t) => /* @__PURE__ */ d(
|
|
638
|
+
"span",
|
|
639
|
+
{
|
|
640
|
+
style: { display: "inline-flex", alignItems: "center" },
|
|
641
|
+
children: [
|
|
642
|
+
/* @__PURE__ */ n("kbd", { style: Re, children: t.keys }),
|
|
643
|
+
t.label
|
|
644
|
+
]
|
|
645
|
+
},
|
|
646
|
+
JSON.stringify([t.keys, t.label])
|
|
647
|
+
)) })
|
|
648
|
+
]
|
|
368
649
|
}
|
|
369
650
|
),
|
|
370
651
|
document.body
|
|
@@ -374,7 +655,7 @@ const Dt = {
|
|
|
374
655
|
);
|
|
375
656
|
};
|
|
376
657
|
export {
|
|
377
|
-
|
|
378
|
-
|
|
658
|
+
nr as QueryInput,
|
|
659
|
+
nr as default
|
|
379
660
|
};
|
|
380
661
|
//# sourceMappingURL=QueryInput.js.map
|