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,197 +0,0 @@
|
|
|
1
|
-
import { IStyleConfig, IStyleDispatcher, IStyleProvider, TGetBEMResolver, TKeyGenerator, TStyleSheetConfig } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Prefix which will be used for autogenerated
|
|
4
|
-
* - variable names;
|
|
5
|
-
* - keyframes names;
|
|
6
|
-
* - stylesheet keys.
|
|
7
|
-
*/
|
|
8
|
-
export declare const PREFIX = "eff";
|
|
9
|
-
/**
|
|
10
|
-
* Id for special script element,
|
|
11
|
-
* which contains initial style config
|
|
12
|
-
*/
|
|
13
|
-
export declare const SETTINGS_ID = "effcss";
|
|
14
|
-
/**
|
|
15
|
-
* Name of the custom style provider element
|
|
16
|
-
*/
|
|
17
|
-
export declare const COMPONENT_NAME = "style-provider";
|
|
18
|
-
/**
|
|
19
|
-
* Create settings script element
|
|
20
|
-
* @param settings - settings object
|
|
21
|
-
* @param params - params for settings element
|
|
22
|
-
* @see {@link IStyleConfig}
|
|
23
|
-
*/
|
|
24
|
-
export declare const createSettingsElement: (settings: IStyleConfig, params?: {
|
|
25
|
-
/**
|
|
26
|
-
* Settings element id
|
|
27
|
-
* @defaultValue
|
|
28
|
-
* @see {@link SETTINGS_ID}
|
|
29
|
-
*/
|
|
30
|
-
id: string;
|
|
31
|
-
}) => Node;
|
|
32
|
-
/**
|
|
33
|
-
* Create settings HTML string
|
|
34
|
-
* @param settings - settings object
|
|
35
|
-
* @param params - params for settings element
|
|
36
|
-
* @see {@link IStyleConfig}
|
|
37
|
-
*/
|
|
38
|
-
export declare const createSettingsHTML: (settings: IStyleConfig, params?: {
|
|
39
|
-
/**
|
|
40
|
-
* Settings element id
|
|
41
|
-
* @defaultValue
|
|
42
|
-
* @see {@link SETTINGS_ID}
|
|
43
|
-
*/
|
|
44
|
-
id: string;
|
|
45
|
-
}) => string;
|
|
46
|
-
/**
|
|
47
|
-
* Get style provider component
|
|
48
|
-
* @param root - style provider scope
|
|
49
|
-
* @description
|
|
50
|
-
* Use this function to get the first provider element found in the document
|
|
51
|
-
* @see {@link IStyleProvider}
|
|
52
|
-
*/
|
|
53
|
-
export declare const getProvider: (root?: Document, name?: string) => IStyleProvider;
|
|
54
|
-
/**
|
|
55
|
-
* Compile stylesheet
|
|
56
|
-
* @param key - stylesheet key
|
|
57
|
-
* @param config - stylesheet config
|
|
58
|
-
* @param provider - style provider
|
|
59
|
-
* @see {@link IStyleProvider}
|
|
60
|
-
*/
|
|
61
|
-
export declare const compileStyleSheet: (key: string, config: TStyleSheetConfig, provider?: IStyleProvider) => boolean | undefined;
|
|
62
|
-
/**
|
|
63
|
-
* Use stylesheet
|
|
64
|
-
* @param config - stylesheet config
|
|
65
|
-
* @param provider - style provider
|
|
66
|
-
* @see {@link IStyleProvider}
|
|
67
|
-
*/
|
|
68
|
-
export declare const useStyleSheet: (config: TStyleSheetConfig, provider?: IStyleProvider) => (e?: string) => (m?: string | object) => Record<string, string>;
|
|
69
|
-
/**
|
|
70
|
-
* Expand stylesheet
|
|
71
|
-
* @param key - stylesheet key
|
|
72
|
-
* @param config - stylesheet config
|
|
73
|
-
* @param provider - style provider
|
|
74
|
-
* @see {@link IStyleProvider}
|
|
75
|
-
*/
|
|
76
|
-
export declare const expandStyleSheet: (key: string, config: string[], provider?: IStyleProvider) => number | undefined;
|
|
77
|
-
/**
|
|
78
|
-
* Process styles
|
|
79
|
-
* @param styles - stylesheet dictionary
|
|
80
|
-
* @param ext - extra rules config
|
|
81
|
-
* @param provider - style provider
|
|
82
|
-
* @see {@link IStyleProvider}
|
|
83
|
-
*/
|
|
84
|
-
export declare const processStyles: (styles?: Record<string, TStyleSheetConfig>, ext?: Record<string, string[]>, provider?: IStyleProvider) => void;
|
|
85
|
-
/**
|
|
86
|
-
* Resolve stylesheet
|
|
87
|
-
* @param key stylesheet key
|
|
88
|
-
* @param provider - style provider
|
|
89
|
-
* @see {@link IStyleProvider}
|
|
90
|
-
*/
|
|
91
|
-
export declare const resolveStyleSheet: (key: string, provider?: IStyleProvider) => (e?: string) => (m?: string | object) => Record<string, string>;
|
|
92
|
-
/**
|
|
93
|
-
* Get stylesheet from provider
|
|
94
|
-
* @param key - stylesheet key
|
|
95
|
-
* @param provider - style provider
|
|
96
|
-
* @see {@link IStyleProvider}
|
|
97
|
-
*/
|
|
98
|
-
export declare const getStyleSheet: (key: string, provider?: IStyleProvider) => CSSStyleSheet | undefined;
|
|
99
|
-
/**
|
|
100
|
-
* Add stylesheet to provider
|
|
101
|
-
* @param key - stylesheet key
|
|
102
|
-
* @param provider - style provider
|
|
103
|
-
* @see {@link IStyleProvider}
|
|
104
|
-
*/
|
|
105
|
-
export declare const addStyleSheet: (key: string, stylesheet: CSSStyleSheet, provider?: IStyleProvider) => true | void;
|
|
106
|
-
/**
|
|
107
|
-
* Remove stylesheet from provider
|
|
108
|
-
* @param key - stylesheet key
|
|
109
|
-
* @param provider - style provider
|
|
110
|
-
* @see {@link IStyleProvider}
|
|
111
|
-
*/
|
|
112
|
-
export declare const removeStyleSheet: (key: string, provider?: IStyleProvider) => true | void;
|
|
113
|
-
/**
|
|
114
|
-
* Stringify stylesheet
|
|
115
|
-
* @param key - stylesheet key
|
|
116
|
-
* @param provider - style provider
|
|
117
|
-
* @see {@link IStyleProvider}
|
|
118
|
-
*/
|
|
119
|
-
export declare const stringifyStyleSheet: (key: string, provider?: IStyleProvider) => string;
|
|
120
|
-
/**
|
|
121
|
-
* Get all stylesheets
|
|
122
|
-
* @param provider - style provider
|
|
123
|
-
* @see {@link IStyleProvider}
|
|
124
|
-
*/
|
|
125
|
-
export declare const stringifyAllStyles: (provider?: IStyleProvider) => string;
|
|
126
|
-
/**
|
|
127
|
-
* Get rules count for stylesheet
|
|
128
|
-
* @param key - stylesheet key
|
|
129
|
-
* @param provider - style provider
|
|
130
|
-
* @see {@link IStyleProvider}
|
|
131
|
-
*/
|
|
132
|
-
export declare const getRulesCount: (key: string, provider?: IStyleProvider) => number;
|
|
133
|
-
/**
|
|
134
|
-
* Get total rules count
|
|
135
|
-
* @param provider - style provider
|
|
136
|
-
* @see {@link IStyleProvider}
|
|
137
|
-
*/
|
|
138
|
-
export declare const getTotalRulesCount: (provider?: IStyleProvider) => number;
|
|
139
|
-
/**
|
|
140
|
-
* Generate stylesheet key
|
|
141
|
-
* @param configs - current stylesheet configs
|
|
142
|
-
*/
|
|
143
|
-
export declare const generateStyleSheetKey: TKeyGenerator;
|
|
144
|
-
/**
|
|
145
|
-
* BEM resolver
|
|
146
|
-
* @param params - BEM resolver params
|
|
147
|
-
*/
|
|
148
|
-
export declare const getBEMResolver: TGetBEMResolver;
|
|
149
|
-
/**
|
|
150
|
-
* Basic class for manipulating stylesheets
|
|
151
|
-
*/
|
|
152
|
-
export declare class StyleDispatcher implements IStyleDispatcher {
|
|
153
|
-
/**
|
|
154
|
-
* Dispatcher root element
|
|
155
|
-
* @description
|
|
156
|
-
* Scope where style provider will be searched for
|
|
157
|
-
*/
|
|
158
|
-
root: Document;
|
|
159
|
-
/**
|
|
160
|
-
* Style provider
|
|
161
|
-
*/
|
|
162
|
-
provider: IStyleProvider;
|
|
163
|
-
construstor(root?: Document): void;
|
|
164
|
-
/**
|
|
165
|
-
* Use stylesheet
|
|
166
|
-
* @param config - stylesheet config
|
|
167
|
-
* @see {@link useStyleSheet}
|
|
168
|
-
*/
|
|
169
|
-
use: (config: TStyleSheetConfig) => (e?: string) => (m?: string | object) => Record<string, string>;
|
|
170
|
-
/**
|
|
171
|
-
* Compile stylesheet
|
|
172
|
-
* @param key - stylesheet key
|
|
173
|
-
* @param config - stylesheet config
|
|
174
|
-
* @see {@link compileStyleSheet}
|
|
175
|
-
*/
|
|
176
|
-
compile: (key: string, config: TStyleSheetConfig) => boolean | undefined;
|
|
177
|
-
/**
|
|
178
|
-
* Expand stylesheet
|
|
179
|
-
* @param key - stylesheet key
|
|
180
|
-
* @param config - stylesheet config
|
|
181
|
-
* @see {@link expandStyleSheet}
|
|
182
|
-
*/
|
|
183
|
-
expand: (key: string, config: string[]) => number | undefined;
|
|
184
|
-
/**
|
|
185
|
-
* Process styles
|
|
186
|
-
* @param styles - stylesheet dictionary
|
|
187
|
-
* @param ext - stylesheet extra rules
|
|
188
|
-
* @see {@link processStyles}
|
|
189
|
-
*/
|
|
190
|
-
process: (styles?: Record<string, TStyleSheetConfig>, ext?: Record<string, string[]>) => void;
|
|
191
|
-
/**
|
|
192
|
-
* Resolve stylesheet
|
|
193
|
-
* @param key - stylesheet key
|
|
194
|
-
* @see {@link resolveStyleSheet}
|
|
195
|
-
*/
|
|
196
|
-
resolve: (key: string) => (e?: string) => (m?: string | object) => Record<string, string>;
|
|
197
|
-
}
|
package/dist/utils.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=e=>"object"==typeof e,t="eff",r="effcss",i="style-provider",o=(e,t)=>{const i=JSON.stringify(e),o=(null==t?void 0:t.id)||r,n=document.createElement("script");return n.id=o,n.type="application/json",n.innerHTML=i,n},n=(e,t)=>{const i=JSON.stringify(e);return`<script id="${(null==t?void 0:t.id)||r}" type="application/json">${i}<\/script>`},s=(e=document,t=i)=>{var r;return null===(r=e.getElementsByTagName(t))||void 0===r?void 0:r[0]},l=(e,t,r=s())=>r.compileStyleSheet(e,t),d=(e,t=s())=>t.useStyleSheet(e),v=(e,t,r=s())=>r.expandStyleSheet(e,t),u=(e,t,r=s())=>r.processStyles(e,t),a=(e,t=s())=>t.resolveStyleSheet(e),c=(e,t=s())=>{var r;return null===(r=null==t?void 0:t.manager)||void 0===r?void 0:r.get(e)},p=(e,t,r=s())=>{var i;return null===(i=null==r?void 0:r.manager)||void 0===i?void 0:i.add(e,t)},m=(e,t=s())=>{var r;return null===(r=null==t?void 0:t.manager)||void 0===r?void 0:r.remove(e)},h=(e,t=s())=>{var r;return[...(null===(r=c(e,t))||void 0===r?void 0:r.cssRules)||[]].map((e=>e.cssText)).join("")},g=(e=s())=>{var t;return Object.keys((null===(t=null==e?void 0:e.manager)||void 0===t?void 0:t.getAll())||{}).map((t=>h(t,e))).join("")},y=(e,t=s())=>{var r;return function e(t){return t?t.length+[...t].reduce(((t,r)=>t+e(null==r?void 0:r.cssRules)),0):0}(null===(r=c(e,t))||void 0===r?void 0:r.cssRules)},j=(e=s())=>{var t;return Object.keys((null===(t=null==e?void 0:e.manager)||void 0===t?void 0:t.getAll())||{}).reduce(((t,r)=>t+y(r,e)),0)},S=e=>e.size.toString(36),f=t=>{const r=e=>Object.entries(e).reduce(((e,[t,r])=>(void 0!==r&&e.push(t+(r?"-"+r:"")),e)),[]).join(" "),i=(e,t)=>Object.defineProperties({[e]:t},{k:{value:e},v:{value:t}});return"c"===t.mode?{selector:({b:e,e:t,m:r,mv:i,s:o})=>`.${e}${(t?"__"+t:"")+(r?"_"+r:"")+(r&&i?"_"+i:"")+(o?":"+o:"")}`,attr:t=>o=>n=>{let s=n||"";e(s)&&(s=r(s));const l=t+(o?"__"+o:"");return s=l+(s?" "+(null==s?void 0:s.split(" ").map((e=>l+"_"+e.split("-").join("_"))).join(" ")):""),i("class",s)}}:{selector:({b:e,e:t,m:r,mv:i,s:o})=>`[data-${e}${t?"-"+t:""}${r||o?'~="'+(r||"")+(i?"-"+i:"")+(o?":"+o:"")+'"':""}]`,attr:t=>o=>n=>{const s=`data-${t}${o?"-"+o:""}`;let l=n||"";return e(l)&&(l=r(l)),i(s,l)}}};class ${constructor(){this.root=document,this.use=e=>d(e,this.provider),this.compile=(e,t)=>l(e,t,this.provider),this.expand=(e,t)=>v(e,t,this.provider),this.process=(e,t)=>u(e,t,this.provider),this.resolve=e=>a(e,this.provider)}construstor(e){e&&(this.root=e),this.provider=s(this.root)}}export{i as COMPONENT_NAME,t as PREFIX,r as SETTINGS_ID,$ as StyleDispatcher,p as addStyleSheet,l as compileStyleSheet,o as createSettingsElement,n as createSettingsHTML,v as expandStyleSheet,S as generateStyleSheetKey,f as getBEMResolver,s as getProvider,y as getRulesCount,c as getStyleSheet,j as getTotalRulesCount,u as processStyles,m as removeStyleSheet,a as resolveStyleSheet,g as stringifyAllStyles,h as stringifyStyleSheet,d as useStyleSheet};
|