@stackone/malachite 2.129.0 → 2.130.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/COMPONENTS.md +2 -2
- package/dist/components/Breadcrumbs.js +51 -45
- package/dist/components/Breadcrumbs.js.map +1 -1
- package/dist/components/CodeBlock.js +95 -91
- package/dist/components/CodeBlock.js.map +1 -1
- package/dist/components/CopyOverlayButton.js +21 -17
- package/dist/components/CopyOverlayButton.js.map +1 -1
- package/dist/components/Input/Input.js +66 -65
- package/dist/components/Input/Input.js.map +1 -1
- package/dist/components/Modal.js +12 -12
- package/dist/components/Modal.js.map +1 -1
- package/dist/components/Progress.js +20 -19
- package/dist/components/Progress.js.map +1 -1
- package/dist/components/Search.js +36 -36
- package/dist/components/Search.js.map +1 -1
- package/dist/components/Sidebar.js +60 -58
- package/dist/components/Sidebar.js.map +1 -1
- package/dist/components/SidebarProgress.js +79 -0
- package/dist/components/SidebarProgress.js.map +1 -0
- package/dist/components/Table/Table.js +2 -2
- package/dist/components/Table/Table.js.map +1 -1
- package/dist/components/Tag.js +80 -70
- package/dist/components/Tag.js.map +1 -1
- package/dist/components/TextArea/TextArea.js +68 -67
- package/dist/components/TextArea/TextArea.js.map +1 -1
- package/dist/components/focusRing.js +8 -6
- package/dist/components/focusRing.js.map +1 -1
- package/dist/components/visuallyHiddenStyle.js +6 -3
- package/dist/components/visuallyHiddenStyle.js.map +1 -1
- package/dist/index.d.ts +40 -5
- package/dist/tailwind.css.js +1 -1
- package/package.json +1 -1
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import { jsxs as D, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as j, useState as A, useRef as L, useMemo as M } from "react";
|
|
3
|
+
import Z from "./CustomIcons/DismissIcon.js";
|
|
4
|
+
import z from "./CustomIcons/SearchIcon.js";
|
|
5
5
|
import { composeRefs as P } from "./composeRefs.js";
|
|
6
|
-
import { CONTROL_TEXT_SIZE_CLASS as
|
|
7
|
-
import { controlWidthStyle as
|
|
8
|
-
import { FOCUS_RING as
|
|
9
|
-
const
|
|
6
|
+
import { CONTROL_TEXT_SIZE_CLASS as U } from "./controlTextSize.js";
|
|
7
|
+
import { controlWidthStyle as X } from "./controlWidth.js";
|
|
8
|
+
import { FOCUS_BORDER_COLOR as G, FOCUS_RING as W } from "./focusRing.js";
|
|
9
|
+
const Y = "text-[length:var(--malachite-font-size-medium,14px)]", q = {
|
|
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
|
+
}, H = 15, J = (c) => c.preventDefault(), le = j(function({
|
|
14
14
|
value: s,
|
|
15
15
|
onChange: n,
|
|
16
16
|
placeholder: i,
|
|
17
17
|
size: p = "large",
|
|
18
|
-
variant:
|
|
18
|
+
variant: v = "default",
|
|
19
19
|
textSize: S = "control",
|
|
20
|
-
disabled:
|
|
20
|
+
disabled: r = !1,
|
|
21
21
|
autoFocus: C = !1,
|
|
22
22
|
className: y = "",
|
|
23
|
-
width:
|
|
24
|
-
style:
|
|
25
|
-
clearable:
|
|
23
|
+
width: E,
|
|
24
|
+
style: R,
|
|
25
|
+
clearable: _ = !1,
|
|
26
26
|
onClear: o,
|
|
27
27
|
onKeyDown: l,
|
|
28
28
|
"aria-label": m,
|
|
29
29
|
"aria-labelledby": d
|
|
30
30
|
}, h) {
|
|
31
|
-
const [x, u] =
|
|
31
|
+
const [x, u] = A(!1), f = L(null), $ = M(() => P(h, f), [h]), b = _ && s.length > 0 && !r, g = () => {
|
|
32
32
|
var e;
|
|
33
33
|
n(""), o == null || o(), (e = f.current) == null || e.focus();
|
|
34
|
-
},
|
|
34
|
+
}, O = (e) => {
|
|
35
35
|
l == null || l(e);
|
|
36
|
-
const
|
|
37
|
-
e.key !== "Escape" || e.defaultPrevented ||
|
|
38
|
-
},
|
|
39
|
-
return /* @__PURE__ */
|
|
36
|
+
const B = e.nativeEvent.isComposing || e.nativeEvent.keyCode === 229;
|
|
37
|
+
e.key !== "Escape" || e.defaultPrevented || B || !b || (e.preventDefault(), e.stopPropagation(), g());
|
|
38
|
+
}, t = v === "muted", I = t ? "bg-[var(--malachite-card-border)]" : "bg-[var(--malachite-card-background)]", k = t ? "border-transparent" : "border-[var(--malachite-card-border)]", w = r ? "" : "hover:border-[var(--malachite-text-placeholder)]", N = t ? "text-[var(--malachite-text-secondary)]" : "text-[var(--malachite-text-placeholder)]", F = t ? "placeholder:text-[var(--malachite-text-secondary)]" : "placeholder:text-[var(--malachite-text-placeholder)]", T = t ? "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__ */ D(
|
|
40
40
|
"div",
|
|
41
41
|
{
|
|
42
|
-
className: `w-full ${
|
|
42
|
+
className: `w-full ${I} border border-solid ${k} ${w} transition-colors flex items-center ${q[p]} ${r ? "opacity-60 cursor-not-allowed" : ""} ${y}`,
|
|
43
43
|
style: {
|
|
44
|
-
boxShadow:
|
|
45
|
-
borderColor: x ?
|
|
46
|
-
...
|
|
47
|
-
...
|
|
44
|
+
boxShadow: T,
|
|
45
|
+
borderColor: x ? G : void 0,
|
|
46
|
+
...X(E),
|
|
47
|
+
...R
|
|
48
48
|
},
|
|
49
49
|
children: [
|
|
50
|
-
/* @__PURE__ */ a(
|
|
50
|
+
/* @__PURE__ */ a(z, { size: H, className: `${N} shrink-0` }),
|
|
51
51
|
/* @__PURE__ */ a(
|
|
52
52
|
"input",
|
|
53
53
|
{
|
|
54
|
-
ref:
|
|
54
|
+
ref: $,
|
|
55
55
|
type: "text",
|
|
56
56
|
value: s,
|
|
57
57
|
onChange: (e) => n(e.target.value),
|
|
58
|
-
onKeyDown:
|
|
58
|
+
onKeyDown: O,
|
|
59
59
|
onFocus: () => u(!0),
|
|
60
60
|
onBlur: () => u(!1),
|
|
61
61
|
placeholder: i,
|
|
62
62
|
"aria-label": d ? m : m ?? i ?? "Search",
|
|
63
63
|
"aria-labelledby": d,
|
|
64
|
-
disabled:
|
|
64
|
+
disabled: r,
|
|
65
65
|
autoFocus: C,
|
|
66
|
-
className: `flex-1 bg-transparent border-none outline-none ${S === "body" ?
|
|
66
|
+
className: `flex-1 bg-transparent border-none outline-none ${S === "body" ? Y : U[p]} font-medium text-[var(--malachite-text-primary)] ${F} placeholder:font-medium disabled:cursor-not-allowed min-w-0`
|
|
67
67
|
}
|
|
68
68
|
),
|
|
69
69
|
b && /* @__PURE__ */ a(
|
|
@@ -71,10 +71,10 @@ const W = "text-[length:var(--malachite-font-size-medium,14px)]", Y = {
|
|
|
71
71
|
{
|
|
72
72
|
type: "button",
|
|
73
73
|
"aria-label": "Clear search",
|
|
74
|
-
onMouseDown:
|
|
75
|
-
onClick:
|
|
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 ${
|
|
77
|
-
children: /* @__PURE__ */ a(
|
|
74
|
+
onMouseDown: J,
|
|
75
|
+
onClick: g,
|
|
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 ${W}`,
|
|
77
|
+
children: /* @__PURE__ */ a(Z, { size: 10 })
|
|
78
78
|
}
|
|
79
79
|
)
|
|
80
80
|
]
|
|
@@ -82,7 +82,7 @@ const W = "text-[length:var(--malachite-font-size-medium,14px)]", Y = {
|
|
|
82
82
|
);
|
|
83
83
|
});
|
|
84
84
|
export {
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
le as Search,
|
|
86
|
+
le as default
|
|
87
87
|
};
|
|
88
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/** `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,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,KAAaX,EAAM,S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AMA,EAAW,EAAK;AAAA,YAC9B,aAAAhB;AAAA,YACA,cAAYa,IAAiBD,IAAaA,KAAaZ,KAAe;AAAA,YACtE,mBAAiBa;AAAA,YACjB,UAAAT;AAAA,YACA,WAAAC;AAAA,YACA,WAAW,kDAAkDF,MAAa,SAASZ,IAAkBgD,EAAwBtC,CAAI,CAAC,qDAAqDgC,CAAqB;AAAA,UAAA;AAAA,QAAA;AAAA,QAE/MV,KACG,gBAAAc;AAAA,UAAC;AAAA,UAAA;AAAA,YACG,MAAK;AAAA,YACL,cAAW;AAAA,YACX,aAAa3C;AAAA,YACb,SAAS8B;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_BORDER_COLOR, 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 ? FOCUS_BORDER_COLOR : 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","FOCUS_BORDER_COLOR","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;A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,QAC5C,GAAGC,EAAkB9B,CAAK;AAAA,QAC1B,GAAGC;AAAA,MAAA;AAAA,MAGP,UAAA;AAAA,QAAA,gBAAA8B,EAACC,KAAW,MAAM9C,GAAW,WAAW,GAAGuC,CAAc,aAAa;AAAA,QACtE,gBAAAM;AAAA,UAAC;AAAA,UAAA;AAAA,YACG,KAAKlB;AAAA,YACL,MAAK;AAAA,YACL,OAAAtB;AAAA,YACA,UAAU,CAAC,MAAMC,EAAS,EAAE,OAAO,KAAK;AAAA,YACxC,WAAW2B;AAAA,YACX,SAAS,MAAMV,EAAW,EAAI;AAAA,YAC9B,QAAQ,MAAMA,EAAW,EAAK;AAAA,YAC9B,aAAAhB;AAAA,YACA,cAAYa,IAAiBD,IAAaA,KAAaZ,KAAe;AAAA,YACtE,mBAAiBa;AAAA,YACjB,UAAAT;AAAA,YACA,WAAAC;AAAA,YACA,WAAW,kDAAkDF,MAAa,SAASZ,IAAkBiD,EAAwBvC,CAAI,CAAC,qDAAqDgC,CAAqB;AAAA,UAAA;AAAA,QAAA;AAAA,QAE/MV,KACG,gBAAAe;AAAA,UAAC;AAAA,UAAA;AAAA,YACG,MAAK;AAAA,YACL,cAAW;AAAA,YACX,aAAa5C;AAAA,YACb,SAAS8B;AAAA,YACT,WAAW,qMAAqMiB,CAAU;AAAA,YAE1N,UAAA,gBAAAH,EAACI,GAAA,EAAY,MAAM,GAAA,CAAI;AAAA,UAAA;AAAA,QAAA;AAAA,MAC3B;AAAA,IAAA;AAAA,EAAA;AAIhB,CAAC;"}
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { jsxs as d, jsx as r } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo as
|
|
2
|
+
import { useMemo as z, useState as C, useCallback as B, forwardRef as O } from "react";
|
|
3
3
|
import L from "./CustomIcons/CaretLeftIcon.js";
|
|
4
4
|
import G from "./CustomIcons/CaretRightIcon.js";
|
|
5
5
|
import R from "./CustomIcons/ChevronsUpDownIcon.js";
|
|
6
|
+
import { SidebarProgress as H } from "./SidebarProgress.js";
|
|
6
7
|
import k from "./Tooltip.js";
|
|
7
8
|
import g from "./TruncatedTooltip.js";
|
|
8
|
-
import { UsageCard as
|
|
9
|
+
import { UsageCard as U } from "./UsageCard.js";
|
|
9
10
|
import { isExpanded as v } from "./ariaState.js";
|
|
10
|
-
import { BORDER as u, NO_SCROLLBAR as
|
|
11
|
+
import { BORDER as u, NO_SCROLLBAR as X } from "./chromeStyles.js";
|
|
11
12
|
import { FOCUS_RING as y } from "./focusRing.js";
|
|
12
|
-
import { useHasOpenOverlay as
|
|
13
|
-
import { SIDEBAR_WIDTH_PX as S, SidebarContext as
|
|
14
|
-
const s = () => ({ collapsed:
|
|
13
|
+
import { useHasOpenOverlay as V, useOverlayBehaviour as F } from "./overlayBehaviour.js";
|
|
14
|
+
import { SIDEBAR_WIDTH_PX as S, SidebarContext as M, SIDEBAR_Z_INDEX as h, SIDEBAR_POPOVER_WIDTH_PX as Y, SIDEBAR_TOOLTIP_DELAY_S as f, useSidebarCollapsed as W } from "./sidebarContext.js";
|
|
15
|
+
const s = () => ({ collapsed: W() }), Z = 1, q = 24, E = { width: 8, height: 14 }, J = "fixed top-[25px] opacity-0 [will-change:opacity] transition-[left,opacity] duration-200 ease-in-out group-hover/sidebar:opacity-100 group-has-[:focus-visible]/sidebar:opacity-100 [@media(hover:none)]:opacity-100", K = {
|
|
15
16
|
"--malachite-ctx-navitem-ground": "var(--malachite-card-sunken-background, rgb(250,250,250))"
|
|
16
|
-
},
|
|
17
|
-
}, I = (e, { overlay: t, collapsed: a, canToggle: n, blocked: c }) => t ? a ? "rail" : n ? e === "off" || e === "drawer" ? e : c ? "waiting" : "drawer" : "off" : "off",
|
|
17
|
+
}, Q = () => {
|
|
18
|
+
}, I = (e, { overlay: t, collapsed: a, canToggle: n, blocked: c }) => t ? a ? "rail" : n ? e === "off" || e === "drawer" ? e : c ? "waiting" : "drawer" : "off" : "off", ee = ({
|
|
18
19
|
collapsed: e = !1,
|
|
19
20
|
overlay: t = !1,
|
|
20
21
|
onToggleCollapse: a,
|
|
@@ -23,20 +24,20 @@ const s = () => ({ collapsed: Y() }), W = 1, Z = 24, E = { width: 8, height: 14
|
|
|
23
24
|
"aria-label": l = "Main",
|
|
24
25
|
children: p
|
|
25
26
|
}) => {
|
|
26
|
-
const
|
|
27
|
+
const o = e ? n : c, i = z(() => ({ collapsed: e }), [e]), x = e ? S.collapsed : S.expanded, A = V(), N = {
|
|
27
28
|
overlay: t,
|
|
28
29
|
collapsed: e,
|
|
29
30
|
canToggle: a !== void 0,
|
|
30
31
|
blocked: A
|
|
31
32
|
}, [w, _] = C(() => I("off", N)), b = I(w, N);
|
|
32
33
|
b !== w && _(b);
|
|
33
|
-
const m = b === "drawer", T = B(() => _("waiting"), []), { ref: j, isTopmost:
|
|
34
|
+
const m = b === "drawer", T = B(() => _("waiting"), []), { ref: j, isTopmost: P } = F({
|
|
34
35
|
open: m,
|
|
35
|
-
onClose: a ??
|
|
36
|
+
onClose: a ?? Q,
|
|
36
37
|
initialFocus: "content",
|
|
37
38
|
onYield: T
|
|
38
39
|
});
|
|
39
|
-
return /* @__PURE__ */ d(
|
|
40
|
+
return /* @__PURE__ */ d(M.Provider, { value: i, children: [
|
|
40
41
|
t && /* @__PURE__ */ r(
|
|
41
42
|
"div",
|
|
42
43
|
{
|
|
@@ -51,22 +52,22 @@ const s = () => ({ collapsed: Y() }), W = 1, Z = 24, E = { width: 8, height: 14
|
|
|
51
52
|
{
|
|
52
53
|
ref: j,
|
|
53
54
|
role: m ? "dialog" : void 0,
|
|
54
|
-
"aria-modal": m &&
|
|
55
|
+
"aria-modal": m && P ? "true" : void 0,
|
|
55
56
|
"aria-label": m ? l : void 0,
|
|
56
57
|
className: "group/sidebar fixed top-0 bottom-0 left-0 box-border pt-[9px] bg-[var(--malachite-card-sunken-background,rgb(250,250,250))] transition-[width] duration-200 ease-in-out",
|
|
57
|
-
style: { width: x, zIndex: h, ...
|
|
58
|
+
style: { width: x, zIndex: h, ...K },
|
|
58
59
|
children: [
|
|
59
60
|
/* @__PURE__ */ r("nav", { "aria-label": l, className: "flex h-full flex-col", children: p }),
|
|
60
61
|
a && /* @__PURE__ */ r(
|
|
61
62
|
"div",
|
|
62
63
|
{
|
|
63
|
-
className:
|
|
64
|
-
style: { left: x -
|
|
65
|
-
children: /* @__PURE__ */ r(k, { text:
|
|
64
|
+
className: J,
|
|
65
|
+
style: { left: x - q / 2, zIndex: h + 1 },
|
|
66
|
+
children: /* @__PURE__ */ r(k, { text: o, placement: "right", describesTrigger: !1, children: /* @__PURE__ */ r(
|
|
66
67
|
"button",
|
|
67
68
|
{
|
|
68
69
|
type: "button",
|
|
69
|
-
"aria-label":
|
|
70
|
+
"aria-label": o,
|
|
70
71
|
onClick: a,
|
|
71
72
|
className: `m-0 inline-flex size-6 cursor-pointer items-center justify-center rounded-lg border border-solid p-0 ${u} bg-[var(--malachite-card-background,rgb(255,255,255))] text-[var(--malachite-text-secondary,rgb(123,123,123))] [box-shadow:var(--malachite-shadow-default,0px_1px_0px_0px_rgba(0,0,0,0.15))] transition-colors duration-200 hover:border-[var(--malachite-text-placeholder,rgb(187,187,187))] hover:text-[var(--malachite-text-primary,rgb(10,10,10))] ${y}`,
|
|
72
73
|
children: e ? /* @__PURE__ */ r(G, { size: 12 }) : /* @__PURE__ */ r(L, { size: 12 })
|
|
@@ -78,7 +79,7 @@ const s = () => ({ collapsed: Y() }), W = 1, Z = 24, E = { width: 8, height: 14
|
|
|
78
79
|
}
|
|
79
80
|
)
|
|
80
81
|
] });
|
|
81
|
-
},
|
|
82
|
+
}, re = ({ children: e }) => {
|
|
82
83
|
const { collapsed: t } = s();
|
|
83
84
|
return /* @__PURE__ */ r(
|
|
84
85
|
"div",
|
|
@@ -87,7 +88,7 @@ const s = () => ({ collapsed: Y() }), W = 1, Z = 24, E = { width: 8, height: 14
|
|
|
87
88
|
children: e
|
|
88
89
|
}
|
|
89
90
|
);
|
|
90
|
-
},
|
|
91
|
+
}, te = ({ children: e }) => /* @__PURE__ */ r("div", { className: `min-h-0 flex-1 overflow-x-hidden overflow-y-auto ${X}`, children: e }), ae = ({ children: e }) => {
|
|
91
92
|
const { collapsed: t } = s();
|
|
92
93
|
return /* @__PURE__ */ r(
|
|
93
94
|
"div",
|
|
@@ -96,19 +97,19 @@ const s = () => ({ collapsed: Y() }), W = 1, Z = 24, E = { width: 8, height: 14
|
|
|
96
97
|
children: e
|
|
97
98
|
}
|
|
98
99
|
);
|
|
99
|
-
},
|
|
100
|
+
}, oe = ({ children: e }) => /* @__PURE__ */ r("div", { className: "my-[2px] flex flex-col gap-[6px]", children: e }), ie = ({ children: e }) => /* @__PURE__ */ r("div", { className: "flex flex-col gap-[6px]", children: e }), se = ({ children: e }) => {
|
|
100
101
|
const { collapsed: t } = s();
|
|
101
102
|
return /* @__PURE__ */ r("div", { className: `flex pt-5 pb-[18px] ${t ? "justify-center px-3" : "px-4"}`, children: e });
|
|
102
|
-
},
|
|
103
|
+
}, ne = ({
|
|
103
104
|
children: e,
|
|
104
105
|
"aria-label": t
|
|
105
106
|
}) => {
|
|
106
107
|
const { collapsed: a } = s();
|
|
107
108
|
return a ? null : /* @__PURE__ */ r("div", { role: "status", "aria-label": t, className: "flex flex-col gap-2 px-3 pt-4", children: e });
|
|
108
|
-
},
|
|
109
|
+
}, le = () => {
|
|
109
110
|
const { collapsed: e } = s();
|
|
110
111
|
return e ? null : /* @__PURE__ */ r("hr", { className: `m-0 my-2 h-0 shrink-0 border-0 border-t border-solid ${u}` });
|
|
111
|
-
},
|
|
112
|
+
}, ce = ({ children: e }) => {
|
|
112
113
|
const { collapsed: t } = s();
|
|
113
114
|
return /* @__PURE__ */ r(
|
|
114
115
|
"div",
|
|
@@ -118,16 +119,16 @@ const s = () => ({ collapsed: Y() }), W = 1, Z = 24, E = { width: 8, height: 14
|
|
|
118
119
|
}
|
|
119
120
|
);
|
|
120
121
|
}, $ = O(
|
|
121
|
-
({ logo: e, title: t, subtitle: a, titleTooltip: n, subtitleTooltip: c, className: l = "", ...p },
|
|
122
|
-
const { collapsed:
|
|
122
|
+
({ logo: e, title: t, subtitle: a, titleTooltip: n, subtitleTooltip: c, className: l = "", ...p }, o) => {
|
|
123
|
+
const { collapsed: i } = s(), x = v(p["aria-expanded"]);
|
|
123
124
|
return /* @__PURE__ */ d(
|
|
124
125
|
"button",
|
|
125
126
|
{
|
|
126
|
-
ref:
|
|
127
|
+
ref: o,
|
|
127
128
|
type: "button",
|
|
128
|
-
"aria-label":
|
|
129
|
+
"aria-label": i ? t : void 0,
|
|
129
130
|
...p,
|
|
130
|
-
className: `group/switcher m-0 box-border flex h-full w-full min-w-0 cursor-pointer items-center gap-3 rounded-lg border-0 bg-transparent font-sans text-left ${
|
|
131
|
+
className: `group/switcher m-0 box-border flex h-full w-full min-w-0 cursor-pointer items-center gap-3 rounded-lg border-0 bg-transparent font-sans text-left ${i ? "justify-center p-1" : "justify-between px-4 py-[6px]"} ${y} ${l}`.trim(),
|
|
131
132
|
children: [
|
|
132
133
|
/* @__PURE__ */ d("span", { className: "flex min-w-0 items-center gap-4", children: [
|
|
133
134
|
/* @__PURE__ */ r(
|
|
@@ -138,7 +139,7 @@ const s = () => ({ collapsed: Y() }), W = 1, Z = 24, E = { width: 8, height: 14
|
|
|
138
139
|
children: e
|
|
139
140
|
}
|
|
140
141
|
),
|
|
141
|
-
!
|
|
142
|
+
!i && /* @__PURE__ */ d("span", { className: "flex min-w-0 flex-col gap-1", children: [
|
|
142
143
|
/* @__PURE__ */ r(
|
|
143
144
|
g,
|
|
144
145
|
{
|
|
@@ -167,27 +168,27 @@ const s = () => ({ collapsed: Y() }), W = 1, Z = 24, E = { width: 8, height: 14
|
|
|
167
168
|
)
|
|
168
169
|
] })
|
|
169
170
|
] }),
|
|
170
|
-
!
|
|
171
|
+
!i && /* @__PURE__ */ r("span", { className: "flex shrink-0 text-[var(--malachite-text-secondary,rgb(123,123,123))] transition-colors group-hover/switcher:text-[var(--malachite-text-primary,rgb(10,10,10))]", children: /* @__PURE__ */ r(R, { style: E }) })
|
|
171
172
|
]
|
|
172
173
|
}
|
|
173
174
|
);
|
|
174
175
|
}
|
|
175
176
|
);
|
|
176
177
|
$.displayName = "Sidebar.Switcher";
|
|
177
|
-
const
|
|
178
|
+
const de = `inline-flex items-center justify-center rounded-[var(--malachite-radius-md,6px)] border border-solid ${u} bg-[var(--malachite-pillbutton-background,rgb(241,241,241))] supports-[color:color-mix(in_srgb,red,red)]:border-[color-mix(in_srgb,var(--malachite-text-placeholder,rgb(187,187,187))_20%,transparent)] supports-[color:color-mix(in_srgb,red,red)]:bg-[color-mix(in_srgb,var(--malachite-text-placeholder,rgb(187,187,187))_10%,transparent)] px-1 py-[3px] text-[length:var(--malachite-font-size-small,13px)] leading-[12px] font-semibold text-[var(--malachite-text-secondary,rgb(123,123,123))]`, D = O(
|
|
178
179
|
({ avatar: e, initials: t, name: a, tooltip: n, className: c = "", ...l }, p) => {
|
|
179
|
-
const { collapsed:
|
|
180
|
+
const { collapsed: o } = s(), i = /* @__PURE__ */ d(
|
|
180
181
|
"button",
|
|
181
182
|
{
|
|
182
183
|
ref: p,
|
|
183
184
|
type: "button",
|
|
184
|
-
"aria-label":
|
|
185
|
+
"aria-label": o ? a : void 0,
|
|
185
186
|
...l,
|
|
186
|
-
className: `group/account m-0 box-border flex min-h-8 w-full cursor-pointer items-center gap-3 rounded-lg border-0 bg-transparent font-sans ${
|
|
187
|
+
className: `group/account m-0 box-border flex min-h-8 w-full cursor-pointer items-center gap-3 rounded-lg border-0 bg-transparent font-sans ${o ? "justify-center p-0" : "justify-between px-2"} ${y} ${c}`.trim(),
|
|
187
188
|
children: [
|
|
188
189
|
/* @__PURE__ */ d("span", { className: "flex min-w-0 items-center gap-3", children: [
|
|
189
|
-
/* @__PURE__ */ r("span", { "aria-hidden":
|
|
190
|
-
!
|
|
190
|
+
/* @__PURE__ */ r("span", { "aria-hidden": o ? void 0 : !0, className: "flex shrink-0", children: e ?? (t ? /* @__PURE__ */ r("span", { className: de, children: t }) : null) }),
|
|
191
|
+
!o && /* @__PURE__ */ r(
|
|
191
192
|
g,
|
|
192
193
|
{
|
|
193
194
|
text: a ? n ?? a : void 0,
|
|
@@ -201,11 +202,11 @@ const ce = `inline-flex items-center justify-center rounded-[var(--malachite-rad
|
|
|
201
202
|
}
|
|
202
203
|
)
|
|
203
204
|
] }),
|
|
204
|
-
!
|
|
205
|
+
!o && /* @__PURE__ */ r("span", { className: "flex shrink-0 text-[var(--malachite-text-secondary,rgb(123,123,123))] transition-colors group-hover/account:text-[var(--malachite-text-primary,rgb(10,10,10))]", children: /* @__PURE__ */ r(R, { style: E }) })
|
|
205
206
|
]
|
|
206
207
|
}
|
|
207
208
|
);
|
|
208
|
-
return
|
|
209
|
+
return o ? /* @__PURE__ */ r(
|
|
209
210
|
k,
|
|
210
211
|
{
|
|
211
212
|
text: a ? n ?? a : void 0,
|
|
@@ -213,35 +214,36 @@ const ce = `inline-flex items-center justify-center rounded-[var(--malachite-rad
|
|
|
213
214
|
delay: f,
|
|
214
215
|
describesTrigger: !1,
|
|
215
216
|
suppressed: v(l["aria-expanded"]),
|
|
216
|
-
children:
|
|
217
|
+
children: i
|
|
217
218
|
}
|
|
218
|
-
) :
|
|
219
|
+
) : i;
|
|
219
220
|
}
|
|
220
221
|
);
|
|
221
222
|
D.displayName = "Sidebar.Account";
|
|
222
|
-
const
|
|
223
|
+
const pe = (e) => {
|
|
223
224
|
const { collapsed: t } = s();
|
|
224
|
-
return t ? null : /* @__PURE__ */ r("div", { className: "shrink-0 px-3 pt-3 pb-4", children: /* @__PURE__ */ r(
|
|
225
|
-
},
|
|
225
|
+
return t ? null : /* @__PURE__ */ r("div", { className: "shrink-0 px-3 pt-3 pb-4", children: /* @__PURE__ */ r(U, { ...e }) });
|
|
226
|
+
}, me = ({
|
|
226
227
|
children: e,
|
|
227
|
-
width: t =
|
|
228
|
-
}) => /* @__PURE__ */ r("div", { className: "flex flex-col", style: { width: t - 2 *
|
|
229
|
-
Header:
|
|
230
|
-
Body:
|
|
231
|
-
Section:
|
|
232
|
-
Group:
|
|
228
|
+
width: t = Y
|
|
229
|
+
}) => /* @__PURE__ */ r("div", { className: "flex flex-col", style: { width: t - 2 * Z }, children: e }), Re = Object.assign(ee, {
|
|
230
|
+
Header: re,
|
|
231
|
+
Body: te,
|
|
232
|
+
Section: ae,
|
|
233
|
+
Group: oe,
|
|
233
234
|
GroupItems: ie,
|
|
234
|
-
Search:
|
|
235
|
-
Notices:
|
|
236
|
-
Divider:
|
|
237
|
-
Footer:
|
|
235
|
+
Search: se,
|
|
236
|
+
Notices: ne,
|
|
237
|
+
Divider: le,
|
|
238
|
+
Footer: ce,
|
|
238
239
|
Switcher: $,
|
|
239
240
|
Account: D,
|
|
240
|
-
Usage:
|
|
241
|
-
|
|
241
|
+
Usage: pe,
|
|
242
|
+
Progress: H,
|
|
243
|
+
Panel: me
|
|
242
244
|
});
|
|
243
245
|
export {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
+
Re as Sidebar,
|
|
247
|
+
Re as default
|
|
246
248
|
};
|
|
247
249
|
//# sourceMappingURL=Sidebar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sidebar.js","sources":["../../src/components/Sidebar.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useMemo, useState } from 'react';\nimport CaretLeftIcon from './CustomIcons/CaretLeftIcon';\nimport CaretRightIcon from './CustomIcons/CaretRightIcon';\nimport ChevronsUpDownIcon from './CustomIcons/ChevronsUpDownIcon';\nimport Tooltip from './Tooltip';\nimport TruncatedTooltip from './TruncatedTooltip';\nimport UsageCard, { type UsageCardProps } from './UsageCard';\nimport { isExpanded } from './ariaState';\nimport { BORDER, NO_SCROLLBAR } from './chromeStyles';\nimport { FOCUS_RING } from './focusRing';\nimport { useHasOpenOverlay, useOverlayBehaviour } from './overlayBehaviour';\nimport {\n SIDEBAR_POPOVER_WIDTH_PX,\n SIDEBAR_TOOLTIP_DELAY_S,\n SIDEBAR_WIDTH_PX,\n SIDEBAR_Z_INDEX,\n SidebarContext,\n useSidebarCollapsed,\n} from './sidebarContext';\n\nconst useSidebar = () => ({ collapsed: useSidebarCollapsed() });\n\nconst POPOVER_BORDER_PX = 1;\nconst TOGGLE_SIZE_PX = 24;\nconst CHEVRONS = { width: 8, height: 14 } as const;\n\nexport interface SidebarProps {\n collapsed?: boolean;\n /** Expanded from its rail, the sidebar floats over the page as a modal drawer: a scrim, Escape\n * and a focus trap, each of which collapses it through `onToggleCollapse`. For viewports\n * under `SIDEBAR_OVERLAY_BREAKPOINT_PX`; collapse it on entering, as a drawer starts shut. */\n overlay?: boolean;\n onToggleCollapse?: () => void;\n expandLabel?: string;\n collapseLabel?: string;\n 'aria-label'?: string;\n children: React.ReactNode;\n}\n\n// Hidden by opacity, not visibility, so the half over the page can be hovered; touch always shows it.\nconst TOGGLE_LAYER =\n 'fixed top-[25px] opacity-0 [will-change:opacity] transition-[left,opacity] duration-200 ease-in-out group-hover/sidebar:opacity-100 group-has-[:focus-visible]/sidebar:opacity-100 [@media(hover:none)]:opacity-100';\n\n// The rows' ground, which a `NavItem` puts under its tag. A context channel, not a theme token.\nconst NAVITEM_GROUND = {\n '--malachite-ctx-navitem-ground': 'var(--malachite-card-sunken-background, rgb(250,250,250))',\n} as React.CSSProperties;\n\nconst noop = () => undefined;\n\ntype DrawerState = 'off' | 'rail' | 'waiting' | 'drawer';\ntype DrawerInputs = Record<'overlay' | 'collapsed' | 'canToggle' | 'blocked', boolean>;\n\n// A drawer only once expanded from the rail: expanded on mount or across the breakpoint it would\n// take focus from the page. Expanded under another dialog, it waits for that dialog to close.\nconst nextDrawerState = (\n previous: DrawerState,\n { overlay, collapsed, canToggle, blocked }: DrawerInputs,\n): DrawerState => {\n if (!overlay) return 'off';\n if (collapsed) return 'rail';\n if (!canToggle) return 'off';\n if (previous === 'off' || previous === 'drawer') return previous;\n return blocked ? 'waiting' : 'drawer';\n};\n\nconst SidebarRoot: React.FC<SidebarProps> = ({\n collapsed = false,\n overlay = false,\n onToggleCollapse,\n expandLabel = 'Expand menu',\n collapseLabel = 'Collapse menu',\n 'aria-label': ariaLabel = 'Main',\n children,\n}) => {\n const toggleLabel = collapsed ? expandLabel : collapseLabel;\n const context = useMemo(() => ({ collapsed }), [collapsed]);\n const width = collapsed ? SIDEBAR_WIDTH_PX.collapsed : SIDEBAR_WIDTH_PX.expanded;\n const otherOverlayOpen = useHasOpenOverlay();\n const inputs = {\n overlay,\n collapsed,\n canToggle: onToggleCollapse !== undefined,\n blocked: otherOverlayOpen,\n };\n const [drawerState, setDrawerState] = useState(() => nextDrawerState('off', inputs));\n const nextState = nextDrawerState(drawerState, inputs);\n if (nextState !== drawerState) {\n setDrawerState(nextState);\n }\n const open = nextState === 'drawer';\n const yieldDrawer = useCallback(() => setDrawerState('waiting'), []);\n const { ref: overlayRef, isTopmost } = useOverlayBehaviour({\n open,\n onClose: onToggleCollapse ?? noop,\n initialFocus: 'content',\n onYield: yieldDrawer,\n });\n\n return (\n <SidebarContext.Provider value={context}>\n {overlay && (\n <div\n aria-hidden=\"true\"\n onClick={open ? onToggleCollapse : undefined}\n className={`fixed inset-0 bg-[var(--malachite-overlay-scrim)] transition-opacity duration-200 ease-in-out ${open ? 'opacity-100' : 'pointer-events-none opacity-0'}`}\n style={{ zIndex: SIDEBAR_Z_INDEX - 1 }}\n />\n )}\n <aside\n ref={overlayRef}\n role={open ? 'dialog' : undefined}\n aria-modal={open && isTopmost ? 'true' : undefined}\n aria-label={open ? ariaLabel : undefined}\n className=\"group/sidebar fixed top-0 bottom-0 left-0 box-border pt-[9px] bg-[var(--malachite-card-sunken-background,rgb(250,250,250))] transition-[width] duration-200 ease-in-out\"\n style={{ width, zIndex: SIDEBAR_Z_INDEX, ...NAVITEM_GROUND }}\n >\n <nav aria-label={ariaLabel} className=\"flex h-full flex-col\">\n {children}\n </nav>\n {onToggleCollapse && (\n <div\n className={TOGGLE_LAYER}\n style={{ left: width - TOGGLE_SIZE_PX / 2, zIndex: SIDEBAR_Z_INDEX + 1 }}\n >\n <Tooltip text={toggleLabel} placement=\"right\" describesTrigger={false}>\n <button\n type=\"button\"\n aria-label={toggleLabel}\n onClick={onToggleCollapse}\n className={`m-0 inline-flex size-6 cursor-pointer items-center justify-center rounded-lg border border-solid p-0 ${BORDER} bg-[var(--malachite-card-background,rgb(255,255,255))] text-[var(--malachite-text-secondary,rgb(123,123,123))] [box-shadow:var(--malachite-shadow-default,0px_1px_0px_0px_rgba(0,0,0,0.15))] transition-colors duration-200 hover:border-[var(--malachite-text-placeholder,rgb(187,187,187))] hover:text-[var(--malachite-text-primary,rgb(10,10,10))] ${FOCUS_RING}`}\n >\n {collapsed ? (\n <CaretRightIcon size={12} />\n ) : (\n <CaretLeftIcon size={12} />\n )}\n </button>\n </Tooltip>\n </div>\n )}\n </aside>\n </SidebarContext.Provider>\n );\n};\n\nconst Header: React.FC<{ children: React.ReactNode }> = ({ children }) => {\n const { collapsed } = useSidebar();\n return (\n <div\n className={`box-border flex h-14 shrink-0 items-center border-0 border-b border-solid ${BORDER} py-[6px] ${collapsed ? 'px-1' : 'px-2'}`}\n >\n {children}\n </div>\n );\n};\n\nconst Body: React.FC<{ children: React.ReactNode }> = ({ children }) => (\n <div className={`min-h-0 flex-1 overflow-x-hidden overflow-y-auto ${NO_SCROLLBAR}`}>\n {children}\n </div>\n);\n\nconst Section: React.FC<{ children: React.ReactNode }> = ({ children }) => {\n const { collapsed } = useSidebar();\n return (\n <div\n className={`flex flex-col gap-[2px] py-[2px] ${collapsed ? 'items-center px-3' : 'px-4'}`}\n >\n {children}\n </div>\n );\n};\n\nconst Group: React.FC<{ children: React.ReactNode }> = ({ children }) => (\n <div className=\"my-[2px] flex flex-col gap-[6px]\">{children}</div>\n);\n\nconst GroupItems: React.FC<{ children: React.ReactNode }> = ({ children }) => (\n <div className=\"flex flex-col gap-[6px]\">{children}</div>\n);\n\nconst Search: React.FC<{ children: React.ReactNode }> = ({ children }) => {\n const { collapsed } = useSidebar();\n return (\n <div className={`flex pt-5 pb-[18px] ${collapsed ? 'justify-center px-3' : 'px-4'}`}>\n {children}\n </div>\n );\n};\n\nconst Notices: React.FC<{ children: React.ReactNode; 'aria-label': string }> = ({\n children,\n 'aria-label': ariaLabel,\n}) => {\n const { collapsed } = useSidebar();\n if (collapsed) {\n return null;\n }\n return (\n <div role=\"status\" aria-label={ariaLabel} className=\"flex flex-col gap-2 px-3 pt-4\">\n {children}\n </div>\n );\n};\n\nconst Divider: React.FC = () => {\n const { collapsed } = useSidebar();\n if (collapsed) {\n return null;\n }\n return <hr className={`m-0 my-2 h-0 shrink-0 border-0 border-t border-solid ${BORDER}`} />;\n};\n\nconst Footer: React.FC<{ children: React.ReactNode }> = ({ children }) => {\n const { collapsed } = useSidebar();\n return (\n <div\n className={`mt-1 flex shrink-0 border-0 border-t border-solid ${BORDER} py-3 ${collapsed ? 'justify-center px-2' : 'px-4'}`}\n >\n {children}\n </div>\n );\n};\n\ntype SidebarButtonAttributes = Omit<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n 'style' | 'color' | 'children' | 'title' | 'name'\n>;\n\nexport interface SidebarSwitcherProps extends SidebarButtonAttributes {\n logo: React.ReactNode;\n title: string;\n subtitle?: string;\n /** Shown when `title` is cut off; a node so it can be wrapped. Defaults to `title`. */\n titleTooltip?: React.ReactNode;\n /** As `titleTooltip`, for `subtitle`. */\n subtitleTooltip?: React.ReactNode;\n}\n\nconst Switcher = forwardRef<HTMLButtonElement, SidebarSwitcherProps>(\n ({ logo, title, subtitle, titleTooltip, subtitleTooltip, className = '', ...rest }, ref) => {\n const { collapsed } = useSidebar();\n const open = isExpanded(rest['aria-expanded']);\n return (\n <button\n ref={ref}\n type=\"button\"\n aria-label={collapsed ? title : undefined}\n {...rest}\n className={`group/switcher m-0 box-border flex h-full w-full min-w-0 cursor-pointer items-center gap-3 rounded-lg border-0 bg-transparent font-sans text-left ${collapsed ? 'justify-center p-1' : 'justify-between px-4 py-[6px]'} ${FOCUS_RING} ${className}`.trim()}\n >\n <span className=\"flex min-w-0 items-center gap-4\">\n <span\n aria-hidden=\"true\"\n className=\"relative top-[-2.5px] flex size-6 shrink-0 items-center justify-center overflow-hidden rounded-md [&_img]:size-6 [&_img]:object-contain\"\n >\n {logo}\n </span>\n {!collapsed && (\n <span className=\"flex min-w-0 flex-col gap-1\">\n <TruncatedTooltip\n text={titleTooltip ?? title}\n placement=\"right\"\n delay={SIDEBAR_TOOLTIP_DELAY_S}\n triggerAs=\"span\"\n describesTrigger={false}\n suppressed={open}\n className=\"text-[length:var(--malachite-font-size-medium,14px)] leading-[14px] font-medium text-[var(--malachite-text-primary,rgb(10,10,10))]\"\n >\n {title}\n </TruncatedTooltip>\n {subtitle && (\n <TruncatedTooltip\n text={subtitleTooltip ?? subtitle}\n placement=\"right\"\n delay={SIDEBAR_TOOLTIP_DELAY_S}\n triggerAs=\"span\"\n describesTrigger={false}\n suppressed={open}\n className=\"text-[12px] leading-[12px] font-normal text-[var(--malachite-text-secondary,rgb(123,123,123))]\"\n >\n {subtitle}\n </TruncatedTooltip>\n )}\n </span>\n )}\n </span>\n {!collapsed && (\n <span className=\"flex shrink-0 text-[var(--malachite-text-secondary,rgb(123,123,123))] transition-colors group-hover/switcher:text-[var(--malachite-text-primary,rgb(10,10,10))]\">\n <ChevronsUpDownIcon style={CHEVRONS} />\n </span>\n )}\n </button>\n );\n },\n);\nSwitcher.displayName = 'Sidebar.Switcher';\n\nexport interface SidebarAccountProps extends SidebarButtonAttributes {\n avatar?: React.ReactNode;\n initials?: string;\n name: string;\n /** Collapsed-rail tooltip, and expanded when `name` is cut off; a node so `name` can be wrapped.\n * Should read as `name`. Defaults to `name`, `false` hides it; none when `name` is empty. */\n tooltip?: React.ReactNode;\n}\n\nconst INITIALS = `inline-flex items-center justify-center rounded-[var(--malachite-radius-md,6px)] border border-solid ${BORDER} bg-[var(--malachite-pillbutton-background,rgb(241,241,241))] supports-[color:color-mix(in_srgb,red,red)]:border-[color-mix(in_srgb,var(--malachite-text-placeholder,rgb(187,187,187))_20%,transparent)] supports-[color:color-mix(in_srgb,red,red)]:bg-[color-mix(in_srgb,var(--malachite-text-placeholder,rgb(187,187,187))_10%,transparent)] px-1 py-[3px] text-[length:var(--malachite-font-size-small,13px)] leading-[12px] font-semibold text-[var(--malachite-text-secondary,rgb(123,123,123))]`;\n\nconst Account = forwardRef<HTMLButtonElement, SidebarAccountProps>(\n ({ avatar, initials, name, tooltip, className = '', ...rest }, ref) => {\n const { collapsed } = useSidebar();\n const button = (\n <button\n ref={ref}\n type=\"button\"\n aria-label={collapsed ? name : undefined}\n {...rest}\n className={`group/account m-0 box-border flex min-h-8 w-full cursor-pointer items-center gap-3 rounded-lg border-0 bg-transparent font-sans ${collapsed ? 'justify-center p-0' : 'justify-between px-2'} ${FOCUS_RING} ${className}`.trim()}\n >\n <span className=\"flex min-w-0 items-center gap-3\">\n <span aria-hidden={collapsed ? undefined : true} className=\"flex shrink-0\">\n {avatar ?? (initials ? <span className={INITIALS}>{initials}</span> : null)}\n </span>\n {!collapsed && (\n <TruncatedTooltip\n text={name ? (tooltip ?? name) : undefined}\n placement=\"right\"\n delay={SIDEBAR_TOOLTIP_DELAY_S}\n triggerAs=\"span\"\n describesTrigger={false}\n suppressed={isExpanded(rest['aria-expanded'])}\n className=\"min-w-0 text-[length:var(--malachite-font-size-medium,14px)] leading-[22px] font-semibold text-[var(--malachite-text-primary,rgb(10,10,10))]\"\n >\n {name}\n </TruncatedTooltip>\n )}\n </span>\n {!collapsed && (\n <span className=\"flex shrink-0 text-[var(--malachite-text-secondary,rgb(123,123,123))] transition-colors group-hover/account:text-[var(--malachite-text-primary,rgb(10,10,10))]\">\n <ChevronsUpDownIcon style={CHEVRONS} />\n </span>\n )}\n </button>\n );\n return collapsed ? (\n <Tooltip\n text={name ? (tooltip ?? name) : undefined}\n placement=\"right\"\n delay={SIDEBAR_TOOLTIP_DELAY_S}\n describesTrigger={false}\n suppressed={isExpanded(rest['aria-expanded'])}\n >\n {button}\n </Tooltip>\n ) : (\n button\n );\n },\n);\nAccount.displayName = 'Sidebar.Account';\n\nconst Usage: React.FC<UsageCardProps> = (props) => {\n const { collapsed } = useSidebar();\n if (collapsed) {\n return null;\n }\n return (\n <div className=\"shrink-0 px-3 pt-3 pb-4\">\n <UsageCard {...props} />\n </div>\n );\n};\n\n/** `width` widens a popover past the sidebar's, for a menu wider than the control it opens from. */\nconst Panel: React.FC<{ children: React.ReactNode; width?: number }> = ({\n children,\n width = SIDEBAR_POPOVER_WIDTH_PX,\n}) => (\n <div className=\"flex flex-col\" style={{ width: width - 2 * POPOVER_BORDER_PX }}>\n {children}\n </div>\n);\n\nexport const Sidebar = Object.assign(SidebarRoot, {\n Header,\n Body,\n Section,\n Group,\n GroupItems,\n Search,\n Notices,\n Divider,\n Footer,\n Switcher,\n Account,\n Usage,\n Panel,\n});\n\nexport default Sidebar;\n"],"names":["useSidebar","useSidebarCollapsed","POPOVER_BORDER_PX","TOGGLE_SIZE_PX","CHEVRONS","TOGGLE_LAYER","NAVITEM_GROUND","noop","nextDrawerState","previous","overlay","collapsed","canToggle","blocked","SidebarRoot","onToggleCollapse","expandLabel","collapseLabel","ariaLabel","children","toggleLabel","context","useMemo","width","SIDEBAR_WIDTH_PX","otherOverlayOpen","useHasOpenOverlay","inputs","drawerState","setDrawerState","useState","nextState","open","yieldDrawer","useCallback","overlayRef","isTopmost","useOverlayBehaviour","jsxs","SidebarContext","jsx","SIDEBAR_Z_INDEX","Tooltip","BORDER","FOCUS_RING","CaretRightIcon","CaretLeftIcon","Header","Body","NO_SCROLLBAR","Section","Group","GroupItems","Search","Notices","Divider","Footer","Switcher","forwardRef","logo","title","subtitle","titleTooltip","subtitleTooltip","className","rest","ref","isExpanded","TruncatedTooltip","SIDEBAR_TOOLTIP_DELAY_S","ChevronsUpDownIcon","INITIALS","Account","avatar","initials","name","tooltip","button","Usage","props","UsageCard","Panel","SIDEBAR_POPOVER_WIDTH_PX","Sidebar"],"m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EAAA,CACL,GAGSgE,KAAU,OAAO,OAAOrE,GAAa;AAAA,EAC9C,QAAAiC;AAAA,EACA,MAAAC;AAAA,EACA,SAAAE;AAAA,EACA,OAAAC;AAAA,EACA,YAAAC;AAAA,EACA,QAAAC;AAAA,EACA,SAAAC;AAAA,EACA,SAAAC;AAAA,EACA,QAAAC;AAAA,EACA,UAAAC;AAAA,EACA,SAAAe;AAAA,EACA,OAAAM;AAAA,EACA,OAAAG;AACJ,CAAC;"}
|
|
1
|
+
{"version":3,"file":"Sidebar.js","sources":["../../src/components/Sidebar.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useMemo, useState } from 'react';\nimport CaretLeftIcon from './CustomIcons/CaretLeftIcon';\nimport CaretRightIcon from './CustomIcons/CaretRightIcon';\nimport ChevronsUpDownIcon from './CustomIcons/ChevronsUpDownIcon';\nimport SidebarProgress from './SidebarProgress';\nimport Tooltip from './Tooltip';\nimport TruncatedTooltip from './TruncatedTooltip';\nimport UsageCard, { type UsageCardProps } from './UsageCard';\nimport { isExpanded } from './ariaState';\nimport { BORDER, NO_SCROLLBAR } from './chromeStyles';\nimport { FOCUS_RING } from './focusRing';\nimport { useHasOpenOverlay, useOverlayBehaviour } from './overlayBehaviour';\nimport {\n SIDEBAR_POPOVER_WIDTH_PX,\n SIDEBAR_TOOLTIP_DELAY_S,\n SIDEBAR_WIDTH_PX,\n SIDEBAR_Z_INDEX,\n SidebarContext,\n useSidebarCollapsed,\n} from './sidebarContext';\n\nconst useSidebar = () => ({ collapsed: useSidebarCollapsed() });\n\nconst POPOVER_BORDER_PX = 1;\nconst TOGGLE_SIZE_PX = 24;\nconst CHEVRONS = { width: 8, height: 14 } as const;\n\nexport interface SidebarProps {\n collapsed?: boolean;\n /** Expanded from its rail, the sidebar floats over the page as a modal drawer: a scrim, Escape\n * and a focus trap, each of which collapses it through `onToggleCollapse`. For viewports\n * under `SIDEBAR_OVERLAY_BREAKPOINT_PX`; collapse it on entering, as a drawer starts shut. */\n overlay?: boolean;\n onToggleCollapse?: () => void;\n expandLabel?: string;\n collapseLabel?: string;\n 'aria-label'?: string;\n children: React.ReactNode;\n}\n\n// Hidden by opacity, not visibility, so the half over the page can be hovered; touch always shows it.\nconst TOGGLE_LAYER =\n 'fixed top-[25px] opacity-0 [will-change:opacity] transition-[left,opacity] duration-200 ease-in-out group-hover/sidebar:opacity-100 group-has-[:focus-visible]/sidebar:opacity-100 [@media(hover:none)]:opacity-100';\n\n// The rows' ground, which a `NavItem` puts under its tag. A context channel, not a theme token.\nconst NAVITEM_GROUND = {\n '--malachite-ctx-navitem-ground': 'var(--malachite-card-sunken-background, rgb(250,250,250))',\n} as React.CSSProperties;\n\nconst noop = () => undefined;\n\ntype DrawerState = 'off' | 'rail' | 'waiting' | 'drawer';\ntype DrawerInputs = Record<'overlay' | 'collapsed' | 'canToggle' | 'blocked', boolean>;\n\n// A drawer only once expanded from the rail: expanded on mount or across the breakpoint it would\n// take focus from the page. Expanded under another dialog, it waits for that dialog to close.\nconst nextDrawerState = (\n previous: DrawerState,\n { overlay, collapsed, canToggle, blocked }: DrawerInputs,\n): DrawerState => {\n if (!overlay) return 'off';\n if (collapsed) return 'rail';\n if (!canToggle) return 'off';\n if (previous === 'off' || previous === 'drawer') return previous;\n return blocked ? 'waiting' : 'drawer';\n};\n\nconst SidebarRoot: React.FC<SidebarProps> = ({\n collapsed = false,\n overlay = false,\n onToggleCollapse,\n expandLabel = 'Expand menu',\n collapseLabel = 'Collapse menu',\n 'aria-label': ariaLabel = 'Main',\n children,\n}) => {\n const toggleLabel = collapsed ? expandLabel : collapseLabel;\n const context = useMemo(() => ({ collapsed }), [collapsed]);\n const width = collapsed ? SIDEBAR_WIDTH_PX.collapsed : SIDEBAR_WIDTH_PX.expanded;\n const otherOverlayOpen = useHasOpenOverlay();\n const inputs = {\n overlay,\n collapsed,\n canToggle: onToggleCollapse !== undefined,\n blocked: otherOverlayOpen,\n };\n const [drawerState, setDrawerState] = useState(() => nextDrawerState('off', inputs));\n const nextState = nextDrawerState(drawerState, inputs);\n if (nextState !== drawerState) {\n setDrawerState(nextState);\n }\n const open = nextState === 'drawer';\n const yieldDrawer = useCallback(() => setDrawerState('waiting'), []);\n const { ref: overlayRef, isTopmost } = useOverlayBehaviour({\n open,\n onClose: onToggleCollapse ?? noop,\n initialFocus: 'content',\n onYield: yieldDrawer,\n });\n\n return (\n <SidebarContext.Provider value={context}>\n {overlay && (\n <div\n aria-hidden=\"true\"\n onClick={open ? onToggleCollapse : undefined}\n className={`fixed inset-0 bg-[var(--malachite-overlay-scrim)] transition-opacity duration-200 ease-in-out ${open ? 'opacity-100' : 'pointer-events-none opacity-0'}`}\n style={{ zIndex: SIDEBAR_Z_INDEX - 1 }}\n />\n )}\n <aside\n ref={overlayRef}\n role={open ? 'dialog' : undefined}\n aria-modal={open && isTopmost ? 'true' : undefined}\n aria-label={open ? ariaLabel : undefined}\n className=\"group/sidebar fixed top-0 bottom-0 left-0 box-border pt-[9px] bg-[var(--malachite-card-sunken-background,rgb(250,250,250))] transition-[width] duration-200 ease-in-out\"\n style={{ width, zIndex: SIDEBAR_Z_INDEX, ...NAVITEM_GROUND }}\n >\n <nav aria-label={ariaLabel} className=\"flex h-full flex-col\">\n {children}\n </nav>\n {onToggleCollapse && (\n <div\n className={TOGGLE_LAYER}\n style={{ left: width - TOGGLE_SIZE_PX / 2, zIndex: SIDEBAR_Z_INDEX + 1 }}\n >\n <Tooltip text={toggleLabel} placement=\"right\" describesTrigger={false}>\n <button\n type=\"button\"\n aria-label={toggleLabel}\n onClick={onToggleCollapse}\n className={`m-0 inline-flex size-6 cursor-pointer items-center justify-center rounded-lg border border-solid p-0 ${BORDER} bg-[var(--malachite-card-background,rgb(255,255,255))] text-[var(--malachite-text-secondary,rgb(123,123,123))] [box-shadow:var(--malachite-shadow-default,0px_1px_0px_0px_rgba(0,0,0,0.15))] transition-colors duration-200 hover:border-[var(--malachite-text-placeholder,rgb(187,187,187))] hover:text-[var(--malachite-text-primary,rgb(10,10,10))] ${FOCUS_RING}`}\n >\n {collapsed ? (\n <CaretRightIcon size={12} />\n ) : (\n <CaretLeftIcon size={12} />\n )}\n </button>\n </Tooltip>\n </div>\n )}\n </aside>\n </SidebarContext.Provider>\n );\n};\n\nconst Header: React.FC<{ children: React.ReactNode }> = ({ children }) => {\n const { collapsed } = useSidebar();\n return (\n <div\n className={`box-border flex h-14 shrink-0 items-center border-0 border-b border-solid ${BORDER} py-[6px] ${collapsed ? 'px-1' : 'px-2'}`}\n >\n {children}\n </div>\n );\n};\n\nconst Body: React.FC<{ children: React.ReactNode }> = ({ children }) => (\n <div className={`min-h-0 flex-1 overflow-x-hidden overflow-y-auto ${NO_SCROLLBAR}`}>\n {children}\n </div>\n);\n\nconst Section: React.FC<{ children: React.ReactNode }> = ({ children }) => {\n const { collapsed } = useSidebar();\n return (\n <div\n className={`flex flex-col gap-[2px] py-[2px] ${collapsed ? 'items-center px-3' : 'px-4'}`}\n >\n {children}\n </div>\n );\n};\n\nconst Group: React.FC<{ children: React.ReactNode }> = ({ children }) => (\n <div className=\"my-[2px] flex flex-col gap-[6px]\">{children}</div>\n);\n\nconst GroupItems: React.FC<{ children: React.ReactNode }> = ({ children }) => (\n <div className=\"flex flex-col gap-[6px]\">{children}</div>\n);\n\nconst Search: React.FC<{ children: React.ReactNode }> = ({ children }) => {\n const { collapsed } = useSidebar();\n return (\n <div className={`flex pt-5 pb-[18px] ${collapsed ? 'justify-center px-3' : 'px-4'}`}>\n {children}\n </div>\n );\n};\n\nconst Notices: React.FC<{ children: React.ReactNode; 'aria-label': string }> = ({\n children,\n 'aria-label': ariaLabel,\n}) => {\n const { collapsed } = useSidebar();\n if (collapsed) {\n return null;\n }\n return (\n <div role=\"status\" aria-label={ariaLabel} className=\"flex flex-col gap-2 px-3 pt-4\">\n {children}\n </div>\n );\n};\n\nconst Divider: React.FC = () => {\n const { collapsed } = useSidebar();\n if (collapsed) {\n return null;\n }\n return <hr className={`m-0 my-2 h-0 shrink-0 border-0 border-t border-solid ${BORDER}`} />;\n};\n\nconst Footer: React.FC<{ children: React.ReactNode }> = ({ children }) => {\n const { collapsed } = useSidebar();\n return (\n <div\n className={`mt-1 flex shrink-0 border-0 border-t border-solid ${BORDER} py-3 ${collapsed ? 'justify-center px-2' : 'px-4'}`}\n >\n {children}\n </div>\n );\n};\n\ntype SidebarButtonAttributes = Omit<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n 'style' | 'color' | 'children' | 'title' | 'name'\n>;\n\nexport interface SidebarSwitcherProps extends SidebarButtonAttributes {\n logo: React.ReactNode;\n title: string;\n subtitle?: string;\n /** Shown when `title` is cut off; a node so it can be wrapped. Defaults to `title`. */\n titleTooltip?: React.ReactNode;\n /** As `titleTooltip`, for `subtitle`. */\n subtitleTooltip?: React.ReactNode;\n}\n\nconst Switcher = forwardRef<HTMLButtonElement, SidebarSwitcherProps>(\n ({ logo, title, subtitle, titleTooltip, subtitleTooltip, className = '', ...rest }, ref) => {\n const { collapsed } = useSidebar();\n const open = isExpanded(rest['aria-expanded']);\n return (\n <button\n ref={ref}\n type=\"button\"\n aria-label={collapsed ? title : undefined}\n {...rest}\n className={`group/switcher m-0 box-border flex h-full w-full min-w-0 cursor-pointer items-center gap-3 rounded-lg border-0 bg-transparent font-sans text-left ${collapsed ? 'justify-center p-1' : 'justify-between px-4 py-[6px]'} ${FOCUS_RING} ${className}`.trim()}\n >\n <span className=\"flex min-w-0 items-center gap-4\">\n <span\n aria-hidden=\"true\"\n className=\"relative top-[-2.5px] flex size-6 shrink-0 items-center justify-center overflow-hidden rounded-md [&_img]:size-6 [&_img]:object-contain\"\n >\n {logo}\n </span>\n {!collapsed && (\n <span className=\"flex min-w-0 flex-col gap-1\">\n <TruncatedTooltip\n text={titleTooltip ?? title}\n placement=\"right\"\n delay={SIDEBAR_TOOLTIP_DELAY_S}\n triggerAs=\"span\"\n describesTrigger={false}\n suppressed={open}\n className=\"text-[length:var(--malachite-font-size-medium,14px)] leading-[14px] font-medium text-[var(--malachite-text-primary,rgb(10,10,10))]\"\n >\n {title}\n </TruncatedTooltip>\n {subtitle && (\n <TruncatedTooltip\n text={subtitleTooltip ?? subtitle}\n placement=\"right\"\n delay={SIDEBAR_TOOLTIP_DELAY_S}\n triggerAs=\"span\"\n describesTrigger={false}\n suppressed={open}\n className=\"text-[12px] leading-[12px] font-normal text-[var(--malachite-text-secondary,rgb(123,123,123))]\"\n >\n {subtitle}\n </TruncatedTooltip>\n )}\n </span>\n )}\n </span>\n {!collapsed && (\n <span className=\"flex shrink-0 text-[var(--malachite-text-secondary,rgb(123,123,123))] transition-colors group-hover/switcher:text-[var(--malachite-text-primary,rgb(10,10,10))]\">\n <ChevronsUpDownIcon style={CHEVRONS} />\n </span>\n )}\n </button>\n );\n },\n);\nSwitcher.displayName = 'Sidebar.Switcher';\n\nexport interface SidebarAccountProps extends SidebarButtonAttributes {\n avatar?: React.ReactNode;\n initials?: string;\n name: string;\n /** Collapsed-rail tooltip, and expanded when `name` is cut off; a node so `name` can be wrapped.\n * Should read as `name`. Defaults to `name`, `false` hides it; none when `name` is empty. */\n tooltip?: React.ReactNode;\n}\n\nconst INITIALS = `inline-flex items-center justify-center rounded-[var(--malachite-radius-md,6px)] border border-solid ${BORDER} bg-[var(--malachite-pillbutton-background,rgb(241,241,241))] supports-[color:color-mix(in_srgb,red,red)]:border-[color-mix(in_srgb,var(--malachite-text-placeholder,rgb(187,187,187))_20%,transparent)] supports-[color:color-mix(in_srgb,red,red)]:bg-[color-mix(in_srgb,var(--malachite-text-placeholder,rgb(187,187,187))_10%,transparent)] px-1 py-[3px] text-[length:var(--malachite-font-size-small,13px)] leading-[12px] font-semibold text-[var(--malachite-text-secondary,rgb(123,123,123))]`;\n\nconst Account = forwardRef<HTMLButtonElement, SidebarAccountProps>(\n ({ avatar, initials, name, tooltip, className = '', ...rest }, ref) => {\n const { collapsed } = useSidebar();\n const button = (\n <button\n ref={ref}\n type=\"button\"\n aria-label={collapsed ? name : undefined}\n {...rest}\n className={`group/account m-0 box-border flex min-h-8 w-full cursor-pointer items-center gap-3 rounded-lg border-0 bg-transparent font-sans ${collapsed ? 'justify-center p-0' : 'justify-between px-2'} ${FOCUS_RING} ${className}`.trim()}\n >\n <span className=\"flex min-w-0 items-center gap-3\">\n <span aria-hidden={collapsed ? undefined : true} className=\"flex shrink-0\">\n {avatar ?? (initials ? <span className={INITIALS}>{initials}</span> : null)}\n </span>\n {!collapsed && (\n <TruncatedTooltip\n text={name ? (tooltip ?? name) : undefined}\n placement=\"right\"\n delay={SIDEBAR_TOOLTIP_DELAY_S}\n triggerAs=\"span\"\n describesTrigger={false}\n suppressed={isExpanded(rest['aria-expanded'])}\n className=\"min-w-0 text-[length:var(--malachite-font-size-medium,14px)] leading-[22px] font-semibold text-[var(--malachite-text-primary,rgb(10,10,10))]\"\n >\n {name}\n </TruncatedTooltip>\n )}\n </span>\n {!collapsed && (\n <span className=\"flex shrink-0 text-[var(--malachite-text-secondary,rgb(123,123,123))] transition-colors group-hover/account:text-[var(--malachite-text-primary,rgb(10,10,10))]\">\n <ChevronsUpDownIcon style={CHEVRONS} />\n </span>\n )}\n </button>\n );\n return collapsed ? (\n <Tooltip\n text={name ? (tooltip ?? name) : undefined}\n placement=\"right\"\n delay={SIDEBAR_TOOLTIP_DELAY_S}\n describesTrigger={false}\n suppressed={isExpanded(rest['aria-expanded'])}\n >\n {button}\n </Tooltip>\n ) : (\n button\n );\n },\n);\nAccount.displayName = 'Sidebar.Account';\n\nconst Usage: React.FC<UsageCardProps> = (props) => {\n const { collapsed } = useSidebar();\n if (collapsed) {\n return null;\n }\n return (\n <div className=\"shrink-0 px-3 pt-3 pb-4\">\n <UsageCard {...props} />\n </div>\n );\n};\n\n/** `width` widens a popover past the sidebar's, for a menu wider than the control it opens from. */\nconst Panel: React.FC<{ children: React.ReactNode; width?: number }> = ({\n children,\n width = SIDEBAR_POPOVER_WIDTH_PX,\n}) => (\n <div className=\"flex flex-col\" style={{ width: width - 2 * POPOVER_BORDER_PX }}>\n {children}\n </div>\n);\n\nexport const Sidebar = Object.assign(SidebarRoot, {\n Header,\n Body,\n Section,\n Group,\n GroupItems,\n Search,\n Notices,\n Divider,\n Footer,\n Switcher,\n Account,\n Usage,\n Progress: SidebarProgress,\n Panel,\n});\n\nexport default Sidebar;\n"],"names":["useSidebar","useSidebarCollapsed","POPOVER_BORDER_PX","TOGGLE_SIZE_PX","CHEVRONS","TOGGLE_LAYER","NAVITEM_GROUND","noop","nextDrawerState","previous","overlay","collapsed","canToggle","blocked","SidebarRoot","onToggleCollapse","expandLabel","collapseLabel","ariaLabel","children","toggleLabel","context","useMemo","width","SIDEBAR_WIDTH_PX","otherOverlayOpen","useHasOpenOverlay","inputs","drawerState","setDrawerState","useState","nextState","open","yieldDrawer","useCallback","overlayRef","isTopmost","useOverlayBehaviour","jsxs","SidebarContext","jsx","SIDEBAR_Z_INDEX","Tooltip","BORDER","FOCUS_RING","CaretRightIcon","CaretLeftIcon","Header","Body","NO_SCROLLBAR","Section","Group","GroupItems","Search","Notices","Divider","Footer","Switcher","forwardRef","logo","title","subtitle","titleTooltip","subtitleTooltip","className","rest","ref","isExpanded","TruncatedTooltip","SIDEBAR_TOOLTIP_DELAY_S","ChevronsUpDownIcon","INITIALS","Account","avatar","initials","name","tooltip","button","Usage","props","UsageCard","Panel","SIDEBAR_POPOVER_WIDTH_PX","Sidebar","SidebarProgress"],"mappings":";;;;;;;;;;;;;;AAqBA,MAAMA,IAAa,OAAO,EAAE,WAAWC,IAAoB,IAErDC,IAAoB,GACpBC,IAAiB,IACjBC,IAAW,EAAE,OAAO,GAAG,QAAQ,GAAA,GAgB/BC,IACF,uNAGEC,IAAiB;AAAA,EACnB,kCAAkC;AACtC,GAEMC,IAAO,MAAA;AAAA,GAOPC,IAAkB,CACpBC,GACA,EAAE,SAAAC,GAAS,WAAAC,GAAW,WAAAC,GAAW,SAAAC,QAE5BH,IACDC,IAAkB,SACjBC,IACDH,MAAa,SAASA,MAAa,WAAiBA,IACjDI,IAAU,YA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