@stackone/malachite 2.70.0 → 2.72.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 +12 -11
- package/dist/components/Accordion.js +59 -53
- package/dist/components/Accordion.js.map +1 -1
- package/dist/components/Alert.js +100 -75
- package/dist/components/Alert.js.map +1 -1
- package/dist/components/Button.js +89 -82
- package/dist/components/Button.js.map +1 -1
- package/dist/components/Modal.js +75 -74
- package/dist/components/Modal.js.map +1 -1
- package/dist/components/PopoverParts.js +35 -35
- package/dist/components/PopoverParts.js.map +1 -1
- package/dist/components/Search.js +30 -29
- package/dist/components/Search.js.map +1 -1
- package/dist/components/SidePanel.js +124 -106
- package/dist/components/SidePanel.js.map +1 -1
- package/dist/components/StatusPill.js +61 -0
- package/dist/components/StatusPill.js.map +1 -0
- package/dist/components/Surface.js +138 -133
- package/dist/components/Surface.js.map +1 -1
- package/dist/components/Toolbar.js +40 -33
- package/dist/components/Toolbar.js.map +1 -1
- package/dist/components/Typography/EllipsisText.js +27 -25
- package/dist/components/Typography/EllipsisText.js.map +1 -1
- package/dist/components/Typography/MarkdownBlock.js +36 -28
- package/dist/components/Typography/MarkdownBlock.js.map +1 -1
- package/dist/components/Typography/Text.js +24 -22
- package/dist/components/Typography/Text.js.map +1 -1
- package/dist/components/WizardLayout.js +81 -67
- package/dist/components/WizardLayout.js.map +1 -1
- package/dist/index.d.ts +65 -2
- package/dist/index.js +356 -354
- package/dist/index.js.map +1 -1
- package/dist/tailwind.css.js +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsx as n, jsxs as u, Fragment as
|
|
2
|
-
import { forwardRef as
|
|
1
|
+
import { jsx as n, jsxs as u, Fragment as v } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as x, useContext as f, useRef as h, useLayoutEffect as b } from "react";
|
|
3
3
|
import { Button as g } from "./Button.js";
|
|
4
4
|
import T from "./Tooltip.js";
|
|
5
5
|
import { BORDER as c, NO_SCROLLBAR as N } from "./chromeStyles.js";
|
|
@@ -7,26 +7,26 @@ import { FOCUS_RING_INSET as y } from "./focusRing.js";
|
|
|
7
7
|
import { isPlainClick as S } from "./linkClick.js";
|
|
8
8
|
import { PopoverShownContext as w } from "./popoverTree.js";
|
|
9
9
|
import { safeHref as R } from "./safeHref.js";
|
|
10
|
-
const F = ({ title: e, action: t }) => /* @__PURE__ */ u(
|
|
10
|
+
const F = ({ title: e, action: r, divider: t = !0 }) => /* @__PURE__ */ u(
|
|
11
11
|
"div",
|
|
12
12
|
{
|
|
13
|
-
className: `flex items-center justify-between border-0 border-b border-solid ${c} px-5 py-4 text-[12px] leading-[15px] font-normal text-[var(--malachite-text-dimmed,rgb(161,161,161))]`,
|
|
13
|
+
className: `flex items-center justify-between border-0 ${t ? `border-b border-solid ${c} px-5 py-4` : "px-5 pt-4 pb-[4px]"} text-[12px] leading-[15px] font-normal text-[var(--malachite-text-dimmed,rgb(161,161,161))]`,
|
|
14
14
|
children: [
|
|
15
15
|
/* @__PURE__ */ n("span", { children: e }),
|
|
16
|
-
|
|
16
|
+
r
|
|
17
17
|
]
|
|
18
18
|
}
|
|
19
19
|
), E = '[aria-current]:not([aria-current="false"]):not([aria-current=""]), [aria-selected="true"], [role="radio"][aria-checked="true"]', P = ["aria-current", "aria-selected", "aria-checked"], m = (e) => {
|
|
20
|
-
const
|
|
21
|
-
if (!
|
|
20
|
+
const r = e.querySelector(E);
|
|
21
|
+
if (!r)
|
|
22
22
|
return !1;
|
|
23
|
-
const
|
|
23
|
+
const t = e.getBoundingClientRect().top + e.clientTop, { top: l, bottom: o } = r.getBoundingClientRect(), a = l - t + e.scrollTop, i = o - t + e.scrollTop;
|
|
24
24
|
return a < e.scrollTop ? e.scrollTop = a : i > e.scrollTop + e.clientHeight && (e.scrollTop = i - e.clientHeight), !0;
|
|
25
|
-
}, U = ({ children: e, scrollToSelected:
|
|
26
|
-
const
|
|
25
|
+
}, U = ({ children: e, scrollToSelected: r = !1 }) => {
|
|
26
|
+
const t = f(w), l = h(null);
|
|
27
27
|
return b(() => {
|
|
28
28
|
const o = l.current;
|
|
29
|
-
if (!
|
|
29
|
+
if (!r || !t || !o || m(o))
|
|
30
30
|
return;
|
|
31
31
|
const a = new MutationObserver(() => {
|
|
32
32
|
m(o) && a.disconnect();
|
|
@@ -37,7 +37,7 @@ const F = ({ title: e, action: t }) => /* @__PURE__ */ u(
|
|
|
37
37
|
attributes: !0,
|
|
38
38
|
attributeFilter: P
|
|
39
39
|
}), () => a.disconnect();
|
|
40
|
-
}, [
|
|
40
|
+
}, [r, t]), /* @__PURE__ */ n(
|
|
41
41
|
"div",
|
|
42
42
|
{
|
|
43
43
|
ref: l,
|
|
@@ -45,8 +45,8 @@ const F = ({ title: e, action: t }) => /* @__PURE__ */ u(
|
|
|
45
45
|
children: e
|
|
46
46
|
}
|
|
47
47
|
);
|
|
48
|
-
}, C =
|
|
49
|
-
({ children: e },
|
|
48
|
+
}, C = x(
|
|
49
|
+
({ children: e }, r) => /* @__PURE__ */ n("div", { ref: r, className: `border-0 border-t border-solid ${c} p-2`, children: e })
|
|
50
50
|
);
|
|
51
51
|
C.displayName = "Popover.Section";
|
|
52
52
|
const M = ({ children: e }) => /* @__PURE__ */ n("div", { className: "px-3 py-2 text-[length:var(--malachite-font-size-small,13px)] text-[var(--malachite-text-dimmed,rgb(161,161,161))] select-none", children: e }), q = ({ children: e }) => /* @__PURE__ */ n("div", { className: "px-2 pt-2", children: e }), G = ({ children: e }) => /* @__PURE__ */ n(
|
|
@@ -55,13 +55,13 @@ const M = ({ children: e }) => /* @__PURE__ */ n("div", { className: "px-3 py-2
|
|
|
55
55
|
className: `border-0 border-t border-solid ${c} px-5 py-3 text-[length:var(--malachite-font-size-xsmall,11px)] leading-4 text-[var(--malachite-text-secondary,rgb(123,123,123))]`,
|
|
56
56
|
children: e
|
|
57
57
|
}
|
|
58
|
-
),
|
|
58
|
+
), $ = {
|
|
59
59
|
default: "text-[var(--malachite-text-secondary,rgb(123,123,123))]",
|
|
60
60
|
error: "text-[var(--malachite-text-error,rgb(237,53,54))]"
|
|
61
|
-
},
|
|
62
|
-
({ message: e, tone:
|
|
63
|
-
const a =
|
|
64
|
-
return /* @__PURE__ */ u(
|
|
61
|
+
}, O = (e) => e != null && e !== !1 && e !== "", _ = x(
|
|
62
|
+
({ message: e, tone: r = "default", action: t, focusable: l = !1 }, o) => {
|
|
63
|
+
const a = O(e);
|
|
64
|
+
return /* @__PURE__ */ u(v, { children: [
|
|
65
65
|
/* @__PURE__ */ n(
|
|
66
66
|
"div",
|
|
67
67
|
{
|
|
@@ -72,41 +72,41 @@ const M = ({ children: e }) => /* @__PURE__ */ n("div", { className: "px-3 py-2
|
|
|
72
72
|
children: a && /* @__PURE__ */ n(
|
|
73
73
|
"div",
|
|
74
74
|
{
|
|
75
|
-
className: `px-3 py-2 text-[length:var(--malachite-font-size-small,13px)] ${
|
|
75
|
+
className: `px-3 py-2 text-[length:var(--malachite-font-size-small,13px)] ${$[r]}`,
|
|
76
76
|
children: e
|
|
77
77
|
}
|
|
78
78
|
)
|
|
79
79
|
}
|
|
80
80
|
),
|
|
81
|
-
a &&
|
|
81
|
+
a && t && /* @__PURE__ */ n("div", { className: "px-3 pb-2", children: /* @__PURE__ */ n(
|
|
82
82
|
g,
|
|
83
83
|
{
|
|
84
84
|
variant: "outline",
|
|
85
85
|
size: "small",
|
|
86
|
-
loading:
|
|
87
|
-
onClick:
|
|
88
|
-
children:
|
|
86
|
+
loading: t.pending,
|
|
87
|
+
onClick: t.onClick,
|
|
88
|
+
children: t.label
|
|
89
89
|
}
|
|
90
90
|
) })
|
|
91
91
|
] });
|
|
92
92
|
}
|
|
93
93
|
);
|
|
94
|
-
|
|
94
|
+
_.displayName = "Popover.Status";
|
|
95
95
|
const V = ({
|
|
96
96
|
icon: e,
|
|
97
|
-
"aria-label":
|
|
98
|
-
onClick:
|
|
97
|
+
"aria-label": r,
|
|
98
|
+
onClick: t,
|
|
99
99
|
href: l,
|
|
100
100
|
disabled: o = !1,
|
|
101
101
|
tooltip: a
|
|
102
102
|
}) => {
|
|
103
|
-
const i = o ? void 0 : R(l), s = `m-0 inline-flex size-5 items-center justify-center rounded-[var(--malachite-radius-sm,4px)] border-0 bg-transparent p-0 transition-colors duration-150 [&_svg]:size-3! ${o ? "cursor-not-allowed text-[var(--malachite-text-placeholder,rgb(187,187,187))] opacity-50" : "cursor-pointer text-[var(--malachite-text-placeholder,rgb(187,187,187))] hover:bg-[var(--malachite-pillbutton-background,rgb(241,241,241))] hover:text-[var(--malachite-text-secondary,rgb(123,123,123))]"} ${y}`,
|
|
103
|
+
const i = o ? void 0 : R(l), s = `m-0 inline-flex size-5 items-center justify-center rounded-[var(--malachite-radius-sm,4px)] border-0 bg-transparent p-0 transition-colors duration-150 [&_svg]:size-3! ${o ? "cursor-not-allowed text-[var(--malachite-text-placeholder,rgb(187,187,187))] opacity-50" : "cursor-pointer text-[var(--malachite-text-placeholder,rgb(187,187,187))] hover:bg-[var(--malachite-pillbutton-background,rgb(241,241,241))] hover:text-[var(--malachite-text-secondary,rgb(123,123,123))]"} ${y}`, p = i !== void 0 ? /* @__PURE__ */ n(
|
|
104
104
|
"a",
|
|
105
105
|
{
|
|
106
106
|
href: i,
|
|
107
|
-
"aria-label":
|
|
108
|
-
onClick: (
|
|
109
|
-
S(
|
|
107
|
+
"aria-label": r,
|
|
108
|
+
onClick: (d) => {
|
|
109
|
+
S(d) && t && (d.preventDefault(), t());
|
|
110
110
|
},
|
|
111
111
|
className: `no-underline ${s}`,
|
|
112
112
|
children: e
|
|
@@ -115,14 +115,14 @@ const V = ({
|
|
|
115
115
|
"button",
|
|
116
116
|
{
|
|
117
117
|
type: "button",
|
|
118
|
-
"aria-label":
|
|
118
|
+
"aria-label": r,
|
|
119
119
|
"aria-disabled": o || void 0,
|
|
120
|
-
onClick: o ? void 0 :
|
|
120
|
+
onClick: o ? void 0 : t,
|
|
121
121
|
className: s,
|
|
122
122
|
children: e
|
|
123
123
|
}
|
|
124
124
|
);
|
|
125
|
-
return a ? /* @__PURE__ */ n(T, { text: a, children:
|
|
125
|
+
return a ? /* @__PURE__ */ n(T, { text: a, children: p }) : p;
|
|
126
126
|
};
|
|
127
127
|
export {
|
|
128
128
|
V as PopoverAction,
|
|
@@ -132,6 +132,6 @@ export {
|
|
|
132
132
|
G as PopoverNote,
|
|
133
133
|
q as PopoverSearch,
|
|
134
134
|
C as PopoverSection,
|
|
135
|
-
|
|
135
|
+
_ as PopoverStatus
|
|
136
136
|
};
|
|
137
137
|
//# sourceMappingURL=PopoverParts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PopoverParts.js","sources":["../../src/components/PopoverParts.tsx"],"sourcesContent":["import React, { forwardRef, useContext, useLayoutEffect, useRef } from 'react';\nimport Button from './Button';\nimport Tooltip from './Tooltip';\nimport { BORDER, NO_SCROLLBAR } from './chromeStyles';\nimport { FOCUS_RING_INSET } from './focusRing';\nimport { isPlainClick } from './linkClick';\nimport { PopoverShownContext } from './popoverTree';\nimport { safeHref } from './safeHref';\n\nexport interface PopoverHeaderProps {\n title: string;\n action?: React.ReactNode;\n}\n\nexport const PopoverHeader: React.FC<PopoverHeaderProps> = ({ title, action }) => (\n <div\n className={`flex items-center justify-between border-0 border-b border-solid ${BORDER} px-5 py-4 text-[12px] leading-[15px] font-normal text-[var(--malachite-text-dimmed,rgb(161,161,161))]`}\n >\n <span>{title}</span>\n {action}\n </div>\n);\n\nconst SELECTED_ROW =\n '[aria-current]:not([aria-current=\"false\"]):not([aria-current=\"\"]), [aria-selected=\"true\"], [role=\"radio\"][aria-checked=\"true\"]';\nconst SELECTION_ATTRIBUTES = ['aria-current', 'aria-selected', 'aria-checked'];\n\n// Not `scrollIntoView`: that also scrolls every scrollable ancestor, the page included.\nconst scrollSelectedRowIntoView = (list: HTMLElement): boolean => {\n const row = list.querySelector<HTMLElement>(SELECTED_ROW);\n if (!row) {\n return false;\n }\n const listTop = list.getBoundingClientRect().top + list.clientTop;\n const { top, bottom } = row.getBoundingClientRect();\n const rowTop = top - listTop + list.scrollTop;\n const rowBottom = bottom - listTop + list.scrollTop;\n if (rowTop < list.scrollTop) {\n list.scrollTop = rowTop;\n } else if (rowBottom > list.scrollTop + list.clientHeight) {\n list.scrollTop = rowBottom - list.clientHeight;\n }\n return true;\n};\n\nexport interface PopoverListProps {\n children: React.ReactNode;\n /**\n * Scrolls the list to its selected row (`aria-current`, `aria-selected` or a checked radio)\n * each time the popover is shown, once that row mounts. Only the list scrolls.\n */\n scrollToSelected?: boolean;\n}\n\nexport const PopoverList: React.FC<PopoverListProps> = ({ children, scrollToSelected = false }) => {\n const shown = useContext(PopoverShownContext);\n const listRef = useRef<HTMLDivElement>(null);\n\n // Before paint, so a shown panel never draws a frame at the top and then jumps.\n useLayoutEffect(() => {\n const list = listRef.current;\n if (!scrollToSelected || !shown || !list || scrollSelectedRowIntoView(list)) {\n return;\n }\n const observer = new MutationObserver(() => {\n if (scrollSelectedRowIntoView(list)) {\n observer.disconnect();\n }\n });\n observer.observe(list, {\n childList: true,\n subtree: true,\n attributes: true,\n attributeFilter: SELECTION_ATTRIBUTES,\n });\n return () => observer.disconnect();\n }, [scrollToSelected, shown]);\n\n return (\n <div\n ref={listRef}\n className={`flex max-h-80 flex-col gap-[2px] overflow-y-auto p-2 ${NO_SCROLLBAR}`}\n >\n {children}\n </div>\n );\n};\n\nexport const PopoverSection = forwardRef<HTMLDivElement, { children: React.ReactNode }>(\n ({ children }, ref) => (\n <div ref={ref} className={`border-0 border-t border-solid ${BORDER} p-2`}>\n {children}\n </div>\n ),\n);\nPopoverSection.displayName = 'Popover.Section';\n\nexport const PopoverEmpty: React.FC<{ children: React.ReactNode }> = ({ children }) => (\n <div className=\"px-3 py-2 text-[length:var(--malachite-font-size-small,13px)] text-[var(--malachite-text-dimmed,rgb(161,161,161))] select-none\">\n {children}\n </div>\n);\n\nexport const PopoverSearch: React.FC<{ children: React.ReactNode }> = ({ children }) => (\n <div className=\"px-2 pt-2\">{children}</div>\n);\n\nexport const PopoverNote: React.FC<{ children: React.ReactNode }> = ({ children }) => (\n <div\n className={`border-0 border-t border-solid ${BORDER} px-5 py-3 text-[length:var(--malachite-font-size-xsmall,11px)] leading-4 text-[var(--malachite-text-secondary,rgb(123,123,123))]`}\n >\n {children}\n </div>\n);\n\nexport type PopoverStatusTone = 'default' | 'error';\n\nexport interface PopoverStatusAction {\n label: string;\n onClick: () => void;\n /** Shows the button's spinner and ignores clicks, e.g. while a retry is in flight. */\n pending?: boolean;\n}\n\nexport interface PopoverStatusProps {\n /**\n * What the panel is waiting on, or why it is empty. Clear it rather than unmount the part:\n * only a region already in the tree announces a new message.\n */\n message?: React.ReactNode;\n tone?: PopoverStatusTone;\n /** A button under the message that resolves it, such as Retry. Shown only with a message. */\n action?: PopoverStatusAction;\n /** Lets the region take focus from script (`tabIndex={-1}`), e.g. from `initialFocus`. */\n focusable?: boolean;\n}\n\nconst STATUS_TONE_TEXT: Record<PopoverStatusTone, string> = {\n default: 'text-[var(--malachite-text-secondary,rgb(123,123,123))]',\n error: 'text-[var(--malachite-text-error,rgb(237,53,54))]',\n};\n\nconst hasMessage = (message: React.ReactNode): boolean =>\n message !== undefined && message !== null && message !== false && message !== '';\n\nexport const PopoverStatus = forwardRef<HTMLDivElement, PopoverStatusProps>(\n ({ message, tone = 'default', action, focusable = false }, ref) => {\n const shown = hasMessage(message);\n return (\n <>\n {/* Stays `status` while empty and for errors: a role or aria-hidden changed with the\n text is not reliably announced. No ring: a focus target, not a control. */}\n <div\n ref={ref}\n role=\"status\"\n tabIndex={focusable ? -1 : undefined}\n className={shown ? 'outline-none' : 'sr-only'}\n >\n {shown && (\n <div\n className={`px-3 py-2 text-[length:var(--malachite-font-size-small,13px)] ${STATUS_TONE_TEXT[tone]}`}\n >\n {message}\n </div>\n )}\n </div>\n {shown && action && (\n <div className=\"px-3 pb-2\">\n <Button\n variant=\"outline\"\n size=\"small\"\n loading={action.pending}\n onClick={action.onClick}\n >\n {action.label}\n </Button>\n </div>\n )}\n </>\n );\n },\n);\nPopoverStatus.displayName = 'Popover.Status';\n\nexport interface PopoverActionProps {\n icon: React.ReactNode;\n 'aria-label': string;\n onClick?: () => void;\n /** Renders a link; a plain click runs `onClick` instead of following it, when one is given. */\n href?: string;\n disabled?: boolean;\n tooltip?: string;\n}\n\nexport const PopoverAction: React.FC<PopoverActionProps> = ({\n icon,\n 'aria-label': ariaLabel,\n onClick,\n href: rawHref,\n disabled = false,\n tooltip,\n}) => {\n const href = disabled ? undefined : safeHref(rawHref);\n const className = `m-0 inline-flex size-5 items-center justify-center rounded-[var(--malachite-radius-sm,4px)] border-0 bg-transparent p-0 transition-colors duration-150 [&_svg]:size-3! ${disabled ? 'cursor-not-allowed text-[var(--malachite-text-placeholder,rgb(187,187,187))] opacity-50' : `cursor-pointer text-[var(--malachite-text-placeholder,rgb(187,187,187))] hover:bg-[var(--malachite-pillbutton-background,rgb(241,241,241))] hover:text-[var(--malachite-text-secondary,rgb(123,123,123))]`} ${FOCUS_RING_INSET}`;\n const button =\n href !== undefined ? (\n <a\n href={href}\n aria-label={ariaLabel}\n onClick={(event) => {\n if (isPlainClick(event) && onClick) {\n event.preventDefault();\n onClick();\n }\n }}\n className={`no-underline ${className}`}\n >\n {icon}\n </a>\n ) : (\n <button\n type=\"button\"\n aria-label={ariaLabel}\n aria-disabled={disabled || undefined}\n onClick={disabled ? undefined : onClick}\n className={className}\n >\n {icon}\n </button>\n );\n return tooltip ? <Tooltip text={tooltip}>{button}</Tooltip> : button;\n};\n"],"names":["PopoverHeader","title","action","jsxs","BORDER","jsx","SELECTED_ROW","SELECTION_ATTRIBUTES","scrollSelectedRowIntoView","list","row","listTop","top","bottom","rowTop","rowBottom","PopoverList","children","scrollToSelected","shown","useContext","PopoverShownContext","listRef","useRef","useLayoutEffect","observer","NO_SCROLLBAR","PopoverSection","forwardRef","ref","PopoverEmpty","PopoverSearch","PopoverNote","STATUS_TONE_TEXT","hasMessage","message","PopoverStatus","tone","focusable","Fragment","Button","PopoverAction","icon","ariaLabel","onClick","rawHref","disabled","tooltip","href","safeHref","className","FOCUS_RING_INSET","button","event","isPlainClick","Tooltip"],"mappings":";;;;;;;;;AAcO,MAAMA,IAA8C,CAAC,EAAE,OAAAC,GAAO,QAAAC,QACjE,gBAAAC;AAAA,EAAC;AAAA,EAAA;AAAA,IACG,WAAW,oEAAoEC,CAAM;AAAA,IAErF,UAAA;AAAA,MAAA,gBAAAC,EAAC,UAAM,UAAAJ,EAAA,CAAM;AAAA,MACZC;AAAA,IAAA;AAAA,EAAA;AACL,GAGEI,IACF,kIACEC,IAAuB,CAAC,gBAAgB,iBAAiB,cAAc,GAGvEC,IAA4B,CAACC,MAA+B;AAC9D,QAAMC,IAAMD,EAAK,cAA2BH,CAAY;AACxD,MAAI,CAACI;AACD,WAAO;AAEX,QAAMC,IAAUF,EAAK,sBAAA,EAAwB,MAAMA,EAAK,WAClD,EAAE,KAAAG,GAAK,QAAAC,MAAWH,EAAI,sBAAA,GACtBI,IAASF,IAAMD,IAAUF,EAAK,WAC9BM,IAAYF,IAASF,IAAUF,EAAK;AAC1C,SAAIK,IAASL,EAAK,YACdA,EAAK,YAAYK,IACVC,IAAYN,EAAK,YAAYA,EAAK,iBACzCA,EAAK,YAAYM,IAAYN,EAAK,eAE/B;AACX,GAWaO,IAA0C,CAAC,EAAE,UAAAC,GAAU,kBAAAC,IAAmB,SAAY;AAC/F,QAAMC,IAAQC,EAAWC,CAAmB,GACtCC,IAAUC,EAAuB,IAAI;AAG3C,SAAAC,EAAgB,MAAM;AAClB,UAAMf,IAAOa,EAAQ;AACrB,QAAI,CAACJ,KAAoB,CAACC,KAAS,CAACV,KAAQD,EAA0BC,CAAI;AACtE;AAEJ,UAAMgB,IAAW,IAAI,iBAAiB,MAAM;AACxC,MAAIjB,EAA0BC,CAAI,KAC9BgB,EAAS,WAAA;AAAA,IAEjB,CAAC;AACD,WAAAA,EAAS,Q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F;AAAA,MAChC,WAAAM;AAAA,MAEC,UAAAR;AAAA,IAAA;AAAA,EAAA;AAGb,SAAOK,IAAU,gBAAA1C,EAACkD,GAAA,EAAQ,MAAMR,GAAU,aAAO,IAAaK;AAClE;"}
|
|
1
|
+
{"version":3,"file":"PopoverParts.js","sources":["../../src/components/PopoverParts.tsx"],"sourcesContent":["import React, { forwardRef, useContext, useLayoutEffect, useRef } from 'react';\nimport Button from './Button';\nimport Tooltip from './Tooltip';\nimport { BORDER, NO_SCROLLBAR } from './chromeStyles';\nimport { FOCUS_RING_INSET } from './focusRing';\nimport { isPlainClick } from './linkClick';\nimport { PopoverShownContext } from './popoverTree';\nimport { safeHref } from './safeHref';\n\nexport interface PopoverHeaderProps {\n title: string;\n action?: React.ReactNode;\n /** `false` drops the rule and sits the header 4px over the list. */\n divider?: boolean;\n}\n\nexport const PopoverHeader: React.FC<PopoverHeaderProps> = ({ title, action, divider = true }) => (\n <div\n className={`flex items-center justify-between border-0 ${divider ? `border-b border-solid ${BORDER} px-5 py-4` : 'px-5 pt-4 pb-[4px]'} text-[12px] leading-[15px] font-normal text-[var(--malachite-text-dimmed,rgb(161,161,161))]`}\n >\n <span>{title}</span>\n {action}\n </div>\n);\n\nconst SELECTED_ROW =\n '[aria-current]:not([aria-current=\"false\"]):not([aria-current=\"\"]), [aria-selected=\"true\"], [role=\"radio\"][aria-checked=\"true\"]';\nconst SELECTION_ATTRIBUTES = ['aria-current', 'aria-selected', 'aria-checked'];\n\n// Not `scrollIntoView`: that also scrolls every scrollable ancestor, the page included.\nconst scrollSelectedRowIntoView = (list: HTMLElement): boolean => {\n const row = list.querySelector<HTMLElement>(SELECTED_ROW);\n if (!row) {\n return false;\n }\n const listTop = list.getBoundingClientRect().top + list.clientTop;\n const { top, bottom } = row.getBoundingClientRect();\n const rowTop = top - listTop + list.scrollTop;\n const rowBottom = bottom - listTop + list.scrollTop;\n if (rowTop < list.scrollTop) {\n list.scrollTop = rowTop;\n } else if (rowBottom > list.scrollTop + list.clientHeight) {\n list.scrollTop = rowBottom - list.clientHeight;\n }\n return true;\n};\n\nexport interface PopoverListProps {\n children: React.ReactNode;\n /**\n * Scrolls the list to its selected row (`aria-current`, `aria-selected` or a checked radio)\n * each time the popover is shown, once that row mounts. Only the list scrolls.\n */\n scrollToSelected?: boolean;\n}\n\nexport const PopoverList: React.FC<PopoverListProps> = ({ children, scrollToSelected = false }) => {\n const shown = useContext(PopoverShownContext);\n const listRef = useRef<HTMLDivElement>(null);\n\n // Before paint, so a shown panel never draws a frame at the top and then jumps.\n useLayoutEffect(() => {\n const list = listRef.current;\n if (!scrollToSelected || !shown || !list || scrollSelectedRowIntoView(list)) {\n return;\n }\n const observer = new MutationObserver(() => {\n if (scrollSelectedRowIntoView(list)) {\n observer.disconnect();\n }\n });\n observer.observe(list, {\n childList: true,\n subtree: true,\n attributes: true,\n attributeFilter: SELECTION_ATTRIBUTES,\n });\n return () => observer.disconnect();\n }, [scrollToSelected, shown]);\n\n return (\n <div\n ref={listRef}\n className={`flex max-h-80 flex-col gap-[2px] overflow-y-auto p-2 ${NO_SCROLLBAR}`}\n >\n {children}\n </div>\n );\n};\n\nexport const PopoverSection = forwardRef<HTMLDivElement, { children: React.ReactNode }>(\n ({ children }, ref) => (\n <div ref={ref} className={`border-0 border-t border-solid ${BORDER} p-2`}>\n {children}\n </div>\n ),\n);\nPopoverSection.displayName = 'Popover.Section';\n\nexport const PopoverEmpty: React.FC<{ children: React.ReactNode }> = ({ children }) => (\n <div className=\"px-3 py-2 text-[length:var(--malachite-font-size-small,13px)] text-[var(--malachite-text-dimmed,rgb(161,161,161))] select-none\">\n {children}\n </div>\n);\n\nexport const PopoverSearch: React.FC<{ children: React.ReactNode }> = ({ children }) => (\n <div className=\"px-2 pt-2\">{children}</div>\n);\n\nexport const PopoverNote: React.FC<{ children: React.ReactNode }> = ({ children }) => (\n <div\n className={`border-0 border-t border-solid ${BORDER} px-5 py-3 text-[length:var(--malachite-font-size-xsmall,11px)] leading-4 text-[var(--malachite-text-secondary,rgb(123,123,123))]`}\n >\n {children}\n </div>\n);\n\nexport type PopoverStatusTone = 'default' | 'error';\n\nexport interface PopoverStatusAction {\n label: string;\n onClick: () => void;\n /** Shows the button's spinner and ignores clicks, e.g. while a retry is in flight. */\n pending?: boolean;\n}\n\nexport interface PopoverStatusProps {\n /**\n * What the panel is waiting on, or why it is empty. Clear it rather than unmount the part:\n * only a region already in the tree announces a new message.\n */\n message?: React.ReactNode;\n tone?: PopoverStatusTone;\n /** A button under the message that resolves it, such as Retry. Shown only with a message. */\n action?: PopoverStatusAction;\n /** Lets the region take focus from script (`tabIndex={-1}`), e.g. from `initialFocus`. */\n focusable?: boolean;\n}\n\nconst STATUS_TONE_TEXT: Record<PopoverStatusTone, string> = {\n default: 'text-[var(--malachite-text-secondary,rgb(123,123,123))]',\n error: 'text-[var(--malachite-text-error,rgb(237,53,54))]',\n};\n\nconst hasMessage = (message: React.ReactNode): boolean =>\n message !== undefined && message !== null && message !== false && message !== '';\n\nexport const PopoverStatus = forwardRef<HTMLDivElement, PopoverStatusProps>(\n ({ message, tone = 'default', action, focusable = false }, ref) => {\n const shown = hasMessage(message);\n return (\n <>\n {/* Stays `status` while empty and for errors: a role or aria-hidden changed with the\n text is not reliably announced. No ring: a focus target, not a control. */}\n <div\n ref={ref}\n role=\"status\"\n tabIndex={focusable ? -1 : undefined}\n className={shown ? 'outline-none' : 'sr-only'}\n >\n {shown && (\n <div\n className={`px-3 py-2 text-[length:var(--malachite-font-size-small,13px)] ${STATUS_TONE_TEXT[tone]}`}\n >\n {message}\n </div>\n )}\n </div>\n {shown && action && (\n <div className=\"px-3 pb-2\">\n <Button\n variant=\"outline\"\n size=\"small\"\n loading={action.pending}\n onClick={action.onClick}\n >\n {action.label}\n </Button>\n </div>\n )}\n </>\n );\n },\n);\nPopoverStatus.displayName = 'Popover.Status';\n\nexport interface PopoverActionProps {\n icon: React.ReactNode;\n 'aria-label': string;\n onClick?: () => void;\n /** Renders a link; a plain click runs `onClick` instead of following it, when one is given. */\n href?: string;\n disabled?: boolean;\n tooltip?: string;\n}\n\nexport const PopoverAction: React.FC<PopoverActionProps> = ({\n icon,\n 'aria-label': ariaLabel,\n onClick,\n href: rawHref,\n disabled = false,\n tooltip,\n}) => {\n const href = disabled ? undefined : safeHref(rawHref);\n const className = `m-0 inline-flex size-5 items-center justify-center rounded-[var(--malachite-radius-sm,4px)] border-0 bg-transparent p-0 transition-colors duration-150 [&_svg]:size-3! ${disabled ? 'cursor-not-allowed text-[var(--malachite-text-placeholder,rgb(187,187,187))] opacity-50' : `cursor-pointer text-[var(--malachite-text-placeholder,rgb(187,187,187))] hover:bg-[var(--malachite-pillbutton-background,rgb(241,241,241))] hover:text-[var(--malachite-text-secondary,rgb(123,123,123))]`} ${FOCUS_RING_INSET}`;\n const button =\n href !== undefined ? (\n <a\n href={href}\n aria-label={ariaLabel}\n onClick={(event) => {\n if (isPlainClick(event) && onClick) {\n event.preventDefault();\n onClick();\n }\n }}\n className={`no-underline ${className}`}\n >\n {icon}\n </a>\n ) : (\n <button\n type=\"button\"\n aria-label={ariaLabel}\n aria-disabled={disabled || undefined}\n onClick={disabled ? undefined : onClick}\n className={className}\n >\n {icon}\n </button>\n );\n return tooltip ? <Tooltip text={tooltip}>{button}</Tooltip> : button;\n};\n"],"names":["PopoverHeader","title","action","divider","jsxs","BORDER","jsx","SELECTED_ROW","SELECTION_ATTRIBUTES","scrollSelectedRowIntoView","list","row","listTop","top","bottom","rowTop","rowBottom","PopoverList","children","scrollToSelected","shown","useContext","PopoverShownContext","listRef","useRef","useLayoutEffect","observer","NO_SCROLLBAR","PopoverSection","forwardRef","ref","PopoverEmpty","PopoverSearch","PopoverNote","STATUS_TONE_TEXT","hasMessage","message","PopoverStatus","tone","focusable","Fragment","Button","PopoverAction","icon","ariaLabel","onClick","rawHref","disabled","tooltip","href","safeHref","className","FOCUS_RING_INSET","button","event","isPlainClick","Tooltip"],"mappings":";;;;;;;;;AAgBO,MAAMA,IAA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U,aAAO,IAAaK;AAClE;"}
|
|
@@ -1,56 +1,57 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { composeRefs as
|
|
6
|
-
import { CONTROL_TEXT_SIZE_CLASS as
|
|
7
|
-
import { controlWidthStyle as
|
|
1
|
+
import { jsxs as A, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as B, useState as D, useRef as M, useMemo as Z } from "react";
|
|
3
|
+
import z from "./CustomIcons/DismissIcon.js";
|
|
4
|
+
import L from "./CustomIcons/SearchIcon.js";
|
|
5
|
+
import { composeRefs as P } from "./composeRefs.js";
|
|
6
|
+
import { CONTROL_TEXT_SIZE_CLASS as X } from "./controlTextSize.js";
|
|
7
|
+
import { controlWidthStyle as G } from "./controlWidth.js";
|
|
8
8
|
import { FOCUS_RING as U } from "./focusRing.js";
|
|
9
|
-
const W = {
|
|
9
|
+
const W = "text-[length:var(--malachite-font-size-medium,14px)]", Y = {
|
|
10
10
|
small: "h-[var(--malachite-control-height-small,28px)] gap-[6px] px-[10px] rounded-[var(--malachite-radius-10,10px)]",
|
|
11
11
|
medium: "h-[var(--malachite-control-height-medium,32px)] gap-[10px] px-[10px] rounded-xl",
|
|
12
12
|
large: "h-[var(--malachite-control-height-large,42px)] gap-[12px] px-[12px] rounded-[var(--malachite-radius-xxl,14px)]"
|
|
13
|
-
},
|
|
13
|
+
}, q = 15, H = (c) => c.preventDefault(), oe = B(function({
|
|
14
14
|
value: s,
|
|
15
15
|
onChange: n,
|
|
16
16
|
placeholder: i,
|
|
17
17
|
size: p = "large",
|
|
18
18
|
variant: g = "default",
|
|
19
|
+
textSize: S = "control",
|
|
19
20
|
disabled: t = !1,
|
|
20
|
-
autoFocus:
|
|
21
|
-
className:
|
|
22
|
-
width:
|
|
23
|
-
style:
|
|
24
|
-
clearable:
|
|
21
|
+
autoFocus: C = !1,
|
|
22
|
+
className: y = "",
|
|
23
|
+
width: $,
|
|
24
|
+
style: E,
|
|
25
|
+
clearable: I = !1,
|
|
25
26
|
onClear: o,
|
|
26
27
|
onKeyDown: l,
|
|
27
28
|
"aria-label": m,
|
|
28
29
|
"aria-labelledby": d
|
|
29
30
|
}, h) {
|
|
30
|
-
const [x, u] =
|
|
31
|
+
const [x, u] = D(!1), f = M(null), _ = Z(() => P(h, f), [h]), b = I && s.length > 0 && !t, v = () => {
|
|
31
32
|
var e;
|
|
32
33
|
n(""), o == null || o(), (e = f.current) == null || e.focus();
|
|
33
34
|
}, k = (e) => {
|
|
34
35
|
l == null || l(e);
|
|
35
36
|
const j = e.nativeEvent.isComposing || e.nativeEvent.keyCode === 229;
|
|
36
37
|
e.key !== "Escape" || e.defaultPrevented || j || !b || (e.preventDefault(), e.stopPropagation(), v());
|
|
37
|
-
}, r = g === "muted", w = r ? "bg-[var(--malachite-card-border)]" : "bg-[var(--malachite-card-background)]", N = r ? "border-transparent" : "border-[var(--malachite-card-border)]", R = t ? "" : "hover:border-[var(--malachite-text-placeholder)]",
|
|
38
|
-
return /* @__PURE__ */
|
|
38
|
+
}, r = g === "muted", w = r ? "bg-[var(--malachite-card-border)]" : "bg-[var(--malachite-card-background)]", N = r ? "border-transparent" : "border-[var(--malachite-card-border)]", R = t ? "" : "hover:border-[var(--malachite-text-placeholder)]", O = r ? "text-[var(--malachite-text-secondary)]" : "text-[var(--malachite-text-placeholder)]", T = r ? "placeholder:text-[var(--malachite-text-secondary)]" : "placeholder:text-[var(--malachite-text-placeholder)]", F = r ? "none" : x ? "var(--malachite-shadow-accent, 0px 1px 0px 0px rgba(0, 175, 102, 0.15))" : "0px 1px 1px 0px rgba(0, 0, 0, 0.15)";
|
|
39
|
+
return /* @__PURE__ */ A(
|
|
39
40
|
"div",
|
|
40
41
|
{
|
|
41
|
-
className: `w-full ${w} border border-solid ${N} ${R} transition-colors flex items-center ${
|
|
42
|
+
className: `w-full ${w} border border-solid ${N} ${R} transition-colors flex items-center ${Y[p]} ${t ? "opacity-60 cursor-not-allowed" : ""} ${y}`,
|
|
42
43
|
style: {
|
|
43
|
-
boxShadow:
|
|
44
|
+
boxShadow: F,
|
|
44
45
|
borderColor: x ? "var(--malachite-control-border-hover, rgba(0, 175, 102, 0.4))" : void 0,
|
|
45
|
-
...
|
|
46
|
-
|
|
46
|
+
...G($),
|
|
47
|
+
...E
|
|
47
48
|
},
|
|
48
49
|
children: [
|
|
49
|
-
/* @__PURE__ */ a(
|
|
50
|
+
/* @__PURE__ */ a(L, { size: q, className: `${O} shrink-0` }),
|
|
50
51
|
/* @__PURE__ */ a(
|
|
51
52
|
"input",
|
|
52
53
|
{
|
|
53
|
-
ref:
|
|
54
|
+
ref: _,
|
|
54
55
|
type: "text",
|
|
55
56
|
value: s,
|
|
56
57
|
onChange: (e) => n(e.target.value),
|
|
@@ -61,8 +62,8 @@ const W = {
|
|
|
61
62
|
"aria-label": d ? m : m ?? i ?? "Search",
|
|
62
63
|
"aria-labelledby": d,
|
|
63
64
|
disabled: t,
|
|
64
|
-
autoFocus:
|
|
65
|
-
className: `flex-1 bg-transparent border-none outline-none ${
|
|
65
|
+
autoFocus: C,
|
|
66
|
+
className: `flex-1 bg-transparent border-none outline-none ${S === "body" ? W : X[p]} font-medium text-[var(--malachite-text-primary)] ${T} placeholder:font-medium disabled:cursor-not-allowed min-w-0`
|
|
66
67
|
}
|
|
67
68
|
),
|
|
68
69
|
b && /* @__PURE__ */ a(
|
|
@@ -70,10 +71,10 @@ const W = {
|
|
|
70
71
|
{
|
|
71
72
|
type: "button",
|
|
72
73
|
"aria-label": "Clear search",
|
|
73
|
-
onMouseDown:
|
|
74
|
+
onMouseDown: H,
|
|
74
75
|
onClick: v,
|
|
75
76
|
className: `shrink-0 flex items-center justify-center w-6 h-6 -mr-[5px] bg-transparent border-none rounded text-[var(--malachite-text-placeholder)] hover:text-[var(--malachite-text-primary)] cursor-pointer ${U}`,
|
|
76
|
-
children: /* @__PURE__ */ a(
|
|
77
|
+
children: /* @__PURE__ */ a(z, { size: 10 })
|
|
77
78
|
}
|
|
78
79
|
)
|
|
79
80
|
]
|
|
@@ -81,7 +82,7 @@ const W = {
|
|
|
81
82
|
);
|
|
82
83
|
});
|
|
83
84
|
export {
|
|
84
|
-
|
|
85
|
-
|
|
85
|
+
oe as Search,
|
|
86
|
+
oe as default
|
|
86
87
|
};
|
|
87
88
|
//# sourceMappingURL=Search.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Search.js","sources":["../../src/components/Search.tsx"],"sourcesContent":["import React, { forwardRef, useMemo, useRef, useState } from 'react';\nimport DismissIcon from './CustomIcons/DismissIcon';\nimport SearchIcon from './CustomIcons/SearchIcon';\nimport { composeRefs } from './composeRefs';\nimport { CONTROL_TEXT_SIZE_CLASS } from './controlTextSize';\nimport { controlWidthStyle } from './controlWidth';\nimport { FOCUS_RING } from './focusRing';\n\nexport type SearchSize = 'small' | 'medium' | 'large';\nexport type SearchVariant = 'default' | 'muted';\n\n// Figma \"Search Element - Standard\": Small 28px, Medium 32px, Large 42px, with the radius\n// tracking the tier (10/12/14) and the icon staying 15px throughout.\nconst SIZE_CLASSES: Record<SearchSize, string> = {\n small: 'h-[var(--malachite-control-height-small,28px)] gap-[6px] px-[10px] rounded-[var(--malachite-radius-10,10px)]',\n medium: 'h-[var(--malachite-control-height-medium,32px)] gap-[10px] px-[10px] rounded-xl',\n large: 'h-[var(--malachite-control-height-large,42px)] gap-[12px] px-[12px] rounded-[var(--malachite-radius-xxl,14px)]',\n};\n\nconst ICON_SIZE = 15;\n\nexport interface SearchProps {\n value: string;\n onChange: (value: string) => void;\n placeholder?: string;\n /** 'large' (42px) for form inputs; 'medium' (32px) for toolbars; 'small' (28px) in a table. */\n size?: SearchSize;\n variant?: SearchVariant;\n disabled?: boolean;\n autoFocus?: boolean;\n className?: string;\n width?: string | number;\n style?: React.CSSProperties;\n /**\n * Shows a clear button while the field has text, and lets Escape clear it. Either way focus\n * stays in the field, and Escape that clears is not also passed to a surrounding panel.\n */\n clearable?: boolean;\n /** Called after `onChange('')` when the clear button or Escape empties the field. */\n onClear?: () => void;\n /** Runs before Search's own Escape handling; call `preventDefault()` to skip it. */\n onKeyDown?: React.KeyboardEventHandler<HTMLInputElement>;\n /** The field's accessible name. Falls back to the placeholder, then \"Search\". */\n 'aria-label'?: string;\n 'aria-labelledby'?: string;\n}\n\nconst keepFocus = (event: React.MouseEvent) => event.preventDefault();\n\n/** Forwards a ref to the input, so a consumer can focus the field. */\nconst Search = forwardRef<HTMLInputElement, SearchProps>(function Search(\n {\n value,\n onChange,\n placeholder,\n size = 'large',\n variant = 'default',\n disabled = false,\n autoFocus = false,\n className = '',\n width,\n style,\n clearable = false,\n onClear,\n onKeyDown,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n },\n ref,\n) {\n const [focused, setFocused] = useState(false);\n const inputRef = useRef<HTMLInputElement>(null);\n const setInputRef = useMemo(() => composeRefs(ref, inputRef), [ref]);\n const canClear = clearable && value.length > 0 && !disabled;\n\n const clear = () => {\n onChange('');\n onClear?.();\n inputRef.current?.focus();\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n onKeyDown?.(event);\n // Escape mid-composition cancels the IME's candidate text, not the query.\n const composing = event.nativeEvent.isComposing || event.nativeEvent.keyCode === 229;\n if (event.key !== 'Escape' || event.defaultPrevented || composing || !canClear) {\n return;\n }\n // Both, as Dropdown does: an ancestor's own onKeyDown runs before the escape layers.\n event.preventDefault();\n event.stopPropagation();\n clear();\n };\n const isMuted = variant === 'muted';\n\n // Muted variant: a borderless search that sits on a surface (no shadow). Default:\n // white field with border + subtle shadow. Both keep a visible focus border.\n // The fill is the Border colour by design; the dimmed grey vanishes on a sunken page.\n const bgClass = isMuted\n ? 'bg-[var(--malachite-card-border)]'\n : 'bg-[var(--malachite-card-background)]';\n const restingBorderClass = isMuted\n ? 'border-transparent'\n : 'border-[var(--malachite-card-border)]';\n // Hover darkens the border; focus (inline below) takes precedence.\n const hoverBorderClass = disabled ? '' : 'hover:border-[var(--malachite-text-placeholder)]';\n const iconColorClass = isMuted\n ? 'text-[var(--malachite-text-secondary)]'\n : 'text-[var(--malachite-text-placeholder)]';\n const placeholderColorClass = isMuted\n ? 'placeholder:text-[var(--malachite-text-secondary)]'\n : 'placeholder:text-[var(--malachite-text-placeholder)]';\n const boxShadow = isMuted\n ? 'none'\n : focused\n ? 'var(--malachite-shadow-accent, 0px 1px 0px 0px rgba(0, 175, 102, 0.15))'\n : '0px 1px 1px 0px rgba(0, 0, 0, 0.15)';\n\n return (\n <div\n className={`w-full ${bgClass} border border-solid ${restingBorderClass} ${hoverBorderClass} transition-colors flex items-center ${SIZE_CLASSES[size]} ${disabled ? 'opacity-60 cursor-not-allowed' : ''} ${className}`}\n style={{\n boxShadow,\n borderColor: focused\n ? 'var(--malachite-control-border-hover, rgba(0, 175, 102, 0.4))'\n : undefined,\n ...controlWidthStyle(width),\n ...style,\n }}\n >\n <SearchIcon size={ICON_SIZE} className={`${iconColorClass} shrink-0`} />\n <input\n ref={setInputRef}\n type=\"text\"\n value={value}\n onChange={(e) => onChange(e.target.value)}\n onKeyDown={handleKeyDown}\n onFocus={() => setFocused(true)}\n onBlur={() => setFocused(false)}\n placeholder={placeholder}\n aria-label={ariaLabelledBy ? ariaLabel : (ariaLabel ?? placeholder ?? 'Search')}\n aria-labelledby={ariaLabelledBy}\n disabled={disabled}\n autoFocus={autoFocus}\n className={`flex-1 bg-transparent border-none outline-none ${CONTROL_TEXT_SIZE_CLASS[size]} font-medium text-[var(--malachite-text-primary)] ${placeholderColorClass} placeholder:font-medium disabled:cursor-not-allowed min-w-0`}\n />\n {canClear && (\n <button\n type=\"button\"\n aria-label=\"Clear search\"\n onMouseDown={keepFocus}\n onClick={clear}\n className={`shrink-0 flex items-center justify-center w-6 h-6 -mr-[5px] bg-transparent border-none rounded text-[var(--malachite-text-placeholder)] hover:text-[var(--malachite-text-primary)] cursor-pointer ${FOCUS_RING}`}\n >\n <DismissIcon size={10} />\n </button>\n )}\n </div>\n );\n});\n\nexport default Search;\nexport { Search };\n"],"names":["SIZE_CLASSES","ICON_SIZE","keepFocus","event","Search","forwardRef","value","onChange","placeholder","size","variant","disabled","autoFocus","className","width","style","clearable","onClear","onKeyDown","ariaLabel","ariaLabelledBy","ref","focused","setFocused","useState","inputRef","useRef","setInputRef","useMemo","composeRefs","canClear","clear","_a","handleKeyDown","composing","isMuted","bgClass","restingBorderClass","hoverBorderClass","iconColorClass","placeholderColorClass","boxShadow","jsxs","controlWidthStyle","jsx","SearchIcon","CONTROL_TEXT_SIZE_CLASS","FOCUS_RING","DismissIcon"],"mappings":";;;;;;;;AAaA,MAAMA,IAA2C;AAAA,EAC7C,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AACX,GAEMC,IAAY,IA4BZC,IAAY,CAACC,MAA4BA,EAAM,eAAA,GAG/CC,KAASC,EAA0C,SACrD;AAAA,EACI,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,aAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,SAAAC,IAAU;AAAA,EACV,UAAAC,IAAW;AAAA,EACX,WAAAC,IAAY;AAAA,EACZ,WAAAC,IAAY;AAAA,EACZ,OAAAC;AAAA,EACA,OAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,SAAAC;AAAA,EACA,WAAAC;AAAA,EACA,cAAcC;AAAA,EACd,mBAAmBC;AACvB,GACAC,GACF;AACE,QAAM,CAACC,GAASC,CAAU,IAAIC,EAAS,EAAK,GACtCC,IAAWC,EAAyB,IAAI,GACxCC,IAAcC,EAAQ,MAAMC,EAAYR,GAAKI,CAAQ,GAAG,CAACJ,CAAG,CAAC,GAC7DS,IAAWd,KAAaV,EAAM,SAAS,KAAK,CAACK,GAE7CoB,IAAQ,MAAM;;AAChB,IAAAxB,EAAS,EAAE,GACXU,KAAA,QAAAA,MACAe,IAAAP,EAAS,YAAT,QAAAO,EAAkB;AAAA,EACtB,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;AAAA,YACA,WAAW,kDAAkDkC,EAAwBrC,CAAI,CAAC,qDAAqD+B,CAAqB;AAAA,UAAA;AAAA,QAAA;AAAA,QAEvKV,KACG,gBAAAc;AAAA,UAAC;AAAA,UAAA;AAAA,YACG,MAAK;AAAA,YACL,cAAW;AAAA,YACX,aAAa1C;AAAA,YACb,SAAS6B;AAAA,YACT,WAAW,qMAAqMgB,CAAU;AAAA,YAE1N,UAAA,gBAAAH,EAACI,GAAA,EAAY,MAAM,GAAA,CAAI;AAAA,UAAA;AAAA,QAAA;AAAA,MAC3B;AAAA,IAAA;AAAA,EAAA;AAIhB,CAAC;"}
|
|
1
|
+
{"version":3,"file":"Search.js","sources":["../../src/components/Search.tsx"],"sourcesContent":["import React, { forwardRef, useMemo, useRef, useState } from 'react';\nimport DismissIcon from './CustomIcons/DismissIcon';\nimport SearchIcon from './CustomIcons/SearchIcon';\nimport { composeRefs } from './composeRefs';\nimport { CONTROL_TEXT_SIZE_CLASS } from './controlTextSize';\nimport { controlWidthStyle } from './controlWidth';\nimport { FOCUS_RING } from './focusRing';\n\nexport type SearchSize = 'small' | 'medium' | 'large';\nexport type SearchVariant = 'default' | 'muted';\n/** `body` is the 14px body step at any size. */\nexport type SearchTextSize = 'control' | 'body';\n\nconst BODY_TEXT_CLASS = 'text-[length:var(--malachite-font-size-medium,14px)]';\n\n// Figma \"Search Element - Standard\": Small 28px, Medium 32px, Large 42px, with the radius\n// tracking the tier (10/12/14) and the icon staying 15px throughout.\nconst SIZE_CLASSES: Record<SearchSize, string> = {\n small: 'h-[var(--malachite-control-height-small,28px)] gap-[6px] px-[10px] rounded-[var(--malachite-radius-10,10px)]',\n medium: 'h-[var(--malachite-control-height-medium,32px)] gap-[10px] px-[10px] rounded-xl',\n large: 'h-[var(--malachite-control-height-large,42px)] gap-[12px] px-[12px] rounded-[var(--malachite-radius-xxl,14px)]',\n};\n\nconst ICON_SIZE = 15;\n\nexport interface SearchProps {\n value: string;\n onChange: (value: string) => void;\n placeholder?: string;\n /** 'large' (42px) for form inputs; 'medium' (32px) for toolbars; 'small' (28px) in a table. */\n size?: SearchSize;\n variant?: SearchVariant;\n textSize?: SearchTextSize;\n disabled?: boolean;\n autoFocus?: boolean;\n className?: string;\n width?: string | number;\n style?: React.CSSProperties;\n /**\n * Shows a clear button while the field has text, and lets Escape clear it. Either way focus\n * stays in the field, and Escape that clears is not also passed to a surrounding panel.\n */\n clearable?: boolean;\n /** Called after `onChange('')` when the clear button or Escape empties the field. */\n onClear?: () => void;\n /** Runs before Search's own Escape handling; call `preventDefault()` to skip it. */\n onKeyDown?: React.KeyboardEventHandler<HTMLInputElement>;\n /** The field's accessible name. Falls back to the placeholder, then \"Search\". */\n 'aria-label'?: string;\n 'aria-labelledby'?: string;\n}\n\nconst keepFocus = (event: React.MouseEvent) => event.preventDefault();\n\n/** Forwards a ref to the input, so a consumer can focus the field. */\nconst Search = forwardRef<HTMLInputElement, SearchProps>(function Search(\n {\n value,\n onChange,\n placeholder,\n size = 'large',\n variant = 'default',\n textSize = 'control',\n disabled = false,\n autoFocus = false,\n className = '',\n width,\n style,\n clearable = false,\n onClear,\n onKeyDown,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n },\n ref,\n) {\n const [focused, setFocused] = useState(false);\n const inputRef = useRef<HTMLInputElement>(null);\n const setInputRef = useMemo(() => composeRefs(ref, inputRef), [ref]);\n const canClear = clearable && value.length > 0 && !disabled;\n\n const clear = () => {\n onChange('');\n onClear?.();\n inputRef.current?.focus();\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n onKeyDown?.(event);\n // Escape mid-composition cancels the IME's candidate text, not the query.\n const composing = event.nativeEvent.isComposing || event.nativeEvent.keyCode === 229;\n if (event.key !== 'Escape' || event.defaultPrevented || composing || !canClear) {\n return;\n }\n // Both, as Dropdown does: an ancestor's own onKeyDown runs before the escape layers.\n event.preventDefault();\n event.stopPropagation();\n clear();\n };\n const isMuted = variant === 'muted';\n\n // Muted variant: a borderless search that sits on a surface (no shadow). Default:\n // white field with border + subtle shadow. Both keep a visible focus border.\n // The fill is the Border colour by design; the dimmed grey vanishes on a sunken page.\n const bgClass = isMuted\n ? 'bg-[var(--malachite-card-border)]'\n : 'bg-[var(--malachite-card-background)]';\n const restingBorderClass = isMuted\n ? 'border-transparent'\n : 'border-[var(--malachite-card-border)]';\n // Hover darkens the border; focus (inline below) takes precedence.\n const hoverBorderClass = disabled ? '' : 'hover:border-[var(--malachite-text-placeholder)]';\n const iconColorClass = isMuted\n ? 'text-[var(--malachite-text-secondary)]'\n : 'text-[var(--malachite-text-placeholder)]';\n const placeholderColorClass = isMuted\n ? 'placeholder:text-[var(--malachite-text-secondary)]'\n : 'placeholder:text-[var(--malachite-text-placeholder)]';\n const boxShadow = isMuted\n ? 'none'\n : focused\n ? 'var(--malachite-shadow-accent, 0px 1px 0px 0px rgba(0, 175, 102, 0.15))'\n : '0px 1px 1px 0px rgba(0, 0, 0, 0.15)';\n\n return (\n <div\n className={`w-full ${bgClass} border border-solid ${restingBorderClass} ${hoverBorderClass} transition-colors flex items-center ${SIZE_CLASSES[size]} ${disabled ? 'opacity-60 cursor-not-allowed' : ''} ${className}`}\n style={{\n boxShadow,\n borderColor: focused\n ? 'var(--malachite-control-border-hover, rgba(0, 175, 102, 0.4))'\n : undefined,\n ...controlWidthStyle(width),\n ...style,\n }}\n >\n <SearchIcon size={ICON_SIZE} className={`${iconColorClass} shrink-0`} />\n <input\n ref={setInputRef}\n type=\"text\"\n value={value}\n onChange={(e) => onChange(e.target.value)}\n onKeyDown={handleKeyDown}\n onFocus={() => setFocused(true)}\n onBlur={() => setFocused(false)}\n placeholder={placeholder}\n aria-label={ariaLabelledBy ? ariaLabel : (ariaLabel ?? placeholder ?? 'Search')}\n aria-labelledby={ariaLabelledBy}\n disabled={disabled}\n autoFocus={autoFocus}\n className={`flex-1 bg-transparent border-none outline-none ${textSize === 'body' ? BODY_TEXT_CLASS : CONTROL_TEXT_SIZE_CLASS[size]} font-medium text-[var(--malachite-text-primary)] ${placeholderColorClass} placeholder:font-medium disabled:cursor-not-allowed min-w-0`}\n />\n {canClear && (\n <button\n type=\"button\"\n aria-label=\"Clear search\"\n onMouseDown={keepFocus}\n onClick={clear}\n className={`shrink-0 flex items-center justify-center w-6 h-6 -mr-[5px] bg-transparent border-none rounded text-[var(--malachite-text-placeholder)] hover:text-[var(--malachite-text-primary)] cursor-pointer ${FOCUS_RING}`}\n >\n <DismissIcon size={10} />\n </button>\n )}\n </div>\n );\n});\n\nexport default Search;\nexport { Search };\n"],"names":["BODY_TEXT_CLASS","SIZE_CLASSES","ICON_SIZE","keepFocus","event","Search","forwardRef","value","onChange","placeholder","size","variant","textSize","disabled","autoFocus","className","width","style","clearable","onClear","onKeyDown","ariaLabel","ariaLabelledBy","ref","focused","setFocused","useState","inputRef","useRef","setInputRef","useMemo","composeRefs","canClear","clear","_a","handleKeyDown","composing","isMuted","bgClass","restingBorderClass","hoverBorderClass","iconColorClass","placeholderColorClass","boxShadow","jsxs","controlWidthStyle","jsx","SearchIcon","CONTROL_TEXT_SIZE_CLASS","FOCUS_RING","DismissIcon"],"mappings":";;;;;;;;AAaA,MAAMA,IAAkB,wDAIlBC,IAA2C;AAAA,EAC7C,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AACX,GAEMC,IAAY,IA6BZC,IAAY,CAACC,MAA4BA,EAAM,eAAA,GAG/CC,KAASC,EAA0C,SACrD;AAAA,EACI,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,aAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,SAAAC,IAAU;AAAA,EACV,UAAAC,IAAW;AAAA,EACX,UAAAC,IAAW;AAAA,EACX,WAAAC,IAAY;AAAA,EACZ,WAAAC,IAAY;AAAA,EACZ,OAAAC;AAAA,EACA,OAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,SAAAC;AAAA,EACA,WAAAC;AAAA,EACA,cAAcC;AAAA,EACd,m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