@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 @@
1
+ {"version":3,"file":"flex-flow-shorthand.d.ts","sourceRoot":"","sources":["../../../src/shorthands/openers/flex-flow-shorthand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAyB,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAWjH,eAAO,MAAM,qBAAqB,EAAE,wBAAwB,CAAC,SAAS,CAQzB,CAAC;AAE9C,eAAO,MAAM,sBAAsB,EAAE,kBAAkB,CAAC,SAAS,CAC8C,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { flexDirectionDataType, flexWrapDataType } from '../../css-data-types/index.js';
2
+ import { unorderedListShorthandOpener, createShorthandOpener, shorthandCloserTemplate, createShorthandCloser, } from '../shorthand-parser-utils.js';
3
+ // flex-flow
4
+ export const openFlexFlowShorthand = () => createShorthandOpener({
5
+ prop: 'flex-flow',
6
+ parts: [
7
+ { prop: 'flex-direction', dataType: flexDirectionDataType },
8
+ { prop: 'flex-wrap', dataType: flexWrapDataType },
9
+ ],
10
+ shorthandOpener: (astNodes, api, parts) => unorderedListShorthandOpener(parts)(astNodes, api),
11
+ });
12
+ export const closeFlexFlowShorthand = () => createShorthandCloser(shorthandCloserTemplate `${'flex-direction'} ${'flex-wrap'}`);
13
+ //# sourceMappingURL=flex-flow-shorthand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flex-flow-shorthand.js","sourceRoot":"","sources":["../../../src/shorthands/openers/flex-flow-shorthand.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACxF,OAAO,EACH,4BAA4B,EAC5B,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,GACxB,MAAM,8BAA8B,CAAC;AAEtC,YAAY;AACZ,MAAM,CAAC,MAAM,qBAAqB,GAAwC,GAAM,EAAE,CAC9E,qBAAqB,CAAC;IAClB,IAAI,EAAE,WAAW;IACjB,KAAK,EAAE;QACH,EAAE,IAAI,EAAE,gBAAgB,EAAE,QAAQ,EAAE,qBAAqB,EAAE;QAC3D,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,gBAAgB,EAAE;KACpD;IACD,eAAe,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,4BAA4B,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,GAAG,CAAC;CAChG,CAAwC,CAAC;AAE9C,MAAM,CAAC,MAAM,sBAAsB,GAAkC,GAAM,EAAE,CACzE,qBAAqB,CAAe,uBAAuB,CAAW,GAAG,gBAAgB,IAAI,WAAW,EAAE,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { GetSimpleShorthandOpener, GetShorthandCloser } from '../shorthand-types.js';
2
+ import { type Flexes } from '../shorthand-css-data.js';
3
+ export declare const openFlexShorthand: GetSimpleShorthandOpener<Flexes>;
4
+ export declare const closeFlexShorthand: GetShorthandCloser<Flexes>;
5
+ //# sourceMappingURL=flex-shorthand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flex-shorthand.d.ts","sourceRoot":"","sources":["../../../src/shorthands/openers/flex-shorthand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAKR,wBAAwB,EACxB,kBAAkB,EACrB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,KAAK,MAAM,EAA0B,MAAM,0BAA0B,CAAC;AAwB/E,eAAO,MAAM,iBAAiB,EAAE,wBAAwB,CAAC,MAAM,CA0CrB,CAAC;AAE3C,eAAO,MAAM,kBAAkB,EAAE,kBAAkB,CAAC,MAAM,CAC2C,CAAC"}
@@ -0,0 +1,55 @@
1
+ import { FLEX_KEYWORD_VALUE_MAP } from '../shorthand-css-data.js';
2
+ import { flexSingleValueDataType, flexGrowDataType, flexShrinkDataType, flexBasisDataType, } from '../../css-data-types/index.js';
3
+ import { matchDataType, singleKeywordShorthandOpener, createShorthandOpener, createShorthandCloserTemplateFromParts, createShorthandCloser, } from '../shorthand-parser-utils.js';
4
+ import { NoMandatoryPartMatchError } from '../shorthand-parser-errors.js';
5
+ const getFlexShorthandParts = () => [
6
+ { prop: 'flex-grow', dataType: flexGrowDataType, mandatory: true },
7
+ { prop: 'flex-shrink', dataType: flexShrinkDataType },
8
+ { prop: 'flex-basis', dataType: flexBasisDataType },
9
+ ];
10
+ // flex
11
+ export const openFlexShorthand = () => createShorthandOpener({
12
+ prop: 'flex',
13
+ singleKeywordPart: {
14
+ prop: 'flex',
15
+ dataType: flexSingleValueDataType,
16
+ partOpener: singleKeywordShorthandOpener(FLEX_KEYWORD_VALUE_MAP),
17
+ },
18
+ parts: getFlexShorthandParts(),
19
+ shorthandOpener: (astNodes) => {
20
+ const opened = {};
21
+ if (matchDataType(flexGrowDataType, astNodes, 0)) {
22
+ opened['flex-grow'] = astNodes[0];
23
+ if (astNodes.length > 1) {
24
+ if (matchDataType(flexShrinkDataType, astNodes, 1)) {
25
+ opened['flex-shrink'] = astNodes[1];
26
+ if (astNodes.length > 2) {
27
+ if (matchDataType(flexBasisDataType, astNodes, 2)) {
28
+ opened['flex-basis'] = astNodes[2];
29
+ }
30
+ else {
31
+ throw new NoMandatoryPartMatchError('flex', 'flex-basis');
32
+ }
33
+ }
34
+ }
35
+ else if (matchDataType(flexBasisDataType, astNodes, 1)) {
36
+ if (astNodes.length < 3) {
37
+ opened['flex-basis'] = astNodes[1];
38
+ }
39
+ else {
40
+ throw new NoMandatoryPartMatchError('flex', 'flex-shrink');
41
+ }
42
+ }
43
+ else {
44
+ throw new NoMandatoryPartMatchError('flex', `${'flex-shrink'}, ${'flex-basis'}`);
45
+ }
46
+ }
47
+ }
48
+ else {
49
+ throw new NoMandatoryPartMatchError('flex', 'flex-grow');
50
+ }
51
+ return opened;
52
+ },
53
+ });
54
+ export const closeFlexShorthand = () => createShorthandCloser(createShorthandCloserTemplateFromParts(getFlexShorthandParts()));
55
+ //# sourceMappingURL=flex-shorthand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flex-shorthand.js","sourceRoot":"","sources":["../../../src/shorthands/openers/flex-shorthand.ts"],"names":[],"mappings":"AASA,OAAO,EAAe,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAC/E,OAAO,EACH,uBAAuB,EACvB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,GACpB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACH,aAAa,EACb,4BAA4B,EAC5B,qBAAqB,EACrB,sCAAsC,EACtC,qBAAqB,GACxB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAE1E,MAAM,qBAAqB,GAAG,GAAM,EAAE,CAClC;IACI,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,gBAAgB,EAAE,SAAS,EAAE,IAAI,EAAE;IAClE,EAAE,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,kBAAkB,EAAE;IACrD,EAAE,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,iBAAiB,EAAE;CACxB,CAAC;AAEpC,OAAO;AACP,MAAM,CAAC,MAAM,iBAAiB,GAAqC,GAAM,EAAE,CACvE,qBAAqB,CAAC;IAClB,IAAI,EAAE,MAAM;IACZ,iBAAiB,EAAE;QACf,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,uBAAuB;QACjC,UAAU,EAAE,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EAAE,CAAC,CAAC;gBACrF,CAAC;YACL,CAAC;QACL,CAAC;aAAM,CAAC;YACJ,MAAM,IAAI,yBAAyB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;QAC7D,CAAC;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ,CAAqC,CAAC;AAE3C,MAAM,CAAC,MAAM,kBAAkB,GAA+B,GAAM,EAAE,CAClE,qBAAqB,CAAY,sCAAsC,CAAC,qBAAqB,EAAE,CAAC,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { Fonts, OpenedFontShorthand } from '../shorthand-css-data.js';
2
+ import type { ShorthandOpener } from '../shorthand-types.js';
3
+ export declare const openFontShorthand: <V>() => ShorthandOpener<V, Fonts, OpenedFontShorthand<V>>;
4
+ export declare const closeFontShorthand: <V>() => import("../shorthand-types.js").ShorthandCloser<V, Fonts, OpenedFontShorthand<V>>;
5
+ //# sourceMappingURL=font-shorthand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"font-shorthand.d.ts","sourceRoot":"","sources":["../../../src/shorthands/openers/font-shorthand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA8B,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACvG,OAAO,KAAK,EAAmB,eAAe,EAAiB,MAAM,uBAAuB,CAAC;AAwB7F,eAAO,MAAM,iBAAiB,GAAI,CAAC,OAAK,eAAe,CAAC,CAAC,EAAE,KAAK,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAsDvF,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,CAAC,wFAG/B,CAAC"}
@@ -0,0 +1,60 @@
1
+ import { fontSingleValueDataType, fontStyleDataType, fontVariantDataType, fontWeightDataType, fontStretchDataType, fontSizeDataType, lineHeightDataType, fontFamilyDataType, COMMON_FONT_PREFIX_NORMAL, } from '../../css-data-types/index.js';
2
+ import { matchDataType, unorderedListShorthandOpener, createShorthandOpener, shorthandCloserTemplate, createShorthandCloser, } from '../shorthand-parser-utils.js';
3
+ import { NoMandatoryPartMatchError } from '../shorthand-parser-errors.js';
4
+ // TODO: Though not directly settable by font, the longhands font-size-adjust and font-kerning are also reset to their initial values.
5
+ // font
6
+ export const openFontShorthand = () => {
7
+ const fontPrefixShorthandParts = [
8
+ { prop: 'font-style', dataType: fontStyleDataType, multipleItems: true },
9
+ { prop: 'font-variant', dataType: fontVariantDataType },
10
+ { prop: 'font-weight', dataType: fontWeightDataType },
11
+ { prop: 'font-stretch', dataType: fontStretchDataType },
12
+ ];
13
+ const fontSizeShorthandPart = {
14
+ prop: 'font-size',
15
+ dataType: fontSizeDataType,
16
+ mandatory: true,
17
+ };
18
+ const fontSuffixShorthandParts = [
19
+ fontSizeShorthandPart,
20
+ { prop: 'line-height', dataType: lineHeightDataType },
21
+ {
22
+ prop: 'font-family',
23
+ dataType: fontFamilyDataType,
24
+ multipleItems: true,
25
+ mandatory: true,
26
+ },
27
+ ];
28
+ const openFontShorthandPrefixInner = unorderedListShorthandOpener(fontPrefixShorthandParts, {
29
+ commonValue: COMMON_FONT_PREFIX_NORMAL,
30
+ });
31
+ const openFontShorthandSuffixInner = unorderedListShorthandOpener(fontSuffixShorthandParts);
32
+ return createShorthandOpener({
33
+ prop: 'font',
34
+ singleKeywordPart: { prop: 'font', dataType: fontSingleValueDataType },
35
+ parts: fontPrefixShorthandParts.concat(fontSuffixShorthandParts),
36
+ shorthandOpener: (astNodes, api) => {
37
+ let opened = {};
38
+ const prefixEndPart = fontSizeShorthandPart;
39
+ let prefixEndIndex = -1;
40
+ for (let i = 0; i < astNodes.length; i++) {
41
+ if (matchDataType(prefixEndPart.dataType, astNodes, i)) {
42
+ prefixEndIndex = i;
43
+ break;
44
+ }
45
+ }
46
+ if (prefixEndIndex !== -1) {
47
+ opened = {
48
+ ...openFontShorthandPrefixInner(astNodes.slice(0, prefixEndIndex), api),
49
+ ...openFontShorthandSuffixInner(astNodes.slice(prefixEndIndex), api),
50
+ };
51
+ }
52
+ else {
53
+ throw new NoMandatoryPartMatchError('font', prefixEndPart.prop);
54
+ }
55
+ return opened;
56
+ },
57
+ });
58
+ };
59
+ export const closeFontShorthand = () => createShorthandCloser(shorthandCloserTemplate `${'font-style'} ${'font-variant'} ${'font-weight'} ${'font-stretch'} ${'font-size'} / ${'line-height'} ${'font-family'}`);
60
+ //# sourceMappingURL=font-shorthand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"font-shorthand.js","sourceRoot":"","sources":["../../../src/shorthands/openers/font-shorthand.ts"],"names":[],"mappings":"AAGA,OAAO,EACH,uBAAuB,EACvB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,yBAAyB,GAC5B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACH,aAAa,EACb,4BAA4B,EAC5B,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,GACxB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAE1E,sIAAsI;AACtI,OAAO;AACP,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAyD,EAAE;IACxF,MAAM,wBAAwB,GAAuB;QACjD,EAAE,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,iBAAiB,EAAE,aAAa,EAAE,IAAI,EAAE;QACxE,EAAE,IAAI,EAAE,cAAc,EAAE,QAAQ,EAAE,mBAAmB,EAAE;QACvD,EAAE,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,kBAAkB,EAAE;QACrD,EAAE,IAAI,EAAE,cAAc,EAAE,QAAQ,EAAE,mBAAmB,EAAE;KAC1D,CAAC;IACF,MAAM,qBAAqB,GAAqB;QAC5C,IAAI,EAAE,WAAW;QACjB,QAAQ,EAAE,gBAAgB;QAC1B,SAAS,EAAE,IAAI;KAClB,CAAC;IACF,MAAM,wBAAwB,GAAuB;QACjD,qBAAqB;QACr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,CAAC;iBAAM,CAAC;gBACJ,MAAM,IAAI,yBAAyB,CAAC,MAAM,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;YACpE,CAAC;YAED,OAAO,MAAM,CAAC;QAClB,CAAC;KACJ,CAAsD,CAAC;AAC5D,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAM,EAAE,CACtC,qBAAqB,CACjB,uBAAuB,CAAO,GAAG,YAAY,IAAI,cAAc,IAAI,aAAa,IAAI,cAAc,IAAI,WAAW,MAAM,aAAa,IAAI,aAAa,EAAE,CAC1J,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { Gaps } from '../shorthand-css-data.js';
2
+ import type { GetSimpleShorthandOpener, GetShorthandCloser } from '../shorthand-types.js';
3
+ export declare const openGapShorthand: GetSimpleShorthandOpener<Gaps>;
4
+ export declare const closeGapShorthand: GetShorthandCloser<Gaps>;
5
+ //# sourceMappingURL=gap-shorthand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gap-shorthand.d.ts","sourceRoot":"","sources":["../../../src/shorthands/openers/gap-shorthand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,KAAK,EAGR,wBAAwB,EACxB,kBAAkB,EAGrB,MAAM,uBAAuB,CAAC;AA8B/B,eAAO,MAAM,gBAAgB,EAAE,wBAAwB,CAAC,IAAI,CAKpB,CAAC;AAEzC,eAAO,MAAM,iBAAiB,EAAE,kBAAkB,CAAC,IAAI,CAC2C,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { lengthPercentageDataType } from '../../css-data-types/index.js';
2
+ import { createShorthandOpener, createShorthandCloserTemplateFromParts, createShorthandCloser, } from '../shorthand-parser-utils.js';
3
+ const getGapShorthandParts = () => [
4
+ {
5
+ prop: 'row-gap',
6
+ dataType: lengthPercentageDataType,
7
+ },
8
+ {
9
+ prop: 'column-gap',
10
+ dataType: lengthPercentageDataType,
11
+ },
12
+ ];
13
+ function gapOpener(nodes) {
14
+ if (nodes.length === 0 || nodes.length > 2)
15
+ throw new Error('gap shorthand can only have 1 or 2 values');
16
+ return {
17
+ 'row-gap': nodes[0],
18
+ 'column-gap': nodes[1] ?? nodes[0],
19
+ };
20
+ }
21
+ // gap
22
+ export const openGapShorthand = () => createShorthandOpener({
23
+ prop: 'gap',
24
+ parts: getGapShorthandParts(),
25
+ shorthandOpener: gapOpener,
26
+ });
27
+ export const closeGapShorthand = () => createShorthandCloser(createShorthandCloserTemplateFromParts(getGapShorthandParts()));
28
+ //# sourceMappingURL=gap-shorthand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gap-shorthand.js","sourceRoot":"","sources":["../../../src/shorthands/openers/gap-shorthand.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EACH,qBAAqB,EACrB,sCAAsC,EACtC,qBAAqB,GACxB,MAAM,8BAA8B,CAAC;AAEtC,MAAM,oBAAoB,GAAG,GAAM,EAAE,CACjC;IACI;QACI,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE,wBAAwB;KACrC;IACD;QACI,IAAI,EAAE,YAAY;QAClB,QAAQ,EAAE,wBAAwB;KACrC;CACwB,CAAC;AAElC,SAAS,SAAS,CAAI,KAAwB;IAC1C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IACzG,OAAO;QACH,SAAS,EAAE,KAAK,CAAC,CAAC,CAAE;QACpB,YAAY,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAE;KACtC,CAAC;AACN,CAAC;AAED,MAAM;AACN,MAAM,CAAC,MAAM,gBAAgB,GAAmC,GAAM,EAAE,CACpE,qBAAqB,CAAC;IAClB,IAAI,EAAE,KAAK;IACX,KAAK,EAAE,oBAAoB,EAAE;IAC7B,eAAe,EAAE,SAAS;CAC7B,CAAmC,CAAC;AAEzC,MAAM,CAAC,MAAM,iBAAiB,GAA6B,GAAM,EAAE,CAC/D,qBAAqB,CAAU,sCAAsC,CAAC,oBAAoB,EAAE,CAAC,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { GetSimpleShorthandOpener, GetShorthandCloser } from '../shorthand-types.js';
2
+ export declare const openGridRowShorthand: GetSimpleShorthandOpener<import("../shorthand-css-data.js").GridRows>;
3
+ export declare const closeGridRowShorthand: GetShorthandCloser<import("../shorthand-css-data.js").GridRows>;
4
+ export declare const openGridColumnShorthand: GetSimpleShorthandOpener<import("../shorthand-css-data.js").GridColumns>;
5
+ export declare const closeGridColumnShorthand: GetShorthandCloser<import("../shorthand-css-data.js").GridColumns>;
6
+ //# sourceMappingURL=grid-axis-shorthand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grid-axis-shorthand.d.ts","sourceRoot":"","sources":["../../../src/shorthands/openers/grid-axis-shorthand.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAGR,wBAAwB,EACxB,kBAAkB,EAGrB,MAAM,uBAAuB,CAAC;AA8C/B,eAAO,MAAM,oBAAoB,uEAAuC,CAAC;AACzE,eAAO,MAAM,qBAAqB,iEAAuC,CAAC;AAG1E,eAAO,MAAM,uBAAuB,0EAA0C,CAAC;AAC/E,eAAO,MAAM,wBAAwB,oEAA0C,CAAC"}
@@ -0,0 +1,36 @@
1
+ import { gridLineDataType, gridLineEndDataType } from '../../css-data-types/index.js';
2
+ import { createShorthandOpener, createShorthandCloser, shorthandCloserTemplate } from '../shorthand-parser-utils.js';
3
+ const getGridAxisShorthandParts = (axis) => [
4
+ {
5
+ prop: `grid-${axis}-start`,
6
+ dataType: gridLineDataType,
7
+ multipleItems: true,
8
+ },
9
+ {
10
+ prop: `grid-${axis}-end`,
11
+ dataType: gridLineEndDataType,
12
+ multipleItems: true,
13
+ },
14
+ ];
15
+ function openGridAxisShorthand(axis, valueAst) {
16
+ const delimiterIndex = valueAst.findIndex((node) => node.value.type === '/');
17
+ const startNodes = delimiterIndex === -1 ? valueAst : valueAst.slice(0, delimiterIndex);
18
+ const endNodes = delimiterIndex === -1 ? [...startNodes] : valueAst.slice(delimiterIndex + 1);
19
+ return {
20
+ [`grid-${axis}-start`]: startNodes,
21
+ [`grid-${axis}-end`]: endNodes,
22
+ };
23
+ }
24
+ const createGridAxisShorthandOpener = (axis) => () => createShorthandOpener({
25
+ prop: `grid-${axis}`,
26
+ parts: getGridAxisShorthandParts(axis),
27
+ shorthandOpener: (astNodes) => openGridAxisShorthand(axis, astNodes),
28
+ });
29
+ const createGridAxisShorthandCloser = (axis) => () => createShorthandCloser(shorthandCloserTemplate `${`grid-${axis}-start`} / ${`grid-${axis}-end`}`);
30
+ // grid-row
31
+ export const openGridRowShorthand = createGridAxisShorthandOpener('row');
32
+ export const closeGridRowShorthand = createGridAxisShorthandCloser('row');
33
+ // grid-column
34
+ export const openGridColumnShorthand = createGridAxisShorthandOpener('column');
35
+ export const closeGridColumnShorthand = createGridAxisShorthandCloser('column');
36
+ //# sourceMappingURL=grid-axis-shorthand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grid-axis-shorthand.js","sourceRoot":"","sources":["../../../src/shorthands/openers/grid-axis-shorthand.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAStF,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAErH,MAAM,yBAAyB,GAAG,CAAwB,IAAO,EAAE,EAAE,CACjE;IACI;QACI,IAAI,EAAE,QAAQ,IAAI,QAAQ;QAC1B,QAAQ,EAAE,gBAAgB;QAC1B,aAAa,EAAE,IAAI;KACtB;IACD;QACI,IAAI,EAAE,QAAQ,IAAI,MAAM;QACxB,QAAQ,EAAE,mBAAmB;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qBAAqB,GAAG,6BAA6B,CAAC,KAAK,CAAC,CAAC;AAE1E,cAAc;AACd,MAAM,CAAC,MAAM,uBAAuB,GAAG,6BAA6B,CAAC,QAAQ,CAAC,CAAC;AAC/E,MAAM,CAAC,MAAM,wBAAwB,GAAG,6BAA6B,CAAC,QAAQ,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { GridGaps } from '../shorthand-css-data.js';
2
+ import type { GetSimpleShorthandOpener, GetShorthandCloser } from '../shorthand-types.js';
3
+ export declare const openGridGapShorthand: GetSimpleShorthandOpener<GridGaps>;
4
+ export declare const closeGridGapShorthand: GetShorthandCloser<GridGaps>;
5
+ //# sourceMappingURL=grid-gap-shorthand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grid-gap-shorthand.d.ts","sourceRoot":"","sources":["../../../src/shorthands/openers/grid-gap-shorthand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,KAAK,EAGR,wBAAwB,EACxB,kBAAkB,EACrB,MAAM,uBAAuB,CAAC;AAyB/B,eAAO,MAAM,oBAAoB,EAAE,wBAAwB,CAAC,QAAQ,CAKxB,CAAC;AAE7C,eAAO,MAAM,qBAAqB,EAAE,kBAAkB,CAAC,QAAQ,CAC2C,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { lengthPercentageDataType } from '../../css-data-types/index.js';
2
+ import { splitSimpleShorthandOpener, unorderedListShorthandOpener, createShorthandOpener, createShorthandCloserTemplateFromParts, createShorthandCloser, } from '../shorthand-parser-utils.js';
3
+ const getGridGapShorthandParts = () => [
4
+ {
5
+ prop: 'grid-row-gap',
6
+ dataType: lengthPercentageDataType,
7
+ partOpener: splitSimpleShorthandOpener(['grid-row-gap', 'grid-column-gap']),
8
+ },
9
+ {
10
+ prop: 'grid-column-gap',
11
+ dataType: lengthPercentageDataType,
12
+ },
13
+ ];
14
+ // grid-gap
15
+ export const openGridGapShorthand = () => createShorthandOpener({
16
+ prop: 'grid-gap',
17
+ parts: getGridGapShorthandParts(),
18
+ shorthandOpener: (astNodes, api, parts) => unorderedListShorthandOpener(parts)(astNodes, api),
19
+ });
20
+ export const closeGridGapShorthand = () => createShorthandCloser(createShorthandCloserTemplateFromParts(getGridGapShorthandParts()));
21
+ //# sourceMappingURL=grid-gap-shorthand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grid-gap-shorthand.js","sourceRoot":"","sources":["../../../src/shorthands/openers/grid-gap-shorthand.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EACH,0BAA0B,EAC1B,4BAA4B,EAC5B,qBAAqB,EACrB,sCAAsC,EACtC,qBAAqB,GACxB,MAAM,8BAA8B,CAAC;AAEtC,MAAM,wBAAwB,GAAG,GAAM,EAAE,CACrC;IACI;QACI,IAAI,EAAE,cAAc;QACpB,QAAQ,EAAE,wBAAwB;QAClC,UAAU,EAAE,0BAA0B,CAAC,CAAC,cAAc,EAAE,iBAAiB,CAAC,CAAC;KAC9E;IACD;QACI,IAAI,EAAE,iBAAiB;QACvB,QAAQ,EAAE,wBAAwB;KACrC;CAC4B,CAAC;AAEtC,WAAW;AACX,MAAM,CAAC,MAAM,oBAAoB,GAAuC,GAAM,EAAE,CAC5E,qBAAqB,CAAC;IAClB,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE,wBAAwB,EAAE;IACjC,eAAe,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,4BAA4B,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,GAAG,CAAC;CAChG,CAAuC,CAAC;AAE7C,MAAM,CAAC,MAAM,qBAAqB,GAAiC,GAAM,EAAE,CACvE,qBAAqB,CAAc,sCAAsC,CAAC,wBAAwB,EAAE,CAAC,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { OpenedShorthand, GetSimpleShorthandOpener, ShorthandCloser } from '../shorthand-types.js';
2
+ import { type Grids } from '../shorthand-css-data.js';
3
+ type OpenedGrids<V> = OpenedShorthand<V, Grids>;
4
+ type GridShorthandCloser<V> = ShorthandCloser<V, Grids, OpenedGrids<V>>;
5
+ export declare const openGridShorthand: GetSimpleShorthandOpener<Grids>;
6
+ export declare const closeGridShorthand: <V>() => GridShorthandCloser<V>;
7
+ export {};
8
+ //# sourceMappingURL=grid-shorthand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grid-shorthand.d.ts","sourceRoot":"","sources":["../../../src/shorthands/openers/grid-shorthand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGR,eAAe,EAIf,wBAAwB,EACxB,eAAe,EAClB,MAAM,uBAAuB,CAAC;AAI/B,OAAO,EAAiB,KAAK,KAAK,EAA0B,MAAM,0BAA0B,CAAC;AAyC7F,KAAK,WAAW,CAAC,CAAC,IAAI,eAAe,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;AAEhD,KAAK,mBAAmB,CAAC,CAAC,IAAI,eAAe,CAAC,CAAC,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;AAwFxE,eAAO,MAAM,iBAAiB,EAAE,wBAAwB,CAAC,KAAK,CAuBrB,CAAC;AA4D1C,eAAO,MAAM,kBAAkB,GAC1B,CAAC,OAAK,mBAAmB,CAAC,CAAC,CA+B3B,CAAC"}
@@ -0,0 +1,145 @@
1
+ import { createCssValueAST, valueTextNode } from '../../tokenizers/index.js';
2
+ import { codeToEvaluatedAst } from '../shorthands-ast-evaluation.js';
3
+ import { GRID_KEYWORD_VALUE_MAP } from '../shorthand-css-data.js';
4
+ import { DataTypeType, asteriskPredicate, findPredicateIndexMatch, seperatorPredicate, trackSizePredicate, gridAutoFlowPredicate, gridTemplateAreasDataType, gridTemplateRowsDataType, gridTemplateColumnsDataType, gridAutoFlowDataType, gridAutoRowsDataType, gridAutoColumnsDataType, gridSingleValueDataType, GRID_AUTO_FLOW_KEYWORD, GRID_AUTO_FLOW_ROW_KEYWORD, GRID_AUTO_FLOW_COLUMN_KEYWORD, GRID_AUTO_FLOW_DENSE_KEYWORD, } from '../../css-data-types/index.js';
5
+ import { matchDataType, isOpenedInitial, singleKeywordShorthandOpener, createShorthandOpener, getOpenedNode, fixAstNodesPositions, } from '../shorthand-parser-utils.js';
6
+ import { getGridTemplateShorthandParts, gridTemplateShorthandOpener, closeGridTemplateShorthand, } from './grid-template-shorthand.js';
7
+ import { NoMandatoryPartMatchError, CannotCloseGridError } from '../shorthand-parser-errors.js';
8
+ const getGridShorthandParts = () => [
9
+ ...getGridTemplateShorthandParts(),
10
+ { prop: 'grid-auto-flow', dataType: gridAutoFlowDataType, multipleItems: true },
11
+ { prop: 'grid-auto-rows', dataType: gridAutoRowsDataType, multipleItems: true },
12
+ { prop: 'grid-auto-columns', dataType: gridAutoColumnsDataType, multipleItems: true },
13
+ ];
14
+ const isSeperator = (astNodes, index) => seperatorPredicate()(astNodes[index].value);
15
+ const getTrackSizeLength = (astNodes, index) => astNodes.length > index
16
+ ? Number(asteriskPredicate(trackSizePredicate)(astNodes[index].value, index, astNodes))
17
+ : 0;
18
+ const getAutoFlowText = (axis, dense = false) => (axis === 'row' ? GRID_AUTO_FLOW_ROW_KEYWORD : GRID_AUTO_FLOW_COLUMN_KEYWORD) +
19
+ (dense ? ` ${GRID_AUTO_FLOW_DENSE_KEYWORD}` : '');
20
+ const openGridShorthandAutoFlow = (axis, astNodes, autoFlowMatch, trackSizeLength, rowsLength) => {
21
+ const { index: autoFlowIndex, length: autoFlowLength } = autoFlowMatch;
22
+ const opened = {};
23
+ if (axis === 'row') {
24
+ opened['grid-template-columns'] = astNodes.slice(autoFlowLength + trackSizeLength + 1);
25
+ if (trackSizeLength > 0) {
26
+ opened['grid-auto-rows'] = astNodes.slice(autoFlowLength, autoFlowLength + trackSizeLength);
27
+ }
28
+ }
29
+ else {
30
+ opened['grid-template-rows'] = astNodes.slice(0, rowsLength);
31
+ if (trackSizeLength > 0) {
32
+ opened['grid-auto-columns'] = astNodes.slice(autoFlowIndex + autoFlowLength);
33
+ }
34
+ }
35
+ opened['grid-auto-flow'] = codeToEvaluatedAst(createCssValueAST(getAutoFlowText(axis, autoFlowLength === 2)));
36
+ return opened;
37
+ };
38
+ const openGridShorthandTemplateRowsSyntax = (astNodes, autoFlowMatch) => {
39
+ const { index: autoFlowIndex, length: autoFlowLength } = autoFlowMatch;
40
+ if (autoFlowIndex <= 1 || !isSeperator(astNodes, autoFlowIndex - 1)) {
41
+ throw new NoMandatoryPartMatchError('grid', 'grid-auto-flow');
42
+ }
43
+ const rowsMatch = matchDataType(gridTemplateRowsDataType, astNodes, 0);
44
+ if (!rowsMatch || Number(rowsMatch) !== autoFlowIndex - 1) {
45
+ throw new NoMandatoryPartMatchError('grid', 'grid-template-rows');
46
+ }
47
+ const trackSizeLength = getTrackSizeLength(astNodes, autoFlowIndex + autoFlowLength);
48
+ if (trackSizeLength !== astNodes.length - autoFlowIndex - autoFlowLength) {
49
+ throw new NoMandatoryPartMatchError('grid', 'grid-auto-flow');
50
+ }
51
+ return openGridShorthandAutoFlow('column', astNodes, autoFlowMatch, trackSizeLength, Number(rowsMatch));
52
+ };
53
+ const openGridShorthandTemplateColumnsSyntax = (astNodes, autoFlowMatch) => {
54
+ const { length: autoFlowLength } = autoFlowMatch;
55
+ const trackSizeLength = getTrackSizeLength(astNodes, autoFlowLength);
56
+ if (!isSeperator(astNodes, autoFlowLength + trackSizeLength)) {
57
+ throw new NoMandatoryPartMatchError('grid', 'grid-auto-flow');
58
+ }
59
+ const columnsMatch = matchDataType(gridTemplateColumnsDataType, astNodes, autoFlowLength + trackSizeLength, DataTypeType.GridTemplateRows);
60
+ if (!columnsMatch || Number(columnsMatch) !== astNodes.length - autoFlowLength - trackSizeLength) {
61
+ throw new NoMandatoryPartMatchError('grid', 'grid-template-columns');
62
+ }
63
+ return openGridShorthandAutoFlow('row', astNodes, autoFlowMatch, trackSizeLength);
64
+ };
65
+ // grid
66
+ export const openGridShorthand = () => createShorthandOpener({
67
+ prop: 'grid',
68
+ singleKeywordPart: {
69
+ prop: 'grid',
70
+ dataType: gridSingleValueDataType,
71
+ partOpener: singleKeywordShorthandOpener(GRID_KEYWORD_VALUE_MAP, true),
72
+ },
73
+ parts: getGridShorthandParts(),
74
+ shorthandOpener: (astNodes) => {
75
+ const autoFlowMatch = findPredicateIndexMatch(astNodes, gridAutoFlowPredicate);
76
+ return (autoFlowMatch
77
+ ? autoFlowMatch.index > 0
78
+ ? openGridShorthandTemplateRowsSyntax(astNodes, autoFlowMatch)
79
+ : openGridShorthandTemplateColumnsSyntax(astNodes, autoFlowMatch)
80
+ : gridTemplateShorthandOpener(astNodes));
81
+ },
82
+ });
83
+ const getParsedOpenedAutoFlow = (opened) => {
84
+ const openedAutoFlow = opened['grid-auto-flow'];
85
+ const openedAutoArray = Array.isArray(openedAutoFlow) ? openedAutoFlow : [openedAutoFlow];
86
+ if (!isOpenedInitial(opened, 'grid-template-areas', gridTemplateAreasDataType) || openedAutoArray.length < 1) {
87
+ throw new CannotCloseGridError();
88
+ }
89
+ const parsedAutoFlow = openedAutoArray.reduce((autoFlow, { value }) => {
90
+ switch (value.text) {
91
+ case GRID_AUTO_FLOW_ROW_KEYWORD:
92
+ if (autoFlow.axis === undefined) {
93
+ autoFlow.axis = 'row';
94
+ return autoFlow;
95
+ }
96
+ break;
97
+ case GRID_AUTO_FLOW_COLUMN_KEYWORD:
98
+ if (autoFlow.axis === undefined) {
99
+ autoFlow.axis = 'column';
100
+ return autoFlow;
101
+ }
102
+ break;
103
+ case GRID_AUTO_FLOW_DENSE_KEYWORD:
104
+ if (autoFlow.dense === undefined) {
105
+ autoFlow.dense = true;
106
+ return autoFlow;
107
+ }
108
+ break;
109
+ }
110
+ throw new CannotCloseGridError();
111
+ }, {});
112
+ if (parsedAutoFlow.axis === undefined && parsedAutoFlow.dense === undefined) {
113
+ throw new CannotCloseGridError();
114
+ }
115
+ return { axis: parsedAutoFlow.axis ?? 'row', dense: !!parsedAutoFlow.dense };
116
+ };
117
+ const closeGridShorthandAutoFlowSyntax = (autoFlow, isAutoRowsInitial, isAutoColumnsInitial) => (opened, api, detachExpression) => {
118
+ const { axis, dense } = autoFlow;
119
+ if ((axis === 'row' &&
120
+ (!isOpenedInitial(opened, 'grid-template-rows', gridTemplateRowsDataType) || !isAutoColumnsInitial)) ||
121
+ (axis === 'column' &&
122
+ (!isOpenedInitial(opened, 'grid-template-columns', gridTemplateColumnsDataType) || !isAutoRowsInitial))) {
123
+ throw new CannotCloseGridError();
124
+ }
125
+ return [valueTextNode(GRID_AUTO_FLOW_KEYWORD)]
126
+ .concat(dense ? [valueTextNode(GRID_AUTO_FLOW_DENSE_KEYWORD)] : [])
127
+ .concat(getOpenedNode(opened[axis === 'row' ? 'grid-auto-rows' : 'grid-auto-columns'], api, detachExpression));
128
+ };
129
+ export const closeGridShorthand = () => (opened, api, detachExpression) => {
130
+ const isAutoRowsInitial = isOpenedInitial(opened, 'grid-auto-rows', gridAutoRowsDataType);
131
+ const isAutoColumnsInitial = isOpenedInitial(opened, 'grid-auto-columns', gridAutoColumnsDataType);
132
+ if (isOpenedInitial(opened, 'grid-auto-flow', gridAutoFlowDataType) &&
133
+ isAutoRowsInitial &&
134
+ isAutoColumnsInitial) {
135
+ return closeGridTemplateShorthand()(opened, api, detachExpression);
136
+ }
137
+ const autoFlow = getParsedOpenedAutoFlow(opened);
138
+ const closedAutoFlowAst = closeGridShorthandAutoFlowSyntax(autoFlow, isAutoRowsInitial, isAutoColumnsInitial)(opened, api, detachExpression);
139
+ const closedTemplateAxisAst = getOpenedNode(opened[autoFlow.axis === 'row' ? 'grid-template-columns' : 'grid-template-rows'], api, detachExpression);
140
+ const slashNode = { ...valueTextNode('/'), type: '/' };
141
+ return fixAstNodesPositions(autoFlow.axis === 'row'
142
+ ? closedAutoFlowAst.concat(slashNode).concat(closedTemplateAxisAst)
143
+ : closedTemplateAxisAst.concat(slashNode).concat(closedAutoFlowAst), api);
144
+ };
145
+ //# sourceMappingURL=grid-shorthand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grid-shorthand.js","sourceRoot":"","sources":["../../../src/shorthands/openers/grid-shorthand.ts"],"names":[],"mappings":"AAWA,OAAO,EAAkB,iBAAiB,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC7F,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAA6B,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAC7F,OAAO,EACH,YAAY,EAEZ,iBAAiB,EACjB,uBAAuB,EACvB,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,EACrB,yBAAyB,EACzB,wBAAwB,EACxB,2BAA2B,EAC3B,oBAAoB,EACpB,oBAAoB,EACpB,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,0BAA0B,EAC1B,6BAA6B,EAC7B,4BAA4B,GAC/B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACH,aAAa,EACb,eAAe,EACf,4BAA4B,EAC5B,qBAAqB,EACrB,aAAa,EACb,oBAAoB,GACvB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACH,6BAA6B,EAC7B,2BAA2B,EAC3B,0BAA0B,GAC7B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAWhG,MAAM,qBAAqB,GAAG,GAAM,EAAE,CAClC;IACI,GAAG,6BAA6B,EAAK;IACrC,EAAE,IAAI,EAAE,gBAAgB,EAAE,QAAQ,EAAE,oBAAoB,EAAE,aAAa,EAAE,IAAI,EAAE;IAC/E,EAAE,IAAI,EAAE,gBAAgB,EAAE,QAAQ,EAAE,oBAAoB,EAAE,aAAa,EAAE,IAAI,EAAE;IAC/E,EAAE,IAAI,EAAE,mBAAmB,EAAE,QAAQ,EAAE,uBAAuB,EAAE,aAAa,EAAE,I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C,CAAC,iBAAiB,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,qBAAqB,CAAC;QACnE,CAAC,CAAC,qBAAqB,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,iBAAiB,CAAC,EACvE,GAAG,CACN,CAAC;AACN,CAAC,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { EvaluatedAst, OpenedShorthand, ShorthandPart, GetSimpleShorthandOpener, ShorthandCloser } from '../shorthand-types.js';
2
+ import { type GridTemplates } from '../shorthand-css-data.js';
3
+ type OpenedGridTemplates<V> = OpenedShorthand<V, GridTemplates>;
4
+ type GridTemplateShorthandCloser<V> = ShorthandCloser<V, GridTemplates, OpenedGridTemplates<V>>;
5
+ export declare const getGridTemplateShorthandParts: <V>() => ShorthandPart<V, GridTemplates>[];
6
+ export declare function gridTemplateShorthandOpener<V>(valueAst: EvaluatedAst<V>[]): OpenedShorthand<V, 'grid-template-rows' | 'grid-template-columns' | 'grid-template-areas'>;
7
+ export declare const openGridTemplateShorthand: GetSimpleShorthandOpener<GridTemplates>;
8
+ export declare const closeGridTemplateShorthand: <V>() => GridTemplateShorthandCloser<V>;
9
+ export {};
10
+ //# sourceMappingURL=grid-template-shorthand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grid-template-shorthand.d.ts","sourceRoot":"","sources":["../../../src/shorthands/openers/grid-template-shorthand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,YAAY,EACZ,eAAe,EAIf,aAAa,EACb,wBAAwB,EACxB,eAAe,EAElB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,KAAK,aAAa,EAAmC,MAAM,0BAA0B,CAAC;AAmB/F,KAAK,mBAAmB,CAAC,CAAC,IAAI,eAAe,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC;AAChE,KAAK,2BAA2B,CAAC,CAAC,IAAI,eAAe,CAAC,CAAC,EAAE,aAAa,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC;AAEhG,eAAO,MAAM,6BAA6B,GAAI,CAAC,OAKtC,aAAa,CAAC,CAAC,EAAE,aAAa,CAAC,EAAE,CAAC;AAc3C,wBAAgB,2BAA2B,CAAC,CAAC,EACzC,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,GAC5B,eAAe,CAAC,CAAC,EAAE,oBAAoB,GAAG,uBAAuB,GAAG,qBAAqB,CAAC,CAoD5F;AAGD,eAAO,MAAM,yBAAyB,EAAE,wBAAwB,CAAC,aAAa,CAa7B,CAAC;AAiClD,eAAO,MAAM,0BAA0B,GAClC,CAAC,OAAK,2BAA2B,CAAC,CAAC,CAiBnC,CAAC"}
@@ -0,0 +1,113 @@
1
+ import { valueTextNode } from '../../tokenizers/index.js';
2
+ import { GRID_TEMPLATE_KEYWORD_VALUE_MAP } from '../shorthand-css-data.js';
3
+ import { trackSizePredicate, gridTemplateAreasDataType, gridTemplateRowsDataType, gridTemplateColumnsDataType, gridTemplateSingleValueDataType, } from '../../css-data-types/index.js';
4
+ import { isOpenedInitial, singleKeywordShorthandOpener, createShorthandOpener, getOpenedNode, shorthandCloserTemplate, createShorthandCloser, fixAstNodesPositions, } from '../shorthand-parser-utils.js';
5
+ import { CannotCloseGridTemplateError } from '../shorthand-parser-errors.js';
6
+ export const getGridTemplateShorthandParts = () => [
7
+ { prop: 'grid-template-areas', dataType: gridTemplateAreasDataType, multipleItems: true },
8
+ { prop: 'grid-template-rows', dataType: gridTemplateRowsDataType, multipleItems: true },
9
+ { prop: 'grid-template-columns', dataType: gridTemplateColumnsDataType, multipleItems: true },
10
+ ];
11
+ function isNamedLineStart({ value }) {
12
+ return value.type === 'text' && value.text.startsWith('[');
13
+ }
14
+ function isNamedLineEnd({ value }) {
15
+ return value.type === 'text' && value.text.endsWith(']');
16
+ }
17
+ function isGridAreasString({ value }) {
18
+ return value.type === 'string';
19
+ }
20
+ export function gridTemplateShorthandOpener(valueAst) {
21
+ const delimiterIndex = valueAst.findIndex((node) => node.value.type === '/');
22
+ const rowAndAreaNodes = delimiterIndex === -1 ? [...valueAst] : valueAst.slice(0, delimiterIndex);
23
+ const columnNodes = delimiterIndex === -1 ? [] : valueAst.slice(delimiterIndex + 1);
24
+ const hasAreas = rowAndAreaNodes.some((node) => node.value.type === 'string');
25
+ if (!hasAreas) {
26
+ if (columnNodes.length === 0)
27
+ throw new Error('Invalid definition. grid-template should have columns defined.');
28
+ return {
29
+ 'grid-template-areas': [{ value: valueTextNode('none') }],
30
+ 'grid-template-rows': rowAndAreaNodes,
31
+ 'grid-template-columns': columnNodes,
32
+ };
33
+ }
34
+ const rowNodes = [];
35
+ const areaNodes = [];
36
+ while (rowAndAreaNodes.length) {
37
+ const node = rowAndAreaNodes.shift();
38
+ if (!node)
39
+ break;
40
+ if (isNamedLineStart(node)) {
41
+ let namedLine = node;
42
+ rowNodes.push(namedLine);
43
+ while (!isNamedLineEnd(namedLine)) {
44
+ namedLine = rowAndAreaNodes.shift();
45
+ if (!namedLine)
46
+ throw new Error('Invalid definition. Named lines should be closed with ].');
47
+ rowNodes.push(namedLine);
48
+ }
49
+ }
50
+ else if (isGridAreasString(node)) {
51
+ areaNodes.push(node);
52
+ const nextNode = rowAndAreaNodes[0];
53
+ if (nextNode && !isNamedLineStart(nextNode) && !isGridAreasString(nextNode)) {
54
+ // right after grid areas string should follow a row track
55
+ rowNodes.push(rowAndAreaNodes.shift());
56
+ }
57
+ else {
58
+ // It is `auto` by default, if not defined explicitly
59
+ rowNodes.push({ value: valueTextNode('auto') });
60
+ }
61
+ }
62
+ else {
63
+ throw new Error('Invalid definition. Grid row track should follow right after grid area.');
64
+ }
65
+ }
66
+ return {
67
+ 'grid-template-rows': rowNodes,
68
+ 'grid-template-areas': areaNodes,
69
+ 'grid-template-columns': columnNodes.length ? columnNodes : [{ value: valueTextNode('none') }],
70
+ };
71
+ }
72
+ // grid-template
73
+ export const openGridTemplateShorthand = () => createShorthandOpener({
74
+ prop: 'grid-template',
75
+ singleKeywordPart: {
76
+ prop: 'grid-template',
77
+ dataType: gridTemplateSingleValueDataType,
78
+ partOpener: singleKeywordShorthandOpener(GRID_TEMPLATE_KEYWORD_VALUE_MAP, true),
79
+ },
80
+ parts: getGridTemplateShorthandParts(),
81
+ shorthandOpener: gridTemplateShorthandOpener,
82
+ });
83
+ const closeGridTemplateShorthandRowsColumnsSyntax = () => createShorthandCloser(shorthandCloserTemplate `${'grid-template-rows'} / ${'grid-template-columns'}`);
84
+ const closeGridTemplateShorthandAreasSyntax = () => (opened, api, detachExpression) => {
85
+ const openedAreas = opened['grid-template-areas'];
86
+ const openedRows = opened['grid-template-rows'];
87
+ const areasList = [...openedAreas];
88
+ const splicedAreasRows = openedRows.reduce((splicedAreasRows, value) => {
89
+ const valueList = [value];
90
+ if (trackSizePredicate(value.value)) {
91
+ const currArea = areasList.shift();
92
+ if (!currArea) {
93
+ throw new CannotCloseGridTemplateError();
94
+ }
95
+ valueList.unshift(currArea);
96
+ }
97
+ return splicedAreasRows.concat(valueList);
98
+ }, []);
99
+ if (areasList.length > 0) {
100
+ throw new CannotCloseGridTemplateError();
101
+ }
102
+ return getOpenedNode(splicedAreasRows, api, detachExpression);
103
+ };
104
+ export const closeGridTemplateShorthand = () => (opened, api, detachExpression) => {
105
+ if (isOpenedInitial(opened, 'grid-template-areas', gridTemplateAreasDataType)) {
106
+ return closeGridTemplateShorthandRowsColumnsSyntax()(opened, api, detachExpression);
107
+ }
108
+ const closedAst = closeGridTemplateShorthandAreasSyntax()(opened, api, detachExpression);
109
+ return fixAstNodesPositions(closedAst
110
+ .concat({ ...valueTextNode('/'), type: '/' })
111
+ .concat(getOpenedNode(opened['grid-template-columns'], api, detachExpression)), api);
112
+ };
113
+ //# sourceMappingURL=grid-template-shorthand.js.map