UNPKG

@heroui/theme

Version:

The default theme for HeroUI components

429 lines (416 loc) 11.2 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/modal.ts var modal_exports = {}; __export(modal_exports, { modal: () => modal }); module.exports = __toCommonJS(modal_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/components/modal.ts var modal = tv({ slots: { wrapper: [ "flex", "w-screen", "h-[100dvh]", "fixed", "inset-0", "z-50", "overflow-x-auto", "justify-center", "h-[--visual-viewport-height]" ], base: [ "flex", "flex-col", "relative", "bg-white", "z-50", "w-full", "box-border", "bg-content1", "outline-solid outline-transparent", "mx-1", "my-1", "sm:mx-6", "sm:my-16" ], backdrop: "z-50", header: "flex py-4 px-6 flex-initial text-large font-semibold", body: "flex flex-1 flex-col gap-3 px-6 py-2", footer: "flex flex-row gap-2 px-6 py-4 justify-end", closeButton: [ "absolute", "appearance-none", "outline-solid outline-transparent", "select-none", "top-1", "end-1", "p-2", "text-foreground-500", "rounded-full", "hover:bg-default-100", "active:bg-default-200", "tap-highlight-transparent", // focus ring ...dataFocusVisibleClasses ] }, variants: { size: { xs: { base: "max-w-xs" }, sm: { base: "max-w-sm" }, md: { base: "max-w-md" }, lg: { base: "max-w-lg" }, xl: { base: "max-w-xl" }, "2xl": { base: "max-w-2xl" }, "3xl": { base: "max-w-3xl" }, "4xl": { base: "max-w-4xl" }, "5xl": { base: "max-w-5xl" }, full: { base: "my-0 mx-0 sm:mx-0 sm:my-0 max-w-full h-[100dvh] min-h-[100dvh] !rounded-none" } }, radius: { none: { base: "rounded-none" }, sm: { base: "rounded-small" }, md: { base: "rounded-medium" }, lg: { base: "rounded-large" } }, placement: { auto: { wrapper: "items-end sm:items-center" }, center: { wrapper: "items-center sm:items-center" }, top: { wrapper: "items-start sm:items-start" }, "top-center": { wrapper: "items-start sm:items-center" }, bottom: { wrapper: "items-end sm:items-end" }, "bottom-center": { wrapper: "items-end sm:items-center" } }, shadow: { none: { base: "shadow-none" }, sm: { base: "shadow-small" }, md: { base: "shadow-medium" }, lg: { base: "shadow-large" } }, backdrop: { transparent: { backdrop: "hidden" }, opaque: { backdrop: "bg-overlay/50 backdrop-opacity-disabled" }, blur: { backdrop: "backdrop-blur-md backdrop-saturate-150 bg-overlay/30" } }, scrollBehavior: { normal: { base: "overflow-y-hidden" }, inside: { base: "max-h-[calc(100%_-_8rem)]", body: "overflow-y-auto" }, outside: { wrapper: "items-start sm:items-start overflow-y-auto", base: "my-16" } }, disableAnimation: { false: { wrapper: [ // mobile animation vars "[--scale-enter:100%]", "[--scale-exit:100%]", "[--slide-enter:0px]", "[--slide-exit:80px]", // tablet/desktop animation vars "sm:[--scale-enter:100%]", "sm:[--scale-exit:103%]", "sm:[--slide-enter:0px]", "sm:[--slide-exit:0px]" ] } } }, defaultVariants: { size: "md", radius: "lg", shadow: "sm", placement: "auto", backdrop: "opaque", scrollBehavior: "normal" }, compoundVariants: [ // backdrop (opaque/blur) { backdrop: ["opaque", "blur"], class: { backdrop: "w-screen h-screen fixed inset-0" } } ] }); // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { modal });