@heroui/theme
Version:
The default theme for HeroUI components
695 lines (683 loc) • 20.6 kB
JavaScript
"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/date-input.ts
var date_input_exports = {};
__export(date_input_exports, {
dateInput: () => dateInput
});
module.exports = __toCommonJS(date_input_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/components/date-input.ts
var dateInput = tv({
slots: {
base: "group flex flex-col",
label: [
"block subpixel-antialiased text-small text-default-600",
// isRequired=true
"group-data-[required=true]:after:content-['*'] group-data-[required=true]:after:text-danger group-data-[required=true]:after:ml-0.5",
// isInValid=true
"group-data-[invalid=true]:text-danger"
],
inputWrapper: [
"relative px-3 gap-3 w-full inline-flex flex-row items-center",
"cursor-text tap-highlight-transparent shadow-xs"
],
input: "flex h-full gap-x-0.5 w-full font-normal",
innerWrapper: [
"flex items-center text-default-400 w-full gap-x-2 h-6",
// isInValid=true
"group-data-[invalid=true]:text-danger"
],
// this wraps the input and the start/end content
segment: [
"group first:-ml-0.5 [&:not(:first-child)]:-ml-1 px-0.5 my-auto box-content tabular-nums text-start",
"inline-block outline-solid outline-transparent focus:shadow-xs rounded-md",
"text-foreground-500 data-[editable=true]:text-foreground",
"data-[editable=true]:data-[placeholder=true]:text-foreground-500",
// isInvalid=true
"data-[invalid=true]:text-danger-300 data-[invalid=true]:data-[editable=true]:text-danger",
"data-[invalid=true]:focus:bg-danger-400/50 dark:data-[invalid=true]:focus:bg-danger-400/20",
"data-[invalid=true]:data-[editable=true]:focus:text-danger"
],
helperWrapper: "hidden group-data-[has-helper=true]:flex p-1 relative flex-col gap-1.5",
description: "text-tiny text-foreground-400",
errorMessage: "text-tiny text-danger"
},
variants: {
variant: {
flat: {
inputWrapper: [
"bg-default-100",
"hover:bg-default-200",
"focus-within:hover:bg-default-100",
// isInvalid=true
"group-data-[invalid=true]:bg-danger-50",
"group-data-[invalid=true]:hover:bg-danger-100",
"group-data-[invalid=true]:focus-within:hover:bg-danger-50"
]
},
faded: {
inputWrapper: [
"bg-default-100",
"border-medium",
"border-default-200",
"hover:border-default-400"
]
},
bordered: {
inputWrapper: [
"border-medium",
"border-default-200",
"hover:border-default-400",
"focus-within:border-default-foreground",
"focus-within:hover:border-default-foreground",
// isInvalid=true
"group-data-[invalid=true]:border-danger",
"group-data-[invalid=true]:hover:border-danger",
"group-data-[invalid=true]:focus-within:hover:border-danger"
]
},
underlined: {
inputWrapper: [
"px-1",
"pb-1",
"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]",
"focus-within:after:w-full",
// isInvalid=true
"group-data-[invalid=true]:after:bg-danger"
]
}
},
color: {
default: {
segment: "focus:bg-default-400/50 data-[editable=true]:focus:text-default-foreground"
},
primary: {
segment: "focus:bg-primary-400/50 data-[editable=true]:focus:text-primary"
},
secondary: {
segment: "focus:bg-secondary-400/50 data-[editable=true]:focus:text-secondary"
},
success: {
segment: "focus:bg-success-400/50 dark:focus:bg-success-400/20 data-[editable=true]:focus:text-success"
},
warning: {
segment: "focus:bg-warning-400/50 dark:focus:bg-warning-400/20 data-[editable=true]:focus:text-warning"
},
danger: {
segment: "focus:bg-danger-400/50 dark:focus:bg-danger-400/20 data-[editable=true]:focus:text-danger"
}
},
size: {
sm: {
label: "text-tiny",
input: "text-small",
inputWrapper: "h-8 min-h-8 px-2 rounded-small"
},
md: {
input: "text-small",
inputWrapper: "h-10 min-h-10 rounded-medium",
clearButton: "text-large"
},
lg: {
label: "text-medium",
input: "text-medium",
inputWrapper: "h-12 min-h-12 rounded-large"
}
},
radius: {
none: {
inputWrapper: "rounded-none"
},
sm: {
inputWrapper: "rounded-small"
},
md: {
inputWrapper: "rounded-medium"
},
lg: {
inputWrapper: "rounded-large"
},
full: {
inputWrapper: "rounded-full"
}
},
labelPlacement: {
outside: {
base: "flex flex-col data-[has-helper=true]:pb-[calc(var(--heroui-font-size-tiny)_+8px)] gap-y-1.5",
label: "w-full text-foreground",
helperWrapper: "absolute top-[calc(100%_+_2px)] start-0"
},
"outside-left": {
base: "flex-row items-center data-[has-helper=true]:pb-[calc(var(--heroui-font-size-tiny)_+_8px)] gap-x-2 flex-nowrap",
label: "relative text-foreground",
inputWrapper: "relative flex-1",
helperWrapper: "absolute top-[calc(100%_+_2px)] start-0"
},
inside: {
label: "w-full text-tiny cursor-text",
inputWrapper: "flex-col items-start justify-center gap-0"
}
},
fullWidth: {
true: {
base: "w-full",
inputWrapper: "w-full"
}
},
isDisabled: {
true: {
base: "opacity-disabled pointer-events-none",
inputWrapper: "pointer-events-none",
label: "pointer-events-none"
}
},
disableAnimation: {
true: {
label: "transition-none",
input: "transition-none",
inputWrapper: "transition-none"
},
false: {
label: [
"!ease-out",
"!duration-200",
"will-change-auto",
"motion-reduce:transition-none",
"transition-[color,opacity]"
],
inputWrapper: "transition-background motion-reduce:transition-none !duration-150",
segment: "transition-colors motion-reduce:transition-none"
}
}
},
defaultVariants: {
variant: "flat",
color: "default",
size: "md",
fullWidth: true,
isDisabled: false
},
compoundVariants: [
// flat & color
{
variant: "flat",
color: "primary",
class: {
innerWrapper: "text-primary",
inputWrapper: ["bg-primary-100", "hover:bg-primary-50", "focus-within:bg-primary-50"],
segment: "text-primary-300 data-[editable=true]:data-[placeholder=true]:text-primary-300 data-[editable=true]:text-primary",
label: "text-primary"
}
},
{
variant: "flat",
color: "secondary",
class: {
innerWrapper: "text-secondary",
inputWrapper: ["bg-secondary-100", "hover:bg-secondary-50", "focus-within:bg-secondary-50"],
segment: "text-secondary-300 data-[editable=true]:data-[placeholder=true]:text-secondary-300 data-[editable=true]:text-secondary",
label: "text-secondary"
}
},
{
variant: "flat",
color: "success",
class: {
innerWrapper: "text-success-600 dark:text-success",
inputWrapper: ["bg-success-100", "hover:bg-success-50", "focus-within:bg-success-50"],
segment: "text-success-400 data-[editable=true]:data-[placeholder=true]:text-success-400 data-[editable=true]:text-success-600 data-[editable=true]:focus:text-success-600",
label: "text-success-600 dark:text-success"
}
},
{
variant: "flat",
color: "warning",
class: {
innerWrapper: "text-warning-600 dark:text-warning",
inputWrapper: ["bg-warning-100", "hover:bg-warning-50", "focus-within:bg-warning-50"],
segment: "text-warning-400 data-[editable=true]:data-[placeholder=true]:text-warning-400 data-[editable=true]:text-warning-600 data-[editable=true]:focus:text-warning-600",
label: "text-warning-600 dark:text-warning"
}
},
{
variant: "flat",
color: "danger",
class: {
innerWrapper: "text-danger",
inputWrapper: ["bg-danger-100", "hover:bg-danger-50", "focus-within:bg-danger-50"],
segment: "text-danger-300 data-[editable=true]:data-[placeholder=true]:text-danger-300 data-[editable=true]:text-danger",
label: "text-danger"
}
},
// faded & color
{
variant: "faded",
color: "primary",
class: {
innerWrapper: "text-primary",
inputWrapper: [
"hover:border-primary",
"focus-within:border-primary",
"focus-within:hover:border-primary"
],
label: "text-primary"
}
},
{
variant: "faded",
color: "secondary",
class: {
innerWrapper: "text-secondary",
inputWrapper: [
"hover:border-secondary",
"focus-within:border-secondary",
"focus-within:hover:border-secondary"
],
label: "text-secondary"
}
},
{
variant: "faded",
color: "success",
class: {
innerWrapper: "text-success",
inputWrapper: [
"hover:border-success",
"focus-within:border-success",
"focus-within:hover:border-success"
],
label: "text-success"
}
},
{
variant: "faded",
color: "warning",
class: {
innerWrapper: "text-warning",
inputWrapper: [
"hover:border-warning",
"focus-within:border-warning",
"focus-within:hover:border-warning"
],
label: "text-warning"
}
},
{
variant: "faded",
color: "danger",
class: {
innerWrapper: "text-danger",
inputWrapper: [
"hover:border-danger",
"focus-within:border-danger",
"focus-within:hover:border-danger"
],
label: "text-danger"
}
},
// bordered & color
{
variant: "bordered",
color: "primary",
class: {
innerWrapper: "text-primary",
inputWrapper: ["focus-within:border-primary", "focus-within:hover:border-primary"],
label: "text-primary"
}
},
{
variant: "bordered",
color: "secondary",
class: {
innerWrapper: "text-secondary",
inputWrapper: ["focus-within:border-secondary", "focus-within:hover:border-secondary"],
label: "text-secondary"
}
},
{
variant: "bordered",
color: "success",
class: {
innerWrapper: "text-success",
inputWrapper: ["focus-within:border-success", "focus-within:hover:border-success"],
label: "text-success"
}
},
{
variant: "bordered",
color: "warning",
class: {
innerWrapper: "text-warning",
inputWrapper: ["focus-within:border-warning", "focus-within:hover:border-warning"],
label: "text-warning"
}
},
{
variant: "bordered",
color: "danger",
class: {
innerWrapper: "text-danger",
inputWrapper: ["focus-within:border-danger", "focus-within:hover:border-danger"],
label: "text-danger"
}
},
// underlined & color
{
variant: "underlined",
color: "primary",
class: {
innerWrapper: "text-primary",
inputWrapper: "after:bg-primary",
label: "text-primary"
}
},
{
variant: "underlined",
color: "secondary",
class: {
innerWrapper: "text-secondary",
inputWrapper: "after:bg-secondary",
label: "text-secondary"
}
},
{
variant: "underlined",
color: "success",
class: {
innerWrapper: "text-success",
inputWrapper: "after:bg-success",
label: "text-success"
}
},
{
variant: "underlined",
color: "warning",
class: {
innerWrapper: "text-warning",
inputWrapper: "after:bg-warning",
label: "text-warning"
}
},
{
variant: "underlined",
color: "danger",
class: {
innerWrapper: "text-danger",
inputWrapper: "after:bg-danger",
label: "text-danger"
}
},
// size & labelPlacement
{
labelPlacement: "inside",
size: "sm",
class: {
inputWrapper: "h-12 py-1.5 px-3"
}
},
{
labelPlacement: "inside",
size: "md",
class: {
inputWrapper: "h-14 py-2"
}
},
{
labelPlacement: "inside",
size: "lg",
class: {
label: "text-medium",
inputWrapper: "h-16 py-2.5 gap-0"
}
},
// !disableAnimation & variant
{
disableAnimation: false,
variant: ["faded", "bordered"],
class: {
inputWrapper: "transition-colors motion-reduce:transition-none"
}
},
{
disableAnimation: false,
variant: "underlined",
class: {
inputWrapper: "after:transition-width motion-reduce:after:transition-none"
}
}
]
});
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
dateInput
});