@tenphi/tasty 1.0.0 → 1.2.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.
Files changed (247) hide show
  1. package/dist/_virtual/_rolldown/runtime.js +1 -2
  2. package/dist/chunks/cacheKey.d.ts +1 -0
  3. package/dist/chunks/cacheKey.js +1 -2
  4. package/dist/chunks/cacheKey.js.map +1 -1
  5. package/dist/chunks/definitions.js +1 -2
  6. package/dist/chunks/definitions.js.map +1 -1
  7. package/dist/chunks/index.d.ts +1 -0
  8. package/dist/chunks/renderChunk.d.ts +1 -0
  9. package/dist/chunks/renderChunk.js +1 -2
  10. package/dist/chunks/renderChunk.js.map +1 -1
  11. package/dist/config.js +1 -2
  12. package/dist/config.js.map +1 -1
  13. package/dist/core/index.d.ts +0 -1
  14. package/dist/core/index.js +1 -2
  15. package/dist/counter-style/index.js +1 -1
  16. package/dist/counter-style/index.js.map +1 -1
  17. package/dist/debug.js +1 -2
  18. package/dist/debug.js.map +1 -1
  19. package/dist/font-face/index.js +1 -1
  20. package/dist/font-face/index.js.map +1 -1
  21. package/dist/hooks/index.d.ts +7 -0
  22. package/dist/hooks/resolve-ssr-collector.js +1 -2
  23. package/dist/hooks/resolve-ssr-collector.js.map +1 -1
  24. package/dist/hooks/useCounterStyle.js +1 -2
  25. package/dist/hooks/useCounterStyle.js.map +1 -1
  26. package/dist/hooks/useFontFace.js +1 -2
  27. package/dist/hooks/useFontFace.js.map +1 -1
  28. package/dist/hooks/useGlobalStyles.js +1 -2
  29. package/dist/hooks/useGlobalStyles.js.map +1 -1
  30. package/dist/hooks/useKeyframes.js +1 -2
  31. package/dist/hooks/useKeyframes.js.map +1 -1
  32. package/dist/hooks/useProperty.js +1 -2
  33. package/dist/hooks/useProperty.js.map +1 -1
  34. package/dist/hooks/useRawCSS.js +1 -2
  35. package/dist/hooks/useRawCSS.js.map +1 -1
  36. package/dist/hooks/useStyles.js +1 -2
  37. package/dist/hooks/useStyles.js.map +1 -1
  38. package/dist/index.d.ts +0 -1
  39. package/dist/index.js +1 -2
  40. package/dist/injector/index.js +2 -3
  41. package/dist/injector/index.js.map +1 -1
  42. package/dist/injector/injector.js +1 -2
  43. package/dist/injector/injector.js.map +1 -1
  44. package/dist/injector/sheet-manager.js +1 -2
  45. package/dist/injector/sheet-manager.js.map +1 -1
  46. package/dist/keyframes/index.js +1 -1
  47. package/dist/parser/classify.js +1 -2
  48. package/dist/parser/classify.js.map +1 -1
  49. package/dist/parser/const.js +14 -3
  50. package/dist/parser/const.js.map +1 -1
  51. package/dist/parser/lru.js +1 -1
  52. package/dist/parser/lru.js.map +1 -1
  53. package/dist/parser/parser.js +1 -2
  54. package/dist/parser/parser.js.map +1 -1
  55. package/dist/parser/tokenizer.js +1 -1
  56. package/dist/parser/tokenizer.js.map +1 -1
  57. package/dist/parser/types.js +1 -1
  58. package/dist/parser/types.js.map +1 -1
  59. package/dist/pipeline/conditions.js +1 -1
  60. package/dist/pipeline/conditions.js.map +1 -1
  61. package/dist/pipeline/exclusive.js +1 -2
  62. package/dist/pipeline/exclusive.js.map +1 -1
  63. package/dist/pipeline/index.js +2 -3
  64. package/dist/pipeline/index.js.map +1 -1
  65. package/dist/pipeline/materialize.js +1 -2
  66. package/dist/pipeline/materialize.js.map +1 -1
  67. package/dist/pipeline/parseStateKey.js +1 -2
  68. package/dist/pipeline/parseStateKey.js.map +1 -1
  69. package/dist/pipeline/simplify.js +1 -2
  70. package/dist/pipeline/simplify.js.map +1 -1
  71. package/dist/pipeline/warnings.js +1 -1
  72. package/dist/plugins/index.d.ts +2 -0
  73. package/dist/plugins/okhsl-plugin.js +1 -2
  74. package/dist/plugins/okhsl-plugin.js.map +1 -1
  75. package/dist/properties/index.js +2 -3
  76. package/dist/properties/index.js.map +1 -1
  77. package/dist/properties/property-type-resolver.js +1 -2
  78. package/dist/properties/property-type-resolver.js.map +1 -1
  79. package/dist/ssr/astro.js +1 -2
  80. package/dist/ssr/astro.js.map +1 -1
  81. package/dist/ssr/async-storage.js +1 -2
  82. package/dist/ssr/async-storage.js.map +1 -1
  83. package/dist/ssr/collect-auto-properties.js +1 -2
  84. package/dist/ssr/collect-auto-properties.js.map +1 -1
  85. package/dist/ssr/collector.js +1 -2
  86. package/dist/ssr/collector.js.map +1 -1
  87. package/dist/ssr/context.d.ts +2 -2
  88. package/dist/ssr/context.js +1 -2
  89. package/dist/ssr/context.js.map +1 -1
  90. package/dist/ssr/format-global-rules.js +1 -1
  91. package/dist/ssr/format-keyframes.js +1 -2
  92. package/dist/ssr/format-keyframes.js.map +1 -1
  93. package/dist/ssr/format-property.js +1 -2
  94. package/dist/ssr/format-property.js.map +1 -1
  95. package/dist/ssr/format-rules.js +1 -1
  96. package/dist/ssr/hydrate.js +1 -2
  97. package/dist/ssr/hydrate.js.map +1 -1
  98. package/dist/ssr/index.js +1 -2
  99. package/dist/ssr/index.js.map +1 -1
  100. package/dist/ssr/next.d.ts +2 -2
  101. package/dist/ssr/next.js +2 -4
  102. package/dist/ssr/next.js.map +1 -1
  103. package/dist/ssr/ssr-collector-ref.js +1 -1
  104. package/dist/states/index.js +1 -2
  105. package/dist/states/index.js.map +1 -1
  106. package/dist/static/index.js +1 -2
  107. package/dist/static/inject.d.ts +5 -0
  108. package/dist/static/inject.js +17 -0
  109. package/dist/static/inject.js.map +1 -0
  110. package/dist/static/tastyStatic.js +1 -2
  111. package/dist/static/tastyStatic.js.map +1 -1
  112. package/dist/static/types.js +1 -1
  113. package/dist/styles/border.d.ts +1 -1
  114. package/dist/styles/border.js +28 -22
  115. package/dist/styles/border.js.map +1 -1
  116. package/dist/styles/color.d.ts +1 -1
  117. package/dist/styles/color.js +2 -3
  118. package/dist/styles/color.js.map +1 -1
  119. package/dist/styles/const.js +17 -0
  120. package/dist/styles/const.js.map +1 -0
  121. package/dist/styles/createStyle.js +4 -5
  122. package/dist/styles/createStyle.js.map +1 -1
  123. package/dist/styles/dimension.js +15 -3
  124. package/dist/styles/dimension.js.map +1 -1
  125. package/dist/styles/directional.js +133 -0
  126. package/dist/styles/directional.js.map +1 -0
  127. package/dist/styles/display.d.ts +3 -10
  128. package/dist/styles/display.js +45 -39
  129. package/dist/styles/display.js.map +1 -1
  130. package/dist/styles/fade.d.ts +1 -1
  131. package/dist/styles/fade.js +9 -5
  132. package/dist/styles/fade.js.map +1 -1
  133. package/dist/styles/fill.d.ts +2 -2
  134. package/dist/styles/fill.js +3 -4
  135. package/dist/styles/fill.js.map +1 -1
  136. package/dist/styles/flow.js +1 -1
  137. package/dist/styles/gap.d.ts +1 -1
  138. package/dist/styles/gap.js +4 -3
  139. package/dist/styles/gap.js.map +1 -1
  140. package/dist/styles/height.d.ts +1 -1
  141. package/dist/styles/height.js +1 -2
  142. package/dist/styles/height.js.map +1 -1
  143. package/dist/styles/index.d.ts +0 -1
  144. package/dist/styles/index.js +3 -4
  145. package/dist/styles/index.js.map +1 -1
  146. package/dist/styles/inset.d.ts +1 -29
  147. package/dist/styles/inset.js +19 -135
  148. package/dist/styles/inset.js.map +1 -1
  149. package/dist/styles/list.d.ts +5 -5
  150. package/dist/styles/list.js +4 -2
  151. package/dist/styles/list.js.map +1 -1
  152. package/dist/styles/margin.d.ts +1 -1
  153. package/dist/styles/margin.js +17 -89
  154. package/dist/styles/margin.js.map +1 -1
  155. package/dist/styles/outline.d.ts +1 -1
  156. package/dist/styles/outline.js +6 -16
  157. package/dist/styles/outline.js.map +1 -1
  158. package/dist/styles/padding.d.ts +1 -1
  159. package/dist/styles/padding.js +17 -89
  160. package/dist/styles/padding.js.map +1 -1
  161. package/dist/styles/placement.d.ts +37 -0
  162. package/dist/styles/placement.js +74 -0
  163. package/dist/styles/placement.js.map +1 -0
  164. package/dist/styles/predefined.d.ts +4 -4
  165. package/dist/styles/predefined.js +8 -9
  166. package/dist/styles/predefined.js.map +1 -1
  167. package/dist/styles/preset.d.ts +6 -1
  168. package/dist/styles/preset.js +29 -14
  169. package/dist/styles/preset.js.map +1 -1
  170. package/dist/styles/radius.d.ts +1 -3
  171. package/dist/styles/radius.js +38 -6
  172. package/dist/styles/radius.js.map +1 -1
  173. package/dist/styles/scrollMargin.d.ts +24 -0
  174. package/dist/styles/scrollMargin.js +32 -0
  175. package/dist/styles/scrollMargin.js.map +1 -0
  176. package/dist/styles/scrollbar.d.ts +1 -1
  177. package/dist/styles/scrollbar.js +8 -5
  178. package/dist/styles/scrollbar.js.map +1 -1
  179. package/dist/styles/shadow.d.ts +1 -1
  180. package/dist/styles/shadow.js +4 -3
  181. package/dist/styles/shadow.js.map +1 -1
  182. package/dist/styles/shared.js +17 -0
  183. package/dist/styles/shared.js.map +1 -0
  184. package/dist/styles/transition.d.ts +1 -1
  185. package/dist/styles/transition.js +5 -4
  186. package/dist/styles/transition.js.map +1 -1
  187. package/dist/styles/types.d.ts +27 -8
  188. package/dist/styles/width.d.ts +1 -1
  189. package/dist/styles/width.js +1 -2
  190. package/dist/styles/width.js.map +1 -1
  191. package/dist/tasty.d.ts +2 -2
  192. package/dist/tasty.js +1 -2
  193. package/dist/tasty.js.map +1 -1
  194. package/dist/utils/cache-wrapper.js +1 -2
  195. package/dist/utils/cache-wrapper.js.map +1 -1
  196. package/dist/utils/case-converter.js +1 -1
  197. package/dist/utils/color-math.js +1 -1
  198. package/dist/utils/color-math.js.map +1 -1
  199. package/dist/utils/color-space.js +1 -2
  200. package/dist/utils/color-space.js.map +1 -1
  201. package/dist/utils/colors.js +1 -2
  202. package/dist/utils/colors.js.map +1 -1
  203. package/dist/utils/dotize.js +1 -1
  204. package/dist/utils/dotize.js.map +1 -1
  205. package/dist/utils/filter-base-props.js +1 -1
  206. package/dist/utils/get-display-name.js +1 -1
  207. package/dist/utils/has-keys.js +1 -1
  208. package/dist/utils/is-dev-env.js +1 -1
  209. package/dist/utils/is-dev-env.js.map +1 -1
  210. package/dist/utils/is-valid-element-type.js +1 -1
  211. package/dist/utils/merge-styles.js +1 -2
  212. package/dist/utils/merge-styles.js.map +1 -1
  213. package/dist/utils/mod-attrs.d.ts +0 -2
  214. package/dist/utils/mod-attrs.js +1 -2
  215. package/dist/utils/mod-attrs.js.map +1 -1
  216. package/dist/utils/process-tokens.js +2 -3
  217. package/dist/utils/process-tokens.js.map +1 -1
  218. package/dist/utils/resolve-recipes.js +1 -2
  219. package/dist/utils/resolve-recipes.js.map +1 -1
  220. package/dist/utils/selector-transform.js +1 -1
  221. package/dist/utils/string.js +1 -1
  222. package/dist/utils/styles.d.ts +1 -1
  223. package/dist/utils/styles.js +2 -3
  224. package/dist/utils/styles.js.map +1 -1
  225. package/dist/utils/typography.js +9 -1
  226. package/dist/utils/typography.js.map +1 -1
  227. package/dist/utils/warnings.js +1 -1
  228. package/dist/zero/babel.d.ts +17 -2
  229. package/dist/zero/babel.js +105 -41
  230. package/dist/zero/babel.js.map +1 -1
  231. package/dist/zero/css-writer.js +1 -2
  232. package/dist/zero/css-writer.js.map +1 -1
  233. package/dist/zero/extractor.js +1 -2
  234. package/dist/zero/extractor.js.map +1 -1
  235. package/dist/zero/index.js +1 -2
  236. package/dist/zero/next.d.ts +12 -0
  237. package/dist/zero/next.js +5 -4
  238. package/dist/zero/next.js.map +1 -1
  239. package/docs/styles.md +26 -6
  240. package/docs/tasty-static.md +87 -0
  241. package/package.json +11 -6
  242. package/dist/styles/align.d.ts +0 -15
  243. package/dist/styles/align.js +0 -14
  244. package/dist/styles/align.js.map +0 -1
  245. package/dist/styles/justify.d.ts +0 -15
  246. package/dist/styles/justify.js +0 -14
  247. package/dist/styles/justify.js.map +0 -1
