@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.
Files changed (149) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +34 -14
  3. package/dist/components/accordion.d.ts +29 -10
  4. package/dist/components/accordion.js +38 -37
  5. package/dist/components/alert-dialog.d.ts +60 -24
  6. package/dist/components/alert-dialog.js +69 -72
  7. package/dist/components/alert.d.ts +27 -15
  8. package/dist/components/alert.js +29 -31
  9. package/dist/components/aspect-ratio.d.ts +8 -4
  10. package/dist/components/aspect-ratio.js +7 -5
  11. package/dist/components/avatar.d.ts +17 -6
  12. package/dist/components/avatar.js +19 -17
  13. package/dist/components/badge.d.ts +21 -14
  14. package/dist/components/badge.js +19 -22
  15. package/dist/components/breadcrumb.d.ts +35 -12
  16. package/dist/components/breadcrumb.js +48 -54
  17. package/dist/components/button-group.d.ts +29 -14
  18. package/dist/components/button-group.js +27 -32
  19. package/dist/components/button.d.ts +35 -25
  20. package/dist/components/button.js +50 -48
  21. package/dist/components/calendar.d.ts +24 -9
  22. package/dist/components/calendar.js +92 -98
  23. package/dist/components/card.d.ts +34 -10
  24. package/dist/components/card.js +39 -37
  25. package/dist/components/carousel.d.ts +55 -24
  26. package/dist/components/carousel.js +113 -130
  27. package/dist/components/chart.d.ts +72 -36
  28. package/dist/components/chart.js +154 -166
  29. package/dist/components/checkbox-cards.d.ts +15 -8
  30. package/dist/components/checkbox-cards.js +22 -25
  31. package/dist/components/checkbox-group.d.ts +16 -8
  32. package/dist/components/checkbox-group.js +19 -19
  33. package/dist/components/checkbox.d.ts +9 -4
  34. package/dist/components/checkbox.js +14 -14
  35. package/dist/components/collapsible.d.ts +14 -6
  36. package/dist/components/collapsible.js +18 -16
  37. package/dist/components/command.d.ts +55 -23
  38. package/dist/components/command.js +70 -85
  39. package/dist/components/context-menu.d.ts +72 -22
  40. package/dist/components/context-menu.js +88 -109
  41. package/dist/components/dialog.d.ts +53 -22
  42. package/dist/components/dialog.js +71 -85
  43. package/dist/components/drawer.d.ts +60 -28
  44. package/dist/components/drawer.js +59 -67
  45. package/dist/components/dropdown-menu.d.ts +73 -22
  46. package/dist/components/dropdown-menu.js +95 -112
  47. package/dist/components/empty.d.ts +37 -15
  48. package/dist/components/empty.js +43 -45
  49. package/dist/components/field.d.ts +63 -25
  50. package/dist/components/field.js +88 -104
  51. package/dist/components/form.d.ts +37 -15
  52. package/dist/components/form.js +65 -70
  53. package/dist/components/hover-card.d.ts +21 -7
  54. package/dist/components/hover-card.js +24 -24
  55. package/dist/components/input-group.d.ts +53 -28
  56. package/dist/components/input-group.js +63 -77
  57. package/dist/components/input-number.d.ts +28 -7
  58. package/dist/components/input-number.js +55 -59
  59. package/dist/components/input-otp.d.ts +24 -10
  60. package/dist/components/input-otp.js +33 -37
  61. package/dist/components/input-password.d.ts +12 -5
  62. package/dist/components/input-password.js +31 -32
  63. package/dist/components/input-search.d.ts +18 -8
  64. package/dist/components/input-search.js +43 -41
  65. package/dist/components/input.d.ts +10 -4
  66. package/dist/components/input.js +9 -7
  67. package/dist/components/item.d.ts +69 -32
  68. package/dist/components/item.js +89 -92
  69. package/dist/components/kbd.d.ts +13 -5
  70. package/dist/components/kbd.js +13 -11
  71. package/dist/components/label.d.ts +9 -4
  72. package/dist/components/label.js +9 -7
  73. package/dist/components/menubar.d.ts +80 -23
  74. package/dist/components/menubar.js +97 -118
  75. package/dist/components/native-select.d.ts +16 -6
  76. package/dist/components/native-select.js +25 -26
  77. package/dist/components/navigation-menu.d.ts +36 -12
  78. package/dist/components/navigation-menu.js +60 -75
  79. package/dist/components/pagination.d.ts +35 -14
  80. package/dist/components/pagination.js +54 -69
  81. package/dist/components/popover.d.ts +24 -8
  82. package/dist/components/popover.js +28 -28
  83. package/dist/components/progress-circle.d.ts +106 -88
  84. package/dist/components/progress-circle.js +106 -138
  85. package/dist/components/progress.d.ts +10 -4
  86. package/dist/components/progress.js +14 -14
  87. package/dist/components/radio-cards.d.ts +10 -4
  88. package/dist/components/radio-cards.js +22 -23
  89. package/dist/components/radio-group.d.ts +13 -5
  90. package/dist/components/radio-group.js +18 -16
  91. package/dist/components/radio.d.ts +12 -5
  92. package/dist/components/radio.js +10 -8
  93. package/dist/components/resizable.d.ts +18 -7
  94. package/dist/components/resizable.js +22 -22
  95. package/dist/components/scroll-area.d.ts +33 -20
  96. package/dist/components/scroll-area.js +84 -88
  97. package/dist/components/select.d.ts +50 -16
  98. package/dist/components/select.js +77 -96
  99. package/dist/components/separator.d.ts +29 -19
  100. package/dist/components/separator.js +36 -34
  101. package/dist/components/sheet.d.ts +62 -29
  102. package/dist/components/sheet.js +79 -100
  103. package/dist/components/sidebar.d.ts +160 -66
  104. package/dist/components/sidebar.js +294 -336
  105. package/dist/components/skeleton.d.ts +9 -4
  106. package/dist/components/skeleton.js +8 -6
  107. package/dist/components/slider.d.ts +13 -4
  108. package/dist/components/slider.js +34 -40
  109. package/dist/components/sonner.d.ts +10 -7
  110. package/dist/components/sonner.js +16 -14
  111. package/dist/components/spinner.d.ts +12 -5
  112. package/dist/components/spinner.js +33 -35
  113. package/dist/components/switch.d.ts +9 -4
  114. package/dist/components/switch.js +13 -11
  115. package/dist/components/table.d.ts +37 -11
  116. package/dist/components/table.js +47 -45
  117. package/dist/components/tabs.d.ts +21 -7
  118. package/dist/components/tabs.js +24 -22
  119. package/dist/components/textarea.d.ts +9 -4
  120. package/dist/components/textarea.js +8 -6
  121. package/dist/components/toggle-group.d.ts +24 -9
  122. package/dist/components/toggle-group.js +41 -42
  123. package/dist/components/toggle.d.ts +25 -17
  124. package/dist/components/toggle.js +30 -28
  125. package/dist/components/tooltip.d.ts +24 -8
  126. package/dist/components/tooltip.js +29 -32
  127. package/dist/hooks/use-animated-value.d.ts +4 -1
  128. package/dist/hooks/use-animated-value.js +57 -36
  129. package/dist/hooks/use-copy-to-clipboard.d.ts +11 -5
  130. package/dist/hooks/use-copy-to-clipboard.js +39 -20
  131. package/dist/hooks/use-is-mobile.d.ts +4 -1
  132. package/dist/hooks/use-is-mobile.js +21 -1
  133. package/dist/hooks/use-media-query.d.ts +4 -1
  134. package/dist/hooks/use-media-query.js +45 -18
  135. package/dist/hooks/use-mutation-observer.d.ts +6 -2
  136. package/dist/hooks/use-mutation-observer.js +34 -16
  137. package/dist/hooks/use-pagination.d.ts +22 -14
  138. package/dist/hooks/use-pagination.js +100 -49
  139. package/dist/index.d.ts +69 -130
  140. package/dist/index.js +11 -11
  141. package/dist/primitives/checkbox-group.d.ts +105 -83
  142. package/dist/primitives/checkbox-group.js +111 -84
  143. package/dist/primitives/input-number.d.ts +51 -40
  144. package/dist/primitives/input-number.js +483 -350
  145. package/dist/primitives/input.d.ts +48 -42
  146. package/dist/primitives/input.js +65 -43
  147. package/dist/primitives/progress-circle.d.ts +79 -48
  148. package/dist/primitives/progress-circle.js +154 -105
  149. 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
