@kimdw-rtk/ui 0.0.23 → 0.0.24
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/dist/assets/src/components/Accordion/Accordion.css.ts.vanilla-DHoRkV3W.css +13 -0
- package/dist/assets/src/components/Accordion/AccordionContent.css.ts.vanilla-BB_uFIKZ.css +17 -0
- package/dist/assets/src/components/Accordion/AccordionTrigger.css.ts.vanilla-DqImW62b.css +27 -0
- package/dist/assets/src/components/Box/Box.css.ts.vanilla-B1R5OnVN.css +9 -0
- package/dist/assets/src/components/Button/Button.css.ts.vanilla-CwKkiO3-.css +256 -0
- package/dist/assets/src/components/Card/Card.css.ts.vanilla-B6zOHg3m.css +129 -0
- package/dist/assets/src/components/Card/CardContent.css.ts.vanilla-D6el3eAl.css +7 -0
- package/dist/assets/src/components/Card/CardInteraction.css.ts.vanilla-BE4dgSQF.css +10 -0
- package/dist/assets/src/components/Card/CardThumbnail.css.ts.vanilla-4ExzCHGB.css +7 -0
- package/dist/assets/src/components/Chip/Chip.css.ts.vanilla-BQyyiuIh.css +144 -0
- package/dist/assets/src/components/Dialog/Dialog.css.ts.vanilla-YKNZi-5m.css +17 -0
- package/dist/assets/src/components/Dialog/DialogContent.css.ts.vanilla-CDgem4JS.css +10 -0
- package/dist/assets/src/components/Dialog/DialogHeader.css.ts.vanilla-B7ELV9Tz.css +24 -0
- package/dist/assets/src/components/Navigation/NavigationAside.css.ts.vanilla-CyvGpR0t.css +8 -0
- package/dist/assets/src/components/Navigation/NavigationBar.css.ts.vanilla-CIWo8PT9.css +25 -0
- package/dist/assets/src/components/Navigation/NavigationContainer.css.ts.vanilla-D_Mh6uxB.css +8 -0
- package/dist/assets/src/components/Navigation/NavigationDrawer.css.ts.vanilla-C0bcZ6aX.css +41 -0
- package/dist/assets/src/components/Navigation/NavigationItem.css.ts.vanilla-B8sDhdDM.css +25 -0
- package/dist/assets/src/components/Navigation/NavigationLogo.css.ts.vanilla-CDfEsRyO.css +6 -0
- package/dist/assets/src/components/Navigation/NavigationMenu.css.ts.vanilla-DMG1nMNx.css +16 -0
- package/dist/assets/src/components/Range/Range.css.ts.vanilla-CuL4CEBH.css +152 -0
- package/dist/assets/src/components/ScrollArea/ScrollArea.css.ts.vanilla-Cj6CJqL6.css +32 -0
- package/dist/assets/src/components/Select/Select.css.ts.vanilla-BaHmnuCn.css +15 -0
- package/dist/assets/src/components/Select/SelectOption.css.ts.vanilla-AyA2p0kJ.css +11 -0
- package/dist/assets/src/components/Select/SelectOptionList.css.ts.vanilla-B4SUP6QX.css +47 -0
- package/dist/assets/src/components/Select/SelectTrigger.css.ts.vanilla-BsJygMMX.css +42 -0
- package/dist/assets/src/components/Skeleton/Skeleton.css.ts.vanilla-CIMdGwKw.css +19 -0
- package/dist/assets/src/components/Table/Table.css.ts.vanilla-D-ufMKzq.css +8 -0
- package/dist/assets/src/components/Table/TableCell.css.ts.vanilla-Bj9LamuH.css +29 -0
- package/dist/assets/src/components/Table/TableHead.css.ts.vanilla-UQ-15lSo.css +9 -0
- package/dist/assets/src/components/Table/TableRow.css.ts.vanilla-C40POryZ.css +4 -0
- package/dist/assets/src/components/Tabs/TabsList.css.ts.vanilla-ZS6oU-aI.css +9 -0
- package/dist/assets/src/components/Tabs/TabsTrigger.css.ts.vanilla-BqYCvzGu.css +24 -0
- package/dist/assets/src/components/TextField/TextField.css.ts.vanilla-BfCzKhrn.css +120 -0
- package/dist/assets/src/components/Toast/Toast.css.ts.vanilla-Bfrg1VjC.css +69 -0
- package/dist/assets/src/components/Typography/Typography.css.ts.vanilla-Bs-8bmOK.css +11 -0
- package/dist/assets/src/hooks/useRipple/ripple.css.ts.vanilla-DN79qPCL.css +18 -0
- package/dist/assets/src/hooks/useToast/ToastContainer.css.ts.vanilla-Drak4Eu3.css +9 -0
- package/dist/assets/src/styles/globalStyle.css.ts.vanilla-DSX8q-vB.css +552 -0
- package/dist/assets/src/styles/layers.css.ts.vanilla-CjJMJJa-.css +2 -0
- package/dist/assets/src/styles/overlay.css.ts.vanilla-8OV7kDoh.css +30 -0
- package/dist/assets/src/styles/sprinkles.css.ts.vanilla-BtxhG1FX.css +3506 -0
- package/dist/components/Accordion/Accordion.css.js +3 -25
- package/dist/components/Accordion/AccordionContent.css.js +3 -22
- package/dist/components/Accordion/AccordionTrigger.css.js +3 -39
- package/dist/components/Box/Box.css.js +2 -16
- package/dist/components/Button/Button.css.js +4 -182
- package/dist/components/Card/Card.css.js +2 -68
- package/dist/components/Card/CardContent.css.js +1 -7
- package/dist/components/Card/CardInteraction.css.js +1 -9
- package/dist/components/Card/CardThumbnail.css.js +1 -6
- package/dist/components/Chip/Chip.css.js +2 -56
- package/dist/components/Dialog/Dialog.css.js +1 -20
- package/dist/components/Dialog/DialogContent.css.js +1 -13
- package/dist/components/Dialog/DialogHeader.css.js +2 -24
- package/dist/components/Navigation/NavigationAside.css.js +1 -7
- package/dist/components/Navigation/NavigationBar.css.js +3 -32
- package/dist/components/Navigation/NavigationContainer.css.js +1 -10
- package/dist/components/Navigation/NavigationDrawer.css.js +4 -49
- package/dist/components/Navigation/NavigationItem.css.js +2 -35
- package/dist/components/Navigation/NavigationLogo.css.js +1 -5
- package/dist/components/Navigation/NavigationMenu.css.js +1 -20
- package/dist/components/Range/Range.css.js +5 -93
- package/dist/components/ScrollArea/ScrollArea.css.js +5 -33
- package/dist/components/Select/Select.css.js +2 -20
- package/dist/components/Select/SelectOption.css.js +1 -11
- package/dist/components/Select/SelectOptionList.css.js +2 -55
- package/dist/components/Select/SelectTrigger.css.js +4 -59
- package/dist/components/Skeleton/Skeleton.css.js +1 -20
- package/dist/components/Table/Table.css.js +2 -8
- package/dist/components/Table/TableCell.css.js +1 -33
- package/dist/components/Table/TableHead.css.js +1 -9
- package/dist/components/Table/TableRow.css.js +1 -3
- package/dist/components/Tabs/TabsList.css.js +1 -9
- package/dist/components/Tabs/TabsTrigger.css.js +2 -29
- package/dist/components/TextField/TextField.css.js +2 -59
- package/dist/components/Toast/Toast.css.js +3 -62
- package/dist/components/Typography/Typography.css.js +2 -15
- package/dist/hooks/useRipple/ripple.css.js +3 -30
- package/dist/hooks/useToast/ToastContainer.css.js +1 -11
- package/dist/node_modules/.pnpm/@vanilla-extract_sprinkles@1.6.5_@vanilla-extract_css@1.17.4_babel-plugin-macros@3.1.0_/node_modules/@vanilla-extract/sprinkles/createRuntimeSprinkles/dist/vanilla-extract-sprinkles-createRuntimeSprinkles.esm.js +8 -0
- package/dist/styles/layers.css.js +2 -4
- package/dist/styles/overlay.css.js +3 -32
- package/dist/styles/sprinkles.css.js +6 -121
- package/dist/themes/darkTheme.css.js +1 -30
- package/dist/themes/lightTheme.css.js +1 -30
- package/dist/themes/theme.css.js +1 -22
- package/package.json +2 -1
- package/dist/_virtual/cjs.js +0 -5
- package/dist/_virtual/cssesc.js +0 -5
- package/dist/node_modules/.pnpm/@emotion_hash@0.9.2/node_modules/@emotion/hash/dist/emotion-hash.esm.js +0 -55
- package/dist/node_modules/.pnpm/@vanilla-extract_css@1.17.4_babel-plugin-macros@3.1.0/node_modules/@vanilla-extract/css/adapter/dist/vanilla-extract-css-adapter.esm.js +0 -51
- package/dist/node_modules/.pnpm/@vanilla-extract_css@1.17.4_babel-plugin-macros@3.1.0/node_modules/@vanilla-extract/css/dist/taggedTemplateLiteral-10998315.esm.js +0 -12
- package/dist/node_modules/.pnpm/@vanilla-extract_css@1.17.4_babel-plugin-macros@3.1.0/node_modules/@vanilla-extract/css/dist/transformCss-0dba36bf.esm.js +0 -955
- package/dist/node_modules/.pnpm/@vanilla-extract_css@1.17.4_babel-plugin-macros@3.1.0/node_modules/@vanilla-extract/css/dist/vanilla-extract-css.esm.js +0 -325
- package/dist/node_modules/.pnpm/@vanilla-extract_css@1.17.4_babel-plugin-macros@3.1.0/node_modules/@vanilla-extract/css/fileScope/dist/vanilla-extract-css-fileScope.esm.js +0 -20
- package/dist/node_modules/.pnpm/@vanilla-extract_css@1.17.4_babel-plugin-macros@3.1.0/node_modules/@vanilla-extract/css/functionSerializer/dist/vanilla-extract-css-functionSerializer.esm.js +0 -11
- package/dist/node_modules/.pnpm/@vanilla-extract_css@1.17.4_babel-plugin-macros@3.1.0/node_modules/@vanilla-extract/css/injectStyles/dist/vanilla-extract-css-injectStyles.esm.js +0 -22
- package/dist/node_modules/.pnpm/@vanilla-extract_private@1.0.9/node_modules/@vanilla-extract/private/dist/vanilla-extract-private.esm.js +0 -26
- package/dist/node_modules/.pnpm/@vanilla-extract_recipes@0.5.7_@vanilla-extract_css@1.17.4_babel-plugin-macros@3.1.0_/node_modules/@vanilla-extract/recipes/dist/vanilla-extract-recipes.esm.js +0 -43
- package/dist/node_modules/.pnpm/@vanilla-extract_sprinkles@1.6.5_@vanilla-extract_css@1.17.4_babel-plugin-macros@3.1.0_/node_modules/@vanilla-extract/sprinkles/dist/vanilla-extract-sprinkles.esm.js +0 -146
- package/dist/node_modules/.pnpm/css-what@6.2.2/node_modules/css-what/lib/es/parse.js +0 -423
- package/dist/node_modules/.pnpm/css-what@6.2.2/node_modules/css-what/lib/es/types.js +0 -28
- package/dist/node_modules/.pnpm/cssesc@3.0.0/node_modules/cssesc/cssesc.js +0 -119
- package/dist/node_modules/.pnpm/dedent@1.6.0_babel-plugin-macros@3.1.0/node_modules/dedent/dist/dedent.js +0 -68
- package/dist/node_modules/.pnpm/deepmerge@4.3.1/node_modules/deepmerge/dist/cjs.js +0 -142
- package/dist/node_modules/.pnpm/lru-cache@10.4.3/node_modules/lru-cache/dist/esm/index.js +0 -1542
- package/dist/node_modules/.pnpm/media-query-parser@2.0.2/node_modules/media-query-parser/dist/media-query-parser.esm.js +0 -1378
- package/dist/node_modules/.pnpm/modern-ahocorasick@1.1.0/node_modules/modern-ahocorasick/dist/index.js +0 -101
- package/dist/tokens/scale/color.js +0 -602
- package/dist/tokens/semantic/breakpoint.js +0 -4
- package/dist/tokens/semantic/color.js +0 -12
- package/dist/tokens/semantic/spacing.js +0 -11
- package/dist/tokens/semantic/typography.js +0 -34
- package/dist/utils/styleUtils.css.js +0 -64
|
@@ -1,955 +0,0 @@
|
|
|
1
|
-
import { getVarName } from '../../../../../@vanilla-extract_private@1.0.9/node_modules/@vanilla-extract/private/dist/vanilla-extract-private.esm.js';
|
|
2
|
-
import cssescExports from '../../../../../../../_virtual/cssesc.js';
|
|
3
|
-
import AhoCorasick from '../../../../../modern-ahocorasick@1.1.0/node_modules/modern-ahocorasick/dist/index.js';
|
|
4
|
-
import { markCompositionUsed } from '../adapter/dist/vanilla-extract-css-adapter.esm.js';
|
|
5
|
-
import { _ as _taggedTemplateLiteral } from './taggedTemplateLiteral-10998315.esm.js';
|
|
6
|
-
import dedent from '../../../../../dedent@1.6.0_babel-plugin-macros@3.1.0/node_modules/dedent/dist/dedent.js';
|
|
7
|
-
import { toAST } from '../../../../../media-query-parser@2.0.2/node_modules/media-query-parser/dist/media-query-parser.esm.js';
|
|
8
|
-
import { parse } from '../../../../../css-what@6.2.2/node_modules/css-what/lib/es/parse.js';
|
|
9
|
-
|
|
10
|
-
function toPrimitive(t, r) {
|
|
11
|
-
if ("object" != typeof t || !t) return t;
|
|
12
|
-
var e = t[Symbol.toPrimitive];
|
|
13
|
-
if (void 0 !== e) {
|
|
14
|
-
var i = e.call(t, r);
|
|
15
|
-
if ("object" != typeof i) return i;
|
|
16
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
17
|
-
}
|
|
18
|
-
return ("string" === r ? String : Number)(t);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function toPropertyKey(t) {
|
|
22
|
-
var i = toPrimitive(t, "string");
|
|
23
|
-
return "symbol" == typeof i ? i : String(i);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function _defineProperty(obj, key, value) {
|
|
27
|
-
key = toPropertyKey(key);
|
|
28
|
-
if (key in obj) {
|
|
29
|
-
Object.defineProperty(obj, key, {
|
|
30
|
-
value: value,
|
|
31
|
-
enumerable: true,
|
|
32
|
-
configurable: true,
|
|
33
|
-
writable: true
|
|
34
|
-
});
|
|
35
|
-
} else {
|
|
36
|
-
obj[key] = value;
|
|
37
|
-
}
|
|
38
|
-
return obj;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function ownKeys(e, r) {
|
|
42
|
-
var t = Object.keys(e);
|
|
43
|
-
if (Object.getOwnPropertySymbols) {
|
|
44
|
-
var o = Object.getOwnPropertySymbols(e);
|
|
45
|
-
r && (o = o.filter(function (r) {
|
|
46
|
-
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
47
|
-
})), t.push.apply(t, o);
|
|
48
|
-
}
|
|
49
|
-
return t;
|
|
50
|
-
}
|
|
51
|
-
function _objectSpread2(e) {
|
|
52
|
-
for (var r = 1; r < arguments.length; r++) {
|
|
53
|
-
var t = null != arguments[r] ? arguments[r] : {};
|
|
54
|
-
r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
|
|
55
|
-
_defineProperty(e, r, t[r]);
|
|
56
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
|
57
|
-
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
return e;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
64
|
-
if (source == null) return {};
|
|
65
|
-
var target = {};
|
|
66
|
-
var sourceKeys = Object.keys(source);
|
|
67
|
-
var key, i;
|
|
68
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
69
|
-
key = sourceKeys[i];
|
|
70
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
71
|
-
target[key] = source[key];
|
|
72
|
-
}
|
|
73
|
-
return target;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function _objectWithoutProperties(source, excluded) {
|
|
77
|
-
if (source == null) return {};
|
|
78
|
-
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
79
|
-
var key, i;
|
|
80
|
-
if (Object.getOwnPropertySymbols) {
|
|
81
|
-
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
82
|
-
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
83
|
-
key = sourceSymbolKeys[i];
|
|
84
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
85
|
-
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
86
|
-
target[key] = source[key];
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return target;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function forEach(obj, fn) {
|
|
93
|
-
for (var _key in obj) {
|
|
94
|
-
fn(obj[_key], _key);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
function omit(obj, omitKeys) {
|
|
98
|
-
var result = {};
|
|
99
|
-
for (var _key2 in obj) {
|
|
100
|
-
if (omitKeys.indexOf(_key2) === -1) {
|
|
101
|
-
result[_key2] = obj[_key2];
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
return result;
|
|
105
|
-
}
|
|
106
|
-
function mapKeys(obj, fn) {
|
|
107
|
-
var result = {};
|
|
108
|
-
for (var _key3 in obj) {
|
|
109
|
-
result[fn(obj[_key3], _key3)] = obj[_key3];
|
|
110
|
-
}
|
|
111
|
-
return result;
|
|
112
|
-
}
|
|
113
|
-
function composeStylesIntoSet(set) {
|
|
114
|
-
for (var _len = arguments.length, classNames = new Array(_len > 1 ? _len - 1 : 0), _key5 = 1; _key5 < _len; _key5++) {
|
|
115
|
-
classNames[_key5 - 1] = arguments[_key5];
|
|
116
|
-
}
|
|
117
|
-
for (var className of classNames) {
|
|
118
|
-
if (className.length === 0) {
|
|
119
|
-
continue;
|
|
120
|
-
}
|
|
121
|
-
if (typeof className === 'string') {
|
|
122
|
-
if (className.includes(' ')) {
|
|
123
|
-
composeStylesIntoSet(set, ...className.trim().split(' '));
|
|
124
|
-
} else {
|
|
125
|
-
set.add(className);
|
|
126
|
-
}
|
|
127
|
-
} else if (Array.isArray(className)) {
|
|
128
|
-
composeStylesIntoSet(set, ...className);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
function dudupeAndJoinClassList(classNames) {
|
|
133
|
-
var set = new Set();
|
|
134
|
-
composeStylesIntoSet(set, ...classNames);
|
|
135
|
-
return Array.from(set).join(' ');
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
var _templateObject$1;
|
|
139
|
-
|
|
140
|
-
// https://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
|
|
141
|
-
function escapeRegex(string) {
|
|
142
|
-
return string.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
143
|
-
}
|
|
144
|
-
var validateSelector = (selector, targetClassName) => {
|
|
145
|
-
var replaceTarget = () => {
|
|
146
|
-
var targetRegex = new RegExp(".".concat(escapeRegex(cssescExports(targetClassName, {
|
|
147
|
-
isIdentifier: true
|
|
148
|
-
}))), 'g');
|
|
149
|
-
return selector.replace(targetRegex, '&');
|
|
150
|
-
};
|
|
151
|
-
var selectorParts;
|
|
152
|
-
try {
|
|
153
|
-
selectorParts = parse(selector);
|
|
154
|
-
} catch (err) {
|
|
155
|
-
throw new Error("Invalid selector: ".concat(replaceTarget()));
|
|
156
|
-
}
|
|
157
|
-
selectorParts.forEach(tokens => {
|
|
158
|
-
try {
|
|
159
|
-
for (var i = tokens.length - 1; i >= -1; i--) {
|
|
160
|
-
if (!tokens[i]) {
|
|
161
|
-
throw new Error();
|
|
162
|
-
}
|
|
163
|
-
var token = tokens[i];
|
|
164
|
-
if (token.type === 'child' || token.type === 'parent' || token.type === 'sibling' || token.type === 'adjacent' || token.type === 'descendant') {
|
|
165
|
-
throw new Error();
|
|
166
|
-
}
|
|
167
|
-
if (token.type === 'attribute' && token.name === 'class' && token.value === targetClassName) {
|
|
168
|
-
return; // Found it
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
} catch (err) {
|
|
172
|
-
throw new Error(dedent(_templateObject$1 || (_templateObject$1 = _taggedTemplateLiteral(["\n Invalid selector: ", "\n \n Style selectors must target the '&' character (along with any modifiers), e.g. ", " or ", ".\n \n This is to ensure that each style block only affects the styling of a single class.\n \n If your selector is targeting another class, you should move it to the style definition for that class, e.g. given we have styles for 'parent' and 'child' elements, instead of adding a selector of ", ") to 'parent', you should add ", " to 'child').\n \n If your selector is targeting something global, use the 'globalStyle' function instead, e.g. if you wanted to write ", ", you should instead write 'globalStyle(", ", { ... })'\n "])), replaceTarget(), '`${parent} &`', '`${parent} &:hover`', '`& ${child}`', '`${parent} &`', '`& h1`', '`${parent} h1`'));
|
|
173
|
-
}
|
|
174
|
-
});
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
/** e.g. @media screen and (min-width: 500px) */
|
|
178
|
-
|
|
179
|
-
class ConditionalRuleset {
|
|
180
|
-
/**
|
|
181
|
-
* Stores information about where conditions must be in relation to other conditions
|
|
182
|
-
*
|
|
183
|
-
* e.g. mobile -> tablet, desktop
|
|
184
|
-
*/
|
|
185
|
-
|
|
186
|
-
constructor() {
|
|
187
|
-
this.ruleset = new Map();
|
|
188
|
-
this.precedenceLookup = new Map();
|
|
189
|
-
}
|
|
190
|
-
findOrCreateCondition(conditionQuery) {
|
|
191
|
-
var targetCondition = this.ruleset.get(conditionQuery);
|
|
192
|
-
if (!targetCondition) {
|
|
193
|
-
// No target condition so create one
|
|
194
|
-
targetCondition = {
|
|
195
|
-
query: conditionQuery,
|
|
196
|
-
rules: [],
|
|
197
|
-
children: new ConditionalRuleset()
|
|
198
|
-
};
|
|
199
|
-
this.ruleset.set(conditionQuery, targetCondition);
|
|
200
|
-
}
|
|
201
|
-
return targetCondition;
|
|
202
|
-
}
|
|
203
|
-
getConditionalRulesetByPath(conditionPath) {
|
|
204
|
-
var currRuleset = this;
|
|
205
|
-
for (var query of conditionPath) {
|
|
206
|
-
var condition = currRuleset.findOrCreateCondition(query);
|
|
207
|
-
currRuleset = condition.children;
|
|
208
|
-
}
|
|
209
|
-
return currRuleset;
|
|
210
|
-
}
|
|
211
|
-
addRule(rule, conditionQuery, conditionPath) {
|
|
212
|
-
var ruleset = this.getConditionalRulesetByPath(conditionPath);
|
|
213
|
-
var targetCondition = ruleset.findOrCreateCondition(conditionQuery);
|
|
214
|
-
if (!targetCondition) {
|
|
215
|
-
throw new Error('Failed to add conditional rule');
|
|
216
|
-
}
|
|
217
|
-
targetCondition.rules.push(rule);
|
|
218
|
-
}
|
|
219
|
-
addConditionPrecedence(conditionPath, conditionOrder) {
|
|
220
|
-
var ruleset = this.getConditionalRulesetByPath(conditionPath);
|
|
221
|
-
for (var i = 0; i < conditionOrder.length; i++) {
|
|
222
|
-
var _ruleset$precedenceLo;
|
|
223
|
-
var query = conditionOrder[i];
|
|
224
|
-
var conditionPrecedence = (_ruleset$precedenceLo = ruleset.precedenceLookup.get(query)) !== null && _ruleset$precedenceLo !== void 0 ? _ruleset$precedenceLo : new Set();
|
|
225
|
-
for (var lowerPrecedenceCondition of conditionOrder.slice(i + 1)) {
|
|
226
|
-
conditionPrecedence.add(lowerPrecedenceCondition);
|
|
227
|
-
}
|
|
228
|
-
ruleset.precedenceLookup.set(query, conditionPrecedence);
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
isCompatible(incomingRuleset) {
|
|
232
|
-
for (var [condition, orderPrecedence] of this.precedenceLookup.entries()) {
|
|
233
|
-
for (var lowerPrecedenceCondition of orderPrecedence) {
|
|
234
|
-
var _incomingRuleset$prec;
|
|
235
|
-
if ((_incomingRuleset$prec = incomingRuleset.precedenceLookup.get(lowerPrecedenceCondition)) !== null && _incomingRuleset$prec !== void 0 && _incomingRuleset$prec.has(condition)) {
|
|
236
|
-
return false;
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
// Check that children are compatible
|
|
242
|
-
for (var {
|
|
243
|
-
query,
|
|
244
|
-
children
|
|
245
|
-
} of incomingRuleset.ruleset.values()) {
|
|
246
|
-
var matchingCondition = this.ruleset.get(query);
|
|
247
|
-
if (matchingCondition && !matchingCondition.children.isCompatible(children)) {
|
|
248
|
-
return false;
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
return true;
|
|
252
|
-
}
|
|
253
|
-
merge(incomingRuleset) {
|
|
254
|
-
// Merge rulesets into one array
|
|
255
|
-
for (var {
|
|
256
|
-
query,
|
|
257
|
-
rules,
|
|
258
|
-
children
|
|
259
|
-
} of incomingRuleset.ruleset.values()) {
|
|
260
|
-
var matchingCondition = this.ruleset.get(query);
|
|
261
|
-
if (matchingCondition) {
|
|
262
|
-
matchingCondition.rules.push(...rules);
|
|
263
|
-
matchingCondition.children.merge(children);
|
|
264
|
-
} else {
|
|
265
|
-
this.ruleset.set(query, {
|
|
266
|
-
query,
|
|
267
|
-
rules,
|
|
268
|
-
children
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
// Merge order precedences
|
|
274
|
-
for (var [condition, incomingOrderPrecedence] of incomingRuleset.precedenceLookup.entries()) {
|
|
275
|
-
var _this$precedenceLooku;
|
|
276
|
-
var orderPrecedence = (_this$precedenceLooku = this.precedenceLookup.get(condition)) !== null && _this$precedenceLooku !== void 0 ? _this$precedenceLooku : new Set();
|
|
277
|
-
this.precedenceLookup.set(condition, new Set([...orderPrecedence, ...incomingOrderPrecedence]));
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* Merge another ConditionalRuleset into this one if they are compatible
|
|
283
|
-
*
|
|
284
|
-
* @returns true if successful, false if the ruleset is incompatible
|
|
285
|
-
*/
|
|
286
|
-
mergeIfCompatible(incomingRuleset) {
|
|
287
|
-
if (!this.isCompatible(incomingRuleset)) {
|
|
288
|
-
return false;
|
|
289
|
-
}
|
|
290
|
-
this.merge(incomingRuleset);
|
|
291
|
-
return true;
|
|
292
|
-
}
|
|
293
|
-
getSortedRuleset() {
|
|
294
|
-
var _this = this;
|
|
295
|
-
var sortedRuleset = [];
|
|
296
|
-
|
|
297
|
-
// Loop through all queries and add them to the sorted ruleset
|
|
298
|
-
var _loop = function _loop(dependents) {
|
|
299
|
-
var conditionForQuery = _this.ruleset.get(query);
|
|
300
|
-
if (!conditionForQuery) {
|
|
301
|
-
throw new Error("Can't find condition for ".concat(query));
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
// Find the location of the first dependent condition in the sortedRuleset
|
|
305
|
-
// A dependent condition is a condition that must be placed *after* the current one
|
|
306
|
-
var firstMatchingDependent = sortedRuleset.findIndex(condition => dependents.has(condition.query));
|
|
307
|
-
if (firstMatchingDependent > -1) {
|
|
308
|
-
// Insert the condition before the dependent one
|
|
309
|
-
sortedRuleset.splice(firstMatchingDependent, 0, conditionForQuery);
|
|
310
|
-
} else {
|
|
311
|
-
// No match, just insert at the end
|
|
312
|
-
sortedRuleset.push(conditionForQuery);
|
|
313
|
-
}
|
|
314
|
-
};
|
|
315
|
-
for (var [query, dependents] of this.precedenceLookup.entries()) {
|
|
316
|
-
_loop(dependents);
|
|
317
|
-
}
|
|
318
|
-
return sortedRuleset;
|
|
319
|
-
}
|
|
320
|
-
renderToArray() {
|
|
321
|
-
var arr = [];
|
|
322
|
-
for (var {
|
|
323
|
-
query,
|
|
324
|
-
rules,
|
|
325
|
-
children
|
|
326
|
-
} of this.getSortedRuleset()) {
|
|
327
|
-
var selectors = {};
|
|
328
|
-
for (var rule of rules) {
|
|
329
|
-
selectors[rule.selector] = _objectSpread2(_objectSpread2({}, selectors[rule.selector]), rule.rule);
|
|
330
|
-
}
|
|
331
|
-
Object.assign(selectors, ...children.renderToArray());
|
|
332
|
-
arr.push({
|
|
333
|
-
[query]: selectors
|
|
334
|
-
});
|
|
335
|
-
}
|
|
336
|
-
return arr;
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
var simplePseudoMap = {
|
|
341
|
-
':-moz-any-link': true,
|
|
342
|
-
':-moz-full-screen': true,
|
|
343
|
-
':-moz-placeholder': true,
|
|
344
|
-
':-moz-read-only': true,
|
|
345
|
-
':-moz-read-write': true,
|
|
346
|
-
':-ms-fullscreen': true,
|
|
347
|
-
':-ms-input-placeholder': true,
|
|
348
|
-
':-webkit-any-link': true,
|
|
349
|
-
':-webkit-full-screen': true,
|
|
350
|
-
'::-moz-color-swatch': true,
|
|
351
|
-
'::-moz-list-bullet': true,
|
|
352
|
-
'::-moz-list-number': true,
|
|
353
|
-
'::-moz-page-sequence': true,
|
|
354
|
-
'::-moz-page': true,
|
|
355
|
-
'::-moz-placeholder': true,
|
|
356
|
-
'::-moz-progress-bar': true,
|
|
357
|
-
'::-moz-range-progress': true,
|
|
358
|
-
'::-moz-range-thumb': true,
|
|
359
|
-
'::-moz-range-track': true,
|
|
360
|
-
'::-moz-scrolled-page-sequence': true,
|
|
361
|
-
'::-moz-selection': true,
|
|
362
|
-
'::-ms-backdrop': true,
|
|
363
|
-
'::-ms-browse': true,
|
|
364
|
-
'::-ms-check': true,
|
|
365
|
-
'::-ms-clear': true,
|
|
366
|
-
'::-ms-fill-lower': true,
|
|
367
|
-
'::-ms-fill-upper': true,
|
|
368
|
-
'::-ms-fill': true,
|
|
369
|
-
'::-ms-reveal': true,
|
|
370
|
-
'::-ms-thumb': true,
|
|
371
|
-
'::-ms-ticks-after': true,
|
|
372
|
-
'::-ms-ticks-before': true,
|
|
373
|
-
'::-ms-tooltip': true,
|
|
374
|
-
'::-ms-track': true,
|
|
375
|
-
'::-ms-value': true,
|
|
376
|
-
'::-webkit-backdrop': true,
|
|
377
|
-
'::-webkit-calendar-picker-indicator': true,
|
|
378
|
-
'::-webkit-inner-spin-button': true,
|
|
379
|
-
'::-webkit-input-placeholder': true,
|
|
380
|
-
'::-webkit-meter-bar': true,
|
|
381
|
-
'::-webkit-meter-even-less-good-value': true,
|
|
382
|
-
'::-webkit-meter-inner-element': true,
|
|
383
|
-
'::-webkit-meter-optimum-value': true,
|
|
384
|
-
'::-webkit-meter-suboptimum-value': true,
|
|
385
|
-
'::-webkit-outer-spin-button': true,
|
|
386
|
-
'::-webkit-progress-bar': true,
|
|
387
|
-
'::-webkit-progress-inner-element': true,
|
|
388
|
-
'::-webkit-progress-inner-value': true,
|
|
389
|
-
'::-webkit-progress-value': true,
|
|
390
|
-
'::-webkit-resizer': true,
|
|
391
|
-
'::-webkit-scrollbar-button': true,
|
|
392
|
-
'::-webkit-scrollbar-corner': true,
|
|
393
|
-
'::-webkit-scrollbar-thumb': true,
|
|
394
|
-
'::-webkit-scrollbar-track-piece': true,
|
|
395
|
-
'::-webkit-scrollbar-track': true,
|
|
396
|
-
'::-webkit-scrollbar': true,
|
|
397
|
-
'::-webkit-search-cancel-button': true,
|
|
398
|
-
'::-webkit-search-results-button': true,
|
|
399
|
-
'::-webkit-slider-runnable-track': true,
|
|
400
|
-
'::-webkit-slider-thumb': true,
|
|
401
|
-
'::after': true,
|
|
402
|
-
'::backdrop': true,
|
|
403
|
-
'::before': true,
|
|
404
|
-
'::cue': true,
|
|
405
|
-
'::file-selector-button': true,
|
|
406
|
-
'::first-letter': true,
|
|
407
|
-
'::first-line': true,
|
|
408
|
-
'::grammar-error': true,
|
|
409
|
-
'::marker': true,
|
|
410
|
-
'::placeholder': true,
|
|
411
|
-
'::selection': true,
|
|
412
|
-
'::spelling-error': true,
|
|
413
|
-
'::target-text': true,
|
|
414
|
-
'::view-transition-group': true,
|
|
415
|
-
'::view-transition-image-pair': true,
|
|
416
|
-
'::view-transition-new': true,
|
|
417
|
-
'::view-transition-old': true,
|
|
418
|
-
'::view-transition': true,
|
|
419
|
-
':active': true,
|
|
420
|
-
':after': true,
|
|
421
|
-
':any-link': true,
|
|
422
|
-
':before': true,
|
|
423
|
-
':blank': true,
|
|
424
|
-
':checked': true,
|
|
425
|
-
':default': true,
|
|
426
|
-
':defined': true,
|
|
427
|
-
':disabled': true,
|
|
428
|
-
':empty': true,
|
|
429
|
-
':enabled': true,
|
|
430
|
-
':first-child': true,
|
|
431
|
-
':first-letter': true,
|
|
432
|
-
':first-line': true,
|
|
433
|
-
':first-of-type': true,
|
|
434
|
-
':first': true,
|
|
435
|
-
':focus-visible': true,
|
|
436
|
-
':focus-within': true,
|
|
437
|
-
':focus': true,
|
|
438
|
-
':fullscreen': true,
|
|
439
|
-
':hover': true,
|
|
440
|
-
':in-range': true,
|
|
441
|
-
':indeterminate': true,
|
|
442
|
-
':invalid': true,
|
|
443
|
-
':last-child': true,
|
|
444
|
-
':last-of-type': true,
|
|
445
|
-
':left': true,
|
|
446
|
-
':link': true,
|
|
447
|
-
':only-child': true,
|
|
448
|
-
':only-of-type': true,
|
|
449
|
-
':optional': true,
|
|
450
|
-
':out-of-range': true,
|
|
451
|
-
':placeholder-shown': true,
|
|
452
|
-
':read-only': true,
|
|
453
|
-
':read-write': true,
|
|
454
|
-
':required': true,
|
|
455
|
-
':right': true,
|
|
456
|
-
':root': true,
|
|
457
|
-
':scope': true,
|
|
458
|
-
':target': true,
|
|
459
|
-
':valid': true,
|
|
460
|
-
':visited': true
|
|
461
|
-
};
|
|
462
|
-
var simplePseudos = Object.keys(simplePseudoMap);
|
|
463
|
-
var simplePseudoLookup = simplePseudoMap;
|
|
464
|
-
|
|
465
|
-
var _templateObject;
|
|
466
|
-
var createMediaQueryError = (mediaQuery, msg) => new Error(dedent(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n Invalid media query: \"", "\"\n\n ", "\n\n Read more on MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries\n "])), mediaQuery, msg));
|
|
467
|
-
var validateMediaQuery = mediaQuery => {
|
|
468
|
-
// Empty queries will start with '@media '
|
|
469
|
-
if (mediaQuery === '@media ') {
|
|
470
|
-
throw createMediaQueryError(mediaQuery, 'Query is empty');
|
|
471
|
-
}
|
|
472
|
-
try {
|
|
473
|
-
toAST(mediaQuery);
|
|
474
|
-
} catch (e) {
|
|
475
|
-
throw createMediaQueryError(mediaQuery, e.message);
|
|
476
|
-
}
|
|
477
|
-
};
|
|
478
|
-
|
|
479
|
-
var _excluded = ["vars"],
|
|
480
|
-
_excluded2 = ["content"];
|
|
481
|
-
var DECLARATION = '__DECLARATION';
|
|
482
|
-
var UNITLESS = {
|
|
483
|
-
animationIterationCount: true,
|
|
484
|
-
borderImage: true,
|
|
485
|
-
borderImageOutset: true,
|
|
486
|
-
borderImageSlice: true,
|
|
487
|
-
borderImageWidth: true,
|
|
488
|
-
boxFlex: true,
|
|
489
|
-
boxFlexGroup: true,
|
|
490
|
-
columnCount: true,
|
|
491
|
-
columns: true,
|
|
492
|
-
flex: true,
|
|
493
|
-
flexGrow: true,
|
|
494
|
-
flexShrink: true,
|
|
495
|
-
fontWeight: true,
|
|
496
|
-
gridArea: true,
|
|
497
|
-
gridColumn: true,
|
|
498
|
-
gridColumnEnd: true,
|
|
499
|
-
gridColumnStart: true,
|
|
500
|
-
gridRow: true,
|
|
501
|
-
gridRowEnd: true,
|
|
502
|
-
gridRowStart: true,
|
|
503
|
-
initialLetter: true,
|
|
504
|
-
lineClamp: true,
|
|
505
|
-
lineHeight: true,
|
|
506
|
-
maxLines: true,
|
|
507
|
-
opacity: true,
|
|
508
|
-
order: true,
|
|
509
|
-
orphans: true,
|
|
510
|
-
scale: true,
|
|
511
|
-
tabSize: true,
|
|
512
|
-
WebkitLineClamp: true,
|
|
513
|
-
widows: true,
|
|
514
|
-
zIndex: true,
|
|
515
|
-
zoom: true,
|
|
516
|
-
// svg properties
|
|
517
|
-
fillOpacity: true,
|
|
518
|
-
floodOpacity: true,
|
|
519
|
-
maskBorder: true,
|
|
520
|
-
maskBorderOutset: true,
|
|
521
|
-
maskBorderSlice: true,
|
|
522
|
-
maskBorderWidth: true,
|
|
523
|
-
shapeImageThreshold: true,
|
|
524
|
-
stopOpacity: true,
|
|
525
|
-
strokeDashoffset: true,
|
|
526
|
-
strokeMiterlimit: true,
|
|
527
|
-
strokeOpacity: true,
|
|
528
|
-
strokeWidth: true
|
|
529
|
-
};
|
|
530
|
-
function dashify(str) {
|
|
531
|
-
return str.replace(/([A-Z])/g, '-$1').replace(/^ms-/, '-ms-').toLowerCase();
|
|
532
|
-
}
|
|
533
|
-
function replaceBetweenIndexes(target, startIndex, endIndex, replacement) {
|
|
534
|
-
var start = target.slice(0, startIndex);
|
|
535
|
-
var end = target.slice(endIndex);
|
|
536
|
-
return "".concat(start).concat(replacement).concat(end);
|
|
537
|
-
}
|
|
538
|
-
var DOUBLE_SPACE = ' ';
|
|
539
|
-
var specialKeys = [...simplePseudos, '@layer', '@media', '@supports', '@container', 'selectors'];
|
|
540
|
-
class Stylesheet {
|
|
541
|
-
constructor(localClassNames, composedClassLists) {
|
|
542
|
-
this.rules = [];
|
|
543
|
-
this.conditionalRulesets = [new ConditionalRuleset()];
|
|
544
|
-
this.fontFaceRules = [];
|
|
545
|
-
this.keyframesRules = [];
|
|
546
|
-
this.propertyRules = [];
|
|
547
|
-
this.localClassNamesMap = new Map(localClassNames.map(localClassName => [localClassName, localClassName]));
|
|
548
|
-
this.localClassNamesSearch = new AhoCorasick(localClassNames);
|
|
549
|
-
this.layers = new Map();
|
|
550
|
-
|
|
551
|
-
// Class list compositions should be priortized by Newer > Older
|
|
552
|
-
// Therefore we reverse the array as they are added in sequence
|
|
553
|
-
this.composedClassLists = composedClassLists.map(_ref => {
|
|
554
|
-
var {
|
|
555
|
-
identifier,
|
|
556
|
-
classList
|
|
557
|
-
} = _ref;
|
|
558
|
-
return {
|
|
559
|
-
identifier,
|
|
560
|
-
regex: RegExp("(".concat(classList, ")"), 'g')
|
|
561
|
-
};
|
|
562
|
-
}).reverse();
|
|
563
|
-
}
|
|
564
|
-
processCssObj(root) {
|
|
565
|
-
if (root.type === 'fontFace') {
|
|
566
|
-
this.fontFaceRules.push(root.rule);
|
|
567
|
-
return;
|
|
568
|
-
}
|
|
569
|
-
if (root.type === 'property') {
|
|
570
|
-
this.propertyRules.push(root);
|
|
571
|
-
return;
|
|
572
|
-
}
|
|
573
|
-
if (root.type === 'keyframes') {
|
|
574
|
-
root.rule = Object.fromEntries(Object.entries(root.rule).map(_ref2 => {
|
|
575
|
-
var [keyframe, rule] = _ref2;
|
|
576
|
-
return [keyframe, this.transformVars(this.transformProperties(rule))];
|
|
577
|
-
}));
|
|
578
|
-
this.keyframesRules.push(root);
|
|
579
|
-
return;
|
|
580
|
-
}
|
|
581
|
-
this.currConditionalRuleset = new ConditionalRuleset();
|
|
582
|
-
if (root.type === 'layer') {
|
|
583
|
-
var layerDefinition = "@layer ".concat(root.name);
|
|
584
|
-
this.addLayer([layerDefinition]);
|
|
585
|
-
} else {
|
|
586
|
-
// Add main styles
|
|
587
|
-
var mainRule = omit(root.rule, specialKeys);
|
|
588
|
-
this.addRule({
|
|
589
|
-
selector: root.selector,
|
|
590
|
-
rule: mainRule
|
|
591
|
-
});
|
|
592
|
-
this.transformLayer(root, root.rule['@layer']);
|
|
593
|
-
this.transformMedia(root, root.rule['@media']);
|
|
594
|
-
this.transformSupports(root, root.rule['@supports']);
|
|
595
|
-
this.transformContainer(root, root.rule['@container']);
|
|
596
|
-
this.transformSimplePseudos(root, root.rule);
|
|
597
|
-
this.transformSelectors(root, root.rule);
|
|
598
|
-
}
|
|
599
|
-
var activeConditionalRuleset = this.conditionalRulesets[this.conditionalRulesets.length - 1];
|
|
600
|
-
if (!activeConditionalRuleset.mergeIfCompatible(this.currConditionalRuleset)) {
|
|
601
|
-
// Ruleset merge failed due to incompatibility. We now deopt by starting a fresh ConditionalRuleset
|
|
602
|
-
this.conditionalRulesets.push(this.currConditionalRuleset);
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
|
-
addConditionalRule(cssRule, conditions) {
|
|
606
|
-
// Run `transformProperties` before `transformVars` as we don't want to pixelify CSS Vars
|
|
607
|
-
var rule = this.transformVars(this.transformProperties(cssRule.rule));
|
|
608
|
-
var selector = this.transformSelector(cssRule.selector);
|
|
609
|
-
if (!this.currConditionalRuleset) {
|
|
610
|
-
throw new Error("Couldn't add conditional rule");
|
|
611
|
-
}
|
|
612
|
-
var conditionQuery = conditions[conditions.length - 1];
|
|
613
|
-
var parentConditions = conditions.slice(0, conditions.length - 1);
|
|
614
|
-
this.currConditionalRuleset.addRule({
|
|
615
|
-
selector,
|
|
616
|
-
rule
|
|
617
|
-
}, conditionQuery, parentConditions);
|
|
618
|
-
}
|
|
619
|
-
addRule(cssRule) {
|
|
620
|
-
// Run `transformProperties` before `transformVars` as we don't want to pixelify CSS Vars
|
|
621
|
-
var rule = this.transformVars(this.transformProperties(cssRule.rule));
|
|
622
|
-
var selector = this.transformSelector(cssRule.selector);
|
|
623
|
-
this.rules.push({
|
|
624
|
-
selector,
|
|
625
|
-
rule
|
|
626
|
-
});
|
|
627
|
-
}
|
|
628
|
-
addLayer(layer) {
|
|
629
|
-
var uniqueLayerKey = layer.join(' - ');
|
|
630
|
-
this.layers.set(uniqueLayerKey, layer);
|
|
631
|
-
}
|
|
632
|
-
transformProperties(cssRule) {
|
|
633
|
-
return this.transformContent(this.pixelifyProperties(cssRule));
|
|
634
|
-
}
|
|
635
|
-
pixelifyProperties(cssRule) {
|
|
636
|
-
forEach(cssRule, (value, key) => {
|
|
637
|
-
if (typeof value === 'number' && value !== 0 && !UNITLESS[key]) {
|
|
638
|
-
// @ts-expect-error Any ideas?
|
|
639
|
-
cssRule[key] = "".concat(value, "px");
|
|
640
|
-
}
|
|
641
|
-
});
|
|
642
|
-
return cssRule;
|
|
643
|
-
}
|
|
644
|
-
transformVars(_ref3) {
|
|
645
|
-
var {
|
|
646
|
-
vars
|
|
647
|
-
} = _ref3,
|
|
648
|
-
rest = _objectWithoutProperties(_ref3, _excluded);
|
|
649
|
-
if (!vars) {
|
|
650
|
-
return rest;
|
|
651
|
-
}
|
|
652
|
-
return _objectSpread2(_objectSpread2({}, mapKeys(vars, (_value, key) => getVarName(key))), rest);
|
|
653
|
-
}
|
|
654
|
-
transformContent(_ref4) {
|
|
655
|
-
var {
|
|
656
|
-
content
|
|
657
|
-
} = _ref4,
|
|
658
|
-
rest = _objectWithoutProperties(_ref4, _excluded2);
|
|
659
|
-
if (typeof content === 'undefined') {
|
|
660
|
-
return rest;
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
// Handle fallback arrays:
|
|
664
|
-
var contentArray = Array.isArray(content) ? content : [content];
|
|
665
|
-
return _objectSpread2({
|
|
666
|
-
content: contentArray.map(value =>
|
|
667
|
-
// This logic was adapted from Stitches :)
|
|
668
|
-
value && (value.includes('"') || value.includes("'") || /^([A-Za-z\-]+\([^]*|[^]*-quote|inherit|initial|none|normal|revert|unset)(\s|$)/.test(value)) ? value : "\"".concat(value, "\""))
|
|
669
|
-
}, rest);
|
|
670
|
-
}
|
|
671
|
-
transformClassname(identifier) {
|
|
672
|
-
return ".".concat(cssescExports(identifier, {
|
|
673
|
-
isIdentifier: true
|
|
674
|
-
}));
|
|
675
|
-
}
|
|
676
|
-
transformSelector(selector) {
|
|
677
|
-
// Map class list compositions to single identifiers
|
|
678
|
-
var transformedSelector = selector;
|
|
679
|
-
var _loop = function _loop(identifier) {
|
|
680
|
-
transformedSelector = transformedSelector.replace(regex, () => {
|
|
681
|
-
markCompositionUsed(identifier);
|
|
682
|
-
return identifier;
|
|
683
|
-
});
|
|
684
|
-
};
|
|
685
|
-
for (var {
|
|
686
|
-
identifier,
|
|
687
|
-
regex
|
|
688
|
-
} of this.composedClassLists) {
|
|
689
|
-
_loop(identifier);
|
|
690
|
-
}
|
|
691
|
-
if (this.localClassNamesMap.has(transformedSelector)) {
|
|
692
|
-
return this.transformClassname(transformedSelector);
|
|
693
|
-
}
|
|
694
|
-
var results = this.localClassNamesSearch.search(transformedSelector);
|
|
695
|
-
var lastReplaceIndex = transformedSelector.length;
|
|
696
|
-
|
|
697
|
-
// Perform replacements backwards to simplify index handling
|
|
698
|
-
for (var i = results.length - 1; i >= 0; i--) {
|
|
699
|
-
var [endIndex, [firstMatch]] = results[i];
|
|
700
|
-
var startIndex = endIndex - firstMatch.length + 1;
|
|
701
|
-
|
|
702
|
-
// Class names can be substrings of other class names
|
|
703
|
-
// e.g. '_1g1ptzo1' and '_1g1ptzo10'
|
|
704
|
-
//
|
|
705
|
-
// Additionally, concatenated classnames can contain substrings equal to other classnames
|
|
706
|
-
// e.g. '&&' where '&' is 'debugName_hash1' and 'debugName_hash1d' is also a local classname
|
|
707
|
-
// Before transforming the selector, this would look like `debugName_hash1debugName_hash1`
|
|
708
|
-
// which contains the substring `debugName_hash1d`’.
|
|
709
|
-
//
|
|
710
|
-
// In either of these cases, the last replace index will occur either before or within the
|
|
711
|
-
// current replacement range (from `startIndex` to `endIndex`).
|
|
712
|
-
// If this occurs, we skip the replacement to avoid transforming the selector incorrectly.
|
|
713
|
-
var skipReplacement = lastReplaceIndex <= endIndex;
|
|
714
|
-
if (skipReplacement) {
|
|
715
|
-
continue;
|
|
716
|
-
}
|
|
717
|
-
lastReplaceIndex = startIndex;
|
|
718
|
-
|
|
719
|
-
// If class names already starts with a '.' then skip
|
|
720
|
-
if (transformedSelector[startIndex - 1] !== '.') {
|
|
721
|
-
transformedSelector = replaceBetweenIndexes(transformedSelector, startIndex, endIndex + 1, this.transformClassname(firstMatch));
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
return transformedSelector;
|
|
725
|
-
}
|
|
726
|
-
transformSelectors(root, rule, conditions) {
|
|
727
|
-
forEach(rule.selectors, (selectorRule, selector) => {
|
|
728
|
-
if (root.type !== 'local') {
|
|
729
|
-
throw new Error("Selectors are not allowed within ".concat(root.type === 'global' ? '"globalStyle"' : '"selectors"'));
|
|
730
|
-
}
|
|
731
|
-
var transformedSelector = this.transformSelector(selector.replace(RegExp('&', 'g'), root.selector));
|
|
732
|
-
validateSelector(transformedSelector, root.selector);
|
|
733
|
-
var rule = {
|
|
734
|
-
selector: transformedSelector,
|
|
735
|
-
rule: omit(selectorRule, specialKeys)
|
|
736
|
-
};
|
|
737
|
-
if (conditions) {
|
|
738
|
-
this.addConditionalRule(rule, conditions);
|
|
739
|
-
} else {
|
|
740
|
-
this.addRule(rule);
|
|
741
|
-
}
|
|
742
|
-
var selectorRoot = {
|
|
743
|
-
type: 'selector',
|
|
744
|
-
selector: transformedSelector,
|
|
745
|
-
rule: selectorRule
|
|
746
|
-
};
|
|
747
|
-
this.transformLayer(selectorRoot, selectorRule['@layer'], conditions);
|
|
748
|
-
this.transformSupports(selectorRoot, selectorRule['@supports'], conditions);
|
|
749
|
-
this.transformMedia(selectorRoot, selectorRule['@media'], conditions);
|
|
750
|
-
this.transformContainer(selectorRoot, selectorRule['@container'], conditions);
|
|
751
|
-
});
|
|
752
|
-
}
|
|
753
|
-
transformMedia(root, rules) {
|
|
754
|
-
var parentConditions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
755
|
-
if (rules) {
|
|
756
|
-
var _this$currConditional;
|
|
757
|
-
(_this$currConditional = this.currConditionalRuleset) === null || _this$currConditional === void 0 || _this$currConditional.addConditionPrecedence(parentConditions, Object.keys(rules).map(query => "@media ".concat(query)));
|
|
758
|
-
for (var [query, mediaRule] of Object.entries(rules)) {
|
|
759
|
-
var mediaQuery = "@media ".concat(query);
|
|
760
|
-
validateMediaQuery(mediaQuery);
|
|
761
|
-
var conditions = [...parentConditions, mediaQuery];
|
|
762
|
-
this.addConditionalRule({
|
|
763
|
-
selector: root.selector,
|
|
764
|
-
rule: omit(mediaRule, specialKeys)
|
|
765
|
-
}, conditions);
|
|
766
|
-
if (root.type === 'local') {
|
|
767
|
-
this.transformSimplePseudos(root, mediaRule, conditions);
|
|
768
|
-
this.transformSelectors(root, mediaRule, conditions);
|
|
769
|
-
}
|
|
770
|
-
this.transformLayer(root, mediaRule['@layer'], conditions);
|
|
771
|
-
this.transformSupports(root, mediaRule['@supports'], conditions);
|
|
772
|
-
this.transformContainer(root, mediaRule['@container'], conditions);
|
|
773
|
-
}
|
|
774
|
-
}
|
|
775
|
-
}
|
|
776
|
-
transformContainer(root, rules) {
|
|
777
|
-
var parentConditions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
778
|
-
if (rules) {
|
|
779
|
-
var _this$currConditional2;
|
|
780
|
-
(_this$currConditional2 = this.currConditionalRuleset) === null || _this$currConditional2 === void 0 || _this$currConditional2.addConditionPrecedence(parentConditions, Object.keys(rules).map(query => "@container ".concat(query)));
|
|
781
|
-
forEach(rules, (containerRule, query) => {
|
|
782
|
-
var containerQuery = "@container ".concat(query);
|
|
783
|
-
var conditions = [...parentConditions, containerQuery];
|
|
784
|
-
this.addConditionalRule({
|
|
785
|
-
selector: root.selector,
|
|
786
|
-
rule: omit(containerRule, specialKeys)
|
|
787
|
-
}, conditions);
|
|
788
|
-
if (root.type === 'local') {
|
|
789
|
-
this.transformSimplePseudos(root, containerRule, conditions);
|
|
790
|
-
this.transformSelectors(root, containerRule, conditions);
|
|
791
|
-
}
|
|
792
|
-
this.transformLayer(root, containerRule['@layer'], conditions);
|
|
793
|
-
this.transformSupports(root, containerRule['@supports'], conditions);
|
|
794
|
-
this.transformMedia(root, containerRule['@media'], conditions);
|
|
795
|
-
});
|
|
796
|
-
}
|
|
797
|
-
}
|
|
798
|
-
transformLayer(root, rules) {
|
|
799
|
-
var parentConditions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
800
|
-
if (rules) {
|
|
801
|
-
var _this$currConditional3;
|
|
802
|
-
(_this$currConditional3 = this.currConditionalRuleset) === null || _this$currConditional3 === void 0 || _this$currConditional3.addConditionPrecedence(parentConditions, Object.keys(rules).map(name => "@layer ".concat(name)));
|
|
803
|
-
forEach(rules, (layerRule, name) => {
|
|
804
|
-
var conditions = [...parentConditions, "@layer ".concat(name)];
|
|
805
|
-
this.addLayer(conditions);
|
|
806
|
-
this.addConditionalRule({
|
|
807
|
-
selector: root.selector,
|
|
808
|
-
rule: omit(layerRule, specialKeys)
|
|
809
|
-
}, conditions);
|
|
810
|
-
if (root.type === 'local') {
|
|
811
|
-
this.transformSimplePseudos(root, layerRule, conditions);
|
|
812
|
-
this.transformSelectors(root, layerRule, conditions);
|
|
813
|
-
}
|
|
814
|
-
this.transformMedia(root, layerRule['@media'], conditions);
|
|
815
|
-
this.transformSupports(root, layerRule['@supports'], conditions);
|
|
816
|
-
this.transformContainer(root, layerRule['@container'], conditions);
|
|
817
|
-
});
|
|
818
|
-
}
|
|
819
|
-
}
|
|
820
|
-
transformSupports(root, rules) {
|
|
821
|
-
var parentConditions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
822
|
-
if (rules) {
|
|
823
|
-
var _this$currConditional4;
|
|
824
|
-
(_this$currConditional4 = this.currConditionalRuleset) === null || _this$currConditional4 === void 0 || _this$currConditional4.addConditionPrecedence(parentConditions, Object.keys(rules).map(query => "@supports ".concat(query)));
|
|
825
|
-
forEach(rules, (supportsRule, query) => {
|
|
826
|
-
var conditions = [...parentConditions, "@supports ".concat(query)];
|
|
827
|
-
this.addConditionalRule({
|
|
828
|
-
selector: root.selector,
|
|
829
|
-
rule: omit(supportsRule, specialKeys)
|
|
830
|
-
}, conditions);
|
|
831
|
-
if (root.type === 'local') {
|
|
832
|
-
this.transformSimplePseudos(root, supportsRule, conditions);
|
|
833
|
-
this.transformSelectors(root, supportsRule, conditions);
|
|
834
|
-
}
|
|
835
|
-
this.transformLayer(root, supportsRule['@layer'], conditions);
|
|
836
|
-
this.transformMedia(root, supportsRule['@media'], conditions);
|
|
837
|
-
this.transformContainer(root, supportsRule['@container'], conditions);
|
|
838
|
-
});
|
|
839
|
-
}
|
|
840
|
-
}
|
|
841
|
-
transformSimplePseudos(root, rule, conditions) {
|
|
842
|
-
for (var key of Object.keys(rule)) {
|
|
843
|
-
// Process simple pseudos
|
|
844
|
-
if (simplePseudoLookup[key]) {
|
|
845
|
-
if (root.type !== 'local') {
|
|
846
|
-
throw new Error("Simple pseudos are not valid in ".concat(root.type === 'global' ? '"globalStyle"' : '"selectors"'));
|
|
847
|
-
}
|
|
848
|
-
if (conditions) {
|
|
849
|
-
this.addConditionalRule({
|
|
850
|
-
selector: "".concat(root.selector).concat(key),
|
|
851
|
-
rule: rule[key]
|
|
852
|
-
}, conditions);
|
|
853
|
-
} else {
|
|
854
|
-
this.addRule({
|
|
855
|
-
conditions,
|
|
856
|
-
selector: "".concat(root.selector).concat(key),
|
|
857
|
-
rule: rule[key]
|
|
858
|
-
});
|
|
859
|
-
}
|
|
860
|
-
}
|
|
861
|
-
}
|
|
862
|
-
}
|
|
863
|
-
toCss() {
|
|
864
|
-
var css = [];
|
|
865
|
-
|
|
866
|
-
// Render font-face rules
|
|
867
|
-
for (var fontFaceRule of this.fontFaceRules) {
|
|
868
|
-
css.push(renderCss({
|
|
869
|
-
'@font-face': fontFaceRule
|
|
870
|
-
}));
|
|
871
|
-
}
|
|
872
|
-
|
|
873
|
-
// Render property rules
|
|
874
|
-
for (var property of this.propertyRules) {
|
|
875
|
-
css.push(renderCss({
|
|
876
|
-
["@property ".concat(property.name)]: property.rule
|
|
877
|
-
}));
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
// Render keyframes
|
|
881
|
-
for (var keyframe of this.keyframesRules) {
|
|
882
|
-
css.push(renderCss({
|
|
883
|
-
["@keyframes ".concat(keyframe.name)]: keyframe.rule
|
|
884
|
-
}));
|
|
885
|
-
}
|
|
886
|
-
|
|
887
|
-
// Render layer definitions
|
|
888
|
-
for (var layer of this.layers.values()) {
|
|
889
|
-
var [definition, ...nesting] = layer.reverse();
|
|
890
|
-
var cssObj = {
|
|
891
|
-
[definition]: DECLARATION
|
|
892
|
-
};
|
|
893
|
-
for (var part of nesting) {
|
|
894
|
-
cssObj = {
|
|
895
|
-
[part]: cssObj
|
|
896
|
-
};
|
|
897
|
-
}
|
|
898
|
-
css.push(renderCss(cssObj));
|
|
899
|
-
}
|
|
900
|
-
|
|
901
|
-
// Render unconditional rules
|
|
902
|
-
for (var rule of this.rules) {
|
|
903
|
-
css.push(renderCss({
|
|
904
|
-
[rule.selector]: rule.rule
|
|
905
|
-
}));
|
|
906
|
-
}
|
|
907
|
-
|
|
908
|
-
// Render conditional rules
|
|
909
|
-
for (var conditionalRuleset of this.conditionalRulesets) {
|
|
910
|
-
for (var conditionalRule of conditionalRuleset.renderToArray()) {
|
|
911
|
-
css.push(renderCss(conditionalRule));
|
|
912
|
-
}
|
|
913
|
-
}
|
|
914
|
-
return css.filter(Boolean);
|
|
915
|
-
}
|
|
916
|
-
}
|
|
917
|
-
function renderCss(v) {
|
|
918
|
-
var indent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
919
|
-
var rules = [];
|
|
920
|
-
var _loop2 = function _loop2(key) {
|
|
921
|
-
var value = v[key];
|
|
922
|
-
if (value && Array.isArray(value)) {
|
|
923
|
-
rules.push(...value.map(v => renderCss({
|
|
924
|
-
[key]: v
|
|
925
|
-
}, indent)));
|
|
926
|
-
} else if (value && typeof value === 'object') {
|
|
927
|
-
var isEmpty = Object.keys(value).length === 0;
|
|
928
|
-
if (!isEmpty) {
|
|
929
|
-
rules.push("".concat(indent).concat(key, " {\n").concat(renderCss(value, indent + DOUBLE_SPACE), "\n").concat(indent, "}"));
|
|
930
|
-
}
|
|
931
|
-
} else if (value === DECLARATION) {
|
|
932
|
-
rules.push("".concat(indent).concat(key, ";"));
|
|
933
|
-
} else {
|
|
934
|
-
rules.push("".concat(indent).concat(key.startsWith('--') ? key : dashify(key), ": ").concat(value, ";"));
|
|
935
|
-
}
|
|
936
|
-
};
|
|
937
|
-
for (var key of Object.keys(v)) {
|
|
938
|
-
_loop2(key);
|
|
939
|
-
}
|
|
940
|
-
return rules.join('\n');
|
|
941
|
-
}
|
|
942
|
-
function transformCss(_ref5) {
|
|
943
|
-
var {
|
|
944
|
-
localClassNames,
|
|
945
|
-
cssObjs,
|
|
946
|
-
composedClassLists
|
|
947
|
-
} = _ref5;
|
|
948
|
-
var stylesheet = new Stylesheet(localClassNames, composedClassLists);
|
|
949
|
-
for (var root of cssObjs) {
|
|
950
|
-
stylesheet.processCssObj(root);
|
|
951
|
-
}
|
|
952
|
-
return stylesheet.toCss();
|
|
953
|
-
}
|
|
954
|
-
|
|
955
|
-
export { _objectSpread2 as _, _objectWithoutProperties as a, dudupeAndJoinClassList as d, transformCss as t };
|