@tenphi/tasty 1.1.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (257) hide show
  1. package/dist/_virtual/_rolldown/runtime.js +1 -2
  2. package/dist/chunks/cacheKey.d.ts +1 -0
  3. package/dist/chunks/cacheKey.js +1 -2
  4. package/dist/chunks/cacheKey.js.map +1 -1
  5. package/dist/chunks/definitions.js +1 -2
  6. package/dist/chunks/definitions.js.map +1 -1
  7. package/dist/chunks/index.d.ts +1 -0
  8. package/dist/chunks/renderChunk.d.ts +1 -0
  9. package/dist/chunks/renderChunk.js +1 -2
  10. package/dist/chunks/renderChunk.js.map +1 -1
  11. package/dist/compute-styles.d.ts +31 -0
  12. package/dist/compute-styles.js +356 -0
  13. package/dist/compute-styles.js.map +1 -0
  14. package/dist/config.d.ts +7 -1
  15. package/dist/config.js +25 -22
  16. package/dist/config.js.map +1 -1
  17. package/dist/core/index.d.ts +4 -4
  18. package/dist/core/index.js +6 -6
  19. package/dist/counter-style/index.js +1 -1
  20. package/dist/counter-style/index.js.map +1 -1
  21. package/dist/debug.js +1 -2
  22. package/dist/debug.js.map +1 -1
  23. package/dist/font-face/index.js +1 -1
  24. package/dist/font-face/index.js.map +1 -1
  25. package/dist/hooks/index.d.ts +7 -0
  26. package/dist/hooks/resolve-ssr-collector.js +1 -2
  27. package/dist/hooks/resolve-ssr-collector.js.map +1 -1
  28. package/dist/hooks/useCounterStyle.js +2 -3
  29. package/dist/hooks/useCounterStyle.js.map +1 -1
  30. package/dist/hooks/useFontFace.js +2 -3
  31. package/dist/hooks/useFontFace.js.map +1 -1
  32. package/dist/hooks/useGlobalStyles.js +4 -5
  33. package/dist/hooks/useGlobalStyles.js.map +1 -1
  34. package/dist/hooks/useKeyframes.js +3 -4
  35. package/dist/hooks/useKeyframes.js.map +1 -1
  36. package/dist/hooks/useProperty.js +2 -3
  37. package/dist/hooks/useProperty.js.map +1 -1
  38. package/dist/hooks/useRawCSS.js +2 -3
  39. package/dist/hooks/useRawCSS.js.map +1 -1
  40. package/dist/hooks/useStyles.d.ts +3 -8
  41. package/dist/hooks/useStyles.js +7 -214
  42. package/dist/hooks/useStyles.js.map +1 -1
  43. package/dist/index.d.ts +5 -5
  44. package/dist/index.js +7 -7
  45. package/dist/injector/index.d.ts +1 -18
  46. package/dist/injector/index.js +5 -19
  47. package/dist/injector/index.js.map +1 -1
  48. package/dist/injector/injector.js +1 -2
  49. package/dist/injector/injector.js.map +1 -1
  50. package/dist/injector/sheet-manager.js +1 -2
  51. package/dist/injector/sheet-manager.js.map +1 -1
  52. package/dist/keyframes/index.js +1 -1
  53. package/dist/parser/classify.js +1 -2
  54. package/dist/parser/classify.js.map +1 -1
  55. package/dist/parser/const.js +14 -3
  56. package/dist/parser/const.js.map +1 -1
  57. package/dist/parser/lru.js +1 -1
  58. package/dist/parser/lru.js.map +1 -1
  59. package/dist/parser/parser.js +1 -2
  60. package/dist/parser/parser.js.map +1 -1
  61. package/dist/parser/tokenizer.js +1 -1
  62. package/dist/parser/tokenizer.js.map +1 -1
  63. package/dist/parser/types.js +1 -1
  64. package/dist/parser/types.js.map +1 -1
  65. package/dist/pipeline/conditions.js +1 -1
  66. package/dist/pipeline/conditions.js.map +1 -1
  67. package/dist/pipeline/exclusive.js +1 -2
  68. package/dist/pipeline/exclusive.js.map +1 -1
  69. package/dist/pipeline/index.js +2 -3
  70. package/dist/pipeline/index.js.map +1 -1
  71. package/dist/pipeline/materialize.js +1 -2
  72. package/dist/pipeline/materialize.js.map +1 -1
  73. package/dist/pipeline/parseStateKey.js +1 -2
  74. package/dist/pipeline/parseStateKey.js.map +1 -1
  75. package/dist/pipeline/simplify.js +1 -2
  76. package/dist/pipeline/simplify.js.map +1 -1
  77. package/dist/pipeline/warnings.js +1 -1
  78. package/dist/plugins/index.d.ts +2 -0
  79. package/dist/plugins/okhsl-plugin.js +1 -2
  80. package/dist/plugins/okhsl-plugin.js.map +1 -1
  81. package/dist/properties/index.js +2 -3
  82. package/dist/properties/index.js.map +1 -1
  83. package/dist/properties/property-type-resolver.js +1 -2
  84. package/dist/properties/property-type-resolver.js.map +1 -1
  85. package/dist/ssr/astro.js +1 -2
  86. package/dist/ssr/astro.js.map +1 -1
  87. package/dist/ssr/async-storage.js +1 -2
  88. package/dist/ssr/async-storage.js.map +1 -1
  89. package/dist/ssr/collect-auto-properties.js +1 -2
  90. package/dist/ssr/collect-auto-properties.js.map +1 -1
  91. package/dist/ssr/collector.js +4 -12
  92. package/dist/ssr/collector.js.map +1 -1
  93. package/dist/ssr/context.d.ts +2 -2
  94. package/dist/ssr/context.js +1 -2
  95. package/dist/ssr/context.js.map +1 -1
  96. package/dist/ssr/format-global-rules.js +1 -1
  97. package/dist/ssr/format-keyframes.js +1 -2
  98. package/dist/ssr/format-keyframes.js.map +1 -1
  99. package/dist/ssr/format-property.js +1 -2
  100. package/dist/ssr/format-property.js.map +1 -1
  101. package/dist/ssr/format-rules.js +1 -1
  102. package/dist/ssr/hydrate.js +1 -2
  103. package/dist/ssr/hydrate.js.map +1 -1
  104. package/dist/ssr/index.js +1 -2
  105. package/dist/ssr/index.js.map +1 -1
  106. package/dist/ssr/next.d.ts +2 -2
  107. package/dist/ssr/next.js +9 -5
  108. package/dist/ssr/next.js.map +1 -1
  109. package/dist/ssr/ssr-collector-ref.js +1 -1
  110. package/dist/states/index.js +1 -2
  111. package/dist/states/index.js.map +1 -1
  112. package/dist/static/index.js +1 -2
  113. package/dist/static/inject.d.ts +5 -0
  114. package/dist/static/inject.js +17 -0
  115. package/dist/static/inject.js.map +1 -0
  116. package/dist/static/tastyStatic.js +1 -2
  117. package/dist/static/tastyStatic.js.map +1 -1
  118. package/dist/static/types.js +1 -1
  119. package/dist/styles/border.d.ts +1 -1
  120. package/dist/styles/border.js +28 -22
  121. package/dist/styles/border.js.map +1 -1
  122. package/dist/styles/color.d.ts +1 -1
  123. package/dist/styles/color.js +2 -3
  124. package/dist/styles/color.js.map +1 -1
  125. package/dist/styles/const.js +17 -0
  126. package/dist/styles/const.js.map +1 -0
  127. package/dist/styles/createStyle.js +4 -5
  128. package/dist/styles/createStyle.js.map +1 -1
  129. package/dist/styles/dimension.js +15 -3
  130. package/dist/styles/dimension.js.map +1 -1
  131. package/dist/styles/directional.js +133 -0
  132. package/dist/styles/directional.js.map +1 -0
  133. package/dist/styles/display.d.ts +3 -10
  134. package/dist/styles/display.js +45 -39
  135. package/dist/styles/display.js.map +1 -1
  136. package/dist/styles/fade.d.ts +1 -1
  137. package/dist/styles/fade.js +9 -5
  138. package/dist/styles/fade.js.map +1 -1
  139. package/dist/styles/fill.d.ts +2 -2
  140. package/dist/styles/fill.js +3 -4
  141. package/dist/styles/fill.js.map +1 -1
  142. package/dist/styles/flow.js +1 -1
  143. package/dist/styles/gap.d.ts +1 -1
  144. package/dist/styles/gap.js +4 -3
  145. package/dist/styles/gap.js.map +1 -1
  146. package/dist/styles/height.d.ts +1 -1
  147. package/dist/styles/height.js +1 -2
  148. package/dist/styles/height.js.map +1 -1
  149. package/dist/styles/index.d.ts +0 -1
  150. package/dist/styles/index.js +3 -4
  151. package/dist/styles/index.js.map +1 -1
  152. package/dist/styles/inset.d.ts +1 -29
  153. package/dist/styles/inset.js +19 -135
  154. package/dist/styles/inset.js.map +1 -1
  155. package/dist/styles/list.d.ts +5 -5
  156. package/dist/styles/list.js +4 -2
  157. package/dist/styles/list.js.map +1 -1
  158. package/dist/styles/margin.d.ts +1 -1
  159. package/dist/styles/margin.js +17 -89
  160. package/dist/styles/margin.js.map +1 -1
  161. package/dist/styles/outline.d.ts +1 -1
  162. package/dist/styles/outline.js +6 -16
  163. package/dist/styles/outline.js.map +1 -1
  164. package/dist/styles/padding.d.ts +1 -1
  165. package/dist/styles/padding.js +17 -89
  166. package/dist/styles/padding.js.map +1 -1
  167. package/dist/styles/placement.d.ts +37 -0
  168. package/dist/styles/placement.js +74 -0
  169. package/dist/styles/placement.js.map +1 -0
  170. package/dist/styles/predefined.d.ts +4 -4
  171. package/dist/styles/predefined.js +8 -9
  172. package/dist/styles/predefined.js.map +1 -1
  173. package/dist/styles/preset.d.ts +1 -1
  174. package/dist/styles/preset.js +7 -7
  175. package/dist/styles/preset.js.map +1 -1
  176. package/dist/styles/radius.d.ts +1 -3
  177. package/dist/styles/radius.js +38 -6
  178. package/dist/styles/radius.js.map +1 -1
  179. package/dist/styles/scrollMargin.d.ts +24 -0
  180. package/dist/styles/scrollMargin.js +32 -0
  181. package/dist/styles/scrollMargin.js.map +1 -0
  182. package/dist/styles/scrollbar.d.ts +1 -1
  183. package/dist/styles/scrollbar.js +8 -5
  184. package/dist/styles/scrollbar.js.map +1 -1
  185. package/dist/styles/shadow.d.ts +1 -1
  186. package/dist/styles/shadow.js +4 -3
  187. package/dist/styles/shadow.js.map +1 -1
  188. package/dist/styles/shared.js +17 -0
  189. package/dist/styles/shared.js.map +1 -0
  190. package/dist/styles/transition.d.ts +1 -1
  191. package/dist/styles/transition.js +5 -4
  192. package/dist/styles/transition.js.map +1 -1
  193. package/dist/styles/types.d.ts +24 -7
  194. package/dist/styles/width.d.ts +1 -1
  195. package/dist/styles/width.js +1 -2
  196. package/dist/styles/width.js.map +1 -1
  197. package/dist/tasty.d.ts +29 -14
  198. package/dist/tasty.js +70 -62
  199. package/dist/tasty.js.map +1 -1
  200. package/dist/utils/cache-wrapper.js +1 -2
  201. package/dist/utils/cache-wrapper.js.map +1 -1
  202. package/dist/utils/case-converter.js +1 -1
  203. package/dist/utils/color-math.js +1 -1
  204. package/dist/utils/color-math.js.map +1 -1
  205. package/dist/utils/color-space.js +1 -2
  206. package/dist/utils/color-space.js.map +1 -1
  207. package/dist/utils/colors.js +1 -2
  208. package/dist/utils/colors.js.map +1 -1
  209. package/dist/utils/dotize.js +1 -1
  210. package/dist/utils/dotize.js.map +1 -1
  211. package/dist/utils/filter-base-props.js +1 -1
  212. package/dist/utils/get-display-name.js +1 -1
  213. package/dist/utils/has-keys.js +1 -1
  214. package/dist/utils/is-dev-env.js +1 -1
  215. package/dist/utils/is-dev-env.js.map +1 -1
  216. package/dist/utils/is-valid-element-type.js +1 -1
  217. package/dist/utils/merge-styles.js +1 -2
  218. package/dist/utils/merge-styles.js.map +1 -1
  219. package/dist/utils/mod-attrs.d.ts +0 -2
  220. package/dist/utils/mod-attrs.js +1 -2
  221. package/dist/utils/mod-attrs.js.map +1 -1
  222. package/dist/utils/process-tokens.d.ts +1 -5
  223. package/dist/utils/process-tokens.js +3 -11
  224. package/dist/utils/process-tokens.js.map +1 -1
  225. package/dist/utils/resolve-recipes.js +1 -2
  226. package/dist/utils/resolve-recipes.js.map +1 -1
  227. package/dist/utils/selector-transform.js +1 -1
  228. package/dist/utils/string.js +1 -1
  229. package/dist/utils/styles.d.ts +1 -1
  230. package/dist/utils/styles.js +2 -3
  231. package/dist/utils/styles.js.map +1 -1
  232. package/dist/utils/typography.js +1 -1
  233. package/dist/utils/typography.js.map +1 -1
  234. package/dist/utils/warnings.js +1 -1
  235. package/dist/zero/babel.d.ts +17 -2
  236. package/dist/zero/babel.js +105 -41
  237. package/dist/zero/babel.js.map +1 -1
  238. package/dist/zero/css-writer.js +1 -2
  239. package/dist/zero/css-writer.js.map +1 -1
  240. package/dist/zero/extractor.js +1 -2
  241. package/dist/zero/extractor.js.map +1 -1
  242. package/dist/zero/index.js +1 -2
  243. package/dist/zero/next.d.ts +12 -0
  244. package/dist/zero/next.js +5 -4
  245. package/dist/zero/next.js.map +1 -1
  246. package/docs/methodology.md +50 -1
  247. package/docs/runtime.md +90 -3
  248. package/docs/ssr.md +10 -10
  249. package/docs/styles.md +17 -0
  250. package/docs/tasty-static.md +87 -0
  251. package/package.json +12 -7
  252. package/dist/styles/align.d.ts +0 -15
  253. package/dist/styles/align.js +0 -14
  254. package/dist/styles/align.js.map +0 -1
  255. package/dist/styles/justify.d.ts +0 -15
  256. package/dist/styles/justify.js +0 -14
  257. package/dist/styles/justify.js.map +0 -1