@@ -1,57 +1,63 @@
1
1
  import { parseStyle } from "../utils/styles.js";
2
-
3
2
  //#region src/styles/display.ts
4
3
  /**
5
- * Handles display, hide, textOverflow, overflow, and whiteSpace styles.
4
+ * Process textOverflow into CSS properties for truncation/clamping.
6
5
  *
7
- * textOverflow syntax:
8
- * - `textOverflow="ellipsis"` - single-line truncation with ellipsis
9
- * - `textOverflow="ellipsis / 3"` - multi-line clamping (3 lines) with ellipsis
10
- * - `textOverflow="clip"` - single-line truncation with clip (no ellipsis)
11
- * - `textOverflow="clip / 2"` - multi-line clip (2 lines)
12
- * - `textOverflow={true}` or `textOverflow="initial"` - reset to initial
6
+ * - `ellipsis` — single-line truncation with ellipsis
7
+ * - `ellipsis / 3` multi-line clamping (3 lines) with ellipsis
8
+ * - `clip` single-line truncation with clip
9
+ * - `clip / 2` multi-line clip (2 lines)
10
+ * - `true` or `initial` reset to initial
11
+ */
12
+ function processTextOverflow(textOverflow, whiteSpace) {
13
+ if (textOverflow === true || textOverflow === "initial") return { "text-overflow": "initial" };
14
+ const group = parseStyle(String(textOverflow)).groups[0];
15
+ if (!group) return null;
16
+ const { parts } = group;
17
+ const modePart = parts[0];
18
+ const clampPart = parts[1];
19
+ const hasEllipsis = modePart?.mods.includes("ellipsis");
20
+ const hasClip = modePart?.mods.includes("clip");
21
+ if (!hasEllipsis && !hasClip) return null;
22
+ let clamp = 1;
23
+ if (clampPart?.values[0]) {
24
+ const parsed = parseInt(clampPart.values[0], 10);
25
+ if (!isNaN(parsed) && parsed > 0) clamp = parsed;
26
+ }
27
+ const result = {
28
+ overflow: "hidden",
29
+ "text-overflow": hasEllipsis ? "ellipsis" : "clip"
30
+ };
31
+ if (clamp === 1) result["white-space"] = whiteSpace || "nowrap";
32
+ else {
33
+ result["display"] = "-webkit-box";
34
+ result["-webkit-box-orient"] = "vertical";
35
+ result["-webkit-line-clamp"] = clamp;
36
+ result["line-clamp"] = clamp;
37
+ result["white-space"] = whiteSpace || "initial";
38
+ }
39
+ return result;
40
+ }
41
+ /**
42
+ * Handles display, hide, textOverflow, overflow, and whiteSpace styles.
13
43
  *
14
44
  * Priority:
15
45
  * 1. `hide` takes precedence (display: none)
16
46
  * 2. Multi-line `textOverflow` forces display: -webkit-box
17
- * 3. Single-line `textOverflow` defaults white-space to nowrap, multi-line defaults to initial
18
- * 4. Explicit `whiteSpace` overrides the default white-space from `textOverflow`
47
+ * 3. Single-line `textOverflow` defaults white-space to nowrap
48
+ * 4. Explicit `whiteSpace` overrides the default from `textOverflow`
19
49
  */
