@cleartrip/ct-design-style-manager 3.1.0-SNAPSHOT-test.6
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/StylingCache/index.d.ts +13 -0
- package/dist/StylingCache/index.d.ts.map +1 -0
- package/dist/ct-design-styleManager.browser.cjs.js +2 -0
- package/dist/ct-design-styleManager.browser.cjs.js.map +1 -0
- package/dist/ct-design-styleManager.browser.esm.js +2 -0
- package/dist/ct-design-styleManager.browser.esm.js.map +1 -0
- package/dist/ct-design-styleManager.cjs.js +411 -0
- package/dist/ct-design-styleManager.cjs.js.map +1 -0
- package/dist/ct-design-styleManager.esm.js +403 -0
- package/dist/ct-design-styleManager.esm.js.map +1 -0
- package/dist/ct-design-styleManager.umd.js +829 -0
- package/dist/ct-design-styleManager.umd.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/makeStyles/index.d.ts +7 -0
- package/dist/makeStyles/index.d.ts.map +1 -0
- package/dist/makeStyles/preprocess/index.d.ts +7 -0
- package/dist/makeStyles/preprocess/index.d.ts.map +1 -0
- package/dist/makeStyles/validate/index.d.ts +2 -0
- package/dist/makeStyles/validate/index.d.ts.map +1 -0
- package/dist/useStableMemo/index.d.ts +4 -0
- package/dist/useStableMemo/index.d.ts.map +1 -0
- package/dist/useStyles/index.d.ts +7 -0
- package/dist/useStyles/index.d.ts.map +1 -0
- package/dist/useWebMergeStyles/index.d.ts +5 -0
- package/dist/useWebMergeStyles/index.d.ts.map +1 -0
- package/package.json +38 -0
|
@@ -0,0 +1,829 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@cleartrip/ct-design-theme'), require('react'), require('@emotion/css')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', '@cleartrip/ct-design-theme', 'react', '@emotion/css'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.CTDesignSystem = {}, global.ctDesignTheme, global.React, global.css));
|
|
5
|
+
})(this, (function (exports, ctDesignTheme, react, css) { 'use strict';
|
|
6
|
+
|
|
7
|
+
var useStableMemo = function (callback, deps) {
|
|
8
|
+
return react.useMemo(function () {
|
|
9
|
+
return callback();
|
|
10
|
+
}, deps);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
function normalizeColor(color) {
|
|
14
|
+
{
|
|
15
|
+
return color;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
var isWebColor = function (color) {
|
|
19
|
+
return color === 'currentcolor' || color === 'currentColor' || color === 'inherit' || color.indexOf('var(') === 0;
|
|
20
|
+
};
|
|
21
|
+
var normalizeColorWrapper = function (color, opacity) {
|
|
22
|
+
if (color == null)
|
|
23
|
+
return;
|
|
24
|
+
if (typeof color === 'string' && isWebColor(color)) {
|
|
25
|
+
return color;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
var colorProps = {
|
|
29
|
+
backgroundColor: true,
|
|
30
|
+
borderColor: true,
|
|
31
|
+
borderTopColor: true,
|
|
32
|
+
borderRightColor: true,
|
|
33
|
+
borderBottomColor: true,
|
|
34
|
+
borderLeftColor: true,
|
|
35
|
+
color: true,
|
|
36
|
+
shadowColor: true,
|
|
37
|
+
textDecorationColor: true,
|
|
38
|
+
textShadowColor: true,
|
|
39
|
+
};
|
|
40
|
+
var unitlessNumbers = {
|
|
41
|
+
animationIterationCount: true,
|
|
42
|
+
aspectRatio: true,
|
|
43
|
+
borderImageOutset: true,
|
|
44
|
+
borderImageSlice: true,
|
|
45
|
+
borderImageWidth: true,
|
|
46
|
+
boxFlex: true,
|
|
47
|
+
boxFlexGroup: true,
|
|
48
|
+
boxOrdinalGroup: true,
|
|
49
|
+
columnCount: true,
|
|
50
|
+
flex: true,
|
|
51
|
+
flexGrow: true,
|
|
52
|
+
flexOrder: true,
|
|
53
|
+
flexPositive: true,
|
|
54
|
+
flexShrink: true,
|
|
55
|
+
flexNegative: true,
|
|
56
|
+
fontWeight: true,
|
|
57
|
+
gridRow: true,
|
|
58
|
+
gridRowEnd: true,
|
|
59
|
+
gridRowGap: true,
|
|
60
|
+
gridRowStart: true,
|
|
61
|
+
gridColumn: true,
|
|
62
|
+
gridColumnEnd: true,
|
|
63
|
+
gridColumnGap: true,
|
|
64
|
+
gridColumnStart: true,
|
|
65
|
+
lineClamp: true,
|
|
66
|
+
opacity: true,
|
|
67
|
+
order: true,
|
|
68
|
+
orphans: true,
|
|
69
|
+
tabSize: true,
|
|
70
|
+
widows: true,
|
|
71
|
+
zIndex: true,
|
|
72
|
+
zoom: true,
|
|
73
|
+
fillOpacity: true,
|
|
74
|
+
floodOpacity: true,
|
|
75
|
+
stopOpacity: true,
|
|
76
|
+
strokeDasharray: true,
|
|
77
|
+
strokeDashoffset: true,
|
|
78
|
+
strokeMiterlimit: true,
|
|
79
|
+
strokeOpacity: true,
|
|
80
|
+
strokeWidth: true,
|
|
81
|
+
scale: true,
|
|
82
|
+
scaleX: true,
|
|
83
|
+
scaleY: true,
|
|
84
|
+
scaleZ: true,
|
|
85
|
+
shadowOpacity: true,
|
|
86
|
+
};
|
|
87
|
+
function normalizeValueWithProperty(value, property) {
|
|
88
|
+
var returnValue = value;
|
|
89
|
+
if ((property == null || !unitlessNumbers[property]) && typeof value === 'number') {
|
|
90
|
+
returnValue = "".concat(value, "px");
|
|
91
|
+
}
|
|
92
|
+
else if (property != null && colorProps[property]) {
|
|
93
|
+
returnValue = normalizeColor(value);
|
|
94
|
+
}
|
|
95
|
+
return returnValue;
|
|
96
|
+
}
|
|
97
|
+
var emptyObject = {};
|
|
98
|
+
var defaultOffset = { height: 0, width: 0 };
|
|
99
|
+
var createBoxShadowValue = function (style) {
|
|
100
|
+
var shadowColor = style.shadowColor, shadowOffset = style.shadowOffset; style.shadowOpacity; var shadowRadius = style.shadowRadius;
|
|
101
|
+
var _a = shadowOffset || defaultOffset, height = _a.height, width = _a.width;
|
|
102
|
+
var offsetX = normalizeValueWithProperty(width);
|
|
103
|
+
var offsetY = normalizeValueWithProperty(height);
|
|
104
|
+
var blurRadius = normalizeValueWithProperty(shadowRadius || 0);
|
|
105
|
+
var color = normalizeColorWrapper(shadowColor || 'black');
|
|
106
|
+
if (color != null && offsetX != null && offsetY != null && blurRadius != null) {
|
|
107
|
+
return "".concat(offsetX, " ").concat(offsetY, " ").concat(blurRadius, " ").concat(color);
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
var createTextShadowValue = function (style) {
|
|
111
|
+
var textShadowColor = style.textShadowColor, textShadowOffset = style.textShadowOffset, textShadowRadius = style.textShadowRadius;
|
|
112
|
+
var _a = textShadowOffset || defaultOffset, height = _a.height, width = _a.width;
|
|
113
|
+
var radius = textShadowRadius || 0;
|
|
114
|
+
var offsetX = normalizeValueWithProperty(width);
|
|
115
|
+
var offsetY = normalizeValueWithProperty(height);
|
|
116
|
+
var blurRadius = normalizeValueWithProperty(radius);
|
|
117
|
+
var color = normalizeValueWithProperty(textShadowColor, 'textShadowColor');
|
|
118
|
+
if (color &&
|
|
119
|
+
(height !== 0 || width !== 0 || radius !== 0) &&
|
|
120
|
+
offsetX != null &&
|
|
121
|
+
offsetY != null &&
|
|
122
|
+
blurRadius != null) {
|
|
123
|
+
return "".concat(offsetX, " ").concat(offsetY, " ").concat(blurRadius, " ").concat(color);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
var mapTransform = function (transform) {
|
|
127
|
+
var type = Object.keys(transform)[0];
|
|
128
|
+
var value = transform[type];
|
|
129
|
+
if (type === 'matrix' || type === 'matrix3d') {
|
|
130
|
+
return "".concat(type, "(").concat(value.join(','), ")");
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
var normalizedValue = normalizeValueWithProperty(value, type);
|
|
134
|
+
return "".concat(type, "(").concat(normalizedValue, ")");
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
var createTransformValue = function (value) {
|
|
138
|
+
return value.map(mapTransform).join(' ');
|
|
139
|
+
};
|
|
140
|
+
var PROPERTIES_STANDARD = {
|
|
141
|
+
borderBottomEndRadius: 'borderEndEndRadius',
|
|
142
|
+
borderBottomStartRadius: 'borderEndStartRadius',
|
|
143
|
+
borderTopEndRadius: 'borderStartEndRadius',
|
|
144
|
+
borderTopStartRadius: 'borderStartStartRadius',
|
|
145
|
+
borderEndColor: 'borderInlineEndColor',
|
|
146
|
+
borderEndStyle: 'borderInlineEndStyle',
|
|
147
|
+
borderEndWidth: 'borderInlineEndWidth',
|
|
148
|
+
borderStartColor: 'borderInlineStartColor',
|
|
149
|
+
borderStartStyle: 'borderInlineStartStyle',
|
|
150
|
+
borderStartWidth: 'borderInlineStartWidth',
|
|
151
|
+
end: 'insetInlineEnd',
|
|
152
|
+
marginEnd: 'marginInlineEnd',
|
|
153
|
+
marginHorizontal: 'marginInline',
|
|
154
|
+
marginStart: 'marginInlineStart',
|
|
155
|
+
marginVertical: 'marginBlock',
|
|
156
|
+
paddingEnd: 'paddingInlineEnd',
|
|
157
|
+
paddingHorizontal: 'paddingInline',
|
|
158
|
+
paddingStart: 'paddingInlineStart',
|
|
159
|
+
paddingVertical: 'paddingBlock',
|
|
160
|
+
start: 'insetInlineStart',
|
|
161
|
+
};
|
|
162
|
+
var ignoredProps = {
|
|
163
|
+
elevation: true,
|
|
164
|
+
overlayColor: true,
|
|
165
|
+
resizeMode: true,
|
|
166
|
+
tintColor: true,
|
|
167
|
+
};
|
|
168
|
+
var preprocess = function (originalStyle, options) {
|
|
169
|
+
if (options === void 0) { options = {}; }
|
|
170
|
+
var style = originalStyle || emptyObject;
|
|
171
|
+
var nextStyle = {};
|
|
172
|
+
if ((options.shadow === true,
|
|
173
|
+
style.shadowColor != null ||
|
|
174
|
+
style.shadowOffset != null ||
|
|
175
|
+
style.shadowOpacity != null ||
|
|
176
|
+
style.shadowRadius != null)) {
|
|
177
|
+
var boxShadowValue = createBoxShadowValue(style);
|
|
178
|
+
if (boxShadowValue != null && nextStyle.boxShadow == null) {
|
|
179
|
+
var boxShadow = style.boxShadow;
|
|
180
|
+
var value = boxShadow ? "".concat(boxShadow, ", ").concat(boxShadowValue) : boxShadowValue;
|
|
181
|
+
nextStyle.boxShadow = value;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
if ((options.textShadow === true && style.textShadowColor != null) ||
|
|
185
|
+
style.textShadowOffset != null ||
|
|
186
|
+
style.textShadowRadius != null) {
|
|
187
|
+
var textShadowValue = createTextShadowValue(style);
|
|
188
|
+
if (textShadowValue != null && nextStyle.textShadow == null) {
|
|
189
|
+
var textShadow = style.textShadow;
|
|
190
|
+
var value = textShadow ? "".concat(textShadow, ", ").concat(textShadowValue) : textShadowValue;
|
|
191
|
+
nextStyle.textShadow = value;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
for (var originalProp in style) {
|
|
195
|
+
if (ignoredProps[originalProp] != null ||
|
|
196
|
+
originalProp === 'shadowColor' ||
|
|
197
|
+
originalProp === 'shadowOffset' ||
|
|
198
|
+
originalProp === 'shadowOpacity' ||
|
|
199
|
+
originalProp === 'shadowRadius' ||
|
|
200
|
+
originalProp === 'textShadowColor' ||
|
|
201
|
+
originalProp === 'textShadowOffset' ||
|
|
202
|
+
originalProp === 'textShadowRadius') {
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
var originalValue = style[originalProp];
|
|
206
|
+
var prop = PROPERTIES_STANDARD[originalProp] || originalProp;
|
|
207
|
+
var value = originalValue;
|
|
208
|
+
if (!Object.prototype.hasOwnProperty.call(style, originalProp) || (prop !== originalProp && style[prop] != null)) {
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
if (prop === 'aspectRatio' && typeof value === 'number') {
|
|
212
|
+
nextStyle[prop] = value.toString();
|
|
213
|
+
}
|
|
214
|
+
else if (prop === 'fontVariant') {
|
|
215
|
+
if (Array.isArray(value) && value.length > 0) {
|
|
216
|
+
value = value.join(' ');
|
|
217
|
+
}
|
|
218
|
+
nextStyle[prop] = value;
|
|
219
|
+
}
|
|
220
|
+
else if (prop === 'textAlignVertical') {
|
|
221
|
+
if (style.verticalAlign == null) {
|
|
222
|
+
nextStyle.verticalAlign = value === 'center' ? 'middle' : value;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
else if (prop === 'transform') {
|
|
226
|
+
if (Array.isArray(value)) {
|
|
227
|
+
value = createTransformValue(value);
|
|
228
|
+
}
|
|
229
|
+
nextStyle.transform = value;
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
nextStyle[prop] = normalizeValueWithProperty(value, prop);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return nextStyle;
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
var openParentheses = "(".charCodeAt(0);
|
|
239
|
+
var closeParentheses = ")".charCodeAt(0);
|
|
240
|
+
var singleQuote = "'".charCodeAt(0);
|
|
241
|
+
var doubleQuote = '"'.charCodeAt(0);
|
|
242
|
+
var backslash = "\\".charCodeAt(0);
|
|
243
|
+
var slash = "/".charCodeAt(0);
|
|
244
|
+
var comma = ",".charCodeAt(0);
|
|
245
|
+
var colon = ":".charCodeAt(0);
|
|
246
|
+
var star = "*".charCodeAt(0);
|
|
247
|
+
var uLower = "u".charCodeAt(0);
|
|
248
|
+
var uUpper = "U".charCodeAt(0);
|
|
249
|
+
var plus = "+".charCodeAt(0);
|
|
250
|
+
var isUnicodeRange = /^[a-f0-9?-]+$/i;
|
|
251
|
+
var parse$1 = function (input) {
|
|
252
|
+
var tokens = [];
|
|
253
|
+
var value = input;
|
|
254
|
+
var next, quote, prev, token, escape, escapePos, whitespacePos, parenthesesOpenPos;
|
|
255
|
+
var pos = 0;
|
|
256
|
+
var code = value.charCodeAt(pos);
|
|
257
|
+
var max = value.length;
|
|
258
|
+
var stack = [{
|
|
259
|
+
nodes: tokens
|
|
260
|
+
}];
|
|
261
|
+
var balanced = 0;
|
|
262
|
+
var parent;
|
|
263
|
+
var name = "";
|
|
264
|
+
var before = "";
|
|
265
|
+
var after = "";
|
|
266
|
+
while (pos < max) {
|
|
267
|
+
// Whitespaces
|
|
268
|
+
if (code <= 32) {
|
|
269
|
+
next = pos;
|
|
270
|
+
do {
|
|
271
|
+
next += 1;
|
|
272
|
+
code = value.charCodeAt(next);
|
|
273
|
+
} while (code <= 32);
|
|
274
|
+
token = value.slice(pos, next);
|
|
275
|
+
prev = tokens[tokens.length - 1];
|
|
276
|
+
if (code === closeParentheses && balanced) {
|
|
277
|
+
after = token;
|
|
278
|
+
} else if (prev && prev.type === "div") {
|
|
279
|
+
prev.after = token;
|
|
280
|
+
prev.sourceEndIndex += token.length;
|
|
281
|
+
} else if (code === comma || code === colon || code === slash && value.charCodeAt(next + 1) !== star && (!parent || parent && parent.type === "function" && parent.value !== "calc")) {
|
|
282
|
+
before = token;
|
|
283
|
+
} else {
|
|
284
|
+
tokens.push({
|
|
285
|
+
type: "space",
|
|
286
|
+
sourceIndex: pos,
|
|
287
|
+
sourceEndIndex: next,
|
|
288
|
+
value: token
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
pos = next;
|
|
292
|
+
|
|
293
|
+
// Quotes
|
|
294
|
+
} else if (code === singleQuote || code === doubleQuote) {
|
|
295
|
+
next = pos;
|
|
296
|
+
quote = code === singleQuote ? "'" : '"';
|
|
297
|
+
token = {
|
|
298
|
+
type: "string",
|
|
299
|
+
sourceIndex: pos,
|
|
300
|
+
quote: quote
|
|
301
|
+
};
|
|
302
|
+
do {
|
|
303
|
+
escape = false;
|
|
304
|
+
next = value.indexOf(quote, next + 1);
|
|
305
|
+
if (~next) {
|
|
306
|
+
escapePos = next;
|
|
307
|
+
while (value.charCodeAt(escapePos - 1) === backslash) {
|
|
308
|
+
escapePos -= 1;
|
|
309
|
+
escape = !escape;
|
|
310
|
+
}
|
|
311
|
+
} else {
|
|
312
|
+
value += quote;
|
|
313
|
+
next = value.length - 1;
|
|
314
|
+
token.unclosed = true;
|
|
315
|
+
}
|
|
316
|
+
} while (escape);
|
|
317
|
+
token.value = value.slice(pos + 1, next);
|
|
318
|
+
token.sourceEndIndex = token.unclosed ? next : next + 1;
|
|
319
|
+
tokens.push(token);
|
|
320
|
+
pos = next + 1;
|
|
321
|
+
code = value.charCodeAt(pos);
|
|
322
|
+
|
|
323
|
+
// Comments
|
|
324
|
+
} else if (code === slash && value.charCodeAt(pos + 1) === star) {
|
|
325
|
+
next = value.indexOf("*/", pos);
|
|
326
|
+
token = {
|
|
327
|
+
type: "comment",
|
|
328
|
+
sourceIndex: pos,
|
|
329
|
+
sourceEndIndex: next + 2
|
|
330
|
+
};
|
|
331
|
+
if (next === -1) {
|
|
332
|
+
token.unclosed = true;
|
|
333
|
+
next = value.length;
|
|
334
|
+
token.sourceEndIndex = next;
|
|
335
|
+
}
|
|
336
|
+
token.value = value.slice(pos + 2, next);
|
|
337
|
+
tokens.push(token);
|
|
338
|
+
pos = next + 2;
|
|
339
|
+
code = value.charCodeAt(pos);
|
|
340
|
+
|
|
341
|
+
// Operation within calc
|
|
342
|
+
} else if ((code === slash || code === star) && parent && parent.type === "function" && parent.value === "calc") {
|
|
343
|
+
token = value[pos];
|
|
344
|
+
tokens.push({
|
|
345
|
+
type: "word",
|
|
346
|
+
sourceIndex: pos - before.length,
|
|
347
|
+
sourceEndIndex: pos + token.length,
|
|
348
|
+
value: token
|
|
349
|
+
});
|
|
350
|
+
pos += 1;
|
|
351
|
+
code = value.charCodeAt(pos);
|
|
352
|
+
|
|
353
|
+
// Dividers
|
|
354
|
+
} else if (code === slash || code === comma || code === colon) {
|
|
355
|
+
token = value[pos];
|
|
356
|
+
tokens.push({
|
|
357
|
+
type: "div",
|
|
358
|
+
sourceIndex: pos - before.length,
|
|
359
|
+
sourceEndIndex: pos + token.length,
|
|
360
|
+
value: token,
|
|
361
|
+
before: before,
|
|
362
|
+
after: ""
|
|
363
|
+
});
|
|
364
|
+
before = "";
|
|
365
|
+
pos += 1;
|
|
366
|
+
code = value.charCodeAt(pos);
|
|
367
|
+
|
|
368
|
+
// Open parentheses
|
|
369
|
+
} else if (openParentheses === code) {
|
|
370
|
+
// Whitespaces after open parentheses
|
|
371
|
+
next = pos;
|
|
372
|
+
do {
|
|
373
|
+
next += 1;
|
|
374
|
+
code = value.charCodeAt(next);
|
|
375
|
+
} while (code <= 32);
|
|
376
|
+
parenthesesOpenPos = pos;
|
|
377
|
+
token = {
|
|
378
|
+
type: "function",
|
|
379
|
+
sourceIndex: pos - name.length,
|
|
380
|
+
value: name,
|
|
381
|
+
before: value.slice(parenthesesOpenPos + 1, next)
|
|
382
|
+
};
|
|
383
|
+
pos = next;
|
|
384
|
+
if (name === "url" && code !== singleQuote && code !== doubleQuote) {
|
|
385
|
+
next -= 1;
|
|
386
|
+
do {
|
|
387
|
+
escape = false;
|
|
388
|
+
next = value.indexOf(")", next + 1);
|
|
389
|
+
if (~next) {
|
|
390
|
+
escapePos = next;
|
|
391
|
+
while (value.charCodeAt(escapePos - 1) === backslash) {
|
|
392
|
+
escapePos -= 1;
|
|
393
|
+
escape = !escape;
|
|
394
|
+
}
|
|
395
|
+
} else {
|
|
396
|
+
value += ")";
|
|
397
|
+
next = value.length - 1;
|
|
398
|
+
token.unclosed = true;
|
|
399
|
+
}
|
|
400
|
+
} while (escape);
|
|
401
|
+
// Whitespaces before closed
|
|
402
|
+
whitespacePos = next;
|
|
403
|
+
do {
|
|
404
|
+
whitespacePos -= 1;
|
|
405
|
+
code = value.charCodeAt(whitespacePos);
|
|
406
|
+
} while (code <= 32);
|
|
407
|
+
if (parenthesesOpenPos < whitespacePos) {
|
|
408
|
+
if (pos !== whitespacePos + 1) {
|
|
409
|
+
token.nodes = [{
|
|
410
|
+
type: "word",
|
|
411
|
+
sourceIndex: pos,
|
|
412
|
+
sourceEndIndex: whitespacePos + 1,
|
|
413
|
+
value: value.slice(pos, whitespacePos + 1)
|
|
414
|
+
}];
|
|
415
|
+
} else {
|
|
416
|
+
token.nodes = [];
|
|
417
|
+
}
|
|
418
|
+
if (token.unclosed && whitespacePos + 1 !== next) {
|
|
419
|
+
token.after = "";
|
|
420
|
+
token.nodes.push({
|
|
421
|
+
type: "space",
|
|
422
|
+
sourceIndex: whitespacePos + 1,
|
|
423
|
+
sourceEndIndex: next,
|
|
424
|
+
value: value.slice(whitespacePos + 1, next)
|
|
425
|
+
});
|
|
426
|
+
} else {
|
|
427
|
+
token.after = value.slice(whitespacePos + 1, next);
|
|
428
|
+
token.sourceEndIndex = next;
|
|
429
|
+
}
|
|
430
|
+
} else {
|
|
431
|
+
token.after = "";
|
|
432
|
+
token.nodes = [];
|
|
433
|
+
}
|
|
434
|
+
pos = next + 1;
|
|
435
|
+
token.sourceEndIndex = token.unclosed ? next : pos;
|
|
436
|
+
code = value.charCodeAt(pos);
|
|
437
|
+
tokens.push(token);
|
|
438
|
+
} else {
|
|
439
|
+
balanced += 1;
|
|
440
|
+
token.after = "";
|
|
441
|
+
token.sourceEndIndex = pos + 1;
|
|
442
|
+
tokens.push(token);
|
|
443
|
+
stack.push(token);
|
|
444
|
+
tokens = token.nodes = [];
|
|
445
|
+
parent = token;
|
|
446
|
+
}
|
|
447
|
+
name = "";
|
|
448
|
+
|
|
449
|
+
// Close parentheses
|
|
450
|
+
} else if (closeParentheses === code && balanced) {
|
|
451
|
+
pos += 1;
|
|
452
|
+
code = value.charCodeAt(pos);
|
|
453
|
+
parent.after = after;
|
|
454
|
+
parent.sourceEndIndex += after.length;
|
|
455
|
+
after = "";
|
|
456
|
+
balanced -= 1;
|
|
457
|
+
stack[stack.length - 1].sourceEndIndex = pos;
|
|
458
|
+
stack.pop();
|
|
459
|
+
parent = stack[balanced];
|
|
460
|
+
tokens = parent.nodes;
|
|
461
|
+
|
|
462
|
+
// Words
|
|
463
|
+
} else {
|
|
464
|
+
next = pos;
|
|
465
|
+
do {
|
|
466
|
+
if (code === backslash) {
|
|
467
|
+
next += 1;
|
|
468
|
+
}
|
|
469
|
+
next += 1;
|
|
470
|
+
code = value.charCodeAt(next);
|
|
471
|
+
} while (next < max && !(code <= 32 || code === singleQuote || code === doubleQuote || code === comma || code === colon || code === slash || code === openParentheses || code === star && parent && parent.type === "function" && parent.value === "calc" || code === slash && parent.type === "function" && parent.value === "calc" || code === closeParentheses && balanced));
|
|
472
|
+
token = value.slice(pos, next);
|
|
473
|
+
if (openParentheses === code) {
|
|
474
|
+
name = token;
|
|
475
|
+
} else if ((uLower === token.charCodeAt(0) || uUpper === token.charCodeAt(0)) && plus === token.charCodeAt(1) && isUnicodeRange.test(token.slice(2))) {
|
|
476
|
+
tokens.push({
|
|
477
|
+
type: "unicode-range",
|
|
478
|
+
sourceIndex: pos,
|
|
479
|
+
sourceEndIndex: next,
|
|
480
|
+
value: token
|
|
481
|
+
});
|
|
482
|
+
} else {
|
|
483
|
+
tokens.push({
|
|
484
|
+
type: "word",
|
|
485
|
+
sourceIndex: pos,
|
|
486
|
+
sourceEndIndex: next,
|
|
487
|
+
value: token
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
pos = next;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
for (pos = stack.length - 1; pos; pos -= 1) {
|
|
494
|
+
stack[pos].unclosed = true;
|
|
495
|
+
stack[pos].sourceEndIndex = value.length;
|
|
496
|
+
}
|
|
497
|
+
return stack[0].nodes;
|
|
498
|
+
};
|
|
499
|
+
|
|
500
|
+
var walk$1 = function walk(nodes, cb, bubble) {
|
|
501
|
+
var i, max, node, result;
|
|
502
|
+
for (i = 0, max = nodes.length; i < max; i += 1) {
|
|
503
|
+
node = nodes[i];
|
|
504
|
+
if (!bubble) {
|
|
505
|
+
result = cb(node, i, nodes);
|
|
506
|
+
}
|
|
507
|
+
if (result !== false && node.type === "function" && Array.isArray(node.nodes)) {
|
|
508
|
+
walk(node.nodes, cb, bubble);
|
|
509
|
+
}
|
|
510
|
+
if (bubble) {
|
|
511
|
+
cb(node, i, nodes);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
};
|
|
515
|
+
|
|
516
|
+
function stringifyNode(node, custom) {
|
|
517
|
+
var type = node.type;
|
|
518
|
+
var value = node.value;
|
|
519
|
+
var buf;
|
|
520
|
+
var customResult;
|
|
521
|
+
if (custom && (customResult = custom(node)) !== undefined) {
|
|
522
|
+
return customResult;
|
|
523
|
+
} else if (type === "word" || type === "space") {
|
|
524
|
+
return value;
|
|
525
|
+
} else if (type === "string") {
|
|
526
|
+
buf = node.quote || "";
|
|
527
|
+
return buf + value + (node.unclosed ? "" : buf);
|
|
528
|
+
} else if (type === "comment") {
|
|
529
|
+
return "/*" + value + (node.unclosed ? "" : "*/");
|
|
530
|
+
} else if (type === "div") {
|
|
531
|
+
return (node.before || "") + value + (node.after || "");
|
|
532
|
+
} else if (Array.isArray(node.nodes)) {
|
|
533
|
+
buf = stringify$1(node.nodes, custom);
|
|
534
|
+
if (type !== "function") {
|
|
535
|
+
return buf;
|
|
536
|
+
}
|
|
537
|
+
return value + "(" + (node.before || "") + buf + (node.after || "") + (node.unclosed ? "" : ")");
|
|
538
|
+
}
|
|
539
|
+
return value;
|
|
540
|
+
}
|
|
541
|
+
function stringify$1(nodes, custom) {
|
|
542
|
+
var result, i;
|
|
543
|
+
if (Array.isArray(nodes)) {
|
|
544
|
+
result = "";
|
|
545
|
+
for (i = nodes.length - 1; ~i; i -= 1) {
|
|
546
|
+
result = stringifyNode(nodes[i], custom) + result;
|
|
547
|
+
}
|
|
548
|
+
return result;
|
|
549
|
+
}
|
|
550
|
+
return stringifyNode(nodes, custom);
|
|
551
|
+
}
|
|
552
|
+
var stringify_1 = stringify$1;
|
|
553
|
+
|
|
554
|
+
var unit;
|
|
555
|
+
var hasRequiredUnit;
|
|
556
|
+
function requireUnit() {
|
|
557
|
+
if (hasRequiredUnit) return unit;
|
|
558
|
+
hasRequiredUnit = 1;
|
|
559
|
+
var minus = "-".charCodeAt(0);
|
|
560
|
+
var plus = "+".charCodeAt(0);
|
|
561
|
+
var dot = ".".charCodeAt(0);
|
|
562
|
+
var exp = "e".charCodeAt(0);
|
|
563
|
+
var EXP = "E".charCodeAt(0);
|
|
564
|
+
|
|
565
|
+
// Check if three code points would start a number
|
|
566
|
+
// https://www.w3.org/TR/css-syntax-3/#starts-with-a-number
|
|
567
|
+
function likeNumber(value) {
|
|
568
|
+
var code = value.charCodeAt(0);
|
|
569
|
+
var nextCode;
|
|
570
|
+
if (code === plus || code === minus) {
|
|
571
|
+
nextCode = value.charCodeAt(1);
|
|
572
|
+
if (nextCode >= 48 && nextCode <= 57) {
|
|
573
|
+
return true;
|
|
574
|
+
}
|
|
575
|
+
var nextNextCode = value.charCodeAt(2);
|
|
576
|
+
if (nextCode === dot && nextNextCode >= 48 && nextNextCode <= 57) {
|
|
577
|
+
return true;
|
|
578
|
+
}
|
|
579
|
+
return false;
|
|
580
|
+
}
|
|
581
|
+
if (code === dot) {
|
|
582
|
+
nextCode = value.charCodeAt(1);
|
|
583
|
+
if (nextCode >= 48 && nextCode <= 57) {
|
|
584
|
+
return true;
|
|
585
|
+
}
|
|
586
|
+
return false;
|
|
587
|
+
}
|
|
588
|
+
if (code >= 48 && code <= 57) {
|
|
589
|
+
return true;
|
|
590
|
+
}
|
|
591
|
+
return false;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
// Consume a number
|
|
595
|
+
// https://www.w3.org/TR/css-syntax-3/#consume-number
|
|
596
|
+
unit = function (value) {
|
|
597
|
+
var pos = 0;
|
|
598
|
+
var length = value.length;
|
|
599
|
+
var code;
|
|
600
|
+
var nextCode;
|
|
601
|
+
var nextNextCode;
|
|
602
|
+
if (length === 0 || !likeNumber(value)) {
|
|
603
|
+
return false;
|
|
604
|
+
}
|
|
605
|
+
code = value.charCodeAt(pos);
|
|
606
|
+
if (code === plus || code === minus) {
|
|
607
|
+
pos++;
|
|
608
|
+
}
|
|
609
|
+
while (pos < length) {
|
|
610
|
+
code = value.charCodeAt(pos);
|
|
611
|
+
if (code < 48 || code > 57) {
|
|
612
|
+
break;
|
|
613
|
+
}
|
|
614
|
+
pos += 1;
|
|
615
|
+
}
|
|
616
|
+
code = value.charCodeAt(pos);
|
|
617
|
+
nextCode = value.charCodeAt(pos + 1);
|
|
618
|
+
if (code === dot && nextCode >= 48 && nextCode <= 57) {
|
|
619
|
+
pos += 2;
|
|
620
|
+
while (pos < length) {
|
|
621
|
+
code = value.charCodeAt(pos);
|
|
622
|
+
if (code < 48 || code > 57) {
|
|
623
|
+
break;
|
|
624
|
+
}
|
|
625
|
+
pos += 1;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
code = value.charCodeAt(pos);
|
|
629
|
+
nextCode = value.charCodeAt(pos + 1);
|
|
630
|
+
nextNextCode = value.charCodeAt(pos + 2);
|
|
631
|
+
if ((code === exp || code === EXP) && (nextCode >= 48 && nextCode <= 57 || (nextCode === plus || nextCode === minus) && nextNextCode >= 48 && nextNextCode <= 57)) {
|
|
632
|
+
pos += nextCode === plus || nextCode === minus ? 3 : 2;
|
|
633
|
+
while (pos < length) {
|
|
634
|
+
code = value.charCodeAt(pos);
|
|
635
|
+
if (code < 48 || code > 57) {
|
|
636
|
+
break;
|
|
637
|
+
}
|
|
638
|
+
pos += 1;
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
return {
|
|
642
|
+
number: value.slice(0, pos),
|
|
643
|
+
unit: value.slice(pos)
|
|
644
|
+
};
|
|
645
|
+
};
|
|
646
|
+
return unit;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
var parse = parse$1;
|
|
650
|
+
var walk = walk$1;
|
|
651
|
+
var stringify = stringify_1;
|
|
652
|
+
function ValueParser(value) {
|
|
653
|
+
if (this instanceof ValueParser) {
|
|
654
|
+
this.nodes = parse(value);
|
|
655
|
+
return this;
|
|
656
|
+
}
|
|
657
|
+
return new ValueParser(value);
|
|
658
|
+
}
|
|
659
|
+
ValueParser.prototype.toString = function () {
|
|
660
|
+
return Array.isArray(this.nodes) ? stringify(this.nodes) : "";
|
|
661
|
+
};
|
|
662
|
+
ValueParser.prototype.walk = function (cb, bubble) {
|
|
663
|
+
walk(this.nodes, cb, bubble);
|
|
664
|
+
return this;
|
|
665
|
+
};
|
|
666
|
+
ValueParser.unit = requireUnit();
|
|
667
|
+
ValueParser.walk = walk;
|
|
668
|
+
ValueParser.stringify = stringify;
|
|
669
|
+
var lib = ValueParser;
|
|
670
|
+
|
|
671
|
+
var invalidShortforms = {
|
|
672
|
+
background: true,
|
|
673
|
+
borderBottom: true,
|
|
674
|
+
borderLeft: true,
|
|
675
|
+
borderRight: true,
|
|
676
|
+
borderTop: true,
|
|
677
|
+
font: true,
|
|
678
|
+
grid: true,
|
|
679
|
+
outline: true,
|
|
680
|
+
textDecoration: true,
|
|
681
|
+
};
|
|
682
|
+
var invalidMultiValueShortforms = {
|
|
683
|
+
flex: true,
|
|
684
|
+
margin: true,
|
|
685
|
+
padding: true,
|
|
686
|
+
borderColor: true,
|
|
687
|
+
borderRadius: true,
|
|
688
|
+
borderStyle: true,
|
|
689
|
+
borderWidth: true,
|
|
690
|
+
inset: true,
|
|
691
|
+
insetBlock: true,
|
|
692
|
+
insetInline: true,
|
|
693
|
+
marginBlock: true,
|
|
694
|
+
marginInline: true,
|
|
695
|
+
marginHorizontal: true,
|
|
696
|
+
marginVertical: true,
|
|
697
|
+
paddingBlock: true,
|
|
698
|
+
paddingInline: true,
|
|
699
|
+
paddingHorizontal: true,
|
|
700
|
+
paddingVertical: true,
|
|
701
|
+
overflow: true,
|
|
702
|
+
overscrollBehavior: true,
|
|
703
|
+
backgroundPosition: true,
|
|
704
|
+
};
|
|
705
|
+
function error(message) {
|
|
706
|
+
console.error(message);
|
|
707
|
+
}
|
|
708
|
+
function validate(obj) {
|
|
709
|
+
for (var k in obj) {
|
|
710
|
+
var prop = k.trim();
|
|
711
|
+
var value = obj[prop];
|
|
712
|
+
var isInvalid = false;
|
|
713
|
+
if (value === null) {
|
|
714
|
+
continue;
|
|
715
|
+
}
|
|
716
|
+
if (typeof value === 'string' && value.indexOf('!important') > -1) {
|
|
717
|
+
error("Invalid style declaration \"".concat(prop, ":").concat(value, "\". Values cannot include \"!important\""));
|
|
718
|
+
isInvalid = true;
|
|
719
|
+
}
|
|
720
|
+
else {
|
|
721
|
+
var suggestion = '';
|
|
722
|
+
if (prop === 'animation' || prop === 'animationName') {
|
|
723
|
+
suggestion = 'Did you mean "animationKeyframes"?';
|
|
724
|
+
isInvalid = true;
|
|
725
|
+
}
|
|
726
|
+
else if (prop === 'direction') {
|
|
727
|
+
suggestion = 'Did you mean "writingDirection"?';
|
|
728
|
+
isInvalid = true;
|
|
729
|
+
}
|
|
730
|
+
else if (invalidShortforms[prop]) {
|
|
731
|
+
suggestion = 'Please use long-form properties.';
|
|
732
|
+
isInvalid = true;
|
|
733
|
+
}
|
|
734
|
+
else if (invalidMultiValueShortforms[prop]) {
|
|
735
|
+
if (typeof value === 'string' && lib(value).nodes.length > 1) {
|
|
736
|
+
suggestion = "Value is \"".concat(value, "\" but only single values are supported.");
|
|
737
|
+
isInvalid = true;
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
if (suggestion !== '') {
|
|
741
|
+
error("Invalid style property of \"".concat(prop, "\". ").concat(suggestion));
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
if (isInvalid) {
|
|
745
|
+
delete obj[k];
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
var makeStyles = function (styleFactory, customTheme) {
|
|
751
|
+
var theme = customTheme || ctDesignTheme.ThemeManager.get();
|
|
752
|
+
var styles = styleFactory(theme);
|
|
753
|
+
for (var _i = 0, _a = Object.entries(styles); _i < _a.length; _i++) {
|
|
754
|
+
var _b = _a[_i], key = _b[0], value = _b[1];
|
|
755
|
+
var updatedValue = typeof value === 'function' ? value(theme) : value;
|
|
756
|
+
styles[key] = updatedValue;
|
|
757
|
+
}
|
|
758
|
+
var classes = {};
|
|
759
|
+
for (var _c = 0, _d = Object.entries(styles); _c < _d.length; _c++) {
|
|
760
|
+
var _e = _d[_c], key = _e[0], value = _e[1];
|
|
761
|
+
var defaultPreprocessOptions = { shadow: true, textShadow: true };
|
|
762
|
+
validate(value);
|
|
763
|
+
var updatedStyle = preprocess(value, defaultPreprocessOptions);
|
|
764
|
+
classes[key] = css.css(updatedStyle);
|
|
765
|
+
}
|
|
766
|
+
return classes;
|
|
767
|
+
};
|
|
768
|
+
|
|
769
|
+
var useStyles = function (styleFactory, dep) {
|
|
770
|
+
var theme = ctDesignTheme.useTheme();
|
|
771
|
+
return useStableMemo(function () {
|
|
772
|
+
var adaptedFactory = function (providedTheme) {
|
|
773
|
+
return styleFactory(providedTheme);
|
|
774
|
+
};
|
|
775
|
+
return makeStyles(adaptedFactory, theme);
|
|
776
|
+
}, dep);
|
|
777
|
+
};
|
|
778
|
+
|
|
779
|
+
var StylingCacheManager = (function () {
|
|
780
|
+
function StylingCacheManager() {
|
|
781
|
+
if (StylingCacheManager.instance) {
|
|
782
|
+
throw new Error('You can only create one instance!');
|
|
783
|
+
}
|
|
784
|
+
StylingCacheManager.instance = this;
|
|
785
|
+
this.cache = new WeakMap();
|
|
786
|
+
}
|
|
787
|
+
StylingCacheManager.prototype.set = function (key, value) {
|
|
788
|
+
this.cache.set(key, value);
|
|
789
|
+
};
|
|
790
|
+
StylingCacheManager.prototype.get = function (key) {
|
|
791
|
+
return this.cache.get(key);
|
|
792
|
+
};
|
|
793
|
+
return StylingCacheManager;
|
|
794
|
+
}());
|
|
795
|
+
var StylingCache = Object.freeze(new StylingCacheManager());
|
|
796
|
+
|
|
797
|
+
var useWebMergeStyles = function (styles, deps) {
|
|
798
|
+
return useStableMemo(function () {
|
|
799
|
+
var classes = [];
|
|
800
|
+
styles.forEach(function (style) {
|
|
801
|
+
if (typeof style === 'string') {
|
|
802
|
+
classes.push(style);
|
|
803
|
+
}
|
|
804
|
+
else {
|
|
805
|
+
if (style) {
|
|
806
|
+
var _style = StylingCache.get(style);
|
|
807
|
+
if (_style) {
|
|
808
|
+
classes.push(_style);
|
|
809
|
+
}
|
|
810
|
+
else {
|
|
811
|
+
var defaultPreprocessOptions = { shadow: true, textShadow: true };
|
|
812
|
+
var preprocessedStyle = preprocess(style, defaultPreprocessOptions);
|
|
813
|
+
var emotionClass = css.css(preprocessedStyle);
|
|
814
|
+
StylingCache.set(style, emotionClass);
|
|
815
|
+
classes.push(emotionClass);
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
});
|
|
820
|
+
return css.css(classes);
|
|
821
|
+
}, deps);
|
|
822
|
+
};
|
|
823
|
+
|
|
824
|
+
exports.makeStyles = makeStyles;
|
|
825
|
+
exports.useStyles = useStyles;
|
|
826
|
+
exports.useWebMergeStyles = useWebMergeStyles;
|
|
827
|
+
|
|
828
|
+
}));
|
|
829
|
+
//# sourceMappingURL=ct-design-styleManager.umd.js.map
|