UNPKG

@heroui/theme

Version:

The default theme for HeroUI components

1,078 lines (1,066 loc) 28.5 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/components/select.ts var select_exports = {}; __export(select_exports, { select: () => select }); module.exports = __toCommonJS(select_exports); // src/utils/classes.ts var dataFocusVisibleClasses = [ "outline-solid outline-transparent", "data-[focus-visible=true]:z-10", "data-[focus-visible=true]:outline-2", "data-[focus-visible=true]:outline-focus", "data-[focus-visible=true]:outline-offset-2" ]; // src/utilities/transition.ts var DEFAULT_TRANSITION_DURATION = "250ms"; var transition_default = { /** * Transition utilities */ ".transition-background": { "transition-property": "background", "transition-timing-function": "ease", "transition-duration": DEFAULT_TRANSITION_DURATION }, ".transition-colors-opacity": { "transition-property": "color, background-color, border-color, text-decoration-color, fill, stroke, opacity", "transition-timing-function": "ease", "transition-duration": DEFAULT_TRANSITION_DURATION }, ".transition-width": { "transition-property": "width", "transition-timing-function": "ease", "transition-duration": DEFAULT_TRANSITION_DURATION }, ".transition-height": { "transition-property": "height", "transition-timing-function": "ease", "transition-duration": DEFAULT_TRANSITION_DURATION }, ".transition-size": { "transition-property": "width, height", "transition-timing-function": "ease", "transition-duration": DEFAULT_TRANSITION_DURATION }, ".transition-left": { "transition-property": "left", "transition-timing-function": "ease", "transition-duration": DEFAULT_TRANSITION_DURATION }, ".transition-transform-opacity": { "transition-property": "transform, scale, opacity rotate", "transition-timing-function": "ease", "transition-duration": DEFAULT_TRANSITION_DURATION }, ".transition-transform-background": { "transition-property": "transform, scale, background", "transition-timing-function": "ease", "transition-duration": DEFAULT_TRANSITION_DURATION }, ".transition-transform-colors": { "transition-property": "transform, scale, color, background, background-color, border-color, text-decoration-color, fill, stroke", "transition-timing-function": "ease", "transition-duration": DEFAULT_TRANSITION_DURATION }, ".transition-transform-colors-opacity": { "transition-property": "transform, scale, color, background, background-color, border-color, text-decoration-color, fill, stroke, opacity", "transition-timing-function": "ease", "transition-duration": DEFAULT_TRANSITION_DURATION } }; // src/utilities/custom.ts var custom_default = { /** * Custom utilities */ ".leading-inherit": { "line-height": "inherit" }, ".bg-img-inherit": { "background-image": "inherit" }, ".bg-clip-inherit": { "background-clip": "inherit" }, ".text-fill-inherit": { "-webkit-text-fill-color": "inherit" }, ".tap-highlight-transparent": { "-webkit-tap-highlight-color": "transparent" }, ".input-search-cancel-button-none": { "&::-webkit-search-cancel-button": { "-webkit-appearance": "none" } } }; // src/utilities/scrollbar-hide.ts var scrollbar_hide_default = { /** * Scroll Hide */ ".scrollbar-hide": { /* IE and Edge */ "-ms-overflow-style": "none", /* Firefox */ "scrollbar-width": "none", /* Safari and Chrome */ "&::-webkit-scrollbar": { display: "none" } }, ".scrollbar-default": { /* IE and Edge */ "-ms-overflow-style": "auto", /* Firefox */ "scrollbar-width": "auto", /* Safari and Chrome */ "&::-webkit-scrollbar": { display: "block" } } }; // src/utilities/text.ts var text_default = { /** * Text utilities */ ".text-tiny": { "font-size": "var(--heroui-font-size-tiny)", "line-height": "var(--heroui-line-height-tiny)" }, ".text-small": { "font-size": "var(--heroui-font-size-small)", "line-height": "var(--heroui-line-height-small)" }, ".text-medium": { "font-size": "var(--heroui-font-size-medium)", "line-height": "var(--heroui-line-height-medium)" }, ".text-large": { "font-size": "var(--heroui-font-size-large)", "line-height": "var(--heroui-line-height-large)" } }; // src/utilities/animation.ts var animation_default = { /** Animation Utilities */ ".spinner-bar-animation": { "animation-delay": "calc(-1.2s + (0.1s * var(--bar-index)))", transform: "rotate(calc(30deg * var(--bar-index)))translate(140%)" }, ".spinner-dot-animation": { "animation-delay": "calc(250ms * var(--dot-index))" }, ".spinner-dot-blink-animation": { "animation-delay": "calc(200ms * var(--dot-index))" } }; // src/utilities/index.ts var utilities = { ...custom_default, ...transition_default, ...scrollbar_hide_default, ...text_default, ...animation_default }; // src/utils/tw-merge-config.ts var COMMON_UNITS = ["small", "medium", "large"]; var twMergeConfig = { theme: { spacing: ["divider"], radius: COMMON_UNITS }, classGroups: { shadow: [{ shadow: COMMON_UNITS }], opacity: [{ opacity: ["disabled"] }], "font-size": [{ text: ["tiny", ...COMMON_UNITS] }], "border-w": [{ border: COMMON_UNITS }], "bg-image": [ "bg-stripe-gradient-default", "bg-stripe-gradient-primary", "bg-stripe-gradient-secondary", "bg-stripe-gradient-success", "bg-stripe-gradient-warning", "bg-stripe-gradient-danger" ], transition: Object.keys(utilities).filter((key) => key.includes(".transition")).map((key) => key.replace(".", "")) // remove the dot from the key, .transition-background -> transition-background } }; // src/utils/tv.ts var import_tailwind_variants = require("tailwind-variants"); var tv = (options, config) => { var _a, _b, _c; return (0, import_tailwind_variants.tv)(options, { ...config, twMerge: (_a = config == null ? void 0 : config.twMerge) != null ? _a : true, twMergeConfig: { ...config == null ? void 0 : config.twMergeConfig, theme: { ...(_b = config == null ? void 0 : config.twMergeConfig) == null ? void 0 : _b.theme, ...twMergeConfig.theme }, classGroups: { ...(_c = config == null ? void 0 : config.twMergeConfig) == null ? void 0 : _c.classGroups, ...twMergeConfig.classGroups } } }); }; // src/components/select.ts var select = tv({ slots: { base: ["group inline-flex flex-col relative"], label: [ "block", "absolute", "z-10", "origin-top-left", "flex-shrink-0", // Using RTL here as Tailwind CSS doesn't support `start` and `end` logical properties for transforms yet. "rtl:origin-top-right", "subpixel-antialiased", "text-small", "text-foreground-500", "pointer-events-none", "group-data-[has-label-outside=true]:pointer-events-auto" ], mainWrapper: "w-full flex flex-col", trigger: "relative px-3 gap-3 w-full inline-flex flex-row items-center shadow-xs outline-solid outline-transparent tap-highlight-transparent", innerWrapper: "inline-flex h-fit w-[calc(100%_-theme(spacing.6))] min-h-4 items-center gap-1.5 box-border", selectorIcon: "absolute end-3 w-4 h-4", spinner: "absolute end-3", value: ["text-foreground-500", "font-normal", "w-full", "text-start"], listboxWrapper: "scroll-py-6 w-full", listbox: "", popoverContent: "w-full p-1 overflow-hidden", clearButton: [ "w-4", "h-4", "z-10", "mb-4", "relative", "start-auto", "appearance-none", "outline-none", "select-none", "opacity-70", "hover:!opacity-100", "cursor-pointer", "active:!opacity-70", "rounded-full", // focus ring ...dataFocusVisibleClasses ], helperWrapper: "p-1 flex relative flex-col gap-1.5 group-data-[has-helper=true]:flex", description: "text-tiny text-foreground-400", errorMessage: "text-tiny text-danger", endWrapper: "flex end-18", endContent: "mb-4" }, variants: { variant: { flat: { trigger: [ "bg-default-100", "data-[hover=true]:bg-default-200", "group-data-[focus=true]:bg-default-200" ], clearButton: "mb-4" }, faded: { trigger: [ "bg-default-100", "border-medium", "border-default-200", "data-[hover=true]:border-default-400 data-[focus=true]:border-default-400 data-[open=true]:border-default-400" ], value: "group-data-[has-value=true]:text-default-foreground", clearButton: "mb-4" }, bordered: { trigger: [ "border-medium", "border-default-200", "data-[hover=true]:border-default-400", "data-[open=true]:border-default-foreground", "data-[focus=true]:border-default-foreground" ], value: "group-data-[has-value=true]:text-default-foreground", clearButton: "mb-4" }, underlined: { trigger: [ "!px-1", "!pb-0", "!gap-0", "relative", "box-border", "border-b-medium", "shadow-[0_1px_0px_0_rgba(0,0,0,0.05)]", "border-default-200", "!rounded-none", "hover:border-default-300", "after:content-['']", "after:w-0", "after:origin-center", "after:bg-default-foreground", "after:absolute", "after:left-1/2", "after:-translate-x-1/2", "after:-bottom-[2px]", "after:h-[2px]", "data-[open=true]:after:w-full", "data-[focus=true]:after:w-full" ], value: "group-data-[has-value=true]:text-default-foreground", clearButton: "mb-4 me-2" } }, color: { default: {}, primary: { selectorIcon: "text-primary" }, secondary: { selectorIcon: "text-secondary" }, success: { selectorIcon: "text-success" }, warning: { selectorIcon: "text-warning" }, danger: { selectorIcon: "text-danger" } }, size: { sm: { label: "text-tiny", trigger: "h-8 min-h-8 px-2 rounded-small", value: "text-small", clearButton: "text-medium" }, md: { trigger: "h-10 min-h-10 rounded-medium", value: "text-small", clearButton: "text-large" }, lg: { trigger: "h-12 min-h-12 rounded-large", value: "text-medium", clearButton: "mb-5 text-large" } }, radius: { none: { trigger: "rounded-none" }, sm: { trigger: "rounded-small" }, md: { trigger: "rounded-medium" }, lg: { trigger: "rounded-large" }, full: { trigger: "rounded-full" } }, labelPlacement: { outside: { base: "flex flex-col", clearButton: "mb-0" }, "outside-left": { base: "flex-row items-center flex-nowrap data-[has-helper=true]:items-start", label: "relative pe-2 text-foreground", clearButton: "mb-0" }, inside: { label: "text-tiny cursor-pointer", trigger: "flex-col items-start justify-center gap-0" } }, fullWidth: { true: { base: "w-full" }, false: { base: "min-w-40" } }, isClearable: { true: { clearButton: "peer-data-[filled=true]:opacity-70 peer-data-[filled=true]:block", endContent: "ms-3" } }, isDisabled: { true: { base: "opacity-disabled pointer-events-none", trigger: "pointer-events-none" } }, isInvalid: { true: { label: "!text-danger", value: "!text-danger", selectorIcon: "text-danger" } }, isRequired: { true: { label: "after:content-['*'] after:text-danger after:ms-0.5" } }, isMultiline: { true: { label: "relative", trigger: "!h-auto" }, false: { value: "truncate" } }, disableAnimation: { true: { trigger: "after:transition-none", base: "transition-none", label: "transition-none", selectorIcon: "transition-none" }, false: { base: "transition-background motion-reduce:transition-none !duration-150", label: [ "will-change-auto", "origin-top-left", // Using RTL here as Tailwind CSS doesn't support `start` and `end` logical properties for transforms yet. "rtl:origin-top-right", "!duration-200", "!ease-out", "transition-[transform,color,left,opacity,translate,scale]", "motion-reduce:transition-none" ], selectorIcon: "transition-transform duration-150 ease motion-reduce:transition-none", clearButton: ["transition-opacity", "motion-reduce:transition-none"] } }, disableSelectorIconRotation: { true: {}, false: { selectorIcon: "data-[open=true]:rotate-180" } } }, defaultVariants: { variant: "flat", color: "default", size: "md", fullWidth: true, isDisabled: false, isMultiline: false, disableSelectorIconRotation: false }, compoundVariants: [ // flat & color { variant: "flat", color: "default", class: { value: "group-data-[has-value=true]:text-default-foreground", trigger: ["bg-default-100", "data-[hover=true]:bg-default-200"] } }, { variant: "flat", color: "primary", class: { trigger: [ "bg-primary-100", "text-primary", "data-[hover=true]:bg-primary-50", "group-data-[focus=true]:bg-primary-50" ], value: "text-primary", label: "text-primary" } }, { variant: "flat", color: "secondary", class: { trigger: [ "bg-secondary-100", "text-secondary", "data-[hover=true]:bg-secondary-50", "group-data-[focus=true]:bg-secondary-50" ], value: "text-secondary", label: "text-secondary" } }, { variant: "flat", color: "success", class: { trigger: [ "bg-success-100", "text-success-600", "dark:text-success", "data-[hover=true]:bg-success-50", "group-data-[focus=true]:bg-success-50" ], value: "text-success-600 dark:text-success", label: "text-success-600 dark:text-success" } }, { variant: "flat", color: "warning", class: { trigger: [ "bg-warning-100", "text-warning-600", "dark:text-warning", "data-[hover=true]:bg-warning-50", "group-data-[focus=true]:bg-warning-50" ], value: "text-warning-600 dark:text-warning", label: "text-warning-600 dark:text-warning" } }, { variant: "flat", color: "danger", class: { trigger: [ "bg-danger-100", "text-danger", "dark:text-danger-500", "data-[hover=true]:bg-danger-50", "group-data-[focus=true]:bg-danger-50" ], value: "text-danger dark:text-danger-500", label: "text-danger dark:text-danger-500" } }, // faded & color { variant: "faded", color: "primary", class: { trigger: "data-[hover=true]:border-primary data-[focus=true]:border-primary data-[open=true]:border-primary", label: "text-primary" } }, { variant: "faded", color: "secondary", class: { trigger: "data-[hover=true]:border-secondary data-[focus=true]:border-secondary data-[open=true]:border-secondary", label: "text-secondary" } }, { variant: "faded", color: "success", class: { trigger: "data-[hover=true]:border-success data-[focus=true]:border-success data-[open=true]:border-success", label: "text-success" } }, { variant: "faded", color: "warning", class: { trigger: "data-[hover=true]:border-warning data-[focus=true]:border-warning data-[open=true]:border-warning", label: "text-warning" } }, { variant: "faded", color: "danger", class: { trigger: "data-[hover=true]:border-danger data-[focus=true]:border-danger data-[open=true]:border-danger", label: "text-danger" } }, // underlined & color // underlined & color { variant: "underlined", color: "default", class: { value: "group-data-[has-value=true]:text-foreground" } }, { variant: "underlined", color: "primary", class: { trigger: "after:bg-primary", label: "text-primary" } }, { variant: "underlined", color: "secondary", class: { trigger: "after:bg-secondary", label: "text-secondary" } }, { variant: "underlined", color: "success", class: { trigger: "after:bg-success", label: "text-success" } }, { variant: "underlined", color: "warning", class: { trigger: "after:bg-warning", label: "text-warning" } }, { variant: "underlined", color: "danger", class: { trigger: "after:bg-danger", label: "text-danger" } }, // bordered & color { variant: "bordered", color: "primary", class: { trigger: ["data-[open=true]:border-primary", "data-[focus=true]:border-primary"], label: "text-primary" } }, { variant: "bordered", color: "secondary", class: { trigger: ["data-[open=true]:border-secondary", "data-[focus=true]:border-secondary"], label: "text-secondary" } }, { variant: "bordered", color: "success", class: { trigger: ["data-[open=true]:border-success", "data-[focus=true]:border-success"], label: "text-success" } }, { variant: "bordered", color: "warning", class: { trigger: ["data-[open=true]:border-warning", "data-[focus=true]:border-warning"], label: "text-warning" } }, { variant: "bordered", color: "danger", class: { trigger: ["data-[open=true]:border-danger", "data-[focus=true]:border-danger"], label: "text-danger" } }, // labelPlacement=outside & default { labelPlacement: "inside", color: "default", class: { label: "group-data-[filled=true]:text-default-600" } }, // labelPlacement=outside & default { labelPlacement: "outside", color: "default", class: { label: "group-data-[filled=true]:text-foreground" } }, // radius-full & size { radius: "full", size: ["sm"], class: { trigger: "px-3" } }, { radius: "full", size: "md", class: { trigger: "px-4" } }, { radius: "full", size: "lg", class: { trigger: "px-5" } }, // !disableAnimation & variant { disableAnimation: false, variant: ["faded", "bordered"], class: { trigger: "transition-colors motion-reduce:transition-none" } }, { disableAnimation: false, variant: "underlined", class: { trigger: "after:transition-width motion-reduce:after:transition-none" } }, // flat & faded { variant: ["flat", "faded"], class: { trigger: [ // focus ring ...dataFocusVisibleClasses ] } }, // isInvalid & variant { isInvalid: true, variant: "flat", class: { trigger: [ "bg-danger-50", "data-[hover=true]:bg-danger-100", "group-data-[focus=true]:bg-danger-50" ] } }, { isInvalid: true, variant: "bordered", class: { trigger: "!border-danger group-data-[focus=true]:border-danger" } }, { isInvalid: true, variant: "underlined", class: { trigger: "after:bg-danger" } }, // size & labelPlacement { labelPlacement: "inside", size: "sm", class: { trigger: "h-12 min-h-12 py-1.5 px-3" } }, { labelPlacement: "inside", size: "md", class: { trigger: "h-14 min-h-14 py-2" } }, { labelPlacement: "inside", size: "lg", class: { label: "text-medium", trigger: "h-16 min-h-16 py-2.5 gap-0" } }, { labelPlacement: "outside", isMultiline: false, class: { base: "group relative justify-end", label: ["pb-0", "z-20", "top-1/2", "-translate-y-1/2", "group-data-[filled=true]:start-0"] } }, // labelPlacement=[inside] { labelPlacement: ["inside"], class: { label: "group-data-[filled=true]:scale-85" } }, // inside & size { labelPlacement: "inside", size: ["sm", "md"], class: { label: "text-small" } }, { labelPlacement: "inside", isMultiline: false, size: "sm", class: { label: [ "group-data-[filled=true]:-translate-y-[calc(50%_+_var(--heroui-font-size-tiny)/2_-_8px)]" ], innerWrapper: "group-data-[has-label=true]:pt-4" } }, { labelPlacement: "inside", isMultiline: false, size: "md", class: { label: [ "group-data-[filled=true]:-translate-y-[calc(50%_+_var(--heroui-font-size-small)/2_-_6px)]" ], innerWrapper: "group-data-[has-label=true]:pt-4" } }, { labelPlacement: "inside", isMultiline: false, size: "lg", class: { label: [ "text-medium", "group-data-[filled=true]:-translate-y-[calc(50%_+_var(--heroui-font-size-small)/2_-_8px)]" ], innerWrapper: "group-data-[has-label=true]:pt-5" } }, // inside & size & [faded, bordered] { labelPlacement: "inside", variant: ["faded", "bordered"], isMultiline: false, size: "sm", class: { label: [ "group-data-[filled=true]:-translate-y-[calc(50%_+_var(--heroui-font-size-tiny)/2_-_8px_-_var(--heroui-border-width-medium))]" ] } }, { labelPlacement: "inside", variant: ["faded", "bordered"], isMultiline: false, size: "md", class: { label: [ "group-data-[filled=true]:-translate-y-[calc(50%_+_var(--heroui-font-size-small)/2_-_6px_-_var(--heroui-border-width-medium))]" ] } }, { labelPlacement: "inside", variant: ["faded", "bordered"], isMultiline: false, size: "lg", class: { label: [ "text-medium", "group-data-[filled=true]:-translate-y-[calc(50%_+_var(--heroui-font-size-small)/2_-_8px_-_var(--heroui-border-width-medium))]" ] } }, // inside & size & underlined { labelPlacement: "inside", variant: "underlined", isMultiline: false, size: "sm", class: { label: [ "group-data-[filled=true]:-translate-y-[calc(50%_+_var(--heroui-font-size-tiny)/2_-_5px)]" ] } }, { labelPlacement: "inside", variant: "underlined", isMultiline: false, size: "md", class: { label: [ "group-data-[filled=true]:-translate-y-[calc(50%_+_var(--heroui-font-size-small)/2_-_3.5px)]" ] } }, { labelPlacement: "inside", variant: "underlined", isMultiline: false, size: "lg", class: { label: [ "text-medium", "group-data-[filled=true]:-translate-y-[calc(50%_+_var(--heroui-font-size-small)/2_-_4px)]" ] } }, // outside & size { labelPlacement: "outside", size: "sm", isMultiline: false, class: { label: [ "start-2", "text-tiny", "group-data-[filled=true]:-translate-y-[calc(100%_+var(--heroui-font-size-tiny)/2_+_16px)]", "group-data-[has-helper=true]:-translate-y-[calc(100%_+_var(--heroui-font-size-small)/2_+_26px)]" ], base: "data-[has-label=true]:mt-[calc(var(--heroui-font-size-small)_+_8px)]" } }, { labelPlacement: "outside", isMultiline: false, size: "md", class: { label: [ "start-3", "text-small", "group-data-[filled=true]:-translate-y-[calc(100%_+_var(--heroui-font-size-small)/2_+_20px)]", "group-data-[has-helper=true]:-translate-y-[calc(100%_+_var(--heroui-font-size-small)/2_+_30px)]" ], base: "data-[has-label=true]:mt-[calc(var(--heroui-font-size-small)_+_10px)]" } }, { labelPlacement: "outside", isMultiline: false, size: "lg", class: { label: [ "start-3", "text-medium", "group-data-[filled=true]:-translate-y-[calc(100%_+_var(--heroui-font-size-small)/2_+_24px)]", "group-data-[has-helper=true]:-translate-y-[calc(100%_+_var(--heroui-font-size-small)/2_+_34px)]" ], base: "data-[has-label=true]:mt-[calc(var(--heroui-font-size-small)_+_12px)]" } }, // outside-left & size { labelPlacement: "outside-left", size: "sm", class: { label: "group-data-[has-helper=true]:pt-2" } }, { labelPlacement: "outside-left", size: "md", class: { label: "group-data-[has-helper=true]:pt-3" } }, { labelPlacement: "outside-left", size: "lg", class: { label: "group-data-[has-helper=true]:pt-4" } }, // isMultiline & labelPlacement="outside" { labelPlacement: "outside", isMultiline: true, class: { label: "pb-1.5" } }, // text truncate labelPlacement=[inside,outside] { labelPlacement: ["inside", "outside"], class: { label: ["pe-2", "max-w-full", "text-ellipsis", "overflow-hidden"] } }, // isClearable & labelPlacement { labelPlacement: ["outside", "outside-left"], isClearable: true, class: { endContent: ["mt-4"], clearButton: ["group-data-[has-end-content=true]:mt-4"] } }, { isClearable: false, labelPlacement: ["outside", "outside-left"], class: { endContent: ["mt-4"] } }, // isClearable + variant { isClearable: true, variant: ["underlined"], class: { clearButton: ["relative group-data-[has-end-content=true]:left-2"], endContent: ["me-2"] } }, { isClearable: false, variant: ["underlined"], class: { endContent: ["me-2"] } }, // isClearable + size { isClearable: true, size: "sm", class: { endContent: "ms-2" } } ] }); // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { select });