UNPKG

@nextui-org/theme

Version:

The default theme for NextUI components

258 lines (251 loc) • 7.15 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/radio.ts var radio_exports = {}; __export(radio_exports, { radio: () => radio, radioGroup: () => radioGroup }); module.exports = __toCommonJS(radio_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 groupDataFocusVisibleClasses = [ "outline-none", "group-data-[focus-visible=true]:z-10", "group-data-[focus-visible=true]:ring-2", "group-data-[focus-visible=true]:ring-focus", "group-data-[focus-visible=true]:ring-offset-2", "group-data-[focus-visible=true]:ring-offset-background" ]; var hiddenInputClasses = [ "[--cursor-hit-x:8px]", "font-inherit", "text-[100%]", "leading-[1.15]", "m-0", "p-0", "overflow-visible", "box-border", "absolute", "top-0", "start-[calc(var(--cursor-hit-x)*-1)]", "w-[calc(100%+var(--cursor-hit-x)*2)]", "h-full", "opacity-[0.0001]", "z-[1]", "cursor-pointer", "disabled:cursor-default" ]; // src/components/radio.ts var radio = tv({ slots: { base: "group relative max-w-fit inline-flex items-center justify-start cursor-pointer tap-highlight-transparent p-2 -m-2 select-none", wrapper: [ "relative", "inline-flex", "items-center", "justify-center", "flex-shrink-0", "overflow-hidden", "border-solid", "border-medium", "box-border", "border-default", "rounded-full", "group-data-[hover-unselected=true]:bg-default-100", ...groupDataFocusVisibleClasses ], hiddenInput: hiddenInputClasses, labelWrapper: "flex flex-col ml-1", control: [ "z-10", "w-2", "h-2", "opacity-0", "scale-0", "origin-center", "rounded-full", "group-data-[selected=true]:opacity-100", "group-data-[selected=true]:scale-100" ], label: "relative text-foreground select-none", description: "relative text-foreground-400" }, variants: { color: { default: { control: "bg-default-500 text-default-foreground", wrapper: "group-data-[selected=true]:border-default-500" }, primary: { control: "bg-primary text-primary-foreground", wrapper: "group-data-[selected=true]:border-primary" }, secondary: { control: "bg-secondary text-secondary-foreground", wrapper: "group-data-[selected=true]:border-secondary" }, success: { control: "bg-success text-success-foreground", wrapper: "group-data-[selected=true]:border-success" }, warning: { control: "bg-warning text-warning-foreground", wrapper: "group-data-[selected=true]:border-warning" }, danger: { control: "bg-danger text-danger-foreground", wrapper: "group-data-[selected=true]:border-danger" } }, size: { sm: { wrapper: "w-4 h-4", control: "w-1.5 h-1.5", labelWrapper: "ml-1", label: "text-small", description: "text-tiny" }, md: { wrapper: "w-5 h-5", control: "w-2 h-2", labelWrapper: "ms-2", label: "text-medium", description: "text-small" }, lg: { wrapper: "w-6 h-6", control: "w-2.5 h-2.5", labelWrapper: "ms-2", label: "text-large", description: "text-medium" } }, isDisabled: { true: { base: "opacity-disabled pointer-events-none" } }, isInvalid: { true: { control: "bg-danger text-danger-foreground", wrapper: "border-danger group-data-[selected=true]:border-danger", label: "text-danger", description: "text-danger-300" } }, disableAnimation: { true: {}, false: { wrapper: [ "group-data-[pressed=true]:scale-95", "transition-transform-colors", "motion-reduce:transition-none" ], control: "transition-transform-opacity motion-reduce:transition-none", label: "transition-colors motion-reduce:transition-none", description: "transition-colors motion-reduce:transition-none" } } }, defaultVariants: { color: "primary", size: "md", isDisabled: false, isInvalid: false } }); var radioGroup = tv({ slots: { base: "relative flex flex-col gap-2", label: "relative text-foreground-500", wrapper: "flex flex-col flex-wrap gap-2 data-[orientation=horizontal]:flex-row", description: "text-tiny text-foreground-400", errorMessage: "text-tiny text-danger" }, variants: { isRequired: { true: { label: "after:content-['*'] after:text-danger after:ml-0.5" } }, isInvalid: { true: { description: "text-danger" } }, disableAnimation: { true: {}, false: { description: "transition-colors !duration-150 motion-reduce:transition-none" } } }, defaultVariants: { isInvalid: false, isRequired: false } }); // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { radio, radioGroup });