UNPKG

@nextui-org/theme

Version:

The default theme for NextUI components

322 lines (314 loc) • 10.4 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/popover.ts var popover_exports = {}; __export(popover_exports, { popover: () => popover }); module.exports = __toCommonJS(popover_exports); // src/utils/tv.ts var import_tailwind_variants = require("tailwind-variants"); // src/utils/tw-merge-config.ts var COMMON_UNITS = ["small", "medium", "large"]; var twMergeConfig = { theme: { opacity: ["disabled"], spacing: ["divider"], borderWidth: COMMON_UNITS, borderRadius: COMMON_UNITS }, classGroups: { shadow: [{ shadow: COMMON_UNITS }], "font-size": [{ text: ["tiny", ...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" ] } }; // 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-none", "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/popover.ts var popover = tv({ slots: { base: [ "z-0", "relative", "bg-transparent", "before:content-['']", "before:hidden", "before:z-[-1]", "before:absolute", "before:rotate-45", "before:w-2.5", "before:h-2.5", "before:rounded-sm", "data-[arrow=true]:before:block", "data-[placement=top]:before:-bottom-[calc(theme(spacing.5)/4_-_1.5px)]", "data-[placement=top]:before:left-1/2", "data-[placement=top]:before:-translate-x-1/2", "data-[placement=top-start]:before:-bottom-[calc(theme(spacing.5)/4_-_1.5px)]", "data-[placement=top-start]:before:left-3", "data-[placement=top-end]:before:-bottom-[calc(theme(spacing.5)/4_-_1.5px)]", "data-[placement=top-end]:before:right-3", "data-[placement=bottom]:before:-top-[calc(theme(spacing.5)/4_-_1.5px)]", "data-[placement=bottom]:before:left-1/2", "data-[placement=bottom]:before:-translate-x-1/2", "data-[placement=bottom-start]:before:-top-[calc(theme(spacing.5)/4_-_1.5px)]", "data-[placement=bottom-start]:before:left-3", "data-[placement=bottom-end]:before:-top-[calc(theme(spacing.5)/4_-_1.5px)]", "data-[placement=bottom-end]:before:right-3", "data-[placement=left]:before:-right-[calc(theme(spacing.5)/4_-_2px)]", "data-[placement=left]:before:top-1/2", "data-[placement=left]:before:-translate-y-1/2", "data-[placement=left-start]:before:-right-[calc(theme(spacing.5)/4_-_3px)]", "data-[placement=left-start]:before:top-1/4", "data-[placement=left-end]:before:-right-[calc(theme(spacing.5)/4_-_3px)]", "data-[placement=left-end]:before:bottom-1/4", "data-[placement=right]:before:-left-[calc(theme(spacing.5)/4_-_2px)]", "data-[placement=right]:before:top-1/2", "data-[placement=right]:before:-translate-y-1/2", "data-[placement=right-start]:before:-left-[calc(theme(spacing.5)/4_-_3px)]", "data-[placement=right-start]:before:top-1/4", "data-[placement=right-end]:before:-left-[calc(theme(spacing.5)/4_-_3px)]", "data-[placement=right-end]:before:bottom-1/4", ...dataFocusVisibleClasses ], content: [ "z-10", "px-2.5", "py-1", "w-full", "inline-flex", "flex-col", "items-center", "justify-center", "box-border", "subpixel-antialiased", "outline-none", "box-border" ], trigger: ["z-10"], backdrop: ["hidden"], arrow: [] }, variants: { size: { sm: { content: "text-tiny" }, md: { content: "text-small" }, lg: { content: "text-medium" } }, color: { default: { base: "before:bg-content1 before:shadow-small", content: "bg-content1" }, foreground: { base: "before:bg-foreground", content: colorVariants.solid.foreground }, primary: { base: "before:bg-primary", content: colorVariants.solid.primary }, secondary: { base: "before:bg-secondary", content: colorVariants.solid.secondary }, success: { base: "before:bg-success", content: colorVariants.solid.success }, warning: { base: "before:bg-warning", content: colorVariants.solid.warning }, danger: { base: "before:bg-danger", content: colorVariants.solid.danger } }, radius: { none: { content: "rounded-none" }, sm: { content: "rounded-small" }, md: { content: "rounded-medium" }, lg: { content: "rounded-large" }, full: { content: "rounded-full" } }, shadow: { sm: { content: "shadow-small" }, md: { content: "shadow-medium" }, lg: { content: "shadow-large" } }, backdrop: { transparent: {}, opaque: { backdrop: "bg-overlay/50 backdrop-opacity-disabled" }, blur: { backdrop: "backdrop-blur-sm backdrop-saturate-150 bg-overlay/30" } }, triggerScaleOnOpen: { true: { trigger: ["aria-expanded:scale-[0.97]", "aria-expanded:opacity-70", "subpixel-antialiased"] }, false: {} }, disableAnimation: { true: { base: "animate-none" } }, isTriggerDisabled: { true: { trigger: "opacity-disabled pointer-events-none" }, false: {} } }, defaultVariants: { color: "default", radius: "lg", size: "md", shadow: "md", backdrop: "transparent", triggerScaleOnOpen: true }, compoundVariants: [ { backdrop: ["opaque", "blur"], class: { backdrop: "block w-full h-full fixed inset-0 -z-30" } } ] }); // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { popover });