@stackone/malachite 2.131.0 → 2.133.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 +8 -8
- package/dist/assets/icons/hexagon_fill.svg.js +6 -0
- package/dist/assets/icons/hexagon_fill.svg.js.map +1 -0
- package/dist/assets/icons/shield_star_fill.svg.js +6 -0
- package/dist/assets/icons/shield_star_fill.svg.js.map +1 -0
- package/dist/components/Button.js.map +1 -1
- package/dist/components/CodeBlock.js +130 -130
- package/dist/components/CodeBlock.js.map +1 -1
- package/dist/components/CodeBlockHighlighter.js +65 -65
- package/dist/components/CodeBlockHighlighter.js.map +1 -1
- package/dist/components/CodePreview.js +74 -63
- package/dist/components/CodePreview.js.map +1 -1
- package/dist/components/FormActions.js +13 -9
- package/dist/components/FormActions.js.map +1 -1
- package/dist/components/Hexagon.js +33 -26
- package/dist/components/Hexagon.js.map +1 -1
- package/dist/components/HexagonScale.js +20 -19
- package/dist/components/HexagonScale.js.map +1 -1
- package/dist/components/Input/Input.js +55 -54
- package/dist/components/Input/Input.js.map +1 -1
- package/dist/components/KeyValueList.js +36 -32
- package/dist/components/KeyValueList.js.map +1 -1
- package/dist/components/QueryInput.js +91 -90
- package/dist/components/QueryInput.js.map +1 -1
- package/dist/components/Surface.js +1 -1
- package/dist/components/Surface.js.map +1 -1
- package/dist/components/Table/Table.js +691 -637
- package/dist/components/Table/Table.js.map +1 -1
- package/dist/components/TextArea/TextArea.js +46 -46
- package/dist/components/TextArea/TextArea.js.map +1 -1
- package/dist/components/buttonStyles.js +2 -0
- package/dist/components/buttonStyles.js.map +1 -1
- package/dist/components/codeBlockStyles.js +11 -6
- package/dist/components/codeBlockStyles.js.map +1 -1
- package/dist/components/codePreviewJson.js +25 -0
- package/dist/components/codePreviewJson.js.map +1 -0
- package/dist/index.d.ts +42 -7
- package/dist/tailwind.css.js +1 -1
- package/dist/theme.js +11 -3
- package/dist/theme.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,47 +1,50 @@
|
|
|
1
|
-
import { jsx as e, jsxs as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import
|
|
4
|
-
import { textOf as
|
|
5
|
-
const
|
|
1
|
+
import { jsx as e, jsxs as w } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as p, useContext as d } from "react";
|
|
3
|
+
import b from "./Typography/EllipsisText.js";
|
|
4
|
+
import { textOf as f } from "./childrenText.js";
|
|
5
|
+
const v = {
|
|
6
6
|
small: {
|
|
7
7
|
row: "min-h-[36px]",
|
|
8
|
-
label: "
|
|
8
|
+
label: "px-[12px] py-[8px]",
|
|
9
9
|
value: "py-[8px] pr-[12px]"
|
|
10
10
|
},
|
|
11
11
|
medium: {
|
|
12
12
|
row: "min-h-[52px]",
|
|
13
|
-
label: "
|
|
13
|
+
label: "p-[16px]",
|
|
14
14
|
value: "py-[16px] pr-[16px]"
|
|
15
15
|
}
|
|
16
|
-
},
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
}, h = {
|
|
17
|
+
small: { narrow: "w-[100px]", regular: "w-[140px]", wide: "w-[200px]" },
|
|
18
|
+
medium: { narrow: "w-[140px]", regular: "w-[200px]", wide: "w-[280px]" }
|
|
19
|
+
}, n = p("medium"), m = p(!1), c = p("regular"), g = { row: "", label: "py-[7px]", value: "py-[7px]" }, y = ({
|
|
20
|
+
label: t,
|
|
21
|
+
className: o = "",
|
|
19
22
|
children: r,
|
|
20
|
-
truncate:
|
|
21
|
-
tooltip:
|
|
23
|
+
truncate: a = !1,
|
|
24
|
+
tooltip: l
|
|
22
25
|
}) => {
|
|
23
|
-
const i =
|
|
24
|
-
return /* @__PURE__ */
|
|
26
|
+
const i = d(m), s = d(n), u = h[i ? "small" : s][d(c)], x = i ? g : v[s];
|
|
27
|
+
return /* @__PURE__ */ w(
|
|
25
28
|
"div",
|
|
26
29
|
{
|
|
27
|
-
className: `flex ${
|
|
30
|
+
className: `flex ${x.row} w-full items-start ${i ? "" : "border-0 border-b border-solid border-[var(--malachite-card-border)] last:border-b-0"} ${o}`,
|
|
28
31
|
children: [
|
|
29
32
|
/* @__PURE__ */ e(
|
|
30
33
|
"dt",
|
|
31
34
|
{
|
|
32
|
-
className: `m-0 shrink-0 ${
|
|
33
|
-
children:
|
|
35
|
+
className: `m-0 shrink-0 ${u} ${x.label} text-[13px] leading-[1.6] tracking-[0.13px] text-[var(--malachite-text-secondary)]`,
|
|
36
|
+
children: t
|
|
34
37
|
}
|
|
35
38
|
),
|
|
36
39
|
/* @__PURE__ */ e(
|
|
37
40
|
"dd",
|
|
38
41
|
{
|
|
39
|
-
className: `m-0 flex min-w-0 flex-1 flex-wrap items-center gap-[6px] ${
|
|
40
|
-
children:
|
|
41
|
-
|
|
42
|
+
className: `m-0 flex min-w-0 flex-1 flex-wrap items-center gap-[6px] ${x.value} text-[13px] leading-[1.6] tracking-[0.13px] text-[var(--malachite-text-primary)]`,
|
|
43
|
+
children: a ? /* @__PURE__ */ e(
|
|
44
|
+
b,
|
|
42
45
|
{
|
|
43
46
|
maxWidth: "100%",
|
|
44
|
-
tooltip:
|
|
47
|
+
tooltip: l !== void 0 ? l : f(r),
|
|
45
48
|
tooltipWhenTruncated: !0,
|
|
46
49
|
children: r
|
|
47
50
|
}
|
|
@@ -51,21 +54,22 @@ const f = {
|
|
|
51
54
|
]
|
|
52
55
|
}
|
|
53
56
|
);
|
|
54
|
-
},
|
|
55
|
-
className:
|
|
56
|
-
children:
|
|
57
|
+
}, $ = ({
|
|
58
|
+
className: t = "",
|
|
59
|
+
children: o,
|
|
57
60
|
size: r = "medium",
|
|
58
|
-
plain:
|
|
59
|
-
|
|
61
|
+
plain: a = !1,
|
|
62
|
+
labelWidth: l = "regular"
|
|
63
|
+
}) => /* @__PURE__ */ e(n.Provider, { value: r, children: /* @__PURE__ */ e(m.Provider, { value: a, children: /* @__PURE__ */ e(c.Provider, { value: l, children: /* @__PURE__ */ e(
|
|
60
64
|
"dl",
|
|
61
65
|
{
|
|
62
|
-
className: `m-0 flex w-full flex-col ${
|
|
63
|
-
children:
|
|
66
|
+
className: `m-0 flex w-full flex-col ${a ? "px-[14px] py-[4px]" : "overflow-hidden rounded-lg border border-solid border-[var(--malachite-card-border)] bg-[var(--malachite-card-background)]"} ${t}`,
|
|
67
|
+
children: o
|
|
64
68
|
}
|
|
65
|
-
) }) });
|
|
66
|
-
|
|
69
|
+
) }) }) });
|
|
70
|
+
$.Row = y;
|
|
67
71
|
export {
|
|
68
|
-
|
|
69
|
-
|
|
72
|
+
$ as KeyValueList,
|
|
73
|
+
$ as default
|
|
70
74
|
};
|
|
71
75
|
//# sourceMappingURL=KeyValueList.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KeyValueList.js","sources":["../../src/components/KeyValueList.tsx"],"sourcesContent":["import React, { createContext, useContext } from 'react';\nimport EllipsisText from './Typography/EllipsisText';\nimport { textOf } from './childrenText';\n\nexport type KeyValueListSize = 'small' | 'medium';\n\nexport interface KeyValueListProps {\n className?: string;\n children: React.ReactNode;\n /** `small` tightens the rows for a list inside a dialog or panel. */\n size?: KeyValueListSize;\n /**\n * Rows with no frame and no rules between them, for a list that sits inside a card which\n * frames it already, rather than a box inside a box.\n */\n plain?: boolean;\n}\n\nexport interface KeyValueListRowProps {\n label: React.ReactNode;\n className?: string;\n children: React.ReactNode;\n /**\n * Keep the value to one line, cut with an ellipsis at the cell's width. For inline content:\n * block/flex children (Tag, AppLogo) are clipped without an ellipsis, so use their own truncate.\n */\n truncate?: boolean;\n /**\n * Shown on hover/focus when a `truncate` value is actually cut off. Defaults to the value\n * itself when it is text (strings/numbers); give one for any other value, or none is shown.\n * Pass `null` to turn the tooltip off.\n */\n tooltip?: React.ReactNode;\n}\n\nconst SIZE_ROW: Record<KeyValueListSize, { row: string; label: string; value: string }> = {\n small: {\n row: 'min-h-[36px]',\n label: '
|
|
1
|
+
{"version":3,"file":"KeyValueList.js","sources":["../../src/components/KeyValueList.tsx"],"sourcesContent":["import React, { createContext, useContext } from 'react';\nimport EllipsisText from './Typography/EllipsisText';\nimport { textOf } from './childrenText';\n\nexport type KeyValueListSize = 'small' | 'medium';\n\n/** How wide the label column is, on the scale of the list's size. */\nexport type KeyValueListLabelWidth = 'narrow' | 'regular' | 'wide';\n\nexport interface KeyValueListProps {\n className?: string;\n children: React.ReactNode;\n /** `small` tightens the rows for a list inside a dialog or panel. */\n size?: KeyValueListSize;\n /**\n * Rows with no frame and no rules between them, for a list that sits inside a card which\n * frames it already, rather than a box inside a box.\n */\n plain?: boolean;\n /**\n * The label column's width, scaled to `size`. `narrow` for a list in a small window or panel\n * where the values need the room, `wide` for long labels. Defaults to `regular`, the width the\n * column has always had.\n */\n labelWidth?: KeyValueListLabelWidth;\n}\n\nexport interface KeyValueListRowProps {\n label: React.ReactNode;\n className?: string;\n children: React.ReactNode;\n /**\n * Keep the value to one line, cut with an ellipsis at the cell's width. For inline content:\n * block/flex children (Tag, AppLogo) are clipped without an ellipsis, so use their own truncate.\n */\n truncate?: boolean;\n /**\n * Shown on hover/focus when a `truncate` value is actually cut off. Defaults to the value\n * itself when it is text (strings/numbers); give one for any other value, or none is shown.\n * Pass `null` to turn the tooltip off.\n */\n tooltip?: React.ReactNode;\n}\n\nconst SIZE_ROW: Record<KeyValueListSize, { row: string; label: string; value: string }> = {\n small: {\n row: 'min-h-[36px]',\n label: 'px-[12px] py-[8px]',\n value: 'py-[8px] pr-[12px]',\n },\n medium: {\n row: 'min-h-[52px]',\n label: 'p-[16px]',\n value: 'py-[16px] pr-[16px]',\n },\n};\n\n// Literal classes, so Tailwind finds each one. A plain list's labels have no padding of their own,\n// so it takes the small scale.\nconst LABEL_WIDTH: Record<KeyValueListSize, Record<KeyValueListLabelWidth, string>> = {\n small: { narrow: 'w-[100px]', regular: 'w-[140px]', wide: 'w-[200px]' },\n medium: { narrow: 'w-[140px]', regular: 'w-[200px]', wide: 'w-[280px]' },\n};\n\nconst SizeContext = createContext<KeyValueListSize>('medium');\nconst PlainContext = createContext(false);\nconst LabelWidthContext = createContext<KeyValueListLabelWidth>('regular');\n\nconst PLAIN_ROW = { row: '', label: 'py-[7px]', value: 'py-[7px]' };\n\nconst Row: React.FC<KeyValueListRowProps> = ({\n label,\n className = '',\n children,\n truncate = false,\n tooltip,\n}) => {\n const plain = useContext(PlainContext);\n const sizeName = useContext(SizeContext);\n const labelWidth = LABEL_WIDTH[plain ? 'small' : sizeName][useContext(LabelWidthContext)];\n const size = plain ? PLAIN_ROW : SIZE_ROW[sizeName];\n return (\n <div\n className={`flex ${size.row} w-full items-start ${plain ? '' : 'border-0 border-b border-solid border-[var(--malachite-card-border)] last:border-b-0'} ${className}`}\n >\n <dt\n className={`m-0 shrink-0 ${labelWidth} ${size.label} text-[13px] leading-[1.6] tracking-[0.13px] text-[var(--malachite-text-secondary)]`}\n >\n {label}\n </dt>\n <dd\n className={`m-0 flex min-w-0 flex-1 flex-wrap items-center gap-[6px] ${size.value} text-[13px] leading-[1.6] tracking-[0.13px] text-[var(--malachite-text-primary)]`}\n >\n {truncate ? (\n <EllipsisText\n maxWidth=\"100%\"\n tooltip={tooltip !== undefined ? tooltip : textOf(children)}\n tooltipWhenTruncated\n >\n {children}\n </EllipsisText>\n ) : (\n children\n )}\n </dd>\n </div>\n );\n};\n\nconst KeyValueList: React.FC<KeyValueListProps> & { Row: typeof Row } = ({\n className = '',\n children,\n size = 'medium',\n plain = false,\n labelWidth = 'regular',\n}) => (\n <SizeContext.Provider value={size}>\n <PlainContext.Provider value={plain}>\n <LabelWidthContext.Provider value={labelWidth}>\n <dl\n className={`m-0 flex w-full flex-col ${plain ? 'px-[14px] py-[4px]' : 'overflow-hidden rounded-lg border border-solid border-[var(--malachite-card-border)] bg-[var(--malachite-card-background)]'} ${className}`}\n >\n {children}\n </dl>\n </LabelWidthContext.Provider>\n </PlainContext.Provider>\n </SizeContext.Provider>\n);\n\nKeyValueList.Row = Row;\n\nexport default KeyValueList;\nexport { KeyValueList };\n"],"names":["SIZE_ROW","LABEL_WIDTH","SizeContext","createContext","PlainContext","LabelWidthContext","PLAIN_ROW","Row","label","className","children","truncate","tooltip","plain","useContext","sizeName","labelWidth","size","jsxs","jsx","EllipsisText","textOf","KeyValueList"],"mappings":";;;;AA4CA,MAAMA,IAAoF;AAAA,EACtF,OAAO;AAAA,IACH,KAAK;AAAA,IACL,OAAO;AAAA,IACP,OAAO;AAAA,EAAA;AAAA,EAEX,QAAQ;AAAA,IACJ,KAAK;AAAA,IACL,OAAO;AAAA,IACP,OAAO;AAAA,EAAA;AAEf,GAIMC,IAAgF;AAAA,EAClF,OAAO,EAAE,QAAQ,aAAa,SAAS,aAAa,MAAM,YAAA;AAAA,EAC1D,QAAQ,EAAE,QAAQ,aAAa,SAAS,aAAa,MAAM,YAAA;AAC/D,GAEMC,IAAcC,EAAgC,QAAQ,GACtDC,IAAeD,EAAc,EAAK,GAClCE,IAAoBF,EAAsC,SAAS,GAEnEG,IAAY,EAAE,KAAK,IAAI,OAAO,YAAY,OAAO,WAAA,GAEjDC,IAAsC,CAAC;AAAA,EACzC,OAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,UAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,SAAAC;AACJ,MAAM;AACF,QAAMC,IAAQC,EAAWV,CAAY,GAC/BW,IAAWD,EAAWZ,CAAW,GACjCc,IAAaf,EAAYY,IAAQ,UAAUE,CAAQ,EAAED,EAAWT,CAAiB,CAAC,GAClFY,IAAOJ,IAAQP,IAAYN,EAASe,CAAQ;AAClD,SACI,gBAAAG;AAAA,IAAC;AAAA,IAAA;AAAA,MACG,WAAW,QAAQD,EAAK,GAAG,uBAAuBJ,IAAQ,KAAK,sFAAsF,IAAIJ,CAAS;AAAA,MAElK,UAAA;AAAA,QAAA,gBAAAU;AAAA,UAAC;AAAA,UAAA;AAAA,YACG,WAAW,gBAAgBH,CAAU,IAAIC,EAAK,KAAK;AAAA,YAElD,UAAAT;AAAA,UAAA;AAAA,QAAA;AAAA,QAEL,gBAAAW;AAAA,UAAC;AAAA,UAAA;AAAA,YACG,WAAW,4DAA4DF,EAAK,KAAK;AAAA,YAEhF,UAAAN,IACG,gBAAAQ;AAAA,cAACC;AAAA,cAAA;AAAA,gBACG,UAAS;AAAA,gBACT,SAASR,MAAY,SAAYA,IAAUS,EAAOX,CAAQ;AAAA,gBAC1D,sBAAoB;AAAA,gBAEnB,UAAAA;AAAA,cAAA;AAAA,YAAA,IAGLA;AAAA,UAAA;AAAA,QAAA;AAAA,MAER;AAAA,IAAA;AAAA,EAAA;AAGZ,GAEMY,IAAkE,CAAC;AAAA,EACrE,WAAAb,IAAY;AAAA,EACZ,UAAAC;AAAA,EACA,MAAAO,IAAO;AAAA,EACP,OAAAJ,IAAQ;AAAA,EACR,YAAAG,IAAa;AACjB,wBACKd,EAAY,UAAZ,EAAqB,OAAOe,GACzB,UAAA,gBAAAE,EAACf,EAAa,UAAb,EAAsB,OAAOS,GAC1B,UAAA,gBAAAM,EAACd,EAAkB,UAAlB,EAA2B,OAAOW,GAC/B,UAAA,gBAAAG;AAAA,EAAC;AAAA,EAAA;AAAA,IACG,WAAW,4BAA4BN,IAAQ,uBAAuB,4HAA4H,IAAIJ,CAAS;AAAA,IAE9M,UAAAC;AAAA,EAAA;AACL,EAAA,CACJ,GACJ,EAAA,CACJ;AAGJY,EAAa,MAAMf;"}
|
|
@@ -1,30 +1,31 @@
|
|
|
1
1
|
import { jsxs as E, jsx as d } from "react/jsx-runtime";
|
|
2
|
-
import { useId as
|
|
3
|
-
import { createPortal as
|
|
4
|
-
import { Spinner as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
2
|
+
import { useId as yt, useState as T, useRef as b, useCallback as H, useLayoutEffect as M, useEffect as St, useInsertionEffect as vt } from "react";
|
|
3
|
+
import { createPortal as Et } from "react-dom";
|
|
4
|
+
import { Spinner as Tt } from "./Spinner.js";
|
|
5
|
+
import { CODE_TOKEN_COLOR as rt } from "./codeBlockStyles.js";
|
|
6
|
+
import { CONTROL_TEXT_SIZE as O, CONTROL_TEXT_SIZE_CLASS as nt } from "./controlTextSize.js";
|
|
7
|
+
import { pushEscapeLayer as Mt } from "./escapeLayers.js";
|
|
7
8
|
import { ensureMultiSelectPanelStyles as kt } from "./optionRowStyles.js";
|
|
8
|
-
import { usePopupLayer as
|
|
9
|
-
import { useOwnedByPopover as
|
|
9
|
+
import { usePopupLayer as Lt } from "./overlayLayers.js";
|
|
10
|
+
import { useOwnedByPopover as Rt } from "./popoverTree.js";
|
|
10
11
|
import { computeCaretMenuGeometry as It } from "./queryInputGeometry.js";
|
|
11
|
-
import { useFollowTrigger as
|
|
12
|
+
import { useFollowTrigger as _t } from "./useFollowTrigger.js";
|
|
12
13
|
const Dt = {
|
|
13
14
|
small: "h-[var(--malachite-control-height-small,28px)] px-[10px] rounded-[var(--malachite-radius-10,10px)]",
|
|
14
15
|
medium: "h-[var(--malachite-control-height-medium,32px)] px-[10px] rounded-xl",
|
|
15
16
|
large: "h-[var(--malachite-control-height-large,42px)] px-[12px] rounded-[var(--malachite-radius-xxl,14px)]"
|
|
16
|
-
},
|
|
17
|
-
key:
|
|
18
|
-
value:
|
|
17
|
+
}, Ht = {
|
|
18
|
+
key: rt.keyword,
|
|
19
|
+
value: rt.string,
|
|
19
20
|
operator: "var(--malachite-codeblock-type, rgb(12, 88, 174))",
|
|
20
21
|
negation: "var(--malachite-text-destructive, rgb(237, 53, 54))",
|
|
21
22
|
punctuation: "var(--malachite-codeblock-foreground, rgb(10, 10, 10))",
|
|
22
23
|
error: "var(--malachite-text-error, rgb(237, 53, 54))",
|
|
23
24
|
plain: "var(--malachite-text-primary, rgb(10, 10, 10))"
|
|
24
|
-
},
|
|
25
|
+
}, Ot = {
|
|
25
26
|
small: {
|
|
26
27
|
fontFamily: "inherit",
|
|
27
|
-
fontSize:
|
|
28
|
+
fontSize: O.small,
|
|
28
29
|
fontWeight: 500,
|
|
29
30
|
letterSpacing: "normal",
|
|
30
31
|
lineHeight: "normal",
|
|
@@ -32,7 +33,7 @@ const Dt = {
|
|
|
32
33
|
},
|
|
33
34
|
medium: {
|
|
34
35
|
fontFamily: "inherit",
|
|
35
|
-
fontSize:
|
|
36
|
+
fontSize: O.medium,
|
|
36
37
|
fontWeight: 500,
|
|
37
38
|
letterSpacing: "normal",
|
|
38
39
|
lineHeight: "normal",
|
|
@@ -40,13 +41,13 @@ const Dt = {
|
|
|
40
41
|
},
|
|
41
42
|
large: {
|
|
42
43
|
fontFamily: "inherit",
|
|
43
|
-
fontSize:
|
|
44
|
+
fontSize: O.large,
|
|
44
45
|
fontWeight: 500,
|
|
45
46
|
letterSpacing: "normal",
|
|
46
47
|
lineHeight: "normal",
|
|
47
48
|
padding: 0
|
|
48
49
|
}
|
|
49
|
-
}, B = 220,
|
|
50
|
+
}, B = 220, ot = 360, it = {
|
|
50
51
|
display: "flex",
|
|
51
52
|
alignItems: "center",
|
|
52
53
|
justifyContent: "center",
|
|
@@ -59,18 +60,18 @@ const Dt = {
|
|
|
59
60
|
}, Nt = (r, u) => {
|
|
60
61
|
const l = [...u.filter(
|
|
61
62
|
(n) => n.start >= 0 && n.end <= r.length && n.start < n.end
|
|
62
|
-
)].sort((n,
|
|
63
|
+
)].sort((n, k) => n.start - k.start), s = [];
|
|
63
64
|
let m = 0;
|
|
64
65
|
for (const n of l)
|
|
65
66
|
n.start < m || (s.push(n), m = n.end);
|
|
66
67
|
return s;
|
|
67
|
-
},
|
|
68
|
+
}, $t = (r, u) => {
|
|
68
69
|
const h = [];
|
|
69
70
|
let l = 0;
|
|
70
71
|
for (const s of Nt(r, u))
|
|
71
72
|
s.start > l && h.push({ start: l, end: s.start, kind: "plain" }), h.push(s), l = s.end;
|
|
72
73
|
return l < r.length && h.push({ start: l, end: r.length, kind: "plain" }), h;
|
|
73
|
-
},
|
|
74
|
+
}, Jt = ({
|
|
74
75
|
value: r,
|
|
75
76
|
onChange: u,
|
|
76
77
|
tokens: h = [],
|
|
@@ -78,95 +79,95 @@ const Dt = {
|
|
|
78
79
|
activeRange: s,
|
|
79
80
|
onAccept: m,
|
|
80
81
|
onQueryContextChange: n,
|
|
81
|
-
onSubmit:
|
|
82
|
+
onSubmit: k,
|
|
82
83
|
placeholder: K,
|
|
83
84
|
size: w = "large",
|
|
84
85
|
disabled: L = !1,
|
|
85
|
-
loading:
|
|
86
|
-
emptyMessage:
|
|
87
|
-
className:
|
|
88
|
-
style:
|
|
89
|
-
"aria-label":
|
|
90
|
-
"aria-labelledby":
|
|
86
|
+
loading: R = !1,
|
|
87
|
+
emptyMessage: W,
|
|
88
|
+
className: at = "",
|
|
89
|
+
style: lt,
|
|
90
|
+
"aria-label": st,
|
|
91
|
+
"aria-labelledby": C
|
|
91
92
|
}) => {
|
|
92
|
-
const
|
|
93
|
-
|
|
93
|
+
const N = `${yt()}-listbox`, U = (t) => `${N}-option-${t}`, [$, j] = T(!1), [P, A] = T(() => r.length), [ct, z] = T(0), [dt, I] = T(!1), [i, Y] = T(null), g = b(null), Z = b(null), G = b(null), x = b(null), V = b([]), F = b(null), pt = Array.isArray(l), y = l ?? [], S = y.length > 0, a = $ && (R || S || pt && !S && !!W) && !dt && !L, ht = Lt("dropdown", a, x);
|
|
94
|
+
Rt(
|
|
94
95
|
H(() => x.current, []),
|
|
95
96
|
a
|
|
96
97
|
);
|
|
97
|
-
const
|
|
98
|
-
|
|
98
|
+
const v = a && S && !R, c = S ? Math.min(ct, y.length - 1) : -1;
|
|
99
|
+
M(() => {
|
|
99
100
|
A((t) => Math.min(t, r.length));
|
|
100
101
|
}, [r]);
|
|
101
|
-
const
|
|
102
|
-
const t = g.current, e =
|
|
102
|
+
const _ = H(() => {
|
|
103
|
+
const t = g.current, e = Z.current;
|
|
103
104
|
t && e && (e.style.transform = `translateX(${-t.scrollLeft}px)`);
|
|
104
105
|
}, []);
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}, [r,
|
|
106
|
+
M(() => {
|
|
107
|
+
_();
|
|
108
|
+
}, [r, _]);
|
|
108
109
|
const f = H(() => {
|
|
109
|
-
var o, p,
|
|
110
|
+
var o, p, D;
|
|
110
111
|
const t = g.current;
|
|
111
112
|
if (!t)
|
|
112
113
|
return;
|
|
113
114
|
const e = (((o = G.current) == null ? void 0 : o.offsetWidth) ?? 0) - t.scrollLeft;
|
|
114
|
-
|
|
115
|
+
Y(
|
|
115
116
|
It({
|
|
116
117
|
inputRect: t.getBoundingClientRect(),
|
|
117
118
|
caretOffsetPx: e,
|
|
118
119
|
menuWidth: ((p = x.current) == null ? void 0 : p.offsetWidth) ?? B,
|
|
119
|
-
menuHeight: ((
|
|
120
|
+
menuHeight: ((D = x.current) == null ? void 0 : D.offsetHeight) ?? 0,
|
|
120
121
|
viewportWidth: window.innerWidth,
|
|
121
122
|
viewportHeight: window.innerHeight
|
|
122
123
|
})
|
|
123
124
|
);
|
|
124
125
|
}, []);
|
|
125
|
-
|
|
126
|
-
a ? f() :
|
|
127
|
-
}, [a, r,
|
|
128
|
-
const
|
|
129
|
-
|
|
126
|
+
M(() => {
|
|
127
|
+
a ? f() : Y(null);
|
|
128
|
+
}, [a, r, P, l, R, f]);
|
|
129
|
+
const ft = H(() => I(!0), []);
|
|
130
|
+
_t(a, g, f, ft), St(() => {
|
|
130
131
|
if (!a)
|
|
131
132
|
return;
|
|
132
133
|
const t = () => f();
|
|
133
134
|
window.addEventListener("resize", t);
|
|
134
|
-
const e =
|
|
135
|
+
const e = Mt(() => I(!0));
|
|
135
136
|
return () => {
|
|
136
137
|
window.removeEventListener("resize", t), e();
|
|
137
138
|
};
|
|
138
|
-
}, [a, f]),
|
|
139
|
+
}, [a, f]), M(() => {
|
|
139
140
|
const t = F.current;
|
|
140
141
|
if (t === null)
|
|
141
142
|
return;
|
|
142
143
|
F.current = null;
|
|
143
144
|
const e = g.current;
|
|
144
|
-
!e || t.value !== r || (e.setSelectionRange(t.caret, t.caret), A(t.caret), n == null || n({ value: r, caret: t.caret }),
|
|
145
|
-
}, [r]),
|
|
146
|
-
if (!
|
|
145
|
+
!e || t.value !== r || (e.setSelectionRange(t.caret, t.caret), A(t.caret), n == null || n({ value: r, caret: t.caret }), _(), f());
|
|
146
|
+
}, [r]), M(() => {
|
|
147
|
+
if (!v)
|
|
147
148
|
return;
|
|
148
149
|
const t = V.current[c], e = x.current;
|
|
149
150
|
if (!t || !e)
|
|
150
151
|
return;
|
|
151
152
|
const o = t.offsetTop + t.offsetHeight;
|
|
152
153
|
o > e.scrollTop + e.clientHeight ? e.scrollTop = o - e.clientHeight : t.offsetTop < e.scrollTop && (e.scrollTop = t.offsetTop);
|
|
153
|
-
}, [c,
|
|
154
|
+
}, [c, v]), vt(() => {
|
|
154
155
|
a && kt();
|
|
155
156
|
}, [a]);
|
|
156
157
|
const q = (t, e) => {
|
|
157
158
|
A(e), n == null || n({ value: t, caret: e });
|
|
158
|
-
}, ft = (t) => {
|
|
159
|
-
const e = t.target.value;
|
|
160
|
-
R(!1), z(0), u(e), q(e, t.target.selectionStart ?? e.length);
|
|
161
159
|
}, ut = (t) => {
|
|
160
|
+
const e = t.target.value;
|
|
161
|
+
I(!1), z(0), u(e), q(e, t.target.selectionStart ?? e.length);
|
|
162
|
+
}, mt = (t) => {
|
|
162
163
|
const e = t.currentTarget;
|
|
163
164
|
q(e.value, e.selectionStart ?? e.value.length);
|
|
164
165
|
}, X = (t) => {
|
|
165
166
|
var et;
|
|
166
|
-
const e = ((et = g.current) == null ? void 0 : et.selectionStart) ?? r.length, o = s ?? { start: e, end: e }, p = Math.max(0, Math.min(o.start, r.length)),
|
|
167
|
+
const e = ((et = g.current) == null ? void 0 : et.selectionStart) ?? r.length, o = s ?? { start: e, end: e }, p = Math.max(0, Math.min(o.start, r.length)), D = Math.max(p, Math.min(o.end, r.length)), Q = t.insertText ?? t.label, tt = r.slice(0, p) + Q + r.slice(D);
|
|
167
168
|
F.current = { value: tt, caret: p + Q.length }, u(tt), m == null || m(t);
|
|
168
|
-
},
|
|
169
|
-
if (
|
|
169
|
+
}, gt = (t) => {
|
|
170
|
+
if (v && (t.key === "ArrowDown" || t.key === "ArrowUp")) {
|
|
170
171
|
t.preventDefault();
|
|
171
172
|
const o = y.length;
|
|
172
173
|
z(
|
|
@@ -174,23 +175,23 @@ const Dt = {
|
|
|
174
175
|
);
|
|
175
176
|
return;
|
|
176
177
|
}
|
|
177
|
-
const e =
|
|
178
|
+
const e = v && c >= 0 ? y[c] : void 0;
|
|
178
179
|
if (t.key === "Enter") {
|
|
179
180
|
if (e) {
|
|
180
181
|
t.preventDefault(), X(e);
|
|
181
182
|
return;
|
|
182
183
|
}
|
|
183
|
-
|
|
184
|
+
k && (t.preventDefault(), k(r));
|
|
184
185
|
return;
|
|
185
186
|
}
|
|
186
187
|
t.key === "Tab" && e && (t.preventDefault(), X(e));
|
|
187
|
-
},
|
|
188
|
+
}, xt = $t(r, h), J = Ot[w], bt = R ? (
|
|
188
189
|
// `role="listbox"` admits only option/group children.
|
|
189
|
-
/* @__PURE__ */ E("div", { role: "presentation", style:
|
|
190
|
-
/* @__PURE__ */ d(
|
|
190
|
+
/* @__PURE__ */ E("div", { role: "presentation", style: it, children: [
|
|
191
|
+
/* @__PURE__ */ d(Tt, { size: "xxxsmall" }),
|
|
191
192
|
/* @__PURE__ */ d("span", { children: "Loading…" })
|
|
192
193
|
] })
|
|
193
|
-
) :
|
|
194
|
+
) : S ? y.map((t, e) => {
|
|
194
195
|
const o = e === c;
|
|
195
196
|
return /* @__PURE__ */ E(
|
|
196
197
|
"button",
|
|
@@ -199,7 +200,7 @@ const Dt = {
|
|
|
199
200
|
V.current[e] = p;
|
|
200
201
|
},
|
|
201
202
|
type: "button",
|
|
202
|
-
id:
|
|
203
|
+
id: U(e),
|
|
203
204
|
role: "option",
|
|
204
205
|
"aria-selected": o,
|
|
205
206
|
tabIndex: -1,
|
|
@@ -250,31 +251,31 @@ const Dt = {
|
|
|
250
251
|
},
|
|
251
252
|
t.id
|
|
252
253
|
);
|
|
253
|
-
}) :
|
|
254
|
+
}) : W ? /* @__PURE__ */ d("div", { role: "presentation", style: it, children: W }) : null, wt = L ? "" : "hover:border-[var(--malachite-text-placeholder)]";
|
|
254
255
|
return /* @__PURE__ */ E(
|
|
255
256
|
"div",
|
|
256
257
|
{
|
|
257
|
-
className: `relative w-full ${Dt[w]} bg-[var(--malachite-card-background)] border border-solid border-[var(--malachite-card-border)] ${
|
|
258
|
+
className: `relative w-full ${Dt[w]} bg-[var(--malachite-card-background)] border border-solid border-[var(--malachite-card-border)] ${wt} transition-colors flex items-center ${L ? "opacity-60 cursor-not-allowed" : ""} ${at}`,
|
|
258
259
|
style: {
|
|
259
260
|
boxShadow: $ ? "var(--malachite-shadow-accent, 0px 1px 0px 0px rgba(0, 175, 102, 0.15))" : "0px 1px 1px 0px rgba(0, 0, 0, 0.15)",
|
|
260
261
|
borderColor: $ ? "var(--malachite-control-border-hover, rgba(0, 175, 102, 0.4))" : void 0,
|
|
261
|
-
...
|
|
262
|
+
...lt
|
|
262
263
|
},
|
|
263
264
|
children: [
|
|
264
265
|
/* @__PURE__ */ E("div", { className: "relative flex-1 h-full min-w-0 overflow-hidden", children: [
|
|
265
266
|
/* @__PURE__ */ E(
|
|
266
267
|
"div",
|
|
267
268
|
{
|
|
268
|
-
ref:
|
|
269
|
+
ref: Z,
|
|
269
270
|
"aria-hidden": "true",
|
|
270
|
-
className: `absolute inset-0 flex items-center pointer-events-none ${
|
|
271
|
+
className: `absolute inset-0 flex items-center pointer-events-none ${nt[w]}`,
|
|
271
272
|
style: { ...J, whiteSpace: "pre" },
|
|
272
273
|
children: [
|
|
273
|
-
|
|
274
|
+
xt.map((t) => /* @__PURE__ */ d(
|
|
274
275
|
"span",
|
|
275
276
|
{
|
|
276
277
|
style: {
|
|
277
|
-
color:
|
|
278
|
+
color: Ht[t.kind],
|
|
278
279
|
...t.kind === "error" ? { textDecoration: "underline wavy" } : {}
|
|
279
280
|
},
|
|
280
281
|
children: r.slice(t.start, t.end)
|
|
@@ -286,7 +287,7 @@ const Dt = {
|
|
|
286
287
|
{
|
|
287
288
|
ref: G,
|
|
288
289
|
style: { position: "absolute", top: 0, left: 0, visibility: "hidden" },
|
|
289
|
-
children: r.slice(0,
|
|
290
|
+
children: r.slice(0, P)
|
|
290
291
|
}
|
|
291
292
|
)
|
|
292
293
|
]
|
|
@@ -299,27 +300,27 @@ const Dt = {
|
|
|
299
300
|
type: "text",
|
|
300
301
|
role: "combobox",
|
|
301
302
|
"aria-expanded": a,
|
|
302
|
-
"aria-controls": a ?
|
|
303
|
-
"aria-activedescendant":
|
|
303
|
+
"aria-controls": a ? N : void 0,
|
|
304
|
+
"aria-activedescendant": v && c >= 0 ? U(c) : void 0,
|
|
304
305
|
"aria-autocomplete": "list",
|
|
305
306
|
autoComplete: "off",
|
|
306
307
|
spellCheck: !1,
|
|
307
|
-
"aria-labelledby":
|
|
308
|
-
"aria-label":
|
|
308
|
+
"aria-labelledby": C,
|
|
309
|
+
"aria-label": C ? void 0 : st ?? K,
|
|
309
310
|
value: r,
|
|
310
|
-
onChange:
|
|
311
|
-
onSelect:
|
|
311
|
+
onChange: ut,
|
|
312
|
+
onSelect: mt,
|
|
312
313
|
onScroll: () => {
|
|
313
|
-
|
|
314
|
+
_(), a && f();
|
|
314
315
|
},
|
|
315
|
-
onKeyDown:
|
|
316
|
+
onKeyDown: gt,
|
|
316
317
|
onFocus: () => {
|
|
317
|
-
|
|
318
|
+
j(!0), I(!1);
|
|
318
319
|
},
|
|
319
|
-
onBlur: () =>
|
|
320
|
+
onBlur: () => j(!1),
|
|
320
321
|
placeholder: K,
|
|
321
322
|
disabled: L,
|
|
322
|
-
className: `absolute inset-0 w-full h-full bg-transparent border-none outline-none ${
|
|
323
|
+
className: `absolute inset-0 w-full h-full bg-transparent border-none outline-none ${nt[w]} placeholder:text-[var(--malachite-text-placeholder)] placeholder:font-medium disabled:cursor-not-allowed`,
|
|
323
324
|
style: {
|
|
324
325
|
...J,
|
|
325
326
|
color: "transparent",
|
|
@@ -328,14 +329,14 @@ const Dt = {
|
|
|
328
329
|
}
|
|
329
330
|
)
|
|
330
331
|
] }),
|
|
331
|
-
a &&
|
|
332
|
+
a && Et(
|
|
332
333
|
/* @__PURE__ */ d(
|
|
333
334
|
"div",
|
|
334
335
|
{
|
|
335
336
|
ref: x,
|
|
336
|
-
id:
|
|
337
|
+
id: N,
|
|
337
338
|
role: "listbox",
|
|
338
|
-
...
|
|
339
|
+
...ht,
|
|
339
340
|
onMouseDown: Wt,
|
|
340
341
|
style: {
|
|
341
342
|
position: "fixed",
|
|
@@ -346,8 +347,8 @@ const Dt = {
|
|
|
346
347
|
(i == null ? void 0 : i.width) ?? B
|
|
347
348
|
),
|
|
348
349
|
maxWidth: Math.min(
|
|
349
|
-
|
|
350
|
-
(i == null ? void 0 : i.width) ??
|
|
350
|
+
ot,
|
|
351
|
+
(i == null ? void 0 : i.width) ?? ot
|
|
351
352
|
),
|
|
352
353
|
background: "var(--malachite-card-background, rgb(255, 255, 255))",
|
|
353
354
|
border: "1px solid var(--malachite-card-border, rgb(232, 232, 232))",
|
|
@@ -359,11 +360,11 @@ const Dt = {
|
|
|
359
360
|
gap: 2,
|
|
360
361
|
maxHeight: 320,
|
|
361
362
|
overflowY: "auto",
|
|
362
|
-
fontSize:
|
|
363
|
+
fontSize: O[w],
|
|
363
364
|
visibility: i ? "visible" : "hidden",
|
|
364
365
|
opacity: i ? 1 : 0
|
|
365
366
|
},
|
|
366
|
-
children:
|
|
367
|
+
children: bt
|
|
367
368
|
}
|
|
368
369
|
),
|
|
369
370
|
document.body
|
|
@@ -373,7 +374,7 @@ const Dt = {
|
|
|
373
374
|
);
|
|
374
375
|
};
|
|
375
376
|
export {
|
|
376
|
-
|
|
377
|
-
|
|
377
|
+
Jt as QueryInput,
|
|
378
|
+
Jt as default
|
|
378
379
|
};
|
|
379
380
|
//# sourceMappingURL=QueryInput.js.map
|