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.
Files changed (57) hide show
  1. package/README.md +26 -19
  2. package/dist/build/define-provider.min.js +2 -2
  3. package/dist/constants.js +1 -0
  4. package/dist/index.js +1 -1
  5. package/dist/types/src/_provider/manage.d.ts +1 -1
  6. package/dist/types/src/_provider/process.d.ts +4 -8
  7. package/dist/types/src/constants.d.ts +85 -0
  8. package/dist/types/src/index.d.ts +10 -20
  9. package/dist/types/src/types.d.ts +172 -168
  10. package/dist/types/src/utils/browser.d.ts +123 -0
  11. package/dist/types/src/utils/common.d.ts +74 -0
  12. package/dist/utils/browser.js +1 -0
  13. package/dist/utils/common.js +1 -0
  14. package/package.json +12 -18
  15. package/dist/build/define-provider-with-configs.min.js +0 -7
  16. package/dist/configs/basic.js +0 -1
  17. package/dist/configs/ext.js +0 -1
  18. package/dist/css/dict.js +0 -1
  19. package/dist/css/functions.js +0 -1
  20. package/dist/types/build/defineProviderWithConfigs.d.ts +0 -1
  21. package/dist/types/src/_provider/constants.d.ts +0 -19
  22. package/dist/types/src/configs/basic/Agent.d.ts +0 -3
  23. package/dist/types/src/configs/basic/AgentColor.d.ts +0 -3
  24. package/dist/types/src/configs/basic/Animation.d.ts +0 -3
  25. package/dist/types/src/configs/basic/Background.d.ts +0 -3
  26. package/dist/types/src/configs/basic/Border.d.ts +0 -3
  27. package/dist/types/src/configs/basic/BorderExt.d.ts +0 -3
  28. package/dist/types/src/configs/basic/Box.d.ts +0 -3
  29. package/dist/types/src/configs/basic/Color.d.ts +0 -3
  30. package/dist/types/src/configs/basic/Column.d.ts +0 -3
  31. package/dist/types/src/configs/basic/FlexContainer.d.ts +0 -3
  32. package/dist/types/src/configs/basic/FlexItem.d.ts +0 -3
  33. package/dist/types/src/configs/basic/Font.d.ts +0 -3
  34. package/dist/types/src/configs/basic/GridContainer.d.ts +0 -3
  35. package/dist/types/src/configs/basic/GridItem.d.ts +0 -3
  36. package/dist/types/src/configs/basic/Indent.d.ts +0 -3
  37. package/dist/types/src/configs/basic/Inset.d.ts +0 -3
  38. package/dist/types/src/configs/basic/Mask.d.ts +0 -3
  39. package/dist/types/src/configs/basic/Object.d.ts +0 -3
  40. package/dist/types/src/configs/basic/Outline.d.ts +0 -3
  41. package/dist/types/src/configs/basic/Scroll.d.ts +0 -3
  42. package/dist/types/src/configs/basic/ScrollExt.d.ts +0 -3
  43. package/dist/types/src/configs/basic/Size.d.ts +0 -3
  44. package/dist/types/src/configs/basic/SizeExt.d.ts +0 -3
  45. package/dist/types/src/configs/basic/Text.d.ts +0 -3
  46. package/dist/types/src/configs/basic/Transform.d.ts +0 -3
  47. package/dist/types/src/configs/basic/Transition.d.ts +0 -3
  48. package/dist/types/src/configs/basic/User.d.ts +0 -3
  49. package/dist/types/src/configs/basic/View.d.ts +0 -3
  50. package/dist/types/src/configs/basic.d.ts +0 -112
  51. package/dist/types/src/configs/ext/Keyframes.d.ts +0 -6
  52. package/dist/types/src/configs/ext/Reset.d.ts +0 -3
  53. package/dist/types/src/configs/ext.d.ts +0 -8
  54. package/dist/types/src/css/dict.d.ts +0 -4
  55. package/dist/types/src/css/functions.d.ts +0 -443
  56. package/dist/types/src/utils.d.ts +0 -197
  57. package/dist/utils.js +0 -1
@@ -1,18 +1,53 @@
1
1
  /**
2
- * Style config
2
+ * Stylesheet config
3
3
  * @description
4
- * Config which is used as initial settings for the {@link IStyleProvider | style provider}.
4
+ * Contains descriptions of rules, variables, keyframes, and interpolation dictionaries used within the stylesheet.
5
5
  */
