@tenphi/tasty 0.0.0-snapshot.08a6610

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 (288) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +666 -0
  3. package/dist/_virtual/_rolldown/runtime.js +8 -0
  4. package/dist/chunks/cacheKey.js +70 -0
  5. package/dist/chunks/cacheKey.js.map +1 -0
  6. package/dist/chunks/definitions.d.ts +37 -0
  7. package/dist/chunks/definitions.js +259 -0
  8. package/dist/chunks/definitions.js.map +1 -0
  9. package/dist/chunks/renderChunk.js +61 -0
  10. package/dist/chunks/renderChunk.js.map +1 -0
  11. package/dist/config.d.ts +311 -0
  12. package/dist/config.js +458 -0
  13. package/dist/config.js.map +1 -0
  14. package/dist/core/index.d.ts +32 -0
  15. package/dist/core/index.js +26 -0
  16. package/dist/debug.d.ts +204 -0
  17. package/dist/debug.js +733 -0
  18. package/dist/debug.js.map +1 -0
  19. package/dist/hooks/useGlobalStyles.d.ts +30 -0
  20. package/dist/hooks/useGlobalStyles.js +83 -0
  21. package/dist/hooks/useGlobalStyles.js.map +1 -0
  22. package/dist/hooks/useKeyframes.d.ts +56 -0
  23. package/dist/hooks/useKeyframes.js +69 -0
  24. package/dist/hooks/useKeyframes.js.map +1 -0
  25. package/dist/hooks/useProperty.d.ts +79 -0
  26. package/dist/hooks/useProperty.js +114 -0
  27. package/dist/hooks/useProperty.js.map +1 -0
  28. package/dist/hooks/useRawCSS.d.ts +53 -0
  29. package/dist/hooks/useRawCSS.js +40 -0
  30. package/dist/hooks/useRawCSS.js.map +1 -0
  31. package/dist/hooks/useStyles.d.ts +45 -0
  32. package/dist/hooks/useStyles.js +248 -0
  33. package/dist/hooks/useStyles.js.map +1 -0
  34. package/dist/index.d.ts +47 -0
  35. package/dist/index.js +33 -0
  36. package/dist/injector/index.d.ts +165 -0
  37. package/dist/injector/index.js +162 -0
  38. package/dist/injector/index.js.map +1 -0
  39. package/dist/injector/injector.d.ts +148 -0
  40. package/dist/injector/injector.js +430 -0
  41. package/dist/injector/injector.js.map +1 -0
  42. package/dist/injector/sheet-manager.d.ts +136 -0
  43. package/dist/injector/sheet-manager.js +729 -0
  44. package/dist/injector/sheet-manager.js.map +1 -0
  45. package/dist/injector/types.d.ts +144 -0
  46. package/dist/keyframes/index.js +206 -0
  47. package/dist/keyframes/index.js.map +1 -0
  48. package/dist/parser/classify.js +319 -0
  49. package/dist/parser/classify.js.map +1 -0
  50. package/dist/parser/const.js +33 -0
  51. package/dist/parser/const.js.map +1 -0
  52. package/dist/parser/lru.js +109 -0
  53. package/dist/parser/lru.js.map +1 -0
  54. package/dist/parser/parser.d.ts +25 -0
  55. package/dist/parser/parser.js +116 -0
  56. package/dist/parser/parser.js.map +1 -0
  57. package/dist/parser/tokenizer.js +69 -0
  58. package/dist/parser/tokenizer.js.map +1 -0
  59. package/dist/parser/types.d.ts +51 -0
  60. package/dist/parser/types.js +46 -0
  61. package/dist/parser/types.js.map +1 -0
  62. package/dist/pipeline/conditions.d.ts +134 -0
  63. package/dist/pipeline/conditions.js +406 -0
  64. package/dist/pipeline/conditions.js.map +1 -0
  65. package/dist/pipeline/exclusive.js +231 -0
  66. package/dist/pipeline/exclusive.js.map +1 -0
  67. package/dist/pipeline/index.d.ts +53 -0
  68. package/dist/pipeline/index.js +660 -0
  69. package/dist/pipeline/index.js.map +1 -0
  70. package/dist/pipeline/materialize.js +856 -0
  71. package/dist/pipeline/materialize.js.map +1 -0
  72. package/dist/pipeline/parseStateKey.d.ts +15 -0
  73. package/dist/pipeline/parseStateKey.js +451 -0
  74. package/dist/pipeline/parseStateKey.js.map +1 -0
  75. package/dist/pipeline/simplify.js +516 -0
  76. package/dist/pipeline/simplify.js.map +1 -0
  77. package/dist/pipeline/warnings.js +18 -0
  78. package/dist/pipeline/warnings.js.map +1 -0
  79. package/dist/plugins/okhsl-plugin.d.ts +35 -0
  80. package/dist/plugins/okhsl-plugin.js +371 -0
  81. package/dist/plugins/okhsl-plugin.js.map +1 -0
  82. package/dist/plugins/types.d.ts +76 -0
  83. package/dist/properties/index.js +236 -0
  84. package/dist/properties/index.js.map +1 -0
  85. package/dist/properties/property-type-resolver.d.ts +24 -0
  86. package/dist/properties/property-type-resolver.js +91 -0
  87. package/dist/properties/property-type-resolver.js.map +1 -0
  88. package/dist/ssr/astro.d.ts +29 -0
  89. package/dist/ssr/astro.js +65 -0
  90. package/dist/ssr/astro.js.map +1 -0
  91. package/dist/ssr/async-storage.d.ts +17 -0
  92. package/dist/ssr/async-storage.js +35 -0
  93. package/dist/ssr/async-storage.js.map +1 -0
  94. package/dist/ssr/collect-auto-properties.js +40 -0
  95. package/dist/ssr/collect-auto-properties.js.map +1 -0
  96. package/dist/ssr/collector.d.ts +85 -0
  97. package/dist/ssr/collector.js +183 -0
  98. package/dist/ssr/collector.js.map +1 -0
  99. package/dist/ssr/context.d.ts +8 -0
  100. package/dist/ssr/context.js +14 -0
  101. package/dist/ssr/context.js.map +1 -0
  102. package/dist/ssr/format-global-rules.js +22 -0
  103. package/dist/ssr/format-global-rules.js.map +1 -0
  104. package/dist/ssr/format-keyframes.js +70 -0
  105. package/dist/ssr/format-keyframes.js.map +1 -0
  106. package/dist/ssr/format-property.js +48 -0
  107. package/dist/ssr/format-property.js.map +1 -0
  108. package/dist/ssr/format-rules.js +70 -0
  109. package/dist/ssr/format-rules.js.map +1 -0
  110. package/dist/ssr/hydrate.d.ts +22 -0
  111. package/dist/ssr/hydrate.js +50 -0
  112. package/dist/ssr/hydrate.js.map +1 -0
  113. package/dist/ssr/index.d.ts +5 -0
  114. package/dist/ssr/index.js +12 -0
  115. package/dist/ssr/index.js.map +1 -0
  116. package/dist/ssr/next.d.ts +45 -0
  117. package/dist/ssr/next.js +71 -0
  118. package/dist/ssr/next.js.map +1 -0
  119. package/dist/ssr/ssr-collector-ref.js +12 -0
  120. package/dist/ssr/ssr-collector-ref.js.map +1 -0
  121. package/dist/states/index.d.ts +49 -0
  122. package/dist/states/index.js +416 -0
  123. package/dist/states/index.js.map +1 -0
  124. package/dist/static/index.d.ts +5 -0
  125. package/dist/static/index.js +5 -0
  126. package/dist/static/tastyStatic.d.ts +46 -0
  127. package/dist/static/tastyStatic.js +31 -0
  128. package/dist/static/tastyStatic.js.map +1 -0
  129. package/dist/static/types.d.ts +49 -0
  130. package/dist/static/types.js +24 -0
  131. package/dist/static/types.js.map +1 -0
  132. package/dist/styles/align.d.ts +15 -0
  133. package/dist/styles/align.js +14 -0
  134. package/dist/styles/align.js.map +1 -0
  135. package/dist/styles/border.d.ts +25 -0
  136. package/dist/styles/border.js +114 -0
  137. package/dist/styles/border.js.map +1 -0
  138. package/dist/styles/color.d.ts +14 -0
  139. package/dist/styles/color.js +23 -0
  140. package/dist/styles/color.js.map +1 -0
  141. package/dist/styles/createStyle.js +77 -0
  142. package/dist/styles/createStyle.js.map +1 -0
  143. package/dist/styles/dimension.js +97 -0
  144. package/dist/styles/dimension.js.map +1 -0
  145. package/dist/styles/display.d.ts +37 -0
  146. package/dist/styles/display.js +67 -0
  147. package/dist/styles/display.js.map +1 -0
  148. package/dist/styles/fade.d.ts +15 -0
  149. package/dist/styles/fade.js +58 -0
  150. package/dist/styles/fade.js.map +1 -0
  151. package/dist/styles/fill.d.ts +42 -0
  152. package/dist/styles/fill.js +52 -0
  153. package/dist/styles/fill.js.map +1 -0
  154. package/dist/styles/flow.d.ts +16 -0
  155. package/dist/styles/flow.js +12 -0
  156. package/dist/styles/flow.js.map +1 -0
  157. package/dist/styles/gap.d.ts +31 -0
  158. package/dist/styles/gap.js +37 -0
  159. package/dist/styles/gap.js.map +1 -0
  160. package/dist/styles/height.d.ts +17 -0
  161. package/dist/styles/height.js +20 -0
  162. package/dist/styles/height.js.map +1 -0
  163. package/dist/styles/index.d.ts +2 -0
  164. package/dist/styles/index.js +9 -0
  165. package/dist/styles/index.js.map +1 -0
  166. package/dist/styles/inset.d.ts +52 -0
  167. package/dist/styles/inset.js +150 -0
  168. package/dist/styles/inset.js.map +1 -0
  169. package/dist/styles/justify.d.ts +15 -0
  170. package/dist/styles/justify.js +14 -0
  171. package/dist/styles/justify.js.map +1 -0
  172. package/dist/styles/list.d.ts +16 -0
  173. package/dist/styles/list.js +98 -0
  174. package/dist/styles/list.js.map +1 -0
  175. package/dist/styles/margin.d.ts +24 -0
  176. package/dist/styles/margin.js +104 -0
  177. package/dist/styles/margin.js.map +1 -0
  178. package/dist/styles/outline.d.ts +29 -0
  179. package/dist/styles/outline.js +65 -0
  180. package/dist/styles/outline.js.map +1 -0
  181. package/dist/styles/padding.d.ts +24 -0
  182. package/dist/styles/padding.js +104 -0
  183. package/dist/styles/padding.js.map +1 -0
  184. package/dist/styles/predefined.d.ts +71 -0
  185. package/dist/styles/predefined.js +238 -0
  186. package/dist/styles/predefined.js.map +1 -0
  187. package/dist/styles/preset.d.ts +47 -0
  188. package/dist/styles/preset.js +126 -0
  189. package/dist/styles/preset.js.map +1 -0
  190. package/dist/styles/radius.d.ts +14 -0
  191. package/dist/styles/radius.js +51 -0
  192. package/dist/styles/radius.js.map +1 -0
  193. package/dist/styles/scrollbar.d.ts +25 -0
  194. package/dist/styles/scrollbar.js +48 -0
  195. package/dist/styles/scrollbar.js.map +1 -0
  196. package/dist/styles/shadow.d.ts +14 -0
  197. package/dist/styles/shadow.js +24 -0
  198. package/dist/styles/shadow.js.map +1 -0
  199. package/dist/styles/transition.d.ts +14 -0
  200. package/dist/styles/transition.js +158 -0
  201. package/dist/styles/transition.js.map +1 -0
  202. package/dist/styles/types.d.ts +508 -0
  203. package/dist/styles/width.d.ts +17 -0
  204. package/dist/styles/width.js +20 -0
  205. package/dist/styles/width.js.map +1 -0
  206. package/dist/tasty.d.ts +981 -0
  207. package/dist/tasty.js +206 -0
  208. package/dist/tasty.js.map +1 -0
  209. package/dist/types.d.ts +184 -0
  210. package/dist/utils/cache-wrapper.js +26 -0
  211. package/dist/utils/cache-wrapper.js.map +1 -0
  212. package/dist/utils/case-converter.js +8 -0
  213. package/dist/utils/case-converter.js.map +1 -0
  214. package/dist/utils/colors.d.ts +5 -0
  215. package/dist/utils/colors.js +9 -0
  216. package/dist/utils/colors.js.map +1 -0
  217. package/dist/utils/css-types.d.ts +7 -0
  218. package/dist/utils/dotize.d.ts +26 -0
  219. package/dist/utils/dotize.js +122 -0
  220. package/dist/utils/dotize.js.map +1 -0
  221. package/dist/utils/filter-base-props.d.ts +15 -0
  222. package/dist/utils/filter-base-props.js +45 -0
  223. package/dist/utils/filter-base-props.js.map +1 -0
  224. package/dist/utils/get-display-name.d.ts +7 -0
  225. package/dist/utils/get-display-name.js +10 -0
  226. package/dist/utils/get-display-name.js.map +1 -0
  227. package/dist/utils/hsl-to-rgb.js +38 -0
  228. package/dist/utils/hsl-to-rgb.js.map +1 -0
  229. package/dist/utils/is-dev-env.js +19 -0
  230. package/dist/utils/is-dev-env.js.map +1 -0
  231. package/dist/utils/is-valid-element-type.js +15 -0
  232. package/dist/utils/is-valid-element-type.js.map +1 -0
  233. package/dist/utils/merge-styles.d.ts +7 -0
  234. package/dist/utils/merge-styles.js +146 -0
  235. package/dist/utils/merge-styles.js.map +1 -0
  236. package/dist/utils/mod-attrs.d.ts +8 -0
  237. package/dist/utils/mod-attrs.js +21 -0
  238. package/dist/utils/mod-attrs.js.map +1 -0
  239. package/dist/utils/okhsl-to-rgb.js +296 -0
  240. package/dist/utils/okhsl-to-rgb.js.map +1 -0
  241. package/dist/utils/process-tokens.d.ts +31 -0
  242. package/dist/utils/process-tokens.js +171 -0
  243. package/dist/utils/process-tokens.js.map +1 -0
  244. package/dist/utils/resolve-recipes.d.ts +17 -0
  245. package/dist/utils/resolve-recipes.js +147 -0
  246. package/dist/utils/resolve-recipes.js.map +1 -0
  247. package/dist/utils/selector-transform.js +32 -0
  248. package/dist/utils/selector-transform.js.map +1 -0
  249. package/dist/utils/string.js +8 -0
  250. package/dist/utils/string.js.map +1 -0
  251. package/dist/utils/styles.d.ts +177 -0
  252. package/dist/utils/styles.js +730 -0
  253. package/dist/utils/styles.js.map +1 -0
  254. package/dist/utils/typography.d.ts +47 -0
  255. package/dist/utils/typography.js +43 -0
  256. package/dist/utils/typography.js.map +1 -0
  257. package/dist/utils/warnings.d.ts +16 -0
  258. package/dist/utils/warnings.js +16 -0
  259. package/dist/utils/warnings.js.map +1 -0
  260. package/dist/zero/babel.d.ts +147 -0
  261. package/dist/zero/babel.js +331 -0
  262. package/dist/zero/babel.js.map +1 -0
  263. package/dist/zero/css-writer.d.ts +45 -0
  264. package/dist/zero/css-writer.js +74 -0
  265. package/dist/zero/css-writer.js.map +1 -0
  266. package/dist/zero/extractor.d.ts +24 -0
  267. package/dist/zero/extractor.js +215 -0
  268. package/dist/zero/extractor.js.map +1 -0
  269. package/dist/zero/index.d.ts +3 -0
  270. package/dist/zero/index.js +4 -0
  271. package/dist/zero/next.d.ts +74 -0
  272. package/dist/zero/next.js +129 -0
  273. package/dist/zero/next.js.map +1 -0
  274. package/docs/adoption.md +286 -0
  275. package/docs/comparison.md +413 -0
  276. package/docs/configuration.md +242 -0
  277. package/docs/debug.md +505 -0
  278. package/docs/design-system.md +401 -0
  279. package/docs/dsl.md +540 -0
  280. package/docs/getting-started.md +201 -0
  281. package/docs/injector.md +528 -0
  282. package/docs/methodology.md +501 -0
  283. package/docs/runtime.md +291 -0
  284. package/docs/ssr.md +382 -0
  285. package/docs/styles.md +574 -0
  286. package/docs/tasty-static.md +421 -0
  287. package/package.json +209 -0
  288. package/tasty.config.ts +14 -0