@@ -1,139 +1,23 @@
1
- import { DIRECTIONS, filterMods, parseStyle } from "../utils/styles.js";
2
-
1
+ import { processDirectionalStyle } from "./directional.js";
3
2
  //#region src/styles/inset.ts
4
- /**
5
- * Parse an inset value and return the first processed value
6
- */
7
- function parseInsetValue(value) {
8
- if (typeof value === "number") return `${value}px`;
9
- if (!value) return null;
10
- if (value === true) value = "0";
11
- const { values } = parseStyle(value).groups[0] ?? { values: [] };
12
- return values[0] || "0";
13
- }
14
- /**
15
- * Extract values and directions from a single parsed group.
16
- */
17
- function extractGroupData(group) {
18
- const { values = [], mods = [] } = group;
19
- return {
20
- values: values.length ? values : ["0"],
21
- directions: filterMods(mods, DIRECTIONS)
22
- };
23
- }
24
- /**
25
- * Apply a single group's values and directions onto a direction map.
26
- */
27
- function applyGroup(dirs, values, directions) {
28
- if (!values.length) return;
29
- if (directions.length === 0) {
30
- dirs.top = values[0];
31
- dirs.right = values[1] || values[0];
32
- dirs.bottom = values[2] || values[0];
33
- dirs.left = values[3] || values[1] || values[0];
34
- } else directions.forEach((dir, i) => {
35
- dirs[dir] = values[i] ?? values[0];
36
- });
37
- }
38
- /**
39
- * Optimize inset output shorthand.
40
- */
41
- function optimizeInset(dirs) {
42
- const { top, right, bottom, left } = dirs;
43
- if (top === right && right === bottom && bottom === left) return { inset: top };
44
- if (top === bottom && left === right) return { inset: `${top} ${left}` };
45
- return { inset: `${top} ${right} ${bottom} ${left}` };
46
- }
47
- /**
48
- * Inset style handler.
49
- *
50
- * IMPORTANT: This handler uses individual CSS properties (top, right, bottom, left)
51
- * when only individual direction props are specified. This allows CSS cascade to work
52
- * correctly when modifiers override only some directions.
53
- *
54
- * Example problem with using `inset` shorthand everywhere:
55
- * styles: {
56
- * top: { '': 0, 'side=bottom': 'initial' },
57
- * right: { '': 0, 'side=left': 'initial' },
58
- * bottom: { '': 0, 'side=top': 'initial' },
59
- * left: { '': 0, 'side=right': 'initial' },
60
- * }
61
- *
62
- * If we output `inset` for both cases:
63
- * - Default: inset: 0 0 0 0
64
- * - side=bottom: inset: initial auto auto auto ← WRONG! Overrides all 4 directions
65
- *
66
- * With individual properties:
67
- * - Default: top: 0; right: 0; bottom: 0; left: 0
68
- * - side=bottom: top: initial ← CORRECT! Only overrides top
69
- *
70
- * The `inset` shorthand is only used when the base `inset` prop is specified
71
- * OR when `insetBlock`/`insetInline` are used (which imply setting pairs).
72
- */
3
+ const INSET_CONFIG = {
4
+ property: "inset",
5
+ defaultValue: "0",
6
+ trueValue: "0",
7
+ defaultInit: "auto",
8
+ individualOnly: true,
9
+ directionProperty: (dir) => dir
10
+ };
73
11
  function insetStyle({ inset, insetBlock, insetInline, top, right, bottom, left }) {
74
- if (inset == null && insetBlock == null && insetInline == null && top == null && right == null && bottom == null && left == null) return {};
75
- if (inset == null && insetBlock == null && insetInline == null) {
76
- const result = {};
77
- if (top != null) {
78
- const val = parseInsetValue(top);
79
- if (val) result["top"] = val;
80
- }
81
- if (right != null) {
82
- const val = parseInsetValue(right);
83
- if (val) result["right"] = val;
84
- }
85
- if (bottom != null) {
86
- const val = parseInsetValue(bottom);
87
- if (val) result["bottom"] = val;
88
- }
89
- if (left != null) {
90
- const val = parseInsetValue(left);
91
- if (val) result["left"] = val;
92
- }
93
- return result;
94
- }
95
- const dirs = {
96
- top: "auto",
97
- right: "auto",
98
- bottom: "auto",
99
- left: "auto"
100
- };
101
- if (inset != null) {
102
- if (typeof inset === "number") dirs.top = dirs.right = dirs.bottom = dirs.left = `${inset}px`;
103
- else if (inset === true) inset = "0";
104
- if (typeof inset === "string" && inset) {
105
- const groups = parseStyle(inset).groups ?? [];
106
- for (const group of groups) {
107
- const { values, directions } = extractGroupData(group);
108
- applyGroup(dirs, values, directions);
109
- }
110
- }
111
- }
112
- if (insetBlock != null) {
113
- const val = parseInsetValue(insetBlock);
114
- if (val) dirs.top = dirs.bottom = val;
115
- }
116
- if (insetInline != null) {
117
- const val = parseInsetValue(insetInline);
118
- if (val) dirs.left = dirs.right = val;
119
- }
120
- if (top != null) {
121
- const val = parseInsetValue(top);
122
- if (val) dirs.top = val;
123
- }
124
- if (right != null) {
125
- const val = parseInsetValue(right);
126
- if (val) dirs.right = val;
127
- }
128
- if (bottom != null) {
129
- const val = parseInsetValue(bottom);
130
- if (val) dirs.bottom = val;
131
- }
132
- if (left != null) {
133
- const val = parseInsetValue(left);
134
- if (val) dirs.left = val;
135
- }
136
- return optimizeInset(dirs);
12
+ return processDirectionalStyle(INSET_CONFIG, {
13
+ main: inset,
14
+ block: insetBlock,
15
+ inline: insetInline,
16
+ top,
17
+ right,
18
+ bottom,
19
+ left
20
+ });
137
21
  }
