effcss 3.12.1 → 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/README.md +26 -22
- package/dist/index.js +2 -2
- package/dist/types/_provider/_process/atrules.d.ts +222 -0
- package/dist/types/_provider/_process/coef.d.ts +131 -0
- package/dist/types/_provider/_process/color.d.ts +37 -0
- package/dist/types/_provider/_process/palette.d.ts +105 -0
- package/dist/types/{src/_provider → _provider}/collect.d.ts +14 -10
- package/dist/types/{src/_provider → _provider}/manage.d.ts +17 -33
- package/dist/types/_provider/process.d.ts +84 -0
- package/dist/types/{src/_provider → _provider}/scope.d.ts +21 -6
- package/dist/types/_provider/theme.d.ts +49 -0
- package/dist/types/_provider/utils.d.ts +10 -0
- package/dist/types/{src/index.d.ts → index.d.ts} +60 -64
- package/package.json +3 -8
- package/dist/build/define-provider.min.js +0 -7
- package/dist/consumer.js +0 -7
- package/dist/types/build/defineProvider.d.ts +0 -1
- package/dist/types/src/_provider/_process/atrules.d.ts +0 -330
- package/dist/types/src/_provider/_process/base.d.ts +0 -11
- package/dist/types/src/_provider/_process/coef.d.ts +0 -3
- package/dist/types/src/_provider/_process/color.d.ts +0 -98
- package/dist/types/src/_provider/_process/palette.d.ts +0 -3
- package/dist/types/src/_provider/name.d.ts +0 -24
- package/dist/types/src/_provider/process.d.ts +0 -125
- package/dist/types/src/common.d.ts +0 -525
- package/dist/types/src/consumer.d.ts +0 -8
- /package/dist/types/{src/_provider → _provider}/_process/pseudo.d.ts +0 -0
- /package/dist/types/{src/_provider → _provider}/_process/units.d.ts +0 -0
- /package/dist/types/{src/_provider → _provider}/_process/utils.d.ts +0 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { TCreateScope } from '../../_provider/scope';
|
|
2
|
+
type THue = 'pri' | 'sec' | 'suc' | 'inf' | 'war' | 'dan';
|
|
3
|
+
type TLightness = 'xs' | 's' | 'm' | 'l' | 'xl';
|
|
4
|
+
type TChroma = 'gray' | 'pale' | 'base' | 'rich';
|
|
5
|
+
type TMode = 'bg' | 'fg';
|
|
6
|
+
/**
|
|
7
|
+
* Palette generator
|
|
8
|
+
* @description
|
|
9
|
+
* Allows to create palette colors
|
|
10
|
+
*/
|
|
11
|
+
export interface IPalette {
|
|
12
|
+
state: {
|
|
13
|
+
l: TLightness;
|
|
14
|
+
c: TChroma;
|
|
15
|
+
h: THue;
|
|
16
|
+
a: number;
|
|
17
|
+
m: TMode;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Returns `xs` lightness color
|
|
21
|
+
*/
|
|
22
|
+
get xs(): IPalette;
|
|
23
|
+
/**
|
|
24
|
+
* Returns `s` lightness color
|
|
25
|
+
*/
|
|
26
|
+
get s(): IPalette;
|
|
27
|
+
/**
|
|
28
|
+
* Returns `m` lightness color
|
|
29
|
+
*/
|
|
30
|
+
get m(): IPalette;
|
|
31
|
+
/**
|
|
32
|
+
* Returns `l` lightness color
|
|
33
|
+
*/
|
|
34
|
+
get l(): IPalette;
|
|
35
|
+
/**
|
|
36
|
+
* Returns `xl` lightness color
|
|
37
|
+
*/
|
|
38
|
+
get xl(): IPalette;
|
|
39
|
+
/**
|
|
40
|
+
* Returns lightness color dictionary
|
|
41
|
+
*/
|
|
42
|
+
get lightness(): Record<TLightness, IPalette>;
|
|
43
|
+
/**
|
|
44
|
+
* Returns zero chroma color
|
|
45
|
+
*/
|
|
46
|
+
get gray(): IPalette;
|
|
47
|
+
/**
|
|
48
|
+
* Returns pale chroma color
|
|
49
|
+
*/
|
|
50
|
+
get pale(): IPalette;
|
|
51
|
+
/**
|
|
52
|
+
* Returns base chroma color
|
|
53
|
+
*/
|
|
54
|
+
get base(): IPalette;
|
|
55
|
+
/**
|
|
56
|
+
* Returns rich chroma color
|
|
57
|
+
*/
|
|
58
|
+
get rich(): IPalette;
|
|
59
|
+
/**
|
|
60
|
+
* Returns chroma color dictionary
|
|
61
|
+
*/
|
|
62
|
+
get chroma(): Record<TChroma, IPalette>;
|
|
63
|
+
/**
|
|
64
|
+
* Returns primary hue color
|
|
65
|
+
*/
|
|
66
|
+
get pri(): IPalette;
|
|
67
|
+
/**
|
|
68
|
+
* Returns secondary hue color
|
|
69
|
+
*/
|
|
70
|
+
get sec(): IPalette;
|
|
71
|
+
/**
|
|
72
|
+
* Returns success hue color
|
|
73
|
+
*/
|
|
74
|
+
get suc(): IPalette;
|
|
75
|
+
/**
|
|
76
|
+
* Returns info hue color
|
|
77
|
+
*/
|
|
78
|
+
get inf(): IPalette;
|
|
79
|
+
/**
|
|
80
|
+
* Returns warning hue color
|
|
81
|
+
*/
|
|
82
|
+
get war(): IPalette;
|
|
83
|
+
/**
|
|
84
|
+
* Returns danger hue color
|
|
85
|
+
*/
|
|
86
|
+
get dan(): IPalette;
|
|
87
|
+
/**
|
|
88
|
+
* Returns hue color dictionary
|
|
89
|
+
*/
|
|
90
|
+
get hue(): Record<THue, IPalette>;
|
|
91
|
+
/**
|
|
92
|
+
* Returns specified alpha color
|
|
93
|
+
*/
|
|
94
|
+
alpha(a?: number): IPalette;
|
|
95
|
+
/**
|
|
96
|
+
* Returns background color
|
|
97
|
+
*/
|
|
98
|
+
get bg(): IPalette;
|
|
99
|
+
/**
|
|
100
|
+
* Returns foreground color
|
|
101
|
+
*/
|
|
102
|
+
get fg(): IPalette;
|
|
103
|
+
}
|
|
104
|
+
export declare const resolvePalette: (varExp: ReturnType<ReturnType<TCreateScope>>["varExp"]) => IPalette;
|
|
105
|
+
export {};
|
|
@@ -1,24 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
* Create stylesheet maker collector
|
|
3
|
-
* @param params - collector params
|
|
4
|
-
*/
|
|
5
|
-
export declare const createCollector: () => {
|
|
1
|
+
export type TCollector = {
|
|
6
2
|
/**
|
|
7
3
|
* Collect maker
|
|
8
4
|
* @param maker - stylesheet maker
|
|
9
5
|
* @param key - stylesheet key
|
|
10
6
|
*/
|
|
11
|
-
use(maker: Function
|
|
7
|
+
use(maker: Function): string;
|
|
12
8
|
/**
|
|
13
|
-
*
|
|
14
|
-
* @param
|
|
9
|
+
* Replace collected maker
|
|
10
|
+
* @param maker - next maker
|
|
11
|
+
* @param original - original maker
|
|
15
12
|
*/
|
|
16
|
-
|
|
13
|
+
remake(maker: Function, key: Function): string;
|
|
17
14
|
/**
|
|
18
15
|
* Get key of collected maker
|
|
19
16
|
* @param maker - stylesheet maker
|
|
20
17
|
*/
|
|
21
|
-
|
|
18
|
+
key(maker?: Function): string;
|
|
22
19
|
/**
|
|
23
20
|
* Get all collected keys
|
|
24
21
|
*/
|
|
@@ -28,3 +25,10 @@ export declare const createCollector: () => {
|
|
|
28
25
|
*/
|
|
29
26
|
makers: Record<string, Function>;
|
|
30
27
|
};
|
|
28
|
+
/**
|
|
29
|
+
* Create stylesheet maker collector
|
|
30
|
+
* @param params - collector params
|
|
31
|
+
*/
|
|
32
|
+
export declare const createCollector: ({ prefix }: {
|
|
33
|
+
prefix: string;
|
|
34
|
+
}) => TCollector;
|
|
@@ -8,21 +8,16 @@ type TStyleRoot = {
|
|
|
8
8
|
/**
|
|
9
9
|
* Style manager
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
export type TManager = {
|
|
12
12
|
/**
|
|
13
13
|
* Get stylesheet by key
|
|
14
14
|
* @param key - stylesheet key
|
|
15
15
|
*/
|
|
16
16
|
get(key?: string): CSSStyleSheet | undefined;
|
|
17
|
-
/**
|
|
18
|
-
* Get index of stylesheet
|
|
19
|
-
* @param styleSheet - CSSStylesheet
|
|
20
|
-
*/
|
|
21
|
-
getIndex(styleSheet: CSSStyleSheet): number;
|
|
22
17
|
/**
|
|
23
18
|
* Get all stylesheets dictionary
|
|
24
19
|
*/
|
|
25
|
-
|
|
20
|
+
all(): Record<string, CSSStyleSheet>;
|
|
26
21
|
/**
|
|
27
22
|
* Add stylesheet
|
|
28
23
|
* @param key - stylesheet key
|
|
@@ -34,12 +29,6 @@ interface IStyleManager {
|
|
|
34
29
|
* @param key - stylesheet key
|
|
35
30
|
*/
|
|
36
31
|
hydrate(key: string): string | undefined;
|
|
37
|
-
/**
|
|
38
|
-
* Replace stylesheet content
|
|
39
|
-
* @param key - stylesheet key
|
|
40
|
-
* @param styles - stylesheet content
|
|
41
|
-
*/
|
|
42
|
-
replace(key: string, styles: string): TOptBool;
|
|
43
32
|
/**
|
|
44
33
|
* Remove stylesheet
|
|
45
34
|
* @param key - stylesheet key
|
|
@@ -56,11 +45,6 @@ interface IStyleManager {
|
|
|
56
45
|
* @param styles - stylesheet content
|
|
57
46
|
*/
|
|
58
47
|
pack(key: string, styles: string): TOptBool;
|
|
59
|
-
/**
|
|
60
|
-
* Check if stylesheet exist
|
|
61
|
-
* @param key - stylesheet key
|
|
62
|
-
*/
|
|
63
|
-
has(key?: string): boolean;
|
|
64
48
|
/**
|
|
65
49
|
* Is stylesheet on
|
|
66
50
|
* @param key - stylesheet key
|
|
@@ -70,17 +54,12 @@ interface IStyleManager {
|
|
|
70
54
|
* Switch stylesheet on
|
|
71
55
|
* @param key - stylesheet key
|
|
72
56
|
*/
|
|
73
|
-
on(...keys: (string | undefined)[]):
|
|
57
|
+
on(...keys: (string | undefined)[]): void;
|
|
74
58
|
/**
|
|
75
59
|
* Switch stylesheet off
|
|
76
60
|
* @param key - stylesheet key
|
|
77
61
|
*/
|
|
78
|
-
off(...keys: (string | undefined)[]):
|
|
79
|
-
/**
|
|
80
|
-
* Apply stylesheets to style root
|
|
81
|
-
* @param consumer - style root
|
|
82
|
-
*/
|
|
83
|
-
apply(consumer: TStyleRoot): void;
|
|
62
|
+
off(...keys: (string | undefined)[]): void;
|
|
84
63
|
/**
|
|
85
64
|
* Register style root
|
|
86
65
|
* @param consumer - style root
|
|
@@ -91,15 +70,20 @@ interface IStyleManager {
|
|
|
91
70
|
* @param consumer - style root
|
|
92
71
|
*/
|
|
93
72
|
unregister(consumer: TStyleRoot): void;
|
|
94
|
-
|
|
95
|
-
* Apply style changes to dependent nodes
|
|
96
|
-
*/
|
|
97
|
-
notify(): void;
|
|
98
|
-
}
|
|
73
|
+
};
|
|
99
74
|
/**
|
|
100
|
-
* Create {@link
|
|
75
|
+
* Create {@link TManager | style manager}
|
|
101
76
|
* @param params - manager params
|
|
102
|
-
* @returns
|
|
77
|
+
* @returns TManager
|
|
103
78
|
*/
|
|
104
|
-
export declare function createManager(initStyles?:
|
|
79
|
+
export declare function createManager({ initStyles, emulate }?: {
|
|
80
|
+
initStyles?: {
|
|
81
|
+
dataset?: {
|
|
82
|
+
effcss?: string;
|
|
83
|
+
};
|
|
84
|
+
disabled: boolean;
|
|
85
|
+
textContent: string | null;
|
|
86
|
+
}[];
|
|
87
|
+
emulate?: boolean;
|
|
88
|
+
}): TManager;
|
|
105
89
|
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { TCreateScope } from './scope';
|
|
2
|
+
import { resolveAtRules } from './_process/atrules';
|
|
3
|
+
import { resolveUnits } from './_process/units';
|
|
4
|
+
import { resolvePseudo } from './_process/pseudo';
|
|
5
|
+
import { resolveColor } from './_process/color';
|
|
6
|
+
import { resolvePalette } from './_process/palette';
|
|
7
|
+
import { resolveCoef } from './_process/coef';
|
|
8
|
+
import { dash, comma, space, range, each, when, merge } from './utils';
|
|
9
|
+
type TScope = ReturnType<ReturnType<TCreateScope>>;
|
|
10
|
+
export interface IMakerParams {
|
|
11
|
+
dash: typeof dash;
|
|
12
|
+
comma: typeof comma;
|
|
13
|
+
space: typeof space;
|
|
14
|
+
range: typeof range;
|
|
15
|
+
each: typeof each;
|
|
16
|
+
merge: typeof merge;
|
|
17
|
+
when: typeof when;
|
|
18
|
+
/**
|
|
19
|
+
* BEM selector resolver
|
|
20
|
+
*/
|
|
21
|
+
bem: TScope['selector'];
|
|
22
|
+
/**
|
|
23
|
+
* CSS units
|
|
24
|
+
*/
|
|
25
|
+
units: ReturnType<typeof resolveUnits>;
|
|
26
|
+
/**
|
|
27
|
+
* Pseudoclasses and pseudoelements
|
|
28
|
+
*/
|
|
29
|
+
pseudo: ReturnType<typeof resolvePseudo>;
|
|
30
|
+
/**
|
|
31
|
+
* At-rules
|
|
32
|
+
*/
|
|
33
|
+
at: ReturnType<typeof resolveAtRules>;
|
|
34
|
+
/**
|
|
35
|
+
* Colors
|
|
36
|
+
*/
|
|
37
|
+
color: ReturnType<typeof resolveColor>;
|
|
38
|
+
/**
|
|
39
|
+
* Color palette
|
|
40
|
+
*/
|
|
41
|
+
palette: ReturnType<typeof resolvePalette>;
|
|
42
|
+
/**
|
|
43
|
+
* Coefficient
|
|
44
|
+
*/
|
|
45
|
+
coef: ReturnType<typeof resolveCoef>;
|
|
46
|
+
/**
|
|
47
|
+
* Resolve theme variable
|
|
48
|
+
* @param name - name
|
|
49
|
+
* @param fallback - fallback value
|
|
50
|
+
*/
|
|
51
|
+
themeVar: TScope['varExp'];
|
|
52
|
+
/**
|
|
53
|
+
* Scalable size value
|
|
54
|
+
*/
|
|
55
|
+
size: (coef?: number | string) => string;
|
|
56
|
+
/**
|
|
57
|
+
* Scalable time value
|
|
58
|
+
*/
|
|
59
|
+
time: (coef?: number | string) => string;
|
|
60
|
+
/**
|
|
61
|
+
* Scalable angle value
|
|
62
|
+
*/
|
|
63
|
+
angle: (coef?: number | string) => string;
|
|
64
|
+
}
|
|
65
|
+
export type TProcessor = {
|
|
66
|
+
/**
|
|
67
|
+
* Compile stylesheet maker to CSSStylesheet content
|
|
68
|
+
* @param params - params
|
|
69
|
+
*/
|
|
70
|
+
compile(params: {
|
|
71
|
+
key: string;
|
|
72
|
+
maker: (params: IMakerParams) => object;
|
|
73
|
+
}): string;
|
|
74
|
+
};
|
|
75
|
+
type TCreateProcessor = (params: {
|
|
76
|
+
scope: ReturnType<TCreateScope>;
|
|
77
|
+
globalKey: string;
|
|
78
|
+
}) => TProcessor;
|
|
79
|
+
/**
|
|
80
|
+
* Create style processor
|
|
81
|
+
* @param params - processor params
|
|
82
|
+
*/
|
|
83
|
+
export declare const createProcessor: TCreateProcessor;
|
|
84
|
+
export {};
|
|
@@ -8,12 +8,18 @@ type TBlocks<T> = Exclude<keyof T, symbol | number>;
|
|
|
8
8
|
type TElems<T> = T extends object ? {
|
|
9
9
|
[K in keyof T]: `${Exclude<K, symbol>}${T[K] extends object ? `.${Exclude<keyof T[K], symbol | ''>}` : never}`;
|
|
10
10
|
}[keyof T] : never;
|
|
11
|
+
type TLeaves<T> = T extends object ? {
|
|
12
|
+
[K in keyof T]: `${Exclude<K, symbol>}${TLeaves<T[K]> extends never ? "" : `.${TLeaves<T[K]>}`}`;
|
|
13
|
+
}[keyof T] : never;
|
|
11
14
|
type TMods<T> = T extends object ? {
|
|
12
15
|
[K in keyof T]: `${Exclude<K, symbol>}${'' | Paths<T[K]> extends '' ? '' : `.${Paths<T[K]>}`}`;
|
|
13
16
|
}[keyof T] : T extends string ? T : never;
|
|
14
17
|
type TStringBEM<T> = TBlocks<T> | TMods<T> | TElems<T>;
|
|
15
18
|
type TBEM<T> = TDeepPartial<T> | TStringBEM<T> | TStringBEM<T>[];
|
|
16
19
|
type TStyleSheet = Record<string, Record<string, Record<string, string | number>>>;
|
|
20
|
+
export type Leaves<T> = T extends object ? {
|
|
21
|
+
[K in keyof T]: `${Exclude<K, symbol>}${Leaves<T[K]> extends never ? '' : `.${Leaves<T[K]>}`}`;
|
|
22
|
+
}[keyof T] : never;
|
|
17
23
|
export type TMonoResolver<T extends TStyleSheet, B extends keyof T, E extends keyof T[B]> = {
|
|
18
24
|
/**
|
|
19
25
|
* Specify block
|
|
@@ -37,13 +43,22 @@ export type TMonoResolver<T extends TStyleSheet, B extends keyof T, E extends ke
|
|
|
37
43
|
[key in string]: string;
|
|
38
44
|
};
|
|
39
45
|
};
|
|
40
|
-
type TResolveSelector = <T extends TStyleSheet>(params:
|
|
46
|
+
type TResolveSelector = <T extends TStyleSheet>(params: TStringBEM<T>) => string;
|
|
41
47
|
type TResolveAttr = {
|
|
42
48
|
<T extends TStyleSheet>(params: TBEM<T>): Record<string, string>;
|
|
43
49
|
<T extends TStyleSheet>(): TMonoResolver<T, "", "">;
|
|
44
50
|
};
|
|
45
51
|
type TParts = (string | number)[];
|
|
46
|
-
type
|
|
52
|
+
export type TDefaultTheme = {
|
|
53
|
+
angle: number;
|
|
54
|
+
size: number;
|
|
55
|
+
time: number;
|
|
56
|
+
coef: Record<number, number>;
|
|
57
|
+
hue: Record<'pri' | 'sec' | 'suc' | 'inf' | 'war' | 'dan', number>;
|
|
58
|
+
lightness: Record<'bg' | 'fg', Record<'xs' | 's' | 'm' | 'l' | 'xl', number>>;
|
|
59
|
+
chroma: Record<'bg' | 'fg', Record<'pale' | 'base' | 'rich' | 'gray', number>>;
|
|
60
|
+
};
|
|
61
|
+
export type TScope = {
|
|
47
62
|
/**
|
|
48
63
|
* BEM selector resolver
|
|
49
64
|
*/
|
|
@@ -55,20 +70,20 @@ type TScope = {
|
|
|
55
70
|
/**
|
|
56
71
|
* Name resolver
|
|
57
72
|
*/
|
|
58
|
-
name: (
|
|
73
|
+
name: (parts: TParts | string) => string;
|
|
59
74
|
/**
|
|
60
75
|
* Var name
|
|
61
76
|
*/
|
|
62
|
-
varName: (
|
|
77
|
+
varName: (name: TParts | string) => string;
|
|
63
78
|
/**
|
|
64
79
|
* Var expression
|
|
65
80
|
*/
|
|
66
|
-
varExp: (
|
|
81
|
+
varExp: <T extends Record<string, object | number | string | boolean> = TDefaultTheme>(name: TLeaves<T>, fallback?: string | number) => string;
|
|
67
82
|
};
|
|
68
83
|
/**
|
|
69
84
|
* Style scope resolver
|
|
70
85
|
*/
|
|
71
|
-
type TScopeResolver = {
|
|
86
|
+
export type TScopeResolver = {
|
|
72
87
|
(key: string): TScope;
|
|
73
88
|
dict?: Record<string, Record<string, string>>;
|
|
74
89
|
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { TScope } from './scope';
|
|
2
|
+
type TThemeParams<T extends object> = Partial<T> & {
|
|
3
|
+
$light?: Partial<T>;
|
|
4
|
+
$dark?: Partial<T>;
|
|
5
|
+
};
|
|
6
|
+
type TThemeAction = {
|
|
7
|
+
type: 'delete';
|
|
8
|
+
payload: {
|
|
9
|
+
name: string;
|
|
10
|
+
};
|
|
11
|
+
} | {
|
|
12
|
+
type: 'update';
|
|
13
|
+
payload: {
|
|
14
|
+
params: object;
|
|
15
|
+
name?: string;
|
|
16
|
+
};
|
|
17
|
+
} | {
|
|
18
|
+
type: 'add';
|
|
19
|
+
payload: {
|
|
20
|
+
params: object;
|
|
21
|
+
name: string;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export type TThemeValue = {
|
|
25
|
+
[key in (string | number)]: string | number | boolean | TThemeValue;
|
|
26
|
+
};
|
|
27
|
+
export type TThemeController = {
|
|
28
|
+
get(name?: string): TThemeValue;
|
|
29
|
+
add(params: TThemeValue, name: string): void;
|
|
30
|
+
delete(name: string): void;
|
|
31
|
+
update(params: TThemeValue, name?: string): void;
|
|
32
|
+
switch(name?: string): void;
|
|
33
|
+
vars<T extends object = object>(theme?: string): TThemeParams<T>;
|
|
34
|
+
get list(): string[];
|
|
35
|
+
get current(): string | '';
|
|
36
|
+
get all(): Record<string, object>;
|
|
37
|
+
get actions(): TThemeAction[];
|
|
38
|
+
};
|
|
39
|
+
export declare const createThemeController: ({ provider, init, scope, onChange }: {
|
|
40
|
+
provider: {
|
|
41
|
+
getAttribute(name: string): string | null;
|
|
42
|
+
removeAttribute(name: string): void;
|
|
43
|
+
setAttribute(name: string, value: string): void;
|
|
44
|
+
};
|
|
45
|
+
init?: TThemeAction[];
|
|
46
|
+
onChange: () => void;
|
|
47
|
+
scope: TScope;
|
|
48
|
+
}) => TThemeController;
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type TStrOrNum = string | number;
|
|
2
|
+
type TJoinArr = (...val: TStrOrNum[]) => string;
|
|
3
|
+
export declare const range: (size: number, handler: (k: number) => object) => object;
|
|
4
|
+
export declare const each: <V extends Record<TStrOrNum, any>>(rules: V, handler: (k: V extends ArrayLike<any> ? string : keyof V, v: V extends ArrayLike<any> ? NoInfer<V[number]> : NoInfer<V[keyof V]>) => object) => object;
|
|
5
|
+
export declare const when: (condition: number | boolean | undefined | null, rules: object, otherwise?: object) => object;
|
|
6
|
+
export declare const dash: TJoinArr;
|
|
7
|
+
export declare const comma: TJoinArr;
|
|
8
|
+
export declare const space: TJoinArr;
|
|
9
|
+
export declare const merge: (target: Record<string, any>, ...sources: any[]) => any;
|
|
10
|
+
export {};
|
|
@@ -1,13 +1,44 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import type {
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import type { TProcessor } from './_provider/process';
|
|
2
|
+
import type { TCollector } from './_provider/collect';
|
|
3
|
+
import type { TScopeResolver } from './_provider/scope';
|
|
4
|
+
import type { TThemeController } from './_provider/theme';
|
|
5
|
+
/**
|
|
6
|
+
* Provider attributes
|
|
7
|
+
*/
|
|
8
|
+
export type TProviderAttrs = {
|
|
9
|
+
/**
|
|
10
|
+
* Stylesheet key prefix
|
|
11
|
+
*/
|
|
12
|
+
pre: string;
|
|
13
|
+
/**
|
|
14
|
+
* BEM selector generation mode
|
|
15
|
+
* @description
|
|
16
|
+
* `a` - data-attributes
|
|
17
|
+
* `c` - classes
|
|
18
|
+
*/
|
|
19
|
+
mode: 'a' | 'c';
|
|
20
|
+
/**
|
|
21
|
+
* BEM selectors minification
|
|
22
|
+
*/
|
|
23
|
+
min: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Root font size in px
|
|
26
|
+
*/
|
|
27
|
+
size: number;
|
|
28
|
+
/**
|
|
29
|
+
* Root time in ms
|
|
30
|
+
*/
|
|
31
|
+
time: number;
|
|
32
|
+
/**
|
|
33
|
+
* Root angle in deg
|
|
34
|
+
*/
|
|
35
|
+
angle: number;
|
|
36
|
+
};
|
|
37
|
+
type TResolveAttr = ReturnType<TScopeResolver>['attr'];
|
|
7
38
|
/**
|
|
8
39
|
* StyleSheet maker
|
|
9
40
|
*/
|
|
10
|
-
export type TStyleSheetMaker = Parameters<
|
|
41
|
+
export type TStyleSheetMaker = Parameters<TProcessor['compile']>[0]['maker'];
|
|
11
42
|
/**
|
|
12
43
|
* StyleSheet maker utils
|
|
13
44
|
*/
|
|
@@ -22,11 +53,14 @@ type TStyleTarget = string | TStyleSheetMaker;
|
|
|
22
53
|
* Basic interface for style provider component.
|
|
23
54
|
*/
|
|
24
55
|
export interface IStyleProvider {
|
|
56
|
+
/**
|
|
57
|
+
* Provider tag name
|
|
58
|
+
*/
|
|
25
59
|
get tagName(): string;
|
|
26
60
|
/**
|
|
27
61
|
* Get prefix
|
|
28
62
|
*/
|
|
29
|
-
get
|
|
63
|
+
get pre(): string;
|
|
30
64
|
/**
|
|
31
65
|
* Get mode
|
|
32
66
|
*/
|
|
@@ -35,24 +69,14 @@ export interface IStyleProvider {
|
|
|
35
69
|
* Get min flag
|
|
36
70
|
*/
|
|
37
71
|
get min(): boolean;
|
|
38
|
-
/**
|
|
39
|
-
* Get hydrate flag
|
|
40
|
-
* @deprecated The flag will be removed in v4
|
|
41
|
-
*/
|
|
42
|
-
get hydrate(): boolean | null;
|
|
43
72
|
/**
|
|
44
73
|
* Get stylesheet makers
|
|
45
74
|
*/
|
|
46
|
-
get makers():
|
|
75
|
+
get makers(): TCollector['makers'];
|
|
47
76
|
/**
|
|
48
|
-
*
|
|
77
|
+
* Theme controller
|
|
49
78
|
*/
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Set theme value
|
|
53
|
-
* @param val - theme value
|
|
54
|
-
*/
|
|
55
|
-
set theme(val: string);
|
|
79
|
+
theme: TThemeController;
|
|
56
80
|
/**
|
|
57
81
|
* Get root size value
|
|
58
82
|
*/
|
|
@@ -81,48 +105,22 @@ export interface IStyleProvider {
|
|
|
81
105
|
*/
|
|
82
106
|
set angle(val: number | null);
|
|
83
107
|
/**
|
|
84
|
-
*
|
|
85
|
-
*/
|
|
86
|
-
get settings(): Partial<TProviderSettings>;
|
|
87
|
-
/**
|
|
88
|
-
* Set provider settings
|
|
89
|
-
*/
|
|
90
|
-
set settings(val: Partial<TProviderSettings>);
|
|
91
|
-
/**
|
|
92
|
-
* Use stylesheet maker
|
|
93
|
-
* @param maker - stylesheet maker
|
|
94
|
-
* @param key - stylesheet key
|
|
95
|
-
* @param force - force generation
|
|
96
|
-
* @returns {@link TResolveAttr | attribute resolver}
|
|
97
|
-
*/
|
|
98
|
-
use(maker: TStyleSheetMaker, key?: string, force?: boolean): TResolveAttr;
|
|
99
|
-
/**
|
|
100
|
-
* Use public stylesheet makers
|
|
108
|
+
* Use stylesheet makers
|
|
101
109
|
* @param makers - stylesheet makers
|
|
102
110
|
*/
|
|
103
|
-
|
|
111
|
+
use: (...makers: TStyleSheetMaker[]) => TResolveAttr[];
|
|
104
112
|
/**
|
|
105
|
-
*
|
|
106
|
-
* @param
|
|
107
|
-
|
|
108
|
-
usePrivate(makers: TStyleSheetMaker[]): TResolveAttr[];
|
|
109
|
-
/**
|
|
110
|
-
* Resolve stylesheet
|
|
111
|
-
* @param key - stylesheet key
|
|
112
|
-
* @returns BEM attribute resolver for stylesheet
|
|
113
|
+
* Remake stylesheet
|
|
114
|
+
* @param maker - stylesheet maker
|
|
115
|
+
* @param original - original maker
|
|
113
116
|
*/
|
|
114
|
-
|
|
117
|
+
remake(maker: TStyleSheetMaker, original?: TStyleSheetMaker): TResolveAttr;
|
|
115
118
|
/**
|
|
116
119
|
* Prepare CSS from config
|
|
117
120
|
* @param maker - stylesheet maker
|
|
118
121
|
* @param key - stylesheet key
|
|
119
122
|
*/
|
|
120
123
|
css(maker: TStyleSheetMaker, key: string): string;
|
|
121
|
-
/**
|
|
122
|
-
* Resolve target key
|
|
123
|
-
* @param target - style target
|
|
124
|
-
*/
|
|
125
|
-
key(target: TStyleTarget): string | undefined;
|
|
126
124
|
/**
|
|
127
125
|
* Is stylesheet on
|
|
128
126
|
* @param key - stylesheet key
|
|
@@ -132,24 +130,23 @@ export interface IStyleProvider {
|
|
|
132
130
|
* Switch stylesheets on
|
|
133
131
|
* @param targets - target stylesheet maker or key
|
|
134
132
|
*/
|
|
135
|
-
on(...targets: TStyleTarget[]):
|
|
133
|
+
on(...targets: TStyleTarget[]): void;
|
|
136
134
|
/**
|
|
137
135
|
* Switch stylesheets off
|
|
138
136
|
* @param targets - target stylesheet maker or key
|
|
139
137
|
*/
|
|
140
|
-
off(...targets: TStyleTarget[]):
|
|
138
|
+
off(...targets: TStyleTarget[]): void;
|
|
141
139
|
/**
|
|
142
140
|
* Get CSS stylesheets
|
|
143
141
|
* @param targets - target stylesheet makers and/or keys
|
|
144
142
|
*/
|
|
145
143
|
stylesheets(targets?: TStyleTarget[]): (CSSStyleSheet | undefined)[];
|
|
146
|
-
stylesheets(...targets: TStyleTarget[]): (CSSStyleSheet | undefined)[];
|
|
147
144
|
/**
|
|
148
145
|
* String representation that allows save or send current state
|
|
149
146
|
*/
|
|
150
147
|
toString(): string;
|
|
151
148
|
}
|
|
152
|
-
export type
|
|
149
|
+
export type TBaseStyleSheetMaker = {
|
|
153
150
|
/**
|
|
154
151
|
* Main block
|
|
155
152
|
*/
|
|
@@ -165,8 +162,9 @@ export type TBaseStyleSheet = {
|
|
|
165
162
|
};
|
|
166
163
|
};
|
|
167
164
|
};
|
|
168
|
-
type
|
|
169
|
-
|
|
165
|
+
export type IStyleProviderScript = IStyleProvider & HTMLScriptElement;
|
|
166
|
+
type TUseStylePropviderParams = {
|
|
167
|
+
attrs?: Partial<TProviderAttrs>;
|
|
170
168
|
/**
|
|
171
169
|
* Don`t send provider script tag from server-side
|
|
172
170
|
*/
|
|
@@ -175,15 +173,13 @@ type TUseStylePropviderParams = Partial<TProviderSettings & {
|
|
|
175
173
|
* Create Style Provider emulation
|
|
176
174
|
*/
|
|
177
175
|
emulate?: boolean;
|
|
178
|
-
}
|
|
176
|
+
};
|
|
179
177
|
type TUseStyleProvider = {
|
|
180
178
|
(settings?: TUseStylePropviderParams): IStyleProvider;
|
|
181
179
|
isDefined?: boolean;
|
|
182
180
|
};
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
*/
|
|
186
|
-
export declare function defineProvider(settings?: Partial<TProviderSettings>): boolean;
|
|
181
|
+
export declare const TAG_NAME: string;
|
|
182
|
+
export declare const DEFAULT_ATTRS: Record<string, string>;
|
|
187
183
|
/**
|
|
188
184
|
* Use Style Provider
|
|
189
185
|
* @description
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "effcss",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "Self-confident CSS-in-JS",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -17,17 +17,12 @@
|
|
|
17
17
|
"author": "Marat Sabitov",
|
|
18
18
|
"license": "Apache-2.0",
|
|
19
19
|
"main": "dist/index.js",
|
|
20
|
-
"types": "dist/types/
|
|
20
|
+
"types": "dist/types/index.d.ts",
|
|
21
21
|
"exports": {
|
|
22
22
|
".": {
|
|
23
|
-
"types": "./dist/types/
|
|
23
|
+
"types": "./dist/types/index.d.ts",
|
|
24
24
|
"import": "./dist/index.js",
|
|
25
25
|
"require": "./dist/index.js"
|
|
26
|
-
},
|
|
27
|
-
"./consumer": {
|
|
28
|
-
"types": "./dist/types/src/consumer.d.ts",
|
|
29
|
-
"import": "./dist/consumer.js",
|
|
30
|
-
"require": "./dist/consumer.js"
|
|
31
26
|
}
|
|
32
27
|
},
|
|
33
28
|
"devDependencies": {
|