@uselets/ui 0.4.0 → 0.6.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/README.md +81 -7
- package/dist/chunk-CHh1Zzun.js +1 -0
- package/dist/cli/uselets.mjs +7 -0
- package/dist/cli/uselets.mjs.map +1 -0
- package/dist/components/accordion.d.ts +6 -6
- package/dist/components/accordion.js +1 -1
- package/dist/components/accordion.js.map +1 -1
- package/dist/components/alert-dialog.d.ts +14 -14
- package/dist/components/alert-dialog.js +1 -1
- package/dist/components/alert-dialog.js.map +1 -1
- package/dist/components/alert.d.ts +8 -8
- package/dist/components/alert.js +1 -1
- package/dist/components/anchor.d.ts +24 -0
- package/dist/components/anchor.js +2 -0
- package/dist/components/anchor.js.map +1 -0
- package/dist/components/avatar.d.ts +8 -8
- package/dist/components/avatar.js +1 -1
- package/dist/components/badge.d.ts +5 -5
- package/dist/components/badge.js +1 -1
- package/dist/components/breadcrumb.d.ts +9 -9
- package/dist/components/breadcrumb.js +1 -1
- package/dist/components/breadcrumb.js.map +1 -1
- package/dist/components/button-group.d.ts +7 -7
- package/dist/components/button-group.js +1 -1
- package/dist/components/button.d.ts +9 -7
- package/dist/components/button.js +1 -1
- package/dist/components/button.js.map +1 -1
- package/dist/components/calendar.d.ts +7 -6
- package/dist/components/calendar.js +1 -1
- package/dist/components/calendar.js.map +1 -1
- package/dist/components/card.d.ts +9 -9
- package/dist/components/card.js +1 -1
- package/dist/components/carousel.d.ts +9 -7
- package/dist/components/carousel.js +1 -1
- package/dist/components/carousel.js.map +1 -1
- package/dist/components/center.d.ts +6 -6
- package/dist/components/center.js +1 -1
- package/dist/components/chart.d.ts +90 -90
- package/dist/components/chart.js +1 -1
- package/dist/components/chart.js.map +1 -1
- package/dist/components/checkbox.d.ts +6 -6
- package/dist/components/checkbox.js +1 -1
- package/dist/components/code.d.ts +13 -0
- package/dist/components/code.js +2 -0
- package/dist/components/code.js.map +1 -0
- package/dist/components/collapsible.d.ts +5 -5
- package/dist/components/collapsible.js +1 -1
- package/dist/components/collapsible.js.map +1 -1
- package/dist/components/combobox.d.ts +17 -17
- package/dist/components/combobox.js +1 -1
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/command.d.ts +11 -11
- package/dist/components/command.js +1 -1
- package/dist/components/command.js.map +1 -1
- package/dist/components/container.d.ts +6 -6
- package/dist/components/container.js +1 -1
- package/dist/components/dialog.d.ts +15 -15
- package/dist/components/dialog.js +1 -1
- package/dist/components/drawer.d.ts +15 -15
- package/dist/components/drawer.js +1 -1
- package/dist/components/dropdown-menu.d.ts +17 -17
- package/dist/components/dropdown-menu.js +1 -1
- package/dist/components/dropzone.d.ts +107 -0
- package/dist/components/dropzone.js +2 -0
- package/dist/components/dropzone.js.map +1 -0
- package/dist/components/empty.d.ts +10 -10
- package/dist/components/empty.js +1 -1
- package/dist/components/field.d.ts +14 -14
- package/dist/components/field.js +1 -1
- package/dist/components/group.d.ts +6 -6
- package/dist/components/group.js +1 -1
- package/dist/components/heading.d.ts +22 -0
- package/dist/components/heading.js +2 -0
- package/dist/components/heading.js.map +1 -0
- package/dist/components/hover-card.d.ts +5 -5
- package/dist/components/hover-card.js +1 -1
- package/dist/components/hover-card.js.map +1 -1
- package/dist/components/input-group.d.ts +12 -11
- package/dist/components/input-group.js +1 -1
- package/dist/components/input-group.js.map +1 -1
- package/dist/components/input-otp.d.ts +6 -6
- package/dist/components/input-otp.js +1 -1
- package/dist/components/input-otp.js.map +1 -1
- package/dist/components/input.d.ts +3 -3
- package/dist/components/input.js +1 -1
- package/dist/components/kbd.d.ts +4 -4
- package/dist/components/kbd.js +1 -1
- package/dist/components/label.d.ts +3 -3
- package/dist/components/label.js +1 -1
- package/dist/components/list.d.ts +44 -0
- package/dist/components/list.js +2 -0
- package/dist/components/list.js.map +1 -0
- package/dist/components/native-select.d.ts +5 -5
- package/dist/components/native-select.js +1 -1
- package/dist/components/navigation-menu.d.ts +12 -12
- package/dist/components/navigation-menu.js +1 -1
- package/dist/components/navigation-menu.js.map +1 -1
- package/dist/components/pagination.d.ts +11 -10
- package/dist/components/pagination.js +1 -1
- package/dist/components/pagination.js.map +1 -1
- package/dist/components/popover.d.ts +9 -9
- package/dist/components/popover.js +1 -1
- package/dist/components/progress.d.ts +3 -3
- package/dist/components/progress.js +1 -1
- package/dist/components/radio-group.d.ts +4 -4
- package/dist/components/radio-group.js +1 -1
- package/dist/components/resizable.d.ts +5 -5
- package/dist/components/resizable.js +1 -1
- package/dist/components/scroll-area.d.ts +4 -4
- package/dist/components/scroll-area.js +1 -1
- package/dist/components/select.d.ts +12 -12
- package/dist/components/select.js +1 -1
- package/dist/components/separator.d.ts +3 -3
- package/dist/components/separator.js +1 -1
- package/dist/components/sheet.d.ts +12 -12
- package/dist/components/sheet.js +1 -1
- package/dist/components/sheet.js.map +1 -1
- package/dist/components/sidebar.d.ts +28 -28
- package/dist/components/sidebar.js +1 -1
- package/dist/components/sidebar.js.map +1 -1
- package/dist/components/skeleton.d.ts +3 -3
- package/dist/components/skeleton.js +1 -1
- package/dist/components/slider.d.ts +3 -3
- package/dist/components/slider.js +1 -1
- package/dist/components/sonner.d.ts +3 -3
- package/dist/components/sonner.js +1 -1
- package/dist/components/sonner.js.map +1 -1
- package/dist/components/spinner.d.ts +6 -6
- package/dist/components/spinner.js +1 -1
- package/dist/components/stack.d.ts +6 -6
- package/dist/components/stack.js +1 -1
- package/dist/components/switch.d.ts +3 -3
- package/dist/components/switch.js +1 -1
- package/dist/components/table.d.ts +10 -10
- package/dist/components/table.js +1 -1
- package/dist/components/table.js.map +1 -1
- package/dist/components/tabs.d.ts +8 -8
- package/dist/components/tabs.js +1 -1
- package/dist/components/tabs.js.map +1 -1
- package/dist/components/text.d.ts +22 -0
- package/dist/components/text.js +2 -0
- package/dist/components/text.js.map +1 -0
- package/dist/components/textarea.d.ts +3 -3
- package/dist/components/textarea.js +1 -1
- package/dist/components/theme.d.ts +4 -4
- package/dist/components/theme.js +1 -1
- package/dist/components/timeline.d.ts +63 -0
- package/dist/components/timeline.js +2 -0
- package/dist/components/timeline.js.map +1 -0
- package/dist/components/toggle-group.d.ts +4 -4
- package/dist/components/toggle-group.js +1 -1
- package/dist/components/toggle.d.ts +6 -6
- package/dist/components/toggle.js +1 -1
- package/dist/components/tooltip.d.ts +6 -6
- package/dist/components/tooltip.js +1 -1
- package/dist/hooks/use-disclosure.d.ts +23 -0
- package/dist/hooks/use-disclosure.js +2 -0
- package/dist/hooks/use-disclosure.js.map +1 -0
- package/dist/hooks/use-disclosure.spec.d.ts +1 -0
- package/dist/hooks/use-disclosure.spec.js +2 -0
- package/dist/hooks/use-disclosure.spec.js.map +1 -0
- package/dist/hooks/use-document-visibility.d.ts +7 -0
- package/dist/hooks/use-document-visibility.js +2 -0
- package/dist/hooks/use-document-visibility.js.map +1 -0
- package/dist/hooks/use-document-visibility.spec.d.ts +1 -0
- package/dist/hooks/use-document-visibility.spec.js +2 -0
- package/dist/hooks/use-document-visibility.spec.js.map +1 -0
- package/dist/hooks/use-idle.d.ts +14 -0
- package/dist/hooks/use-idle.js +2 -0
- package/dist/hooks/use-idle.js.map +1 -0
- package/dist/hooks/use-idle.spec.d.ts +1 -0
- package/dist/hooks/use-idle.spec.js +2 -0
- package/dist/hooks/use-idle.spec.js.map +1 -0
- package/dist/hooks/use-interval.d.ts +22 -0
- package/dist/hooks/use-interval.js +2 -0
- package/dist/hooks/use-interval.js.map +1 -0
- package/dist/hooks/use-interval.spec.d.ts +1 -0
- package/dist/hooks/use-interval.spec.js +2 -0
- package/dist/hooks/use-interval.spec.js.map +1 -0
- package/dist/hooks/use-local-storage.d.ts +17 -0
- package/dist/hooks/use-local-storage.js +2 -0
- package/dist/hooks/use-local-storage.js.map +1 -0
- package/dist/hooks/use-local-storage.spec.d.ts +1 -0
- package/dist/hooks/use-local-storage.spec.js +2 -0
- package/dist/hooks/use-local-storage.spec.js.map +1 -0
- package/dist/hooks/use-mobile.d.ts +1 -1
- package/dist/hooks/use-mobile.js +1 -1
- package/dist/hooks/use-mobile.spec.d.ts +1 -0
- package/dist/hooks/use-mobile.spec.js +2 -0
- package/dist/hooks/use-mobile.spec.js.map +1 -0
- package/dist/index.d.ts +16 -3
- package/dist/index.js +1 -1
- package/dist/lib/button.d.ts +16 -0
- package/dist/lib/button.js +2 -0
- package/dist/lib/button.js.map +1 -0
- package/dist/lib/utils.d.ts +3 -2
- package/dist/lib/utils.js +1 -1
- package/dist/lib/utils.js.map +1 -1
- package/dist/react.esm-BuxkFT_p.js +59 -0
- package/dist/react.esm-BuxkFT_p.js.map +1 -0
- package/dist/styles.css +2 -1437
- package/dist/themes/gomax.css +2 -0
- package/dist/themes/max.css +2 -0
- package/package.json +43 -27
- package/dist/chunk-IpJEthwI.js +0 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { n as __name } from "../chunk-CHh1Zzun.js";
|
|
2
|
+
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
|
+
import { VariantProps } from "class-variance-authority";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import * as _$class_variance_authority_types0 from "class-variance-authority/types";
|
|
6
|
+
|
|
7
|
+
//#region src/components/text.d.ts
|
|
8
|
+
declare const textVariants: (props?: ({
|
|
9
|
+
size?: "xs" | "sm" | "md" | "lg" | "xl" | null | undefined;
|
|
10
|
+
} & _$class_variance_authority_types0.ClassProp) | undefined) => string;
|
|
11
|
+
type TextProps = React.ComponentProps<'p'> & VariantProps<typeof textVariants> & {
|
|
12
|
+
asChild?: boolean;
|
|
13
|
+
};
|
|
14
|
+
declare function Text({
|
|
15
|
+
className,
|
|
16
|
+
size,
|
|
17
|
+
asChild,
|
|
18
|
+
...props
|
|
19
|
+
}: TextProps): _$react_jsx_runtime0.JSX.Element;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { Text, TextProps, textVariants };
|
|
22
|
+
//# sourceMappingURL=text.d.ts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"../chunk-CHh1Zzun.js";import{cn as e}from"../lib/utils.js";import{Slot as t}from"radix-ui";import{jsx as n}from"react/jsx-runtime";import{cva as r}from"class-variance-authority";const i=r(`text-foreground font-normal`,{variants:{size:{xs:`text-xs leading-4`,sm:`text-sm leading-5`,md:`text-base leading-6`,lg:`text-lg leading-7`,xl:`text-xl leading-8`}},defaultVariants:{size:`md`}});function Text({className:r,size:a=`md`,asChild:o=!1,...s}){return n(o?t.Root:`p`,{"data-slot":`text`,"data-size":a,className:e(i({size:a}),r),...s})}export{Text,i as textVariants};
|
|
2
|
+
//# sourceMappingURL=text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.js","names":[],"sources":["../../src/components/text.tsx"],"sourcesContent":["import type * as React from 'react'\n\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { Slot } from 'radix-ui'\n\nimport { cn } from '../lib/utils'\n\nconst textVariants = cva('text-foreground font-normal', {\n variants: {\n size: {\n xs: 'text-xs leading-4',\n sm: 'text-sm leading-5',\n md: 'text-base leading-6',\n lg: 'text-lg leading-7',\n xl: 'text-xl leading-8'\n }\n },\n defaultVariants: {\n size: 'md'\n }\n})\n\nexport type TextProps = React.ComponentProps<'p'> &\n VariantProps<typeof textVariants> & {\n asChild?: boolean\n }\n\nfunction Text({ className, size = 'md', asChild = false, ...props }: TextProps) {\n const Comp = asChild ? Slot.Root : 'p'\n\n return <Comp data-slot=\"text\" data-size={size} className={cn(textVariants({ size }), className)} {...props} />\n}\n\nexport { Text, textVariants }\n"],"mappings":"yLAOA,MAAM,EAAe,EAAI,8BAA+B,CACtD,SAAU,CACR,KAAM,CACJ,GAAI,oBACJ,GAAI,oBACJ,GAAI,sBACJ,GAAI,oBACJ,GAAI,oBACL,CACF,CACD,gBAAiB,CACf,KAAM,KACP,CACF,CAAC,CAOF,SAAS,KAAK,CAAE,YAAW,OAAO,KAAM,UAAU,GAAO,GAAG,GAAoB,CAG9E,OAAO,EAFM,EAAU,EAAK,KAAO,IAE5B,CAAM,YAAU,OAAO,YAAW,EAAM,UAAW,EAAG,EAAa,CAAE,OAAM,CAAC,CAAE,EAAU,CAAE,GAAI,EAAS,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
1
|
+
import { n as __name } from "../chunk-CHh1Zzun.js";
|
|
2
|
+
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
|
|
5
5
|
//#region src/components/textarea.d.ts
|
|
@@ -7,7 +7,7 @@ type TextareaProps = React.ComponentProps<'textarea'>;
|
|
|
7
7
|
declare function Textarea({
|
|
8
8
|
className,
|
|
9
9
|
...props
|
|
10
|
-
}: TextareaProps): react_jsx_runtime0.JSX.Element;
|
|
10
|
+
}: TextareaProps): _$react_jsx_runtime0.JSX.Element;
|
|
11
11
|
//#endregion
|
|
12
12
|
export { Textarea, TextareaProps };
|
|
13
13
|
//# sourceMappingURL=textarea.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../chunk-
|
|
1
|
+
import"../chunk-CHh1Zzun.js";import{cn as e}from"../lib/utils.js";import{jsx as t}from"react/jsx-runtime";function Textarea({className:n,...r}){return t(`textarea`,{"data-slot":`textarea`,className:e(`flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-transparent px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,n),...r})}export{Textarea};
|
|
2
2
|
//# sourceMappingURL=textarea.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as __name } from "../chunk-CHh1Zzun.js";
|
|
2
2
|
import { Button } from "./button.js";
|
|
3
|
-
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
|
+
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
4
4
|
import * as React from "react";
|
|
5
5
|
|
|
6
6
|
//#region src/components/theme.d.ts
|
|
@@ -20,9 +20,9 @@ declare function ThemeProvider({
|
|
|
20
20
|
defaultTheme,
|
|
21
21
|
storageKey,
|
|
22
22
|
...props
|
|
23
|
-
}: ThemeProviderProps): react_jsx_runtime0.JSX.Element;
|
|
23
|
+
}: ThemeProviderProps): _$react_jsx_runtime0.JSX.Element;
|
|
24
24
|
declare const useTheme: () => ThemeProviderState;
|
|
25
|
-
declare function ModeToggle(props: ModeToggleProps): react_jsx_runtime0.JSX.Element;
|
|
25
|
+
declare function ModeToggle(props: ModeToggleProps): _$react_jsx_runtime0.JSX.Element;
|
|
26
26
|
//#endregion
|
|
27
27
|
export { ModeToggle, ModeToggleProps, Theme, ThemeProvider, ThemeProviderProps, ThemeProviderState, useTheme };
|
|
28
28
|
//# sourceMappingURL=theme.d.ts.map
|
package/dist/components/theme.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../chunk-
|
|
1
|
+
import"../chunk-CHh1Zzun.js";import{Button as e}from"./button.js";import{DropdownMenu as t,DropdownMenuContent as n,DropdownMenuItem as r,DropdownMenuTrigger as i}from"./dropdown-menu.js";import{IconMoon as a,IconSun as o}from"@tabler/icons-react";import{jsx as s,jsxs as c}from"react/jsx-runtime";import{createContext as l,use as u,useEffect as d,useState as f}from"react";const p=l({});function ThemeProvider({children:e,defaultTheme:t=`system`,storageKey:n=`vite-ui-theme`,...r}){let[i,a]=f(()=>localStorage.getItem(n)||t);d(()=>{let e=window.document.documentElement;if(e.classList.remove(`light`,`dark`),i===`system`){let t=window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`;e.classList.add(t);return}e.classList.add(i)},[i]);let o={theme:i,setTheme:e=>{localStorage.setItem(n,e),a(e)}};return s(p.Provider,{...r,value:o,children:e})}const useTheme=()=>{let e=u(p);if(e===void 0||Object.keys(e).length===0)throw Error(`useTheme must be used within a ThemeProvider`);return e};function ModeToggle(l){let{setTheme:u}=useTheme();return c(t,{children:[s(i,{children:c(e,{variant:`outline`,size:`icon`,...l,children:[s(o,{className:`h-[1.2rem] w-[1.2rem] scale-100 rotate-0 transition-all dark:scale-0 dark:-rotate-90`}),s(a,{className:`absolute h-[1.2rem] w-[1.2rem] scale-0 rotate-90 transition-all dark:scale-100 dark:rotate-0`}),s(`span`,{className:`sr-only`,children:`Toggle theme`})]})}),c(n,{align:`end`,children:[s(r,{onClick:()=>u(`light`),children:`Light`}),s(r,{onClick:()=>u(`dark`),children:`Dark`}),s(r,{onClick:()=>u(`system`),children:`System`})]})]})}export{ModeToggle,ThemeProvider,useTheme};
|
|
2
2
|
//# sourceMappingURL=theme.js.map
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { n as __name } from "../chunk-CHh1Zzun.js";
|
|
2
|
+
import { VariantProps } from "class-variance-authority";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import * as _$class_variance_authority_types0 from "class-variance-authority/types";
|
|
5
|
+
|
|
6
|
+
//#region src/components/timeline.d.ts
|
|
7
|
+
declare const timelineVariants: (props?: ({
|
|
8
|
+
size?: "sm" | "md" | "lg" | null | undefined;
|
|
9
|
+
} & _$class_variance_authority_types0.ClassProp) | undefined) => string;
|
|
10
|
+
declare const timelineConnectorVariants: (props?: ({
|
|
11
|
+
status?: "pending" | "completed" | "in-progress" | null | undefined;
|
|
12
|
+
color?: "destructive" | "secondary" | "primary" | "muted" | "accent" | "gradient" | null | undefined;
|
|
13
|
+
} & _$class_variance_authority_types0.ClassProp) | undefined) => string;
|
|
14
|
+
declare const timelineIconVariants: (props?: ({
|
|
15
|
+
color?: "destructive" | "secondary" | "primary" | "muted" | "accent" | null | undefined;
|
|
16
|
+
size?: "sm" | "md" | "lg" | null | undefined;
|
|
17
|
+
} & _$class_variance_authority_types0.ClassProp) | undefined) => string;
|
|
18
|
+
type TimelineIconSize = NonNullable<VariantProps<typeof timelineIconVariants>['size']>;
|
|
19
|
+
type TimelineConnectorColor = NonNullable<VariantProps<typeof timelineConnectorVariants>['color']>;
|
|
20
|
+
type TimelineIconColor = NonNullable<VariantProps<typeof timelineIconVariants>['color']>;
|
|
21
|
+
type TimelineStatus = NonNullable<VariantProps<typeof timelineConnectorVariants>['status']>;
|
|
22
|
+
type TimelineProps = React.ComponentProps<'ol'> & VariantProps<typeof timelineVariants> & {
|
|
23
|
+
iconSize?: TimelineIconSize;
|
|
24
|
+
};
|
|
25
|
+
declare const Timeline: React.ForwardRefExoticComponent<Omit<TimelineProps, "ref"> & React.RefAttributes<HTMLOListElement>>;
|
|
26
|
+
type TimelineItemProps = React.ComponentProps<'li'> & {
|
|
27
|
+
date?: React.ReactNode;
|
|
28
|
+
title?: React.ReactNode;
|
|
29
|
+
description?: React.ReactNode;
|
|
30
|
+
icon?: React.ReactNode;
|
|
31
|
+
iconColor?: TimelineIconColor;
|
|
32
|
+
status?: TimelineStatus;
|
|
33
|
+
connectorColor?: TimelineConnectorColor;
|
|
34
|
+
showConnector?: boolean;
|
|
35
|
+
iconSize?: TimelineIconSize;
|
|
36
|
+
loading?: boolean;
|
|
37
|
+
error?: React.ReactNode;
|
|
38
|
+
};
|
|
39
|
+
declare const TimelineItem: React.ForwardRefExoticComponent<Omit<TimelineItemProps, "ref"> & React.RefAttributes<HTMLLIElement>>;
|
|
40
|
+
type TimelineTimeProps = React.ComponentProps<'time'> & {
|
|
41
|
+
date?: string | Date | number;
|
|
42
|
+
format?: Intl.DateTimeFormatOptions;
|
|
43
|
+
};
|
|
44
|
+
declare const TimelineTime: React.ForwardRefExoticComponent<Omit<TimelineTimeProps, "ref"> & React.RefAttributes<HTMLTimeElement>>;
|
|
45
|
+
type TimelineConnectorProps = React.ComponentProps<'div'> & VariantProps<typeof timelineConnectorVariants>;
|
|
46
|
+
declare const TimelineConnector: React.ForwardRefExoticComponent<Omit<TimelineConnectorProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
47
|
+
type TimelineHeaderProps = React.ComponentProps<'div'>;
|
|
48
|
+
declare const TimelineHeader: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
49
|
+
type TimelineTitleProps = React.ComponentProps<'h3'>;
|
|
50
|
+
declare const TimelineTitle: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, "ref"> & React.RefAttributes<HTMLHeadingElement>>;
|
|
51
|
+
type TimelineIconProps = React.ComponentProps<'div'> & VariantProps<typeof timelineIconVariants> & {
|
|
52
|
+
icon?: React.ReactNode;
|
|
53
|
+
};
|
|
54
|
+
declare const TimelineIcon: React.ForwardRefExoticComponent<Omit<TimelineIconProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
55
|
+
type TimelineDescriptionProps = React.ComponentProps<'p'>;
|
|
56
|
+
declare const TimelineDescription: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, "ref"> & React.RefAttributes<HTMLParagraphElement>>;
|
|
57
|
+
type TimelineContentProps = React.ComponentProps<'div'>;
|
|
58
|
+
declare const TimelineContent: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
59
|
+
type TimelineEmptyProps = React.ComponentProps<'div'>;
|
|
60
|
+
declare const TimelineEmpty: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
61
|
+
//#endregion
|
|
62
|
+
export { Timeline, TimelineConnector, TimelineConnectorColor, TimelineConnectorProps, TimelineContent, TimelineContentProps, TimelineDescription, TimelineDescriptionProps, TimelineEmpty, TimelineEmptyProps, TimelineHeader, TimelineHeaderProps, TimelineIcon, TimelineIconColor, TimelineIconProps, TimelineIconSize, TimelineItem, TimelineItemProps, TimelineProps, TimelineStatus, TimelineTime, TimelineTimeProps, TimelineTitle, TimelineTitleProps, timelineVariants };
|
|
63
|
+
//# sourceMappingURL=timeline.d.ts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"../chunk-CHh1Zzun.js";import{cn as e}from"../lib/utils.js";import{Spinner as t}from"./spinner.js";import{IconAlertCircle as n}from"@tabler/icons-react";import{jsx as r,jsxs as i}from"react/jsx-runtime";import{cva as a}from"class-variance-authority";import*as o from"react";const s=a(`relative mx-auto m-0 flex w-full max-w-2xl min-h-150 list-none flex-col p-0 py-8`,{variants:{size:{sm:`gap-4`,md:`gap-6`,lg:`gap-8`}},defaultVariants:{size:`md`}}),c=a(`relative w-full last:mb-0`,{variants:{tone:{default:`mb-2`,error:`mb-2`}},defaultVariants:{tone:`default`}}),l=a(`w-0.5`,{variants:{status:{completed:`bg-primary`,"in-progress":`bg-accent`,pending:`bg-muted`},color:{primary:`bg-primary`,secondary:`bg-secondary`,muted:`bg-muted`,accent:`bg-accent`,destructive:`bg-destructive`,gradient:`bg-linear-to-b from-primary to-muted`}}}),u=a(`relative flex items-center justify-center rounded-full ring-8 ring-background shadow-sm`,{variants:{color:{primary:`bg-primary text-primary-foreground`,secondary:`bg-secondary text-secondary-foreground`,muted:`bg-muted text-muted-foreground`,accent:`bg-accent text-accent-foreground`,destructive:`bg-destructive text-destructive-foreground`},size:{sm:`h-8 w-8`,md:`h-10 w-10`,lg:`h-12 w-12`}},defaultVariants:{color:`primary`,size:`md`}}),d=a(`flex items-center justify-center`,{variants:{size:{sm:`h-4 w-4`,md:`h-5 w-5`,lg:`h-6 w-6`}},defaultVariants:{size:`md`}}),f=o.forwardRef(({className:t,iconSize:n,size:i=`md`,children:a,...c},l)=>{let u=o.Children.toArray(a).filter(isTimelineItemElement).length;if(u===0)return r(`ol`,{ref:l,"aria-label":`Timeline`,"data-slot":`timeline`,"data-size":i,className:e(s({size:i}),t),...c,children:r(`li`,{className:`list-none`,children:r(S,{})})});let d=0;return r(`ol`,{ref:l,"aria-label":`Timeline`,"data-slot":`timeline`,"data-size":i,className:e(s({size:i}),t),...c,children:o.Children.map(a,e=>{if(!isTimelineItemElement(e))return e;let t=d===u-1;return d+=1,o.cloneElement(e,{iconSize:e.props.iconSize??n,showConnector:e.props.showConnector??!t})})})});f.displayName=`Timeline`;const p=o.forwardRef(({className:a,children:o,date:s,title:l,description:u,icon:d,iconColor:f,status:p=`completed`,connectorColor:m,showConnector:S=!0,iconSize:C,loading:w=!1,error:T,...E},D)=>w?r(`li`,{ref:D,"aria-busy":`true`,"data-slot":`timeline-item`,"data-status":p,className:e(c(),a),...E,children:i(`div`,{className:`grid grid-cols-[minmax(auto,8rem)_auto_1fr] items-start px-4`,children:[r(`div`,{className:`pr-4 text-right`,children:r(`div`,{className:`h-4 w-24 animate-pulse rounded bg-muted`})}),i(`div`,{className:`mx-3 flex flex-col items-center justify-start gap-y-2`,children:[r(`div`,{className:`relative flex h-8 w-8 animate-pulse items-center justify-center rounded-full bg-muted ring-8 ring-background`,children:r(t,{})}),S&&r(`div`,{className:`h-full w-0.5 animate-pulse bg-muted`})]}),r(`div`,{className:`flex flex-col gap-2 pl-2`,children:i(`div`,{className:`space-y-2`,children:[r(`div`,{className:`h-4 w-24 animate-pulse rounded bg-muted`}),r(`div`,{className:`h-3 w-48 animate-pulse rounded bg-muted`})]})})]})}):T?r(`li`,{ref:D,role:`alert`,"data-slot":`timeline-item`,"data-status":`error`,className:e(c({tone:`error`}),a),...E,children:i(`div`,{className:`grid grid-cols-[minmax(auto,8rem)_auto_1fr] items-start px-4`,children:[r(`div`,{className:`pr-4 text-right`,children:r(h,{className:`text-destructive`,children:s})}),i(`div`,{className:`mx-3 flex flex-col items-center justify-start gap-y-2`,children:[r(`div`,{className:`relative flex h-8 w-8 items-center justify-center rounded-full bg-destructive/20 ring-8 ring-background`,children:r(n,{className:`h-4 w-4 text-destructive`})}),S&&r(g,{color:`destructive`,className:`h-full`})]}),i(`div`,{className:`flex flex-col gap-2 pl-2`,children:[r(_,{children:r(v,{className:`text-destructive`,children:l||`Error`})}),r(b,{className:`text-destructive`,children:T})]})]})}):o==null?r(`li`,{ref:D,"data-slot":`timeline-item`,"data-status":p,className:e(c(),a),"aria-current":p===`in-progress`?`step`:void 0,...E,children:i(`div`,{className:`grid grid-cols-[1fr_auto_1fr] items-start gap-4`,children:[r(`div`,{className:`flex flex-col justify-start pt-1`,children:r(h,{className:`pr-4 text-right`,children:s})}),i(`div`,{className:`flex flex-col items-center`,children:[r(`div`,{className:`relative z-10`,children:r(y,{icon:d,color:f??(p===`pending`?`muted`:`primary`),size:C})}),S&&r(g,{status:p,color:m,className:`mt-2 h-16`})]}),i(x,{children:[r(_,{children:r(v,{children:l})}),r(b,{children:u})]})]})}):r(`li`,{ref:D,"data-slot":`timeline-item`,"data-status":p,className:e(c(),a),"aria-current":p===`in-progress`?`step`:void 0,...E,children:o}));p.displayName=`TimelineItem`;const m={year:`numeric`,month:`short`,day:`2-digit`},h=o.forwardRef(({className:t,date:n,format:i,children:a,...s},c)=>{let l=o.useMemo(()=>getValidDate(n),[n]),u=o.useMemo(()=>l?new Intl.DateTimeFormat(`en-US`,{...m,...i}).format(l):``,[l,i]);return r(`time`,{ref:c,"data-slot":`timeline-time`,dateTime:l?.toISOString(),className:e(`text-sm font-medium tracking-tight text-muted-foreground`,t),...s,children:a||u})});h.displayName=`TimelineTime`;const g=o.forwardRef(({className:t,status:n=`completed`,color:i,...a},o)=>r(`div`,{ref:o,"data-slot":`timeline-connector`,"data-status":n,"data-color":i,className:e(l(i?{color:i}:{status:n}),t),...a}));g.displayName=`TimelineConnector`;const _=o.forwardRef(({className:t,...n},i)=>r(`div`,{ref:i,"data-slot":`timeline-header`,className:e(`flex items-center gap-4`,t),...n}));_.displayName=`TimelineHeader`;const v=o.forwardRef(({className:t,...n},i)=>r(`h3`,{ref:i,"data-slot":`timeline-title`,className:e(`font-semibold leading-none tracking-tight text-secondary-foreground`,t),...n}));v.displayName=`TimelineTitle`;const y=o.forwardRef(({className:t,color:n=`primary`,icon:i,size:a=`md`,...o},s)=>r(`div`,{ref:s,"data-slot":`timeline-icon`,"data-color":n,"data-size":a,className:e(u({color:n,size:a}),t),...o,children:i?r(`div`,{className:d({size:a}),children:i}):r(`div`,{className:e(`rounded-full`,d({size:a}))})}));y.displayName=`TimelineIcon`;const b=o.forwardRef(({className:t,...n},i)=>r(`p`,{ref:i,"data-slot":`timeline-description`,className:e(`max-w-sm text-sm text-muted-foreground`,t),...n}));b.displayName=`TimelineDescription`;const x=o.forwardRef(({className:t,...n},i)=>r(`div`,{ref:i,"data-slot":`timeline-content`,className:e(`flex flex-col gap-2 pl-2`,t),...n}));x.displayName=`TimelineContent`;const S=o.forwardRef(({className:t,children:n,...i},a)=>r(`div`,{ref:a,"data-slot":`timeline-empty`,className:e(`flex flex-col items-center justify-center p-8 text-center`,t),...i,children:r(`p`,{className:`text-sm text-muted-foreground`,children:n||`No timeline items to display`})}));S.displayName=`TimelineEmpty`;function getValidDate(e){if(e==null||e===``)return null;let t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?null:t}function isTimelineItemElement(e){return o.isValidElement(e)&&e.type===p}export{f as Timeline,g as TimelineConnector,x as TimelineContent,b as TimelineDescription,S as TimelineEmpty,_ as TimelineHeader,y as TimelineIcon,p as TimelineItem,h as TimelineTime,v as TimelineTitle,s as timelineVariants};
|
|
2
|
+
//# sourceMappingURL=timeline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeline.js","names":[],"sources":["../../src/components/timeline.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { IconAlertCircle } from '@tabler/icons-react'\nimport { cva, type VariantProps } from 'class-variance-authority'\n\nimport { cn } from '../lib/utils'\nimport { Spinner } from './spinner'\n\nconst timelineVariants = cva('relative mx-auto m-0 flex w-full max-w-2xl min-h-150 list-none flex-col p-0 py-8', {\n variants: {\n size: {\n sm: 'gap-4',\n md: 'gap-6',\n lg: 'gap-8'\n }\n },\n defaultVariants: {\n size: 'md'\n }\n})\n\nconst timelineItemVariants = cva('relative w-full last:mb-0', {\n variants: {\n tone: {\n default: 'mb-2',\n error: 'mb-2'\n }\n },\n defaultVariants: {\n tone: 'default'\n }\n})\n\nconst timelineConnectorVariants = cva('w-0.5', {\n variants: {\n status: {\n completed: 'bg-primary',\n 'in-progress': 'bg-accent',\n pending: 'bg-muted'\n },\n color: {\n primary: 'bg-primary',\n secondary: 'bg-secondary',\n muted: 'bg-muted',\n accent: 'bg-accent',\n destructive: 'bg-destructive',\n gradient: 'bg-linear-to-b from-primary to-muted'\n }\n }\n})\n\nconst timelineIconVariants = cva(\n 'relative flex items-center justify-center rounded-full ring-8 ring-background shadow-sm',\n {\n variants: {\n color: {\n primary: 'bg-primary text-primary-foreground',\n secondary: 'bg-secondary text-secondary-foreground',\n muted: 'bg-muted text-muted-foreground',\n accent: 'bg-accent text-accent-foreground',\n destructive: 'bg-destructive text-destructive-foreground'\n },\n size: {\n sm: 'h-8 w-8',\n md: 'h-10 w-10',\n lg: 'h-12 w-12'\n }\n },\n defaultVariants: {\n color: 'primary',\n size: 'md'\n }\n }\n)\n\nconst timelineIconContentVariants = cva('flex items-center justify-center', {\n variants: {\n size: {\n sm: 'h-4 w-4',\n md: 'h-5 w-5',\n lg: 'h-6 w-6'\n }\n },\n defaultVariants: {\n size: 'md'\n }\n})\n\nexport type TimelineIconSize = NonNullable<VariantProps<typeof timelineIconVariants>['size']>\nexport type TimelineConnectorColor = NonNullable<VariantProps<typeof timelineConnectorVariants>['color']>\nexport type TimelineIconColor = NonNullable<VariantProps<typeof timelineIconVariants>['color']>\nexport type TimelineStatus = NonNullable<VariantProps<typeof timelineConnectorVariants>['status']>\n\nexport type TimelineProps = React.ComponentProps<'ol'> &\n VariantProps<typeof timelineVariants> & {\n iconSize?: TimelineIconSize\n }\n\nconst Timeline = React.forwardRef<HTMLOListElement, TimelineProps>(\n ({ className, iconSize, size = 'md', children, ...props }, ref) => {\n const childArray = React.Children.toArray(children)\n const totalItems = childArray.filter(isTimelineItemElement).length\n\n if (totalItems === 0) {\n return (\n <ol\n ref={ref}\n aria-label=\"Timeline\"\n data-slot=\"timeline\"\n data-size={size}\n className={cn(timelineVariants({ size }), className)}\n {...props}\n >\n <li className=\"list-none\">\n <TimelineEmpty />\n </li>\n </ol>\n )\n }\n\n let itemIndex = 0\n\n return (\n <ol\n ref={ref}\n aria-label=\"Timeline\"\n data-slot=\"timeline\"\n data-size={size}\n className={cn(timelineVariants({ size }), className)}\n {...props}\n >\n {React.Children.map(children, (child) => {\n if (!isTimelineItemElement(child)) {\n return child\n }\n\n const isLastItem = itemIndex === totalItems - 1\n itemIndex += 1\n\n return React.cloneElement(child, {\n iconSize: child.props.iconSize ?? iconSize,\n showConnector: child.props.showConnector ?? !isLastItem\n })\n })}\n </ol>\n )\n }\n)\nTimeline.displayName = 'Timeline'\n\nexport type TimelineItemProps = React.ComponentProps<'li'> & {\n date?: React.ReactNode\n title?: React.ReactNode\n description?: React.ReactNode\n icon?: React.ReactNode\n iconColor?: TimelineIconColor\n status?: TimelineStatus\n connectorColor?: TimelineConnectorColor\n showConnector?: boolean\n iconSize?: TimelineIconSize\n loading?: boolean\n error?: React.ReactNode\n}\n\nconst TimelineItem = React.forwardRef<HTMLLIElement, TimelineItemProps>(\n (\n {\n className,\n children,\n date,\n title,\n description,\n icon,\n iconColor,\n status = 'completed',\n connectorColor,\n showConnector = true,\n iconSize,\n loading = false,\n error,\n ...props\n },\n ref\n ) => {\n if (loading) {\n return (\n <li\n ref={ref}\n aria-busy=\"true\"\n data-slot=\"timeline-item\"\n data-status={status}\n className={cn(timelineItemVariants(), className)}\n {...props}\n >\n <div className=\"grid grid-cols-[minmax(auto,8rem)_auto_1fr] items-start px-4\">\n <div className=\"pr-4 text-right\">\n <div className=\"h-4 w-24 animate-pulse rounded bg-muted\" />\n </div>\n\n <div className=\"mx-3 flex flex-col items-center justify-start gap-y-2\">\n <div className=\"relative flex h-8 w-8 animate-pulse items-center justify-center rounded-full bg-muted ring-8 ring-background\">\n <Spinner />\n </div>\n {showConnector && <div className=\"h-full w-0.5 animate-pulse bg-muted\" />}\n </div>\n\n <div className=\"flex flex-col gap-2 pl-2\">\n <div className=\"space-y-2\">\n <div className=\"h-4 w-24 animate-pulse rounded bg-muted\" />\n <div className=\"h-3 w-48 animate-pulse rounded bg-muted\" />\n </div>\n </div>\n </div>\n </li>\n )\n }\n\n if (error) {\n return (\n <li\n ref={ref}\n role=\"alert\"\n data-slot=\"timeline-item\"\n data-status=\"error\"\n className={cn(timelineItemVariants({ tone: 'error' }), className)}\n {...props}\n >\n <div className=\"grid grid-cols-[minmax(auto,8rem)_auto_1fr] items-start px-4\">\n <div className=\"pr-4 text-right\">\n <TimelineTime className=\"text-destructive\">{date}</TimelineTime>\n </div>\n\n <div className=\"mx-3 flex flex-col items-center justify-start gap-y-2\">\n <div className=\"relative flex h-8 w-8 items-center justify-center rounded-full bg-destructive/20 ring-8 ring-background\">\n <IconAlertCircle className=\"h-4 w-4 text-destructive\" />\n </div>\n {showConnector && <TimelineConnector color=\"destructive\" className=\"h-full\" />}\n </div>\n\n <div className=\"flex flex-col gap-2 pl-2\">\n <TimelineHeader>\n <TimelineTitle className=\"text-destructive\">{title || 'Error'}</TimelineTitle>\n </TimelineHeader>\n <TimelineDescription className=\"text-destructive\">{error}</TimelineDescription>\n </div>\n </div>\n </li>\n )\n }\n\n if (children != null) {\n return (\n <li\n ref={ref}\n data-slot=\"timeline-item\"\n data-status={status}\n className={cn(timelineItemVariants(), className)}\n aria-current={status === 'in-progress' ? 'step' : undefined}\n {...props}\n >\n {children}\n </li>\n )\n }\n\n return (\n <li\n ref={ref}\n data-slot=\"timeline-item\"\n data-status={status}\n className={cn(timelineItemVariants(), className)}\n aria-current={status === 'in-progress' ? 'step' : undefined}\n {...props}\n >\n <div className=\"grid grid-cols-[1fr_auto_1fr] items-start gap-4\">\n <div className=\"flex flex-col justify-start pt-1\">\n <TimelineTime className=\"pr-4 text-right\">{date}</TimelineTime>\n </div>\n\n <div className=\"flex flex-col items-center\">\n <div className=\"relative z-10\">\n <TimelineIcon\n icon={icon}\n color={iconColor ?? (status === 'pending' ? 'muted' : 'primary')}\n size={iconSize}\n />\n </div>\n {showConnector && <TimelineConnector status={status} color={connectorColor} className=\"mt-2 h-16\" />}\n </div>\n\n <TimelineContent>\n <TimelineHeader>\n <TimelineTitle>{title}</TimelineTitle>\n </TimelineHeader>\n <TimelineDescription>{description}</TimelineDescription>\n </TimelineContent>\n </div>\n </li>\n )\n }\n)\nTimelineItem.displayName = 'TimelineItem'\n\nexport type TimelineTimeProps = React.ComponentProps<'time'> & {\n date?: string | Date | number\n format?: Intl.DateTimeFormatOptions\n}\n\nconst defaultDateFormat: Intl.DateTimeFormatOptions = {\n year: 'numeric',\n month: 'short',\n day: '2-digit'\n}\n\nconst TimelineTime = React.forwardRef<HTMLTimeElement, TimelineTimeProps>(\n ({ className, date, format, children, ...props }, ref) => {\n const dateValue = React.useMemo(() => getValidDate(date), [date])\n\n const formattedDate = React.useMemo(() => {\n if (!dateValue) {\n return ''\n }\n\n return new Intl.DateTimeFormat('en-US', {\n ...defaultDateFormat,\n ...format\n }).format(dateValue)\n }, [dateValue, format])\n\n return (\n <time\n ref={ref}\n data-slot=\"timeline-time\"\n dateTime={dateValue?.toISOString()}\n className={cn('text-sm font-medium tracking-tight text-muted-foreground', className)}\n {...props}\n >\n {children || formattedDate}\n </time>\n )\n }\n)\nTimelineTime.displayName = 'TimelineTime'\n\nexport type TimelineConnectorProps = React.ComponentProps<'div'> & VariantProps<typeof timelineConnectorVariants>\n\nconst TimelineConnector = React.forwardRef<HTMLDivElement, TimelineConnectorProps>(\n ({ className, status = 'completed', color, ...props }, ref) => (\n <div\n ref={ref}\n data-slot=\"timeline-connector\"\n data-status={status}\n data-color={color}\n className={cn(color ? timelineConnectorVariants({ color }) : timelineConnectorVariants({ status }), className)}\n {...props}\n />\n )\n)\nTimelineConnector.displayName = 'TimelineConnector'\n\nexport type TimelineHeaderProps = React.ComponentProps<'div'>\n\nconst TimelineHeader = React.forwardRef<HTMLDivElement, TimelineHeaderProps>(({ className, ...props }, ref) => (\n <div ref={ref} data-slot=\"timeline-header\" className={cn('flex items-center gap-4', className)} {...props} />\n))\nTimelineHeader.displayName = 'TimelineHeader'\n\nexport type TimelineTitleProps = React.ComponentProps<'h3'>\n\nconst TimelineTitle = React.forwardRef<HTMLHeadingElement, TimelineTitleProps>(({ className, ...props }, ref) => (\n <h3\n ref={ref}\n data-slot=\"timeline-title\"\n className={cn('font-semibold leading-none tracking-tight text-secondary-foreground', className)}\n {...props}\n />\n))\nTimelineTitle.displayName = 'TimelineTitle'\n\nexport type TimelineIconProps = React.ComponentProps<'div'> &\n VariantProps<typeof timelineIconVariants> & {\n icon?: React.ReactNode\n }\n\nconst TimelineIcon = React.forwardRef<HTMLDivElement, TimelineIconProps>(\n ({ className, color = 'primary', icon, size = 'md', ...props }, ref) => (\n <div\n ref={ref}\n data-slot=\"timeline-icon\"\n data-color={color}\n data-size={size}\n className={cn(timelineIconVariants({ color, size }), className)}\n {...props}\n >\n {icon ? (\n <div className={timelineIconContentVariants({ size })}>{icon}</div>\n ) : (\n <div className={cn('rounded-full', timelineIconContentVariants({ size }))} />\n )}\n </div>\n )\n)\nTimelineIcon.displayName = 'TimelineIcon'\n\nexport type TimelineDescriptionProps = React.ComponentProps<'p'>\n\nconst TimelineDescription = React.forwardRef<HTMLParagraphElement, TimelineDescriptionProps>(\n ({ className, ...props }, ref) => (\n <p\n ref={ref}\n data-slot=\"timeline-description\"\n className={cn('max-w-sm text-sm text-muted-foreground', className)}\n {...props}\n />\n )\n)\nTimelineDescription.displayName = 'TimelineDescription'\n\nexport type TimelineContentProps = React.ComponentProps<'div'>\n\nconst TimelineContent = React.forwardRef<HTMLDivElement, TimelineContentProps>(({ className, ...props }, ref) => (\n <div ref={ref} data-slot=\"timeline-content\" className={cn('flex flex-col gap-2 pl-2', className)} {...props} />\n))\nTimelineContent.displayName = 'TimelineContent'\n\nexport type TimelineEmptyProps = React.ComponentProps<'div'>\n\nconst TimelineEmpty = React.forwardRef<HTMLDivElement, TimelineEmptyProps>(({ className, children, ...props }, ref) => (\n <div\n ref={ref}\n data-slot=\"timeline-empty\"\n className={cn('flex flex-col items-center justify-center p-8 text-center', className)}\n {...props}\n >\n <p className=\"text-sm text-muted-foreground\">{children || 'No timeline items to display'}</p>\n </div>\n))\nTimelineEmpty.displayName = 'TimelineEmpty'\n\nfunction getValidDate(date?: string | Date | number) {\n if (date == null || date === '') {\n return null\n }\n\n const parsedDate = date instanceof Date ? date : new Date(date)\n\n return Number.isNaN(parsedDate.getTime()) ? null : parsedDate\n}\n\nfunction isTimelineItemElement(child: React.ReactNode): child is React.ReactElement<TimelineItemProps> {\n return React.isValidElement(child) && child.type === TimelineItem\n}\n\nexport {\n Timeline,\n TimelineConnector,\n TimelineContent,\n TimelineDescription,\n TimelineEmpty,\n TimelineHeader,\n TimelineIcon,\n TimelineItem,\n TimelineTime,\n TimelineTitle,\n timelineVariants\n}\n"],"mappings":"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"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as __name } from "../chunk-CHh1Zzun.js";
|
|
2
2
|
import { toggleVariants } from "./toggle.js";
|
|
3
3
|
import { ToggleGroup as ToggleGroup$1 } from "radix-ui";
|
|
4
|
-
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
4
|
+
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
5
5
|
import { VariantProps } from "class-variance-authority";
|
|
6
6
|
import * as React from "react";
|
|
7
7
|
|
|
@@ -19,14 +19,14 @@ declare function ToggleGroup({
|
|
|
19
19
|
orientation,
|
|
20
20
|
children,
|
|
21
21
|
...props
|
|
22
|
-
}: ToggleGroupProps): react_jsx_runtime0.JSX.Element;
|
|
22
|
+
}: ToggleGroupProps): _$react_jsx_runtime0.JSX.Element;
|
|
23
23
|
declare function ToggleGroupItem({
|
|
24
24
|
className,
|
|
25
25
|
children,
|
|
26
26
|
variant,
|
|
27
27
|
size,
|
|
28
28
|
...props
|
|
29
|
-
}: ToggleGroupItemProps): react_jsx_runtime0.JSX.Element;
|
|
29
|
+
}: ToggleGroupItemProps): _$react_jsx_runtime0.JSX.Element;
|
|
30
30
|
//#endregion
|
|
31
31
|
export { ToggleGroup, ToggleGroupItem, ToggleGroupItemProps, ToggleGroupProps };
|
|
32
32
|
//# sourceMappingURL=toggle-group.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../chunk-
|
|
1
|
+
import"../chunk-CHh1Zzun.js";import{cn as e}from"../lib/utils.js";import{toggleVariants as t}from"./toggle.js";import{ToggleGroup as n}from"radix-ui";import{jsx as r}from"react/jsx-runtime";import*as i from"react";const a=i.createContext({size:`default`,variant:`default`,spacing:0,orientation:`horizontal`});function ToggleGroup({className:t,variant:i,size:o,spacing:s=0,orientation:c=`horizontal`,children:l,...u}){return r(n.Root,{"data-slot":`toggle-group`,"data-variant":i,"data-size":o,"data-spacing":s,"data-orientation":c,style:{"--gap":s},className:e(`group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] rounded-lg data-[size=sm]:rounded-[min(var(--radius-md),10px)] data-vertical:flex-col data-vertical:items-stretch`,t),...u,children:r(a.Provider,{value:{variant:i,size:o,spacing:s,orientation:c},children:l})})}function ToggleGroupItem({className:o,children:s,variant:c=`default`,size:l=`default`,...u}){let d=i.useContext(a);return r(n.Item,{"data-slot":`toggle-group-item`,"data-variant":d.variant||c,"data-size":d.size||l,"data-spacing":d.spacing,className:e(`shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 focus:z-10 focus-visible:z-10 group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-l-lg group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-lg group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-r-lg group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-b-lg group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t`,t({variant:d.variant||c,size:d.size||l}),o),...u,children:s})}export{ToggleGroup,ToggleGroupItem};
|
|
2
2
|
//# sourceMappingURL=toggle-group.js.map
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as __name } from "../chunk-CHh1Zzun.js";
|
|
2
2
|
import { Toggle as Toggle$1 } from "radix-ui";
|
|
3
|
-
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
|
+
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
4
4
|
import { VariantProps } from "class-variance-authority";
|
|
5
5
|
import * as React from "react";
|
|
6
|
-
import * as class_variance_authority_types0 from "class-variance-authority/types";
|
|
6
|
+
import * as _$class_variance_authority_types0 from "class-variance-authority/types";
|
|
7
7
|
|
|
8
8
|
//#region src/components/toggle.d.ts
|
|
9
9
|
declare const toggleVariants: (props?: ({
|
|
10
10
|
variant?: "default" | "outline" | null | undefined;
|
|
11
|
-
size?: "
|
|
12
|
-
} & class_variance_authority_types0.ClassProp) | undefined) => string;
|
|
11
|
+
size?: "default" | "sm" | "lg" | null | undefined;
|
|
12
|
+
} & _$class_variance_authority_types0.ClassProp) | undefined) => string;
|
|
13
13
|
type ToggleProps = React.ComponentProps<typeof Toggle$1.Root> & VariantProps<typeof toggleVariants>;
|
|
14
14
|
declare function Toggle({
|
|
15
15
|
className,
|
|
16
16
|
variant,
|
|
17
17
|
size,
|
|
18
18
|
...props
|
|
19
|
-
}: ToggleProps): react_jsx_runtime0.JSX.Element;
|
|
19
|
+
}: ToggleProps): _$react_jsx_runtime0.JSX.Element;
|
|
20
20
|
//#endregion
|
|
21
21
|
export { Toggle, ToggleProps, toggleVariants };
|
|
22
22
|
//# sourceMappingURL=toggle.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../chunk-
|
|
1
|
+
import"../chunk-CHh1Zzun.js";import{cn as e}from"../lib/utils.js";import{Toggle as t}from"radix-ui";import{jsx as n}from"react/jsx-runtime";import{cva as r}from"class-variance-authority";const i=r(`group/toggle inline-flex items-center justify-center gap-1 rounded-lg text-sm font-medium whitespace-nowrap transition-all outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-muted data-[state=on]:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`bg-transparent`,outline:`border border-input bg-transparent hover:bg-muted`},size:{default:`h-8 min-w-8 px-2`,sm:`h-7 min-w-7 rounded-[min(var(--radius-md),12px)] px-1.5 text-[0.8rem]`,lg:`h-9 min-w-9 px-2.5`}},defaultVariants:{variant:`default`,size:`default`}});function Toggle({className:r,variant:a=`default`,size:o=`default`,...s}){return n(t.Root,{"data-slot":`toggle`,className:e(i({variant:a,size:o,className:r})),...s})}export{Toggle,i as toggleVariants};
|
|
2
2
|
//# sourceMappingURL=toggle.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as __name } from "../chunk-CHh1Zzun.js";
|
|
2
2
|
import { Tooltip as Tooltip$1 } from "radix-ui";
|
|
3
|
-
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
|
+
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
4
4
|
import * as React from "react";
|
|
5
5
|
|
|
6
6
|
//#region src/components/tooltip.d.ts
|
|
@@ -11,19 +11,19 @@ type TooltipContentProps = React.ComponentProps<typeof Tooltip$1.Content>;
|
|
|
11
11
|
declare function TooltipProvider({
|
|
12
12
|
delayDuration,
|
|
13
13
|
...props
|
|
14
|
-
}: TooltipProviderProps): react_jsx_runtime0.JSX.Element;
|
|
14
|
+
}: TooltipProviderProps): _$react_jsx_runtime0.JSX.Element;
|
|
15
15
|
declare function Tooltip({
|
|
16
16
|
...props
|
|
17
|
-
}: TooltipProps): react_jsx_runtime0.JSX.Element;
|
|
17
|
+
}: TooltipProps): _$react_jsx_runtime0.JSX.Element;
|
|
18
18
|
declare function TooltipTrigger({
|
|
19
19
|
...props
|
|
20
|
-
}: TooltipTriggerProps): react_jsx_runtime0.JSX.Element;
|
|
20
|
+
}: TooltipTriggerProps): _$react_jsx_runtime0.JSX.Element;
|
|
21
21
|
declare function TooltipContent({
|
|
22
22
|
className,
|
|
23
23
|
sideOffset,
|
|
24
24
|
children,
|
|
25
25
|
...props
|
|
26
|
-
}: TooltipContentProps): react_jsx_runtime0.JSX.Element;
|
|
26
|
+
}: TooltipContentProps): _$react_jsx_runtime0.JSX.Element;
|
|
27
27
|
//#endregion
|
|
28
28
|
export { Tooltip, TooltipContent, TooltipContentProps, TooltipProps, TooltipProvider, TooltipProviderProps, TooltipTrigger, TooltipTriggerProps };
|
|
29
29
|
//# sourceMappingURL=tooltip.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../chunk-
|
|
1
|
+
import"../chunk-CHh1Zzun.js";import{cn as e}from"../lib/utils.js";import{Tooltip as t}from"radix-ui";import{jsx as n,jsxs as r}from"react/jsx-runtime";function TooltipProvider({delayDuration:e=0,...r}){return n(t.Provider,{"data-slot":`tooltip-provider`,delayDuration:e,...r})}function Tooltip({...e}){return n(t.Root,{"data-slot":`tooltip`,...e})}function TooltipTrigger({...e}){return n(t.Trigger,{"data-slot":`tooltip-trigger`,...e})}function TooltipContent({className:i,sideOffset:a=0,children:o,...s}){return n(t.Portal,{children:r(t.Content,{"data-slot":`tooltip-content`,sideOffset:a,className:e(`bg-foreground text-background z-50 w-fit max-w-xs rounded-md px-3 py-1.5 text-xs origin-(--radix-tooltip-content-transform-origin)`,`data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95`,`data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,`data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,i),...s,children:[o,n(t.Arrow,{className:`size-2.5 rotate-45 rounded-[2px] bg-foreground fill-foreground z-50 translate-y-[calc(-50%-2px)]`})]})})}export{Tooltip,TooltipContent,TooltipProvider,TooltipTrigger};
|
|
2
2
|
//# sourceMappingURL=tooltip.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { n as __name } from "../chunk-CHh1Zzun.js";
|
|
2
|
+
|
|
3
|
+
//#region src/hooks/use-disclosure.d.ts
|
|
4
|
+
type UseDisclosureOptions = {
|
|
5
|
+
onOpen?: () => void;
|
|
6
|
+
onClose?: () => void;
|
|
7
|
+
};
|
|
8
|
+
type UseDisclosureHandlers = {
|
|
9
|
+
set: (value: boolean) => void;
|
|
10
|
+
open: () => void;
|
|
11
|
+
close: () => void;
|
|
12
|
+
toggle: () => void;
|
|
13
|
+
};
|
|
14
|
+
type UseDisclosureReturnValue = [boolean, UseDisclosureHandlers];
|
|
15
|
+
declare function useDisclosure(initialState?: boolean, options?: UseDisclosureOptions): UseDisclosureReturnValue;
|
|
16
|
+
declare namespace useDisclosure {
|
|
17
|
+
type Options = UseDisclosureOptions;
|
|
18
|
+
type Handlers = UseDisclosureHandlers;
|
|
19
|
+
type ReturnValue = UseDisclosureReturnValue;
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { UseDisclosureHandlers, UseDisclosureOptions, UseDisclosureReturnValue, useDisclosure };
|
|
23
|
+
//# sourceMappingURL=use-disclosure.d.ts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"../chunk-CHh1Zzun.js";import{useCallback as e,useState as t}from"react";function useDisclosure(n=!1,r={}){let[i,a]=t(n),o=e(()=>{a(e=>e||(r.onOpen?.(),!0))},[r.onOpen]),s=e(()=>{a(e=>e&&(r.onClose?.(),!1))},[r.onClose]);return[i,{open:o,close:s,toggle:e(()=>{i?s():o()},[s,o,i]),set:a}]}export{useDisclosure};
|
|
2
|
+
//# sourceMappingURL=use-disclosure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-disclosure.js","names":[],"sources":["../../src/hooks/use-disclosure.ts"],"sourcesContent":["import { useCallback, useState } from 'react'\n\nexport type UseDisclosureOptions = {\n onOpen?: () => void\n onClose?: () => void\n}\n\nexport type UseDisclosureHandlers = {\n set: (value: boolean) => void\n open: () => void\n close: () => void\n toggle: () => void\n}\n\nexport type UseDisclosureReturnValue = [boolean, UseDisclosureHandlers]\n\nexport function useDisclosure(initialState = false, options: UseDisclosureOptions = {}): UseDisclosureReturnValue {\n const [opened, setOpened] = useState(initialState)\n\n const open = useCallback(() => {\n setOpened((isOpened) => {\n if (!isOpened) {\n options.onOpen?.()\n return true\n }\n return isOpened\n })\n }, [options.onOpen])\n\n const close = useCallback(() => {\n setOpened((isOpened) => {\n if (isOpened) {\n options.onClose?.()\n return false\n }\n return isOpened\n })\n }, [options.onClose])\n\n const toggle = useCallback(() => {\n opened ? close() : open()\n }, [close, open, opened])\n\n return [opened, { open, close, toggle, set: setOpened }]\n}\n\nexport namespace useDisclosure {\n export type Options = UseDisclosureOptions\n export type Handlers = UseDisclosureHandlers\n export type ReturnValue = UseDisclosureReturnValue\n}\n"],"mappings":"+EAgBA,SAAgB,cAAc,EAAe,GAAO,EAAgC,EAAE,CAA4B,CAChH,GAAM,CAAC,EAAQ,GAAa,EAAS,EAAa,CAE5C,EAAO,MAAkB,CAC7B,EAAW,GACJ,IACH,EAAQ,UAAU,CACX,IAGT,EACD,CAAC,EAAQ,OAAO,CAAC,CAEd,EAAQ,MAAkB,CAC9B,EAAW,GACL,IACF,EAAQ,WAAW,CACZ,IAGT,EACD,CAAC,EAAQ,QAAQ,CAAC,CAMrB,MAAO,CAAC,EAAQ,CAAE,OAAM,QAAO,OAJhB,MAAkB,CAC/B,EAAS,GAAO,CAAG,GAAM,EACxB,CAAC,EAAO,EAAM,EAAO,CAEa,CAAE,IAAK,EAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"../chunk-CHh1Zzun.js";import{useDisclosure as e}from"./use-disclosure.js";import{n as t,t as n}from"../react.esm-BuxkFT_p.js";describe(`useDisclosure`,()=>{it(`uses false as the default initial state`,()=>{let{result:n}=t(()=>e());expect(n.current[0]).toBe(!1)}),it(`uses the provided initial state`,()=>{let{result:n}=t(()=>e(!0));expect(n.current[0]).toBe(!0)}),it(`opens, closes, toggles, and sets the state`,()=>{let{result:r}=t(()=>e());n(()=>r.current[1].open()),expect(r.current[0]).toBe(!0),n(()=>r.current[1].close()),expect(r.current[0]).toBe(!1),n(()=>r.current[1].toggle()),expect(r.current[0]).toBe(!0),n(()=>r.current[1].set(!1)),expect(r.current[0]).toBe(!1)}),it(`calls callbacks only when state transitions happen`,()=>{let r=vi.fn(),i=vi.fn(),{result:a}=t(()=>e(!1,{onOpen:r,onClose:i}));n(()=>a.current[1].close()),expect(i).not.toHaveBeenCalled(),n(()=>a.current[1].open()),n(()=>a.current[1].open()),expect(r).toHaveBeenCalledTimes(1),n(()=>a.current[1].close()),n(()=>a.current[1].close()),expect(i).toHaveBeenCalledTimes(1)})});
|
|
2
|
+
//# sourceMappingURL=use-disclosure.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-disclosure.spec.js","names":[],"sources":["../../src/hooks/use-disclosure.spec.ts"],"sourcesContent":["import { act, renderHook } from '@testing-library/react'\n\nimport { useDisclosure } from './use-disclosure'\n\ndescribe('useDisclosure', () => {\n it('uses false as the default initial state', () => {\n const { result } = renderHook(() => useDisclosure())\n\n expect(result.current[0]).toBe(false)\n })\n\n it('uses the provided initial state', () => {\n const { result } = renderHook(() => useDisclosure(true))\n\n expect(result.current[0]).toBe(true)\n })\n\n it('opens, closes, toggles, and sets the state', () => {\n const { result } = renderHook(() => useDisclosure())\n\n act(() => result.current[1].open())\n expect(result.current[0]).toBe(true)\n\n act(() => result.current[1].close())\n expect(result.current[0]).toBe(false)\n\n act(() => result.current[1].toggle())\n expect(result.current[0]).toBe(true)\n\n act(() => result.current[1].set(false))\n expect(result.current[0]).toBe(false)\n })\n\n it('calls callbacks only when state transitions happen', () => {\n const onOpen = vi.fn()\n const onClose = vi.fn()\n const { result } = renderHook(() => useDisclosure(false, { onOpen, onClose }))\n\n act(() => result.current[1].close())\n expect(onClose).not.toHaveBeenCalled()\n\n act(() => result.current[1].open())\n act(() => result.current[1].open())\n expect(onOpen).toHaveBeenCalledTimes(1)\n\n act(() => result.current[1].close())\n act(() => result.current[1].close())\n expect(onClose).toHaveBeenCalledTimes(1)\n })\n})\n"],"mappings":"qIAIA,SAAS,oBAAuB,CAC9B,GAAG,8CAAiD,CAClD,GAAM,CAAE,UAAW,MAAiB,GAAe,CAAC,CAEpD,OAAO,EAAO,QAAQ,GAAG,CAAC,KAAK,GAAM,EACrC,CAEF,GAAG,sCAAyC,CAC1C,GAAM,CAAE,UAAW,MAAiB,EAAc,GAAK,CAAC,CAExD,OAAO,EAAO,QAAQ,GAAG,CAAC,KAAK,GAAK,EACpC,CAEF,GAAG,iDAAoD,CACrD,GAAM,CAAE,UAAW,MAAiB,GAAe,CAAC,CAEpD,MAAU,EAAO,QAAQ,GAAG,MAAM,CAAC,CACnC,OAAO,EAAO,QAAQ,GAAG,CAAC,KAAK,GAAK,CAEpC,MAAU,EAAO,QAAQ,GAAG,OAAO,CAAC,CACpC,OAAO,EAAO,QAAQ,GAAG,CAAC,KAAK,GAAM,CAErC,MAAU,EAAO,QAAQ,GAAG,QAAQ,CAAC,CACrC,OAAO,EAAO,QAAQ,GAAG,CAAC,KAAK,GAAK,CAEpC,MAAU,EAAO,QAAQ,GAAG,IAAI,GAAM,CAAC,CACvC,OAAO,EAAO,QAAQ,GAAG,CAAC,KAAK,GAAM,EACrC,CAEF,GAAG,yDAA4D,CAC7D,IAAM,EAAS,GAAG,IAAI,CAChB,EAAU,GAAG,IAAI,CACjB,CAAE,UAAW,MAAiB,EAAc,GAAO,CAAE,SAAQ,UAAS,CAAC,CAAC,CAE9E,MAAU,EAAO,QAAQ,GAAG,OAAO,CAAC,CACpC,OAAO,EAAQ,CAAC,IAAI,kBAAkB,CAEtC,MAAU,EAAO,QAAQ,GAAG,MAAM,CAAC,CACnC,MAAU,EAAO,QAAQ,GAAG,MAAM,CAAC,CACnC,OAAO,EAAO,CAAC,sBAAsB,EAAE,CAEvC,MAAU,EAAO,QAAQ,GAAG,OAAO,CAAC,CACpC,MAAU,EAAO,QAAQ,GAAG,OAAO,CAAC,CACpC,OAAO,EAAQ,CAAC,sBAAsB,EAAE,EACxC,EACF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { n as __name } from "../chunk-CHh1Zzun.js";
|
|
2
|
+
|
|
3
|
+
//#region src/hooks/use-document-visibility.d.ts
|
|
4
|
+
declare function useDocumentVisibility(): DocumentVisibilityState;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { useDocumentVisibility };
|
|
7
|
+
//# sourceMappingURL=use-document-visibility.d.ts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"../chunk-CHh1Zzun.js";import{useEffect as e,useState as t}from"react";function useDocumentVisibility(){let[n,r]=t(`visible`);return e(()=>{r(document.visibilityState);let listener=()=>r(document.visibilityState);return document.addEventListener(`visibilitychange`,listener),()=>document.removeEventListener(`visibilitychange`,listener)},[]),n}export{useDocumentVisibility};
|
|
2
|
+
//# sourceMappingURL=use-document-visibility.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-document-visibility.js","names":[],"sources":["../../src/hooks/use-document-visibility.ts"],"sourcesContent":["import { useEffect, useState } from 'react'\n\nexport function useDocumentVisibility(): DocumentVisibilityState {\n const [documentVisibility, setDocumentVisibility] = useState<DocumentVisibilityState>('visible')\n\n useEffect(() => {\n setDocumentVisibility(document.visibilityState)\n const listener = () => setDocumentVisibility(document.visibilityState)\n document.addEventListener('visibilitychange', listener)\n return () => document.removeEventListener('visibilitychange', listener)\n }, [])\n\n return documentVisibility\n}\n"],"mappings":"6EAEA,SAAgB,uBAAiD,CAC/D,GAAM,CAAC,EAAoB,GAAyB,EAAkC,UAAU,CAShG,OAPA,MAAgB,CACd,EAAsB,SAAS,gBAAgB,CAC/C,IAAM,aAAiB,EAAsB,SAAS,gBAAgB,CAEtE,OADA,SAAS,iBAAiB,mBAAoB,SAAS,KAC1C,SAAS,oBAAoB,mBAAoB,SAAS,EACtE,EAAE,CAAC,CAEC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"../chunk-CHh1Zzun.js";import{useDocumentVisibility as e}from"./use-document-visibility.js";import{n as t,t as n}from"../react.esm-BuxkFT_p.js";function setDocumentVisibility(e){Object.defineProperty(document,`visibilityState`,{configurable:!0,get:()=>e})}describe(`useDocumentVisibility`,()=>{it(`uses the current document visibility on mount`,()=>{setDocumentVisibility(`hidden`);let{result:n}=t(()=>e());expect(n.current).toBe(`hidden`)}),it(`updates when the document visibility changes`,()=>{setDocumentVisibility(`visible`);let{result:r}=t(()=>e());n(()=>{setDocumentVisibility(`hidden`),document.dispatchEvent(new Event(`visibilitychange`))}),expect(r.current).toBe(`hidden`)}),it(`removes the visibility listener on unmount`,()=>{let n=vi.spyOn(document,`removeEventListener`),{unmount:r}=t(()=>e());r(),expect(n).toHaveBeenCalledWith(`visibilitychange`,expect.any(Function))})});
|
|
2
|
+
//# sourceMappingURL=use-document-visibility.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-document-visibility.spec.js","names":[],"sources":["../../src/hooks/use-document-visibility.spec.ts"],"sourcesContent":["import { act, renderHook } from '@testing-library/react'\n\nimport { useDocumentVisibility } from './use-document-visibility'\n\nfunction setDocumentVisibility(visibilityState: DocumentVisibilityState) {\n Object.defineProperty(document, 'visibilityState', {\n configurable: true,\n get: () => visibilityState\n })\n}\n\ndescribe('useDocumentVisibility', () => {\n it('uses the current document visibility on mount', () => {\n setDocumentVisibility('hidden')\n\n const { result } = renderHook(() => useDocumentVisibility())\n\n expect(result.current).toBe('hidden')\n })\n\n it('updates when the document visibility changes', () => {\n setDocumentVisibility('visible')\n const { result } = renderHook(() => useDocumentVisibility())\n\n act(() => {\n setDocumentVisibility('hidden')\n document.dispatchEvent(new Event('visibilitychange'))\n })\n\n expect(result.current).toBe('hidden')\n })\n\n it('removes the visibility listener on unmount', () => {\n const removeEventListener = vi.spyOn(document, 'removeEventListener')\n const { unmount } = renderHook(() => useDocumentVisibility())\n\n unmount()\n\n expect(removeEventListener).toHaveBeenCalledWith('visibilitychange', expect.any(Function))\n })\n})\n"],"mappings":"sJAIA,SAAS,sBAAsB,EAA0C,CACvE,OAAO,eAAe,SAAU,kBAAmB,CACjD,aAAc,GACd,QAAW,EACZ,CAAC,CAGJ,SAAS,4BAA+B,CACtC,GAAG,oDAAuD,CACxD,sBAAsB,SAAS,CAE/B,GAAM,CAAE,UAAW,MAAiB,GAAuB,CAAC,CAE5D,OAAO,EAAO,QAAQ,CAAC,KAAK,SAAS,EACrC,CAEF,GAAG,mDAAsD,CACvD,sBAAsB,UAAU,CAChC,GAAM,CAAE,UAAW,MAAiB,GAAuB,CAAC,CAE5D,MAAU,CACR,sBAAsB,SAAS,CAC/B,SAAS,cAAc,IAAI,MAAM,mBAAmB,CAAC,EACrD,CAEF,OAAO,EAAO,QAAQ,CAAC,KAAK,SAAS,EACrC,CAEF,GAAG,iDAAoD,CACrD,IAAM,EAAsB,GAAG,MAAM,SAAU,sBAAsB,CAC/D,CAAE,WAAY,MAAiB,GAAuB,CAAC,CAE7D,GAAS,CAET,OAAO,EAAoB,CAAC,qBAAqB,mBAAoB,OAAO,IAAI,SAAS,CAAC,EAC1F,EACF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { n as __name } from "../chunk-CHh1Zzun.js";
|
|
2
|
+
|
|
3
|
+
//#region src/hooks/use-idle.d.ts
|
|
4
|
+
type UseIdleOptions = {
|
|
5
|
+
events?: (keyof DocumentEventMap)[];
|
|
6
|
+
initialState?: boolean;
|
|
7
|
+
};
|
|
8
|
+
declare function useIdle(timeout: number, options?: UseIdleOptions): boolean;
|
|
9
|
+
declare namespace useIdle {
|
|
10
|
+
type Options = UseIdleOptions;
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { UseIdleOptions, useIdle };
|
|
14
|
+
//# sourceMappingURL=use-idle.d.ts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"../chunk-CHh1Zzun.js";import{useEffect as e,useRef as t,useState as n}from"react";const r={events:[`keydown`,`mousemove`,`touchmove`,`click`,`scroll`,`wheel`],initialState:!0};function useIdle(i,a){let{events:o,initialState:s}={...r,...a},[c,l]=n(s),u=t(-1);return e(()=>{let handleEvents=()=>{l(!1),u.current&&window.clearTimeout(u.current),u.current=window.setTimeout(()=>{l(!0)},i)};for(let e of o)document.addEventListener(e,handleEvents);return u.current=window.setTimeout(()=>{l(!0)},i),()=>{for(let e of o)document.removeEventListener(e,handleEvents);window.clearTimeout(u.current),u.current=-1}},[i]),c}export{useIdle};
|
|
2
|
+
//# sourceMappingURL=use-idle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-idle.js","names":[],"sources":["../../src/hooks/use-idle.ts"],"sourcesContent":["import { useEffect, useRef, useState } from 'react'\n\nexport type UseIdleOptions = {\n events?: (keyof DocumentEventMap)[]\n initialState?: boolean\n}\n\nconst DEFAULT_OPTIONS: Required<UseIdleOptions> = {\n events: ['keydown', 'mousemove', 'touchmove', 'click', 'scroll', 'wheel'],\n initialState: true\n}\n\nexport function useIdle(timeout: number, options?: UseIdleOptions) {\n const { events, initialState } = { ...DEFAULT_OPTIONS, ...options }\n const [idle, setIdle] = useState(initialState)\n const timer = useRef(-1)\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: should not re-execute the effect when `events` changes\n useEffect(() => {\n const handleEvents = () => {\n setIdle(false)\n\n if (timer.current) {\n window.clearTimeout(timer.current)\n }\n\n timer.current = window.setTimeout(() => {\n setIdle(true)\n }, timeout)\n }\n\n for (const event of events) {\n document.addEventListener(event, handleEvents)\n }\n\n // Start the timer immediately instead of waiting for the first event to happen\n timer.current = window.setTimeout(() => {\n setIdle(true)\n }, timeout)\n\n return () => {\n for (const event of events) {\n document.removeEventListener(event, handleEvents)\n }\n\n window.clearTimeout(timer.current)\n timer.current = -1\n }\n }, [timeout])\n\n return idle\n}\n\nexport namespace useIdle {\n export type Options = UseIdleOptions\n}\n"],"mappings":"yFAOA,MAAM,EAA4C,CAChD,OAAQ,CAAC,UAAW,YAAa,YAAa,QAAS,SAAU,QAAQ,CACzE,aAAc,GACf,CAED,SAAgB,QAAQ,EAAiB,EAA0B,CACjE,GAAM,CAAE,SAAQ,gBAAiB,CAAE,GAAG,EAAiB,GAAG,EAAS,CAC7D,CAAC,EAAM,GAAW,EAAS,EAAa,CACxC,EAAQ,EAAO,GAAG,CAmCxB,OAhCA,MAAgB,CACd,IAAM,iBAAqB,CACzB,EAAQ,GAAM,CAEV,EAAM,SACR,OAAO,aAAa,EAAM,QAAQ,CAGpC,EAAM,QAAU,OAAO,eAAiB,CACtC,EAAQ,GAAK,EACZ,EAAQ,EAGb,IAAK,IAAM,KAAS,EAClB,SAAS,iBAAiB,EAAO,aAAa,CAQhD,MAJA,GAAM,QAAU,OAAO,eAAiB,CACtC,EAAQ,GAAK,EACZ,EAAQ,KAEE,CACX,IAAK,IAAM,KAAS,EAClB,SAAS,oBAAoB,EAAO,aAAa,CAGnD,OAAO,aAAa,EAAM,QAAQ,CAClC,EAAM,QAAU,KAEjB,CAAC,EAAQ,CAAC,CAEN"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"../chunk-CHh1Zzun.js";import{useIdle as e}from"./use-idle.js";import{n as t,t as n}from"../react.esm-BuxkFT_p.js";describe(`useIdle`,()=>{it(`starts idle by default`,()=>{vi.useFakeTimers();let{result:n}=t(()=>e(1e3));expect(n.current).toBe(!0)}),it(`supports a custom initial state and becomes idle after the timeout`,()=>{vi.useFakeTimers();let{result:r}=t(()=>e(1e3,{initialState:!1}));expect(r.current).toBe(!1),n(()=>{vi.advanceTimersByTime(1e3)}),expect(r.current).toBe(!0)}),it(`becomes active on configured events and returns to idle after the timeout`,()=>{vi.useFakeTimers();let{result:r}=t(()=>e(1e3,{events:[`click`]}));n(()=>{document.dispatchEvent(new Event(`click`))}),expect(r.current).toBe(!1),n(()=>{vi.advanceTimersByTime(999)}),expect(r.current).toBe(!1),n(()=>{vi.advanceTimersByTime(1)}),expect(r.current).toBe(!0)}),it(`registers and removes only the configured event listeners`,()=>{vi.useFakeTimers();let n=vi.spyOn(document,`addEventListener`),r=vi.spyOn(document,`removeEventListener`),{unmount:i}=t(()=>e(1e3,{events:[`click`,`keydown`]}));expect(n).toHaveBeenCalledWith(`click`,expect.any(Function)),expect(n).toHaveBeenCalledWith(`keydown`,expect.any(Function)),expect(n).not.toHaveBeenCalledWith(`mousemove`,expect.any(Function)),i(),expect(r).toHaveBeenCalledWith(`click`,expect.any(Function)),expect(r).toHaveBeenCalledWith(`keydown`,expect.any(Function))}),it(`clears pending timers on unmount`,()=>{vi.useFakeTimers();let n=vi.spyOn(window,`clearTimeout`),{unmount:r}=t(()=>e(1e3));r(),expect(n).toHaveBeenCalled()})});
|
|
2
|
+
//# sourceMappingURL=use-idle.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-idle.spec.js","names":[],"sources":["../../src/hooks/use-idle.spec.ts"],"sourcesContent":["import { act, renderHook } from '@testing-library/react'\n\nimport { useIdle } from './use-idle'\n\ndescribe('useIdle', () => {\n it('starts idle by default', () => {\n vi.useFakeTimers()\n\n const { result } = renderHook(() => useIdle(1000))\n\n expect(result.current).toBe(true)\n })\n\n it('supports a custom initial state and becomes idle after the timeout', () => {\n vi.useFakeTimers()\n\n const { result } = renderHook(() => useIdle(1000, { initialState: false }))\n\n expect(result.current).toBe(false)\n\n act(() => {\n vi.advanceTimersByTime(1000)\n })\n\n expect(result.current).toBe(true)\n })\n\n it('becomes active on configured events and returns to idle after the timeout', () => {\n vi.useFakeTimers()\n\n const { result } = renderHook(() => useIdle(1000, { events: ['click'] }))\n\n act(() => {\n document.dispatchEvent(new Event('click'))\n })\n\n expect(result.current).toBe(false)\n\n act(() => {\n vi.advanceTimersByTime(999)\n })\n\n expect(result.current).toBe(false)\n\n act(() => {\n vi.advanceTimersByTime(1)\n })\n\n expect(result.current).toBe(true)\n })\n\n it('registers and removes only the configured event listeners', () => {\n vi.useFakeTimers()\n const addEventListener = vi.spyOn(document, 'addEventListener')\n const removeEventListener = vi.spyOn(document, 'removeEventListener')\n\n const { unmount } = renderHook(() => useIdle(1000, { events: ['click', 'keydown'] }))\n\n expect(addEventListener).toHaveBeenCalledWith('click', expect.any(Function))\n expect(addEventListener).toHaveBeenCalledWith('keydown', expect.any(Function))\n expect(addEventListener).not.toHaveBeenCalledWith('mousemove', expect.any(Function))\n\n unmount()\n\n expect(removeEventListener).toHaveBeenCalledWith('click', expect.any(Function))\n expect(removeEventListener).toHaveBeenCalledWith('keydown', expect.any(Function))\n })\n\n it('clears pending timers on unmount', () => {\n vi.useFakeTimers()\n const clearTimeout = vi.spyOn(window, 'clearTimeout')\n const { unmount } = renderHook(() => useIdle(1000))\n\n unmount()\n\n expect(clearTimeout).toHaveBeenCalled()\n })\n})\n"],"mappings":"yHAIA,SAAS,cAAiB,CACxB,GAAG,6BAAgC,CACjC,GAAG,eAAe,CAElB,GAAM,CAAE,UAAW,MAAiB,EAAQ,IAAK,CAAC,CAElD,OAAO,EAAO,QAAQ,CAAC,KAAK,GAAK,EACjC,CAEF,GAAG,yEAA4E,CAC7E,GAAG,eAAe,CAElB,GAAM,CAAE,UAAW,MAAiB,EAAQ,IAAM,CAAE,aAAc,GAAO,CAAC,CAAC,CAE3E,OAAO,EAAO,QAAQ,CAAC,KAAK,GAAM,CAElC,MAAU,CACR,GAAG,oBAAoB,IAAK,EAC5B,CAEF,OAAO,EAAO,QAAQ,CAAC,KAAK,GAAK,EACjC,CAEF,GAAG,gFAAmF,CACpF,GAAG,eAAe,CAElB,GAAM,CAAE,UAAW,MAAiB,EAAQ,IAAM,CAAE,OAAQ,CAAC,QAAQ,CAAE,CAAC,CAAC,CAEzE,MAAU,CACR,SAAS,cAAc,IAAI,MAAM,QAAQ,CAAC,EAC1C,CAEF,OAAO,EAAO,QAAQ,CAAC,KAAK,GAAM,CAElC,MAAU,CACR,GAAG,oBAAoB,IAAI,EAC3B,CAEF,OAAO,EAAO,QAAQ,CAAC,KAAK,GAAM,CAElC,MAAU,CACR,GAAG,oBAAoB,EAAE,EACzB,CAEF,OAAO,EAAO,QAAQ,CAAC,KAAK,GAAK,EACjC,CAEF,GAAG,gEAAmE,CACpE,GAAG,eAAe,CAClB,IAAM,EAAmB,GAAG,MAAM,SAAU,mBAAmB,CACzD,EAAsB,GAAG,MAAM,SAAU,sBAAsB,CAE/D,CAAE,WAAY,MAAiB,EAAQ,IAAM,CAAE,OAAQ,CAAC,QAAS,UAAU,CAAE,CAAC,CAAC,CAErF,OAAO,EAAiB,CAAC,qBAAqB,QAAS,OAAO,IAAI,SAAS,CAAC,CAC5E,OAAO,EAAiB,CAAC,qBAAqB,UAAW,OAAO,IAAI,SAAS,CAAC,CAC9E,OAAO,EAAiB,CAAC,IAAI,qBAAqB,YAAa,OAAO,IAAI,SAAS,CAAC,CAEpF,GAAS,CAET,OAAO,EAAoB,CAAC,qBAAqB,QAAS,OAAO,IAAI,SAAS,CAAC,CAC/E,OAAO,EAAoB,CAAC,qBAAqB,UAAW,OAAO,IAAI,SAAS,CAAC,EACjF,CAEF,GAAG,uCAA0C,CAC3C,GAAG,eAAe,CAClB,IAAM,EAAe,GAAG,MAAM,OAAQ,eAAe,CAC/C,CAAE,WAAY,MAAiB,EAAQ,IAAK,CAAC,CAEnD,GAAS,CAET,OAAO,EAAa,CAAC,kBAAkB,EACvC,EACF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { n as __name } from "../chunk-CHh1Zzun.js";
|
|
2
|
+
|
|
3
|
+
//#region src/hooks/use-interval.d.ts
|
|
4
|
+
type UseIntervalOptions = {
|
|
5
|
+
/** If set, the interval will start automatically when the component is mounted, `false` by default */autoInvoke?: boolean;
|
|
6
|
+
};
|
|
7
|
+
type UseIntervalReturnValue = {
|
|
8
|
+
/** Starts the interval */start: () => void; /** Stops the interval */
|
|
9
|
+
stop: () => void; /** Toggles the interval */
|
|
10
|
+
toggle: () => void; /** Indicates if the interval is active */
|
|
11
|
+
active: boolean;
|
|
12
|
+
};
|
|
13
|
+
declare function useInterval(fn: () => void, interval: number, {
|
|
14
|
+
autoInvoke
|
|
15
|
+
}?: UseIntervalOptions): UseIntervalReturnValue;
|
|
16
|
+
declare namespace useInterval {
|
|
17
|
+
type Options = UseIntervalOptions;
|
|
18
|
+
type ReturnValue = UseIntervalReturnValue;
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { UseIntervalOptions, UseIntervalReturnValue, useInterval };
|
|
22
|
+
//# sourceMappingURL=use-interval.d.ts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"../chunk-CHh1Zzun.js";import{useCallback as e,useEffect as t,useRef as n,useState as r}from"react";function useInterval(i,a,{autoInvoke:o=!1}={}){let s=n(null),c=n(null),l=n(a),[u,d]=r(!1);l.current=a;let f=e(()=>{d(e=>(!e&&!s.current&&(s.current=window.setInterval(c.current,l.current)),!0))},[]),p=e(()=>{d(!1),s.current&&window.clearInterval(s.current),s.current=null},[]),m=e(()=>{d(e=>e?(s.current&&window.clearInterval(s.current),s.current=null,!1):(s.current||=window.setInterval(c.current,l.current),!0))},[]);return t(()=>(c.current=i,u&&f(),p),[i,u,a,f,p]),t(()=>{o&&f()},[f]),{start:f,stop:p,toggle:m,active:u}}export{useInterval};
|
|
2
|
+
//# sourceMappingURL=use-interval.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-interval.js","names":[],"sources":["../../src/hooks/use-interval.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react'\n\nexport type UseIntervalOptions = {\n /** If set, the interval will start automatically when the component is mounted, `false` by default */\n autoInvoke?: boolean\n}\n\nexport type UseIntervalReturnValue = {\n /** Starts the interval */\n start: () => void\n\n /** Stops the interval */\n stop: () => void\n\n /** Toggles the interval */\n toggle: () => void\n\n /** Indicates if the interval is active */\n active: boolean\n}\n\nexport function useInterval(\n fn: () => void,\n interval: number,\n { autoInvoke = false }: UseIntervalOptions = {}\n): UseIntervalReturnValue {\n const intervalRef = useRef<number | null>(null)\n const fnRef = useRef<() => void>(null)\n const intervalValueRef = useRef(interval)\n\n const [active, setActive] = useState(false)\n\n intervalValueRef.current = interval\n\n const start = useCallback(() => {\n setActive((old) => {\n if (!old && !intervalRef.current) {\n intervalRef.current = window.setInterval(fnRef.current!, intervalValueRef.current)\n }\n return true\n })\n }, [])\n\n const stop = useCallback(() => {\n setActive(false)\n if (intervalRef.current) {\n window.clearInterval(intervalRef.current)\n }\n intervalRef.current = null\n }, [])\n\n const toggle = useCallback(() => {\n setActive((current) => {\n if (current) {\n if (intervalRef.current) {\n window.clearInterval(intervalRef.current)\n }\n intervalRef.current = null\n return false\n }\n if (!intervalRef.current) {\n intervalRef.current = window.setInterval(fnRef.current!, intervalValueRef.current)\n }\n return true\n })\n }, [])\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: should includes the 'interval'\n useEffect(() => {\n fnRef.current = fn\n active && start()\n return stop\n }, [fn, active, interval, start, stop])\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: should execute only once\n useEffect(() => {\n if (autoInvoke) {\n start()\n }\n }, [start])\n\n return { start, stop, toggle, active }\n}\n\nexport namespace useInterval {\n export type Options = UseIntervalOptions\n export type ReturnValue = UseIntervalReturnValue\n}\n"],"mappings":"0GAqBA,SAAgB,YACd,EACA,EACA,CAAE,aAAa,IAA8B,EAAE,CACvB,CACxB,IAAM,EAAc,EAAsB,KAAK,CACzC,EAAQ,EAAmB,KAAK,CAChC,EAAmB,EAAO,EAAS,CAEnC,CAAC,EAAQ,GAAa,EAAS,GAAM,CAE3C,EAAiB,QAAU,EAE3B,IAAM,EAAQ,MAAkB,CAC9B,EAAW,IACL,CAAC,GAAO,CAAC,EAAY,UACvB,EAAY,QAAU,OAAO,YAAY,EAAM,QAAU,EAAiB,QAAQ,EAE7E,IACP,EACD,EAAE,CAAC,CAEA,EAAO,MAAkB,CAC7B,EAAU,GAAM,CACZ,EAAY,SACd,OAAO,cAAc,EAAY,QAAQ,CAE3C,EAAY,QAAU,MACrB,EAAE,CAAC,CAEA,EAAS,MAAkB,CAC/B,EAAW,GACL,GACE,EAAY,SACd,OAAO,cAAc,EAAY,QAAQ,CAE3C,EAAY,QAAU,KACf,KAET,AACE,EAAY,UAAU,OAAO,YAAY,EAAM,QAAU,EAAiB,QAAQ,CAE7E,IACP,EACD,EAAE,CAAC,CAgBN,OAbA,OACE,EAAM,QAAU,EAChB,GAAU,GAAO,CACV,GACN,CAAC,EAAI,EAAQ,EAAU,EAAO,EAAK,CAAC,CAGvC,MAAgB,CACV,GACF,GAAO,EAER,CAAC,EAAM,CAAC,CAEJ,CAAE,QAAO,OAAM,SAAQ,SAAQ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"../chunk-CHh1Zzun.js";import{useInterval as e}from"./use-interval.js";import{n as t,t as n}from"../react.esm-BuxkFT_p.js";describe(`useInterval`,()=>{it(`does not start by default`,()=>{vi.useFakeTimers();let r=vi.fn(),{result:i}=t(()=>e(r,1e3));expect(i.current.active).toBe(!1),n(()=>{vi.advanceTimersByTime(1e3)}),expect(r).not.toHaveBeenCalled()}),it(`starts and stops the interval`,()=>{vi.useFakeTimers();let r=vi.fn(),{result:i}=t(()=>e(r,1e3));n(()=>i.current.start()),expect(i.current.active).toBe(!0),n(()=>{vi.advanceTimersByTime(3e3)}),expect(r).toHaveBeenCalledTimes(3),n(()=>i.current.stop()),expect(i.current.active).toBe(!1),n(()=>{vi.advanceTimersByTime(1e3)}),expect(r).toHaveBeenCalledTimes(3)}),it(`toggles the interval`,()=>{vi.useFakeTimers();let r=vi.fn(),{result:i}=t(()=>e(r,1e3));n(()=>i.current.toggle()),expect(i.current.active).toBe(!0),n(()=>{vi.advanceTimersByTime(1e3)}),expect(r).toHaveBeenCalledTimes(1),n(()=>i.current.toggle()),expect(i.current.active).toBe(!1),n(()=>{vi.advanceTimersByTime(1e3)}),expect(r).toHaveBeenCalledTimes(1)}),it(`starts automatically when autoInvoke is enabled`,()=>{vi.useFakeTimers();let r=vi.fn(),{result:i}=t(()=>e(r,1e3,{autoInvoke:!0}));expect(i.current.active).toBe(!0),n(()=>{vi.advanceTimersByTime(1e3)}),expect(r).toHaveBeenCalledTimes(1)}),it(`uses the latest callback after rerendering`,()=>{vi.useFakeTimers();let r=vi.fn(),i=vi.fn(),{result:a,rerender:o}=t(({callback:t})=>e(t,1e3),{initialProps:{callback:r}});n(()=>a.current.start()),n(()=>{vi.advanceTimersByTime(1e3)}),o({callback:i}),n(()=>{vi.advanceTimersByTime(1e3)}),expect(r).toHaveBeenCalledTimes(1),expect(i).toHaveBeenCalledTimes(1)}),it(`cleans the interval on unmount`,()=>{vi.useFakeTimers();let r=vi.fn(),{result:i,unmount:a}=t(()=>e(r,1e3));n(()=>i.current.start()),a(),n(()=>{vi.advanceTimersByTime(1e3)}),expect(r).not.toHaveBeenCalled()})});
|
|
2
|
+
//# sourceMappingURL=use-interval.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-interval.spec.js","names":[],"sources":["../../src/hooks/use-interval.spec.ts"],"sourcesContent":["import { act, renderHook } from '@testing-library/react'\n\nimport { useInterval } from './use-interval'\n\ndescribe('useInterval', () => {\n it('does not start by default', () => {\n vi.useFakeTimers()\n const callback = vi.fn()\n\n const { result } = renderHook(() => useInterval(callback, 1000))\n\n expect(result.current.active).toBe(false)\n\n act(() => {\n vi.advanceTimersByTime(1000)\n })\n\n expect(callback).not.toHaveBeenCalled()\n })\n\n it('starts and stops the interval', () => {\n vi.useFakeTimers()\n const callback = vi.fn()\n const { result } = renderHook(() => useInterval(callback, 1000))\n\n act(() => result.current.start())\n expect(result.current.active).toBe(true)\n\n act(() => {\n vi.advanceTimersByTime(3000)\n })\n\n expect(callback).toHaveBeenCalledTimes(3)\n\n act(() => result.current.stop())\n expect(result.current.active).toBe(false)\n\n act(() => {\n vi.advanceTimersByTime(1000)\n })\n\n expect(callback).toHaveBeenCalledTimes(3)\n })\n\n it('toggles the interval', () => {\n vi.useFakeTimers()\n const callback = vi.fn()\n const { result } = renderHook(() => useInterval(callback, 1000))\n\n act(() => result.current.toggle())\n expect(result.current.active).toBe(true)\n\n act(() => {\n vi.advanceTimersByTime(1000)\n })\n\n expect(callback).toHaveBeenCalledTimes(1)\n\n act(() => result.current.toggle())\n expect(result.current.active).toBe(false)\n\n act(() => {\n vi.advanceTimersByTime(1000)\n })\n\n expect(callback).toHaveBeenCalledTimes(1)\n })\n\n it('starts automatically when autoInvoke is enabled', () => {\n vi.useFakeTimers()\n const callback = vi.fn()\n\n const { result } = renderHook(() => useInterval(callback, 1000, { autoInvoke: true }))\n\n expect(result.current.active).toBe(true)\n\n act(() => {\n vi.advanceTimersByTime(1000)\n })\n\n expect(callback).toHaveBeenCalledTimes(1)\n })\n\n it('uses the latest callback after rerendering', () => {\n vi.useFakeTimers()\n const firstCallback = vi.fn()\n const secondCallback = vi.fn()\n const { result, rerender } = renderHook(({ callback }) => useInterval(callback, 1000), {\n initialProps: { callback: firstCallback }\n })\n\n act(() => result.current.start())\n act(() => {\n vi.advanceTimersByTime(1000)\n })\n\n rerender({ callback: secondCallback })\n\n act(() => {\n vi.advanceTimersByTime(1000)\n })\n\n expect(firstCallback).toHaveBeenCalledTimes(1)\n expect(secondCallback).toHaveBeenCalledTimes(1)\n })\n\n it('cleans the interval on unmount', () => {\n vi.useFakeTimers()\n const callback = vi.fn()\n const { result, unmount } = renderHook(() => useInterval(callback, 1000))\n\n act(() => result.current.start())\n unmount()\n\n act(() => {\n vi.advanceTimersByTime(1000)\n })\n\n expect(callback).not.toHaveBeenCalled()\n })\n})\n"],"mappings":"iIAIA,SAAS,kBAAqB,CAC5B,GAAG,gCAAmC,CACpC,GAAG,eAAe,CAClB,IAAM,EAAW,GAAG,IAAI,CAElB,CAAE,UAAW,MAAiB,EAAY,EAAU,IAAK,CAAC,CAEhE,OAAO,EAAO,QAAQ,OAAO,CAAC,KAAK,GAAM,CAEzC,MAAU,CACR,GAAG,oBAAoB,IAAK,EAC5B,CAEF,OAAO,EAAS,CAAC,IAAI,kBAAkB,EACvC,CAEF,GAAG,oCAAuC,CACxC,GAAG,eAAe,CAClB,IAAM,EAAW,GAAG,IAAI,CAClB,CAAE,UAAW,MAAiB,EAAY,EAAU,IAAK,CAAC,CAEhE,MAAU,EAAO,QAAQ,OAAO,CAAC,CACjC,OAAO,EAAO,QAAQ,OAAO,CAAC,KAAK,GAAK,CAExC,MAAU,CACR,GAAG,oBAAoB,IAAK,EAC5B,CAEF,OAAO,EAAS,CAAC,sBAAsB,EAAE,CAEzC,MAAU,EAAO,QAAQ,MAAM,CAAC,CAChC,OAAO,EAAO,QAAQ,OAAO,CAAC,KAAK,GAAM,CAEzC,MAAU,CACR,GAAG,oBAAoB,IAAK,EAC5B,CAEF,OAAO,EAAS,CAAC,sBAAsB,EAAE,EACzC,CAEF,GAAG,2BAA8B,CAC/B,GAAG,eAAe,CAClB,IAAM,EAAW,GAAG,IAAI,CAClB,CAAE,UAAW,MAAiB,EAAY,EAAU,IAAK,CAAC,CAEhE,MAAU,EAAO,QAAQ,QAAQ,CAAC,CAClC,OAAO,EAAO,QAAQ,OAAO,CAAC,KAAK,GAAK,CAExC,MAAU,CACR,GAAG,oBAAoB,IAAK,EAC5B,CAEF,OAAO,EAAS,CAAC,sBAAsB,EAAE,CAEzC,MAAU,EAAO,QAAQ,QAAQ,CAAC,CAClC,OAAO,EAAO,QAAQ,OAAO,CAAC,KAAK,GAAM,CAEzC,MAAU,CACR,GAAG,oBAAoB,IAAK,EAC5B,CAEF,OAAO,EAAS,CAAC,sBAAsB,EAAE,EACzC,CAEF,GAAG,sDAAyD,CAC1D,GAAG,eAAe,CAClB,IAAM,EAAW,GAAG,IAAI,CAElB,CAAE,UAAW,MAAiB,EAAY,EAAU,IAAM,CAAE,WAAY,GAAM,CAAC,CAAC,CAEtF,OAAO,EAAO,QAAQ,OAAO,CAAC,KAAK,GAAK,CAExC,MAAU,CACR,GAAG,oBAAoB,IAAK,EAC5B,CAEF,OAAO,EAAS,CAAC,sBAAsB,EAAE,EACzC,CAEF,GAAG,iDAAoD,CACrD,GAAG,eAAe,CAClB,IAAM,EAAgB,GAAG,IAAI,CACvB,EAAiB,GAAG,IAAI,CACxB,CAAE,SAAQ,YAAa,GAAY,CAAE,cAAe,EAAY,EAAU,IAAK,CAAE,CACrF,aAAc,CAAE,SAAU,EAAe,CAC1C,CAAC,CAEF,MAAU,EAAO,QAAQ,OAAO,CAAC,CACjC,MAAU,CACR,GAAG,oBAAoB,IAAK,EAC5B,CAEF,EAAS,CAAE,SAAU,EAAgB,CAAC,CAEtC,MAAU,CACR,GAAG,oBAAoB,IAAK,EAC5B,CAEF,OAAO,EAAc,CAAC,sBAAsB,EAAE,CAC9C,OAAO,EAAe,CAAC,sBAAsB,EAAE,EAC/C,CAEF,GAAG,qCAAwC,CACzC,GAAG,eAAe,CAClB,IAAM,EAAW,GAAG,IAAI,CAClB,CAAE,SAAQ,WAAY,MAAiB,EAAY,EAAU,IAAK,CAAC,CAEzE,MAAU,EAAO,QAAQ,OAAO,CAAC,CACjC,GAAS,CAET,MAAU,CACR,GAAG,oBAAoB,IAAK,EAC5B,CAEF,OAAO,EAAS,CAAC,IAAI,kBAAkB,EACvC,EACF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { n as __name } from "../chunk-CHh1Zzun.js";
|
|
2
|
+
|
|
3
|
+
//#region src/hooks/use-local-storage.d.ts
|
|
4
|
+
type UseLocalStorageOptions<T> = {
|
|
5
|
+
defaultValue?: T;
|
|
6
|
+
sync?: boolean;
|
|
7
|
+
};
|
|
8
|
+
declare function useLocalStorage<T>(key: string, options: UseLocalStorageOptions<T> & {
|
|
9
|
+
defaultValue: T;
|
|
10
|
+
}): [T, React.Dispatch<React.SetStateAction<T>>];
|
|
11
|
+
declare function useLocalStorage<T = undefined>(key: string, options?: UseLocalStorageOptions<T>): [T | undefined, React.Dispatch<React.SetStateAction<T | undefined>>];
|
|
12
|
+
declare namespace useLocalStorage {
|
|
13
|
+
type Options<T> = UseLocalStorageOptions<T>;
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { UseLocalStorageOptions, useLocalStorage };
|
|
17
|
+
//# sourceMappingURL=use-local-storage.d.ts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"../chunk-CHh1Zzun.js";import{useCallback as e,useEffect as t,useRef as n,useState as r}from"react";function parseStorageValue(e){try{return JSON.parse(e)}catch{return e}}function readStorageValue(e,t){if(typeof window>`u`)return t;try{let n=window.localStorage.getItem(e);return n===null?t:parseStorageValue(n)}catch{return t}}function writeStorageValue(e,t){if(!(typeof window>`u`))try{window.localStorage.setItem(e,String(JSON.stringify(t)))}catch{}}function useLocalStorage(i,a={}){let{defaultValue:o,sync:s=!0}=a,c=n(o),[l,u]=r(()=>readStorageValue(i,o)),d=n(l);c.current=o,d.current=l;let f=e(e=>{let t=typeof e==`function`?e(d.current):e;d.current=t,writeStorageValue(i,t),u(t)},[i]);return t(()=>{if(!s||typeof window>`u`)return;let handleStorage=e=>{if(e.storageArea!==window.localStorage||e.key!==i)return;let t=e.newValue===null?c.current:parseStorageValue(e.newValue);d.current=t,u(t)};return window.addEventListener(`storage`,handleStorage),()=>window.removeEventListener(`storage`,handleStorage)},[i,s]),[l,f]}export{useLocalStorage};
|
|
2
|
+
//# sourceMappingURL=use-local-storage.js.map
|