@g4rcez/components 0.2.6 → 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 +7717 -7528
- 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/polymorph.d.ts +1 -1
- package/dist/src/components/core/polymorph.d.ts.map +1 -1
- package/dist/src/components/core/tag.d.ts +16 -16
- package/dist/src/components/core/tag.d.ts.map +1 -1
- 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/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 +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"}
|
|
@@ -6,23 +6,23 @@ 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
8
|
declare const variants: {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
size: {
|
|
10
|
+
icon: string;
|
|
11
|
+
big: string;
|
|
12
|
+
default: string;
|
|
13
|
+
small: string;
|
|
14
14
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
26
|
};
|
|
27
27
|
};
|
|
28
28
|
export type TagProps<T extends React.ElementType = "span"> = PolymorphicProps<CvaVariants<typeof variants> & Partial<{
|
|
@@ -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,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;;;;;;;;;;;;;;;;;;;
|
|
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"}
|
|
@@ -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
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { type ElementProps } from "@floating-ui/react";
|
|
1
2
|
import { HTMLMotionProps } from "motion/react";
|
|
2
|
-
import React
|
|
3
|
+
import React from "react";
|
|
3
4
|
import { Label, Override } from "../../types";
|
|
4
5
|
type DialogType = "dialog" | "drawer" | "sheet";
|
|
5
6
|
type DrawerPosition = "left" | "right";
|
|
@@ -11,20 +12,76 @@ export type ModalProps = Override<HTMLMotionProps<"div">, ({
|
|
|
11
12
|
title?: Label;
|
|
12
13
|
}) & {
|
|
13
14
|
open: boolean;
|
|
15
|
+
onChange: (nextState: boolean) => void;
|
|
16
|
+
} & Partial<{
|
|
17
|
+
interactions?: ElementProps[];
|
|
18
|
+
role?: "dialog" | "listbox";
|
|
19
|
+
footer?: Label;
|
|
20
|
+
asChild?: boolean;
|
|
21
|
+
layoutId?: string;
|
|
22
|
+
resizer?: boolean;
|
|
23
|
+
type?: DialogType;
|
|
24
|
+
className?: string;
|
|
25
|
+
bodyClassName?: string;
|
|
26
|
+
closable?: boolean;
|
|
27
|
+
forceType?: boolean;
|
|
28
|
+
overlayClassName?: string;
|
|
29
|
+
position?: DrawerPosition;
|
|
30
|
+
overlayClickClose?: boolean;
|
|
31
|
+
trigger?: Label | React.FC<any>;
|
|
32
|
+
}>>;
|
|
33
|
+
type ModalRef = {
|
|
34
|
+
context: any;
|
|
35
|
+
floating: HTMLElement | null;
|
|
36
|
+
};
|
|
37
|
+
export declare const Modal: React.ForwardRefExoticComponent<(Omit<Omit<HTMLMotionProps<"div">, "footer" | "title" | "type" | "className" | "role" | "onChange" | "layoutId" | "open" | "position" | "resizer" | "asChild" | "closable" | "interactions" | "bodyClassName" | "forceType" | "overlayClassName" | "overlayClickClose" | "trigger" | "ariaTitle"> & {
|
|
38
|
+
title: Label;
|
|
39
|
+
ariaTitle?: string;
|
|
40
|
+
} & {
|
|
41
|
+
open: boolean;
|
|
42
|
+
onChange: (nextState: boolean) => void;
|
|
43
|
+
} & Partial<{
|
|
44
|
+
interactions?: ElementProps[];
|
|
45
|
+
role?: "dialog" | "listbox";
|
|
14
46
|
footer?: Label;
|
|
15
47
|
asChild?: boolean;
|
|
16
48
|
layoutId?: string;
|
|
17
49
|
resizer?: boolean;
|
|
18
50
|
type?: DialogType;
|
|
19
51
|
className?: string;
|
|
52
|
+
bodyClassName?: string;
|
|
20
53
|
closable?: boolean;
|
|
21
54
|
forceType?: boolean;
|
|
22
55
|
overlayClassName?: string;
|
|
23
56
|
position?: DrawerPosition;
|
|
24
57
|
overlayClickClose?: boolean;
|
|
25
58
|
trigger?: Label | React.FC<any>;
|
|
59
|
+
}> & {
|
|
60
|
+
children?: React.ReactNode | undefined;
|
|
61
|
+
}, "ref"> | Omit<Omit<HTMLMotionProps<"div">, "footer" | "title" | "type" | "className" | "role" | "onChange" | "layoutId" | "open" | "position" | "resizer" | "asChild" | "closable" | "interactions" | "bodyClassName" | "forceType" | "overlayClassName" | "overlayClickClose" | "trigger" | "ariaTitle"> & {
|
|
62
|
+
ariaTitle: string;
|
|
63
|
+
title?: Label;
|
|
64
|
+
} & {
|
|
65
|
+
open: boolean;
|
|
26
66
|
onChange: (nextState: boolean) => void;
|
|
27
|
-
}
|
|
28
|
-
|
|
67
|
+
} & Partial<{
|
|
68
|
+
interactions?: ElementProps[];
|
|
69
|
+
role?: "dialog" | "listbox";
|
|
70
|
+
footer?: Label;
|
|
71
|
+
asChild?: boolean;
|
|
72
|
+
layoutId?: string;
|
|
73
|
+
resizer?: boolean;
|
|
74
|
+
type?: DialogType;
|
|
75
|
+
className?: string;
|
|
76
|
+
bodyClassName?: string;
|
|
77
|
+
closable?: boolean;
|
|
78
|
+
forceType?: boolean;
|
|
79
|
+
overlayClassName?: string;
|
|
80
|
+
position?: DrawerPosition;
|
|
81
|
+
overlayClickClose?: boolean;
|
|
82
|
+
trigger?: Label | React.FC<any>;
|
|
83
|
+
}> & {
|
|
84
|
+
children?: React.ReactNode | undefined;
|
|
85
|
+
}, "ref">) & React.RefAttributes<ModalRef>>;
|
|
29
86
|
export {};
|
|
30
87
|
//# sourceMappingURL=modal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../../../src/components/floating/modal.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../../../src/components/floating/modal.tsx"],"names":[],"mappings":"AACA,OAAO,EACH,KAAK,YAAY,EASpB,MAAM,oBAAoB,CAAC;AAI5B,OAAO,EAAmB,eAAe,EAAqE,MAAM,cAAc,CAAC;AACnI,OAAO,KAA4F,MAAM,OAAO,CAAC;AAIjH,OAAO,EAAE,KAAK,EAAO,QAAQ,EAAE,MAAM,aAAa,CAAC;AA2DnD,KAAK,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEhD,KAAK,cAAc,GAAG,MAAM,GAAG,OAAO,CAAC;AAEvC,MAAM,MAAM,UAAU,GAAG,QAAQ,CAC7B,eAAe,CAAC,KAAK,CAAC,EACtB,CAAC;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC,GAAG;IAC5E,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CAC1C,GAAG,OAAO,CAAC;IACJ,YAAY,CAAC,EAAE,YAAY,EAAE,CAAC;IAC9B,IAAI,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC5B,MAAM,CAAC,EAAE,KAAK,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,OAAO,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;CACnC,CAAC,CACT,CAAC;AA2EF,KAAK,QAAQ,GAAG;IAAE,OAAO,EAAE,GAAG,CAAC;IAAC,QAAQ,EAAE,WAAW,GAAG,IAAI,CAAA;CAAE,CAAC;AAI/D,eAAO,MAAM,KAAK;WAnGJ,KAAK;gBAAc,MAAM;;UACzB,OAAO;cACH,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI;;mBAEnB,YAAY,EAAE;WACtB,QAAQ,GAAG,SAAS;aAClB,KAAK;cACJ,OAAO;eACN,MAAM;cACP,OAAO;WACV,UAAU;gBACL,MAAM;oBACF,MAAM;eACX,OAAO;gBACN,OAAO;uBACA,MAAM;eACd,cAAc;wBACL,OAAO;cACjB,KAAK,GAAG,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC;;;;eAlBc,MAAM;YAAU,KAAK;;UAChE,OAAO;cACH,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI;;mBAEnB,YAAY,EAAE;WACtB,QAAQ,GAAG,SAAS;aAClB,KAAK;cACJ,OAAO;eACN,MAAM;cACP,OAAO;WACV,UAAU;gBACL,MAAM;oBACF,MAAM;eACX,OAAO;gBACN,OAAO;uBACA,MAAM;eACd,cAAc;wBACL,OAAO;cACjB,KAAK,GAAG,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC;;;2CAoO1C,CAAC"}
|
|
@@ -5,7 +5,7 @@ import { Slot } from "@radix-ui/react-slot";
|
|
|
5
5
|
import { cva } from "class-variance-authority";
|
|
6
6
|
import { XIcon } from "lucide-react";
|
|
7
7
|
import { AnimatePresence, motion, useMotionValue } from "motion/react";
|
|
8
|
-
import { Fragment, useId } from "react";
|
|
8
|
+
import { forwardRef, Fragment, useId, useImperativeHandle } from "react";
|
|
9
9
|
import { useMediaQuery } from "../../hooks/use-media-query";
|
|
10
10
|
import { useRemoveScroll } from "../../hooks/use-remove-scroll";
|
|
11
11
|
import { css, mergeRefs } from "../../lib/dom";
|
|
@@ -85,7 +85,8 @@ const fetchPosition = (isDesktop, forceType, propsType, propsPosition) => {
|
|
|
85
85
|
return propsType === "drawer" ? (propsPosition ?? positions.drawer) : positions[type];
|
|
86
86
|
return forceType ? positions[type] : positions.sheet;
|
|
87
87
|
};
|
|
88
|
-
|
|
88
|
+
const noop = [];
|
|
89
|
+
export const Modal = forwardRef(({ interactions: outInteractions = noop, open, title, footer, asChild, trigger, children, layoutId, role: roleName = "dialog", onChange, className, bodyClassName, resizer = true, closable = true, forceType = false, overlayClassName = "", type: _type = "dialog", position: propsPosition, overlayClickClose = false, ariaTitle, ...props }, externalRef) => {
|
|
89
90
|
const removeScrollRef = useRemoveScroll(open, "overflow-hidden");
|
|
90
91
|
const headingId = useId();
|
|
91
92
|
const descriptionId = useId();
|
|
@@ -95,18 +96,25 @@ export const Modal = ({ open, title, footer, asChild, trigger, children, layoutI
|
|
|
95
96
|
const func = isDesktop ? animations[_type] : forceType ? animations[_type] : animations.sheet;
|
|
96
97
|
const animation = typeof func === "function" ? func(position) : func;
|
|
97
98
|
const type = isDesktop ? _type : forceType ? _type : "sheet";
|
|
98
|
-
const
|
|
99
|
-
const click = useClick(context);
|
|
100
|
-
const role = useRole(context, { role:
|
|
101
|
-
const dismiss = useDismiss(context, {
|
|
102
|
-
|
|
99
|
+
const floating = useFloating({ open: open, onOpenChange: onChange, transform: true, strategy: "absolute" });
|
|
100
|
+
const click = useClick(floating.context);
|
|
101
|
+
const role = useRole(floating.context, { role: roleName });
|
|
102
|
+
const dismiss = useDismiss(floating.context, {
|
|
103
|
+
escapeKey: true,
|
|
104
|
+
referencePress: true,
|
|
105
|
+
outsidePress: overlayClickClose,
|
|
106
|
+
});
|
|
107
|
+
const interactions = useInteractions([click, role, dismiss].concat(outInteractions));
|
|
103
108
|
const Trigger = trigger;
|
|
104
109
|
const floatingSize = useMotionValue(undefined);
|
|
105
110
|
const onClose = () => onChange(false);
|
|
106
|
-
|
|
111
|
+
useImperativeHandle(externalRef, () => {
|
|
112
|
+
return { context: floating.context, floating: removeScrollRef.current };
|
|
113
|
+
}, [floating]);
|
|
114
|
+
return (_jsxs(Fragment, { children: [trigger ? (_jsx(Fragment, { children: asChild ? (_jsx(Slot, { ref: floating.refs.setReference, ...interactions.getReferenceProps({ layoutId: layoutId }), children: Trigger })) : (_jsx(motion.button, { ref: floating.refs.setReference, ...interactions.getReferenceProps(), layoutId: layoutId, type: "button", children: Trigger })) })) : null, _jsx(FloatingPortal, { children: _jsx(AnimatePresence, { mode: "wait", presenceAffectsLayout: true, children: open ? (_jsx(FloatingOverlay, { lockScroll: false, className: css(`inset-0 isolate z-overlay h-[100dvh] !overflow-clip bg-floating-overlay/70 ${type === "drawer" ? "" : "flex items-start justify-center p-10"}`, overlayClassName), children: _jsx(FloatingFocusManager, { visuallyHiddenDismiss: true, modal: true, closeOnFocusOut: true, context: floating.context, children: _jsxs(motion.div, { ...props, exit: "exit", animate: "enter", "aria-modal": open, initial: "initial", layoutId: layoutId, variants: animation, "data-component": "modal", ref: mergeRefs(floating.refs.setFloating, removeScrollRef), className: css(variants({ position, type }), className, "overscroll-contain"), style: type === "drawer" ? { width: floatingSize } : { height: floatingSize }, ...(title
|
|
107
115
|
? {
|
|
108
116
|
"aria-labelledby": headingId,
|
|
109
117
|
"aria-describedby": descriptionId,
|
|
110
118
|
}
|
|
111
|
-
: { "aria-label": ariaTitle }), ...getFloatingProps(), children: [title ? (_jsx("header", { className: "relative w-full", children: title ? (_jsx("h2", { id: headingId, className: "border-b border-floating-border px-8 pb-2 text-3xl font-medium leading-relaxed", children: title })) : null })) : null, _jsx("section", { className: "flex-1 overflow-y-auto px-8 py-1", children: children }), footer ? _jsx("footer", { className: "w-full border-t border-floating-border px-8 pt-4", children: footer }) : null, closable ? (_jsx("nav", { className: "absolute right-4 top-1 z-floating", children: _jsx("button", { type: "button", onClick: onClose, className: "p-1 opacity-70 transition-colors hover:text-danger hover:opacity-100 focus:text-danger", children: _jsx(XIcon, {}) }) })) : null, useResizer && resizer ? (_jsx(Draggable, { onChange: onChange, parent: refs.floating, position: position, sheet: type === "sheet", value: floatingSize })) : null] }) }) })) : null }) })] }));
|
|
112
|
-
};
|
|
119
|
+
: { "aria-label": ariaTitle }), ...interactions.getFloatingProps(), children: [title ? (_jsx("header", { className: "relative w-full", children: title ? (_jsx("h2", { id: headingId, className: "border-b border-floating-border px-8 pb-2 text-3xl font-medium leading-relaxed", children: title })) : null })) : null, _jsx("section", { className: css("flex-1 overflow-y-auto px-8 py-1", bodyClassName), children: children }), footer ? _jsx("footer", { className: "w-full border-t border-floating-border px-8 pt-4", children: footer }) : null, closable ? (_jsx("nav", { className: "absolute right-4 top-1 z-floating", children: _jsx("button", { type: "button", onClick: onClose, className: "p-1 opacity-70 transition-colors hover:text-danger hover:opacity-100 focus:text-danger", children: _jsx(XIcon, {}) }) })) : null, useResizer && resizer ? (_jsx(Draggable, { onChange: onChange, parent: floating.refs.floating, position: position, sheet: type === "sheet", value: floatingSize })) : null] }) }) })) : null }) })] }));
|
|
120
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autocomplete.d.ts","sourceRoot":"","sources":["../../../../src/components/form/autocomplete.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"autocomplete.d.ts","sourceRoot":"","sources":["../../../../src/components/form/autocomplete.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAoF,MAAM,OAAO,CAAC;AAQzG,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAc,eAAe,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAG5C,MAAM,MAAM,qBAAqB,GAAG,WAAW,GAAG;IAAE,MAAM,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAAC,CAAA;CAAE,CAAC;AAErF,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,GAAG;IACtE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,KAAK,CAAC;IACrB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,OAAO,EAAE,qBAAqB,EAAE,CAAC;CACpC,CAAC;AAiCF,eAAO,MAAM,YAAY,yGAkWxB,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { autoUpdate, FloatingFocusManager, FloatingPortal, offset, size, useDismiss, useFloating, useInteractions, useListNavigation, useRole, useTransitionStyles, } from "@floating-ui/react";
|
|
4
|
-
import Fuzzy from "fuzzy-search";
|
|
5
4
|
import { ChevronDown } from "lucide-react";
|
|
6
5
|
import { AnimatePresence, motion } from "motion/react";
|
|
7
6
|
import { forwardRef, Fragment, useEffect, useRef, useState } from "react";
|
|
@@ -13,6 +12,7 @@ import { useTranslations } from "../../hooks/use-translations";
|
|
|
13
12
|
import { css, dispatchInput, getRemainingSize, initializeInputDataset, mergeRefs } from "../../lib/dom";
|
|
14
13
|
import { safeRegex } from "../../lib/fns";
|
|
15
14
|
import { InputField } from "./input-field";
|
|
15
|
+
import { fzf } from "../../lib/fzf";
|
|
16
16
|
const Frag = (props) => _jsx(Fragment, { children: props.children });
|
|
17
17
|
const transitionStyles = {
|
|
18
18
|
duration: 300,
|
|
@@ -20,7 +20,6 @@ const transitionStyles = {
|
|
|
20
20
|
open: { transform: "scaleY(1)", opacity: 1 },
|
|
21
21
|
close: { transform: "scaleY(0)", opacity: 0 },
|
|
22
22
|
};
|
|
23
|
-
const fuzzyOptions = { caseSensitive: false, sort: false };
|
|
24
23
|
const emptyRef = [];
|
|
25
24
|
const List = forwardRef(function VirtualList(props, ref) {
|
|
26
25
|
return (_jsx(motion.ul, { ...props, ref: ref, className: "w-full overscroll-contain rounded-lg border-b border-tooltip-border last:border-transparent", children: _jsx(AnimatePresence, { children: props.children }) }));
|
|
@@ -43,6 +42,7 @@ export const Autocomplete = forwardRef(({ left, error, right, loading, options,
|
|
|
43
42
|
const [label, setLabel] = useState(() => options.find((x) => x.value === defaults)?.label ?? defaults);
|
|
44
43
|
const [index, setIndex] = useState(null);
|
|
45
44
|
const listRef = useRef(emptyRef);
|
|
45
|
+
const removeScrollRef = useRemoveScroll(open, "block-only");
|
|
46
46
|
const innerOptions = dynamicOption && shadow !== ""
|
|
47
47
|
? [
|
|
48
48
|
{
|
|
@@ -53,8 +53,12 @@ export const Autocomplete = forwardRef(({ left, error, right, loading, options,
|
|
|
53
53
|
...options,
|
|
54
54
|
]
|
|
55
55
|
: options;
|
|
56
|
-
const list =
|
|
57
|
-
|
|
56
|
+
const list = shadow
|
|
57
|
+
? fzf(innerOptions, "value", [
|
|
58
|
+
{ key: "value", value: shadow },
|
|
59
|
+
{ key: "label", value: shadow },
|
|
60
|
+
])
|
|
61
|
+
: innerOptions;
|
|
58
62
|
const setClosed = () => {
|
|
59
63
|
setOpen(false);
|
|
60
64
|
setH(0);
|
|
@@ -66,8 +70,8 @@ export const Autocomplete = forwardRef(({ left, error, right, loading, options,
|
|
|
66
70
|
const { x, y, strategy, refs, context } = useFloating({
|
|
67
71
|
open,
|
|
68
72
|
transform: true,
|
|
69
|
-
placement: "bottom-start",
|
|
70
73
|
onOpenChange: setOpen,
|
|
74
|
+
placement: "bottom-start",
|
|
71
75
|
whileElementsMounted: autoUpdate,
|
|
72
76
|
middleware: [
|
|
73
77
|
offset(4),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multi-select.d.ts","sourceRoot":"","sources":["../../../../src/components/form/multi-select.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"multi-select.d.ts","sourceRoot":"","sources":["../../../../src/components/form/multi-select.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAA6F,MAAM,OAAO,CAAC;AASlH,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAG9C,OAAO,EAAc,eAAe,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,MAAM,MAAM,oBAAoB,GAAG,WAAW,GAAG;IAAE,MAAM,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAAC,CAAA;CAAE,CAAC;AAEpF,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CACnC,eAAe,CAAC,OAAO,CAAC,EACxB;IACI,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,YAAY,CAAC,EAAE,KAAK,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,OAAO,EAAE,oBAAoB,EAAE,CAAC;IAChC,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;CACjD,CACJ,CAAC;AA4DF,eAAO,MAAM,WAAW,wGA4ZvB,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { autoUpdate, FloatingFocusManager, FloatingPortal, offset, size, useDismiss, useFloating, useInteractions, useListNavigation, useRole, useTransitionStyles, } from "@floating-ui/react";
|
|
4
|
-
import Fuzzy from "fuzzy-search";
|
|
5
4
|
import { ChevronDown, XIcon } from "lucide-react";
|
|
6
5
|
import { AnimatePresence, motion } from "motion/react";
|
|
7
6
|
import React, { forwardRef, Fragment, useEffect, useMemo, useRef, useState } from "react";
|
|
@@ -12,6 +11,7 @@ import { useTranslations } from "../../hooks/use-translations";
|
|
|
12
11
|
import { Dict } from "../../lib/dict";
|
|
13
12
|
import { css, getRemainingSize, initializeInputDataset } from "../../lib/dom";
|
|
14
13
|
import { noop } from "../../lib/fns";
|
|
14
|
+
import { fzf } from "../../lib/fzf";
|
|
15
15
|
import { Tag } from "../core/tag";
|
|
16
16
|
import { Checkbox } from "./checkbox";
|
|
17
17
|
import { InputField } from "./input-field";
|
|
@@ -85,7 +85,12 @@ export const MultiSelect = forwardRef(({ left, error, right, options, container,
|
|
|
85
85
|
...options,
|
|
86
86
|
]
|
|
87
87
|
: options;
|
|
88
|
-
const list =
|
|
88
|
+
const list = shadow.length === 0
|
|
89
|
+
? innerOptions
|
|
90
|
+
: fzf(innerOptions, "value", [
|
|
91
|
+
{ key: "value", value: shadow },
|
|
92
|
+
{ key: "label", value: shadow },
|
|
93
|
+
]);
|
|
89
94
|
const removeScrollRef = useRemoveScroll(open, "block-only");
|
|
90
95
|
const displayList = list.filter((x) => x.hidden !== true);
|
|
91
96
|
const isEmpty = displayList.length === 0;
|
|
@@ -10,6 +10,7 @@ export * from "./display/notifications";
|
|
|
10
10
|
export * from "./display/stats";
|
|
11
11
|
export * from "./display/tabs";
|
|
12
12
|
export * from "./display/timeline";
|
|
13
|
+
export * from "./floating/command-palette";
|
|
13
14
|
export * from "./floating/dropdown";
|
|
14
15
|
export * from "./floating/expand";
|
|
15
16
|
export * from "./floating/menu";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,KAAK,OAAO,EAAE,mBAAmB,EAAE,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC7H,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,KAAK,OAAO,EAAE,mBAAmB,EAAE,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC7H,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC"}
|