@codefast/ui 0.3.11-canary.1 → 0.3.11
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/CHANGELOG.md +36 -0
- package/README.md +34 -14
- package/dist/components/accordion.d.ts +29 -10
- package/dist/components/accordion.js +38 -37
- package/dist/components/alert-dialog.d.ts +60 -24
- package/dist/components/alert-dialog.js +69 -72
- package/dist/components/alert.d.ts +27 -15
- package/dist/components/alert.js +29 -31
- package/dist/components/aspect-ratio.d.ts +8 -4
- package/dist/components/aspect-ratio.js +7 -5
- package/dist/components/avatar.d.ts +17 -6
- package/dist/components/avatar.js +19 -17
- package/dist/components/badge.d.ts +21 -14
- package/dist/components/badge.js +19 -22
- package/dist/components/breadcrumb.d.ts +35 -12
- package/dist/components/breadcrumb.js +48 -54
- package/dist/components/button-group.d.ts +29 -14
- package/dist/components/button-group.js +27 -32
- package/dist/components/button.d.ts +35 -25
- package/dist/components/button.js +50 -48
- package/dist/components/calendar.d.ts +24 -9
- package/dist/components/calendar.js +92 -98
- package/dist/components/card.d.ts +34 -10
- package/dist/components/card.js +39 -37
- package/dist/components/carousel.d.ts +55 -24
- package/dist/components/carousel.js +113 -130
- package/dist/components/chart.d.ts +72 -36
- package/dist/components/chart.js +154 -166
- package/dist/components/checkbox-cards.d.ts +15 -8
- package/dist/components/checkbox-cards.js +22 -25
- package/dist/components/checkbox-group.d.ts +16 -8
- package/dist/components/checkbox-group.js +19 -19
- package/dist/components/checkbox.d.ts +9 -4
- package/dist/components/checkbox.js +14 -14
- package/dist/components/collapsible.d.ts +14 -6
- package/dist/components/collapsible.js +18 -16
- package/dist/components/command.d.ts +55 -23
- package/dist/components/command.js +70 -85
- package/dist/components/context-menu.d.ts +72 -22
- package/dist/components/context-menu.js +88 -109
- package/dist/components/dialog.d.ts +53 -22
- package/dist/components/dialog.js +71 -85
- package/dist/components/drawer.d.ts +60 -28
- package/dist/components/drawer.js +59 -67
- package/dist/components/dropdown-menu.d.ts +73 -22
- package/dist/components/dropdown-menu.js +95 -112
- package/dist/components/empty.d.ts +37 -15
- package/dist/components/empty.js +43 -45
- package/dist/components/field.d.ts +63 -25
- package/dist/components/field.js +88 -104
- package/dist/components/form.d.ts +37 -15
- package/dist/components/form.js +65 -70
- package/dist/components/hover-card.d.ts +21 -7
- package/dist/components/hover-card.js +24 -24
- package/dist/components/input-group.d.ts +53 -28
- package/dist/components/input-group.js +63 -77
- package/dist/components/input-number.d.ts +28 -7
- package/dist/components/input-number.js +55 -59
- package/dist/components/input-otp.d.ts +24 -10
- package/dist/components/input-otp.js +33 -37
- package/dist/components/input-password.d.ts +12 -5
- package/dist/components/input-password.js +31 -32
- package/dist/components/input-search.d.ts +18 -8
- package/dist/components/input-search.js +43 -41
- package/dist/components/input.d.ts +10 -4
- package/dist/components/input.js +9 -7
- package/dist/components/item.d.ts +69 -32
- package/dist/components/item.js +89 -92
- package/dist/components/kbd.d.ts +13 -5
- package/dist/components/kbd.js +13 -11
- package/dist/components/label.d.ts +9 -4
- package/dist/components/label.js +9 -7
- package/dist/components/menubar.d.ts +80 -23
- package/dist/components/menubar.js +97 -118
- package/dist/components/native-select.d.ts +16 -6
- package/dist/components/native-select.js +25 -26
- package/dist/components/navigation-menu.d.ts +36 -12
- package/dist/components/navigation-menu.js +60 -75
- package/dist/components/pagination.d.ts +35 -14
- package/dist/components/pagination.js +54 -69
- package/dist/components/popover.d.ts +24 -8
- package/dist/components/popover.js +28 -28
- package/dist/components/progress-circle.d.ts +106 -88
- package/dist/components/progress-circle.js +106 -138
- package/dist/components/progress.d.ts +10 -4
- package/dist/components/progress.js +14 -14
- package/dist/components/radio-cards.d.ts +10 -4
- package/dist/components/radio-cards.js +22 -23
- package/dist/components/radio-group.d.ts +13 -5
- package/dist/components/radio-group.js +18 -16
- package/dist/components/radio.d.ts +12 -5
- package/dist/components/radio.js +10 -8
- package/dist/components/resizable.d.ts +18 -7
- package/dist/components/resizable.js +22 -22
- package/dist/components/scroll-area.d.ts +33 -20
- package/dist/components/scroll-area.js +84 -88
- package/dist/components/select.d.ts +50 -16
- package/dist/components/select.js +77 -96
- package/dist/components/separator.d.ts +29 -19
- package/dist/components/separator.js +36 -34
- package/dist/components/sheet.d.ts +62 -29
- package/dist/components/sheet.js +79 -100
- package/dist/components/sidebar.d.ts +160 -66
- package/dist/components/sidebar.js +294 -336
- package/dist/components/skeleton.d.ts +9 -4
- package/dist/components/skeleton.js +8 -6
- package/dist/components/slider.d.ts +13 -4
- package/dist/components/slider.js +34 -40
- package/dist/components/sonner.d.ts +10 -7
- package/dist/components/sonner.js +16 -14
- package/dist/components/spinner.d.ts +12 -5
- package/dist/components/spinner.js +33 -35
- package/dist/components/switch.d.ts +9 -4
- package/dist/components/switch.js +13 -11
- package/dist/components/table.d.ts +37 -11
- package/dist/components/table.js +47 -45
- package/dist/components/tabs.d.ts +21 -7
- package/dist/components/tabs.js +24 -22
- package/dist/components/textarea.d.ts +9 -4
- package/dist/components/textarea.js +8 -6
- package/dist/components/toggle-group.d.ts +24 -9
- package/dist/components/toggle-group.js +41 -42
- package/dist/components/toggle.d.ts +25 -17
- package/dist/components/toggle.js +30 -28
- package/dist/components/tooltip.d.ts +24 -8
- package/dist/components/tooltip.js +29 -32
- package/dist/hooks/use-animated-value.d.ts +4 -1
- package/dist/hooks/use-animated-value.js +57 -36
- package/dist/hooks/use-copy-to-clipboard.d.ts +11 -5
- package/dist/hooks/use-copy-to-clipboard.js +39 -20
- package/dist/hooks/use-is-mobile.d.ts +4 -1
- package/dist/hooks/use-is-mobile.js +21 -1
- package/dist/hooks/use-media-query.d.ts +4 -1
- package/dist/hooks/use-media-query.js +45 -18
- package/dist/hooks/use-mutation-observer.d.ts +6 -2
- package/dist/hooks/use-mutation-observer.js +34 -16
- package/dist/hooks/use-pagination.d.ts +22 -14
- package/dist/hooks/use-pagination.js +100 -49
- package/dist/index.d.ts +69 -130
- package/dist/index.js +11 -11
- package/dist/primitives/checkbox-group.d.ts +105 -83
- package/dist/primitives/checkbox-group.js +111 -84
- package/dist/primitives/input-number.d.ts +51 -40
- package/dist/primitives/input-number.js +483 -350
- package/dist/primitives/input.d.ts +48 -42
- package/dist/primitives/input.js +65 -43
- package/dist/primitives/progress-circle.d.ts +79 -48
- package/dist/primitives/progress-circle.js +154 -105
- package/package.json +6 -7
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
1
|
import { cn } from "@codefast/tailwind-variants";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
//#region src/components/textarea.tsx
|
|
3
4
|
function Textarea({ className, ...props }) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
return /* @__PURE__ */ jsx("textarea", {
|
|
6
|
+
className: cn("flex min-h-16 w-full grow rounded-lg border border-input px-3 py-2 text-base shadow-xs outline-hidden transition placeholder:text-muted-foreground hover:not-disabled:not-focus-visible:border-ring/60 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:opacity-50 aria-invalid:border-destructive focus-within:aria-invalid:ring-destructive/20 hover:not-disabled:not-focus-within:aria-invalid:border-destructive/60 md:text-sm dark:bg-input/30 dark:focus-within:aria-invalid:ring-destructive/40", className),
|
|
7
|
+
"data-slot": "textarea",
|
|
8
|
+
...props
|
|
9
|
+
});
|
|
9
10
|
}
|
|
11
|
+
//#endregion
|
|
10
12
|
export { Textarea };
|
|
@@ -1,15 +1,30 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { ToggleVariants } from "./toggle.js";
|
|
2
|
+
import { ComponentProps, JSX } from "react";
|
|
3
|
+
import { Scope } from "@radix-ui/react-context";
|
|
3
4
|
import * as ToggleGroupPrimitive from "@radix-ui/react-toggle-group";
|
|
4
|
-
|
|
5
|
+
|
|
6
|
+
//#region src/components/toggle-group.d.ts
|
|
5
7
|
type ScopedProps<P> = P & {
|
|
6
|
-
|
|
8
|
+
__scopeToggleGroup?: Scope;
|
|
7
9
|
};
|
|
8
10
|
type ToggleGroupProps = ComponentProps<typeof ToggleGroupPrimitive.Root> & ToggleVariants & {
|
|
9
|
-
|
|
11
|
+
spacing?: number;
|
|
10
12
|
};
|
|
11
|
-
declare function ToggleGroup({
|
|
13
|
+
declare function ToggleGroup({
|
|
14
|
+
__scopeToggleGroup,
|
|
15
|
+
children,
|
|
16
|
+
className,
|
|
17
|
+
size,
|
|
18
|
+
spacing,
|
|
19
|
+
variant,
|
|
20
|
+
...props
|
|
21
|
+
}: ScopedProps<ToggleGroupProps>): JSX.Element;
|
|
12
22
|
type ToggleGroupItemProps = ScopedProps<ComponentProps<typeof ToggleGroupPrimitive.Item>>;
|
|
13
|
-
declare function ToggleGroupItem({
|
|
14
|
-
|
|
15
|
-
|
|
23
|
+
declare function ToggleGroupItem({
|
|
24
|
+
__scopeToggleGroup,
|
|
25
|
+
children,
|
|
26
|
+
className,
|
|
27
|
+
...props
|
|
28
|
+
}: ToggleGroupItemProps): JSX.Element;
|
|
29
|
+
//#endregion
|
|
30
|
+
export { ToggleGroup, ToggleGroupItem, type ToggleGroupItemProps, type ToggleGroupProps };
|
|
@@ -1,54 +1,53 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import { toggleVariants } from "./toggle.js";
|
|
3
3
|
import { cn } from "@codefast/tailwind-variants";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
5
|
import { createContextScope } from "@radix-ui/react-context";
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
6
|
+
import * as ToggleGroupPrimitive from "@radix-ui/react-toggle-group";
|
|
7
|
+
import { createToggleGroupScope } from "@radix-ui/react-toggle-group";
|
|
8
|
+
//#region src/components/toggle-group.tsx
|
|
7
9
|
const TOGGLE_GROUP_NAME = "ToggleGroup";
|
|
8
|
-
const [createToggleGroupContext] = createContextScope(TOGGLE_GROUP_NAME, [
|
|
9
|
-
createToggleGroupScope
|
|
10
|
-
]);
|
|
10
|
+
const [createToggleGroupContext] = createContextScope(TOGGLE_GROUP_NAME, [createToggleGroupScope]);
|
|
11
11
|
const useToggleGroupScope = createToggleGroupScope();
|
|
12
12
|
const [ToggleGroupProvider, useToggleGroupContext] = createToggleGroupContext(TOGGLE_GROUP_NAME);
|
|
13
13
|
function ToggleGroup({ __scopeToggleGroup, children, className, size, spacing = 0, variant, ...props }) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
})
|
|
33
|
-
});
|
|
14
|
+
const toggleGroupScope = useToggleGroupScope(__scopeToggleGroup);
|
|
15
|
+
return /* @__PURE__ */ jsx(ToggleGroupProvider, {
|
|
16
|
+
scope: __scopeToggleGroup,
|
|
17
|
+
size,
|
|
18
|
+
spacing,
|
|
19
|
+
variant,
|
|
20
|
+
children: /* @__PURE__ */ jsx(ToggleGroupPrimitive.Root, {
|
|
21
|
+
className: cn("group/toggle-group flex w-fit items-center gap-[--spacing(var(--gap))] rounded-lg data-[spacing=default]:data-[variant=outline]:shadow-xs", className),
|
|
22
|
+
"data-size": size,
|
|
23
|
+
"data-slot": "toggle-group",
|
|
24
|
+
"data-spacing": spacing,
|
|
25
|
+
"data-variant": variant,
|
|
26
|
+
style: { "--gap": spacing },
|
|
27
|
+
...toggleGroupScope,
|
|
28
|
+
...props,
|
|
29
|
+
children
|
|
30
|
+
})
|
|
31
|
+
});
|
|
34
32
|
}
|
|
35
33
|
const TOGGLE_GROUP_ITEM_NAME = "ToggleGroupItem";
|
|
36
34
|
function ToggleGroupItem({ __scopeToggleGroup, children, className, ...props }) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
35
|
+
const { size, spacing, variant } = useToggleGroupContext(TOGGLE_GROUP_ITEM_NAME, __scopeToggleGroup);
|
|
36
|
+
const toggleGroupScope = useToggleGroupScope(__scopeToggleGroup);
|
|
37
|
+
return /* @__PURE__ */ jsx(ToggleGroupPrimitive.Item, {
|
|
38
|
+
className: cn(toggleVariants({
|
|
39
|
+
className,
|
|
40
|
+
size,
|
|
41
|
+
variant
|
|
42
|
+
}), "w-auto min-w-0 shrink-0 px-3 focus:z-10 focus-visible:z-10", "data-[spacing=0]:rounded-none data-[spacing=0]:shadow-none data-[spacing=0]:first:rounded-l-lg data-[spacing=0]:last:rounded-r-lg data-[spacing=0]:data-[variant=outline]:border-l-0 data-[spacing=0]:data-[variant=outline]:first:border-l"),
|
|
43
|
+
"data-size": size,
|
|
44
|
+
"data-slot": "toggle-group-item",
|
|
45
|
+
"data-spacing": spacing,
|
|
46
|
+
"data-variant": variant,
|
|
47
|
+
...toggleGroupScope,
|
|
48
|
+
...props,
|
|
49
|
+
children
|
|
50
|
+
});
|
|
53
51
|
}
|
|
52
|
+
//#endregion
|
|
54
53
|
export { ToggleGroup, ToggleGroupItem };
|
|
@@ -1,20 +1,28 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import * as _$_codefast_tailwind_variants0 from "@codefast/tailwind-variants";
|
|
2
|
+
import { VariantProps } from "@codefast/tailwind-variants";
|
|
3
|
+
import { ComponentProps, JSX } from "react";
|
|
3
4
|
import * as TogglePrimitive from "@radix-ui/react-toggle";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
|
|
6
|
+
//#region src/components/toggle.d.ts
|
|
7
|
+
declare const toggleVariants: _$_codefast_tailwind_variants0.VariantFunctionType<{
|
|
8
|
+
size: {
|
|
9
|
+
default: string;
|
|
10
|
+
lg: string;
|
|
11
|
+
sm: string;
|
|
12
|
+
};
|
|
13
|
+
variant: {
|
|
14
|
+
default: string;
|
|
15
|
+
outline: string;
|
|
16
|
+
};
|
|
14
17
|
}, Record<string, never>>;
|
|
15
18
|
type ToggleVariants = VariantProps<typeof toggleVariants>;
|
|
16
|
-
interface ToggleProps extends ComponentProps<typeof TogglePrimitive.Root>, ToggleVariants {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
interface ToggleProps extends ComponentProps<typeof TogglePrimitive.Root>, ToggleVariants {}
|
|
20
|
+
declare function Toggle({
|
|
21
|
+
children,
|
|
22
|
+
className,
|
|
23
|
+
size,
|
|
24
|
+
variant,
|
|
25
|
+
...props
|
|
26
|
+
}: ToggleProps): JSX.Element;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { Toggle, type ToggleProps, type ToggleVariants, toggleVariants };
|
|
@@ -1,35 +1,37 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx } from "react/jsx-runtime";
|
|
3
2
|
import { tv } from "@codefast/tailwind-variants";
|
|
4
|
-
import {
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import * as TogglePrimitive from "@radix-ui/react-toggle";
|
|
5
|
+
//#region src/components/toggle.tsx
|
|
5
6
|
const toggleVariants = tv({
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
7
|
+
base: "inline-flex items-center justify-center gap-2 rounded-lg text-sm font-medium whitespace-nowrap transition-[color,box-shadow] outline-none hover:bg-muted hover:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
8
|
+
variants: {
|
|
9
|
+
size: {
|
|
10
|
+
default: "h-9 min-w-9 px-2",
|
|
11
|
+
lg: "h-10 min-w-10 px-2.5",
|
|
12
|
+
sm: "h-8 min-w-8 px-1.5"
|
|
13
|
+
},
|
|
14
|
+
variant: {
|
|
15
|
+
default: "bg-transparent",
|
|
16
|
+
outline: "border border-input bg-transparent shadow-xs hover:bg-accent hover:text-accent-foreground"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
defaultVariants: {
|
|
20
|
+
size: "default",
|
|
21
|
+
variant: "default"
|
|
22
|
+
}
|
|
22
23
|
});
|
|
23
24
|
function Toggle({ children, className, size, variant, ...props }) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
return /* @__PURE__ */ jsx(TogglePrimitive.Root, {
|
|
26
|
+
className: toggleVariants({
|
|
27
|
+
className,
|
|
28
|
+
size,
|
|
29
|
+
variant
|
|
30
|
+
}),
|
|
31
|
+
"data-slot": "toggle",
|
|
32
|
+
...props,
|
|
33
|
+
children
|
|
34
|
+
});
|
|
34
35
|
}
|
|
36
|
+
//#endregion
|
|
35
37
|
export { Toggle, toggleVariants };
|
|
@@ -1,14 +1,30 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ComponentProps, JSX } from "react";
|
|
2
2
|
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
3
|
+
|
|
4
|
+
//#region src/components/tooltip.d.ts
|
|
3
5
|
type TooltipProviderProps = ComponentProps<typeof TooltipPrimitive.Provider>;
|
|
4
|
-
declare function TooltipProvider({
|
|
6
|
+
declare function TooltipProvider({
|
|
7
|
+
...props
|
|
8
|
+
}: TooltipProviderProps): JSX.Element;
|
|
5
9
|
type TooltipProps = ComponentProps<typeof TooltipPrimitive.Root>;
|
|
6
|
-
declare function Tooltip({
|
|
10
|
+
declare function Tooltip({
|
|
11
|
+
...props
|
|
12
|
+
}: TooltipProps): JSX.Element;
|
|
7
13
|
type TooltipTriggerProps = ComponentProps<typeof TooltipPrimitive.Trigger>;
|
|
8
|
-
declare function TooltipTrigger({
|
|
14
|
+
declare function TooltipTrigger({
|
|
15
|
+
...props
|
|
16
|
+
}: TooltipTriggerProps): JSX.Element;
|
|
9
17
|
type TooltipContentProps = ComponentProps<typeof TooltipPrimitive.Content>;
|
|
10
|
-
declare function TooltipContent({
|
|
18
|
+
declare function TooltipContent({
|
|
19
|
+
children,
|
|
20
|
+
className,
|
|
21
|
+
sideOffset,
|
|
22
|
+
...props
|
|
23
|
+
}: TooltipContentProps): JSX.Element;
|
|
11
24
|
type TooltipArrowProps = ComponentProps<typeof TooltipPrimitive.Arrow>;
|
|
12
|
-
declare function TooltipArrow({
|
|
13
|
-
|
|
14
|
-
|
|
25
|
+
declare function TooltipArrow({
|
|
26
|
+
className,
|
|
27
|
+
...props
|
|
28
|
+
}: TooltipArrowProps): JSX.Element;
|
|
29
|
+
//#endregion
|
|
30
|
+
export { Tooltip, TooltipArrow, type TooltipArrowProps, TooltipContent, type TooltipContentProps, type TooltipProps, TooltipProvider, type TooltipProviderProps, TooltipTrigger, type TooltipTriggerProps };
|
|
@@ -1,45 +1,42 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
2
|
import { cn } from "@codefast/tailwind-variants";
|
|
4
|
-
import {
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
5
|
+
//#region src/components/tooltip.tsx
|
|
5
6
|
function TooltipProvider({ ...props }) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
return /* @__PURE__ */ jsx(TooltipPrimitive.Provider, {
|
|
8
|
+
"data-slot": "tooltip-provider",
|
|
9
|
+
...props
|
|
10
|
+
});
|
|
10
11
|
}
|
|
11
12
|
function Tooltip({ ...props }) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
return /* @__PURE__ */ jsx(TooltipPrimitive.Root, {
|
|
14
|
+
"data-slot": "tooltip",
|
|
15
|
+
...props
|
|
16
|
+
});
|
|
16
17
|
}
|
|
17
18
|
function TooltipTrigger({ ...props }) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
return /* @__PURE__ */ jsx(TooltipPrimitive.Trigger, {
|
|
20
|
+
"data-slot": "tooltip-trigger",
|
|
21
|
+
...props
|
|
22
|
+
});
|
|
22
23
|
}
|
|
23
24
|
function TooltipContent({ children, className, sideOffset = 4, ...props }) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
children,
|
|
33
|
-
/*#__PURE__*/ jsx(TooltipArrow, {})
|
|
34
|
-
]
|
|
35
|
-
})
|
|
36
|
-
});
|
|
25
|
+
return /* @__PURE__ */ jsx(TooltipPrimitive.Portal, { children: /* @__PURE__ */ jsxs(TooltipPrimitive.Content, {
|
|
26
|
+
className: cn("z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md bg-primary px-3 py-1.5 text-xs text-balance text-primary-foreground ease-ui data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=closed]:data-[side=bottom]:slide-out-to-top-2 data-[state=closed]:data-[side=left]:slide-out-to-right-2 data-[state=closed]:data-[side=right]:slide-out-to-left-2 data-[state=closed]:data-[side=top]:slide-out-to-bottom-2 data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-[state=delayed-open]:data-[side=bottom]:slide-in-from-top-2 data-[state=delayed-open]:data-[side=left]:slide-in-from-right-2 data-[state=delayed-open]:data-[side=right]:slide-in-from-left-2 data-[state=delayed-open]:data-[side=top]:slide-in-from-bottom-2", "max-w-(--radix-tooltip-content-available-width)", className),
|
|
27
|
+
collisionPadding: 8,
|
|
28
|
+
"data-slot": "tooltip-content",
|
|
29
|
+
sideOffset,
|
|
30
|
+
...props,
|
|
31
|
+
children: [children, /* @__PURE__ */ jsx(TooltipArrow, {})]
|
|
32
|
+
}) });
|
|
37
33
|
}
|
|
38
34
|
function TooltipArrow({ className, ...props }) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
35
|
+
return /* @__PURE__ */ jsx(TooltipPrimitive.Arrow, {
|
|
36
|
+
className: cn("fill-primary", className),
|
|
37
|
+
"data-slot": "tooltip-arrow",
|
|
38
|
+
...props
|
|
39
|
+
});
|
|
44
40
|
}
|
|
41
|
+
//#endregion
|
|
45
42
|
export { Tooltip, TooltipArrow, TooltipContent, TooltipProvider, TooltipTrigger };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/hooks/use-animated-value.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* Produce a smoothly animated numeric value in response to changes.
|
|
3
4
|
*
|
|
@@ -15,4 +16,6 @@
|
|
|
15
16
|
* return <div>{value}%</div>;
|
|
16
17
|
* ```
|
|
17
18
|
*/
|
|
18
|
-
|
|
19
|
+
declare function useAnimatedValue(targetValue: null | number, duration: number, animate?: boolean): number;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { useAnimatedValue };
|
|
@@ -1,41 +1,62 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useEffect, useRef, useState } from "react";
|
|
3
|
+
//#region src/hooks/use-animated-value.ts
|
|
4
|
+
/**
|
|
5
|
+
* Produce a smoothly animated numeric value in response to changes.
|
|
6
|
+
*
|
|
7
|
+
* Applies a time-based easing (easeOutQuad) between the current and target values
|
|
8
|
+
* over the specified duration. When disabled, the value updates immediately.
|
|
9
|
+
*
|
|
10
|
+
* @param targetValue - Target number to animate toward; null resolves to 0.
|
|
11
|
+
* @param duration - Animation duration in milliseconds.
|
|
12
|
+
* @param animate - When false, bypasses animation and sets the value directly.
|
|
13
|
+
* @returns The current (rounded) animated value.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```tsx
|
|
17
|
+
* const value = useAnimatedValue(75, 1000, true);
|
|
18
|
+
* return <div>{value}%</div>;
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
3
21
|
function useAnimatedValue(targetValue, duration, animate) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
22
|
+
const actualTargetValue = targetValue ?? 0;
|
|
23
|
+
const [animatedValue, setAnimatedValue] = useState(actualTargetValue);
|
|
24
|
+
const animatedValueRef = useRef(actualTargetValue);
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
animatedValueRef.current = animatedValue;
|
|
27
|
+
}, [animatedValue]);
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (!animate) {
|
|
30
|
+
setAnimatedValue(actualTargetValue);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const currentValue = animatedValueRef.current;
|
|
34
|
+
const valueRange = actualTargetValue - currentValue;
|
|
35
|
+
const startTime = performance.now();
|
|
36
|
+
if (duration <= 0 || valueRange === 0) {
|
|
37
|
+
setAnimatedValue(actualTargetValue);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
let animationFrame;
|
|
41
|
+
const animateValue = (currentTime) => {
|
|
42
|
+
const elapsedTime = currentTime - startTime;
|
|
43
|
+
if (elapsedTime >= duration) setAnimatedValue(actualTargetValue);
|
|
44
|
+
else {
|
|
45
|
+
const progress = elapsedTime / duration;
|
|
46
|
+
setAnimatedValue(currentValue + valueRange * (1 - (1 - progress) * (1 - progress)));
|
|
47
|
+
animationFrame = requestAnimationFrame(animateValue);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
animationFrame = requestAnimationFrame(animateValue);
|
|
51
|
+
return () => {
|
|
52
|
+
cancelAnimationFrame(animationFrame);
|
|
53
|
+
};
|
|
54
|
+
}, [
|
|
55
|
+
actualTargetValue,
|
|
56
|
+
duration,
|
|
57
|
+
animate
|
|
58
|
+
]);
|
|
59
|
+
return Math.round(animatedValue);
|
|
40
60
|
}
|
|
61
|
+
//#endregion
|
|
41
62
|
export { useAnimatedValue };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/hooks/use-copy-to-clipboard.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* Provide clipboard copy capability with a transient copied state.
|
|
3
4
|
*
|
|
@@ -15,10 +16,15 @@
|
|
|
15
16
|
* <button onClick={() => copyToClipboard("Hello")}>{isCopied ? "Copied" : "Copy"}</button>
|
|
16
17
|
* ```
|
|
17
18
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
declare function useCopyToClipboard({
|
|
20
|
+
onCopy,
|
|
21
|
+
timeout
|
|
22
|
+
}?: {
|
|
23
|
+
onCopy?: () => void;
|
|
24
|
+
timeout?: number;
|
|
21
25
|
}): {
|
|
22
|
-
|
|
23
|
-
|
|
26
|
+
copyToClipboard: (value: string) => Promise<void>;
|
|
27
|
+
isCopied: boolean;
|
|
24
28
|
};
|
|
29
|
+
//#endregion
|
|
30
|
+
export { useCopyToClipboard };
|
|
@@ -1,24 +1,43 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useState } from "react";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
3
|
+
//#region src/hooks/use-copy-to-clipboard.ts
|
|
4
|
+
/**
|
|
5
|
+
* Provide clipboard copy capability with a transient copied state.
|
|
6
|
+
*
|
|
7
|
+
* Internally uses the Clipboard API when available and sets a temporary
|
|
8
|
+
* `isCopied` flag for UI feedback. A custom callback may be invoked upon copy.
|
|
9
|
+
*
|
|
10
|
+
* @param options - Configuration options.
|
|
11
|
+
* - onCopy: Callback invoked after a successful copy.
|
|
12
|
+
* - timeout: Duration in milliseconds to keep `isCopied` true. Defaults to 2000.
|
|
13
|
+
* @returns An object with a `copyToClipboard` function and an `isCopied` flag.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```tsx
|
|
17
|
+
* const { copyToClipboard, isCopied } = useCopyToClipboard({ timeout: 1500 });
|
|
18
|
+
* <button onClick={() => copyToClipboard("Hello")}>{isCopied ? "Copied" : "Copy"}</button>
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
function useCopyToClipboard({ onCopy, timeout = 2e3 } = {}) {
|
|
22
|
+
const [isCopied, setIsCopied] = useState(false);
|
|
23
|
+
const copyToClipboard = async (value) => {
|
|
24
|
+
if (typeof window === "undefined" || !("clipboard" in navigator) || typeof navigator.clipboard.writeText !== "function") return;
|
|
25
|
+
if (!value) return;
|
|
26
|
+
try {
|
|
27
|
+
await navigator.clipboard.writeText(value);
|
|
28
|
+
setIsCopied(true);
|
|
29
|
+
if (onCopy) onCopy();
|
|
30
|
+
setTimeout(() => {
|
|
31
|
+
setIsCopied(false);
|
|
32
|
+
}, timeout);
|
|
33
|
+
} catch (error) {
|
|
34
|
+
console.error(error);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
return {
|
|
38
|
+
copyToClipboard,
|
|
39
|
+
isCopied
|
|
40
|
+
};
|
|
23
41
|
}
|
|
42
|
+
//#endregion
|
|
24
43
|
export { useCopyToClipboard };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/hooks/use-is-mobile.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* Determine whether the current viewport should be treated as mobile.
|
|
3
4
|
*
|
|
@@ -16,4 +17,6 @@
|
|
|
16
17
|
* }
|
|
17
18
|
* ```
|
|
18
19
|
*/
|
|
19
|
-
|
|
20
|
+
declare function useIsMobile(mobileBreakpoint?: number): boolean;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { useIsMobile };
|
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useMediaQuery } from "./use-media-query.js";
|
|
3
|
+
//#region src/hooks/use-is-mobile.ts
|
|
4
|
+
/**
|
|
5
|
+
* Determine whether the current viewport should be treated as mobile.
|
|
6
|
+
*
|
|
7
|
+
* Uses {@link useMediaQuery} to evaluate a max-width media query derived from the
|
|
8
|
+
* provided breakpoint. By default, widths below 768px are considered mobile.
|
|
9
|
+
*
|
|
10
|
+
* @param mobileBreakpoint - Pixel width used as the mobile breakpoint. Values strictly
|
|
11
|
+
* less than this breakpoint are treated as mobile. Defaults to 768.
|
|
12
|
+
* @returns true when the viewport width is less than the given breakpoint; otherwise false.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* const isMobile = useIsMobile();
|
|
17
|
+
* if (isMobile) {
|
|
18
|
+
* // Render compact layout
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
3
22
|
function useIsMobile(mobileBreakpoint = 768) {
|
|
4
|
-
|
|
23
|
+
return useMediaQuery(`(max-width: ${(mobileBreakpoint - 1).toString()}px)`);
|
|
5
24
|
}
|
|
25
|
+
//#endregion
|
|
6
26
|
export { useIsMobile };
|