138
22
  insetStyle.__lookupStyles = [
139
23
  "inset",
@@ -144,7 +28,7 @@ insetStyle.__lookupStyles = [
144
28
  "bottom",
145
29
  "left"
146
30
  ];
147
-
148
31
  //#endregion
149
32
  export { insetStyle };
33
+
150
34
  //# sourceMappingURL=inset.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"inset.js","names":[],"sources":["../../src/styles/inset.ts"],"sourcesContent":["import type { StyleDetails } from '../parser/types';\nimport { DIRECTIONS, filterMods, parseStyle } from '../utils/styles';\n\ntype Direction = (typeof DIRECTIONS)[number];\n\n/**\n * Parse an inset value and return the first processed value\n */\nfunction parseInsetValue(value: string | number | boolean): string | null {\n if (typeof value === 'number') return `${value}px`;\n if (!value) return null;\n if (value === true) value = '0';\n\n const { values } = parseStyle(value).groups[0] ?? { values: [] };\n\n return values[0] || '0';\n}\n\n/**\n * Extract values and directions from a single parsed group.\n */\nfunction extractGroupData(group: StyleDetails): {\n values: string[];\n directions: Direction[];\n} {\n const { values = [], mods = [] } = group;\n return {\n values: values.length ? values : ['0'],\n directions: filterMods(mods, DIRECTIONS) as Direction[],\n };\n}\n\n/**\n * Apply a single group's values and directions onto a direction map.\n */\nfunction applyGroup(\n dirs: Record<Direction, string>,\n values: string[],\n directions: Direction[],\n): void {\n if (!values.length) return;\n\n if (directions.length === 0) {\n dirs.top = values[0];\n dirs.right = values[1] || values[0];\n dirs.bottom = values[2] || values[0];\n dirs.left = values[3] || values[1] || values[0];\n } else {\n directions.forEach((dir, i) => {\n dirs[dir] = values[i] ?? values[0];\n });\n }\n}\n\n/**\n * Optimize inset output shorthand.\n */\nfunction optimizeInset(dirs: Record<Direction, string>): { inset: string } {\n const { top, right, bottom, left } = dirs;\n if (top === right && right === bottom && bottom === left) {\n return { inset: top };\n }\n if (top === bottom && left === right) {\n return { inset: `${top} ${left}` };\n }\n return { inset: `${top} ${right} ${bottom} ${left}` };\n}\n\n/**\n * Inset style handler.\n *\n * IMPORTANT: This handler uses individual CSS properties (top, right, bottom, left)\n * when only individual direction props are specified. This allows CSS cascade to work\n * correctly when modifiers override only some directions.\n *\n * Example problem with using `inset` shorthand everywhere:\n * styles: {\n * top: { '': 0, 'side=bottom': 'initial' },\n * right: { '': 0, 'side=left': 'initial' },\n * bottom: { '': 0, 'side=top': 'initial' },\n * left: { '': 0, 'side=right': 'initial' },\n * }\n *\n * If we output `inset` for both cases:\n * - Default: inset: 0 0 0 0\n * - side=bottom: inset: initial auto auto auto ← WRONG! Overrides all 4 directions\n *\n * With individual properties:\n * - Default: top: 0; right: 0; bottom: 0; left: 0\n * - side=bottom: top: initial ← CORRECT! Only overrides top\n *\n * The `inset` shorthand is only used when the base `inset` prop is specified\n * OR when `insetBlock`/`insetInline` are used (which imply setting pairs).\n */\nexport function insetStyle({\n inset,\n insetBlock,\n insetInline,\n top,\n right,\n bottom,\n left,\n}: {\n inset?: string | number | boolean;\n insetBlock?: string | number | boolean;\n insetInline?: string | number | boolean;\n top?: string | number | boolean;\n right?: string | number | boolean;\n bottom?: string | number | boolean;\n left?: string | number | boolean;\n}) {\n if (\n inset == null &&\n insetBlock == null &&\n insetInline == null &&\n top == null &&\n right == null &&\n bottom == null &&\n left == null\n ) {\n return {};\n }\n\n // When only individual direction props are used (no inset, insetBlock, insetInline),\n // output individual CSS properties to allow proper CSS cascade with modifiers\n const onlyIndividualProps =\n inset == null && insetBlock == null && insetInline == null;\n\n if (onlyIndividualProps) {\n const result: Record<string, string> = {};\n\n if (top != null) {\n const val = parseInsetValue(top);\n if (val) result['top'] = val;\n }\n if (right != null) {\n const val = parseInsetValue(right);\n if (val) result['right'] = val;\n }\n if (bottom != null) {\n const val = parseInsetValue(bottom);\n if (val) result['bottom'] = val;\n }\n if (left != null) {\n const val = parseInsetValue(left);\n if (val) result['left'] = val;\n }\n\n return result;\n }\n\n const dirs: Record<Direction, string> = {\n top: 'auto',\n right: 'auto',\n bottom: 'auto',\n left: 'auto',\n };\n\n // Priority 1 (lowest): inset\n if (inset != null) {\n if (typeof inset === 'number') {\n const v = `${inset}px`;\n dirs.top = dirs.right = dirs.bottom = dirs.left = v;\n } else if (inset === true) {\n inset = '0';\n }\n\n if (typeof inset === 'string' && inset) {\n const processed = parseStyle(inset);\n const groups = processed.groups ?? [];\n\n for (const group of groups) {\n const { values, directions } = extractGroupData(group);\n applyGroup(dirs, values, directions);\n }\n }\n }\n\n // Priority 2 (medium): insetBlock/insetInline\n if (insetBlock != null) {\n const val = parseInsetValue(insetBlock);\n if (val) dirs.top = dirs.bottom = val;\n }\n if (insetInline != null) {\n const val = parseInsetValue(insetInline);\n if (val) dirs.left = dirs.right = val;\n }\n\n // Priority 3 (highest): individual directions\n if (top != null) {\n const val = parseInsetValue(top);\n if (val) dirs.top = val;\n }\n if (right != null) {\n const val = parseInsetValue(right);\n if (val) dirs.right = val;\n }\n if (bottom != null) {\n const val = parseInsetValue(bottom);\n if (val) dirs.bottom = val;\n }\n if (left != null) {\n const val = parseInsetValue(left);\n if (val) dirs.left = val;\n }\n\n return optimizeInset(dirs);\n}\n\ninsetStyle.__lookupStyles = [\n 'inset',\n 'insetBlock',\n 'insetInline',\n 'top',\n 'right',\n 'bottom',\n 'left',\n];\n"],"mappings":";;;;;;AAQA,SAAS,gBAAgB,OAAiD;AACxE,KAAI,OAAO,UAAU,SAAU,QAAO,GAAG,MAAM;AAC/C,KAAI,CAAC,MAAO,QAAO;AACnB,KAAI,UAAU,KAAM,SAAQ;CAE5B,MAAM,EAAE,WAAW,WAAW,MAAM,CAAC,OAAO,MAAM,EAAE,QAAQ,EAAE,EAAE;AAEhE,QAAO,OAAO,MAAM;;;;;AAMtB,SAAS,iBAAiB,OAGxB;CACA,MAAM,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,KAAK;AACnC,QAAO;EACL,QAAQ,OAAO,SAAS,SAAS,CAAC,IAAI;EACtC,YAAY,WAAW,MAAM,WAAW;EACzC;;;;;AAMH,SAAS,WACP,MACA,QACA,YACM;AACN,KAAI,CAAC,OAAO,OAAQ;AAEpB,KAAI,WAAW,WAAW,GAAG;AAC3B,OAAK,MAAM,OAAO;AAClB,OAAK,QAAQ,OAAO,MAAM,OAAO;AACjC,OAAK,SAAS,OAAO,MAAM,OAAO;AAClC,OAAK,OAAO,OAAO,MAAM,OAAO,MAAM,OAAO;OAE7C,YAAW,SAAS,KAAK,MAAM;AAC7B,OAAK,OAAO,OAAO,MAAM,OAAO;GAChC;;;;;AAON,SAAS,cAAc,MAAoD;CACzE,MAAM,EAAE,KAAK,OAAO,QAAQ,SAAS;AACrC,KAAI,QAAQ,SAAS,UAAU,UAAU,WAAW,KAClD,QAAO,EAAE,OAAO,KAAK;AAEvB,KAAI,QAAQ,UAAU,SAAS,MAC7B,QAAO,EAAE,OAAO,GAAG,IAAI,GAAG,QAAQ;AAEpC,QAAO,EAAE,OAAO,GAAG,IAAI,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BvD,SAAgB,WAAW,EACzB,OACA,YACA,aACA,KACA,OACA,QACA,QASC;AACD,KACE,SAAS,QACT,cAAc,QACd,eAAe,QACf,OAAO,QACP,SAAS,QACT,UAAU,QACV,QAAQ,KAER,QAAO,EAAE;AAQX,KAFE,SAAS,QAAQ,cAAc,QAAQ,eAAe,MAE/B;EACvB,MAAM,SAAiC,EAAE;AAEzC,MAAI,OAAO,MAAM;GACf,MAAM,MAAM,gBAAgB,IAAI;AAChC,OAAI,IAAK,QAAO,SAAS;;AAE3B,MAAI,SAAS,MAAM;GACjB,MAAM,MAAM,gBAAgB,MAAM;AAClC,OAAI,IAAK,QAAO,WAAW;;AAE7B,MAAI,UAAU,MAAM;GAClB,MAAM,MAAM,gBAAgB,OAAO;AACnC,OAAI,IAAK,QAAO,YAAY;;AAE9B,MAAI,QAAQ,MAAM;GAChB,MAAM,MAAM,gBAAgB,KAAK;AACjC,OAAI,IAAK,QAAO,UAAU;;AAG5B,SAAO;;CAGT,MAAM,OAAkC;EACtC,KAAK;EACL,OAAO;EACP,QAAQ;EACR,MAAM;EACP;AAGD,KAAI,SAAS,MAAM;AACjB,MAAI,OAAO,UAAU,SAEnB,MAAK,MAAM,KAAK,QAAQ,KAAK,SAAS,KAAK,OADjC,GAAG,MAAM;WAEV,UAAU,KACnB,SAAQ;AAGV,MAAI,OAAO,UAAU,YAAY,OAAO;GAEtC,MAAM,SADY,WAAW,MAAM,CACV,UAAU,EAAE;AAErC,QAAK,MAAM,SAAS,QAAQ;IAC1B,MAAM,EAAE,QAAQ,eAAe,iBAAiB,MAAM;AACtD,eAAW,MAAM,QAAQ,WAAW;;;;AAM1C,KAAI,cAAc,MAAM;EACtB,MAAM,MAAM,gBAAgB,WAAW;AACvC,MAAI,IAAK,MAAK,MAAM,KAAK,SAAS;;AAEpC,KAAI,eAAe,MAAM;EACvB,MAAM,MAAM,gBAAgB,YAAY;AACxC,MAAI,IAAK,MAAK,OAAO,KAAK,QAAQ;;AAIpC,KAAI,OAAO,MAAM;EACf,MAAM,MAAM,gBAAgB,IAAI;AAChC,MAAI,IAAK,MAAK,MAAM;;AAEtB,KAAI,SAAS,MAAM;EACjB,MAAM,MAAM,gBAAgB,MAAM;AAClC,MAAI,IAAK,MAAK,QAAQ;;AAExB,KAAI,UAAU,MAAM;EAClB,MAAM,MAAM,gBAAgB,OAAO;AACnC,MAAI,IAAK,MAAK,SAAS;;AAEzB,KAAI,QAAQ,MAAM;EAChB,MAAM,MAAM,gBAAgB,KAAK;AACjC,MAAI,IAAK,MAAK,OAAO;;AAGvB,QAAO,cAAc,KAAK;;AAG5B,WAAW,iBAAiB;CAC1B;CACA;CACA;CACA;CACA;CACA;CACA;CACD"}
1
+ {"version":3,"file":"inset.js","names":[],"sources":["../../src/styles/inset.ts"],"sourcesContent":["import { type DirectionalConfig, processDirectionalStyle } from './directional';\n\nconst INSET_CONFIG: DirectionalConfig = {\n property: 'inset',\n defaultValue: '0',\n trueValue: '0',\n defaultInit: 'auto',\n individualOnly: true,\n directionProperty: (dir) => dir,\n};\n\nexport function insetStyle({\n inset,\n insetBlock,\n insetInline,\n top,\n right,\n bottom,\n left,\n}: {\n inset?: string | number | boolean;\n insetBlock?: string | number | boolean;\n insetInline?: string | number | boolean;\n top?: string | number | boolean;\n right?: string | number | boolean;\n bottom?: string | number | boolean;\n left?: string | number | boolean;\n}) {\n return processDirectionalStyle(INSET_CONFIG, {\n main: inset,\n block: insetBlock,\n inline: insetInline,\n top,\n right,\n bottom,\n left,\n });\n}\n\ninsetStyle.__lookupStyles = [\n 'inset',\n 'insetBlock',\n 'insetInline',\n 'top',\n 'right',\n 'bottom',\n 'left',\n];\n"],"mappings":";;AAEA,MAAM,eAAkC;CACtC,UAAU;CACV,cAAc;CACd,WAAW;CACX,aAAa;CACb,gBAAgB;CAChB,oBAAoB,QAAQ;CAC7B;AAED,SAAgB,WAAW,EACzB,OACA,YACA,aACA,KACA,OACA,QACA,QASC;AACD,QAAO,wBAAwB,cAAc;EAC3C,MAAM;EACN,OAAO;EACP,QAAQ;EACR;EACA;EACA;EACA;EACD,CAAC;;AAGJ,WAAW,iBAAiB;CAC1B;CACA;CACA;CACA;CACA;CACA;CACA;CACD"}
@@ -1,16 +1,16 @@
1
1
  //#region src/styles/list.d.ts
2
2
  declare const BASE_STYLES: readonly ["display", "font", "preset", "hide", "whiteSpace", "opacity", "transition"];
3
- declare const POSITION_STYLES: readonly ["gridArea", "order", "gridColumn", "gridRow", "placeSelf", "alignSelf", "justifySelf", "zIndex", "margin", "inset", "position"];
3
+ declare const POSITION_STYLES: readonly ["gridArea", "order", "gridColumn", "gridRow", "placeSelf", "alignSelf", "justifySelf", "zIndex", "margin", "inset", "position", "scrollMargin"];
4
4
  declare const BLOCK_INNER_STYLES: readonly ["padding", "paddingInline", "paddingBlock", "overflow", "scrollbar", "textAlign"];
5
5
  declare const BLOCK_OUTER_STYLES: readonly ["border", "radius", "shadow", "outline"];
6
6
  declare const BLOCK_STYLES: readonly ["padding", "paddingInline", "paddingBlock", "overflow", "scrollbar", "textAlign", "border", "radius", "shadow", "outline"];
7
7
  declare const COLOR_STYLES: readonly ["color", "fill", "fade", "image"];
8
8
  declare const TEXT_STYLES: readonly ["textTransform", "fontWeight", "fontStyle"];
9
9
  declare const DIMENSION_STYLES: readonly ["width", "height", "flexBasis", "flexGrow", "flexShrink", "flex"];
10
- declare const FLOW_STYLES: readonly ["flow", "placeItems", "placeContent", "alignItems", "alignContent", "justifyItems", "justifyContent", "align", "justify", "gap", "columnGap", "rowGap", "gridColumns", "gridRows", "gridTemplate", "gridAreas"];
11
- declare const CONTAINER_STYLES: readonly ["display", "font", "preset", "hide", "whiteSpace", "opacity", "transition", "color", "fill", "fade", "image", "width", "height", "flexBasis", "flexGrow", "flexShrink", "flex", "gridArea", "order", "gridColumn", "gridRow", "placeSelf", "alignSelf", "justifySelf", "zIndex", "margin", "inset", "position", "padding", "paddingInline", "paddingBlock", "overflow", "scrollbar", "textAlign", "border", "radius", "shadow", "outline", "flow", "placeItems", "placeContent", "alignItems", "alignContent", "justifyItems", "justifyContent", "align", "justify", "gap", "columnGap", "rowGap", "gridColumns", "gridRows", "gridTemplate", "gridAreas"];
12
- declare const OUTER_STYLES: readonly ["gridArea", "order", "gridColumn", "gridRow", "placeSelf", "alignSelf", "justifySelf", "zIndex", "margin", "inset", "position", "width", "height", "flexBasis", "flexGrow", "flexShrink", "flex", "border", "radius", "shadow", "outline"];
13
- declare const INNER_STYLES: readonly ["display", "font", "preset", "hide", "whiteSpace", "opacity", "transition", "color", "fill", "fade", "image", "padding", "paddingInline", "paddingBlock", "overflow", "scrollbar", "textAlign", "flow", "placeItems", "placeContent", "alignItems", "alignContent", "justifyItems", "justifyContent", "align", "justify", "gap", "columnGap", "rowGap", "gridColumns", "gridRows", "gridTemplate", "gridAreas"];
10
+ declare const FLOW_STYLES: readonly ["flow", "place", "placeItems", "placeContent", "alignItems", "alignContent", "justifyItems", "justifyContent", "align", "justify", "gap", "columnGap", "rowGap", "gridColumns", "gridRows", "gridTemplate", "gridAreas"];
11
+ declare const CONTAINER_STYLES: readonly ["display", "font", "preset", "hide", "whiteSpace", "opacity", "transition", "color", "fill", "fade", "image", "width", "height", "flexBasis", "flexGrow", "flexShrink", "flex", "gridArea", "order", "gridColumn", "gridRow", "placeSelf", "alignSelf", "justifySelf", "zIndex", "margin", "inset", "position", "scrollMargin", "padding", "paddingInline", "paddingBlock", "overflow", "scrollbar", "textAlign", "border", "radius", "shadow", "outline", "flow", "place", "placeItems", "placeContent", "alignItems", "alignContent", "justifyItems", "justifyContent", "align", "justify", "gap", "columnGap", "rowGap", "gridColumns", "gridRows", "gridTemplate", "gridAreas"];
12
+ declare const OUTER_STYLES: readonly ["gridArea", "order", "gridColumn", "gridRow", "placeSelf", "alignSelf", "justifySelf", "zIndex", "margin", "inset", "position", "scrollMargin", "width", "height", "flexBasis", "flexGrow", "flexShrink", "flex", "border", "radius", "shadow", "outline"];
13
+ declare const INNER_STYLES: readonly ["display", "font", "preset", "hide", "whiteSpace", "opacity", "transition", "color", "fill", "fade", "image", "padding", "paddingInline", "paddingBlock", "overflow", "scrollbar", "textAlign", "flow", "place", "placeItems", "placeContent", "alignItems", "alignContent", "justifyItems", "justifyContent", "align", "justify", "gap", "columnGap", "rowGap", "gridColumns", "gridRows", "gridTemplate", "gridAreas"];
14
14
  //#endregion
15
15
  export { BASE_STYLES, BLOCK_INNER_STYLES, BLOCK_OUTER_STYLES, BLOCK_STYLES, COLOR_STYLES, CONTAINER_STYLES, DIMENSION_STYLES, FLOW_STYLES, INNER_STYLES, OUTER_STYLES, POSITION_STYLES, TEXT_STYLES };
16
16
  //# sourceMappingURL=list.d.ts.map
@@ -19,7 +19,8 @@ const POSITION_STYLES = [
19
19
  "zIndex",
20
20
  "margin",
21
21
  "inset",
22
- "position"
22
+ "position",
23
+ "scrollMargin"
23
24
  ];
24
25
  const BLOCK_INNER_STYLES = [
25
26
  "padding",
@@ -57,6 +58,7 @@ const DIMENSION_STYLES = [
57
58
  ];
58
59
  const FLOW_STYLES = [
59
60
  "flow",
61
+ "place",
60
62
  "placeItems",
61
63
  "placeContent",
62
64
  "alignItems",
@@ -92,7 +94,7 @@ const INNER_STYLES = [
92
94
  ...BLOCK_INNER_STYLES,
93
95
  ...FLOW_STYLES
94
96
  ];
95
-
96
97
  //#endregion
97
98
  export { BASE_STYLES, BLOCK_INNER_STYLES, BLOCK_OUTER_STYLES, BLOCK_STYLES, COLOR_STYLES, CONTAINER_STYLES, DIMENSION_STYLES, FLOW_STYLES, INNER_STYLES, OUTER_STYLES, POSITION_STYLES, TEXT_STYLES };
99
+
98
100
  //# sourceMappingURL=list.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"list.js","names":[],"sources":["../../src/styles/list.ts"],"sourcesContent":["export const BASE_STYLES = [\n 'display',\n 'font',\n 'preset',\n 'hide',\n 'whiteSpace',\n 'opacity',\n 'transition',\n] as const;\n\nexport const POSITION_STYLES = [\n 'gridArea',\n 'order',\n 'gridColumn',\n 'gridRow',\n 'placeSelf',\n 'alignSelf',\n 'justifySelf',\n 'zIndex',\n 'margin',\n 'inset',\n 'position',\n] as const;\n\nexport const BLOCK_INNER_STYLES = [\n 'padding',\n 'paddingInline',\n 'paddingBlock',\n 'overflow',\n 'scrollbar',\n 'textAlign',\n] as const;\n\nexport const BLOCK_OUTER_STYLES = [\n 'border',\n 'radius',\n 'shadow',\n 'outline',\n] as const;\n\nexport const BLOCK_STYLES = [\n ...BLOCK_INNER_STYLES,\n ...BLOCK_OUTER_STYLES,\n] as const;\n\nexport const COLOR_STYLES = ['color', 'fill', 'fade', 'image'] as const;\n\nexport const TEXT_STYLES = [\n 'textTransform',\n 'fontWeight',\n 'fontStyle',\n] as const;\n\nexport const DIMENSION_STYLES = [\n 'width',\n 'height',\n 'flexBasis',\n 'flexGrow',\n 'flexShrink',\n 'flex',\n] as const;\n\nexport const FLOW_STYLES = [\n 'flow',\n 'placeItems',\n 'placeContent',\n 'alignItems',\n 'alignContent',\n 'justifyItems',\n 'justifyContent',\n 'align',\n 'justify',\n 'gap',\n 'columnGap',\n 'rowGap',\n 'gridColumns',\n 'gridRows',\n 'gridTemplate',\n 'gridAreas',\n] as const;\n\nexport const CONTAINER_STYLES = [\n ...BASE_STYLES,\n ...COLOR_STYLES,\n ...DIMENSION_STYLES,\n ...POSITION_STYLES,\n ...BLOCK_STYLES,\n ...FLOW_STYLES,\n] as const;\n\nexport const OUTER_STYLES = [\n ...POSITION_STYLES,\n ...DIMENSION_STYLES,\n ...BLOCK_OUTER_STYLES,\n] as const;\n\nexport const INNER_STYLES = [\n ...BASE_STYLES,\n ...COLOR_STYLES,\n ...BLOCK_INNER_STYLES,\n ...FLOW_STYLES,\n] as const;\n"],"mappings":";AAAA,MAAa,cAAc;CACzB;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAa,kBAAkB;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAa,qBAAqB;CAChC;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAa,qBAAqB;CAChC;CACA;CACA;CACA;CACD;AAED,MAAa,eAAe,CAC1B,GAAG,oBACH,GAAG,mBACJ;AAED,MAAa,eAAe;CAAC;CAAS;CAAQ;CAAQ;CAAQ;AAE9D,MAAa,cAAc;CACzB;CACA;CACA;CACD;AAED,MAAa,mBAAmB;CAC9B;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAa,cAAc;CACzB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAa,mBAAmB;CAC9B,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACJ;AAED,MAAa,eAAe;CAC1B,GAAG;CACH,GAAG;CACH,GAAG;CACJ;AAED,MAAa,eAAe;CAC1B,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACJ"}
1
+ {"version":3,"file":"list.js","names":[],"sources":["../../src/styles/list.ts"],"sourcesContent":["export const BASE_STYLES = [\n 'display',\n 'font',\n 'preset',\n 'hide',\n 'whiteSpace',\n 'opacity',\n 'transition',\n] as const;\n\nexport const POSITION_STYLES = [\n 'gridArea',\n 'order',\n 'gridColumn',\n 'gridRow',\n 'placeSelf',\n 'alignSelf',\n 'justifySelf',\n 'zIndex',\n 'margin',\n 'inset',\n 'position',\n 'scrollMargin',\n] as const;\n\nexport const BLOCK_INNER_STYLES = [\n 'padding',\n 'paddingInline',\n 'paddingBlock',\n 'overflow',\n 'scrollbar',\n 'textAlign',\n] as const;\n\nexport const BLOCK_OUTER_STYLES = [\n 'border',\n 'radius',\n 'shadow',\n 'outline',\n] as const;\n\nexport const BLOCK_STYLES = [\n ...BLOCK_INNER_STYLES,\n ...BLOCK_OUTER_STYLES,\n] as const;\n\nexport const COLOR_STYLES = ['color', 'fill', 'fade', 'image'] as const;\n\nexport const TEXT_STYLES = [\n 'textTransform',\n 'fontWeight',\n 'fontStyle',\n] as const;\n\nexport const DIMENSION_STYLES = [\n 'width',\n 'height',\n 'flexBasis',\n 'flexGrow',\n 'flexShrink',\n 'flex',\n] as const;\n\nexport const FLOW_STYLES = [\n 'flow',\n 'place',\n 'placeItems',\n 'placeContent',\n 'alignItems',\n 'alignContent',\n 'justifyItems',\n 'justifyContent',\n 'align',\n 'justify',\n 'gap',\n 'columnGap',\n 'rowGap',\n 'gridColumns',\n 'gridRows',\n 'gridTemplate',\n 'gridAreas',\n] as const;\n\nexport const CONTAINER_STYLES = [\n ...BASE_STYLES,\n ...COLOR_STYLES,\n ...DIMENSION_STYLES,\n ...POSITION_STYLES,\n ...BLOCK_STYLES,\n ...FLOW_STYLES,\n] as const;\n\nexport const OUTER_STYLES = [\n ...POSITION_STYLES,\n ...DIMENSION_STYLES,\n ...BLOCK_OUTER_STYLES,\n] as const;\n\nexport const INNER_STYLES = [\n ...BASE_STYLES,\n ...COLOR_STYLES,\n ...BLOCK_INNER_STYLES,\n ...FLOW_STYLES,\n] as const;\n"],"mappings":";AAAA,MAAa,cAAc;CACzB;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAa,kBAAkB;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAa,qBAAqB;CAChC;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAa,qBAAqB;CAChC;CACA;CACA;CACA;CACD;AAED,MAAa,eAAe,CAC1B,GAAG,oBACH,GAAG,mBACJ;AAED,MAAa,eAAe;CAAC;CAAS;CAAQ;CAAQ;CAAQ;AAE9D,MAAa,cAAc;CACzB;CACA;CACA;CACD;AAED,MAAa,mBAAmB;CAC9B;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAa,cAAc;CACzB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAa,mBAAmB;CAC9B,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACJ;AAED,MAAa,eAAe;CAC1B,GAAG;CACH,GAAG;CACH,GAAG;CACJ;AAED,MAAa,eAAe;CAC1B,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACJ"}
@@ -15,7 +15,7 @@ declare function marginStyle({
15
15
  marginRight?: string | number | boolean;
16
16
  marginBottom?: string | number | boolean;
17
17
  marginLeft?: string | number | boolean;
18
- }): {};
18
+ }): Record<string, string> | null;
19
19
  declare namespace marginStyle {
20
20
  var __lookupStyles: string[];
21
21
  }
@@ -1,93 +1,21 @@
1
- import { DIRECTIONS, filterMods, parseStyle } from "../utils/styles.js";
2
-
1
+ import { processDirectionalStyle } from "./directional.js";
3
2
  //#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
- }
3
+ const MARGIN_CONFIG = {
4
+ property: "margin",
5
+ defaultValue: "var(--gap)",
6
+ trueValue: "1x",
7
+ defaultInit: "0"
8
+ };
47
9
  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);