20
50
  function displayStyle({ display, hide, textOverflow, overflow, whiteSpace }) {
21
51
  const result = {};
22
- if (textOverflow != null && textOverflow !== false) if (textOverflow === true || textOverflow === "initial") result["text-overflow"] = "initial";
23
- else {
24
- const group = parseStyle(String(textOverflow)).groups[0];
25
- if (group) {
26
- const { parts } = group;
27
- const modePart = parts[0];
28
- const clampPart = parts[1];
29
- const hasEllipsis = modePart?.mods.includes("ellipsis");
30
- const hasClip = modePart?.mods.includes("clip");
31
- let clamp = 1;
32
- if (clampPart?.values[0]) {
33
- const parsed = parseInt(clampPart.values[0], 10);
34
- if (!isNaN(parsed) && parsed > 0) clamp = parsed;
35
- }
36
- if (hasEllipsis || hasClip) {
37
- result["overflow"] = "hidden";
38
- result["text-overflow"] = hasEllipsis ? "ellipsis" : "clip";
39
- if (clamp === 1) result["white-space"] = whiteSpace || "nowrap";
40
- else {
41
- result["display"] = "-webkit-box";
42
- result["-webkit-box-orient"] = "vertical";
43
- result["-webkit-line-clamp"] = clamp;
44
- result["line-clamp"] = clamp;
45
- result["white-space"] = whiteSpace || "initial";
46
- }
47
- }
48
- }
52
+ if (textOverflow != null && textOverflow !== false) {
53
+ const textResult = processTextOverflow(textOverflow, whiteSpace);
54
+ if (textResult) Object.assign(result, textResult);
49
55
  }
50
56
  if (overflow && !result["overflow"]) result["overflow"] = overflow;
51
57
  if (whiteSpace && !result["white-space"]) result["white-space"] = whiteSpace;
52
58
  if (hide) result["display"] = "none";
53
59
  else if (!result["display"] && display) result["display"] = display;
54
- if (Object.keys(result).length === 0) return;
60
+ if (Object.keys(result).length === 0) return null;
55
61
  return result;
56
62
  }
57
63
  displayStyle.__lookupStyles = [
@@ -61,7 +67,7 @@ displayStyle.__lookupStyles = [
61
67
  "overflow",
62
68
  "whiteSpace"
63
69
  ];
64
-
65
70
  //#endregion
66
71
  export { displayStyle };
72
+
67
73
  //# sourceMappingURL=display.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"display.js","names":[],"sources":["../../src/styles/display.ts"],"sourcesContent":["import { parseStyle } from '../utils/styles';\n\ninterface DisplayStyleProps {\n display?: string;\n hide?: boolean;\n textOverflow?: string | boolean;\n overflow?: string;\n whiteSpace?: string;\n}\n\n/**\n * Handles display, hide, textOverflow, overflow, and whiteSpace styles.\n *\n * textOverflow syntax:\n * - `textOverflow=\"ellipsis\"` - single-line truncation with ellipsis\n * - `textOverflow=\"ellipsis / 3\"` - multi-line clamping (3 lines) with ellipsis\n * - `textOverflow=\"clip\"` - single-line truncation with clip (no ellipsis)\n * - `textOverflow=\"clip / 2\"` - multi-line clip (2 lines)\n * - `textOverflow={true}` or `textOverflow=\"initial\"` - reset to initial\n *\n * Priority:\n * 1. `hide` takes precedence (display: none)\n * 2. Multi-line `textOverflow` forces display: -webkit-box\n * 3. Single-line `textOverflow` defaults white-space to nowrap, multi-line defaults to initial\n * 4. Explicit `whiteSpace` overrides the default white-space from `textOverflow`\n */\nexport function displayStyle({\n display,\n hide,\n textOverflow,\n overflow,\n whiteSpace,\n}: DisplayStyleProps) {\n const result: Record<string, string | number> = {};\n\n // Handle textOverflow first to determine required overrides\n if (textOverflow != null && textOverflow !== false) {\n // Boolean true or 'initial' → reset to initial\n if (textOverflow === true || textOverflow === 'initial') {\n result['text-overflow'] = 'initial';\n } else {\n const processed = parseStyle(String(textOverflow));\n const group = processed.groups[0];\n\n if (group) {\n const { parts } = group;\n const modePart = parts[0];\n const clampPart = parts[1];\n\n const hasEllipsis = modePart?.mods.includes('ellipsis');\n const hasClip = modePart?.mods.includes('clip');\n\n // Get clamp value from second part (after /)\n let clamp = 1;\n if (clampPart?.values[0]) {\n const parsed = parseInt(clampPart.values[0], 10);\n if (!isNaN(parsed) && parsed > 0) {\n clamp = parsed;\n }\n }\n\n if (hasEllipsis || hasClip) {\n result['overflow'] = 'hidden';\n result['text-overflow'] = hasEllipsis ? 'ellipsis' : 'clip';\n\n if (clamp === 1) {\n result['white-space'] = whiteSpace || 'nowrap';\n } else {\n result['display'] = '-webkit-box';\n result['-webkit-box-orient'] = 'vertical';\n result['-webkit-line-clamp'] = clamp;\n result['line-clamp'] = clamp;\n result['white-space'] = whiteSpace || 'initial';\n }\n }\n }\n }\n }\n\n // Apply user-specified values (only if not overridden by textOverflow)\n if (overflow && !result['overflow']) {\n result['overflow'] = overflow;\n }\n if (whiteSpace && !result['white-space']) {\n result['white-space'] = whiteSpace;\n }\n\n // Handle display (hide > textOverflow > user value)\n if (hide) {\n result['display'] = 'none';\n } else if (!result['display'] && display) {\n result['display'] = display;\n }\n\n // Return undefined if no styles to apply\n if (Object.keys(result).length === 0) {\n return;\n }\n\n return result;\n}\n\ndisplayStyle.__lookupStyles = [\n 'display',\n 'hide',\n 'textOverflow',\n 'overflow',\n 'whiteSpace',\n];\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA0BA,SAAgB,aAAa,EAC3B,SACA,MACA,cACA,UACA,cACoB;CACpB,MAAM,SAA0C,EAAE;AAGlD,KAAI,gBAAgB,QAAQ,iBAAiB,MAE3C,KAAI,iBAAiB,QAAQ,iBAAiB,UAC5C,QAAO,mBAAmB;MACrB;EAEL,MAAM,QADY,WAAW,OAAO,aAAa,CAAC,CAC1B,OAAO;AAE/B,MAAI,OAAO;GACT,MAAM,EAAE,UAAU;GAClB,MAAM,WAAW,MAAM;GACvB,MAAM,YAAY,MAAM;GAExB,MAAM,cAAc,UAAU,KAAK,SAAS,WAAW;GACvD,MAAM,UAAU,UAAU,KAAK,SAAS,OAAO;GAG/C,IAAI,QAAQ;AACZ,OAAI,WAAW,OAAO,IAAI;IACxB,MAAM,SAAS,SAAS,UAAU,OAAO,IAAI,GAAG;AAChD,QAAI,CAAC,MAAM,OAAO,IAAI,SAAS,EAC7B,SAAQ;;AAIZ,OAAI,eAAe,SAAS;AAC1B,WAAO,cAAc;AACrB,WAAO,mBAAmB,cAAc,aAAa;AAErD,QAAI,UAAU,EACZ,QAAO,iBAAiB,cAAc;SACjC;AACL,YAAO,aAAa;AACpB,YAAO,wBAAwB;AAC/B,YAAO,wBAAwB;AAC/B,YAAO,gBAAgB;AACvB,YAAO,iBAAiB,cAAc;;;;;AAQhD,KAAI,YAAY,CAAC,OAAO,YACtB,QAAO,cAAc;AAEvB,KAAI,cAAc,CAAC,OAAO,eACxB,QAAO,iBAAiB;AAI1B,KAAI,KACF,QAAO,aAAa;UACX,CAAC,OAAO,cAAc,QAC/B,QAAO,aAAa;AAItB,KAAI,OAAO,KAAK,OAAO,CAAC,WAAW,EACjC;AAGF,QAAO;;AAGT,aAAa,iBAAiB;CAC5B;CACA;CACA;CACA;CACA;CACD"}
1
+ {"version":3,"file":"display.js","names":[],"sources":["../../src/styles/display.ts"],"sourcesContent":["import { parseStyle } from '../utils/styles';\n\ninterface DisplayStyleProps {\n display?: string;\n hide?: boolean;\n textOverflow?: string | boolean;\n overflow?: string;\n whiteSpace?: string;\n}\n\n/**\n * Process textOverflow into CSS properties for truncation/clamping.\n *\n * - `ellipsis` single-line truncation with ellipsis\n * - `ellipsis / 3` multi-line clamping (3 lines) with ellipsis\n * - `clip` single-line truncation with clip\n * - `clip / 2` multi-line clip (2 lines)\n * - `true` or `initial` reset to initial\n */\nfunction processTextOverflow(\n textOverflow: string | boolean,\n whiteSpace?: string,\n): Record<string, string | number> | null {\n if (textOverflow === true || textOverflow === 'initial') {\n return { 'text-overflow': 'initial' };\n }\n\n const processed = parseStyle(String(textOverflow));\n const group = processed.groups[0];\n\n if (!group) return null;\n\n const { parts } = group;\n const modePart = parts[0];\n const clampPart = parts[1];\n\n const hasEllipsis = modePart?.mods.includes('ellipsis');\n const hasClip = modePart?.mods.includes('clip');\n\n if (!hasEllipsis && !hasClip) return null;\n\n let clamp = 1;\n\n if (clampPart?.values[0]) {\n const parsed = parseInt(clampPart.values[0], 10);\n\n if (!isNaN(parsed) && parsed > 0) {\n clamp = parsed;\n }\n }\n\n const result: Record<string, string | number> = {\n overflow: 'hidden',\n 'text-overflow': hasEllipsis ? 'ellipsis' : 'clip',\n };\n\n if (clamp === 1) {\n result['white-space'] = whiteSpace || 'nowrap';\n } else {\n result['display'] = '-webkit-box';\n result['-webkit-box-orient'] = 'vertical';\n result['-webkit-line-clamp'] = clamp;\n result['line-clamp'] = clamp;\n result['white-space'] = whiteSpace || 'initial';\n }\n\n return result;\n}\n\n/**\n * Handles display, hide, textOverflow, overflow, and whiteSpace styles.\n *\n * Priority:\n * 1. `hide` takes precedence (display: none)\n * 2. Multi-line `textOverflow` forces display: -webkit-box\n * 3. Single-line `textOverflow` defaults white-space to nowrap\n * 4. Explicit `whiteSpace` overrides the default from `textOverflow`\n */\nexport function displayStyle({\n display,\n hide,\n textOverflow,\n overflow,\n whiteSpace,\n}: DisplayStyleProps) {\n const result: Record<string, string | number> = {};\n\n if (textOverflow != null && textOverflow !== false) {\n const textResult = processTextOverflow(textOverflow, whiteSpace);\n\n if (textResult) Object.assign(result, textResult);\n }\n\n if (overflow && !result['overflow']) {\n result['overflow'] = overflow;\n }\n if (whiteSpace && !result['white-space']) {\n result['white-space'] = whiteSpace;\n }\n\n if (hide) {\n result['display'] = 'none';\n } else if (!result['display'] && display) {\n result['display'] = display;\n }\n\n if (Object.keys(result).length === 0) {\n return null;\n }\n\n return result;\n}\n\ndisplayStyle.__lookupStyles = [\n 'display',\n 'hide',\n 'textOverflow',\n 'overflow',\n 'whiteSpace',\n];\n"],"mappings":";;;;;;;;;;;AAmBA,SAAS,oBACP,cACA,YACwC;AACxC,KAAI,iBAAiB,QAAQ,iBAAiB,UAC5C,QAAO,EAAE,iBAAiB,WAAW;CAIvC,MAAM,QADY,WAAW,OAAO,aAAa,CAAC,CAC1B,OAAO;AAE/B,KAAI,CAAC,MAAO,QAAO;CAEnB,MAAM,EAAE,UAAU;CAClB,MAAM,WAAW,MAAM;CACvB,MAAM,YAAY,MAAM;CAExB,MAAM,cAAc,UAAU,KAAK,SAAS,WAAW;CACvD,MAAM,UAAU,UAAU,KAAK,SAAS,OAAO;AAE/C,KAAI,CAAC,eAAe,CAAC,QAAS,QAAO;CAErC,IAAI,QAAQ;AAEZ,KAAI,WAAW,OAAO,IAAI;EACxB,MAAM,SAAS,SAAS,UAAU,OAAO,IAAI,GAAG;AAEhD,MAAI,CAAC,MAAM,OAAO,IAAI,SAAS,EAC7B,SAAQ;;CAIZ,MAAM,SAA0C;EAC9C,UAAU;EACV,iBAAiB,cAAc,aAAa;EAC7C;AAED,KAAI,UAAU,EACZ,QAAO,iBAAiB,cAAc;MACjC;AACL,SAAO,aAAa;AACpB,SAAO,wBAAwB;AAC/B,SAAO,wBAAwB;AAC/B,SAAO,gBAAgB;AACvB,SAAO,iBAAiB,cAAc;;AAGxC,QAAO;;;;;;;;;;;AAYT,SAAgB,aAAa,EAC3B,SACA,MACA,cACA,UACA,cACoB;CACpB,MAAM,SAA0C,EAAE;AAElD,KAAI,gBAAgB,QAAQ,iBAAiB,OAAO;EAClD,MAAM,aAAa,oBAAoB,cAAc,WAAW;AAEhE,MAAI,WAAY,QAAO,OAAO,QAAQ,WAAW;;AAGnD,KAAI,YAAY,CAAC,OAAO,YACtB,QAAO,cAAc;AAEvB,KAAI,cAAc,CAAC,OAAO,eACxB,QAAO,iBAAiB;AAG1B,KAAI,KACF,QAAO,aAAa;UACX,CAAC,OAAO,cAAc,QAC/B,QAAO,aAAa;AAGtB,KAAI,OAAO,KAAK,OAAO,CAAC,WAAW,EACjC,QAAO;AAGT,QAAO;;AAGT,aAAa,iBAAiB;CAC5B;CACA;CACA;CACA;CACA;CACD"}
@@ -6,7 +6,7 @@ declare function fadeStyle({
6
6
  }): {
7
7
  mask: string;
8
8
  'mask-composite': string;
9
- } | undefined;
9
+ } | null;
10
10
  declare namespace fadeStyle {
11
11
  var __lookupStyles: string[];
12
12
  }
@@ -1,5 +1,5 @@
1
+ import { CSS_WIDE_KEYWORDS } from "../parser/const.js";
1
2
  import { DIRECTIONS, filterMods, parseStyle } from "../utils/styles.js";
2
-
3
3
  //#region src/styles/fade.ts
4
4
  const DIRECTION_MAP = {
5
5
  right: "to left",
@@ -32,9 +32,13 @@ function processGroup(group, isOnlyGroup) {
32
32
  });
33
33
  }
34
34
  function fadeStyle({ fade }) {
35
- if (!fade) return;
35
+ if (!fade) return null;
36
+ if (CSS_WIDE_KEYWORDS.has(fade)) return {
37
+ mask: fade,
38
+ "mask-composite": fade
39
+ };
36
40
  const groups = parseStyle(fade).groups ?? [];
37
- if (!groups.length) return;
41
+ if (!groups.length) return null;
38
42
  const isOnlyGroup = groups.length === 1;
39
43
  const gradients = [];
40
44
  for (const group of groups) {
@@ -45,14 +49,14 @@ function fadeStyle({ fade }) {
45
49
  }, isOnlyGroup);
46
50
  gradients.push(...groupGradients);
47
51
  }
48
- if (!gradients.length) return;
52
+ if (!gradients.length) return null;
49
53
  return {
50
54
  mask: gradients.join(", "),
51
55
  "mask-composite": "intersect"
52
56
  };
53
57
  }
54
58
  fadeStyle.__lookupStyles = ["fade"];
55
-
56
59
  //#endregion
57
60
  export { fadeStyle };
