@dazl/shorthands-opener 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (237) hide show
  1. package/README.md +3 -0
  2. package/dist/compounds/compound-css-data.d.ts +22 -0
  3. package/dist/compounds/compound-css-data.d.ts.map +1 -0
  4. package/dist/compounds/compound-css-data.js +2 -0
  5. package/dist/compounds/compound-css-data.js.map +1 -0
  6. package/dist/compounds/compound-mapper.d.ts +4 -0
  7. package/dist/compounds/compound-mapper.d.ts.map +1 -0
  8. package/dist/compounds/compound-mapper.js +10 -0
  9. package/dist/compounds/compound-mapper.js.map +1 -0
  10. package/dist/compounds/compound-parser-utils.d.ts +3 -0
  11. package/dist/compounds/compound-parser-utils.d.ts.map +1 -0
  12. package/dist/compounds/compound-parser-utils.js +33 -0
  13. package/dist/compounds/compound-parser-utils.js.map +1 -0
  14. package/dist/compounds/compound-types.d.ts +26 -0
  15. package/dist/compounds/compound-types.d.ts.map +1 -0
  16. package/dist/compounds/compound-types.js +2 -0
  17. package/dist/compounds/compound-types.js.map +1 -0
  18. package/dist/compounds/compound-value-parsers.d.ts +6 -0
  19. package/dist/compounds/compound-value-parsers.d.ts.map +1 -0
  20. package/dist/compounds/compound-value-parsers.js +5 -0
  21. package/dist/compounds/compound-value-parsers.js.map +1 -0
  22. package/dist/compounds/index.d.ts +6 -0
  23. package/dist/compounds/index.d.ts.map +1 -0
  24. package/dist/compounds/index.js +6 -0
  25. package/dist/compounds/index.js.map +1 -0
  26. package/dist/compounds/parsers/index.d.ts +2 -0
  27. package/dist/compounds/parsers/index.d.ts.map +1 -0
  28. package/dist/compounds/parsers/index.js +2 -0
  29. package/dist/compounds/parsers/index.js.map +1 -0
  30. package/dist/compounds/parsers/shadow-compound.d.ts +5 -0
  31. package/dist/compounds/parsers/shadow-compound.d.ts.map +1 -0
  32. package/dist/compounds/parsers/shadow-compound.js +39 -0
  33. package/dist/compounds/parsers/shadow-compound.js.map +1 -0
  34. package/dist/css-data-types/data-types-consts.d.ts +212 -0
  35. package/dist/css-data-types/data-types-consts.d.ts.map +1 -0
  36. package/dist/css-data-types/data-types-consts.js +790 -0
  37. package/dist/css-data-types/data-types-consts.js.map +1 -0
  38. package/dist/css-data-types/data-types-predicates.d.ts +32 -0
  39. package/dist/css-data-types/data-types-predicates.d.ts.map +1 -0
  40. package/dist/css-data-types/data-types-predicates.js +353 -0
  41. package/dist/css-data-types/data-types-predicates.js.map +1 -0
  42. package/dist/css-data-types/data-types-state-machines.d.ts +14 -0
  43. package/dist/css-data-types/data-types-state-machines.d.ts.map +1 -0
  44. package/dist/css-data-types/data-types-state-machines.js +129 -0
  45. package/dist/css-data-types/data-types-state-machines.js.map +1 -0
  46. package/dist/css-data-types/data-types-types.d.ts +26 -0
  47. package/dist/css-data-types/data-types-types.d.ts.map +1 -0
  48. package/dist/css-data-types/data-types-types.js +2 -0
  49. package/dist/css-data-types/data-types-types.js.map +1 -0
  50. package/dist/css-data-types/data-types-utils.d.ts +31 -0
  51. package/dist/css-data-types/data-types-utils.d.ts.map +1 -0
  52. package/dist/css-data-types/data-types-utils.js +176 -0
  53. package/dist/css-data-types/data-types-utils.js.map +1 -0
  54. package/dist/css-data-types/data-types.d.ts +64 -0
  55. package/dist/css-data-types/data-types.d.ts.map +1 -0
  56. package/dist/css-data-types/data-types.js +304 -0
  57. package/dist/css-data-types/data-types.js.map +1 -0
  58. package/dist/css-data-types/index.d.ts +7 -0
  59. package/dist/css-data-types/index.d.ts.map +1 -0
  60. package/dist/css-data-types/index.js +7 -0
  61. package/dist/css-data-types/index.js.map +1 -0
  62. package/dist/index.d.ts +5 -0
  63. package/dist/index.d.ts.map +1 -0
  64. package/dist/index.js +5 -0
  65. package/dist/index.js.map +1 -0
  66. package/dist/shorthands/index.d.ts +8 -0
  67. package/dist/shorthands/index.d.ts.map +1 -0
  68. package/dist/shorthands/index.js +8 -0
  69. package/dist/shorthands/index.js.map +1 -0
  70. package/dist/shorthands/openers/background-position-shorthand.d.ts +5 -0
  71. package/dist/shorthands/openers/background-position-shorthand.d.ts.map +1 -0
  72. package/dist/shorthands/openers/background-position-shorthand.js +173 -0
  73. package/dist/shorthands/openers/background-position-shorthand.js.map +1 -0
  74. package/dist/shorthands/openers/background-shorthand.d.ts +5 -0
  75. package/dist/shorthands/openers/background-shorthand.d.ts.map +1 -0
  76. package/dist/shorthands/openers/background-shorthand.js +88 -0
  77. package/dist/shorthands/openers/background-shorthand.js.map +1 -0
  78. package/dist/shorthands/openers/border-image-shorthand.d.ts +5 -0
  79. package/dist/shorthands/openers/border-image-shorthand.d.ts.map +1 -0
  80. package/dist/shorthands/openers/border-image-shorthand.js +16 -0
  81. package/dist/shorthands/openers/border-image-shorthand.js.map +1 -0
  82. package/dist/shorthands/openers/border-radius-shorthand.d.ts +5 -0
  83. package/dist/shorthands/openers/border-radius-shorthand.d.ts.map +1 -0
  84. package/dist/shorthands/openers/border-radius-shorthand.js +61 -0
  85. package/dist/shorthands/openers/border-radius-shorthand.js.map +1 -0
  86. package/dist/shorthands/openers/border-shorthand.d.ts +20 -0
  87. package/dist/shorthands/openers/border-shorthand.d.ts.map +1 -0
  88. package/dist/shorthands/openers/border-shorthand.js +90 -0
  89. package/dist/shorthands/openers/border-shorthand.js.map +1 -0
  90. package/dist/shorthands/openers/flex-flow-shorthand.d.ts +5 -0
  91. package/dist/shorthands/openers/flex-flow-shorthand.d.ts.map +1 -0
  92. package/dist/shorthands/openers/flex-flow-shorthand.js +13 -0
  93. package/dist/shorthands/openers/flex-flow-shorthand.js.map +1 -0
  94. package/dist/shorthands/openers/flex-shorthand.d.ts +5 -0
  95. package/dist/shorthands/openers/flex-shorthand.d.ts.map +1 -0
  96. package/dist/shorthands/openers/flex-shorthand.js +55 -0
  97. package/dist/shorthands/openers/flex-shorthand.js.map +1 -0
  98. package/dist/shorthands/openers/font-shorthand.d.ts +5 -0
  99. package/dist/shorthands/openers/font-shorthand.d.ts.map +1 -0
  100. package/dist/shorthands/openers/font-shorthand.js +60 -0
  101. package/dist/shorthands/openers/font-shorthand.js.map +1 -0
  102. package/dist/shorthands/openers/gap-shorthand.d.ts +5 -0
  103. package/dist/shorthands/openers/gap-shorthand.d.ts.map +1 -0
  104. package/dist/shorthands/openers/gap-shorthand.js +28 -0
  105. package/dist/shorthands/openers/gap-shorthand.js.map +1 -0
  106. package/dist/shorthands/openers/grid-axis-shorthand.d.ts +6 -0
  107. package/dist/shorthands/openers/grid-axis-shorthand.d.ts.map +1 -0
  108. package/dist/shorthands/openers/grid-axis-shorthand.js +36 -0
  109. package/dist/shorthands/openers/grid-axis-shorthand.js.map +1 -0
  110. package/dist/shorthands/openers/grid-gap-shorthand.d.ts +5 -0
  111. package/dist/shorthands/openers/grid-gap-shorthand.d.ts.map +1 -0
  112. package/dist/shorthands/openers/grid-gap-shorthand.js +21 -0
  113. package/dist/shorthands/openers/grid-gap-shorthand.js.map +1 -0
  114. package/dist/shorthands/openers/grid-shorthand.d.ts +8 -0
  115. package/dist/shorthands/openers/grid-shorthand.d.ts.map +1 -0
  116. package/dist/shorthands/openers/grid-shorthand.js +145 -0
  117. package/dist/shorthands/openers/grid-shorthand.js.map +1 -0
  118. package/dist/shorthands/openers/grid-template-shorthand.d.ts +10 -0
  119. package/dist/shorthands/openers/grid-template-shorthand.d.ts.map +1 -0
  120. package/dist/shorthands/openers/grid-template-shorthand.js +113 -0
  121. package/dist/shorthands/openers/grid-template-shorthand.js.map +1 -0
  122. package/dist/shorthands/openers/index.d.ts +22 -0
  123. package/dist/shorthands/openers/index.d.ts.map +1 -0
  124. package/dist/shorthands/openers/index.js +22 -0
  125. package/dist/shorthands/openers/index.js.map +1 -0
  126. package/dist/shorthands/openers/list-style-shorthand.d.ts +5 -0
  127. package/dist/shorthands/openers/list-style-shorthand.d.ts.map +1 -0
  128. package/dist/shorthands/openers/list-style-shorthand.js +15 -0
  129. package/dist/shorthands/openers/list-style-shorthand.js.map +1 -0
  130. package/dist/shorthands/openers/margin-shorthand.d.ts +5 -0
  131. package/dist/shorthands/openers/margin-shorthand.d.ts.map +1 -0
  132. package/dist/shorthands/openers/margin-shorthand.js +11 -0
  133. package/dist/shorthands/openers/margin-shorthand.js.map +1 -0
  134. package/dist/shorthands/openers/outline-shorthand.d.ts +5 -0
  135. package/dist/shorthands/openers/outline-shorthand.d.ts.map +1 -0
  136. package/dist/shorthands/openers/outline-shorthand.js +14 -0
  137. package/dist/shorthands/openers/outline-shorthand.js.map +1 -0
  138. package/dist/shorthands/openers/overflow-shorthand.d.ts +5 -0
  139. package/dist/shorthands/openers/overflow-shorthand.d.ts.map +1 -0
  140. package/dist/shorthands/openers/overflow-shorthand.js +21 -0
  141. package/dist/shorthands/openers/overflow-shorthand.js.map +1 -0
  142. package/dist/shorthands/openers/padding-shorthand.d.ts +5 -0
  143. package/dist/shorthands/openers/padding-shorthand.d.ts.map +1 -0
  144. package/dist/shorthands/openers/padding-shorthand.js +11 -0
  145. package/dist/shorthands/openers/padding-shorthand.js.map +1 -0
  146. package/dist/shorthands/openers/place-content-shorthand.d.ts +5 -0
  147. package/dist/shorthands/openers/place-content-shorthand.d.ts.map +1 -0
  148. package/dist/shorthands/openers/place-content-shorthand.js +29 -0
  149. package/dist/shorthands/openers/place-content-shorthand.js.map +1 -0
  150. package/dist/shorthands/openers/place-items-shorthand.d.ts +5 -0
  151. package/dist/shorthands/openers/place-items-shorthand.d.ts.map +1 -0
  152. package/dist/shorthands/openers/place-items-shorthand.js +23 -0
  153. package/dist/shorthands/openers/place-items-shorthand.js.map +1 -0
  154. package/dist/shorthands/openers/text-decoration-shorthand.d.ts +5 -0
  155. package/dist/shorthands/openers/text-decoration-shorthand.d.ts.map +1 -0
  156. package/dist/shorthands/openers/text-decoration-shorthand.js +14 -0
  157. package/dist/shorthands/openers/text-decoration-shorthand.js.map +1 -0
  158. package/dist/shorthands/shorthand-css-data.d.ts +120 -0
  159. package/dist/shorthands/shorthand-css-data.d.ts.map +1 -0
  160. package/dist/shorthands/shorthand-css-data.js +48 -0
  161. package/dist/shorthands/shorthand-css-data.js.map +1 -0
  162. package/dist/shorthands/shorthand-mapper.d.ts +6 -0
  163. package/dist/shorthands/shorthand-mapper.d.ts.map +1 -0
  164. package/dist/shorthands/shorthand-mapper.js +72 -0
  165. package/dist/shorthands/shorthand-mapper.js.map +1 -0
  166. package/dist/shorthands/shorthand-parser-errors.d.ts +25 -0
  167. package/dist/shorthands/shorthand-parser-errors.d.ts.map +1 -0
  168. package/dist/shorthands/shorthand-parser-errors.js +41 -0
  169. package/dist/shorthands/shorthand-parser-errors.js.map +1 -0
  170. package/dist/shorthands/shorthand-parser-utils.d.ts +24 -0
  171. package/dist/shorthands/shorthand-parser-utils.d.ts.map +1 -0
  172. package/dist/shorthands/shorthand-parser-utils.js +398 -0
  173. package/dist/shorthands/shorthand-parser-utils.js.map +1 -0
  174. package/dist/shorthands/shorthand-types.d.ts +64 -0
  175. package/dist/shorthands/shorthand-types.d.ts.map +1 -0
  176. package/dist/shorthands/shorthand-types.js +2 -0
  177. package/dist/shorthands/shorthand-types.js.map +1 -0
  178. package/dist/shorthands/shorthands-ast-evaluation.d.ts +5 -0
  179. package/dist/shorthands/shorthands-ast-evaluation.d.ts.map +1 -0
  180. package/dist/shorthands/shorthands-ast-evaluation.js +19 -0
  181. package/dist/shorthands/shorthands-ast-evaluation.js.map +1 -0
  182. package/dist/tokenizers/css-value-tokenizer.d.ts +43 -0
  183. package/dist/tokenizers/css-value-tokenizer.d.ts.map +1 -0
  184. package/dist/tokenizers/css-value-tokenizer.js +154 -0
  185. package/dist/tokenizers/css-value-tokenizer.js.map +1 -0
  186. package/dist/tokenizers/index.d.ts +2 -0
  187. package/dist/tokenizers/index.d.ts.map +1 -0
  188. package/dist/tokenizers/index.js +2 -0
  189. package/dist/tokenizers/index.js.map +1 -0
  190. package/package.json +54 -0
  191. package/src/compounds/compound-css-data.ts +24 -0
  192. package/src/compounds/compound-mapper.ts +21 -0
  193. package/src/compounds/compound-parser-utils.ts +47 -0
  194. package/src/compounds/compound-types.ts +35 -0
  195. package/src/compounds/compound-value-parsers.ts +12 -0
  196. package/src/compounds/index.ts +5 -0
  197. package/src/compounds/parsers/index.ts +1 -0
  198. package/src/compounds/parsers/shadow-compound.ts +56 -0
  199. package/src/css-data-types/data-types-consts.ts +877 -0
  200. package/src/css-data-types/data-types-predicates.ts +477 -0
  201. package/src/css-data-types/data-types-state-machines.ts +169 -0
  202. package/src/css-data-types/data-types-types.ts +43 -0
  203. package/src/css-data-types/data-types-utils.ts +258 -0
  204. package/src/css-data-types/data-types.ts +435 -0
  205. package/src/css-data-types/index.ts +6 -0
  206. package/src/index.ts +4 -0
  207. package/src/shorthands/index.ts +7 -0
  208. package/src/shorthands/openers/background-position-shorthand.ts +180 -0
  209. package/src/shorthands/openers/background-shorthand.ts +161 -0
  210. package/src/shorthands/openers/border-image-shorthand.ts +35 -0
  211. package/src/shorthands/openers/border-radius-shorthand.ts +93 -0
  212. package/src/shorthands/openers/border-shorthand.ts +198 -0
  213. package/src/shorthands/openers/flex-flow-shorthand.ts +24 -0
  214. package/src/shorthands/openers/flex-shorthand.ts +79 -0
  215. package/src/shorthands/openers/font-shorthand.ts +85 -0
  216. package/src/shorthands/openers/gap-shorthand.ts +47 -0
  217. package/src/shorthands/openers/grid-axis-shorthand.ts +61 -0
  218. package/src/shorthands/openers/grid-gap-shorthand.ts +40 -0
  219. package/src/shorthands/openers/grid-shorthand.ts +260 -0
  220. package/src/shorthands/openers/grid-template-shorthand.ts +176 -0
  221. package/src/shorthands/openers/index.ts +21 -0
  222. package/src/shorthands/openers/list-style-shorthand.ts +33 -0
  223. package/src/shorthands/openers/margin-shorthand.ts +20 -0
  224. package/src/shorthands/openers/outline-shorthand.ts +27 -0
  225. package/src/shorthands/openers/overflow-shorthand.ts +40 -0
  226. package/src/shorthands/openers/padding-shorthand.ts +21 -0
  227. package/src/shorthands/openers/place-content-shorthand.ts +49 -0
  228. package/src/shorthands/openers/place-items-shorthand.ts +43 -0
  229. package/src/shorthands/openers/text-decoration-shorthand.ts +27 -0
  230. package/src/shorthands/shorthand-css-data.ts +210 -0
  231. package/src/shorthands/shorthand-mapper.ts +157 -0
  232. package/src/shorthands/shorthand-parser-errors.ts +47 -0
  233. package/src/shorthands/shorthand-parser-utils.ts +602 -0
  234. package/src/shorthands/shorthand-types.ts +107 -0
  235. package/src/shorthands/shorthands-ast-evaluation.ts +38 -0
  236. package/src/tokenizers/css-value-tokenizer.ts +220 -0
  237. package/src/tokenizers/index.ts +1 -0
