@linaria/atomic 4.1.5 → 4.2.1

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 (43) hide show
  1. package/dist/index.js +46 -0
  2. package/dist/index.js.map +1 -0
  3. package/dist/index.mjs +17 -0
  4. package/dist/index.mjs.map +1 -0
  5. package/dist/processors/css.js +372 -0
  6. package/dist/processors/css.js.map +1 -0
  7. package/dist/processors/css.mjs +344 -0
  8. package/dist/processors/css.mjs.map +1 -0
  9. package/dist/processors/styled.js +387 -0
  10. package/dist/processors/styled.js.map +1 -0
  11. package/dist/processors/styled.mjs +359 -0
  12. package/dist/processors/styled.mjs.map +1 -0
  13. package/package.json +35 -14
  14. package/processors/css.js +1 -1
  15. package/processors/styled.js +1 -1
  16. package/esm/CSSProperties.js +0 -2
  17. package/esm/CSSProperties.js.map +0 -1
  18. package/esm/css.js +0 -5
  19. package/esm/css.js.map +0 -1
  20. package/esm/index.js +0 -4
  21. package/esm/index.js.map +0 -1
  22. package/esm/processors/css.js +0 -39
  23. package/esm/processors/css.js.map +0 -1
  24. package/esm/processors/helpers/atomize.js +0 -100
  25. package/esm/processors/helpers/atomize.js.map +0 -1
  26. package/esm/processors/helpers/propertyPriority.js +0 -67
  27. package/esm/processors/helpers/propertyPriority.js.map +0 -1
  28. package/esm/processors/styled.js +0 -56
  29. package/esm/processors/styled.js.map +0 -1
  30. package/lib/CSSProperties.js +0 -2
  31. package/lib/CSSProperties.js.map +0 -1
  32. package/lib/css.js +0 -13
  33. package/lib/css.js.map +0 -1
  34. package/lib/index.js +0 -19
  35. package/lib/index.js.map +0 -1
  36. package/lib/processors/css.js +0 -55
  37. package/lib/processors/css.js.map +0 -1
  38. package/lib/processors/helpers/atomize.js +0 -116
  39. package/lib/processors/helpers/atomize.js.map +0 -1
  40. package/lib/processors/helpers/propertyPriority.js +0 -73
  41. package/lib/processors/helpers/propertyPriority.js.map +0 -1
  42. package/lib/processors/styled.js +0 -73
  43. package/lib/processors/styled.js.map +0 -1