10
+ return processDirectionalStyle(MARGIN_CONFIG, {
11
+ main: margin,
12
+ block: marginBlock,
13
+ inline: marginInline,
14
+ top: marginTop,
15
+ right: marginRight,
16
+ bottom: marginBottom,
17
+ left: marginLeft
18
+ });
91
19
  }
92
20
  marginStyle.__lookupStyles = [
93
21
  "margin",
@@ -98,7 +26,7 @@ marginStyle.__lookupStyles = [
98
26
  "marginBlock",
99
27
  "marginInline"
100
28
  ];
101
-
102
29
  //#endregion
103
30
  export { marginStyle };
31
+
104
32
  //# sourceMappingURL=margin.js.map
@@ -1 +1 @@
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
+ {"version":3,"file":"margin.js","names":[],"sources":["../../src/styles/margin.ts"],"sourcesContent":["import { processDirectionalStyle } from './directional';\n\nconst MARGIN_CONFIG = {\n property: 'margin',\n defaultValue: 'var(--gap)',\n trueValue: '1x',\n defaultInit: '0',\n} as const;\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 return processDirectionalStyle(MARGIN_CONFIG, {\n main: margin,\n block: marginBlock,\n inline: marginInline,\n top: marginTop,\n right: marginRight,\n bottom: marginBottom,\n left: marginLeft,\n });\n}\n\nmarginStyle.__lookupStyles = [\n 'margin',\n 'marginTop',\n 'marginRight',\n 'marginBottom',\n 'marginLeft',\n 'marginBlock',\n 'marginInline',\n];\n"],"mappings":";;AAEA,MAAM,gBAAgB;CACpB,UAAU;CACV,cAAc;CACd,WAAW;CACX,aAAa;CACd;AAED,SAAgB,YAAY,EAC1B,QACA,aACA,cACA,WACA,aACA,cACA,cASC;AACD,QAAO,wBAAwB,eAAe;EAC5C,MAAM;EACN,OAAO;EACP,QAAQ;EACR,KAAK;EACL,OAAO;EACP,QAAQ;EACR,MAAM;EACP,CAAC;;AAGJ,YAAY,iBAAiB;CAC3B;CACA;CACA;CACA;CACA;CACA;CACA;CACD"}
@@ -20,7 +20,7 @@ interface OutlineStyleProps {
20
20
  declare function outlineStyle({
21
21
  outline,
22
22
  outlineOffset
23
- }: OutlineStyleProps): Record<string, string> | undefined;
23
+ }: OutlineStyleProps): Record<string, string> | null;
24
24
  declare namespace outlineStyle {
25
25
  var __lookupStyles: string[];
26
26
  }