@@ -0,0 +1,176 @@
1
+ import type {
2
+ EvaluatedAst,
3
+ OpenedShorthand,
4
+ SimpleOpenedShorthand,
5
+ SimpleShorthandOpener,
6
+ SimpleShorthandOpenerInner,
7
+ ShorthandPart,
8
+ GetSimpleShorthandOpener,
9
+ ShorthandCloser,
10
+ GetShorthandCloser,
11
+ } from '../shorthand-types.js';
12
+
13
+ import { valueTextNode } from '../../tokenizers/index.js';
14
+ import { type GridTemplates, GRID_TEMPLATE_KEYWORD_VALUE_MAP } from '../shorthand-css-data.js';
15
+ import {
16
+ trackSizePredicate,
17
+ gridTemplateAreasDataType,
18
+ gridTemplateRowsDataType,
19
+ gridTemplateColumnsDataType,
20
+ gridTemplateSingleValueDataType,
21
+ } from '../../css-data-types/index.js';
22
+ import {
23
+ isOpenedInitial,
24
+ singleKeywordShorthandOpener,
25
+ createShorthandOpener,
26
+ getOpenedNode,
27
+ shorthandCloserTemplate,
28
+ createShorthandCloser,
29
+ fixAstNodesPositions,
30
+ } from '../shorthand-parser-utils.js';
31
+ import { CannotCloseGridTemplateError } from '../shorthand-parser-errors.js';
32
+
33
+ type OpenedGridTemplates<V> = OpenedShorthand<V, GridTemplates>;
34
+ type GridTemplateShorthandCloser<V> = ShorthandCloser<V, GridTemplates, OpenedGridTemplates<V>>;
35
+
36
+ export const getGridTemplateShorthandParts = <V>() =>
37
+ [
38
+ { prop: 'grid-template-areas', dataType: gridTemplateAreasDataType, multipleItems: true },
39
+ { prop: 'grid-template-rows', dataType: gridTemplateRowsDataType, multipleItems: true },
40
+ { prop: 'grid-template-columns', dataType: gridTemplateColumnsDataType, multipleItems: true },
41
+ ] as ShorthandPart<V, GridTemplates>[];
42
+
43
+ function isNamedLineStart<V>({ value }: EvaluatedAst<V>) {
44
+ return value.type === 'text' && value.text.startsWith('[');
45
+ }
46
+
47
+ function isNamedLineEnd<V>({ value }: EvaluatedAst<V>) {
48
+ return value.type === 'text' && value.text.endsWith(']');
49
+ }
50
+
51
+ function isGridAreasString<V>({ value }: EvaluatedAst<V>) {
52
+ return value.type === 'string';
53
+ }
54
+
55
+ export function gridTemplateShorthandOpener<V>(
56
+ valueAst: EvaluatedAst<V>[],
57
+ ): OpenedShorthand<V, 'grid-template-rows' | 'grid-template-columns' | 'grid-template-areas'> {
58
+ const delimiterIndex = valueAst.findIndex((node) => node.value.type === '/');
59
+
60
+ const rowAndAreaNodes = delimiterIndex === -1 ? [...valueAst] : valueAst.slice(0, delimiterIndex);
61
+ const columnNodes = delimiterIndex === -1 ? [] : valueAst.slice(delimiterIndex + 1);
62
+
63
+ const hasAreas = rowAndAreaNodes.some((node) => node.value.type === 'string');
64
+ if (!hasAreas) {
65
+ if (columnNodes.length === 0) throw new Error('Invalid definition. grid-template should have columns defined.');
66
+
67
+ return {
68
+ 'grid-template-areas': [{ value: valueTextNode('none') }],
69
+ 'grid-template-rows': rowAndAreaNodes,
70
+ 'grid-template-columns': columnNodes,
71
+ };
72
+ }
73
+
74
+ const rowNodes: EvaluatedAst<V>[] = [];
75
+ const areaNodes: EvaluatedAst<V>[] = [];
76
+ while (rowAndAreaNodes.length) {
77
+ const node = rowAndAreaNodes.shift();
78
+ if (!node) break;
79
+
80
+ if (isNamedLineStart(node)) {
81
+ let namedLine: EvaluatedAst<V> | undefined = node;
82
+ rowNodes.push(namedLine);
83
+ while (!isNamedLineEnd(namedLine)) {
84
+ namedLine = rowAndAreaNodes.shift();
85
+ if (!namedLine) throw new Error('Invalid definition. Named lines should be closed with ].');
86
+ rowNodes.push(namedLine);
87
+ }
88
+ } else if (isGridAreasString(node)) {
89
+ areaNodes.push(node);
90
+
91
+ const nextNode = rowAndAreaNodes[0];
92
+ if (nextNode && !isNamedLineStart(nextNode) && !isGridAreasString(nextNode)) {
93
+ // right after grid areas string should follow a row track
94
+ rowNodes.push(rowAndAreaNodes.shift()!);
95
+ } else {
96
+ // It is `auto` by default, if not defined explicitly
97
+ rowNodes.push({ value: valueTextNode('auto') });
98
+ }
99
+ } else {
100
+ throw new Error('Invalid definition. Grid row track should follow right after grid area.');
101
+ }
102
+ }
103
+
104
+ return {
105
+ 'grid-template-rows': rowNodes,
106
+ 'grid-template-areas': areaNodes,
107
+ 'grid-template-columns': columnNodes.length ? columnNodes : [{ value: valueTextNode('none') }],
108
+ };
109
+ }
110
+
111
+ // grid-template
112
+ export const openGridTemplateShorthand: GetSimpleShorthandOpener<GridTemplates> = <V>() =>
113
+ createShorthandOpener({
114
+ prop: 'grid-template',
115
+ singleKeywordPart: {
116
+ prop: 'grid-template',
117
+ dataType: gridTemplateSingleValueDataType,
118
+ partOpener: singleKeywordShorthandOpener(
119
+ GRID_TEMPLATE_KEYWORD_VALUE_MAP,
120
+ true,
121
+ ) as SimpleShorthandOpenerInner<V, GridTemplates>,
122
+ },
123
+ parts: getGridTemplateShorthandParts(),
124
+ shorthandOpener: gridTemplateShorthandOpener,
125
+ }) as SimpleShorthandOpener<V, GridTemplates>;
126
+
127
+ const closeGridTemplateShorthandRowsColumnsSyntax: GetShorthandCloser<GridTemplates> = <V>() =>
128
+ createShorthandCloser<V, GridTemplates>(
129
+ shorthandCloserTemplate<GridTemplates>`${'grid-template-rows'} / ${'grid-template-columns'}`,
130
+ );
131
+
132
+ const closeGridTemplateShorthandAreasSyntax =
133
+ <V>(): GridTemplateShorthandCloser<V> =>
134
+ (opened, api, detachExpression) => {
135
+ const openedAreas = opened['grid-template-areas'] as EvaluatedAst<V>[];
136
+ const openedRows = opened['grid-template-rows'] as EvaluatedAst<V>[];
137
+
138
+ const areasList = [...openedAreas];
139
+ const splicedAreasRows = openedRows.reduce((splicedAreasRows, value) => {
140
+ const valueList = [value];
141
+ if (trackSizePredicate(value.value)) {
142
+ const currArea = areasList.shift();
143
+ if (!currArea) {
144
+ throw new CannotCloseGridTemplateError();
145
+ }
146
+
147
+ valueList.unshift(currArea);
148
+ }
149
+ return splicedAreasRows.concat(valueList);
150
+ }, [] as EvaluatedAst<V>[]);
151
+ if (areasList.length > 0) {
152
+ throw new CannotCloseGridTemplateError();
153
+ }
154
+
155
+ return getOpenedNode(splicedAreasRows, api, detachExpression);
156
+ };
157
+
158
+ export const closeGridTemplateShorthand =
159
+ <V>(): GridTemplateShorthandCloser<V> =>
160
+ (opened, api, detachExpression) => {
161
+ if (isOpenedInitial(opened, 'grid-template-areas', gridTemplateAreasDataType)) {
162
+ return closeGridTemplateShorthandRowsColumnsSyntax<V>()(
163
+ opened as SimpleOpenedShorthand<V, GridTemplates>,
164
+ api,
165
+ detachExpression,
166
+ );
167
+ }
168
+
169
+ const closedAst = closeGridTemplateShorthandAreasSyntax<V>()(opened, api, detachExpression);
170
+ return fixAstNodesPositions(
171
+ closedAst
172
+ .concat({ ...valueTextNode('/'), type: '/' })
173
+ .concat(getOpenedNode(opened['grid-template-columns'], api, detachExpression)),
174
+ api,
175
+ );
176
+ };
@@ -0,0 +1,21 @@
1
+ export * from './margin-shorthand.js';
2
+ export * from './padding-shorthand.js';
3
+ export * from './border-radius-shorthand.js';
4
+ export * from './border-shorthand.js';
5
+ export * from './outline-shorthand.js';
6
+ export * from './border-image-shorthand.js';
7
+ export * from './background-shorthand.js';
8
+ export * from './background-position-shorthand.js';
9
+ export * from './font-shorthand.js';
10
+ export * from './place-content-shorthand.js';
11
+ export * from './place-items-shorthand.js';
12
+ export * from './flex-shorthand.js';
13
+ export * from './flex-flow-shorthand.js';
14
+ export * from './gap-shorthand.js';
15
+ export * from './grid-gap-shorthand.js';
16
+ export * from './grid-axis-shorthand.js';
17
+ export * from './grid-template-shorthand.js';
18
+ export * from './grid-shorthand.js';
19
+ export * from './overflow-shorthand.js';
20
+ export * from './text-decoration-shorthand.js';
21
+ export * from './list-style-shorthand.js';
@@ -0,0 +1,33 @@
1
+ import type { ListStyles } from '../shorthand-css-data.js';
2
+ import type { SimpleShorthandOpener, GetSimpleShorthandOpener, GetShorthandCloser } from '../shorthand-types.js';
3
+
4
+ import {
5
+ imageSourceDataType,
6
+ listStyleSingleValueDataType,
7
+ listStylePositionDataType,
8
+ listStyleTypeDataType,
9
+ } from '../../css-data-types/index.js';
10
+ import {
11
+ unorderedListShorthandOpener,
12
+ createShorthandOpener,
13
+ shorthandCloserTemplate,
14
+ createShorthandCloser,
15
+ } from '../shorthand-parser-utils.js';
16
+
17
+ // list-style
18
+ export const openListStyleShorthand: GetSimpleShorthandOpener<ListStyles> = <V>() =>
19
+ createShorthandOpener({
20
+ prop: 'list-style',
21
+ singleKeywordPart: { prop: 'list-style', dataType: listStyleSingleValueDataType },
22
+ parts: [
23
+ { prop: 'list-style-type', dataType: listStyleTypeDataType },
24
+ { prop: 'list-style-image', dataType: imageSourceDataType },
25
+ { prop: 'list-style-position', dataType: listStylePositionDataType },
26
+ ],
27
+ shorthandOpener: (astNodes, api, parts) => unorderedListShorthandOpener(parts)(astNodes, api),
28
+ }) as SimpleShorthandOpener<V, ListStyles>;
29
+
30
+ export const closeListStyleShorthand: GetShorthandCloser<ListStyles> = <V>() =>
31
+ createShorthandCloser<V, ListStyles>(
32
+ shorthandCloserTemplate<ListStyles>`${'list-style-type'} ${'list-style-image'} ${'list-style-position'}`,
33
+ );
@@ -0,0 +1,20 @@
1
+ import type { Margins } from '../shorthand-css-data.js';
2
+ import type { GetSimpleShorthandOpener, GetShorthandCloser } from '../shorthand-types.js';
3
+
4
+ import {
5
+ edgesShorthandOpener,
6
+ createShorthandOpenerFromPart,
7
+ edgesShorthandCloser,
8
+ } from '../shorthand-parser-utils.js';
9
+ import { ALWAYS_DATA_TYPE } from '../../css-data-types/index.js';
10
+
11
+ // margin
12
+ export const openMarginShorthand: GetSimpleShorthandOpener<Margins> = <V>() =>
13
+ createShorthandOpenerFromPart<V, Margins>({
14
+ prop: 'margin',
15
+ dataType: ALWAYS_DATA_TYPE,
16
+ partOpener: edgesShorthandOpener('margin'),
17
+ openedProps: ['margin-top', 'margin-right', 'margin-bottom', 'margin-left'],
18
+ });
19
+
20
+ export const closeMarginShorthand: GetShorthandCloser<Margins> = <V>() => edgesShorthandCloser<V, Margins>('margin');
@@ -0,0 +1,27 @@
1
+ import type { Outlines } from '../shorthand-css-data.js';
2
+ import type { SimpleShorthandOpener, GetSimpleShorthandOpener, GetShorthandCloser } from '../shorthand-types.js';
3
+
4
+ import { outlineStyleDataType, lineWidthDataType, outlineColorDataType } from '../../css-data-types/index.js';
5
+ import {
6
+ unorderedListShorthandOpener,
7
+ createShorthandOpener,
8
+ shorthandCloserTemplate,
9
+ createShorthandCloser,
10
+ } from '../shorthand-parser-utils.js';
11
+
12
+ // outline
13
+ export const openOutlineShorthand: GetSimpleShorthandOpener<Outlines> = <V>() =>
14
+ createShorthandOpener({
15
+ prop: 'outline',
16
+ parts: [
17
+ { prop: 'outline-style', dataType: outlineStyleDataType },
18
+ { prop: 'outline-width', dataType: lineWidthDataType },
19
+ { prop: 'outline-color', dataType: outlineColorDataType },
20
+ ],
21
+ shorthandOpener: (astNodes, api, parts) => unorderedListShorthandOpener(parts)(astNodes, api),
22
+ }) as SimpleShorthandOpener<V, Outlines>;
23
+
24
+ export const closeOutlineShorthand: GetShorthandCloser<Outlines> = <V>() =>
25
+ createShorthandCloser<V, Outlines>(
26
+ shorthandCloserTemplate<Outlines>`${'outline-style'} ${'outline-width'} ${'outline-color'}`,
27
+ );
@@ -0,0 +1,40 @@
1
+ import type { Overflows } from '../shorthand-css-data.js';
2
+ import type {
3
+ SimpleShorthandOpener,
4
+ ShorthandPart,
5
+ GetSimpleShorthandOpener,
6
+ GetShorthandCloser,
7
+ } from '../shorthand-types.js';
8
+
9
+ import { overflowDataType } from '../../css-data-types/index.js';
10
+ import {
11
+ splitSimpleShorthandOpener,
12
+ unorderedListShorthandOpener,
13
+ createShorthandOpener,
14
+ createShorthandCloserTemplateFromParts,
15
+ createShorthandCloser,
16
+ } from '../shorthand-parser-utils.js';
17
+
18
+ const getOverflowShorthandParts = <V>() =>
19
+ [
20
+ {
21
+ prop: 'overflow-x',
22
+ dataType: overflowDataType,
23
+ partOpener: splitSimpleShorthandOpener(['overflow-x', 'overflow-y']),
24
+ },
25
+ {
26
+ prop: 'overflow-y',
27
+ dataType: overflowDataType,
28
+ },
29
+ ] as ShorthandPart<V, Overflows>[];
30
+
31
+ // overflow
32
+ export const openOverflowShorthand: GetSimpleShorthandOpener<Overflows> = <V>() =>
33
+ createShorthandOpener({
34
+ prop: 'overflow',
35
+ parts: getOverflowShorthandParts(),
36
+ shorthandOpener: (astNodes, api, parts) => unorderedListShorthandOpener(parts)(astNodes, api),
37
+ }) as SimpleShorthandOpener<V, Overflows>;
38
+
39
+ export const closeOverflowShorthand: GetShorthandCloser<Overflows> = <V>() =>
40
+ createShorthandCloser<V, Overflows>(createShorthandCloserTemplateFromParts(getOverflowShorthandParts()));
@@ -0,0 +1,21 @@
1
+ import type { Paddings } from '../shorthand-css-data.js';
2
+ import type { GetSimpleShorthandOpener, GetShorthandCloser } from '../shorthand-types.js';
3
+
4
+ import {
5
+ edgesShorthandOpener,
6
+ createShorthandOpenerFromPart,
7
+ edgesShorthandCloser,
8
+ } from '../shorthand-parser-utils.js';
9
+ import { ALWAYS_DATA_TYPE } from '../../css-data-types/index.js';
10
+
11
+ // padding
12
+ export const openPaddingShorthand: GetSimpleShorthandOpener<Paddings> = <V>() =>
13
+ createShorthandOpenerFromPart<V, Paddings>({
14
+ prop: 'padding',
15
+ dataType: ALWAYS_DATA_TYPE,
16
+ partOpener: edgesShorthandOpener('padding'),
17
+ openedProps: ['padding-top', 'padding-right', 'padding-bottom', 'padding-left'],
18
+ });
19
+
20
+ export const closePaddingShorthand: GetShorthandCloser<Paddings> = <V>() =>
21
+ edgesShorthandCloser<V, Paddings>('padding');
@@ -0,0 +1,49 @@
1
+ import type { PlaceContents } from '../shorthand-css-data.js';
2
+ import type {
3
+ SimpleShorthandOpener,
4
+ ShorthandPart,
5
+ GetSimpleShorthandOpener,
6
+ GetShorthandCloser,
7
+ } from '../shorthand-types.js';
8
+
9
+ import { alignContentDataType, justifyContentDataType } from '../../css-data-types/index.js';
10
+ import {
11
+ intersectionBeforeOpenerCheck,
12
+ splitSimpleShorthandOpener,
13
+ unorderedListShorthandOpener,
14
+ createShorthandOpener,
15
+ createShorthandCloserTemplateFromParts,
16
+ createShorthandCloser,
17
+ } from '../shorthand-parser-utils.js';
18
+
19
+ const getPlaceContentShorthandParts = <V>() =>
20
+ [
21
+ {
22
+ prop: 'align-content',
23
+ dataType: alignContentDataType,
24
+ beforeOpenerCheck: intersectionBeforeOpenerCheck('place-content', [
25
+ alignContentDataType,
26
+ justifyContentDataType,
27
+ ]),
28
+ partOpener: splitSimpleShorthandOpener(['align-content', 'justify-content']),
29
+ },
30
+ {
31
+ prop: 'justify-content',
32
+ dataType: justifyContentDataType,
33
+ beforeOpenerCheck: intersectionBeforeOpenerCheck('place-content', [
34
+ alignContentDataType,
35
+ justifyContentDataType,
36
+ ]),
37
+ },
38
+ ] as ShorthandPart<V, PlaceContents>[];
39
+
40
+ // place-content
41
+ export const openPlaceContentShorthand: GetSimpleShorthandOpener<PlaceContents> = <V>() =>
42
+ createShorthandOpener({
43
+ prop: 'place-content',
44
+ parts: getPlaceContentShorthandParts(),
45
+ shorthandOpener: (astNodes, api, parts) => unorderedListShorthandOpener(parts)(astNodes, api),
46
+ }) as SimpleShorthandOpener<V, PlaceContents>;
47
+
48
+ export const closePlaceContentShorthand: GetShorthandCloser<PlaceContents> = <V>() =>
49
+ createShorthandCloser<V, PlaceContents>(createShorthandCloserTemplateFromParts(getPlaceContentShorthandParts()));
@@ -0,0 +1,43 @@
1
+ import type { PlaceItems } from '../shorthand-css-data.js';
2
+ import type {
3
+ SimpleShorthandOpener,
4
+ ShorthandPart,
5
+ GetSimpleShorthandOpener,
6
+ GetShorthandCloser,
7
+ } from '../shorthand-types.js';
8
+
9
+ import { alignItemsDataType, justifyItemsDataType } from '../../css-data-types/index.js';
10
+ import {
11
+ intersectionBeforeOpenerCheck,
12
+ splitSimpleShorthandOpener,
13
+ unorderedListShorthandOpener,
14
+ createShorthandOpener,
15
+ createShorthandCloserTemplateFromParts,
16
+ createShorthandCloser,
17
+ } from '../shorthand-parser-utils.js';
18
+
19
+ const getPlaceItemsShorthandParts = <V>() =>
20
+ [
21
+ {
22
+ prop: 'align-items',
23
+ dataType: alignItemsDataType,
24
+ beforeOpenerCheck: intersectionBeforeOpenerCheck('place-items', [alignItemsDataType, justifyItemsDataType]),
25
+ partOpener: splitSimpleShorthandOpener(['align-items', 'justify-items']),
26
+ },
27
+ {
28
+ prop: 'justify-items',
29
+ dataType: justifyItemsDataType,
30
+ beforeOpenerCheck: intersectionBeforeOpenerCheck('place-items', [alignItemsDataType, justifyItemsDataType]),
31
+ },
32
+ ] as ShorthandPart<V, PlaceItems>[];
33
+
34
+ // place-items
35
+ export const openPlaceItemsShorthand: GetSimpleShorthandOpener<PlaceItems> = <V>() =>
36
+ createShorthandOpener({
37
+ prop: 'place-items',
38
+ parts: getPlaceItemsShorthandParts(),
39
+ shorthandOpener: (astNodes, api, parts) => unorderedListShorthandOpener(parts)(astNodes, api),
40
+ }) as SimpleShorthandOpener<V, PlaceItems>;
41
+
42
+ export const closePlaceItemsShorthand: GetShorthandCloser<PlaceItems> = <V>() =>
43
+ createShorthandCloser<V, PlaceItems>(createShorthandCloserTemplateFromParts(getPlaceItemsShorthandParts()));
@@ -0,0 +1,27 @@
1
+ import type { TextDecorations } from '../shorthand-css-data.js';
2
+ import type { SimpleShorthandOpener, GetSimpleShorthandOpener, GetShorthandCloser } from '../shorthand-types.js';
3
+
4
+ import { colorDataType, textDecorationLineDataType, textDecorationStyleDataType } from '../../css-data-types/index.js';
5
+ import {
6
+ unorderedListShorthandOpener,
7
+ createShorthandOpener,
8
+ shorthandCloserTemplate,
9
+ createShorthandCloser,
10
+ } from '../shorthand-parser-utils.js';
11
+
12
+ // text-decoration
13
+ export const openTextDecorationShorthand: GetSimpleShorthandOpener<TextDecorations> = <V>() =>
14
+ createShorthandOpener({
15
+ prop: 'text-decoration',
16
+ parts: [
17
+ { prop: 'text-decoration-color', dataType: colorDataType },
18
+ { prop: 'text-decoration-line', dataType: textDecorationLineDataType },
19
+ { prop: 'text-decoration-style', dataType: textDecorationStyleDataType },
20
+ ],
21
+ shorthandOpener: (astNodes, api, parts) => unorderedListShorthandOpener(parts)(astNodes, api),
22
+ }) as SimpleShorthandOpener<V, TextDecorations>;
23
+
24
+ export const closeTextDecorationShorthand: GetShorthandCloser<TextDecorations> = <V>() =>
25
+ createShorthandCloser<V, TextDecorations>(
26
+ shorthandCloserTemplate<TextDecorations>`${'text-decoration-color'} ${'text-decoration-line'} ${'text-decoration-style'}`,
27
+ );
@@ -0,0 +1,210 @@
1
+ import type { EvaluatedAst } from './shorthand-types.js';
2
+ import {
3
+ INITIAL_FLEX_GROW,
4
+ AUTO_FLEX_GROW,
5
+ INITIAL_FLEX_SHRINK,
6
+ NONE_FLEX_SHRINK,
7
+ AUTO_FLEX_BASIS,
8
+ INITIAL_GRID_TEMPLATE_AREAS,
9
+ INITIAL_GRID_TEMPLATE_AXIS,
10
+ INITIAL_GRID_AUTO_FLOW,
11
+ INITIAL_GRID_AUTO_AXIS,
12
+ } from '../css-data-types/index.js';
13
+
14
+ export type Margins = 'margin-top' | 'margin-right' | 'margin-bottom' | 'margin-left';
15
+
16
+ export type Paddings = 'padding-top' | 'padding-right' | 'padding-bottom' | 'padding-left';
17
+
18
+ export type BorderRadiuses =
19
+ | 'border-top-left-radius'
20
+ | 'border-top-right-radius'
21
+ | 'border-bottom-right-radius'
22
+ | 'border-bottom-left-radius';
23
+ export type OpenedBorderRadiusShorthand<V> = Array<Record<BorderRadiuses, EvaluatedAst<V>>>;
24
+
25
+ export type BorderStyles = 'border-top-style' | 'border-right-style' | 'border-bottom-style' | 'border-left-style';
26
+ export type BorderWidths = 'border-top-width' | 'border-right-width' | 'border-bottom-width' | 'border-left-width';
27
+ export type BorderColors = 'border-top-color' | 'border-right-color' | 'border-bottom-color' | 'border-left-color';
28
+ export type BordersShallow = 'border-style' | 'border-width' | 'border-color';
29
+ export type Borders = BorderStyles | BorderWidths | BorderColors;
30
+ export type BordersTop = 'border-top-style' | 'border-top-width' | 'border-top-color';
31
+ export type BordersRight = 'border-right-style' | 'border-right-width' | 'border-right-color';
32
+ export type BordersBottom = 'border-bottom-style' | 'border-bottom-width' | 'border-bottom-color';
33
+ export type BordersLeft = 'border-left-style' | 'border-left-width' | 'border-left-color';
34
+
35
+ export type Outlines = 'outline-style' | 'outline-width' | 'outline-color';
36
+
37
+ export type BorderImages =
38
+ | 'border-image-source'
39
+ | 'border-image-slice'
40
+ | 'border-image-width'
41
+ | 'border-image-outset'
42
+ | 'border-image-repeat';
43
+ export type OpenedBorderImageShorthand<V> = {
44
+ 'border-image-source': EvaluatedAst<V>;
45
+ 'border-image-slice': EvaluatedAst<V>[];
46
+ 'border-image-width': EvaluatedAst<V>[];
47
+ 'border-image-outset': EvaluatedAst<V>[];
48
+ 'border-image-repeat': EvaluatedAst<V>[];
49
+ };
50
+
51
+ export type Backgrounds =
52
+ | 'background-attachment'
53
+ | 'background-clip'
54
+ | 'background-color'
55
+ | 'background-image'
56
+ | 'background-origin'
57
+ | 'background-position'
58
+ | 'background-repeat'
59
+ | 'background-size';
60
+ export type BackgroundLayer<V> = {
61
+ 'background-attachment': EvaluatedAst<V>;
62
+ 'background-clip': EvaluatedAst<V>;
63
+ 'background-image': EvaluatedAst<V>;
64
+ 'background-origin': EvaluatedAst<V>;
65
+ 'background-position': EvaluatedAst<V>[];
66
+ 'background-repeat': EvaluatedAst<V>[];
67
+ 'background-size': EvaluatedAst<V>[];
68
+ };
69
+ export interface OpenedBackgroundShorthand<V> {
70
+ layers: BackgroundLayer<V>[];
71
+ color: EvaluatedAst<V>;
72
+ }
73
+
74
+ export type BackgroundPositionLonghand = 'background-position-x' | 'background-position-y';
75
+
76
+ export interface OpenedBackgroundPositionShorthand<V> {
77
+ 'background-position-x': EvaluatedAst<V>[];
78
+ 'background-position-y': EvaluatedAst<V>[];
79
+ }
80
+
81
+ export type FontPrefixes = 'font-style' | 'font-variant' | 'font-weight' | 'font-stretch';
82
+ export type FontSuffixes = 'font-size' | 'line-height' | 'font-family';
83
+ export type Fonts = FontPrefixes | FontSuffixes | 'font';
84
+ export type OpenedFontShorthand<V> = {
85
+ 'font-style': EvaluatedAst<V>[];
86
+ 'font-variant': EvaluatedAst<V>;
87
+ 'font-weight': EvaluatedAst<V>;
88
+ 'font-stretch': EvaluatedAst<V>;
89
+ 'font-size': EvaluatedAst<V>;
90
+ 'line-height': EvaluatedAst<V>;
91
+ 'font-family': EvaluatedAst<V>[];
92
+ font: EvaluatedAst<V>;
93
+ };
94
+
95
+ export type PlaceContents = 'align-content' | 'justify-content';
96
+ export type PlaceItems = 'align-items' | 'justify-items';
97
+
98
+ export type Flexes = 'flex-grow' | 'flex-shrink' | 'flex-basis';
99
+
100
+ export type FlexFlows = 'flex-direction' | 'flex-wrap';
101
+
102
+ export type Gaps = 'row-gap' | 'column-gap';
103
+ export type GridGaps = 'grid-row-gap' | 'grid-column-gap';
104
+ export type GridRows = 'grid-row-start' | 'grid-row-end';
105
+ export type GridColumns = 'grid-column-start' | 'grid-column-end';
106
+ export type GridAxis = 'row' | 'column';
107
+ export type GridAxisLonghands<A extends GridAxis> = A extends 'row' ? GridRows : GridColumns;
108
+
109
+ export type GridTemplates = 'grid-template-areas' | 'grid-template-rows' | 'grid-template-columns';
110
+ export type Grids = GridTemplates | 'grid-auto-flow' | 'grid-auto-rows' | 'grid-auto-columns';
111
+
112
+ export type Overflows = 'overflow-x' | 'overflow-y';
113
+
114
+ export type TextDecorations = 'text-decoration-color' | 'text-decoration-line' | 'text-decoration-style';
115
+
116
+ export type ListStyles = 'list-style-type' | 'list-style-image' | 'list-style-position';
117
+
118
+ export type ShorthandsTypeMap = {
119
+ background: Backgrounds;
120
+ 'background-position': BackgroundPositionLonghand;
121
+ 'border-radius': BorderRadiuses;
122
+ border: Borders;
123
+ 'border-top': BordersTop;
124
+ 'border-right': BordersRight;
125
+ 'border-bottom': BordersBottom;
126
+ 'border-left': BordersLeft;
127
+ 'border-style': BorderStyles;
128
+ 'border-width': BorderWidths;
129
+ 'border-color': BorderColors;
130
+ outline: Outlines;
131
+ 'border-image': BorderImages;
132
+ font: Fonts;
133
+ 'place-content': PlaceContents;
134
+ 'place-items': PlaceItems;
135
+ flex: Flexes;
136
+ 'flex-flow': FlexFlows;
137
+ gap: Gaps;
138
+ 'grid-gap': GridGaps;
139
+ 'grid-row': GridRows;
140
+ 'grid-column': GridColumns;
141
+ 'grid-template': GridTemplates;
142
+ grid: Grids;
143
+ margin: Margins;
144
+ padding: Paddings;
145
+ overflow: Overflows;
146
+ 'text-decoration': TextDecorations;
147
+ 'list-style': ListStyles;
148
+ };
149
+
150
+ export type ShorthandsSpecialReturnTypeMap<V> = {
151
+ background: OpenedBackgroundShorthand<V>;
152
+ 'background-position': OpenedBackgroundPositionShorthand<V>;
153
+ 'border-radius': OpenedBorderRadiusShorthand<V>;
154
+ font: OpenedFontShorthand<V>;
155
+ 'border-image': OpenedBorderImageShorthand<V>;
156
+ };
157
+
158
+ export type CssEdge = 'top' | 'right' | 'bottom' | 'left';
159
+ export type CssCorner = 'top-left' | 'top-right' | 'bottom-right' | 'bottom-left';
160
+ export const CSS_PROPERTY_DELIMITER = '-';
161
+ export const EDGE_SHORTHAND_EDGES = ['top', 'right', 'bottom', 'left'] as const satisfies CssEdge[];
162
+ export const CORNER_SHORTHAND_CORNERS = [
163
+ 'top-left',
164
+ 'top-right',
165
+ 'bottom-right',
166
+ 'bottom-left',
167
+ ] as const satisfies CssCorner[];
168
+ export const EDGE_SHORTHAND_INDICES_BY_LENGTH = [
169
+ [0, 0, 0, 0],
170
+ [0, 1, 0, 1],
171
+ [0, 1, 2, 1],
172
+ [0, 1, 2, 3],
173
+ ] as const satisfies number[][];
174
+
175
+ export type FlexKeyword = 'initial' | 'auto' | 'none';
176
+ export const FLEX_KEYWORD_VALUE_MAP: Record<FlexKeyword, Record<Flexes, string>> = {
177
+ initial: {
178
+ 'flex-grow': INITIAL_FLEX_GROW,
179
+ 'flex-shrink': INITIAL_FLEX_SHRINK,
180
+ 'flex-basis': AUTO_FLEX_BASIS,
181
+ },
182
+ auto: {
183
+ 'flex-grow': AUTO_FLEX_GROW,
184
+ 'flex-shrink': INITIAL_FLEX_SHRINK,
185
+ 'flex-basis': AUTO_FLEX_BASIS,
186
+ },
187
+ none: {
188
+ 'flex-grow': INITIAL_FLEX_GROW,
189
+ 'flex-shrink': NONE_FLEX_SHRINK,
190
+ 'flex-basis': AUTO_FLEX_BASIS,
191
+ },
192
+ };
193
+
194
+ export type GridKeyword = 'none';
195
+ export const GRID_TEMPLATE_KEYWORD_VALUE_MAP: Record<GridKeyword, Record<GridTemplates, string>> = {
196
+ none: {
197
+ 'grid-template-areas': INITIAL_GRID_TEMPLATE_AREAS,
198
+ 'grid-template-rows': INITIAL_GRID_TEMPLATE_AXIS,
199
+ 'grid-template-columns': INITIAL_GRID_TEMPLATE_AXIS,
200
+ },
201
+ };
202
+
203
+ export const GRID_KEYWORD_VALUE_MAP: Record<GridKeyword, Record<Grids, string>> = {
204
+ none: {
205
+ ...GRID_TEMPLATE_KEYWORD_VALUE_MAP.none,
206
+ 'grid-auto-flow': INITIAL_GRID_AUTO_FLOW,
207
+ 'grid-auto-rows': INITIAL_GRID_AUTO_AXIS,
208
+ 'grid-auto-columns': INITIAL_GRID_AUTO_AXIS,
209
+ },
210
+ };