package/dist/index.js ADDED
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ css: () => css_default,
24
+ cx: () => import_core.cx,
25
+ styled: () => import_react.styled
26
+ });
27
+ module.exports = __toCommonJS(src_exports);
28
+
29
+ // src/css.ts
30
+ var css = () => {
31
+ throw new Error(
32
+ 'Using the "css" tag in runtime is not supported. Make sure you have set up the Babel plugin correctly.'
33
+ );
34
+ };
35
+ var css_default = css;
36
+
37
+ // src/index.ts
38
+ var import_react = require("@linaria/react");
39
+ var import_core = require("@linaria/core");
40
+ // Annotate the CommonJS export names for ESM import in node:
41
+ 0 && (module.exports = {
42
+ css,
43
+ cx,
44
+ styled
45
+ });
46
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/css.ts"],"sourcesContent":["export { default as css } from './css';\nexport { styled } from '@linaria/react';\nexport { cx } from '@linaria/core';\n\nexport type { CSSProperties } from './CSSProperties';\n","import type { LinariaClassName } from '@linaria/core';\n\nimport type { CSSProperties } from './CSSProperties';\n\ntype CSS = (\n strings: TemplateStringsArray,\n ...exprs: Array<string | number | CSSProperties>\n) => LinariaClassName;\n\nexport const css: CSS = () => {\n throw new Error(\n 'Using the \"css\" tag in runtime is not supported. Make sure you have set up the Babel plugin correctly.'\n );\n};\n\nexport default css;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACSO,IAAM,MAAW,MAAM;AAC5B,QAAM,IAAI;AAAA,IACR;AAAA,EACF;AACF;AAEA,IAAO,cAAQ;;;ADdf,mBAAuB;AACvB,kBAAmB;","names":[]}
package/dist/index.mjs ADDED
@@ -0,0 +1,17 @@
1
+ // src/css.ts
2
+ var css = () => {
3
+ throw new Error(
4
+ 'Using the "css" tag in runtime is not supported. Make sure you have set up the Babel plugin correctly.'
5
+ );
6
+ };
7
+ var css_default = css;
8
+
9
+ // src/index.ts
10
+ import { styled } from "@linaria/react";
11
+ import { cx } from "@linaria/core";
12
+ export {
13
+ css_default as css,
14
+ cx,
15
+ styled
16
+ };
17
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/css.ts","../src/index.ts"],"sourcesContent":["import type { LinariaClassName } from '@linaria/core';\n\nimport type { CSSProperties } from './CSSProperties';\n\ntype CSS = (\n strings: TemplateStringsArray,\n ...exprs: Array<string | number | CSSProperties>\n) => LinariaClassName;\n\nexport const css: CSS = () => {\n throw new Error(\n 'Using the \"css\" tag in runtime is not supported. Make sure you have set up the Babel plugin correctly.'\n );\n};\n\nexport default css;\n","export { default as css } from './css';\nexport { styled } from '@linaria/react';\nexport { cx } from '@linaria/core';\n\nexport type { CSSProperties } from './CSSProperties';\n"],"mappings":";AASO,IAAM,MAAW,MAAM;AAC5B,QAAM,IAAI;AAAA,IACR;AAAA,EACF;AACF;AAEA,IAAO,cAAQ;;;ACdf,SAAS,cAAc;AACvB,SAAS,UAAU;","names":[]}
@@ -0,0 +1,372 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
+ var __accessCheck = (obj, member, msg) => {
26
+ if (!member.has(obj))
27
+ throw TypeError("Cannot " + msg);
28
+ };
29
+ var __privateGet = (obj, member, getter) => {
30
+ __accessCheck(obj, member, "read from private field");
31
+ return getter ? getter.call(obj) : member.get(obj);
32
+ };
33
+ var __privateAdd = (obj, member, value) => {
34
+ if (member.has(obj))
35
+ throw TypeError("Cannot add the same private member more than once");
36
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
37
+ };
38
+ var __privateSet = (obj, member, value, setter) => {
39
+ __accessCheck(obj, member, "write to private field");
40
+ setter ? setter.call(obj, value) : member.set(obj, value);
41
+ return value;
42
+ };
43
+
44
+ // src/processors/css.ts
45
+ var css_exports = {};
46
+ __export(css_exports, {
47
+ default: () => AtomicCssProcessor
48
+ });
49
+ module.exports = __toCommonJS(css_exports);
50
+ var import_css = __toESM(require("@linaria/core/processors/css"));
51
+ var import_logger = require("@linaria/logger");
52
+
53
+ // src/processors/helpers/atomize.ts
54
+ var import_known_css_properties = require("known-css-properties");
55
+ var import_postcss = __toESM(require("postcss"));
56
+ var import_stylis = __toESM(require("stylis"));
57
+ var import_utils = require("@linaria/utils");
58
+
59
+ // src/processors/helpers/propertyPriority.ts
60
+ var shorthandProperties = {
61
+ animation: [
62
+ "animation-name",
63
+ "animation-duration",
64
+ "animation-timing-function",
65
+ "animation-delay",
66
+ "animation-iteration-count",
67
+ "animation-direction",
68
+ "animation-fill-mode",
69
+ "animation-play-state"
70
+ ],
71
+ background: [
72
+ "background-attachment",
73
+ "background-clip",
74
+ "background-color",
75
+ "background-image",
76
+ "background-origin",
77
+ "background-position",
78
+ "background-repeat",
79
+ "background-size"
80
+ ],
81
+ border: ["border-color", "border-style", "border-width"],
82
+ "border-block-end": [
83
+ "border-block-end-color",
84
+ "border-block-end-style",
85
+ "border-block-end-width"
86
+ ],
87
+ "border-block-start": [
88
+ "border-block-start-color",
89
+ "border-block-start-style",
90
+ "border-block-start-width"
91
+ ],
92
+ "border-bottom": [
93
+ "border-bottom-color",
94
+ "border-bottom-style",
95
+ "border-bottom-width"
96
+ ],
97
+ "border-color": [
98
+ "border-bottom-color",
99
+ "border-left-color",
100
+ "border-right-color",
101
+ "border-top-color"
102
+ ],
103
+ "border-image": [
104
+ "border-image-outset",
105
+ "border-image-repeat",
106
+ "border-image-slice",
107
+ "border-image-source",
108
+ "border-image-width"
109
+ ],
110
+ "border-inline-end": [
111
+ "border-inline-end-color",
112
+ "border-inline-end-style",
113
+ "border-inline-end-width"
114
+ ],
115
+ "border-inline-start": [
116
+ "border-inline-start-color",
117
+ "border-inline-start-style",
118
+ "border-inline-start-width"
119
+ ],
120
+ "border-left": [
121
+ "border-left-color",
122
+ "border-left-style",
123
+ "border-left-width"
124
+ ],
125
+ "border-radius": [
126
+ "border-top-left-radius",
127
+ "border-top-right-radius",
128
+ "border-bottom-right-radius",
129
+ "border-bottom-left-radius"
130
+ ],
131
+ "border-right": [
132
+ "border-right-color",
133
+ "border-right-style",
134
+ "border-right-width"
135
+ ],
136
+ "border-style": [
137
+ "border-bottom-style",
138
+ "border-left-style",
139
+ "border-right-style",
140
+ "border-top-style"
141
+ ],
142
+ "border-top": ["border-top-color", "border-top-style", "border-top-width"],
143
+ "border-width": [
144
+ "border-bottom-width",
145
+ "border-left-width",
146
+ "border-right-width",
147
+ "border-top-width"
148
+ ],
149
+ "column-rule": [
150
+ "column-rule-width",
151
+ "column-rule-style",
152
+ "column-rule-color"
153
+ ],
154
+ columns: ["column-count", "column-width"],
155
+ flex: ["flex-grow", "flex-shrink", "flex-basis"],
156
+ "flex-flow": ["flex-direction", "flex-wrap"],
157
+ font: [
158
+ "font-family",
159
+ "font-size",
160
+ "font-stretch",
161
+ "font-style",
162
+ "font-variant",
163
+ "font-weight",
164
+ "line-height"
165
+ ],
166
+ gap: ["row-gap", "column-gap"],
167
+ grid: [
168
+ "grid-auto-columns",
169
+ "grid-auto-flow",
170
+ "grid-auto-rows",
171
+ "grid-template-areas",
172
+ "grid-template-columns",
173
+ "grid-template-rows"
174
+ ],
175
+ "grid-area": [
176
+ "grid-row-start",
177
+ "grid-column-start",
178
+ "grid-row-end",
179
+ "grid-column-end"
180
+ ],
181
+ "grid-column": ["grid-column-end", "grid-column-start"],
182
+ "grid-row": ["grid-row-end", "grid-row-start"],
183
+ "grid-template": [
184
+ "grid-template-areas",
185
+ "grid-template-columns",
186
+ "grid-template-rows"
187
+ ],
188
+ "list-style": ["list-style-image", "list-style-position", "list-style-type"],
189
+ margin: ["margin-bottom", "margin-left", "margin-right", "margin-top"],
190
+ mask: [
191
+ "mask-clip",
192
+ "mask-composite",
193
+ "mask-image",
194
+ "mask-mode",
195
+ "mask-origin",
196
+ "mask-position",
197
+ "mask-repeat",
198
+ "mask-size"
199
+ ],
200
+ offset: [
201
+ "offset-anchor",
202
+ "offset-distance",
203
+ "offset-path",
204
+ "offset-position",
205
+ "offset-rotate"
206
+ ],
207
+ outline: ["outline-color", "outline-style", "outline-width"],
208
+ overflow: ["overflow-x", "overflow-y"],
209
+ padding: ["padding-bottom", "padding-left", "padding-right", "padding-top"],
210
+ "place-content": ["align-content", "justify-content"],
211
+ "place-items": ["align-items", "justify-items"],
212
+ "place-self": ["align-self", "justify-self"],
213
+ "scroll-margin": [
214
+ "scroll-margin-bottom",
215
+ "scroll-margin-left",
216
+ "scroll-margin-right",
217
+ "scroll-margin-top"
218
+ ],
219
+ "scroll-padding": [
220
+ "scroll-padding-bottom",
221
+ "scroll-padding-left",
222
+ "scroll-padding-right",
223
+ "scroll-padding-top"
224
+ ],
225
+ "text-decoration": [
226
+ "text-decoration-color",
227
+ "text-decoration-line",
228
+ "text-decoration-style",
229
+ "text-decoration-thickness"
230
+ ],
231
+ "text-emphasis": ["text-emphasis-color", "text-emphasis-style"],
232
+ transition: [
233
+ "transition-delay",
234
+ "transition-duration",
235
+ "transition-property",
236
+ "transition-timing-function"
237
+ ]
238
+ };
239
+ function getPropertyPriority(property) {
240
+ const longhands = Object.values(shorthandProperties).reduce(
241
+ (a, b) => [...a, ...b],
242
+ []
243
+ );
244
+ return longhands.includes(property) ? 2 : 1;
245
+ }
246
+
247
+ // src/processors/helpers/atomize.ts
248
+ var knownPropertiesMap = import_known_css_properties.all.reduce(
249
+ (acc, property, i) => {
250
+ acc[property] = i;
251
+ return acc;
252
+ },
253
+ {}
254
+ );
255
+ function hashProperty(property) {
256
+ const index = knownPropertiesMap[property];
257
+ if (index !== void 0) {
258
+ return index.toString(36);
259
+ }
260
+ return (0, import_utils.slugify)(property);
261
+ }
262
+ var parseCss = (cssText) => {
263
+ try {
264
+ return import_postcss.default.parse(cssText);
265
+ } catch (e) {
266
+ if (e instanceof Error) {
267
+ throw new Error(`Error parsing CSS: ${e.message}
268
+ CSS:
269
+ ${cssText}`);
270
+ }
271
+ throw new Error(`Unknown error parsing CSS.
272
+ CSS:
273
+ ${cssText}`);
274
+ }
275
+ };
276
+ function atomize(cssText, hasPriority = false) {
277
+ import_stylis.default.set({
278
+ prefix: false,
279
+ keyframe: false
280
+ });
281
+ const atomicRules = [];
282
+ const stylesheet = parseCss(cssText);
283
+ stylesheet.walkAtRules("keyframes", (atRule) => {
284
+ atRule.remove();
285
+ atomicRules.push({
286
+ property: atRule.name,
287
+ cssText: atRule.toString()
288
+ });
289
+ });
290
+ stylesheet.walkDecls((decl) => {
291
+ let thisParent = decl.parent;
292
+ const parents = [];
293
+ const atomicProperty = [decl.prop];
294
+ let hasAtRule = false;
295
+ while (thisParent && thisParent !== stylesheet) {
296
+ parents.unshift(thisParent);
297
+ if (thisParent.type === "atrule") {
298
+ hasAtRule = true;
299
+ atomicProperty.push(
300
+ thisParent.name,
301
+ thisParent.params
302
+ );
303
+ } else if (thisParent.type === "rule") {
304
+ atomicProperty.push(thisParent.selector);
305
+ }
306
+ thisParent = thisParent.parent;
307
+ }
308
+ const root = import_postcss.default.root();
309
+ let container = root;
310
+ parents.forEach((parent) => {
311
+ const newNode = parent.clone();
312
+ newNode.removeAll();
313
+ container.append(newNode);
314
+ container = newNode;
315
+ });
316
+ container.append(decl.clone());
317
+ const css = root.toString();
318
+ const propertySlug = hashProperty([...atomicProperty].join(";"));
319
+ const valueSlug = (0, import_utils.slugify)(decl.value);
320
+ const className = `atm_${propertySlug}_${valueSlug}`;
321
+ const propertyPriority = getPropertyPriority(decl.prop) + (hasAtRule ? 1 : 0) + (hasPriority ? 1 : 0);
322
+ const processedCss = (0, import_stylis.default)(`.${className}`.repeat(propertyPriority), css);
323
+ atomicRules.push({
324
+ property: atomicProperty.join(" "),
325
+ className,
326
+ cssText: processedCss
327
+ });
328
+ });
329
+ return atomicRules;
330
+ }
331
+
332
+ // src/processors/css.ts
333
+ var _classes;
334
+ var AtomicCssProcessor = class extends import_css.default {
335
+ constructor() {
336
+ super(...arguments);
337
+ __privateAdd(this, _classes, void 0);
338
+ }
339
+ get classes() {
340
+ if (__privateGet(this, _classes)) {
341
+ return __privateGet(this, _classes);
342
+ }
343
+ throw new Error("Styles are not extracted yet. Please call `build` first.");
344
+ }
345
+ doRuntimeReplacement() {
346
+ this.replacer(this.astService.stringLiteral(this.classes), false);
347
+ }
348
+ extractRules(valueCache, cssText, loc) {
349
+ const rules = {};
350
+ const atomicRules = atomize(cssText, false);
351
+ atomicRules.forEach((rule) => {
352
+ rules[rule.cssText] = {
353
+ cssText: rule.cssText,
354
+ start: (loc == null ? void 0 : loc.start) ?? null,
355
+ className: this.className,
356
+ displayName: this.displayName,
357
+ atom: true
358
+ };
359
+ (0, import_logger.debug)(
360
+ "evaluator:template-processor:extracted-atomic-rule",
361
+ `
362
+ ${rule.cssText}`
363
+ );
364
+ });
365
+ __privateSet(this, _classes, atomicRules.filter((rule) => !!rule.className).map((rule) => rule.className).join(" "));
366
+ return rules;
367
+ }
368
+ };
369
+ _classes = new WeakMap();
370
+ // Annotate the CommonJS export names for ESM import in node:
371
+ 0 && (module.exports = {});
372
+ //# sourceMappingURL=css.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/processors/css.ts","../../src/processors/helpers/atomize.ts","../../src/processors/helpers/propertyPriority.ts"],"sourcesContent":["import type { SourceLocation } from '@babel/types';\n\nimport CssProcessor from '@linaria/core/processors/css';\nimport { debug } from '@linaria/logger';\nimport type { Rules, ValueCache } from '@linaria/tags';\n\nimport atomize from './helpers/atomize';\n\nexport default class AtomicCssProcessor extends CssProcessor {\n #classes: string | undefined;\n\n private get classes(): string {\n if (this.#classes) {\n return this.#classes;\n }\n\n throw new Error('Styles are not extracted yet. Please call `build` first.');\n }\n\n public override doRuntimeReplacement(): void {\n this.replacer(this.astService.stringLiteral(this.classes), false);\n }\n\n public override extractRules(\n valueCache: ValueCache,\n cssText: string,\n loc?: SourceLocation | null\n ): Rules {\n const rules: Rules = {};\n\n const atomicRules = atomize(cssText, false);\n atomicRules.forEach((rule) => {\n // eslint-disable-next-line no-param-reassign\n rules[rule.cssText] = {\n cssText: rule.cssText,\n start: loc?.start ?? null,\n className: this.className!,\n displayName: this.displayName!,\n atom: true,\n };\n\n debug(\n 'evaluator:template-processor:extracted-atomic-rule',\n `\\n${rule.cssText}`\n );\n });\n\n this.#classes = atomicRules\n // Some atomic rules produced (eg. keyframes) don't have class names, and they also don't need to appear in the object\n .filter((rule) => !!rule.className)\n .map((rule) => rule.className!)\n .join(' ');\n\n return rules;\n }\n}\n","import { all as knownProperties } from 'known-css-properties';\nimport type { Document, AtRule, Container, Rule } from 'postcss';\nimport postcss from 'postcss';\nimport stylis from 'stylis';\n\nimport { slugify } from '@linaria/utils';\n\nimport { getPropertyPriority } from './propertyPriority';\n\nconst knownPropertiesMap = knownProperties.reduce(\n (acc: { [property: string]: number }, property, i) => {\n acc[property] = i;\n return acc;\n },\n {}\n);\n\nfunction hashProperty(property: string) {\n const index = knownPropertiesMap[property];\n // If it's a known property, let's use the index to cut down the length of the hash.\n // otherwise, slugify\n if (index !== undefined) {\n return index.toString(36); // base 36 so that we get a-z,0-9\n }\n return slugify(property);\n}\n\nconst parseCss = (cssText: string) => {\n try {\n return postcss.parse(cssText);\n } catch (e) {\n if (e instanceof Error) {\n throw new Error(`Error parsing CSS: ${e.message}\\nCSS:\\n${cssText}`);\n }\n\n throw new Error(`Unknown error parsing CSS.\\nCSS:\\n${cssText}`);\n }\n};\n\nexport default function atomize(cssText: string, hasPriority = false) {\n stylis.set({\n prefix: false,\n keyframe: false,\n });\n const atomicRules: {\n className?: string;\n cssText: string;\n property: string;\n }[] = [];\n\n const stylesheet = parseCss(cssText);\n\n // We want to extract all keyframes and leave them as-is.\n // This isn't scoped locally yet\n stylesheet.walkAtRules('keyframes', (atRule) => {\n atRule.remove();\n atomicRules.push({\n property: atRule.name,\n cssText: atRule.toString(),\n });\n });\n\n stylesheet.walkDecls((decl) => {\n let thisParent: Document | Container | undefined = decl.parent;\n const parents: (Document | Container)[] = [];\n const atomicProperty = [decl.prop];\n let hasAtRule = false;\n\n // Traverse the declarations parents, and collect them all.\n while (thisParent && thisParent !== stylesheet) {\n parents.unshift(thisParent);\n if (thisParent.type === 'atrule') {\n hasAtRule = true;\n // @media queries, @supports etc.\n atomicProperty.push(\n (thisParent as AtRule).name,\n (thisParent as AtRule).params\n );\n } else if (thisParent.type === 'rule') {\n // pseudo classes etc.\n atomicProperty.push((thisParent as Rule).selector);\n }\n\n thisParent = thisParent.parent;\n }\n\n // Create a new stylesheet that contains *just* the extracted atomic rule and wrapping selectors, eg.\n // `@media (max-width: 400px) { background: red; }`, or\n // `&:hover { background: red; }`, or\n // `background: red;`\n // We do this so we can run it through stylis, to produce a full atom, eg.\n // `@media (max-width: 400px) { .atm_foo { background: red; } }`\n const root = postcss.root();\n let container: Document | Container = root;\n parents.forEach((parent) => {\n const newNode = parent.clone();\n newNode.removeAll();\n container.append(newNode);\n container = newNode;\n });\n container.append(decl.clone());\n\n const css = root.toString();\n const propertySlug = hashProperty([...atomicProperty].join(';'));\n const valueSlug = slugify(decl.value);\n const className = `atm_${propertySlug}_${valueSlug}`;\n\n const propertyPriority =\n getPropertyPriority(decl.prop) +\n (hasAtRule ? 1 : 0) +\n (hasPriority ? 1 : 0);\n const processedCss = stylis(`.${className}`.repeat(propertyPriority), css);\n\n atomicRules.push({\n property: atomicProperty.join(' '),\n className,\n cssText: processedCss,\n });\n });\n\n return atomicRules;\n}\n","const shorthandProperties = {\n // The `all` property resets everything, and should effectively have priority zero.\n // In practice, this can be achieved by using: div { all: ... } to have even less specificity, but to avoid duplicating all selectors, we just let it be\n // 'all': []\n animation: [\n 'animation-name',\n 'animation-duration',\n 'animation-timing-function',\n 'animation-delay',\n 'animation-iteration-count',\n 'animation-direction',\n 'animation-fill-mode',\n 'animation-play-state',\n ],\n background: [\n 'background-attachment',\n 'background-clip',\n 'background-color',\n 'background-image',\n 'background-origin',\n 'background-position',\n 'background-repeat',\n 'background-size',\n ],\n border: ['border-color', 'border-style', 'border-width'],\n 'border-block-end': [\n 'border-block-end-color',\n 'border-block-end-style',\n 'border-block-end-width',\n ],\n 'border-block-start': [\n 'border-block-start-color',\n 'border-block-start-style',\n 'border-block-start-width',\n ],\n 'border-bottom': [\n 'border-bottom-color',\n 'border-bottom-style',\n 'border-bottom-width',\n ],\n 'border-color': [\n 'border-bottom-color',\n 'border-left-color',\n 'border-right-color',\n 'border-top-color',\n ],\n 'border-image': [\n 'border-image-outset',\n 'border-image-repeat',\n 'border-image-slice',\n 'border-image-source',\n 'border-image-width',\n ],\n 'border-inline-end': [\n 'border-inline-end-color',\n 'border-inline-end-style',\n 'border-inline-end-width',\n ],\n 'border-inline-start': [\n 'border-inline-start-color',\n 'border-inline-start-style',\n 'border-inline-start-width',\n ],\n 'border-left': [\n 'border-left-color',\n 'border-left-style',\n 'border-left-width',\n ],\n 'border-radius': [\n 'border-top-left-radius',\n 'border-top-right-radius',\n 'border-bottom-right-radius',\n 'border-bottom-left-radius',\n ],\n 'border-right': [\n 'border-right-color',\n 'border-right-style',\n 'border-right-width',\n ],\n 'border-style': [\n 'border-bottom-style',\n 'border-left-style',\n 'border-right-style',\n 'border-top-style',\n ],\n 'border-top': ['border-top-color', 'border-top-style', 'border-top-width'],\n 'border-width': [\n 'border-bottom-width',\n 'border-left-width',\n 'border-right-width',\n 'border-top-width',\n ],\n 'column-rule': [\n 'column-rule-width',\n 'column-rule-style',\n 'column-rule-color',\n ],\n columns: ['column-count', 'column-width'],\n flex: ['flex-grow', 'flex-shrink', 'flex-basis'],\n 'flex-flow': ['flex-direction', 'flex-wrap'],\n font: [\n 'font-family',\n 'font-size',\n 'font-stretch',\n 'font-style',\n 'font-variant',\n 'font-weight',\n 'line-height',\n ],\n gap: ['row-gap', 'column-gap'],\n grid: [\n 'grid-auto-columns',\n 'grid-auto-flow',\n 'grid-auto-rows',\n 'grid-template-areas',\n 'grid-template-columns',\n 'grid-template-rows',\n ],\n 'grid-area': [\n 'grid-row-start',\n 'grid-column-start',\n 'grid-row-end',\n 'grid-column-end',\n ],\n 'grid-column': ['grid-column-end', 'grid-column-start'],\n 'grid-row': ['grid-row-end', 'grid-row-start'],\n 'grid-template': [\n 'grid-template-areas',\n 'grid-template-columns',\n 'grid-template-rows',\n ],\n 'list-style': ['list-style-image', 'list-style-position', 'list-style-type'],\n margin: ['margin-bottom', 'margin-left', 'margin-right', 'margin-top'],\n mask: [\n 'mask-clip',\n 'mask-composite',\n 'mask-image',\n 'mask-mode',\n 'mask-origin',\n 'mask-position',\n 'mask-repeat',\n 'mask-size',\n ],\n offset: [\n 'offset-anchor',\n 'offset-distance',\n 'offset-path',\n 'offset-position',\n 'offset-rotate',\n ],\n outline: ['outline-color', 'outline-style', 'outline-width'],\n overflow: ['overflow-x', 'overflow-y'],\n padding: ['padding-bottom', 'padding-left', 'padding-right', 'padding-top'],\n 'place-content': ['align-content', 'justify-content'],\n 'place-items': ['align-items', 'justify-items'],\n 'place-self': ['align-self', 'justify-self'],\n 'scroll-margin': [\n 'scroll-margin-bottom',\n 'scroll-margin-left',\n 'scroll-margin-right',\n 'scroll-margin-top',\n ],\n 'scroll-padding': [\n 'scroll-padding-bottom',\n 'scroll-padding-left',\n 'scroll-padding-right',\n 'scroll-padding-top',\n ],\n 'text-decoration': [\n 'text-decoration-color',\n 'text-decoration-line',\n 'text-decoration-style',\n 'text-decoration-thickness',\n ],\n 'text-emphasis': ['text-emphasis-color', 'text-emphasis-style'],\n transition: [\n 'transition-delay',\n 'transition-duration',\n 'transition-property',\n 'transition-timing-function',\n ],\n};\n\n// Get the property priority: the higher the priority, the higher the resulting\n// specificity of the atom. For example, if we had:\n//\n// import { css } from '@linaria/atomic';\n// css`\n// background-color: blue;\n// background: red;\n// `;\n//\n// we would produce:\n//\n// .atm_a.atm_a { background-color: blue }\n// .atm_b { background: red }\n//\n// and so the more specific selector (.atm_a.atm_a) would win\nexport function getPropertyPriority(property: string) {\n const longhands = Object.values(shorthandProperties).reduce(\n (a, b) => [...a, ...b],\n []\n );\n\n return longhands.includes(property) ? 2 : 1;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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