effcss 1.3.5 → 2.0.0
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/README.md +26 -19
- package/dist/build/define-provider.min.js +2 -2
- package/dist/constants.js +1 -0
- package/dist/index.js +1 -1
- package/dist/types/src/_provider/manage.d.ts +1 -1
- package/dist/types/src/_provider/process.d.ts +4 -6
- package/dist/types/src/constants.d.ts +85 -0
- package/dist/types/src/index.d.ts +10 -16
- package/dist/types/src/types.d.ts +182 -154
- package/dist/types/src/utils/browser.d.ts +123 -0
- package/dist/types/src/utils/common.d.ts +74 -0
- package/dist/utils/browser.js +1 -0
- package/dist/utils/common.js +1 -0
- package/package.json +12 -18
- package/dist/build/define-provider-with-configs.min.js +0 -7
- package/dist/configs/basic.js +0 -1
- package/dist/configs/ext.js +0 -1
- package/dist/css/dict.js +0 -1
- package/dist/css/functions.js +0 -1
- package/dist/types/build/defineProviderWithConfigs.d.ts +0 -1
- package/dist/types/src/_provider/constants.d.ts +0 -6
- package/dist/types/src/configs/basic/Agent.d.ts +0 -3
- package/dist/types/src/configs/basic/AgentColor.d.ts +0 -3
- package/dist/types/src/configs/basic/Animation.d.ts +0 -3
- package/dist/types/src/configs/basic/Background.d.ts +0 -3
- package/dist/types/src/configs/basic/Border.d.ts +0 -3
- package/dist/types/src/configs/basic/BorderExt.d.ts +0 -3
- package/dist/types/src/configs/basic/Box.d.ts +0 -3
- package/dist/types/src/configs/basic/Color.d.ts +0 -3
- package/dist/types/src/configs/basic/Column.d.ts +0 -3
- package/dist/types/src/configs/basic/FlexContainer.d.ts +0 -3
- package/dist/types/src/configs/basic/FlexItem.d.ts +0 -3
- package/dist/types/src/configs/basic/Font.d.ts +0 -3
- package/dist/types/src/configs/basic/GridContainer.d.ts +0 -3
- package/dist/types/src/configs/basic/GridItem.d.ts +0 -3
- package/dist/types/src/configs/basic/Indent.d.ts +0 -3
- package/dist/types/src/configs/basic/Inset.d.ts +0 -3
- package/dist/types/src/configs/basic/Mask.d.ts +0 -3
- package/dist/types/src/configs/basic/Object.d.ts +0 -3
- package/dist/types/src/configs/basic/Outline.d.ts +0 -3
- package/dist/types/src/configs/basic/Scroll.d.ts +0 -3
- package/dist/types/src/configs/basic/ScrollExt.d.ts +0 -3
- package/dist/types/src/configs/basic/Size.d.ts +0 -3
- package/dist/types/src/configs/basic/SizeExt.d.ts +0 -3
- package/dist/types/src/configs/basic/Text.d.ts +0 -3
- package/dist/types/src/configs/basic/Transform.d.ts +0 -3
- package/dist/types/src/configs/basic/Transition.d.ts +0 -3
- package/dist/types/src/configs/basic/User.d.ts +0 -3
- package/dist/types/src/configs/basic/View.d.ts +0 -3
- package/dist/types/src/configs/basic.d.ts +0 -112
- package/dist/types/src/configs/ext/Keyframes.d.ts +0 -6
- package/dist/types/src/configs/ext/Reset.d.ts +0 -3
- package/dist/types/src/configs/ext.d.ts +0 -8
- package/dist/types/src/css/dict.d.ts +0 -4
- package/dist/types/src/css/functions.d.ts +0 -443
- package/dist/types/src/utils.d.ts +0 -195
- package/dist/utils.js +0 -1
|
@@ -1,31 +1,86 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Stylesheet config
|
|
3
3
|
* @description
|
|
4
|
-
*
|
|
4
|
+
* Contains descriptions of rules, variables, keyframes, and interpolation dictionaries used within the stylesheet.
|
|
5
5
|
*/
|
|
6
|
-
export
|
|
6
|
+
export type TStyleSheetConfig = {
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* CSS variables
|
|
9
|
+
* @see {@link TVariable}
|
|
9
10
|
*/
|
|
10
|
-
|
|
11
|
+
_?: Record<string, TVariable>;
|
|
12
|
+
/**
|
|
13
|
+
* Keyframes
|
|
14
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@keyframes}
|
|
15
|
+
*/
|
|
16
|
+
kf?: Record<string, Record<string, Record<string, string>>>;
|
|
17
|
+
/**
|
|
18
|
+
* Keys interpolation dictionary
|
|
19
|
+
* @description
|
|
20
|
+
* Dictionary with primitive type values.
|
|
21
|
+
* In interpolation expressions, these values will have an advantage over the global ones.
|
|
22
|
+
*/
|
|
23
|
+
k?: Record<string, string>;
|
|
24
|
+
/**
|
|
25
|
+
* Values interpolation dictionary
|
|
26
|
+
* @description
|
|
27
|
+
* Dictionary with object type values. Each object is a mini dictionary of grouped variant values.
|
|
28
|
+
* In interpolation expressions, these values will have an advantage over the global ones.
|
|
29
|
+
*/
|
|
30
|
+
v?: Record<string, Record<string, string | number>>;
|
|
31
|
+
/**
|
|
32
|
+
* Stylesheet content
|
|
33
|
+
* @description
|
|
34
|
+
* This object will be compiled to CSSStylesheet string content.
|
|
35
|
+
* The conversion rules are defined by the {@link IStyleProcessor | style processor}.
|
|
36
|
+
*/
|
|
37
|
+
c: object;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Style target
|
|
41
|
+
*/
|
|
42
|
+
export type TStyleTarget = string | TStyleSheetConfig;
|
|
43
|
+
/**
|
|
44
|
+
* Provider settings
|
|
45
|
+
*/
|
|
46
|
+
export type TProviderSettings = {
|
|
47
|
+
/**
|
|
48
|
+
* Style themes
|
|
49
|
+
*/
|
|
50
|
+
themes?: TThemes;
|
|
51
|
+
/**
|
|
52
|
+
* Root styles
|
|
53
|
+
*/
|
|
54
|
+
rootStyle?: object;
|
|
11
55
|
/**
|
|
12
56
|
* Global params units
|
|
13
57
|
*/
|
|
14
58
|
units?: Record<string, string>;
|
|
15
59
|
/**
|
|
16
|
-
*
|
|
60
|
+
* Global keys
|
|
17
61
|
*/
|
|
18
|
-
|
|
62
|
+
keys?: Record<string, string>;
|
|
19
63
|
/**
|
|
20
|
-
*
|
|
64
|
+
* Global sets of keys
|
|
21
65
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
66
|
+
sets?: Record<string, Record<string, string | number>>;
|
|
67
|
+
/**
|
|
68
|
+
* Media queries breakpoints
|
|
69
|
+
*/
|
|
70
|
+
mediaBP?: Record<string, string>;
|
|
71
|
+
/**
|
|
72
|
+
* Container queries breakpoints
|
|
73
|
+
*/
|
|
74
|
+
containerBP?: Record<string, string>;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Provider initial content
|
|
78
|
+
*/
|
|
79
|
+
export type TProviderInitContent = Record<string, TStyleSheetConfig>;
|
|
24
80
|
/**
|
|
25
81
|
* Style manager
|
|
26
82
|
* @description
|
|
27
|
-
*
|
|
28
|
-
* You usually don't need to use it directly, as it is contained in the {@link IStyleProvider.manager | style provider}.
|
|
83
|
+
* Manages CSS stylesheets.
|
|
29
84
|
*/
|
|
30
85
|
export interface IStyleManager {
|
|
31
86
|
/**
|
|
@@ -33,7 +88,7 @@ export interface IStyleManager {
|
|
|
33
88
|
* @param key - stylesheet key
|
|
34
89
|
* @returns CSS stylesheet if found with this key, otherwise `undefined`
|
|
35
90
|
*/
|
|
36
|
-
get(key
|
|
91
|
+
get(key?: string): CSSStyleSheet | undefined;
|
|
37
92
|
/**
|
|
38
93
|
* Get all stylesheets
|
|
39
94
|
* @returns CSS stylesheet dicitonary
|
|
@@ -68,25 +123,21 @@ export interface IStyleManager {
|
|
|
68
123
|
*/
|
|
69
124
|
pack(key: string, styles: string): boolean | void;
|
|
70
125
|
/**
|
|
71
|
-
*
|
|
126
|
+
* Check if stylesheet exist
|
|
72
127
|
* @param key - stylesheet key
|
|
73
|
-
* @
|
|
128
|
+
* @returns boolean flag
|
|
74
129
|
*/
|
|
75
|
-
|
|
130
|
+
has(key?: string): boolean;
|
|
76
131
|
/**
|
|
77
|
-
*
|
|
132
|
+
* Switch stylesheet on
|
|
78
133
|
* @param key - stylesheet key
|
|
79
|
-
* @returns expanded selectors Set
|
|
80
134
|
*/
|
|
81
|
-
|
|
135
|
+
on(key?: string): boolean | undefined;
|
|
82
136
|
/**
|
|
83
|
-
*
|
|
137
|
+
* Switch stylesheet off
|
|
84
138
|
* @param key - stylesheet key
|
|
85
|
-
* @param init - initial selector
|
|
86
|
-
* @param exp - expanded selector
|
|
87
|
-
* @returns `true` if rule is expanded, otherwise `undefined`
|
|
88
139
|
*/
|
|
89
|
-
|
|
140
|
+
off(key?: string): boolean | undefined;
|
|
90
141
|
/**
|
|
91
142
|
* Apply stylesheets to style consumer
|
|
92
143
|
* @param consumer - {@link TStyleConsumer | style consumer}
|
|
@@ -102,12 +153,6 @@ export interface IStyleManager {
|
|
|
102
153
|
* @description
|
|
103
154
|
* A registered consumer will automatically receive up-to-date styles when they are added, modified, or deleted.
|
|
104
155
|
* If the style provider does not contain the `isolated` {@link IStyleProviderParams.isolated | attribute}, the current document will be automatically registered.
|
|
105
|
-
* @example
|
|
106
|
-
* ```ts
|
|
107
|
-
* // register web component shadow root as consumer
|
|
108
|
-
* const shadow = this.attachShadow({mode: 'open'});
|
|
109
|
-
* getProvider().manager.registerNode(shadow);
|
|
110
|
-
* ```
|
|
111
156
|
*/
|
|
112
157
|
registerNode(consumer: TStyleConsumer): void;
|
|
113
158
|
/**
|
|
@@ -131,7 +176,7 @@ export interface IStyleManager {
|
|
|
131
176
|
* Creates a selector from the passed parts.
|
|
132
177
|
* @returns BEM selector string
|
|
133
178
|
*/
|
|
134
|
-
type
|
|
179
|
+
export type TResolveSelector = (params: {
|
|
135
180
|
/**
|
|
136
181
|
* {@link https://en.bem.info/methodology/key-concepts/#block | Block}
|
|
137
182
|
*/
|
|
@@ -162,11 +207,11 @@ type TGetBEMSelector = (params: {
|
|
|
162
207
|
* The object content depends on the value of the style provider's `mode` {@link IStyleProviderParams.mode | attribute}.
|
|
163
208
|
* @returns object containing target attribute with its value.
|
|
164
209
|
*/
|
|
165
|
-
type
|
|
210
|
+
export type TResolveAttr = (
|
|
166
211
|
/**
|
|
167
212
|
* {@link https://en.bem.info/methodology/key-concepts/#block | Block}
|
|
168
213
|
*/
|
|
169
|
-
b
|
|
214
|
+
b?: string) => (
|
|
170
215
|
/**
|
|
171
216
|
* {@link https://en.bem.info/methodology/key-concepts/#element | Element}
|
|
172
217
|
*/
|
|
@@ -176,61 +221,72 @@ e?: string) => (
|
|
|
176
221
|
*/
|
|
177
222
|
m?: string | object) => Record<string, string>;
|
|
178
223
|
/**
|
|
179
|
-
*
|
|
224
|
+
* Style resolver
|
|
180
225
|
* @description
|
|
181
|
-
*
|
|
226
|
+
* Resolves stylesheets' selectors/attributes/identifiers
|
|
182
227
|
*/
|
|
183
|
-
export interface
|
|
228
|
+
export interface IStyleResolver {
|
|
184
229
|
/**
|
|
185
230
|
* Selector resolver
|
|
186
231
|
*/
|
|
187
|
-
selector:
|
|
232
|
+
selector: TResolveSelector;
|
|
188
233
|
/**
|
|
189
234
|
* Attribute resolver
|
|
190
235
|
*/
|
|
191
|
-
attr:
|
|
236
|
+
attr: TResolveAttr;
|
|
237
|
+
/**
|
|
238
|
+
* Var name resolver
|
|
239
|
+
*/
|
|
240
|
+
varName: (...parts: (string | number)[]) => string;
|
|
241
|
+
/**
|
|
242
|
+
* Keyframes name resolver
|
|
243
|
+
*/
|
|
244
|
+
kfName: (...parts: (string | number)[]) => string;
|
|
192
245
|
}
|
|
246
|
+
/**
|
|
247
|
+
* Stylesheet resolver getter
|
|
248
|
+
*/
|
|
249
|
+
export type TCreateResolver = (params?: {
|
|
250
|
+
mode?: TStyleMode | null;
|
|
251
|
+
}) => IStyleResolver;
|
|
193
252
|
/**
|
|
194
253
|
* Style processor
|
|
195
254
|
* @description
|
|
196
|
-
*
|
|
197
|
-
* You usually don't need to use it directly, as it is contained in the {@link IStyleProvider.processor | style provider}.
|
|
255
|
+
* Converts stylesheet config to CSSStylesheet string content.
|
|
198
256
|
*/
|
|
199
257
|
export interface IStyleProcessor {
|
|
200
258
|
/**
|
|
201
|
-
*
|
|
202
|
-
* @
|
|
203
|
-
*
|
|
259
|
+
* Compile style config to CSS stylesheet text content
|
|
260
|
+
* @param b - block key
|
|
261
|
+
* @param config - stylesheet config
|
|
204
262
|
*/
|
|
205
|
-
|
|
263
|
+
compile(b: string, config: TStyleSheetConfig): string;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Style collector
|
|
267
|
+
* @description
|
|
268
|
+
* Collects stylesheet configs and maps them with keys
|
|
269
|
+
*/
|
|
270
|
+
export interface IStyleCollector {
|
|
206
271
|
/**
|
|
207
|
-
*
|
|
208
|
-
* @
|
|
209
|
-
*
|
|
272
|
+
* Collect config
|
|
273
|
+
* @param config - stylesheet config
|
|
274
|
+
* @param key - stylesheet key
|
|
210
275
|
*/
|
|
211
|
-
|
|
276
|
+
use(config: TStyleSheetConfig, key?: string): string;
|
|
212
277
|
/**
|
|
213
|
-
*
|
|
214
|
-
* @param
|
|
215
|
-
* @param selector
|
|
278
|
+
* Get key of collected config
|
|
279
|
+
* @param config - stylesheet config
|
|
216
280
|
*/
|
|
217
|
-
|
|
281
|
+
getKey(config: TStyleSheetConfig): string | undefined;
|
|
218
282
|
/**
|
|
219
|
-
*
|
|
220
|
-
* @param selector
|
|
283
|
+
* Get all collected keys
|
|
221
284
|
*/
|
|
222
|
-
|
|
223
|
-
e?: string;
|
|
224
|
-
m?: string;
|
|
225
|
-
mv?: string;
|
|
226
|
-
s?: string;
|
|
227
|
-
};
|
|
285
|
+
getKeys(): string[];
|
|
228
286
|
/**
|
|
229
|
-
*
|
|
230
|
-
* @param b - block key
|
|
231
|
-
* @param config - stylesheet config
|
|
287
|
+
* Get all collected configs
|
|
232
288
|
*/
|
|
233
|
-
|
|
289
|
+
getConfigs(): Record<string, TStyleSheetConfig>;
|
|
234
290
|
}
|
|
235
291
|
/**
|
|
236
292
|
* Style provider
|
|
@@ -239,75 +295,91 @@ export interface IStyleProcessor {
|
|
|
239
295
|
*/
|
|
240
296
|
export interface IStyleProvider {
|
|
241
297
|
/**
|
|
242
|
-
*
|
|
298
|
+
* Provider initial content
|
|
243
299
|
*/
|
|
244
|
-
|
|
300
|
+
initContent: TProviderInitContent;
|
|
245
301
|
/**
|
|
246
|
-
*
|
|
302
|
+
* Provider settings
|
|
247
303
|
*/
|
|
248
|
-
|
|
304
|
+
settingsContent: TProviderSettings;
|
|
249
305
|
/**
|
|
250
306
|
* Use stylesheet
|
|
251
307
|
* @param config - stylesheet config
|
|
252
|
-
* @returns {@link
|
|
308
|
+
* @returns {@link IStyleResolver.attr | attribute resolver}
|
|
253
309
|
* @description
|
|
254
310
|
* The method allows to use stylesheet without having its key.
|
|
255
|
-
* It returns {@link
|
|
311
|
+
* It returns {@link IStyleResolver.attr | attribute resolver}, that can create BEM selectors for config passed.
|
|
256
312
|
*/
|
|
257
|
-
|
|
313
|
+
use(config: TStyleSheetConfig, key?: string): ReturnType<TResolveAttr>;
|
|
258
314
|
/**
|
|
259
|
-
*
|
|
260
|
-
* @
|
|
261
|
-
* @config - stylesheet config
|
|
262
|
-
* @returns `true` if stylesheet compiled, otherwise `undefined`
|
|
315
|
+
* Use public stylesheet configs
|
|
316
|
+
* @param configs - stylesheet configs
|
|
263
317
|
*/
|
|
264
|
-
|
|
318
|
+
usePublic(configs: Record<string, TStyleSheetConfig>): Record<string, ReturnType<TResolveAttr>>;
|
|
265
319
|
/**
|
|
266
|
-
*
|
|
267
|
-
* @param
|
|
268
|
-
* @param selectors - stylesheet extra selectors
|
|
269
|
-
* @returns processed rules count if stylesheet expanded, otherwise `undefined`
|
|
320
|
+
* Use private stylesheet configs
|
|
321
|
+
* @param configs - stylesheet configs
|
|
270
322
|
*/
|
|
271
|
-
|
|
323
|
+
usePrivate(configs: TStyleSheetConfig[]): ReturnType<TResolveAttr>[];
|
|
272
324
|
/**
|
|
273
325
|
* Resolve stylesheet
|
|
274
326
|
* @param key - stylesheet key
|
|
275
327
|
* @returns BEM attribute resolver for stylesheet
|
|
276
328
|
*/
|
|
277
|
-
|
|
329
|
+
resolve(key?: string): ReturnType<TResolveAttr>;
|
|
330
|
+
/**
|
|
331
|
+
* Prepare CSS from config
|
|
332
|
+
* @param config - stylesheet config
|
|
333
|
+
* @param key - stylesheet key
|
|
334
|
+
*/
|
|
335
|
+
css(config: TStyleSheetConfig, key: string): string;
|
|
278
336
|
/**
|
|
279
|
-
*
|
|
280
|
-
* @param
|
|
281
|
-
* @param ext - extra rules dictionary
|
|
337
|
+
* Get CSS stylesheet
|
|
338
|
+
* @param target - target stylesheet config or key
|
|
282
339
|
*/
|
|
283
|
-
|
|
340
|
+
get(target?: TStyleTarget): CSSStyleSheet | undefined;
|
|
341
|
+
/**
|
|
342
|
+
* Switch stylesheet on
|
|
343
|
+
* @param target - target stylesheet config or key
|
|
344
|
+
*/
|
|
345
|
+
on(target?: TStyleTarget): boolean | undefined;
|
|
346
|
+
/**
|
|
347
|
+
* Switch stylesheet off
|
|
348
|
+
* @param target - target stylesheet config or key
|
|
349
|
+
*/
|
|
350
|
+
off(target?: TStyleTarget): boolean | undefined;
|
|
351
|
+
/**
|
|
352
|
+
* Get many CSS stylesheets
|
|
353
|
+
* @param target - target stylesheet configs and/or keys
|
|
354
|
+
*/
|
|
355
|
+
getMany(targets?: TStyleTarget[]): (CSSStyleSheet | undefined)[];
|
|
284
356
|
}
|
|
285
357
|
/**
|
|
286
358
|
* Style dispatcher
|
|
287
359
|
* @description
|
|
288
|
-
*
|
|
360
|
+
* Dispatches style operations to provider
|
|
289
361
|
*/
|
|
290
362
|
export interface IStyleDispatcher {
|
|
291
363
|
/**
|
|
292
364
|
* Use stylesheet
|
|
293
|
-
* @see {@link IStyleProvider.
|
|
365
|
+
* @see {@link IStyleProvider.use}
|
|
294
366
|
*/
|
|
295
|
-
use: IStyleProvider['
|
|
367
|
+
use: IStyleProvider['use'];
|
|
296
368
|
/**
|
|
297
|
-
*
|
|
298
|
-
* @see {@link IStyleProvider.
|
|
369
|
+
* Use public stylesheet configs
|
|
370
|
+
* @see {@link IStyleProvider.usePublic}
|
|
299
371
|
*/
|
|
300
|
-
|
|
372
|
+
usePublic: IStyleProvider['usePublic'];
|
|
301
373
|
/**
|
|
302
|
-
*
|
|
303
|
-
* @see {@link IStyleProvider.
|
|
374
|
+
* Use private stylesheet configs
|
|
375
|
+
* @see {@link IStyleProvider.usePrivate}
|
|
304
376
|
*/
|
|
305
|
-
|
|
377
|
+
usePrivate: IStyleProvider['usePrivate'];
|
|
306
378
|
/**
|
|
307
|
-
*
|
|
308
|
-
* @see {@link IStyleProvider.
|
|
379
|
+
* Resolve stylesheet
|
|
380
|
+
* @see {@link IStyleProvider.resolve}
|
|
309
381
|
*/
|
|
310
|
-
|
|
382
|
+
resolve: IStyleProvider['resolve'];
|
|
311
383
|
}
|
|
312
384
|
/**
|
|
313
385
|
* Variable type
|
|
@@ -348,53 +420,11 @@ export type TVariable = {
|
|
|
348
420
|
all?: boolean;
|
|
349
421
|
};
|
|
350
422
|
/**
|
|
351
|
-
*
|
|
352
|
-
* @description
|
|
353
|
-
* Contains descriptions of rules, variables, keyframes, and interpolation dictionaries used within the stylesheet.
|
|
423
|
+
* Style themes
|
|
354
424
|
*/
|
|
355
|
-
export type
|
|
356
|
-
/**
|
|
357
|
-
* CSS variables
|
|
358
|
-
* @see {@link TVariable}
|
|
359
|
-
*/
|
|
360
|
-
_?: Record<string, TVariable>;
|
|
361
|
-
/**
|
|
362
|
-
* Keyframes
|
|
363
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/@keyframes}
|
|
364
|
-
*/
|
|
365
|
-
kf?: Record<string, Record<string, Record<string, string>>>;
|
|
366
|
-
/**
|
|
367
|
-
* Keys interpolation dictionary
|
|
368
|
-
* @description
|
|
369
|
-
* Dictionary with primitive type values.
|
|
370
|
-
* In interpolation expressions, these values will have an advantage over the global ones.
|
|
371
|
-
*/
|
|
372
|
-
k?: Record<string, string>;
|
|
373
|
-
/**
|
|
374
|
-
* Values interpolation dictionary
|
|
375
|
-
* @description
|
|
376
|
-
* Dictionary with object type values. Each object is a mini dictionary of grouped variant values.
|
|
377
|
-
* In interpolation expressions, these values will have an advantage over the global ones.
|
|
378
|
-
*/
|
|
379
|
-
v?: Record<string, Record<string, string | number>>;
|
|
380
|
-
/**
|
|
381
|
-
* Stylesheet content
|
|
382
|
-
* @description
|
|
383
|
-
* This object will be compiled to CSSStylesheet string content.
|
|
384
|
-
* The conversion rules are defined by the {@link IStyleProcessor | style processor}.
|
|
385
|
-
*/
|
|
386
|
-
c: object;
|
|
387
|
-
};
|
|
388
|
-
/**
|
|
389
|
-
* Display mode values
|
|
390
|
-
* @description
|
|
391
|
-
* The display mode allows you to override global values.
|
|
392
|
-
* The required mode is root.
|
|
393
|
-
* Other display modes can only override values from `root`, but not set their own.
|
|
394
|
-
*/
|
|
395
|
-
export type TDisplayModeValues = Record<string, Record<string, Record<string, string | number>>>;
|
|
425
|
+
export type TThemes = Record<string, Record<string, Record<string, string | number>>>;
|
|
396
426
|
/**
|
|
397
|
-
* Style generation mode for {@link
|
|
427
|
+
* Style generation mode for {@link IStyleResolver | BEM selectors}
|
|
398
428
|
* @description
|
|
399
429
|
* `a` - attributes
|
|
400
430
|
* `c` - classes
|
|
@@ -403,16 +433,20 @@ export type TStyleMode = 'a' | 'c';
|
|
|
403
433
|
/**
|
|
404
434
|
* Style provider attributes
|
|
405
435
|
* @description
|
|
406
|
-
* Attributes that can be set on a component.
|
|
436
|
+
* Attributes that can be set on a provider component.
|
|
407
437
|
*/
|
|
408
438
|
export interface IStyleProviderParams {
|
|
409
439
|
/**
|
|
410
|
-
* Settings script
|
|
440
|
+
* Settings script selector
|
|
411
441
|
* @description
|
|
412
442
|
* Allows to read the initial settings from a separate element script.
|
|
413
443
|
* If not specified, `effcss` is used.
|
|
414
444
|
*/
|
|
415
445
|
settingsid?: string;
|
|
446
|
+
/**
|
|
447
|
+
* Initial content script selector
|
|
448
|
+
*/
|
|
449
|
+
initcls?: string;
|
|
416
450
|
/**
|
|
417
451
|
* Prefix
|
|
418
452
|
* @description
|
|
@@ -432,16 +466,11 @@ export interface IStyleProviderParams {
|
|
|
432
466
|
* @description
|
|
433
467
|
* If specified, provider won`t register document as dependent node
|
|
434
468
|
*/
|
|
435
|
-
isolated?:
|
|
469
|
+
isolated?: '' | null;
|
|
436
470
|
/**
|
|
437
|
-
*
|
|
438
|
-
* @description
|
|
439
|
-
* It value controls initializer stylesheet:
|
|
440
|
-
* - if it is equals '', the stylesheet will be omitted;
|
|
441
|
-
* - if it is not specified, the stylesheet will be generated with default `initkey`;
|
|
442
|
-
* - if it is specified as no-empty string, the stylesheet will be generated with specified key.
|
|
471
|
+
* Hydrate initial stylesheets
|
|
443
472
|
*/
|
|
444
|
-
|
|
473
|
+
hydrate?: '' | null;
|
|
445
474
|
}
|
|
446
475
|
/**
|
|
447
476
|
* Style consumer node
|
|
@@ -451,4 +480,3 @@ export interface IStyleProviderParams {
|
|
|
451
480
|
export type TStyleConsumer = {
|
|
452
481
|
adoptedStyleSheets: CSSStyleSheet[];
|
|
453
482
|
};
|
|
454
|
-
export {};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { IStyleDispatcher, IStyleProvider, TStyleSheetConfig, TStyleTarget } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Get style provider component
|
|
4
|
+
* @param root - style provider scope
|
|
5
|
+
* @description
|
|
6
|
+
* Use this function to get the first provider element found in the document
|
|
7
|
+
* @see {@link IStyleProvider}
|
|
8
|
+
*/
|
|
9
|
+
export declare const getProvider: (root?: Document, tag?: string) => IStyleProvider;
|
|
10
|
+
/**
|
|
11
|
+
* Use stylesheet
|
|
12
|
+
* @param config - stylesheet config
|
|
13
|
+
* @param provider - style provider
|
|
14
|
+
* @see {@link IStyleProvider}
|
|
15
|
+
*/
|
|
16
|
+
export declare const useStyleSheet: (config: TStyleSheetConfig, key?: string, provider?: IStyleProvider) => (e?: string) => (m?: string | object) => Record<string, string>;
|
|
17
|
+
/**
|
|
18
|
+
* Use public stylehseet configs
|
|
19
|
+
* @param styles - stylesheet configs
|
|
20
|
+
* @param provider - style provider
|
|
21
|
+
* @see {@link IStyleProvider}
|
|
22
|
+
*/
|
|
23
|
+
export declare const usePublicStyleSheets: (styles: Parameters<IStyleProvider["usePublic"]>[0], provider?: IStyleProvider) => Record<string, (e?: string) => (m?: string | object) => Record<string, string>>;
|
|
24
|
+
/**
|
|
25
|
+
* Use private stylehseet configs
|
|
26
|
+
* @param styles - stylesheet configs
|
|
27
|
+
* @param provider - style provider
|
|
28
|
+
* @see {@link IStyleProvider}
|
|
29
|
+
*/
|
|
30
|
+
export declare const usePrivateStyleSheets: (styles: Parameters<IStyleProvider["usePrivate"]>[0], provider?: IStyleProvider) => ((e?: string) => (m?: string | object) => Record<string, string>)[];
|
|
31
|
+
/**
|
|
32
|
+
* Resolve stylesheet
|
|
33
|
+
* @param key stylesheet key
|
|
34
|
+
* @param provider - style provider
|
|
35
|
+
* @see {@link IStyleProvider}
|
|
36
|
+
*/
|
|
37
|
+
export declare const resolveStyleSheet: (key?: string, provider?: IStyleProvider) => (e?: string) => (m?: string | object) => Record<string, string>;
|
|
38
|
+
/**
|
|
39
|
+
* Get stylesheet from provider
|
|
40
|
+
* @param key - stylesheet key
|
|
41
|
+
* @param provider - style provider
|
|
42
|
+
* @see {@link IStyleProvider}
|
|
43
|
+
*/
|
|
44
|
+
export declare const getStyleSheet: (key?: TStyleTarget, provider?: IStyleProvider) => CSSStyleSheet | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Get stylesheet from provider
|
|
47
|
+
* @param key - stylesheet key
|
|
48
|
+
* @param provider - style provider
|
|
49
|
+
* @see {@link IStyleProvider}
|
|
50
|
+
*/
|
|
51
|
+
export declare const getManyStyleSheets: (key?: TStyleTarget[], provider?: IStyleProvider) => (CSSStyleSheet | undefined)[];
|
|
52
|
+
/**
|
|
53
|
+
* Stringify stylesheet
|
|
54
|
+
* @param key - stylesheet key
|
|
55
|
+
* @param provider - style provider
|
|
56
|
+
* @see {@link IStyleProvider}
|
|
57
|
+
*/
|
|
58
|
+
export declare const stringifyOne: (key?: TStyleTarget, provider?: IStyleProvider) => string;
|
|
59
|
+
/**
|
|
60
|
+
* Stringify stylesheet
|
|
61
|
+
* @param key - stylesheet key
|
|
62
|
+
* @param provider - style provider
|
|
63
|
+
* @see {@link IStyleProvider}
|
|
64
|
+
*/
|
|
65
|
+
export declare const stringifyMany: (key?: TStyleTarget[], provider?: IStyleProvider) => string;
|
|
66
|
+
/**
|
|
67
|
+
* Get rules count for stylesheet
|
|
68
|
+
* @param key - stylesheet key
|
|
69
|
+
* @param provider - style provider
|
|
70
|
+
* @see {@link IStyleProvider}
|
|
71
|
+
*/
|
|
72
|
+
export declare const measureOne: (key: string, provider?: IStyleProvider) => number;
|
|
73
|
+
/**
|
|
74
|
+
* Get rules count for stylesheet
|
|
75
|
+
* @param key - stylesheet key
|
|
76
|
+
* @param provider - style provider
|
|
77
|
+
* @see {@link IStyleProvider}
|
|
78
|
+
*/
|
|
79
|
+
export declare const measureMany: (keys: string[], provider?: IStyleProvider) => number;
|
|
80
|
+
interface IStyleDispatcherParams {
|
|
81
|
+
root?: Document;
|
|
82
|
+
tag?: string;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Basic class for manipulating stylesheets
|
|
86
|
+
*/
|
|
87
|
+
declare class StyleDispatcher implements IStyleDispatcher {
|
|
88
|
+
/**
|
|
89
|
+
* Style provider
|
|
90
|
+
*/
|
|
91
|
+
protected _provider: IStyleProvider;
|
|
92
|
+
constructor(params?: IStyleDispatcherParams);
|
|
93
|
+
/**
|
|
94
|
+
* Use stylesheet
|
|
95
|
+
* @param config - stylesheet config
|
|
96
|
+
* @see {@link IStyleProvider}
|
|
97
|
+
*/
|
|
98
|
+
use: IStyleProvider['use'];
|
|
99
|
+
/**
|
|
100
|
+
* Use public stylesheet configs
|
|
101
|
+
* @param styles - stylesheet configs
|
|
102
|
+
* @see {@link IStyleProvider}
|
|
103
|
+
*/
|
|
104
|
+
usePublic: IStyleProvider['usePublic'];
|
|
105
|
+
/**
|
|
106
|
+
* Use private stylesheet configs
|
|
107
|
+
* @param styles - stylesheet configs
|
|
108
|
+
* @see {@link IStyleProvider}
|
|
109
|
+
*/
|
|
110
|
+
usePrivate: IStyleProvider['usePrivate'];
|
|
111
|
+
/**
|
|
112
|
+
* Resolve stylesheet
|
|
113
|
+
* @param key - stylesheet key
|
|
114
|
+
* @see {@link IStyleProvider}
|
|
115
|
+
*/
|
|
116
|
+
resolve: IStyleProvider['resolve'];
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Create style dispatcher
|
|
120
|
+
* @param params - dispatcher params
|
|
121
|
+
*/
|
|
122
|
+
export declare function createDispatcher(params?: IStyleDispatcherParams): StyleDispatcher;
|
|
123
|
+
export {};
|