6
- export interface IStyleConfig {
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
- * Global params
9
- * @deprecated use `themes` instead
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
- params?: TDisplayModeValues;
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?: TDisplayModeValues;
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
- * Stylesheets` configs
60
+ * Global keys
26
61
  */
27
- styles?: Record<string, TStyleSheetConfig>;
62
+ keys?: Record<string, string>;
28
63
  /**
29
- * Stylesheets` extra rules
64
+ * Global sets of keys
30
65
  */
31
- ext?: Record<string, string[]>;
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
- * Class that manages CSS stylesheets.
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: string): CSSStyleSheet | undefined;
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
- * Caches CSS rules in the special dictionary so that they can be expanded.
126
+ * Check if stylesheet exist
81
127
  * @param key - stylesheet key
82
- * @param styleSheet - {@link https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet | CSSStylesheet} instance
128
+ * @returns boolean flag
83
129
  */
84
- cacheRules: (key: string, stylesheet: CSSStyleSheet) => void;
130
+ has(key?: string): boolean;
85
131
  /**
86
- * Get expanded selectors by stylesheet key
132
+ * Switch stylesheet on
87
133
  * @param key - stylesheet key
88
- * @returns expanded selectors Set
89
134
  */
90
- getExpandedSelectors: (key: string) => Set<string>;
135
+ on(key?: string): boolean | undefined;
91
136
  /**
92
- * Expand existing CSS rule
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
- expandRule: (key: string, init: string, exp: string) => true | void;
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 TGetBEMSelector = (params: {
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 TGetBEMAttr = (
210
+ export type TResolveAttr = (
175
211
  /**
176
212
  * {@link https://en.bem.info/methodology/key-concepts/#block | Block}
177
213
  */
