@tenphi/tasty 0.0.0-snapshot.bae20d4 → 0.0.0-snapshot.bbd36bd

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 (351) hide show
  1. package/README.md +309 -293
  2. package/dist/astro-CeYENy2x.js +301 -0
  3. package/dist/astro-CeYENy2x.js.map +1 -0
  4. package/dist/{ssr/async-storage.js → async-storage-DKK-wTD4.js} +17 -8
  5. package/dist/async-storage-DKK-wTD4.js.map +1 -0
  6. package/dist/babel-DWCsafYw.d.ts +83 -0
  7. package/dist/collector-B3OsM252.js +327 -0
  8. package/dist/collector-B3OsM252.js.map +1 -0
  9. package/dist/collector-BTVXj2hS.d.ts +163 -0
  10. package/dist/config-B3gPdCqd.js +12421 -0
  11. package/dist/config-B3gPdCqd.js.map +1 -0
  12. package/dist/config-LfIDmVHx.d.ts +1363 -0
  13. package/dist/context-CA8YKeMn.js +24 -0
  14. package/dist/context-CA8YKeMn.js.map +1 -0
  15. package/dist/core/index.d.ts +5 -34
  16. package/dist/core/index.js +6 -27
  17. package/dist/core-DGm0CFHP.js +1732 -0
  18. package/dist/core-DGm0CFHP.js.map +1 -0
  19. package/dist/css-resources-Cyl_axbI.js +149 -0
  20. package/dist/css-resources-Cyl_axbI.js.map +1 -0
  21. package/dist/{zero/extractor.js → css-writer-Bgowobbx.js} +188 -13
  22. package/dist/css-writer-Bgowobbx.js.map +1 -0
  23. package/dist/{ssr/format-global-rules.js → format-global-rules-DklyaXv-.js} +3 -3
  24. package/dist/format-global-rules-DklyaXv-.js.map +1 -0
  25. package/dist/{ssr/format-rules.js → format-rules-XRw9u7d4.js} +41 -7
  26. package/dist/format-rules-XRw9u7d4.js.map +1 -0
  27. package/dist/hydrate-CNOmZprz.js +37 -0
  28. package/dist/hydrate-CNOmZprz.js.map +1 -0
  29. package/dist/index-Bm9ltvdH.d.ts +1933 -0
  30. package/dist/index-BmogEzTo.d.ts +1575 -0
  31. package/dist/index.d.ts +5 -49
  32. package/dist/index.js +921 -33
  33. package/dist/index.js.map +1 -0
  34. package/dist/keyframes-DE-OE76F.js +535 -0
  35. package/dist/keyframes-DE-OE76F.js.map +1 -0
  36. package/dist/{utils/merge-styles.d.ts → merge-styles-BcLl1u_d.d.ts} +3 -3
  37. package/dist/{utils/merge-styles.js → merge-styles-DuoZEsm9.js} +4 -6
  38. package/dist/merge-styles-DuoZEsm9.js.map +1 -0
  39. package/dist/{utils/resolve-recipes.js → resolve-recipes-H9NqOQuP.js} +5 -8
  40. package/dist/resolve-recipes-H9NqOQuP.js.map +1 -0
  41. package/dist/ssr/astro-client.d.ts +1 -0
  42. package/dist/ssr/astro-client.js +19 -0
  43. package/dist/ssr/astro-client.js.map +1 -0
  44. package/dist/ssr/astro-middleware-extract-static.d.ts +11 -0
  45. package/dist/ssr/astro-middleware-extract-static.js +9 -0
  46. package/dist/ssr/astro-middleware-extract-static.js.map +1 -0
  47. package/dist/ssr/astro-middleware-extract.d.ts +11 -0
  48. package/dist/ssr/astro-middleware-extract.js +9 -0
  49. package/dist/ssr/astro-middleware-extract.js.map +1 -0
  50. package/dist/ssr/astro-middleware-static.d.ts +18 -0
  51. package/dist/ssr/astro-middleware-static.js +18 -0
  52. package/dist/ssr/astro-middleware-static.js.map +1 -0
  53. package/dist/ssr/astro-middleware.d.ts +19 -0
  54. package/dist/ssr/astro-middleware.js +19 -0
  55. package/dist/ssr/astro-middleware.js.map +1 -0
  56. package/dist/ssr/astro.d.ts +117 -11
  57. package/dist/ssr/astro.js +2 -65
  58. package/dist/ssr/index.d.ts +37 -5
  59. package/dist/ssr/index.js +7 -9
  60. package/dist/ssr/index.js.map +1 -1
  61. package/dist/ssr/next-config.d.ts +66 -0
  62. package/dist/ssr/next-config.js +115 -0
  63. package/dist/ssr/next-config.js.map +1 -0
  64. package/dist/ssr/next.d.ts +14 -7
  65. package/dist/ssr/next.js +40 -20
  66. package/dist/ssr/next.js.map +1 -1
  67. package/dist/ssr-collector-ref-COs_ioWl.js +29 -0
  68. package/dist/ssr-collector-ref-COs_ioWl.js.map +1 -0
  69. package/dist/static/index.d.ts +91 -5
  70. package/dist/static/index.js +49 -4
  71. package/dist/static/index.js.map +1 -0
  72. package/dist/static/inject.d.ts +5 -0
  73. package/dist/static/inject.js +17 -0
  74. package/dist/static/inject.js.map +1 -0
  75. package/dist/zero/babel.d.ts +2 -155
  76. package/dist/zero/babel.js +183 -51
  77. package/dist/zero/babel.js.map +1 -1
  78. package/dist/zero/index.d.ts +81 -3
  79. package/dist/zero/index.js +2 -4
  80. package/dist/zero/next.d.ts +13 -1
  81. package/dist/zero/next.js +6 -5
  82. package/dist/zero/next.js.map +1 -1
  83. package/docs/README.md +39 -0
  84. package/docs/adoption.md +72 -35
  85. package/docs/ai-agents.md +224 -0
  86. package/docs/comparison.md +88 -53
  87. package/docs/configuration.md +623 -63
  88. package/docs/debug.md +172 -342
  89. package/docs/design-system.md +83 -29
  90. package/docs/dsl.md +614 -133
  91. package/docs/getting-started.md +80 -43
  92. package/docs/injector.md +159 -53
  93. package/docs/methodology.md +178 -31
  94. package/docs/migration-v3.md +285 -0
  95. package/docs/pipeline.md +741 -0
  96. package/docs/plugins.md +353 -0
  97. package/docs/react-api.md +681 -0
  98. package/docs/runtime-benchmarks.md +351 -0
  99. package/docs/ssr.md +356 -128
  100. package/docs/styles.md +103 -32
  101. package/docs/tasty-static.md +227 -65
  102. package/package.json +83 -22
  103. package/tasty.config.ts +6 -0
  104. package/dist/_virtual/_rolldown/runtime.js +0 -8
  105. package/dist/chunks/cacheKey.js +0 -78
  106. package/dist/chunks/cacheKey.js.map +0 -1
  107. package/dist/chunks/definitions.d.ts +0 -37
  108. package/dist/chunks/definitions.js +0 -259
  109. package/dist/chunks/definitions.js.map +0 -1
  110. package/dist/chunks/renderChunk.js +0 -60
  111. package/dist/chunks/renderChunk.js.map +0 -1
  112. package/dist/config.d.ts +0 -323
  113. package/dist/config.js +0 -465
  114. package/dist/config.js.map +0 -1
  115. package/dist/debug.d.ts +0 -204
  116. package/dist/debug.js +0 -733
  117. package/dist/debug.js.map +0 -1
  118. package/dist/hooks/useGlobalStyles.d.ts +0 -30
  119. package/dist/hooks/useGlobalStyles.js +0 -83
  120. package/dist/hooks/useGlobalStyles.js.map +0 -1
  121. package/dist/hooks/useKeyframes.d.ts +0 -56
  122. package/dist/hooks/useKeyframes.js +0 -69
  123. package/dist/hooks/useKeyframes.js.map +0 -1
  124. package/dist/hooks/useProperty.d.ts +0 -79
  125. package/dist/hooks/useProperty.js +0 -114
  126. package/dist/hooks/useProperty.js.map +0 -1
  127. package/dist/hooks/useRawCSS.d.ts +0 -53
  128. package/dist/hooks/useRawCSS.js +0 -40
  129. package/dist/hooks/useRawCSS.js.map +0 -1
  130. package/dist/hooks/useStyles.d.ts +0 -45
  131. package/dist/hooks/useStyles.js +0 -249
  132. package/dist/hooks/useStyles.js.map +0 -1
  133. package/dist/injector/index.d.ts +0 -165
  134. package/dist/injector/index.js +0 -162
  135. package/dist/injector/index.js.map +0 -1
  136. package/dist/injector/injector.d.ts +0 -148
  137. package/dist/injector/injector.js +0 -430
  138. package/dist/injector/injector.js.map +0 -1
  139. package/dist/injector/sheet-manager.d.ts +0 -136
  140. package/dist/injector/sheet-manager.js +0 -729
  141. package/dist/injector/sheet-manager.js.map +0 -1
  142. package/dist/injector/types.d.ts +0 -144
  143. package/dist/keyframes/index.js +0 -206
  144. package/dist/keyframes/index.js.map +0 -1
  145. package/dist/parser/classify.js +0 -320
  146. package/dist/parser/classify.js.map +0 -1
  147. package/dist/parser/const.js +0 -33
  148. package/dist/parser/const.js.map +0 -1
  149. package/dist/parser/lru.js +0 -109
  150. package/dist/parser/lru.js.map +0 -1
  151. package/dist/parser/parser.d.ts +0 -25
  152. package/dist/parser/parser.js +0 -116
  153. package/dist/parser/parser.js.map +0 -1
  154. package/dist/parser/tokenizer.js +0 -69
  155. package/dist/parser/tokenizer.js.map +0 -1
  156. package/dist/parser/types.d.ts +0 -51
  157. package/dist/parser/types.js +0 -46
  158. package/dist/parser/types.js.map +0 -1
  159. package/dist/pipeline/conditions.d.ts +0 -134
  160. package/dist/pipeline/conditions.js +0 -406
  161. package/dist/pipeline/conditions.js.map +0 -1
  162. package/dist/pipeline/exclusive.js +0 -231
  163. package/dist/pipeline/exclusive.js.map +0 -1
  164. package/dist/pipeline/index.d.ts +0 -53
  165. package/dist/pipeline/index.js +0 -670
  166. package/dist/pipeline/index.js.map +0 -1
  167. package/dist/pipeline/materialize.js +0 -1105
  168. package/dist/pipeline/materialize.js.map +0 -1
  169. package/dist/pipeline/parseStateKey.d.ts +0 -15
  170. package/dist/pipeline/parseStateKey.js +0 -447
  171. package/dist/pipeline/parseStateKey.js.map +0 -1
  172. package/dist/pipeline/simplify.js +0 -516
  173. package/dist/pipeline/simplify.js.map +0 -1
  174. package/dist/pipeline/warnings.js +0 -18
  175. package/dist/pipeline/warnings.js.map +0 -1
  176. package/dist/plugins/okhsl-plugin.d.ts +0 -35
  177. package/dist/plugins/okhsl-plugin.js +0 -98
  178. package/dist/plugins/okhsl-plugin.js.map +0 -1
  179. package/dist/plugins/types.d.ts +0 -76
  180. package/dist/properties/index.js +0 -223
  181. package/dist/properties/index.js.map +0 -1
  182. package/dist/properties/property-type-resolver.d.ts +0 -24
  183. package/dist/properties/property-type-resolver.js +0 -91
  184. package/dist/properties/property-type-resolver.js.map +0 -1
  185. package/dist/ssr/astro.js.map +0 -1
  186. package/dist/ssr/async-storage.d.ts +0 -17
  187. package/dist/ssr/async-storage.js.map +0 -1
  188. package/dist/ssr/collect-auto-properties.js +0 -40
  189. package/dist/ssr/collect-auto-properties.js.map +0 -1
  190. package/dist/ssr/collector.d.ts +0 -85
  191. package/dist/ssr/collector.js +0 -183
  192. package/dist/ssr/collector.js.map +0 -1
  193. package/dist/ssr/context.d.ts +0 -8
  194. package/dist/ssr/context.js +0 -14
  195. package/dist/ssr/context.js.map +0 -1
  196. package/dist/ssr/format-global-rules.js.map +0 -1
  197. package/dist/ssr/format-keyframes.js +0 -70
  198. package/dist/ssr/format-keyframes.js.map +0 -1
  199. package/dist/ssr/format-property.js +0 -50
  200. package/dist/ssr/format-property.js.map +0 -1
  201. package/dist/ssr/format-rules.js.map +0 -1
  202. package/dist/ssr/hydrate.d.ts +0 -22
  203. package/dist/ssr/hydrate.js +0 -50
  204. package/dist/ssr/hydrate.js.map +0 -1
  205. package/dist/ssr/ssr-collector-ref.js +0 -12
  206. package/dist/ssr/ssr-collector-ref.js.map +0 -1
  207. package/dist/states/index.d.ts +0 -49
  208. package/dist/states/index.js +0 -169
  209. package/dist/states/index.js.map +0 -1
  210. package/dist/static/tastyStatic.d.ts +0 -46
  211. package/dist/static/tastyStatic.js +0 -31
  212. package/dist/static/tastyStatic.js.map +0 -1
  213. package/dist/static/types.d.ts +0 -49
  214. package/dist/static/types.js +0 -24
  215. package/dist/static/types.js.map +0 -1
  216. package/dist/styles/align.d.ts +0 -15
  217. package/dist/styles/align.js +0 -14
  218. package/dist/styles/align.js.map +0 -1
  219. package/dist/styles/border.d.ts +0 -25
  220. package/dist/styles/border.js +0 -114
  221. package/dist/styles/border.js.map +0 -1
  222. package/dist/styles/color.d.ts +0 -14
  223. package/dist/styles/color.js +0 -27
  224. package/dist/styles/color.js.map +0 -1
  225. package/dist/styles/createStyle.js +0 -80
  226. package/dist/styles/createStyle.js.map +0 -1
  227. package/dist/styles/dimension.js +0 -97
  228. package/dist/styles/dimension.js.map +0 -1
  229. package/dist/styles/display.d.ts +0 -37
  230. package/dist/styles/display.js +0 -67
  231. package/dist/styles/display.js.map +0 -1
  232. package/dist/styles/fade.d.ts +0 -15
  233. package/dist/styles/fade.js +0 -58
  234. package/dist/styles/fade.js.map +0 -1
  235. package/dist/styles/fill.d.ts +0 -42
  236. package/dist/styles/fill.js +0 -52
  237. package/dist/styles/fill.js.map +0 -1
  238. package/dist/styles/flow.d.ts +0 -16
  239. package/dist/styles/flow.js +0 -12
  240. package/dist/styles/flow.js.map +0 -1
  241. package/dist/styles/gap.d.ts +0 -31
  242. package/dist/styles/gap.js +0 -37
  243. package/dist/styles/gap.js.map +0 -1
  244. package/dist/styles/height.d.ts +0 -17
  245. package/dist/styles/height.js +0 -20
  246. package/dist/styles/height.js.map +0 -1
  247. package/dist/styles/index.d.ts +0 -2
  248. package/dist/styles/index.js +0 -9
  249. package/dist/styles/index.js.map +0 -1
  250. package/dist/styles/inset.d.ts +0 -52
  251. package/dist/styles/inset.js +0 -150
  252. package/dist/styles/inset.js.map +0 -1
  253. package/dist/styles/justify.d.ts +0 -15
  254. package/dist/styles/justify.js +0 -14
  255. package/dist/styles/justify.js.map +0 -1
  256. package/dist/styles/list.d.ts +0 -16
  257. package/dist/styles/list.js +0 -98
  258. package/dist/styles/list.js.map +0 -1
  259. package/dist/styles/margin.d.ts +0 -24
  260. package/dist/styles/margin.js +0 -104
  261. package/dist/styles/margin.js.map +0 -1
  262. package/dist/styles/outline.d.ts +0 -29
  263. package/dist/styles/outline.js +0 -65
  264. package/dist/styles/outline.js.map +0 -1
  265. package/dist/styles/padding.d.ts +0 -24
  266. package/dist/styles/padding.js +0 -104
  267. package/dist/styles/padding.js.map +0 -1
  268. package/dist/styles/predefined.d.ts +0 -71
  269. package/dist/styles/predefined.js +0 -238
  270. package/dist/styles/predefined.js.map +0 -1
  271. package/dist/styles/preset.d.ts +0 -47
  272. package/dist/styles/preset.js +0 -126
  273. package/dist/styles/preset.js.map +0 -1
  274. package/dist/styles/radius.d.ts +0 -14
  275. package/dist/styles/radius.js +0 -51
  276. package/dist/styles/radius.js.map +0 -1
  277. package/dist/styles/scrollbar.d.ts +0 -25
  278. package/dist/styles/scrollbar.js +0 -48
  279. package/dist/styles/scrollbar.js.map +0 -1
  280. package/dist/styles/shadow.d.ts +0 -14
  281. package/dist/styles/shadow.js +0 -24
  282. package/dist/styles/shadow.js.map +0 -1
  283. package/dist/styles/transition.d.ts +0 -14
  284. package/dist/styles/transition.js +0 -158
  285. package/dist/styles/transition.js.map +0 -1
  286. package/dist/styles/types.d.ts +0 -508
  287. package/dist/styles/width.d.ts +0 -17
  288. package/dist/styles/width.js +0 -20
  289. package/dist/styles/width.js.map +0 -1
  290. package/dist/tasty.d.ts +0 -981
  291. package/dist/tasty.js +0 -219
  292. package/dist/tasty.js.map +0 -1
  293. package/dist/types.d.ts +0 -184
  294. package/dist/utils/cache-wrapper.js +0 -22
  295. package/dist/utils/cache-wrapper.js.map +0 -1
  296. package/dist/utils/case-converter.js +0 -8
  297. package/dist/utils/case-converter.js.map +0 -1
  298. package/dist/utils/color-math.d.ts +0 -45
  299. package/dist/utils/color-math.js +0 -749
  300. package/dist/utils/color-math.js.map +0 -1
  301. package/dist/utils/color-space.d.ts +0 -5
  302. package/dist/utils/color-space.js +0 -228
  303. package/dist/utils/color-space.js.map +0 -1
  304. package/dist/utils/colors.d.ts +0 -5
  305. package/dist/utils/colors.js +0 -11
  306. package/dist/utils/colors.js.map +0 -1
  307. package/dist/utils/css-types.d.ts +0 -7
  308. package/dist/utils/dotize.d.ts +0 -26
  309. package/dist/utils/dotize.js +0 -122
  310. package/dist/utils/dotize.js.map +0 -1
  311. package/dist/utils/filter-base-props.d.ts +0 -15
  312. package/dist/utils/filter-base-props.js +0 -45
  313. package/dist/utils/filter-base-props.js.map +0 -1
  314. package/dist/utils/get-display-name.d.ts +0 -7
  315. package/dist/utils/get-display-name.js +0 -10
  316. package/dist/utils/get-display-name.js.map +0 -1
  317. package/dist/utils/has-keys.js +0 -13
  318. package/dist/utils/has-keys.js.map +0 -1
  319. package/dist/utils/is-dev-env.js +0 -19
  320. package/dist/utils/is-dev-env.js.map +0 -1
  321. package/dist/utils/is-valid-element-type.js +0 -15
  322. package/dist/utils/is-valid-element-type.js.map +0 -1
  323. package/dist/utils/merge-styles.js.map +0 -1
  324. package/dist/utils/mod-attrs.d.ts +0 -8
  325. package/dist/utils/mod-attrs.js +0 -21
  326. package/dist/utils/mod-attrs.js.map +0 -1
  327. package/dist/utils/process-tokens.d.ts +0 -21
  328. package/dist/utils/process-tokens.js +0 -91
  329. package/dist/utils/process-tokens.js.map +0 -1
  330. package/dist/utils/resolve-recipes.d.ts +0 -17
  331. package/dist/utils/resolve-recipes.js.map +0 -1
  332. package/dist/utils/selector-transform.js +0 -32
  333. package/dist/utils/selector-transform.js.map +0 -1
  334. package/dist/utils/string.js +0 -8
  335. package/dist/utils/string.js.map +0 -1
  336. package/dist/utils/styles.d.ts +0 -101
  337. package/dist/utils/styles.js +0 -223
  338. package/dist/utils/styles.js.map +0 -1
  339. package/dist/utils/typography.d.ts +0 -47
  340. package/dist/utils/typography.js +0 -43
  341. package/dist/utils/typography.js.map +0 -1
  342. package/dist/utils/warnings.d.ts +0 -16
  343. package/dist/utils/warnings.js +0 -16
  344. package/dist/utils/warnings.js.map +0 -1
  345. package/dist/zero/css-writer.d.ts +0 -45
  346. package/dist/zero/css-writer.js +0 -74
  347. package/dist/zero/css-writer.js.map +0 -1
  348. package/dist/zero/extractor.d.ts +0 -24
  349. package/dist/zero/extractor.js.map +0 -1
  350. package/docs/PIPELINE.md +0 -519
  351. package/docs/runtime.md +0 -291