@@ -1,18 +1,7 @@
1
+ import { CSS_WIDE_KEYWORDS } from "../parser/const.js";
1
2
  import { filterMods, parseStyle } from "../utils/styles.js";
2
-
3
+ import { BORDER_STYLES } from "./const.js";
3
4
  //#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
5
  /**
17
6
  * Generates CSS for outline property with optional offset.
18
7
  *
@@ -29,7 +18,8 @@ const BORDER_STYLES = [
29
18
  */
30
19
  function outlineStyle({ outline, outlineOffset }) {
31
20
  const result = {};
32
- if (outline != null && outline !== false) {
21
+ if (outline != null && outline !== false) if (typeof outline === "string" && CSS_WIDE_KEYWORDS.has(outline)) result["outline"] = outline;
22
+ else {
33
23
  let outlineValue = outline;
34
24
  if (outline === true) outlineValue = "1ow";
35
25
  if (outline === 0) outlineValue = "0";
@@ -55,11 +45,11 @@ function outlineStyle({ outline, outlineOffset }) {
55
45
  const offsetValue = typeof outlineOffset === "number" ? `${outlineOffset}px` : outlineOffset;
56
46
  result["outline-offset"] = parseStyle(offsetValue).groups[0]?.values[0] || offsetValue;
57
47
  }
58
- if (Object.keys(result).length === 0) return;
48
+ if (Object.keys(result).length === 0) return null;
59
49
  return result;
60
50
  }
61
51
  outlineStyle.__lookupStyles = ["outline", "outlineOffset"];
62
-
63
52
  //#endregion
64
53
  export { outlineStyle };
54
+
65
55
  //# sourceMappingURL=outline.js.map
@@ -1 +1 @@
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
+ {"version":3,"file":"outline.js","names":[],"sources":["../../src/styles/outline.ts"],"sourcesContent":["import { CSS_WIDE_KEYWORDS } from '../parser/const';\nimport { filterMods, parseStyle } from '../utils/styles';\nimport { BORDER_STYLES } from './const';\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 if (typeof outline === 'string' && CSS_WIDE_KEYWORDS.has(outline)) {\n result['outline'] = outline;\n } else {\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(\n outlinePart.mods,\n BORDER_STYLES as unknown as string[],\n );\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 if (offsetPart?.values[0]) {\n result['outline-offset'] = offsetPart.values[0];\n }\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 if (Object.keys(result).length === 0) {\n return null;\n }\n\n return result;\n}\n\noutlineStyle.__lookupStyles = ['outline', 'outlineOffset'];\n"],"mappings":";;;;;;;;;;;;;;;;;;AAuBA,SAAgB,aAAa,EAAE,SAAS,iBAAoC;CAC1E,MAAM,SAAiC,EAAE;AAGzC,KAAI,WAAW,QAAQ,YAAY,MACjC,KAAI,OAAO,YAAY,YAAY,kBAAkB,IAAI,QAAQ,CAC/D,QAAO,aAAa;MACf;EACL,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,WACf,YAAY,MACZ,cACD;AAMD,UAAO,aAAa;IAJN,YAAY,OAAO,MAAM;IAC1B,SAAS,MAAM;IACP,YAAY,OAAO,MAAM;IAEC,CAAC,KAAK,IAAI;AAEzD,OAAI,YAAY,OAAO,GACrB,QAAO,oBAAoB,WAAW,OAAO;;;AAOrD,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;;AAG/D,KAAI,OAAO,KAAK,OAAO,CAAC,WAAW,EACjC,QAAO;AAGT,QAAO;;AAGT,aAAa,iBAAiB,CAAC,WAAW,gBAAgB"}
@@ -15,7 +15,7 @@ declare function paddingStyle({
15
15
  paddingRight?: string | number | boolean;
16
16
  paddingBottom?: string | number | boolean;
17
17
  paddingLeft?: string | number | boolean;
18
- }): {};
18
+ }): Record<string, string> | null;
19
19
  declare namespace paddingStyle {
20
20
  var __lookupStyles: string[];
21
21
  }
@@ -1,93 +1,21 @@
1
- import { DIRECTIONS, filterMods, parseStyle } from "../utils/styles.js";
2
-
1
+ import { processDirectionalStyle } from "./directional.js";
3
2
  //#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
- }
3
+ const PADDING_CONFIG = {
4
+ property: "padding",
5
+ defaultValue: "var(--gap)",
6
+ trueValue: "1x",
7
+ defaultInit: "0"
8
+ };
47
9
  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);
10
+ return processDirectionalStyle(PADDING_CONFIG, {
11
+ main: padding,
12
+ block: paddingBlock,
13
+ inline: paddingInline,
14
+ top: paddingTop,
15
+ right: paddingRight,
16
+ bottom: paddingBottom,
17
+ left: paddingLeft
18
+ });
91
19
  }
92
20
  paddingStyle.__lookupStyles = [
93
21
  "padding",
@@ -98,7 +26,7 @@ paddingStyle.__lookupStyles = [
98
26
  "paddingBlock",
99
27
  "paddingInline"
100
28
  ];
101
-
102
29
  //#endregion
103
30
  export { paddingStyle };
31
+
104
32
  //# sourceMappingURL=padding.js.map