@@ -0,0 +1,730 @@
1
+ import { StyleParser } from "../parser/parser.js";
2
+ import { okhslFunc } from "../plugins/okhsl-plugin.js";
3
+ import { createStateParserContext, parseAdvancedState } from "../states/index.js";
4
+ import { cacheWrapper } from "./cache-wrapper.js";
5
+ import { camelToKebab } from "./case-converter.js";
6
+ import { okhslToRgb } from "./okhsl-to-rgb.js";
7
+ import { hslToRgb } from "./hsl-to-rgb.js";
8
+
9
+ //#region src/utils/styles.ts
10
+ /**
11
+ * Normalize a color token value.
12
+ * - Boolean `true` is converted to `'transparent'`
13
+ * - Boolean `false` returns `null` (signals the token should be skipped)
14
+ * - Other values are returned as-is
15
+ *
16
+ * @param value - The raw token value
17
+ * @returns Normalized value or null if the token should be skipped
18
+ */
19
+ function normalizeColorTokenValue(value) {
20
+ if (value === true) return "transparent";
21
+ if (value === false) return null;
22
+ return value;
23
+ }
24
+ const COLOR_VAR_PATTERN = /var\(--([a-z0-9-]+)-color/;
25
+ const COLOR_VAR_RGB_PATTERN = /var\(--([a-z0-9-]+)-color-rgb/;
26
+ const RGB_ALPHA_PATTERN = /\/\s*([0-9.]+)\)/;
27
+ const SIMPLE_COLOR_PATTERNS = [
28
+ /^#[0-9a-fA-F]{3,8}$/,
29
+ /^rgb\(/,
30
+ /^hsl\(/,
31
+ /^lch\(/,
32
+ /^oklch\(/,
33
+ /^okhsl\(/,
34
+ /^var\(--[a-z0-9-]+-color/,
35
+ /^currentColor$/,
36
+ /^transparent$/
37
+ ];
38
+ let colorWarningCount = 0;
39
+ const MAX_COLOR_WARNINGS = 10;
40
+ const CUSTOM_UNITS = {
41
+ r: "6px",
42
+ cr: "10px",
43
+ bw: "1px",
44
+ ow: "3px",
45
+ x: "8px",
46
+ fs: "var(--font-size)",
47
+ lh: "var(--line-height)",
48
+ sf: function sf(num) {
49
+ return `minmax(0, ${num}fr)`;
50
+ }
51
+ };
52
+ const DIRECTIONS = [
53
+ "top",
54
+ "right",
55
+ "bottom",
56
+ "left"
57
+ ];
58
+ let __tastyParser = null;
59
+ function getOrCreateParser() {
60
+ if (!__tastyParser) {
61
+ __tastyParser = new StyleParser({ units: CUSTOM_UNITS });
62
+ __tastyParser.setFuncs(__tastyFuncs);
63
+ }
64
+ return __tastyParser;
65
+ }
66
+ const __tastyFuncs = { okhsl: okhslFunc };
67
+ function customFunc(name, fn) {
68
+ __tastyFuncs[name] = fn;
69
+ getOrCreateParser().setFuncs(__tastyFuncs);
70
+ }
71
+ /**
72
+ * Get the global StyleParser instance.
73
+ * Used by configure() to apply parser configuration.
74
+ */
75
+ function getGlobalParser() {
76
+ return getOrCreateParser();
77
+ }
78
+ /**
79
+ * Get the current custom functions registry.
80
+ * Used by configure() to merge with new functions.
81
+ */
82
+ function getGlobalFuncs() {
83
+ return __tastyFuncs;
84
+ }
85
+ /**
86
+ * Storage for predefined tokens that are replaced during style parsing.
87
+ * Keys are token names (with $ or # prefix), values are pre-processed CSS values.
88
+ */
89
+ let __globalPredefinedTokens = null;
90
+ /**
91
+ * Set global predefined tokens.
92
+ * Called from configure() after processing token values.
93
+ * Merges with existing tokens (new tokens override existing ones with same key).
94
+ * Keys are normalized to lowercase (parser lowercases input before classification).
95
+ * @internal
96
+ */
97
+ function setGlobalPredefinedTokens(tokens) {
98
+ const normalizedTokens = {};
99
+ for (const [key, value] of Object.entries(tokens)) {
100
+ const lowerKey = key.toLowerCase();
101
+ const lowerValue = value.toLowerCase();
102
+ if (lowerKey.startsWith("#") && lowerValue === "#current") {
103
+ console.warn(`Tasty: Using #current to define color token "${key}" is not supported. The #current token represents currentcolor which cannot be used as a base for other tokens.`);
104
+ continue;
105
+ }
106
+ normalizedTokens[lowerKey] = value;
107
+ }
108
+ __globalPredefinedTokens = __globalPredefinedTokens ? {
109
+ ...__globalPredefinedTokens,
110
+ ...normalizedTokens
111
+ } : normalizedTokens;
112
+ getOrCreateParser().clearCache();
113
+ }
114
+ /**
115
+ * Get the current global predefined tokens.
116
+ * Returns null if no tokens are configured.
117
+ */
118
+ function getGlobalPredefinedTokens() {
119
+ return __globalPredefinedTokens;
120
+ }
121
+ /**
122
+ * Reset global predefined tokens.
123
+ * Used for testing.
124
+ * @internal
125
+ */
126
+ function resetGlobalPredefinedTokens() {
127
+ __globalPredefinedTokens = null;
128
+ getOrCreateParser().clearCache();
129
+ }
130
+ /**
131
+ *
132
+ * @param {String} value
133
+ * @param {Number} mode
134
+ * @returns {Object<String,String|Array>}
135
+ */
136
+ function parseStyle(value) {
137
+ let str;
138
+ if (typeof value === "string") str = value;
139
+ else if (typeof value === "number") str = String(value);
140
+ else str = "";
141
+ return getOrCreateParser().process(str);
142
+ }
143
+ /**
144
+ * Parse color. Find it value, name and opacity.
145
+ * Optimized to avoid heavy parseStyle calls for simple color patterns.
146
+ */
147
+ function parseColor(val, ignoreError = false) {
148
+ if (typeof val !== "string") val = String(val ?? "");
149
+ val = val.trim();
150
+ if (!val) return {};
151
+ const isSimpleColor = SIMPLE_COLOR_PATTERNS.some((pattern) => pattern.test(val));
152
+ let firstColor;
153
+ if (isSimpleColor) firstColor = val;
154
+ else {
155
+ const extractedColor = parseStyle(val).groups.find((g) => g.colors.length)?.colors[0];
156
+ if (!extractedColor) {
157
+ if (!ignoreError && colorWarningCount < MAX_COLOR_WARNINGS) {
158
+ console.warn("CubeUIKit: unable to parse color:", val);
159
+ colorWarningCount++;
160
+ if (colorWarningCount === MAX_COLOR_WARNINGS) console.warn("CubeUIKit: color parsing warnings will be suppressed from now on");
161
+ }
162
+ return {};
163
+ }
164
+ firstColor = extractedColor;
165
+ }
166
+ let nameMatch = firstColor.match(COLOR_VAR_PATTERN);
167
+ if (!nameMatch) nameMatch = firstColor.match(COLOR_VAR_RGB_PATTERN);
168
+ let opacity;
169
+ if (firstColor.startsWith("rgb") || firstColor.startsWith("hsl") || firstColor.startsWith("lch") || firstColor.startsWith("oklch") || firstColor.startsWith("okhsl")) {
170
+ const alphaMatch = firstColor.match(RGB_ALPHA_PATTERN);
171
+ if (alphaMatch) {
172
+ const v = parseFloat(alphaMatch[1]);
173
+ if (!isNaN(v)) opacity = v * 100;
174
+ }
175
+ }
176
+ return {
177
+ color: firstColor,
178
+ name: nameMatch ? nameMatch[1] : void 0,
179
+ opacity
180
+ };
181
+ }
182
+ /**
183
+ * CSS named color keywords → hex values.
184
+ * Lazy-initialized on first use to avoid up-front cost.
185
+ */
186
+ let _namedColorHex = null;
187
+ function getNamedColorHex() {
188
+ if (_namedColorHex) return _namedColorHex;
189
+ _namedColorHex = new Map([
190
+ ["aliceblue", "#f0f8ff"],
191
+ ["antiquewhite", "#faebd7"],
192
+ ["aqua", "#00ffff"],
193
+ ["aquamarine", "#7fffd4"],
194
+ ["azure", "#f0ffff"],
195
+ ["beige", "#f5f5dc"],
196
+ ["bisque", "#ffe4c4"],
197
+ ["black", "#000000"],
198
+ ["blanchedalmond", "#ffebcd"],
199
+ ["blue", "#0000ff"],
200
+ ["blueviolet", "#8a2be2"],
201
+ ["brown", "#a52a2a"],
202
+ ["burlywood", "#deb887"],
203
+ ["cadetblue", "#5f9ea0"],
204
+ ["chartreuse", "#7fff00"],
205
+ ["chocolate", "#d2691e"],
206
+ ["coral", "#ff7f50"],
207
+ ["cornflowerblue", "#6495ed"],
208
+ ["cornsilk", "#fff8dc"],
209
+ ["crimson", "#dc143c"],
210
+ ["cyan", "#00ffff"],
211
+ ["darkblue", "#00008b"],
212
+ ["darkcyan", "#008b8b"],
213
+ ["darkgoldenrod", "#b8860b"],
214
+ ["darkgray", "#a9a9a9"],
215
+ ["darkgreen", "#006400"],
216
+ ["darkgrey", "#a9a9a9"],
217
+ ["darkkhaki", "#bdb76b"],
218
+ ["darkmagenta", "#8b008b"],
219
+ ["darkolivegreen", "#556b2f"],
220
+ ["darkorange", "#ff8c00"],
221
+ ["darkorchid", "#9932cc"],
222
+ ["darkred", "#8b0000"],
223
+ ["darksalmon", "#e9967a"],
224
+ ["darkseagreen", "#8fbc8f"],
225
+ ["darkslateblue", "#483d8b"],
226
+ ["darkslategray", "#2f4f4f"],
227
+ ["darkslategrey", "#2f4f4f"],
228
+ ["darkturquoise", "#00ced1"],
229
+ ["darkviolet", "#9400d3"],
230
+ ["deeppink", "#ff1493"],
231
+ ["deepskyblue", "#00bfff"],
232
+ ["dimgray", "#696969"],
233
+ ["dimgrey", "#696969"],
234
+ ["dodgerblue", "#1e90ff"],
235
+ ["firebrick", "#b22222"],
236
+ ["floralwhite", "#fffaf0"],
237
+ ["forestgreen", "#228b22"],
238
+ ["fuchsia", "#ff00ff"],
239
+ ["gainsboro", "#dcdcdc"],
240
+ ["ghostwhite", "#f8f8ff"],
241
+ ["gold", "#ffd700"],
242
+ ["goldenrod", "#daa520"],
243
+ ["gray", "#808080"],
244
+ ["green", "#008000"],
245
+ ["greenyellow", "#adff2f"],
246
+ ["grey", "#808080"],
247
+ ["honeydew", "#f0fff0"],
248
+ ["hotpink", "#ff69b4"],
249
+ ["indianred", "#cd5c5c"],
250
+ ["indigo", "#4b0082"],
251
+ ["ivory", "#fffff0"],
252
+ ["khaki", "#f0e68c"],
253
+ ["lavender", "#e6e6fa"],
254
+ ["lavenderblush", "#fff0f5"],
255
+ ["lawngreen", "#7cfc00"],
256
+ ["lemonchiffon", "#fffacd"],
257
+ ["lightblue", "#add8e6"],
258
+ ["lightcoral", "#f08080"],
259
+ ["lightcyan", "#e0ffff"],
260
+ ["lightgoldenrodyellow", "#fafad2"],
261
+ ["lightgray", "#d3d3d3"],
262
+ ["lightgreen", "#90ee90"],
263
+ ["lightgrey", "#d3d3d3"],
264
+ ["lightpink", "#ffb6c1"],
265
+ ["lightsalmon", "#ffa07a"],
266
+ ["lightseagreen", "#20b2aa"],
267
+ ["lightskyblue", "#87cefa"],
268
+ ["lightslategray", "#778899"],
269
+ ["lightslategrey", "#778899"],
270
+ ["lightsteelblue", "#b0c4de"],
271
+ ["lightyellow", "#ffffe0"],
272
+ ["lime", "#00ff00"],
273
+ ["limegreen", "#32cd32"],
274
+ ["linen", "#faf0e6"],
275
+ ["magenta", "#ff00ff"],
276
+ ["maroon", "#800000"],
277
+ ["mediumaquamarine", "#66cdaa"],
278
+ ["mediumblue", "#0000cd"],
279
+ ["mediumorchid", "#ba55d3"],
280
+ ["mediumpurple", "#9370db"],
281
+ ["mediumseagreen", "#3cb371"],
282
+ ["mediumslateblue", "#7b68ee"],
283
+ ["mediumspringgreen", "#00fa9a"],
284
+ ["mediumturquoise", "#48d1cc"],
285
+ ["mediumvioletred", "#c71585"],
286
+ ["midnightblue", "#191970"],
287
+ ["mintcream", "#f5fffa"],
288
+ ["mistyrose", "#ffe4e1"],
289
+ ["moccasin", "#ffe4b5"],
290
+ ["navajowhite", "#ffdead"],
291
+ ["navy", "#000080"],
292
+ ["oldlace", "#fdf5e6"],
293
+ ["olive", "#808000"],
294
+ ["olivedrab", "#6b8e23"],
295
+ ["orange", "#ffa500"],
296
+ ["orangered", "#ff4500"],
297
+ ["orchid", "#da70d6"],
298
+ ["palegoldenrod", "#eee8aa"],
299
+ ["palegreen", "#98fb98"],
300
+ ["paleturquoise", "#afeeee"],
301
+ ["palevioletred", "#db7093"],
302
+ ["papayawhip", "#ffefd5"],
303
+ ["peachpuff", "#ffdab9"],
304
+ ["peru", "#cd853f"],
305
+ ["pink", "#ffc0cb"],
306
+ ["plum", "#dda0dd"],
307
+ ["powderblue", "#b0e0e6"],
308
+ ["purple", "#800080"],
309
+ ["rebeccapurple", "#663399"],
310
+ ["red", "#ff0000"],
311
+ ["rosybrown", "#bc8f8f"],
312
+ ["royalblue", "#4169e1"],
313
+ ["saddlebrown", "#8b4513"],
314
+ ["salmon", "#fa8072"],
315
+ ["sandybrown", "#f4a460"],
316
+ ["seagreen", "#2e8b57"],
317
+ ["seashell", "#fff5ee"],
318
+ ["sienna", "#a0522d"],
319
+ ["silver", "#c0c0c0"],
320
+ ["skyblue", "#87ceeb"],
321
+ ["slateblue", "#6a5acd"],
322
+ ["slategray", "#708090"],
323
+ ["slategrey", "#708090"],
324
+ ["snow", "#fffafa"],
325
+ ["springgreen", "#00ff7f"],
326
+ ["steelblue", "#4682b4"],
327
+ ["tan", "#d2b48c"],
328
+ ["teal", "#008080"],
329
+ ["thistle", "#d8bfd8"],
330
+ ["tomato", "#ff6347"],
331
+ ["turquoise", "#40e0d0"],
332
+ ["violet", "#ee82ee"],
333
+ ["wheat", "#f5deb3"],
334
+ ["white", "#ffffff"],
335
+ ["whitesmoke", "#f5f5f5"],
336
+ ["yellow", "#ffff00"],
337
+ ["yellowgreen", "#9acd32"]
338
+ ]);
339
+ return _namedColorHex;
340
+ }
341
+ function strToRgb(color, _ignoreAlpha = false) {
342
+ if (!color) return void 0;
343
+ if (color.startsWith("rgb")) return color;
344
+ if (color.startsWith("#")) return hexToRgb(color);
345
+ if (color.startsWith("okhsl(")) return okhslToRgb(color);
346
+ if (color.startsWith("hsl")) return hslToRgb(color);
347
+ const namedHex = getNamedColorHex().get(color.toLowerCase());
348
+ if (namedHex) return hexToRgb(namedHex);
349
+ return null;
350
+ }
351
+ /**
352
+ * Extract RGB values from an rgb()/rgba() string.
353
+ * Supports all modern CSS syntax variations:
354
+ * - Comma-separated: rgb(255, 128, 0)
355
+ * - Space-separated: rgb(255 128 0)
356
+ * - Fractional: rgb(128.5, 64.3, 32.1)
357
+ * - Percentages: rgb(50%, 25%, 75%)
358
+ * - Slash alpha notation: rgb(255 128 0 / 0.5)
359
+ *
360
+ * Returns array of RGB values (0-255 range), converting percentages as needed.
361
+ */
362
+ function getRgbValuesFromRgbaString(str) {
363
+ const match = str.match(/rgba?\(([^)]+)\)/i);
364
+ if (!match) return [];
365
+ const [colorPart] = match[1].trim().split("/");
366
+ return colorPart.trim().split(/[,\s]+/).filter(Boolean).slice(0, 3).map((part) => {
367
+ part = part.trim();
368
+ if (part.endsWith("%")) return parseFloat(part) / 100 * 255;
369
+ return parseFloat(part);
370
+ });
371
+ }
372
+ function hexToRgb(hex) {
373
+ const matched = hex.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i, (_m, r, g, b) => "#" + r + r + g + g + b + b).substring(1).match(/.{2}/g);
374
+ if (!matched) return null;
375
+ const rgba = matched.map((x, i) => parseInt(x, 16) * (i === 3 ? 1 / 255 : 1));
376
+ if (rgba.some((v) => Number.isNaN(v))) return null;
377
+ if (rgba.length >= 3) return `rgb(${rgba.slice(0, 3).join(" ")}${rgba.length > 3 ? ` / ${rgba[3]}` : ""})`;
378
+ return null;
379
+ }
380
+ function filterMods(mods, allowedMods) {
381
+ return mods.filter((mod) => allowedMods.includes(mod));
382
+ }
383
+ function extendStyles(defaultStyles, newStyles) {
384
+ let styles = {};
385
+ if (!defaultStyles) {
386
+ if (!newStyles) return styles;
387
+ } else styles = Object.assign({}, defaultStyles);
388
+ if (newStyles) Object.keys(newStyles).forEach((key) => {
389
+ if (newStyles[key] != null) styles[key] = newStyles[key];
390
+ });
391
+ return styles;
392
+ }
393
+ /**
394
+ * Split properties into style and non-style properties.
395
+ * @param props - Component prop map.
396
+ * @param [styleList] - List of all style properties.
397
+ * @param [defaultStyles] - Default style map of the component.
398
+ * @param [propMap] - Props to style alias map.
399
+ * @param [ignoreList] - A list of properties to ignore.
400
+ */
401
+ function extractStyles(props, styleList = [], defaultStyles, propMap, ignoreList = []) {
402
+ const styles = {
403
+ ...defaultStyles,
404
+ ...ignoreList.includes("styles") ? void 0 : props.styles && typeof props.styles === "object" ? props.styles : void 0
405
+ };
406
+ Object.keys(props).forEach((prop) => {
407
+ const propName = propMap ? propMap[prop] || prop : prop;
408
+ const value = props[prop];
409
+ if (ignoreList && ignoreList.includes(prop)) {} else if (styleList.includes(propName)) styles[propName] = value;
410
+ }, {});
411
+ return styles;
412
+ }
413
+ const STATES_REGEXP = /([&|!^])|([()])|(@media:[a-z]+)|(@media\([^)]+\))|(@root\([^)]+\))|(@own\([^)]+\))|(@\([^)]+\))|(@starting)|(@[A-Za-z][A-Za-z0-9-]*)|([a-z][a-z0-9-]+=(?:"[^"]*"|'[^']*'|[^\s&|!^()]+))|([a-z][a-z0-9-]+)|(:[a-z][a-z0-9-]+\([^)]+\)|:[a-z][a-z0-9-]+)|(\.[a-z][a-z0-9-]+)|(\[[^\]]+])/gi;
414
+ /**
415
+ * Check if a token is an advanced state (starts with @)
416
+ */
417
+ function isAdvancedStateToken(token) {
418
+ return token.startsWith("@") || token.startsWith("!@");
419
+ }
420
+ const STATE_OPERATORS = {
421
+ NOT: "!",
422
+ AND: "&",
423
+ OR: "|",
424
+ XOR: "^"
425
+ };
426
+ const STATE_OPERATOR_LIST = [
427
+ "!",
428
+ "&",
429
+ "|",
430
+ "^"
431
+ ];
432
+ /**
433
+ * Convert state notation tokens to a compute model (string, or nested [op, lhs, rhs]).
434
+ */
435
+ function convertTokensToComputeUnits(tokens) {
436
+ if (tokens.length === 1) return tokens[0];
437
+ const hasLength = (x) => typeof x === "string" || Array.isArray(x);
438
+ STATE_OPERATOR_LIST.forEach((operator) => {
439
+ let i;
440
+ while ((i = tokens.indexOf(operator)) !== -1) {
441
+ const token = tokens[i];
442
+ if (token === "!") {
443
+ const next = tokens[i + 1];
444
+ if (next !== void 0 && hasLength(next) && next.length !== 1) tokens.splice(i, 2, ["!", next]);
445
+ else tokens.splice(i, 1);
446
+ } else {
447
+ const prev = tokens[i - 1];
448
+ const next = tokens[i + 1];
449
+ if (prev !== void 0 && next !== void 0 && hasLength(prev) && hasLength(next) && prev.length !== 1 && next.length !== 1) tokens.splice(i - 1, 3, [
450
+ token,
451
+ prev,
452
+ next
453
+ ]);
454
+ else tokens.splice(i, 1);
455
+ }
456
+ }
457
+ });
458
+ return tokens.length === 1 ? tokens[0] : tokens;
459
+ }
460
+ /**
461
+ * Replace commas with | only outside of parentheses.
462
+ * This preserves commas in advanced states like @(card, w < 600px)
463
+ */
464
+ function replaceCommasOutsideParens(str) {
465
+ let result = "";
466
+ let depth = 0;
467
+ for (const char of str) if (char === "(") {
468
+ depth++;
469
+ result += char;
470
+ } else if (char === ")") {
471
+ depth--;
472
+ result += char;
473
+ } else if (char === "," && depth === 0) result += "|";
474
+ else result += char;
475
+ return result;
476
+ }
477
+ /**
478
+ * Parse state notation and return tokens, modifiers and compute model.
479
+ */
480
+ function parseStateNotationInner(notation, value) {
481
+ const tokens = replaceCommasOutsideParens(notation).match(STATES_REGEXP);
482
+ if (!tokens || !tokens.length) return {
483
+ model: void 0,
484
+ mods: [],
485
+ notMods: [],
486
+ tokens: [],
487
+ value
488
+ };
489
+ else if (tokens.length === 1) return {
490
+ model: tokens[0],
491
+ mods: tokens.slice(0),
492
+ notMods: [],
493
+ tokens,
494
+ value
495
+ };
496
+ const mods = [];
497
+ const operations = [[]];
498
+ let list = operations[0];
499
+ let position = 0;
500
+ let operation;
501
+ tokens.forEach((token) => {
502
+ switch (token) {
503
+ case "(":
504
+ operation = [];
505
+ position++;
506
+ list = operations[position] = operation;
507
+ break;
508
+ case ")":
509
+ position--;
510
+ operations[position].push(convertTokensToComputeUnits(list));
511
+ list = operations[position];
512
+ break;
513
+ default:
514
+ if (token.length > 1) {
515
+ if (!mods.includes(token)) mods.push(token);
516
+ }
517
+ list.push(token);
518
+ }
519
+ });
520
+ while (position) {
521
+ position--;
522
+ operations[position].push(convertTokensToComputeUnits(list));
523
+ list = operations[position];
524
+ }
525
+ return {
526
+ tokens,
527
+ mods,
528
+ notMods: [],
529
+ model: convertTokensToComputeUnits(operations[0]),
530
+ value
531
+ };
532
+ }
533
+ const parseStateNotation = cacheWrapper(parseStateNotationInner);
534
+ /**
535
+ * Build an AtRuleContext from parsed advanced states
536
+ */
537
+ function buildAtRuleContext(advancedStates, negatedStates) {
538
+ if (advancedStates.length === 0) return void 0;
539
+ const ctx = {};
540
+ for (const state of advancedStates) {
541
+ const isNegated = negatedStates.has(state.raw);
542
+ switch (state.type) {
543
+ case "media": {
544
+ if (!ctx.media) ctx.media = [];
545
+ let mediaCondition = "";
546
+ if (state.mediaType) mediaCondition = state.mediaType;
547
+ else if (state.condition) mediaCondition = `(${state.condition})`;
548
+ if (mediaCondition) if (isNegated) ctx.media.push(`not ${mediaCondition}`);
549
+ else ctx.media.push(mediaCondition);
550
+ break;
551
+ }
552
+ case "container": {
553
+ if (!ctx.container) ctx.container = [];
554
+ let condition = state.condition;
555
+ if (isNegated) condition = `not (${condition})`;
556
+ ctx.container.push({
557
+ name: state.containerName,
558
+ condition
559
+ });
560
+ break;
561
+ }
562
+ case "root": {
563
+ if (!ctx.rootStates) ctx.rootStates = [];
564
+ const rootSelector = buildRootSelector(state.condition, isNegated);
565
+ ctx.rootStates.push(rootSelector);
566
+ break;
567
+ }
568
+ case "starting":
569
+ if (!isNegated) ctx.startingStyle = true;
570
+ break;
571
+ }
572
+ }
573
+ if (!ctx.media?.length && !ctx.container?.length && !ctx.rootStates?.length && !ctx.startingStyle) return;
574
+ return ctx;
575
+ }
576
+ /**
577
+ * Build a root state selector from a condition
578
+ */
579
+ function buildRootSelector(condition, isNegated) {
580
+ let selector;
581
+ if (condition.startsWith(".")) selector = condition;
582
+ else if (condition.startsWith("[")) selector = condition;
583
+ else if (condition.includes("=")) {
584
+ const [key, value] = condition.split("=");
585
+ selector = `[data-${camelToKebab(key.trim())}="${value.trim()}"]`;
586
+ } else selector = `[data-${camelToKebab(condition)}]`;
587
+ if (isNegated) return `:not(${selector})`;
588
+ return selector;
589
+ }
590
+ /**
591
+ * Parse state notation and return tokens, modifiers and compute model.
592
+ * Enhanced to detect and extract advanced states.
593
+ */
594
+ function styleStateMapToStyleStateDataList(styleStateMap, parserContext) {
595
+ if (typeof styleStateMap !== "object" || !styleStateMap) return {
596
+ states: [{
597
+ model: void 0,
598
+ mods: [],
599
+ notMods: [],
600
+ value: styleStateMap
601
+ }],
602
+ mods: [],
603
+ hasAdvancedStates: false
604
+ };
605
+ const stateDataList = [];
606
+ let hasAdvancedStates = false;
607
+ Object.keys(styleStateMap).forEach((stateNotation) => {
608
+ const state = parseStateNotation(stateNotation, styleStateMap[stateNotation]);
609
+ const advancedStates = [];
610
+ const negatedAdvancedStates = /* @__PURE__ */ new Set();
611
+ const regularMods = [];
612
+ const ownMods = [];
613
+ const negatedOwnMods = [];
614
+ if (state.tokens) {
615
+ let isNegated = false;
616
+ for (const token of state.tokens) {
617
+ if (token === "!") {
618
+ isNegated = true;
619
+ continue;
620
+ }
621
+ if (isAdvancedStateToken(token)) {
622
+ hasAdvancedStates = true;
623
+ const parsed = parseAdvancedState(token, parserContext || createStateParserContext(void 0));
624
+ advancedStates.push(parsed);
625
+ if (parsed.type === "own" && parsed.condition) if (isNegated) negatedOwnMods.push(parsed.condition);
626
+ else ownMods.push(parsed.condition);
627
+ else if (isNegated) negatedAdvancedStates.add(token);
628
+ isNegated = false;
629
+ } else if (token.length > 1 && ![
630
+ "&",
631
+ "|",
632
+ "^",
633
+ "(",
634
+ ")"
635
+ ].includes(token)) {
636
+ regularMods.push(token);
637
+ isNegated = false;
638
+ } else isNegated = false;
639
+ }
640
+ }
641
+ if (advancedStates.length > 0) {
642
+ state.advancedStates = advancedStates;
643
+ state.atRuleContext = buildAtRuleContext(advancedStates, negatedAdvancedStates);
644
+ state.mods = regularMods;
645
+ }
646
+ if (ownMods.length > 0) state.ownMods = ownMods;
647
+ if (negatedOwnMods.length > 0) state.negatedOwnMods = negatedOwnMods;
648
+ stateDataList.push(state);
649
+ });
650
+ stateDataList.reverse();
651
+ let initialState;
652
+ const allMods = stateDataList.reduce((all, state) => {
653
+ if (!state.mods.length && !state.advancedStates?.length) initialState = state;
654
+ else state.mods.forEach((mod) => {
655
+ if (!all.includes(mod)) all.push(mod);
656
+ });
657
+ return all;
658
+ }, []);
659
+ if (!initialState) stateDataList.push({
660
+ mods: [],
661
+ notMods: allMods,
662
+ value: true
663
+ });
664
+ return {
665
+ states: stateDataList,
666
+ mods: allMods,
667
+ hasAdvancedStates
668
+ };
669
+ }
670
+ const COMPUTE_FUNC_MAP = {
671
+ "!": (a) => !a,
672
+ "^": (a, b) => a && !b || !a && b,
673
+ "|": (a, b) => a || b,
674
+ "&": (a, b) => a && b
675
+ };
676
+ /**
677
+ * Compute a result based on a model and incoming map.
678
+ */
679
+ function computeState(computeModel, valueMap) {
680
+ if (!computeModel) return true;
681
+ const map = valueMap;
682
+ if (!Array.isArray(computeModel)) if (typeof valueMap === "function") return !!valueMap(computeModel);
683
+ else return !!map[computeModel];
684
+ const func = COMPUTE_FUNC_MAP[computeModel[0]];
685
+ if (!func) console.warn("CubeUIKit: unexpected compute method in the model", computeModel);
686
+ let a = computeModel[1];
687
+ if (typeof a === "object") a = !!computeState(a, valueMap);
688
+ else if (typeof valueMap === "function") a = !!valueMap(a);
689
+ else a = !!map[a];
690
+ if (computeModel.length === 2) return func(a);
691
+ let b = computeModel[2];
692
+ if (typeof b === "object") b = !!computeState(b, valueMap);
693
+ else if (typeof valueMap === "function") b = !!valueMap(b);
694
+ else b = !!map[b];
695
+ return !!func(a, b);
696
+ }
697
+ const _innerCache = /* @__PURE__ */ new WeakMap();
698
+ function stringifyStyles(styles) {
699
+ if (styles == null || typeof styles !== "object") return "";
700
+ const obj = styles;
701
+ const keys = Object.keys(obj).sort();
702
+ const parts = [];
703
+ for (const k of keys) {
704
+ const v = obj[k];
705
+ if (v === void 0 || typeof v === "function" || typeof v === "symbol") continue;
706
+ const c0 = k.charCodeAt(0);
707
+ const needsInnerSort = (c0 >= 65 && c0 <= 90 || c0 === 38) && v && typeof v === "object" && !Array.isArray(v);
708
+ let sv;
709
+ if (needsInnerSort) {
710
+ sv = _innerCache.get(v);
711
+ if (sv === void 0) {
712
+ const innerObj = v;
713
+ const innerKeys = Object.keys(innerObj).sort();
714
+ const innerParts = [];
715
+ for (const ik of innerKeys) {
716
+ const ivs = JSON.stringify(innerObj[ik]);
717
+ if (ivs !== void 0) innerParts.push(JSON.stringify(ik) + ":" + ivs);
718
+ }
719
+ sv = "{" + innerParts.join(",") + "}";
720
+ _innerCache.set(v, sv);
721
+ }
722
+ } else sv = JSON.stringify(v);
723
+ parts.push(JSON.stringify(k) + ":" + sv);
724
+ }
725
+ return "{" + parts.join(",") + "}";
726
+ }
727
+
728
+ //#endregion
729
+ export { COMPUTE_FUNC_MAP, CUSTOM_UNITS, DIRECTIONS, STATE_OPERATORS, STATE_OPERATOR_LIST, buildAtRuleContext, computeState, customFunc, extendStyles, extractStyles, filterMods, getGlobalFuncs, getGlobalParser, getGlobalPredefinedTokens, getRgbValuesFromRgbaString, hexToRgb, isAdvancedStateToken, normalizeColorTokenValue, parseColor, parseStateNotation, parseStyle, resetGlobalPredefinedTokens, setGlobalPredefinedTokens, strToRgb, stringifyStyles, styleStateMapToStyleStateDataList };
730
+ //# sourceMappingURL=styles.js.map