@zuzjs/ui 0.3.7 → 0.3.8
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/dist/bin.d.ts +2 -0
- package/dist/bin.js +107 -0
- package/dist/comps/box.d.ts +3 -0
- package/dist/comps/box.js +7 -0
- package/dist/comps/button.d.ts +3 -0
- package/dist/comps/button.js +8 -0
- package/dist/comps/checkbox.d.ts +3 -0
- package/dist/comps/checkbox.js +14 -0
- package/dist/comps/cover.d.ts +4 -0
- package/dist/comps/cover.js +8 -0
- package/dist/comps/form.d.ts +4 -0
- package/dist/comps/form.js +105 -0
- package/dist/comps/heading.d.ts +3 -0
- package/dist/comps/heading.js +10 -0
- package/dist/comps/icon.d.ts +3 -0
- package/dist/comps/icon.js +7 -0
- package/dist/comps/input.d.ts +7 -0
- package/dist/comps/input.js +8 -0
- package/dist/comps/spinner.d.ts +13 -0
- package/dist/comps/spinner.js +40 -0
- package/dist/funs/css.d.ts +268 -0
- package/dist/funs/css.js +339 -0
- package/dist/funs/index.d.ts +17 -0
- package/dist/funs/index.js +60 -0
- package/dist/funs/styles.d.ts +242 -0
- package/dist/funs/styles.js +249 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +10 -0
- package/dist/styles.css +1 -460
- package/dist/types/enums.d.ts +10 -0
- package/dist/types/enums.js +12 -0
- package/dist/types/index.d.ts +23 -0
- package/dist/types/index.js +1 -0
- package/dist/types/interfaces.d.ts +4 -0
- package/dist/types/interfaces.js +1 -0
- package/package.json +48 -44
- package/README.md +0 -1
- package/dist/hooks.js +0 -89
- package/dist/ui.js +0 -688
package/dist/funs/css.js
ADDED
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
import Hashids from "hashids";
|
|
2
|
+
import { cssProps } from "./styles.js";
|
|
3
|
+
class CSS {
|
|
4
|
+
constructor(options) {
|
|
5
|
+
const opts = options || {};
|
|
6
|
+
this.unit = opts.unit || `px`;
|
|
7
|
+
this.hashids = new Hashids('', 4);
|
|
8
|
+
this.chars = "#abcdefghijklmnopqrstuvwxyz0123456789";
|
|
9
|
+
this.PROPS = cssProps;
|
|
10
|
+
this.IGNORE = [
|
|
11
|
+
`flex`, `opacity`, `z-index`, `zIndex`, `color`, `line-height`
|
|
12
|
+
];
|
|
13
|
+
this.DIRECT = {
|
|
14
|
+
"content": "content:'';",
|
|
15
|
+
"bold": "font-weight: bold;",
|
|
16
|
+
"flex": "display:flex;",
|
|
17
|
+
"cols": "flex-direction:column;",
|
|
18
|
+
"ass": "align-self:flex-start;",
|
|
19
|
+
"ais": "align-items:flex-start;",
|
|
20
|
+
"aic": "align-items:center;",
|
|
21
|
+
"aie": "align-items:flex-end;",
|
|
22
|
+
"jcs": "justify-content:flex-start;",
|
|
23
|
+
"jcc": "justify-content:center;",
|
|
24
|
+
"jce": "justify-content:flex-end;",
|
|
25
|
+
"fill": "top: 0px;left: 0px;right: 0px;bottom: 0px;",
|
|
26
|
+
"rel": "position:relative;",
|
|
27
|
+
"abs": "position:absolute;",
|
|
28
|
+
"abc": "top: 50%;left: 50%;transform: translate(-50%, -50%);",
|
|
29
|
+
"tdn": "text-decoration:none;",
|
|
30
|
+
"tdu": "text-decoration:underline;",
|
|
31
|
+
"nous": "user-select:none;",
|
|
32
|
+
"nope": "pointer-events:none;",
|
|
33
|
+
"ph": "padding-left:__VALUE__;padding-right:__VALUE__;",
|
|
34
|
+
"pv": "padding-top:__VALUE__;padding-bottom:__VALUE__;",
|
|
35
|
+
"mh": "margin-left:__VALUE__;margin-right:__VALUE__;",
|
|
36
|
+
"mv": "margin-top:__VALUE__;margin-bottom:__VALUE__;",
|
|
37
|
+
"translate": "transform:translate(__VALUE__);",
|
|
38
|
+
"translateX": "transform:translateX(__VALUE__);",
|
|
39
|
+
"translateY": "transform:translateY(__VALUE__);",
|
|
40
|
+
"rotate": "transform: rotate(__VALUE__)"
|
|
41
|
+
};
|
|
42
|
+
this.keysWithoutCommaToSpace = [`transform`, `translate`, `color`, `background`, `background-color`, `backgroundColor`];
|
|
43
|
+
this.propCounter = {};
|
|
44
|
+
this.cx = [];
|
|
45
|
+
this.cache = {};
|
|
46
|
+
this.baseRegex = /(\$?[\w%!-]+:\$?\w+\[(.*?)\]+)|(\$?[\w%!-]+:\$?[-\w%,.!]+|\$?[-\w%,.!]+)/g;
|
|
47
|
+
// /(\$?[\w%-]+:\$?[-\w%,]+|\$?[-\w%,]+)/g;
|
|
48
|
+
this.pseudoList = [`hover`, `before`, `after`, `focus`, `blur`];
|
|
49
|
+
this.pseudoCounter = {};
|
|
50
|
+
this.pseudoList.map((p) => this.pseudoCounter[p] = 0);
|
|
51
|
+
this.pseudoPattern = this.pseudoList.map((word) => word).join('|');
|
|
52
|
+
this.pseudoReg = new RegExp(this.pseudoPattern, `g`);
|
|
53
|
+
this.pseudoRegExp = /&(\w+)\(\s*([^()]*?(?:\([^()]*\))*[^()]*)\s*\)/g;
|
|
54
|
+
// /&(\w+)\(([^()]+(?:\([^()]*\))*[^()]*)\)/g
|
|
55
|
+
}
|
|
56
|
+
getStyleSheet(cache, indentLevel = 0, pseudo = false) {
|
|
57
|
+
const self = this;
|
|
58
|
+
const indent = ``; //` `.repeat(indentLevel)
|
|
59
|
+
let scss = ``;
|
|
60
|
+
// for( const key in cache){
|
|
61
|
+
Object.keys(cache).map((key) => {
|
|
62
|
+
// console.log(`kc`, key, cache[key])
|
|
63
|
+
if (`object` == typeof cache[key]) {
|
|
64
|
+
const _key = self.pseudoList.filter(x => key.indexOf(x) > -1);
|
|
65
|
+
scss += `${indent}${_key.length > 0 ? `&:${_key[0]}` : `\n.${key}`}{`;
|
|
66
|
+
scss += self.getStyleSheet(cache[key], indentLevel + 1, _key.length > 0 ? true : false);
|
|
67
|
+
scss += `${indent}}`;
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
if (pseudo) {
|
|
71
|
+
scss += `${indent}${cache[key]}`;
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
scss += `\n${indent}.${key}{`;
|
|
75
|
+
scss += `${indent}${cache[key]}`;
|
|
76
|
+
scss += `${indent}}`;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
return scss;
|
|
81
|
+
}
|
|
82
|
+
makeColor() {
|
|
83
|
+
}
|
|
84
|
+
makeUnit(k, v) {
|
|
85
|
+
// console.log(`unit`, k, v)
|
|
86
|
+
if (k == `rotate`) {
|
|
87
|
+
return `deg`;
|
|
88
|
+
}
|
|
89
|
+
if (typeof v == "string" && /\d+(\.\d+)?$/.test(v) === false || this.IGNORE.indexOf(k) > -1)
|
|
90
|
+
return ``;
|
|
91
|
+
return this.unit;
|
|
92
|
+
}
|
|
93
|
+
makeValue(k, v) {
|
|
94
|
+
if (k in this.PROPS) {
|
|
95
|
+
const key = this.PROPS[k];
|
|
96
|
+
let value;
|
|
97
|
+
v = v.trim();
|
|
98
|
+
let hasImportant = v.charAt(v.length - 1) == `!`;
|
|
99
|
+
v = hasImportant ? v.slice(0, -1) : v;
|
|
100
|
+
let important = hasImportant ? ` !important` : ``;
|
|
101
|
+
// console.log(`makevalue`, key, k, v)
|
|
102
|
+
/**
|
|
103
|
+
* Variable
|
|
104
|
+
*/
|
|
105
|
+
if (v.includes(`$`)) {
|
|
106
|
+
value = `var(--${v.replace(`$`, ``)})`;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Color
|
|
110
|
+
*/
|
|
111
|
+
else if ([`color`, `bg`, `background`, `background-color`, `backgroundColor`].includes(key)) {
|
|
112
|
+
// else if ( [`color`].includes( key ) ){
|
|
113
|
+
if (v.charAt(0) == `#`) {
|
|
114
|
+
v = v.substring(1);
|
|
115
|
+
}
|
|
116
|
+
if (/^#[0-9A-F]{6}[0-9a-f]{0,2}$/i.test(`#${v}`) ||
|
|
117
|
+
/^#([0-9A-F]{3}){1,2}$/i.test(`#${v}`)) {
|
|
118
|
+
value = `#${v}`;
|
|
119
|
+
}
|
|
120
|
+
else if (v.includes(`rgb`) || v.includes(`rgba`)) {
|
|
121
|
+
value = v.replace(`[`, `(`).replace(`]`, `)`);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* FontWeight
|
|
126
|
+
*/
|
|
127
|
+
else if (key == `font-weight`) {
|
|
128
|
+
value = v;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* calc
|
|
132
|
+
* passed as calc[value]
|
|
133
|
+
*/
|
|
134
|
+
else if (v.match(/\[(.*?)\]/g)) {
|
|
135
|
+
try {
|
|
136
|
+
const vs = v.match(/\[(.*?)\]/g)[0].slice(1, -1);
|
|
137
|
+
const [_vc] = v.split(`[`);
|
|
138
|
+
value = `${_vc.trim()}(${vs})`;
|
|
139
|
+
}
|
|
140
|
+
catch (e) { }
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
// ${v.charAt(0) == `$` ? `var(--${v.substring(1)})` : v}
|
|
144
|
+
value = `${v}${this.makeUnit(key, v)}`;
|
|
145
|
+
}
|
|
146
|
+
if (!value)
|
|
147
|
+
return ``;
|
|
148
|
+
// if ( key == `background` ) console.log(`makevalue`, key, value)
|
|
149
|
+
value = value.includes(`,`) && !this.keysWithoutCommaToSpace.includes(key) ? value.replace(`,`, ` `) : value;
|
|
150
|
+
return `${key}: ${value}${important};`;
|
|
151
|
+
}
|
|
152
|
+
return ``;
|
|
153
|
+
}
|
|
154
|
+
makeID(k, v, _out) {
|
|
155
|
+
const self = this;
|
|
156
|
+
const _css = _out.toString().replace(/;|:|\s/g, "");
|
|
157
|
+
let _indices = 0;
|
|
158
|
+
for (let i = 0; i < _css.length; i++) {
|
|
159
|
+
_indices += self.chars.indexOf(_out.charAt(i));
|
|
160
|
+
}
|
|
161
|
+
let _cp = k.substring(0, 1);
|
|
162
|
+
if (self.PROPS[k]?.indexOf("-") > -1) {
|
|
163
|
+
_cp = "";
|
|
164
|
+
self.PROPS[k].split("-").map((c) => _cp += c.substring(0, 1));
|
|
165
|
+
}
|
|
166
|
+
if (v.toString().indexOf("-") > -1) {
|
|
167
|
+
v.toString().split("-").map(c => _cp += c.substring(0, 1));
|
|
168
|
+
}
|
|
169
|
+
return `${_cp}${self.hashids.encode((self.PROPS[k] ? self.PROPS[k].length : 0) + _indices + (isNaN(parseInt(v)) ? 0 : parseInt(v)))}`.replace(/\s/g, '-');
|
|
170
|
+
}
|
|
171
|
+
makeIDFromObject(key, obj) {
|
|
172
|
+
const self = this;
|
|
173
|
+
const out = [key];
|
|
174
|
+
const fcs = [key.charAt(0)];
|
|
175
|
+
const vals = [];
|
|
176
|
+
const build = (o) => {
|
|
177
|
+
Object.keys(o).map((n) => {
|
|
178
|
+
if (`object` == typeof o[n]) {
|
|
179
|
+
build(o[n]);
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
fcs.push(n.charAt(0));
|
|
183
|
+
vals.push(o[n]);
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
};
|
|
187
|
+
build(obj);
|
|
188
|
+
let _indices = 0;
|
|
189
|
+
let _cp = "";
|
|
190
|
+
for (const ot of vals) {
|
|
191
|
+
const _css = ot.toString().replace(/;|:|\s/g, "");
|
|
192
|
+
for (let i = 0; i < _css.length; i++) {
|
|
193
|
+
_indices += self.chars.indexOf(ot.charAt(i));
|
|
194
|
+
}
|
|
195
|
+
if (ot.indexOf("-") > -1) {
|
|
196
|
+
ot.split("-").map((c) => _cp += c.substring(0, 1));
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return `${_cp}${self.hashids.encode(_indices)}`.replace(/\s/g, '-');
|
|
200
|
+
}
|
|
201
|
+
parseRawLine(line) {
|
|
202
|
+
const self = this;
|
|
203
|
+
const result = {};
|
|
204
|
+
try {
|
|
205
|
+
const matches = line.match(self.pseudoRegExp);
|
|
206
|
+
if (matches) {
|
|
207
|
+
matches.map((m) => {
|
|
208
|
+
const pseudo = self.pseudoRegExp.exec(m); ///&\w+/g.exec(m)
|
|
209
|
+
if (pseudo) {
|
|
210
|
+
const psd = `${pseudo[1]}${++self.pseudoCounter[pseudo[1]]}`;
|
|
211
|
+
result[psd] = self.parseRawLine(pseudo[2]);
|
|
212
|
+
}
|
|
213
|
+
line = line.replace(self.pseudoRegExp, ``);
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
const baseProperties = line.match(self.baseRegex);
|
|
217
|
+
if (baseProperties) {
|
|
218
|
+
baseProperties.forEach(prop => {
|
|
219
|
+
const [key, value] = prop.split(':');
|
|
220
|
+
if (value) {
|
|
221
|
+
if (result[key]) {
|
|
222
|
+
const _kk = key in self.propCounter ? ++self.propCounter[key] : self.propCounter[key] = 1;
|
|
223
|
+
result[`${key}${_kk}`] = `${key}:${value}`;
|
|
224
|
+
}
|
|
225
|
+
else
|
|
226
|
+
result[key] = `${key}:${value}`;
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
const _kk = prop in self.propCounter ? ++self.propCounter[prop] : self.propCounter[prop] = 1;
|
|
230
|
+
result[`${prop}${_kk}`] = prop; // true;
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
catch (e) {
|
|
236
|
+
// console.log(e)
|
|
237
|
+
}
|
|
238
|
+
// console.log(result)
|
|
239
|
+
return result;
|
|
240
|
+
}
|
|
241
|
+
makeCSS(line) {
|
|
242
|
+
const self = this;
|
|
243
|
+
// console.log(line)
|
|
244
|
+
const rest = self.parseRawLine(line);
|
|
245
|
+
const value = (_k, pseudo = ``) => {
|
|
246
|
+
if (_k in self.DIRECT) {
|
|
247
|
+
const _out = self.DIRECT[_k];
|
|
248
|
+
const _id = self.makeID(_k, _k + pseudo, _out);
|
|
249
|
+
if (pseudo == ``)
|
|
250
|
+
self.cx.push(_id);
|
|
251
|
+
return { [_id]: _out };
|
|
252
|
+
}
|
|
253
|
+
else if (_k.includes(`:`)) {
|
|
254
|
+
const [key, _val] = _k.split(`:`);
|
|
255
|
+
if (key in self.PROPS) {
|
|
256
|
+
const _out = self.makeValue(key, _val);
|
|
257
|
+
const _id = self.makeID(key, _val + pseudo, _out);
|
|
258
|
+
if (pseudo == ``)
|
|
259
|
+
self.cx.push(_id);
|
|
260
|
+
return { [_id]: _out };
|
|
261
|
+
}
|
|
262
|
+
else if (key in self.DIRECT) {
|
|
263
|
+
const hasImportant = _val.endsWith(`!`);
|
|
264
|
+
const val = hasImportant ? _val.slice(0, -1) : _val;
|
|
265
|
+
const important = hasImportant ? ` !important` : ``;
|
|
266
|
+
const _out = self.DIRECT[key].includes(`__VALUE__`) ?
|
|
267
|
+
self.DIRECT[key].replace(/__VALUE__/g, `${val}${self.makeUnit(key, val)}${important}`) : self.DIRECT[key];
|
|
268
|
+
const _id = self.makeID(key, key + pseudo, _out);
|
|
269
|
+
if (pseudo == ``)
|
|
270
|
+
self.cx.push(_id);
|
|
271
|
+
return { [_id]: _out };
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
else {
|
|
275
|
+
self.cx.push(_k.trim());
|
|
276
|
+
}
|
|
277
|
+
return {};
|
|
278
|
+
};
|
|
279
|
+
const build = (o, pseudo = ``) => {
|
|
280
|
+
let out = {};
|
|
281
|
+
Object.keys(o).map((_k) => {
|
|
282
|
+
if (`object` == typeof o[_k]) {
|
|
283
|
+
out = { ...out, [_k]: build(o[_k], _k) };
|
|
284
|
+
// self.makeIDFromObject(_k, cache[_k])
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
out = { ...out, ...value(o[_k], pseudo) };
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
return out;
|
|
291
|
+
};
|
|
292
|
+
// console.log(rest)
|
|
293
|
+
self.cache = { ...self.cache, ...build(rest) };
|
|
294
|
+
}
|
|
295
|
+
cleanPseudo(cache) {
|
|
296
|
+
const self = this;
|
|
297
|
+
const _ = {};
|
|
298
|
+
Object.keys(cache).map((_k) => {
|
|
299
|
+
if (`object` == typeof cache[_k]) {
|
|
300
|
+
const _id = self.makeIDFromObject(_k, cache[_k]);
|
|
301
|
+
self.cx.push(_id);
|
|
302
|
+
_[_id] = { [_k]: cache[_k] };
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
_[_k] = cache[_k];
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
return _;
|
|
309
|
+
}
|
|
310
|
+
Build(css) {
|
|
311
|
+
let self = this;
|
|
312
|
+
self.cx = [];
|
|
313
|
+
self.cache = {};
|
|
314
|
+
if (undefined == css)
|
|
315
|
+
return {
|
|
316
|
+
cx: self.cx,
|
|
317
|
+
sheet: ``
|
|
318
|
+
};
|
|
319
|
+
if (`string` == typeof css) {
|
|
320
|
+
css = [[css]];
|
|
321
|
+
}
|
|
322
|
+
css.map((arr) => {
|
|
323
|
+
arr.map((line) => {
|
|
324
|
+
self.makeCSS(line);
|
|
325
|
+
});
|
|
326
|
+
});
|
|
327
|
+
// console.log({
|
|
328
|
+
// cx: self.cx,
|
|
329
|
+
// sheet: self.getStyleSheet(self.cleanPseudo(self.cache))
|
|
330
|
+
// })
|
|
331
|
+
// console.log(self.cache)
|
|
332
|
+
// console.log(self.getStyleSheet(self.cleanPseudo(self.cache)))
|
|
333
|
+
return {
|
|
334
|
+
cx: self.cx,
|
|
335
|
+
sheet: self.getStyleSheet(self.cleanPseudo(self.cache))
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
export default CSS;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import CSS from './css';
|
|
2
|
+
import { dynamicObject } from "../types";
|
|
3
|
+
export declare const css: CSS;
|
|
4
|
+
export declare const hexColorRegex: RegExp;
|
|
5
|
+
export declare const rgbaColorRegex: RegExp;
|
|
6
|
+
export declare const hslColorRegex: RegExp;
|
|
7
|
+
export declare const isHexColor: (color: string) => boolean;
|
|
8
|
+
export declare const isRgbaColor: (color: string) => boolean;
|
|
9
|
+
export declare const isHslColor: (color: string) => boolean;
|
|
10
|
+
export declare const isColor: (color: string) => boolean;
|
|
11
|
+
export declare const hexToRgba: (hex: string, alpha?: number) => string;
|
|
12
|
+
export declare const ucfirst: (str: string) => string;
|
|
13
|
+
export declare const cleanProps: (props: dynamicObject, withProps?: string[]) => {
|
|
14
|
+
[x: string]: any;
|
|
15
|
+
};
|
|
16
|
+
export declare const withZuz: (cx: string) => string;
|
|
17
|
+
export declare const extendGlobals: () => void;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { cssProps } from "./styles";
|
|
2
|
+
import CSS from './css';
|
|
3
|
+
export const css = new CSS();
|
|
4
|
+
// Hex color regex (#RGB, #RRGGBB)
|
|
5
|
+
export const hexColorRegex = /^#([A-Fa-f0-9]{3}){1,2}$/;
|
|
6
|
+
// RGBA color regex (rgba(255, 255, 255, 1))
|
|
7
|
+
export const rgbaColorRegex = /^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*((0|1|0?\.\d+)\s*))?\)$/;
|
|
8
|
+
// HSL color regex (hsl(360, 100%, 100%))
|
|
9
|
+
export const hslColorRegex = /^hsl\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*\)$/;
|
|
10
|
+
export const isHexColor = (color) => hexColorRegex.test(color);
|
|
11
|
+
export const isRgbaColor = (color) => rgbaColorRegex.test(color);
|
|
12
|
+
export const isHslColor = (color) => hslColorRegex.test(color);
|
|
13
|
+
// Function to validate a color string
|
|
14
|
+
export const isColor = (color) => isHexColor(color) || isRgbaColor(color) || isHslColor(color);
|
|
15
|
+
// Convert hex to rgba
|
|
16
|
+
export const hexToRgba = (hex, alpha = 1) => {
|
|
17
|
+
// Remove the hash symbol if present
|
|
18
|
+
hex = hex.replace(/^#/, '');
|
|
19
|
+
// If shorthand hex (#RGB), expand it to full form (#RRGGBB)
|
|
20
|
+
if (hex.length === 3) {
|
|
21
|
+
hex = hex.split('').map(char => char + char).join('');
|
|
22
|
+
}
|
|
23
|
+
// Convert to integer values for RGB
|
|
24
|
+
const bigint = parseInt(hex, 16);
|
|
25
|
+
const r = (bigint >> 16) & 255;
|
|
26
|
+
const g = (bigint >> 8) & 255;
|
|
27
|
+
const b = bigint & 255;
|
|
28
|
+
return `rgba(${r}, ${g}, ${b}, ${alpha})`;
|
|
29
|
+
};
|
|
30
|
+
export const ucfirst = (str) => `${str.charAt(0).toUpperCase()}${str.substring(1, str.length)}`;
|
|
31
|
+
export const cleanProps = (props, withProps = []) => {
|
|
32
|
+
let _extras = [`as`, ...withProps];
|
|
33
|
+
let _props = { ...props };
|
|
34
|
+
Object.keys(_props).map(k => {
|
|
35
|
+
if (k in cssProps) {
|
|
36
|
+
delete _props[k];
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
_extras.map(x => x in _props && delete _props[x]);
|
|
40
|
+
return _props;
|
|
41
|
+
};
|
|
42
|
+
export const withZuz = (cx) => css.Build([[cx]]).cx.join(` `);
|
|
43
|
+
export const extendGlobals = () => {
|
|
44
|
+
Object.prototype.is = function (v) { return typeof this === v; };
|
|
45
|
+
Object.prototype.typeof = function (v) { return typeof this === typeof v; };
|
|
46
|
+
Object.prototype.equals = function (v) { return this === v; };
|
|
47
|
+
Object.prototype.isNull = function () { return this === null; };
|
|
48
|
+
Object.prototype.isString = function () { return typeof this == `string`; };
|
|
49
|
+
Object.prototype.isNumber = function () { return /^[+-]?\d+(\.\d+)?$/.test(this); };
|
|
50
|
+
Object.prototype.isObject = function () { return typeof this == `object` && !Array.isArray(this) && this !== null; };
|
|
51
|
+
Object.prototype.isArray = function () { return Array.isArray(this); };
|
|
52
|
+
Object.prototype.isEmpty = function () {
|
|
53
|
+
if (Array.isArray(this))
|
|
54
|
+
return this.length === 0;
|
|
55
|
+
else if (`object` === typeof this)
|
|
56
|
+
return Object.keys(this).length == 0;
|
|
57
|
+
else
|
|
58
|
+
return this == "" || this.length == 0;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
export declare const cssProps: {
|
|
2
|
+
alignContent: string;
|
|
3
|
+
alignItems: string;
|
|
4
|
+
alignSelf: string;
|
|
5
|
+
animation: string;
|
|
6
|
+
animationDelay: string;
|
|
7
|
+
animationDirection: string;
|
|
8
|
+
animationDuration: string;
|
|
9
|
+
animationFillMode: string;
|
|
10
|
+
animationIterationCount: string;
|
|
11
|
+
animationName: string;
|
|
12
|
+
animationPlayState: string;
|
|
13
|
+
animationTimingFunction: string;
|
|
14
|
+
background: string;
|
|
15
|
+
bg: string;
|
|
16
|
+
backgroundColor: string;
|
|
17
|
+
backgroundImage: string;
|
|
18
|
+
backgroundOrigin: string;
|
|
19
|
+
backgroundPosition: string;
|
|
20
|
+
backgroundRepeat: string;
|
|
21
|
+
backgroundSize: string;
|
|
22
|
+
backfaceVisibility: string;
|
|
23
|
+
backgroundAttachment: string;
|
|
24
|
+
backgroundBlendMode: string;
|
|
25
|
+
backgroundClip: string;
|
|
26
|
+
border: string;
|
|
27
|
+
borderBottom: string;
|
|
28
|
+
borderBottomColor: string;
|
|
29
|
+
borderBottomStyle: string;
|
|
30
|
+
borderBottomWidth: string;
|
|
31
|
+
borderCollapse: string;
|
|
32
|
+
borderColor: string;
|
|
33
|
+
borderImage: string;
|
|
34
|
+
borderImageOutset: string;
|
|
35
|
+
borderImageRepeat: string;
|
|
36
|
+
borderImageSlice: string;
|
|
37
|
+
borderImageSource: string;
|
|
38
|
+
borderImageWidth: string;
|
|
39
|
+
borderLeft: string;
|
|
40
|
+
borderLeftColor: string;
|
|
41
|
+
borderLeftStyle: string;
|
|
42
|
+
borderLeftWidth: string;
|
|
43
|
+
borderRight: string;
|
|
44
|
+
borderRightColor: string;
|
|
45
|
+
borderRightStyle: string;
|
|
46
|
+
borderRightWidth: string;
|
|
47
|
+
borderSpacing: string;
|
|
48
|
+
borderStyle: string;
|
|
49
|
+
borderTop: string;
|
|
50
|
+
borderTopColor: string;
|
|
51
|
+
borderTopStyle: string;
|
|
52
|
+
borderTopWidth: string;
|
|
53
|
+
borderWidth: string;
|
|
54
|
+
borderRadius: string;
|
|
55
|
+
r: string;
|
|
56
|
+
borderTopLeftRadius: string;
|
|
57
|
+
rtl: string;
|
|
58
|
+
borderTopRightRadius: string;
|
|
59
|
+
rtr: string;
|
|
60
|
+
borderBottomLeftRadius: string;
|
|
61
|
+
rbl: string;
|
|
62
|
+
borderBottomRightRadius: string;
|
|
63
|
+
rbr: string;
|
|
64
|
+
bottom: string;
|
|
65
|
+
boxDecorationBreak: string;
|
|
66
|
+
boxShadow: string;
|
|
67
|
+
boxSizing: string;
|
|
68
|
+
captionSide: string;
|
|
69
|
+
caretColor: string;
|
|
70
|
+
"@charset": string;
|
|
71
|
+
clear: string;
|
|
72
|
+
clip: string;
|
|
73
|
+
clipPath: string;
|
|
74
|
+
color: string;
|
|
75
|
+
c: string;
|
|
76
|
+
columnCount: string;
|
|
77
|
+
columnFill: string;
|
|
78
|
+
columnGap: string;
|
|
79
|
+
colGap: string;
|
|
80
|
+
columnRule: string;
|
|
81
|
+
columnRuleColor: string;
|
|
82
|
+
columnRuleStyle: string;
|
|
83
|
+
columnRuleWidth: string;
|
|
84
|
+
columnSpan: string;
|
|
85
|
+
columnWidth: string;
|
|
86
|
+
columns: string;
|
|
87
|
+
content: string;
|
|
88
|
+
counterIncrement: string;
|
|
89
|
+
counterReset: string;
|
|
90
|
+
cursor: string;
|
|
91
|
+
pointer: string;
|
|
92
|
+
direction: string;
|
|
93
|
+
display: string;
|
|
94
|
+
emptyCells: string;
|
|
95
|
+
filter: string;
|
|
96
|
+
flex: string;
|
|
97
|
+
flexBasis: string;
|
|
98
|
+
flexDirection: string;
|
|
99
|
+
flexDir: string;
|
|
100
|
+
flexFlow: string;
|
|
101
|
+
flexGrow: string;
|
|
102
|
+
flexShrink: string;
|
|
103
|
+
flexWrap: string;
|
|
104
|
+
float: string;
|
|
105
|
+
font: string;
|
|
106
|
+
fontFamily: string;
|
|
107
|
+
fontKerning: string;
|
|
108
|
+
s: string;
|
|
109
|
+
fontSize: string;
|
|
110
|
+
fontSizeAdjust: string;
|
|
111
|
+
fontStretch: string;
|
|
112
|
+
fontStyle: string;
|
|
113
|
+
fontVariant: string;
|
|
114
|
+
bold: string;
|
|
115
|
+
fontWeight: string;
|
|
116
|
+
b: string;
|
|
117
|
+
gap: string;
|
|
118
|
+
grid: string;
|
|
119
|
+
gridArea: string;
|
|
120
|
+
gridAutoColumns: string;
|
|
121
|
+
gridAutoFlow: string;
|
|
122
|
+
gridAutoRows: string;
|
|
123
|
+
gridColumn: string;
|
|
124
|
+
gridColumnEnd: string;
|
|
125
|
+
gridColumnGap: string;
|
|
126
|
+
gridColumnStart: string;
|
|
127
|
+
gridGap: string;
|
|
128
|
+
gridRow: string;
|
|
129
|
+
gridRowEnd: string;
|
|
130
|
+
gridRowGap: string;
|
|
131
|
+
gridRowStart: string;
|
|
132
|
+
gridTemplate: string;
|
|
133
|
+
gridTemplateAreas: string;
|
|
134
|
+
gridTemplateColumns: string;
|
|
135
|
+
gridTemplateRows: string;
|
|
136
|
+
hangingPunctuation: string;
|
|
137
|
+
hyphens: string;
|
|
138
|
+
isolation: string;
|
|
139
|
+
justifyContent: string;
|
|
140
|
+
left: string;
|
|
141
|
+
letterSpacing: string;
|
|
142
|
+
lineHeight: string;
|
|
143
|
+
lh: string;
|
|
144
|
+
listStyle: string;
|
|
145
|
+
listStyleImage: string;
|
|
146
|
+
listStylePosition: string;
|
|
147
|
+
listStyleType: string;
|
|
148
|
+
aspectRatio: string;
|
|
149
|
+
margin: string;
|
|
150
|
+
m: string;
|
|
151
|
+
marginBottom: string;
|
|
152
|
+
mb: string;
|
|
153
|
+
marginLeft: string;
|
|
154
|
+
ml: string;
|
|
155
|
+
marginRight: string;
|
|
156
|
+
mr: string;
|
|
157
|
+
marginTop: string;
|
|
158
|
+
mt: string;
|
|
159
|
+
height: string;
|
|
160
|
+
h: string;
|
|
161
|
+
minHeight: string;
|
|
162
|
+
minH: string;
|
|
163
|
+
maxHeight: string;
|
|
164
|
+
maxH: string;
|
|
165
|
+
width: string;
|
|
166
|
+
w: string;
|
|
167
|
+
minWidth: string;
|
|
168
|
+
minW: string;
|
|
169
|
+
maxWidth: string;
|
|
170
|
+
maxW: string;
|
|
171
|
+
mixBlendMode: string;
|
|
172
|
+
objectFit: string;
|
|
173
|
+
objectPosition: string;
|
|
174
|
+
opacity: string;
|
|
175
|
+
order: string;
|
|
176
|
+
outline: string;
|
|
177
|
+
outlineColor: string;
|
|
178
|
+
outlineOffset: string;
|
|
179
|
+
outlineStyle: string;
|
|
180
|
+
outlineWidth: string;
|
|
181
|
+
overflow: string;
|
|
182
|
+
overflowX: string;
|
|
183
|
+
overflowY: string;
|
|
184
|
+
padding: string;
|
|
185
|
+
p: string;
|
|
186
|
+
paddingBottom: string;
|
|
187
|
+
pb: string;
|
|
188
|
+
paddingLeft: string;
|
|
189
|
+
pl: string;
|
|
190
|
+
paddingRight: string;
|
|
191
|
+
pr: string;
|
|
192
|
+
paddingTop: string;
|
|
193
|
+
pt: string;
|
|
194
|
+
pageBreakAfter: string;
|
|
195
|
+
pageBreakBefore: string;
|
|
196
|
+
pageBreakInside: string;
|
|
197
|
+
perspective: string;
|
|
198
|
+
perspectiveOrigin: string;
|
|
199
|
+
pointerEvents: string;
|
|
200
|
+
position: string;
|
|
201
|
+
quotes: string;
|
|
202
|
+
resize: string;
|
|
203
|
+
right: string;
|
|
204
|
+
scrollBehavior: string;
|
|
205
|
+
tabSize: string;
|
|
206
|
+
tableLayout: string;
|
|
207
|
+
align: string;
|
|
208
|
+
textAlign: string;
|
|
209
|
+
textAlignLast: string;
|
|
210
|
+
textDecoration: string;
|
|
211
|
+
td: string;
|
|
212
|
+
textDecorationColor: string;
|
|
213
|
+
textDecorationLine: string;
|
|
214
|
+
textDecorationStyle: string;
|
|
215
|
+
textIndent: string;
|
|
216
|
+
textJustify: string;
|
|
217
|
+
textOverflow: string;
|
|
218
|
+
textShadow: string;
|
|
219
|
+
textTransform: string;
|
|
220
|
+
top: string;
|
|
221
|
+
transform: string;
|
|
222
|
+
"transform(2D)": string;
|
|
223
|
+
"transformOrigin(twoValue syntax)": string;
|
|
224
|
+
transformStyle: string;
|
|
225
|
+
transition: string;
|
|
226
|
+
transitionDelay: string;
|
|
227
|
+
transitionDuration: string;
|
|
228
|
+
transitionProperty: string;
|
|
229
|
+
transitionTimingFunction: string;
|
|
230
|
+
unicodeBidi: string;
|
|
231
|
+
userSelect: string;
|
|
232
|
+
verticalAlign: string;
|
|
233
|
+
visibility: string;
|
|
234
|
+
whiteSpace: string;
|
|
235
|
+
wordBreak: string;
|
|
236
|
+
wordSpacing: string;
|
|
237
|
+
textWrap: string;
|
|
238
|
+
wordWrap: string;
|
|
239
|
+
writingMode: string;
|
|
240
|
+
zIndex: string;
|
|
241
|
+
backdropFilter: string;
|
|
242
|
+
};
|