178
- b: string) => (
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
- * {@link BEM | https://en.bem.info/methodology/} resolver
224
+ * Style resolver
189
225
  * @description
190
- * Resolver object allows to create selectors/attribute by passed parts.
226
+ * Resolves stylesheets' selectors/attributes/identifiers
191
227
  */
192
- export interface IBEMResolver {
228
+ export interface IStyleResolver {
193
229
  /**
194
230
  * Selector resolver
195
231
  */
196
- selector: TGetBEMSelector;
232
+ selector: TResolveSelector;
197
233
  /**
198
234
  * Attribute resolver
199
235
  */
200
- attr: TGetBEMAttr;
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
- * BEM resolver getter
247
+ * Stylesheet resolver getter
204
248
  */
205
- export type TGetBEMResolver = (params: {
206
- mode: TStyleMode | null;
207
- }) => IBEMResolver;
249
+ export type TCreateResolver = (params?: {
250
+ mode?: TStyleMode | null;
251
+ }) => IStyleResolver;
208
252
  /**
209
253
  * Style processor
210
254
  * @description
211
- * Class that converts style object to CSSStylesheet string content
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
- * Base styles
217
- * @description
218
- * Contains base styles created in the constructor that define global variables and display modes.
259
+ * Compile style config to CSS stylesheet text content
260
+ * @param b - block key
261
+ * @param config - stylesheet config
219
262
  */
220
- baseStyles: string;
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
- * BEM resolver
223
- * @description
224
- * Allows to get BEM selectors/attributes by passed parts
272
+ * Collect config
273
+ * @param config - stylesheet config
274
+ * @param key - stylesheet key
225
275
  */
226
- bem: IBEMResolver;
276
+ use(config: TStyleSheetConfig, key?: string): string;
227
277
  /**
228
- * Create expanded selector with state
229
- * @param b
230
- * @param selector
278
+ * Get key of collected config
279
+ * @param config - stylesheet config
231
280
  */
232
- expandSelector(b: string, selector: string): [string, string];
281
+ getKey(config: TStyleSheetConfig): string | undefined;
233
282
  /**
234
- * Parse BEM selector
235
- * @param selector
283
+ * Get all collected keys
236
284
  */
237
- parseSelector(selector: string): {
238
- e?: string;
239
- m?: string;
240
- mv?: string;
241
- s?: string;
242
- };
285
+ getKeys(): string[];
243
286
  /**
244
- * Compile style config to CSS stylesheet text content
245
- * @param b - block key
246
- * @param config - stylesheet config
287
+ * Get all collected configs
247
288
  */
248
- compile(b: string, config: TStyleSheetConfig): string;
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
- * {@link IStyleManager | Style manager}
298
+ * Provider initial content
258
299
  */
259
- manager: IStyleManager;
300
+ initContent: TProviderInitContent;
260
301
  /**
261
- * {@link IStyleProcessor | Style processor}
302
+ * Provider settings
262
303
  */
263
- processor: IStyleProcessor;
304
+ settingsContent: TProviderSettings;
264
305
  /**
265
306
  * Use stylesheet
266
307
  * @param config - stylesheet config
267
- * @returns {@link IBEMResolver.attr | attribute resolver}
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 IBEMResolver.attr | attribute resolver}, that can create BEM selectors for config passed.
311
+ * It returns {@link IStyleResolver.attr | attribute resolver}, that can create BEM selectors for config passed.
271
312
  */
272
- useStyleSheet(config: TStyleSheetConfig): ReturnType<IBEMResolver['attr']>;
313
+ use(config: TStyleSheetConfig, key?: string): ReturnType<TResolveAttr>;
273
314
  /**
274
- * Compile stylesheet
275
- * @key - stylesheet key
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
- compileStyleSheet(key: string, config: TStyleSheetConfig): boolean | undefined;
318
+ usePublic(configs: Record<string, TStyleSheetConfig>): Record<string, ReturnType<TResolveAttr>>;
280
319
  /**
281
- * Expand stylesheet
282
- * @param key - stylesheet key
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
- expandStyleSheet(key: string, selectors: string[]): number | undefined;
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
- resolveStyleSheet(key: string): ReturnType<IStyleProcessor['bem']['attr']>;
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
- * Process configs
295
- * @param styles - stylesheet dictionary
296
- * @param ext - extra rules dictionary
352
+ * Get many CSS stylesheets
353
+ * @param target - target stylesheet configs and/or keys
297
354
  */
298
- processStyles(styles?: Record<string, TStyleSheetConfig>, ext?: Record<string, string[]>): void;
355
+ getMany(targets?: TStyleTarget[]): (CSSStyleSheet | undefined)[];
299
356
  }
300
357
  /**
301
358
  * Style dispatcher
302
359
  * @description
303
- * Class that allows to directly call the style provider's methods
360
+ * Dispatches style operations to provider
304
361
  */
305
362
  export interface IStyleDispatcher {
306
363
  /**
307
364
  * Use stylesheet
308
- * @see {@link IStyleProvider.useStyleSheet}
309
- */
310
- use: IStyleProvider['useStyleSheet'];
311
- /**
312
- * Compile stylesheet
313
- * @see {@link IStyleProvider.compileStyleSheet}
365
+ * @see {@link IStyleProvider.use}
314
366
  */
315
- compile: IStyleProvider['compileStyleSheet'];
367
+ use: IStyleProvider['use'];
316
368
  /**
317
- * Expand stylesheet
318
- * @see {@link IStyleProvider.expandStyleSheet}
369
+ * Use public stylesheet configs
370
+ * @see {@link IStyleProvider.usePublic}
319
371
  */
320
- expand: IStyleProvider['expandStyleSheet'];
372
+ usePublic: IStyleProvider['usePublic'];
321
373
  /**
322
- * Process configs
323
- * @see {@link IStyleProvider.processStyles}
374
+ * Use private stylesheet configs
375
+ * @see {@link IStyleProvider.usePrivate}
324
376
  */
325
- process: IStyleProvider['processStyles'];
377
+ usePrivate: IStyleProvider['usePrivate'];
326
378
  /**
327
379
  * Resolve stylesheet
328
- * @see {@link IStyleProvider.resolveStyleSheet}
380
+ * @see {@link IStyleProvider.resolve}
329
381
  */
330
- resolve: IStyleProvider['resolveStyleSheet'];
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
- * Stylesheet config
372
- * @description
373
- * Contains descriptions of rules, variables, keyframes, and interpolation dictionaries used within the stylesheet.
423
+ * Style themes
374
424
  */
375
- export type TStyleSheetConfig = {
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
- * Display mode values
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 element id
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?: string | null;
469
+ isolated?: '' | null;
460
470
  /**
461
- * Initializer stylesheet key
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
- initkey?: string | null;
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 {};