@navita/engine 0.0.9 → 0.0.11
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.
- package/cache.cjs +27 -0
- package/cache.mjs +25 -0
- package/helpers/declarationsToBlock.cjs +17 -0
- package/helpers/declarationsToBlock.mjs +15 -0
- package/helpers/generateCombinedAtRules.cjs +10 -0
- package/helpers/generateCombinedAtRules.mjs +8 -0
- package/helpers/getPropertyPriority.cjs +262 -0
- package/helpers/getPropertyPriority.mjs +260 -0
- package/helpers/hypenateProperty.cjs +11 -0
- package/helpers/hypenateProperty.mjs +9 -0
- package/helpers/isMediaQuery.cjs +7 -0
- package/helpers/isMediaQuery.mjs +5 -0
- package/helpers/isNestedSelector.cjs +8 -0
- package/helpers/isNestedSelector.mjs +6 -0
- package/helpers/isObject.cjs +7 -0
- package/helpers/isObject.mjs +5 -0
- package/helpers/isSupportsQuery.cjs +7 -0
- package/helpers/isSupportsQuery.mjs +5 -0
- package/helpers/normalizeCSSVarsProperty.cjs +15 -0
- package/helpers/normalizeCSSVarsProperty.mjs +13 -0
- package/helpers/normalizeNestedProperty.cjs +10 -0
- package/helpers/normalizeNestedProperty.mjs +8 -0
- package/helpers/pixelifyProperties.cjs +58 -0
- package/helpers/pixelifyProperties.mjs +56 -0
- package/helpers/splitStyleBlocks.cjs +19 -0
- package/helpers/splitStyleBlocks.mjs +17 -0
- package/helpers/transformContentProperty.cjs +8 -0
- package/helpers/transformContentProperty.mjs +6 -0
- package/identifiers/IDGenerator.cjs +10 -0
- package/identifiers/IDGenerator.mjs +8 -0
- package/identifiers/alphaIDGenerator.cjs +27 -0
- package/identifiers/alphaIDGenerator.mjs +25 -0
- package/identifiers/propertyValueIDGenerator.cjs +24 -0
- package/identifiers/propertyValueIDGenerator.mjs +22 -0
- package/index.cjs +226 -0
- package/index.mjs +27 -673
- package/package.json +2 -2
- package/printers/printFontFaces.cjs +16 -0
- package/printers/printFontFaces.mjs +14 -0
- package/printers/printKeyFrames.cjs +22 -0
- package/printers/printKeyFrames.mjs +20 -0
- package/printers/printSourceMap.cjs +42 -0
- package/printers/printSourceMap.mjs +40 -0
- package/printers/printStyleBlocks.cjs +60 -0
- package/printers/printStyleBlocks.mjs +58 -0
- package/printers/sortAtRules.cjs +10 -0
- package/printers/sortAtRules.mjs +8 -0
- package/printers/sortStatic.cjs +7 -0
- package/printers/sortStatic.mjs +5 -0
- package/processStyles.cjs +88 -0
- package/processStyles.mjs +86 -0
- package/types.cjs +2 -0
- package/types.mjs +1 -0
- package/wrappers/classList.cjs +6 -0
- package/wrappers/classList.mjs +4 -0
- package/wrappers/static.cjs +6 -0
- package/wrappers/static.mjs +4 -0
- package/index.js +0 -872
package/cache.cjs
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
class Cache {
|
|
4
|
+
constructor(_idGenerator){
|
|
5
|
+
this._idGenerator = _idGenerator;
|
|
6
|
+
this._items = {};
|
|
7
|
+
}
|
|
8
|
+
getOrStore(value) {
|
|
9
|
+
const cacheKey = JSON.stringify(value);
|
|
10
|
+
if (this._items[cacheKey]) {
|
|
11
|
+
return this._items[cacheKey];
|
|
12
|
+
}
|
|
13
|
+
return this._items[cacheKey] = {
|
|
14
|
+
id: this._idGenerator.next(value),
|
|
15
|
+
...value
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
items(ids = undefined) {
|
|
19
|
+
const items = Object.values(this._items);
|
|
20
|
+
if (ids === undefined) {
|
|
21
|
+
return items;
|
|
22
|
+
}
|
|
23
|
+
return items.filter((item)=>ids.includes(item.id));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
exports.Cache = Cache;
|
package/cache.mjs
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
class Cache {
|
|
2
|
+
constructor(_idGenerator){
|
|
3
|
+
this._idGenerator = _idGenerator;
|
|
4
|
+
this._items = {};
|
|
5
|
+
}
|
|
6
|
+
getOrStore(value) {
|
|
7
|
+
const cacheKey = JSON.stringify(value);
|
|
8
|
+
if (this._items[cacheKey]) {
|
|
9
|
+
return this._items[cacheKey];
|
|
10
|
+
}
|
|
11
|
+
return this._items[cacheKey] = {
|
|
12
|
+
id: this._idGenerator.next(value),
|
|
13
|
+
...value
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
items(ids = undefined) {
|
|
17
|
+
const items = Object.values(this._items);
|
|
18
|
+
if (ids === undefined) {
|
|
19
|
+
return items;
|
|
20
|
+
}
|
|
21
|
+
return items.filter((item)=>ids.includes(item.id));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { Cache };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var helpers_hypenateProperty = require('./hypenateProperty.cjs');
|
|
4
|
+
|
|
5
|
+
// https://github.com/styletron/styletron/blob/b552ddc5050a8cc5eec84a46a299d937d3bb0112/packages/styletron-engine-atomic/src/css.ts#L36
|
|
6
|
+
function declarationsToBlock(style) {
|
|
7
|
+
let css = "";
|
|
8
|
+
for(const prop in style){
|
|
9
|
+
const val = style[prop];
|
|
10
|
+
if (typeof val === "string" || typeof val === "number") {
|
|
11
|
+
css += `${helpers_hypenateProperty.hyphenateProperty(prop)}:${val};`;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return css.slice(0, -1);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
exports.declarationsToBlock = declarationsToBlock;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { hyphenateProperty } from './hypenateProperty.mjs';
|
|
2
|
+
|
|
3
|
+
// https://github.com/styletron/styletron/blob/b552ddc5050a8cc5eec84a46a299d937d3bb0112/packages/styletron-engine-atomic/src/css.ts#L36
|
|
4
|
+
function declarationsToBlock(style) {
|
|
5
|
+
let css = "";
|
|
6
|
+
for(const prop in style){
|
|
7
|
+
const val = style[prop];
|
|
8
|
+
if (typeof val === "string" || typeof val === "number") {
|
|
9
|
+
css += `${hyphenateProperty(prop)}:${val};`;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return css.slice(0, -1);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { declarationsToBlock };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function generateCombinedAtRules(currentMediaQuery, nestedMediaQuery) {
|
|
4
|
+
if (currentMediaQuery.length === 0) {
|
|
5
|
+
return nestedMediaQuery;
|
|
6
|
+
}
|
|
7
|
+
return `${currentMediaQuery} and ${nestedMediaQuery}`;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
exports.generateCombinedAtRules = generateCombinedAtRules;
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This list comes from:
|
|
5
|
+
* https://github.com/callstack/linaria/blob/master/packages/atomic/src/processors/helpers/propertyPriority.ts
|
|
6
|
+
*/ const shorthandProperties = {
|
|
7
|
+
// The `all` property resets everything, and should effectively have priority zero.
|
|
8
|
+
// 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
|
|
9
|
+
// 'all': []
|
|
10
|
+
animation: [
|
|
11
|
+
'animation-name',
|
|
12
|
+
'animation-duration',
|
|
13
|
+
'animation-timing-function',
|
|
14
|
+
'animation-delay',
|
|
15
|
+
'animation-iteration-count',
|
|
16
|
+
'animation-direction',
|
|
17
|
+
'animation-fill-mode',
|
|
18
|
+
'animation-play-state'
|
|
19
|
+
],
|
|
20
|
+
background: [
|
|
21
|
+
'background-attachment',
|
|
22
|
+
'background-clip',
|
|
23
|
+
'background-color',
|
|
24
|
+
'background-image',
|
|
25
|
+
'background-origin',
|
|
26
|
+
'background-position',
|
|
27
|
+
'background-repeat',
|
|
28
|
+
'background-size'
|
|
29
|
+
],
|
|
30
|
+
border: [
|
|
31
|
+
'border-color',
|
|
32
|
+
'border-style',
|
|
33
|
+
'border-width'
|
|
34
|
+
],
|
|
35
|
+
'border-block-end': [
|
|
36
|
+
'border-block-end-color',
|
|
37
|
+
'border-block-end-style',
|
|
38
|
+
'border-block-end-width'
|
|
39
|
+
],
|
|
40
|
+
'border-block-start': [
|
|
41
|
+
'border-block-start-color',
|
|
42
|
+
'border-block-start-style',
|
|
43
|
+
'border-block-start-width'
|
|
44
|
+
],
|
|
45
|
+
'border-bottom': [
|
|
46
|
+
'border-bottom-color',
|
|
47
|
+
'border-bottom-style',
|
|
48
|
+
'border-bottom-width'
|
|
49
|
+
],
|
|
50
|
+
'border-color': [
|
|
51
|
+
'border-bottom-color',
|
|
52
|
+
'border-left-color',
|
|
53
|
+
'border-right-color',
|
|
54
|
+
'border-top-color'
|
|
55
|
+
],
|
|
56
|
+
'border-image': [
|
|
57
|
+
'border-image-outset',
|
|
58
|
+
'border-image-repeat',
|
|
59
|
+
'border-image-slice',
|
|
60
|
+
'border-image-source',
|
|
61
|
+
'border-image-width'
|
|
62
|
+
],
|
|
63
|
+
'border-inline-end': [
|
|
64
|
+
'border-inline-end-color',
|
|
65
|
+
'border-inline-end-style',
|
|
66
|
+
'border-inline-end-width'
|
|
67
|
+
],
|
|
68
|
+
'border-inline-start': [
|
|
69
|
+
'border-inline-start-color',
|
|
70
|
+
'border-inline-start-style',
|
|
71
|
+
'border-inline-start-width'
|
|
72
|
+
],
|
|
73
|
+
'border-left': [
|
|
74
|
+
'border-left-color',
|
|
75
|
+
'border-left-style',
|
|
76
|
+
'border-left-width'
|
|
77
|
+
],
|
|
78
|
+
'border-radius': [
|
|
79
|
+
'border-top-left-radius',
|
|
80
|
+
'border-top-right-radius',
|
|
81
|
+
'border-bottom-right-radius',
|
|
82
|
+
'border-bottom-left-radius'
|
|
83
|
+
],
|
|
84
|
+
'border-right': [
|
|
85
|
+
'border-right-color',
|
|
86
|
+
'border-right-style',
|
|
87
|
+
'border-right-width'
|
|
88
|
+
],
|
|
89
|
+
'border-style': [
|
|
90
|
+
'border-bottom-style',
|
|
91
|
+
'border-left-style',
|
|
92
|
+
'border-right-style',
|
|
93
|
+
'border-top-style'
|
|
94
|
+
],
|
|
95
|
+
'border-top': [
|
|
96
|
+
'border-top-color',
|
|
97
|
+
'border-top-style',
|
|
98
|
+
'border-top-width'
|
|
99
|
+
],
|
|
100
|
+
'border-width': [
|
|
101
|
+
'border-bottom-width',
|
|
102
|
+
'border-left-width',
|
|
103
|
+
'border-right-width',
|
|
104
|
+
'border-top-width'
|
|
105
|
+
],
|
|
106
|
+
'column-rule': [
|
|
107
|
+
'column-rule-width',
|
|
108
|
+
'column-rule-style',
|
|
109
|
+
'column-rule-color'
|
|
110
|
+
],
|
|
111
|
+
columns: [
|
|
112
|
+
'column-count',
|
|
113
|
+
'column-width'
|
|
114
|
+
],
|
|
115
|
+
flex: [
|
|
116
|
+
'flex-grow',
|
|
117
|
+
'flex-shrink',
|
|
118
|
+
'flex-basis'
|
|
119
|
+
],
|
|
120
|
+
'flex-flow': [
|
|
121
|
+
'flex-direction',
|
|
122
|
+
'flex-wrap'
|
|
123
|
+
],
|
|
124
|
+
font: [
|
|
125
|
+
'font-family',
|
|
126
|
+
'font-size',
|
|
127
|
+
'font-stretch',
|
|
128
|
+
'font-style',
|
|
129
|
+
'font-variant',
|
|
130
|
+
'font-weight',
|
|
131
|
+
'line-height'
|
|
132
|
+
],
|
|
133
|
+
gap: [
|
|
134
|
+
'row-gap',
|
|
135
|
+
'column-gap'
|
|
136
|
+
],
|
|
137
|
+
grid: [
|
|
138
|
+
'grid-auto-columns',
|
|
139
|
+
'grid-auto-flow',
|
|
140
|
+
'grid-auto-rows',
|
|
141
|
+
'grid-template-areas',
|
|
142
|
+
'grid-template-columns',
|
|
143
|
+
'grid-template-rows'
|
|
144
|
+
],
|
|
145
|
+
'grid-area': [
|
|
146
|
+
'grid-row-start',
|
|
147
|
+
'grid-column-start',
|
|
148
|
+
'grid-row-end',
|
|
149
|
+
'grid-column-end'
|
|
150
|
+
],
|
|
151
|
+
'grid-column': [
|
|
152
|
+
'grid-column-end',
|
|
153
|
+
'grid-column-start'
|
|
154
|
+
],
|
|
155
|
+
'grid-row': [
|
|
156
|
+
'grid-row-end',
|
|
157
|
+
'grid-row-start'
|
|
158
|
+
],
|
|
159
|
+
'grid-template': [
|
|
160
|
+
'grid-template-areas',
|
|
161
|
+
'grid-template-columns',
|
|
162
|
+
'grid-template-rows'
|
|
163
|
+
],
|
|
164
|
+
'list-style': [
|
|
165
|
+
'list-style-image',
|
|
166
|
+
'list-style-position',
|
|
167
|
+
'list-style-type'
|
|
168
|
+
],
|
|
169
|
+
margin: [
|
|
170
|
+
'margin-bottom',
|
|
171
|
+
'margin-left',
|
|
172
|
+
'margin-right',
|
|
173
|
+
'margin-top'
|
|
174
|
+
],
|
|
175
|
+
mask: [
|
|
176
|
+
'mask-clip',
|
|
177
|
+
'mask-composite',
|
|
178
|
+
'mask-image',
|
|
179
|
+
'mask-mode',
|
|
180
|
+
'mask-origin',
|
|
181
|
+
'mask-position',
|
|
182
|
+
'mask-repeat',
|
|
183
|
+
'mask-size'
|
|
184
|
+
],
|
|
185
|
+
offset: [
|
|
186
|
+
'offset-anchor',
|
|
187
|
+
'offset-distance',
|
|
188
|
+
'offset-path',
|
|
189
|
+
'offset-position',
|
|
190
|
+
'offset-rotate'
|
|
191
|
+
],
|
|
192
|
+
outline: [
|
|
193
|
+
'outline-color',
|
|
194
|
+
'outline-style',
|
|
195
|
+
'outline-width'
|
|
196
|
+
],
|
|
197
|
+
overflow: [
|
|
198
|
+
'overflow-x',
|
|
199
|
+
'overflow-y'
|
|
200
|
+
],
|
|
201
|
+
padding: [
|
|
202
|
+
'padding-bottom',
|
|
203
|
+
'padding-left',
|
|
204
|
+
'padding-right',
|
|
205
|
+
'padding-top'
|
|
206
|
+
],
|
|
207
|
+
'place-content': [
|
|
208
|
+
'align-content',
|
|
209
|
+
'justify-content'
|
|
210
|
+
],
|
|
211
|
+
'place-items': [
|
|
212
|
+
'align-items',
|
|
213
|
+
'justify-items'
|
|
214
|
+
],
|
|
215
|
+
'place-self': [
|
|
216
|
+
'align-self',
|
|
217
|
+
'justify-self'
|
|
218
|
+
],
|
|
219
|
+
'scroll-margin': [
|
|
220
|
+
'scroll-margin-bottom',
|
|
221
|
+
'scroll-margin-left',
|
|
222
|
+
'scroll-margin-right',
|
|
223
|
+
'scroll-margin-top'
|
|
224
|
+
],
|
|
225
|
+
'scroll-padding': [
|
|
226
|
+
'scroll-padding-bottom',
|
|
227
|
+
'scroll-padding-left',
|
|
228
|
+
'scroll-padding-right',
|
|
229
|
+
'scroll-padding-top'
|
|
230
|
+
],
|
|
231
|
+
'text-decoration': [
|
|
232
|
+
'text-decoration-color',
|
|
233
|
+
'text-decoration-line',
|
|
234
|
+
'text-decoration-style',
|
|
235
|
+
'text-decoration-thickness'
|
|
236
|
+
],
|
|
237
|
+
'text-emphasis': [
|
|
238
|
+
'text-emphasis-color',
|
|
239
|
+
'text-emphasis-style'
|
|
240
|
+
],
|
|
241
|
+
transition: [
|
|
242
|
+
'transition-delay',
|
|
243
|
+
'transition-duration',
|
|
244
|
+
'transition-property',
|
|
245
|
+
'transition-timing-function'
|
|
246
|
+
]
|
|
247
|
+
};
|
|
248
|
+
const longhands = Object.values(shorthandProperties).reduce((a, b)=>[
|
|
249
|
+
...a,
|
|
250
|
+
...b
|
|
251
|
+
], []);
|
|
252
|
+
/**
|
|
253
|
+
* The concept here is that shorthand properties, such as "border" gets
|
|
254
|
+
* a priority of one, while longhand properties, such as "border-color" gets
|
|
255
|
+
* a priority of 2.
|
|
256
|
+
*
|
|
257
|
+
* Read more:
|
|
258
|
+
* @see https://weser.io/blog/the-shorthand-longhand-problem-in-atomic-css
|
|
259
|
+
* @see https://www.w3.org/TR/selectors-3/#specificity
|
|
260
|
+
*/ const getPropertyPriority = (property)=>longhands.includes(property) ? 2 : 1;
|
|
261
|
+
|
|
262
|
+
exports.getPropertyPriority = getPropertyPriority;
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This list comes from:
|
|
3
|
+
* https://github.com/callstack/linaria/blob/master/packages/atomic/src/processors/helpers/propertyPriority.ts
|
|
4
|
+
*/ const shorthandProperties = {
|
|
5
|
+
// The `all` property resets everything, and should effectively have priority zero.
|
|
6
|
+
// 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
|
|
7
|
+
// 'all': []
|
|
8
|
+
animation: [
|
|
9
|
+
'animation-name',
|
|
10
|
+
'animation-duration',
|
|
11
|
+
'animation-timing-function',
|
|
12
|
+
'animation-delay',
|
|
13
|
+
'animation-iteration-count',
|
|
14
|
+
'animation-direction',
|
|
15
|
+
'animation-fill-mode',
|
|
16
|
+
'animation-play-state'
|
|
17
|
+
],
|
|
18
|
+
background: [
|
|
19
|
+
'background-attachment',
|
|
20
|
+
'background-clip',
|
|
21
|
+
'background-color',
|
|
22
|
+
'background-image',
|
|
23
|
+
'background-origin',
|
|
24
|
+
'background-position',
|
|
25
|
+
'background-repeat',
|
|
26
|
+
'background-size'
|
|
27
|
+
],
|
|
28
|
+
border: [
|
|
29
|
+
'border-color',
|
|
30
|
+
'border-style',
|
|
31
|
+
'border-width'
|
|
32
|
+
],
|
|
33
|
+
'border-block-end': [
|
|
34
|
+
'border-block-end-color',
|
|
35
|
+
'border-block-end-style',
|
|
36
|
+
'border-block-end-width'
|
|
37
|
+
],
|
|
38
|
+
'border-block-start': [
|
|
39
|
+
'border-block-start-color',
|
|
40
|
+
'border-block-start-style',
|
|
41
|
+
'border-block-start-width'
|
|
42
|
+
],
|
|
43
|
+
'border-bottom': [
|
|
44
|
+
'border-bottom-color',
|
|
45
|
+
'border-bottom-style',
|
|
46
|
+
'border-bottom-width'
|
|
47
|
+
],
|
|
48
|
+
'border-color': [
|
|
49
|
+
'border-bottom-color',
|
|
50
|
+
'border-left-color',
|
|
51
|
+
'border-right-color',
|
|
52
|
+
'border-top-color'
|
|
53
|
+
],
|
|
54
|
+
'border-image': [
|
|
55
|
+
'border-image-outset',
|
|
56
|
+
'border-image-repeat',
|
|
57
|
+
'border-image-slice',
|
|
58
|
+
'border-image-source',
|
|
59
|
+
'border-image-width'
|
|
60
|
+
],
|
|
61
|
+
'border-inline-end': [
|
|
62
|
+
'border-inline-end-color',
|
|
63
|
+
'border-inline-end-style',
|
|
64
|
+
'border-inline-end-width'
|
|
65
|
+
],
|
|
66
|
+
'border-inline-start': [
|
|
67
|
+
'border-inline-start-color',
|
|
68
|
+
'border-inline-start-style',
|
|
69
|
+
'border-inline-start-width'
|
|
70
|
+
],
|
|
71
|
+
'border-left': [
|
|
72
|
+
'border-left-color',
|
|
73
|
+
'border-left-style',
|
|
74
|
+
'border-left-width'
|
|
75
|
+
],
|
|
76
|
+
'border-radius': [
|
|
77
|
+
'border-top-left-radius',
|
|
78
|
+
'border-top-right-radius',
|
|
79
|
+
'border-bottom-right-radius',
|
|
80
|
+
'border-bottom-left-radius'
|
|
81
|
+
],
|
|
82
|
+
'border-right': [
|
|
83
|
+
'border-right-color',
|
|
84
|
+
'border-right-style',
|
|
85
|
+
'border-right-width'
|
|
86
|
+
],
|
|
87
|
+
'border-style': [
|
|
88
|
+
'border-bottom-style',
|
|
89
|
+
'border-left-style',
|
|
90
|
+
'border-right-style',
|
|
91
|
+
'border-top-style'
|
|
92
|
+
],
|
|
93
|
+
'border-top': [
|
|
94
|
+
'border-top-color',
|
|
95
|
+
'border-top-style',
|
|
96
|
+
'border-top-width'
|
|
97
|
+
],
|
|
98
|
+
'border-width': [
|
|
99
|
+
'border-bottom-width',
|
|
100
|
+
'border-left-width',
|
|
101
|
+
'border-right-width',
|
|
102
|
+
'border-top-width'
|
|
103
|
+
],
|
|
104
|
+
'column-rule': [
|
|
105
|
+
'column-rule-width',
|
|
106
|
+
'column-rule-style',
|
|
107
|
+
'column-rule-color'
|
|
108
|
+
],
|
|
109
|
+
columns: [
|
|
110
|
+
'column-count',
|
|
111
|
+
'column-width'
|
|
112
|
+
],
|
|
113
|
+
flex: [
|
|
114
|
+
'flex-grow',
|
|
115
|
+
'flex-shrink',
|
|
116
|
+
'flex-basis'
|
|
117
|
+
],
|
|
118
|
+
'flex-flow': [
|
|
119
|
+
'flex-direction',
|
|
120
|
+
'flex-wrap'
|
|
121
|
+
],
|
|
122
|
+
font: [
|
|
123
|
+
'font-family',
|
|
124
|
+
'font-size',
|
|
125
|
+
'font-stretch',
|
|
126
|
+
'font-style',
|
|
127
|
+
'font-variant',
|
|
128
|
+
'font-weight',
|
|
129
|
+
'line-height'
|
|
130
|
+
],
|
|
131
|
+
gap: [
|
|
132
|
+
'row-gap',
|
|
133
|
+
'column-gap'
|
|
134
|
+
],
|
|
135
|
+
grid: [
|
|
136
|
+
'grid-auto-columns',
|
|
137
|
+
'grid-auto-flow',
|
|
138
|
+
'grid-auto-rows',
|
|
139
|
+
'grid-template-areas',
|
|
140
|
+
'grid-template-columns',
|
|
141
|
+
'grid-template-rows'
|
|
142
|
+
],
|
|
143
|
+
'grid-area': [
|
|
144
|
+
'grid-row-start',
|
|
145
|
+
'grid-column-start',
|
|
146
|
+
'grid-row-end',
|
|
147
|
+
'grid-column-end'
|
|
148
|
+
],
|
|
149
|
+
'grid-column': [
|
|
150
|
+
'grid-column-end',
|
|
151
|
+
'grid-column-start'
|
|
152
|
+
],
|
|
153
|
+
'grid-row': [
|
|
154
|
+
'grid-row-end',
|
|
155
|
+
'grid-row-start'
|
|
156
|
+
],
|
|
157
|
+
'grid-template': [
|
|
158
|
+
'grid-template-areas',
|
|
159
|
+
'grid-template-columns',
|
|
160
|
+
'grid-template-rows'
|
|
161
|
+
],
|
|
162
|
+
'list-style': [
|
|
163
|
+
'list-style-image',
|
|
164
|
+
'list-style-position',
|
|
165
|
+
'list-style-type'
|
|
166
|
+
],
|
|
167
|
+
margin: [
|
|
168
|
+
'margin-bottom',
|
|
169
|
+
'margin-left',
|
|
170
|
+
'margin-right',
|
|
171
|
+
'margin-top'
|
|
172
|
+
],
|
|
173
|
+
mask: [
|
|
174
|
+
'mask-clip',
|
|
175
|
+
'mask-composite',
|
|
176
|
+
'mask-image',
|
|
177
|
+
'mask-mode',
|
|
178
|
+
'mask-origin',
|
|
179
|
+
'mask-position',
|
|
180
|
+
'mask-repeat',
|
|
181
|
+
'mask-size'
|
|
182
|
+
],
|
|
183
|
+
offset: [
|
|
184
|
+
'offset-anchor',
|
|
185
|
+
'offset-distance',
|
|
186
|
+
'offset-path',
|
|
187
|
+
'offset-position',
|
|
188
|
+
'offset-rotate'
|
|
189
|
+
],
|
|
190
|
+
outline: [
|
|
191
|
+
'outline-color',
|
|
192
|
+
'outline-style',
|
|
193
|
+
'outline-width'
|
|
194
|
+
],
|
|
195
|
+
overflow: [
|
|
196
|
+
'overflow-x',
|
|
197
|
+
'overflow-y'
|
|
198
|
+
],
|
|
199
|
+
padding: [
|
|
200
|
+
'padding-bottom',
|
|
201
|
+
'padding-left',
|
|
202
|
+
'padding-right',
|
|
203
|
+
'padding-top'
|
|
204
|
+
],
|
|
205
|
+
'place-content': [
|
|
206
|
+
'align-content',
|
|
207
|
+
'justify-content'
|
|
208
|
+
],
|
|
209
|
+
'place-items': [
|
|
210
|
+
'align-items',
|
|
211
|
+
'justify-items'
|
|
212
|
+
],
|
|
213
|
+
'place-self': [
|
|
214
|
+
'align-self',
|
|
215
|
+
'justify-self'
|
|
216
|
+
],
|
|
217
|
+
'scroll-margin': [
|
|
218
|
+
'scroll-margin-bottom',
|
|
219
|
+
'scroll-margin-left',
|
|
220
|
+
'scroll-margin-right',
|
|
221
|
+
'scroll-margin-top'
|
|
222
|
+
],
|
|
223
|
+
'scroll-padding': [
|
|
224
|
+
'scroll-padding-bottom',
|
|
225
|
+
'scroll-padding-left',
|
|
226
|
+
'scroll-padding-right',
|
|
227
|
+
'scroll-padding-top'
|
|
228
|
+
],
|
|
229
|
+
'text-decoration': [
|
|
230
|
+
'text-decoration-color',
|
|
231
|
+
'text-decoration-line',
|
|
232
|
+
'text-decoration-style',
|
|
233
|
+
'text-decoration-thickness'
|
|
234
|
+
],
|
|
235
|
+
'text-emphasis': [
|
|
236
|
+
'text-emphasis-color',
|
|
237
|
+
'text-emphasis-style'
|
|
238
|
+
],
|
|
239
|
+
transition: [
|
|
240
|
+
'transition-delay',
|
|
241
|
+
'transition-duration',
|
|
242
|
+
'transition-property',
|
|
243
|
+
'transition-timing-function'
|
|
244
|
+
]
|
|
245
|
+
};
|
|
246
|
+
const longhands = Object.values(shorthandProperties).reduce((a, b)=>[
|
|
247
|
+
...a,
|
|
248
|
+
...b
|
|
249
|
+
], []);
|
|
250
|
+
/**
|
|
251
|
+
* The concept here is that shorthand properties, such as "border" gets
|
|
252
|
+
* a priority of one, while longhand properties, such as "border-color" gets
|
|
253
|
+
* a priority of 2.
|
|
254
|
+
*
|
|
255
|
+
* Read more:
|
|
256
|
+
* @see https://weser.io/blog/the-shorthand-longhand-problem-in-atomic-css
|
|
257
|
+
* @see https://www.w3.org/TR/selectors-3/#specificity
|
|
258
|
+
*/ const getPropertyPriority = (property)=>longhands.includes(property) ? 2 : 1;
|
|
259
|
+
|
|
260
|
+
export { getPropertyPriority };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// https://github.com/styletron/styletron/blob/b552ddc5050a8cc5eec84a46a299d937d3bb0112/packages/styletron-engine-atomic/src/hyphenate-style-name.ts
|
|
4
|
+
const uppercasePattern = /[A-Z]/g;
|
|
5
|
+
const msPattern = /^ms-/;
|
|
6
|
+
const cache = {};
|
|
7
|
+
function hyphenateProperty(property) {
|
|
8
|
+
return property in cache ? cache[property] : cache[property] = property.replace(uppercasePattern, "-$&").toLowerCase().replace(msPattern, "-ms-");
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
exports.hyphenateProperty = hyphenateProperty;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// https://github.com/styletron/styletron/blob/b552ddc5050a8cc5eec84a46a299d937d3bb0112/packages/styletron-engine-atomic/src/hyphenate-style-name.ts
|
|
2
|
+
const uppercasePattern = /[A-Z]/g;
|
|
3
|
+
const msPattern = /^ms-/;
|
|
4
|
+
const cache = {};
|
|
5
|
+
function hyphenateProperty(property) {
|
|
6
|
+
return property in cache ? cache[property] : cache[property] = property.replace(uppercasePattern, "-$&").toLowerCase().replace(msPattern, "-ms-");
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export { hyphenateProperty };
|