@uselets/ui 1.20.4 → 2.0.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 +309 -426
- package/dist/as-child-Dxg3Xo1G.d.ts +41 -0
- package/dist/cli/uselets.mjs +5 -4
- package/dist/cli/uselets.mjs.map +1 -1
- package/dist/components/accordion.d.ts +12 -8
- package/dist/components/accordion.js +1 -1
- package/dist/components/accordion.js.map +1 -1
- package/dist/components/alert-dialog.d.ts +20 -15
- package/dist/components/alert-dialog.js +1 -1
- package/dist/components/alert-dialog.js.map +1 -1
- package/dist/components/alert.d.ts +1 -1
- package/dist/components/anchor.d.ts +3 -5
- package/dist/components/anchor.js +1 -1
- package/dist/components/anchor.js.map +1 -1
- package/dist/components/area-chart.d.ts +54 -0
- package/dist/components/area-chart.js +1 -1
- package/dist/components/area-chart.js.map +1 -1
- package/dist/components/avatar.d.ts +12 -7
- package/dist/components/avatar.js +1 -1
- package/dist/components/avatar.js.map +1 -1
- package/dist/components/badge.d.ts +3 -5
- package/dist/components/badge.js +1 -1
- package/dist/components/badge.js.map +1 -1
- package/dist/components/bar-chart.d.ts +48 -0
- package/dist/components/bar-chart.js +1 -1
- package/dist/components/bar-chart.js.map +1 -1
- package/dist/components/bottom-nav.d.ts +7 -3
- package/dist/components/bottom-nav.js +1 -1
- package/dist/components/bottom-nav.js.map +1 -1
- package/dist/components/breadcrumb.d.ts +3 -4
- package/dist/components/breadcrumb.js +1 -1
- package/dist/components/breadcrumb.js.map +1 -1
- package/dist/components/button-group.d.ts +3 -4
- package/dist/components/button-group.js +1 -1
- package/dist/components/button-group.js.map +1 -1
- package/dist/components/button.d.ts +8 -4
- package/dist/components/button.js +1 -1
- package/dist/components/button.js.map +1 -1
- package/dist/components/calendar.d.ts +4 -0
- package/dist/components/calendar.js +1 -1
- package/dist/components/calendar.js.map +1 -1
- package/dist/components/card.d.ts +4 -0
- package/dist/components/card.js.map +1 -1
- package/dist/components/carousel.d.ts +11 -3
- package/dist/components/carousel.js +1 -1
- package/dist/components/carousel.js.map +1 -1
- package/dist/components/center.d.ts +1 -1
- package/dist/components/chart.js +4 -4
- package/dist/components/checkbox.d.ts +14 -4
- package/dist/components/checkbox.js +1 -1
- package/dist/components/checkbox.js.map +1 -1
- package/dist/components/collapsible.d.ts +8 -7
- package/dist/components/collapsible.js +1 -1
- package/dist/components/collapsible.js.map +1 -1
- package/dist/components/combobox.d.ts +48 -26
- package/dist/components/combobox.js +1 -1
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/command.d.ts +16 -2
- package/dist/components/command.js +1 -1
- package/dist/components/command.js.map +1 -1
- package/dist/components/container.d.ts +1 -1
- package/dist/components/data-table.d.ts +39 -0
- package/dist/components/data-table.js +1 -1
- package/dist/components/data-table.js.map +1 -1
- package/dist/components/date-range-picker.d.ts +24 -2
- package/dist/components/date-range-picker.js +1 -1
- package/dist/components/date-range-picker.js.map +1 -1
- package/dist/components/dialog.d.ts +33 -15
- package/dist/components/dialog.js +1 -1
- package/dist/components/dialog.js.map +1 -1
- package/dist/components/direction.d.ts +7 -0
- package/dist/components/direction.js +1 -0
- package/dist/components/donut-chart.d.ts +12 -0
- package/dist/components/donut-chart.js +1 -1
- package/dist/components/donut-chart.js.map +1 -1
- package/dist/components/drawer.d.ts +33 -15
- package/dist/components/drawer.js +1 -1
- package/dist/components/drawer.js.map +1 -1
- package/dist/components/dropdown-menu.d.ts +36 -26
- package/dist/components/dropdown-menu.js +1 -1
- package/dist/components/dropdown-menu.js.map +1 -1
- package/dist/components/dropzone.d.ts +19 -0
- package/dist/components/dropzone.js +1 -1
- package/dist/components/dropzone.js.map +1 -1
- package/dist/components/field.d.ts +16 -4
- package/dist/components/field.js +1 -1
- package/dist/components/field.js.map +1 -1
- package/dist/components/flex.d.ts +1 -1
- package/dist/components/grid.d.ts +13 -0
- package/dist/components/grid.js.map +1 -1
- package/dist/components/group.d.ts +1 -1
- package/dist/components/heading.d.ts +3 -5
- package/dist/components/heading.js +1 -1
- package/dist/components/heading.js.map +1 -1
- package/dist/components/hover-card.d.ts +7 -6
- package/dist/components/hover-card.js +1 -1
- package/dist/components/hover-card.js.map +1 -1
- package/dist/components/input-group.d.ts +2 -2
- package/dist/components/input-group.js +1 -1
- package/dist/components/input-group.js.map +1 -1
- package/dist/components/input-otp.d.ts +4 -2
- package/dist/components/input-otp.js +1 -1
- package/dist/components/input-otp.js.map +1 -1
- package/dist/components/input.d.ts +1 -1
- package/dist/components/input.js +1 -1
- package/dist/components/input.js.map +1 -1
- package/dist/components/label.d.ts +3 -4
- package/dist/components/label.js +1 -1
- package/dist/components/label.js.map +1 -1
- package/dist/components/list.d.ts +8 -5
- package/dist/components/list.js +1 -1
- package/dist/components/list.js.map +1 -1
- package/dist/components/logo.d.ts +113 -0
- package/dist/components/marker.d.ts +4 -5
- package/dist/components/marker.js +1 -1
- package/dist/components/marker.js.map +1 -1
- package/dist/components/mask-input.d.ts +6 -0
- package/dist/components/mask-input.js.map +1 -1
- package/dist/components/native-select.d.ts +5 -1
- package/dist/components/native-select.js +1 -1
- package/dist/components/native-select.js.map +1 -1
- package/dist/components/navigation-menu.d.ts +19 -20
- package/dist/components/navigation-menu.js +1 -1
- package/dist/components/navigation-menu.js.map +1 -1
- package/dist/components/number-field.d.ts +18 -13
- package/dist/components/number-field.js +1 -1
- package/dist/components/number-field.js.map +1 -1
- package/dist/components/pagination.d.ts +9 -0
- package/dist/components/pagination.js +1 -1
- package/dist/components/pagination.js.map +1 -1
- package/dist/components/phone-input.d.ts +3 -0
- package/dist/components/phone-input.js +1 -1
- package/dist/components/phone-input.js.map +1 -1
- package/dist/components/pie-chart.d.ts +53 -0
- package/dist/components/pie-chart.js +1 -1
- package/dist/components/pie-chart.js.map +1 -1
- package/dist/components/popover.d.ts +13 -12
- package/dist/components/popover.js +1 -1
- package/dist/components/popover.js.map +1 -1
- package/dist/components/progress.d.ts +9 -3
- package/dist/components/progress.js +1 -1
- package/dist/components/progress.js.map +1 -1
- package/dist/components/radio-group.d.ts +20 -6
- package/dist/components/radio-group.js +1 -1
- package/dist/components/radio-group.js.map +1 -1
- package/dist/components/resizable.d.ts +1 -0
- package/dist/components/resizable.js.map +1 -1
- package/dist/components/ring-progress.d.ts +9 -1
- package/dist/components/ring-progress.js.map +1 -1
- package/dist/components/scroll-area.d.ts +3 -3
- package/dist/components/scroll-area.js +1 -1
- package/dist/components/scroll-area.js.map +1 -1
- package/dist/components/select.d.ts +25 -20
- package/dist/components/select.js +1 -1
- package/dist/components/select.js.map +1 -1
- package/dist/components/separator.d.ts +9 -4
- package/dist/components/separator.js +1 -1
- package/dist/components/separator.js.map +1 -1
- package/dist/components/sidebar.d.ts +63 -18
- package/dist/components/sidebar.js +1 -1
- package/dist/components/sidebar.js.map +1 -1
- package/dist/components/simple-grid.d.ts +7 -0
- package/dist/components/simple-grid.js +1 -1
- package/dist/components/simple-grid.js.map +1 -1
- package/dist/components/skeleton.d.ts +4 -0
- package/dist/components/skeleton.js.map +1 -1
- package/dist/components/slider.d.ts +2 -2
- package/dist/components/slider.js +1 -1
- package/dist/components/slider.js.map +1 -1
- package/dist/components/spinner.d.ts +1 -1
- package/dist/components/stack.d.ts +1 -1
- package/dist/components/stepper.d.ts +46 -25
- package/dist/components/stepper.js +1 -1
- package/dist/components/stepper.js.map +1 -1
- package/dist/components/switch.d.ts +17 -3
- package/dist/components/switch.js +1 -1
- package/dist/components/switch.js.map +1 -1
- package/dist/components/table.d.ts +10 -1
- package/dist/components/table.js +1 -1
- package/dist/components/table.js.map +1 -1
- package/dist/components/tabs.d.ts +14 -10
- package/dist/components/tabs.js +1 -1
- package/dist/components/tabs.js.map +1 -1
- package/dist/components/text.d.ts +3 -5
- package/dist/components/text.js +1 -1
- package/dist/components/text.js.map +1 -1
- package/dist/components/textarea.d.ts +1 -1
- package/dist/components/textarea.js +1 -1
- package/dist/components/textarea.js.map +1 -1
- package/dist/components/theme.d.ts +12 -0
- package/dist/components/theme.js +1 -1
- package/dist/components/theme.js.map +1 -1
- package/dist/components/timeline.d.ts +25 -1
- package/dist/components/timeline.js +1 -1
- package/dist/components/timeline.js.map +1 -1
- package/dist/components/toggle-group.d.ts +16 -6
- package/dist/components/toggle-group.js +1 -1
- package/dist/components/toggle-group.js.map +1 -1
- package/dist/components/toggle.d.ts +4 -4
- package/dist/components/toggle.js +1 -1
- package/dist/components/toggle.js.map +1 -1
- package/dist/components/tooltip.d.ts +15 -8
- package/dist/components/tooltip.js +1 -1
- package/dist/components/tooltip.js.map +1 -1
- package/dist/components/unstyled-button.d.ts +3 -5
- package/dist/components/unstyled-button.js +1 -1
- package/dist/components/unstyled-button.js.map +1 -1
- package/dist/components/visibility.d.ts +2 -0
- package/dist/components/visibility.js +1 -1
- package/dist/components/visibility.js.map +1 -1
- package/dist/hooks/use-breakpoint-value.d.ts +1 -0
- package/dist/hooks/use-breakpoint-value.js.map +1 -1
- package/dist/hooks/use-breakpoint.d.ts +1 -0
- package/dist/hooks/use-breakpoint.js.map +1 -1
- package/dist/hooks/use-disclosure.d.ts +3 -0
- package/dist/hooks/use-disclosure.js +1 -1
- package/dist/hooks/use-disclosure.js.map +1 -1
- package/dist/hooks/use-document-visibility.d.ts +1 -0
- package/dist/hooks/use-document-visibility.js.map +1 -1
- package/dist/hooks/use-hotkeys.d.ts +1 -1
- package/dist/hooks/use-idle.d.ts +9 -0
- package/dist/hooks/use-idle.js.map +1 -1
- package/dist/hooks/use-interval.d.ts +1 -0
- package/dist/hooks/use-interval.js.map +1 -1
- package/dist/hooks/use-local-storage.d.ts +6 -0
- package/dist/hooks/use-local-storage.js +1 -1
- package/dist/hooks/use-local-storage.js.map +1 -1
- package/dist/hooks/use-mask.d.ts +1 -0
- package/dist/hooks/use-mask.js.map +1 -1
- package/dist/hooks/use-mobile.d.ts +1 -0
- package/dist/hooks/use-mobile.js.map +1 -1
- package/dist/index.d.ts +7 -5
- package/dist/index.js +1 -1
- package/dist/lib/as-child.d.ts +2 -0
- package/dist/lib/as-child.js +2 -0
- package/dist/lib/as-child.js.map +1 -0
- package/dist/lib/utils.d.ts +1 -1
- package/dist/logo--R3_XDgA.js.map +1 -1
- package/dist/resolve-class-name-BurP8ngI.js +2 -0
- package/dist/resolve-class-name-BurP8ngI.js.map +1 -0
- package/dist/skills/uselets-ui/SKILL.md +8 -3
- package/dist/skills/uselets-ui/references/component-catalog.md +31 -16
- package/dist/skills/uselets-ui/references/migration-v1-to-v2.md +599 -0
- package/dist/skills/uselets-ui/references/package-guide.md +7 -7
- package/dist/styles/base.css +21 -0
- package/dist/{use-hotkeys-DOjcX9Tt.d.ts → use-hotkeys-D1_TEIwN.d.ts} +2 -1
- package/dist/use-hotkeys-YDJmGWX6.js.map +1 -1
- package/package.json +16 -17
- package/skills/uselets-ui/SKILL.md +8 -3
- package/skills/uselets-ui/references/component-catalog.md +31 -16
- package/skills/uselets-ui/references/migration-v1-to-v2.md +599 -0
- package/skills/uselets-ui/references/package-guide.md +7 -7
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { t as __name } from "../rolldown-runtime-BhWHdk3m.js";
|
|
2
|
+
import { n as AsChildProps } from "../as-child-Dxg3Xo1G.js";
|
|
2
3
|
import { VariantProps } from "class-variance-authority";
|
|
3
|
-
import * as React from "react";
|
|
4
4
|
//#region src/components/text.d.ts
|
|
5
5
|
declare const textVariants: (props?: ({
|
|
6
6
|
size?: "lg" | "md" | "sm" | "xl" | "xs" | null | undefined;
|
|
7
7
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
8
|
-
export type TextProps =
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
declare function Text({ className, size, asChild, ...props }: TextProps): React.JSX.Element;
|
|
8
|
+
export type TextProps = AsChildProps<'p'> & VariantProps<typeof textVariants>;
|
|
9
|
+
declare function Text({ className, size, ...props }: TextProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
12
10
|
//#endregion
|
|
13
11
|
export { Text, textVariants };
|
|
14
12
|
//# sourceMappingURL=text.d.ts.map
|
package/dist/components/text.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../rolldown-runtime-BhWHdk3m.js";import{
|
|
1
|
+
import"../rolldown-runtime-BhWHdk3m.js";import{useAsChild as e}from"../lib/as-child.js";import{cn as t}from"../lib/utils.js";import{cva as n}from"class-variance-authority";const r=n(`text-foreground font-normal`,{variants:{size:{xs:`text-xs`,sm:`text-sm`,md:`text-base`,lg:`text-lg`,xl:`text-xl`}},defaultVariants:{size:`md`}});function Text({className:n,size:i=`md`,...a}){return e(`p`,{"data-slot":`text`,"data-size":i,className:t(r({size:i}),n),...a})}export{Text,r as textVariants};
|
|
2
2
|
//# sourceMappingURL=text.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.js","names":["textVariants","cva","props","
|
|
1
|
+
{"version":3,"file":"text.js","names":["textVariants","cva","props","useAsChild","size","cn","className"],"sources":["../../src/components/text.tsx"],"sourcesContent":["import { cva, type VariantProps } from 'class-variance-authority'\n\nimport { type AsChildProps, useAsChild } from '../lib/as-child'\nimport { cn } from '../lib/utils'\n\nconst textVariants = cva('text-foreground font-normal', {\n variants: {\n size: {\n xs: 'text-xs',\n sm: 'text-sm',\n md: 'text-base',\n lg: 'text-lg',\n xl: 'text-xl'\n }\n },\n defaultVariants: {\n size: 'md'\n }\n})\n\nexport type TextProps = AsChildProps<'p'> & VariantProps<typeof textVariants>\n\nfunction Text({ className, size = 'md', ...props }: TextProps) {\n return useAsChild('p', {\n 'data-slot': 'text',\n 'data-size': size,\n className: cn(textVariants({ size }), className),\n ...props\n })\n}\n\nexport { Text, textVariants }\n"],"mappings":"4KAKA,MAAMA,EAAeC,EAAI,8BAA+B,CACtD,SAAU,CACR,KAAM,CACJ,GAAI,UACJ,GAAI,UACJ,GAAI,YACJ,GAAI,UACJ,GAAI,SACN,CACF,EACA,gBAAiB,CACf,KAAM,IACR,CACF,CAAC,EAID,SAAS,KAAK,CAAE,YAAW,OAAO,KAAM,GAAGC,GAAoB,CAC7D,OAAOC,EAAW,IAAK,CACrB,YAAa,OACb,YAAaC,EACb,UAAWC,EAAGL,EAAa,CAAE,MAAK,CAAC,EAAGM,CAAS,EAC/C,GAAGJ,CACL,CAAC,CACH"}
|
|
@@ -2,7 +2,7 @@ import { t as __name } from "../rolldown-runtime-BhWHdk3m.js";
|
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
//#region src/components/textarea.d.ts
|
|
4
4
|
export type TextareaProps = React.ComponentProps<'textarea'>;
|
|
5
|
-
declare function Textarea({ className, id, ...props }: TextareaProps): React.JSX.Element;
|
|
5
|
+
declare function Textarea({ className, id, 'aria-invalid': ariaInvalid, ...props }: TextareaProps): React.JSX.Element;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { Textarea };
|
|
8
8
|
//# sourceMappingURL=textarea.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../rolldown-runtime-BhWHdk3m.js";import{cn as e}from"../lib/utils.js";import{useFieldControlId as t}from"./field.js";import{jsx as
|
|
1
|
+
import"../rolldown-runtime-BhWHdk3m.js";import{cn as e}from"../lib/utils.js";import{useFieldControlId as t,useFieldInvalid as n}from"./field.js";import{jsx as r}from"react/jsx-runtime";function Textarea({className:i,id:a,"aria-invalid":o,...s}){let c=t(a),l=n(o);return/* @__PURE__ */ r(`textarea`,{id:c,"aria-invalid":l,"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-placeholder 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`,i),...s})}export{Textarea};
|
|
2
2
|
//# sourceMappingURL=textarea.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textarea.js","names":["props","fieldControlId","useFieldControlId","id","cn","className"],"sources":["../../src/components/textarea.tsx"],"sourcesContent":["import type * as React from 'react'\n\nimport { cn } from '../lib/utils'\nimport { useFieldControlId } from './field'\n\nexport type TextareaProps = React.ComponentProps<'textarea'>\n\nfunction Textarea({ className, id, ...props }: TextareaProps) {\n const fieldControlId = useFieldControlId(id)\n\n return (\n <textarea\n id={fieldControlId}\n data-slot=\"textarea\"\n className={cn(\n '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-placeholder 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 className\n )}\n {...props}\n />\n )\n}\n\nexport { Textarea }\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"textarea.js","names":["ariaInvalid","props","fieldControlId","useFieldControlId","id","invalid","useFieldInvalid","cn","className"],"sources":["../../src/components/textarea.tsx"],"sourcesContent":["import type * as React from 'react'\n\nimport { cn } from '../lib/utils'\nimport { useFieldControlId, useFieldInvalid } from './field'\n\nexport type TextareaProps = React.ComponentProps<'textarea'>\n\nfunction Textarea({ className, id, 'aria-invalid': ariaInvalid, ...props }: TextareaProps) {\n const fieldControlId = useFieldControlId(id)\n const invalid = useFieldInvalid(ariaInvalid)\n\n return (\n <textarea\n id={fieldControlId}\n aria-invalid={invalid}\n data-slot=\"textarea\"\n className={cn(\n '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-placeholder 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 className\n )}\n {...props}\n />\n )\n}\n\nexport { Textarea }\n"],"mappings":"yLAOA,SAAS,SAAS,CAAE,YAAW,KAAI,eAAgBA,EAAa,GAAGC,GAAwB,CACzF,IAAMC,EAAiBC,EAAkBC,CAAE,EACrCC,EAAUC,EAAgBN,CAAW,EAE3C,MACE,kBAAC,WAAD,CACE,GAAIE,EACJ,eAAcG,EACd,YAAU,WACV,UAAWE,EACT,ohBACAC,CACF,EACA,GAAIP,CACL,CAAA,CAEL"}
|
|
@@ -5,8 +5,20 @@ import * as React from "react";
|
|
|
5
5
|
export type Theme = 'dark' | 'light' | 'system';
|
|
6
6
|
export type ThemeProviderProps = {
|
|
7
7
|
children: React.ReactNode;
|
|
8
|
+
/**
|
|
9
|
+
* Theme used until the user picks one.
|
|
10
|
+
* @default 'system'
|
|
11
|
+
*/
|
|
8
12
|
defaultTheme?: Theme;
|
|
13
|
+
/**
|
|
14
|
+
* `localStorage` key where the theme is saved.
|
|
15
|
+
* @default 'vite-ui-theme'
|
|
16
|
+
*/
|
|
9
17
|
storageKey?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Turns off CSS transitions while the theme switches.
|
|
20
|
+
* @default false
|
|
21
|
+
*/
|
|
10
22
|
disableTransitionOnChange?: boolean;
|
|
11
23
|
};
|
|
12
24
|
export type ThemeProviderState = {
|
package/dist/components/theme.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../rolldown-runtime-BhWHdk3m.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{
|
|
1
|
+
import"../rolldown-runtime-BhWHdk3m.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{createContext as s,use as c,useEffect as l,useState as u}from"react";import{jsx as d,jsxs as f}from"react/jsx-runtime";const p=s({});function disableAnimation(){let e=document.createElement(`style`);return e.appendChild(document.createTextNode(`*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}`)),document.head.appendChild(e),()=>{window.getComputedStyle(document.body),setTimeout(()=>{document.head.removeChild(e)},1)}}function readStoredTheme(e,t){try{return window.localStorage.getItem(e)||t}catch{return t}}function writeStoredTheme(e,t){try{window.localStorage.setItem(e,t)}catch{}}function ThemeProvider({children:e,defaultTheme:t=`system`,storageKey:n=`vite-ui-theme`,disableTransitionOnChange:r=!1,...i}){let[a,o]=u(()=>readStoredTheme(n,t));l(()=>{let e=window.document.documentElement,t=window.matchMedia(`(prefers-color-scheme: dark)`),applyTheme=()=>{let n=r?disableAnimation():null;e.classList.remove(`light`,`dark`),e.classList.add(a===`system`?t.matches?`dark`:`light`:a),n?.()};if(applyTheme(),a===`system`)return t.addEventListener(`change`,applyTheme),()=>t.removeEventListener(`change`,applyTheme)},[a,r]);let s={theme:a,setTheme:e=>{writeStoredTheme(n,e),o(e)}};return/* @__PURE__ */ d(p.Provider,{...i,value:s,children:e})}const useTheme=()=>{let e=c(p);if(e===void 0||Object.keys(e).length===0)throw Error(`useTheme must be used within a ThemeProvider`);return e};function ModeToggle(s){let{setTheme:c}=useTheme();return/* @__PURE__ */ f(t,{children:[/* @__PURE__ */ d(i,{asChild:!0,children:/* @__PURE__ */ f(e,{variant:`outline`,size:`icon`,...s,children:[/* @__PURE__ */ d(o,{className:`h-[1.2rem] w-[1.2rem] scale-100 rotate-0 transition-all dark:scale-0 dark:-rotate-90`}),/* @__PURE__ */ d(a,{className:`absolute h-[1.2rem] w-[1.2rem] scale-0 rotate-90 transition-all dark:scale-100 dark:rotate-0`}),/* @__PURE__ */ d(`span`,{className:`sr-only`,children:`Toggle theme`})]})}),/* @__PURE__ */ f(n,{align:`end`,children:[/* @__PURE__ */ d(r,{onClick:()=>c(`light`),children:`Light`}),/* @__PURE__ */ d(r,{onClick:()=>c(`dark`),children:`Dark`}),/* @__PURE__ */ d(r,{onClick:()=>c(`system`),children:`System`})]})]})}export{ModeToggle,ThemeProvider,useTheme};
|
|
2
2
|
//# sourceMappingURL=theme.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.js","names":["ThemeProviderContext","createContext","css","
|
|
1
|
+
{"version":3,"file":"theme.js","names":["ThemeProviderContext","createContext","css","storageKey","defaultTheme","theme","props","setTheme","useState","useEffect","root","darkSchemeQuery","enableTransitions","disableTransitionOnChange","value","context","use","DropdownMenu","DropdownMenuTrigger","Button","IconSun","IconMoon","DropdownMenuContent","DropdownMenuItem"],"sources":["../../src/components/theme.tsx"],"sourcesContent":["import type * as React from 'react'\nimport { createContext, use, useEffect, useState } from 'react'\n\nimport { IconMoon, IconSun } from '@tabler/icons-react'\n\nimport { Button } from './button'\nimport { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from './dropdown-menu'\n\nexport type Theme = 'dark' | 'light' | 'system'\n\nexport type ThemeProviderProps = {\n children: React.ReactNode\n /**\n * Theme used until the user picks one.\n * @default 'system'\n */\n defaultTheme?: Theme\n /**\n * `localStorage` key where the theme is saved.\n * @default 'vite-ui-theme'\n */\n storageKey?: string\n /**\n * Turns off CSS transitions while the theme switches.\n * @default false\n */\n disableTransitionOnChange?: boolean\n}\n\nexport type ThemeProviderState = {\n theme: Theme\n setTheme: (theme: Theme) => void\n}\n\nexport type ModeToggleProps = React.ComponentProps<typeof Button>\n\nconst ThemeProviderContext = createContext({} as ThemeProviderState)\n\nfunction disableAnimation() {\n const css = document.createElement('style')\n\n css.appendChild(\n document.createTextNode(\n '*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}'\n )\n )\n document.head.appendChild(css)\n\n return () => {\n window.getComputedStyle(document.body)\n\n setTimeout(() => {\n document.head.removeChild(css)\n }, 1)\n }\n}\n\n// Storage can be missing (server rendering) or throw (blocked by the browser); the theme then just isn't persisted.\nfunction readStoredTheme(storageKey: string, defaultTheme: Theme) {\n try {\n return (window.localStorage.getItem(storageKey) as Theme | null) || defaultTheme\n } catch {\n return defaultTheme\n }\n}\n\nfunction writeStoredTheme(storageKey: string, theme: Theme) {\n try {\n window.localStorage.setItem(storageKey, theme)\n } catch {}\n}\n\nexport function ThemeProvider({\n children,\n defaultTheme = 'system',\n storageKey = 'vite-ui-theme',\n disableTransitionOnChange = false,\n ...props\n}: ThemeProviderProps) {\n const [theme, setTheme] = useState<Theme>(() => readStoredTheme(storageKey, defaultTheme))\n\n useEffect(() => {\n const root = window.document.documentElement\n const darkSchemeQuery = window.matchMedia('(prefers-color-scheme: dark)')\n\n const applyTheme = () => {\n const enableTransitions = disableTransitionOnChange ? disableAnimation() : null\n\n root.classList.remove('light', 'dark')\n root.classList.add(theme === 'system' ? (darkSchemeQuery.matches ? 'dark' : 'light') : theme)\n\n enableTransitions?.()\n }\n\n applyTheme()\n\n // With the system theme, follow the OS while the app is open.\n if (theme !== 'system') return\n darkSchemeQuery.addEventListener('change', applyTheme)\n return () => darkSchemeQuery.removeEventListener('change', applyTheme)\n }, [theme, disableTransitionOnChange])\n\n const value = {\n theme,\n setTheme: (theme: Theme) => {\n writeStoredTheme(storageKey, theme)\n setTheme(theme)\n }\n }\n\n return (\n <ThemeProviderContext.Provider {...props} value={value}>\n {children}\n </ThemeProviderContext.Provider>\n )\n}\n\nexport const useTheme = () => {\n const context = use(ThemeProviderContext)\n\n if (context === undefined || Object.keys(context).length === 0) {\n throw new Error('useTheme must be used within a ThemeProvider')\n }\n\n return context\n}\n\nexport function ModeToggle(props: ModeToggleProps) {\n const { setTheme } = useTheme()\n\n return (\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button variant=\"outline\" size=\"icon\" {...props}>\n <IconSun className=\"h-[1.2rem] w-[1.2rem] scale-100 rotate-0 transition-all dark:scale-0 dark:-rotate-90\" />\n <IconMoon className=\"absolute h-[1.2rem] w-[1.2rem] scale-0 rotate-90 transition-all dark:scale-100 dark:rotate-0\" />\n <span className=\"sr-only\">Toggle theme</span>\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\">\n <DropdownMenuItem onClick={() => setTheme('light')}>Light</DropdownMenuItem>\n <DropdownMenuItem onClick={() => setTheme('dark')}>Dark</DropdownMenuItem>\n <DropdownMenuItem onClick={() => setTheme('system')}>System</DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n )\n}\n"],"mappings":"iYAoCA,MAAMA,EAAuBC,EAAc,CAAC,CAAuB,EAEnE,SAAS,kBAAmB,CAC1B,IAAMC,EAAM,SAAS,cAAc,OAAO,EAS1C,OAPAA,EAAI,YACF,SAAS,eACP,6KACF,CACF,EACA,SAAS,KAAK,YAAYA,CAAG,MAEhB,CACX,OAAO,iBAAiB,SAAS,IAAI,EAErC,eAAiB,CACf,SAAS,KAAK,YAAYA,CAAG,CAC/B,EAAG,CAAC,CACN,CACF,CAGA,SAAS,gBAAgB,EAAoB,EAAqB,CAChE,GAAI,CACF,OAAQ,OAAO,aAAa,QAAQC,CAAU,GAAsBC,CACtE,MAAQ,CACN,OAAOA,CACT,CACF,CAEA,SAAS,iBAAiB,EAAoB,EAAc,CAC1D,GAAI,CACF,OAAO,aAAa,QAAQD,EAAYE,CAAK,CAC/C,MAAQ,CAAC,CACX,CAEA,SAAgB,cAAc,CAC5B,WACA,eAAe,SACf,aAAa,gBACb,4BAA4B,GAC5B,GAAGC,GACkB,CACrB,GAAM,CAACD,EAAOE,GAAYC,MAAsB,gBAAgBL,EAAYC,CAAY,CAAC,EAEzFK,MAAgB,CACd,IAAMC,EAAO,OAAO,SAAS,gBACvBC,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YAAehB,EAAS,MAAM,EAAG,SAAA,MAAsB,CAAA,EACzE,kBAACgB,EAAD,CAAkB,YAAehB,EAAS,QAAQ,EAAG,SAAA,QAAwB,CAAA,CAC1D,CACT,CAAA,CAAA,CAAA,CAAA,CAElB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as __name } from "../rolldown-runtime-BhWHdk3m.js";
|
|
2
|
-
import { VariantProps } from "class-variance-authority";
|
|
3
2
|
import * as React from "react";
|
|
3
|
+
import { VariantProps } from "class-variance-authority";
|
|
4
4
|
//#region src/components/timeline.d.ts
|
|
5
5
|
declare const timelineVariants: (props?: ({
|
|
6
6
|
size?: "lg" | "md" | "sm" | null | undefined;
|
|
@@ -18,25 +18,48 @@ export type TimelineConnectorColor = NonNullable<VariantProps<typeof timelineCon
|
|
|
18
18
|
export type TimelineIconColor = NonNullable<VariantProps<typeof timelineIconVariants>['color']>;
|
|
19
19
|
export type TimelineStatus = NonNullable<VariantProps<typeof timelineConnectorVariants>['status']>;
|
|
20
20
|
export type TimelineProps = React.ComponentProps<'ol'> & VariantProps<typeof timelineVariants> & {
|
|
21
|
+
/** Icon size for every item. */
|
|
21
22
|
iconSize?: TimelineIconSize;
|
|
22
23
|
};
|
|
23
24
|
declare const Timeline: React.ForwardRefExoticComponent<Omit<TimelineProps, "ref"> & React.RefAttributes<HTMLOListElement>>;
|
|
24
25
|
export type TimelineItemProps = React.ComponentProps<'li'> & {
|
|
26
|
+
/** Date shown next to the icon. ISO strings and timestamps are also exposed as machine-readable dates. */
|
|
25
27
|
date?: React.ReactNode;
|
|
28
|
+
/** Item title. */
|
|
26
29
|
title?: React.ReactNode;
|
|
30
|
+
/** Text below the title. */
|
|
27
31
|
description?: React.ReactNode;
|
|
32
|
+
/** Icon inside the circle. */
|
|
28
33
|
icon?: React.ReactNode;
|
|
34
|
+
/** Background color of the icon. */
|
|
29
35
|
iconColor?: TimelineIconColor;
|
|
36
|
+
/**
|
|
37
|
+
* Progress of the item; sets the connector color. `in-progress` marks it as the current step.
|
|
38
|
+
* @default 'completed'
|
|
39
|
+
*/
|
|
30
40
|
status?: TimelineStatus;
|
|
41
|
+
/** Overrides the connector color. */
|
|
31
42
|
connectorColor?: TimelineConnectorColor;
|
|
43
|
+
/**
|
|
44
|
+
* Shows the line to the next item.
|
|
45
|
+
* @default true
|
|
46
|
+
*/
|
|
32
47
|
showConnector?: boolean;
|
|
48
|
+
/** Icon size for this item. Defaults to the timeline `iconSize`. */
|
|
33
49
|
iconSize?: TimelineIconSize;
|
|
50
|
+
/**
|
|
51
|
+
* Renders a skeleton instead of the item.
|
|
52
|
+
* @default false
|
|
53
|
+
*/
|
|
34
54
|
loading?: boolean;
|
|
55
|
+
/** Renders the item as failed, with this message. */
|
|
35
56
|
error?: React.ReactNode;
|
|
36
57
|
};
|
|
37
58
|
declare const TimelineItem: React.ForwardRefExoticComponent<Omit<TimelineItemProps, "ref"> & React.RefAttributes<HTMLLIElement>>;
|
|
38
59
|
export type TimelineTimeProps = React.ComponentProps<'time'> & {
|
|
60
|
+
/** Date to format (`Date`, timestamp or ISO string). */
|
|
39
61
|
date?: string | Date | number;
|
|
62
|
+
/** `Intl.DateTimeFormat` options merged over the defaults. */
|
|
40
63
|
format?: Intl.DateTimeFormatOptions;
|
|
41
64
|
};
|
|
42
65
|
declare const TimelineTime: React.ForwardRefExoticComponent<Omit<TimelineTimeProps, "ref"> & React.RefAttributes<HTMLTimeElement>>;
|
|
@@ -47,6 +70,7 @@ declare const TimelineHeader: React.ForwardRefExoticComponent<Omit<React.Detaile
|
|
|
47
70
|
export type TimelineTitleProps = React.ComponentProps<'h3'>;
|
|
48
71
|
declare const TimelineTitle: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, "ref"> & React.RefAttributes<HTMLHeadingElement>>;
|
|
49
72
|
export type TimelineIconProps = React.ComponentProps<'div'> & VariantProps<typeof timelineIconVariants> & {
|
|
73
|
+
/** Icon inside the circle. */
|
|
50
74
|
icon?: React.ReactNode;
|
|
51
75
|
};
|
|
52
76
|
declare const TimelineIcon: React.ForwardRefExoticComponent<Omit<TimelineIconProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../rolldown-runtime-BhWHdk3m.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
|
|
1
|
+
import"../rolldown-runtime-BhWHdk3m.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*as r from"react";import{jsx as i,jsxs as a}from"react/jsx-runtime";import{cva as o}from"class-variance-authority";const s=o(`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=o(`relative w-full last:mb-0`,{variants:{tone:{default:`mb-2`,error:`mb-2`}},defaultVariants:{tone:`default`}}),l=o(`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=o(`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=o(`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=r.forwardRef(({className:t,iconSize:n,size:a=`md`,children:o,...c},l)=>{let u=flattenFragments(o),d=u.filter(isTimelineItemElement).length;if(u.length===0)return/* @__PURE__ */ i(`ol`,{ref:l,"aria-label":`Timeline`,"data-slot":`timeline`,"data-size":a,className:e(s({size:a}),t),...c,children:/* @__PURE__ */ i(`li`,{className:`list-none`,children:/* @__PURE__ */ i(S,{})})});let f=0;return/* @__PURE__ */ i(`ol`,{ref:l,"aria-label":`Timeline`,"data-slot":`timeline`,"data-size":a,className:e(s({size:a}),t),...c,children:u.map(e=>{if(!isTimelineItemElement(e))return e;let t=f===d-1;return f+=1,r.cloneElement(e,{iconSize:e.props.iconSize??n,showConnector:e.props.showConnector??!t})})})});f.displayName=`Timeline`;const p=r.forwardRef(({className:r,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?/* @__PURE__ */ i(`li`,{ref:D,"aria-busy":`true`,"data-slot":`timeline-item`,"data-status":p,className:e(c(),r),...E,children:/* @__PURE__ */ a(`div`,{className:`grid grid-cols-[minmax(auto,8rem)_auto_1fr] items-start px-4`,children:[/* @__PURE__ */ i(`div`,{className:`pr-4 text-right`,children:/* @__PURE__ */ i(`div`,{className:`h-4 w-24 animate-pulse rounded bg-muted`})}),/* @__PURE__ */ a(`div`,{className:`mx-3 flex flex-col items-center justify-start gap-y-2`,children:[/* @__PURE__ */ i(`div`,{className:`relative flex h-8 w-8 animate-pulse items-center justify-center rounded-full bg-muted ring-8 ring-background`,children:/* @__PURE__ */ i(t,{})}),S&&/* @__PURE__ */ i(`div`,{className:`h-full w-0.5 animate-pulse bg-muted`})]}),/* @__PURE__ */ i(`div`,{className:`flex flex-col gap-2 pl-2`,children:/* @__PURE__ */ a(`div`,{className:`space-y-2`,children:[/* @__PURE__ */ i(`div`,{className:`h-4 w-24 animate-pulse rounded bg-muted`}),/* @__PURE__ */ i(`div`,{className:`h-3 w-48 animate-pulse rounded bg-muted`})]})})]})}):T?/* @__PURE__ */ i(`li`,{ref:D,role:`alert`,"data-slot":`timeline-item`,"data-status":`error`,className:e(c({tone:`error`}),r),...E,children:/* @__PURE__ */ a(`div`,{className:`grid grid-cols-[minmax(auto,8rem)_auto_1fr] items-start px-4`,children:[/* @__PURE__ */ i(`div`,{className:`pr-4 text-right`,children:/* @__PURE__ */ i(h,{className:`text-destructive`,dateTime:getItemDateTime(s),children:s})}),/* @__PURE__ */ a(`div`,{className:`mx-3 flex flex-col items-center justify-start gap-y-2`,children:[/* @__PURE__ */ i(`div`,{className:`relative flex h-8 w-8 items-center justify-center rounded-full bg-destructive/20 ring-8 ring-background`,children:/* @__PURE__ */ i(n,{className:`h-4 w-4 text-destructive`})}),S&&/* @__PURE__ */ i(g,{color:`destructive`,className:`h-full`})]}),/* @__PURE__ */ a(`div`,{className:`flex flex-col gap-2 pl-2`,children:[/* @__PURE__ */ i(_,{children:/* @__PURE__ */ i(v,{className:`text-destructive`,children:l||`Error`})}),/* @__PURE__ */ i(b,{className:`text-destructive`,children:T})]})]})}):o==null?/* @__PURE__ */ i(`li`,{ref:D,"data-slot":`timeline-item`,"data-status":p,className:e(c(),r),"aria-current":p===`in-progress`?`step`:void 0,...E,children:/* @__PURE__ */ a(`div`,{className:`grid grid-cols-[1fr_auto_1fr] items-start gap-4`,children:[/* @__PURE__ */ i(`div`,{className:`flex flex-col justify-start pt-1`,children:/* @__PURE__ */ i(h,{className:`pr-4 text-right`,dateTime:getItemDateTime(s),children:s})}),/* @__PURE__ */ a(`div`,{className:`flex flex-col items-center`,children:[/* @__PURE__ */ i(`div`,{className:`relative z-10`,children:/* @__PURE__ */ i(y,{icon:d,color:f??(p===`pending`?`muted`:`primary`),size:C})}),S&&/* @__PURE__ */ i(g,{status:p,color:m,className:`mt-2 h-16`})]}),/* @__PURE__ */ a(x,{children:[/* @__PURE__ */ i(_,{children:/* @__PURE__ */ i(v,{children:l})}),/* @__PURE__ */ i(b,{children:u})]})]})}):/* @__PURE__ */ i(`li`,{ref:D,"data-slot":`timeline-item`,"data-status":p,className:e(c(),r),"aria-current":p===`in-progress`?`step`:void 0,...E,children:o}));p.displayName=`TimelineItem`;const m={year:`numeric`,month:`short`,day:`2-digit`},h=r.forwardRef(({className:t,date:n,format:a,children:o,...s},c)=>{let l=r.useMemo(()=>getValidDate(n),[n]),u=r.useMemo(()=>l?new Intl.DateTimeFormat(`en-US`,{...m,...a}).format(l):``,[l,a]);return/* @__PURE__ */ i(`time`,{ref:c,"data-slot":`timeline-time`,dateTime:l?.toISOString(),className:e(`text-sm font-medium tracking-tight text-muted-foreground`,t),...s,children:o||u})});h.displayName=`TimelineTime`;const g=r.forwardRef(({className:t,status:n=`completed`,color:r,...a},o)=>/* @__PURE__ */ i(`div`,{ref:o,"data-slot":`timeline-connector`,"data-status":n,"data-color":r,className:e(l(r?{color:r}:{status:n}),t),...a}));g.displayName=`TimelineConnector`;const _=r.forwardRef(({className:t,...n},r)=>/* @__PURE__ */ i(`div`,{ref:r,"data-slot":`timeline-header`,className:e(`flex items-center gap-4`,t),...n}));_.displayName=`TimelineHeader`;const v=r.forwardRef(({className:t,...n},r)=>/* @__PURE__ */ i(`h3`,{ref:r,"data-slot":`timeline-title`,className:e(`font-semibold leading-none tracking-tight text-secondary-foreground`,t),...n}));v.displayName=`TimelineTitle`;const y=r.forwardRef(({className:t,color:n=`primary`,icon:r,size:a=`md`,...o},s)=>/* @__PURE__ */ i(`div`,{ref:s,"data-slot":`timeline-icon`,"data-color":n,"data-size":a,className:e(u({color:n,size:a}),t),...o,children:r?/* @__PURE__ */ i(`div`,{className:d({size:a}),children:r}):/* @__PURE__ */ i(`div`,{className:e(`rounded-full`,d({size:a}))})}));y.displayName=`TimelineIcon`;const b=r.forwardRef(({className:t,...n},r)=>/* @__PURE__ */ i(`p`,{ref:r,"data-slot":`timeline-description`,className:e(`max-w-sm text-sm text-muted-foreground`,t),...n}));b.displayName=`TimelineDescription`;const x=r.forwardRef(({className:t,...n},r)=>/* @__PURE__ */ i(`div`,{ref:r,"data-slot":`timeline-content`,className:e(`flex flex-col gap-2 pl-2`,t),...n}));x.displayName=`TimelineContent`;const S=r.forwardRef(({className:t,children:n,...r},a)=>/* @__PURE__ */ i(`div`,{ref:a,"data-slot":`timeline-empty`,className:e(`flex flex-col items-center justify-center p-8 text-center`,t),...r,children:/* @__PURE__ */ i(`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}const C=/^\d{4}-\d{2}-\d{2}(T[\d:.]+(Z|[+-]\d{2}:?\d{2})?)?$/;function getItemDateTime(e){if(typeof e==`number`)return getValidDate(e)?.toISOString();if(typeof e==`string`&&C.test(e.trim())&&getValidDate(e.trim()))return e.trim()}function flattenFragments(e,t=``){return r.Children.toArray(e).flatMap(e=>r.isValidElement(e)&&e.type===r.Fragment?flattenFragments(e.props.children,`${t}${e.key}/`):t&&r.isValidElement(e)?[r.cloneElement(e,{key:`${t}${e.key}`})]:[e])}function isTimelineItemElement(e){return r.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
2
|
//# sourceMappingURL=timeline.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeline.js","names":["React","timelineVariants","cva","timelineItemVariants","timelineConnectorVariants","timelineIconVariants","timelineIconContentVariants","Timeline","props","totalItems","children","size","cn","className","TimelineEmpty","itemIndex","child","isLastItem","iconSize","TimelineItem","loading","status","Spinner","showConnector","error","TimelineTime","date","IconAlertCircle","TimelineConnector","TimelineHeader","TimelineTitle","title","TimelineDescription","TimelineIcon","iconColor","connectorColor","TimelineContent","description","defaultDateFormat","dateValue","formattedDate","format","color","icon","parsedDate"],"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":"mSAQA,MAAMC,EAAmBC,EAAI,mFAAoF,CAC/G,SAAU,CACR,KAAM,CACJ,GAAI,QACJ,GAAI,QACJ,GAAI,OACN,CACF,EACA,gBAAiB,CACf,KAAM,IACR,CACF,CAAC,EAEKC,EAAuBD,EAAI,4BAA6B,CAC5D,SAAU,CACR,KAAM,CACJ,QAAS,OACT,MAAO,MACT,CACF,EACA,gBAAiB,CACf,KAAM,SACR,CACF,CAAC,EAEKE,EAA4BF,EAAI,QAAS,C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,8BAAkC,CAAA,CACzF,CAAA,CACN,EACD,EAAc,YAAc,gBAE5B,SAAS,aAAa,EAA+B,CACnD,GAAIgB,GAAQ,MAAQA,IAAS,GAC3B,OAAO,KAGT,IAAMkB,EAAalB,aAAgB,KAAOA,EAAO,IAAI,KAAKA,CAAI,EAE9D,OAAO,OAAO,MAAMkB,EAAW,QAAQ,CAAC,EAAI,KAAOA,CACrD,CAEA,SAAS,sBAAsB,EAAwE,CACrG,OAAO5C,EAAM,eAAegB,CAAK,GAAKA,EAAM,OAASG,CACvD"}
|
|
1
|
+
{"version":3,"file":"timeline.js","names":["React","timelineVariants","cva","timelineItemVariants","timelineConnectorVariants","timelineIconVariants","timelineIconContentVariants","Timeline","props","childArray","children","totalItems","size","cn","className","TimelineEmpty","itemIndex","child","isLastItem","iconSize","TimelineItem","loading","status","Spinner","showConnector","error","TimelineTime","date","IconAlertCircle","TimelineConnector","TimelineHeader","TimelineTitle","title","TimelineDescription","TimelineIcon","iconColor","connectorColor","TimelineContent","description","defaultDateFormat","dateValue","formattedDate","format","color","icon","parsedDate","ISO_DATE_PATTERN","keyPrefix"],"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 /** Icon size for every item. */\n iconSize?: TimelineIconSize\n }\n\nconst Timeline = React.forwardRef<HTMLOListElement, TimelineProps>(\n ({ className, iconSize, size = 'md', children, ...props }, ref) => {\n const childArray = flattenFragments(children)\n const totalItems = childArray.filter(isTimelineItemElement).length\n\n if (childArray.length === 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 {childArray.map((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 shown next to the icon. ISO strings and timestamps are also exposed as machine-readable dates. */\n date?: React.ReactNode\n /** Item title. */\n title?: React.ReactNode\n /** Text below the title. */\n description?: React.ReactNode\n /** Icon inside the circle. */\n icon?: React.ReactNode\n /** Background color of the icon. */\n iconColor?: TimelineIconColor\n /**\n * Progress of the item; sets the connector color. `in-progress` marks it as the current step.\n * @default 'completed'\n */\n status?: TimelineStatus\n /** Overrides the connector color. */\n connectorColor?: TimelineConnectorColor\n /**\n * Shows the line to the next item.\n * @default true\n */\n showConnector?: boolean\n /** Icon size for this item. Defaults to the timeline `iconSize`. */\n iconSize?: TimelineIconSize\n /**\n * Renders a skeleton instead of the item.\n * @default false\n */\n loading?: boolean\n /** Renders the item as failed, with this message. */\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\" dateTime={getItemDateTime(date)}>\n {date}\n </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\" dateTime={getItemDateTime(date)}>\n {date}\n </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 to format (`Date`, timestamp or ISO string). */\n date?: string | Date | number\n /** `Intl.DateTimeFormat` options merged over the defaults. */\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 inside the circle. */\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\n// Matches ISO 8601 dates (`2024-01-15`, `2024-01-15T10:30:00Z`). Other formats such as `01/02/2024` are\n// ambiguous across locales, so they are shown as given without a machine-readable `dateTime`.\nconst ISO_DATE_PATTERN = /^\\d{4}-\\d{2}-\\d{2}(T[\\d:.]+(Z|[+-]\\d{2}:?\\d{2})?)?$/\n\nfunction getItemDateTime(date: React.ReactNode) {\n if (typeof date === 'number') {\n return getValidDate(date)?.toISOString()\n }\n if (typeof date === 'string' && ISO_DATE_PATTERN.test(date.trim()) && getValidDate(date.trim())) {\n return date.trim()\n }\n return undefined\n}\n\n// Opens fragments so items inside them count as items (empty state, last connector, `iconSize`). Keys are\n// prefixed with the fragment key so items from sibling fragments never collide.\nfunction flattenFragments(children: React.ReactNode, keyPrefix = ''): React.ReactNode[] {\n return React.Children.toArray(children).flatMap((child) => {\n if (React.isValidElement<{ children?: React.ReactNode }>(child) && child.type === React.Fragment) {\n return flattenFragments(child.props.children, `${keyPrefix}${child.key}/`)\n }\n if (keyPrefix && React.isValidElement(child)) {\n return [React.cloneElement(child, { key: `${keyPrefix}${child.key}` })]\n }\n return [child]\n })\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":"mSAQA,MAAMC,EAAmBC,EAAI,mFAAoF,CAC/G,SAAU,CACR,KAAM,CACJ,GAAI,QACJ,GAAI,QACJ,GAAI,OACN,CACF,EACA,gBAAiB,CACf,KAAM,IACR,CACF,CAAC,EAEKC,EAAuBD,EAAI,4BAA6B,CAC5D,SAAU,CACR,KAAM,CACJ,QAAS,OACT,MAAO,MACT,CACF,EACA,gBAAiB,CACf,KAAM,SACR,CACF,CAAC,EAEKE,EAA4BF,EAAI,QAAS,CAC7C,SAAU,CACR,OAAQ,CACN,UAAW,aACX,cAAe,YACf,QAAS,UACX,EACA,MAAO,CACL,QAAS,aACT,UAAW,eACX,MAAO,WACP,OAAQ,YACR,YAAa,iBACb,SAAU,sCACZ,CACF,CACF,CAAC,EAEKG,EAAuBH,EAC3B,0FACA,CACE,SAAU,CACR,MAAO,CACL,QAAS,qCACT,UAAW,yCACX,MAAO,iCACP,OAAQ,mCACR,YAAa,4CACf,EACA,KAAM,CACJ,GAAI,UACJ,GAAI,YACJ,GAAI,WACN,CACF,EACA,gBAAiB,CACf,MAAO,UACP,KAAM,IACR,CACF,CACF,EAEMI,EAA8BJ,EAAI,mCAAoC,CAC1E,SAAU,CACR,KAAM,CACJ,GAAI,UACJ,GAAI,UACJ,GAAI,SACN,CACF,EACA,gBAAiB,CACf,KAAM,IACR,CACF,CAAC,EAaKK,EAAWP,EAAM,YACpB,CAAE,YAAW,WAAU,OAAO,KAAM,WAAU,GAAGQ,GAAS,IAAQ,CAC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AAS,QAAQU,CAAQ,CAAC,CAAC,QAAS,GAC3CV,EAAM,eAA+CiB,CAAK,GAAKA,EAAM,OAASjB,EAAM,SAC/E,iBAAiBiB,EAAM,MAAM,SAAU,GAAG8B,IAAY9B,EAAM,IAAI,EAAE,EAEvE8B,GAAa/C,EAAM,eAAeiB,CAAK,EAClC,CAACjB,EAAM,aAAaiB,EAAO,CAAE,IAAK,GAAG8B,IAAY9B,EAAM,KAAM,CAAC,CAAC,EAEjE,CAACA,CAAK,CACd,CACH,CAEA,SAAS,sBAAsB,EAAwE,CACrG,OAAOjB,EAAM,eAAeiB,CAAK,GAAKA,EAAM,OAASG,CACvD"}
|
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
import { t as __name } from "../rolldown-runtime-BhWHdk3m.js";
|
|
2
|
+
import { t as AsChildPrimitiveProps } from "../as-child-Dxg3Xo1G.js";
|
|
2
3
|
import { toggleVariants } from "./toggle.js";
|
|
3
|
-
import { ToggleGroup as ToggleGroup$1 } from "radix-ui";
|
|
4
|
-
import { VariantProps } from "class-variance-authority";
|
|
5
4
|
import * as React from "react";
|
|
5
|
+
import { VariantProps } from "class-variance-authority";
|
|
6
|
+
import { Toggle } from "@base-ui/react/toggle";
|
|
7
|
+
import { ToggleGroup as ToggleGroup$1 } from "@base-ui/react/toggle-group";
|
|
6
8
|
//#region src/components/toggle-group.d.ts
|
|
7
|
-
export type ToggleGroupProps =
|
|
9
|
+
export type ToggleGroupProps = AsChildPrimitiveProps<typeof ToggleGroup$1> & VariantProps<typeof toggleVariants> & {
|
|
10
|
+
/**
|
|
11
|
+
* Gap between items, in Tailwind spacing units. `0` joins them into one control.
|
|
12
|
+
* @default 0
|
|
13
|
+
*/
|
|
8
14
|
spacing?: number;
|
|
15
|
+
/**
|
|
16
|
+
* Layout and arrow-key direction.
|
|
17
|
+
* @default 'horizontal'
|
|
18
|
+
*/
|
|
9
19
|
orientation?: 'horizontal' | 'vertical';
|
|
10
20
|
};
|
|
11
|
-
export type ToggleGroupItemProps =
|
|
12
|
-
declare function ToggleGroup({ className, variant, color, size, spacing, orientation, children, ...props }: ToggleGroupProps): React.JSX.Element;
|
|
13
|
-
declare function ToggleGroupItem({ className, children, variant, color, size, ...props }: ToggleGroupItemProps): React.JSX.Element;
|
|
21
|
+
export type ToggleGroupItemProps = AsChildPrimitiveProps<typeof Toggle> & VariantProps<typeof toggleVariants>;
|
|
22
|
+
declare function ToggleGroup({ className, variant, color, size, spacing, orientation, children, asChild, ...props }: ToggleGroupProps): React.JSX.Element;
|
|
23
|
+
declare function ToggleGroupItem({ className, children, variant, color, size, asChild, ...props }: ToggleGroupItemProps): React.JSX.Element;
|
|
14
24
|
//#endregion
|
|
15
25
|
export { ToggleGroup, ToggleGroupItem };
|
|
16
26
|
//# sourceMappingURL=toggle-group.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../rolldown-runtime-BhWHdk3m.js";import{
|
|
1
|
+
import"../rolldown-runtime-BhWHdk3m.js";import{toAsChildRenderProps as e}from"../lib/as-child.js";import{cn as t}from"../lib/utils.js";import{t as n}from"../resolve-class-name-BurP8ngI.js";import{toggleVariants as r}from"./toggle.js";import*as i from"react";import{jsx as a}from"react/jsx-runtime";import{Toggle as o}from"@base-ui/react/toggle";import{ToggleGroup as s}from"@base-ui/react/toggle-group";const c=i.createContext({size:`md`,variant:`ghost`,color:`primary`,spacing:0,orientation:`horizontal`});function ToggleGroup({className:r,variant:i,color:o,size:l,spacing:u=0,orientation:d=`horizontal`,children:f,asChild:p,...m}){return/* @__PURE__ */ a(c.Provider,{value:{variant:i,color:o,size:l,spacing:u,orientation:d},children:/* @__PURE__ */ a(s,{"data-slot":`toggle-group`,"data-variant":i??`ghost`,"data-color":o??`primary`,"data-size":l??`md`,"data-spacing":u,"data-orientation":d,orientation:d,style:{"--gap":u},className:e=>t(`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`,n(r,e)),...m,...e(p,f)})})}function ToggleGroupItem({className:s,children:l,variant:u=`ghost`,color:d=`primary`,size:f=`md`,asChild:p,...m}){let h=i.useContext(c);return/* @__PURE__ */ a(o,{"data-slot":`toggle-group-item`,"data-variant":h.variant||u,"data-color":h.color||d,"data-size":h.size||f,"data-spacing":h.spacing,className:e=>t(`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`,`group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=secondary]:border-l-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=secondary]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=secondary]:first:border-l group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=secondary]:first:border-t`,r({variant:h.variant||u,color:h.color||d,size:h.size||f}),n(s,e)),...m,...e(p,l),children:!p&&l})}export{ToggleGroup,ToggleGroupItem};
|
|
2
2
|
//# sourceMappingURL=toggle-group.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggle-group.js","names":["ToggleGroupPrimitive","
|
|
1
|
+
{"version":3,"file":"toggle-group.js","names":["ToggleGroupPrimitive","TogglePrimitive","resolveClassName","React","ToggleGroup$1","ToggleGroupContext","props","variant","color","size","spacing","orientation","cn","className","state","toAsChildRenderProps","asChild","children","context","Toggle","toggleVariants"],"sources":["../../src/components/toggle-group.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport { Toggle as TogglePrimitive } from '@base-ui/react/toggle'\nimport { ToggleGroup as ToggleGroupPrimitive } from '@base-ui/react/toggle-group'\nimport type { VariantProps } from 'class-variance-authority'\n\nimport { type AsChildPrimitiveProps, toAsChildRenderProps } from '../lib/as-child'\nimport { cn } from '../lib/utils'\nimport { resolveClassName } from '../utils/resolve-class-name'\nimport { toggleVariants } from './toggle'\n\nconst ToggleGroupContext = React.createContext<\n VariantProps<typeof toggleVariants> & {\n spacing?: number\n orientation?: 'horizontal' | 'vertical'\n }\n>({\n size: 'md',\n variant: 'ghost',\n color: 'primary',\n spacing: 0,\n orientation: 'horizontal'\n})\n\nexport type ToggleGroupProps = AsChildPrimitiveProps<typeof ToggleGroupPrimitive> &\n VariantProps<typeof toggleVariants> & {\n /**\n * Gap between items, in Tailwind spacing units. `0` joins them into one control.\n * @default 0\n */\n spacing?: number\n /**\n * Layout and arrow-key direction.\n * @default 'horizontal'\n */\n orientation?: 'horizontal' | 'vertical'\n }\n\nexport type ToggleGroupItemProps = AsChildPrimitiveProps<typeof TogglePrimitive> & VariantProps<typeof toggleVariants>\n\nfunction ToggleGroup({\n className,\n variant,\n color,\n size,\n spacing = 0,\n orientation = 'horizontal',\n children,\n asChild,\n ...props\n}: ToggleGroupProps) {\n return (\n <ToggleGroupContext.Provider value={{ variant, color, size, spacing, orientation }}>\n <ToggleGroupPrimitive\n data-slot=\"toggle-group\"\n data-variant={variant ?? 'ghost'}\n data-color={color ?? 'primary'}\n data-size={size ?? 'md'}\n data-spacing={spacing}\n data-orientation={orientation}\n orientation={orientation}\n style={{ '--gap': spacing } as React.CSSProperties}\n className={(state) =>\n cn(\n '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',\n resolveClassName(className, state)\n )\n }\n {...props}\n {...toAsChildRenderProps(asChild, children)}\n />\n </ToggleGroupContext.Provider>\n )\n}\n\nfunction ToggleGroupItem({\n className,\n children,\n variant = 'ghost',\n color = 'primary',\n size = 'md',\n asChild,\n ...props\n}: ToggleGroupItemProps) {\n const context = React.useContext(ToggleGroupContext)\n\n return (\n <TogglePrimitive\n data-slot=\"toggle-group-item\"\n data-variant={context.variant || variant}\n data-color={context.color || color}\n data-size={context.size || size}\n data-spacing={context.spacing}\n className={(state) =>\n cn(\n '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',\n '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',\n 'group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=secondary]:border-l-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=secondary]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=secondary]:first:border-l group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=secondary]:first:border-t',\n toggleVariants({\n variant: context.variant || variant,\n color: context.color || color,\n size: context.size || size\n }),\n resolveClassName(className, state)\n )\n }\n {...props}\n {...toAsChildRenderProps(asChild, children)}\n >\n {!asChild && children}\n </TogglePrimitive>\n )\n}\n\nexport { ToggleGroup, ToggleGroupItem }\n"],"mappings":"mZAWA,MAAMK,EAAqBF,EAAM,cAK/B,CACA,KAAM,KACN,QAAS,QACT,MAAO,UACP,QAAS,EACT,YAAa,YACf,CAAC,EAkBD,SAAS,YAAY,CACnB,YACA,UACA,QACA,OACA,UAAU,EACV,cAAc,aACd,WACA,UACA,GAAGG,GACgB,CACnB,MACE,kBAACD,EAAmB,SAApB,CAA6B,MAAO,CAAE,UAAS,QAAO,OAAM,UAAS,aAAY,EAC/E,SAAA,kBAACL,EAAD,CACE,YAAU,eACV,eAAcO,GAAW,QACzB,aAAYC,GAAS,UACrB,YAAWC,GAAQ,KACnB,eAAcC,EACd,mBAAkBC,EACL,cACb,MAAO,CAAE,QAASD,CAAQ,EAC1B,UAAY,GACVE,EACE,oMACAV,EAAiBW,EAAWC,CAAK,CACnC,EAEF,GAAIR,EACJ,GAAIS,EAAqBC,EAASC,CAAQ,CAC3C,CAAA,CAC0B,CAAA,CAEjC,CAEA,SAAS,gBAAgB,CACvB,YACA,WACA,UAAU,QACV,QAAQ,UACR,OAAO,KACP,UACA,GAAGX,GACoB,CACvB,IAAMY,EAAUf,EAAM,WAAWE,CAAkB,EAEnD,MACE,kBAACJ,EAAD,CACE,YAAU,oBACV,eAAciB,EAAQ,SAAWX,EACjC,aAAYW,EAAQ,OAASV,EAC7B,YAAWU,EAAQ,MAAQT,EAC3B,eAAcS,EAAQ,QACtB,UAAY,GACVN,EACE,yZACA,8VACA,sWACAQ,EAAe,CACb,QAASF,EAAQ,SAAWX,EAC5B,MAAOW,EAAQ,OAASV,EACxB,KAAMU,EAAQ,MAAQT,CACxB,CAAC,EACDP,EAAiBW,EAAWC,CAAK,CACnC,EAEF,GAAIR,EACJ,GAAIS,EAAqBC,EAASC,CAAQ,EAEzC,SAAA,CAACD,GAAWC,CACE,CAAA,CAErB"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { t as __name } from "../rolldown-runtime-BhWHdk3m.js";
|
|
2
|
-
import {
|
|
2
|
+
import { t as AsChildPrimitiveProps } from "../as-child-Dxg3Xo1G.js";
|
|
3
3
|
import { VariantProps } from "class-variance-authority";
|
|
4
|
-
import
|
|
4
|
+
import { Toggle as Toggle$1 } from "@base-ui/react/toggle";
|
|
5
5
|
//#region src/components/toggle.d.ts
|
|
6
6
|
declare const toggleVariants: (props?: ({
|
|
7
7
|
variant?: "ghost" | "outline" | "secondary" | null | undefined;
|
|
8
8
|
color?: "blue" | "brand" | "gray" | "green" | "indigo" | "pink" | "primary" | "red" | "yellow" | "zinc" | null | undefined;
|
|
9
9
|
size?: "lg" | "md" | "sm" | null | undefined;
|
|
10
10
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
11
|
-
export type ToggleProps =
|
|
12
|
-
declare function Toggle({ className, variant, color, size, ...props }: ToggleProps):
|
|
11
|
+
export type ToggleProps = AsChildPrimitiveProps<typeof Toggle$1> & VariantProps<typeof toggleVariants>;
|
|
12
|
+
declare function Toggle({ className, variant, color, size, asChild, children, ...props }: ToggleProps): import("react").JSX.Element;
|
|
13
13
|
//#endregion
|
|
14
14
|
export { Toggle, toggleVariants };
|
|
15
15
|
//# sourceMappingURL=toggle.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../rolldown-runtime-BhWHdk3m.js";import{
|
|
1
|
+
import"../rolldown-runtime-BhWHdk3m.js";import{toAsChildRenderProps as e}from"../lib/as-child.js";import{cn as t}from"../lib/utils.js";import{t as n}from"../resolve-class-name-BurP8ngI.js";import{buttonColorVariants as r}from"../lib/button.js";import{jsx as i}from"react/jsx-runtime";import{cva as a}from"class-variance-authority";import{Toggle as o}from"@base-ui/react/toggle";const s=a(`group/toggle inline-flex items-center justify-center gap-1 rounded-full border border-transparent text-sm font-medium whitespace-nowrap transition-all outline-none 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-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{secondary:`border-border bg-background hover:bg-muted hover:text-foreground data-pressed:bg-muted data-pressed:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50 dark:data-pressed:bg-input/50`,outline:`border-(--button-outline-border) bg-background text-(--button-outline-foreground) hover:bg-(--button-solid) hover:text-(--button-solid-foreground) data-pressed:bg-(--button-solid) data-pressed:text-(--button-solid-foreground)`,ghost:`text-(--button-ghost-foreground) hover:bg-(--button-ghost-hover) hover:text-(--button-ghost-foreground) data-pressed:bg-(--button-ghost-hover) data-pressed:text-(--button-ghost-foreground)`},color:r,size:{sm:`h-8 min-w-8 px-1.5 text-[0.8rem]`,md:`h-9 min-w-9 px-2`,lg:`h-10 min-w-10 px-2.5`}},defaultVariants:{variant:`ghost`,color:`primary`,size:`md`}});function Toggle({className:r,variant:a=`ghost`,color:c=`primary`,size:l=`md`,asChild:u,children:d,...f}){return/* @__PURE__ */ i(o,{"data-slot":`toggle`,"data-variant":a,"data-color":c,"data-size":l,className:e=>t(s({variant:a,color:c,size:l}),n(r,e)),...f,...e(u,d)})}export{Toggle,s as toggleVariants};
|
|
2
2
|
//# sourceMappingURL=toggle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggle.js","names":["TogglePrimitive","Toggle$1","toggleVariants","cva","buttonColorVariants","props","variant","color","size","cn"],"sources":["../../src/components/toggle.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"toggle.js","names":["TogglePrimitive","resolveClassName","Toggle$1","toggleVariants","cva","buttonColorVariants","props","variant","color","size","cn","className","state","toAsChildRenderProps","asChild","children"],"sources":["../../src/components/toggle.tsx"],"sourcesContent":["import { Toggle as TogglePrimitive } from '@base-ui/react/toggle'\nimport { cva, type VariantProps } from 'class-variance-authority'\n\nimport { type AsChildPrimitiveProps, toAsChildRenderProps } from '../lib/as-child'\nimport { buttonColorVariants } from '../lib/button'\nimport { cn } from '../lib/utils'\nimport { resolveClassName } from '../utils/resolve-class-name'\n\nconst toggleVariants = cva(\n \"group/toggle inline-flex items-center justify-center gap-1 rounded-full border border-transparent text-sm font-medium whitespace-nowrap transition-all outline-none 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-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n {\n variants: {\n variant: {\n secondary:\n 'border-border bg-background hover:bg-muted hover:text-foreground data-pressed:bg-muted data-pressed:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50 dark:data-pressed:bg-input/50',\n outline:\n 'border-(--button-outline-border) bg-background text-(--button-outline-foreground) hover:bg-(--button-solid) hover:text-(--button-solid-foreground) data-pressed:bg-(--button-solid) data-pressed:text-(--button-solid-foreground)',\n ghost:\n 'text-(--button-ghost-foreground) hover:bg-(--button-ghost-hover) hover:text-(--button-ghost-foreground) data-pressed:bg-(--button-ghost-hover) data-pressed:text-(--button-ghost-foreground)'\n },\n color: buttonColorVariants,\n size: {\n sm: 'h-8 min-w-8 px-1.5 text-[0.8rem]',\n md: 'h-9 min-w-9 px-2',\n lg: 'h-10 min-w-10 px-2.5'\n }\n },\n defaultVariants: {\n variant: 'ghost',\n color: 'primary',\n size: 'md'\n }\n }\n)\n\nexport type ToggleProps = AsChildPrimitiveProps<typeof TogglePrimitive> & VariantProps<typeof toggleVariants>\n\nfunction Toggle({\n className,\n variant = 'ghost',\n color = 'primary',\n size = 'md',\n asChild,\n children,\n ...props\n}: ToggleProps) {\n return (\n <TogglePrimitive\n data-slot=\"toggle\"\n data-variant={variant}\n data-color={color}\n data-size={size}\n className={(state) => cn(toggleVariants({ variant, color, size }), resolveClassName(className, state))}\n {...props}\n {...toAsChildRenderProps(asChild, children)}\n />\n )\n}\n\nexport { Toggle, toggleVariants }\n"],"mappings":"0XAQA,MAAMG,EAAiBC,EACrB,shBACA,CACE,SAAU,CACR,QAAS,CACP,UACE,8MACF,QACE,oOACF,MACE,8LACJ,EACA,MAAOC,EACP,KAAM,CACJ,GAAI,mCACJ,GAAI,mBACJ,GAAI,sBACN,CACF,EACA,gBAAiB,CACf,QAAS,QACT,MAAO,UACP,KAAM,IACR,CACF,CACF,EAIA,SAAS,OAAO,CACd,YACA,UAAU,QACV,QAAQ,UACR,OAAO,KACP,UACA,WACA,GAAGC,GACW,CACd,MACE,kBAACN,EAAD,CACE,YAAU,SACV,eAAcO,EACd,aAAYC,EACZ,YAAWC,EACX,UAAY,GAAUC,EAAGP,EAAe,CAAE,UAAS,QAAO,MAAK,CAAC,EAAGF,EAAiBU,EAAWC,CAAK,CAAC,EACrG,GAAIN,EACJ,GAAIO,EAAqBC,EAASC,CAAQ,CAC3C,CAAA,CAEL"}
|
|
@@ -1,21 +1,28 @@
|
|
|
1
1
|
import { t as __name } from "../rolldown-runtime-BhWHdk3m.js";
|
|
2
|
-
import {
|
|
2
|
+
import { t as AsChildPrimitiveProps } from "../as-child-Dxg3Xo1G.js";
|
|
3
3
|
import * as React from "react";
|
|
4
|
+
import { Tooltip as Tooltip$1 } from "@base-ui/react/tooltip";
|
|
4
5
|
//#region src/components/tooltip.d.ts
|
|
5
6
|
export type TooltipProviderProps = React.ComponentProps<typeof Tooltip$1.Provider>;
|
|
6
7
|
export type TooltipRootProps = React.ComponentProps<typeof Tooltip$1.Root>;
|
|
7
|
-
export type TooltipTriggerProps =
|
|
8
|
-
export type TooltipContentProps = React.ComponentProps<typeof Tooltip$1.
|
|
9
|
-
export type TooltipProps =
|
|
8
|
+
export type TooltipTriggerProps = AsChildPrimitiveProps<typeof Tooltip$1.Trigger>;
|
|
9
|
+
export type TooltipContentProps = AsChildPrimitiveProps<typeof Tooltip$1.Popup> & Pick<React.ComponentProps<typeof Tooltip$1.Positioner>, 'side' | 'sideOffset' | 'align' | 'alignOffset' | 'sticky'> & Pick<React.ComponentProps<typeof Tooltip$1.Portal>, 'keepMounted'>;
|
|
10
|
+
export type TooltipProps = Pick<TooltipRootProps, 'open' | 'defaultOpen' | 'onOpenChange' | 'onOpenChangeComplete' | 'disableHoverablePopup' | 'trackCursorAxis' | 'actionsRef'> & Omit<TooltipContentProps, 'children'> & Pick<TooltipTriggerProps, 'delay' | 'closeDelay'> & {
|
|
11
|
+
/** The trigger. Must be a single element that accepts a ref and event handlers. */
|
|
10
12
|
children?: React.ReactNode;
|
|
13
|
+
/** Tooltip content. */
|
|
11
14
|
label?: React.ReactNode;
|
|
15
|
+
/**
|
|
16
|
+
* Renders only the trigger, without a tooltip.
|
|
17
|
+
* @default false
|
|
18
|
+
*/
|
|
12
19
|
disabled?: boolean;
|
|
13
20
|
};
|
|
14
|
-
declare function TooltipProvider({
|
|
21
|
+
declare function TooltipProvider({ delay, ...props }: TooltipProviderProps): React.JSX.Element;
|
|
15
22
|
declare function TooltipRoot({ ...props }: TooltipRootProps): React.JSX.Element;
|
|
16
|
-
declare function Tooltip({ label, children, disabled, open, defaultOpen, onOpenChange,
|
|
17
|
-
declare function TooltipTrigger({ ...props }: TooltipTriggerProps): React.JSX.Element;
|
|
18
|
-
declare function TooltipContent({ className, sideOffset, children, ...props }: TooltipContentProps): React.JSX.Element;
|
|
23
|
+
declare function Tooltip({ label, children, disabled, open, defaultOpen, onOpenChange, onOpenChangeComplete, disableHoverablePopup, trackCursorAxis, actionsRef, delay, closeDelay, ...contentProps }: TooltipProps): string | number | bigint | boolean | React.JSX.Element | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | Iterable<React.ReactNode> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | React.ReactPortal | null | undefined> | null | undefined;
|
|
24
|
+
declare function TooltipTrigger({ asChild, children, ...props }: TooltipTriggerProps): React.JSX.Element;
|
|
25
|
+
declare function TooltipContent({ className, side, sideOffset, align, alignOffset, sticky, keepMounted, children, asChild, ...props }: TooltipContentProps): React.JSX.Element;
|
|
19
26
|
//#endregion
|
|
20
27
|
export { Tooltip, TooltipContent, TooltipProvider, TooltipRoot, TooltipTrigger };
|
|
21
28
|
//# sourceMappingURL=tooltip.d.ts.map
|