effcss 2.2.0 → 3.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 +150 -97
- package/dist/build/define-provider.min.js +2 -2
- package/dist/consumer.js +7 -0
- package/dist/index.js +7 -1
- package/dist/types/src/_provider/_process/atrules.d.ts +148 -0
- package/dist/types/src/_provider/_process/base.d.ts +12 -0
- package/dist/types/src/_provider/_process/color.d.ts +97 -0
- package/dist/types/src/_provider/_process/pseudo.d.ts +146 -0
- package/dist/types/src/_provider/_process/units.d.ts +16 -0
- package/dist/types/src/_provider/_process/utils.d.ts +1 -0
- package/dist/types/src/_provider/manage.d.ts +96 -1
- package/dist/types/src/_provider/process.d.ts +93 -17
- package/dist/types/src/common.d.ts +172 -0
- package/dist/types/src/consumer.d.ts +7 -0
- package/dist/types/src/index.d.ts +123 -2
- package/package.json +49 -60
- package/dist/constants.js +0 -1
- package/dist/types/src/constants.d.ts +0 -89
- package/dist/types/src/types.d.ts +0 -561
- package/dist/types/src/utils/browser.d.ts +0 -123
- package/dist/types/src/utils/common.d.ts +0 -75
- package/dist/types/vitest.config.d.ts +0 -2
- package/dist/utils/browser.js +0 -1
- package/dist/utils/common.js +0 -1
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { TCreateScope } from '../../common';
|
|
2
|
+
type TChangeStr = (val: string) => string;
|
|
3
|
+
type TChangeColor = (color: string | object, val?: number | string) => string;
|
|
4
|
+
type TPaletteState = {
|
|
5
|
+
l: string | number;
|
|
6
|
+
c: string | number;
|
|
7
|
+
h: string | number;
|
|
8
|
+
a: string | number;
|
|
9
|
+
};
|
|
10
|
+
export declare const resolveColor: (vars: ReturnType<ReturnType<TCreateScope>>["varExp"]) => {
|
|
11
|
+
/**
|
|
12
|
+
* Create color object
|
|
13
|
+
*/
|
|
14
|
+
create: (params?: Partial<TPaletteState>) => {
|
|
15
|
+
/**
|
|
16
|
+
* Palette state
|
|
17
|
+
*/
|
|
18
|
+
state: TPaletteState;
|
|
19
|
+
merge: <Theme>(value: Theme extends Partial<TPaletteState> ? Theme : object) => /*elided*/ any;
|
|
20
|
+
/**
|
|
21
|
+
* Set lightness
|
|
22
|
+
* @param l - lightness value
|
|
23
|
+
*/
|
|
24
|
+
l: <Theme>(val: Theme extends {
|
|
25
|
+
l: Record<string, number | string>;
|
|
26
|
+
} ? Exclude<keyof Theme["l"], symbol> : string | number) => /*elided*/ any;
|
|
27
|
+
/**
|
|
28
|
+
* Set chroma
|
|
29
|
+
* @param c - chroma value
|
|
30
|
+
*/
|
|
31
|
+
c: <Theme>(val: Theme extends {
|
|
32
|
+
c: Record<string, number | string>;
|
|
33
|
+
} ? Exclude<keyof Theme["c"], symbol> : string | number) => /*elided*/ any;
|
|
34
|
+
/**
|
|
35
|
+
* Set hue
|
|
36
|
+
* @param h - hue value
|
|
37
|
+
*/
|
|
38
|
+
h: <Theme>(val: Theme extends {
|
|
39
|
+
h: Record<string, number | string>;
|
|
40
|
+
} ? Exclude<keyof Theme["h"], symbol> : string | number) => /*elided*/ any;
|
|
41
|
+
/**
|
|
42
|
+
* Set alpha
|
|
43
|
+
* @param value - alpha value
|
|
44
|
+
*/
|
|
45
|
+
a: <Theme>(val: Theme extends {
|
|
46
|
+
a: Record<string, number | string>;
|
|
47
|
+
} ? Exclude<keyof Theme["a"], symbol> : string | number) => /*elided*/ any;
|
|
48
|
+
/**
|
|
49
|
+
* Color string
|
|
50
|
+
*/
|
|
51
|
+
readonly s: string;
|
|
52
|
+
toString(): string;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* oklch()
|
|
56
|
+
*/
|
|
57
|
+
oklch: TChangeStr;
|
|
58
|
+
/**
|
|
59
|
+
* Increase color lightness
|
|
60
|
+
*/
|
|
61
|
+
lighten: TChangeColor;
|
|
62
|
+
/**
|
|
63
|
+
* Decrease color lightness
|
|
64
|
+
*/
|
|
65
|
+
darken: TChangeColor;
|
|
66
|
+
/**
|
|
67
|
+
* Increase color chroma
|
|
68
|
+
*/
|
|
69
|
+
saturate: TChangeColor;
|
|
70
|
+
/**
|
|
71
|
+
* Decrease color chroma
|
|
72
|
+
*/
|
|
73
|
+
desaturate: TChangeColor;
|
|
74
|
+
/**
|
|
75
|
+
* Increase color alpha
|
|
76
|
+
*/
|
|
77
|
+
fadein: TChangeColor;
|
|
78
|
+
/**
|
|
79
|
+
* Decrease color alpha
|
|
80
|
+
*/
|
|
81
|
+
fadeout: TChangeColor;
|
|
82
|
+
/**
|
|
83
|
+
* Rotate color hue
|
|
84
|
+
*/
|
|
85
|
+
spin: TChangeColor;
|
|
86
|
+
/**
|
|
87
|
+
* Mix colors
|
|
88
|
+
*/
|
|
89
|
+
mix: ({ base, mixin, method, bpart, mpart }: {
|
|
90
|
+
base: string | object;
|
|
91
|
+
mixin: string | object;
|
|
92
|
+
bpart?: number;
|
|
93
|
+
mpart?: number;
|
|
94
|
+
method?: "srgb" | "srgb-linear" | "display-p3" | "a98-rgb" | "prophoto-rgb" | "rec2020" | "lab" | "oklab" | "xyz" | "xyz-d50" | "xyz-d65" | "hsl" | "hwb" | "lch" | "oklch";
|
|
95
|
+
}) => string;
|
|
96
|
+
};
|
|
97
|
+
export {};
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
type TSimplePseudo = (val?: string | number) => string;
|
|
2
|
+
type TComplexPseudo = (content: string | number, val?: string | number) => string;
|
|
3
|
+
type TPseudo = {
|
|
4
|
+
/**
|
|
5
|
+
* :root
|
|
6
|
+
*/
|
|
7
|
+
r: TSimplePseudo;
|
|
8
|
+
/**
|
|
9
|
+
* :hover
|
|
10
|
+
*/
|
|
11
|
+
h: TSimplePseudo;
|
|
12
|
+
/**
|
|
13
|
+
* :focus
|
|
14
|
+
*/
|
|
15
|
+
f: TSimplePseudo;
|
|
16
|
+
/**
|
|
17
|
+
* :focus-visible
|
|
18
|
+
*/
|
|
19
|
+
fv: TSimplePseudo;
|
|
20
|
+
/**
|
|
21
|
+
* :active
|
|
22
|
+
*/
|
|
23
|
+
a: TSimplePseudo;
|
|
24
|
+
/**
|
|
25
|
+
* :visited
|
|
26
|
+
*/
|
|
27
|
+
v: TSimplePseudo;
|
|
28
|
+
/**
|
|
29
|
+
* :valid
|
|
30
|
+
*/
|
|
31
|
+
val: TSimplePseudo;
|
|
32
|
+
/**
|
|
33
|
+
* :invalid
|
|
34
|
+
*/
|
|
35
|
+
inv: TSimplePseudo;
|
|
36
|
+
/**
|
|
37
|
+
* :empty
|
|
38
|
+
*/
|
|
39
|
+
e: TSimplePseudo;
|
|
40
|
+
/**
|
|
41
|
+
* :disabled
|
|
42
|
+
*/
|
|
43
|
+
d: TSimplePseudo;
|
|
44
|
+
/**
|
|
45
|
+
* :required
|
|
46
|
+
*/
|
|
47
|
+
rq: TSimplePseudo;
|
|
48
|
+
/**
|
|
49
|
+
* :optional
|
|
50
|
+
*/
|
|
51
|
+
o: TSimplePseudo;
|
|
52
|
+
/**
|
|
53
|
+
* :modal
|
|
54
|
+
*/
|
|
55
|
+
m: TSimplePseudo;
|
|
56
|
+
/**
|
|
57
|
+
* :link
|
|
58
|
+
*/
|
|
59
|
+
l: TSimplePseudo;
|
|
60
|
+
/**
|
|
61
|
+
* :placeholder
|
|
62
|
+
*/
|
|
63
|
+
ph: TSimplePseudo;
|
|
64
|
+
/**
|
|
65
|
+
* :first-child
|
|
66
|
+
*/
|
|
67
|
+
fc: TSimplePseudo;
|
|
68
|
+
/**
|
|
69
|
+
* :last-child
|
|
70
|
+
*/
|
|
71
|
+
lc: TSimplePseudo;
|
|
72
|
+
/**
|
|
73
|
+
* :obly-child
|
|
74
|
+
*/
|
|
75
|
+
oc: TSimplePseudo;
|
|
76
|
+
/**
|
|
77
|
+
* :nth-child(odd)
|
|
78
|
+
*/
|
|
79
|
+
odd: TSimplePseudo;
|
|
80
|
+
/**
|
|
81
|
+
* :nth-child(even)
|
|
82
|
+
*/
|
|
83
|
+
even: TSimplePseudo;
|
|
84
|
+
/**
|
|
85
|
+
* :first-of-type
|
|
86
|
+
*/
|
|
87
|
+
ft: TSimplePseudo;
|
|
88
|
+
/**
|
|
89
|
+
* :last-of-type
|
|
90
|
+
*/
|
|
91
|
+
lt: TSimplePseudo;
|
|
92
|
+
/**
|
|
93
|
+
* :only-of-type
|
|
94
|
+
*/
|
|
95
|
+
ot: TSimplePseudo;
|
|
96
|
+
/**
|
|
97
|
+
* ::before
|
|
98
|
+
*/
|
|
99
|
+
bef: TSimplePseudo;
|
|
100
|
+
/**
|
|
101
|
+
* ::after
|
|
102
|
+
*/
|
|
103
|
+
aft: TSimplePseudo;
|
|
104
|
+
/**
|
|
105
|
+
* ::backdrop
|
|
106
|
+
*/
|
|
107
|
+
bd: TSimplePseudo;
|
|
108
|
+
/**
|
|
109
|
+
* :has
|
|
110
|
+
*/
|
|
111
|
+
has: TComplexPseudo;
|
|
112
|
+
/**
|
|
113
|
+
* :not
|
|
114
|
+
*/
|
|
115
|
+
not: TComplexPseudo;
|
|
116
|
+
/**
|
|
117
|
+
* :is
|
|
118
|
+
*/
|
|
119
|
+
is: TComplexPseudo;
|
|
120
|
+
/**
|
|
121
|
+
* :where
|
|
122
|
+
*/
|
|
123
|
+
wh: TComplexPseudo;
|
|
124
|
+
/**
|
|
125
|
+
* :state
|
|
126
|
+
*/
|
|
127
|
+
st: TComplexPseudo;
|
|
128
|
+
/**
|
|
129
|
+
* :nth-child
|
|
130
|
+
*/
|
|
131
|
+
nthc: TComplexPseudo;
|
|
132
|
+
/**
|
|
133
|
+
* :nth-of-type
|
|
134
|
+
*/
|
|
135
|
+
ntho: TComplexPseudo;
|
|
136
|
+
/**
|
|
137
|
+
* :dir
|
|
138
|
+
*/
|
|
139
|
+
dir: TComplexPseudo;
|
|
140
|
+
/**
|
|
141
|
+
* :lang
|
|
142
|
+
*/
|
|
143
|
+
lang: TComplexPseudo;
|
|
144
|
+
};
|
|
145
|
+
export declare const resolvePseudo: () => TPseudo;
|
|
146
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type TGetUnit = (val: number | string) => string;
|
|
2
|
+
export declare const resolveUnits: () => {
|
|
3
|
+
px: TGetUnit;
|
|
4
|
+
vh: TGetUnit;
|
|
5
|
+
vw: TGetUnit;
|
|
6
|
+
rem: TGetUnit;
|
|
7
|
+
deg: TGetUnit;
|
|
8
|
+
ms: TGetUnit;
|
|
9
|
+
pc: TGetUnit;
|
|
10
|
+
cqw: TGetUnit;
|
|
11
|
+
cqh: TGetUnit;
|
|
12
|
+
cqb: TGetUnit;
|
|
13
|
+
cqi: TGetUnit;
|
|
14
|
+
cqmin: TGetUnit;
|
|
15
|
+
cqmax: TGetUnit;
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const parseStyles: (styles: object) => any;
|
|
@@ -1,7 +1,102 @@
|
|
|
1
|
-
|
|
1
|
+
type TOptBool = boolean | undefined;
|
|
2
|
+
/**
|
|
3
|
+
* Style root
|
|
4
|
+
*/
|
|
5
|
+
type TStyleRoot = {
|
|
6
|
+
adoptedStyleSheets: CSSStyleSheet[];
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Style manager
|
|
10
|
+
* @description
|
|
11
|
+
* Manages CSS stylesheets.
|
|
12
|
+
*/
|
|
13
|
+
interface IStyleManager {
|
|
14
|
+
/**
|
|
15
|
+
* Get stylesheet by key
|
|
16
|
+
* @param key - stylesheet key
|
|
17
|
+
*/
|
|
18
|
+
get(key?: string): CSSStyleSheet | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Get index of stylesheet
|
|
21
|
+
* @param styleSheet - CSS stylesheet
|
|
22
|
+
*/
|
|
23
|
+
getIndex(styleSheet: CSSStyleSheet): number;
|
|
24
|
+
/**
|
|
25
|
+
* Get all stylesheets dictionary
|
|
26
|
+
*/
|
|
27
|
+
getAll(): Record<string, CSSStyleSheet>;
|
|
28
|
+
/**
|
|
29
|
+
* Add stylesheet
|
|
30
|
+
* @param key - stylesheet key
|
|
31
|
+
* @param stylesheet - CSSStylesheet instance
|
|
32
|
+
*/
|
|
33
|
+
add(key: string, stylesheet: CSSStyleSheet): TOptBool;
|
|
34
|
+
/**
|
|
35
|
+
* Replace stylesheet content
|
|
36
|
+
* @param key - stylesheet key
|
|
37
|
+
* @param styles - stylesheet content string
|
|
38
|
+
*/
|
|
39
|
+
replace(key: string, styles: string): TOptBool;
|
|
40
|
+
/**
|
|
41
|
+
* Remove stylesheet
|
|
42
|
+
* @param key - stylesheet key
|
|
43
|
+
* @returns `true` if stylesheet is removed
|
|
44
|
+
*/
|
|
45
|
+
remove(key: string): TOptBool;
|
|
46
|
+
/**
|
|
47
|
+
* Remove all stylesheets
|
|
48
|
+
*/
|
|
49
|
+
removeAll(): void;
|
|
50
|
+
/**
|
|
51
|
+
* Pack styles into CSSStyleSheet and add it into stylesheet dictionary
|
|
52
|
+
* @param key - stylesheet key
|
|
53
|
+
* @param styles - stylesheet content string
|
|
54
|
+
*/
|
|
55
|
+
pack(key: string, styles: string): TOptBool;
|
|
56
|
+
/**
|
|
57
|
+
* Check if stylesheet exist
|
|
58
|
+
* @param key - stylesheet key
|
|
59
|
+
*/
|
|
60
|
+
has(key?: string): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Is stylesheet on
|
|
63
|
+
* @param key - stylesheet key
|
|
64
|
+
*/
|
|
65
|
+
status(key?: string): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Switch stylesheet on
|
|
68
|
+
* @param key - stylesheet key
|
|
69
|
+
*/
|
|
70
|
+
on(...keys: (string | undefined)[]): TOptBool;
|
|
71
|
+
/**
|
|
72
|
+
* Switch stylesheet off
|
|
73
|
+
* @param key - stylesheet key
|
|
74
|
+
*/
|
|
75
|
+
off(...keys: (string | undefined)[]): TOptBool;
|
|
76
|
+
/**
|
|
77
|
+
* Apply stylesheets to style root
|
|
78
|
+
* @param consumer - style root
|
|
79
|
+
*/
|
|
80
|
+
apply(consumer: TStyleRoot): void;
|
|
81
|
+
/**
|
|
82
|
+
* Register style root
|
|
83
|
+
* @param consumer - style root
|
|
84
|
+
*/
|
|
85
|
+
register(consumer: TStyleRoot): void;
|
|
86
|
+
/**
|
|
87
|
+
* Unregister style root
|
|
88
|
+
* @param consumer - style root
|
|
89
|
+
*/
|
|
90
|
+
unregister(consumer: TStyleRoot): void;
|
|
91
|
+
/**
|
|
92
|
+
* Apply style changes to dependent nodes
|
|
93
|
+
*/
|
|
94
|
+
notify(): void;
|
|
95
|
+
}
|
|
2
96
|
/**
|
|
3
97
|
* Create {@link IStyleManager | style manager}
|
|
4
98
|
* @param params - manager params
|
|
5
99
|
* @returns IStyleManager
|
|
6
100
|
*/
|
|
7
101
|
export declare function createManager(): IStyleManager;
|
|
102
|
+
export {};
|
|
@@ -1,22 +1,98 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import type { TDeafultBreakpoints, TCreateScope } from '../common';
|
|
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 { getBaseHandlers } from './_process/base';
|
|
7
|
+
type Leaves<T> = T extends object ? {
|
|
8
|
+
[K in keyof T]: `${Exclude<K, symbol>}${Leaves<T[K]> extends never ? '' : `.${Leaves<T[K]>}`}`;
|
|
9
|
+
}[keyof T] : never;
|
|
10
|
+
interface IMakerParams extends ReturnType<typeof getBaseHandlers> {
|
|
11
|
+
/**
|
|
12
|
+
* StyleSheet key
|
|
13
|
+
*/
|
|
14
|
+
key: string;
|
|
15
|
+
/**
|
|
16
|
+
* BEM selector resolver
|
|
17
|
+
*/
|
|
18
|
+
bem: ReturnType<ReturnType<TCreateScope>>['selector'];
|
|
19
|
+
/**
|
|
20
|
+
* CSS units
|
|
21
|
+
*/
|
|
22
|
+
units: ReturnType<typeof resolveUnits>;
|
|
23
|
+
/**
|
|
24
|
+
* Pseudoclasses and pseudoelements
|
|
25
|
+
*/
|
|
26
|
+
pseudo: ReturnType<typeof resolvePseudo>;
|
|
27
|
+
/**
|
|
28
|
+
* At-rules
|
|
29
|
+
*/
|
|
30
|
+
at: ReturnType<typeof resolveAtRules>;
|
|
31
|
+
/**
|
|
32
|
+
* Colors
|
|
33
|
+
*/
|
|
34
|
+
color: ReturnType<typeof resolveColor>;
|
|
35
|
+
/**
|
|
36
|
+
* Global vars
|
|
37
|
+
*/
|
|
38
|
+
vars: <G>(val: Leaves<G>) => string;
|
|
39
|
+
/**
|
|
40
|
+
* Width limit queries
|
|
41
|
+
*/
|
|
42
|
+
limit: {
|
|
43
|
+
/**
|
|
44
|
+
* `(min-width: val)` query
|
|
45
|
+
* @param val - breakpoint
|
|
46
|
+
* @param scope - container name for `@container`
|
|
47
|
+
*/
|
|
48
|
+
up: <T = TDeafultBreakpoints>(val: Exclude<keyof T, Symbol> | number, scope?: string) => string;
|
|
49
|
+
/**
|
|
50
|
+
* `(max-width: val)` query
|
|
51
|
+
* @param val - breakpoint
|
|
52
|
+
* @param scope - container name for `@container`
|
|
53
|
+
*/
|
|
54
|
+
down: <T = TDeafultBreakpoints>(val: Exclude<keyof T, Symbol> | number, scope?: string) => string;
|
|
55
|
+
/**
|
|
56
|
+
* `(min-width: from) and (max-width: to)` query
|
|
57
|
+
* @param from - start breakpoint
|
|
58
|
+
* @param to - end breakpoint
|
|
59
|
+
* @param scope - container name for `@container`
|
|
60
|
+
*/
|
|
61
|
+
between: <T = TDeafultBreakpoints>(from: Exclude<keyof T, Symbol> | number, to: Exclude<keyof T, Symbol> | number, scope?: string) => string;
|
|
62
|
+
/**
|
|
63
|
+
* `(min-width: val) and (max-width: val)` query
|
|
64
|
+
* @param val - breakpoint
|
|
65
|
+
* @param scope - container name for `@container`
|
|
66
|
+
*/
|
|
67
|
+
only: <T = TDeafultBreakpoints>(val: Exclude<keyof T, Symbol> | number, scope?: string) => string;
|
|
68
|
+
};
|
|
10
69
|
}
|
|
70
|
+
type TCreateProcessor = (params: {
|
|
71
|
+
scope: ReturnType<TCreateScope>;
|
|
72
|
+
globalKey?: string;
|
|
73
|
+
bp?: Record<string, string | number>;
|
|
74
|
+
}) => {
|
|
75
|
+
/**
|
|
76
|
+
* Compile style maker to CSS stylesheet text content
|
|
77
|
+
* @param params - params
|
|
78
|
+
*/
|
|
79
|
+
compile(params: {
|
|
80
|
+
key: string;
|
|
81
|
+
maker: (params: IMakerParams) => object;
|
|
82
|
+
}): string;
|
|
83
|
+
};
|
|
84
|
+
export declare const baseHandlers: {
|
|
85
|
+
dash: (...val: (string | number)[]) => string;
|
|
86
|
+
comma: (...val: (string | number)[]) => string;
|
|
87
|
+
space: (...val: (string | number)[]) => string;
|
|
88
|
+
range: (size: number, handler: (k: number) => object) => object;
|
|
89
|
+
each: <V>(rules: Record<string, V> | V[], handler: (k: string | number, v: V) => object) => object;
|
|
90
|
+
merge: (target: Record<string, any>, ...sources: Record<string, any>[]) => Record<string, any>;
|
|
91
|
+
when: (condition: boolean | undefined, rules: object, otherwise?: object) => object;
|
|
92
|
+
};
|
|
11
93
|
/**
|
|
12
|
-
*
|
|
13
|
-
* @param val
|
|
14
|
-
*/
|
|
15
|
-
export declare const curlyBraces: (val: string | number) => string;
|
|
16
|
-
/**
|
|
17
|
-
* Create {@link IStyleProcessor | style processor}
|
|
94
|
+
* Create style processor
|
|
18
95
|
* @param params - processor params
|
|
19
|
-
* @returns IStyleProcessor
|
|
20
96
|
*/
|
|
21
|
-
export declare
|
|
97
|
+
export declare const createProcessor: TCreateProcessor;
|
|
22
98
|
export {};
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider attributes
|
|
3
|
+
*/
|
|
4
|
+
export type TProviderAttrs = {
|
|
5
|
+
/**
|
|
6
|
+
* Hydratation flag
|
|
7
|
+
*/
|
|
8
|
+
hydrate: string | null;
|
|
9
|
+
/**
|
|
10
|
+
* Private stylesheet prefix
|
|
11
|
+
*/
|
|
12
|
+
prefix: string | null;
|
|
13
|
+
/**
|
|
14
|
+
* BEM selector generation mode
|
|
15
|
+
* @description
|
|
16
|
+
* `a` - data-attributes
|
|
17
|
+
* `c` - classes
|
|
18
|
+
*/
|
|
19
|
+
mode: 'a' | 'c' | null;
|
|
20
|
+
/**
|
|
21
|
+
* Theme
|
|
22
|
+
*/
|
|
23
|
+
theme: string | null;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Provider settings
|
|
27
|
+
*/
|
|
28
|
+
export type TProviderSettings = {
|
|
29
|
+
/**
|
|
30
|
+
* Breakpoints
|
|
31
|
+
*/
|
|
32
|
+
bp: Record<string, number | string>;
|
|
33
|
+
/**
|
|
34
|
+
* Global vars for each theme
|
|
35
|
+
*/
|
|
36
|
+
vars: Record<string, object>;
|
|
37
|
+
/**
|
|
38
|
+
* Stylesheet makers
|
|
39
|
+
*/
|
|
40
|
+
makers: Record<string, Function>;
|
|
41
|
+
/**
|
|
42
|
+
* Switched off stylesheets
|
|
43
|
+
*/
|
|
44
|
+
off: string[];
|
|
45
|
+
};
|
|
46
|
+
type TStrDict = Record<string, string>;
|
|
47
|
+
type Paths<T> = T extends object ? {
|
|
48
|
+
[K in keyof T]: `${Exclude<K, symbol>}${'' | Paths<T[K]> extends '' ? '' : `.${Paths<T[K]>}`}`;
|
|
49
|
+
}[keyof T] : T extends string ? T : never;
|
|
50
|
+
type TDeepPartial<T> = T extends object ? {
|
|
51
|
+
[P in keyof T]?: TDeepPartial<T[P]>;
|
|
52
|
+
} : T;
|
|
53
|
+
type TBlocks<T> = Exclude<keyof T, symbol | number>;
|
|
54
|
+
type TElems<T> = T extends object ? {
|
|
55
|
+
[K in keyof T]: `${Exclude<K, symbol>}${T[K] extends object ? `.${Exclude<keyof T[K], symbol | ''>}` : never}`;
|
|
56
|
+
}[keyof T] : never;
|
|
57
|
+
type TMods<T> = T extends object ? {
|
|
58
|
+
[K in keyof T]: `${Exclude<K, symbol>}${'' | Paths<T[K]> extends '' ? '' : `.${Paths<T[K]>}`}`;
|
|
59
|
+
}[keyof T] : T extends string ? T : never;
|
|
60
|
+
type TStringBEM<T> = TBlocks<T> | TMods<T> | TElems<T>;
|
|
61
|
+
type TBEM<T> = TDeepPartial<T> | TStringBEM<T> | TStringBEM<T>[];
|
|
62
|
+
type TResolveSelector = <T extends object>(params: TBEM<T>) => string;
|
|
63
|
+
type TResolveAttr = <T extends object>(params: TBEM<T>) => TStrDict;
|
|
64
|
+
type TScope = {
|
|
65
|
+
/**
|
|
66
|
+
* BEM selector resolver
|
|
67
|
+
*/
|
|
68
|
+
selector: TResolveSelector;
|
|
69
|
+
/**
|
|
70
|
+
* BEM attribute resolver
|
|
71
|
+
*/
|
|
72
|
+
attr: TResolveAttr;
|
|
73
|
+
/**
|
|
74
|
+
* Name resolver
|
|
75
|
+
*/
|
|
76
|
+
name: (...parts: (string | number)[] | string[]) => string;
|
|
77
|
+
/**
|
|
78
|
+
* Var name
|
|
79
|
+
*/
|
|
80
|
+
varName: (...parts: (string | number)[] | string[]) => string;
|
|
81
|
+
/**
|
|
82
|
+
* Var expression
|
|
83
|
+
*/
|
|
84
|
+
varExp: (...parts: (string | number)[]) => string;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Style scope resolver
|
|
88
|
+
*/
|
|
89
|
+
type TScopeResolver = (key: string) => TScope;
|
|
90
|
+
/**
|
|
91
|
+
* Create stylesheet scope
|
|
92
|
+
*/
|
|
93
|
+
export type TCreateScope = (params?: {
|
|
94
|
+
mode?: string | null;
|
|
95
|
+
}) => TScopeResolver;
|
|
96
|
+
export declare const TAG_NAME = "effcss-provider";
|
|
97
|
+
export declare const DEFAULT_ATTRS: TProviderAttrs;
|
|
98
|
+
export declare const DEFAULT_BREAKPOINTS: {
|
|
99
|
+
'3xs': number;
|
|
100
|
+
'2xs': number;
|
|
101
|
+
xs: number;
|
|
102
|
+
sm: number;
|
|
103
|
+
md: number;
|
|
104
|
+
lg: number;
|
|
105
|
+
xl: number;
|
|
106
|
+
'2xl': number;
|
|
107
|
+
};
|
|
108
|
+
export type TDeafultBreakpoints = typeof DEFAULT_BREAKPOINTS;
|
|
109
|
+
/**
|
|
110
|
+
* Default provider settings
|
|
111
|
+
*/
|
|
112
|
+
export declare const DEFAULT_SETTINGS: Partial<TProviderSettings>;
|
|
113
|
+
/**
|
|
114
|
+
* Create BEM resolver
|
|
115
|
+
* @param params - BEM resolver params
|
|
116
|
+
*/
|
|
117
|
+
export declare const createScope: TCreateScope;
|
|
118
|
+
/**
|
|
119
|
+
* Create stylesheet key maker
|
|
120
|
+
* @param params - collector params
|
|
121
|
+
*/
|
|
122
|
+
export declare const createKeyMaker: ({ prefix }: {
|
|
123
|
+
prefix: string;
|
|
124
|
+
}) => {
|
|
125
|
+
/**
|
|
126
|
+
* Base stylesheet key
|
|
127
|
+
*/
|
|
128
|
+
base: string;
|
|
129
|
+
/**
|
|
130
|
+
* Current stylesheet key
|
|
131
|
+
*/
|
|
132
|
+
current: string;
|
|
133
|
+
/**
|
|
134
|
+
* Create next key
|
|
135
|
+
*/
|
|
136
|
+
next(): string;
|
|
137
|
+
/**
|
|
138
|
+
* Reset current key
|
|
139
|
+
*/
|
|
140
|
+
reset(): void;
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* Create stylesheet maker collector
|
|
144
|
+
* @param params - collector params
|
|
145
|
+
*/
|
|
146
|
+
export declare const createCollector: () => {
|
|
147
|
+
/**
|
|
148
|
+
* Collect maker
|
|
149
|
+
* @param maker - stylesheet maker
|
|
150
|
+
* @param key - stylesheet key
|
|
151
|
+
*/
|
|
152
|
+
use(maker: Function, key: string): string;
|
|
153
|
+
/**
|
|
154
|
+
* Collect makers
|
|
155
|
+
* @param makers - stylesheet makers dict
|
|
156
|
+
*/
|
|
157
|
+
useMany(makers: Record<string, Function>): string[];
|
|
158
|
+
/**
|
|
159
|
+
* Get key of collected maker
|
|
160
|
+
* @param maker - stylesheet maker
|
|
161
|
+
*/
|
|
162
|
+
getKey(maker: Function): string | undefined;
|
|
163
|
+
/**
|
|
164
|
+
* Get all collected keys
|
|
165
|
+
*/
|
|
166
|
+
keys: string[];
|
|
167
|
+
/**
|
|
168
|
+
* Get all collected makers
|
|
169
|
+
*/
|
|
170
|
+
makers: Record<string, Function>;
|
|
171
|
+
};
|
|
172
|
+
export {};
|