@g4rcez/components 0.2.5 → 0.3.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/dist/index.css +1 -1
- package/dist/index.js +51 -46
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7617 -7426
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +51 -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/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/button.d.ts +41 -11
- package/dist/src/components/core/button.d.ts.map +1 -1
- package/dist/src/components/core/button.js +36 -35
- package/dist/src/components/core/polymorph.d.ts +5 -7
- package/dist/src/components/core/polymorph.d.ts.map +1 -1
- package/dist/src/components/core/tag.d.ts +22 -6
- package/dist/src/components/core/tag.d.ts.map +1 -1
- package/dist/src/components/core/tag.js +21 -20
- package/dist/src/components/display/alert.d.ts +15 -7
- package/dist/src/components/display/alert.d.ts.map +1 -1
- package/dist/src/components/display/alert.js +12 -11
- 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 +17 -0
- package/dist/src/components/floating/command-palette.d.ts +36 -0
- package/dist/src/components/floating/command-palette.d.ts.map +1 -0
- package/dist/src/components/floating/command-palette.js +139 -0
- package/dist/src/components/floating/menu.d.ts +2 -2
- 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 +1 -0
- package/dist/src/config/default-translations.d.ts.map +1 -1
- package/dist/src/config/default-translations.js +1 -0
- package/dist/src/hooks/use-remove-scroll.js +5 -4
- package/dist/src/hooks/use-translations.d.ts +1 -0
- package/dist/src/hooks/use-translations.d.ts.map +1 -1
- package/dist/src/lib/combi-keys.d.ts +12 -0
- package/dist/src/lib/combi-keys.d.ts.map +1 -0
- package/dist/src/lib/combi-keys.js +48 -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 +120 -0
- package/dist/src/styles/dark.js +1 -1
- package/dist/src/styles/light.js +1 -1
- package/dist/src/types.d.ts +8 -0
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +126 -130
|
@@ -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
|
@@ -1,16 +1,46 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import { type Label } from "../../types";
|
|
1
|
+
import React, { PropsWithChildren } from "react";
|
|
2
|
+
import { CvaVariants, type Label } from "../../types";
|
|
4
3
|
import { PolymorphicProps } from "./polymorph";
|
|
5
|
-
declare const
|
|
6
|
-
size
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
declare const variants: {
|
|
5
|
+
size: {
|
|
6
|
+
icon: string;
|
|
7
|
+
big: string;
|
|
8
|
+
default: string;
|
|
9
|
+
min: string;
|
|
10
|
+
small: string;
|
|
11
|
+
};
|
|
12
|
+
rounded: {
|
|
13
|
+
rough: string;
|
|
14
|
+
squared: string;
|
|
15
|
+
default: string;
|
|
16
|
+
circle: string;
|
|
17
|
+
};
|
|
18
|
+
theme: {
|
|
19
|
+
raw: string;
|
|
20
|
+
disabled: string;
|
|
21
|
+
loading: string;
|
|
22
|
+
main: string;
|
|
23
|
+
info: string;
|
|
24
|
+
warn: string;
|
|
25
|
+
muted: string;
|
|
26
|
+
danger: string;
|
|
27
|
+
neutral: string;
|
|
28
|
+
primary: string;
|
|
29
|
+
success: string;
|
|
30
|
+
secondary: string;
|
|
31
|
+
"ghost-info": string;
|
|
32
|
+
"ghost-warn": string;
|
|
33
|
+
"ghost-danger": string;
|
|
34
|
+
"ghost-primary": string;
|
|
35
|
+
"ghost-success": string;
|
|
36
|
+
"ghost-secondary": string;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
type Variants = CvaVariants<typeof variants>;
|
|
40
|
+
export type ButtonProps<T extends React.ElementType = "button"> = PropsWithChildren<PolymorphicProps<Variants & Partial<{
|
|
11
41
|
icon: Label;
|
|
12
42
|
loading: boolean;
|
|
13
|
-
}>, T
|
|
14
|
-
export declare const Button: <T extends React.ElementType = "button">(props: ButtonProps<T>) =>
|
|
43
|
+
}>, T>>;
|
|
44
|
+
export declare const Button: <T extends React.ElementType = "button">(props: ButtonProps<T>) => React.ReactNode;
|
|
15
45
|
export {};
|
|
16
46
|
//# sourceMappingURL=button.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../../src/components/core/button.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../../src/components/core/button.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAc,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE7D,OAAO,EAAE,WAAW,EAAE,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAa,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE1D,QAAA,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmCb,CAAC;AAUF,KAAK,QAAQ,GAAG,WAAW,CAAC,OAAO,QAAQ,CAAC,CAAC;AAE7C,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,KAAK,CAAC,WAAW,GAAG,QAAQ,IAAI,iBAAiB,CAC/E,gBAAgB,CAAC,QAAQ,GAAG,OAAO,CAAC;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,EAAE,CAAC,CAAC,CAC7E,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,CAAC,CAAC,SAAS,KAAK,CAAC,WAAW,GAAG,QAAQ,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,SAwB5F,CAAC"}
|
|
@@ -3,42 +3,43 @@ 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
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
circle: "rounded-full aspect-square",
|
|
20
|
-
},
|
|
21
|
-
theme: {
|
|
22
|
-
raw: "",
|
|
23
|
-
disabled: "bg-disabled opacity-70",
|
|
24
|
-
loading: "animate-pulse bg-disabled",
|
|
25
|
-
main: "bg-primary text-primary-foreground",
|
|
26
|
-
info: "bg-button-info-bg text-button-info-text",
|
|
27
|
-
warn: "bg-button-warn-bg text-button-warn-text",
|
|
28
|
-
muted: "bg-button-muted-bg text-button-muted-text",
|
|
29
|
-
danger: "bg-button-danger-bg text-button-danger-text",
|
|
30
|
-
neutral: "bg-transparent border-2 border-card-border",
|
|
31
|
-
primary: "bg-button-primary-bg text-button-primary-text",
|
|
32
|
-
success: "bg-button-success-bg text-button-success-text",
|
|
33
|
-
secondary: "bg-button-secondary-bg text-button-secondary-text",
|
|
34
|
-
"ghost-info": "bg-transparent hover:bg-info/20 border border-info text-info",
|
|
35
|
-
"ghost-warn": "bg-transparent hover:bg-warn/20 border border-warn text-warn",
|
|
36
|
-
"ghost-danger": "bg-transparent hover:bg-danger/20 border border-danger text-danger",
|
|
37
|
-
"ghost-primary": "bg-transparent hover:bg-primary/20 border border-primary text-primary",
|
|
38
|
-
"ghost-success": "bg-transparent hover:bg-success/20 border border-success text-success",
|
|
39
|
-
"ghost-secondary": "bg-transparent hover:bg-secondary/20 border border-secondary text-secondary",
|
|
40
|
-
},
|
|
6
|
+
const variants = {
|
|
7
|
+
size: {
|
|
8
|
+
icon: "p-1",
|
|
9
|
+
big: "h-12 px-6 py-4",
|
|
10
|
+
default: "h-10 px-4 py-2",
|
|
11
|
+
min: "h-7 px-3 py-1 text-sm",
|
|
12
|
+
small: "h-8 px-4 py-2 text-sm",
|
|
13
|
+
},
|
|
14
|
+
rounded: {
|
|
15
|
+
rough: "rounded-sm",
|
|
16
|
+
squared: "rounded-none",
|
|
17
|
+
default: "rounded-button",
|
|
18
|
+
circle: "rounded-full aspect-square",
|
|
41
19
|
},
|
|
20
|
+
theme: {
|
|
21
|
+
raw: "",
|
|
22
|
+
disabled: "bg-disabled opacity-70",
|
|
23
|
+
loading: "animate-pulse bg-disabled",
|
|
24
|
+
main: "bg-primary text-primary-foreground",
|
|
25
|
+
info: "bg-button-info-bg text-button-info-text",
|
|
26
|
+
warn: "bg-button-warn-bg text-button-warn-text",
|
|
27
|
+
muted: "bg-button-muted-bg text-button-muted-text",
|
|
28
|
+
danger: "bg-button-danger-bg text-button-danger-text",
|
|
29
|
+
neutral: "bg-transparent border-2 border-card-border",
|
|
30
|
+
primary: "bg-button-primary-bg text-button-primary-text",
|
|
31
|
+
success: "bg-button-success-bg text-button-success-text",
|
|
32
|
+
secondary: "bg-button-secondary-bg text-button-secondary-text",
|
|
33
|
+
"ghost-info": "bg-transparent hover:bg-info/20 border border-info text-info",
|
|
34
|
+
"ghost-warn": "bg-transparent hover:bg-warn/20 border border-warn text-warn",
|
|
35
|
+
"ghost-danger": "bg-transparent hover:bg-danger/20 border border-danger text-danger",
|
|
36
|
+
"ghost-primary": "bg-transparent hover:bg-primary/20 border border-primary text-primary",
|
|
37
|
+
"ghost-success": "bg-transparent hover:bg-success/20 border border-success text-success",
|
|
38
|
+
"ghost-secondary": "bg-transparent hover:bg-secondary/20 border border-secondary text-secondary",
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
const buttonVariants = cva("relative overflow-hidden inline-flex duration-500 enabled:hover:bg-opacity-70 enabled:focus:bg-opacity-70 data-[loading=true]:opacity-30 data-[loading=true]:animate-pulse gap-1.5 items-center justify-center align-middle cursor-pointer whitespace-nowrap font-medium transition-colors ease-in disabled:cursor-not-allowed disabled:bg-opacity-40 disabled:text-opacity-80 focus-visible:outline-none focus-visible:ring-4 focus-visible:ring-ring", {
|
|
42
|
+
variants,
|
|
42
43
|
defaultVariants: { theme: "main", size: "default", rounded: "default" },
|
|
43
44
|
});
|
|
44
45
|
export const Button = forwardRef(function Button({ className, icon, loading, theme, type = "button", size, rounded, ...props }, ref) {
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import type React from "react";
|
|
2
|
-
import {
|
|
3
|
-
type TransformProps<E extends React.ElementType = React.ElementType> = {
|
|
2
|
+
import { Merge, Override } from "../../types";
|
|
3
|
+
type TransformProps<E extends React.ElementType = React.ElementType> = Merge<{
|
|
4
4
|
as?: E;
|
|
5
|
-
}
|
|
6
|
-
export type PolymorphicProps<P extends
|
|
7
|
-
|
|
8
|
-
declare const defaultElement = "span";
|
|
9
|
-
export declare const Polymorph: <E extends React.ElementType = typeof defaultElement>(props: InnerPolymorphicProps<E>) => React.ReactElement | null;
|
|
5
|
+
} & React.ComponentPropsWithRef<E>>;
|
|
6
|
+
export type PolymorphicProps<P extends object, E extends React.ElementType> = Merge<Override<TransformProps<E>, P>>;
|
|
7
|
+
export declare const Polymorph: <E extends React.ElementType = React.ElementType>(props: TransformProps<E>) => React.ReactNode;
|
|
10
8
|
export {};
|
|
11
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,
|
|
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,15 +1,31 @@
|
|
|
1
1
|
import { type VariantProps } from "class-variance-authority";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { Label } from "../../types";
|
|
3
|
+
import { CvaVariants, Label } from "../../types";
|
|
4
4
|
import { PolymorphicProps } from "./polymorph";
|
|
5
5
|
declare const indicatorVariant: (props?: ({
|
|
6
6
|
theme?: "info" | "warn" | "muted" | "danger" | "primary" | "success" | "secondary" | null | undefined;
|
|
7
7
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
8
|
-
declare const
|
|
9
|
-
size
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
declare const variants: {
|
|
9
|
+
size: {
|
|
10
|
+
icon: string;
|
|
11
|
+
big: string;
|
|
12
|
+
default: string;
|
|
13
|
+
small: string;
|
|
14
|
+
};
|
|
15
|
+
theme: {
|
|
16
|
+
primary: string;
|
|
17
|
+
danger: string;
|
|
18
|
+
info: string;
|
|
19
|
+
success: string;
|
|
20
|
+
secondary: string;
|
|
21
|
+
warn: string;
|
|
22
|
+
muted: string;
|
|
23
|
+
neutral: string;
|
|
24
|
+
disabled: string;
|
|
25
|
+
loading: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export type TagProps<T extends React.ElementType = "span"> = PolymorphicProps<CvaVariants<typeof variants> & Partial<{
|
|
13
29
|
icon: Label;
|
|
14
30
|
loading: boolean;
|
|
15
31
|
indicator: VariantProps<typeof indicatorVariant>["theme"];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tag.d.ts","sourceRoot":"","sources":["../../../../src/components/core/tag.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAqB,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"tag.d.ts","sourceRoot":"","sources":["../../../../src/components/core/tag.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAClE,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,gBAAgB;;mFAYpB,CAAC;AAEH,QAAA,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;CAmBb,CAAC;AAOF,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,KAAK,CAAC,WAAW,GAAG,MAAM,IAAI,gBAAgB,CACzE,WAAW,CAAC,OAAO,QAAQ,CAAC,GACxB,OAAO,CAAC;IACJ,IAAI,EAAE,KAAK,CAAC;IACZ,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,YAAY,CAAC,OAAO,gBAAgB,CAAC,CAAC,OAAO,CAAC,CAAC;CAC7D,CAAC,EACN,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"}
|
|
@@ -16,27 +16,28 @@ const indicatorVariant = cva("size-2.5 aspect-square rounded-full border-0", {
|
|
|
16
16
|
},
|
|
17
17
|
},
|
|
18
18
|
});
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
loading: "animate-pulse bg-disabled duration-700 opacity-70",
|
|
38
|
-
},
|
|
19
|
+
const variants = {
|
|
20
|
+
size: {
|
|
21
|
+
icon: "p-1",
|
|
22
|
+
big: "h-12 px-6 py-4",
|
|
23
|
+
default: "h-8 px-4 py-2",
|
|
24
|
+
small: "h-6 p-2 px-3 text-sm",
|
|
25
|
+
},
|
|
26
|
+
theme: {
|
|
27
|
+
primary: "bg-tag-primary-bg text-tag-primary-text",
|
|
28
|
+
danger: "bg-tag-danger-bg text-tag-danger-text",
|
|
29
|
+
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
|
+
warn: "bg-tag-warn-bg text-tag-warn-text",
|
|
33
|
+
muted: "bg-tag-muted-bg text-tag-muted-text",
|
|
34
|
+
neutral: "bg-transparent border border-card-border",
|
|
35
|
+
disabled: "bg-disabled duration-700 opacity-70",
|
|
36
|
+
loading: "animate-pulse bg-disabled duration-700 opacity-70",
|
|
39
37
|
},
|
|
38
|
+
};
|
|
39
|
+
const tagVariants = cva("inline-flex rounded-pill gap-1.5 border-2 border-transparent items-center justify-center align-middle whitespace-nowrap", {
|
|
40
|
+
variants,
|
|
40
41
|
defaultVariants: { theme: "primary", size: "default" },
|
|
41
42
|
});
|
|
42
43
|
export const Tag = forwardRef(function Tag({ className, indicator = undefined, icon, loading, theme, size, ...props }, ref) {
|
|
@@ -1,18 +1,26 @@
|
|
|
1
|
-
import { type VariantProps } from "class-variance-authority";
|
|
2
1
|
import { HTMLMotionProps } from "motion/react";
|
|
3
2
|
import React, { PropsWithChildren } from "react";
|
|
3
|
+
import { CvaVariants } from "../../types";
|
|
4
4
|
import { PolymorphicProps } from "../core/polymorph";
|
|
5
5
|
type CollapseProps = HTMLMotionProps<"section"> & {
|
|
6
6
|
open: boolean;
|
|
7
7
|
};
|
|
8
8
|
export declare const Collapse: (props: PropsWithChildren<CollapseProps>) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
-
declare const
|
|
10
|
-
theme
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
declare const themeVariants: {
|
|
10
|
+
theme: {
|
|
11
|
+
primary: string;
|
|
12
|
+
danger: string;
|
|
13
|
+
info: string;
|
|
14
|
+
success: string;
|
|
15
|
+
secondary: string;
|
|
16
|
+
warn: string;
|
|
17
|
+
neutral: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export type AlertProps<T extends React.ElementType = "div"> = PolymorphicProps<CvaVariants<typeof themeVariants> & Partial<{
|
|
15
21
|
open?: boolean;
|
|
22
|
+
container: string;
|
|
23
|
+
Icon: React.ReactElement;
|
|
16
24
|
onClose: (nextState: boolean) => void;
|
|
17
25
|
}>, T>;
|
|
18
26
|
export declare const Alert: <T extends React.ElementType = "div">(props: AlertProps<T>) => any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alert.d.ts","sourceRoot":"","sources":["../../../../src/components/display/alert.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"alert.d.ts","sourceRoot":"","sources":["../../../../src/components/display/alert.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAU,MAAM,cAAc,CAAC;AAEvD,OAAO,KAAK,EAAE,EAAc,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE7D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAa,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAahE,KAAK,aAAa,GAAG,eAAe,CAAC,SAAS,CAAC,GAAG;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC;AAEpE,eAAO,MAAM,QAAQ,GAAI,OAAO,iBAAiB,CAAC,aAAa,CAAC,4CAiB/D,CAAC;AAEF,QAAA,MAAM,aAAa;;;;;;;;;;CAUlB,CAAC;AAOF,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,KAAK,CAAC,WAAW,GAAG,KAAK,IAAI,gBAAgB,CAC1E,WAAW,CAAC,OAAO,aAAa,CAAC,GAC7B,OAAO,CAAC;IACJ,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,KAAK,CAAC,YAAY,CAAC;IACzB,OAAO,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CACzC,CAAC,EACN,CAAC,CACJ,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,CAAC,CAAC,SAAS,KAAK,CAAC,WAAW,GAAG,KAAK,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,GA2CxE,CAAC"}
|
|
@@ -16,18 +16,19 @@ const transition = {
|
|
|
16
16
|
ease: [0.04, 0.62, 0.23, 0.98],
|
|
17
17
|
};
|
|
18
18
|
export const Collapse = (props) => (_jsx(motion.div, { ...props, layout: true, layoutRoot: true, layoutScroll: true, initial: false, variants: variants, exit: variants.false, transition: transition, "aria-hidden": !props.open, "data-component": "collapse", animate: props.open.toString(), className: css("aria-hidden:pointer-events-none", props.className), children: props.children }));
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
neutral: "bg-transparent border border-card-border text-alert-primary-text",
|
|
29
|
-
},
|
|
19
|
+
const themeVariants = {
|
|
20
|
+
theme: {
|
|
21
|
+
primary: "bg-alert-primary-bg text-alert-primary-text border-alert-primary-border",
|
|
22
|
+
danger: "bg-alert-danger-bg text-alert-danger-text border-alert-danger-border",
|
|
23
|
+
info: "bg-alert-info-bg text-alert-info-text border-alert-info-border",
|
|
24
|
+
success: "bg-alert-success-bg text-alert-success-text border-alert-success-border",
|
|
25
|
+
secondary: "bg-alert-secondary-bg text-alert-secondary-text border-alert-secondary-border",
|
|
26
|
+
warn: "bg-alert-warn-bg text-alert-warn-text border-alert-warn-border",
|
|
27
|
+
neutral: "bg-transparent border border-card-border text-alert-primary-text",
|
|
30
28
|
},
|
|
29
|
+
};
|
|
30
|
+
const alertVariants = cva("p-4 w-full block border relative rounded-lg text-sm", {
|
|
31
|
+
variants: themeVariants,
|
|
31
32
|
defaultVariants: { theme: "neutral" },
|
|
32
33
|
});
|
|
33
34
|
export const Alert = forwardRef(function Alert({ className, theme, Icon, onClose, open = true, ...props }, ref) {
|
|
@@ -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,17 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { CommandIcon } from "lucide-react";
|
|
3
|
+
import { Fragment } from "react";
|
|
4
|
+
import { isMac } from "../../lib/combi-keys";
|
|
5
|
+
const remap = (x) => {
|
|
6
|
+
if (x === "Mod") {
|
|
7
|
+
return isMac() ? _jsx(CommandIcon, { "aria-label": "Command", size: 14 }) : "Ctrl";
|
|
8
|
+
}
|
|
9
|
+
return x;
|
|
10
|
+
};
|
|
11
|
+
export const Shortcut = (props) => {
|
|
12
|
+
const p = props.value.trim().split("+");
|
|
13
|
+
return (_jsx("span", { className: "flex items-center gap-1", children: p.map((x, i) => {
|
|
14
|
+
const isLast = p.length - 1 === i;
|
|
15
|
+
return (_jsxs(Fragment, { children: [_jsx("kbd", { "aria-label": x, children: remap(x) }), isLast ? null : _jsx("span", { children: "+" })] }, `${props.value}-${x}-key-${i}`));
|
|
16
|
+
}) }));
|
|
17
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Label } from "../../types";
|
|
3
|
+
type ViewProps = {
|
|
4
|
+
text: string;
|
|
5
|
+
};
|
|
6
|
+
type CommandItem<T extends string, P extends object> = {
|
|
7
|
+
type: T;
|
|
8
|
+
hint?: string;
|
|
9
|
+
enabled?: (props: ViewProps) => boolean;
|
|
10
|
+
} & P;
|
|
11
|
+
type View = Label | React.FC<ViewProps>;
|
|
12
|
+
type CommandShortcutItem = CommandItem<"shortcut", {
|
|
13
|
+
title: View;
|
|
14
|
+
shortcut?: string;
|
|
15
|
+
action: (args: {
|
|
16
|
+
text: string;
|
|
17
|
+
setOpen: (state: boolean) => void;
|
|
18
|
+
event: KeyboardEvent | React.MouseEvent | React.KeyboardEvent;
|
|
19
|
+
}) => void;
|
|
20
|
+
}>;
|
|
21
|
+
type CommandGroupItem = CommandItem<"group", {
|
|
22
|
+
title: View;
|
|
23
|
+
items: CommandItemTypes[];
|
|
24
|
+
}>;
|
|
25
|
+
export type CommandItemTypes = CommandGroupItem | CommandShortcutItem;
|
|
26
|
+
export type CommandPaletteProps = {
|
|
27
|
+
open: boolean;
|
|
28
|
+
bind?: string;
|
|
29
|
+
emptyMessage?: Label;
|
|
30
|
+
footer?: React.ReactElement;
|
|
31
|
+
commands: CommandItemTypes[];
|
|
32
|
+
onChange: (next: boolean) => void;
|
|
33
|
+
};
|
|
34
|
+
export declare const CommandPalette: (props: CommandPaletteProps) => import("react/jsx-runtime").JSX.Element;
|
|
35
|
+
export {};
|
|
36
|
+
//# 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":"AAGA,OAAO,KAAmE,MAAM,OAAO,CAAC;AAMxF,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAIpC,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,CAAC;IACd,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,OAAO,CAAC;CAC3C,GAAG,CAAC,CAAC;AAEN,KAAK,IAAI,GAAG,KAAK,GAAG,KAAK,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC;AAExC,KAAK,mBAAmB,GAAG,WAAW,CAClC,UAAU,EACV;IACI,KAAK,EAAE,IAAI,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;QAAC,KAAK,EAAE,aAAa,GAAG,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC,aAAa,CAAA;KAAE,KAAK,IAAI,CAAC;CAC9I,CACJ,CAAC;AAEF,KAAK,gBAAgB,GAAG,WAAW,CAC/B,OAAO,EACP;IACI,KAAK,EAAE,IAAI,CAAC;IACZ,KAAK,EAAE,gBAAgB,EAAE,CAAC;CAC7B,CACJ,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,gBAAgB,GAAG,mBAAmB,CAAC;AAkDtE,MAAM,MAAM,mBAAmB,GAAG;IAC9B,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,KAAK,CAAC;IACrB,MAAM,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC;IAC5B,QAAQ,EAAE,gBAAgB,EAAE,CAAC;IAC7B,QAAQ,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;CACrC,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,OAAO,mBAAmB,4CA0KxD,CAAC"}
|
|
@@ -0,0 +1,139 @@
|
|
|
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, useRole } from "@floating-ui/react";
|
|
5
|
+
import { AnimatePresence, motion } from "motion/react";
|
|
6
|
+
import { forwardRef, Fragment, useEffect, useId, useRef, useState } from "react";
|
|
7
|
+
import { useStableRef } from "../../hooks/use-stable-ref";
|
|
8
|
+
import { useTranslations } from "../../hooks/use-translations";
|
|
9
|
+
import { CombiKeys } from "../../lib/combi-keys";
|
|
10
|
+
import { css, isReactFC } from "../../lib/dom";
|
|
11
|
+
import { fzf } from "../../lib/fzf";
|
|
12
|
+
import { Shortcut } from "../display/shortcut";
|
|
13
|
+
import { Modal } from "./modal";
|
|
14
|
+
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 }));
|
|
15
|
+
const Item = forwardRef((props, ref) => {
|
|
16
|
+
const id = useId();
|
|
17
|
+
const active = props.active;
|
|
18
|
+
const classNameBase = "h-10";
|
|
19
|
+
const item = props.item;
|
|
20
|
+
if (item.type === "group") {
|
|
21
|
+
return (_jsx(motion.div, { id: id, className: "h-10 px-2 pb-1 pt-2", children: _jsx(Group, { text: props.text, item: item }) }));
|
|
22
|
+
}
|
|
23
|
+
if (item.type === "shortcut") {
|
|
24
|
+
return (_jsxs(motion.button, { id: id, ref: ref, role: "option", "aria-selected": active, "data-component": "command-palette-item", onClick: (event) => item.action({ event, setOpen: props.onChange, text: props.text }), className: css(classNameBase, "flex items-center justify-between rounded-lg p-2 hover:bg-primary hover:text-primary-foreground", active ? "bg-primary text-primary-foreground" : ""), children: [_jsx("span", { children: isReactFC(item.title) ? _jsx(item.title, { text: props.text }) : item.title }), item.shortcut ? _jsx(Shortcut, { value: item.shortcut }) : null] }));
|
|
25
|
+
}
|
|
26
|
+
return _jsx(Fragment, {});
|
|
27
|
+
});
|
|
28
|
+
export const CommandPalette = (props) => {
|
|
29
|
+
const translations = useTranslations();
|
|
30
|
+
const [value, setValue] = useState("");
|
|
31
|
+
const valueRef = useStableRef(value);
|
|
32
|
+
const bindKey = props.bind ?? "Mod + k";
|
|
33
|
+
const [combi] = useState(new CombiKeys());
|
|
34
|
+
const id = useId();
|
|
35
|
+
const ref = useRef(null);
|
|
36
|
+
const [activeIndex, setActiveIndex] = useState(null);
|
|
37
|
+
const floating = useFloating({
|
|
38
|
+
open: props.open,
|
|
39
|
+
onOpenChange: props.onChange,
|
|
40
|
+
whileElementsMounted: autoUpdate,
|
|
41
|
+
});
|
|
42
|
+
const listRef = useRef([]);
|
|
43
|
+
const listNav = useListNavigation(floating.context, {
|
|
44
|
+
listRef,
|
|
45
|
+
loop: true,
|
|
46
|
+
activeIndex,
|
|
47
|
+
virtual: true,
|
|
48
|
+
allowEscape: true,
|
|
49
|
+
onNavigate: setActiveIndex,
|
|
50
|
+
scrollItemIntoView: true,
|
|
51
|
+
});
|
|
52
|
+
const role = useRole(floating.context, { role: "listbox" });
|
|
53
|
+
const { getItemProps } = useInteractions([role, listNav]);
|
|
54
|
+
const commands = props.commands.flatMap((x) => x.type !== "group"
|
|
55
|
+
? x.enabled
|
|
56
|
+
? x.enabled({ text: value })
|
|
57
|
+
? [x]
|
|
58
|
+
: []
|
|
59
|
+
: [x]
|
|
60
|
+
: [x, ...x.items].filter((x) => (x.enabled === undefined ? true : x.enabled({ text: value }))));
|
|
61
|
+
const fuzzy = commands.length === 0
|
|
62
|
+
? commands
|
|
63
|
+
: fzf(commands, "title", [
|
|
64
|
+
{ key: "title", value },
|
|
65
|
+
{ key: "shortcut", value },
|
|
66
|
+
{ key: "hint", value },
|
|
67
|
+
...commands.reduce((acc, el) => {
|
|
68
|
+
if (!el.hint)
|
|
69
|
+
return acc;
|
|
70
|
+
return [...acc, { key: "hint", value: el.hint }];
|
|
71
|
+
}, []),
|
|
72
|
+
]);
|
|
73
|
+
const displayItems = value === ""
|
|
74
|
+
? commands
|
|
75
|
+
: [
|
|
76
|
+
{
|
|
77
|
+
type: "group",
|
|
78
|
+
title: "Results",
|
|
79
|
+
items: [],
|
|
80
|
+
},
|
|
81
|
+
...fuzzy.filter((x) => x.type !== "group"),
|
|
82
|
+
];
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
combi.add(bindKey, () => props.onChange?.(true));
|
|
85
|
+
commands.forEach((cmd) => {
|
|
86
|
+
if (cmd.type === "group")
|
|
87
|
+
return;
|
|
88
|
+
if (cmd.type === "shortcut" && cmd.shortcut !== undefined)
|
|
89
|
+
combi.add(cmd.shortcut, (event) => cmd.action({
|
|
90
|
+
event,
|
|
91
|
+
text: valueRef.current,
|
|
92
|
+
setOpen: props.onChange,
|
|
93
|
+
}));
|
|
94
|
+
});
|
|
95
|
+
return combi.register();
|
|
96
|
+
}, [combi, bindKey]);
|
|
97
|
+
return (_jsx(Fragment, { children: _jsxs(Modal, { ref: ref, closable: false, open: props.open, overlayClickClose: true, interactions: [listNav], onChange: props.onChange, ariaTitle: "Command palette", bodyClassName: "px-0 py-0 pt-2", className: "container relative py-0 md:max-w-screen-sm lg:max-w-screen-md", children: [_jsx("header", { className: "h-12 isolate z-floating bg-floating-background w-full sticky top-0 border-b border-floating-border px-4", children: _jsx("input", { autoFocus: true, value: value, "data-combikeysbypass": "true", placeholder: "Search for...", onChange: (e) => setValue(e.target.value), className: "h-12 w-full bg-transparent pb-2 outline-none", onKeyDown: (e) => {
|
|
98
|
+
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
99
|
+
if (activeIndex !== null)
|
|
100
|
+
listRef.current[activeIndex]?.scrollIntoView({
|
|
101
|
+
block: "start",
|
|
102
|
+
inline: "start",
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
if (e.key === "Enter") {
|
|
106
|
+
if (activeIndex !== null && displayItems[activeIndex]) {
|
|
107
|
+
e.preventDefault();
|
|
108
|
+
const x = displayItems[activeIndex];
|
|
109
|
+
const text = e.currentTarget.value;
|
|
110
|
+
if (x.type === "shortcut")
|
|
111
|
+
return x.action({
|
|
112
|
+
event: e,
|
|
113
|
+
setOpen: props.onChange,
|
|
114
|
+
text,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
if (displayItems.length === 1) {
|
|
118
|
+
e.preventDefault();
|
|
119
|
+
const x = displayItems[0];
|
|
120
|
+
const text = e.currentTarget.value;
|
|
121
|
+
if (x.type === "shortcut")
|
|
122
|
+
return x.action({
|
|
123
|
+
event: e,
|
|
124
|
+
setOpen: props.onChange,
|
|
125
|
+
text,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
} }) }), _jsx(motion.ul, { initial: { transform: "scaleY(0)", opacity: 0.3 }, animate: { transform: "scaleY(1)", opacity: 1 }, className: "my-2 flex h-fit max-h-96 origin-[top_center] flex-col gap-1 px-2", children: _jsxs(AnimatePresence, { children: [displayItems.map((item, index) => (_createElement(Item, { ...getItemProps({
|
|
130
|
+
ref(node) {
|
|
131
|
+
listRef.current[index] = node;
|
|
132
|
+
},
|
|
133
|
+
onClick(e) {
|
|
134
|
+
e.preventDefault();
|
|
135
|
+
props.onChange(false);
|
|
136
|
+
floating.refs.domReference.current?.focus();
|
|
137
|
+
},
|
|
138
|
+
}), item: item, text: value, onChange: props.onChange, 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.footer ? _jsx("footer", { className: "flex h-8 items-center rounded-b-lg bg-background p-2", children: props.footer }) : null] }) }));
|
|
139
|
+
};
|