@g4rcez/components 0.2.6 → 0.3.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/dist/index.css +1 -1
- package/dist/index.js +61 -46
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8676 -8415
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +61 -46
- package/dist/index.umd.js.map +1 -1
- package/dist/preset/preset.tailwind.d.ts +1 -1
- package/dist/preset/preset.tailwind.d.ts.map +1 -1
- package/dist/preset/preset.tailwind.js +1 -1
- package/dist/preset/src/styles/common.d.ts +1 -1
- package/dist/preset/src/styles/common.js +1 -1
- package/dist/preset/src/styles/dark.js +1 -1
- package/dist/preset/src/styles/light.js +1 -1
- package/dist/preset.tailwind.d.ts +1 -1
- package/dist/preset.tailwind.d.ts.map +1 -1
- package/dist/preset.tailwind.js +1 -1
- package/dist/src/components/core/polymorph.d.ts +1 -1
- package/dist/src/components/core/polymorph.d.ts.map +1 -1
- package/dist/src/components/core/tag.d.ts +20 -21
- package/dist/src/components/core/tag.d.ts.map +1 -1
- package/dist/src/components/core/tag.js +20 -18
- package/dist/src/components/display/shortcut.d.ts +4 -0
- package/dist/src/components/display/shortcut.d.ts.map +1 -0
- package/dist/src/components/display/shortcut.js +19 -0
- package/dist/src/components/floating/command-palette.d.ts +48 -0
- package/dist/src/components/floating/command-palette.d.ts.map +1 -0
- package/dist/src/components/floating/command-palette.js +157 -0
- package/dist/src/components/floating/menu.d.ts.map +1 -1
- package/dist/src/components/floating/menu.js +12 -15
- package/dist/src/components/floating/modal.d.ts +60 -3
- package/dist/src/components/floating/modal.d.ts.map +1 -1
- package/dist/src/components/floating/modal.js +18 -10
- package/dist/src/components/form/autocomplete.d.ts.map +1 -1
- package/dist/src/components/form/autocomplete.js +9 -5
- package/dist/src/components/form/multi-select.d.ts.map +1 -1
- package/dist/src/components/form/multi-select.js +7 -2
- package/dist/src/components/index.d.ts +1 -0
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +1 -0
- package/dist/src/components/table/index.d.ts.map +1 -1
- package/dist/src/components/table/index.js +1 -1
- package/dist/src/config/context.d.ts.map +1 -1
- package/dist/src/config/default-translations.d.ts +38 -36
- package/dist/src/config/default-translations.d.ts.map +1 -1
- package/dist/src/config/default-translations.js +37 -35
- package/dist/src/constants.d.ts +1 -1
- package/dist/src/constants.js +1 -1
- package/dist/src/hooks/use-remove-scroll.js +5 -4
- package/dist/src/hooks/use-translations.d.ts +38 -36
- package/dist/src/hooks/use-translations.d.ts.map +1 -1
- package/dist/src/lib/combi-keys.d.ts +15 -0
- package/dist/src/lib/combi-keys.d.ts.map +1 -0
- package/dist/src/lib/combi-keys.js +60 -0
- package/dist/src/lib/dict.d.ts +1 -0
- package/dist/src/lib/dict.d.ts.map +1 -1
- package/dist/src/lib/dict.js +3 -0
- package/dist/src/lib/fns.d.ts.map +1 -1
- package/dist/src/lib/fzf.d.ts +16 -0
- package/dist/src/lib/fzf.d.ts.map +1 -0
- package/dist/src/lib/fzf.js +117 -0
- package/dist/src/styles/common.d.ts +1 -1
- package/dist/src/styles/common.js +1 -1
- package/dist/src/styles/dark.js +1 -1
- package/dist/src/styles/light.js +1 -1
- package/dist/src/types.d.ts +5 -0
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +118 -120
|
@@ -2,6 +2,6 @@ import { Config } from "tailwindcss";
|
|
|
2
2
|
import { createDesignTokens, parsers } from "./src/styles/design-tokens";
|
|
3
3
|
import { defaultLightTheme as theme } from "./src/styles/theme";
|
|
4
4
|
declare const config: Partial<Config>;
|
|
5
|
-
export { createDesignTokens, parsers, theme };
|
|
5
|
+
export { createDesignTokens, parsers, theme, config };
|
|
6
6
|
export default config;
|
|
7
7
|
//# sourceMappingURL=preset.tailwind.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preset.tailwind.d.ts","sourceRoot":"","sources":["../../preset.tailwind.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,iBAAiB,IAAI,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAMhE,QAAA,MAAM,MAAM,EAAE,OAAO,CAAC,MAAM,CA2C3B,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"preset.tailwind.d.ts","sourceRoot":"","sources":["../../preset.tailwind.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,iBAAiB,IAAI,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAMhE,QAAA,MAAM,MAAM,EAAE,OAAO,CAAC,MAAM,CA2C3B,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AAEtD,eAAe,MAAM,CAAC"}
|
|
@@ -10,7 +10,7 @@ export var DARK_THEME = {
|
|
|
10
10
|
colors: {
|
|
11
11
|
foreground: "hsla(210, 50%, 98%)",
|
|
12
12
|
background: "hsla(0, 0%, 9%)",
|
|
13
|
-
muted: "hsla(
|
|
13
|
+
muted: "hsla(210, 10%, 40%)",
|
|
14
14
|
disabled: "hsla(240, 4%, 33%)",
|
|
15
15
|
emphasis: {
|
|
16
16
|
foreground: "hsla(251, 91%, 95%)",
|
|
@@ -26,7 +26,7 @@ export var LIGHT_THEME = {
|
|
|
26
26
|
},
|
|
27
27
|
secondary: {
|
|
28
28
|
background: "hsla(210, 25%, 35%)",
|
|
29
|
-
DEFAULT: "hsla(210, 25%,
|
|
29
|
+
DEFAULT: "hsla(210, 25%, 45%)",
|
|
30
30
|
subtle: "hsla(207, 29%, 39%)",
|
|
31
31
|
hover: "hsla(210, 21%, 67%)",
|
|
32
32
|
foreground: "hsla(210, 40%, 98%)",
|
|
@@ -2,6 +2,6 @@ import { Config } from "tailwindcss";
|
|
|
2
2
|
import { createDesignTokens, parsers } from "./src/styles/design-tokens";
|
|
3
3
|
import { defaultLightTheme as theme } from "./src/styles/theme";
|
|
4
4
|
declare const config: Partial<Config>;
|
|
5
|
-
export { createDesignTokens, parsers, theme };
|
|
5
|
+
export { createDesignTokens, parsers, theme, config };
|
|
6
6
|
export default config;
|
|
7
7
|
//# sourceMappingURL=preset.tailwind.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preset.tailwind.d.ts","sourceRoot":"","sources":["../preset.tailwind.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,iBAAiB,IAAI,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAMhE,QAAA,MAAM,MAAM,EAAE,OAAO,CAAC,MAAM,CA2C3B,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"preset.tailwind.d.ts","sourceRoot":"","sources":["../preset.tailwind.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,iBAAiB,IAAI,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAMhE,QAAA,MAAM,MAAM,EAAE,OAAO,CAAC,MAAM,CA2C3B,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AAEtD,eAAe,MAAM,CAAC"}
|
package/dist/preset.tailwind.js
CHANGED
|
@@ -3,7 +3,7 @@ import { Merge, Override } from "../../types";
|
|
|
3
3
|
type TransformProps<E extends React.ElementType = React.ElementType> = Merge<{
|
|
4
4
|
as?: E;
|
|
5
5
|
} & React.ComponentPropsWithRef<E>>;
|
|
6
|
-
export type PolymorphicProps<P extends object, E extends React.ElementType> = Override<TransformProps<E>, P
|
|
6
|
+
export type PolymorphicProps<P extends object, E extends React.ElementType> = Merge<Override<TransformProps<E>, P>>;
|
|
7
7
|
export declare const Polymorph: <E extends React.ElementType = React.ElementType>(props: TransformProps<E>) => React.ReactNode;
|
|
8
8
|
export {};
|
|
9
9
|
//# sourceMappingURL=polymorph.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"polymorph.d.ts","sourceRoot":"","sources":["../../../../src/components/core/polymorph.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE9C,KAAK,cAAc,CAAC,CAAC,SAAS,KAAK,CAAC,WAAW,GAAG,KAAK,CAAC,WAAW,IAAI,KAAK,
|
|
1
|
+
{"version":3,"file":"polymorph.d.ts","sourceRoot":"","sources":["../../../../src/components/core/polymorph.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE9C,KAAK,cAAc,CAAC,CAAC,SAAS,KAAK,CAAC,WAAW,GAAG,KAAK,CAAC,WAAW,IAAI,KAAK,CACxE;IACI,EAAE,CAAC,EAAE,CAAC,CAAC;CACV,GAAG,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAC,CACrC,CAAC;AAEF,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,KAAK,CAAC,WAAW,IAAI,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAIpH,eAAO,MAAM,SAAS,EAAE,CAAC,CAAC,SAAS,KAAK,CAAC,WAAW,GAAG,KAAK,CAAC,WAAW,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,SAKrG,CAAC"}
|
|
@@ -1,34 +1,33 @@
|
|
|
1
|
-
import { type VariantProps } from "class-variance-authority";
|
|
2
1
|
import React from "react";
|
|
3
2
|
import { CvaVariants, Label } from "../../types";
|
|
4
3
|
import { PolymorphicProps } from "./polymorph";
|
|
5
|
-
declare const indicatorVariant: (props?: ({
|
|
6
|
-
theme?: "info" | "warn" | "muted" | "danger" | "primary" | "success" | "secondary" | null | undefined;
|
|
7
|
-
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
8
4
|
declare const variants: {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
size: {
|
|
6
|
+
icon: string;
|
|
7
|
+
big: string;
|
|
8
|
+
default: string;
|
|
9
|
+
small: string;
|
|
14
10
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
11
|
+
theme: {
|
|
12
|
+
custom: string;
|
|
13
|
+
info: string;
|
|
14
|
+
warn: string;
|
|
15
|
+
muted: string;
|
|
16
|
+
danger: string;
|
|
17
|
+
disabled: string;
|
|
18
|
+
primary: string;
|
|
19
|
+
success: string;
|
|
20
|
+
neutral: string;
|
|
21
|
+
secondary: string;
|
|
22
|
+
loading: string;
|
|
26
23
|
};
|
|
27
24
|
};
|
|
25
|
+
type Variants = CvaVariants<typeof variants>;
|
|
26
|
+
type Themes = NonNullable<Variants["theme"]>;
|
|
28
27
|
export type TagProps<T extends React.ElementType = "span"> = PolymorphicProps<CvaVariants<typeof variants> & Partial<{
|
|
29
28
|
icon: Label;
|
|
30
29
|
loading: boolean;
|
|
31
|
-
indicator:
|
|
30
|
+
indicator: Themes;
|
|
32
31
|
}>, T>;
|
|
33
32
|
export declare const Tag: <T extends React.ElementType = "span">(props: TagProps<T>) => any;
|
|
34
33
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tag.d.ts","sourceRoot":"","sources":["../../../../src/components/core/tag.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tag.d.ts","sourceRoot":"","sources":["../../../../src/components/core/tag.tsx"],"names":[],"mappings":"AACA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAa,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE1D,QAAA,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;CAoBb,CAAC;AAEF,KAAK,QAAQ,GAAG,WAAW,CAAC,OAAO,QAAQ,CAAC,CAAC;AAE7C,KAAK,MAAM,GAAG,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;AAsB7C,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,KAAK,CAAC,WAAW,GAAG,MAAM,IAAI,gBAAgB,CACzE,WAAW,CAAC,OAAO,QAAQ,CAAC,GAAG,OAAO,CAAC;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,EAC5F,CAAC,CACJ,CAAC;AAEF,eAAO,MAAM,GAAG,EAAE,CAAC,CAAC,SAAS,KAAK,CAAC,WAAW,GAAG,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,GAkB9E,CAAC"}
|
|
@@ -3,19 +3,6 @@ import { cva } from "class-variance-authority";
|
|
|
3
3
|
import { forwardRef } from "react";
|
|
4
4
|
import { css } from "../../lib/dom";
|
|
5
5
|
import { Polymorph } from "./polymorph";
|
|
6
|
-
const indicatorVariant = cva("size-2.5 aspect-square rounded-full border-0", {
|
|
7
|
-
variants: {
|
|
8
|
-
theme: {
|
|
9
|
-
info: "bg-info",
|
|
10
|
-
warn: "bg-warn",
|
|
11
|
-
muted: "bg-muted",
|
|
12
|
-
primary: "bg-primary",
|
|
13
|
-
danger: "bg-danger",
|
|
14
|
-
success: "bg-success",
|
|
15
|
-
secondary: "bg-secondary",
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
6
|
const variants = {
|
|
20
7
|
size: {
|
|
21
8
|
icon: "p-1",
|
|
@@ -24,18 +11,33 @@ const variants = {
|
|
|
24
11
|
small: "h-6 p-2 px-3 text-sm",
|
|
25
12
|
},
|
|
26
13
|
theme: {
|
|
27
|
-
|
|
28
|
-
danger: "bg-tag-danger-bg text-tag-danger-text",
|
|
14
|
+
custom: "",
|
|
29
15
|
info: "bg-tag-info-bg text-tag-info-text",
|
|
30
|
-
success: "bg-tag-success-bg text-tag-success-text",
|
|
31
|
-
secondary: "bg-tag-secondary-bg text-tag-secondary-text",
|
|
32
16
|
warn: "bg-tag-warn-bg text-tag-warn-text",
|
|
33
17
|
muted: "bg-tag-muted-bg text-tag-muted-text",
|
|
34
|
-
|
|
18
|
+
danger: "bg-tag-danger-bg text-tag-danger-text",
|
|
35
19
|
disabled: "bg-disabled duration-700 opacity-70",
|
|
20
|
+
primary: "bg-tag-primary-bg text-tag-primary-text",
|
|
21
|
+
success: "bg-tag-success-bg text-tag-success-text",
|
|
22
|
+
neutral: "bg-transparent border border-card-border",
|
|
23
|
+
secondary: "bg-tag-secondary-bg text-tag-secondary-text",
|
|
36
24
|
loading: "animate-pulse bg-disabled duration-700 opacity-70",
|
|
37
25
|
},
|
|
38
26
|
};
|
|
27
|
+
const indicatorVariant = cva("size-2.5 aspect-square rounded-full border-0", {
|
|
28
|
+
variants: {
|
|
29
|
+
theme: {
|
|
30
|
+
info: "bg-info",
|
|
31
|
+
warn: "bg-warn",
|
|
32
|
+
muted: "bg-muted",
|
|
33
|
+
danger: "bg-danger",
|
|
34
|
+
neutral: "bg-muted",
|
|
35
|
+
primary: "bg-primary",
|
|
36
|
+
success: "bg-success",
|
|
37
|
+
secondary: "bg-secondary",
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
});
|
|
39
41
|
const tagVariants = cva("inline-flex rounded-pill gap-1.5 border-2 border-transparent items-center justify-center align-middle whitespace-nowrap", {
|
|
40
42
|
variants,
|
|
41
43
|
defaultVariants: { theme: "primary", size: "default" },
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shortcut.d.ts","sourceRoot":"","sources":["../../../../src/components/display/shortcut.tsx"],"names":[],"mappings":"AAWA,eAAO,MAAM,QAAQ,GAAI,OAAO;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,4CAehD,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { CommandIcon, OptionIcon } from "lucide-react";
|
|
3
|
+
import { Fragment } from "react";
|
|
4
|
+
import { isMac } from "../../lib/combi-keys";
|
|
5
|
+
const remap = (x) => {
|
|
6
|
+
x = x.trim();
|
|
7
|
+
if (x === "Alt")
|
|
8
|
+
return isMac() ? _jsx(OptionIcon, { "aria-label": "Option", size: 14 }) : "Alt";
|
|
9
|
+
if (x === "Mod")
|
|
10
|
+
return isMac() ? _jsx(CommandIcon, { "aria-label": "Command", size: 14 }) : "Ctrl";
|
|
11
|
+
return x;
|
|
12
|
+
};
|
|
13
|
+
export const Shortcut = (props) => {
|
|
14
|
+
const p = props.value.trim().split("+");
|
|
15
|
+
return (_jsx("span", { className: "flex items-center gap-1", children: p.map((x, i) => {
|
|
16
|
+
const isLast = p.length - 1 === i;
|
|
17
|
+
return (_jsxs(Fragment, { children: [_jsx("kbd", { "aria-label": x, children: remap(x) }), isLast ? null : _jsx("span", { children: "+" })] }, `${props.value}-${x}-key-${i}`));
|
|
18
|
+
}) }));
|
|
19
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { LucideProps } from "lucide-react";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { Label } from "../../types";
|
|
4
|
+
type ViewProps = {
|
|
5
|
+
text: string;
|
|
6
|
+
};
|
|
7
|
+
type CommandItem<T extends string, P extends object> = {
|
|
8
|
+
type: T;
|
|
9
|
+
hint?: string | string[];
|
|
10
|
+
Icon?: React.ReactElement;
|
|
11
|
+
enabled?: ((props: ViewProps) => boolean) | boolean;
|
|
12
|
+
} & P;
|
|
13
|
+
type View = string | ((props: ViewProps) => string);
|
|
14
|
+
type CommandShortcutItem = CommandItem<"shortcut", {
|
|
15
|
+
title: View;
|
|
16
|
+
shortcut?: string;
|
|
17
|
+
action: (args: {
|
|
18
|
+
text: string;
|
|
19
|
+
setOpen: (state: boolean) => void;
|
|
20
|
+
event: KeyboardEvent | React.MouseEvent | React.KeyboardEvent;
|
|
21
|
+
}) => void | Promise<void>;
|
|
22
|
+
}>;
|
|
23
|
+
type CommandGroupItem = CommandItem<"group", {
|
|
24
|
+
title: View;
|
|
25
|
+
items: CommandItemTypes[];
|
|
26
|
+
}>;
|
|
27
|
+
export type CommandItemTypes = CommandGroupItem | CommandShortcutItem;
|
|
28
|
+
export type CommandPaletteProps = {
|
|
29
|
+
bind?: string;
|
|
30
|
+
open: boolean;
|
|
31
|
+
loading?: boolean;
|
|
32
|
+
emptyMessage?: Label;
|
|
33
|
+
footer?: React.ReactElement;
|
|
34
|
+
commands: CommandItemTypes[];
|
|
35
|
+
onChangeText?: (text: string) => void;
|
|
36
|
+
onChangeVisibility: (next: boolean) => void;
|
|
37
|
+
Preview?: React.FC<{
|
|
38
|
+
command: CommandItemTypes;
|
|
39
|
+
text: string;
|
|
40
|
+
}>;
|
|
41
|
+
Icon?: React.FC<LucideProps & {
|
|
42
|
+
text: string;
|
|
43
|
+
Default: React.FC<LucideProps>;
|
|
44
|
+
}>;
|
|
45
|
+
};
|
|
46
|
+
export declare const CommandPalette: (props: CommandPaletteProps) => import("react/jsx-runtime").JSX.Element;
|
|
47
|
+
export {};
|
|
48
|
+
//# sourceMappingURL=command-palette.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-palette.d.ts","sourceRoot":"","sources":["../../../../src/components/floating/command-palette.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAc,WAAW,EAAE,MAAM,cAAc,CAAC;AAEvD,OAAO,KAAmE,MAAM,OAAO,CAAC;AAQxF,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAKpC,KAAK,SAAS,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAElC,KAAK,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,IAAI;IACnD,IAAI,EAAE,CAAC,CAAC;IACR,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACzB,IAAI,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC;IAC1B,OAAO,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,SAAS,KAAK,OAAO,CAAC,GAAG,OAAO,CAAC;CACvD,GAAG,CAAC,CAAC;AAEN,KAAK,IAAI,GAAG,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,SAAS,KAAK,MAAM,CAAC,CAAC;AAEpD,KAAK,mBAAmB,GAAG,WAAW,CAClC,UAAU,EACV;IACI,KAAK,EAAE,IAAI,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,CAAC,IAAI,EAAE;QACX,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;QAClC,KAAK,EAAE,aAAa,GAAG,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC,aAAa,CAAC;KACjE,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B,CACJ,CAAC;AAEF,KAAK,gBAAgB,GAAG,WAAW,CAAC,OAAO,EAAE;IAAE,KAAK,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,gBAAgB,EAAE,CAAA;CAAE,CAAC,CAAC;AAEzF,MAAM,MAAM,gBAAgB,GAAG,gBAAgB,GAAG,mBAAmB,CAAC;AAiDtE,MAAM,MAAM,mBAAmB,GAAG;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,KAAK,CAAC;IACrB,MAAM,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC;IAC5B,QAAQ,EAAE,gBAAgB,EAAE,CAAC;IAC7B,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,kBAAkB,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAC5C,OAAO,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC;QAAE,OAAO,EAAE,gBAAgB,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAChE,IAAI,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAAC,CAAA;KAAE,CAAC,CAAC;CACnF,CAAC;AAsBF,eAAO,MAAM,cAAc,GAAI,OAAO,mBAAmB,4CAoMxD,CAAC"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createElement as _createElement } from "react";
|
|
3
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { autoUpdate, useFloating, useInteractions, useListNavigation } from "@floating-ui/react";
|
|
5
|
+
import { FilterIcon } from "lucide-react";
|
|
6
|
+
import { AnimatePresence, motion } from "motion/react";
|
|
7
|
+
import { forwardRef, Fragment, useEffect, useId, useRef, useState } from "react";
|
|
8
|
+
import { Is } from "sidekicker";
|
|
9
|
+
import { useStableRef } from "../../hooks/use-stable-ref";
|
|
10
|
+
import { useTranslations } from "../../hooks/use-translations";
|
|
11
|
+
import { CombiKeys } from "../../lib/combi-keys";
|
|
12
|
+
import { Dict } from "../../lib/dict";
|
|
13
|
+
import { css, isReactFC } from "../../lib/dom";
|
|
14
|
+
import { fzf } from "../../lib/fzf";
|
|
15
|
+
import { Shortcut } from "../display/shortcut";
|
|
16
|
+
import { SkeletonCell } from "../display/skeleton";
|
|
17
|
+
import { Modal } from "./modal";
|
|
18
|
+
const Group = (props) => (_jsx("span", { className: "flex h-full items-center text-left text-sm font-medium text-secondary", children: isReactFC(props.item.title) ? _jsx(props.item.title, { text: props.text }) : props.item.title }));
|
|
19
|
+
const Item = forwardRef((props, ref) => {
|
|
20
|
+
const id = useId();
|
|
21
|
+
const active = props.active;
|
|
22
|
+
const item = props.item;
|
|
23
|
+
if (item.type === "group")
|
|
24
|
+
return (_jsx(motion.div, { id: id, className: "h-10 px-2 pb-1 pt-2", children: _jsx(Group, { text: props.text, item: item }) }));
|
|
25
|
+
if (item.type !== "shortcut")
|
|
26
|
+
return _jsx(Fragment, {});
|
|
27
|
+
return (_jsxs(motion.button, { ...props, id: id, ref: ref, role: "option", type: "button", "aria-selected": active, "data-component": "command-palette-item", className: css("flex h-10 items-center justify-between rounded-lg p-2 hover:bg-floating-hover hover:text-floating-foreground", active ? "bg-floating-hover text-primary-foreground" : ""), children: [_jsxs("span", { className: "flex items-center gap-2", children: [item.Icon ? item.Icon : null, _jsx("span", { children: isReactFC(item.title) ? _jsx(item.title, { text: props.text }) : item.title })] }), item.shortcut ? _jsx(Shortcut, { value: item.shortcut }) : null] }));
|
|
28
|
+
});
|
|
29
|
+
const getFuzzyData = (commands, value) => {
|
|
30
|
+
if (value.length === 0)
|
|
31
|
+
return commands;
|
|
32
|
+
const rules = [
|
|
33
|
+
{ key: "title", value },
|
|
34
|
+
{ key: "shortcut", value },
|
|
35
|
+
{ key: "hint", value },
|
|
36
|
+
];
|
|
37
|
+
const normalize = commands.map((x) => ({ ...x, title: Is.function(x.title) ? x.title({ text: value }) : x.title }));
|
|
38
|
+
const target = normalize.reduce((acc, x) => {
|
|
39
|
+
const enabled = Is.function(x.enabled) ? x.enabled({ text: value }) : (x.enabled ?? true);
|
|
40
|
+
if (enabled)
|
|
41
|
+
acc.push({ ...x, enabled: enabled });
|
|
42
|
+
return acc;
|
|
43
|
+
}, []);
|
|
44
|
+
const filter = fzf(target, "title", rules);
|
|
45
|
+
const withEnabled = normalize.filter((x) => (Is.function(x.enabled) ? x.enabled({ text: value }) : false));
|
|
46
|
+
return Dict.unique(filter.concat(withEnabled), (x) => x.title);
|
|
47
|
+
};
|
|
48
|
+
const loadingSkeleton = [0, 0, 0, 0, 0];
|
|
49
|
+
export const CommandPalette = (props) => {
|
|
50
|
+
const bindKey = props.bind ?? "Mod + k";
|
|
51
|
+
const listRef = useRef([]);
|
|
52
|
+
const translations = useTranslations();
|
|
53
|
+
const [value, setValue] = useState("");
|
|
54
|
+
const valueRef = useStableRef(value);
|
|
55
|
+
const id = useId();
|
|
56
|
+
const ref = useRef(null);
|
|
57
|
+
const [activeIndex, setActiveIndex] = useState(null);
|
|
58
|
+
const floating = useFloating({
|
|
59
|
+
open: props.open,
|
|
60
|
+
strategy: "absolute",
|
|
61
|
+
onOpenChange: props.onChangeVisibility,
|
|
62
|
+
whileElementsMounted: autoUpdate,
|
|
63
|
+
});
|
|
64
|
+
const listNav = useListNavigation(floating.context, {
|
|
65
|
+
listRef,
|
|
66
|
+
loop: true,
|
|
67
|
+
activeIndex,
|
|
68
|
+
virtual: true,
|
|
69
|
+
allowEscape: true,
|
|
70
|
+
scrollItemIntoView: true,
|
|
71
|
+
onNavigate: (n) => setActiveIndex((prev) => {
|
|
72
|
+
if (Is.number(n))
|
|
73
|
+
return n;
|
|
74
|
+
return props.open ? (prev ?? 0) : null;
|
|
75
|
+
}),
|
|
76
|
+
});
|
|
77
|
+
const { getItemProps } = useInteractions([listNav]);
|
|
78
|
+
const commands = props.commands.flatMap((x) => (x.type === "group" ? [x, ...x.items] : [x]));
|
|
79
|
+
const fuzzy = getFuzzyData(commands, value);
|
|
80
|
+
const displayItems = value === ""
|
|
81
|
+
? commands
|
|
82
|
+
: [
|
|
83
|
+
{
|
|
84
|
+
type: "group",
|
|
85
|
+
title: "Results",
|
|
86
|
+
items: [],
|
|
87
|
+
},
|
|
88
|
+
...fuzzy.filter((x) => x.type !== "group"),
|
|
89
|
+
];
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
const combi = new CombiKeys();
|
|
92
|
+
combi.add(bindKey, () => props.onChangeVisibility?.(true));
|
|
93
|
+
commands.forEach((cmd) => {
|
|
94
|
+
if (cmd.type === "group")
|
|
95
|
+
return;
|
|
96
|
+
if (cmd.type === "shortcut" && cmd.shortcut !== undefined)
|
|
97
|
+
combi.add(cmd.shortcut, (event) => cmd.action({
|
|
98
|
+
event,
|
|
99
|
+
text: valueRef.current,
|
|
100
|
+
setOpen: props.onChangeVisibility,
|
|
101
|
+
}));
|
|
102
|
+
});
|
|
103
|
+
return combi.register();
|
|
104
|
+
}, [bindKey]);
|
|
105
|
+
const Icon = props.Icon ?? FilterIcon;
|
|
106
|
+
return (_jsx(Fragment, { children: _jsxs(Modal, { ref: ref, closable: false, open: props.open, overlayClickClose: true, interactions: [listNav], onChange: props.onChangeVisibility, ariaTitle: "Command palette", bodyClassName: "px-0 py-0 pt-2", "data-component": "command-palette", className: "container relative py-0 md:max-w-screen-sm lg:max-w-screen-md", children: [_jsxs("header", { className: "sticky top-0 isolate z-floating flex h-12 w-full items-center border-b border-floating-border bg-floating-background px-4", children: [_jsx("div", { className: "flex size-10 items-center justify-center", children: _jsx(Icon, { Default: FilterIcon, text: value, size: 16 }) }), _jsx("input", { autoFocus: true, value: value, "data-combikeysbypass": "true", placeholder: "Search for...", onChange: (e) => setValue(e.target.value), className: "h-12 w-full items-center bg-transparent px-2 py-2 pb-2 text-left text-lg outline-none", onKeyDown: (e) => {
|
|
107
|
+
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
108
|
+
if (activeIndex !== null)
|
|
109
|
+
listRef.current[activeIndex]?.scrollIntoView({
|
|
110
|
+
block: "start",
|
|
111
|
+
inline: "start",
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
if (e.key === "Enter") {
|
|
115
|
+
if (activeIndex !== null && displayItems[activeIndex]) {
|
|
116
|
+
e.preventDefault();
|
|
117
|
+
const x = displayItems[activeIndex];
|
|
118
|
+
const text = e.currentTarget.value;
|
|
119
|
+
if (x.type === "shortcut")
|
|
120
|
+
return x.action({
|
|
121
|
+
event: e,
|
|
122
|
+
setOpen: props.onChangeVisibility,
|
|
123
|
+
text,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
if (displayItems.length === 1) {
|
|
127
|
+
e.preventDefault();
|
|
128
|
+
const x = displayItems[0];
|
|
129
|
+
const text = e.currentTarget.value;
|
|
130
|
+
if (x.type === "shortcut")
|
|
131
|
+
return x.action({
|
|
132
|
+
event: e,
|
|
133
|
+
setOpen: props.onChangeVisibility,
|
|
134
|
+
text,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
} })] }), _jsx(AnimatePresence, { children: props.loading ? (_jsxs(motion.ul, { role: "listbox", "data-component": "command-palette-list", animate: { transform: "scaleY(1)", opacity: 1 }, initial: { transform: "scaleY(0)", opacity: 0.3 }, className: "my-2 flex max-h-96 w-full origin-[top_center] flex-col gap-1 overflow-y-auto px-2", children: [_jsx(motion.div, { className: "h-10 px-2 pb-1 pt-2", children: translations.commandPaletteLoading }), loadingSkeleton.map((x, i) => {
|
|
139
|
+
return (_jsx(motion.li, { className: css("flex h-10 items-center justify-between rounded-lg p-2 hover:bg-primary hover:text-primary-foreground"), children: SkeletonCell }, `${id}-${i}-skeleton-index`));
|
|
140
|
+
})] })) : (_jsxs(motion.div, { className: "flex min-w-full flex-row flex-nowrap", "data-component": "command-palette-container", children: [_jsxs(motion.ul, { role: "listbox", "data-component": "command-palette-list", animate: { transform: "scaleY(1)", opacity: 1 }, initial: { transform: "scaleY(0)", opacity: 0.3 }, className: "my-2 flex h-fit max-h-96 w-full origin-[top_center] flex-col gap-1 overflow-y-auto px-2", children: [displayItems.map((item, index) => (_createElement(Item, { ...getItemProps({
|
|
141
|
+
onMouseEnter: () => setActiveIndex(index),
|
|
142
|
+
ref(node) {
|
|
143
|
+
listRef.current[index] = node;
|
|
144
|
+
},
|
|
145
|
+
onClick(e) {
|
|
146
|
+
e.preventDefault();
|
|
147
|
+
props.onChangeVisibility(false);
|
|
148
|
+
floating.refs.domReference.current?.focus();
|
|
149
|
+
if (item.type === "shortcut")
|
|
150
|
+
item.action({
|
|
151
|
+
event: e,
|
|
152
|
+
setOpen: props.onChangeVisibility,
|
|
153
|
+
text: value,
|
|
154
|
+
});
|
|
155
|
+
},
|
|
156
|
+
}), item: item, text: value, active: activeIndex === index, key: `${id}-${item.type}-${index}` }))), displayItems.length === 1 ? (_jsx(motion.div, { className: css("flex items-center justify-between rounded-lg p-2 text-secondary"), children: translations.commandPaletteEmpty ?? props.emptyMessage })) : null] }), props.Preview && Is.number(activeIndex) ? _jsx(props.Preview, { command: displayItems[activeIndex], text: value }) : null] })) }), props.footer ? _jsx("footer", { className: "flex h-8 items-center rounded-b-lg bg-background p-2", children: props.footer }) : null] }) }));
|
|
157
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menu.d.ts","sourceRoot":"","sources":["../../../../src/components/floating/menu.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"menu.d.ts","sourceRoot":"","sources":["../../../../src/components/floating/menu.tsx"],"names":[],"mappings":"AA0BA,OAAO,EAAoB,WAAW,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,KAA2E,MAAM,OAAO,CAAC;AA6BhG,MAAM,MAAM,SAAS,GAAG,OAAO,CAC3B;IACI,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,EAAE,KAAK,CAAC,WAAW,CAAC;CACxC,GAAG,CAAC;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CACzE,CAAC;AAmKF,KAAK,aAAa,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAAC,CAAA;CAAE,CAAC;AAE1F,eAAO,MAAM,QAAQ,oKAmCpB,CAAC;AAEF,eAAO,MAAM,IAAI;WAnNF,OAAO;WACP,OAAO;YACN,OAAO;aACN,OAAO;cACN,OAAO;cACP,KAAK,CAAC,SAAS;uBACN,MAAM;uBACN,KAAK,CAAC,WAAW;;WAC1B,MAAM;;WART,OAAO;WACP,OAAO;YACN,OAAO;aACN,OAAO;cACN,OAAO;cACP,KAAK,CAAC,SAAS;uBACN,MAAM;uBACN,KAAK,CAAC,WAAW;;WACN,KAAK,CAAC,YAAY;WAAS,MAAM;qDAoNrE,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { autoUpdate, flip, FloatingFocusManager, FloatingList, FloatingNode, FloatingPortal, FloatingTree, offset, safePolygon, shift, useClick, useDismiss, useFloating, useFloatingNodeId, useFloatingParentNodeId, useFloatingTree, useHover, useInteractions, useListItem, useListNavigation,
|
|
3
|
+
import { autoUpdate, flip, FloatingFocusManager, FloatingList, FloatingNode, FloatingPortal, FloatingTree, offset, safePolygon, shift, useClick, useDismiss, useFloating, useFloatingNodeId, useFloatingParentNodeId, useFloatingTree, useHover, useInteractions, useListItem, useListNavigation, useRole, useTypeahead, } from "@floating-ui/react";
|
|
4
4
|
import { Slot } from "@radix-ui/react-slot";
|
|
5
5
|
import { ChevronRightIcon } from "lucide-react";
|
|
6
6
|
import React, { createContext, Fragment, useContext, useEffect, useRef, useState } from "react";
|
|
7
7
|
import { FLOATING_DELAY, TYPEAHEAD_RESET_DELAY } from "../../constants";
|
|
8
|
-
import { css } from "../../lib/dom";
|
|
8
|
+
import { css, mergeRefs } from "../../lib/dom";
|
|
9
9
|
const menuItemClassName = (highlight = "") => css("w-full min-w-36 outline-none p-2.5 items-center flex justify-between text-left", "hover:bg-primary focus:bg-primary aria-expanded:opacity-80", "focus:text-primary-foreground hover:text-primary-foreground", "first-of-type:rounded-t-lg last-of-type:rounded-b-lg", "disabled:opacity-40 disabled:cursor-not-allowed", highlight);
|
|
10
10
|
const MenuContext = createContext({
|
|
11
11
|
isOpen: false,
|
|
@@ -45,16 +45,17 @@ const MenuComponent = React.forwardRef(({ children, FloatingComponent = "div", h
|
|
|
45
45
|
handleClose: safePolygon({ blockPointerEvents: true }),
|
|
46
46
|
});
|
|
47
47
|
const click = useClick(context, {
|
|
48
|
-
event: "mousedown",
|
|
49
48
|
toggle: !isNested,
|
|
49
|
+
event: "mousedown",
|
|
50
50
|
ignoreMouse: isNested,
|
|
51
51
|
keyboardHandlers: true,
|
|
52
|
+
enabled: props.disabled === false,
|
|
52
53
|
});
|
|
53
54
|
const listNavigation = useListNavigation(context, {
|
|
54
55
|
loop: true,
|
|
55
|
-
listRef: elementsRef,
|
|
56
56
|
activeIndex,
|
|
57
57
|
nested: isNested,
|
|
58
|
+
listRef: elementsRef,
|
|
58
59
|
onNavigate: setActiveIndex,
|
|
59
60
|
});
|
|
60
61
|
const typeahead = useTypeahead(context, {
|
|
@@ -67,14 +68,11 @@ const MenuComponent = React.forwardRef(({ children, FloatingComponent = "div", h
|
|
|
67
68
|
useEffect(() => {
|
|
68
69
|
if (!tree)
|
|
69
70
|
return;
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
function onSubMenuOpen(event) {
|
|
74
|
-
if (event.nodeId !== nodeId && event.parentId === parentId) {
|
|
71
|
+
const handleTreeClick = () => setIsOpen(false);
|
|
72
|
+
const onSubMenuOpen = (event) => {
|
|
73
|
+
if (event.nodeId !== nodeId && event.parentId === parentId)
|
|
75
74
|
setIsOpen(false);
|
|
76
|
-
|
|
77
|
-
}
|
|
75
|
+
};
|
|
78
76
|
tree.events.on("click", handleTreeClick);
|
|
79
77
|
tree.events.on("menuopen", onSubMenuOpen);
|
|
80
78
|
return () => {
|
|
@@ -83,9 +81,8 @@ const MenuComponent = React.forwardRef(({ children, FloatingComponent = "div", h
|
|
|
83
81
|
};
|
|
84
82
|
}, [tree, nodeId, parentId]);
|
|
85
83
|
useEffect(() => {
|
|
86
|
-
if (isOpen && tree)
|
|
84
|
+
if (isOpen && tree)
|
|
87
85
|
tree.events.emit("menuopen", { parentId, nodeId });
|
|
88
|
-
}
|
|
89
86
|
}, [tree, isOpen, nodeId, parentId]);
|
|
90
87
|
const className = isParent ? props.className : css(menuItemClassName(props.className));
|
|
91
88
|
return (_jsxs(FloatingNode, { id: nodeId, children: [_jsx(Fragment, { children: props.asChild ? (_jsx(Slot, { ...getReferenceProps(parent.getItemProps({
|
|
@@ -95,7 +92,7 @@ const MenuComponent = React.forwardRef(({ children, FloatingComponent = "div", h
|
|
|
95
92
|
setHasFocusInside(false);
|
|
96
93
|
parent.setHasFocusInside(true);
|
|
97
94
|
},
|
|
98
|
-
})), children: label,
|
|
95
|
+
})), children: label, className: className, "data-open": isOpen ? "" : undefined, "data-nested": isNested ? "" : undefined, role: isNested ? "menuitem" : undefined, "data-focus-inside": hasFocusInside ? "" : undefined, ref: mergeRefs(refs.setReference, item.ref, forwardedRef), tabIndex: !isNested ? undefined : parent.activeIndex === item.index ? 0 : -1 })) : (_jsxs("button", { type: "button", className: className, "data-open": isOpen ? "" : undefined, "data-nested": isNested ? "" : undefined, role: isNested ? "menuitem" : undefined, "data-focus-inside": hasFocusInside ? "" : undefined, ref: mergeRefs(refs.setReference, item.ref, forwardedRef), tabIndex: !isNested ? undefined : parent.activeIndex === item.index ? 0 : -1, ...getReferenceProps(parent.getItemProps({
|
|
99
96
|
...props,
|
|
100
97
|
onFocus(event) {
|
|
101
98
|
props.onFocus?.(event);
|
|
@@ -109,7 +106,7 @@ export const MenuItem = React.forwardRef(({ title, Right, disabled, children, ..
|
|
|
109
106
|
const item = useListItem({ label: disabled ? null : title });
|
|
110
107
|
const tree = useFloatingTree();
|
|
111
108
|
const isActive = item.index === menu.activeIndex;
|
|
112
|
-
return (_jsxs("button", { ...props, title: title, type: "button", role: "menuitem", disabled: disabled, "data-active": isActive, "data-open": menu.isOpen, tabIndex: isActive ? 0 : -1, ref:
|
|
109
|
+
return (_jsxs("button", { ...props, title: title, type: "button", role: "menuitem", disabled: disabled, "data-active": isActive, "data-open": menu.isOpen, tabIndex: isActive ? 0 : -1, ref: mergeRefs(item.ref, forwardedRef), className: menuItemClassName(`${props.className ?? ""} ${isActive ? "bg-primary text-primary-foreground" : ""}`), ...menu.getItemProps({
|
|
113
110
|
onClick(event) {
|
|
114
111
|
props.onClick?.(event);
|
|
115
112
|
tree?.events.emit("click");
|