@@ -1,104 +0,0 @@
1
- import { DIRECTIONS, filterMods, parseStyle } from "../utils/styles.js";
2
-
3
- //#region src/styles/margin.ts
4
- /**
5
- * Parse a margin value and return the first processed value
6
- */
7
- function parseMarginValue(value) {
8
- if (typeof value === "number") return `${value}px`;
9
- if (!value) return null;
10
- if (value === true) value = "1x";
11
- const { values } = parseStyle(value).groups[0] ?? { values: [] };
12
- return values[0] || "var(--gap)";
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 : ["var(--gap)"],
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 margin output shorthand.
40
- */
41
- function optimizeMargin(dirs) {
42
- const { top, right, bottom, left } = dirs;
43
- if (top === right && right === bottom && bottom === left) return { margin: top };
44
- if (top === bottom && left === right) return { margin: `${top} ${left}` };
45
- return { margin: `${top} ${right} ${bottom} ${left}` };
46
- }
47
- function marginStyle({ margin, marginBlock, marginInline, marginTop, marginRight, marginBottom, marginLeft }) {
48
- if (margin == null && marginBlock == null && marginInline == null && marginTop == null && marginRight == null && marginBottom == null && marginLeft == null) return {};
49
- const dirs = {
50
- top: "0",
51
- right: "0",
52
- bottom: "0",
53
- left: "0"
54
- };
55
- if (margin != null) {
56
- if (typeof margin === "number") dirs.top = dirs.right = dirs.bottom = dirs.left = `${margin}px`;
57
- else if (margin === true) margin = "1x";
58
- if (typeof margin === "string" && margin) {
59
- const groups = parseStyle(margin).groups ?? [];
60
- for (const group of groups) {
61
- const { values, directions } = extractGroupData(group);
62
- applyGroup(dirs, values, directions);
63
- }
64
- }
65
- }
66
- if (marginBlock != null) {
67
- const val = parseMarginValue(marginBlock);
68
- if (val) dirs.top = dirs.bottom = val;
69
- }
70
- if (marginInline != null) {
71
- const val = parseMarginValue(marginInline);
72
- if (val) dirs.left = dirs.right = val;
73
- }
74
- if (marginTop != null) {
75
- const val = parseMarginValue(marginTop);
76
- if (val) dirs.top = val;
77
- }
78
- if (marginRight != null) {
79
- const val = parseMarginValue(marginRight);
80
- if (val) dirs.right = val;
81
- }
82
- if (marginBottom != null) {
83
- const val = parseMarginValue(marginBottom);
84
- if (val) dirs.bottom = val;
85
- }
86
- if (marginLeft != null) {
87
- const val = parseMarginValue(marginLeft);
88
- if (val) dirs.left = val;
89
- }
90
- return optimizeMargin(dirs);
91
- }
92
- marginStyle.__lookupStyles = [
93
- "margin",
94
- "marginTop",
95
- "marginRight",
96
- "marginBottom",
97
- "marginLeft",
98
- "marginBlock",
99
- "marginInline"
100
- ];
101
-
102
- //#endregion
103
- export { marginStyle };
104
- //# sourceMappingURL=margin.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"margin.js","names":[],"sources":["../../src/styles/margin.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 a margin value and return the first processed value\n */\nfunction parseMarginValue(value: string | number | boolean): string | null {\n if (typeof value === 'number') return `${value}px`;\n if (!value) return null;\n if (value === true) value = '1x';\n\n const { values } = parseStyle(value).groups[0] ?? { values: [] };\n\n return values[0] || 'var(--gap)';\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 : ['var(--gap)'],\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 margin output shorthand.\n */\nfunction optimizeMargin(dirs: Record<Direction, string>): {\n margin: string;\n} {\n const { top, right, bottom, left } = dirs;\n if (top === right && right === bottom && bottom === left) {\n return { margin: top };\n }\n if (top === bottom && left === right) {\n return { margin: `${top} ${left}` };\n }\n return { margin: `${top} ${right} ${bottom} ${left}` };\n}\n\nexport function marginStyle({\n margin,\n marginBlock,\n marginInline,\n marginTop,\n marginRight,\n marginBottom,\n marginLeft,\n}: {\n margin?: string | number | boolean;\n marginBlock?: string | number | boolean;\n marginInline?: string | number | boolean;\n marginTop?: string | number | boolean;\n marginRight?: string | number | boolean;\n marginBottom?: string | number | boolean;\n marginLeft?: string | number | boolean;\n}) {\n if (\n margin == null &&\n marginBlock == null &&\n marginInline == null &&\n marginTop == null &&\n marginRight == null &&\n marginBottom == null &&\n marginLeft == null\n ) {\n return {};\n }\n\n const dirs: Record<Direction, string> = {\n top: '0',\n right: '0',\n bottom: '0',\n left: '0',\n };\n\n // Priority 1 (lowest): margin\n if (margin != null) {\n if (typeof margin === 'number') {\n const v = `${margin}px`;\n dirs.top = dirs.right = dirs.bottom = dirs.left = v;\n } else if (margin === true) {\n margin = '1x';\n }\n\n if (typeof margin === 'string' && margin) {\n const processed = parseStyle(margin);\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): marginBlock/marginInline\n if (marginBlock != null) {\n const val = parseMarginValue(marginBlock);\n if (val) dirs.top = dirs.bottom = val;\n }\n if (marginInline != null) {\n const val = parseMarginValue(marginInline);\n if (val) dirs.left = dirs.right = val;\n }\n\n // Priority 3 (highest): individual directions\n if (marginTop != null) {\n const val = parseMarginValue(marginTop);\n if (val) dirs.top = val;\n }\n if (marginRight != null) {\n const val = parseMarginValue(marginRight);\n if (val) dirs.right = val;\n }\n if (marginBottom != null) {\n const val = parseMarginValue(marginBottom);\n if (val) dirs.bottom = val;\n }\n if (marginLeft != null) {\n const val = parseMarginValue(marginLeft);\n if (val) dirs.left = val;\n }\n\n return optimizeMargin(dirs);\n}\n\nmarginStyle.__lookupStyles = [\n 'margin',\n 'marginTop',\n 'marginRight',\n 'marginBottom',\n 'marginLeft',\n 'marginBlock',\n 'marginInline',\n];\n"],"mappings":";;;;;;AAQA,SAAS,iBAAiB,OAAiD;AACzE,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,aAAa;EAC/C,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,eAAe,MAEtB;CACA,MAAM,EAAE,KAAK,OAAO,QAAQ,SAAS;AACrC,KAAI,QAAQ,SAAS,UAAU,UAAU,WAAW,KAClD,QAAO,EAAE,QAAQ,KAAK;AAExB,KAAI,QAAQ,UAAU,SAAS,MAC7B,QAAO,EAAE,QAAQ,GAAG,IAAI,GAAG,QAAQ;AAErC,QAAO,EAAE,QAAQ,GAAG,IAAI,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ;;AAGxD,SAAgB,YAAY,EAC1B,QACA,aACA,cACA,WACA,aACA,cACA,cASC;AACD,KACE,UAAU,QACV,eAAe,QACf,gBAAgB,QAChB,aAAa,QACb,eAAe,QACf,gBAAgB,QAChB,cAAc,KAEd,QAAO,EAAE;CAGX,MAAM,OAAkC;EACtC,KAAK;EACL,OAAO;EACP,QAAQ;EACR,MAAM;EACP;AAGD,KAAI,UAAU,MAAM;AAClB,MAAI,OAAO,WAAW,SAEpB,MAAK,MAAM,KAAK,QAAQ,KAAK,SAAS,KAAK,OADjC,GAAG,OAAO;WAEX,WAAW,KACpB,UAAS;AAGX,MAAI,OAAO,WAAW,YAAY,QAAQ;GAExC,MAAM,SADY,WAAW,OAAO,CACX,UAAU,EAAE;AAErC,QAAK,MAAM,SAAS,QAAQ;IAC1B,MAAM,EAAE,QAAQ,eAAe,iBAAiB,MAAM;AACtD,eAAW,MAAM,QAAQ,WAAW;;;;AAM1C,KAAI,eAAe,MAAM;EACvB,MAAM,MAAM,iBAAiB,YAAY;AACzC,MAAI,IAAK,MAAK,MAAM,KAAK,SAAS;;AAEpC,KAAI,gBAAgB,MAAM;EACxB,MAAM,MAAM,iBAAiB,aAAa;AAC1C,MAAI,IAAK,MAAK,OAAO,KAAK,QAAQ;;AAIpC,KAAI,aAAa,MAAM;EACrB,MAAM,MAAM,iBAAiB,UAAU;AACvC,MAAI,IAAK,MAAK,MAAM;;AAEtB,KAAI,eAAe,MAAM;EACvB,MAAM,MAAM,iBAAiB,YAAY;AACzC,MAAI,IAAK,MAAK,QAAQ;;AAExB,KAAI,gBAAgB,MAAM;EACxB,MAAM,MAAM,iBAAiB,aAAa;AAC1C,MAAI,IAAK,MAAK,SAAS;;AAEzB,KAAI,cAAc,MAAM;EACtB,MAAM,MAAM,iBAAiB,WAAW;AACxC,MAAI,IAAK,MAAK,OAAO;;AAGvB,QAAO,eAAe,KAAK;;AAG7B,YAAY,iBAAiB;CAC3B;CACA;CACA;CACA;CACA;CACA;CACA;CACD"}
@@ -1,29 +0,0 @@
1
- //#region src/styles/outline.d.ts
2
- interface OutlineStyleProps {
3
- outline?: string | boolean | number;
4
- outlineOffset?: string | number;
5
- }
6
- /**
7
- * Generates CSS for outline property with optional offset.
8
- *
9
- * Syntax:
10
- * - `outline="2px solid #red"` - outline only
11
- * - `outline="2px solid #red / 4px"` - outline with offset (slash separator)
12
- * - `outline="2px / 4px"` - width with offset (simpler form)
13
- * - `outline={true}` - default 1ow solid outline
14
- * - `outlineOffset="4px"` - offset as separate prop (can be combined with outline)
15
- *
16
- * Priority: slash syntax in outline takes precedence over outlineOffset prop
17
- *
18
- * @return CSS properties for outline and optionally outline-offset
19
- */
20
- declare function outlineStyle({
21
- outline,
22
- outlineOffset
23
- }: OutlineStyleProps): Record<string, string> | undefined;
24
- declare namespace outlineStyle {
25
- var __lookupStyles: string[];
26
- }
27
- //#endregion
28
- export { outlineStyle };
29
- //# sourceMappingURL=outline.d.ts.map
@@ -1,65 +0,0 @@
1
- import { filterMods, parseStyle } from "../utils/styles.js";
2
-
3
- //#region src/styles/outline.ts
4
- const BORDER_STYLES = [
5
- "none",
6
- "hidden",
7
- "dotted",
8
- "dashed",
9
- "solid",
10
- "double",
11
- "groove",
12
- "ridge",
13
- "inset",
14
- "outset"
15
- ];
16
- /**
17
- * Generates CSS for outline property with optional offset.
18
- *
19
- * Syntax:
20
- * - `outline="2px solid #red"` - outline only
21
- * - `outline="2px solid #red / 4px"` - outline with offset (slash separator)
22
- * - `outline="2px / 4px"` - width with offset (simpler form)
23
- * - `outline={true}` - default 1ow solid outline
24
- * - `outlineOffset="4px"` - offset as separate prop (can be combined with outline)
25
- *
26
- * Priority: slash syntax in outline takes precedence over outlineOffset prop
27
- *
28
- * @return CSS properties for outline and optionally outline-offset
29
- */
30
- function outlineStyle({ outline, outlineOffset }) {
31
- const result = {};
32
- if (outline != null && outline !== false) {
33
- let outlineValue = outline;
34
- if (outline === true) outlineValue = "1ow";
35
- if (outline === 0) outlineValue = "0";
36
- const group = parseStyle(String(outlineValue)).groups[0];
37
- if (group) {
38
- const { parts } = group;
39
- const outlinePart = parts[0] ?? {
40
- values: [],
41
- mods: [],
42
- colors: []
43
- };
44
- const offsetPart = parts[1];
45
- const typeMods = filterMods(outlinePart.mods, BORDER_STYLES);
46
- result["outline"] = [
47
- outlinePart.values[0] || "var(--outline-width)",
48
- typeMods[0] || "solid",
49
- outlinePart.colors[0] || "var(--outline-color)"
50
- ].join(" ");
51
- if (offsetPart?.values[0]) result["outline-offset"] = offsetPart.values[0];
52
- }
53
- }
54
- if (outlineOffset != null && !result["outline-offset"]) {
55
- const offsetValue = typeof outlineOffset === "number" ? `${outlineOffset}px` : outlineOffset;
56
- result["outline-offset"] = parseStyle(offsetValue).groups[0]?.values[0] || offsetValue;
57
- }
58
- if (Object.keys(result).length === 0) return;
59
- return result;
60
- }
61
- outlineStyle.__lookupStyles = ["outline", "outlineOffset"];
62
-
63
- //#endregion
64
- export { outlineStyle };
65
- //# sourceMappingURL=outline.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"outline.js","names":[],"sources":["../../src/styles/outline.ts"],"sourcesContent":["import { filterMods, parseStyle } from '../utils/styles';\n\nconst BORDER_STYLES = [\n 'none',\n 'hidden',\n 'dotted',\n 'dashed',\n 'solid',\n 'double',\n 'groove',\n 'ridge',\n 'inset',\n 'outset',\n];\n\ninterface OutlineStyleProps {\n outline?: string | boolean | number;\n outlineOffset?: string | number;\n}\n\n/**\n * Generates CSS for outline property with optional offset.\n *\n * Syntax:\n * - `outline=\"2px solid #red\"` - outline only\n * - `outline=\"2px solid #red / 4px\"` - outline with offset (slash separator)\n * - `outline=\"2px / 4px\"` - width with offset (simpler form)\n * - `outline={true}` - default 1ow solid outline\n * - `outlineOffset=\"4px\"` - offset as separate prop (can be combined with outline)\n *\n * Priority: slash syntax in outline takes precedence over outlineOffset prop\n *\n * @return CSS properties for outline and optionally outline-offset\n */\nexport function outlineStyle({ outline, outlineOffset }: OutlineStyleProps) {\n const result: Record<string, string> = {};\n\n // Handle outline (0 is valid - means no outline)\n if (outline != null && outline !== false) {\n let outlineValue: string | boolean | number = outline;\n if (outline === true) outlineValue = '1ow';\n if (outline === 0) outlineValue = '0';\n\n const processed = parseStyle(String(outlineValue));\n const group = processed.groups[0];\n\n if (group) {\n const { parts } = group;\n const outlinePart = parts[0] ?? { values: [], mods: [], colors: [] };\n const offsetPart = parts[1];\n\n const typeMods = filterMods(outlinePart.mods, BORDER_STYLES);\n\n const value = outlinePart.values[0] || 'var(--outline-width)';\n const type = typeMods[0] || 'solid';\n const outlineColor = outlinePart.colors[0] || 'var(--outline-color)';\n\n result['outline'] = [value, type, outlineColor].join(' ');\n\n // Check for offset in second part (after /) - takes precedence\n if (offsetPart?.values[0]) {\n result['outline-offset'] = offsetPart.values[0];\n }\n }\n }\n\n // Handle outlineOffset prop (only if not already set by slash syntax)\n if (outlineOffset != null && !result['outline-offset']) {\n const offsetValue =\n typeof outlineOffset === 'number' ? `${outlineOffset}px` : outlineOffset;\n const processed = parseStyle(offsetValue);\n result['outline-offset'] = processed.groups[0]?.values[0] || offsetValue;\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\noutlineStyle.__lookupStyles = ['outline', 'outlineOffset'];\n"],"mappings":";;;AAEA,MAAM,gBAAgB;CACpB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;;;;;;;;;;;;;;;AAqBD,SAAgB,aAAa,EAAE,SAAS,iBAAoC;CAC1E,MAAM,SAAiC,EAAE;AAGzC,KAAI,WAAW,QAAQ,YAAY,OAAO;EACxC,IAAI,eAA0C;AAC9C,MAAI,YAAY,KAAM,gBAAe;AACrC,MAAI,YAAY,EAAG,gBAAe;EAGlC,MAAM,QADY,WAAW,OAAO,aAAa,CAAC,CAC1B,OAAO;AAE/B,MAAI,OAAO;GACT,MAAM,EAAE,UAAU;GAClB,MAAM,cAAc,MAAM,MAAM;IAAE,QAAQ,EAAE;IAAE,MAAM,EAAE;IAAE,QAAQ,EAAE;IAAE;GACpE,MAAM,aAAa,MAAM;GAEzB,MAAM,WAAW,WAAW,YAAY,MAAM,cAAc;AAM5D,UAAO,aAAa;IAJN,YAAY,OAAO,MAAM;IAC1B,SAAS,MAAM;IACP,YAAY,OAAO,MAAM;IAEC,CAAC,KAAK,IAAI;AAGzD,OAAI,YAAY,OAAO,GACrB,QAAO,oBAAoB,WAAW,OAAO;;;AAMnD,KAAI,iBAAiB,QAAQ,CAAC,OAAO,mBAAmB;EACtD,MAAM,cACJ,OAAO,kBAAkB,WAAW,GAAG,cAAc,MAAM;AAE7D,SAAO,oBADW,WAAW,YAAY,CACJ,OAAO,IAAI,OAAO,MAAM;;AAI/D,KAAI,OAAO,KAAK,OAAO,CAAC,WAAW,EACjC;AAGF,QAAO;;AAGT,aAAa,iBAAiB,CAAC,WAAW,gBAAgB"}
@@ -1,24 +0,0 @@
1
- //#region src/styles/padding.d.ts
2
- declare function paddingStyle({
3
- padding,
4
- paddingBlock,
5
- paddingInline,
6
- paddingTop,
7
- paddingRight,
8
- paddingBottom,
9
- paddingLeft
10
- }: {
11
- padding?: string | number | boolean;
12
- paddingBlock?: string | number | boolean;
13
- paddingInline?: string | number | boolean;
14
- paddingTop?: string | number | boolean;
15
- paddingRight?: string | number | boolean;
16
- paddingBottom?: string | number | boolean;
17
- paddingLeft?: string | number | boolean;
18
- }): {};
19
- declare namespace paddingStyle {
20
- var __lookupStyles: string[];
21
- }
22
- //#endregion
23
- export { paddingStyle };
24
- //# sourceMappingURL=padding.d.ts.map
@@ -1,104 +0,0 @@
1
- import { DIRECTIONS, filterMods, parseStyle } from "../utils/styles.js";
2
-
3
- //#region src/styles/padding.ts
4
- /**
5
- * Parse a padding value and return the first processed value
6
- */
7
- function parsePaddingValue(value) {
8
- if (typeof value === "number") return `${value}px`;
9
- if (!value) return null;
10
- if (value === true) value = "1x";
11
- const { values } = parseStyle(value).groups[0] ?? { values: [] };
12
- return values[0] || "var(--gap)";
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 : ["var(--gap)"],
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 padding output shorthand.
40
- */
41
- function optimizePadding(dirs) {
42
- const { top, right, bottom, left } = dirs;
43
- if (top === right && right === bottom && bottom === left) return { padding: top };
44
- if (top === bottom && left === right) return { padding: `${top} ${left}` };
45
- return { padding: `${top} ${right} ${bottom} ${left}` };
46
- }
47
- function paddingStyle({ padding, paddingBlock, paddingInline, paddingTop, paddingRight, paddingBottom, paddingLeft }) {
48
- if (padding == null && paddingBlock == null && paddingInline == null && paddingTop == null && paddingRight == null && paddingBottom == null && paddingLeft == null) return {};
49
- const dirs = {
50
- top: "0",
51
- right: "0",
52
- bottom: "0",
53
- left: "0"
54
- };
55
- if (padding != null) {
56
- if (typeof padding === "number") dirs.top = dirs.right = dirs.bottom = dirs.left = `${padding}px`;
57
- else if (padding === true) padding = "1x";
58
- if (typeof padding === "string" && padding) {
59
- const groups = parseStyle(padding).groups ?? [];
60
- for (const group of groups) {
61
- const { values, directions } = extractGroupData(group);
62
- applyGroup(dirs, values, directions);
63
- }
64
- }
65
- }
66
- if (paddingBlock != null) {
67
- const val = parsePaddingValue(paddingBlock);
68
- if (val) dirs.top = dirs.bottom = val;
69
- }
70
- if (paddingInline != null) {
71
- const val = parsePaddingValue(paddingInline);
72
- if (val) dirs.left = dirs.right = val;
73
- }
74
- if (paddingTop != null) {
75
- const val = parsePaddingValue(paddingTop);
76
- if (val) dirs.top = val;
77
- }
78
- if (paddingRight != null) {
79
- const val = parsePaddingValue(paddingRight);
80
- if (val) dirs.right = val;
81
- }
82
- if (paddingBottom != null) {
83
- const val = parsePaddingValue(paddingBottom);
84
- if (val) dirs.bottom = val;
85
- }
86
- if (paddingLeft != null) {
87
- const val = parsePaddingValue(paddingLeft);
88
- if (val) dirs.left = val;
89
- }
90
- return optimizePadding(dirs);
91
- }
92
- paddingStyle.__lookupStyles = [
93
- "padding",
94
- "paddingTop",
95
- "paddingRight",
96
- "paddingBottom",
97
- "paddingLeft",
98
- "paddingBlock",
99
- "paddingInline"
100
- ];
101
-
102
- //#endregion
103
- export { paddingStyle };
104
- //# sourceMappingURL=padding.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"padding.js","names":[],"sources":["../../src/styles/padding.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 a padding value and return the first processed value\n */\nfunction parsePaddingValue(value: string | number | boolean): string | null {\n if (typeof value === 'number') return `${value}px`;\n if (!value) return null;\n if (value === true) value = '1x';\n\n const { values } = parseStyle(value).groups[0] ?? { values: [] };\n\n return values[0] || 'var(--gap)';\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 : ['var(--gap)'],\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 padding output shorthand.\n */\nfunction optimizePadding(dirs: Record<Direction, string>): {\n padding: string;\n} {\n const { top, right, bottom, left } = dirs;\n if (top === right && right === bottom && bottom === left) {\n return { padding: top };\n }\n if (top === bottom && left === right) {\n return { padding: `${top} ${left}` };\n }\n return { padding: `${top} ${right} ${bottom} ${left}` };\n}\n\nexport function paddingStyle({\n padding,\n paddingBlock,\n paddingInline,\n paddingTop,\n paddingRight,\n paddingBottom,\n paddingLeft,\n}: {\n padding?: string | number | boolean;\n paddingBlock?: string | number | boolean;\n paddingInline?: string | number | boolean;\n paddingTop?: string | number | boolean;\n paddingRight?: string | number | boolean;\n paddingBottom?: string | number | boolean;\n paddingLeft?: string | number | boolean;\n}) {\n if (\n padding == null &&\n paddingBlock == null &&\n paddingInline == null &&\n paddingTop == null &&\n paddingRight == null &&\n paddingBottom == null &&\n paddingLeft == null\n ) {\n return {};\n }\n\n const dirs: Record<Direction, string> = {\n top: '0',\n right: '0',\n bottom: '0',\n left: '0',\n };\n\n // Priority 1 (lowest): padding\n if (padding != null) {\n if (typeof padding === 'number') {\n const v = `${padding}px`;\n dirs.top = dirs.right = dirs.bottom = dirs.left = v;\n } else if (padding === true) {\n padding = '1x';\n }\n\n if (typeof padding === 'string' && padding) {\n const processed = parseStyle(padding);\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): paddingBlock/paddingInline\n if (paddingBlock != null) {\n const val = parsePaddingValue(paddingBlock);\n if (val) dirs.top = dirs.bottom = val;\n }\n if (paddingInline != null) {\n const val = parsePaddingValue(paddingInline);\n if (val) dirs.left = dirs.right = val;\n }\n\n // Priority 3 (highest): individual directions\n if (paddingTop != null) {\n const val = parsePaddingValue(paddingTop);\n if (val) dirs.top = val;\n }\n if (paddingRight != null) {\n const val = parsePaddingValue(paddingRight);\n if (val) dirs.right = val;\n }\n if (paddingBottom != null) {\n const val = parsePaddingValue(paddingBottom);\n if (val) dirs.bottom = val;\n }\n if (paddingLeft != null) {\n const val = parsePaddingValue(paddingLeft);\n if (val) dirs.left = val;\n }\n\n return optimizePadding(dirs);\n}\n\npaddingStyle.__lookupStyles = [\n 'padding',\n 'paddingTop',\n 'paddingRight',\n 'paddingBottom',\n 'paddingLeft',\n 'paddingBlock',\n 'paddingInline',\n];\n"],"mappings":";;;;;;AAQA,SAAS,kBAAkB,OAAiD;AAC1E,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,aAAa;EAC/C,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,gBAAgB,MAEvB;CACA,MAAM,EAAE,KAAK,OAAO,QAAQ,SAAS;AACrC,KAAI,QAAQ,SAAS,UAAU,UAAU,WAAW,KAClD,QAAO,EAAE,SAAS,KAAK;AAEzB,KAAI,QAAQ,UAAU,SAAS,MAC7B,QAAO,EAAE,SAAS,GAAG,IAAI,GAAG,QAAQ;AAEtC,QAAO,EAAE,SAAS,GAAG,IAAI,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ;;AAGzD,SAAgB,aAAa,EAC3B,SACA,cACA,eACA,YACA,cACA,eACA,eASC;AACD,KACE,WAAW,QACX,gBAAgB,QAChB,iBAAiB,QACjB,cAAc,QACd,gBAAgB,QAChB,iBAAiB,QACjB,eAAe,KAEf,QAAO,EAAE;CAGX,MAAM,OAAkC;EACtC,KAAK;EACL,OAAO;EACP,QAAQ;EACR,MAAM;EACP;AAGD,KAAI,WAAW,MAAM;AACnB,MAAI,OAAO,YAAY,SAErB,MAAK,MAAM,KAAK,QAAQ,KAAK,SAAS,KAAK,OADjC,GAAG,QAAQ;WAEZ,YAAY,KACrB,WAAU;AAGZ,MAAI,OAAO,YAAY,YAAY,SAAS;GAE1C,MAAM,SADY,WAAW,QAAQ,CACZ,UAAU,EAAE;AAErC,QAAK,MAAM,SAAS,QAAQ;IAC1B,MAAM,EAAE,QAAQ,eAAe,iBAAiB,MAAM;AACtD,eAAW,MAAM,QAAQ,WAAW;;;;AAM1C,KAAI,gBAAgB,MAAM;EACxB,MAAM,MAAM,kBAAkB,aAAa;AAC3C,MAAI,IAAK,MAAK,MAAM,KAAK,SAAS;;AAEpC,KAAI,iBAAiB,MAAM;EACzB,MAAM,MAAM,kBAAkB,cAAc;AAC5C,MAAI,IAAK,MAAK,OAAO,KAAK,QAAQ;;AAIpC,KAAI,cAAc,MAAM;EACtB,MAAM,MAAM,kBAAkB,WAAW;AACzC,MAAI,IAAK,MAAK,MAAM;;AAEtB,KAAI,gBAAgB,MAAM;EACxB,MAAM,MAAM,kBAAkB,aAAa;AAC3C,MAAI,IAAK,MAAK,QAAQ;;AAExB,KAAI,iBAAiB,MAAM;EACzB,MAAM,MAAM,kBAAkB,cAAc;AAC5C,MAAI,IAAK,MAAK,SAAS;;AAEzB,KAAI,eAAe,MAAM;EACvB,MAAM,MAAM,kBAAkB,YAAY;AAC1C,MAAI,IAAK,MAAK,OAAO;;AAGvB,QAAO,gBAAgB,KAAK;;AAG9B,aAAa,iBAAiB;CAC5B;CACA;CACA;CACA;CACA;CACA;CACA;CACD"}
@@ -1,71 +0,0 @@
1
- import { alignStyle } from "./align.js";
2
- import { borderStyle } from "./border.js";
3
- import { colorStyle } from "./color.js";
4
- import { displayStyle } from "./display.js";
5
- import { fadeStyle } from "./fade.js";
6
- import { fillStyle, svgFillStyle } from "./fill.js";
7
- import { flowStyle } from "./flow.js";
8
- import { gapStyle } from "./gap.js";
9
- import { heightStyle } from "./height.js";
10
- import { insetStyle } from "./inset.js";
11
- import { justifyStyle } from "./justify.js";
12
- import { marginStyle } from "./margin.js";
13
- import { outlineStyle } from "./outline.js";
14
- import { paddingStyle } from "./padding.js";
15
- import { presetStyle } from "./preset.js";
16
- import { radiusStyle } from "./radius.js";
17
- import { scrollbarStyle } from "./scrollbar.js";
18
- import { shadowStyle } from "./shadow.js";
19
- import { transitionStyle } from "./transition.js";
20
- import { widthStyle } from "./width.js";
21
-
22
- //#region src/styles/predefined.d.ts
23
- /**
24
- * Exported object containing wrapped predefined style handlers.
25
- * Users can import and call these to extend or delegate to built-in behavior.
26
- *
27
- * Internal handlers use *Style suffix for searchability.
28
- * External API uses short names for convenience.
29
- *
30
- * @example
31
- * ```ts
32
- * import { styleHandlers, configure } from '@tenphi/tasty';
33
- *
34
- * configure({
35
- * handlers: {
36
- * fill: ({ fill }) => {
37
- * if (fill?.startsWith('gradient:')) {
38
- * return { background: fill.slice(9) };
39
- * }
40
- * return styleHandlers.fill({ fill });
41
- * },
42
- * },
43
- * });
44
- * ```
45
- */
46
- declare const styleHandlers: {
47
- readonly align: typeof alignStyle;
48
- readonly border: typeof borderStyle;
49
- readonly color: typeof colorStyle;
50
- readonly display: typeof displayStyle;
51
- readonly fade: typeof fadeStyle;
52
- readonly fill: typeof fillStyle;
53
- readonly svgFill: typeof svgFillStyle;
54
- readonly flow: typeof flowStyle;
55
- readonly gap: typeof gapStyle;
56
- readonly height: typeof heightStyle;
57
- readonly inset: typeof insetStyle;
58
- readonly justify: typeof justifyStyle;
59
- readonly margin: typeof marginStyle;
60
- readonly outline: typeof outlineStyle;
61
- readonly padding: typeof paddingStyle;
62
- readonly preset: typeof presetStyle;
63
- readonly radius: typeof radiusStyle;
64
- readonly scrollbar: typeof scrollbarStyle;
65
- readonly shadow: typeof shadowStyle;
66
- readonly transition: typeof transitionStyle;
67
- readonly width: typeof widthStyle;
68
- };
69
- //#endregion
70
- export { styleHandlers };
71
- //# sourceMappingURL=predefined.d.ts.map
@@ -1,238 +0,0 @@
1
- import { isDevEnv } from "../utils/is-dev-env.js";
2
- import { alignStyle } from "./align.js";
3
- import { borderStyle } from "./border.js";
4
- import { createStyle } from "./createStyle.js";
5
- import { colorStyle } from "./color.js";
6
- import { displayStyle } from "./display.js";
7
- import { fadeStyle } from "./fade.js";
8
- import { fillStyle, svgFillStyle } from "./fill.js";
9
- import { flowStyle } from "./flow.js";
10
- import { gapStyle } from "./gap.js";
11
- import { heightStyle } from "./height.js";
12
- import { insetStyle } from "./inset.js";
13
- import { justifyStyle } from "./justify.js";
14
- import { marginStyle } from "./margin.js";
15
- import { outlineStyle } from "./outline.js";
16
- import { paddingStyle } from "./padding.js";
17
- import { presetStyle } from "./preset.js";
18
- import { radiusStyle } from "./radius.js";
19
- import { scrollbarStyle } from "./scrollbar.js";
20
- import { shadowStyle } from "./shadow.js";
21
- import { transitionStyle } from "./transition.js";
22
- import { widthStyle } from "./width.js";
23
-
24
- //#region src/styles/predefined.ts
25
- const devMode = isDevEnv();
26
- const columnsConverter = (val) => {
27
- if (typeof val === "number") return "minmax(1px, 1fr) ".repeat(val).trim();
28
- };
29
- const rowsConverter = (val) => {
30
- if (typeof val === "number") return "auto ".repeat(val).trim();
31
- };
32
- const STYLE_HANDLER_MAP = {};
33
- let initialHandlerMapSnapshot = null;
34
- /**
35
- * Capture a snapshot of the current STYLE_HANDLER_MAP.
36
- * Called after predefine() to preserve built-in handler state.
37
- */
38
- function captureInitialHandlerState() {
39
- initialHandlerMapSnapshot = {};
40
- for (const key of Object.keys(STYLE_HANDLER_MAP)) initialHandlerMapSnapshot[key] = [...STYLE_HANDLER_MAP[key]];
41
- }
42
- /**
43
- * Reset STYLE_HANDLER_MAP to the initial built-in state.
44
- * Called by resetConfig() to restore handlers after tests.
45
- */
46
- function resetHandlers() {
47
- if (!initialHandlerMapSnapshot) return;
48
- for (const key of Object.keys(STYLE_HANDLER_MAP)) delete STYLE_HANDLER_MAP[key];
49
- for (const key of Object.keys(initialHandlerMapSnapshot)) STYLE_HANDLER_MAP[key] = [...initialHandlerMapSnapshot[key]];
50
- }
51
- function defineCustomStyle(names, handler) {
52
- let handlerWithLookup;
53
- if (typeof names === "function") {
54
- handlerWithLookup = names;
55
- names = handlerWithLookup.__lookupStyles;
56
- } else if (handler) handlerWithLookup = Object.assign(handler, { __lookupStyles: names });
57
- else {
58
- console.warn("CubeUIKit: incorrect custom style definition: ", names);
59
- return;
60
- }
61
- if (Array.isArray(names)) names.forEach((name) => {
62
- if (!STYLE_HANDLER_MAP[name]) STYLE_HANDLER_MAP[name] = [];
63
- STYLE_HANDLER_MAP[name].push(handlerWithLookup);
64
- });
65
- }
66
- function defineStyleAlias(styleName, cssStyleName, converter) {
67
- const styleHandler = createStyle(styleName, cssStyleName, converter);
68
- if (!STYLE_HANDLER_MAP[styleName]) STYLE_HANDLER_MAP[styleName] = [];
69
- STYLE_HANDLER_MAP[styleName].push(styleHandler);
70
- }
71
- function predefine() {
72
- defineStyleAlias("gridAreas", "grid-template-areas");
73
- defineStyleAlias("gridColumns", "grid-template-columns", columnsConverter);
74
- defineStyleAlias("gridRows", "grid-template-rows", rowsConverter);
75
- defineStyleAlias("gridTemplate", "grid-template", (val) => {
76
- if (typeof val !== "string") return;
77
- return val.split("/").map((s, i) => (i ? columnsConverter : rowsConverter)(s)).join("/");
78
- });
79
- [
80
- displayStyle,
81
- transitionStyle,
82
- fillStyle,
83
- svgFillStyle,
84
- widthStyle,
85
- marginStyle,
86
- gapStyle,
87
- flowStyle,
88
- colorStyle,
89
- heightStyle,
90
- radiusStyle,
91
- borderStyle,
92
- shadowStyle,
93
- paddingStyle,
94
- alignStyle,
95
- justifyStyle,
96
- presetStyle,
97
- outlineStyle,
98
- scrollbarStyle,
99
- fadeStyle,
100
- insetStyle
101
- ].forEach((handler) => defineCustomStyle(handler));
102
- captureInitialHandlerState();
103
- return {
104
- STYLE_HANDLER_MAP,
105
- defineCustomStyle,
106
- defineStyleAlias
107
- };
108
- }
109
- /**
110
- * Normalize a handler definition to a StyleHandler with __lookupStyles.
111
- * - Function only: lookup styles inferred from key name
112
- * - [string, fn]: single lookup style
113
- * - [string[], fn]: multiple lookup styles
114
- */
115
- function normalizeHandlerDefinition(keyName, definition) {
116
- let handler;
117
- let lookupStyles;
118
- if (typeof definition === "function") {
119
- handler = definition;
120
- lookupStyles = [keyName];
121
- } else if (Array.isArray(definition)) {
122
- const [first, fn] = definition;
123
- if (typeof fn !== "function") throw new Error(`[Tasty] Invalid handler definition for "${keyName}". Tuple must have a function as the second element: [string, function] or [string[], function].`);
124
- handler = fn;
125
- if (typeof first === "string") lookupStyles = [first];
126
- else if (Array.isArray(first)) lookupStyles = first;
127
- else throw new Error(`[Tasty] Invalid handler definition for "${keyName}". First element must be a string or string array.`);
128
- } else throw new Error(`[Tasty] Invalid handler definition for "${keyName}". Expected function, [string, function], or [string[], function].`);
129
- validateHandler(keyName, handler, lookupStyles);
130
- const wrappedHandler = ((props) => handler(props));
131
- wrappedHandler.__lookupStyles = lookupStyles;
132
- return wrappedHandler;
133
- }
134
- /**
135
- * Validate a handler definition in development mode.
136
- */
137
- function validateHandler(name, handler, lookupStyles) {
138
- if (!devMode) return;
139
- if (typeof handler !== "function") console.warn(`[Tasty] Handler "${name}" is not a function. Handlers must be functions that return CSSMap, CSSMap[], or void.`);
140
- if (!lookupStyles || !Array.isArray(lookupStyles) || lookupStyles.length === 0) console.warn(`[Tasty] Handler "${name}" has invalid lookupStyles. Expected non-empty array of style names.`);
141
- }
142
- /**
143
- * Register a custom handler, replacing any existing handlers for the same lookup styles.
144
- * This is called by configure() to process user-defined handlers.
145
- *
146
- * When registering a handler for style X, any existing handler that processes X
147
- * is removed from ALL its lookup styles to prevent double-processing.
148
- * For example, if gapStyle handles ['display', 'flow', 'gap'] and a new handler
149
- * is registered for just ['gap'], gapStyle is removed from display and flow too.
150
- */
151
- function registerHandler(handler) {
152
- const lookupStyles = handler.__lookupStyles;
153
- if (!lookupStyles || lookupStyles.length === 0) {
154
- if (devMode) console.warn("[Tasty] Cannot register handler without __lookupStyles property.");
155
- return;
156
- }
157
- const handlersToRemove = /* @__PURE__ */ new Set();
158
- for (const styleName of lookupStyles) {
159
- const existing = STYLE_HANDLER_MAP[styleName];
160
- if (existing) for (const existingHandler of existing) handlersToRemove.add(existingHandler);
161
- }
162
- for (const oldHandler of handlersToRemove) {
163
- const oldLookupStyles = oldHandler.__lookupStyles;
164
- if (oldLookupStyles) for (const oldStyleName of oldLookupStyles) {
165
- const handlers = STYLE_HANDLER_MAP[oldStyleName];
166
- if (handlers) {
167
- const filtered = handlers.filter((h) => h !== oldHandler);
168
- if (filtered.length === 0) delete STYLE_HANDLER_MAP[oldStyleName];
169
- else STYLE_HANDLER_MAP[oldStyleName] = filtered;
170
- }
171
- }
172
- }
173
- for (const styleName of lookupStyles) {
174
- const existing = STYLE_HANDLER_MAP[styleName];
175
- if (existing) existing.push(handler);
176
- else STYLE_HANDLER_MAP[styleName] = [handler];
177
- }
178
- }
179
- /**
180
- * Create a wrapped handler that can be safely called by users.
181
- * The wrapper preserves __lookupStyles for proper registration.
182
- */
183
- function wrapHandler(handler) {
184
- const fn = handler;
185
- const wrapped = ((props) => fn(props));
186
- wrapped.__lookupStyles = handler.__lookupStyles;
187
- return wrapped;
188
- }
189
- /**
190
- * Exported object containing wrapped predefined style handlers.
191
- * Users can import and call these to extend or delegate to built-in behavior.
192
- *
193
- * Internal handlers use *Style suffix for searchability.
194
- * External API uses short names for convenience.
195
- *
196
- * @example
197
- * ```ts
198
- * import { styleHandlers, configure } from '@tenphi/tasty';
199
- *
200
- * configure({
201
- * handlers: {
202
- * fill: ({ fill }) => {
203
- * if (fill?.startsWith('gradient:')) {
204
- * return { background: fill.slice(9) };
205
- * }
206
- * return styleHandlers.fill({ fill });
207
- * },
208
- * },
209
- * });
210
- * ```
211
- */
212
- const styleHandlers = {
213
- align: wrapHandler(alignStyle),
214
- border: wrapHandler(borderStyle),
215
- color: wrapHandler(colorStyle),
216
- display: wrapHandler(displayStyle),
217
- fade: wrapHandler(fadeStyle),
218
- fill: wrapHandler(fillStyle),
219
- svgFill: wrapHandler(svgFillStyle),
220
- flow: wrapHandler(flowStyle),
221
- gap: wrapHandler(gapStyle),
222
- height: wrapHandler(heightStyle),
223
- inset: wrapHandler(insetStyle),
224
- justify: wrapHandler(justifyStyle),
225
- margin: wrapHandler(marginStyle),
226
- outline: wrapHandler(outlineStyle),
227
- padding: wrapHandler(paddingStyle),
228
- preset: wrapHandler(presetStyle),
229
- radius: wrapHandler(radiusStyle),
230
- scrollbar: wrapHandler(scrollbarStyle),
231
- shadow: wrapHandler(shadowStyle),
232
- transition: wrapHandler(transitionStyle),
233
- width: wrapHandler(widthStyle)
234
- };
235
-
236
- //#endregion
237
- export { normalizeHandlerDefinition, predefine, registerHandler, resetHandlers, styleHandlers };
238
- //# sourceMappingURL=predefined.js.map