impact-nova 1.5.6 → 1.5.8
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/dist/components/layout/dashboard-layout.d.ts +24 -39
- package/dist/components/ui/ag-grid-react/cell-renderers/date-display-renderer.js +39 -32
- package/dist/components/ui/ag-grid-react/cell-renderers/editors/date-cell-editor.js +47 -47
- package/dist/components/ui/ag-grid-react/cell-renderers/editors/percent-progress-cell-editor.d.ts +16 -0
- package/dist/components/ui/ag-grid-react/cell-renderers/editors/percent-progress-cell-editor.js +135 -0
- package/dist/components/ui/ag-grid-react/cell-renderers/editors/select-cell-editor.js +39 -36
- package/dist/components/ui/ag-grid-react/cell-renderers/index.d.ts +14 -1
- package/dist/components/ui/ag-grid-react/cell-renderers/index.js +41 -35
- package/dist/components/ui/ag-grid-react/cell-renderers/percent-progress-display-renderer.d.ts +31 -0
- package/dist/components/ui/ag-grid-react/cell-renderers/percent-progress-display-renderer.js +63 -0
- package/dist/components/ui/ag-grid-react/cell-renderers/select-display-renderer.js +18 -12
- package/dist/components/ui/badge.d.ts +2 -1
- package/dist/components/ui/badge.js +17 -12
- package/dist/components/ui/command-palette/command-palette-context.d.ts +4 -2
- package/dist/components/ui/command-palette/command-palette-context.js +76 -77
- package/dist/components/ui/command-palette/command-palette.d.ts +20 -4
- package/dist/components/ui/command-palette/command-palette.js +210 -180
- package/dist/components/ui/command-palette/index.d.ts +3 -3
- package/dist/components/ui/command-palette/index.js +43 -40
- package/dist/components/ui/command-palette/shortcut-registry.d.ts +15 -2
- package/dist/components/ui/command-palette/shortcut-registry.js +61 -35
- package/dist/components/ui/command-palette/shortcut-settings.d.ts +14 -3
- package/dist/components/ui/command-palette/shortcut-settings.js +97 -90
- package/dist/components/ui/command-palette/utils.d.ts +15 -0
- package/dist/components/ui/command-palette/utils.js +105 -70
- package/dist/components/ui/filter-strip/filter-strip.d.ts +1 -1
- package/dist/components/ui/filter-strip/filter-strip.js +24 -22
- package/dist/components/ui/filter-strip/filter-tag-list.js +4 -4
- package/dist/components/ui/select/select.js +41 -41
- package/dist/components/ui/tabs.js +46 -45
- package/dist/icons/assets/command-pallet.svg.js +5 -0
- package/dist/icons/index.d.ts +2 -0
- package/dist/icons/index.js +146 -143
- package/dist/impact-nova.css +1 -1
- package/dist/index.js +100 -97
- package/package.json +1 -1
|
@@ -8,16 +8,18 @@ import { InputDisplayRenderer as a } from "./input-display-renderer.js";
|
|
|
8
8
|
import { SelectDisplayRenderer as p } from "./select-display-renderer.js";
|
|
9
9
|
import { CheckboxDisplayRenderer as m } from "./checkbox-display-renderer.js";
|
|
10
10
|
import { SwitchDisplayRenderer as d } from "./switch-display-renderer.js";
|
|
11
|
-
import { TextAreaDisplayRenderer as
|
|
12
|
-
import { DateDisplayRenderer as
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
|
|
11
|
+
import { TextAreaDisplayRenderer as s } from "./textarea-display-renderer.js";
|
|
12
|
+
import { DateDisplayRenderer as n } from "./date-display-renderer.js";
|
|
13
|
+
import { PercentProgressDisplayRenderer as c } from "./percent-progress-display-renderer.js";
|
|
14
|
+
import { InputCellEditor as f } from "./editors/input-cell-editor.js";
|
|
15
|
+
import { PercentProgressCellEditor as D } from "./editors/percent-progress-cell-editor.js";
|
|
16
|
+
import { SelectCellEditor as C } from "./editors/select-cell-editor.js";
|
|
17
|
+
import { TextAreaCellEditor as E } from "./editors/textarea-cell-editor.js";
|
|
18
|
+
import { DateCellEditor as R } from "./editors/date-cell-editor.js";
|
|
19
|
+
import { SplitCellEditor as y } from "./editors/split-cell-editor.js";
|
|
20
|
+
import { applyValueFormatter as z, evaluateValidationRules as H, getFieldValue as J, mapBadgeColor as K, mapBadgeVariant as Q, resolveCellEditable as W, resolveValueFormatter as X } from "./cell-renderer-utils.js";
|
|
21
|
+
import { addRowDataEditableCheck as Z } from "../editable-utils.js";
|
|
22
|
+
const v = "ag-cell-no-padding", w = "ag-cell-renderer-full-control", M = "ag-cell-inner-padding", U = {
|
|
21
23
|
// Display-only renderers
|
|
22
24
|
empty: e,
|
|
23
25
|
badge: r,
|
|
@@ -30,42 +32,46 @@ const V = "ag-cell-no-padding", F = "ag-cell-renderer-full-control", T = "ag-cel
|
|
|
30
32
|
selectDisplay: p,
|
|
31
33
|
checkboxDisplay: m,
|
|
32
34
|
switchDisplay: d,
|
|
33
|
-
textareaDisplay:
|
|
34
|
-
dateDisplay:
|
|
35
|
+
textareaDisplay: s,
|
|
36
|
+
dateDisplay: n,
|
|
37
|
+
percentProgressDisplay: c,
|
|
35
38
|
// Cell editors (real interactive components, mounted on edit)
|
|
36
|
-
inputEditor:
|
|
37
|
-
selectEditor:
|
|
38
|
-
textareaEditor:
|
|
39
|
-
dateEditor:
|
|
40
|
-
splitEditor:
|
|
39
|
+
inputEditor: f,
|
|
40
|
+
selectEditor: C,
|
|
41
|
+
textareaEditor: E,
|
|
42
|
+
dateEditor: R,
|
|
43
|
+
splitEditor: y,
|
|
44
|
+
percentProgressEditor: D
|
|
41
45
|
};
|
|
42
46
|
export {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
w as AG_CELL_FULL_CONTROL,
|
|
48
|
+
M as AG_CELL_INNER_PADDING,
|
|
49
|
+
v as AG_CELL_NO_PADDING,
|
|
50
|
+
U as AG_GRID_CELL_COMPONENTS,
|
|
47
51
|
o as ActionsCellRenderer,
|
|
48
52
|
r as BadgeCellRenderer,
|
|
49
53
|
m as CheckboxDisplayRenderer,
|
|
50
|
-
|
|
51
|
-
|
|
54
|
+
R as DateCellEditor,
|
|
55
|
+
n as DateDisplayRenderer,
|
|
52
56
|
e as EmptyCellRenderer,
|
|
53
57
|
a as InputDisplayRenderer,
|
|
54
58
|
l as LinkCellRenderer,
|
|
55
|
-
|
|
59
|
+
D as PercentProgressCellEditor,
|
|
60
|
+
c as PercentProgressDisplayRenderer,
|
|
61
|
+
C as SelectCellEditor,
|
|
56
62
|
p as SelectDisplayRenderer,
|
|
57
|
-
|
|
63
|
+
y as SplitCellEditor,
|
|
58
64
|
i as SplitCellRenderer,
|
|
59
65
|
t as StatusBadgeRenderer,
|
|
60
66
|
d as SwitchDisplayRenderer,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
E as TextAreaCellEditor,
|
|
68
|
+
s as TextAreaDisplayRenderer,
|
|
69
|
+
Z as addRowDataEditableCheck,
|
|
70
|
+
z as applyValueFormatter,
|
|
71
|
+
H as evaluateValidationRules,
|
|
72
|
+
J as getFieldValue,
|
|
73
|
+
K as mapBadgeColor,
|
|
74
|
+
Q as mapBadgeVariant,
|
|
75
|
+
W as resolveCellEditable,
|
|
76
|
+
X as resolveValueFormatter
|
|
71
77
|
};
|
package/dist/components/ui/ag-grid-react/cell-renderers/percent-progress-display-renderer.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ICellRendererParams } from 'ag-grid-enterprise';
|
|
2
|
+
import { BadgeProps } from '../../badge';
|
|
3
|
+
import { ProgressProps } from '../../progress';
|
|
4
|
+
export interface PercentProgressDisplayRendererProps extends ICellRendererParams {
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
className?: string;
|
|
7
|
+
/** Inclusive min for the scale (default 0) */
|
|
8
|
+
min?: number;
|
|
9
|
+
/** Inclusive max for the scale (default 100) */
|
|
10
|
+
max?: number;
|
|
11
|
+
/** Decimal places for the badge label (default 0) */
|
|
12
|
+
fractionDigits?: number;
|
|
13
|
+
/** Percentage pill — same options as `Badge` (defaults: subtle / neutral / circle) */
|
|
14
|
+
badgeVariant?: BadgeProps['variant'];
|
|
15
|
+
badgeColor?: BadgeProps['color'];
|
|
16
|
+
badgeShape?: BadgeProps['shape'];
|
|
17
|
+
/** Progress track + fill — same options as `ProgressBar` / `Progress` (default: default) */
|
|
18
|
+
progressVariant?: ProgressProps['variant'];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* PercentProgressDisplayRenderer — capsule progress bar + percentage pill (display).
|
|
22
|
+
* Pair with `PercentProgressCellEditor` via `cellEditor` for editing.
|
|
23
|
+
*
|
|
24
|
+
* Cell value: number or string like `"25"` / `"25%"`, or `{ value, cellMetadata? }`.
|
|
25
|
+
*
|
|
26
|
+
* Styling via `cellRendererParams`: `badgeVariant`, `badgeColor`, `badgeShape`, `progressVariant`.
|
|
27
|
+
*/
|
|
28
|
+
export declare const PercentProgressDisplayRenderer: {
|
|
29
|
+
(props: PercentProgressDisplayRendererProps): import("react/jsx-runtime").JSX.Element;
|
|
30
|
+
displayName: string;
|
|
31
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { jsx as o, jsxs as V } from "react/jsx-runtime";
|
|
2
|
+
import { Badge as j } from "../../badge.js";
|
|
3
|
+
import { cn as w } from "../../../../lib/utils.js";
|
|
4
|
+
import { Progress as $ } from "../../progress.js";
|
|
5
|
+
function E(e) {
|
|
6
|
+
return e && typeof e == "object" && "value" in e ? e.value : e;
|
|
7
|
+
}
|
|
8
|
+
function F(e) {
|
|
9
|
+
if (e == null || e === "") return null;
|
|
10
|
+
if (typeof e == "number") return isNaN(e) ? null : e;
|
|
11
|
+
const a = Number(String(e).replace(/%/g, "").trim());
|
|
12
|
+
return isNaN(a) ? null : a;
|
|
13
|
+
}
|
|
14
|
+
function S(e, a, n) {
|
|
15
|
+
return Math.min(n, Math.max(a, e));
|
|
16
|
+
}
|
|
17
|
+
const _ = (e) => {
|
|
18
|
+
const { value: a, disabled: n, colDef: c, className: b, data: s } = e, l = e.min ?? 0, d = e.max ?? 100, u = e.fractionDigits ?? 0, x = e.badgeVariant ?? "subtle", h = e.badgeColor ?? "neutral", p = e.badgeShape ?? "circle", N = e.progressVariant ?? "default", f = a && typeof a == "object" && "cellMetadata" in a ? a.cellMetadata?._isDisabled : void 0, m = s && typeof s == "object" && "rowMetadata" in s ? s.rowMetadata?._isDisabled : void 0;
|
|
19
|
+
let t = !1;
|
|
20
|
+
if (!n) {
|
|
21
|
+
const P = c?._originalEditable;
|
|
22
|
+
c?.editable === !1 ? t = !1 : f === !1 ? t = !0 : f === !0 ? t = !1 : m === !1 ? t = !0 : m === !0 ? t = !1 : t = P === !0 || c?.editable === !0;
|
|
23
|
+
}
|
|
24
|
+
const v = E(a), g = F(v), i = g != null, r = i ? S(g, l, d) : l, y = d - l || 1, D = i ? (r - l) / y * 100 : 0, M = i ? u > 0 ? `${r.toFixed(u)}%` : `${Math.round(r)}%` : "--";
|
|
25
|
+
return /* @__PURE__ */ o(
|
|
26
|
+
"div",
|
|
27
|
+
{
|
|
28
|
+
className: `w-full h-full flex items-center ag-cell-inner-padding ${b ?? ""} ${n ? "opacity-60 cursor-not-allowed" : t ? "in-ag-editable-cell-highlight" : ""}`,
|
|
29
|
+
children: /* @__PURE__ */ V("div", { className: "flex w-full min-w-0 items-center gap-2", children: [
|
|
30
|
+
/* @__PURE__ */ o("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ o(
|
|
31
|
+
$,
|
|
32
|
+
{
|
|
33
|
+
label: !1,
|
|
34
|
+
variant: N,
|
|
35
|
+
value: D,
|
|
36
|
+
max: 100,
|
|
37
|
+
"aria-valuenow": i ? r : void 0,
|
|
38
|
+
"aria-valuemin": l,
|
|
39
|
+
"aria-valuemax": d,
|
|
40
|
+
className: "h-2.5"
|
|
41
|
+
}
|
|
42
|
+
) }),
|
|
43
|
+
/* @__PURE__ */ o(
|
|
44
|
+
j,
|
|
45
|
+
{
|
|
46
|
+
variant: x,
|
|
47
|
+
color: h,
|
|
48
|
+
shape: p,
|
|
49
|
+
className: w(
|
|
50
|
+
"shrink-0 tabular-nums px-2 py-0.5 text-xs font-medium leading-none border-0",
|
|
51
|
+
!i && "text-[#dfe2e7]"
|
|
52
|
+
),
|
|
53
|
+
children: M
|
|
54
|
+
}
|
|
55
|
+
)
|
|
56
|
+
] })
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
_.displayName = "PercentProgressDisplayRenderer";
|
|
61
|
+
export {
|
|
62
|
+
_ as PercentProgressDisplayRenderer
|
|
63
|
+
};
|
|
@@ -1,25 +1,31 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { ChevronDown as
|
|
3
|
-
const
|
|
4
|
-
const { value: e, options:
|
|
5
|
-
|
|
1
|
+
import { jsx as n, jsxs as m } from "react/jsx-runtime";
|
|
2
|
+
import { ChevronDown as g } from "lucide-react";
|
|
3
|
+
const h = (u) => {
|
|
4
|
+
const { value: e, options: b = [], placeholder: p = "Select...", disabled: o, colDef: i, data: t } = u, r = e && typeof e == "object" && "cellMetadata" in e ? e.cellMetadata?._isDisabled : void 0, d = t && typeof t == "object" && "rowMetadata" in t ? t.rowMetadata?._isDisabled : void 0;
|
|
5
|
+
let l = !1;
|
|
6
|
+
if (!o) {
|
|
7
|
+
const s = i?._originalEditable;
|
|
8
|
+
i?.editable === !1 ? l = !1 : r === !1 ? l = !0 : r === !0 ? l = !1 : d === !1 ? l = !0 : d === !0 ? l = !1 : l = s === !0 || i?.editable === !0;
|
|
9
|
+
}
|
|
10
|
+
const a = e && typeof e == "object" && "value" in e ? e.value : e, c = b.find((s) => s.value === String(a ?? ""))?.label ?? (a != null && a !== "" ? String(a) : ""), f = !c;
|
|
11
|
+
return /* @__PURE__ */ n(
|
|
6
12
|
"div",
|
|
7
13
|
{
|
|
8
|
-
className: `w-full h-full flex items-center ag-cell-inner-padding ${
|
|
9
|
-
children: /* @__PURE__ */
|
|
14
|
+
className: `w-full h-full flex items-center ag-cell-inner-padding ${o ? "opacity-60 cursor-not-allowed" : l ? "in-ag-editable-cell-highlight" : ""}`,
|
|
15
|
+
children: /* @__PURE__ */ m(
|
|
10
16
|
"div",
|
|
11
17
|
{
|
|
12
|
-
className:
|
|
18
|
+
className: `flex w-full items-center justify-between rounded-[8px] px-1.5 h-7 ${l ? "bg-white cursor-pointer" : "bg-inherit"}`,
|
|
13
19
|
children: [
|
|
14
|
-
/* @__PURE__ */
|
|
15
|
-
/* @__PURE__ */
|
|
20
|
+
/* @__PURE__ */ n("span", { className: `truncate text-sm font-medium text-[#1f2b4d] ${f ? "text-[#dfe2e7]" : ""}`, children: f ? p : c }),
|
|
21
|
+
l && /* @__PURE__ */ n(g, { className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" })
|
|
16
22
|
]
|
|
17
23
|
}
|
|
18
24
|
)
|
|
19
25
|
}
|
|
20
26
|
);
|
|
21
27
|
};
|
|
22
|
-
|
|
28
|
+
h.displayName = "SelectDisplayRenderer";
|
|
23
29
|
export {
|
|
24
|
-
|
|
30
|
+
h as SelectDisplayRenderer
|
|
25
31
|
};
|
|
@@ -3,8 +3,9 @@ import * as React from "react";
|
|
|
3
3
|
declare const badgeVariants: (props?: {
|
|
4
4
|
variant?: "solid" | "outline" | "subtle";
|
|
5
5
|
color?: "primary" | "destructive" | "warning" | "success" | "neutral";
|
|
6
|
+
shape?: "circle" | "square";
|
|
6
7
|
} & import('class-variance-authority/types').ClassProp) => string;
|
|
7
8
|
export interface BadgeProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "color">, VariantProps<typeof badgeVariants> {
|
|
8
9
|
}
|
|
9
|
-
declare function Badge({ className, variant, color, ...props }: BadgeProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
declare function Badge({ className, variant, color, shape, ...props }: BadgeProps): import("react/jsx-runtime").JSX.Element;
|
|
10
11
|
export { Badge, badgeVariants };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
|
-
import { cva as
|
|
4
|
-
import { cn as
|
|
5
|
-
const
|
|
6
|
-
"inline-flex items-center
|
|
3
|
+
import { cva as o } from "class-variance-authority";
|
|
4
|
+
import { cn as i } from "../../lib/utils.js";
|
|
5
|
+
const c = o(
|
|
6
|
+
"inline-flex items-center border px-2.5 py-0.5 text-sm leading-[18px] font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
7
7
|
{
|
|
8
8
|
variants: {
|
|
9
9
|
variant: {
|
|
@@ -17,6 +17,10 @@ const i = n(
|
|
|
17
17
|
warning: "",
|
|
18
18
|
destructive: "",
|
|
19
19
|
neutral: ""
|
|
20
|
+
},
|
|
21
|
+
shape: {
|
|
22
|
+
circle: "rounded-full",
|
|
23
|
+
square: "rounded"
|
|
20
24
|
}
|
|
21
25
|
},
|
|
22
26
|
compoundVariants: [
|
|
@@ -41,21 +45,22 @@ const i = n(
|
|
|
41
45
|
],
|
|
42
46
|
defaultVariants: {
|
|
43
47
|
variant: "solid",
|
|
44
|
-
color: "primary"
|
|
48
|
+
color: "primary",
|
|
49
|
+
shape: "circle"
|
|
45
50
|
}
|
|
46
51
|
}
|
|
47
52
|
);
|
|
48
|
-
function
|
|
49
|
-
return /* @__PURE__ */
|
|
53
|
+
function m({ className: r, variant: t, color: a, shape: e, ...s }) {
|
|
54
|
+
return /* @__PURE__ */ n(
|
|
50
55
|
"div",
|
|
51
56
|
{
|
|
52
|
-
className:
|
|
57
|
+
className: i(c({ variant: t, color: a, shape: e }), r),
|
|
53
58
|
"data-component": "badge",
|
|
54
|
-
...
|
|
59
|
+
...s
|
|
55
60
|
}
|
|
56
61
|
);
|
|
57
62
|
}
|
|
58
63
|
export {
|
|
59
|
-
|
|
60
|
-
|
|
64
|
+
m as Badge,
|
|
65
|
+
c as badgeVariants
|
|
61
66
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ShortcutRegistry, ConflictInfo } from './shortcut-registry';
|
|
2
|
-
import { CommandDefinition, KeyBinding, ShortcutScope } from './utils';
|
|
2
|
+
import { CommandDefinition, KeyBinding, ShortcutScope, ShortcutStorageAdapter } from './utils';
|
|
3
3
|
/**
|
|
4
4
|
* CommandPaletteProvider — React context that wraps ShortcutRegistry,
|
|
5
5
|
* manages ⌘K open/close, and provides the API to all descendants.
|
|
@@ -44,8 +44,10 @@ export interface CommandPaletteProviderProps {
|
|
|
44
44
|
children: React.ReactNode;
|
|
45
45
|
/** Custom keybinding to open the palette (defaults to ⌘K / Ctrl+K) */
|
|
46
46
|
openKeybinding?: KeyBinding;
|
|
47
|
+
/** Custom storage adapter for shortcuts and recent commands */
|
|
48
|
+
storage?: ShortcutStorageAdapter;
|
|
47
49
|
}
|
|
48
|
-
export declare function CommandPaletteProvider({ children, openKeybinding, }: CommandPaletteProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
50
|
+
export declare function CommandPaletteProvider({ children, openKeybinding, storage, }: CommandPaletteProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
49
51
|
export declare namespace CommandPaletteProvider {
|
|
50
52
|
var displayName: string;
|
|
51
53
|
}
|
|
@@ -1,86 +1,86 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import * as
|
|
3
|
-
import { ShortcutRegistry as
|
|
4
|
-
import { matchesKeybinding as
|
|
5
|
-
const
|
|
1
|
+
import { jsx as A } from "react/jsx-runtime";
|
|
2
|
+
import * as t from "react";
|
|
3
|
+
import { ShortcutRegistry as N } from "./shortcut-registry.js";
|
|
4
|
+
import { matchesKeybinding as R } from "./utils.js";
|
|
5
|
+
const w = t.createContext(null);
|
|
6
6
|
function T({
|
|
7
7
|
children: o,
|
|
8
|
-
openKeybinding:
|
|
8
|
+
openKeybinding: c = { key: "k", meta: !0 },
|
|
9
|
+
storage: h
|
|
9
10
|
}) {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
e
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (N(r, u)) {
|
|
19
|
-
r.preventDefault(), r.stopPropagation(), i((w) => !w);
|
|
11
|
+
const [e] = t.useState(() => new N(h)), [r, i] = t.useState(!1), [u, S] = t.useState(0);
|
|
12
|
+
t.useEffect(() => e.subscribe(() => {
|
|
13
|
+
S((s) => s + 1);
|
|
14
|
+
}), [e]), t.useEffect(() => {
|
|
15
|
+
const n = (s) => {
|
|
16
|
+
const a = s.target, I = a.closest?.("[data-command-palette]"), x = a.tagName === "INPUT" || a.tagName === "TEXTAREA" || a.tagName === "SELECT" || a.isContentEditable;
|
|
17
|
+
if (R(s, c)) {
|
|
18
|
+
s.preventDefault(), s.stopPropagation(), i((v) => !v);
|
|
20
19
|
return;
|
|
21
20
|
}
|
|
22
|
-
|
|
21
|
+
r || x && !I && !(s.metaKey || s.ctrlKey) || e.handleKeyEvent(s);
|
|
23
22
|
};
|
|
24
|
-
return window.addEventListener("keydown",
|
|
25
|
-
}, [
|
|
26
|
-
const m =
|
|
27
|
-
(
|
|
28
|
-
[]
|
|
29
|
-
),
|
|
30
|
-
(
|
|
31
|
-
[]
|
|
32
|
-
),
|
|
33
|
-
(
|
|
34
|
-
[]
|
|
35
|
-
),
|
|
36
|
-
(
|
|
37
|
-
[]
|
|
38
|
-
),
|
|
39
|
-
() =>
|
|
40
|
-
[]
|
|
41
|
-
),
|
|
42
|
-
() =>
|
|
43
|
-
[]
|
|
44
|
-
),
|
|
45
|
-
(
|
|
46
|
-
[]
|
|
47
|
-
),
|
|
48
|
-
() =>
|
|
49
|
-
[]
|
|
50
|
-
),
|
|
51
|
-
(
|
|
52
|
-
[]
|
|
53
|
-
),
|
|
54
|
-
(
|
|
55
|
-
[]
|
|
56
|
-
),
|
|
57
|
-
(
|
|
58
|
-
[]
|
|
59
|
-
),
|
|
60
|
-
() =>
|
|
61
|
-
[]
|
|
62
|
-
),
|
|
63
|
-
registry:
|
|
64
|
-
open:
|
|
23
|
+
return window.addEventListener("keydown", n, !0), () => window.removeEventListener("keydown", n, !0);
|
|
24
|
+
}, [e, r, c]);
|
|
25
|
+
const m = t.useCallback(
|
|
26
|
+
(n) => e.register(n),
|
|
27
|
+
[e]
|
|
28
|
+
), l = t.useCallback(
|
|
29
|
+
(n) => e.unregister(n),
|
|
30
|
+
[e]
|
|
31
|
+
), d = t.useCallback(
|
|
32
|
+
(n, s) => e.updateKeybinding(n, s),
|
|
33
|
+
[e]
|
|
34
|
+
), C = t.useCallback(
|
|
35
|
+
(n) => e.resetKeybinding(n),
|
|
36
|
+
[e]
|
|
37
|
+
), g = t.useCallback(
|
|
38
|
+
() => e.getPaletteCommands(),
|
|
39
|
+
[e]
|
|
40
|
+
), p = t.useCallback(
|
|
41
|
+
() => e.getSettingsCommands(),
|
|
42
|
+
[e]
|
|
43
|
+
), b = t.useCallback(
|
|
44
|
+
(n) => e.getEffectiveKeybinding(n),
|
|
45
|
+
[e]
|
|
46
|
+
), f = t.useCallback(
|
|
47
|
+
() => e.getRecentCommandIds(),
|
|
48
|
+
[e]
|
|
49
|
+
), y = t.useCallback(
|
|
50
|
+
(n) => e.pushScope(n),
|
|
51
|
+
[e]
|
|
52
|
+
), P = t.useCallback(
|
|
53
|
+
(n) => e.popScope(n),
|
|
54
|
+
[e]
|
|
55
|
+
), k = t.useCallback(
|
|
56
|
+
(n) => e.setActiveInstance(n),
|
|
57
|
+
[e]
|
|
58
|
+
), E = t.useCallback(
|
|
59
|
+
() => e.getActiveInstance(),
|
|
60
|
+
[e]
|
|
61
|
+
), K = t.useMemo(() => ({
|
|
62
|
+
registry: e,
|
|
63
|
+
open: r,
|
|
65
64
|
setOpen: i,
|
|
66
65
|
registerCommand: m,
|
|
67
|
-
unregisterCommand:
|
|
68
|
-
updateKeybinding:
|
|
69
|
-
resetKeybinding:
|
|
70
|
-
getPaletteCommands:
|
|
71
|
-
getSettingsCommands:
|
|
72
|
-
getEffectiveKeybinding:
|
|
73
|
-
getRecentCommandIds:
|
|
74
|
-
pushScope:
|
|
75
|
-
popScope:
|
|
76
|
-
setActiveInstance:
|
|
77
|
-
getActiveInstance:
|
|
78
|
-
version:
|
|
66
|
+
unregisterCommand: l,
|
|
67
|
+
updateKeybinding: d,
|
|
68
|
+
resetKeybinding: C,
|
|
69
|
+
getPaletteCommands: g,
|
|
70
|
+
getSettingsCommands: p,
|
|
71
|
+
getEffectiveKeybinding: b,
|
|
72
|
+
getRecentCommandIds: f,
|
|
73
|
+
pushScope: y,
|
|
74
|
+
popScope: P,
|
|
75
|
+
setActiveInstance: k,
|
|
76
|
+
getActiveInstance: E,
|
|
77
|
+
version: u
|
|
79
78
|
}), [
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
e,
|
|
80
|
+
r,
|
|
81
|
+
u,
|
|
83
82
|
m,
|
|
83
|
+
l,
|
|
84
84
|
d,
|
|
85
85
|
C,
|
|
86
86
|
g,
|
|
@@ -90,14 +90,13 @@ function T({
|
|
|
90
90
|
y,
|
|
91
91
|
P,
|
|
92
92
|
k,
|
|
93
|
-
E
|
|
94
|
-
v
|
|
93
|
+
E
|
|
95
94
|
]);
|
|
96
|
-
return /* @__PURE__ */
|
|
95
|
+
return /* @__PURE__ */ A(w.Provider, { value: K, children: o });
|
|
97
96
|
}
|
|
98
97
|
T.displayName = "CommandPaletteProvider";
|
|
99
98
|
function V() {
|
|
100
|
-
const o =
|
|
99
|
+
const o = t.useContext(w);
|
|
101
100
|
if (!o)
|
|
102
101
|
throw new Error(
|
|
103
102
|
"useCommandPalette must be used within a <CommandPaletteProvider>. Wrap your application root with <CommandPaletteProvider>."
|
|
@@ -12,19 +12,35 @@ import { CommandDefinition, KeyBinding } from './utils';
|
|
|
12
12
|
* CommandPaletteEmpty, CommandPaletteSeparator, CommandPaletteFooter
|
|
13
13
|
*/
|
|
14
14
|
import * as React from 'react';
|
|
15
|
-
|
|
15
|
+
interface CommandPaletteLabels {
|
|
16
|
+
/** Placeholder text for the search input */
|
|
17
|
+
placeholder?: string;
|
|
18
|
+
/** Title shown when no results are found */
|
|
19
|
+
emptyTitle?: string;
|
|
20
|
+
/** Description shown when no results are found */
|
|
21
|
+
emptyDescription?: string;
|
|
22
|
+
/** Group heading for recently used commands */
|
|
23
|
+
recentGroupLabel?: string;
|
|
24
|
+
/** Group heading for searched commands when no category is present */
|
|
25
|
+
defaultGroupLabel?: string;
|
|
26
|
+
/** Label for the navigation hint in the footer */
|
|
27
|
+
navigateLabel?: string;
|
|
28
|
+
/** Label for the execution hint in the footer */
|
|
29
|
+
runLabel?: string;
|
|
30
|
+
/** Label for the close hint in the footer */
|
|
31
|
+
closeLabel?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface CommandPaletteProps extends CommandPaletteLabels {
|
|
16
34
|
className?: string;
|
|
17
35
|
children?: React.ReactNode;
|
|
18
36
|
/** Custom list of commands (overrides automatic registry commands) */
|
|
19
37
|
commands?: CommandDefinition[];
|
|
20
|
-
/** Placeholder text for the search input */
|
|
21
|
-
placeholder?: string;
|
|
22
38
|
/** Called when a command is executed */
|
|
23
39
|
onCommandExecute?: (command: CommandDefinition) => void;
|
|
24
40
|
/** Called when the palette opens/closes */
|
|
25
41
|
onOpenChange?: (open: boolean) => void;
|
|
26
42
|
}
|
|
27
|
-
declare function CommandPalette({ className, children, commands: externalCommands, placeholder, onCommandExecute, onOpenChange, }: CommandPaletteProps): import("react/jsx-runtime").JSX.Element;
|
|
43
|
+
declare function CommandPalette({ className, children, commands: externalCommands, placeholder, emptyTitle, emptyDescription, recentGroupLabel, defaultGroupLabel, navigateLabel, runLabel, closeLabel, onCommandExecute, onOpenChange, }: CommandPaletteProps): import("react/jsx-runtime").JSX.Element;
|
|
28
44
|
declare namespace CommandPalette {
|
|
29
45
|
var displayName: string;
|
|
30
46
|
}
|