@codeleap/styles 4.2.9 → 4.2.10
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/package.json +4 -5
- package/package.json.bak +3 -4
- package/src/lib/borderCreator.ts +5 -3
- package/src/lib/constants.ts +3 -0
- package/src/lib/dynamicVariants.ts +28 -13
- package/dist/index.d.ts +0 -5
- package/dist/index.js +0 -26
- package/dist/lib/Cacher.d.ts +0 -37
- package/dist/lib/Cacher.js +0 -104
- package/dist/lib/StaleControl.d.ts +0 -21
- package/dist/lib/StaleControl.js +0 -78
- package/dist/lib/StyleCache.d.ts +0 -20
- package/dist/lib/StyleCache.js +0 -83
- package/dist/lib/StylePersistor.d.ts +0 -13
- package/dist/lib/StylePersistor.js +0 -22
- package/dist/lib/StyleRegistry.d.ts +0 -47
- package/dist/lib/StyleRegistry.js +0 -513
- package/dist/lib/borderCreator.d.ts +0 -11
- package/dist/lib/borderCreator.js +0 -44
- package/dist/lib/constants.d.ts +0 -5
- package/dist/lib/constants.js +0 -8
- package/dist/lib/createAppVariants.d.ts +0 -6
- package/dist/lib/createAppVariants.js +0 -9
- package/dist/lib/createStyles.d.ts +0 -4
- package/dist/lib/createStyles.js +0 -27
- package/dist/lib/createTheme.d.ts +0 -7
- package/dist/lib/createTheme.js +0 -74
- package/dist/lib/defaultVariants.d.ts +0 -178
- package/dist/lib/defaultVariants.js +0 -179
- package/dist/lib/dynamicVariants.d.ts +0 -12
- package/dist/lib/dynamicVariants.js +0 -88
- package/dist/lib/hashKey.d.ts +0 -1
- package/dist/lib/hashKey.js +0 -14
- package/dist/lib/hooks.d.ts +0 -8
- package/dist/lib/hooks.js +0 -76
- package/dist/lib/index.d.ts +0 -10
- package/dist/lib/index.js +0 -37
- package/dist/lib/mediaQuery.d.ts +0 -11
- package/dist/lib/mediaQuery.js +0 -65
- package/dist/lib/minifier.d.ts +0 -6
- package/dist/lib/minifier.js +0 -21
- package/dist/lib/multiplierProperty.d.ts +0 -3
- package/dist/lib/multiplierProperty.js +0 -13
- package/dist/lib/spacing.d.ts +0 -11
- package/dist/lib/spacing.js +0 -104
- package/dist/lib/themeStore.d.ts +0 -7
- package/dist/lib/themeStore.js +0 -9
- package/dist/lib/utils.d.ts +0 -8
- package/dist/lib/utils.js +0 -177
- package/dist/lib/validateTheme.d.ts +0 -2
- package/dist/lib/validateTheme.js +0 -68
- package/dist/types/cache.d.ts +0 -1
- package/dist/types/cache.js +0 -2
- package/dist/types/component.d.ts +0 -25
- package/dist/types/component.js +0 -2
- package/dist/types/core.d.ts +0 -20
- package/dist/types/core.js +0 -2
- package/dist/types/icon.d.ts +0 -4
- package/dist/types/icon.js +0 -3
- package/dist/types/index.d.ts +0 -5
- package/dist/types/index.js +0 -21
- package/dist/types/spacing.d.ts +0 -6
- package/dist/types/spacing.js +0 -21
- package/dist/types/style.d.ts +0 -14
- package/dist/types/style.js +0 -2
- package/dist/types/theme.d.ts +0 -67
- package/dist/types/theme.js +0 -2
|
@@ -1,513 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
14
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
15
|
-
if (!m) return o;
|
|
16
|
-
var i = m.call(o), r, ar = [], e;
|
|
17
|
-
try {
|
|
18
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
19
|
-
}
|
|
20
|
-
catch (error) { e = { error: error }; }
|
|
21
|
-
finally {
|
|
22
|
-
try {
|
|
23
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
24
|
-
}
|
|
25
|
-
finally { if (e) throw e.error; }
|
|
26
|
-
}
|
|
27
|
-
return ar;
|
|
28
|
-
};
|
|
29
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
30
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
31
|
-
if (ar || !(i in from)) {
|
|
32
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
33
|
-
ar[i] = from[i];
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
37
|
-
};
|
|
38
|
-
var __values = (this && this.__values) || function(o) {
|
|
39
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
40
|
-
if (m) return m.call(o);
|
|
41
|
-
if (o && typeof o.length === "number") return {
|
|
42
|
-
next: function () {
|
|
43
|
-
if (o && i >= o.length) o = void 0;
|
|
44
|
-
return { value: o && o[i++], done: !o };
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
48
|
-
};
|
|
49
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
-
};
|
|
52
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
-
exports.CodeleapStyleRegistry = void 0;
|
|
54
|
-
var themeStore_1 = require("./themeStore");
|
|
55
|
-
var deepmerge_1 = __importDefault(require("@fastify/deepmerge"));
|
|
56
|
-
var defaultVariants_1 = require("./defaultVariants");
|
|
57
|
-
var dynamicVariants_1 = require("./dynamicVariants");
|
|
58
|
-
var utils_1 = require("./utils");
|
|
59
|
-
var StyleCache_1 = require("./StyleCache");
|
|
60
|
-
var minifier_1 = require("./minifier");
|
|
61
|
-
var CodeleapStyleRegistry = /** @class */ (function () {
|
|
62
|
-
function CodeleapStyleRegistry(storage) {
|
|
63
|
-
var _a, _b, _c, _d, _e;
|
|
64
|
-
this.stylesheets = {};
|
|
65
|
-
this.commonVariants = {};
|
|
66
|
-
this.aggregators = {};
|
|
67
|
-
this.components = {};
|
|
68
|
-
this.styleCache = new StyleCache_1.StyleCache(storage);
|
|
69
|
-
this.theme = themeStore_1.themeStore.getState();
|
|
70
|
-
this.registerCommonVariants();
|
|
71
|
-
var currentColorScheme = (_e = (_c = (_b = (_a = this.theme) === null || _a === void 0 ? void 0 : _a.current) === null || _b === void 0 ? void 0 : _b['currentColorScheme']) !== null && _c !== void 0 ? _c : (_d = this.theme) === null || _d === void 0 ? void 0 : _d.colorScheme) !== null && _e !== void 0 ? _e : 'default';
|
|
72
|
-
this.styleCache.registerBaseKey([currentColorScheme, this.theme.current, this.commonVariants]);
|
|
73
|
-
}
|
|
74
|
-
CodeleapStyleRegistry.prototype.computeCommonVariantStyle = function (componentName, variant, component) {
|
|
75
|
-
var _a, _b, _c;
|
|
76
|
-
var _d, _e;
|
|
77
|
-
if (component === void 0) { component = null; }
|
|
78
|
-
var cache = this.styleCache.keyFor('common', variant);
|
|
79
|
-
if (!!cache.value) {
|
|
80
|
-
return _a = {},
|
|
81
|
-
_a[component] = this.createStyle(cache.value),
|
|
82
|
-
_a;
|
|
83
|
-
}
|
|
84
|
-
var theme = this.theme.current;
|
|
85
|
-
var mediaQuery = null;
|
|
86
|
-
var _f = __read((variant === null || variant === void 0 ? void 0 : variant.includes(':')) ? variant === null || variant === void 0 ? void 0 : variant.split(':') : [variant, null], 2), variantName = _f[0], value = _f[1];
|
|
87
|
-
// @ts-expect-error
|
|
88
|
-
if (!!(theme === null || theme === void 0 ? void 0 : theme.breakpoints[variantName])) {
|
|
89
|
-
var _g = __read(((_d = variant === null || variant === void 0 ? void 0 : variant.split(':')) === null || _d === void 0 ? void 0 : _d.length) == 2 ? __spreadArray(__spreadArray([], __read(variant === null || variant === void 0 ? void 0 : variant.split(':')), false), [null], false) : variant === null || variant === void 0 ? void 0 : variant.split(':'), 3), breakpoint = _g[0], _variantName = _g[1], _value = _g[2];
|
|
90
|
-
// @ts-expect-error
|
|
91
|
-
mediaQuery = theme.media.down(breakpoint);
|
|
92
|
-
value = _value;
|
|
93
|
-
variantName = _variantName;
|
|
94
|
-
}
|
|
95
|
-
var variantStyle = (_e = this.commonVariants[variantName]) !== null && _e !== void 0 ? _e : this.commonVariants[variant];
|
|
96
|
-
var style = null;
|
|
97
|
-
if (typeof variantStyle == 'function') {
|
|
98
|
-
style = (0, utils_1.isSpacingKey)(variantName) ? variantStyle(value) : variantStyle(theme, value);
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
style = variantStyle;
|
|
102
|
-
}
|
|
103
|
-
if (!style)
|
|
104
|
-
return null;
|
|
105
|
-
if (!!mediaQuery) {
|
|
106
|
-
style = (_b = {},
|
|
107
|
-
_b[mediaQuery] = style,
|
|
108
|
-
_b);
|
|
109
|
-
}
|
|
110
|
-
var commonStyles = (_c = {},
|
|
111
|
-
_c[component] = this.createStyle(style),
|
|
112
|
-
_c);
|
|
113
|
-
this.styleCache.cacheFor('common', cache.key, style);
|
|
114
|
-
return commonStyles;
|
|
115
|
-
};
|
|
116
|
-
CodeleapStyleRegistry.prototype.computeVariantStyle = function (componentName, variants, _component) {
|
|
117
|
-
var _this = this;
|
|
118
|
-
if (_component === void 0) { _component = null; }
|
|
119
|
-
var rootElement = this.getRegisteredComponent(componentName).rootElement;
|
|
120
|
-
var component = _component !== null && _component !== void 0 ? _component : rootElement;
|
|
121
|
-
var stylesheet = minifier_1.minifier.decompress(this.stylesheets[componentName]);
|
|
122
|
-
var aggregator = this.aggregators[componentName];
|
|
123
|
-
var cache = this.styleCache.keyFor('variants', { componentName: componentName, component: component, stylesheet: stylesheet, variants: variants, aggregator: aggregator });
|
|
124
|
-
if (!!cache.value) {
|
|
125
|
-
return cache.value;
|
|
126
|
-
}
|
|
127
|
-
var theme = this.theme.current;
|
|
128
|
-
var variantStyles = variants.map(function (variant) {
|
|
129
|
-
var _a, _b;
|
|
130
|
-
if (!!stylesheet[variant]) {
|
|
131
|
-
return stylesheet[variant];
|
|
132
|
-
}
|
|
133
|
-
var _c = __read((variant === null || variant === void 0 ? void 0 : variant.includes(':')) ? variant === null || variant === void 0 ? void 0 : variant.split(':') : [], 2), breakpoint = _c[0], variantName = _c[1];
|
|
134
|
-
// @ts-ignore
|
|
135
|
-
if (!!(theme === null || theme === void 0 ? void 0 : theme.breakpoints[breakpoint]) && !!stylesheet[variantName]) {
|
|
136
|
-
// @ts-ignore
|
|
137
|
-
var mediaQuery = theme.media.down(breakpoint);
|
|
138
|
-
return _a = {},
|
|
139
|
-
_a[component] = _this.createStyle((_b = {},
|
|
140
|
-
_b[mediaQuery] = stylesheet[variantName][component],
|
|
141
|
-
_b)),
|
|
142
|
-
_a;
|
|
143
|
-
}
|
|
144
|
-
return _this.computeCommonVariantStyle(componentName, variant, component);
|
|
145
|
-
}).filter(function (variantStyle) { return !!variantStyle; });
|
|
146
|
-
var variantStyle = (0, deepmerge_1.default)({ all: true }).apply(void 0, __spreadArray([], __read(variantStyles), false));
|
|
147
|
-
if (!!aggregator) {
|
|
148
|
-
variantStyle = aggregator(theme, variantStyle);
|
|
149
|
-
}
|
|
150
|
-
this.styleCache.cacheFor('variants', cache.key, variantStyle);
|
|
151
|
-
return variantStyle;
|
|
152
|
-
};
|
|
153
|
-
CodeleapStyleRegistry.prototype.isCompositionStyle = function (component, style) {
|
|
154
|
-
var e_1, _a, e_2, _b;
|
|
155
|
-
var composition = {};
|
|
156
|
-
if (!style) {
|
|
157
|
-
return {
|
|
158
|
-
isComposition: false,
|
|
159
|
-
composition: composition,
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
var styleKeys = Object.keys(style);
|
|
163
|
-
var elements = [];
|
|
164
|
-
var _loop_1 = function (element) {
|
|
165
|
-
var componentElements = styleKeys === null || styleKeys === void 0 ? void 0 : styleKeys.filter(function (k) { return (k === null || k === void 0 ? void 0 : k.startsWith(element)) && !(utils_1.ignoredStyleKeys === null || utils_1.ignoredStyleKeys === void 0 ? void 0 : utils_1.ignoredStyleKeys.includes(k)); });
|
|
166
|
-
if ((componentElements === null || componentElements === void 0 ? void 0 : componentElements.length) >= 1) {
|
|
167
|
-
elements = __spreadArray(__spreadArray([], __read(elements), false), __read(componentElements), false);
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
|
-
try {
|
|
171
|
-
for (var _c = __values(component === null || component === void 0 ? void 0 : component.elements), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
172
|
-
var element = _d.value;
|
|
173
|
-
_loop_1(element);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
177
|
-
finally {
|
|
178
|
-
try {
|
|
179
|
-
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
180
|
-
}
|
|
181
|
-
finally { if (e_1) throw e_1.error; }
|
|
182
|
-
}
|
|
183
|
-
try {
|
|
184
|
-
for (var elements_1 = __values(elements), elements_1_1 = elements_1.next(); !elements_1_1.done; elements_1_1 = elements_1.next()) {
|
|
185
|
-
var element = elements_1_1.value;
|
|
186
|
-
composition[element] = style[element];
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
190
|
-
finally {
|
|
191
|
-
try {
|
|
192
|
-
if (elements_1_1 && !elements_1_1.done && (_b = elements_1.return)) _b.call(elements_1);
|
|
193
|
-
}
|
|
194
|
-
finally { if (e_2) throw e_2.error; }
|
|
195
|
-
}
|
|
196
|
-
return {
|
|
197
|
-
isComposition: (elements === null || elements === void 0 ? void 0 : elements.length) >= 1,
|
|
198
|
-
composition: composition,
|
|
199
|
-
};
|
|
200
|
-
};
|
|
201
|
-
CodeleapStyleRegistry.prototype.isResponsiveStyle = function (style) {
|
|
202
|
-
var responsiveStyleKey = 'breakpoints';
|
|
203
|
-
if (!style) {
|
|
204
|
-
return {
|
|
205
|
-
responsiveStyleKey: responsiveStyleKey,
|
|
206
|
-
isResponsive: false,
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
return {
|
|
210
|
-
responsiveStyleKey: responsiveStyleKey,
|
|
211
|
-
isResponsive: !!style[responsiveStyleKey],
|
|
212
|
-
};
|
|
213
|
-
};
|
|
214
|
-
CodeleapStyleRegistry.prototype.getDefaultVariantStyle = function (componentName, defaultVariantStyleName) {
|
|
215
|
-
if (defaultVariantStyleName === void 0) { defaultVariantStyleName = 'default'; }
|
|
216
|
-
var stylesheet = minifier_1.minifier.decompress(this.stylesheets[componentName]);
|
|
217
|
-
var defaultStyle = stylesheet === null || stylesheet === void 0 ? void 0 : stylesheet[defaultVariantStyleName];
|
|
218
|
-
if (!!defaultStyle) {
|
|
219
|
-
return defaultStyle;
|
|
220
|
-
}
|
|
221
|
-
else {
|
|
222
|
-
return {};
|
|
223
|
-
}
|
|
224
|
-
};
|
|
225
|
-
CodeleapStyleRegistry.prototype.mergeStylesWithCache = function (styles, key) {
|
|
226
|
-
var mergedStyles = (0, deepmerge_1.default)({ all: true }).apply(void 0, __spreadArray([], __read(styles), false));
|
|
227
|
-
this.styleCache.cacheFor('components', key, mergedStyles);
|
|
228
|
-
return mergedStyles;
|
|
229
|
-
};
|
|
230
|
-
CodeleapStyleRegistry.prototype.getRegisteredComponent = function (componentName) {
|
|
231
|
-
var _a;
|
|
232
|
-
var registeredComponent = this.components[componentName];
|
|
233
|
-
if (!registeredComponent) {
|
|
234
|
-
throw new Error("Component ".concat(componentName, " not registered"));
|
|
235
|
-
}
|
|
236
|
-
var rootElement = (_a = registeredComponent === null || registeredComponent === void 0 ? void 0 : registeredComponent.rootElement) !== null && _a !== void 0 ? _a : 'wrapper';
|
|
237
|
-
return {
|
|
238
|
-
rootElement: rootElement,
|
|
239
|
-
registeredComponent: registeredComponent,
|
|
240
|
-
};
|
|
241
|
-
};
|
|
242
|
-
CodeleapStyleRegistry.prototype.getResponsiveStyle = function (componentName, responsiveStyleKey, style) {
|
|
243
|
-
var _a;
|
|
244
|
-
var responsiveStyles = style[responsiveStyleKey];
|
|
245
|
-
if (!responsiveStyles)
|
|
246
|
-
return {};
|
|
247
|
-
var stylesheet = minifier_1.minifier.decompress(this.stylesheets[componentName]);
|
|
248
|
-
var cache = this.styleCache.keyFor('responsive', { componentName: componentName, responsiveStyles: responsiveStyles, stylesheet: stylesheet });
|
|
249
|
-
if (!!cache.value) {
|
|
250
|
-
return cache.value;
|
|
251
|
-
}
|
|
252
|
-
var styles = {};
|
|
253
|
-
for (var responsiveStyle in responsiveStyles) {
|
|
254
|
-
var mediaQuery = this.getMediaQuery(responsiveStyle);
|
|
255
|
-
var breakpointStyle = responsiveStyles[responsiveStyle];
|
|
256
|
-
var componentStyles = this.styleFor(componentName, breakpointStyle, false);
|
|
257
|
-
// @ts-ignore
|
|
258
|
-
for (var composition in componentStyles) {
|
|
259
|
-
styles[composition] = (_a = {},
|
|
260
|
-
_a[mediaQuery] = componentStyles[composition],
|
|
261
|
-
_a);
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
this.styleCache.cacheFor('responsive', cache.key, styles);
|
|
265
|
-
return styles;
|
|
266
|
-
};
|
|
267
|
-
CodeleapStyleRegistry.prototype.getStyles = function (componentName, _style, component, predicateObj) {
|
|
268
|
-
var e_3, _a;
|
|
269
|
-
var styles = {};
|
|
270
|
-
var style = typeof _style == 'string' ? [_style] : _style;
|
|
271
|
-
if (Array.isArray(style)) {
|
|
272
|
-
var variants = [];
|
|
273
|
-
try {
|
|
274
|
-
for (var style_1 = __values(style), style_1_1 = style_1.next(); !style_1_1.done; style_1_1 = style_1.next()) {
|
|
275
|
-
var s = style_1_1.value;
|
|
276
|
-
if (typeof s === 'string') {
|
|
277
|
-
variants.push(s);
|
|
278
|
-
}
|
|
279
|
-
else {
|
|
280
|
-
styles = (0, deepmerge_1.default)({ all: true })(styles, !!predicateObj ? predicateObj(s) : s);
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
285
|
-
finally {
|
|
286
|
-
try {
|
|
287
|
-
if (style_1_1 && !style_1_1.done && (_a = style_1.return)) _a.call(style_1);
|
|
288
|
-
}
|
|
289
|
-
finally { if (e_3) throw e_3.error; }
|
|
290
|
-
}
|
|
291
|
-
if ((variants === null || variants === void 0 ? void 0 : variants.length) >= 1) {
|
|
292
|
-
var computedVariantStyle = this.computeVariantStyle(componentName, variants, component);
|
|
293
|
-
styles = (0, deepmerge_1.default)({ all: true })(styles, computedVariantStyle[component]);
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
else if (typeof style === 'object') {
|
|
297
|
-
styles = !!predicateObj ? predicateObj(style) : style;
|
|
298
|
-
}
|
|
299
|
-
return styles;
|
|
300
|
-
};
|
|
301
|
-
CodeleapStyleRegistry.prototype.getMediaQuery = function (responsiveKey) {
|
|
302
|
-
var _a, _b;
|
|
303
|
-
var _c = __read((responsiveKey === null || responsiveKey === void 0 ? void 0 : responsiveKey.includes(':')) ? responsiveKey === null || responsiveKey === void 0 ? void 0 : responsiveKey.split(':') : [responsiveKey, 'down'], 2), breakpoint = _c[0], query = _c[1];
|
|
304
|
-
// @ts-expect-error - media not has type
|
|
305
|
-
var mediaQuery = (_b = (_a = this.theme.current.media) === null || _a === void 0 ? void 0 : _a[query]) === null || _b === void 0 ? void 0 : _b.call(_a, breakpoint);
|
|
306
|
-
return mediaQuery;
|
|
307
|
-
};
|
|
308
|
-
CodeleapStyleRegistry.prototype.getStyleWithResponsive = function (componentName, style, component) {
|
|
309
|
-
var _a;
|
|
310
|
-
if (!style)
|
|
311
|
-
return style;
|
|
312
|
-
var _b = this.isResponsiveStyle(style), isResponsive = _b.isResponsive, responsiveStyleKey = _b.responsiveStyleKey;
|
|
313
|
-
if (isResponsive) {
|
|
314
|
-
var responsiveStyles = {};
|
|
315
|
-
for (var responsiveStyle in style[responsiveStyleKey]) {
|
|
316
|
-
var mediaQuery = this.getMediaQuery(responsiveStyle);
|
|
317
|
-
var breakpointStyle = style[responsiveStyleKey][responsiveStyle];
|
|
318
|
-
responsiveStyles = (0, deepmerge_1.default)({ all: true })(responsiveStyles, (_a = {},
|
|
319
|
-
_a[mediaQuery] = this.getStyles(componentName, breakpointStyle, component),
|
|
320
|
-
_a));
|
|
321
|
-
}
|
|
322
|
-
delete style[responsiveStyleKey];
|
|
323
|
-
return (0, deepmerge_1.default)({ all: true })(style, responsiveStyles);
|
|
324
|
-
}
|
|
325
|
-
else {
|
|
326
|
-
return style;
|
|
327
|
-
}
|
|
328
|
-
};
|
|
329
|
-
CodeleapStyleRegistry.prototype.getCompositionStyle = function (componentName, composition, style) {
|
|
330
|
-
var _this = this;
|
|
331
|
-
var cache = this.styleCache.keyFor('compositions', { componentName: componentName, composition: composition, style: style });
|
|
332
|
-
if (!!cache.value) {
|
|
333
|
-
return cache.value;
|
|
334
|
-
}
|
|
335
|
-
var styles = [];
|
|
336
|
-
var _loop_2 = function (component) {
|
|
337
|
-
var _a;
|
|
338
|
-
var componentStyles = composition[component];
|
|
339
|
-
var componentStyle = this_1.getStyles(componentName, componentStyles, component, function (s) { return _this.getStyleWithResponsive(componentName, s, component); });
|
|
340
|
-
styles.push((_a = {}, _a[component] = componentStyle, _a));
|
|
341
|
-
delete style[component];
|
|
342
|
-
};
|
|
343
|
-
var this_1 = this;
|
|
344
|
-
for (var component in composition) {
|
|
345
|
-
_loop_2(component);
|
|
346
|
-
}
|
|
347
|
-
this.styleCache.cacheFor('compositions', cache.key, styles);
|
|
348
|
-
return styles;
|
|
349
|
-
};
|
|
350
|
-
CodeleapStyleRegistry.prototype.styleFor = function (componentName, componentStyle, mergeWithDefaultStyle) {
|
|
351
|
-
var _a, _b, e_4, _c, _d;
|
|
352
|
-
if (mergeWithDefaultStyle === void 0) { mergeWithDefaultStyle = true; }
|
|
353
|
-
var cache = this.styleCache.keyFor('components', { componentName: componentName, componentStyle: componentStyle, stylesheet: this.stylesheets[componentName] });
|
|
354
|
-
if (!!cache.value) {
|
|
355
|
-
return cache.value;
|
|
356
|
-
}
|
|
357
|
-
var style = this.copyStyle(componentStyle);
|
|
358
|
-
var isStyleArray = Array.isArray(style);
|
|
359
|
-
var _e = this.getRegisteredComponent(componentName), rootElement = _e.rootElement, registeredComponent = _e.registeredComponent;
|
|
360
|
-
var defaultStyle = mergeWithDefaultStyle ? this.getDefaultVariantStyle(componentName) : {};
|
|
361
|
-
if (!style) {
|
|
362
|
-
return this.mergeStylesWithCache([defaultStyle], cache.key);
|
|
363
|
-
}
|
|
364
|
-
var isStyleObject = typeof style === 'object' && !isStyleArray;
|
|
365
|
-
if (typeof style === 'string') {
|
|
366
|
-
var computedVariantStyle = this.computeVariantStyle(componentName, [style]);
|
|
367
|
-
return this.mergeStylesWithCache([defaultStyle, computedVariantStyle], cache.key);
|
|
368
|
-
}
|
|
369
|
-
if (isStyleObject) {
|
|
370
|
-
var _f = this.isCompositionStyle(registeredComponent, style), isComposition = _f.isComposition, composition = _f.composition;
|
|
371
|
-
var _g = this.isResponsiveStyle(style), isResponsive = _g.isResponsive, responsiveStyleKey = _g.responsiveStyleKey;
|
|
372
|
-
var responsiveStyles = this.getResponsiveStyle(componentName, responsiveStyleKey, style);
|
|
373
|
-
if (isResponsive) {
|
|
374
|
-
delete style[responsiveStyleKey];
|
|
375
|
-
}
|
|
376
|
-
if (isComposition) {
|
|
377
|
-
var compositionStyles = this.getCompositionStyle(componentName, composition, style);
|
|
378
|
-
var styles = __spreadArray([defaultStyle, responsiveStyles], __read(compositionStyles), false);
|
|
379
|
-
styles.push((_a = {}, _a[rootElement] = style, _a));
|
|
380
|
-
return this.mergeStylesWithCache(styles, cache.key);
|
|
381
|
-
}
|
|
382
|
-
else {
|
|
383
|
-
return this.mergeStylesWithCache([defaultStyle, responsiveStyles, (_b = {}, _b[rootElement] = style, _b)], cache.key);
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
if (isStyleArray) {
|
|
387
|
-
var filteredStyle = style === null || style === void 0 ? void 0 : style.filter(function (s) { return !!s; });
|
|
388
|
-
var variants = [];
|
|
389
|
-
var styles = [defaultStyle];
|
|
390
|
-
var idx = 0;
|
|
391
|
-
try {
|
|
392
|
-
for (var filteredStyle_1 = __values(filteredStyle), filteredStyle_1_1 = filteredStyle_1.next(); !filteredStyle_1_1.done; filteredStyle_1_1 = filteredStyle_1.next()) {
|
|
393
|
-
var s = filteredStyle_1_1.value;
|
|
394
|
-
if (typeof s === 'string') {
|
|
395
|
-
variants.push(s);
|
|
396
|
-
}
|
|
397
|
-
var isObj = typeof s === 'object';
|
|
398
|
-
if (variants.length > 0 && (idx === filteredStyle.length - 1 || isObj)) {
|
|
399
|
-
var computedVariantStyle = this.computeVariantStyle(componentName, variants);
|
|
400
|
-
styles.push(computedVariantStyle);
|
|
401
|
-
variants = [];
|
|
402
|
-
}
|
|
403
|
-
if (isObj) {
|
|
404
|
-
var _h = this.isCompositionStyle(registeredComponent, s), isComposition = _h.isComposition, composition = _h.composition;
|
|
405
|
-
var _j = this.isResponsiveStyle(s), isResponsive = _j.isResponsive, responsiveStyleKey = _j.responsiveStyleKey;
|
|
406
|
-
if (Array.isArray(s)) {
|
|
407
|
-
var styleComposition = this.styleFor(componentName, s, false);
|
|
408
|
-
styles.push(styleComposition);
|
|
409
|
-
}
|
|
410
|
-
else if (isComposition) {
|
|
411
|
-
var compositionStyles = this.getCompositionStyle(componentName, composition, s);
|
|
412
|
-
styles.push.apply(styles, __spreadArray([], __read(compositionStyles), false));
|
|
413
|
-
}
|
|
414
|
-
else if (isResponsive) {
|
|
415
|
-
var responsiveStyles = this.getResponsiveStyle(componentName, responsiveStyleKey, s);
|
|
416
|
-
styles.push(responsiveStyles);
|
|
417
|
-
delete s[responsiveStyleKey];
|
|
418
|
-
}
|
|
419
|
-
else {
|
|
420
|
-
styles.push((_d = {}, _d[rootElement] = s, _d));
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
idx++;
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
427
|
-
finally {
|
|
428
|
-
try {
|
|
429
|
-
if (filteredStyle_1_1 && !filteredStyle_1_1.done && (_c = filteredStyle_1.return)) _c.call(filteredStyle_1);
|
|
430
|
-
}
|
|
431
|
-
finally { if (e_4) throw e_4.error; }
|
|
432
|
-
}
|
|
433
|
-
return this.mergeStylesWithCache(styles, cache.key);
|
|
434
|
-
}
|
|
435
|
-
console.warn('Invalid style prop for ', componentName, style);
|
|
436
|
-
return {};
|
|
437
|
-
};
|
|
438
|
-
CodeleapStyleRegistry.prototype.registerCommonVariants = function () {
|
|
439
|
-
var _a, _b;
|
|
440
|
-
var spacingVariants = (_a = this.theme.current) === null || _a === void 0 ? void 0 : _a['spacing'];
|
|
441
|
-
var insetVariants = (_b = this.theme.current) === null || _b === void 0 ? void 0 : _b['inset'];
|
|
442
|
-
var appVariants = this.theme.variants;
|
|
443
|
-
var commonVariants = (0, deepmerge_1.default)({ all: true })(defaultVariants_1.defaultVariants, appVariants, dynamicVariants_1.dynamicVariants, spacingVariants, insetVariants);
|
|
444
|
-
this.commonVariants = commonVariants;
|
|
445
|
-
};
|
|
446
|
-
CodeleapStyleRegistry.prototype.registerVariants = function (componentName, variants, aggregator) {
|
|
447
|
-
if (this.stylesheets[componentName]) {
|
|
448
|
-
throw new Error("Variants for ".concat(componentName, " already registered"));
|
|
449
|
-
}
|
|
450
|
-
this.aggregators[componentName] = aggregator;
|
|
451
|
-
this.stylesheets[componentName] = minifier_1.minifier.compress(variants);
|
|
452
|
-
};
|
|
453
|
-
CodeleapStyleRegistry.prototype.registerComponent = function (component) {
|
|
454
|
-
var componentData = {
|
|
455
|
-
styleRegistryName: component === null || component === void 0 ? void 0 : component.styleRegistryName,
|
|
456
|
-
elements: component === null || component === void 0 ? void 0 : component.elements,
|
|
457
|
-
rootElement: component === null || component === void 0 ? void 0 : component.rootElement,
|
|
458
|
-
};
|
|
459
|
-
this.components[component.styleRegistryName] = componentData;
|
|
460
|
-
};
|
|
461
|
-
/**
|
|
462
|
-
* These should be overwritten by the end-user to support
|
|
463
|
-
* custom style merging logic, such as StyleSheet.flatten
|
|
464
|
-
*/
|
|
465
|
-
CodeleapStyleRegistry.prototype.createStyle = function (css) {
|
|
466
|
-
throw new Error('createStyle: Not implemented');
|
|
467
|
-
};
|
|
468
|
-
CodeleapStyleRegistry.prototype.update = function () {
|
|
469
|
-
var _a, _b, _c, _d, _e;
|
|
470
|
-
this.theme = themeStore_1.themeStore.getState();
|
|
471
|
-
var currentColorScheme = (_e = (_c = (_b = (_a = this.theme) === null || _a === void 0 ? void 0 : _a.current) === null || _b === void 0 ? void 0 : _b['currentColorScheme']) !== null && _c !== void 0 ? _c : (_d = this.theme) === null || _d === void 0 ? void 0 : _d.colorScheme) !== null && _e !== void 0 ? _e : 'default';
|
|
472
|
-
this.styleCache.registerBaseKey([currentColorScheme, this.theme.current, this.commonVariants]);
|
|
473
|
-
};
|
|
474
|
-
CodeleapStyleRegistry.prototype.copyStyle = function (style) {
|
|
475
|
-
var copiedStyle = null;
|
|
476
|
-
if (Array.isArray(style)) {
|
|
477
|
-
copiedStyle = __spreadArray([], __read(style), false);
|
|
478
|
-
}
|
|
479
|
-
else if (typeof style == 'object') {
|
|
480
|
-
copiedStyle = __assign({}, style);
|
|
481
|
-
}
|
|
482
|
-
else {
|
|
483
|
-
copiedStyle = style;
|
|
484
|
-
}
|
|
485
|
-
return copiedStyle;
|
|
486
|
-
};
|
|
487
|
-
CodeleapStyleRegistry.prototype.createStyles = function (styles) {
|
|
488
|
-
var _this = this;
|
|
489
|
-
var compute = function () {
|
|
490
|
-
var _a;
|
|
491
|
-
var current = themeStore_1.themeStore.getState().current;
|
|
492
|
-
var stylesObj = typeof styles === 'function' ? styles(current) : styles;
|
|
493
|
-
var cache = _this.styleCache.keyFor('styles', stylesObj);
|
|
494
|
-
if (!!cache.value) {
|
|
495
|
-
return cache.value;
|
|
496
|
-
}
|
|
497
|
-
var createdStyles = {};
|
|
498
|
-
for (var key in stylesObj) {
|
|
499
|
-
var style = _this.styleFor('MyComponent', stylesObj[key], false);
|
|
500
|
-
createdStyles[key] = (_a = style === null || style === void 0 ? void 0 : style.wrapper) !== null && _a !== void 0 ? _a : style;
|
|
501
|
-
}
|
|
502
|
-
_this.styleCache.cacheFor('styles', cache.key, createdStyles);
|
|
503
|
-
return createdStyles;
|
|
504
|
-
};
|
|
505
|
-
return new Proxy(compute(), {
|
|
506
|
-
get: function (target, prop) {
|
|
507
|
-
return compute()[prop];
|
|
508
|
-
},
|
|
509
|
-
});
|
|
510
|
-
};
|
|
511
|
-
return CodeleapStyleRegistry;
|
|
512
|
-
}());
|
|
513
|
-
exports.CodeleapStyleRegistry = CodeleapStyleRegistry;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { IColors, ICSS } from '../types';
|
|
2
|
-
import { borderDirection } from './dynamicVariants';
|
|
3
|
-
type BorderCreatorArgs = {
|
|
4
|
-
color: keyof IColors | (string & {});
|
|
5
|
-
width?: number | string;
|
|
6
|
-
directions?: typeof borderDirection[number][];
|
|
7
|
-
style?: ICSS['borderStyle'];
|
|
8
|
-
};
|
|
9
|
-
export type BorderCreator = (args: BorderCreatorArgs) => ICSS;
|
|
10
|
-
export declare const borderCreator: BorderCreator;
|
|
11
|
-
export {};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __values = (this && this.__values) || function(o) {
|
|
3
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
4
|
-
if (m) return m.call(o);
|
|
5
|
-
if (o && typeof o.length === "number") return {
|
|
6
|
-
next: function () {
|
|
7
|
-
if (o && i >= o.length) o = void 0;
|
|
8
|
-
return { value: o && o[i++], done: !o };
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.borderCreator = void 0;
|
|
15
|
-
var themeStore_1 = require("./themeStore");
|
|
16
|
-
var utils_1 = require("./utils");
|
|
17
|
-
var borderCreator = function (args) {
|
|
18
|
-
var e_1, _a;
|
|
19
|
-
var _b, _c;
|
|
20
|
-
var colorKey = args.color, _d = args.width, width = _d === void 0 ? 1 : _d, _e = args.style, style = _e === void 0 ? 'solid' : _e, _f = args.directions, directions = _f === void 0 ? ['left', 'top', 'bottom', 'right'] : _f;
|
|
21
|
-
var theme = themeStore_1.themeStore.getState().current;
|
|
22
|
-
var color = (_c = (_b = theme === null || theme === void 0 ? void 0 : theme['colors']) === null || _b === void 0 ? void 0 : _b[colorKey]) !== null && _c !== void 0 ? _c : colorKey;
|
|
23
|
-
var borderStyles = {};
|
|
24
|
-
try {
|
|
25
|
-
for (var directions_1 = __values(directions), directions_1_1 = directions_1.next(); !directions_1_1.done; directions_1_1 = directions_1.next()) {
|
|
26
|
-
var direction = directions_1_1.value;
|
|
27
|
-
var property = "border".concat((0, utils_1.capitalize)(direction));
|
|
28
|
-
borderStyles["".concat(property, "Color")] = color;
|
|
29
|
-
borderStyles["".concat(property, "Width")] = width;
|
|
30
|
-
if (typeof localStorage !== 'undefined') {
|
|
31
|
-
borderStyles["".concat(property, "Style")] = style;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
36
|
-
finally {
|
|
37
|
-
try {
|
|
38
|
-
if (directions_1_1 && !directions_1_1.done && (_a = directions_1.return)) _a.call(directions_1);
|
|
39
|
-
}
|
|
40
|
-
finally { if (e_1) throw e_1.error; }
|
|
41
|
-
}
|
|
42
|
-
return borderStyles;
|
|
43
|
-
};
|
|
44
|
-
exports.borderCreator = borderCreator;
|
package/dist/lib/constants.d.ts
DELETED
package/dist/lib/constants.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createAppVariants = void 0;
|
|
4
|
-
var themeStore_1 = require("./themeStore");
|
|
5
|
-
function createAppVariants(variants) {
|
|
6
|
-
themeStore_1.themeStore.setState({ variants: variants });
|
|
7
|
-
return variants;
|
|
8
|
-
}
|
|
9
|
-
exports.createAppVariants = createAppVariants;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { ICSS, ITheme, AnyRecord } from '../types';
|
|
2
|
-
type StylesShape<K extends string, P extends AnyRecord> = Partial<Record<K, ICSS & Partial<P>>>;
|
|
3
|
-
export declare function createStyles<K extends string, P extends AnyRecord = AnyRecord>(styles: StylesShape<K, P> | ((theme: ITheme) => StylesShape<K, P>)): Partial<Record<K, ICSS & Partial<P>>>;
|
|
4
|
-
export {};
|
package/dist/lib/createStyles.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createStyles = void 0;
|
|
4
|
-
var themeStore_1 = require("./themeStore");
|
|
5
|
-
function createStyles(styles) {
|
|
6
|
-
var compute = function () {
|
|
7
|
-
var styleObj = {};
|
|
8
|
-
var current = themeStore_1.themeStore.getState().current;
|
|
9
|
-
if (typeof styles === 'function') {
|
|
10
|
-
styleObj = styles(current);
|
|
11
|
-
}
|
|
12
|
-
else {
|
|
13
|
-
styleObj = styles;
|
|
14
|
-
}
|
|
15
|
-
return styleObj;
|
|
16
|
-
};
|
|
17
|
-
// We use a proxy here so that the color scheme is recomputed every time the
|
|
18
|
-
// theme changes. This is necessary because the theme is a singleton which does not cause
|
|
19
|
-
// a re-render when it changes. The end-user will only have to worry about remounting the root component
|
|
20
|
-
// when the theme changes in order to get the new color scheme due to this proxy.
|
|
21
|
-
return new Proxy(compute(), {
|
|
22
|
-
get: function (target, prop) {
|
|
23
|
-
return compute()[prop];
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
exports.createStyles = createStyles;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { AppTheme, Theme } from '../types';
|
|
2
|
-
type ColorSchemaPersistor = {
|
|
3
|
-
get: () => string;
|
|
4
|
-
set: (colorSchema: string) => void;
|
|
5
|
-
};
|
|
6
|
-
export declare const createTheme: <T extends Theme>(theme: T, colorSchemaPersistor: ColorSchemaPersistor) => AppTheme<T>;
|
|
7
|
-
export {};
|