@codeleap/styles 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +5 -0
- package/dist/index.js +26 -0
- package/dist/lib/Cacher.d.ts +37 -0
- package/dist/lib/Cacher.js +104 -0
- package/dist/lib/StaleControl.d.ts +21 -0
- package/dist/lib/StaleControl.js +78 -0
- package/dist/lib/StyleCache.d.ts +20 -0
- package/dist/lib/StyleCache.js +52 -0
- package/dist/lib/StylePersistor.d.ts +13 -0
- package/dist/lib/StylePersistor.js +22 -0
- package/dist/lib/StyleRegistry.d.ts +46 -0
- package/dist/lib/StyleRegistry.js +499 -0
- package/dist/lib/borderCreator.d.ts +11 -0
- package/dist/lib/borderCreator.js +44 -0
- package/dist/lib/constants.d.ts +5 -0
- package/dist/lib/constants.js +8 -0
- package/dist/lib/createAppVariants.d.ts +6 -0
- package/dist/lib/createAppVariants.js +9 -0
- package/dist/lib/createStyles.d.ts +4 -0
- package/dist/lib/createStyles.js +27 -0
- package/dist/lib/createTheme.d.ts +7 -0
- package/dist/lib/createTheme.js +76 -0
- package/dist/lib/defaultVariants.d.ts +178 -0
- package/dist/lib/defaultVariants.js +179 -0
- package/dist/lib/dynamicVariants.d.ts +12 -0
- package/dist/lib/dynamicVariants.js +88 -0
- package/dist/lib/hashKey.d.ts +1 -0
- package/dist/lib/hashKey.js +14 -0
- package/dist/lib/hooks.d.ts +8 -0
- package/dist/lib/hooks.js +76 -0
- package/dist/lib/index.d.ts +10 -0
- package/dist/lib/index.js +37 -0
- package/dist/lib/mediaQuery.d.ts +11 -0
- package/dist/lib/mediaQuery.js +65 -0
- package/dist/lib/minifier.d.ts +6 -0
- package/dist/lib/minifier.js +21 -0
- package/dist/lib/multiplierProperty.d.ts +3 -0
- package/dist/lib/multiplierProperty.js +13 -0
- package/dist/lib/spacing.d.ts +11 -0
- package/dist/lib/spacing.js +104 -0
- package/dist/lib/themeStore.d.ts +7 -0
- package/dist/lib/themeStore.js +9 -0
- package/dist/lib/utils.d.ts +8 -0
- package/dist/lib/utils.js +172 -0
- package/dist/lib/validateTheme.d.ts +2 -0
- package/dist/lib/validateTheme.js +68 -0
- package/dist/types/cache.d.ts +1 -0
- package/dist/types/cache.js +2 -0
- package/dist/types/component.d.ts +25 -0
- package/dist/types/component.js +2 -0
- package/dist/types/core.d.ts +20 -0
- package/dist/types/core.js +2 -0
- package/dist/types/icon.d.ts +4 -0
- package/dist/types/icon.js +3 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.js +21 -0
- package/dist/types/spacing.d.ts +6 -0
- package/dist/types/spacing.js +21 -0
- package/dist/types/style.d.ts +13 -0
- package/dist/types/style.js +2 -0
- package/dist/types/theme.d.ts +62 -0
- package/dist/types/theme.js +2 -0
- package/package.json +34 -0
- package/src/index.ts +7 -0
- package/src/lib/Cacher.ts +131 -0
- package/src/lib/StaleControl.ts +73 -0
- package/src/lib/StyleCache.ts +69 -0
- package/src/lib/StylePersistor.ts +28 -0
- package/src/lib/StyleRegistry.ts +549 -0
- package/src/lib/borderCreator.ts +42 -0
- package/src/lib/constants.ts +6 -0
- package/src/lib/createAppVariants.ts +12 -0
- package/src/lib/createStyles.ts +32 -0
- package/src/lib/createTheme.ts +89 -0
- package/src/lib/defaultVariants.ts +180 -0
- package/src/lib/dynamicVariants.ts +83 -0
- package/src/lib/hashKey.ts +12 -0
- package/src/lib/hooks.ts +52 -0
- package/src/lib/index.ts +11 -0
- package/src/lib/mediaQuery.ts +70 -0
- package/src/lib/minifier.ts +20 -0
- package/src/lib/multiplierProperty.ts +13 -0
- package/src/lib/spacing.ts +83 -0
- package/src/lib/themeStore.ts +14 -0
- package/src/lib/utils.ts +74 -0
- package/src/lib/validateTheme.ts +22 -0
- package/src/types/cache.ts +2 -0
- package/src/types/component.ts +40 -0
- package/src/types/core.ts +40 -0
- package/src/types/icon.ts +8 -0
- package/src/types/index.ts +5 -0
- package/src/types/spacing.ts +35 -0
- package/src/types/style.ts +41 -0
- package/src/types/theme.ts +77 -0
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.deepmerge = void 0;
|
|
21
|
+
require("./lib/constants");
|
|
22
|
+
require("./lib/utils");
|
|
23
|
+
__exportStar(require("./lib"), exports);
|
|
24
|
+
__exportStar(require("./types"), exports);
|
|
25
|
+
var deepmerge_1 = require("@fastify/deepmerge");
|
|
26
|
+
Object.defineProperty(exports, "deepmerge", { enumerable: true, get: function () { return __importDefault(deepmerge_1).default; } });
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { StateStorage } from 'zustand/middleware';
|
|
2
|
+
import { AnyRecord } from '../types';
|
|
3
|
+
import { CacheType } from '../types/cache';
|
|
4
|
+
type StorePersistor = {
|
|
5
|
+
cached: AnyRecord;
|
|
6
|
+
cacheFor: (key: string, value: any) => void;
|
|
7
|
+
staleTime: Date;
|
|
8
|
+
reset: () => void;
|
|
9
|
+
};
|
|
10
|
+
export declare class Cache<T extends any = any> {
|
|
11
|
+
registryName: CacheType;
|
|
12
|
+
private storage;
|
|
13
|
+
persistCache: boolean;
|
|
14
|
+
cache: Record<string, T>;
|
|
15
|
+
persistor: any;
|
|
16
|
+
store: StorePersistor;
|
|
17
|
+
constructor(registryName: CacheType, storage?: StateStorage, persistCache?: boolean);
|
|
18
|
+
keyFor(cacheBaseKey: string, data: Array<any> | any): {
|
|
19
|
+
key: string;
|
|
20
|
+
value: T;
|
|
21
|
+
};
|
|
22
|
+
cacheFor(key: string, cache: T): T;
|
|
23
|
+
setCache(cache: Record<string, T>): void;
|
|
24
|
+
clear(): void;
|
|
25
|
+
createPersistor(registryName: string): import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<StorePersistor>, "persist"> & {
|
|
26
|
+
persist: {
|
|
27
|
+
setOptions: (options: Partial<import("zustand/middleware").PersistOptions<StorePersistor, StorePersistor>>) => void;
|
|
28
|
+
clearStorage: () => void;
|
|
29
|
+
rehydrate: () => void | Promise<void>;
|
|
30
|
+
hasHydrated: () => boolean;
|
|
31
|
+
onHydrate: (fn: (state: StorePersistor) => void) => () => void;
|
|
32
|
+
onFinishHydration: (fn: (state: StorePersistor) => void) => () => void;
|
|
33
|
+
getOptions: () => Partial<import("zustand/middleware").PersistOptions<StorePersistor, StorePersistor>>;
|
|
34
|
+
};
|
|
35
|
+
}>;
|
|
36
|
+
}
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Cache = void 0;
|
|
4
|
+
var zustand_1 = require("zustand");
|
|
5
|
+
var middleware_1 = require("zustand/middleware");
|
|
6
|
+
var constants_1 = require("./constants");
|
|
7
|
+
var hashKey_1 = require("./hashKey");
|
|
8
|
+
function getStaleTime() {
|
|
9
|
+
var time = 7;
|
|
10
|
+
var currentTime = new Date();
|
|
11
|
+
currentTime.setDate(currentTime.getDate() + time);
|
|
12
|
+
return currentTime;
|
|
13
|
+
}
|
|
14
|
+
var Cache = /** @class */ (function () {
|
|
15
|
+
function Cache(registryName, storage, persistCache) {
|
|
16
|
+
if (storage === void 0) { storage = null; }
|
|
17
|
+
if (persistCache === void 0) { persistCache = !!storage; }
|
|
18
|
+
this.registryName = registryName;
|
|
19
|
+
this.storage = storage;
|
|
20
|
+
this.persistCache = persistCache;
|
|
21
|
+
this.cache = {};
|
|
22
|
+
this.persistor = null;
|
|
23
|
+
this.store = {
|
|
24
|
+
cached: {},
|
|
25
|
+
cacheFor: function () { return null; },
|
|
26
|
+
reset: function () { return null; },
|
|
27
|
+
staleTime: null
|
|
28
|
+
};
|
|
29
|
+
if (!persistCache)
|
|
30
|
+
return;
|
|
31
|
+
this.createPersistor(registryName);
|
|
32
|
+
if (!constants_1.StyleConstants.STORE_CACHE_ENABLED || !this.persistor)
|
|
33
|
+
return;
|
|
34
|
+
var currentTime = new Date();
|
|
35
|
+
var staleTime = new Date(this.store.staleTime);
|
|
36
|
+
var isStaled = currentTime > staleTime;
|
|
37
|
+
if (isStaled) {
|
|
38
|
+
this.store.reset();
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
this.setCache(this.store.cached);
|
|
42
|
+
}
|
|
43
|
+
Cache.prototype.keyFor = function (cacheBaseKey, data) {
|
|
44
|
+
var _a;
|
|
45
|
+
var values = [cacheBaseKey, data];
|
|
46
|
+
var cacheKey = (0, hashKey_1.hashKey)(values);
|
|
47
|
+
var cachedValue = (_a = this.cache[cacheKey]) !== null && _a !== void 0 ? _a : null;
|
|
48
|
+
return {
|
|
49
|
+
key: cacheKey,
|
|
50
|
+
value: cachedValue,
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
Cache.prototype.cacheFor = function (key, cache) {
|
|
54
|
+
this.cache[key] = cache;
|
|
55
|
+
if (this.persistCache)
|
|
56
|
+
this.store.cacheFor(key, cache);
|
|
57
|
+
return cache;
|
|
58
|
+
};
|
|
59
|
+
Cache.prototype.setCache = function (cache) {
|
|
60
|
+
this.cache = cache;
|
|
61
|
+
};
|
|
62
|
+
Cache.prototype.clear = function () {
|
|
63
|
+
this.cache = {};
|
|
64
|
+
if (this.persistCache)
|
|
65
|
+
this.persistor.persist.clearStorage();
|
|
66
|
+
};
|
|
67
|
+
Cache.prototype.createPersistor = function (registryName) {
|
|
68
|
+
var _this = this;
|
|
69
|
+
if (!this.persistCache)
|
|
70
|
+
return null;
|
|
71
|
+
var persistor = (0, zustand_1.create)((0, middleware_1.persist)(function (set, get) { return ({
|
|
72
|
+
staleTime: getStaleTime(),
|
|
73
|
+
cached: {},
|
|
74
|
+
cacheFor: function (key, value) { return set(function (store) {
|
|
75
|
+
var cached = store.cached;
|
|
76
|
+
cached[key] = value;
|
|
77
|
+
return {
|
|
78
|
+
cached: cached
|
|
79
|
+
};
|
|
80
|
+
}); },
|
|
81
|
+
reset: function () { return set({
|
|
82
|
+
cached: {},
|
|
83
|
+
staleTime: getStaleTime()
|
|
84
|
+
}); }
|
|
85
|
+
}); }, {
|
|
86
|
+
name: "@styles.caches.".concat(registryName),
|
|
87
|
+
version: constants_1.StyleConstants.STORES_PERSIST_VERSION,
|
|
88
|
+
migrate: function (persistedState, version) {
|
|
89
|
+
if (version != constants_1.StyleConstants.STORES_PERSIST_VERSION) {
|
|
90
|
+
persistedState.staleTime = getStaleTime();
|
|
91
|
+
persistedState.cached = {};
|
|
92
|
+
return persistedState;
|
|
93
|
+
}
|
|
94
|
+
return persistedState;
|
|
95
|
+
},
|
|
96
|
+
storage: (0, middleware_1.createJSONStorage)(function () { return _this.storage; }),
|
|
97
|
+
}));
|
|
98
|
+
this.persistor = persistor;
|
|
99
|
+
this.store = persistor.getState();
|
|
100
|
+
return persistor;
|
|
101
|
+
};
|
|
102
|
+
return Cache;
|
|
103
|
+
}());
|
|
104
|
+
exports.Cache = Cache;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare class StaleControl {
|
|
2
|
+
private staleTime;
|
|
3
|
+
private staleTimeIdentifier;
|
|
4
|
+
private wiperInterval;
|
|
5
|
+
private wiperId;
|
|
6
|
+
constructor(staleTime?: number, // minutes
|
|
7
|
+
staleTimeIdentifier?: string, wiperInterval?: number);
|
|
8
|
+
isStaled(value: string): boolean;
|
|
9
|
+
insertStaleTime(value: string): string;
|
|
10
|
+
refreshStaleTime(value: string): string;
|
|
11
|
+
extractStaleTime(value: string): {
|
|
12
|
+
staleTime: Date;
|
|
13
|
+
value: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* wipe staled cache; verify isStaled values and remove
|
|
17
|
+
*/
|
|
18
|
+
cacheWiper(): void;
|
|
19
|
+
registerCacheWiper(): void;
|
|
20
|
+
unregisterCacheWiper(): void;
|
|
21
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
+
if (!m) return o;
|
|
5
|
+
var i = m.call(o), r, ar = [], e;
|
|
6
|
+
try {
|
|
7
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
+
}
|
|
9
|
+
catch (error) { e = { error: error }; }
|
|
10
|
+
finally {
|
|
11
|
+
try {
|
|
12
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
+
}
|
|
14
|
+
finally { if (e) throw e.error; }
|
|
15
|
+
}
|
|
16
|
+
return ar;
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.StaleControl = void 0;
|
|
20
|
+
var StaleControl = /** @class */ (function () {
|
|
21
|
+
function StaleControl(staleTime, // minutes
|
|
22
|
+
staleTimeIdentifier, wiperInterval) {
|
|
23
|
+
if (staleTime === void 0) { staleTime = 60; }
|
|
24
|
+
if (staleTimeIdentifier === void 0) { staleTimeIdentifier = '//:'; }
|
|
25
|
+
if (wiperInterval === void 0) { wiperInterval = 30 * 60 * 1000; }
|
|
26
|
+
this.staleTime = staleTime;
|
|
27
|
+
this.staleTimeIdentifier = staleTimeIdentifier;
|
|
28
|
+
this.wiperInterval = wiperInterval;
|
|
29
|
+
this.wiperId = null;
|
|
30
|
+
}
|
|
31
|
+
StaleControl.prototype.isStaled = function (value) {
|
|
32
|
+
var staleTime = this.extractStaleTime(value).staleTime;
|
|
33
|
+
var currentTime = new Date();
|
|
34
|
+
var isStaled = currentTime > staleTime;
|
|
35
|
+
return isStaled;
|
|
36
|
+
};
|
|
37
|
+
StaleControl.prototype.insertStaleTime = function (value) {
|
|
38
|
+
var currentTime = new Date();
|
|
39
|
+
currentTime.setMinutes(currentTime.getMinutes() + this.staleTime);
|
|
40
|
+
var staleTime = currentTime.toISOString();
|
|
41
|
+
var valueWithStaleTime = "".concat(value).concat(this.staleTimeIdentifier).concat(staleTime);
|
|
42
|
+
return valueWithStaleTime;
|
|
43
|
+
};
|
|
44
|
+
StaleControl.prototype.refreshStaleTime = function (value) {
|
|
45
|
+
var extractedValue = this.extractStaleTime(value).value;
|
|
46
|
+
var refreshedValue = this.insertStaleTime(extractedValue);
|
|
47
|
+
return refreshedValue;
|
|
48
|
+
};
|
|
49
|
+
StaleControl.prototype.extractStaleTime = function (value) {
|
|
50
|
+
var _a = __read(value === null || value === void 0 ? void 0 : value.split(this.staleTimeIdentifier), 2), extractedValue = _a[0], _staleTime = _a[1];
|
|
51
|
+
var staleTime = new Date(_staleTime);
|
|
52
|
+
return {
|
|
53
|
+
staleTime: staleTime,
|
|
54
|
+
value: extractedValue,
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* wipe staled cache; verify isStaled values and remove
|
|
59
|
+
*/
|
|
60
|
+
StaleControl.prototype.cacheWiper = function () {
|
|
61
|
+
throw new Error('Cache Wiper not implement');
|
|
62
|
+
};
|
|
63
|
+
StaleControl.prototype.registerCacheWiper = function () {
|
|
64
|
+
var _this = this;
|
|
65
|
+
if (this.wiperId !== null) {
|
|
66
|
+
this.unregisterCacheWiper();
|
|
67
|
+
}
|
|
68
|
+
this.wiperId = setInterval(function () {
|
|
69
|
+
_this.cacheWiper();
|
|
70
|
+
}, this.wiperInterval);
|
|
71
|
+
};
|
|
72
|
+
StaleControl.prototype.unregisterCacheWiper = function () {
|
|
73
|
+
clearInterval(this.wiperId);
|
|
74
|
+
this.wiperId = null;
|
|
75
|
+
};
|
|
76
|
+
return StaleControl;
|
|
77
|
+
}());
|
|
78
|
+
exports.StaleControl = StaleControl;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Cache } from './Cacher';
|
|
2
|
+
import { CacheType } from '../types/cache';
|
|
3
|
+
import { StateStorage } from 'zustand/middleware';
|
|
4
|
+
export declare class StyleCache {
|
|
5
|
+
baseKey: string;
|
|
6
|
+
styles: Cache<any>;
|
|
7
|
+
compositions: Cache<any>;
|
|
8
|
+
responsive: Cache<any>;
|
|
9
|
+
variants: Cache;
|
|
10
|
+
common: Cache;
|
|
11
|
+
components: Cache;
|
|
12
|
+
constructor(storage: StateStorage);
|
|
13
|
+
registerBaseKey(keys: Array<any>): string;
|
|
14
|
+
wipeCache(): void;
|
|
15
|
+
keyFor(type: CacheType, keyData: Array<any> | any): {
|
|
16
|
+
key: string;
|
|
17
|
+
value: any;
|
|
18
|
+
};
|
|
19
|
+
cacheFor(type: CacheType, key: string, value: any): any;
|
|
20
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StyleCache = void 0;
|
|
4
|
+
var Cacher_1 = require("./Cacher");
|
|
5
|
+
var hashKey_1 = require("./hashKey");
|
|
6
|
+
var constants_1 = require("./constants");
|
|
7
|
+
var minifier_1 = require("./minifier");
|
|
8
|
+
var StyleCache = /** @class */ (function () {
|
|
9
|
+
function StyleCache(storage) {
|
|
10
|
+
this.styles = new Cacher_1.Cache('styles');
|
|
11
|
+
this.compositions = new Cacher_1.Cache('compositions');
|
|
12
|
+
this.responsive = new Cacher_1.Cache('responsive');
|
|
13
|
+
this.variants = new Cacher_1.Cache('variants', storage);
|
|
14
|
+
this.common = new Cacher_1.Cache('common', storage);
|
|
15
|
+
this.components = new Cacher_1.Cache('components', storage);
|
|
16
|
+
}
|
|
17
|
+
StyleCache.prototype.registerBaseKey = function (keys) {
|
|
18
|
+
keys.push(constants_1.StyleConstants.STORES_PERSIST_VERSION);
|
|
19
|
+
var baseKey = (0, hashKey_1.hashKey)(keys);
|
|
20
|
+
this.baseKey = baseKey;
|
|
21
|
+
return baseKey;
|
|
22
|
+
};
|
|
23
|
+
StyleCache.prototype.wipeCache = function () {
|
|
24
|
+
this.components.clear();
|
|
25
|
+
this.responsive.clear();
|
|
26
|
+
this.compositions.clear();
|
|
27
|
+
this.variants.clear();
|
|
28
|
+
this.common.clear();
|
|
29
|
+
this.styles.clear();
|
|
30
|
+
};
|
|
31
|
+
StyleCache.prototype.keyFor = function (type, keyData) {
|
|
32
|
+
var _a;
|
|
33
|
+
var cache = this[type];
|
|
34
|
+
var values = [this.baseKey, keyData];
|
|
35
|
+
var cacheKey = (0, hashKey_1.hashKey)(values);
|
|
36
|
+
var cachedValue = minifier_1.minifier.decompress((_a = cache.cache[cacheKey]) !== null && _a !== void 0 ? _a : null);
|
|
37
|
+
return {
|
|
38
|
+
key: cacheKey,
|
|
39
|
+
value: cachedValue,
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
StyleCache.prototype.cacheFor = function (type, key, value) {
|
|
43
|
+
if (!constants_1.StyleConstants.CACHE_ENABLED) {
|
|
44
|
+
return value;
|
|
45
|
+
}
|
|
46
|
+
var cache = this[type];
|
|
47
|
+
var minifiedValue = minifier_1.minifier.compress(value);
|
|
48
|
+
return cache.cacheFor(key, minifiedValue);
|
|
49
|
+
};
|
|
50
|
+
return StyleCache;
|
|
51
|
+
}());
|
|
52
|
+
exports.StyleCache = StyleCache;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { StateStorage } from 'zustand/middleware';
|
|
2
|
+
export type StoragePersistor = {
|
|
3
|
+
set: (key: string, value: any) => void;
|
|
4
|
+
get: (key: string) => any;
|
|
5
|
+
del: (key: string) => void;
|
|
6
|
+
};
|
|
7
|
+
export declare class StylePersistor implements StateStorage {
|
|
8
|
+
private storage;
|
|
9
|
+
constructor(storage: StoragePersistor);
|
|
10
|
+
setItem(name: string, value: string): void;
|
|
11
|
+
getItem(name: string): string | null;
|
|
12
|
+
removeItem(name: string): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StylePersistor = void 0;
|
|
4
|
+
var minifier_1 = require("./minifier");
|
|
5
|
+
var StylePersistor = /** @class */ (function () {
|
|
6
|
+
function StylePersistor(storage) {
|
|
7
|
+
this.storage = storage;
|
|
8
|
+
}
|
|
9
|
+
StylePersistor.prototype.setItem = function (name, value) {
|
|
10
|
+
return this.storage.set(name, value);
|
|
11
|
+
};
|
|
12
|
+
StylePersistor.prototype.getItem = function (name) {
|
|
13
|
+
var _a;
|
|
14
|
+
var persistedValue = (_a = this.storage) === null || _a === void 0 ? void 0 : _a.get(name);
|
|
15
|
+
return minifier_1.minifier.decompress(persistedValue !== null && persistedValue !== void 0 ? persistedValue : null);
|
|
16
|
+
};
|
|
17
|
+
StylePersistor.prototype.removeItem = function (name) {
|
|
18
|
+
return this.storage.del(name);
|
|
19
|
+
};
|
|
20
|
+
return StylePersistor;
|
|
21
|
+
}());
|
|
22
|
+
exports.StylePersistor = StylePersistor;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { AnyRecord, AnyStyledComponent, ICSS, ITheme, StyleProp, VariantStyleSheet } from '../types';
|
|
2
|
+
import { MultiplierFunction } from './spacing';
|
|
3
|
+
import { StateStorage } from 'zustand/middleware';
|
|
4
|
+
export declare class CodeleapStyleRegistry {
|
|
5
|
+
stylesheets: Record<string, VariantStyleSheet>;
|
|
6
|
+
commonVariants: Record<string, ICSS | MultiplierFunction>;
|
|
7
|
+
components: Record<string, AnyStyledComponent>;
|
|
8
|
+
private theme;
|
|
9
|
+
private styleCache;
|
|
10
|
+
constructor(storage: StateStorage);
|
|
11
|
+
computeCommonVariantStyle(componentName: string, variant: string, component?: any): {
|
|
12
|
+
[x: number]: ICSS;
|
|
13
|
+
};
|
|
14
|
+
computeVariantStyle(componentName: string, variants: string[], _component?: any): ICSS;
|
|
15
|
+
isCompositionStyle(component: AnyStyledComponent, style: any): {
|
|
16
|
+
isComposition: boolean;
|
|
17
|
+
composition: {};
|
|
18
|
+
};
|
|
19
|
+
isResponsiveStyle(style: any): {
|
|
20
|
+
responsiveStyleKey: string;
|
|
21
|
+
isResponsive: boolean;
|
|
22
|
+
};
|
|
23
|
+
getDefaultVariantStyle(componentName: string, defaultVariantStyleName?: string): any;
|
|
24
|
+
mergeStylesWithCache<T = unknown>(styles: ICSS[], key: string): T;
|
|
25
|
+
getRegisteredComponent(componentName: string): {
|
|
26
|
+
rootElement: string;
|
|
27
|
+
registeredComponent: AnyStyledComponent;
|
|
28
|
+
};
|
|
29
|
+
getResponsiveStyle(componentName: string, responsiveStyleKey: string, style: object): any;
|
|
30
|
+
getStyles(componentName: string, _style: any, component?: any, predicateObj?: (style: any) => any): {};
|
|
31
|
+
private getMediaQuery;
|
|
32
|
+
getStyleWithResponsive(componentName: string, style: any, component?: any): any;
|
|
33
|
+
getCompositionStyle(componentName: string, composition: Record<string, any>, style: any): any;
|
|
34
|
+
styleFor<T = unknown>(componentName: string, componentStyle: StyleProp<T>, mergeWithDefaultStyle?: boolean): T;
|
|
35
|
+
registerCommonVariants(): void;
|
|
36
|
+
registerVariants(componentName: string, variants: VariantStyleSheet): void;
|
|
37
|
+
registerComponent(component: AnyStyledComponent): void;
|
|
38
|
+
/**
|
|
39
|
+
* These should be overwritten by the end-user to support
|
|
40
|
+
* custom style merging logic, such as StyleSheet.flatten
|
|
41
|
+
*/
|
|
42
|
+
createStyle(css: ICSS): ICSS;
|
|
43
|
+
update(): void;
|
|
44
|
+
private copyStyle;
|
|
45
|
+
createStyles<K extends string = string>(styles: Record<K, StyleProp<AnyRecord, ''>> | ((theme: ITheme) => Record<K, StyleProp<AnyRecord, ''>>)): Record<K, ICSS>;
|
|
46
|
+
}
|