UNPKG

@nuxt/ui

Version:

A UI Library for Modern Web Apps, powered by Vue & Tailwind CSS.

1,719 lines (1,691 loc) 115 kB
import { pick } from '../../dist/runtime/utils/index.js'; import 'node:url'; import { kebabCase } from 'scule'; import { addTypeTemplate, addTemplate } from '@nuxt/kit'; import { defuFn, defu } from 'defu'; import colors from 'tailwindcss/colors'; import { genExport } from 'knitwork'; const icons = { arrowLeft: "i-lucide-arrow-left", arrowRight: "i-lucide-arrow-right", check: "i-lucide-check", chevronDoubleLeft: "i-lucide-chevrons-left", chevronDoubleRight: "i-lucide-chevrons-right", chevronDown: "i-lucide-chevron-down", chevronLeft: "i-lucide-chevron-left", chevronRight: "i-lucide-chevron-right", chevronUp: "i-lucide-chevron-up", close: "i-lucide-x", ellipsis: "i-lucide-ellipsis", external: "i-lucide-arrow-up-right", folder: "i-lucide-folder", folderOpen: "i-lucide-folder-open", loading: "i-lucide-loader-circle", minus: "i-lucide-minus", plus: "i-lucide-plus", search: "i-lucide-search" }; const getDefaultUiConfig = (colors) => ({ colors: pick({ primary: "green", secondary: "blue", success: "green", info: "blue", warning: "yellow", error: "red", neutral: "slate" }, [...colors || [], "neutral"]), icons }); const defaultOptions = { prefix: "U", fonts: true, colorMode: true, theme: { colors: void 0, transitions: true } }; const resolveColors = (colors) => { return colors?.length ? [.../* @__PURE__ */ new Set(["primary", ...colors])] : ["primary", "secondary", "success", "info", "warning", "error"]; }; const accordion = { slots: { root: "w-full", item: "border-b border-default last:border-b-0", header: "flex", trigger: "group flex-1 flex items-center gap-1.5 font-medium text-sm py-3.5 focus-visible:outline-primary min-w-0", content: "data-[state=open]:animate-[accordion-down_200ms_ease-out] data-[state=closed]:animate-[accordion-up_200ms_ease-out] overflow-hidden focus:outline-none", body: "text-sm pb-3.5", leadingIcon: "shrink-0 size-5", trailingIcon: "shrink-0 size-5 ms-auto group-data-[state=open]:rotate-180 transition-transform duration-200", label: "text-start break-words" }, variants: { disabled: { true: { trigger: "cursor-not-allowed opacity-75" } } } }; const alert = (options) => ({ slots: { root: "relative overflow-hidden w-full rounded-lg p-4 flex gap-2.5", wrapper: "min-w-0 flex-1 flex flex-col", title: "text-sm font-medium", description: "text-sm opacity-90", icon: "shrink-0 size-5", avatar: "shrink-0", avatarSize: "2xl", actions: "flex flex-wrap gap-1.5 shrink-0", close: "p-0" }, variants: { color: { ...Object.fromEntries((options.theme.colors || []).map((color) => [color, ""])), neutral: "" }, variant: { solid: "", outline: "", soft: "", subtle: "" }, orientation: { horizontal: { root: "items-center", actions: "items-center" }, vertical: { root: "items-start", actions: "items-start mt-2.5" } }, title: { true: { description: "mt-1" } } }, compoundVariants: [...(options.theme.colors || []).map((color) => ({ color, variant: "solid", class: { root: `bg-${color} text-inverted` } })), ...(options.theme.colors || []).map((color) => ({ color, variant: "outline", class: { root: `text-${color} ring ring-inset ring-${color}/25` } })), ...(options.theme.colors || []).map((color) => ({ color, variant: "soft", class: { root: `bg-${color}/10 text-${color}` } })), ...(options.theme.colors || []).map((color) => ({ color, variant: "subtle", class: { root: `bg-${color}/10 text-${color} ring ring-inset ring-${color}/25` } })), { color: "neutral", variant: "solid", class: { root: "text-inverted bg-inverted" } }, { color: "neutral", variant: "outline", class: { root: "text-highlighted bg-default ring ring-inset ring-default" } }, { color: "neutral", variant: "soft", class: { root: "text-highlighted bg-elevated/50" } }, { color: "neutral", variant: "subtle", class: { root: "text-highlighted bg-elevated/50 ring ring-inset ring-accented" } }], defaultVariants: { color: "primary", variant: "solid" } }); const avatar = { slots: { root: "inline-flex items-center justify-center shrink-0 select-none overflow-hidden rounded-full align-middle bg-elevated", image: "h-full w-full rounded-[inherit] object-cover", fallback: "font-medium leading-none text-muted truncate", icon: "text-muted shrink-0" }, variants: { size: { "3xs": { root: "size-4 text-[8px]" }, "2xs": { root: "size-5 text-[10px]" }, "xs": { root: "size-6 text-xs" }, "sm": { root: "size-7 text-sm" }, "md": { root: "size-8 text-base" }, "lg": { root: "size-9 text-lg" }, "xl": { root: "size-10 text-xl" }, "2xl": { root: "size-11 text-[22px]" }, "3xl": { root: "size-12 text-2xl" } } }, defaultVariants: { size: "md" } }; const avatarGroup = { slots: { root: "inline-flex flex-row-reverse justify-end", base: "relative rounded-full ring-bg first:me-0" }, variants: { size: { "3xs": { base: "ring -me-0.5" }, "2xs": { base: "ring -me-0.5" }, "xs": { base: "ring -me-0.5" }, "sm": { base: "ring-2 -me-1.5" }, "md": { base: "ring-2 -me-1.5" }, "lg": { base: "ring-2 -me-1.5" }, "xl": { base: "ring-3 -me-2" }, "2xl": { base: "ring-3 -me-2" }, "3xl": { base: "ring-3 -me-2" } } }, defaultVariants: { size: "md" } }; const buttonGroupVariant = { buttonGroup: { horizontal: "not-only:first:rounded-e-none not-only:last:rounded-s-none not-last:not-first:rounded-none focus-visible:z-[1]", vertical: "not-only:first:rounded-b-none not-only:last:rounded-t-none not-last:not-first:rounded-none focus-visible:z-[1]" } }; const buttonGroupVariantWithRoot = { buttonGroup: { horizontal: { root: "group has-focus-visible:z-[1]", base: "group-not-only:group-first:rounded-e-none group-not-only:group-last:rounded-s-none group-not-last:group-not-first:rounded-none" }, vertical: { root: "group has-focus-visible:z-[1]", base: "group-not-only:group-first:rounded-b-none group-not-only:group-last:rounded-t-none group-not-last:group-not-first:rounded-none" } } }; const buttonGroup = { base: "relative", variants: { size: { xs: "", sm: "", md: "", lg: "", xl: "" }, orientation: { horizontal: "inline-flex -space-x-px", vertical: "flex flex-col -space-y-px" } } }; const badge = (options) => ({ slots: { base: "font-medium inline-flex items-center", label: "truncate", leadingIcon: "shrink-0", leadingAvatar: "shrink-0", leadingAvatarSize: "", trailingIcon: "shrink-0" }, variants: { ...buttonGroupVariant, color: { ...Object.fromEntries((options.theme.colors || []).map((color) => [color, ""])), neutral: "" }, variant: { solid: "", outline: "", soft: "", subtle: "" }, size: { xs: { base: "text-[8px]/3 px-1 py-0.5 gap-1 rounded-sm", leadingIcon: "size-3", leadingAvatarSize: "3xs", trailingIcon: "size-3" }, sm: { base: "text-[10px]/3 px-1.5 py-1 gap-1 rounded-sm", leadingIcon: "size-3", leadingAvatarSize: "3xs", trailingIcon: "size-3" }, md: { base: "text-xs px-2 py-1 gap-1 rounded-md", leadingIcon: "size-4", leadingAvatarSize: "3xs", trailingIcon: "size-4" }, lg: { base: "text-sm px-2 py-1 gap-1.5 rounded-md", leadingIcon: "size-5", leadingAvatarSize: "2xs", trailingIcon: "size-5" }, xl: { base: "text-base px-2.5 py-1 gap-1.5 rounded-md", leadingIcon: "size-6", leadingAvatarSize: "2xs", trailingIcon: "size-6" } }, square: { true: "" } }, compoundVariants: [...(options.theme.colors || []).map((color) => ({ color, variant: "solid", class: `bg-${color} text-inverted` })), ...(options.theme.colors || []).map((color) => ({ color, variant: "outline", class: `text-${color} ring ring-inset ring-${color}/50` })), ...(options.theme.colors || []).map((color) => ({ color, variant: "soft", class: `bg-${color}/10 text-${color}` })), ...(options.theme.colors || []).map((color) => ({ color, variant: "subtle", class: `bg-${color}/10 text-${color} ring ring-inset ring-${color}/25` })), { color: "neutral", variant: "solid", class: "text-inverted bg-inverted" }, { color: "neutral", variant: "outline", class: "ring ring-inset ring-accented text-default bg-default" }, { color: "neutral", variant: "soft", class: "text-default bg-elevated" }, { color: "neutral", variant: "subtle", class: "ring ring-inset ring-accented text-default bg-elevated" }, { size: "xs", square: true, class: "p-0.5" }, { size: "sm", square: true, class: "p-1" }, { size: "md", square: true, class: "p-1" }, { size: "lg", square: true, class: "p-1" }, { size: "xl", square: true, class: "p-1" }], defaultVariants: { color: "primary", variant: "solid", size: "md" } }); const breadcrumb = (options) => ({ slots: { root: "relative min-w-0", list: "flex items-center gap-1.5", item: "flex min-w-0", link: "group relative flex items-center gap-1.5 text-sm min-w-0 focus-visible:outline-primary", linkLeadingIcon: "shrink-0 size-5", linkLeadingAvatar: "shrink-0", linkLeadingAvatarSize: "2xs", linkLabel: "truncate", separator: "flex", separatorIcon: "shrink-0 size-5 text-muted" }, variants: { active: { true: { link: "text-primary font-semibold" }, false: { link: "text-muted font-medium" } }, disabled: { true: { link: "cursor-not-allowed opacity-75" } }, to: { true: "" } }, compoundVariants: [{ disabled: false, active: false, to: true, class: { link: ["hover:text-default", options.theme.transitions && "transition-colors"] } }] }); const button = (options) => ({ slots: { base: ["rounded-md font-medium inline-flex items-center disabled:cursor-not-allowed aria-disabled:cursor-not-allowed disabled:opacity-75 aria-disabled:opacity-75", options.theme.transitions && "transition-colors"], label: "truncate", leadingIcon: "shrink-0", leadingAvatar: "shrink-0", leadingAvatarSize: "", trailingIcon: "shrink-0" }, variants: { ...buttonGroupVariant, color: { ...Object.fromEntries((options.theme.colors || []).map((color) => [color, ""])), neutral: "" }, variant: { solid: "", outline: "", soft: "", subtle: "", ghost: "", link: "" }, size: { xs: { base: "px-2 py-1 text-xs gap-1", leadingIcon: "size-4", leadingAvatarSize: "3xs", trailingIcon: "size-4" }, sm: { base: "px-2.5 py-1.5 text-xs gap-1.5", leadingIcon: "size-4", leadingAvatarSize: "3xs", trailingIcon: "size-4" }, md: { base: "px-2.5 py-1.5 text-sm gap-1.5", leadingIcon: "size-5", leadingAvatarSize: "2xs", trailingIcon: "size-5" }, lg: { base: "px-3 py-2 text-sm gap-2", leadingIcon: "size-5", leadingAvatarSize: "2xs", trailingIcon: "size-5" }, xl: { base: "px-3 py-2 text-base gap-2", leadingIcon: "size-6", leadingAvatarSize: "xs", trailingIcon: "size-6" } }, block: { true: { base: "w-full justify-center", trailingIcon: "ms-auto" } }, square: { true: "" }, leading: { true: "" }, trailing: { true: "" }, loading: { true: "" }, active: { true: { base: "" }, false: { base: "" } } }, compoundVariants: [...(options.theme.colors || []).map((color) => ({ color, variant: "solid", class: `text-inverted bg-${color} hover:bg-${color}/75 disabled:bg-${color} aria-disabled:bg-${color} focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-${color}` })), ...(options.theme.colors || []).map((color) => ({ color, variant: "outline", class: `ring ring-inset ring-${color}/50 text-${color} hover:bg-${color}/10 disabled:bg-transparent aria-disabled:bg-transparent dark:disabled:bg-transparent dark:aria-disabled:bg-transparent focus:outline-none focus-visible:ring-2 focus-visible:ring-${color}` })), ...(options.theme.colors || []).map((color) => ({ color, variant: "soft", class: `text-${color} bg-${color}/10 hover:bg-${color}/15 focus:outline-none focus-visible:bg-${color}/15 disabled:bg-${color}/10 aria-disabled:bg-${color}/10` })), ...(options.theme.colors || []).map((color) => ({ color, variant: "subtle", class: `text-${color} ring ring-inset ring-${color}/25 bg-${color}/10 hover:bg-${color}/15 disabled:bg-${color}/10 aria-disabled:bg-${color}/10 focus:outline-none focus-visible:ring-2 focus-visible:ring-${color}` })), ...(options.theme.colors || []).map((color) => ({ color, variant: "ghost", class: `text-${color} hover:bg-${color}/10 focus:outline-none focus-visible:bg-${color}/10 disabled:bg-transparent aria-disabled:bg-transparent dark:disabled:bg-transparent dark:aria-disabled:bg-transparent` })), ...(options.theme.colors || []).map((color) => ({ color, variant: "link", class: `text-${color} hover:text-${color}/75 disabled:text-${color} aria-disabled:text-${color} focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-${color}` })), { color: "neutral", variant: "solid", class: "text-inverted bg-inverted hover:bg-inverted/90 disabled:bg-inverted aria-disabled:bg-inverted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-inverted" }, { color: "neutral", variant: "outline", class: "ring ring-inset ring-accented text-default bg-default hover:bg-elevated disabled:bg-default aria-disabled:bg-default focus:outline-none focus-visible:ring-2 focus-visible:ring-inverted" }, { color: "neutral", variant: "soft", class: "text-default bg-elevated hover:bg-accented/75 focus:outline-none focus-visible:bg-accented/75 disabled:bg-elevated aria-disabled:bg-elevated" }, { color: "neutral", variant: "subtle", class: "ring ring-inset ring-accented text-default bg-elevated hover:bg-accented/75 disabled:bg-elevated aria-disabled:bg-elevated focus:outline-none focus-visible:ring-2 focus-visible:ring-inverted" }, { color: "neutral", variant: "ghost", class: "text-default hover:bg-elevated focus:outline-none focus-visible:bg-elevated hover:disabled:bg-transparent dark:hover:disabled:bg-transparent hover:aria-disabled:bg-transparent dark:hover:aria-disabled:bg-transparent" }, { color: "neutral", variant: "link", class: "text-muted hover:text-default disabled:text-muted aria-disabled:text-muted focus:outline-none focus-visible:ring-inset focus-visible:ring-2 focus-visible:ring-inverted" }, { size: "xs", square: true, class: "p-1" }, { size: "sm", square: true, class: "p-1.5" }, { size: "md", square: true, class: "p-1.5" }, { size: "lg", square: true, class: "p-2" }, { size: "xl", square: true, class: "p-2" }, { loading: true, leading: true, class: { leadingIcon: "animate-spin" } }, { loading: true, leading: false, trailing: true, class: { trailingIcon: "animate-spin" } }], defaultVariants: { color: "primary", variant: "solid", size: "md" } }); const calendar = (options) => ({ slots: { root: "", header: "flex items-center justify-between", body: "flex flex-col space-y-4 pt-4 sm:flex-row sm:space-x-4 sm:space-y-0", heading: "text-center font-medium truncate mx-auto", grid: "w-full border-collapse select-none space-y-1 focus:outline-none", gridRow: "grid grid-cols-7 place-items-center", gridWeekDaysRow: "mb-1 grid w-full grid-cols-7", gridBody: "grid", headCell: "rounded-md", cell: "relative text-center", cellTrigger: ["m-0.5 relative flex items-center justify-center rounded-full whitespace-nowrap focus-visible:ring-2 focus:outline-none data-disabled:text-muted data-unavailable:line-through data-unavailable:text-muted data-unavailable:pointer-events-none data-[selected]:text-inverted data-today:font-semibold data-[outside-view]:text-muted", options.theme.transitions && "transition"] }, variants: { color: { ...Object.fromEntries((options.theme.colors || []).map((color) => [color, { headCell: `text-${color}`, cellTrigger: `focus-visible:ring-${color} data-[selected]:bg-${color} data-today:not-data-[selected]:text-${color} data-[highlighted]:bg-${color}/20 hover:not-data-[selected]:bg-${color}/20` }])), neutral: { headCell: "text-highlighted", cellTrigger: "focus-visible:ring-inverted data-[selected]:bg-inverted data-today:not-data-[selected]:text-highlighted data-[highlighted]:bg-inverted/20 hover:not-data-[selected]:bg-inverted/10" } }, size: { xs: { heading: "text-xs", cell: "text-xs", headCell: "text-[10px]", cellTrigger: "size-7", body: "space-y-2 pt-2" }, sm: { heading: "text-xs", headCell: "text-xs", cell: "text-xs", cellTrigger: "size-7" }, md: { heading: "text-sm", headCell: "text-xs", cell: "text-sm", cellTrigger: "size-8" }, lg: { heading: "text-md", headCell: "text-md", cellTrigger: "size-9 text-md" }, xl: { heading: "text-lg", headCell: "text-lg", cellTrigger: "size-10 text-lg" } } }, defaultVariants: { size: "md", color: "primary" } }); const card = { slots: { root: "rounded-lg", header: "p-4 sm:px-6", body: "p-4 sm:p-6", footer: "p-4 sm:px-6" }, variants: { variant: { solid: { root: "bg-inverted text-inverted" }, outline: { root: "bg-default ring ring-default divide-y divide-default" }, soft: { root: "bg-elevated/50 divide-y divide-default" }, subtle: { root: "bg-elevated/50 ring ring-default divide-y divide-default" } } }, defaultVariants: { variant: "outline" } }; const carousel = (options) => ({ slots: { root: "relative focus:outline-none", viewport: "overflow-hidden", container: "flex items-start", item: "min-w-0 shrink-0 basis-full", controls: "", arrows: "", prev: "absolute rounded-full", next: "absolute rounded-full", dots: "absolute inset-x-0 -bottom-7 flex flex-wrap items-center justify-center gap-3", dot: ["cursor-pointer size-3 bg-accented rounded-full", options.theme.transitions && "transition"] }, variants: { orientation: { vertical: { container: "flex-col -mt-4", item: "pt-4", prev: "top-4 sm:-top-12 left-1/2 -translate-x-1/2 rotate-90 rtl:-rotate-90", next: "bottom-4 sm:-bottom-12 left-1/2 -translate-x-1/2 rotate-90 rtl:-rotate-90" }, horizontal: { container: "flex-row -ms-4", item: "ps-4", prev: "start-4 sm:-start-12 top-1/2 -translate-y-1/2", next: "end-4 sm:-end-12 top-1/2 -translate-y-1/2" } }, active: { true: { dot: "bg-inverted" } } } }); const checkbox = (options) => ({ slots: { root: "relative flex items-start", container: "flex items-center", base: "rounded-sm ring ring-inset ring-accented overflow-hidden focus-visible:outline-2 focus-visible:outline-offset-2", indicator: "flex items-center justify-center size-full text-inverted", icon: "shrink-0 size-full", wrapper: "w-full", label: "block font-medium text-default", description: "text-muted" }, variants: { color: { ...Object.fromEntries((options.theme.colors || []).map((color) => [color, { base: `focus-visible:outline-${color}`, indicator: `bg-${color}` }])), neutral: { base: "focus-visible:outline-inverted", indicator: "bg-inverted" } }, variant: { list: { root: "" }, card: { root: "border border-muted rounded-lg" } }, indicator: { start: { root: "flex-row", wrapper: "ms-2" }, end: { root: "flex-row-reverse", wrapper: "me-2" }, hidden: { base: "sr-only", wrapper: "text-center" } }, size: { xs: { base: "size-3", container: "h-4", wrapper: "text-xs" }, sm: { base: "size-3.5", container: "h-4", wrapper: "text-xs" }, md: { base: "size-4", container: "h-5", wrapper: "text-sm" }, lg: { base: "size-4.5", container: "h-5", wrapper: "text-sm" }, xl: { base: "size-5", container: "h-6", wrapper: "text-base" } }, required: { true: { label: "after:content-['*'] after:ms-0.5 after:text-error" } }, disabled: { true: { base: "cursor-not-allowed opacity-75", label: "cursor-not-allowed opacity-75", description: "cursor-not-allowed opacity-75" } }, checked: { true: "" } }, compoundVariants: [ { size: "xs", variant: "card", class: { root: "p-2.5" } }, { size: "sm", variant: "card", class: { root: "p-3" } }, { size: "md", variant: "card", class: { root: "p-3.5" } }, { size: "lg", variant: "card", class: { root: "p-4" } }, { size: "xl", variant: "card", class: { root: "p-4.5" } }, ...(options.theme.colors || []).map((color) => ({ color, variant: "card", class: { root: `has-data-[state=checked]:border-${color}` } })), { color: "neutral", variant: "card", class: { root: "has-data-[state=checked]:border-inverted" } }, { variant: "card", disabled: true, class: { root: "cursor-not-allowed opacity-75" } } ], defaultVariants: { size: "md", color: "primary", variant: "list", indicator: "start" } }); const checkboxGroup = (options) => ({ slots: { root: "relative", fieldset: "flex gap-x-2", legend: "mb-1 block font-medium text-default", item: "" }, variants: { orientation: { horizontal: { fieldset: "flex-row" }, vertical: { fieldset: "flex-col" } }, color: { ...Object.fromEntries((options.theme.colors || []).map((color) => [color, {}])), neutral: {} }, variant: { list: {}, card: {}, table: { item: "border border-muted" } }, size: { xs: { fieldset: "gap-y-0.5", legend: "text-xs" }, sm: { fieldset: "gap-y-0.5", legend: "text-xs" }, md: { fieldset: "gap-y-1", legend: "text-sm" }, lg: { fieldset: "gap-y-1", legend: "text-sm" }, xl: { fieldset: "gap-y-1.5", legend: "text-base" } }, required: { true: { legend: "after:content-['*'] after:ms-0.5 after:text-error" } } }, compoundVariants: [ { size: "xs", variant: "table", class: { item: "p-2.5" } }, { size: "sm", variant: "table", class: { item: "p-3" } }, { size: "md", variant: "table", class: { item: "p-3.5" } }, { size: "lg", variant: "table", class: { item: "p-4" } }, { size: "xl", variant: "table", class: { item: "p-4.5" } }, { orientation: "horizontal", variant: "table", class: { item: "first-of-type:rounded-s-lg last-of-type:rounded-e-lg", fieldset: "gap-0 -space-x-px" } }, { orientation: "vertical", variant: "table", class: { item: "first-of-type:rounded-t-lg last-of-type:rounded-b-lg", fieldset: "gap-0 -space-y-px" } }, ...(options.theme.colors || []).map((color) => ({ color, variant: "table", class: { item: `has-data-[state=checked]:bg-${color}/10 has-data-[state=checked]:border-${color}/50 has-data-[state=checked]:z-[1]` } })), { color: "neutral", variant: "table", class: { item: "has-data-[state=checked]:bg-elevated has-data-[state=checked]:border-inverted/50 has-data-[state=checked]:z-[1]" } }, { variant: "table", disabled: true, class: { item: "cursor-not-allowed opacity-75" } } ], defaultVariants: { size: "md", variant: "list", color: "primary" } }); const chip = (options) => ({ slots: { root: "relative inline-flex items-center justify-center shrink-0", base: "rounded-full ring ring-bg flex items-center justify-center text-inverted font-medium whitespace-nowrap" }, variants: { color: { ...Object.fromEntries((options.theme.colors || []).map((color) => [color, `bg-${color}`])), neutral: "bg-inverted" }, size: { "3xs": "h-[4px] min-w-[4px] text-[4px]", "2xs": "h-[5px] min-w-[5px] text-[5px]", "xs": "h-[6px] min-w-[6px] text-[6px]", "sm": "h-[7px] min-w-[7px] text-[7px]", "md": "h-[8px] min-w-[8px] text-[8px]", "lg": "h-[9px] min-w-[9px] text-[9px]", "xl": "h-[10px] min-w-[10px] text-[10px]", "2xl": "h-[11px] min-w-[11px] text-[11px]", "3xl": "h-[12px] min-w-[12px] text-[12px]" }, position: { "top-right": "top-0 right-0", "bottom-right": "bottom-0 right-0", "top-left": "top-0 left-0", "bottom-left": "bottom-0 left-0" }, inset: { false: "" }, standalone: { false: "absolute" } }, compoundVariants: [{ position: "top-right", inset: false, class: "-translate-y-1/2 translate-x-1/2 transform" }, { position: "bottom-right", inset: false, class: "translate-y-1/2 translate-x-1/2 transform" }, { position: "top-left", inset: false, class: "-translate-y-1/2 -translate-x-1/2 transform" }, { position: "bottom-left", inset: false, class: "translate-y-1/2 -translate-x-1/2 transform" }], defaultVariants: { size: "md", color: "primary", position: "top-right" } }); const collapsible = { slots: { root: "", content: "data-[state=open]:animate-[collapsible-down_200ms_ease-out] data-[state=closed]:animate-[collapsible-up_200ms_ease-out] overflow-hidden" } }; const colorPicker = { slots: { root: "data-[disabled]:opacity-75", picker: "flex gap-4", selector: "rounded-md touch-none", selectorBackground: "w-full h-full relative rounded-md", selectorThumb: "-translate-y-1/2 -translate-x-1/2 absolute size-4 ring-2 ring-(--color-white) rounded-full cursor-pointer data-[disabled]:cursor-not-allowed", track: "w-[8px] relative rounded-md touch-none", trackThumb: "absolute transform -translate-y-1/2 -translate-x-[4px] rtl:translate-x-[4px] size-4 rounded-full ring-2 ring-(--color-white) cursor-pointer data-[disabled]:cursor-not-allowed" }, variants: { size: { xs: { selector: "w-38 h-38", track: "h-38" }, sm: { selector: "w-40 h-40", track: "h-40" }, md: { selector: "w-42 h-42", track: "h-42" }, lg: { selector: "w-44 h-44", track: "h-44" }, xl: { selector: "w-46 h-46", track: "h-46" } } }, compoundVariants: [], defaultVariants: { size: "md" } }; const commandPalette = (options) => ({ slots: { root: "flex flex-col min-h-0 min-w-0 divide-y divide-default", input: "[&>input]:h-12", close: "", content: "relative overflow-hidden flex flex-col", viewport: "relative divide-y divide-default scroll-py-1 overflow-y-auto flex-1 focus:outline-none", group: "p-1 isolate", empty: "py-6 text-center text-sm text-muted", label: "p-1.5 text-xs font-semibold text-highlighted", item: "group relative w-full flex items-center gap-1.5 p-1.5 text-sm select-none outline-none before:absolute before:z-[-1] before:inset-px before:rounded-md data-disabled:cursor-not-allowed data-disabled:opacity-75", itemLeadingIcon: "shrink-0 size-5", itemLeadingAvatar: "shrink-0", itemLeadingAvatarSize: "2xs", itemLeadingChip: "shrink-0 size-5", itemLeadingChipSize: "md", itemTrailing: "ms-auto inline-flex gap-1.5 items-center", itemTrailingIcon: "shrink-0 size-5", itemTrailingHighlightedIcon: "shrink-0 size-5 text-dimmed hidden group-data-highlighted:inline-flex", itemTrailingKbds: "hidden lg:inline-flex items-center shrink-0 gap-0.5", itemTrailingKbdsSize: "md", itemLabel: "truncate space-x-1 rtl:space-x-reverse text-dimmed", itemLabelBase: "text-highlighted [&>mark]:text-inverted [&>mark]:bg-primary", itemLabelPrefix: "text-default", itemLabelSuffix: "text-dimmed [&>mark]:text-inverted [&>mark]:bg-primary" }, variants: { active: { true: { item: "text-highlighted before:bg-elevated", itemLeadingIcon: "text-default" }, false: { item: ["text-default data-highlighted:not-data-disabled:text-highlighted data-highlighted:not-data-disabled:before:bg-elevated/50", options.theme.transitions && "transition-colors before:transition-colors"], itemLeadingIcon: ["text-dimmed group-data-highlighted:not-group-data-disabled:text-default", options.theme.transitions && "transition-colors"] } }, loading: { true: { itemLeadingIcon: "animate-spin" } } } }); const container = { base: "w-full max-w-(--ui-container) mx-auto px-4 sm:px-6 lg:px-8" }; const contextMenu = (options) => ({ slots: { content: "min-w-32 bg-default shadow-lg rounded-md ring ring-default overflow-hidden data-[state=open]:animate-[scale-in_100ms_ease-out] data-[state=closed]:animate-[scale-out_100ms_ease-in] origin-(--reka-context-menu-content-transform-origin) flex flex-col", viewport: "relative divide-y divide-default scroll-py-1 overflow-y-auto flex-1", group: "p-1 isolate", label: "w-full flex items-center font-semibold text-highlighted", separator: "-mx-1 my-1 h-px bg-border", item: "group relative w-full flex items-center select-none outline-none before:absolute before:z-[-1] before:inset-px before:rounded-md data-disabled:cursor-not-allowed data-disabled:opacity-75", itemLeadingIcon: "shrink-0", itemLeadingAvatar: "shrink-0", itemLeadingAvatarSize: "", itemTrailing: "ms-auto inline-flex gap-1.5 items-center", itemTrailingIcon: "shrink-0", itemTrailingKbds: "hidden lg:inline-flex items-center shrink-0", itemTrailingKbdsSize: "", itemLabel: "truncate", itemLabelExternalIcon: "inline-block size-3 align-top text-dimmed" }, variants: { color: { ...Object.fromEntries((options.theme.colors || []).map((color) => [color, ""])), neutral: "" }, active: { true: { item: "text-highlighted before:bg-elevated", itemLeadingIcon: "text-default" }, false: { item: ["text-default data-highlighted:text-highlighted data-[state=open]:text-highlighted data-highlighted:before:bg-elevated/50 data-[state=open]:before:bg-elevated/50", options.theme.transitions && "transition-colors before:transition-colors"], itemLeadingIcon: ["text-dimmed group-data-highlighted:text-default group-data-[state=open]:text-default", options.theme.transitions && "transition-colors"] } }, loading: { true: { itemLeadingIcon: "animate-spin" } }, size: { xs: { label: "p-1 text-xs gap-1", item: "p-1 text-xs gap-1", itemLeadingIcon: "size-4", itemLeadingAvatarSize: "3xs", itemTrailingIcon: "size-4", itemTrailingKbds: "gap-0.5", itemTrailingKbdsSize: "sm" }, sm: { label: "p-1.5 text-xs gap-1.5", item: "p-1.5 text-xs gap-1.5", itemLeadingIcon: "size-4", itemLeadingAvatarSize: "3xs", itemTrailingIcon: "size-4", itemTrailingKbds: "gap-0.5", itemTrailingKbdsSize: "sm" }, md: { label: "p-1.5 text-sm gap-1.5", item: "p-1.5 text-sm gap-1.5", itemLeadingIcon: "size-5", itemLeadingAvatarSize: "2xs", itemTrailingIcon: "size-5", itemTrailingKbds: "gap-0.5", itemTrailingKbdsSize: "md" }, lg: { label: "p-2 text-sm gap-2", item: "p-2 text-sm gap-2", itemLeadingIcon: "size-5", itemLeadingAvatarSize: "2xs", itemTrailingIcon: "size-5", itemTrailingKbds: "gap-1", itemTrailingKbdsSize: "md" }, xl: { label: "p-2 text-base gap-2", item: "p-2 text-base gap-2", itemLeadingIcon: "size-6", itemLeadingAvatarSize: "xs", itemTrailingIcon: "size-6", itemTrailingKbds: "gap-1", itemTrailingKbdsSize: "lg" } } }, compoundVariants: [...(options.theme.colors || []).map((color) => ({ color, active: false, class: { item: `text-${color} data-highlighted:text-${color} data-highlighted:before:bg-${color}/10 data-[state=open]:before:bg-${color}/10`, itemLeadingIcon: `text-${color}/75 group-data-highlighted:text-${color} group-data-[state=open]:text-${color}` } })), ...(options.theme.colors || []).map((color) => ({ color, active: true, class: { item: `text-${color} before:bg-${color}/10`, itemLeadingIcon: `text-${color}` } }))], defaultVariants: { size: "md" } }); const drawer = (options) => ({ slots: { overlay: "fixed inset-0 bg-elevated/75", content: "fixed bg-default ring ring-default flex focus:outline-none", handle: ["shrink-0 !bg-accented", options.theme.transitions && "transition-opacity"], container: "w-full flex flex-col gap-4 p-4 overflow-y-auto", header: "", title: "text-highlighted font-semibold", description: "mt-1 text-muted text-sm", body: "flex-1", footer: "flex flex-col gap-1.5" }, variants: { direction: { top: { content: "mb-24 flex-col-reverse", handle: "mb-4" }, right: { content: "flex-row", handle: "!ml-4" }, bottom: { content: "mt-24 flex-col", handle: "mt-4" }, left: { content: "flex-row-reverse", handle: "!mr-4" } }, inset: { true: { content: "rounded-lg after:hidden" } } }, compoundVariants: [{ direction: ["top", "bottom"], class: { content: "h-auto max-h-[96%]", handle: "!w-12 !h-1.5 mx-auto" } }, { direction: ["right", "left"], class: { content: "w-auto max-w-[calc(100%-2rem)]", handle: "!h-12 !w-1.5 mt-auto mb-auto" } }, { direction: "top", inset: true, class: { content: "inset-x-4 top-4" } }, { direction: "top", inset: false, class: { content: "inset-x-0 top-0 rounded-b-lg" } }, { direction: "bottom", inset: true, class: { content: "inset-x-4 bottom-4" } }, { direction: "bottom", inset: false, class: { content: "inset-x-0 bottom-0 rounded-t-lg" } }, { direction: "left", inset: true, class: { content: "inset-y-4 left-4" } }, { direction: "left", inset: false, class: { content: "inset-y-0 left-0 rounded-r-lg" } }, { direction: "right", inset: true, class: { content: "inset-y-4 right-4" } }, { direction: "right", inset: false, class: { content: "inset-y-0 right-0 rounded-l-lg" } }] }); const dropdownMenu = (options) => ({ slots: { content: "min-w-32 bg-default shadow-lg rounded-md ring ring-default overflow-hidden data-[state=open]:animate-[scale-in_100ms_ease-out] data-[state=closed]:animate-[scale-out_100ms_ease-in] origin-(--reka-dropdown-menu-content-transform-origin) flex flex-col", viewport: "relative divide-y divide-default scroll-py-1 overflow-y-auto flex-1", arrow: "fill-default", group: "p-1 isolate", label: "w-full flex items-center font-semibold text-highlighted", separator: "-mx-1 my-1 h-px bg-border", item: "group relative w-full flex items-center select-none outline-none before:absolute before:z-[-1] before:inset-px before:rounded-md data-disabled:cursor-not-allowed data-disabled:opacity-75", itemLeadingIcon: "shrink-0", itemLeadingAvatar: "shrink-0", itemLeadingAvatarSize: "", itemTrailing: "ms-auto inline-flex gap-1.5 items-center", itemTrailingIcon: "shrink-0", itemTrailingKbds: "hidden lg:inline-flex items-center shrink-0", itemTrailingKbdsSize: "", itemLabel: "truncate", itemLabelExternalIcon: "inline-block size-3 align-top text-dimmed" }, variants: { color: { ...Object.fromEntries((options.theme.colors || []).map((color) => [color, ""])), neutral: "" }, active: { true: { item: "text-highlighted before:bg-elevated", itemLeadingIcon: "text-default" }, false: { item: ["text-default data-highlighted:text-highlighted data-[state=open]:text-highlighted data-highlighted:before:bg-elevated/50 data-[state=open]:before:bg-elevated/50", options.theme.transitions && "transition-colors before:transition-colors"], itemLeadingIcon: ["text-dimmed group-data-highlighted:text-default group-data-[state=open]:text-default", options.theme.transitions && "transition-colors"] } }, loading: { true: { itemLeadingIcon: "animate-spin" } }, size: { xs: { label: "p-1 text-xs gap-1", item: "p-1 text-xs gap-1", itemLeadingIcon: "size-4", itemLeadingAvatarSize: "3xs", itemTrailingIcon: "size-4", itemTrailingKbds: "gap-0.5", itemTrailingKbdsSize: "sm" }, sm: { label: "p-1.5 text-xs gap-1.5", item: "p-1.5 text-xs gap-1.5", itemLeadingIcon: "size-4", itemLeadingAvatarSize: "3xs", itemTrailingIcon: "size-4", itemTrailingKbds: "gap-0.5", itemTrailingKbdsSize: "sm" }, md: { label: "p-1.5 text-sm gap-1.5", item: "p-1.5 text-sm gap-1.5", itemLeadingIcon: "size-5", itemLeadingAvatarSize: "2xs", itemTrailingIcon: "size-5", itemTrailingKbds: "gap-0.5", itemTrailingKbdsSize: "md" }, lg: { label: "p-2 text-sm gap-2", item: "p-2 text-sm gap-2", itemLeadingIcon: "size-5", itemLeadingAvatarSize: "2xs", itemTrailingIcon: "size-5", itemTrailingKbds: "gap-1", itemTrailingKbdsSize: "md" }, xl: { label: "p-2 text-base gap-2", item: "p-2 text-base gap-2", itemLeadingIcon: "size-6", itemLeadingAvatarSize: "xs", itemTrailingIcon: "size-6", itemTrailingKbds: "gap-1", itemTrailingKbdsSize: "lg" } } }, compoundVariants: [...(options.theme.colors || []).map((color) => ({ color, active: false, class: { item: `text-${color} data-highlighted:text-${color} data-highlighted:before:bg-${color}/10 data-[state=open]:before:bg-${color}/10`, itemLeadingIcon: `text-${color}/75 group-data-highlighted:text-${color} group-data-[state=open]:text-${color}` } })), ...(options.theme.colors || []).map((color) => ({ color, active: true, class: { item: `text-${color} before:bg-${color}/10`, itemLeadingIcon: `text-${color}` } }))], defaultVariants: { size: "md" } }); const form = { base: "" }; const formField = { slots: { root: "", wrapper: "", labelWrapper: "flex content-center items-center justify-between", label: "block font-medium text-default", container: "mt-1 relative", description: "text-muted", error: "mt-2 text-error", hint: "text-muted", help: "mt-2 text-muted" }, variants: { size: { xs: { root: "text-xs" }, sm: { root: "text-xs" }, md: { root: "text-sm" }, lg: { root: "text-sm" }, xl: { root: "text-base" } }, required: { true: { label: `after:content-['*'] after:ms-0.5 after:text-error` } } }, defaultVariants: { size: "md" } }; const input = (options) => ({ slots: { root: "relative inline-flex items-center", base: ["w-full rounded-md border-0 placeholder:text-dimmed focus:outline-none disabled:cursor-not-allowed disabled:opacity-75", options.theme.transitions && "transition-colors"], leading: "absolute inset-y-0 start-0 flex items-center", leadingIcon: "shrink-0 text-dimmed", leadingAvatar: "shrink-0", leadingAvatarSize: "", trailing: "absolute inset-y-0 end-0 flex items-center", trailingIcon: "shrink-0 text-dimmed" }, variants: { ...buttonGroupVariantWithRoot, size: { xs: { base: "px-2 py-1 text-xs gap-1", leading: "ps-2", trailing: "pe-2", leadingIcon: "size-4", leadingAvatarSize: "3xs", trailingIcon: "size-4" }, sm: { base: "px-2.5 py-1.5 text-xs gap-1.5", leading: "ps-2.5", trailing: "pe-2.5", leadingIcon: "size-4", leadingAvatarSize: "3xs", trailingIcon: "size-4" }, md: { base: "px-2.5 py-1.5 text-sm gap-1.5", leading: "ps-2.5", trailing: "pe-2.5", leadingIcon: "size-5", leadingAvatarSize: "2xs", trailingIcon: "size-5" }, lg: { base: "px-3 py-2 text-sm gap-2", leading: "ps-3", trailing: "pe-3", leadingIcon: "size-5", leadingAvatarSize: "2xs", trailingIcon: "size-5" }, xl: { base: "px-3 py-2 text-base gap-2", leading: "ps-3", trailing: "pe-3", leadingIcon: "size-6", leadingAvatarSize: "xs", trailingIcon: "size-6" } }, variant: { outline: "text-highlighted bg-default ring ring-inset ring-accented", soft: "text-highlighted bg-elevated/50 hover:bg-elevated focus:bg-elevated disabled:bg-elevated/50", subtle: "text-highlighted bg-elevated ring ring-inset ring-accented", ghost: "text-highlighted bg-transparent hover:bg-elevated focus:bg-elevated disabled:bg-transparent dark:disabled:bg-transparent", none: "text-highlighted bg-transparent" }, color: { ...Object.fromEntries((options.theme.colors || []).map((color) => [color, ""])), neutral: "" }, leading: { true: "" }, trailing: { true: "" }, loading: { true: "" }, highlight: { true: "" }, type: { file: "file:me-1.5 file:font-medium file:text-muted file:outline-none" } }, compoundVariants: [...(options.theme.colors || []).map((color) => ({ color, variant: ["outline", "subtle"], class: `focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-${color}` })), ...(options.theme.colors || []).map((color) => ({ color, highlight: true, class: `ring ring-inset ring-${color}` })), { color: "neutral", variant: ["outline", "subtle"], class: "focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-inverted" }, { color: "neutral", highlight: true, class: "ring ring-inset ring-inverted" }, { leading: true, size: "xs", class: "ps-7" }, { leading: true, size: "sm", class: "ps-8" }, { leading: true, size: "md", class: "ps-9" }, { leading: true, size: "lg", class: "ps-10" }, { leading: true, size: "xl", class: "ps-11" }, { trailing: true, size: "xs", class: "pe-7" }, { trailing: true, size: "sm", class: "pe-8" }, { trailing: true, size: "md", class: "pe-9" }, { trailing: true, size: "lg", class: "pe-10" }, { trailing: true, size: "xl", class: "pe-11" }, { loading: true, leading: true, class: { leadingIcon: "animate-spin" } }, { loading: true, leading: false, trailing: true, class: { trailingIcon: "animate-spin" } }], defaultVariants: { size: "md", color: "primary", variant: "outline" } }); const inputMenu = (options) => { return defuFn({ slots: { base: () => ["rounded-md", options.theme.transitions && "transition-colors"], trailing: "group absolute inset-y-0 end-0 flex items-center disabled:cursor-not-allowed disabled:opacity-75", arrow: "fill-default", content: "max-h-60 w-(--reka-combobox-trigger-width) bg-default shadow-lg rounded-md ring ring-default overflow-hidden data-[state=open]:animate-[scale-in_100ms_ease-out] data-[state=closed]:animate-[scale-out_100ms_ease-in] origin-(--reka-combobox-content-transform-origin) pointer-events-auto flex flex-col", viewport: "relative divide-y divide-default scroll-py-1 overflow-y-auto flex-1", group: "p-1 isolate", empty: "py-2 text-center text-sm text-muted", label: "font-semibold text-highlighted", separator: "-mx-1 my-1 h-px bg-border", item: ["group relative w-full flex items-center gap-1.5 p-1.5 text-sm select-none outline-none before:absolute before:z-[-1] before:inset-px before:rounded-md data-disabled:cursor-not-allowed data-disabled:opacity-75 text-default data-highlighted:not-data-disabled:text-highlighted data-highlighted:not-data-disabled:before:bg-elevated/50", options.theme.transitions && "transition-colors before:transition-colors"], itemLeadingIcon: ["shrink-0 text-dimmed group-data-highlighted:not-group-data-disabled:text-default", options.theme.transitions && "transition-colors"], itemLeadingAvatar: "shrink-0", itemLeadingAvatarSize: "", itemLeadingChip: "shrink-0", itemLeadingChipSize: "", itemTrailing: "ms-auto inline-flex gap-1.5 items-center", itemTrailingIcon: "shrink-0", itemLabel: "truncate", tagsItem: "px-1.5 py-0.5 rounded-sm font-medium inline-flex items-center gap-0.5 ring ring-inset ring-accented bg-elevated text-default data-disabled:cursor-not-allowed data-disabled:opacity-75", tagsItemText: "truncate", tagsItemDelete: ["inline-flex items-center rounded-xs text-dimmed hover:text-default hover:bg-accented/75 disabled:pointer-events-none", options.theme.transitions && "transition-colors"], tagsItemDeleteIcon: "", tagsInput: "" }, variants: { multiple: { true: { root: "flex-wrap", tagsInput: "border-0 bg-transparent placeholder:text-dimmed focus:outline-none disabled:cursor-not-allowed disabled:opacity-75" }, false: { base: "w-full border-0 placeholder:text-dimmed focus:outline-none disabled:cursor-not-allowed disabled:opacity-75" } }, size: { xs: { label: "p-1 text-[10px]/3 gap-1", item: "p-1 text-xs gap-1", itemLeadingIcon: "size-4", itemLeadingAvatarSize: "3xs", itemLeadingChip: "size-4", itemLeadingChipSize: "sm", itemTrailingIcon: "size-4", tagsItem: "text-[10px]/3", tagsItemDeleteIcon: "size-3" }, sm: { label: "p-1.5 text-[10px]/3 gap-1.5", item: "p-1.5 text-xs gap-1.5", itemLeadingIcon: "size-4", itemLeadingAvatarSize: "3xs", itemLeadingChip: "size-4", itemLeadingChipSize: "sm", itemTrailingIcon: "size-4", tagsItem: "text-[10px]/3", tagsItemDeleteIcon: "size-3" }, md: { label: "p-1.5 text-xs gap-1.5", item: "p-1.5 text-sm gap-1.5", itemLeadingIcon: "size-5", itemLeadingAvatarSize: "2xs", itemLeadingChip: "size-5", itemLeadingChipSize: "md", itemTrailingIcon: "size-5", tagsItem: "text-xs", tagsItemDeleteIcon: "size-3.5" }, lg: { label: "p-2 text-xs gap-2", item: "p-2 text-sm gap-2", itemLeadingIcon: "size-5", itemLeadingAvatarSize: "2xs", itemLeadingChip: "size-5", itemLeadingChipSize: "md", itemTrailingIcon: "size-5", tagsItem: "text-xs", tagsItemDeleteIcon: "size-3.5" }, xl: { label: "p-2 text-sm gap-2",