@uselets/ui 1.20.4 → 2.0.1
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 +22 -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 +35 -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 +32 -17
- 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 +32 -17
- package/skills/uselets-ui/references/migration-v1-to-v2.md +599 -0
- package/skills/uselets-ui/references/package-guide.md +7 -7
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../rolldown-runtime-BhWHdk3m.js";import{cn as e}from"../lib/utils.js";import{
|
|
1
|
+
import"../rolldown-runtime-BhWHdk3m.js";import{cn as e}from"../lib/utils.js";import{t}from"../resolve-class-name-BurP8ngI.js";import{useFieldControlId as n,useFieldLabelId as r}from"./field.js";import{jsx as i,jsxs as a}from"react/jsx-runtime";import{Slider as o}from"@base-ui/react/slider";function Slider({className:s,defaultValue:c,id:l,value:u,min:d=0,max:f=100,...p}){let m=n(l),h=r(),g=u??c,_=Array.isArray(g)?g.length:1;return/* @__PURE__ */ i(o.Root,{id:m,"aria-labelledby":h,"data-slot":`slider`,defaultValue:c,value:u,min:d,max:f,thumbAlignment:`edge`,className:n=>e(`data-horizontal:w-full data-vertical:h-full`,t(s,n)),...p,children:/* @__PURE__ */ a(o.Control,{"data-slot":`slider-control`,className:e(`relative flex w-full touch-none items-center select-none data-disabled:opacity-50`,`data-vertical:h-full data-vertical:min-h-40 data-vertical:w-auto data-vertical:flex-col`),children:[/* @__PURE__ */ i(o.Track,{"data-slot":`slider-track`,className:e(`relative grow overflow-hidden rounded-full bg-muted select-none`,`data-horizontal:h-1 data-horizontal:w-full`,`data-vertical:h-full data-vertical:w-1`),children:/* @__PURE__ */ i(o.Indicator,{"data-slot":`slider-range`,className:`bg-primary select-none data-horizontal:h-full data-vertical:w-full`})}),Array.from({length:_},(t,n)=>/* @__PURE__ */ i(o.Thumb,{"data-slot":`slider-thumb`,index:n,className:e(`relative block size-3 shrink-0 rounded-full border border-ring bg-white dark:bg-primary ring-ring/50`,`transition-[color,box-shadow] select-none after:absolute after:-inset-2`,`hover:ring-3 focus-visible:ring-3 focus-visible:outline-hidden active:ring-3 has-focus-visible:ring-3`,`data-disabled:pointer-events-none data-disabled:opacity-50`)},String(n)))]})})}export{Slider};
|
|
2
2
|
//# sourceMappingURL=slider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slider.js","names":["SliderPrimitive","Slider$1","
|
|
1
|
+
{"version":3,"file":"slider.js","names":["SliderPrimitive","Slider$1","props","fieldControlId","useFieldControlId","id","fieldLabelId","useFieldLabelId","currentValue","value","defaultValue","thumbCount","cn","resolveClassName","className","state","index"],"sources":["../../src/components/slider.tsx"],"sourcesContent":["import type * as React from 'react'\n\nimport { Slider as SliderPrimitive } from '@base-ui/react/slider'\n\nimport { cn } from '../lib/utils'\nimport { resolveClassName } from '../utils/resolve-class-name'\nimport { useFieldControlId, useFieldLabelId } from './field'\n\nexport type SliderProps = Omit<React.ComponentProps<typeof SliderPrimitive.Root>, 'render'>\n\nfunction Slider({ className, defaultValue, id, value, min = 0, max = 100, ...props }: SliderProps) {\n const fieldControlId = useFieldControlId(id)\n const fieldLabelId = useFieldLabelId()\n // One thumb per value: a single number (or no value, which defaults to `min`) is a one-thumb slider.\n const currentValue = value ?? defaultValue\n const thumbCount = Array.isArray(currentValue) ? currentValue.length : 1\n\n return (\n <SliderPrimitive.Root\n id={fieldControlId}\n aria-labelledby={fieldLabelId}\n data-slot=\"slider\"\n defaultValue={defaultValue}\n value={value}\n min={min}\n max={max}\n thumbAlignment=\"edge\"\n className={(state) => cn('data-horizontal:w-full data-vertical:h-full', resolveClassName(className, state))}\n {...props}\n >\n <SliderPrimitive.Control\n data-slot=\"slider-control\"\n className={cn(\n 'relative flex w-full touch-none items-center select-none data-disabled:opacity-50',\n 'data-vertical:h-full data-vertical:min-h-40 data-vertical:w-auto data-vertical:flex-col'\n )}\n >\n <SliderPrimitive.Track\n data-slot=\"slider-track\"\n className={cn(\n 'relative grow overflow-hidden rounded-full bg-muted select-none',\n 'data-horizontal:h-1 data-horizontal:w-full',\n 'data-vertical:h-full data-vertical:w-1'\n )}\n >\n <SliderPrimitive.Indicator\n data-slot=\"slider-range\"\n className=\"bg-primary select-none data-horizontal:h-full data-vertical:w-full\"\n />\n </SliderPrimitive.Track>\n {Array.from({ length: thumbCount }, (_, index) => (\n <SliderPrimitive.Thumb\n data-slot=\"slider-thumb\"\n key={String(index)}\n index={index}\n className={cn(\n 'relative block size-3 shrink-0 rounded-full border border-ring bg-white dark:bg-primary ring-ring/50',\n 'transition-[color,box-shadow] select-none after:absolute after:-inset-2',\n 'hover:ring-3 focus-visible:ring-3 focus-visible:outline-hidden active:ring-3 has-focus-visible:ring-3',\n 'data-disabled:pointer-events-none data-disabled:opacity-50'\n )}\n />\n ))}\n </SliderPrimitive.Control>\n </SliderPrimitive.Root>\n )\n}\n\nexport { Slider }\n"],"mappings":"mSAUA,SAAS,OAAO,CAAE,YAAW,eAAc,KAAI,QAAO,MAAM,EAAG,MAAM,IAAK,GAAGE,GAAsB,CACjG,IAAMC,EAAiBC,EAAkBC,CAAE,EACrCC,EAAeC,EAAgB,EAE/BC,EAAeC,GAASC,EACxBC,EAAa,MAAM,QAAQH,CAAY,EAAIA,EAAa,OAAS,EAEvE,MACE,kBAACR,EAAgB,KAAjB,CACE,GAAIG,EACJ,kBAAiBG,EACjB,YAAU,SACI,eACP,QACF,MACA,MACL,eAAe,OACf,UAAY,GAAUM,EAAG,8CAA+CC,EAAiBC,EAAWC,CAAK,CAAC,EAC1G,GAAIb,EAEJ,SAAA,kBAACF,EAAgB,QAAjB,CACE,YAAU,iBACV,UAAWY,EACT,oFACA,yFACF,EALF,SAAA,CAOE,kBAACZ,EAAgB,MAAjB,CACE,YAAU,eACV,UAAWY,EACT,kEACA,6CACA,wCACF,EAEA,SAAA,kBAACZ,EAAgB,UAAjB,CACE,YAAU,eACV,UAAU,oEACX,CAAA,CACoB,CAAA,EACtB,MAAM,KAAK,CAAE,OAAQW,CAAW,GAAI,EAAG,IACtC,kBAACX,EAAgB,MAAjB,CACE,YAAU,eAEH,QACP,UAAWY,EACT,uGACA,0EACA,wGACA,4DACF,CACD,EARM,OAAOI,CAAK,CAQlB,CACF,CACsB,GACL,CAAA,CAE1B"}
|
|
@@ -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/spinner.d.ts
|
|
5
5
|
declare const spinnerVariants: (props?: ({
|
|
6
6
|
size?: "lg" | "md" | "sm" | null | undefined;
|
|
@@ -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/stack.d.ts
|
|
5
5
|
declare const stackVariants: (props?: ({
|
|
6
6
|
align?: "baseline" | "center" | "end" | "start" | "stretch" | null | undefined;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { t as __name } from "../rolldown-runtime-BhWHdk3m.js";
|
|
2
|
-
import {
|
|
2
|
+
import { n as AsChildProps } from "../as-child-Dxg3Xo1G.js";
|
|
3
|
+
import { ReactElement } from "react";
|
|
3
4
|
//#region src/components/stepper.d.ts
|
|
4
5
|
type StepperOrientation = 'horizontal' | 'vertical';
|
|
5
6
|
type StepState = 'active' | 'completed' | 'inactive' | 'loading';
|
|
@@ -14,13 +15,9 @@ interface StepperContextValue {
|
|
|
14
15
|
setActiveStep: (step: number) => void;
|
|
15
16
|
stepsCount: number;
|
|
16
17
|
orientation: StepperOrientation;
|
|
17
|
-
registerTrigger: (node: HTMLButtonElement | null) => void;
|
|
18
|
-
triggerNodes: HTMLButtonElement[];
|
|
19
|
-
focusNext: (currentIdx: number) => void;
|
|
20
|
-
focusPrev: (currentIdx: number) => void;
|
|
21
|
-
focusFirst: () => void;
|
|
22
|
-
focusLast: () => void;
|
|
23
18
|
indicators: StepIndicators;
|
|
19
|
+
getTriggerId: (step: number) => string;
|
|
20
|
+
getContentId: (step: number) => string;
|
|
24
21
|
}
|
|
25
22
|
interface StepItemContextValue {
|
|
26
23
|
step: number;
|
|
@@ -30,42 +27,66 @@ interface StepItemContextValue {
|
|
|
30
27
|
}
|
|
31
28
|
declare function useStepper(): StepperContextValue;
|
|
32
29
|
declare function useStepItem(): StepItemContextValue;
|
|
33
|
-
|
|
30
|
+
export type StepperProps = Omit<React.ComponentProps<'div'>, 'defaultValue'> & {
|
|
31
|
+
/**
|
|
32
|
+
* Initial step (uncontrolled), starting at `1`.
|
|
33
|
+
* @default 1
|
|
34
|
+
*/
|
|
34
35
|
defaultValue?: number;
|
|
36
|
+
/** Current step (controlled). */
|
|
35
37
|
value?: number;
|
|
38
|
+
/** Called with the new step when the user moves to it. */
|
|
36
39
|
onValueChange?: (value: number) => void;
|
|
40
|
+
/**
|
|
41
|
+
* Layout of the steps.
|
|
42
|
+
* @default 'horizontal'
|
|
43
|
+
*/
|
|
37
44
|
orientation?: StepperOrientation;
|
|
45
|
+
/** Custom indicator content per state: `active`, `completed`, `inactive`, `loading`. */
|
|
38
46
|
indicators?: StepIndicators;
|
|
39
|
-
}
|
|
47
|
+
};
|
|
40
48
|
declare function Stepper({ defaultValue, value, onValueChange, orientation, className, children, indicators, ...props }: StepperProps): import("react").JSX.Element;
|
|
41
|
-
|
|
49
|
+
export type StepperItemProps = React.ComponentProps<'div'> & {
|
|
50
|
+
/** Number of this step, starting at `1`. */
|
|
42
51
|
step: number;
|
|
52
|
+
/**
|
|
53
|
+
* Marks the step as completed.
|
|
54
|
+
* @default false
|
|
55
|
+
*/
|
|
43
56
|
completed?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Prevents navigating to this step.
|
|
59
|
+
* @default false
|
|
60
|
+
*/
|
|
44
61
|
disabled?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Shows the loading indicator for this step.
|
|
64
|
+
* @default false
|
|
65
|
+
*/
|
|
45
66
|
loading?: boolean;
|
|
46
|
-
}
|
|
67
|
+
};
|
|
47
68
|
declare function StepperItem({ step, completed, disabled, loading, className, children, ...props }: StepperItemProps): import("react").JSX.Element;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
declare function StepperTrigger({ asChild, className, children, tabIndex, ...props }: StepperTriggerProps): import("react").JSX.Element;
|
|
69
|
+
export type StepperTriggerProps = AsChildProps<'button'>;
|
|
70
|
+
declare function StepperTrigger({ asChild, className, children, tabIndex, onClick, onKeyDown, ...props }: StepperTriggerProps): ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
52
71
|
export type StepperIndicatorProps = React.ComponentProps<'div'>;
|
|
53
|
-
declare function StepperIndicator({ children, className }: StepperIndicatorProps): import("react").JSX.Element;
|
|
72
|
+
declare function StepperIndicator({ children, className, ...props }: StepperIndicatorProps): import("react").JSX.Element;
|
|
54
73
|
export type StepperSeparatorProps = React.ComponentProps<'div'>;
|
|
55
|
-
declare function StepperSeparator({ className }: StepperSeparatorProps): import("react").JSX.Element;
|
|
74
|
+
declare function StepperSeparator({ className, ...props }: StepperSeparatorProps): import("react").JSX.Element;
|
|
56
75
|
export type StepperTitleProps = React.ComponentProps<'h3'>;
|
|
57
|
-
declare function StepperTitle({ children, className }: StepperTitleProps): import("react").JSX.Element;
|
|
76
|
+
declare function StepperTitle({ children, className, ...props }: StepperTitleProps): import("react").JSX.Element;
|
|
58
77
|
export type StepperDescriptionProps = React.ComponentProps<'div'>;
|
|
59
|
-
declare function StepperDescription({ children, className }: StepperDescriptionProps): import("react").JSX.Element;
|
|
78
|
+
declare function StepperDescription({ children, className, ...props }: StepperDescriptionProps): import("react").JSX.Element;
|
|
60
79
|
export type StepperNavProps = React.ComponentProps<'nav'>;
|
|
61
|
-
declare function StepperNav({ children, className }: StepperNavProps): import("react").JSX.Element;
|
|
80
|
+
declare function StepperNav({ children, className, ...props }: StepperNavProps): import("react").JSX.Element;
|
|
62
81
|
export type StepperPanelProps = React.ComponentProps<'div'>;
|
|
63
|
-
declare function StepperPanel({ children, className }: StepperPanelProps): import("react").JSX.Element;
|
|
64
|
-
|
|
82
|
+
declare function StepperPanel({ children, className, ...props }: StepperPanelProps): import("react").JSX.Element;
|
|
83
|
+
export type StepperContentProps = React.ComponentProps<'div'> & {
|
|
84
|
+
/** Step this content belongs to. */
|
|
65
85
|
value: number;
|
|
86
|
+
/** Keeps the content mounted when its step isn’t active. */
|
|
66
87
|
forceMount?: boolean;
|
|
67
|
-
}
|
|
68
|
-
declare function StepperContent({ value, forceMount, children, className }: StepperContentProps): import("react").JSX.Element | null;
|
|
88
|
+
};
|
|
89
|
+
declare function StepperContent({ value, forceMount, children, className, ...props }: StepperContentProps): import("react").JSX.Element | null;
|
|
69
90
|
//#endregion
|
|
70
|
-
export { Stepper, StepperContent,
|
|
91
|
+
export { Stepper, StepperContent, StepperDescription, StepperIndicator, StepperItem, StepperNav, StepperPanel, StepperSeparator, StepperTitle, StepperTrigger, useStepItem, useStepper };
|
|
71
92
|
//# sourceMappingURL=stepper.d.ts.map
|
|
@@ -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{Children as n,createContext as r,isValidElement as i,useCallback as a,useContext as o,useId as s,useMemo as c,useState as l}from"react";import{jsx as u}from"react/jsx-runtime";const d=r(void 0),f=r(void 0);function useStepper(){let e=o(d);if(!e)throw Error(`useStepper must be used within a Stepper`);return e}function useStepItem(){let e=o(f);if(!e)throw Error(`useStepItem must be used within a StepperItem`);return e}function Stepper({defaultValue:e=1,value:r,onValueChange:o,orientation:f=`horizontal`,className:p,children:m,indicators:h={},...g}){let[_,v]=l(e),y=s(),b=a(e=>{r===void 0&&v(e),o?.(e)},[r,o]),x=r??_,S=a(e=>`${y}-tab-${e}`,[y]),C=a(e=>`${y}-panel-${e}`,[y]),w=c(()=>({activeStep:x,setActiveStep:b,stepsCount:n.toArray(m).filter(e=>i(e)&&e.type.displayName===`StepperItem`).length,orientation:f,indicators:h,getTriggerId:S,getContentId:C}),[x,b,m,f,h,S,C]);return/* @__PURE__ */ u(d.Provider,{value:w,children:/* @__PURE__ */ u(`div`,{role:`tablist`,"aria-orientation":f,"data-slot":`stepper`,className:t(`w-full`,p),"data-orientation":f,...g,children:m})})}function StepperItem({step:e,completed:n=!1,disabled:r=!1,loading:i=!1,className:a,children:o,...s}){let{activeStep:c}=useStepper(),l=n||e<c?`completed`:c===e?`active`:`inactive`,d=i&&e===c;return/* @__PURE__ */ u(f.Provider,{value:{step:e,state:l,isDisabled:r,isLoading:d},children:/* @__PURE__ */ u(`div`,{"data-slot":`stepper-item`,className:t(`group/step flex items-center justify-center not-last:flex-1 group-data-[orientation=horizontal]/stepper-nav:flex-row group-data-[orientation=vertical]/stepper-nav:flex-col`,a),"data-state":l,...d?{"data-loading":!0}:{},...s,children:o})})}function getStepperTriggers(e){let t=e.closest(`[data-slot="stepper"]`);return t?Array.from(t.querySelectorAll(`[data-slot="stepper-trigger"]`)).filter(e=>e.closest(`[data-slot="stepper"]`)===t&&!e.matches(`:disabled, [aria-disabled="true"]`)):[]}function StepperTrigger({asChild:n=!1,className:r,children:i,tabIndex:a,onClick:o,onKeyDown:s,...c}){let{setActiveStep:l,activeStep:u,getTriggerId:d,getContentId:f}=useStepper(),{step:p,state:m,isDisabled:h,isLoading:g}=useStepItem(),_=u===p,v=n&&h,handleClick=e=>{o?.(e),!(e.defaultPrevented||h)&&l(p)},handleKeyDown=e=>{if(s?.(e),e.defaultPrevented)return;let t=getStepperTriggers(e.currentTarget),n=t.indexOf(e.currentTarget),r;switch(e.key){case`ArrowRight`:case`ArrowDown`:r=n===-1?void 0:t[(n+1)%t.length];break;case`ArrowLeft`:case`ArrowUp`:r=n===-1?void 0:t[(n-1+t.length)%t.length];break;case`Home`:r=t[0];break;case`End`:r=t[t.length-1];break;case`Enter`:case` `:e.preventDefault(),h||l(p);return;default:return}e.preventDefault(),r?.focus()};return e(`button`,{asChild:n,type:n?void 0:`button`,role:`tab`,id:d(p),"aria-selected":_,"aria-controls":f(p),"aria-disabled":v?!0:void 0,tabIndex:typeof a==`number`?a:_?0:-1,"data-slot":`stepper-trigger`,"data-state":m,"data-loading":g,disabled:n?void 0:h,className:t(`focus-visible:border-ring focus-visible:ring-ring/50 inline-flex cursor-pointer items-center outline-none focus-visible:z-10 focus-visible:ring-3 disabled:pointer-events-none disabled:opacity-60 aria-disabled:pointer-events-none aria-disabled:opacity-60`,`gap-2.5 rounded-full`,r),onClick:handleClick,onKeyDown:handleKeyDown,...c,children:i})}function StepperIndicator({children:e,className:n,...r}){let{state:i,isLoading:a}=useStepItem(),{indicators:o}=useStepper();return/* @__PURE__ */ u(`div`,{"data-slot":`stepper-indicator`,"data-state":i,className:t(`border-background bg-accent text-accent-foreground data-[state=completed]:bg-primary data-[state=completed]:text-primary-foreground data-[state=active]:bg-primary data-[state=active]:text-primary-foreground relative flex size-6 shrink-0 items-center justify-center overflow-hidden`,`rounded-full text-xs`,n),...r,children:/* @__PURE__ */ u(`div`,{className:`absolute`,children:o&&(a&&o.loading||i===`completed`&&o.completed||i===`active`&&o.active||i===`inactive`&&o.inactive)?a&&o.loading||i===`completed`&&o.completed||i===`active`&&o.active||i===`inactive`&&o.inactive:e})})}function StepperSeparator({className:e,...n}){let{state:r}=useStepItem();return/* @__PURE__ */ u(`div`,{"data-slot":`stepper-separator`,"data-state":r,className:t(`bg-muted rounded-sm group-data-[orientation=horizontal]/stepper-nav:h-0.5 group-data-[orientation=vertical]/stepper-nav:h-12 group-data-[orientation=vertical]/stepper-nav:w-0.5 m-0.5 group-data-[orientation=horizontal]/stepper-nav:flex-1`,e),...n})}function StepperTitle({children:e,className:n,...r}){let{state:i}=useStepItem();return/* @__PURE__ */ u(`h3`,{"data-slot":`stepper-title`,"data-state":i,className:t(`text-sm leading-none font-medium`,n),...r,children:e})}function StepperDescription({children:e,className:n,...r}){let{state:i}=useStepItem();return/* @__PURE__ */ u(`div`,{"data-slot":`stepper-description`,"data-state":i,className:t(`text-muted-foreground text-sm`,n),...r,children:e})}function StepperNav({children:e,className:n,...r}){let{activeStep:i,orientation:a}=useStepper();return/* @__PURE__ */ u(`nav`,{"data-slot":`stepper-nav`,"data-state":i,"data-orientation":a,className:t(`group/stepper-nav inline-flex data-[orientation=horizontal]:w-full data-[orientation=horizontal]:flex-row data-[orientation=vertical]:flex-col`,n),...r,children:e})}function StepperPanel({children:e,className:n,...r}){let{activeStep:i}=useStepper();return/* @__PURE__ */ u(`div`,{"data-slot":`stepper-panel`,"data-state":i,className:t(`w-full`,n),...r,children:e})}function StepperContent({value:e,forceMount:n,children:r,className:i,...a}){let{activeStep:o,getTriggerId:s,getContentId:c}=useStepper(),l=e===o;return!n&&!l?null:/* @__PURE__ */ u(`div`,{role:`tabpanel`,id:c(e),"aria-labelledby":s(e),"data-slot":`stepper-content`,"data-state":o,className:t(`w-full`,i,!l&&n&&`hidden`),hidden:!l&&n,...a,children:r})}export{Stepper,StepperContent,StepperDescription,StepperIndicator,StepperItem,StepperNav,StepperPanel,StepperSeparator,StepperTitle,StepperTrigger,useStepItem,useStepper};
|
|
2
2
|
//# sourceMappingURL=stepper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stepper.js","names":["StepperContext","createContext","StepItemContext","ctx","useContext","props","activeStep","setActiveStep","useState","defaultValue","triggerNodes","setTriggerNodes","registerTrigger","useCallback","node","prev","n","handleSetActiveStep","value","step","onValueChange","currentStep","focusTrigger","idx","focusNext","currentIdx","focusPrev","focusFirst","focusLast","contextValue","useMemo","Children","children","isValidElement","child","orientation","indicators","cn","className","state","completed","isLoading","loading","disabled","isSelected","id","panelId","btnRef","useRef","useEffect","myIdx","asChild","tabIndex","isDisabled","isActive","forceMount"],"sources":["../../src/components/stepper.tsx"],"sourcesContent":["import {\n Children,\n createContext,\n type HTMLAttributes,\n isValidElement,\n type ReactElement,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState\n} from 'react'\n\nimport { cn } from '../lib/utils'\n\n// Types\ntype StepperOrientation = 'horizontal' | 'vertical'\ntype StepState = 'active' | 'completed' | 'inactive' | 'loading'\ntype StepIndicators = {\n active?: React.ReactNode\n completed?: React.ReactNode\n inactive?: React.ReactNode\n loading?: React.ReactNode\n}\n\ninterface StepperContextValue {\n activeStep: number\n setActiveStep: (step: number) => void\n stepsCount: number\n orientation: StepperOrientation\n registerTrigger: (node: HTMLButtonElement | null) => void\n triggerNodes: HTMLButtonElement[]\n focusNext: (currentIdx: number) => void\n focusPrev: (currentIdx: number) => void\n focusFirst: () => void\n focusLast: () => void\n indicators: StepIndicators\n}\n\ninterface StepItemContextValue {\n step: number\n state: StepState\n isDisabled: boolean\n isLoading: boolean\n}\n\nconst StepperContext = createContext<StepperContextValue | undefined>(undefined)\nconst StepItemContext = createContext<StepItemContextValue | undefined>(undefined)\n\nfunction useStepper() {\n const ctx = useContext(StepperContext)\n if (!ctx) throw new Error('useStepper must be used within a Stepper')\n return ctx\n}\n\nfunction useStepItem() {\n const ctx = useContext(StepItemContext)\n if (!ctx) throw new Error('useStepItem must be used within a StepperItem')\n return ctx\n}\n\ninterface StepperProps extends HTMLAttributes<HTMLDivElement> {\n defaultValue?: number\n value?: number\n onValueChange?: (value: number) => void\n orientation?: StepperOrientation\n indicators?: StepIndicators\n}\n\nfunction Stepper({\n defaultValue = 1,\n value,\n onValueChange,\n orientation = 'horizontal',\n className,\n children,\n indicators = {},\n ...props\n}: StepperProps) {\n const [activeStep, setActiveStep] = useState(defaultValue)\n const [triggerNodes, setTriggerNodes] = useState<HTMLButtonElement[]>([])\n\n // Register/unregister triggers\n const registerTrigger = useCallback((node: HTMLButtonElement | null) => {\n setTriggerNodes((prev) => {\n if (node && !prev.includes(node)) {\n return [...prev, node]\n } else if (!node && prev.includes(node!)) {\n return prev.filter((n) => n !== node)\n } else {\n return prev\n }\n })\n }, [])\n\n const handleSetActiveStep = useCallback(\n (step: number) => {\n if (value === undefined) {\n setActiveStep(step)\n }\n onValueChange?.(step)\n },\n [value, onValueChange]\n )\n\n const currentStep = value ?? activeStep\n\n // Keyboard navigation logic\n const focusTrigger = useCallback(\n (idx: number) => {\n if (triggerNodes[idx]) triggerNodes[idx].focus()\n },\n [triggerNodes]\n )\n const focusNext = useCallback(\n (currentIdx: number) => focusTrigger((currentIdx + 1) % triggerNodes.length),\n [focusTrigger, triggerNodes]\n )\n const focusPrev = useCallback(\n (currentIdx: number) => focusTrigger((currentIdx - 1 + triggerNodes.length) % triggerNodes.length),\n [focusTrigger, triggerNodes]\n )\n const focusFirst = useCallback(() => focusTrigger(0), [focusTrigger])\n const focusLast = useCallback(() => focusTrigger(triggerNodes.length - 1), [focusTrigger, triggerNodes])\n\n // Context value\n const contextValue = useMemo<StepperContextValue>(\n () => ({\n activeStep: currentStep,\n setActiveStep: handleSetActiveStep,\n stepsCount: Children.toArray(children).filter(\n (child): child is ReactElement =>\n isValidElement(child) && (child.type as { displayName?: string }).displayName === 'StepperItem'\n ).length,\n orientation,\n registerTrigger,\n focusNext,\n focusPrev,\n focusFirst,\n focusLast,\n triggerNodes,\n indicators\n }),\n [\n currentStep,\n handleSetActiveStep,\n children,\n orientation,\n registerTrigger,\n triggerNodes,\n focusFirst,\n focusLast,\n focusNext,\n focusPrev,\n indicators\n ]\n )\n\n return (\n <StepperContext.Provider value={contextValue}>\n <div\n role=\"tablist\"\n aria-orientation={orientation}\n data-slot=\"stepper\"\n className={cn('w-full', className)}\n data-orientation={orientation}\n {...props}\n >\n {children}\n </div>\n </StepperContext.Provider>\n )\n}\n\ninterface StepperItemProps extends React.HTMLAttributes<HTMLDivElement> {\n step: number\n completed?: boolean\n disabled?: boolean\n loading?: boolean\n}\n\nfunction StepperItem({\n step,\n completed = false,\n disabled = false,\n loading = false,\n className,\n children,\n ...props\n}: StepperItemProps) {\n const { activeStep } = useStepper()\n\n const state: StepState = completed || step < activeStep ? 'completed' : activeStep === step ? 'active' : 'inactive'\n\n const isLoading = loading && step === activeStep\n\n return (\n <StepItemContext.Provider value={{ step, state, isDisabled: disabled, isLoading }}>\n <div\n data-slot=\"stepper-item\"\n className={cn(\n 'group/step flex items-center justify-center not-last:flex-1 group-data-[orientation=horizontal]/stepper-nav:flex-row group-data-[orientation=vertical]/stepper-nav:flex-col',\n className\n )}\n data-state={state}\n {...(isLoading ? { 'data-loading': true } : {})}\n {...props}\n >\n {children}\n </div>\n </StepItemContext.Provider>\n )\n}\n\ninterface StepperTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n asChild?: boolean\n}\n\nfunction StepperTrigger({ asChild = false, className, children, tabIndex, ...props }: StepperTriggerProps) {\n const { state, isLoading } = useStepItem()\n const stepperCtx = useStepper()\n const { setActiveStep, activeStep, registerTrigger, triggerNodes, focusNext, focusPrev, focusFirst, focusLast } =\n stepperCtx\n const { step, isDisabled } = useStepItem()\n const isSelected = activeStep === step\n const id = `stepper-tab-${step}`\n const panelId = `stepper-panel-${step}`\n\n // Register this trigger for keyboard navigation\n const btnRef = useRef<HTMLButtonElement>(null)\n useEffect(() => {\n if (btnRef.current) {\n registerTrigger(btnRef.current)\n }\n }, [registerTrigger])\n\n // Find our index among triggers for navigation\n const myIdx = useMemo(() => triggerNodes.findIndex((n: HTMLButtonElement) => n === btnRef.current), [triggerNodes])\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLButtonElement>) => {\n switch (e.key) {\n case 'ArrowRight':\n case 'ArrowDown':\n e.preventDefault()\n if (myIdx !== -1 && focusNext) focusNext(myIdx)\n break\n case 'ArrowLeft':\n case 'ArrowUp':\n e.preventDefault()\n if (myIdx !== -1 && focusPrev) focusPrev(myIdx)\n break\n case 'Home':\n e.preventDefault()\n if (focusFirst) focusFirst()\n break\n case 'End':\n e.preventDefault()\n if (focusLast) focusLast()\n break\n case 'Enter':\n case ' ':\n e.preventDefault()\n setActiveStep(step)\n break\n }\n }\n\n if (asChild) {\n return (\n <span data-slot=\"stepper-trigger\" data-state={state} className={className}>\n {children}\n </span>\n )\n }\n\n return (\n <button\n ref={btnRef}\n role=\"tab\"\n id={id}\n aria-selected={isSelected}\n aria-controls={panelId}\n tabIndex={typeof tabIndex === 'number' ? tabIndex : isSelected ? 0 : -1}\n data-slot=\"stepper-trigger\"\n data-state={state}\n data-loading={isLoading}\n className={cn(\n 'focus-visible:border-ring focus-visible:ring-ring/50 inline-flex cursor-pointer items-center outline-none focus-visible:z-10 focus-visible:ring-3 disabled:pointer-events-none disabled:opacity-60',\n 'gap-2.5 rounded-full',\n className\n )}\n onClick={() => setActiveStep(step)}\n onKeyDown={handleKeyDown}\n disabled={isDisabled}\n {...props}\n >\n {children}\n </button>\n )\n}\n\nexport type StepperIndicatorProps = React.ComponentProps<'div'>\n\nfunction StepperIndicator({ children, className }: StepperIndicatorProps) {\n const { state, isLoading } = useStepItem()\n const { indicators } = useStepper()\n\n return (\n <div\n data-slot=\"stepper-indicator\"\n data-state={state}\n className={cn(\n 'border-background bg-accent text-accent-foreground data-[state=completed]:bg-primary data-[state=completed]:text-primary-foreground data-[state=active]:bg-primary data-[state=active]:text-primary-foreground relative flex size-6 shrink-0 items-center justify-center overflow-hidden',\n 'rounded-full text-xs',\n className\n )}\n >\n <div className=\"absolute\">\n {indicators &&\n ((isLoading && indicators.loading) ||\n (state === 'completed' && indicators.completed) ||\n (state === 'active' && indicators.active) ||\n (state === 'inactive' && indicators.inactive))\n ? (isLoading && indicators.loading) ||\n (state === 'completed' && indicators.completed) ||\n (state === 'active' && indicators.active) ||\n (state === 'inactive' && indicators.inactive)\n : children}\n </div>\n </div>\n )\n}\n\nexport type StepperSeparatorProps = React.ComponentProps<'div'>\n\nfunction StepperSeparator({ className }: StepperSeparatorProps) {\n const { state } = useStepItem()\n\n return (\n <div\n data-slot=\"stepper-separator\"\n data-state={state}\n className={cn(\n 'bg-muted rounded-sm group-data-[orientation=horizontal]/stepper-nav:h-0.5 group-data-[orientation=vertical]/stepper-nav:h-12 group-data-[orientation=vertical]/stepper-nav:w-0.5 m-0.5 group-data-[orientation=horizontal]/stepper-nav:flex-1',\n className\n )}\n />\n )\n}\n\nexport type StepperTitleProps = React.ComponentProps<'h3'>\n\nfunction StepperTitle({ children, className }: StepperTitleProps) {\n const { state } = useStepItem()\n\n return (\n <h3 data-slot=\"stepper-title\" data-state={state} className={cn('text-sm leading-none font-medium', className)}>\n {children}\n </h3>\n )\n}\n\nexport type StepperDescriptionProps = React.ComponentProps<'div'>\n\nfunction StepperDescription({ children, className }: StepperDescriptionProps) {\n const { state } = useStepItem()\n\n return (\n <div data-slot=\"stepper-description\" data-state={state} className={cn('text-muted-foreground text-sm', className)}>\n {children}\n </div>\n )\n}\n\nexport type StepperNavProps = React.ComponentProps<'nav'>\n\nfunction StepperNav({ children, className }: StepperNavProps) {\n const { activeStep, orientation } = useStepper()\n\n return (\n <nav\n data-slot=\"stepper-nav\"\n data-state={activeStep}\n data-orientation={orientation}\n className={cn(\n 'group/stepper-nav inline-flex data-[orientation=horizontal]:w-full data-[orientation=horizontal]:flex-row data-[orientation=vertical]:flex-col',\n className\n )}\n >\n {children}\n </nav>\n )\n}\n\nexport type StepperPanelProps = React.ComponentProps<'div'>\n\nfunction StepperPanel({ children, className }: StepperPanelProps) {\n const { activeStep } = useStepper()\n\n return (\n <div data-slot=\"stepper-panel\" data-state={activeStep} className={cn('w-full', className)}>\n {children}\n </div>\n )\n}\n\ninterface StepperContentProps extends React.ComponentProps<'div'> {\n value: number\n forceMount?: boolean\n}\n\nfunction StepperContent({ value, forceMount, children, className }: StepperContentProps) {\n const { activeStep } = useStepper()\n const isActive = value === activeStep\n\n if (!forceMount && !isActive) {\n return null\n }\n\n return (\n <div\n data-slot=\"stepper-content\"\n data-state={activeStep}\n className={cn('w-full', className, !isActive && forceMount && 'hidden')}\n hidden={!isActive && forceMount}\n >\n {children}\n </div>\n )\n}\n\nexport {\n Stepper,\n StepperContent,\n type StepperContentProps,\n StepperDescription,\n StepperIndicator,\n StepperItem,\n type StepperItemProps,\n StepperNav,\n StepperPanel,\n type StepperProps,\n StepperSeparator,\n StepperTitle,\n StepperTrigger,\n type StepperTriggerProps,\n useStepItem,\n useStepper\n}\n"],"mappings":"oRA+CA,MAAMA,EAAiBC,EAA+C,IAAA,EAAS,EACzEC,EAAkBD,EAAgD,IAAA,EAAS,EAEjF,SAAS,YAAa,CACpB,IAAME,EAAMC,EAAWJ,CAAc,EACrC,GAAI,CAACG,EAAK,MAAU,MAAM,0CAA0C,EACpE,OAAOA,CACT,CAEA,SAAS,aAAc,CACrB,IAAMA,EAAMC,EAAWF,CAAe,EACtC,GAAI,CAACC,EAAK,MAAU,MAAM,+CAA+C,EACzE,OAAOA,CACT,CAUA,SAAS,QAAQ,CACf,eAAe,EACf,QACA,gBACA,cAAc,aACd,YACA,WACA,aAAa,CAAC,EACd,GAAGE,GACY,CACf,GAAM,CAACC,EAAYC,GAAiBC,EAASC,CAAY,EACnD,CAACC,EAAcC,GAAmBH,EAA8B,CAAC,CAAC,EAGlEI,EAAkBC,EAAa,GAAmC,CACtEF,EAAiB,GACXG,GAAQ,CAACC,EAAK,SAASD,CAAI,EACtB,CAAC,GAAGC,EAA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I,YAAU,gBAAgB,aAAYC,EAAO,UAAWF,EAAG,mCAAoCC,CAAS,EACzG,UACC,CAAA,CAER,CAIA,SAAS,mBAAmB,CAAE,WAAU,aAAsC,CAC5E,GAAM,CAAE,SAAU,YAAY,EAE9B,MACE,kBAAC,MAAD,CAAK,YAAU,sBAAsB,aAAYC,EAAO,UAAWF,EAAG,gCAAiCC,CAAS,EAC7G,UACE,CAAA,CAET,CAIA,SAAS,WAAW,CAAE,WAAU,aAA8B,CAC5D,GAAM,CAAE,aAAY,eAAgB,WAAW,EAE/C,MACE,kBAAC,MAAD,CACE,YAAU,cACV,aAAYhC,EACZ,mBAAkB6B,EAClB,UAAWE,EACT,iJACAC,CACF,EAEC,UACE,CAAA,CAET,CAIA,SAAS,aAAa,CAAE,WAAU,aAAgC,CAChE,GAAM,CAAE,cAAe,WAAW,EAElC,MACE,kBAAC,MAAD,CAAK,YAAU,gBAAgB,aAAYhC,EAAY,UAAW+B,EAAG,SAAUC,CAAS,EACrF,UACE,CAAA,CAET,CAOA,SAAS,eAAe,CAAE,QAAO,aAAY,WAAU,aAAkC,CACvF,GAAM,CAAE,cAAe,WAAW,EAC5BgB,EAAWpC,IAAUZ,EAM3B,MAJI,CAACiD,GAAc,CAACD,EACX,KAIP,kBAAC,MAAD,CACE,YAAU,kBACV,aAAYhD,EACZ,UAAW+B,EAAG,SAAUC,EAAW,CAACgB,GAAYC,GAAc,QAAQ,EACtE,OAAQ,CAACD,GAAYC,EAEpB,UACE,CAAA,CAET"}
|
|
1
|
+
{"version":3,"file":"stepper.js","names":["StepperContext","createContext","StepItemContext","ctx","useContext","props","activeStep","setActiveStep","useState","defaultValue","baseId","useId","handleSetActiveStep","useCallback","value","step","onValueChange","currentStep","getTriggerId","getContentId","contextValue","useMemo","Children","children","isValidElement","child","orientation","indicators","cn","className","state","completed","isLoading","loading","disabled","root","trigger","node","isSelected","isAriaDisabled","asChild","isDisabled","onClick","event","onKeyDown","triggers","index","target","useAsChild","tabIndex","isActive","forceMount"],"sources":["../../src/components/stepper.tsx"],"sourcesContent":["import {\n Children,\n createContext,\n isValidElement,\n type ReactElement,\n useCallback,\n useContext,\n useId,\n useMemo,\n useState\n} from 'react'\n\nimport { type AsChildProps, useAsChild } from '../lib/as-child'\nimport { cn } from '../lib/utils'\n\n// Types\ntype StepperOrientation = 'horizontal' | 'vertical'\ntype StepState = 'active' | 'completed' | 'inactive' | 'loading'\ntype StepIndicators = {\n active?: React.ReactNode\n completed?: React.ReactNode\n inactive?: React.ReactNode\n loading?: React.ReactNode\n}\n\ninterface StepperContextValue {\n activeStep: number\n setActiveStep: (step: number) => void\n stepsCount: number\n orientation: StepperOrientation\n indicators: StepIndicators\n getTriggerId: (step: number) => string\n getContentId: (step: number) => string\n}\n\ninterface StepItemContextValue {\n step: number\n state: StepState\n isDisabled: boolean\n isLoading: boolean\n}\n\nconst StepperContext = createContext<StepperContextValue | undefined>(undefined)\nconst StepItemContext = createContext<StepItemContextValue | undefined>(undefined)\n\nfunction useStepper() {\n const ctx = useContext(StepperContext)\n if (!ctx) throw new Error('useStepper must be used within a Stepper')\n return ctx\n}\n\nfunction useStepItem() {\n const ctx = useContext(StepItemContext)\n if (!ctx) throw new Error('useStepItem must be used within a StepperItem')\n return ctx\n}\n\nexport type StepperProps = Omit<React.ComponentProps<'div'>, 'defaultValue'> & {\n /**\n * Initial step (uncontrolled), starting at `1`.\n * @default 1\n */\n defaultValue?: number\n /** Current step (controlled). */\n value?: number\n /** Called with the new step when the user moves to it. */\n onValueChange?: (value: number) => void\n /**\n * Layout of the steps.\n * @default 'horizontal'\n */\n orientation?: StepperOrientation\n /** Custom indicator content per state: `active`, `completed`, `inactive`, `loading`. */\n indicators?: StepIndicators\n}\n\nfunction Stepper({\n defaultValue = 1,\n value,\n onValueChange,\n orientation = 'horizontal',\n className,\n children,\n indicators = {},\n ...props\n}: StepperProps) {\n const [activeStep, setActiveStep] = useState(defaultValue)\n const baseId = useId()\n\n const handleSetActiveStep = useCallback(\n (step: number) => {\n if (value === undefined) {\n setActiveStep(step)\n }\n onValueChange?.(step)\n },\n [value, onValueChange]\n )\n\n const currentStep = value ?? activeStep\n\n const getTriggerId = useCallback((step: number) => `${baseId}-tab-${step}`, [baseId])\n const getContentId = useCallback((step: number) => `${baseId}-panel-${step}`, [baseId])\n\n // Context value\n const contextValue = useMemo<StepperContextValue>(\n () => ({\n activeStep: currentStep,\n setActiveStep: handleSetActiveStep,\n stepsCount: Children.toArray(children).filter(\n (child): child is ReactElement =>\n isValidElement(child) && (child.type as { displayName?: string }).displayName === 'StepperItem'\n ).length,\n orientation,\n indicators,\n getTriggerId,\n getContentId\n }),\n [currentStep, handleSetActiveStep, children, orientation, indicators, getTriggerId, getContentId]\n )\n\n return (\n <StepperContext.Provider value={contextValue}>\n <div\n role=\"tablist\"\n aria-orientation={orientation}\n data-slot=\"stepper\"\n className={cn('w-full', className)}\n data-orientation={orientation}\n {...props}\n >\n {children}\n </div>\n </StepperContext.Provider>\n )\n}\n\nexport type StepperItemProps = React.ComponentProps<'div'> & {\n /** Number of this step, starting at `1`. */\n step: number\n /**\n * Marks the step as completed.\n * @default false\n */\n completed?: boolean\n /**\n * Prevents navigating to this step.\n * @default false\n */\n disabled?: boolean\n /**\n * Shows the loading indicator for this step.\n * @default false\n */\n loading?: boolean\n}\n\nfunction StepperItem({\n step,\n completed = false,\n disabled = false,\n loading = false,\n className,\n children,\n ...props\n}: StepperItemProps) {\n const { activeStep } = useStepper()\n\n const state: StepState = completed || step < activeStep ? 'completed' : activeStep === step ? 'active' : 'inactive'\n\n const isLoading = loading && step === activeStep\n\n return (\n <StepItemContext.Provider value={{ step, state, isDisabled: disabled, isLoading }}>\n <div\n data-slot=\"stepper-item\"\n className={cn(\n 'group/step flex items-center justify-center not-last:flex-1 group-data-[orientation=horizontal]/stepper-nav:flex-row group-data-[orientation=vertical]/stepper-nav:flex-col',\n className\n )}\n data-state={state}\n {...(isLoading ? { 'data-loading': true } : {})}\n {...props}\n >\n {children}\n </div>\n </StepItemContext.Provider>\n )\n}\n\nexport type StepperTriggerProps = AsChildProps<'button'>\n\n// Enabled triggers of the closest Stepper, in DOM order (nested steppers excluded).\nfunction getStepperTriggers(trigger: HTMLElement) {\n const root = trigger.closest('[data-slot=\"stepper\"]')\n if (!root) return []\n\n return Array.from(root.querySelectorAll<HTMLElement>('[data-slot=\"stepper-trigger\"]')).filter(\n (node) => node.closest('[data-slot=\"stepper\"]') === root && !node.matches(':disabled, [aria-disabled=\"true\"]')\n )\n}\n\nfunction StepperTrigger({\n asChild = false,\n className,\n children,\n tabIndex,\n onClick,\n onKeyDown,\n ...props\n}: StepperTriggerProps) {\n const { setActiveStep, activeStep, getTriggerId, getContentId } = useStepper()\n const { step, state, isDisabled, isLoading } = useStepItem()\n const isSelected = activeStep === step\n // A non-button child can't be natively disabled, so it gets `aria-disabled` instead.\n const isAriaDisabled = asChild && isDisabled\n\n const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n onClick?.(event)\n if (event.defaultPrevented || isDisabled) return\n setActiveStep(step)\n }\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLButtonElement>) => {\n onKeyDown?.(event)\n if (event.defaultPrevented) return\n\n const triggers = getStepperTriggers(event.currentTarget)\n const index = triggers.indexOf(event.currentTarget)\n let target: HTMLElement | undefined\n\n switch (event.key) {\n case 'ArrowRight':\n case 'ArrowDown':\n target = index === -1 ? undefined : triggers[(index + 1) % triggers.length]\n break\n case 'ArrowLeft':\n case 'ArrowUp':\n target = index === -1 ? undefined : triggers[(index - 1 + triggers.length) % triggers.length]\n break\n case 'Home':\n target = triggers[0]\n break\n case 'End':\n target = triggers[triggers.length - 1]\n break\n case 'Enter':\n case ' ':\n event.preventDefault()\n if (!isDisabled) setActiveStep(step)\n return\n default:\n return\n }\n\n event.preventDefault()\n target?.focus()\n }\n\n return useAsChild('button', {\n asChild,\n type: !asChild ? 'button' : undefined,\n role: 'tab',\n id: getTriggerId(step),\n 'aria-selected': isSelected,\n 'aria-controls': getContentId(step),\n 'aria-disabled': isAriaDisabled ? true : undefined,\n tabIndex: typeof tabIndex === 'number' ? tabIndex : isSelected ? 0 : -1,\n 'data-slot': 'stepper-trigger',\n 'data-state': state,\n 'data-loading': isLoading,\n disabled: asChild ? undefined : isDisabled,\n className: cn(\n 'focus-visible:border-ring focus-visible:ring-ring/50 inline-flex cursor-pointer items-center outline-none focus-visible:z-10 focus-visible:ring-3 disabled:pointer-events-none disabled:opacity-60 aria-disabled:pointer-events-none aria-disabled:opacity-60',\n 'gap-2.5 rounded-full',\n className\n ),\n onClick: handleClick,\n onKeyDown: handleKeyDown,\n ...props,\n children\n })\n}\n\nexport type StepperIndicatorProps = React.ComponentProps<'div'>\n\nfunction StepperIndicator({ children, className, ...props }: StepperIndicatorProps) {\n const { state, isLoading } = useStepItem()\n const { indicators } = useStepper()\n\n return (\n <div\n data-slot=\"stepper-indicator\"\n data-state={state}\n className={cn(\n 'border-background bg-accent text-accent-foreground data-[state=completed]:bg-primary data-[state=completed]:text-primary-foreground data-[state=active]:bg-primary data-[state=active]:text-primary-foreground relative flex size-6 shrink-0 items-center justify-center overflow-hidden',\n 'rounded-full text-xs',\n className\n )}\n {...props}\n >\n <div className=\"absolute\">\n {indicators &&\n ((isLoading && indicators.loading) ||\n (state === 'completed' && indicators.completed) ||\n (state === 'active' && indicators.active) ||\n (state === 'inactive' && indicators.inactive))\n ? (isLoading && indicators.loading) ||\n (state === 'completed' && indicators.completed) ||\n (state === 'active' && indicators.active) ||\n (state === 'inactive' && indicators.inactive)\n : children}\n </div>\n </div>\n )\n}\n\nexport type StepperSeparatorProps = React.ComponentProps<'div'>\n\nfunction StepperSeparator({ className, ...props }: StepperSeparatorProps) {\n const { state } = useStepItem()\n\n return (\n <div\n data-slot=\"stepper-separator\"\n data-state={state}\n className={cn(\n 'bg-muted rounded-sm group-data-[orientation=horizontal]/stepper-nav:h-0.5 group-data-[orientation=vertical]/stepper-nav:h-12 group-data-[orientation=vertical]/stepper-nav:w-0.5 m-0.5 group-data-[orientation=horizontal]/stepper-nav:flex-1',\n className\n )}\n {...props}\n />\n )\n}\n\nexport type StepperTitleProps = React.ComponentProps<'h3'>\n\nfunction StepperTitle({ children, className, ...props }: StepperTitleProps) {\n const { state } = useStepItem()\n\n return (\n <h3\n data-slot=\"stepper-title\"\n data-state={state}\n className={cn('text-sm leading-none font-medium', className)}\n {...props}\n >\n {children}\n </h3>\n )\n}\n\nexport type StepperDescriptionProps = React.ComponentProps<'div'>\n\nfunction StepperDescription({ children, className, ...props }: StepperDescriptionProps) {\n const { state } = useStepItem()\n\n return (\n <div\n data-slot=\"stepper-description\"\n data-state={state}\n className={cn('text-muted-foreground text-sm', className)}\n {...props}\n >\n {children}\n </div>\n )\n}\n\nexport type StepperNavProps = React.ComponentProps<'nav'>\n\nfunction StepperNav({ children, className, ...props }: StepperNavProps) {\n const { activeStep, orientation } = useStepper()\n\n return (\n <nav\n data-slot=\"stepper-nav\"\n data-state={activeStep}\n data-orientation={orientation}\n className={cn(\n 'group/stepper-nav inline-flex data-[orientation=horizontal]:w-full data-[orientation=horizontal]:flex-row data-[orientation=vertical]:flex-col',\n className\n )}\n {...props}\n >\n {children}\n </nav>\n )\n}\n\nexport type StepperPanelProps = React.ComponentProps<'div'>\n\nfunction StepperPanel({ children, className, ...props }: StepperPanelProps) {\n const { activeStep } = useStepper()\n\n return (\n <div data-slot=\"stepper-panel\" data-state={activeStep} className={cn('w-full', className)} {...props}>\n {children}\n </div>\n )\n}\n\nexport type StepperContentProps = React.ComponentProps<'div'> & {\n /** Step this content belongs to. */\n value: number\n /** Keeps the content mounted when its step isn’t active. */\n forceMount?: boolean\n}\n\nfunction StepperContent({ value, forceMount, children, className, ...props }: StepperContentProps) {\n const { activeStep, getTriggerId, getContentId } = useStepper()\n const isActive = value === activeStep\n\n if (!forceMount && !isActive) {\n return null\n }\n\n return (\n <div\n role=\"tabpanel\"\n id={getContentId(value)}\n aria-labelledby={getTriggerId(value)}\n data-slot=\"stepper-content\"\n data-state={activeStep}\n className={cn('w-full', className, !isActive && forceMount && 'hidden')}\n hidden={!isActive && forceMount}\n {...props}\n >\n {children}\n </div>\n )\n}\n\nexport {\n Stepper,\n StepperContent,\n StepperDescription,\n StepperIndicator,\n StepperItem,\n StepperNav,\n StepperPanel,\n StepperSeparator,\n StepperTitle,\n StepperTrigger,\n useStepItem,\n useStepper\n}\n"],"mappings":"oTA0CA,MAAMA,EAAiBC,EAA+C,IAAA,EAAS,EACzEC,EAAkBD,EAAgD,IAAA,EAAS,EAEjF,SAAS,YAAa,CACpB,IAAME,EAAMC,EAAWJ,CAAc,EACrC,GAAI,CAACG,EAAK,MAAU,MAAM,0CAA0C,EACpE,OAAOA,CACT,CAEA,SAAS,aAAc,CACrB,IAAMA,EAAMC,EAAWF,CAAe,EACtC,GAAI,CAACC,EAAK,MAAU,MAAM,+CAA+C,EACzE,OAAOA,CACT,CAqBA,SAAS,QAAQ,CACf,eAAe,EACf,QACA,gBACA,cAAc,aACd,YACA,WACA,aAAa,CAAC,EACd,GAAGE,GACY,CACf,GAAM,CAACC,EAAYC,GAAiBC,EAASC,CAAY,EACnDC,EAASC,EAAM,EAEfC,EAAsBC,EACzB,GAAiB,CACZC,IAAU,IAAA,IACZP,EAAcQ,CAAI,EAEpBC,IAAgBD,CAAI,CACtB,EACA,CAACD,EAAOE,CAAa,CACvB,EAEMC,EAAcH,GAASR,EAEvBY,EAAeL,EAAa,GAAiB,GAAGH,EAAO,OAAOK,IAAQ,CAACL,CAAM,CAAC,EAC9ES,EAAeN,EAAa,GAAiB,GAAGH,EAAO,SAASK,IAAQ,CAACL,CAAM,CAAC,EAGhFU,EAAeC,OACZ,CACL,WAAYJ,EACZ,cAAeL,EACf,WAAYU,EAAS,QAAQC,CAAQ,CAAC,CAAC,OACpC,GACCC,EAAeC,CAAK,GAAMA,EAAM,KAAkC,cAAgB,aACtF,CAAC,CAAC,OACF,cACA,aACA,eACA,cACF,GACA,CAACR,EAAaL,EAAqBW,EAAUG,EAAaC,E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YAAU,gBAAgB,aAAYC,EAAY,UAAWsB,EAAG,SAAUC,CAAS,EAAG,GAAIxB,EAC5F,UACE,CAAA,CAET,CASA,SAAS,eAAe,CAAE,QAAO,aAAY,WAAU,YAAW,GAAGA,GAA8B,CACjG,GAAM,CAAE,aAAY,eAAc,gBAAiB,WAAW,EACxD6C,EAAWpC,IAAUR,EAM3B,MAJI,CAAC6C,GAAc,CAACD,EACX,KAIP,kBAAC,MAAD,CACE,KAAK,WACL,GAAI/B,EAAaL,CAAK,EACtB,kBAAiBI,EAAaJ,CAAK,EACnC,YAAU,kBACV,aAAYR,EACZ,UAAWsB,EAAG,SAAUC,EAAW,CAACqB,GAAYC,GAAc,QAAQ,EACtE,OAAQ,CAACD,GAAYC,EACrB,GAAI9C,EAEH,UACE,CAAA,CAET"}
|
|
@@ -1,17 +1,31 @@
|
|
|
1
1
|
import { t as __name } from "../rolldown-runtime-BhWHdk3m.js";
|
|
2
2
|
import { UIColor } from "../lib/color.js";
|
|
3
3
|
import { LabelProps } from "./label.js";
|
|
4
|
-
import { Switch as Switch$1 } from "radix-ui";
|
|
5
4
|
import * as React from "react";
|
|
6
5
|
import { ReactNode } from "react";
|
|
6
|
+
import { Switch as Switch$1 } from "@base-ui/react/switch";
|
|
7
7
|
//#region src/components/switch.d.ts
|
|
8
|
-
export type SwitchProps = React.ComponentProps<typeof Switch$1.Root> & {
|
|
8
|
+
export type SwitchProps = Omit<React.ComponentProps<typeof Switch$1.Root>, 'render'> & {
|
|
9
|
+
/**
|
|
10
|
+
* Palette family used when on.
|
|
11
|
+
* @default 'green'
|
|
12
|
+
*/
|
|
9
13
|
color?: UIColor;
|
|
14
|
+
/** Label rendered next to the switch and linked to it. */
|
|
10
15
|
label?: ReactNode;
|
|
16
|
+
/** Props for the rendered label. */
|
|
11
17
|
labelProps?: Omit<LabelProps, 'children' | 'htmlFor'>;
|
|
18
|
+
/** Helper text rendered below the label. */
|
|
19
|
+
description?: ReactNode;
|
|
20
|
+
/** Props for the rendered description. */
|
|
21
|
+
descriptionProps?: Omit<React.ComponentProps<'p'>, 'children'>;
|
|
22
|
+
/**
|
|
23
|
+
* Size of the switch and its label.
|
|
24
|
+
* @default 'md'
|
|
25
|
+
*/
|
|
12
26
|
size?: 'sm' | 'md' | 'lg';
|
|
13
27
|
};
|
|
14
|
-
declare function Switch({ className, color, id, label, labelProps, size, ...props }: SwitchProps): React.JSX.Element;
|
|
28
|
+
declare function Switch({ className, color, id, label, labelProps, description, descriptionProps, size, 'aria-invalid': ariaInvalid, ...props }: SwitchProps): React.JSX.Element;
|
|
15
29
|
//#endregion
|
|
16
30
|
export { Switch };
|
|
17
31
|
//# sourceMappingURL=switch.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../rolldown-runtime-BhWHdk3m.js";import{cn as e}from"../lib/utils.js";import{Label as
|
|
1
|
+
import"../rolldown-runtime-BhWHdk3m.js";import{cn as e}from"../lib/utils.js";import{t}from"../resolve-class-name-BurP8ngI.js";import{Label as n}from"./label.js";import{useFieldControlId as r,useFieldInvalid as i}from"./field.js";import{useId as a}from"react";import{jsx as o,jsxs as s}from"react/jsx-runtime";import{cva as c}from"class-variance-authority";import{Switch as l}from"@base-ui/react/switch";const u={primary:`[--switch-checked:var(--primary)]`,brand:`[--switch-checked:var(--brand)]`,gray:`[--switch-checked:var(--gray)]`,zinc:`[--switch-checked:var(--zinc)]`,red:`[--switch-checked:var(--red)]`,yellow:`[--switch-checked:var(--yellow)]`,blue:`[--switch-checked:var(--blue)]`,indigo:`[--switch-checked:var(--indigo)]`,pink:`[--switch-checked:var(--pink)]`,green:`[--switch-checked:var(--green)]`},d=c(``,{variants:{size:{sm:`text-xs`,md:`text-sm`,lg:`text-lg`}},defaultVariants:{size:`md`}}),f=c(`text-muted-foreground text-left leading-normal font-normal [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary`,{variants:{size:{sm:`text-xs`,md:`text-xs`,lg:`text-sm`}},defaultVariants:{size:`md`}});function Switch({className:c,color:p=`green`,id:m,label:h,labelProps:g,description:_,descriptionProps:v,size:y=`md`,"aria-invalid":b,...x}){let S=a(),C=r(m),w=i(b),T=h!==void 0,E=C??(T?S:void 0),{className:D,...O}=g??{},k=a(),A=_!==void 0,{className:j,...M}=v??{},N=A?M.id??k:void 0,P=/* @__PURE__ */ o(l.Root,{"data-slot":`switch`,"data-color":p,"data-size":y,id:E,"aria-describedby":N,"aria-invalid":w,className:n=>e(`peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none`,`after:absolute after:-inset-x-3 after:-inset-y-2`,`focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50`,`data-[size=lg]:h-5 data-[size=lg]:w-10.5 data-[size=md]:h-4 data-[size=md]:w-8.5 data-[size=sm]:h-3.5 data-[size=sm]:w-7.5`,`data-checked:bg-(--switch-checked) data-unchecked:bg-input dark:data-unchecked:bg-input/80`,`data-disabled:cursor-not-allowed data-disabled:opacity-50`,u[p],t(c,n)),...x,children:/* @__PURE__ */ o(l.Thumb,{"data-slot":`switch-thumb`,className:e(`pointer-events-none flex items-center justify-center rounded-full bg-background ring-0 transition-transform`,`group-data-[size=lg]/switch:size-4 group-data-[size=md]/switch:size-3 group-data-[size=sm]/switch:size-2.5`,`group-data-[size=lg]/switch:data-checked:translate-x-6`,`group-data-[size=md]/switch:data-checked:translate-x-5`,`group-data-[size=sm]/switch:data-checked:translate-x-4.5`,`group-data-[size=lg]/switch:data-unchecked:translate-x-0.5`,`group-data-[size=md]/switch:data-unchecked:translate-x-0.5`,`group-data-[size=sm]/switch:data-unchecked:translate-x-0.5`,`dark:data-checked:bg-primary-foreground dark:data-unchecked:bg-foreground`),children:/* @__PURE__ */ o(`span`,{"data-slot":`switch-thumb-indicator`,className:e(`rounded-full transition-colors`,`group-data-[size=lg]/switch:size-2 group-data-[size=md]/switch:size-1.5 group-data-[size=sm]/switch:size-1`,`group-data-checked/switch:bg-(--switch-checked) group-data-unchecked/switch:bg-input`,`group-data-unchecked/switch:dark:bg-input/80`)})})});return!T&&!A?P:/* @__PURE__ */ s(`div`,{"data-slot":`switch-field`,className:`grid grid-cols-[auto_1fr] items-center justify-items-start gap-x-2 gap-y-0.5`,children:[P,T&&/* @__PURE__ */ o(n,{...O,htmlFor:E,className:e(d({size:y}),D),children:h}),A&&/* @__PURE__ */ o(`p`,{"data-slot":`switch-description`,...M,id:N,className:e(`col-start-2`,f({size:y}),j),children:_})]})}export{Switch};
|
|
2
2
|
//# sourceMappingURL=switch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switch.js","names":["SwitchPrimitive","
|
|
1
|
+
{"version":3,"file":"switch.js","names":["SwitchPrimitive","Switch$1","switchColorVariants","switchLabelVariants","cva","switchDescriptionVariants","ariaInvalid","props","generatedId","useId","fieldControlId","useFieldControlId","id","invalid","useFieldInvalid","hasLabel","label","resolvedId","labelClassName","labelRootProps","labelProps","descriptionId","hasDescription","description","descriptionClassName","descriptionRootProps","descriptionProps","resolvedDescriptionId","switchControl","color","size","cn","resolveClassName","className","state","Label"],"sources":["../../src/components/switch.tsx"],"sourcesContent":["import type * as React from 'react'\nimport { type ReactNode, useId } from 'react'\n\nimport { Switch as SwitchPrimitive } from '@base-ui/react/switch'\nimport { cva } from 'class-variance-authority'\n\nimport type { UIColor } from '../lib/color'\nimport { cn } from '../lib/utils'\nimport { resolveClassName } from '../utils/resolve-class-name'\nimport { useFieldControlId, useFieldInvalid } from './field'\nimport { Label, type LabelProps } from './label'\n\nexport type SwitchProps = Omit<React.ComponentProps<typeof SwitchPrimitive.Root>, 'render'> & {\n /**\n * Palette family used when on.\n * @default 'green'\n */\n color?: UIColor\n /** Label rendered next to the switch and linked to it. */\n label?: ReactNode\n /** Props for the rendered label. */\n labelProps?: Omit<LabelProps, 'children' | 'htmlFor'>\n /** Helper text rendered below the label. */\n description?: ReactNode\n /** Props for the rendered description. */\n descriptionProps?: Omit<React.ComponentProps<'p'>, 'children'>\n /**\n * Size of the switch and its label.\n * @default 'md'\n */\n size?: 'sm' | 'md' | 'lg'\n}\n\nconst switchColorVariants: Record<UIColor, string> = {\n primary: '[--switch-checked:var(--primary)]',\n brand: '[--switch-checked:var(--brand)]',\n gray: '[--switch-checked:var(--gray)]',\n zinc: '[--switch-checked:var(--zinc)]',\n red: '[--switch-checked:var(--red)]',\n yellow: '[--switch-checked:var(--yellow)]',\n blue: '[--switch-checked:var(--blue)]',\n indigo: '[--switch-checked:var(--indigo)]',\n pink: '[--switch-checked:var(--pink)]',\n green: '[--switch-checked:var(--green)]'\n}\n\nconst switchLabelVariants = cva('', {\n variants: {\n size: {\n sm: 'text-xs',\n md: 'text-sm',\n lg: 'text-lg'\n }\n },\n defaultVariants: {\n size: 'md'\n }\n})\n\nconst switchDescriptionVariants = cva(\n 'text-muted-foreground text-left leading-normal font-normal [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary',\n {\n variants: {\n size: {\n sm: 'text-xs',\n md: 'text-xs',\n lg: 'text-sm'\n }\n },\n defaultVariants: {\n size: 'md'\n }\n }\n)\n\nfunction Switch({\n className,\n color = 'green',\n id,\n label,\n labelProps,\n description,\n descriptionProps,\n size = 'md',\n 'aria-invalid': ariaInvalid,\n ...props\n}: SwitchProps) {\n const generatedId = useId()\n const fieldControlId = useFieldControlId(id)\n const invalid = useFieldInvalid(ariaInvalid)\n const hasLabel = label !== undefined\n const resolvedId = fieldControlId ?? (hasLabel ? generatedId : undefined)\n const { className: labelClassName, ...labelRootProps } = labelProps ?? {}\n const descriptionId = useId()\n const hasDescription = description !== undefined\n const { className: descriptionClassName, ...descriptionRootProps } = descriptionProps ?? {}\n const resolvedDescriptionId = hasDescription ? (descriptionRootProps.id ?? descriptionId) : undefined\n\n const switchControl = (\n <SwitchPrimitive.Root\n data-slot=\"switch\"\n data-color={color}\n data-size={size}\n id={resolvedId}\n aria-describedby={resolvedDescriptionId}\n aria-invalid={invalid}\n className={(state) =>\n cn(\n 'peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none',\n 'after:absolute after:-inset-x-3 after:-inset-y-2',\n 'focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50',\n 'data-[size=lg]:h-5 data-[size=lg]:w-10.5 data-[size=md]:h-4 data-[size=md]:w-8.5 data-[size=sm]:h-3.5 data-[size=sm]:w-7.5',\n 'data-checked:bg-(--switch-checked) data-unchecked:bg-input dark:data-unchecked:bg-input/80',\n 'data-disabled:cursor-not-allowed data-disabled:opacity-50',\n switchColorVariants[color],\n resolveClassName(className, state)\n )\n }\n {...props}\n >\n <SwitchPrimitive.Thumb\n data-slot=\"switch-thumb\"\n className={cn(\n 'pointer-events-none flex items-center justify-center rounded-full bg-background ring-0 transition-transform',\n 'group-data-[size=lg]/switch:size-4 group-data-[size=md]/switch:size-3 group-data-[size=sm]/switch:size-2.5',\n 'group-data-[size=lg]/switch:data-checked:translate-x-6',\n 'group-data-[size=md]/switch:data-checked:translate-x-5',\n 'group-data-[size=sm]/switch:data-checked:translate-x-4.5',\n 'group-data-[size=lg]/switch:data-unchecked:translate-x-0.5',\n 'group-data-[size=md]/switch:data-unchecked:translate-x-0.5',\n 'group-data-[size=sm]/switch:data-unchecked:translate-x-0.5',\n 'dark:data-checked:bg-primary-foreground dark:data-unchecked:bg-foreground'\n )}\n >\n <span\n data-slot=\"switch-thumb-indicator\"\n className={cn(\n 'rounded-full transition-colors',\n 'group-data-[size=lg]/switch:size-2 group-data-[size=md]/switch:size-1.5 group-data-[size=sm]/switch:size-1',\n 'group-data-checked/switch:bg-(--switch-checked) group-data-unchecked/switch:bg-input',\n 'group-data-unchecked/switch:dark:bg-input/80'\n )}\n />\n </SwitchPrimitive.Thumb>\n </SwitchPrimitive.Root>\n )\n\n if (!hasLabel && !hasDescription) {\n return switchControl\n }\n\n return (\n <div\n data-slot=\"switch-field\"\n className=\"grid grid-cols-[auto_1fr] items-center justify-items-start gap-x-2 gap-y-0.5\"\n >\n {switchControl}\n {hasLabel && (\n <Label {...labelRootProps} htmlFor={resolvedId} className={cn(switchLabelVariants({ size }), labelClassName)}>\n {label}\n </Label>\n )}\n {hasDescription && (\n <p\n data-slot=\"switch-description\"\n {...descriptionRootProps}\n id={resolvedDescriptionId}\n className={cn('col-start-2', switchDescriptionVariants({ size }), descriptionClassName)}\n >\n {description}\n </p>\n )}\n </div>\n )\n}\n\nexport { Switch }\n"],"mappings":"mZAiCA,MAAME,EAA+C,CACnD,QAAS,oCACT,MAAO,kCACP,KAAM,iCACN,KAAM,iCACN,IAAK,gCACL,OAAQ,mCACR,KAAM,iCACN,OAAQ,mCACR,KAAM,iCACN,MAAO,iCACT,EAEMC,EAAsBC,EAAI,GAAI,CAClC,SAAU,CACR,KAAM,CACJ,GAAI,UACJ,GAAI,UACJ,GAAI,SACN,CACF,EACA,gBAAiB,CACf,KAAM,IACR,CACF,CAAC,EAEKC,EAA4BD,EAChC,+HACA,CACE,SAAU,CACR,KAAM,CACJ,GAAI,UACJ,GAAI,UACJ,GAAI,SACN,CACF,EACA,gBAAiB,CACf,KAAM,IACR,CACF,CACF,EAEA,SAAS,OAAO,CACd,YACA,QAAQ,QACR,KACA,QACA,aACA,cACA,mBACA,OAAO,KACP,eAAgBE,EAChB,GAAGC,GACW,CACd,IAAMC,EAAcC,EAAM,EACpBC,EAAiBC,EAAkBC,CAAE,EACrCC,EAAUC,EAAgBR,CAAW,EACrCS,EAAWC,IAAU,IAAA,GACrBC,EAAaP,IAAmBK,EAAWP,EAAc,IAAA,IACzD,CAAE,UAAWU,EAAgB,GAAGC,GAAmBC,GAAc,CAAC,EAClEC,EAAgBZ,EAAM,EACtBa,EAAiBC,IAAgB,IAAA,GACjC,CAAE,UAAWC,EAAsB,GAAGC,GAAyBC,GAAoB,CAAC,EACpFC,EAAwBL,EAAkBG,EAAqB,IAAMJ,EAAiB,IAAA,GAEtFO,EACJ,kBAAC5B,EAAgB,KAAjB,CACE,YAAU,SACV,aAAY6B,EACZ,YAAWC,EACX,GAAIb,EACJ,mBAAkBU,EAClB,eAAcd,EACd,UAAY,GACVkB,EACE,kIACA,mDACA,4EACA,6HACA,6FACA,4DACA7B,EAAoB2B,GACpBG,EAAiBC,EAAWC,CAAK,CACnC,EAEF,GAAI3B,EAEJ,SAAA,kBAACP,EAAgB,MAAjB,CACE,YAAU,eACV,UAAW+B,EACT,8GACA,6GACA,yDACA,yDACA,2DACA,6DACA,6DACA,6DACA,2EACF,EAEA,SAAA,kBAAC,OAAD,CACE,YAAU,yBACV,UAAWA,EACT,iCACA,6GACA,uFACA,8CACF,CACD,CAAA,CACoB,CAAA,CACH,CAAA,EAOxB,MAJI,CAAChB,GAAY,CAACO,EACTM,EAIP,kBAAC,MAAD,CACE,YAAU,eACV,UAAU,+EAFZ,SAAA,CAIGA,EACAb,GACC,kBAACoB,EAAD,CAAO,GAAIhB,EAAgB,QAASF,EAAY,UAAWc,EAAG5B,EAAoB,CAAE,MAAK,CAAC,EAAGe,CAAc,EACxG,SAAAF,CACI,CAAA,EAERM,GACC,kBAAC,IAAD,CACE,YAAU,qBACV,GAAIG,EACJ,GAAIE,EACJ,UAAWI,EAAG,cAAe1B,EAA0B,CAAE,MAAK,CAAC,EAAGmB,CAAoB,EAErF,SAAAD,CACA,CAAA,CAEF,GAET"}
|
|
@@ -1,15 +1,24 @@
|
|
|
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/table.d.ts
|
|
5
5
|
export type TableContainerProps = React.ComponentProps<'div'> & {
|
|
6
|
+
/** Minimum table width (px number or CSS length); the container scrolls horizontally below it. */
|
|
6
7
|
minWidth?: number | string;
|
|
7
8
|
};
|
|
8
9
|
declare const tableVariants: (props?: ({
|
|
9
10
|
variant?: "line" | "outline" | null | undefined;
|
|
10
11
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
11
12
|
export type TableProps = React.ComponentProps<'table'> & VariantProps<typeof tableVariants> & {
|
|
13
|
+
/**
|
|
14
|
+
* Alternates the row background.
|
|
15
|
+
* @default true
|
|
16
|
+
*/
|
|
12
17
|
striped?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Keeps the header at the top while the body scrolls inside a `TableContainer`.
|
|
20
|
+
* @default false
|
|
21
|
+
*/
|
|
13
22
|
stickyHeader?: boolean;
|
|
14
23
|
};
|
|
15
24
|
export type TableHeaderProps = React.ComponentProps<'thead'>;
|
package/dist/components/table.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../rolldown-runtime-BhWHdk3m.js";import{cn as e}from"../lib/utils.js";import{jsx as t}from"react/jsx-runtime";import{cva as n}from"class-variance-authority";const r=n(`w-full caption-bottom text-sm`,{variants:{variant:{line:``,outline:e(`rounded-lg border border-separate border-spacing-0`,`[&_thead_th]:border-b`,`[&_tbody_tr:not(:last-child)>td]:border-b`)}},defaultVariants:{variant:`line`}});function TableContainer({className:n,minWidth:r,style:i,...a}){return/* @__PURE__ */ t(`div`,{"data-slot":`table-container`,className:e(`relative w-full overflow-x-auto`,`has-[>table[data-variant=outline]]:rounded-lg has-[>table[data-variant=outline]]:border`,`[&>table[data-variant=outline]]:rounded-none [&>table[data-variant=outline]]:border-0`,n),style:r===void 0?i:{
|
|
1
|
+
import"../rolldown-runtime-BhWHdk3m.js";import{cn as e}from"../lib/utils.js";import{jsx as t}from"react/jsx-runtime";import{cva as n}from"class-variance-authority";const r=n(`w-full caption-bottom text-sm`,{variants:{variant:{line:``,outline:e(`rounded-lg border border-separate border-spacing-0`,`[&_thead_th]:border-b`,`[&_tbody_tr:not(:last-child)>td]:border-b`)}},defaultVariants:{variant:`line`}});function TableContainer({className:n,minWidth:r,style:i,...a}){return/* @__PURE__ */ t(`div`,{"data-slot":`table-container`,className:e(`relative w-full overflow-x-auto`,`has-[>table[data-variant=outline]]:rounded-lg has-[>table[data-variant=outline]]:border`,`[&>table[data-variant=outline]]:rounded-none [&>table[data-variant=outline]]:border-0`,`[&>table]:min-w-(--table-min-width)`,n),style:r===void 0?i:{"--table-min-width":typeof r==`number`?`${r}px`:r,...i},...a})}function Table({className:n,variant:i=`line`,striped:a=!0,stickyHeader:o=!1,...s}){return/* @__PURE__ */ t(`table`,{"data-slot":`table`,"data-variant":i,"data-striped":a?`true`:`false`,"data-sticky-header":o?`true`:`false`,className:e(r({variant:i}),`data-[striped=true]:[&_tbody_tr:nth-child(even):not([data-state=selected]):not(:hover)]:bg-muted/50`,`data-[sticky-header=true]:[&_thead]:sticky data-[sticky-header=true]:[&_thead]:top-0 data-[sticky-header=true]:[&_thead]:z-10 data-[sticky-header=true]:[&_thead]:bg-background`,n),...s})}function TableHeader({className:n,...r}){return/* @__PURE__ */ t(`thead`,{"data-slot":`table-header`,className:e(`[&_tr]:border-b`,n),...r})}function TableBody({className:n,...r}){return/* @__PURE__ */ t(`tbody`,{"data-slot":`table-body`,className:e(`[&_tr:last-child]:border-0`,n),...r})}function TableFooter({className:n,...r}){return/* @__PURE__ */ t(`tfoot`,{"data-slot":`table-footer`,className:e(`border-t bg-muted/50 font-medium [&>tr]:last:border-b-0`,n),...r})}function TableRow({className:n,...r}){return/* @__PURE__ */ t(`tr`,{"data-slot":`table-row`,className:e(`border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted`,n),...r})}function TableHead({className:n,...r}){return/* @__PURE__ */ t(`th`,{"data-slot":`table-head`,className:e(`h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground has-[[role=checkbox]]:pr-0`,n),...r})}function TableCell({className:n,...r}){return/* @__PURE__ */ t(`td`,{"data-slot":`table-cell`,className:e(`p-2 align-middle whitespace-nowrap has-[[role=checkbox]]:pr-0`,n),...r})}function TableCaption({className:n,...r}){return/* @__PURE__ */ t(`caption`,{"data-slot":`table-caption`,className:e(`mt-4 text-sm text-muted-foreground`,n),...r})}export{Table,TableBody,TableCaption,TableCell,TableContainer,TableFooter,TableHead,TableHeader,TableRow,r as tableVariants};
|
|
2
2
|
//# sourceMappingURL=table.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.js","names":["tableVariants","cva","cn","props","className","minWidth","style","variant","striped","stickyHeader"],"sources":["../../src/components/table.tsx"],"sourcesContent":["import type * as React from 'react'\n\nimport { cva, type VariantProps } from 'class-variance-authority'\n\nimport { cn } from '../lib/utils'\n\nexport type TableContainerProps = React.ComponentProps<'div'> & {\n minWidth?: number | string\n}\n\nconst tableVariants = cva('w-full caption-bottom text-sm', {\n variants: {\n variant: {\n line: '',\n outline: cn(\n 'rounded-lg border border-separate border-spacing-0',\n '[&_thead_th]:border-b',\n '[&_tbody_tr:not(:last-child)>td]:border-b'\n )\n }\n },\n defaultVariants: {\n variant: 'line'\n }\n})\n\nexport type TableProps = React.ComponentProps<'table'> &\n VariantProps<typeof tableVariants> & {\n striped?: boolean\n stickyHeader?: boolean\n }\n\nexport type TableHeaderProps = React.ComponentProps<'thead'>\n\nexport type TableBodyProps = React.ComponentProps<'tbody'>\n\nexport type TableFooterProps = React.ComponentProps<'tfoot'>\n\nexport type TableRowProps = React.ComponentProps<'tr'>\n\nexport type TableHeadProps = React.ComponentProps<'th'>\n\nexport type TableCellProps = React.ComponentProps<'td'>\n\nexport type TableCaptionProps = React.ComponentProps<'caption'>\n\nfunction TableContainer({ className, minWidth, style, ...props }: TableContainerProps) {\n return (\n <div\n data-slot=\"table-container\"\n className={cn(\n 'relative w-full overflow-x-auto',\n 'has-[>table[data-variant=outline]]:rounded-lg has-[>table[data-variant=outline]]:border',\n '[&>table[data-variant=outline]]:rounded-none [&>table[data-variant=outline]]:border-0',\n className\n )}\n style={minWidth !== undefined ? { minWidth
|
|
1
|
+
{"version":3,"file":"table.js","names":["tableVariants","cva","cn","props","className","minWidth","style","variant","striped","stickyHeader"],"sources":["../../src/components/table.tsx"],"sourcesContent":["import type * as React from 'react'\n\nimport { cva, type VariantProps } from 'class-variance-authority'\n\nimport { cn } from '../lib/utils'\n\nexport type TableContainerProps = React.ComponentProps<'div'> & {\n /** Minimum table width (px number or CSS length); the container scrolls horizontally below it. */\n minWidth?: number | string\n}\n\nconst tableVariants = cva('w-full caption-bottom text-sm', {\n variants: {\n variant: {\n line: '',\n outline: cn(\n 'rounded-lg border border-separate border-spacing-0',\n '[&_thead_th]:border-b',\n '[&_tbody_tr:not(:last-child)>td]:border-b'\n )\n }\n },\n defaultVariants: {\n variant: 'line'\n }\n})\n\nexport type TableProps = React.ComponentProps<'table'> &\n VariantProps<typeof tableVariants> & {\n /**\n * Alternates the row background.\n * @default true\n */\n striped?: boolean\n /**\n * Keeps the header at the top while the body scrolls inside a `TableContainer`.\n * @default false\n */\n stickyHeader?: boolean\n }\n\nexport type TableHeaderProps = React.ComponentProps<'thead'>\n\nexport type TableBodyProps = React.ComponentProps<'tbody'>\n\nexport type TableFooterProps = React.ComponentProps<'tfoot'>\n\nexport type TableRowProps = React.ComponentProps<'tr'>\n\nexport type TableHeadProps = React.ComponentProps<'th'>\n\nexport type TableCellProps = React.ComponentProps<'td'>\n\nexport type TableCaptionProps = React.ComponentProps<'caption'>\n\nfunction TableContainer({ className, minWidth, style, ...props }: TableContainerProps) {\n return (\n <div\n data-slot=\"table-container\"\n className={cn(\n 'relative w-full overflow-x-auto',\n 'has-[>table[data-variant=outline]]:rounded-lg has-[>table[data-variant=outline]]:border',\n '[&>table[data-variant=outline]]:rounded-none [&>table[data-variant=outline]]:border-0',\n '[&>table]:min-w-(--table-min-width)',\n className\n )}\n style={\n minWidth !== undefined\n ? ({\n '--table-min-width': typeof minWidth === 'number' ? `${minWidth}px` : minWidth,\n ...style\n } as React.CSSProperties)\n : style\n }\n {...props}\n />\n )\n}\n\nfunction Table({ className, variant = 'line', striped = true, stickyHeader = false, ...props }: TableProps) {\n return (\n <table\n data-slot=\"table\"\n data-variant={variant}\n data-striped={striped ? 'true' : 'false'}\n data-sticky-header={stickyHeader ? 'true' : 'false'}\n className={cn(\n tableVariants({ variant }),\n 'data-[striped=true]:[&_tbody_tr:nth-child(even):not([data-state=selected]):not(:hover)]:bg-muted/50',\n 'data-[sticky-header=true]:[&_thead]:sticky data-[sticky-header=true]:[&_thead]:top-0 data-[sticky-header=true]:[&_thead]:z-10 data-[sticky-header=true]:[&_thead]:bg-background',\n className\n )}\n {...props}\n />\n )\n}\n\nfunction TableHeader({ className, ...props }: TableHeaderProps) {\n return <thead data-slot=\"table-header\" className={cn('[&_tr]:border-b', className)} {...props} />\n}\n\nfunction TableBody({ className, ...props }: TableBodyProps) {\n return <tbody data-slot=\"table-body\" className={cn('[&_tr:last-child]:border-0', className)} {...props} />\n}\n\nfunction TableFooter({ className, ...props }: TableFooterProps) {\n return (\n <tfoot\n data-slot=\"table-footer\"\n className={cn('border-t bg-muted/50 font-medium [&>tr]:last:border-b-0', className)}\n {...props}\n />\n )\n}\n\nfunction TableRow({ className, ...props }: TableRowProps) {\n return (\n <tr\n data-slot=\"table-row\"\n className={cn('border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted', className)}\n {...props}\n />\n )\n}\n\nfunction TableHead({ className, ...props }: TableHeadProps) {\n return (\n <th\n data-slot=\"table-head\"\n className={cn(\n 'h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground has-[[role=checkbox]]:pr-0',\n className\n )}\n {...props}\n />\n )\n}\n\nfunction TableCell({ className, ...props }: TableCellProps) {\n return (\n <td\n data-slot=\"table-cell\"\n className={cn('p-2 align-middle whitespace-nowrap has-[[role=checkbox]]:pr-0', className)}\n {...props}\n />\n )\n}\n\nfunction TableCaption({ className, ...props }: TableCaptionProps) {\n return (\n <caption data-slot=\"table-caption\" className={cn('mt-4 text-sm text-muted-foreground', className)} {...props} />\n )\n}\n\nexport {\n Table,\n TableBody,\n TableCaption,\n TableCell,\n TableContainer,\n TableFooter,\n TableHead,\n TableHeader,\n TableRow,\n tableVariants\n}\n"],"mappings":"oKAWA,MAAMA,EAAgBC,EAAI,gCAAiC,CACz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GAAID,CACL,CAAA,CAEL,CAEA,SAAS,UAAU,CAAE,YAAW,GAAGA,GAAyB,CAC1D,MACE,kBAAC,KAAD,CACE,YAAU,aACV,UAAWD,EACT,4GACAE,CACF,EACA,GAAID,CACL,CAAA,CAEL,CAEA,SAAS,UAAU,CAAE,YAAW,GAAGA,GAAyB,CAC1D,MACE,kBAAC,KAAD,CACE,YAAU,aACV,UAAWD,EAAG,gEAAiEE,CAAS,EACxF,GAAID,CACL,CAAA,CAEL,CAEA,SAAS,aAAa,CAAE,YAAW,GAAGA,GAA4B,CAChE,MACE,kBAAC,UAAD,CAAS,YAAU,gBAAgB,UAAWD,EAAG,qCAAsCE,CAAS,EAAG,GAAID,CAAQ,CAAA,CAEnH"}
|
|
@@ -1,21 +1,25 @@
|
|
|
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 { Tabs as Tabs$1 } from "@base-ui/react/tabs";
|
|
5
5
|
//#region src/components/tabs.d.ts
|
|
6
|
-
export type TabsProps =
|
|
7
|
-
declare function Tabs({ className, orientation, ...props }: TabsProps):
|
|
6
|
+
export type TabsProps = AsChildPrimitiveProps<typeof Tabs$1.Root>;
|
|
7
|
+
declare function Tabs({ className, orientation, asChild, children, ...props }: TabsProps): import("react").JSX.Element;
|
|
8
8
|
declare const tabsListVariants: (props?: ({
|
|
9
9
|
variant?: "enclosed" | "line" | null | undefined;
|
|
10
10
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
11
|
-
export type TabsListProps =
|
|
11
|
+
export type TabsListProps = AsChildPrimitiveProps<typeof Tabs$1.List> & VariantProps<typeof tabsListVariants> & {
|
|
12
|
+
/**
|
|
13
|
+
* Makes horizontal tabs share the available width equally.
|
|
14
|
+
* @default false
|
|
15
|
+
*/
|
|
12
16
|
grow?: boolean;
|
|
13
17
|
};
|
|
14
|
-
export type TabsTriggerProps =
|
|
15
|
-
export type TabsContentProps =
|
|
16
|
-
declare function TabsList({ className, variant, grow, ...props }: TabsListProps):
|
|
17
|
-
declare function TabsTrigger({ className, ...props }: TabsTriggerProps):
|
|
18
|
-
declare function TabsContent({ className, ...props }: TabsContentProps):
|
|
18
|
+
export type TabsTriggerProps = AsChildPrimitiveProps<typeof Tabs$1.Tab>;
|
|
19
|
+
export type TabsContentProps = AsChildPrimitiveProps<typeof Tabs$1.Panel>;
|
|
20
|
+
declare function TabsList({ className, variant, grow, asChild, children, ...props }: TabsListProps): import("react").JSX.Element;
|
|
21
|
+
declare function TabsTrigger({ className, asChild, children, ...props }: TabsTriggerProps): import("react").JSX.Element;
|
|
22
|
+
declare function TabsContent({ className, asChild, children, ...props }: TabsContentProps): import("react").JSX.Element;
|
|
19
23
|
//#endregion
|
|
20
24
|
export { Tabs, TabsContent, TabsList, TabsTrigger, tabsListVariants };
|
|
21
25
|
//# sourceMappingURL=tabs.d.ts.map
|
package/dist/components/tabs.js
CHANGED
|
@@ -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{jsx as r}from"react/jsx-runtime";import{cva as i}from"class-variance-authority";import{Tabs as a}from"@base-ui/react/tabs";function Tabs({className:i,orientation:o=`horizontal`,asChild:s,children:c,...l}){return/* @__PURE__ */ r(a.Root,{"data-slot":`tabs`,orientation:o,className:e=>t(`group/tabs flex gap-2 data-horizontal:flex-col`,n(i,e)),...l,...e(s,c)})}const o=i(`group/tabs-list inline-flex items-center justify-start rounded-lg h-fit group-data-horizontal/tabs:flex-wrap group-data-horizontal/tabs:w-full group-data-vertical/tabs:w-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none`,{variants:{variant:{enclosed:`bg-muted p-0.75`,line:`gap-1 bg-transparent group-data-horizontal/tabs:border-b group-data-horizontal/tabs:border-b-border group-data-vertical/tabs:border-r group-data-vertical/tabs:border-r-border`}},defaultVariants:{variant:`line`}});function TabsList({className:i,variant:s=`line`,grow:c=!1,asChild:l,children:u,...d}){return/* @__PURE__ */ r(a.List,{"data-slot":`tabs-list`,"data-variant":s,"data-grow":c,className:e=>t(o({variant:s}),n(i,e)),...d,...e(l,u)})}function TabsTrigger({className:i,asChild:o,children:s,...c}){return/* @__PURE__ */ r(a.Tab,{"data-slot":`tabs-trigger`,className:e=>t(`relative inline-flex items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-normal whitespace-nowrap text-foreground transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:bg-muted focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 group-data-[variant=enclosed]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,`group-data-horizontal/tabs:group-data-[grow=true]/tabs-list:flex-1`,`group-data-[variant=line]/tabs-list:bg-transparent group-data-horizontal/tabs:group-data-[variant=line]/tabs-list:rounded-t-[8px] group-data-horizontal/tabs:group-data-[variant=line]/tabs-list:rounded-b-none group-data-vertical/tabs:group-data-[variant=line]/tabs-list:rounded-l-[8px] group-data-vertical/tabs:group-data-[variant=line]/tabs-list:rounded-r-none`,`group-data-[variant=line]/tabs-list:h-8 group-data-horizontal/tabs:group-data-[variant=line]/tabs-list:data-active:border-b-primary-500 group-data-vertical/tabs:group-data-[variant=line]/tabs-list:data-active:border-r-primary-500`,`group-data-[variant=enclosed]/tabs-list:h-[calc(100%-1px)] group-data-[variant=enclosed]/tabs-list:data-active:bg-background group-data-[variant=enclosed]/tabs-list:data-active:hover:bg-muted dark:group-data-[variant=enclosed]/tabs-list:data-active:border-input dark:group-data-[variant=enclosed]/tabs-list:data-active:bg-input/30`,n(i,e)),...c,...e(o,s)})}function TabsContent({className:i,asChild:o,children:s,...c}){return/* @__PURE__ */ r(a.Panel,{"data-slot":`tabs-content`,className:e=>t(`flex-1 text-sm outline-none`,n(i,e)),...c,...e(o,s)})}export{Tabs,TabsContent,TabsList,TabsTrigger,o as tabsListVariants};
|
|
2
2
|
//# sourceMappingURL=tabs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabs.js","names":["TabsPrimitive","Tabs$1","props","
|
|
1
|
+
{"version":3,"file":"tabs.js","names":["TabsPrimitive","resolveClassName","Tabs$1","props","cn","className","state","toAsChildRenderProps","asChild","children","tabsListVariants","cva","variant","grow"],"sources":["../../src/components/tabs.tsx"],"sourcesContent":["import { Tabs as TabsPrimitive } from '@base-ui/react/tabs'\nimport { cva, 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'\n\nexport type TabsProps = AsChildPrimitiveProps<typeof TabsPrimitive.Root>\n\nfunction Tabs({ className, orientation = 'horizontal', asChild, children, ...props }: TabsProps) {\n return (\n <TabsPrimitive.Root\n data-slot=\"tabs\"\n orientation={orientation}\n className={(state) => cn('group/tabs flex gap-2 data-horizontal:flex-col', resolveClassName(className, state))}\n {...props}\n {...toAsChildRenderProps(asChild, children)}\n />\n )\n}\n\nconst tabsListVariants = cva(\n 'group/tabs-list inline-flex items-center justify-start rounded-lg h-fit group-data-horizontal/tabs:flex-wrap group-data-horizontal/tabs:w-full group-data-vertical/tabs:w-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none',\n {\n variants: {\n variant: {\n enclosed: 'bg-muted p-0.75',\n line: 'gap-1 bg-transparent group-data-horizontal/tabs:border-b group-data-horizontal/tabs:border-b-border group-data-vertical/tabs:border-r group-data-vertical/tabs:border-r-border'\n }\n },\n defaultVariants: {\n variant: 'line'\n }\n }\n)\n\nexport type TabsListProps = AsChildPrimitiveProps<typeof TabsPrimitive.List> &\n VariantProps<typeof tabsListVariants> & {\n /**\n * Makes horizontal tabs share the available width equally.\n * @default false\n */\n grow?: boolean\n }\n\nexport type TabsTriggerProps = AsChildPrimitiveProps<typeof TabsPrimitive.Tab>\n\nexport type TabsContentProps = AsChildPrimitiveProps<typeof TabsPrimitive.Panel>\n\nfunction TabsList({ className, variant = 'line', grow = false, asChild, children, ...props }: TabsListProps) {\n return (\n <TabsPrimitive.List\n data-slot=\"tabs-list\"\n data-variant={variant}\n data-grow={grow}\n className={(state) => cn(tabsListVariants({ variant }), resolveClassName(className, state))}\n {...props}\n {...toAsChildRenderProps(asChild, children)}\n />\n )\n}\n\nfunction TabsTrigger({ className, asChild, children, ...props }: TabsTriggerProps) {\n return (\n <TabsPrimitive.Tab\n data-slot=\"tabs-trigger\"\n className={(state) =>\n cn(\n \"relative inline-flex items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-normal whitespace-nowrap text-foreground transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:bg-muted focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 group-data-[variant=enclosed]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n 'group-data-horizontal/tabs:group-data-[grow=true]/tabs-list:flex-1',\n 'group-data-[variant=line]/tabs-list:bg-transparent group-data-horizontal/tabs:group-data-[variant=line]/tabs-list:rounded-t-[8px] group-data-horizontal/tabs:group-data-[variant=line]/tabs-list:rounded-b-none group-data-vertical/tabs:group-data-[variant=line]/tabs-list:rounded-l-[8px] group-data-vertical/tabs:group-data-[variant=line]/tabs-list:rounded-r-none',\n 'group-data-[variant=line]/tabs-list:h-8 group-data-horizontal/tabs:group-data-[variant=line]/tabs-list:data-active:border-b-primary-500 group-data-vertical/tabs:group-data-[variant=line]/tabs-list:data-active:border-r-primary-500',\n 'group-data-[variant=enclosed]/tabs-list:h-[calc(100%-1px)] group-data-[variant=enclosed]/tabs-list:data-active:bg-background group-data-[variant=enclosed]/tabs-list:data-active:hover:bg-muted dark:group-data-[variant=enclosed]/tabs-list:data-active:border-input dark:group-data-[variant=enclosed]/tabs-list:data-active:bg-input/30',\n resolveClassName(className, state)\n )\n }\n {...props}\n {...toAsChildRenderProps(asChild, children)}\n />\n )\n}\n\nfunction TabsContent({ className, asChild, children, ...props }: TabsContentProps) {\n return (\n <TabsPrimitive.Panel\n data-slot=\"tabs-content\"\n className={(state) => cn('flex-1 text-sm outline-none', resolveClassName(className, state))}\n {...props}\n {...toAsChildRenderProps(asChild, children)}\n />\n )\n}\n\nexport { Tabs, TabsContent, TabsList, TabsTrigger, tabsListVariants }\n"],"mappings":"+TASA,SAAS,KAAK,CAAE,YAAW,cAAc,aAAc,UAAS,WAAU,GAAGG,GAAoB,CAC/F,MACE,kBAACH,EAAc,KAAf,CACE,YAAU,OACG,cACb,UAAY,GAAUI,EAAG,iDAAkDH,EAAiBI,EAAWC,CAAK,CAAC,EAC7G,GAAIH,EACJ,GAAII,EAAqBC,EAASC,CAAQ,CAC3C,CAAA,CAEL,CAEA,MAAMC,EAAmBC,EACvB,mPACA,CACE,SAAU,CACR,QAAS,CACP,SAAU,kBACV,KAAM,gLACR,CACF,EACA,gBAAiB,CACf,QAAS,MACX,CACF,CACF,EAeA,SAAS,SAAS,CAAE,YAAW,UAAU,OAAQ,OAAO,GAAO,UAAS,WAAU,GAAGR,GAAwB,CAC3G,MACE,kBAACH,EAAc,KAAf,CACE,YAAU,YACV,eAAcY,EACd,YAAWC,EACX,UAAY,GAAUT,EAAGM,EAAiB,CAAE,SAAQ,CAAC,EAAGT,EAAiBI,EAAWC,CAAK,CAAC,EAC1F,GAAIH,EACJ,GAAII,EAAqBC,EAASC,CAAQ,CAC3C,CAAA,CAEL,CAEA,SAAS,YAAY,CAAE,YAAW,UAAS,WAAU,GAAGN,GAA2B,CACjF,MACE,kBAACH,EAAc,IAAf,CACE,YAAU,eACV,UAAY,GACVI,EACE,ksBACA,qEACA,2WACA,wOACA,6UACAH,EAAiBI,EAAWC,CAAK,CACnC,EAEF,GAAIH,EACJ,GAAII,EAAqBC,EAASC,CAAQ,CAC3C,CAAA,CAEL,CAEA,SAAS,YAAY,CAAE,YAAW,UAAS,WAAU,GAAGN,GAA2B,CACjF,MACE,kBAACH,EAAc,MAAf,CACE,YAAU,eACV,UAAY,GAAUI,EAAG,8BAA+BH,EAAiBI,EAAWC,CAAK,CAAC,EAC1F,GAAIH,EACJ,GAAII,EAAqBC,EAASC,CAAQ,CAC3C,CAAA,CAEL"}
|