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