61
+
58
62
  //# sourceMappingURL=fade.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fade.js","names":[],"sources":["../../src/styles/fade.ts"],"sourcesContent":["import { DIRECTIONS, filterMods, parseStyle } from '../utils/styles';\n\nconst DIRECTION_MAP: Record<(typeof DIRECTIONS)[number], string> = {\n right: 'to left',\n left: 'to right',\n top: 'to bottom',\n bottom: 'to top',\n};\n\n// Default mask colors (standard black with alpha for gradient masks)\nconst DEFAULT_TRANSPARENT_COLOR = 'rgb(0 0 0 / 0)';\nconst DEFAULT_OPAQUE_COLOR = 'rgb(0 0 0 / 1)';\n\ninterface GroupData {\n values: string[];\n mods: string[];\n colors: string[];\n}\n\n/**\n * Process a single group and return gradient strings for its directions.\n */\nfunction processGroup(group: GroupData, isOnlyGroup: boolean): string[] {\n let { values } = group;\n const { mods, colors } = group;\n\n let directions = filterMods(\n mods,\n DIRECTIONS,\n ) as (typeof DIRECTIONS)[number][];\n\n if (!values.length) {\n values = ['calc(2 * var(--gap))'];\n }\n\n // If this is the only group and no directions specified, apply to all edges\n if (!directions.length) {\n if (isOnlyGroup) {\n directions = ['top', 'right', 'bottom', 'left'];\n } else {\n // For multi-group without explicit direction, skip this group\n return [];\n }\n }\n\n // Extract colors: first = transparent mask color, second = opaque mask color\n const transparentColor = colors?.[0] || DEFAULT_TRANSPARENT_COLOR;\n const opaqueColor = colors?.[1] || DEFAULT_OPAQUE_COLOR;\n\n return directions.map(\n (direction: (typeof DIRECTIONS)[number], index: number) => {\n const size = values[index] || values[index % 2] || values[0];\n\n return `linear-gradient(${DIRECTION_MAP[direction]}, ${transparentColor} 0%, ${opaqueColor} ${size})`;\n },\n );\n}\n\nexport function fadeStyle({ fade }: { fade?: string }) {\n if (!fade) return;\n\n const processed = parseStyle(fade);\n const groups: GroupData[] = processed.groups ?? [];\n\n if (!groups.length) return;\n\n const isOnlyGroup = groups.length === 1;\n\n // Process all groups and collect gradients\n const gradients: string[] = [];\n\n for (const group of groups) {\n const groupGradients = processGroup(\n {\n values: group.values ?? [],\n mods: group.mods ?? [],\n colors: group.colors ?? [],\n },\n isOnlyGroup,\n );\n gradients.push(...groupGradients);\n }\n\n if (!gradients.length) return;\n\n return {\n mask: gradients.join(', '),\n 'mask-composite': 'intersect',\n };\n}\n\nfadeStyle.__lookupStyles = ['fade'];\n"],"mappings":";;;AAEA,MAAM,gBAA6D;CACjE,OAAO;CACP,MAAM;CACN,KAAK;CACL,QAAQ;CACT;AAGD,MAAM,4BAA4B;AAClC,MAAM,uBAAuB;;;;AAW7B,SAAS,aAAa,OAAkB,aAAgC;CACtE,IAAI,EAAE,WAAW;CACjB,MAAM,EAAE,MAAM,WAAW;CAEzB,IAAI,aAAa,WACf,MACA,WACD;AAED,KAAI,CAAC,OAAO,OACV,UAAS,CAAC,uBAAuB;AAInC,KAAI,CAAC,WAAW,OACd,KAAI,YACF,cAAa;EAAC;EAAO;EAAS;EAAU;EAAO;KAG/C,QAAO,EAAE;CAKb,MAAM,mBAAmB,SAAS,MAAM;CACxC,MAAM,cAAc,SAAS,MAAM;AAEnC,QAAO,WAAW,KACf,WAAwC,UAAkB;EACzD,MAAM,OAAO,OAAO,UAAU,OAAO,QAAQ,MAAM,OAAO;AAE1D,SAAO,mBAAmB,cAAc,WAAW,IAAI,iBAAiB,OAAO,YAAY,GAAG,KAAK;GAEtG;;AAGH,SAAgB,UAAU,EAAE,QAA2B;AACrD,KAAI,CAAC,KAAM;CAGX,MAAM,SADY,WAAW,KAAK,CACI,UAAU,EAAE;AAElD,KAAI,CAAC,OAAO,OAAQ;CAEpB,MAAM,cAAc,OAAO,WAAW;CAGtC,MAAM,YAAsB,EAAE;AAE9B,MAAK,MAAM,SAAS,QAAQ;EAC1B,MAAM,iBAAiB,aACrB;GACE,QAAQ,MAAM,UAAU,EAAE;GAC1B,MAAM,MAAM,QAAQ,EAAE;GACtB,QAAQ,MAAM,UAAU,EAAE;GAC3B,EACD,YACD;AACD,YAAU,KAAK,GAAG,eAAe;;AAGnC,KAAI,CAAC,UAAU,OAAQ;AAEvB,QAAO;EACL,MAAM,UAAU,KAAK,KAAK;EAC1B,kBAAkB;EACnB;;AAGH,UAAU,iBAAiB,CAAC,OAAO"}
1
+ {"version":3,"file":"fade.js","names":[],"sources":["../../src/styles/fade.ts"],"sourcesContent":["import { CSS_WIDE_KEYWORDS } from '../parser/const';\nimport { DIRECTIONS, filterMods, parseStyle } from '../utils/styles';\n\nconst DIRECTION_MAP: Record<(typeof DIRECTIONS)[number], string> = {\n right: 'to left',\n left: 'to right',\n top: 'to bottom',\n bottom: 'to top',\n};\n\n// Default mask colors (standard black with alpha for gradient masks)\nconst DEFAULT_TRANSPARENT_COLOR = 'rgb(0 0 0 / 0)';\nconst DEFAULT_OPAQUE_COLOR = 'rgb(0 0 0 / 1)';\n\ninterface GroupData {\n values: string[];\n mods: string[];\n colors: string[];\n}\n\n/**\n * Process a single group and return gradient strings for its directions.\n */\nfunction processGroup(group: GroupData, isOnlyGroup: boolean): string[] {\n let { values } = group;\n const { mods, colors } = group;\n\n let directions = filterMods(\n mods,\n DIRECTIONS,\n ) as (typeof DIRECTIONS)[number][];\n\n if (!values.length) {\n values = ['calc(2 * var(--gap))'];\n }\n\n // If this is the only group and no directions specified, apply to all edges\n if (!directions.length) {\n if (isOnlyGroup) {\n directions = ['top', 'right', 'bottom', 'left'];\n } else {\n // For multi-group without explicit direction, skip this group\n return [];\n }\n }\n\n // Extract colors: first = transparent mask color, second = opaque mask color\n const transparentColor = colors?.[0] || DEFAULT_TRANSPARENT_COLOR;\n const opaqueColor = colors?.[1] || DEFAULT_OPAQUE_COLOR;\n\n return directions.map(\n (direction: (typeof DIRECTIONS)[number], index: number) => {\n const size = values[index] || values[index % 2] || values[0];\n\n return `linear-gradient(${DIRECTION_MAP[direction]}, ${transparentColor} 0%, ${opaqueColor} ${size})`;\n },\n );\n}\n\nexport function fadeStyle({ fade }: { fade?: string }) {\n if (!fade) return null;\n\n if (CSS_WIDE_KEYWORDS.has(fade)) {\n return { mask: fade, 'mask-composite': fade };\n }\n\n const processed = parseStyle(fade);\n const groups: GroupData[] = processed.groups ?? [];\n\n if (!groups.length) return null;\n\n const isOnlyGroup = groups.length === 1;\n\n // Process all groups and collect gradients\n const gradients: string[] = [];\n\n for (const group of groups) {\n const groupGradients = processGroup(\n {\n values: group.values ?? [],\n mods: group.mods ?? [],\n colors: group.colors ?? [],\n },\n isOnlyGroup,\n );\n gradients.push(...groupGradients);\n }\n\n if (!gradients.length) return null;\n\n return {\n mask: gradients.join(', '),\n 'mask-composite': 'intersect',\n };\n}\n\nfadeStyle.__lookupStyles = ['fade'];\n"],"mappings":";;;AAGA,MAAM,gBAA6D;CACjE,OAAO;CACP,MAAM;CACN,KAAK;CACL,QAAQ;CACT;AAGD,MAAM,4BAA4B;AAClC,MAAM,uBAAuB;;;;AAW7B,SAAS,aAAa,OAAkB,aAAgC;CACtE,IAAI,EAAE,WAAW;CACjB,MAAM,EAAE,MAAM,WAAW;CAEzB,IAAI,aAAa,WACf,MACA,WACD;AAED,KAAI,CAAC,OAAO,OACV,UAAS,CAAC,uBAAuB;AAInC,KAAI,CAAC,WAAW,OACd,KAAI,YACF,cAAa;EAAC;EAAO;EAAS;EAAU;EAAO;KAG/C,QAAO,EAAE;CAKb,MAAM,mBAAmB,SAAS,MAAM;CACxC,MAAM,cAAc,SAAS,MAAM;AAEnC,QAAO,WAAW,KACf,WAAwC,UAAkB;EACzD,MAAM,OAAO,OAAO,UAAU,OAAO,QAAQ,MAAM,OAAO;AAE1D,SAAO,mBAAmB,cAAc,WAAW,IAAI,iBAAiB,OAAO,YAAY,GAAG,KAAK;GAEtG;;AAGH,SAAgB,UAAU,EAAE,QAA2B;AACrD,KAAI,CAAC,KAAM,QAAO;AAElB,KAAI,kBAAkB,IAAI,KAAK,CAC7B,QAAO;EAAE,MAAM;EAAM,kBAAkB;EAAM;CAI/C,MAAM,SADY,WAAW,KAAK,CACI,UAAU,EAAE;AAElD,KAAI,CAAC,OAAO,OAAQ,QAAO;CAE3B,MAAM,cAAc,OAAO,WAAW;CAGtC,MAAM,YAAsB,EAAE;AAE9B,MAAK,MAAM,SAAS,QAAQ;EAC1B,MAAM,iBAAiB,aACrB;GACE,QAAQ,MAAM,UAAU,EAAE;GAC1B,MAAM,MAAM,QAAQ,EAAE;GACtB,QAAQ,MAAM,UAAU,EAAE;GAC3B,EACD,YACD;AACD,YAAU,KAAK,GAAG,eAAe;;AAGnC,KAAI,CAAC,UAAU,OAAQ,QAAO;AAE9B,QAAO;EACL,MAAM,UAAU,KAAK,KAAK;EAC1B,kBAAkB;EACnB;;AAGH,UAAU,iBAAiB,CAAC,OAAO"}
@@ -23,7 +23,7 @@ declare function fillStyle({
23
23
  backgroundOrigin?: string;
24
24
  backgroundClip?: string;
25
25
  background?: string;
26
- }): Record<string, string> | undefined;
26
+ }): Record<string, string> | null;
27
27
  declare namespace fillStyle {
28
28
  var __lookupStyles: string[];
29
29
  }
@@ -33,7 +33,7 @@ declare function svgFillStyle({
33
33
  svgFill?: string;
34
34
  }): {
35
35
  fill: string;
36
- } | undefined;
36
+ } | null;
37
37
  declare namespace svgFillStyle {
38
38
  var __lookupStyles: string[];
39
39
  }
@@ -1,5 +1,4 @@
1
1
  import { parseStyle } from "../utils/styles.js";
2
-
3
2
  //#region src/styles/fill.ts
