UNPKG

@heroui/theme

Version:

The default theme for HeroUI components

716 lines (702 loc) 19.8 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/tabs.ts var tabs_exports = {}; __export(tabs_exports, { tabs: () => tabs }); module.exports = __toCommonJS(tabs_exports); // src/utils/tv.ts var import_tailwind_variants = require("tailwind-variants"); // 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 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/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/utils/variants.ts var solid = { default: "bg-default text-default-foreground", primary: "bg-primary text-primary-foreground", secondary: "bg-secondary text-secondary-foreground", success: "bg-success text-success-foreground", warning: "bg-warning text-warning-foreground", danger: "bg-danger text-danger-foreground", foreground: "bg-foreground text-background" }; var shadow = { default: "shadow-lg shadow-default/50 bg-default text-default-foreground", primary: "shadow-lg shadow-primary/40 bg-primary text-primary-foreground", secondary: "shadow-lg shadow-secondary/40 bg-secondary text-secondary-foreground", success: "shadow-lg shadow-success/40 bg-success text-success-foreground", warning: "shadow-lg shadow-warning/40 bg-warning text-warning-foreground", danger: "shadow-lg shadow-danger/40 bg-danger text-danger-foreground", foreground: "shadow-lg shadow-foreground/40 bg-foreground text-background" }; var bordered = { default: "bg-transparent border-default text-foreground", primary: "bg-transparent border-primary text-primary", secondary: "bg-transparent border-secondary text-secondary", success: "bg-transparent border-success text-success", warning: "bg-transparent border-warning text-warning", danger: "bg-transparent border-danger text-danger", foreground: "bg-transparent border-foreground text-foreground" }; var flat = { default: "bg-default/40 text-default-700", primary: "bg-primary/20 text-primary-600", secondary: "bg-secondary/20 text-secondary-600", success: "bg-success/20 text-success-700 dark:text-success", warning: "bg-warning/20 text-warning-700 dark:text-warning", danger: "bg-danger/20 text-danger-600 dark:text-danger-500", foreground: "bg-foreground/10 text-foreground" }; var faded = { default: "border-default bg-default-100 text-default-foreground", primary: "border-default bg-default-100 text-primary", secondary: "border-default bg-default-100 text-secondary", success: "border-default bg-default-100 text-success", warning: "border-default bg-default-100 text-warning", danger: "border-default bg-default-100 text-danger", foreground: "border-default bg-default-100 text-foreground" }; var light = { default: "bg-transparent text-default-foreground", primary: "bg-transparent text-primary", secondary: "bg-transparent text-secondary", success: "bg-transparent text-success", warning: "bg-transparent text-warning", danger: "bg-transparent text-danger", foreground: "bg-transparent text-foreground" }; var ghost = { default: "border-default text-default-foreground", primary: "border-primary text-primary", secondary: "border-secondary text-secondary", success: "border-success text-success", warning: "border-warning text-warning", danger: "border-danger text-danger", foreground: "border-foreground text-foreground hover:!bg-foreground" }; var colorVariants = { solid, shadow, bordered, flat, faded, light, ghost }; // src/components/tabs.ts var tabs = tv({ slots: { base: "inline-flex", tabList: [ "flex", "p-1", "h-fit", "gap-2", "items-center", "flex-nowrap", "overflow-x-scroll", "scrollbar-hide", "bg-default-100" ], tab: [ "z-0", "w-full", "px-3", "py-1", "flex", "group", "relative", "justify-center", "items-center", "outline-solid outline-transparent", "cursor-pointer", "transition-opacity", "tap-highlight-transparent", "data-[disabled=true]:cursor-not-allowed", "data-[disabled=true]:opacity-30", "data-[hover-unselected=true]:opacity-disabled", // focus ring ...dataFocusVisibleClasses ], tabContent: [ "relative", "z-10", "text-inherit", "whitespace-nowrap", "transition-colors", "text-default-500", "group-data-[selected=true]:text-foreground" ], cursor: ["absolute", "z-0", "bg-white"], panel: [ "py-3", "px-1", "outline-solid outline-transparent", "data-[inert=true]:hidden", // focus ring ...dataFocusVisibleClasses ], tabWrapper: [] }, variants: { variant: { solid: { cursor: "inset-0" }, light: { tabList: "bg-transparent dark:bg-transparent", cursor: "inset-0" }, underlined: { tabList: "bg-transparent dark:bg-transparent", cursor: "h-[2px] w-[80%] bottom-0 shadow-[0_1px_0px_0_rgba(0,0,0,0.05)]" }, bordered: { tabList: "bg-transparent dark:bg-transparent border-medium border-default-200 shadow-xs", cursor: "inset-0" } }, color: { default: {}, primary: {}, secondary: {}, success: {}, warning: {}, danger: {} }, size: { sm: { tabList: "rounded-medium", tab: "h-7 text-tiny rounded-small", cursor: "rounded-small" }, md: { tabList: "rounded-medium", tab: "h-8 text-small rounded-small", cursor: "rounded-small" }, lg: { tabList: "rounded-large", tab: "h-9 text-medium rounded-medium", cursor: "rounded-medium" } }, radius: { none: { tabList: "rounded-none", tab: "rounded-none", cursor: "rounded-none" }, sm: { tabList: "rounded-medium", tab: "rounded-small", cursor: "rounded-small" }, md: { tabList: "rounded-medium", tab: "rounded-small", cursor: "rounded-small" }, lg: { tabList: "rounded-large", tab: "rounded-medium", cursor: "rounded-medium" }, full: { tabList: "rounded-full", tab: "rounded-full", cursor: "rounded-full" } }, fullWidth: { true: { base: "w-full", tabList: "w-full" } }, isDisabled: { true: { tabList: "opacity-disabled pointer-events-none" } }, disableAnimation: { true: { tab: "transition-none", tabContent: "transition-none" } }, placement: { top: {}, start: { tabList: "flex-col", panel: "py-0 px-3", tabWrapper: "flex" }, end: { tabList: "flex-col", panel: "py-0 px-3", tabWrapper: "flex flex-row-reverse" }, bottom: { tabWrapper: "flex flex-col-reverse" } } }, defaultVariants: { color: "default", variant: "solid", size: "md", fullWidth: false, isDisabled: false }, compoundVariants: [ /** * Variants & Colors */ // solid + bordered + light && color { variant: ["solid", "bordered", "light"], color: "default", class: { cursor: ["bg-background", "dark:bg-default", "shadow-small"], tabContent: "group-data-[selected=true]:text-default-foreground" } }, { variant: ["solid", "bordered", "light"], color: "primary", class: { cursor: colorVariants.solid.primary, tabContent: "group-data-[selected=true]:text-primary-foreground" } }, { variant: ["solid", "bordered", "light"], color: "secondary", class: { cursor: colorVariants.solid.secondary, tabContent: "group-data-[selected=true]:text-secondary-foreground" } }, { variant: ["solid", "bordered", "light"], color: "success", class: { cursor: colorVariants.solid.success, tabContent: "group-data-[selected=true]:text-success-foreground" } }, { variant: ["solid", "bordered", "light"], color: "warning", class: { cursor: colorVariants.solid.warning, tabContent: "group-data-[selected=true]:text-warning-foreground" } }, { variant: ["solid", "bordered", "light"], color: "danger", class: { cursor: colorVariants.solid.danger, tabContent: "group-data-[selected=true]:text-danger-foreground" } }, // underlined && color { variant: "underlined", color: "default", class: { cursor: "bg-foreground", tabContent: "group-data-[selected=true]:text-foreground" } }, { variant: "underlined", color: "primary", class: { cursor: "bg-primary", tabContent: "group-data-[selected=true]:text-primary" } }, { variant: "underlined", color: "secondary", class: { cursor: "bg-secondary", tabContent: "group-data-[selected=true]:text-secondary" } }, { variant: "underlined", color: "success", class: { cursor: "bg-success", tabContent: "group-data-[selected=true]:text-success" } }, { variant: "underlined", color: "warning", class: { cursor: "bg-warning", tabContent: "group-data-[selected=true]:text-warning" } }, { variant: "underlined", color: "danger", class: { cursor: "bg-danger", tabContent: "group-data-[selected=true]:text-danger" } }, /** * Disable animation & Variants & Colors */ // disabledAnimation && underlined { disableAnimation: true, variant: "underlined", class: { tab: [ "after:content-['']", "after:absolute", "after:bottom-0", "after:h-[2px]", "after:w-[80%]", "after:opacity-0", "after:shadow-[0_1px_0px_0_rgba(0,0,0,0.05)]", "data-[selected=true]:after:opacity-100" ] } }, // disableAnimation && color && solid/bordered { disableAnimation: true, color: "default", variant: ["solid", "bordered", "light"], class: { tab: "data-[selected=true]:bg-default data-[selected=true]:text-default-foreground" } }, { disableAnimation: true, color: "primary", variant: ["solid", "bordered", "light"], class: { tab: "data-[selected=true]:bg-primary data-[selected=true]:text-primary-foreground" } }, { disableAnimation: true, color: "secondary", variant: ["solid", "bordered", "light"], class: { tab: "data-[selected=true]:bg-secondary data-[selected=true]:text-secondary-foreground" } }, { disableAnimation: true, color: "success", variant: ["solid", "bordered", "light"], class: { tab: "data-[selected=true]:bg-success data-[selected=true]:text-success-foreground" } }, { disableAnimation: true, color: "warning", variant: ["solid", "bordered", "light"], class: { tab: "data-[selected=true]:bg-warning data-[selected=true]:text-warning-foreground" } }, { disableAnimation: true, color: "danger", variant: ["solid", "bordered", "light"], class: { tab: "data-[selected=true]:bg-danger data-[selected=true]:text-danger-foreground" } }, // disableAnimation && color && underlined { disableAnimation: true, color: "default", variant: "underlined", class: { tab: "data-[selected=true]:after:bg-foreground" } }, { disableAnimation: true, color: "primary", variant: "underlined", class: { tab: "data-[selected=true]:after:bg-primary" } }, { disableAnimation: true, color: "secondary", variant: "underlined", class: { tab: "data-[selected=true]:after:bg-secondary" } }, { disableAnimation: true, color: "success", variant: "underlined", class: { tab: "data-[selected=true]:after:bg-success" } }, { disableAnimation: true, color: "warning", variant: "underlined", class: { tab: "data-[selected=true]:after:bg-warning" } }, { disableAnimation: true, color: "danger", variant: "underlined", class: { tab: "data-[selected=true]:after:bg-danger" } } ], compoundSlots: [ { variant: "underlined", slots: ["tab", "tabList", "cursor"], class: ["rounded-none"] } ] }); // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { tabs });