@overdoser/react-toolkit 0.18.0 → 0.19.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/AGENTS.md +51 -7
- package/CHANGELOG.md +129 -0
- package/components/Accordion/Accordion.d.ts +94 -0
- package/components/Accordion/Accordion.js +180 -0
- package/components/Accordion/Accordion.module.scss.js +36 -0
- package/components/Accordion/index.d.ts +2 -0
- package/components/Alert/Alert.d.ts +29 -1
- package/components/Alert/Alert.js +44 -30
- package/components/Alert/Alert.module.scss.js +24 -16
- package/components/Alert/index.d.ts +1 -1
- package/components/Card/Card.d.ts +86 -0
- package/components/Card/Card.js +132 -0
- package/components/Card/Card.module.scss.js +60 -0
- package/components/Card/index.d.ts +2 -0
- package/components/Chip/Chip.d.ts +86 -0
- package/components/Chip/Chip.js +141 -0
- package/components/Chip/Chip.module.scss.js +59 -0
- package/components/Chip/index.d.ts +2 -0
- package/components/CodeBlock/CodeBlock.d.ts +78 -0
- package/components/CodeBlock/CodeBlock.js +120 -0
- package/components/CodeBlock/CodeBlock.module.scss.js +43 -0
- package/components/CodeBlock/index.d.ts +2 -0
- package/components/CommandPalette/CommandPalette.d.ts +141 -0
- package/components/CommandPalette/CommandPalette.js +397 -0
- package/components/CommandPalette/CommandPalette.module.scss.js +49 -0
- package/components/CommandPalette/index.d.ts +2 -0
- package/components/ConfirmDialog/ConfirmDialog.d.ts +119 -0
- package/components/ConfirmDialog/ConfirmDialog.js +201 -0
- package/components/ConfirmDialog/ConfirmDialog.module.scss.js +21 -0
- package/components/ConfirmDialog/index.d.ts +2 -0
- package/components/Drawer/Drawer.d.ts +1 -0
- package/components/Drawer/Drawer.js +35 -36
- package/components/Drawer/Drawer.module.scss.js +20 -18
- package/components/Dropdown/Dropdown.d.ts +47 -7
- package/components/Dropdown/Dropdown.js +174 -81
- package/components/Dropdown/Dropdown.module.scss.js +40 -22
- package/components/Dropdown/DropdownItem.d.ts +31 -2
- package/components/Dropdown/DropdownItem.js +54 -27
- package/components/Dropdown/DropdownLabel.d.ts +11 -0
- package/components/Dropdown/DropdownLabel.js +11 -0
- package/components/Dropdown/DropdownSeparator.d.ts +12 -0
- package/components/Dropdown/DropdownSeparator.js +11 -0
- package/components/Dropdown/dropdownContext.d.ts +6 -0
- package/components/Dropdown/dropdownContext.js +5 -0
- package/components/Dropdown/index.d.ts +8 -2
- package/components/Dropdown/useContextMenu.d.ts +32 -0
- package/components/Dropdown/useContextMenu.js +18 -0
- package/components/EmptyState/EmptyState.d.ts +53 -0
- package/components/EmptyState/EmptyState.js +55 -0
- package/components/EmptyState/EmptyState.module.scss.js +25 -0
- package/components/EmptyState/index.d.ts +2 -0
- package/components/Form/FormField.js +25 -24
- package/components/ImageViewer/ImageViewer.d.ts +105 -0
- package/components/ImageViewer/ImageViewer.js +201 -0
- package/components/ImageViewer/ImageViewer.module.scss.js +47 -0
- package/components/ImageViewer/index.d.ts +4 -0
- package/components/ImageViewer/useZoomPan.d.ts +94 -0
- package/components/ImageViewer/useZoomPan.js +141 -0
- package/components/Kbd/Kbd.d.ts +26 -0
- package/components/Kbd/Kbd.js +22 -0
- package/components/Kbd/Kbd.module.scss.js +17 -0
- package/components/Kbd/index.d.ts +2 -0
- package/components/KeyValueList/KeyValueList.d.ts +84 -0
- package/components/KeyValueList/KeyValueList.js +127 -0
- package/components/KeyValueList/KeyValueList.module.scss.js +43 -0
- package/components/KeyValueList/index.d.ts +2 -0
- package/components/Modal/Modal.d.ts +1 -0
- package/components/Modal/Modal.js +40 -41
- package/components/Modal/Modal.module.scss.js +18 -16
- package/components/PageHeader/PageHeader.d.ts +61 -0
- package/components/PageHeader/PageHeader.js +73 -0
- package/components/PageHeader/PageHeader.module.scss.js +43 -0
- package/components/PageHeader/index.d.ts +2 -0
- package/components/ProgressBar/ProgressBar.d.ts +74 -0
- package/components/ProgressBar/ProgressBar.js +90 -0
- package/components/ProgressBar/ProgressBar.module.scss.js +51 -0
- package/components/ProgressBar/index.d.ts +2 -0
- package/components/RelativeTime/RelativeTime.d.ts +45 -0
- package/components/RelativeTime/RelativeTime.js +43 -0
- package/components/RelativeTime/RelativeTime.module.scss.js +7 -0
- package/components/RelativeTime/index.d.ts +2 -0
- package/components/SegmentedControl/SegmentedControl.d.ts +84 -0
- package/components/SegmentedControl/SegmentedControl.js +131 -0
- package/components/SegmentedControl/SegmentedControl.module.scss.js +39 -0
- package/components/SegmentedControl/index.d.ts +2 -0
- package/components/SplitPane/SplitPane.d.ts +61 -0
- package/components/SplitPane/SplitPane.js +171 -0
- package/components/SplitPane/SplitPane.module.scss.js +25 -0
- package/components/SplitPane/index.d.ts +2 -0
- package/components/StatCard/StatCard.d.ts +105 -0
- package/components/StatCard/StatCard.js +127 -0
- package/components/StatCard/StatCard.module.scss.js +72 -0
- package/components/StatCard/index.d.ts +2 -0
- package/components/StatusDot/StatusDot.d.ts +33 -0
- package/components/StatusDot/StatusDot.js +39 -0
- package/components/StatusDot/StatusDot.module.scss.js +32 -0
- package/components/StatusDot/index.d.ts +2 -0
- package/components/Table/Table.d.ts +100 -2
- package/components/Table/Table.js +371 -210
- package/components/Table/Table.module.scss.js +68 -46
- package/components/Table/index.d.ts +1 -1
- package/components/ThemeToggle/ThemeToggle.d.ts +38 -0
- package/components/ThemeToggle/ThemeToggle.js +97 -0
- package/components/ThemeToggle/ThemeToggle.module.scss.js +23 -0
- package/components/ThemeToggle/index.d.ts +2 -0
- package/components/inputs/Checkbox/Checkbox.d.ts +2 -0
- package/components/inputs/Checkbox/Checkbox.js +29 -28
- package/components/inputs/Checkbox/Checkbox.module.scss.js +8 -6
- package/components/inputs/Input/Input.d.ts +33 -1
- package/components/inputs/Input/Input.js +94 -35
- package/components/inputs/Input/Input.module.scss.js +14 -12
- package/components/inputs/Radio/Radio.d.ts +5 -4
- package/components/inputs/Radio/Radio.js +55 -50
- package/components/inputs/Radio/Radio.module.scss.js +12 -10
- package/components/inputs/SearchInput/SearchInput.d.ts +57 -0
- package/components/inputs/SearchInput/SearchInput.js +116 -0
- package/components/inputs/SearchInput/SearchInput.module.scss.js +13 -0
- package/components/inputs/SearchInput/index.d.ts +2 -0
- package/components/inputs/Select/Select.d.ts +52 -0
- package/components/inputs/Select/Select.js +494 -385
- package/components/inputs/Select/Select.module.scss.js +34 -30
- package/components/inputs/Switch/Switch.d.ts +15 -0
- package/components/inputs/Switch/Switch.js +8 -0
- package/components/inputs/Switch/index.d.ts +2 -0
- package/hooks/useDebouncedValue.d.ts +15 -0
- package/hooks/useDebouncedValue.js +15 -0
- package/hooks/useElementSize.d.ts +20 -0
- package/hooks/useElementSize.js +23 -0
- package/hooks/useKeyboard.d.ts +49 -5
- package/hooks/useKeyboard.js +66 -16
- package/hooks/useMediaQuery.d.ts +14 -0
- package/hooks/useMediaQuery.js +16 -0
- package/hooks/useNow.d.ts +14 -0
- package/hooks/useNow.js +35 -0
- package/hooks/usePersistedState.d.ts +30 -0
- package/hooks/usePersistedState.js +96 -0
- package/hooks/useResizable.d.ts +66 -0
- package/hooks/useResizable.js +105 -0
- package/hooks/useTheme.d.ts +33 -0
- package/hooks/useTheme.js +27 -0
- package/index.css +1 -1
- package/index.d.ts +58 -4
- package/index.js +208 -132
- package/index.layered.css +1 -1
- package/llms.txt +619 -25
- package/manifest.json +1739 -91
- package/package.json +1 -1
- package/recipes/confirm-modal.tsx +65 -53
- package/recipes/floating-copy-button.tsx +32 -28
- package/utils/formatBytes.d.ts +21 -0
- package/utils/formatBytes.js +14 -0
- package/utils/index.d.ts +6 -0
- package/utils/themeScript.d.ts +17 -0
- package/utils/themeScript.js +9 -0
- package/utils/timeAgo.d.ts +33 -0
- package/utils/timeAgo.js +37 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
const c = "crk-root-zsoSy", r = "crk-sm-QbYLY", s = "crk-md--mV9a", e = "crk-pill-NsOem", o = "crk-rounded-Ps5zU", n = "crk-neutral-7ArkN", t = "crk-primary-rvetC", a = "crk-success-0GXdc", k = "crk-warning-NBLbz", i = "crk-danger-OJzar", d = "crk-soft-Pwn3N", l = "crk-outline-7MTzq", p = "crk-interactive-GksDo", m = "crk-selected-xbmxv", g = "crk-remove-GOhuV", u = "crk-disabled-0tD30", b = "crk-check-d6HS8", w = "crk-checkVisible-BkMxn", v = "crk-icon-Vxm-K", h = "crk-avatar-01FUB", V = "crk-label-VIt6F", x = "crk-group-EnqaM", y = "crk-gap-sm-WjiwB", z = "crk-gap-md-P9eUW", B = "crk-wrap-64-CR", M = "crk-nowrap-oTmY8", f = {
|
|
2
|
+
root: c,
|
|
3
|
+
sm: r,
|
|
4
|
+
md: s,
|
|
5
|
+
pill: e,
|
|
6
|
+
rounded: o,
|
|
7
|
+
neutral: n,
|
|
8
|
+
primary: t,
|
|
9
|
+
success: a,
|
|
10
|
+
warning: k,
|
|
11
|
+
danger: i,
|
|
12
|
+
soft: d,
|
|
13
|
+
outline: l,
|
|
14
|
+
interactive: p,
|
|
15
|
+
selected: m,
|
|
16
|
+
remove: g,
|
|
17
|
+
disabled: u,
|
|
18
|
+
check: b,
|
|
19
|
+
checkVisible: w,
|
|
20
|
+
icon: v,
|
|
21
|
+
avatar: h,
|
|
22
|
+
label: V,
|
|
23
|
+
group: x,
|
|
24
|
+
"gap-sm": "crk-gap-sm-WjiwB",
|
|
25
|
+
gapSm: y,
|
|
26
|
+
"gap-md": "crk-gap-md-P9eUW",
|
|
27
|
+
gapMd: z,
|
|
28
|
+
wrap: B,
|
|
29
|
+
nowrap: M
|
|
30
|
+
};
|
|
31
|
+
export {
|
|
32
|
+
h as avatar,
|
|
33
|
+
b as check,
|
|
34
|
+
w as checkVisible,
|
|
35
|
+
i as danger,
|
|
36
|
+
f as default,
|
|
37
|
+
u as disabled,
|
|
38
|
+
z as gapMd,
|
|
39
|
+
y as gapSm,
|
|
40
|
+
x as group,
|
|
41
|
+
v as icon,
|
|
42
|
+
p as interactive,
|
|
43
|
+
V as label,
|
|
44
|
+
s as md,
|
|
45
|
+
n as neutral,
|
|
46
|
+
M as nowrap,
|
|
47
|
+
l as outline,
|
|
48
|
+
e as pill,
|
|
49
|
+
t as primary,
|
|
50
|
+
g as remove,
|
|
51
|
+
c as root,
|
|
52
|
+
o as rounded,
|
|
53
|
+
m as selected,
|
|
54
|
+
r as sm,
|
|
55
|
+
d as soft,
|
|
56
|
+
a as success,
|
|
57
|
+
k as warning,
|
|
58
|
+
B as wrap
|
|
59
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { ComponentPropsWithRef, ReactNode } from 'react';
|
|
2
|
+
export interface CodeBlockClasses {
|
|
3
|
+
root: string;
|
|
4
|
+
header: string;
|
|
5
|
+
title: string;
|
|
6
|
+
language: string;
|
|
7
|
+
actions: string;
|
|
8
|
+
pre: string;
|
|
9
|
+
code: string;
|
|
10
|
+
line: string;
|
|
11
|
+
lineNumber: string;
|
|
12
|
+
lineHighlight: string;
|
|
13
|
+
copy: string;
|
|
14
|
+
wrapToggle: string;
|
|
15
|
+
}
|
|
16
|
+
export interface CodeBlockProps extends Omit<ComponentPropsWithRef<'div'>, 'children' | 'title'> {
|
|
17
|
+
/** The source text. Also exactly what the copy button copies. */
|
|
18
|
+
code?: string;
|
|
19
|
+
/** Alias for `code` (a plain string). `code` wins when both are given. */
|
|
20
|
+
children?: string;
|
|
21
|
+
/** Language label in the header (`bash`, `tsx`); also `data-language` + `language-<x>` class on `<code>` for CSS-based highlighters. */
|
|
22
|
+
language?: string;
|
|
23
|
+
/** Header text on the left (typically a filename). */
|
|
24
|
+
title?: ReactNode;
|
|
25
|
+
/** Render a copy button that copies `code`. @default true */
|
|
26
|
+
showCopy?: boolean;
|
|
27
|
+
/** `'floating'` = top-right over the code, shown on hover / focus-within; `'header'` = in the header row, always visible. @default 'floating' */
|
|
28
|
+
copyPlacement?: 'floating' | 'header';
|
|
29
|
+
/** Called with the copied text after a successful copy. */
|
|
30
|
+
onCopied?: (text: string) => void;
|
|
31
|
+
/** Soft-wrap long lines instead of scrolling horizontally. @default false */
|
|
32
|
+
wrap?: boolean;
|
|
33
|
+
/** Add a header button that toggles `wrap` locally. @default false */
|
|
34
|
+
showWrapToggle?: boolean;
|
|
35
|
+
/** Render line numbers in a non-selectable gutter. @default false */
|
|
36
|
+
lineNumbers?: boolean;
|
|
37
|
+
/** First line number. @default 1 */
|
|
38
|
+
startLine?: number;
|
|
39
|
+
/** Lines to tint, as displayed (absolute, 1-based — honours `startLine`). */
|
|
40
|
+
highlightLines?: number[];
|
|
41
|
+
/** Vertical scroll past this height (number = px). */
|
|
42
|
+
maxHeight?: number | string;
|
|
43
|
+
/** Font size: `xs` / `sm`. @default 'md' */
|
|
44
|
+
size?: 'sm' | 'md';
|
|
45
|
+
/**
|
|
46
|
+
* Plug in a highlighter: receives the display text and returns the nodes
|
|
47
|
+
* rendered inside `<code>` (or per line, with `lineNumbers`). No
|
|
48
|
+
* highlighter ships with the toolkit.
|
|
49
|
+
*/
|
|
50
|
+
highlight?: (code: string) => ReactNode;
|
|
51
|
+
/** Override class names on internal elements. */
|
|
52
|
+
classes?: Partial<CodeBlockClasses>;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Code snippet with a built-in copy button, optional header (title +
|
|
56
|
+
* language), soft-wrap toggle, line numbers and highlighted lines. Plain
|
|
57
|
+
* `<pre><code>` — no highlighter dependency; pass `highlight` to plug one in,
|
|
58
|
+
* or style `.language-<x>` with a CSS-based one.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* <CodeBlock language="bash" title="install.sh" copyPlacement="header"
|
|
62
|
+
* code={'npm install @overdoser/react-toolkit'} />
|
|
63
|
+
*/
|
|
64
|
+
export declare const CodeBlock: import('react').ForwardRefExoticComponent<Omit<CodeBlockProps, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
|
|
65
|
+
export interface CodeClasses {
|
|
66
|
+
root: string;
|
|
67
|
+
}
|
|
68
|
+
export interface CodeProps extends ComponentPropsWithRef<'code'> {
|
|
69
|
+
/** Override class names on internal elements. */
|
|
70
|
+
classes?: Partial<CodeClasses>;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Inline code span for identifiers inside prose: `<Code>npm test</Code>`.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* Run <Code>npm test</Code> after every change.
|
|
77
|
+
*/
|
|
78
|
+
export declare const Code: import('react').ForwardRefExoticComponent<Omit<CodeProps, "ref"> & import('react').RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { jsx as n, jsxs as l } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as D, useState as $, useMemo as j } from "react";
|
|
3
|
+
import o from "clsx";
|
|
4
|
+
import e from "./CodeBlock.module.scss.js";
|
|
5
|
+
import { CopyButton as K } from "../ActionButton/CopyButton.js";
|
|
6
|
+
function Q() {
|
|
7
|
+
return /* @__PURE__ */ l("svg", { width: "1em", height: "1em", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
|
|
8
|
+
/* @__PURE__ */ n("path", { d: "M3 6h18" }),
|
|
9
|
+
/* @__PURE__ */ n("path", { d: "M3 12h13a3 3 0 0 1 0 6h-4" }),
|
|
10
|
+
/* @__PURE__ */ n("path", { d: "m14 16-2 2 2 2" }),
|
|
11
|
+
/* @__PURE__ */ n("path", { d: "M3 18h6" })
|
|
12
|
+
] });
|
|
13
|
+
}
|
|
14
|
+
const T = (r) => typeof r == "number" ? `${r}px` : r, U = D(
|
|
15
|
+
({
|
|
16
|
+
code: r,
|
|
17
|
+
children: N,
|
|
18
|
+
language: t,
|
|
19
|
+
title: c,
|
|
20
|
+
showCopy: f = !0,
|
|
21
|
+
copyPlacement: b = "floating",
|
|
22
|
+
onCopied: L,
|
|
23
|
+
wrap: i = !1,
|
|
24
|
+
showWrapToggle: y = !1,
|
|
25
|
+
lineNumbers: C = !1,
|
|
26
|
+
startLine: k = 1,
|
|
27
|
+
highlightLines: W,
|
|
28
|
+
maxHeight: z,
|
|
29
|
+
size: I = "md",
|
|
30
|
+
highlight: s,
|
|
31
|
+
classes: a,
|
|
32
|
+
className: O,
|
|
33
|
+
style: R,
|
|
34
|
+
...q
|
|
35
|
+
}, w) => {
|
|
36
|
+
const g = r ?? N ?? "", p = g.replace(/\n$/, ""), [A, v] = $(i), [E, F] = $(i);
|
|
37
|
+
E !== i && (F(i), v(i));
|
|
38
|
+
const m = y ? A : i, h = j(() => C ? p.split(`
|
|
39
|
+
`) : null, [p, C]), B = j(() => new Set(W ?? []), [W]), x = h ? String(k + h.length - 1).length : 0, H = f && b === "header", G = !!c || !!t || H || y, M = f ? /* @__PURE__ */ n(
|
|
40
|
+
K,
|
|
41
|
+
{
|
|
42
|
+
value: g,
|
|
43
|
+
variant: "secondary",
|
|
44
|
+
size: "sm",
|
|
45
|
+
iconOnly: !0,
|
|
46
|
+
"aria-label": "Copy code",
|
|
47
|
+
onCopied: L,
|
|
48
|
+
className: o(e.copy, a?.copy)
|
|
49
|
+
}
|
|
50
|
+
) : null, S = o(e.code, t && `language-${t}`, a?.code);
|
|
51
|
+
return /* @__PURE__ */ l(
|
|
52
|
+
"div",
|
|
53
|
+
{
|
|
54
|
+
ref: w,
|
|
55
|
+
className: o(
|
|
56
|
+
e.root,
|
|
57
|
+
e[I],
|
|
58
|
+
m && e.wrap,
|
|
59
|
+
C && e.hasLineNumbers,
|
|
60
|
+
a?.root,
|
|
61
|
+
O
|
|
62
|
+
),
|
|
63
|
+
style: { ...R, "--crk-code-gutter": x ? `${x}ch` : void 0 },
|
|
64
|
+
...q,
|
|
65
|
+
children: [
|
|
66
|
+
G && /* @__PURE__ */ l("div", { className: o(e.header, a?.header), children: [
|
|
67
|
+
c != null && /* @__PURE__ */ n("span", { className: o(e.title, a?.title), children: c }),
|
|
68
|
+
/* @__PURE__ */ l("span", { className: o(e.actions, a?.actions), children: [
|
|
69
|
+
t && /* @__PURE__ */ n("span", { className: o(e.language, a?.language), children: t }),
|
|
70
|
+
y && /* @__PURE__ */ n(
|
|
71
|
+
"button",
|
|
72
|
+
{
|
|
73
|
+
type: "button",
|
|
74
|
+
className: o(e.wrapToggle, a?.wrapToggle),
|
|
75
|
+
"aria-pressed": m,
|
|
76
|
+
"aria-label": m ? "Disable line wrap" : "Wrap lines",
|
|
77
|
+
title: m ? "Disable line wrap" : "Wrap lines",
|
|
78
|
+
onClick: () => v((u) => !u),
|
|
79
|
+
children: /* @__PURE__ */ n(Q, {})
|
|
80
|
+
}
|
|
81
|
+
),
|
|
82
|
+
H && M
|
|
83
|
+
] })
|
|
84
|
+
] }),
|
|
85
|
+
/* @__PURE__ */ l("div", { className: e.body, children: [
|
|
86
|
+
/* @__PURE__ */ n("pre", { className: o(e.pre, a?.pre), style: { maxHeight: T(z) }, children: h ? /* @__PURE__ */ n("code", { className: S, "data-language": t, children: h.map((u, J) => {
|
|
87
|
+
const d = k + J;
|
|
88
|
+
return /* @__PURE__ */ l(
|
|
89
|
+
"span",
|
|
90
|
+
{
|
|
91
|
+
className: o(e.line, B.has(d) && e.lineHighlight, a?.line, B.has(d) && a?.lineHighlight),
|
|
92
|
+
"data-line": d,
|
|
93
|
+
children: [
|
|
94
|
+
/* @__PURE__ */ n("span", { className: o(e.lineNumber, a?.lineNumber), "aria-hidden": "true", children: d }),
|
|
95
|
+
/* @__PURE__ */ l("span", { className: e.lineContent, children: [
|
|
96
|
+
s ? s(u) : u,
|
|
97
|
+
`
|
|
98
|
+
`
|
|
99
|
+
] })
|
|
100
|
+
]
|
|
101
|
+
},
|
|
102
|
+
d
|
|
103
|
+
);
|
|
104
|
+
}) }) : /* @__PURE__ */ n("code", { className: S, "data-language": t, children: s ? s(p) : p }) }),
|
|
105
|
+
f && b === "floating" && // Solid layer under the (transparent-at-rest) button so the code
|
|
106
|
+
// never shows through it mid-morph.
|
|
107
|
+
/* @__PURE__ */ n("div", { className: e.floating, children: M })
|
|
108
|
+
] })
|
|
109
|
+
]
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
);
|
|
114
|
+
U.displayName = "CodeBlock";
|
|
115
|
+
const V = D(({ classes: r, className: N, ...t }, c) => /* @__PURE__ */ n("code", { ref: c, className: o(e.inline, r?.root, N), ...t }));
|
|
116
|
+
V.displayName = "Code";
|
|
117
|
+
export {
|
|
118
|
+
V as Code,
|
|
119
|
+
U as CodeBlock
|
|
120
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const n = "crk-root-zQ2C1", e = "crk-sm-AJvrH", t = "crk-md-UrPWG", o = "crk-header-nhnDk", c = "crk-title-04Zf4", r = "crk-actions-QiElV", i = "crk-language-i5BRE", l = "crk-wrapToggle-nVfYu", s = "crk-body-XorUH", a = "crk-pre-gKHVv", g = "crk-code-uafC4", k = "crk-wrap-pybed", d = "crk-hasLineNumbers-2bfkO", h = "crk-line-Y6IZx", m = "crk-lineNumber-7WEdl", u = "crk-lineContent--DnJH", b = "crk-lineHighlight-zMlYK", p = "crk-floating-M98QW", f = "crk-inline-f5j4k", H = {
|
|
2
|
+
root: n,
|
|
3
|
+
sm: e,
|
|
4
|
+
md: t,
|
|
5
|
+
header: o,
|
|
6
|
+
title: c,
|
|
7
|
+
actions: r,
|
|
8
|
+
language: i,
|
|
9
|
+
wrapToggle: l,
|
|
10
|
+
body: s,
|
|
11
|
+
pre: a,
|
|
12
|
+
code: g,
|
|
13
|
+
wrap: k,
|
|
14
|
+
hasLineNumbers: d,
|
|
15
|
+
line: h,
|
|
16
|
+
lineNumber: m,
|
|
17
|
+
lineContent: u,
|
|
18
|
+
lineHighlight: b,
|
|
19
|
+
floating: p,
|
|
20
|
+
inline: f
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
r as actions,
|
|
24
|
+
s as body,
|
|
25
|
+
g as code,
|
|
26
|
+
H as default,
|
|
27
|
+
p as floating,
|
|
28
|
+
d as hasLineNumbers,
|
|
29
|
+
o as header,
|
|
30
|
+
f as inline,
|
|
31
|
+
i as language,
|
|
32
|
+
h as line,
|
|
33
|
+
u as lineContent,
|
|
34
|
+
b as lineHighlight,
|
|
35
|
+
m as lineNumber,
|
|
36
|
+
t as md,
|
|
37
|
+
a as pre,
|
|
38
|
+
n as root,
|
|
39
|
+
e as sm,
|
|
40
|
+
c as title,
|
|
41
|
+
k as wrap,
|
|
42
|
+
l as wrapToggle
|
|
43
|
+
};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { CSSProperties, ReactNode } from 'react';
|
|
2
|
+
export interface CommandItem {
|
|
3
|
+
/** Stable identifier; also used for `recentIds`. */
|
|
4
|
+
id: string;
|
|
5
|
+
/** Visible label. String labels are searchable and get match highlighting; nodes match through `keywords`. */
|
|
6
|
+
label: ReactNode;
|
|
7
|
+
/** Extra search terms (synonyms, paths). */
|
|
8
|
+
keywords?: string[];
|
|
9
|
+
/** Muted text under the label. */
|
|
10
|
+
description?: ReactNode;
|
|
11
|
+
/** Leading icon slot. */
|
|
12
|
+
icon?: ReactNode;
|
|
13
|
+
/** Shortcut hint rendered with `<Kbd>`: `'⌘K'` as one cap, `['⌘', 'K']` as a combination. */
|
|
14
|
+
shortcut?: string | string[];
|
|
15
|
+
/** Section heading the item is listed under. */
|
|
16
|
+
group?: string;
|
|
17
|
+
/** Non-interactive; skipped by keyboard navigation. @default false */
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
/** Called when the item is chosen (before the palette's `onSelect`). */
|
|
20
|
+
onSelect?: () => void;
|
|
21
|
+
/** Render the item as an anchor; the browser navigates on select. */
|
|
22
|
+
href?: string;
|
|
23
|
+
/** Nested page: choosing this item shows these instead (Backspace on an empty query goes back). */
|
|
24
|
+
children?: CommandItem[];
|
|
25
|
+
}
|
|
26
|
+
export interface CommandPaletteClasses {
|
|
27
|
+
backdrop: string;
|
|
28
|
+
panel: string;
|
|
29
|
+
header: string;
|
|
30
|
+
breadcrumb: string;
|
|
31
|
+
input: string;
|
|
32
|
+
list: string;
|
|
33
|
+
group: string;
|
|
34
|
+
groupLabel: string;
|
|
35
|
+
item: string;
|
|
36
|
+
itemActive: string;
|
|
37
|
+
itemIcon: string;
|
|
38
|
+
itemLabel: string;
|
|
39
|
+
itemDescription: string;
|
|
40
|
+
itemShortcut: string;
|
|
41
|
+
empty: string;
|
|
42
|
+
loading: string;
|
|
43
|
+
footer: string;
|
|
44
|
+
match: string;
|
|
45
|
+
}
|
|
46
|
+
export interface CommandItemRenderContext {
|
|
47
|
+
active: boolean;
|
|
48
|
+
query: string;
|
|
49
|
+
}
|
|
50
|
+
export interface CommandPaletteProps {
|
|
51
|
+
/** Whether the palette is shown. */
|
|
52
|
+
open: boolean;
|
|
53
|
+
/** Requested open state: the hotkey, Escape, backdrop click and selection all go through here. */
|
|
54
|
+
onOpenChange: (open: boolean) => void;
|
|
55
|
+
/** Root items. */
|
|
56
|
+
items: CommandItem[];
|
|
57
|
+
/** Called after the chosen item's own `onSelect`. */
|
|
58
|
+
onSelect?: (item: CommandItem) => void;
|
|
59
|
+
/** Close after choosing a leaf item. @default true */
|
|
60
|
+
closeOnSelect?: boolean;
|
|
61
|
+
/** Controlled search text. */
|
|
62
|
+
query?: string;
|
|
63
|
+
/** Initial search text (uncontrolled). @default '' */
|
|
64
|
+
defaultQuery?: string;
|
|
65
|
+
/** Fires on every keystroke (and when the query is cleared). */
|
|
66
|
+
onQueryChange?: (query: string) => void;
|
|
67
|
+
/**
|
|
68
|
+
* Local filter. Return `false` to hide, `true` or a number (higher sorts
|
|
69
|
+
* first) to show. `null` disables local filtering — pass already-filtered
|
|
70
|
+
* `items` (remote search). @default fuzzy subsequence + substring over `label` and `keywords`
|
|
71
|
+
*/
|
|
72
|
+
filter?: ((item: CommandItem, query: string) => boolean | number) | null;
|
|
73
|
+
/** Show a spinner row instead of results. @default false */
|
|
74
|
+
loading?: boolean;
|
|
75
|
+
/** Row shown while `loading`. @default 'Searching…' */
|
|
76
|
+
loadingMessage?: ReactNode;
|
|
77
|
+
/** Row shown when nothing matches. @default 'No results' */
|
|
78
|
+
emptyMessage?: ReactNode;
|
|
79
|
+
/** Input placeholder. @default 'Type a command or search…' */
|
|
80
|
+
placeholder?: string;
|
|
81
|
+
/** `useKeyboard` chord that toggles the palette. `false` disables it. @default 'mod+k' */
|
|
82
|
+
hotkey?: string | false;
|
|
83
|
+
/** Item ids listed first (in this order) while the query is empty. */
|
|
84
|
+
recentIds?: string[];
|
|
85
|
+
/** Heading of the recent section. @default 'Recent' */
|
|
86
|
+
recentLabel?: ReactNode;
|
|
87
|
+
/** Cap on rendered results. @default 50 */
|
|
88
|
+
maxResults?: number;
|
|
89
|
+
/** Explicit section order; unlisted groups follow in first-seen order. */
|
|
90
|
+
groupOrder?: string[];
|
|
91
|
+
/** Bottom row. `null` hides it. @default keyboard hints (↑↓ navigate · ↵ select · esc close) */
|
|
92
|
+
footer?: ReactNode | null;
|
|
93
|
+
/** Escape clears a non-empty query before closing. @default false */
|
|
94
|
+
escapeClearsQuery?: boolean;
|
|
95
|
+
/** Wrap matching characters of string labels in `<mark>`. @default true */
|
|
96
|
+
highlightMatches?: boolean;
|
|
97
|
+
/** Replace an item's inner content (icon/label/description/shortcut). */
|
|
98
|
+
renderItem?: (item: CommandItem, ctx: CommandItemRenderContext) => ReactNode;
|
|
99
|
+
/** Accessible name of the dialog. @default 'Command palette' */
|
|
100
|
+
'aria-label'?: string;
|
|
101
|
+
/** Override class names on internal elements. */
|
|
102
|
+
classes?: Partial<CommandPaletteClasses>;
|
|
103
|
+
className?: string;
|
|
104
|
+
style?: CSSProperties;
|
|
105
|
+
}
|
|
106
|
+
/** Indices of `query`'s characters inside `text` (substring first, else subsequence), or null. */
|
|
107
|
+
export declare function matchIndices(text: string, query: string): number[] | null;
|
|
108
|
+
export declare function defaultFilter(item: CommandItem, query: string): boolean | number;
|
|
109
|
+
/**
|
|
110
|
+
* Local open state for a `CommandPalette`.
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* const palette = useCommandPalette();
|
|
114
|
+
* <CommandPalette items={items} {...palette.paletteProps} />
|
|
115
|
+
*/
|
|
116
|
+
export declare function useCommandPalette(initialOpen?: boolean): {
|
|
117
|
+
open: boolean;
|
|
118
|
+
setOpen: import('react').Dispatch<import('react').SetStateAction<boolean>>;
|
|
119
|
+
toggle: () => void;
|
|
120
|
+
paletteProps: {
|
|
121
|
+
open: boolean;
|
|
122
|
+
onOpenChange: import('react').Dispatch<import('react').SetStateAction<boolean>>;
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* ⌘K command palette: a searchable list of actions and destinations in a
|
|
127
|
+
* top-anchored dialog. Items can carry icons, descriptions, shortcut hints,
|
|
128
|
+
* groups and nested pages; the search is local by default (fuzzy) or remote
|
|
129
|
+
* (`filter={null}` + `loading`). Opens on `mod+k` out of the box.
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* const palette = useCommandPalette();
|
|
133
|
+
* <CommandPalette
|
|
134
|
+
* {...palette.paletteProps}
|
|
135
|
+
* items={[
|
|
136
|
+
* { id: 'new', label: 'New project', icon: <PlusIcon />, shortcut: ['⌘', 'N'], group: 'Actions', onSelect: create },
|
|
137
|
+
* { id: 'settings', label: 'Settings', group: 'Navigate', href: '/settings' },
|
|
138
|
+
* ]}
|
|
139
|
+
* />
|
|
140
|
+
*/
|
|
141
|
+
export declare const CommandPalette: import('react').ForwardRefExoticComponent<CommandPaletteProps & import('react').RefAttributes<HTMLDivElement>>;
|