4
3
  function fillStyle({ fill, backgroundColor, image, backgroundImage, backgroundPosition, backgroundSize, backgroundRepeat, backgroundAttachment, backgroundOrigin, backgroundClip, background }) {
5
4
  if (background) return { background: parseStyle(background).output || background };
@@ -24,7 +23,7 @@ function fillStyle({ fill, backgroundColor, image, backgroundImage, backgroundPo
24
23
  if (backgroundAttachment) result["background-attachment"] = backgroundAttachment;
25
24
  if (backgroundOrigin) result["background-origin"] = backgroundOrigin;
26
25
  if (backgroundClip) result["background-clip"] = backgroundClip;
27
- if (Object.keys(result).length === 0) return;
26
+ if (Object.keys(result).length === 0) return null;
28
27
  return result;
29
28
  }
30
29
  fillStyle.__lookupStyles = [
@@ -41,12 +40,12 @@ fillStyle.__lookupStyles = [
41
40
  "background"
42
41
  ];
43
42
  function svgFillStyle({ svgFill }) {
44
- if (!svgFill) return;
43
+ if (!svgFill) return null;
45
44
  svgFill = parseStyle(svgFill).groups[0]?.colors[0] || svgFill;
46
45
  return { fill: svgFill };
47
46
  }
48
47
  svgFillStyle.__lookupStyles = ["svgFill"];
49
-
50
48
  //#endregion
51
49
  export { fillStyle, svgFillStyle };
50
+
52
51
  //# sourceMappingURL=fill.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fill.js","names":[],"sources":["../../src/styles/fill.ts"],"sourcesContent":["import { parseStyle } from '../utils/styles';\n\nexport function fillStyle({\n fill,\n backgroundColor,\n image,\n backgroundImage,\n backgroundPosition,\n backgroundSize,\n backgroundRepeat,\n backgroundAttachment,\n backgroundOrigin,\n backgroundClip,\n background,\n}: {\n fill?: string;\n backgroundColor?: string;\n image?: string;\n backgroundImage?: string;\n backgroundPosition?: string;\n backgroundSize?: string;\n backgroundRepeat?: string;\n backgroundAttachment?: string;\n backgroundOrigin?: string;\n backgroundClip?: string;\n background?: string;\n}) {\n // If background is set, it overrides everything\n if (background) {\n const processed = parseStyle(background);\n return { background: processed.output || background };\n }\n\n const result: Record<string, string> = {};\n\n // Priority: backgroundColor > fill\n const colorValue = backgroundColor ?? fill;\n if (colorValue) {\n const parsed = parseStyle(colorValue);\n const firstColor = parsed.groups[0]?.colors[0];\n const secondColor = parsed.groups[0]?.colors[1];\n\n result['background-color'] = firstColor || colorValue;\n\n if (secondColor) {\n result['--tasty-second-fill-color'] = secondColor;\n }\n }\n\n const gradientLayer = result['--tasty-second-fill-color']\n ? 'linear-gradient(var(--tasty-second-fill-color), var(--tasty-second-fill-color))'\n : null;\n\n // Priority: backgroundImage > image\n const imageValue = backgroundImage ?? image;\n if (imageValue) {\n const parsed = parseStyle(imageValue);\n const imgCss = parsed.output || imageValue;\n\n result['background-image'] = gradientLayer\n ? `${imgCss}, ${gradientLayer}`\n : imgCss;\n } else if (gradientLayer) {\n result['background-image'] = gradientLayer;\n }\n\n // Other background properties (pass through with parseStyle for token support)\n if (backgroundPosition) {\n result['background-position'] =\n parseStyle(backgroundPosition).output || backgroundPosition;\n }\n if (backgroundSize) {\n result['background-size'] =\n parseStyle(backgroundSize).output || backgroundSize;\n }\n if (backgroundRepeat) {\n result['background-repeat'] = backgroundRepeat;\n }\n if (backgroundAttachment) {\n result['background-attachment'] = backgroundAttachment;\n }\n if (backgroundOrigin) {\n result['background-origin'] = backgroundOrigin;\n }\n if (backgroundClip) {\n result['background-clip'] = backgroundClip;\n }\n\n if (Object.keys(result).length === 0) return;\n return result;\n}\n\nfillStyle.__lookupStyles = [\n 'fill',\n 'backgroundColor',\n 'image',\n 'backgroundImage',\n 'backgroundPosition',\n 'backgroundSize',\n 'backgroundRepeat',\n 'backgroundAttachment',\n 'backgroundOrigin',\n 'backgroundClip',\n 'background',\n];\n\nexport function svgFillStyle({ svgFill }: { svgFill?: string }) {\n if (!svgFill) return;\n\n const processed = parseStyle(svgFill);\n svgFill = processed.groups[0]?.colors[0] || svgFill;\n\n return { fill: svgFill };\n}\n\nsvgFillStyle.__lookupStyles = ['svgFill'];\n"],"mappings":";;;AAEA,SAAgB,UAAU,EACxB,MACA,iBACA,OACA,iBACA,oBACA,gBACA,kBACA,sBACA,kBACA,gBACA,cAaC;AAED,KAAI,WAEF,QAAO,EAAE,YADS,WAAW,WAAW,CACT,UAAU,YAAY;CAGvD,MAAM,SAAiC,EAAE;CAGzC,MAAM,aAAa,mBAAmB;AACtC,KAAI,YAAY;EACd,MAAM,SAAS,WAAW,WAAW;EACrC,MAAM,aAAa,OAAO,OAAO,IAAI,OAAO;EAC5C,MAAM,cAAc,OAAO,OAAO,IAAI,OAAO;AAE7C,SAAO,sBAAsB,cAAc;AAE3C,MAAI,YACF,QAAO,+BAA+B;;CAI1C,MAAM,gBAAgB,OAAO,+BACzB,oFACA;CAGJ,MAAM,aAAa,mBAAmB;AACtC,KAAI,YAAY;EAEd,MAAM,SADS,WAAW,WAAW,CACf,UAAU;AAEhC,SAAO,sBAAsB,gBACzB,GAAG,OAAO,IAAI,kBACd;YACK,cACT,QAAO,sBAAsB;AAI/B,KAAI,mBACF,QAAO,yBACL,WAAW,mBAAmB,CAAC,UAAU;AAE7C,KAAI,eACF,QAAO,qBACL,WAAW,eAAe,CAAC,UAAU;AAEzC,KAAI,iBACF,QAAO,uBAAuB;AAEhC,KAAI,qBACF,QAAO,2BAA2B;AAEpC,KAAI,iBACF,QAAO,uBAAuB;AAEhC,KAAI,eACF,QAAO,qBAAqB;AAG9B,KAAI,OAAO,KAAK,OAAO,CAAC,WAAW,EAAG;AACtC,QAAO;;AAGT,UAAU,iBAAiB;CACzB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,SAAgB,aAAa,EAAE,WAAiC;AAC9D,KAAI,CAAC,QAAS;AAGd,WADkB,WAAW,QAAQ,CACjB,OAAO,IAAI,OAAO,MAAM;AAE5C,QAAO,EAAE,MAAM,SAAS;;AAG1B,aAAa,iBAAiB,CAAC,UAAU"}
1
+ {"version":3,"file":"fill.js","names":[],"sources":["../../src/styles/fill.ts"],"sourcesContent":["import { parseStyle } from '../utils/styles';\n\nexport function fillStyle({\n fill,\n backgroundColor,\n image,\n backgroundImage,\n backgroundPosition,\n backgroundSize,\n backgroundRepeat,\n backgroundAttachment,\n backgroundOrigin,\n backgroundClip,\n background,\n}: {\n fill?: string;\n backgroundColor?: string;\n image?: string;\n backgroundImage?: string;\n backgroundPosition?: string;\n backgroundSize?: string;\n backgroundRepeat?: string;\n backgroundAttachment?: string;\n backgroundOrigin?: string;\n backgroundClip?: string;\n background?: string;\n}) {\n // If background is set, it overrides everything\n if (background) {\n const processed = parseStyle(background);\n return { background: processed.output || background };\n }\n\n const result: Record<string, string> = {};\n\n // Priority: backgroundColor > fill\n const colorValue = backgroundColor ?? fill;\n if (colorValue) {\n const parsed = parseStyle(colorValue);\n const firstColor = parsed.groups[0]?.colors[0];\n const secondColor = parsed.groups[0]?.colors[1];\n\n result['background-color'] = firstColor || colorValue;\n\n if (secondColor) {\n result['--tasty-second-fill-color'] = secondColor;\n }\n }\n\n const gradientLayer = result['--tasty-second-fill-color']\n ? 'linear-gradient(var(--tasty-second-fill-color), var(--tasty-second-fill-color))'\n : null;\n\n // Priority: backgroundImage > image\n const imageValue = backgroundImage ?? image;\n if (imageValue) {\n const parsed = parseStyle(imageValue);\n const imgCss = parsed.output || imageValue;\n\n result['background-image'] = gradientLayer\n ? `${imgCss}, ${gradientLayer}`\n : imgCss;\n } else if (gradientLayer) {\n result['background-image'] = gradientLayer;\n }\n\n // Other background properties (pass through with parseStyle for token support)\n if (backgroundPosition) {\n result['background-position'] =\n parseStyle(backgroundPosition).output || backgroundPosition;\n }\n if (backgroundSize) {\n result['background-size'] =\n parseStyle(backgroundSize).output || backgroundSize;\n }\n if (backgroundRepeat) {\n result['background-repeat'] = backgroundRepeat;\n }\n if (backgroundAttachment) {\n result['background-attachment'] = backgroundAttachment;\n }\n if (backgroundOrigin) {\n result['background-origin'] = backgroundOrigin;\n }\n if (backgroundClip) {\n result['background-clip'] = backgroundClip;\n }\n\n if (Object.keys(result).length === 0) return null;\n return result;\n}\n\nfillStyle.__lookupStyles = [\n 'fill',\n 'backgroundColor',\n 'image',\n 'backgroundImage',\n 'backgroundPosition',\n 'backgroundSize',\n 'backgroundRepeat',\n 'backgroundAttachment',\n 'backgroundOrigin',\n 'backgroundClip',\n 'background',\n];\n\nexport function svgFillStyle({ svgFill }: { svgFill?: string }) {\n if (!svgFill) return null;\n\n const processed = parseStyle(svgFill);\n svgFill = processed.groups[0]?.colors[0] || svgFill;\n\n return { fill: svgFill };\n}\n\nsvgFillStyle.__lookupStyles = ['svgFill'];\n"],"mappings":";;AAEA,SAAgB,UAAU,EACxB,MACA,iBACA,OACA,iBACA,oBACA,gBACA,kBACA,sBACA,kBACA,gBACA,cAaC;AAED,KAAI,WAEF,QAAO,EAAE,YADS,WAAW,WAAW,CACT,UAAU,YAAY;CAGvD,MAAM,SAAiC,EAAE;CAGzC,MAAM,aAAa,mBAAmB;AACtC,KAAI,YAAY;EACd,MAAM,SAAS,WAAW,WAAW;EACrC,MAAM,aAAa,OAAO,OAAO,IAAI,OAAO;EAC5C,MAAM,cAAc,OAAO,OAAO,IAAI,OAAO;AAE7C,SAAO,sBAAsB,cAAc;AAE3C,MAAI,YACF,QAAO,+BAA+B;;CAI1C,MAAM,gBAAgB,OAAO,+BACzB,oFACA;CAGJ,MAAM,aAAa,mBAAmB;AACtC,KAAI,YAAY;EAEd,MAAM,SADS,WAAW,WAAW,CACf,UAAU;AAEhC,SAAO,sBAAsB,gBACzB,GAAG,OAAO,IAAI,kBACd;YACK,cACT,QAAO,sBAAsB;AAI/B,KAAI,mBACF,QAAO,yBACL,WAAW,mBAAmB,CAAC,UAAU;AAE7C,KAAI,eACF,QAAO,qBACL,WAAW,eAAe,CAAC,UAAU;AAEzC,KAAI,iBACF,QAAO,uBAAuB;AAEhC,KAAI,qBACF,QAAO,2BAA2B;AAEpC,KAAI,iBACF,QAAO,uBAAuB;AAEhC,KAAI,eACF,QAAO,qBAAqB;AAG9B,KAAI,OAAO,KAAK,OAAO,CAAC,WAAW,EAAG,QAAO;AAC7C,QAAO;;AAGT,UAAU,iBAAiB;CACzB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,SAAgB,aAAa,EAAE,WAAiC;AAC9D,KAAI,CAAC,QAAS,QAAO;AAGrB,WADkB,WAAW,QAAQ,CACjB,OAAO,IAAI,OAAO,MAAM;AAE5C,QAAO,EAAE,MAAM,SAAS;;AAG1B,aAAa,iBAAiB,CAAC,UAAU"}
@@ -6,7 +6,7 @@ function flowStyle({ display = "block", flow }) {
6
6
  return style ? { [style]: flow } : null;
7
7
  }
8
8
  flowStyle.__lookupStyles = ["display", "flow"];
9
-
10
9
  //#endregion
11
10
  export { flowStyle };
11
+
12
12
  //# sourceMappingURL=flow.js.map
@@ -22,7 +22,7 @@ declare function gapStyle({
22
22
  [x: string]: string;
23
23
  $: string;
24
24
  gap?: undefined;
25
- } | undefined;
25
+ } | null;
26
26
  declare namespace gapStyle {
27
27
  var __lookupStyles: string[];
28
28
  }
@@ -1,11 +1,12 @@
1
+ import { CSS_WIDE_KEYWORDS } from "../parser/const.js";
1
2
  import { makeEmptyDetails } from "../parser/types.js";
2
3
  import { parseStyle } from "../utils/styles.js";
3
-
4
4
  //#region src/styles/gap.ts
5
5
  function gapStyle({ display = "block", flow, gap }) {
6
6
  if (typeof gap === "number") gap = `${gap}px`;
7
- if (!gap) return;
7
+ if (!gap) return null;
8
8
  if (gap === true) gap = "1x";
9
+ if (CSS_WIDE_KEYWORDS.has(String(gap))) return { gap: String(gap) };
9
10
  const isGrid = display.includes("grid");
10
11
  const isFlex = display.includes("flex");
11
12
  const isWrap = flow ? flow.includes("wrap") && !flow.includes("nowrap") : false;
@@ -31,7 +32,7 @@ gapStyle.__lookupStyles = [
31
32
  "flow",
32
33
  "gap"
33
34
  ];
34
-
35
35
  //#endregion
36
36
  export { gapStyle };
37
+
37
38
  //# sourceMappingURL=gap.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"gap.js","names":[],"sources":["../../src/styles/gap.ts"],"sourcesContent":["import { makeEmptyDetails } from '../parser/types';\nimport { parseStyle } from '../utils/styles';\n\nexport function gapStyle({\n display = 'block',\n flow,\n gap,\n}: {\n display?: string;\n flow?: string;\n gap?: string | number | boolean;\n}) {\n if (typeof gap === 'number') {\n gap = `${gap}px`;\n }\n\n if (!gap) {\n return;\n }\n\n if (gap === true) {\n gap = '1x';\n }\n\n const isGrid = display.includes('grid');\n const isFlex = display.includes('flex');\n const isWrap = flow\n ? flow.includes('wrap') && !flow.includes('nowrap')\n : false;\n\n if (!isGrid && flow == null) {\n flow = isFlex ? 'row' : 'column';\n }\n\n const processed = parseStyle(gap);\n const { values } = processed.groups[0] ?? makeEmptyDetails();\n\n gap = values.join(' ');\n\n if (isGrid || isFlex) {\n return { gap };\n }\n\n const gapDir = flow?.includes('row') ? 'right' : 'bottom';\n\n return isWrap\n ? [\n {\n 'margin-right': `calc(-1 * ${values[1] || values[0]})`,\n 'margin-bottom': `calc(-1 * ${values[0]})`,\n },\n {\n $: '& > *',\n 'margin-right': values[1] || values[0],\n 'margin-bottom': values[0],\n },\n ]\n : {\n $: '& > *:not(:last-child)',\n [`margin-${gapDir}`]: gap,\n };\n}\n\ngapStyle.__lookupStyles = ['display', 'flow', 'gap'];\n"],"mappings":";;;;AAGA,SAAgB,SAAS,EACvB,UAAU,SACV,MACA,OAKC;AACD,KAAI,OAAO,QAAQ,SACjB,OAAM,GAAG,IAAI;AAGf,KAAI,CAAC,IACH;AAGF,KAAI,QAAQ,KACV,OAAM;CAGR,MAAM,SAAS,QAAQ,SAAS,OAAO;CACvC,MAAM,SAAS,QAAQ,SAAS,OAAO;CACvC,MAAM,SAAS,OACX,KAAK,SAAS,OAAO,IAAI,CAAC,KAAK,SAAS,SAAS,GACjD;AAEJ,KAAI,CAAC,UAAU,QAAQ,KACrB,QAAO,SAAS,QAAQ;CAI1B,MAAM,EAAE,WADU,WAAW,IAAI,CACJ,OAAO,MAAM,kBAAkB;AAE5D,OAAM,OAAO,KAAK,IAAI;AAEtB,KAAI,UAAU,OACZ,QAAO,EAAE,KAAK;CAGhB,MAAM,SAAS,MAAM,SAAS,MAAM,GAAG,UAAU;AAEjD,QAAO,SACH,CACE;EACE,gBAAgB,aAAa,OAAO,MAAM,OAAO,GAAG;EACpD,iBAAiB,aAAa,OAAO,GAAG;EACzC,EACD;EACE,GAAG;EACH,gBAAgB,OAAO,MAAM,OAAO;EACpC,iBAAiB,OAAO;EACzB,CACF,GACD;EACE,GAAG;GACF,UAAU,WAAW;EACvB;;AAGP,SAAS,iBAAiB;CAAC;CAAW;CAAQ;CAAM"}
1
+ {"version":3,"file":"gap.js","names":[],"sources":["../../src/styles/gap.ts"],"sourcesContent":["import { CSS_WIDE_KEYWORDS } from '../parser/const';\nimport { makeEmptyDetails } from '../parser/types';\nimport { parseStyle } from '../utils/styles';\n\nexport function gapStyle({\n display = 'block',\n flow,\n gap,\n}: {\n display?: string;\n flow?: string;\n gap?: string | number | boolean;\n}) {\n if (typeof gap === 'number') {\n gap = `${gap}px`;\n }\n\n if (!gap) {\n return null;\n }\n\n if (gap === true) {\n gap = '1x';\n }\n\n if (CSS_WIDE_KEYWORDS.has(String(gap))) {\n return { gap: String(gap) };\n }\n\n const isGrid = display.includes('grid');\n const isFlex = display.includes('flex');\n const isWrap = flow\n ? flow.includes('wrap') && !flow.includes('nowrap')\n : false;\n\n if (!isGrid && flow == null) {\n flow = isFlex ? 'row' : 'column';\n }\n\n const processed = parseStyle(gap);\n const { values } = processed.groups[0] ?? makeEmptyDetails();\n\n gap = values.join(' ');\n\n if (isGrid || isFlex) {\n return { gap };\n }\n\n const gapDir = flow?.includes('row') ? 'right' : 'bottom';\n\n return isWrap\n ? [\n {\n 'margin-right': `calc(-1 * ${values[1] || values[0]})`,\n 'margin-bottom': `calc(-1 * ${values[0]})`,\n },\n {\n $: '& > *',\n 'margin-right': values[1] || values[0],\n 'margin-bottom': values[0],\n },\n ]\n : {\n $: '& > *:not(:last-child)',\n [`margin-${gapDir}`]: gap,\n };\n}\n\ngapStyle.__lookupStyles = ['display', 'flow', 'gap'];\n"],"mappings":";;;;AAIA,SAAgB,SAAS,EACvB,UAAU,SACV,MACA,OAKC;AACD,KAAI,OAAO,QAAQ,SACjB,OAAM,GAAG,IAAI;AAGf,KAAI,CAAC,IACH,QAAO;AAGT,KAAI,QAAQ,KACV,OAAM;AAGR,KAAI,kBAAkB,IAAI,OAAO,IAAI,CAAC,CACpC,QAAO,EAAE,KAAK,OAAO,IAAI,EAAE;CAG7B,MAAM,SAAS,QAAQ,SAAS,OAAO;CACvC,MAAM,SAAS,QAAQ,SAAS,OAAO;CACvC,MAAM,SAAS,OACX,KAAK,SAAS,OAAO,IAAI,CAAC,KAAK,SAAS,SAAS,GACjD;AAEJ,KAAI,CAAC,UAAU,QAAQ,KACrB,QAAO,SAAS,QAAQ;CAI1B,MAAM,EAAE,WADU,WAAW,IAAI,CACJ,OAAO,MAAM,kBAAkB;AAE5D,OAAM,OAAO,KAAK,IAAI;AAEtB,KAAI,UAAU,OACZ,QAAO,EAAE,KAAK;CAGhB,MAAM,SAAS,MAAM,SAAS,MAAM,GAAG,UAAU;AAEjD,QAAO,SACH,CACE;EACE,gBAAgB,aAAa,OAAO,MAAM,OAAO,GAAG;EACpD,iBAAiB,aAAa,OAAO,GAAG;EACzC,EACD;EACE,GAAG;EACH,gBAAgB,OAAO,MAAM,OAAO;EACpC,iBAAiB,OAAO;EACzB,CACF,GACD;EACE,GAAG;GACF,UAAU,WAAW;EACvB;;AAGP,SAAS,iBAAiB;CAAC;CAAW;CAAQ;CAAM"}
@@ -8,7 +8,7 @@ declare function heightStyle({
8
8
  height,
9
9
  minHeight,
10
10
  maxHeight
11
- }: HeightStyleProps): Record<string, string | string[]> | undefined;
11
+ }: HeightStyleProps): Record<string, string | string[]> | null;
12
12
  declare namespace heightStyle {
13
13
  var __lookupStyles: string[];
14
14
  }
@@ -1,5 +1,4 @@
1
1
  import { dimensionStyle } from "./dimension.js";
2
-
3
2
  //#region src/styles/height.ts
4
3
  const dimension = dimensionStyle("height");
5
4
  function heightStyle({ height, minHeight, maxHeight }) {
@@ -14,7 +13,7 @@ heightStyle.__lookupStyles = [
14
13
  "minHeight",
15
14
  "maxHeight"
16
15
  ];
17
-
18
16
  //#endregion
19
17
  export { heightStyle };
18
+
20
19
  //# sourceMappingURL=height.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"height.js","names":[],"sources":["../../src/styles/height.ts"],"sourcesContent":["import { dimensionStyle } from './dimension';\n\nconst dimension = dimensionStyle('height');\n\ninterface HeightStyleProps {\n height?: string | number | boolean;\n minHeight?: string | number | boolean;\n maxHeight?: string | number | boolean;\n}\n\nexport function heightStyle({\n height,\n minHeight,\n maxHeight,\n}: HeightStyleProps) {\n return dimension({ value: height, min: minHeight, max: maxHeight });\n}\n\nheightStyle.__lookupStyles = ['height', 'minHeight', 'maxHeight'];\n"],"mappings":";;;AAEA,MAAM,YAAY,eAAe,SAAS;AAQ1C,SAAgB,YAAY,EAC1B,QACA,WACA,aACmB;AACnB,QAAO,UAAU;EAAE,OAAO;EAAQ,KAAK;EAAW,KAAK;EAAW,CAAC;;AAGrE,YAAY,iBAAiB;CAAC;CAAU;CAAa;CAAY"}
1
+ {"version":3,"file":"height.js","names":[],"sources":["../../src/styles/height.ts"],"sourcesContent":["import { dimensionStyle } from './dimension';\n\nconst dimension = dimensionStyle('height');\n\ninterface HeightStyleProps {\n height?: string | number | boolean;\n minHeight?: string | number | boolean;\n maxHeight?: string | number | boolean;\n}\n\nexport function heightStyle({\n height,\n minHeight,\n maxHeight,\n}: HeightStyleProps) {\n return dimension({ value: height, min: minHeight, max: maxHeight });\n}\n\nheightStyle.__lookupStyles = ['height', 'minHeight', 'maxHeight'];\n"],"mappings":";;AAEA,MAAM,YAAY,eAAe,SAAS;AAQ1C,SAAgB,YAAY,EAC1B,QACA,WACA,aACmB;AACnB,QAAO,UAAU;EAAE,OAAO;EAAQ,KAAK;EAAW,KAAK;EAAW,CAAC;;AAGrE,YAAY,iBAAiB;CAAC;CAAU;CAAa;CAAY"}
@@ -1,2 +1 @@
1
- import "../index.js";
2
1
  import { styleHandlers } from "./predefined.js";
@@ -1,9 +1,8 @@
1
- import { convertColorChainToComponentChain, createStyle } from "./createStyle.js";
2
- import { normalizeHandlerDefinition, predefine, registerHandler, resetHandlers, styleHandlers } from "./predefined.js";
3
-
1
+ import "./createStyle.js";
2
+ import { predefine } from "./predefined.js";
4
3
  //#region src/styles/index.ts
5
4
  const { STYLE_HANDLER_MAP, defineCustomStyle, defineStyleAlias } = predefine();
6
-
7
5
  //#endregion
8
6
  export { STYLE_HANDLER_MAP };
7
+
9
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/styles/index.ts"],"sourcesContent":["import { predefine, styleHandlers } from './predefined';\n\nconst { STYLE_HANDLER_MAP, defineCustomStyle, defineStyleAlias } = predefine();\n\nexport {\n STYLE_HANDLER_MAP,\n defineCustomStyle,\n defineStyleAlias,\n styleHandlers,\n};\nexport * from './createStyle';\nexport {\n normalizeHandlerDefinition,\n registerHandler,\n resetHandlers,\n validateHandlerResult,\n} from './predefined';\n"],"mappings":";;;;AAEA,MAAM,EAAE,mBAAmB,mBAAmB,qBAAqB,WAAW"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/styles/index.ts"],"sourcesContent":["import { predefine, styleHandlers } from './predefined';\n\nconst { STYLE_HANDLER_MAP, defineCustomStyle, defineStyleAlias } = predefine();\n\nexport {\n STYLE_HANDLER_MAP,\n defineCustomStyle,\n defineStyleAlias,\n styleHandlers,\n};\nexport * from './createStyle';\nexport {\n normalizeHandlerDefinition,\n registerHandler,\n resetHandlers,\n validateHandlerResult,\n} from './predefined';\n"],"mappings":";;;AAEA,MAAM,EAAE,mBAAmB,mBAAmB,qBAAqB,WAAW"}
@@ -1,30 +1,4 @@
1
1
  //#region src/styles/inset.d.ts
2
- /**
3
- * Inset style handler.
4
- *
5
- * IMPORTANT: This handler uses individual CSS properties (top, right, bottom, left)
6
- * when only individual direction props are specified. This allows CSS cascade to work
7
- * correctly when modifiers override only some directions.
8
- *
9
- * Example problem with using `inset` shorthand everywhere:
10
- * styles: {
11
- * top: { '': 0, 'side=bottom': 'initial' },
12
- * right: { '': 0, 'side=left': 'initial' },
13
- * bottom: { '': 0, 'side=top': 'initial' },
14
- * left: { '': 0, 'side=right': 'initial' },
15
- * }
16
- *
17
- * If we output `inset` for both cases:
18
- * - Default: inset: 0 0 0 0
19
- * - side=bottom: inset: initial auto auto auto ← WRONG! Overrides all 4 directions
20
- *
21
- * With individual properties:
22
- * - Default: top: 0; right: 0; bottom: 0; left: 0
23
- * - side=bottom: top: initial ← CORRECT! Only overrides top
24
- *
25
- * The `inset` shorthand is only used when the base `inset` prop is specified
26
- * OR when `insetBlock`/`insetInline` are used (which imply setting pairs).
27
- */
28
2
  declare function insetStyle({
29
3
  inset,
30
4
  insetBlock,
@@ -41,9 +15,7 @@ declare function insetStyle({
41
15
  right?: string | number | boolean;
42
16
  bottom?: string | number | boolean;
43
17
  left?: string | number | boolean;
44
- }): Record<string, string> | {
45
- inset: string;
46
- };
18
+ }): Record<string, string> | null;
47
19
  declare namespace insetStyle {
48
20
  var __lookupStyles: string[];
49
21
  }
@@ -1,139 +1,23 @@
1
- import { DIRECTIONS, filterMods, parseStyle } from "../utils/styles.js";
2
-
1
+ import { processDirectionalStyle } from "./directional.js";
3
2
  //#region src/styles/inset.ts
4
- /**
5
- * Parse an inset value and return the first processed value
6
- */
7
- function parseInsetValue(value) {
8
- if (typeof value === "number") return `${value}px`;
9
- if (!value) return null;
10
- if (value === true) value = "0";
11
- const { values } = parseStyle(value).groups[0] ?? { values: [] };
12
- return values[0] || "0";
13
- }
14
- /**
15
- * Extract values and directions from a single parsed group.
16
- */
17
- function extractGroupData(group) {
18
- const { values = [], mods = [] } = group;
19
- return {
20
- values: values.length ? values : ["0"],
21
- directions: filterMods(mods, DIRECTIONS)
22
- };
23
- }
24
- /**
25
- * Apply a single group's values and directions onto a direction map.
26
- */
27
- function applyGroup(dirs, values, directions) {
28
- if (!values.length) return;
29
- if (directions.length === 0) {
30
- dirs.top = values[0];
31
- dirs.right = values[1] || values[0];
32
- dirs.bottom = values[2] || values[0];
33
- dirs.left = values[3] || values[1] || values[0];
34
- } else directions.forEach((dir, i) => {
35
- dirs[dir] = values[i] ?? values[0];
36
- });
37
- }
38
- /**
39
- * Optimize inset output shorthand.
40
- */
41
- function optimizeInset(dirs) {
42
- const { top, right, bottom, left } = dirs;
43
- if (top === right && right === bottom && bottom === left) return { inset: top };
44
- if (top === bottom && left === right) return { inset: `${top} ${left}` };
45
- return { inset: `${top} ${right} ${bottom} ${left}` };
46
- }
47
- /**
48
- * Inset style handler.
49
- *
50
- * IMPORTANT: This handler uses individual CSS properties (top, right, bottom, left)
51
- * when only individual direction props are specified. This allows CSS cascade to work
52
- * correctly when modifiers override only some directions.
53
- *
54
- * Example problem with using `inset` shorthand everywhere:
55
- * styles: {
56
- * top: { '': 0, 'side=bottom': 'initial' },
57
- * right: { '': 0, 'side=left': 'initial' },
58
- * bottom: { '': 0, 'side=top': 'initial' },
59
- * left: { '': 0, 'side=right': 'initial' },
60
- * }
61
- *
62
- * If we output `inset` for both cases:
63
- * - Default: inset: 0 0 0 0
64
- * - side=bottom: inset: initial auto auto auto ← WRONG! Overrides all 4 directions
65
- *
66
- * With individual properties:
67
- * - Default: top: 0; right: 0; bottom: 0; left: 0
68
- * - side=bottom: top: initial ← CORRECT! Only overrides top
69
- *
70
- * The `inset` shorthand is only used when the base `inset` prop is specified
71
- * OR when `insetBlock`/`insetInline` are used (which imply setting pairs).
72
- */
3
+ const INSET_CONFIG = {
4
+ property: "inset",
5
+ defaultValue: "0",
6
+ trueValue: "0",
7
+ defaultInit: "auto",
8
+ individualOnly: true,
9
+ directionProperty: (dir) => dir
10
+ };
73
11
  function insetStyle({ inset, insetBlock, insetInline, top, right, bottom, left }) {
74
- if (inset == null && insetBlock == null && insetInline == null && top == null && right == null && bottom == null && left == null) return {};
75
- if (inset == null && insetBlock == null && insetInline == null) {
76
- const result = {};
77
- if (top != null) {
78
- const val = parseInsetValue(top);
79
- if (val) result["top"] = val;
80
- }
81
- if (right != null) {
82
- const val = parseInsetValue(right);
83
- if (val) result["right"] = val;
84
- }
85
- if (bottom != null) {
86
- const val = parseInsetValue(bottom);
87
- if (val) result["bottom"] = val;
88
- }
89
- if (left != null) {
90
- const val = parseInsetValue(left);
91
- if (val) result["left"] = val;
92
- }
93
- return result;
94
- }
95
- const dirs = {
96
- top: "auto",
97
- right: "auto",
98
- bottom: "auto",
99
- left: "auto"
100
- };
101
- if (inset != null) {
102
- if (typeof inset === "number") dirs.top = dirs.right = dirs.bottom = dirs.left = `${inset}px`;
103
- else if (inset === true) inset = "0";
104
- if (typeof inset === "string" && inset) {
105
- const groups = parseStyle(inset).groups ?? [];
106
- for (const group of groups) {
107
- const { values, directions } = extractGroupData(group);
108
- applyGroup(dirs, values, directions);
109
- }
110
- }
111
- }
112
- if (insetBlock != null) {
113
- const val = parseInsetValue(insetBlock);
114
- if (val) dirs.top = dirs.bottom = val;
115
- }
116
- if (insetInline != null) {
117
- const val = parseInsetValue(insetInline);
118
- if (val) dirs.left = dirs.right = val;
119
- }
120
- if (top != null) {
121
- const val = parseInsetValue(top);
122
- if (val) dirs.top = val;
123
- }
124
- if (right != null) {
125
- const val = parseInsetValue(right);
126
- if (val) dirs.right = val;
127
- }
128
- if (bottom != null) {
129
- const val = parseInsetValue(bottom);
130
- if (val) dirs.bottom = val;
131
- }
132
- if (left != null) {
133
- const val = parseInsetValue(left);
134
- if (val) dirs.left = val;
135
- }
136
- return optimizeInset(dirs);
12
+ return processDirectionalStyle(INSET_CONFIG, {
13
+ main: inset,
14
+ block: insetBlock,
15
+ inline: insetInline,
16
+ top,
17
+ right,
18
+ bottom,
19
+ left
20
+ });
137
21
  }
138
22
  insetStyle.__lookupStyles = [
139
23
  "inset",
@@ -144,7 +28,7 @@ insetStyle.__lookupStyles = [
144
28
  "bottom",
145
29
  "left"
146
30
  ];
147
-
148
31
  //#endregion
149
32
  export { insetStyle };
33
+
150
34
  //# sourceMappingURL=inset.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"inset.js","names":[],"sources":["../../src/styles/inset.ts"],"sourcesContent":["import type { StyleDetails } from '../parser/types';\nimport { DIRECTIONS, filterMods, parseStyle } from '../utils/styles';\n\ntype Direction = (typeof DIRECTIONS)[number];\n\n/**\n * Parse an inset value and return the first processed value\n */\nfunction parseInsetValue(value: string | number | boolean): string | null {\n if (typeof value === 'number') return `${value}px`;\n if (!value) return null;\n if (value === true) value = '0';\n\n const { values } = parseStyle(value).groups[0] ?? { values: [] };\n\n return values[0] || '0';\n}\n\n/**\n * Extract values and directions from a single parsed group.\n */\nfunction extractGroupData(group: StyleDetails): {\n values: string[];\n directions: Direction[];\n} {\n const { values = [], mods = [] } = group;\n return {\n values: values.length ? values : ['0'],\n directions: filterMods(mods, DIRECTIONS) as Direction[],\n };\n}\n\n/**\n * Apply a single group's values and directions onto a direction map.\n */\nfunction applyGroup(\n dirs: Record<Direction, string>,\n values: string[],\n directions: Direction[],\n): void {\n if (!values.length) return;\n\n if (directions.length === 0) {\n dirs.top = values[0];\n dirs.right = values[1] || values[0];\n dirs.bottom = values[2] || values[0];\n dirs.left = values[3] || values[1] || values[0];\n } else {\n directions.forEach((dir, i) => {\n dirs[dir] = values[i] ?? values[0];\n });\n }\n}\n\n/**\n * Optimize inset output shorthand.\n */\nfunction optimizeInset(dirs: Record<Direction, string>): { inset: string } {\n const { top, right, bottom, left } = dirs;\n if (top === right && right === bottom && bottom === left) {\n return { inset: top };\n }\n if (top === bottom && left === right) {\n return { inset: `${top} ${left}` };\n }\n return { inset: `${top} ${right} ${bottom} ${left}` };\n}\n\n/**\n * Inset style handler.\n *\n * IMPORTANT: This handler uses individual CSS properties (top, right, bottom, left)\n * when only individual direction props are specified. This allows CSS cascade to work\n * correctly when modifiers override only some directions.\n *\n * Example problem with using `inset` shorthand everywhere:\n * styles: {\n * top: { '': 0, 'side=bottom': 'initial' },\n * right: { '': 0, 'side=left': 'initial' },\n * bottom: { '': 0, 'side=top': 'initial' },\n * left: { '': 0, 'side=right': 'initial' },\n * }\n *\n * If we output `inset` for both cases:\n * - Default: inset: 0 0 0 0\n * - side=bottom: inset: initial auto auto auto ← WRONG! Overrides all 4 directions\n *\n * With individual properties:\n * - Default: top: 0; right: 0; bottom: 0; left: 0\n * - side=bottom: top: initial ← CORRECT! Only overrides top\n *\n * The `inset` shorthand is only used when the base `inset` prop is specified\n * OR when `insetBlock`/`insetInline` are used (which imply setting pairs).\n */\nexport function insetStyle({\n inset,\n insetBlock,\n insetInline,\n top,\n right,\n bottom,\n left,\n}: {\n inset?: string | number | boolean;\n insetBlock?: string | number | boolean;\n insetInline?: string | number | boolean;\n top?: string | number | boolean;\n right?: string | number | boolean;\n bottom?: string | number | boolean;\n left?: string | number | boolean;\n}) {\n if (\n inset == null &&\n insetBlock == null &&\n insetInline == null &&\n top == null &&\n right == null &&\n bottom == null &&\n left == null\n ) {\n return {};\n }\n\n // When only individual direction props are used (no inset, insetBlock, insetInline),\n // output individual CSS properties to allow proper CSS cascade with modifiers\n const onlyIndividualProps =\n inset == null && insetBlock == null && insetInline == null;\n\n if (onlyIndividualProps) {\n const result: Record<string, string> = {};\n\n if (top != null) {\n const val = parseInsetValue(top);\n if (val) result['top'] = val;\n }\n if (right != null) {\n const val = parseInsetValue(right);\n if (val) result['right'] = val;\n }\n if (bottom != null) {\n const val = parseInsetValue(bottom);\n if (val) result['bottom'] = val;\n }\n if (left != null) {\n const val = parseInsetValue(left);\n if (val) result['left'] = val;\n }\n\n return result;\n }\n\n const dirs: Record<Direction, string> = {\n top: 'auto',\n right: 'auto',\n bottom: 'auto',\n left: 'auto',\n };\n\n // Priority 1 (lowest): inset\n if (inset != null) {\n if (typeof inset === 'number') {\n const v = `${inset}px`;\n dirs.top = dirs.right = dirs.bottom = dirs.left = v;\n } else if (inset === true) {\n inset = '0';\n }\n\n if (typeof inset === 'string' && inset) {\n const processed = parseStyle(inset);\n const groups = processed.groups ?? [];\n\n for (const group of groups) {\n const { values, directions } = extractGroupData(group);\n applyGroup(dirs, values, directions);\n }\n }\n }\n\n // Priority 2 (medium): insetBlock/insetInline\n if (insetBlock != null) {\n const val = parseInsetValue(insetBlock);\n if (val) dirs.top = dirs.bottom = val;\n }\n if (insetInline != null) {\n const val = parseInsetValue(insetInline);\n if (val) dirs.left = dirs.right = val;\n }\n\n // Priority 3 (highest): individual directions\n if (top != null) {\n const val = parseInsetValue(top);\n if (val) dirs.top = val;\n }\n if (right != null) {\n const val = parseInsetValue(right);\n if (val) dirs.right = val;\n }\n if (bottom != null) {\n const val = parseInsetValue(bottom);\n if (val) dirs.bottom = val;\n }\n if (left != null) {\n const val = parseInsetValue(left);\n if (val) dirs.left = val;\n }\n\n return optimizeInset(dirs);\n}\n\ninsetStyle.__lookupStyles = [\n 'inset',\n 'insetBlock',\n 'insetInline',\n 'top',\n 'right',\n 'bottom',\n 'left',\n];\n"],"mappings":";;;;;;AAQA,SAAS,gBAAgB,OAAiD;AACxE,KAAI,OAAO,UAAU,SAAU,QAAO,GAAG,MAAM;AAC/C,KAAI,CAAC,MAAO,QAAO;AACnB,KAAI,UAAU,KAAM,SAAQ;CAE5B,MAAM,EAAE,WAAW,WAAW,MAAM,CAAC,OAAO,MAAM,EAAE,QAAQ,EAAE,EAAE;AAEhE,QAAO,OAAO,MAAM;;;;;AAMtB,SAAS,iBAAiB,OAGxB;CACA,MAAM,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,KAAK;AACnC,QAAO;EACL,QAAQ,OAAO,SAAS,SAAS,CAAC,IAAI;EACtC,YAAY,WAAW,MAAM,WAAW;EACzC;;;;;AAMH,SAAS,WACP,MACA,QACA,YACM;AACN,KAAI,CAAC,OAAO,OAAQ;AAEpB,KAAI,WAAW,WAAW,GAAG;AAC3B,OAAK,MAAM,OAAO;AAClB,OAAK,QAAQ,OAAO,MAAM,OAAO;AACjC,OAAK,SAAS,OAAO,MAAM,OAAO;AAClC,OAAK,OAAO,OAAO,MAAM,OAAO,MAAM,OAAO;OAE7C,YAAW,SAAS,KAAK,MAAM;AAC7B,OAAK,OAAO,OAAO,MAAM,OAAO;GAChC;;;;;AAON,SAAS,cAAc,MAAoD;CACzE,MAAM,EAAE,KAAK,OAAO,QAAQ,SAAS;AACrC,KAAI,QAAQ,SAAS,UAAU,UAAU,WAAW,KAClD,QAAO,EAAE,OAAO,KAAK;AAEvB,KAAI,QAAQ,UAAU,SAAS,MAC7B,QAAO,EAAE,OAAO,GAAG,IAAI,GAAG,QAAQ;AAEpC,QAAO,EAAE,OAAO,GAAG,IAAI,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BvD,SAAgB,WAAW,EACzB,OACA,YACA,aACA,KACA,OACA,QACA,QASC;AACD,KACE,SAAS,QACT,cAAc,QACd,eAAe,QACf,OAAO,QACP,SAAS,QACT,UAAU,QACV,QAAQ,KAER,QAAO,EAAE;AAQX,KAFE,SAAS,QAAQ,cAAc,QAAQ,eAAe,MAE/B;EACvB,MAAM,SAAiC,EAAE;AAEzC,MAAI,OAAO,MAAM;GACf,MAAM,MAAM,gBAAgB,IAAI;AAChC,OAAI,IAAK,QAAO,SAAS;;AAE3B,MAAI,SAAS,MAAM;GACjB,MAAM,MAAM,gBAAgB,MAAM;AAClC,OAAI,IAAK,QAAO,WAAW;;AAE7B,MAAI,UAAU,MAAM;GAClB,MAAM,MAAM,gBAAgB,OAAO;AACnC,OAAI,IAAK,QAAO,YAAY;;AAE9B,MAAI,QAAQ,MAAM;GAChB,MAAM,MAAM,gBAAgB,KAAK;AACjC,OAAI,IAAK,QAAO,UAAU;;AAG5B,SAAO;;CAGT,MAAM,OAAkC;EACtC,KAAK;EACL,OAAO;EACP,QAAQ;EACR,MAAM;EACP;AAGD,KAAI,SAAS,MAAM;AACjB,MAAI,OAAO,UAAU,SAEnB,MAAK,MAAM,KAAK,QAAQ,KAAK,SAAS,KAAK,OADjC,GAAG,MAAM;WAEV,UAAU,KACnB,SAAQ;AAGV,MAAI,OAAO,UAAU,YAAY,OAAO;GAEtC,MAAM,SADY,WAAW,MAAM,CACV,UAAU,EAAE;AAErC,QAAK,MAAM,SAAS,QAAQ;IAC1B,MAAM,EAAE,QAAQ,eAAe,iBAAiB,MAAM;AACtD,eAAW,MAAM,QAAQ,WAAW;;;;AAM1C,KAAI,cAAc,MAAM;EACtB,MAAM,MAAM,gBAAgB,WAAW;AACvC,MAAI,IAAK,MAAK,MAAM,KAAK,SAAS;;AAEpC,KAAI,eAAe,MAAM;EACvB,MAAM,MAAM,gBAAgB,YAAY;AACxC,MAAI,IAAK,MAAK,OAAO,KAAK,QAAQ;;AAIpC,KAAI,OAAO,MAAM;EACf,MAAM,MAAM,gBAAgB,IAAI;AAChC,MAAI,IAAK,MAAK,MAAM;;AAEtB,KAAI,SAAS,MAAM;EACjB,MAAM,MAAM,gBAAgB,MAAM;AAClC,MAAI,IAAK,MAAK,QAAQ;;AAExB,KAAI,UAAU,MAAM;EAClB,MAAM,MAAM,gBAAgB,OAAO;AACnC,MAAI,IAAK,MAAK,SAAS;;AAEzB,KAAI,QAAQ,MAAM;EAChB,MAAM,MAAM,gBAAgB,KAAK;AACjC,MAAI,IAAK,MAAK,OAAO;;AAGvB,QAAO,cAAc,KAAK;;AAG5B,WAAW,iBAAiB;CAC1B;CACA;CACA;CACA;CACA;CACA;CACA;CACD"}
1
+ {"version":3,"file":"inset.js","names":[],"sources":["../../src/styles/inset.ts"],"sourcesContent":["import { type DirectionalConfig, processDirectionalStyle } from './directional';\n\nconst INSET_CONFIG: DirectionalConfig = {\n property: 'inset',\n defaultValue: '0',\n trueValue: '0',\n defaultInit: 'auto',\n individualOnly: true,\n directionProperty: (dir) => dir,\n};\n\nexport function insetStyle({\n inset,\n insetBlock,\n insetInline,\n top,\n right,\n bottom,\n left,\n}: {\n inset?: string | number | boolean;\n insetBlock?: string | number | boolean;\n insetInline?: string | number | boolean;\n top?: string | number | boolean;\n right?: string | number | boolean;\n bottom?: string | number | boolean;\n left?: string | number | boolean;\n}) {\n return processDirectionalStyle(INSET_CONFIG, {\n main: inset,\n block: insetBlock,\n inline: insetInline,\n top,\n right,\n bottom,\n left,\n });\n}\n\ninsetStyle.__lookupStyles = [\n 'inset',\n 'insetBlock',\n 'insetInline',\n 'top',\n 'right',\n 'bottom',\n 'left',\n];\n"],"mappings":";;AAEA,MAAM,eAAkC;CACtC,UAAU;CACV,cAAc;CACd,WAAW;CACX,aAAa;CACb,gBAAgB;CAChB,oBAAoB,QAAQ;CAC7B;AAED,SAAgB,WAAW,EACzB,OACA,YACA,aACA,KACA,OACA,QACA,QASC;AACD,QAAO,wBAAwB,cAAc;EAC3C,MAAM;EACN,OAAO;EACP,QAAQ;EACR;EACA;EACA;EACA;EACD,CAAC;;AAGJ,WAAW,iBAAiB;CAC1B;CACA;CACA;CACA;CACA;CACA;CACA;CACD"}