tailwind-to-style 5.0.0 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +411 -2
- package/dist/animations/index.cjs +288 -167
- package/dist/animations/index.esm.js +288 -167
- package/dist/animations/index.esm.js.map +1 -1
- package/dist/className/index.cjs +288 -167
- package/dist/className/index.esm.js +288 -167
- package/dist/className/index.esm.js.map +1 -1
- package/dist/core/tws.cjs +1 -1
- package/dist/core/tws.esm.js +1 -1
- package/dist/cx.cjs +1 -1
- package/dist/cx.esm.js +1 -1
- package/dist/index.cjs +288 -167
- package/dist/index.d.ts +8 -15
- package/dist/index.esm.js +288 -167
- package/dist/index.esm.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/react/index.cjs +288 -167
- package/dist/react/index.esm.js +288 -167
- package/dist/react/index.esm.js.map +1 -1
- package/dist/register/index.cjs +8313 -0
- package/dist/register/index.d.ts +229 -0
- package/dist/register/index.esm.js +8307 -0
- package/dist/register/index.esm.js.map +1 -0
- package/dist/runtime/index.cjs +429 -0
- package/dist/runtime/index.d.ts +15 -0
- package/dist/runtime/index.esm.js +425 -0
- package/dist/runtime/index.esm.js.map +1 -0
- package/dist/tokens/index.cjs +1 -1
- package/dist/tokens/index.esm.js +1 -1
- package/dist/v4.d.ts +347 -0
- package/package.json +6 -1
- package/types/index.d.ts +8 -15
- package/types/register.d.ts +229 -0
- package/types/v4.d.ts +159 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* tailwind-to-style v5.
|
|
2
|
+
* tailwind-to-style v5.1.0
|
|
3
3
|
* Zero-build runtime Tailwind CSS engine
|
|
4
4
|
*
|
|
5
5
|
* @author Bigetion
|
|
@@ -7848,7 +7848,7 @@ function twsx(obj) {
|
|
|
7848
7848
|
// Import directly from './className/index.js' if needed
|
|
7849
7849
|
// export { twsxClassName, tw } from "./className/index.js";
|
|
7850
7850
|
|
|
7851
|
-
const _excluded = ["name", "prefix", "hash", "hashLength", "inject"
|
|
7851
|
+
const _excluded = ["name", "prefix", "hash", "hashLength", "inject"],
|
|
7852
7852
|
_excluded2 = ["class", "className"],
|
|
7853
7853
|
_excluded3 = ["class", "className"];
|
|
7854
7854
|
|
|
@@ -8347,14 +8347,115 @@ function processTokens(classString) {
|
|
|
8347
8347
|
// Style Processing Utilities
|
|
8348
8348
|
// ============================================================================
|
|
8349
8349
|
|
|
8350
|
-
|
|
8351
|
-
|
|
8352
|
-
|
|
8350
|
+
/**
|
|
8351
|
+
* Known CSS property names (camelCase and kebab-case).
|
|
8352
|
+
* Used to differentiate raw CSS properties from Tailwind shorthand keys.
|
|
8353
|
+
* Covers the full set of standard CSS properties.
|
|
8354
|
+
*/
|
|
8355
|
+
const CSS_PROPERTIES = new Set([
|
|
8356
|
+
// Box model
|
|
8357
|
+
"width", "height", "minWidth", "minHeight", "maxWidth", "maxHeight", "min-width", "min-height", "max-width", "max-height", "margin", "marginTop", "marginRight", "marginBottom", "marginLeft", "margin-top", "margin-right", "margin-bottom", "margin-left", "padding", "paddingTop", "paddingRight", "paddingBottom", "paddingLeft", "padding-top", "padding-right", "padding-bottom", "padding-left", "boxSizing", "box-sizing",
|
|
8358
|
+
// Display & layout
|
|
8359
|
+
"display", "overflow", "overflowX", "overflowY", "overflow-x", "overflow-y", "visibility", "opacity", "position", "top", "right", "bottom", "left", "zIndex", "z-index", "float", "clear",
|
|
8360
|
+
// Flexbox
|
|
8361
|
+
"flex", "flexGrow", "flexShrink", "flexBasis", "flexFlow", "flexDirection", "flexWrap", "flex-grow", "flex-shrink", "flex-basis", "flex-flow", "flex-direction", "flex-wrap", "alignItems", "alignContent", "alignSelf", "justifyContent", "justifyItems", "justifySelf", "align-items", "align-content", "align-self", "justify-content", "justify-items", "justify-self", "gap", "rowGap", "columnGap", "row-gap", "column-gap", "order", "placeItems", "placeContent", "placeSelf", "place-items", "place-content", "place-self",
|
|
8362
|
+
// Grid
|
|
8363
|
+
"grid", "gridTemplate", "gridTemplateColumns", "gridTemplateRows", "gridTemplateAreas", "gridColumn", "gridRow", "gridArea", "gridAutoFlow", "gridAutoColumns", "gridAutoRows", "grid-template", "grid-template-columns", "grid-template-rows", "grid-template-areas", "grid-column", "grid-row", "grid-area", "grid-auto-flow", "grid-auto-columns", "grid-auto-rows",
|
|
8364
|
+
// Typography
|
|
8365
|
+
"color", "fontSize", "fontWeight", "fontFamily", "fontStyle", "fontVariant", "fontStretch", "font-size", "font-weight", "font-family", "font-style", "font-variant", "font-stretch", "lineHeight", "letterSpacing", "wordSpacing", "textAlign", "textDecoration", "textTransform", "line-height", "letter-spacing", "word-spacing", "text-align", "text-decoration", "text-transform", "textOverflow", "whiteSpace", "wordBreak", "overflowWrap", "hyphens", "textIndent", "text-overflow", "white-space", "word-break", "overflow-wrap", "text-indent", "verticalAlign", "vertical-align", "fontFeatureSettings", "font-feature-settings",
|
|
8366
|
+
// Backgrounds
|
|
8367
|
+
"background", "backgroundColor", "backgroundImage", "backgroundSize", "backgroundPosition", "backgroundRepeat", "backgroundAttachment", "backgroundOrigin", "backgroundClip", "background-color", "background-image", "background-size", "background-position", "background-repeat", "background-attachment", "background-origin", "background-clip",
|
|
8368
|
+
// Borders
|
|
8369
|
+
"border", "borderTop", "borderRight", "borderBottom", "borderLeft", "border-top", "border-right", "border-bottom", "border-left", "borderWidth", "borderStyle", "borderColor", "borderRadius", "border-width", "border-style", "border-color", "border-radius", "borderTopWidth", "borderTopStyle", "borderTopColor", "borderTopLeftRadius", "borderTopRightRadius", "borderBottomWidth", "borderBottomStyle", "borderBottomColor", "borderBottomLeftRadius", "borderBottomRightRadius", "borderLeftWidth", "borderLeftStyle", "borderLeftColor", "borderRightWidth", "borderRightStyle", "borderRightColor", "outline", "outlineWidth", "outlineStyle", "outlineColor", "outlineOffset", "outline-width", "outline-style", "outline-color", "outline-offset",
|
|
8370
|
+
// Transforms & transitions
|
|
8371
|
+
"transform", "transformOrigin", "transformStyle", "perspective", "perspectiveOrigin", "transform-origin", "transform-style", "perspective-origin", "transition", "transitionProperty", "transitionDuration", "transitionTimingFunction", "transitionDelay", "transition-property", "transition-duration", "transition-timing-function", "transition-delay", "animation", "animationName", "animationDuration", "animationTimingFunction", "animationDelay", "animationIterationCount", "animationDirection", "animationFillMode", "animationPlayState", "animation-name", "animation-duration", "animation-timing-function", "animation-delay", "animation-iteration-count", "animation-direction", "animation-fill-mode", "animation-play-state",
|
|
8372
|
+
// Effects
|
|
8373
|
+
"boxShadow", "textShadow", "filter", "backdropFilter", "opacity", "box-shadow", "text-shadow", "backdrop-filter", "mix-blend-mode", "mixBlendMode", "isolation", "objectFit", "objectPosition", "object-fit", "object-position",
|
|
8374
|
+
// Lists & tables
|
|
8375
|
+
"listStyle", "listStyleType", "listStylePosition", "listStyleImage", "list-style", "list-style-type", "list-style-position", "list-style-image", "tableLayout", "borderCollapse", "borderSpacing", "captionSide", "emptyCells", "table-layout", "border-collapse", "border-spacing", "caption-side", "empty-cells",
|
|
8376
|
+
// SVG
|
|
8377
|
+
"fill", "stroke", "strokeWidth", "strokeDasharray", "strokeDashoffset", "strokeLinecap", "strokeLinejoin", "stroke-width", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin",
|
|
8378
|
+
// Misc
|
|
8379
|
+
"content", "cursor", "pointerEvents", "userSelect", "resize", "appearance", "caretColor", "pointer-events", "user-select", "caret-color", "willChange", "will-change", "scrollBehavior", "scroll-behavior", "clipPath", "clip-path", "mask", "maskImage", "mask-image", "columns", "columnCount", "columnGap", "columnRule", "columnWidth", "columnSpan", "column-count", "column-rule", "column-width", "column-span", "pageBreakBefore", "pageBreakAfter", "pageBreakInside", "breakBefore", "breakAfter", "breakInside", "page-break-before", "page-break-after", "page-break-inside", "break-before", "break-after", "break-inside",
|
|
8380
|
+
// CSS variables & custom
|
|
8381
|
+
"all", "direction", "unicodeBidi", "unicode-bidi", "writingMode", "writing-mode", "overscrollBehavior", "overscroll-behavior", "touchAction", "touch-action", "scrollSnapType", "scrollSnapAlign", "scroll-snap-type", "scroll-snap-align"]);
|
|
8382
|
+
|
|
8383
|
+
/**
|
|
8384
|
+
* Detect if a key is a raw CSS property (camelCase or kebab-case).
|
|
8385
|
+
* Also accepts CSS custom properties (--var-name) and any key containing a hyphen
|
|
8386
|
+
* that doesn't match known Tailwind-ish patterns.
|
|
8387
|
+
*
|
|
8388
|
+
* @param {string} key
|
|
8389
|
+
* @returns {boolean}
|
|
8390
|
+
*/
|
|
8391
|
+
function isCssProperty(key) {
|
|
8392
|
+
// Explicit set match (fast path)
|
|
8393
|
+
if (CSS_PROPERTIES.has(key)) return true;
|
|
8394
|
+
// CSS custom properties
|
|
8395
|
+
if (key.startsWith("--")) return true;
|
|
8396
|
+
// kebab-case that isn't a Tailwind modifier pattern (no colons)
|
|
8397
|
+
if (key.includes("-") && !key.includes(":") && !key.startsWith("@")) {
|
|
8398
|
+
// Exclude known Tailwind-ish hyphenated shorthands already in PSEUDO_SHORTHANDS or BREAKPOINTS
|
|
8399
|
+
if (PSEUDO_SHORTHANDS[key] || GROUP_PEER_STATES[key] || BREAKPOINTS[key]) return false;
|
|
8400
|
+
return true;
|
|
8401
|
+
}
|
|
8402
|
+
return false;
|
|
8403
|
+
}
|
|
8404
|
+
|
|
8405
|
+
/**
|
|
8406
|
+
* Convert a camelCase or kebab-case key to a kebab-case CSS property.
|
|
8407
|
+
* @param {string} key
|
|
8408
|
+
* @returns {string}
|
|
8409
|
+
*/
|
|
8410
|
+
function toCssPropertyName(key) {
|
|
8411
|
+
// Already kebab-case
|
|
8412
|
+
if (key.includes("-")) return key;
|
|
8413
|
+
// camelCase → kebab-case
|
|
8414
|
+
return key.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
8415
|
+
}
|
|
8416
|
+
|
|
8417
|
+
/**
|
|
8418
|
+
* Extract all raw CSS property key/value pairs from a config object.
|
|
8419
|
+
* Returns an object suitable for the @css directive (kebab-case keys, string values).
|
|
8420
|
+
*
|
|
8421
|
+
* @param {Object} config
|
|
8422
|
+
* @returns {Object|null} - null if nothing found
|
|
8423
|
+
*/
|
|
8424
|
+
function extractRawCssProps(config) {
|
|
8425
|
+
let result = null;
|
|
8353
8426
|
for (const _ref3 of Object.entries(config)) {
|
|
8354
8427
|
var _ref4 = _slicedToArray(_ref3, 2);
|
|
8355
8428
|
const key = _ref4[0];
|
|
8356
8429
|
const value = _ref4[1];
|
|
8430
|
+
if (!isCssProperty(key)) continue;
|
|
8431
|
+
if (typeof value !== "string" && typeof value !== "number") continue;
|
|
8432
|
+
if (!result) result = {};
|
|
8433
|
+
result[toCssPropertyName(key)] = String(value);
|
|
8434
|
+
}
|
|
8435
|
+
return result;
|
|
8436
|
+
}
|
|
8437
|
+
function expandShorthands(config, baseSelector) {
|
|
8438
|
+
const expanded = {};
|
|
8439
|
+
const specialKeys = new Set(["name", "prefix", "hash", "hashLength", "inject", "base", "variants", "compoundVariants", "defaultVariants", "slots", "responsiveVariants", "extend", "animation", "enter", "exit", "enterFrom", "enterTo", "leaveFrom", "leaveTo", "_", "tw"]);
|
|
8440
|
+
|
|
8441
|
+
// Collect raw CSS properties into the @css directive for this selector
|
|
8442
|
+
const rawCss = extractRawCssProps(config);
|
|
8443
|
+
if (rawCss) {
|
|
8444
|
+
// twsx supports { [selector]: { "@css": { prop: value } } }
|
|
8445
|
+
// We expand that here so it lands in the style object correctly
|
|
8446
|
+
if (!expanded[baseSelector]) expanded[baseSelector] = {};
|
|
8447
|
+
// expanded[baseSelector] may already be a string (Tailwind classes) — keep both
|
|
8448
|
+
// by using a special marker object that the caller (generateBasicClassName) will merge
|
|
8449
|
+
expanded["__rawCss__"] = expanded["__rawCss__"] || {};
|
|
8450
|
+
Object.assign(expanded["__rawCss__"], rawCss);
|
|
8451
|
+
}
|
|
8452
|
+
for (const _ref5 of Object.entries(config)) {
|
|
8453
|
+
var _ref6 = _slicedToArray(_ref5, 2);
|
|
8454
|
+
const key = _ref6[0];
|
|
8455
|
+
const value = _ref6[1];
|
|
8357
8456
|
if (specialKeys.has(key)) continue;
|
|
8457
|
+
// Skip raw CSS properties — already handled above
|
|
8458
|
+
if (isCssProperty(key) && (typeof value === "string" || typeof value === "number")) continue;
|
|
8358
8459
|
|
|
8359
8460
|
// Process tokens in value
|
|
8360
8461
|
const processedValue = typeof value === "string" ? processTokens(value) : value;
|
|
@@ -8406,22 +8507,40 @@ function expandShorthands(config, baseSelector) {
|
|
|
8406
8507
|
}
|
|
8407
8508
|
function processNestedStyles(config, baseSelector) {
|
|
8408
8509
|
const result = {};
|
|
8409
|
-
for (const
|
|
8410
|
-
var
|
|
8411
|
-
const key =
|
|
8412
|
-
const value =
|
|
8510
|
+
for (const _ref7 of Object.entries(config)) {
|
|
8511
|
+
var _ref8 = _slicedToArray(_ref7, 2);
|
|
8512
|
+
const key = _ref8[0];
|
|
8513
|
+
const value = _ref8[1];
|
|
8413
8514
|
if (typeof value === "object" && !Array.isArray(value)) {
|
|
8414
8515
|
const nestedSelector = key.replace(/^&/, baseSelector);
|
|
8415
8516
|
const nested = processNestedStyles(value, nestedSelector);
|
|
8416
8517
|
Object.assign(result, nested);
|
|
8417
|
-
|
|
8418
|
-
|
|
8518
|
+
|
|
8519
|
+
// Support both `_` and `tw` as the Tailwind class key inside nested objects
|
|
8520
|
+
const nestedTwClasses = [value._, value.tw].filter(Boolean).join(" ");
|
|
8521
|
+
if (nestedTwClasses) {
|
|
8522
|
+
result[nestedSelector] = processTokens(nestedTwClasses);
|
|
8419
8523
|
const nestedShorthands = expandShorthands(value, nestedSelector);
|
|
8524
|
+
// Wire raw CSS from nested object
|
|
8525
|
+
if (nestedShorthands.__rawCss__) {
|
|
8526
|
+
const existingNested = result[nestedSelector] || "";
|
|
8527
|
+
if (typeof existingNested === "string") {
|
|
8528
|
+
result[nestedSelector] = [existingNested, {
|
|
8529
|
+
"@css": nestedShorthands.__rawCss__
|
|
8530
|
+
}];
|
|
8531
|
+
}
|
|
8532
|
+
delete nestedShorthands.__rawCss__;
|
|
8533
|
+
}
|
|
8420
8534
|
Object.assign(result, nestedShorthands);
|
|
8421
8535
|
}
|
|
8422
8536
|
} else if (typeof value === "string") {
|
|
8423
|
-
if (key === "_") {
|
|
8424
|
-
|
|
8537
|
+
if (key === "_" || key === "tw") {
|
|
8538
|
+
// Both _ and tw are Tailwind class shorthands for the current selector
|
|
8539
|
+
if (result[baseSelector]) {
|
|
8540
|
+
result[baseSelector] = result[baseSelector] + " " + processTokens(value);
|
|
8541
|
+
} else {
|
|
8542
|
+
result[baseSelector] = processTokens(value);
|
|
8543
|
+
}
|
|
8425
8544
|
} else {
|
|
8426
8545
|
const selector = PSEUDO_SHORTHANDS[key] ? PSEUDO_SHORTHANDS[key].replace("&", baseSelector) : GROUP_PEER_STATES[key] ? GROUP_PEER_STATES[key].replace("&", baseSelector) : key.replace(/^&/, baseSelector);
|
|
8427
8546
|
result[selector] = processTokens(value);
|
|
@@ -8486,10 +8605,10 @@ function processAnimations(config, baseSelector, className) {
|
|
|
8486
8605
|
}
|
|
8487
8606
|
function generateKeyframes(name, frames) {
|
|
8488
8607
|
let css = "@keyframes ".concat(name, " {\n");
|
|
8489
|
-
for (const
|
|
8490
|
-
var
|
|
8491
|
-
const key =
|
|
8492
|
-
const value =
|
|
8608
|
+
for (const _ref9 of Object.entries(frames)) {
|
|
8609
|
+
var _ref0 = _slicedToArray(_ref9, 2);
|
|
8610
|
+
const key = _ref0[0];
|
|
8611
|
+
const value = _ref0[1];
|
|
8493
8612
|
// Convert Tailwind classes to approximate CSS (simplified)
|
|
8494
8613
|
const cssValue = value.replace(/([a-z]+)-([a-z0-9-]+)/g, (match, prop, val) => {
|
|
8495
8614
|
// This is a simplified conversion - real implementation would use twsx
|
|
@@ -8538,8 +8657,6 @@ function generateBasicClassName(config) {
|
|
|
8538
8657
|
hashLength = _config$hashLength === void 0 ? globalConfig.hashLength : _config$hashLength,
|
|
8539
8658
|
_config$inject = config.inject,
|
|
8540
8659
|
inject = _config$inject === void 0 ? globalConfig.inject : _config$inject,
|
|
8541
|
-
_config$_ = config._,
|
|
8542
|
-
baseStyles = _config$_ === void 0 ? "" : _config$_,
|
|
8543
8660
|
rest = _objectWithoutProperties(config, _excluded);
|
|
8544
8661
|
const configHash = getConfigHash(config);
|
|
8545
8662
|
let className;
|
|
@@ -8557,22 +8674,11 @@ function generateBasicClassName(config) {
|
|
|
8557
8674
|
return cached;
|
|
8558
8675
|
}
|
|
8559
8676
|
const baseSelector = ".".concat(className);
|
|
8560
|
-
const styleObj = {};
|
|
8561
8677
|
|
|
8562
|
-
//
|
|
8563
|
-
|
|
8564
|
-
styleObj[baseSelector] = processTokens(baseStyles);
|
|
8565
|
-
}
|
|
8678
|
+
// buildStyleObj handles `_`, `tw`, raw CSS props, pseudo shorthands, nested — all in one place
|
|
8679
|
+
const styleObj = buildStyleObj(rest, baseSelector);
|
|
8566
8680
|
|
|
8567
|
-
// Process
|
|
8568
|
-
const expanded = expandShorthands(rest, baseSelector);
|
|
8569
|
-
Object.assign(styleObj, expanded);
|
|
8570
|
-
|
|
8571
|
-
// Process nested objects
|
|
8572
|
-
const nested = processNestedStyles(rest, baseSelector);
|
|
8573
|
-
Object.assign(styleObj, nested);
|
|
8574
|
-
|
|
8575
|
-
// Process animations
|
|
8681
|
+
// Process animations (has its own dedicated fields)
|
|
8576
8682
|
const _processAnimations = processAnimations(rest, baseSelector, className),
|
|
8577
8683
|
animStyles = _processAnimations.styles,
|
|
8578
8684
|
keyframes = _processAnimations.keyframes;
|
|
@@ -8597,6 +8703,60 @@ function generateBasicClassName(config) {
|
|
|
8597
8703
|
return className;
|
|
8598
8704
|
}
|
|
8599
8705
|
|
|
8706
|
+
// ============================================================================
|
|
8707
|
+
// Shared: Build a twsx-compatible style object from a style config object
|
|
8708
|
+
// Handles `_`, `tw` (Tailwind classes), raw CSS properties, pseudo shorthands,
|
|
8709
|
+
// breakpoints, and nested selectors — centralised so variants & slots reuse it.
|
|
8710
|
+
// ============================================================================
|
|
8711
|
+
|
|
8712
|
+
/**
|
|
8713
|
+
* Build a styleObj ready for twsx() from a style config value.
|
|
8714
|
+
*
|
|
8715
|
+
* @param {string|Object} styleValue - A Tailwind class string OR a mixed config object
|
|
8716
|
+
* @param {string} selector - The CSS selector to target (e.g. ".btn--color-primary")
|
|
8717
|
+
* @returns {Object} - styleObj for twsx()
|
|
8718
|
+
*/
|
|
8719
|
+
function buildStyleObj(styleValue, selector) {
|
|
8720
|
+
const styleObj = {};
|
|
8721
|
+
if (typeof styleValue === "string") {
|
|
8722
|
+
// Plain Tailwind class string
|
|
8723
|
+
styleObj[selector] = processTokens(styleValue);
|
|
8724
|
+
return styleObj;
|
|
8725
|
+
}
|
|
8726
|
+
if (typeof styleValue !== "object" || styleValue === null) return styleObj;
|
|
8727
|
+
|
|
8728
|
+
// Merge `_` and `tw` as Tailwind classes for this selector
|
|
8729
|
+
const twClasses = [styleValue._, styleValue.tw].filter(Boolean).join(" ");
|
|
8730
|
+
|
|
8731
|
+
// Extract raw CSS properties
|
|
8732
|
+
const rawCss = extractRawCssProps(styleValue);
|
|
8733
|
+
if (twClasses && rawCss) {
|
|
8734
|
+
// Both Tailwind classes AND raw CSS — use array form: [twClasses, { "@css": {...} }]
|
|
8735
|
+
styleObj[selector] = [processTokens(twClasses), {
|
|
8736
|
+
"@css": rawCss
|
|
8737
|
+
}];
|
|
8738
|
+
} else if (twClasses) {
|
|
8739
|
+
styleObj[selector] = processTokens(twClasses);
|
|
8740
|
+
} else if (rawCss) {
|
|
8741
|
+
styleObj[selector] = [{
|
|
8742
|
+
"@css": rawCss
|
|
8743
|
+
}];
|
|
8744
|
+
}
|
|
8745
|
+
|
|
8746
|
+
// Expand pseudo shorthands, breakpoints, nested selectors
|
|
8747
|
+
const expanded = expandShorthands(styleValue, selector);
|
|
8748
|
+
if (expanded.__rawCss__) {
|
|
8749
|
+
// top-level rawCss already handled above; drop the marker
|
|
8750
|
+
delete expanded.__rawCss__;
|
|
8751
|
+
}
|
|
8752
|
+
Object.assign(styleObj, expanded);
|
|
8753
|
+
|
|
8754
|
+
// Process nested style objects
|
|
8755
|
+
const nested = processNestedStyles(styleValue, selector);
|
|
8756
|
+
Object.assign(styleObj, nested);
|
|
8757
|
+
return styleObj;
|
|
8758
|
+
}
|
|
8759
|
+
|
|
8600
8760
|
// ============================================================================
|
|
8601
8761
|
// Core: Variants Mode
|
|
8602
8762
|
// ============================================================================
|
|
@@ -8636,18 +8796,7 @@ function createVariants(config) {
|
|
|
8636
8796
|
// Generate base styles
|
|
8637
8797
|
if (base) {
|
|
8638
8798
|
const baseSelector = ".".concat(baseClassName);
|
|
8639
|
-
|
|
8640
|
-
if (typeof base === "string") {
|
|
8641
|
-
styleObj[baseSelector] = processTokens(base);
|
|
8642
|
-
} else if (typeof base === "object") {
|
|
8643
|
-
if (base._) {
|
|
8644
|
-
styleObj[baseSelector] = processTokens(base._);
|
|
8645
|
-
}
|
|
8646
|
-
const expanded = expandShorthands(base, baseSelector);
|
|
8647
|
-
Object.assign(styleObj, expanded);
|
|
8648
|
-
const nested = processNestedStyles(base, baseSelector);
|
|
8649
|
-
Object.assign(styleObj, nested);
|
|
8650
|
-
}
|
|
8799
|
+
const styleObj = buildStyleObj(base, baseSelector);
|
|
8651
8800
|
const baseCss = twsx(styleObj, {
|
|
8652
8801
|
inject: false
|
|
8653
8802
|
});
|
|
@@ -8655,28 +8804,17 @@ function createVariants(config) {
|
|
|
8655
8804
|
}
|
|
8656
8805
|
|
|
8657
8806
|
// Generate styles for each variant value
|
|
8658
|
-
for (const
|
|
8659
|
-
var
|
|
8660
|
-
const variantKey =
|
|
8661
|
-
const variantOptions =
|
|
8662
|
-
for (const
|
|
8663
|
-
var
|
|
8664
|
-
const optionKey =
|
|
8665
|
-
const optionValue =
|
|
8807
|
+
for (const _ref1 of Object.entries(variants)) {
|
|
8808
|
+
var _ref10 = _slicedToArray(_ref1, 2);
|
|
8809
|
+
const variantKey = _ref10[0];
|
|
8810
|
+
const variantOptions = _ref10[1];
|
|
8811
|
+
for (const _ref11 of Object.entries(variantOptions)) {
|
|
8812
|
+
var _ref12 = _slicedToArray(_ref11, 2);
|
|
8813
|
+
const optionKey = _ref12[0];
|
|
8814
|
+
const optionValue = _ref12[1];
|
|
8666
8815
|
const variantClassName = "".concat(baseClassName, "--").concat(variantKey, "-").concat(optionKey);
|
|
8667
8816
|
const selector = ".".concat(variantClassName);
|
|
8668
|
-
|
|
8669
|
-
if (typeof optionValue === "string") {
|
|
8670
|
-
styleObj[selector] = processTokens(optionValue);
|
|
8671
|
-
} else if (typeof optionValue === "object") {
|
|
8672
|
-
if (optionValue._) {
|
|
8673
|
-
styleObj[selector] = processTokens(optionValue._);
|
|
8674
|
-
}
|
|
8675
|
-
const expanded = expandShorthands(optionValue, selector);
|
|
8676
|
-
Object.assign(styleObj, expanded);
|
|
8677
|
-
const nested = processNestedStyles(optionValue, selector);
|
|
8678
|
-
Object.assign(styleObj, nested);
|
|
8679
|
-
}
|
|
8817
|
+
const styleObj = buildStyleObj(optionValue, selector);
|
|
8680
8818
|
const css = twsx(styleObj, {
|
|
8681
8819
|
inject: false
|
|
8682
8820
|
});
|
|
@@ -8687,10 +8825,10 @@ function createVariants(config) {
|
|
|
8687
8825
|
|
|
8688
8826
|
// Generate responsive variant styles if enabled
|
|
8689
8827
|
if (responsiveVariants.includes(variantKey)) {
|
|
8690
|
-
for (const
|
|
8691
|
-
var
|
|
8692
|
-
const bp =
|
|
8693
|
-
const bpValue =
|
|
8828
|
+
for (const _ref13 of Object.entries(BREAKPOINTS)) {
|
|
8829
|
+
var _ref14 = _slicedToArray(_ref13, 2);
|
|
8830
|
+
const bp = _ref14[0];
|
|
8831
|
+
const bpValue = _ref14[1];
|
|
8694
8832
|
const respClassName = "".concat(baseClassName, "--").concat(bp, "-").concat(variantKey, "-").concat(optionKey);
|
|
8695
8833
|
const respSelector = ".".concat(respClassName);
|
|
8696
8834
|
const respStyleObj = {
|
|
@@ -8736,10 +8874,10 @@ function createVariants(config) {
|
|
|
8736
8874
|
// Inject all CSS upfront
|
|
8737
8875
|
if (inject) {
|
|
8738
8876
|
let allCss = "";
|
|
8739
|
-
for (const
|
|
8740
|
-
var
|
|
8741
|
-
const key =
|
|
8742
|
-
const value =
|
|
8877
|
+
for (const _ref15 of variantStyles.entries()) {
|
|
8878
|
+
var _ref16 = _slicedToArray(_ref15, 2);
|
|
8879
|
+
const key = _ref16[0];
|
|
8880
|
+
const value = _ref16[1];
|
|
8743
8881
|
if (key === "__base__") {
|
|
8744
8882
|
allCss += value + "\n";
|
|
8745
8883
|
} else if (typeof value === "object" && value.css) {
|
|
@@ -8760,10 +8898,10 @@ function createVariants(config) {
|
|
|
8760
8898
|
const classes = [baseClassName];
|
|
8761
8899
|
|
|
8762
8900
|
// Add variant classes
|
|
8763
|
-
for (const
|
|
8764
|
-
var
|
|
8765
|
-
const variantKey =
|
|
8766
|
-
const variantValue =
|
|
8901
|
+
for (const _ref17 of Object.entries(mergedProps)) {
|
|
8902
|
+
var _ref18 = _slicedToArray(_ref17, 2);
|
|
8903
|
+
const variantKey = _ref18[0];
|
|
8904
|
+
const variantValue = _ref18[1];
|
|
8767
8905
|
if (variantValue === undefined || variantValue === null) continue;
|
|
8768
8906
|
|
|
8769
8907
|
// Handle boolean variants
|
|
@@ -8771,10 +8909,10 @@ function createVariants(config) {
|
|
|
8771
8909
|
|
|
8772
8910
|
// Handle responsive variants: { size: { initial: 'sm', md: 'lg' } }
|
|
8773
8911
|
if (typeof variantValue === "object" && !Array.isArray(variantValue)) {
|
|
8774
|
-
for (const
|
|
8775
|
-
var
|
|
8776
|
-
const bp =
|
|
8777
|
-
const bpVariantValue =
|
|
8912
|
+
for (const _ref19 of Object.entries(variantValue)) {
|
|
8913
|
+
var _ref20 = _slicedToArray(_ref19, 2);
|
|
8914
|
+
const bp = _ref20[0];
|
|
8915
|
+
const bpVariantValue = _ref20[1];
|
|
8778
8916
|
if (bp === "initial") {
|
|
8779
8917
|
const variantData = variantStyles.get("".concat(variantKey, ":").concat(bpVariantValue));
|
|
8780
8918
|
if (variantData) classes.push(variantData.className);
|
|
@@ -8792,18 +8930,18 @@ function createVariants(config) {
|
|
|
8792
8930
|
}
|
|
8793
8931
|
|
|
8794
8932
|
// Check compound variants
|
|
8795
|
-
for (const
|
|
8796
|
-
var
|
|
8797
|
-
const key =
|
|
8798
|
-
const data =
|
|
8933
|
+
for (const _ref21 of variantStyles.entries()) {
|
|
8934
|
+
var _ref22 = _slicedToArray(_ref21, 2);
|
|
8935
|
+
const key = _ref22[0];
|
|
8936
|
+
const data = _ref22[1];
|
|
8799
8937
|
if (!key.startsWith("__compound__:")) continue;
|
|
8800
8938
|
const conditions = data.conditions,
|
|
8801
8939
|
className = data.className;
|
|
8802
8940
|
let matches = true;
|
|
8803
|
-
for (const
|
|
8804
|
-
var
|
|
8805
|
-
const condKey =
|
|
8806
|
-
const condValue =
|
|
8941
|
+
for (const _ref23 of Object.entries(conditions)) {
|
|
8942
|
+
var _ref24 = _slicedToArray(_ref23, 2);
|
|
8943
|
+
const condKey = _ref24[0];
|
|
8944
|
+
const condValue = _ref24[1];
|
|
8807
8945
|
const propValue = mergedProps[condKey];
|
|
8808
8946
|
const normalizedPropValue = propValue === true ? "true" : propValue === false ? "false" : propValue;
|
|
8809
8947
|
if (Array.isArray(condValue)) {
|
|
@@ -8878,24 +9016,13 @@ function createSlots(config) {
|
|
|
8878
9016
|
let allCss = "";
|
|
8879
9017
|
|
|
8880
9018
|
// Generate base slot styles
|
|
8881
|
-
for (const
|
|
8882
|
-
var
|
|
8883
|
-
const slotName =
|
|
8884
|
-
const slotStyles =
|
|
9019
|
+
for (const _ref25 of Object.entries(slots)) {
|
|
9020
|
+
var _ref26 = _slicedToArray(_ref25, 2);
|
|
9021
|
+
const slotName = _ref26[0];
|
|
9022
|
+
const slotStyles = _ref26[1];
|
|
8885
9023
|
const slotClassName = "".concat(componentName, "__").concat(slotName);
|
|
8886
9024
|
const selector = ".".concat(slotClassName);
|
|
8887
|
-
|
|
8888
|
-
if (typeof slotStyles === "string") {
|
|
8889
|
-
styleObj[selector] = processTokens(slotStyles);
|
|
8890
|
-
} else if (typeof slotStyles === "object") {
|
|
8891
|
-
if (slotStyles._) {
|
|
8892
|
-
styleObj[selector] = processTokens(slotStyles._);
|
|
8893
|
-
}
|
|
8894
|
-
const expanded = expandShorthands(slotStyles, selector);
|
|
8895
|
-
Object.assign(styleObj, expanded);
|
|
8896
|
-
const nested = processNestedStyles(slotStyles, selector);
|
|
8897
|
-
Object.assign(styleObj, nested);
|
|
8898
|
-
}
|
|
9025
|
+
const styleObj = buildStyleObj(slotStyles, selector);
|
|
8899
9026
|
const css = twsx(styleObj, {
|
|
8900
9027
|
inject: false
|
|
8901
9028
|
});
|
|
@@ -8908,32 +9035,26 @@ function createSlots(config) {
|
|
|
8908
9035
|
|
|
8909
9036
|
// Generate variant styles for each slot
|
|
8910
9037
|
const variantSlotStyles = new Map();
|
|
8911
|
-
for (const
|
|
8912
|
-
var
|
|
8913
|
-
const variantKey =
|
|
8914
|
-
const variantOptions =
|
|
8915
|
-
for (const
|
|
8916
|
-
var
|
|
8917
|
-
const optionKey =
|
|
8918
|
-
const optionValue =
|
|
8919
|
-
|
|
8920
|
-
|
|
8921
|
-
|
|
8922
|
-
|
|
8923
|
-
|
|
9038
|
+
for (const _ref27 of Object.entries(variants)) {
|
|
9039
|
+
var _ref28 = _slicedToArray(_ref27, 2);
|
|
9040
|
+
const variantKey = _ref28[0];
|
|
9041
|
+
const variantOptions = _ref28[1];
|
|
9042
|
+
for (const _ref29 of Object.entries(variantOptions)) {
|
|
9043
|
+
var _ref30 = _slicedToArray(_ref29, 2);
|
|
9044
|
+
const optionKey = _ref30[0];
|
|
9045
|
+
const optionValue = _ref30[1];
|
|
9046
|
+
// optionValue may be a slot-keyed object: { root: '...', header: '...' }
|
|
9047
|
+
// Detect: it's an object, and its keys match slot names (not `_` / `tw` / raw CSS)
|
|
9048
|
+
const isSlotMap = typeof optionValue === "object" && optionValue !== null && !optionValue._ && !optionValue.tw && !extractRawCssProps(optionValue) && Object.keys(optionValue).some(k => slots[k]);
|
|
9049
|
+
if (isSlotMap) {
|
|
9050
|
+
for (const _ref31 of Object.entries(optionValue)) {
|
|
9051
|
+
var _ref32 = _slicedToArray(_ref31, 2);
|
|
9052
|
+
const slotName = _ref32[0];
|
|
9053
|
+
const slotStyles = _ref32[1];
|
|
8924
9054
|
if (typeof slotStyles === "string" || typeof slotStyles === "object") {
|
|
8925
9055
|
const variantClassName = "".concat(componentName, "__").concat(slotName, "--").concat(variantKey, "-").concat(optionKey);
|
|
8926
9056
|
const selector = ".".concat(variantClassName);
|
|
8927
|
-
|
|
8928
|
-
if (typeof slotStyles === "string") {
|
|
8929
|
-
styleObj[selector] = processTokens(slotStyles);
|
|
8930
|
-
} else {
|
|
8931
|
-
if (slotStyles._) {
|
|
8932
|
-
styleObj[selector] = processTokens(slotStyles._);
|
|
8933
|
-
}
|
|
8934
|
-
const expanded = expandShorthands(slotStyles, selector);
|
|
8935
|
-
Object.assign(styleObj, expanded);
|
|
8936
|
-
}
|
|
9057
|
+
const styleObj = buildStyleObj(slotStyles, selector);
|
|
8937
9058
|
const css = twsx(styleObj, {
|
|
8938
9059
|
inject: false
|
|
8939
9060
|
});
|
|
@@ -8957,22 +9078,22 @@ function createSlots(config) {
|
|
|
8957
9078
|
const rest = _objectWithoutProperties(compound, _excluded3);
|
|
8958
9079
|
|
|
8959
9080
|
// Check if compound has slot-specific styles
|
|
8960
|
-
for (const
|
|
8961
|
-
var
|
|
8962
|
-
const slotName =
|
|
8963
|
-
|
|
9081
|
+
for (const _ref33 of slotData.entries()) {
|
|
9082
|
+
var _ref34 = _slicedToArray(_ref33, 1);
|
|
9083
|
+
const slotName = _ref34[0];
|
|
9084
|
+
const slotValue = rest[slotName];
|
|
9085
|
+
if (slotValue && (typeof slotValue === "string" || typeof slotValue === "object")) {
|
|
8964
9086
|
const compoundClassName = "".concat(componentName, "__").concat(slotName, "--compound-").concat(i);
|
|
8965
9087
|
const selector = ".".concat(compoundClassName);
|
|
8966
|
-
const
|
|
8967
|
-
|
|
8968
|
-
}, {
|
|
9088
|
+
const styleObj = buildStyleObj(slotValue, selector);
|
|
9089
|
+
const css = twsx(styleObj, {
|
|
8969
9090
|
inject: false
|
|
8970
9091
|
});
|
|
8971
9092
|
const conditions = {};
|
|
8972
|
-
for (const
|
|
8973
|
-
var
|
|
8974
|
-
const k =
|
|
8975
|
-
const v =
|
|
9093
|
+
for (const _ref35 of Object.entries(rest)) {
|
|
9094
|
+
var _ref36 = _slicedToArray(_ref35, 2);
|
|
9095
|
+
const k = _ref36[0];
|
|
9096
|
+
const v = _ref36[1];
|
|
8976
9097
|
if (!slots[k]) conditions[k] = v;
|
|
8977
9098
|
}
|
|
8978
9099
|
variantSlotStyles.set("__compound__:".concat(i, ":").concat(slotName), {
|
|
@@ -8997,17 +9118,17 @@ function createSlots(config) {
|
|
|
8997
9118
|
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
8998
9119
|
const mergedProps = _objectSpread2(_objectSpread2({}, defaultVariants), props);
|
|
8999
9120
|
const result = {};
|
|
9000
|
-
for (const
|
|
9001
|
-
var
|
|
9002
|
-
const slotName =
|
|
9003
|
-
const data =
|
|
9121
|
+
for (const _ref37 of slotData.entries()) {
|
|
9122
|
+
var _ref38 = _slicedToArray(_ref37, 2);
|
|
9123
|
+
const slotName = _ref38[0];
|
|
9124
|
+
const data = _ref38[1];
|
|
9004
9125
|
const classes = [data.className];
|
|
9005
9126
|
|
|
9006
9127
|
// Add variant classes for this slot
|
|
9007
|
-
for (const
|
|
9008
|
-
var
|
|
9009
|
-
const variantKey =
|
|
9010
|
-
const variantValue =
|
|
9128
|
+
for (const _ref39 of Object.entries(mergedProps)) {
|
|
9129
|
+
var _ref40 = _slicedToArray(_ref39, 2);
|
|
9130
|
+
const variantKey = _ref40[0];
|
|
9131
|
+
const variantValue = _ref40[1];
|
|
9011
9132
|
if (variantValue === undefined || variantValue === null) continue;
|
|
9012
9133
|
const normalizedValue = variantValue === true ? "true" : variantValue === false ? "false" : variantValue;
|
|
9013
9134
|
const key = "".concat(variantKey, ":").concat(normalizedValue, ":").concat(slotName);
|
|
@@ -9018,18 +9139,18 @@ function createSlots(config) {
|
|
|
9018
9139
|
}
|
|
9019
9140
|
|
|
9020
9141
|
// Check compound variants for this slot
|
|
9021
|
-
for (const
|
|
9022
|
-
var
|
|
9023
|
-
const key =
|
|
9024
|
-
const data =
|
|
9142
|
+
for (const _ref41 of variantSlotStyles.entries()) {
|
|
9143
|
+
var _ref42 = _slicedToArray(_ref41, 2);
|
|
9144
|
+
const key = _ref42[0];
|
|
9145
|
+
const data = _ref42[1];
|
|
9025
9146
|
if (!key.startsWith("__compound__:") || !key.endsWith(":".concat(slotName))) continue;
|
|
9026
9147
|
const conditions = data.conditions,
|
|
9027
9148
|
className = data.className;
|
|
9028
9149
|
let matches = true;
|
|
9029
|
-
for (const
|
|
9030
|
-
var
|
|
9031
|
-
const condKey =
|
|
9032
|
-
const condValue =
|
|
9150
|
+
for (const _ref43 of Object.entries(conditions)) {
|
|
9151
|
+
var _ref44 = _slicedToArray(_ref43, 2);
|
|
9152
|
+
const condKey = _ref44[0];
|
|
9153
|
+
const condValue = _ref44[1];
|
|
9033
9154
|
const propValue = mergedProps[condKey];
|
|
9034
9155
|
const normalizedPropValue = propValue === true ? "true" : propValue === false ? "false" : propValue;
|
|
9035
9156
|
const normalizedCondValue = condValue === true ? "true" : condValue === false ? "false" : condValue;
|
|
@@ -9057,10 +9178,10 @@ function createSlots(config) {
|
|
|
9057
9178
|
let slotOverrides = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
9058
9179
|
const baseSlots = typeof props === "object" && !Array.isArray(props) && !("$$typeof" in props) ? slotsGenerator(props) : slotsGenerator();
|
|
9059
9180
|
const result = {};
|
|
9060
|
-
for (const
|
|
9061
|
-
var
|
|
9062
|
-
const slotName =
|
|
9063
|
-
const slotClasses =
|
|
9181
|
+
for (const _ref45 of Object.entries(baseSlots)) {
|
|
9182
|
+
var _ref46 = _slicedToArray(_ref45, 2);
|
|
9183
|
+
const slotName = _ref46[0];
|
|
9184
|
+
const slotClasses = _ref46[1];
|
|
9064
9185
|
result[slotName] = cx(slotClasses, slotOverrides[slotName]);
|
|
9065
9186
|
}
|
|
9066
9187
|
return result;
|
|
@@ -9230,17 +9351,17 @@ twsxClassName.setTheme = function (name) {
|
|
|
9230
9351
|
// Apply theme tokens to CSS variables
|
|
9231
9352
|
if (IS_BROWSER) {
|
|
9232
9353
|
const root = document.documentElement;
|
|
9233
|
-
for (const
|
|
9234
|
-
var
|
|
9235
|
-
const key =
|
|
9236
|
-
const value =
|
|
9354
|
+
for (const _ref47 of Object.entries(themes[name])) {
|
|
9355
|
+
var _ref48 = _slicedToArray(_ref47, 2);
|
|
9356
|
+
const key = _ref48[0];
|
|
9357
|
+
const value = _ref48[1];
|
|
9237
9358
|
if (typeof value === "string") {
|
|
9238
9359
|
root.style.setProperty("--".concat(key), value);
|
|
9239
9360
|
} else if (typeof value === "object") {
|
|
9240
|
-
for (const
|
|
9241
|
-
var
|
|
9242
|
-
const subKey =
|
|
9243
|
-
const subValue =
|
|
9361
|
+
for (const _ref49 of Object.entries(value)) {
|
|
9362
|
+
var _ref50 = _slicedToArray(_ref49, 2);
|
|
9363
|
+
const subKey = _ref50[0];
|
|
9364
|
+
const subValue = _ref50[1];
|
|
9244
9365
|
root.style.setProperty("--".concat(key, "-").concat(subKey), subValue);
|
|
9245
9366
|
}
|
|
9246
9367
|
}
|