- return /*#__PURE__*/ jsx("textarea", {
5
- 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),
6
- "data-slot": "textarea",
7
- ...props
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 type { Scope } from "@radix-ui/react-context";
2
- import type { ComponentProps, JSX } from "react";
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
- import type { ToggleVariants } from "./toggle";
5
+
6
+ //#region src/components/toggle-group.d.ts
5
7
  type ScopedProps<P> = P & {
6
- __scopeToggleGroup?: Scope;
8
+ __scopeToggleGroup?: Scope;
7
9
  };
8
10
  type ToggleGroupProps = ComponentProps<typeof ToggleGroupPrimitive.Root> & ToggleVariants & {
9
- spacing?: number;
11
+ spacing?: number;
10
12
  };
11
- declare function ToggleGroup({ __scopeToggleGroup, children, className, size, spacing, variant, ...props }: ScopedProps<ToggleGroupProps>): JSX.Element;
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({ __scopeToggleGroup, children, className, ...props }: ToggleGroupItemProps): JSX.Element;
14
- export { ToggleGroup, ToggleGroupItem };
15
- export type { ToggleGroupItemProps, ToggleGroupProps };
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 { jsx } from "react/jsx-runtime";
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 { Item, Root, createToggleGroupScope } from "@radix-ui/react-toggle-group";
6
- import { toggleVariants } from "./toggle.js";
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
- const toggleGroupScope = useToggleGroupScope(__scopeToggleGroup);
15
- return /*#__PURE__*/ jsx(ToggleGroupProvider, {
16
- scope: __scopeToggleGroup,
17
- size: size,
18
- spacing: spacing,
19
- variant: variant,
20
- children: /*#__PURE__*/ jsx(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: {
27
- "--gap": spacing
28
- },
29
- ...toggleGroupScope,
30
- ...props,
31
- children: children
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
- const { size, spacing, variant } = useToggleGroupContext(TOGGLE_GROUP_ITEM_NAME, __scopeToggleGroup);
38
- const toggleGroupScope = useToggleGroupScope(__scopeToggleGroup);
39
- return /*#__PURE__*/ jsx(Item, {
40
- className: cn(toggleVariants({
41
- className,
42
- size,
43
- variant
44
- }), "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"),
45
- "data-size": size,
46
- "data-slot": "toggle-group-item",
47
- "data-spacing": spacing,
48
- "data-variant": variant,
49
- ...toggleGroupScope,
50
- ...props,
51
- children: children
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 type { VariantProps } from "@codefast/tailwind-variants";
2
- import type { ComponentProps, JSX } from "react";
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
- declare const toggleVariants: import("@codefast/tailwind-variants").VariantFunctionType<{
5
- size: {
6
- default: string;
7
- lg: string;
8
- sm: string;
9
- };
10
- variant: {
11
- default: string;
12
- outline: string;
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
- declare function Toggle({ children, className, size, variant, ...props }: ToggleProps): JSX.Element;
19
- export { Toggle, toggleVariants };
20
- export type { ToggleProps, ToggleVariants };
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 { Root } from "@radix-ui/react-toggle";
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
- 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",
7
- variants: {
8
- size: {
9
- default: "h-9 min-w-9 px-2",
10
- lg: "h-10 min-w-10 px-2.5",
11
- sm: "h-8 min-w-8 px-1.5"
12
- },
13
- variant: {
14
- default: "bg-transparent",
15
- outline: "border border-input bg-transparent shadow-xs hover:bg-accent hover:text-accent-foreground"
16
- }
17
- },
18
- defaultVariants: {
19
- size: "default",
20
- variant: "default"
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
- return /*#__PURE__*/ jsx(Root, {
25
- className: toggleVariants({
26
- className,
27
- size,
28
- variant
29
- }),
30
- "data-slot": "toggle",
31
- ...props,
32
- children: children
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 type { ComponentProps, JSX } from "react";
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({ ...props }: TooltipProviderProps): JSX.Element;
6
+ declare function TooltipProvider({
7
+ ...props
8
+ }: TooltipProviderProps): JSX.Element;
5
9
  type TooltipProps = ComponentProps<typeof TooltipPrimitive.Root>;
6
- declare function Tooltip({ ...props }: TooltipProps): JSX.Element;
10
+ declare function Tooltip({
11
+ ...props
12
+ }: TooltipProps): JSX.Element;
7
13
  type TooltipTriggerProps = ComponentProps<typeof TooltipPrimitive.Trigger>;
8
- declare function TooltipTrigger({ ...props }: TooltipTriggerProps): JSX.Element;
14
+ declare function TooltipTrigger({
15
+ ...props
16
+ }: TooltipTriggerProps): JSX.Element;
9
17
  type TooltipContentProps = ComponentProps<typeof TooltipPrimitive.Content>;
10
- declare function TooltipContent({ children, className, sideOffset, ...props }: TooltipContentProps): JSX.Element;
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({ className, ...props }: TooltipArrowProps): JSX.Element;
13
- export { Tooltip, TooltipArrow, TooltipContent, TooltipProvider, TooltipTrigger };
14
- export type { TooltipArrowProps, TooltipContentProps, TooltipProps, TooltipProviderProps, TooltipTriggerProps, };
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 { Arrow, Content, Portal, Provider, Root, Trigger } from "@radix-ui/react-tooltip";
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
- return /*#__PURE__*/ jsx(Provider, {
7
- "data-slot": "tooltip-provider",
8
- ...props
9
- });
7
+ return /* @__PURE__ */ jsx(TooltipPrimitive.Provider, {
8
+ "data-slot": "tooltip-provider",
9
+ ...props
10
+ });
10
11
  }
11
12
  function Tooltip({ ...props }) {
12
- return /*#__PURE__*/ jsx(Root, {
13
- "data-slot": "tooltip",
14
- ...props
15
- });
13
+ return /* @__PURE__ */ jsx(TooltipPrimitive.Root, {
14
+ "data-slot": "tooltip",
15
+ ...props
16
+ });
16
17
  }
17
18
  function TooltipTrigger({ ...props }) {
18
- return /*#__PURE__*/ jsx(Trigger, {
19
- "data-slot": "tooltip-trigger",
20
- ...props
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
- return /*#__PURE__*/ jsx(Portal, {
25
- children: /*#__PURE__*/ jsxs(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: sideOffset,
30
- ...props,
31
- children: [
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
- return /*#__PURE__*/ jsx(Arrow, {
40
- className: cn("fill-primary", className),
41
- "data-slot": "tooltip-arrow",
42
- ...props
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
- export declare function useAnimatedValue(targetValue: null | number, duration: number, animate?: boolean): number;
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
- const actualTargetValue = targetValue ?? 0;
5
- const [animatedValue, setAnimatedValue] = useState(actualTargetValue);
6
- const animatedValueRef = useRef(actualTargetValue);
7
- useEffect(()=>{
8
- animatedValueRef.current = animatedValue;
9
- }, [
10
- animatedValue
11
- ]);
12
- useEffect(()=>{
13
- if (!animate) return void setAnimatedValue(actualTargetValue);
14
- const currentValue = animatedValueRef.current;
15
- const valueRange = actualTargetValue - currentValue;
16
- const startTime = performance.now();
17
- if (duration <= 0 || 0 === valueRange) return void setAnimatedValue(actualTargetValue);
18
- let animationFrame;
19
- const animateValue = (currentTime)=>{
20
- const elapsedTime = currentTime - startTime;
21
- if (elapsedTime >= duration) setAnimatedValue(actualTargetValue);
22
- else {
23
- const progress = elapsedTime / duration;
24
- const easeProgress = 1 - (1 - progress) * (1 - progress);
25
- const nextValue = currentValue + valueRange * easeProgress;
26
- setAnimatedValue(nextValue);
27
- animationFrame = requestAnimationFrame(animateValue);
28
- }
29
- };
30
- animationFrame = requestAnimationFrame(animateValue);
31
- return ()=>{
32
- cancelAnimationFrame(animationFrame);
33
- };
34
- }, [
35
- actualTargetValue,
36
- duration,
37
- animate
38
- ]);
39
- return Math.round(animatedValue);
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
- export declare function useCopyToClipboard({ onCopy, timeout, }?: {
19
- onCopy?: () => void;
20
- timeout?: number;
19
+ declare function useCopyToClipboard({
20
+ onCopy,
21
+ timeout
22
+ }?: {
23
+ onCopy?: () => void;
24
+ timeout?: number;
21
25
  }): {
22
- copyToClipboard: (value: string) => Promise<void>;
23
- isCopied: boolean;
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
- function useCopyToClipboard({ onCopy, timeout = 2000 } = {}) {
4
- const [isCopied, setIsCopied] = useState(false);
5
- const copyToClipboard = async (value)=>{
6
- if ("u" < typeof window || !("clipboard" in navigator) || "function" != typeof navigator.clipboard.writeText) return;
7
- if (!value) return;
8
- try {
9
- await navigator.clipboard.writeText(value);
10
- setIsCopied(true);
11
- if (onCopy) onCopy();
12
- setTimeout(()=>{
13
- setIsCopied(false);
14
- }, timeout);
15
- } catch (error) {
16
- console.error(error);
17
- }
18
- };
19
- return {
20
- copyToClipboard,
21
- isCopied
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
- export declare function useIsMobile(mobileBreakpoint?: number): boolean;
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
- return useMediaQuery(`(max-width: ${(mobileBreakpoint - 1).toString()}px)`);
23
+ return useMediaQuery(`(max-width: ${(mobileBreakpoint - 1).toString()}px)`);
5
24
  }
25
+ //#endregion
6
26
  export { useIsMobile };