@zuzjs/ui 0.5.4 → 0.5.6
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.js +34 -2
- package/dist/comps/accordion.d.ts +12 -0
- package/dist/comps/accordion.js +10 -0
- package/dist/comps/animate.d.ts +1 -1
- package/dist/comps/base.d.ts +4 -13
- package/dist/comps/base.js +3 -2
- package/dist/comps/box.d.ts +5 -2
- package/dist/comps/box.js +7 -3
- package/dist/comps/button.d.ts +4 -5
- package/dist/comps/button.js +14 -3
- package/dist/comps/checkbox.d.ts +1 -1
- package/dist/comps/checkbox.js +19 -0
- package/dist/comps/contextmenu.d.ts +1 -1
- package/dist/comps/cover.d.ts +1 -1
- package/dist/comps/cover.js +15 -0
- package/dist/comps/editor.js +8 -1
- package/dist/comps/form.d.ts +39 -5
- package/dist/comps/form.js +120 -31
- package/dist/comps/grid/index.d.ts +10 -0
- package/dist/comps/grid/index.js +16 -0
- package/dist/comps/heading.d.ts +4 -3
- package/dist/comps/heading.js +12 -6
- package/dist/comps/icon.d.ts +5 -5
- package/dist/comps/icon.js +18 -3
- package/dist/comps/image.d.ts +1 -1
- package/dist/comps/input.d.ts +5 -8
- package/dist/comps/input.js +15 -5
- package/dist/comps/otp/index.d.ts +6 -0
- package/dist/comps/otp/index.js +50 -0
- package/dist/comps/password.d.ts +3 -0
- package/dist/comps/password.js +30 -0
- package/dist/comps/search/index.d.ts +7 -0
- package/dist/comps/search/index.js +46 -0
- package/dist/comps/segmented/index.d.ts +46 -0
- package/dist/comps/segmented/index.js +59 -0
- package/dist/comps/segmented/item.d.ts +8 -0
- package/dist/comps/segmented/item.js +26 -0
- package/dist/comps/select/index.d.ts +15 -0
- package/dist/comps/select/index.js +79 -0
- package/dist/comps/select/select.d.ts +0 -0
- package/dist/comps/select/select.js +1 -0
- package/dist/comps/sheet.d.ts +1 -0
- package/dist/comps/sheet.js +30 -0
- package/dist/comps/span.d.ts +6 -0
- package/dist/comps/span.js +12 -0
- package/dist/comps/spinner.d.ts +1 -1
- package/dist/comps/spinner.js +1 -0
- package/dist/comps/svgicons.d.ts +3 -0
- package/dist/comps/svgicons.js +8 -0
- package/dist/comps/tabview.js +8 -1
- package/dist/comps/textwheel.d.ts +1 -1
- package/dist/comps/textwheel.js +2 -0
- package/dist/comps/useBase/base.types.d.ts +80 -0
- package/dist/comps/useBase/base.types.js +1 -0
- package/dist/comps/useBase/index.d.ts +10 -0
- package/dist/comps/useBase/index.js +62 -0
- package/dist/funs/colors.d.ts +6 -0
- package/dist/funs/colors.js +6 -0
- package/dist/funs/css.d.ts +3 -1
- package/dist/funs/css.js +172 -21
- package/dist/funs/events.d.ts +4 -2
- package/dist/funs/events.js +9 -6
- package/dist/funs/index.d.ts +9 -0
- package/dist/funs/index.js +62 -2
- package/dist/funs/stylesheet.js +15 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/useDB.d.ts +25 -0
- package/dist/hooks/useDB.js +101 -0
- package/dist/hooks/useIntersectionObserver.d.ts +1 -1
- package/dist/hooks/useIntersectionObserver.js +28 -11
- package/dist/hooks/useKeyBind.js +1 -0
- package/dist/hooks/useMounted.d.ts +15 -0
- package/dist/hooks/useMounted.js +16 -1
- package/dist/hooks/useToast.d.ts +1 -1
- package/dist/hooks/useToast.js +1 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +10 -1
- package/dist/styles.css +1 -1
- package/dist/types/enums.d.ts +15 -10
- package/dist/types/enums.js +25 -0
- package/dist/types/interfaces.d.ts +37 -3
- package/package.json +1 -1
- package/dist/comps/select.d.ts +0 -18
- package/dist/comps/select.js +0 -31
package/dist/funs/css.js
CHANGED
|
@@ -28,8 +28,10 @@ class CSS {
|
|
|
28
28
|
DIRECT_VALUES;
|
|
29
29
|
PROPS_VALUES;
|
|
30
30
|
_currentFile;
|
|
31
|
-
|
|
31
|
+
debug;
|
|
32
|
+
constructor(options, debug) {
|
|
32
33
|
const opts = options || {};
|
|
34
|
+
this.debug = debug;
|
|
33
35
|
this._cli = false;
|
|
34
36
|
this._mediaQueries = {};
|
|
35
37
|
this._mediaQueriesLabels = {
|
|
@@ -40,11 +42,11 @@ class CSS {
|
|
|
40
42
|
xl: `Extra Large Devices (Large Desktops)`,
|
|
41
43
|
};
|
|
42
44
|
this.mediaQueries = {
|
|
43
|
-
ph: `(max-width: 599px)`,
|
|
44
|
-
sm: `(min-width: 600px) and (max-width: 767px)`,
|
|
45
|
-
md: `(min-width: 768px) and (max-width: 991px)`,
|
|
46
|
-
lg: `(min-width: 992px) and (max-width: 1199px)`,
|
|
47
|
-
xl: `(min-width: 1200px)`,
|
|
45
|
+
ph: `(max-width: 599px)`, /* Extra Small Devices (Phones) */
|
|
46
|
+
sm: `(min-width: 600px) and (max-width: 767px)`, /* Small Devices (Tablets) */
|
|
47
|
+
md: `(min-width: 768px) and (max-width: 991px)`, /* Medium Devices (Small Laptops) */
|
|
48
|
+
lg: `(min-width: 992px) and (max-width: 1199px)`, /* Large Devices (Laptops and Desktops) */
|
|
49
|
+
xl: `(min-width: 1200px)`, /* Extra Large Devices (Large Desktops) */
|
|
48
50
|
};
|
|
49
51
|
this.cx = [];
|
|
50
52
|
this.cache = {};
|
|
@@ -61,9 +63,10 @@ class CSS {
|
|
|
61
63
|
`flex`, `opacity`, `z-index`, `zIndex`, `color`, `line-height`, `anim`, `scale`, `saturate`
|
|
62
64
|
];
|
|
63
65
|
this.keysWithoutCommaToSpace = [
|
|
64
|
-
`transform`, `translate`, `color`, `background`, `background-color`, `backgroundColor`,
|
|
66
|
+
`transform`, `translate`, `color`, `background`, `background-color`, `backgroundColor`, `backgroundImage`, `background-image`,
|
|
65
67
|
`border`, `border-bottom`, `border-top`, `border-left`, `border-right`,
|
|
66
|
-
`grid-template-rows`, `grid-template-columns`
|
|
68
|
+
`grid-template-rows`, `grid-template-columns`, `grid-auto-rows`, `grid-auto-columns`,
|
|
69
|
+
`clip-path`, `clipPath`,
|
|
67
70
|
];
|
|
68
71
|
this.propCounter = {};
|
|
69
72
|
this.ids = [];
|
|
@@ -80,6 +83,7 @@ class CSS {
|
|
|
80
83
|
arr.push(cssDirect[k].replace(/\s+/g, ``));
|
|
81
84
|
return arr;
|
|
82
85
|
}, []);
|
|
86
|
+
// extendGlobals()
|
|
83
87
|
}
|
|
84
88
|
buildMediaQueries(queries) {
|
|
85
89
|
const self = this;
|
|
@@ -95,7 +99,9 @@ class CSS {
|
|
|
95
99
|
styleSheet(cache, pseudo = ``) {
|
|
96
100
|
const self = this;
|
|
97
101
|
const scss = [];
|
|
102
|
+
// console.log(cache)
|
|
98
103
|
const build = (key, value) => {
|
|
104
|
+
// console.log(`build`, key, value)
|
|
99
105
|
const __build = (_key, _value) => {
|
|
100
106
|
let _css = `${self.pseudoList.includes(`@${_key}`) ? `&:` : `.`}${_key}{`;
|
|
101
107
|
if (`object` == typeof _value) {
|
|
@@ -117,6 +123,7 @@ class CSS {
|
|
|
117
123
|
let css = ``;
|
|
118
124
|
if (`object` == typeof value && Object.keys(value)[0] in this.mediaQueries) {
|
|
119
125
|
const mq = Object.keys(value)[0];
|
|
126
|
+
// css += `@media screen and ${this.mediaQueries[mq]}{`
|
|
120
127
|
let __css = `.${key}{`;
|
|
121
128
|
const _value = value[mq];
|
|
122
129
|
for (const prop in _value) {
|
|
@@ -131,6 +138,8 @@ class CSS {
|
|
|
131
138
|
this._mediaQueries[mq] = this._mediaQueries[mq] || [];
|
|
132
139
|
this._mediaQueries[mq].push(__css);
|
|
133
140
|
}
|
|
141
|
+
// else if ( key in self.mediaQueries ){
|
|
142
|
+
// }
|
|
134
143
|
else {
|
|
135
144
|
css += __build(key, value);
|
|
136
145
|
}
|
|
@@ -184,9 +193,11 @@ class CSS {
|
|
|
184
193
|
for (const prop in value) {
|
|
185
194
|
if (`string` === typeof value[prop]) {
|
|
186
195
|
_extend.push(`.${prop}`);
|
|
196
|
+
// _extend.push(self.buildCache[prop])
|
|
187
197
|
}
|
|
188
198
|
}
|
|
189
199
|
if (_extend.length > 0)
|
|
200
|
+
// css += _extend.join(``)
|
|
190
201
|
css += `@extend ${_extend.join(`, `)};`;
|
|
191
202
|
for (const prop in value) {
|
|
192
203
|
if (`object` === typeof value[prop]) {
|
|
@@ -197,6 +208,9 @@ class CSS {
|
|
|
197
208
|
css += `}`;
|
|
198
209
|
return css;
|
|
199
210
|
};
|
|
211
|
+
/**
|
|
212
|
+
* Build Master Keys
|
|
213
|
+
*/
|
|
200
214
|
for (const key in cache) {
|
|
201
215
|
if (key == FIELNAME_KEY) {
|
|
202
216
|
scss.push(`/**\n* @file ${cache[key]}\n*/`);
|
|
@@ -204,17 +218,24 @@ class CSS {
|
|
|
204
218
|
}
|
|
205
219
|
extractMasterKeys(key, cache[key]);
|
|
206
220
|
}
|
|
221
|
+
/**
|
|
222
|
+
* Extract LINE_KEY
|
|
223
|
+
*/
|
|
207
224
|
for (const key in cache) {
|
|
208
225
|
if (key.startsWith(LINE_KEY)) {
|
|
209
226
|
scss.push(cache[key]);
|
|
210
227
|
delete cache[key];
|
|
211
228
|
}
|
|
212
229
|
}
|
|
230
|
+
/**
|
|
231
|
+
* Build Extends
|
|
232
|
+
*/
|
|
213
233
|
for (const key in cache) {
|
|
214
234
|
if (`object` == typeof cache[key]) {
|
|
215
235
|
scss.push(build(key, cache[key]));
|
|
216
236
|
}
|
|
217
237
|
}
|
|
238
|
+
// scss.push(self.classLine)
|
|
218
239
|
return scss.join(`\n`);
|
|
219
240
|
}
|
|
220
241
|
cleanKey(key) {
|
|
@@ -237,6 +258,7 @@ class CSS {
|
|
|
237
258
|
const __k = self.cleanKey(_k);
|
|
238
259
|
if (`object` == typeof cache[_k]) {
|
|
239
260
|
const _d = oid(_k, cache[_k]);
|
|
261
|
+
// console.log(_d)
|
|
240
262
|
let _indices = 0;
|
|
241
263
|
for (let i = 0; i < _d.length; i++) {
|
|
242
264
|
_indices += self.chars.indexOf(_d.charAt(i));
|
|
@@ -260,6 +282,7 @@ class CSS {
|
|
|
260
282
|
return _;
|
|
261
283
|
}
|
|
262
284
|
makeUnit(k, v) {
|
|
285
|
+
// console.log(`unit`, k, v)
|
|
263
286
|
if (k == `rotate`) {
|
|
264
287
|
return `deg`;
|
|
265
288
|
}
|
|
@@ -287,6 +310,7 @@ class CSS {
|
|
|
287
310
|
return v.trim();
|
|
288
311
|
}
|
|
289
312
|
makeValue(k, v) {
|
|
313
|
+
// const hasGradient = v.includes(`gradient`)
|
|
290
314
|
const self = this;
|
|
291
315
|
if (k in this.PROPS) {
|
|
292
316
|
const key = this.PROPS[k];
|
|
@@ -295,11 +319,17 @@ class CSS {
|
|
|
295
319
|
let hasImportant = v.charAt(v.length - 1) == `!`;
|
|
296
320
|
v = hasImportant ? v.slice(0, -1) : v;
|
|
297
321
|
let important = hasImportant ? ` !important` : ``;
|
|
298
|
-
|
|
322
|
+
let isGradient = v.startsWith(`gradient`) || v.startsWith(`linear-gradient`) || v.startsWith(`radial-gradient`);
|
|
323
|
+
/**
|
|
324
|
+
* Gradients
|
|
325
|
+
*/
|
|
326
|
+
if (isGradient) {
|
|
299
327
|
if (v.startsWith(`gradient`)) {
|
|
300
328
|
v = `linear-${v}`;
|
|
301
329
|
}
|
|
330
|
+
//linear-gradient-to-bottom-blue-green
|
|
302
331
|
const [_gtype, _xyz, _gto, _gdeg, ..._colors] = v.split(`-`);
|
|
332
|
+
// const _gdegree = _gdeg.isNumber() ? `${_gdeg}deg` : `to ${_gto}`
|
|
303
333
|
const _gdegree = /^[+-]?\d+(\.\d+)?$/.test(_gdeg) ? `${_gdeg}deg` : `to ${_gdeg}`;
|
|
304
334
|
const _gcolors = _colors.reduce((arr, val) => {
|
|
305
335
|
arr.push(self.makeColor(val));
|
|
@@ -310,24 +340,33 @@ class CSS {
|
|
|
310
340
|
value = `linear-gradient(${_gdegree}, ${_gcolors})`;
|
|
311
341
|
break;
|
|
312
342
|
case `radial`:
|
|
343
|
+
// value = `radial-gradient(${_gparts[1]})`
|
|
313
344
|
break;
|
|
314
345
|
default:
|
|
315
346
|
value = v;
|
|
316
347
|
break;
|
|
317
348
|
}
|
|
318
349
|
}
|
|
350
|
+
/**
|
|
351
|
+
* Variable
|
|
352
|
+
*/
|
|
319
353
|
else if (v.charAt(0) == `$`) {
|
|
320
354
|
value = `var(--${v.replace(`$`, ``)})`;
|
|
321
355
|
}
|
|
322
356
|
else if (v.trim() == `transparent`) {
|
|
323
357
|
value = `rgba(0,0,0,0)`;
|
|
324
358
|
}
|
|
359
|
+
/**
|
|
360
|
+
* border
|
|
361
|
+
*/
|
|
325
362
|
else if ([`border`, `borderBottom`, `borderTop`, `borderLeft`, `borderRight`].includes(k)) {
|
|
326
363
|
const _parts = [];
|
|
364
|
+
// console.log(`--border`, key, v)
|
|
327
365
|
if (v.match(this.rgbaRegex)) {
|
|
328
366
|
_parts.push(v.match(this.rgbaRegex)[0].replace(`[`, `(`).replace(`]`, `)`));
|
|
329
367
|
v = v.replace(this.rgbaRegex, ``).trim().replace(`,,`, `,`);
|
|
330
368
|
}
|
|
369
|
+
// console.log(`-border`, key, v, _parts)
|
|
331
370
|
v.split(`,`).map((p) => {
|
|
332
371
|
if (p.includes(`rgb`) || p.includes(`rgba`) || isColor(`#${p}`) || p.startsWith(`$`)) {
|
|
333
372
|
if (p.includes(`rgb`) || p.includes(`rgba`)) {
|
|
@@ -349,8 +388,13 @@ class CSS {
|
|
|
349
388
|
}
|
|
350
389
|
});
|
|
351
390
|
value = _parts.join(` `);
|
|
391
|
+
// console.log(`border`, value)
|
|
352
392
|
}
|
|
393
|
+
/**
|
|
394
|
+
* Color
|
|
395
|
+
*/
|
|
353
396
|
else if ([`color`, `bg`, `background`, `background-color`, `backgroundColor`].includes(key)) {
|
|
397
|
+
// else if ( [`color`].includes( key ) ){
|
|
354
398
|
if (v.charAt(0) == `#`) {
|
|
355
399
|
v = v.substring(1);
|
|
356
400
|
}
|
|
@@ -364,28 +408,69 @@ class CSS {
|
|
|
364
408
|
else
|
|
365
409
|
value = v.trim();
|
|
366
410
|
}
|
|
411
|
+
/**
|
|
412
|
+
* FontWeight
|
|
413
|
+
*/
|
|
367
414
|
else if (key == `font-weight`) {
|
|
368
415
|
value = v;
|
|
369
416
|
}
|
|
417
|
+
/**
|
|
418
|
+
* value with brackets like calc(), var() should be passed as calc[value]
|
|
419
|
+
*/
|
|
370
420
|
else if (v.match(/\[(.*?)\]/g)) {
|
|
421
|
+
const replaceBrackets = (input) => {
|
|
422
|
+
const stack = [];
|
|
423
|
+
const chars = input.split('');
|
|
424
|
+
for (let i = 0; i < chars.length; i++) {
|
|
425
|
+
if (chars[i] === '[') {
|
|
426
|
+
stack.push('('); // Replace '[' with '('
|
|
427
|
+
}
|
|
428
|
+
else if (chars[i] === ']') {
|
|
429
|
+
stack.push(')'); // Replace ']' with ')'
|
|
430
|
+
}
|
|
431
|
+
else if (chars[i] === `$`) {
|
|
432
|
+
let varName = ``;
|
|
433
|
+
i++;
|
|
434
|
+
while (chars[i] && /[a-zA-Z0-9_-]/.test(chars[i])) {
|
|
435
|
+
varName += chars[i];
|
|
436
|
+
i++;
|
|
437
|
+
}
|
|
438
|
+
i--;
|
|
439
|
+
stack.push(`var(--${varName})`);
|
|
440
|
+
}
|
|
441
|
+
else {
|
|
442
|
+
stack.push(chars[i]); // Push other characters as-is
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
return stack.join('');
|
|
446
|
+
};
|
|
371
447
|
try {
|
|
372
|
-
const vs = v.match(/\[(.*?)\]/g)[0].slice(1, -1)
|
|
373
|
-
const [_vc] = v.split(`[`)
|
|
374
|
-
value = `${_vc.trim()}(${vs})
|
|
448
|
+
// const vs = v.match(/\[(.*?)\]/g)[0].slice(1, -1)
|
|
449
|
+
// const [ _vc ] = v.split(`[`)
|
|
450
|
+
// value = `${_vc.trim()}(${vs})`
|
|
451
|
+
value = replaceBrackets(v);
|
|
452
|
+
// console.log(`started with []`, replaceBrackets(v))
|
|
375
453
|
}
|
|
376
454
|
catch (e) { }
|
|
377
455
|
}
|
|
378
456
|
else {
|
|
457
|
+
// ${v.charAt(0) == `$` ? `var(--${v.substring(1)})` : v}
|
|
458
|
+
// if ( key.includes(`padding`) ) console.log(`->padding`, v)
|
|
379
459
|
if (v.includes(`,`)) {
|
|
460
|
+
// console.log(`vwithcomma`, v)
|
|
380
461
|
let __v = [];
|
|
381
462
|
v.split(`,`).map((_) => {
|
|
463
|
+
// console.log(`comma`, _, cssPropsWithColor.includes(_) && isColor(`#${_}`))
|
|
382
464
|
if (_.charAt(0) == `#`) {
|
|
383
465
|
_ = _.substring(1);
|
|
384
466
|
}
|
|
467
|
+
//Variable
|
|
385
468
|
if (_.startsWith(`$`)) {
|
|
386
469
|
__v.push(`var(--${_.substring(1)})`);
|
|
387
470
|
}
|
|
471
|
+
//Color
|
|
388
472
|
else if (cssPropsWithColor.includes(_) && isColor(`#${_}`)) {
|
|
473
|
+
// else if ( isColor(_) ){
|
|
389
474
|
if (_.includes(`rgb`) || _.includes(`rgba`)) {
|
|
390
475
|
__v.push(_.replace(`[`, `(`).replace(`]`, `)`));
|
|
391
476
|
}
|
|
@@ -393,20 +478,32 @@ class CSS {
|
|
|
393
478
|
__v.push(isHexColor(`#${_}`) ? `#${_}` : _);
|
|
394
479
|
}
|
|
395
480
|
}
|
|
481
|
+
else if (isColor(`#${_}`)) {
|
|
482
|
+
__v.push(self.makeColor(_));
|
|
483
|
+
}
|
|
396
484
|
else {
|
|
485
|
+
// console.log(`comma`, key, v, this.makeUnit(key, v))
|
|
397
486
|
__v.push(`${_}${this.makeUnit(key, _)}`);
|
|
398
487
|
}
|
|
399
488
|
});
|
|
400
489
|
value = __v.join(` `);
|
|
490
|
+
// console.log(key, value)
|
|
491
|
+
// if( k == `shadow` || k == `box-shadow` ) console.log(value)
|
|
401
492
|
}
|
|
402
493
|
else
|
|
403
494
|
value = `${v}${this.makeUnit(key, v)}`;
|
|
404
495
|
}
|
|
405
496
|
if (!value)
|
|
406
497
|
return ``;
|
|
498
|
+
// if ( key.includes(`border`) ) console.log(`--border`, `${key}: ${value}${important};`)
|
|
407
499
|
value = value.includes(`,`) && !this.keysWithoutCommaToSpace.includes(key) ? value.replace(`,`, ` `) : value;
|
|
500
|
+
// if ( key == `grid-auto-rows` ) console.log(`makevalue`, key, value)
|
|
501
|
+
// if ( key.includes(`padding`) ) console.log(`->padding`, `${key}: ${value}${important};`)
|
|
408
502
|
if (key == `content`)
|
|
409
503
|
value = `"${value}"`;
|
|
504
|
+
// if ( key == `grid-template-columns` || key == `grid-cols` ){
|
|
505
|
+
// console.log(key, value)
|
|
506
|
+
// }
|
|
410
507
|
return `${key}: ${value}${important};`;
|
|
411
508
|
}
|
|
412
509
|
return ``;
|
|
@@ -423,7 +520,9 @@ class CSS {
|
|
|
423
520
|
const md = md5(_out);
|
|
424
521
|
let _ = [];
|
|
425
522
|
const _mi = (_k, _v) => {
|
|
523
|
+
// console.log(_k, _v, Math.abs(self.DIRECT_KEYS.indexOf(_k)) + Math.abs(self.PROPS_VALUES.indexOf(_k)))
|
|
426
524
|
let i = Math.abs(self.DIRECT_KEYS.indexOf(_k)) + Math.abs(self.PROPS_VALUES.indexOf(_k));
|
|
525
|
+
// _k in self.DIRECT ? self.DIRECT_KEYS.indexOf(_k) : _k in self.PROPS_VALUES ? self.PROPS_VALUES.indexOf(_k) : 0
|
|
427
526
|
_.push(i);
|
|
428
527
|
const nums = _v.match(/[0-9]/g);
|
|
429
528
|
if (nums) {
|
|
@@ -446,7 +545,9 @@ class CSS {
|
|
|
446
545
|
if (ov == ``) {
|
|
447
546
|
console.log(pc.yellow(`[${self._currentFile}]`), pc.cyan(k), pc.red(`value is empty.`));
|
|
448
547
|
return ``;
|
|
548
|
+
// throw new TypeError()
|
|
449
549
|
}
|
|
550
|
+
/**Prefix */
|
|
450
551
|
let _cp = ok.charAt(0);
|
|
451
552
|
if (self.PROPS[ok]?.indexOf("-") > -1) {
|
|
452
553
|
_cp = "";
|
|
@@ -499,15 +600,23 @@ class CSS {
|
|
|
499
600
|
processWord();
|
|
500
601
|
}
|
|
501
602
|
else {
|
|
603
|
+
//SKIPABLE
|
|
604
|
+
// if([`(`].includes(char) && level == 0 ){
|
|
605
|
+
// //DON'T ADD
|
|
606
|
+
// }
|
|
502
607
|
if ([`&`].includes(char)) {
|
|
503
608
|
isLevel = true;
|
|
504
609
|
}
|
|
610
|
+
//Level Start
|
|
505
611
|
else if ([`(`].includes(char) && isLevel) {
|
|
506
612
|
processWord();
|
|
507
613
|
}
|
|
614
|
+
//Level End
|
|
508
615
|
else if ([`)`].includes(char)) {
|
|
509
616
|
processWord();
|
|
617
|
+
// console.log(`before->`, levels)
|
|
510
618
|
levels.splice(-1, 1);
|
|
619
|
+
// console.log(`after->`, levels)
|
|
511
620
|
isLevel = false;
|
|
512
621
|
}
|
|
513
622
|
else {
|
|
@@ -546,8 +655,10 @@ class CSS {
|
|
|
546
655
|
if (key in self.PROPS) {
|
|
547
656
|
const _out = self.makeValue(key, _val);
|
|
548
657
|
const _id = self.makeID(key, _val + pseudo, _out);
|
|
658
|
+
// console.log(`props`, _k, _id)
|
|
549
659
|
if (pseudo == ``)
|
|
550
660
|
self.cx.push(_id);
|
|
661
|
+
// console.log(`_build`, key, _val, _id, _out)
|
|
551
662
|
if (_mediaQuery) {
|
|
552
663
|
self.mediaQueries[_mediaQuery].push({ [_id]: _out });
|
|
553
664
|
return {};
|
|
@@ -559,6 +670,9 @@ class CSS {
|
|
|
559
670
|
const important = hasImportant ? ` !important` : ``;
|
|
560
671
|
let val = hasImportant ? _val.slice(0, -1) : _val;
|
|
561
672
|
var _out = ``;
|
|
673
|
+
// if ( key == `ratio` ){
|
|
674
|
+
// console.log(`RatioFound`, key, val)
|
|
675
|
+
// }
|
|
562
676
|
if (key == `extend`) {
|
|
563
677
|
val = val.split(`,`).reduce((acc, v) => {
|
|
564
678
|
acc.push(`${v.startsWith(`.`) ? `` : `.`}${v.trim()}`);
|
|
@@ -578,6 +692,8 @@ class CSS {
|
|
|
578
692
|
const [_duration, ..._rest] = val.split(`,`);
|
|
579
693
|
let rest = _rest.join(",").trim();
|
|
580
694
|
duration = _duration;
|
|
695
|
+
// if ( rest.includes(`],`) ){
|
|
696
|
+
// }
|
|
581
697
|
if (rest.includes(`[`) && rest.includes(`]`)) {
|
|
582
698
|
for (const curv in cssAnimationCurves) {
|
|
583
699
|
if (rest.startsWith(curv)) {
|
|
@@ -594,11 +710,14 @@ class CSS {
|
|
|
594
710
|
_out = _out.replace(`;`, `${important};`);
|
|
595
711
|
}
|
|
596
712
|
else {
|
|
713
|
+
// const __value = `${val}${key == `extend` ? `` : self.makeUnit(key, val)}`
|
|
597
714
|
const __value = `${val}${self.IGNORE.includes(key) ? `` : self.makeUnit(key, val)}`;
|
|
598
715
|
_out = self.DIRECT[key].includes(`__VALUE__`) ?
|
|
599
716
|
self.DIRECT[key].replace(/__VALUE__/g, __value).replace(`;`, `${important};`) : self.DIRECT[key];
|
|
600
717
|
}
|
|
718
|
+
// console.log(`_build`, key, _val)
|
|
601
719
|
const _id = self.makeID(key, key + pseudo, _out);
|
|
720
|
+
// console.log(`_buildid`, key, _id)
|
|
602
721
|
if (pseudo == ``)
|
|
603
722
|
self.cx.push(_id);
|
|
604
723
|
if (_mediaQuery) {
|
|
@@ -611,6 +730,7 @@ class CSS {
|
|
|
611
730
|
else if (_k in self.DIRECT) {
|
|
612
731
|
const _out = self.DIRECT[_k];
|
|
613
732
|
const _id = self.makeID(_k, _k + pseudo, _out);
|
|
733
|
+
// console.log(_k, _id)
|
|
614
734
|
if (pseudo == ``)
|
|
615
735
|
self.cx.push(_id);
|
|
616
736
|
if (_mediaQuery) {
|
|
@@ -621,6 +741,7 @@ class CSS {
|
|
|
621
741
|
}
|
|
622
742
|
else if (_k.trim().match(/^[a-zA-Z0-9\-]+$/g)) {
|
|
623
743
|
self.cx.push(_k.trim());
|
|
744
|
+
// self.cx.push(`--${_k.trim()}`)
|
|
624
745
|
}
|
|
625
746
|
return {};
|
|
626
747
|
};
|
|
@@ -637,6 +758,9 @@ class CSS {
|
|
|
637
758
|
return out;
|
|
638
759
|
};
|
|
639
760
|
const _built = build(self.lexer(line));
|
|
761
|
+
if (self.debug?.lexer)
|
|
762
|
+
console.log(line, self.lexer(line), _built);
|
|
763
|
+
// console.log(line, self.lexer(line))
|
|
640
764
|
self.cache = { ...self.cache, ..._built };
|
|
641
765
|
}
|
|
642
766
|
}
|
|
@@ -661,13 +785,36 @@ class CSS {
|
|
|
661
785
|
self.processLine(line);
|
|
662
786
|
});
|
|
663
787
|
});
|
|
788
|
+
// console.log(self.deepClean(self.cache))
|
|
789
|
+
// const _ = cli ? {
|
|
790
|
+
// cx: [],
|
|
791
|
+
// sheet: self.styleSheet(self.deepClean(self.cache))
|
|
792
|
+
// } : {
|
|
793
|
+
// cx: self.cx,
|
|
794
|
+
// sheet: ``
|
|
795
|
+
// }
|
|
664
796
|
const _cleaned = self.deepClean(self.cache);
|
|
665
797
|
const _stylesheet = self.styleSheet(_cleaned);
|
|
798
|
+
// const _mediaQueries : dynamicObject = {}
|
|
799
|
+
// if ( !cli ){
|
|
800
|
+
// console.log(css, self.cx, self.styleSheet(_cleaned))
|
|
801
|
+
// }
|
|
802
|
+
if (self.debug?.classes)
|
|
803
|
+
console.log(`[${cli}]`, self.cx);
|
|
804
|
+
if (self.debug?.cache)
|
|
805
|
+
console.log(`[${cli}]`, self.cache);
|
|
806
|
+
if (self.debug?.cleaned)
|
|
807
|
+
console.log(`[${cli}]`, _cleaned);
|
|
808
|
+
if (self.debug?.sheet)
|
|
809
|
+
console.log(_stylesheet);
|
|
810
|
+
if (self.debug?.media)
|
|
811
|
+
console.log(self._mediaQueries);
|
|
666
812
|
const _ = {
|
|
667
813
|
cx: self.cx,
|
|
668
814
|
sheet: _stylesheet,
|
|
669
815
|
mediaQuery: self._mediaQueries
|
|
670
816
|
};
|
|
817
|
+
// console.log(css, _)
|
|
671
818
|
return _;
|
|
672
819
|
}
|
|
673
820
|
}
|
|
@@ -696,6 +843,7 @@ export const buildWithStyles = (source) => {
|
|
|
696
843
|
if (_transform.length > 0) {
|
|
697
844
|
_.transform = _transform.join(` `);
|
|
698
845
|
}
|
|
846
|
+
// console.log(_, _transform)
|
|
699
847
|
}
|
|
700
848
|
return _;
|
|
701
849
|
};
|
|
@@ -704,19 +852,22 @@ export const getAnimationCurve = (curve) => {
|
|
|
704
852
|
return `linear`;
|
|
705
853
|
switch (curve.toUpperCase()) {
|
|
706
854
|
case TRANSITION_CURVES.Bounce:
|
|
707
|
-
return `
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
855
|
+
return `var(--bounce)`;
|
|
856
|
+
// return `linear( 0, 0.0039, 0.0157, 0.0352, 0.0625 9.09%,
|
|
857
|
+
// 0.1407, 0.25, 0.3908, 0.5625, 0.7654,
|
|
858
|
+
// 1, 0.8907, 0.8125 45.45%, 0.7852, 0.7657,
|
|
859
|
+
// 0.7539, 0.75, 0.7539, 0.7657, 0.7852,
|
|
860
|
+
// 0.8125 63.64%, 0.8905, 1 72.73%, 0.9727, 0.9532,
|
|
861
|
+
// 0.9414, 0.9375, 0.9414, 0.9531, 0.9726,
|
|
862
|
+
// 1, 0.9883, 0.9844, 0.9883, 1 )`
|
|
714
863
|
break;
|
|
715
864
|
case TRANSITION_CURVES.Spring:
|
|
716
|
-
return `cubic-bezier(0.2, -0.36, 0, 1.46)
|
|
865
|
+
// return `cubic-bezier(0.2, -0.36, 0, 1.46)`
|
|
866
|
+
return `var(--spring)`;
|
|
717
867
|
break;
|
|
718
868
|
case TRANSITION_CURVES.EaseInOut:
|
|
719
|
-
return `cubic-bezier(0.42, 0, 0.58, 1)
|
|
869
|
+
// return `cubic-bezier(0.42, 0, 0.58, 1)`
|
|
870
|
+
return `ease-in-out`;
|
|
720
871
|
break;
|
|
721
872
|
default:
|
|
722
873
|
return `linear`;
|
package/dist/funs/events.d.ts
CHANGED
package/dist/funs/events.js
CHANGED
|
@@ -5,17 +5,18 @@ class Events {
|
|
|
5
5
|
}
|
|
6
6
|
addEvent(event, fun, context) {
|
|
7
7
|
const evt = this._events.find(x => x.event == event);
|
|
8
|
+
const listener = { fun: context ? fun.bind(context) : fun, context };
|
|
8
9
|
if (!evt) {
|
|
9
|
-
return this._events.push({ event: event, listeners: [
|
|
10
|
+
return this._events.push({ event: event, listeners: [listener] });
|
|
10
11
|
}
|
|
11
|
-
if (!evt.listeners.find(x => x == fun)) {
|
|
12
|
-
evt.listeners.push(
|
|
12
|
+
if (!evt.listeners.find(x => x.fun == fun)) {
|
|
13
|
+
evt.listeners.push(listener);
|
|
13
14
|
}
|
|
14
15
|
}
|
|
15
16
|
removeEvent(event, fun) {
|
|
16
17
|
const evt = this._events.find(x => x.event == event);
|
|
17
18
|
if (evt) {
|
|
18
|
-
evt.listeners = evt.listeners.filter(x => x != fun);
|
|
19
|
+
evt.listeners = evt.listeners.filter(x => x.fun != fun);
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
22
|
on(event, fun, context) {
|
|
@@ -27,9 +28,11 @@ class Events {
|
|
|
27
28
|
emit(event, ...args) {
|
|
28
29
|
const evt = this._events.find(x => x.event == event);
|
|
29
30
|
if (evt) {
|
|
30
|
-
|
|
31
|
+
// console.log(evt)
|
|
32
|
+
evt.listeners.forEach(({ fun, context }) => {
|
|
31
33
|
try {
|
|
32
|
-
f
|
|
34
|
+
// f(args)
|
|
35
|
+
fun.apply(context, args);
|
|
33
36
|
}
|
|
34
37
|
catch (e) {
|
|
35
38
|
console.error(e);
|
package/dist/funs/index.d.ts
CHANGED
|
@@ -9,7 +9,9 @@ export declare const toHash: (n: number, len?: number) => string;
|
|
|
9
9
|
export declare const fromHash: (n: string) => number;
|
|
10
10
|
export declare const css: () => CSS;
|
|
11
11
|
export declare const uuid: (len?: number) => string;
|
|
12
|
+
export declare const MD5: (str: string) => string;
|
|
12
13
|
export declare const numberInRange: (min: number, max: number) => number;
|
|
14
|
+
export declare const getCSSVariable: (el: HTMLElement, name: string) => string;
|
|
13
15
|
export declare const toLowerCase: {
|
|
14
16
|
(locales?: string | string[]): string;
|
|
15
17
|
(locales?: Intl.LocalesArgument): string;
|
|
@@ -38,9 +40,16 @@ export declare const withTime: (fun: (...args: any[]) => any) => {
|
|
|
38
40
|
executionTime: number;
|
|
39
41
|
};
|
|
40
42
|
export declare const time: (stamp?: number, format?: string) => string;
|
|
43
|
+
export declare const timeSince: (stamp: number) => string;
|
|
41
44
|
export declare const arrayRand: (arr: any[]) => any;
|
|
42
45
|
export declare const formatNumber: ({ number, locale, style, decimal, currency }: FormatNumberParams) => string;
|
|
43
46
|
export declare const formatSize: (bytes: number | string) => string;
|
|
44
47
|
export declare const copyToClipboard: (text: string) => Promise<unknown>;
|
|
48
|
+
/**
|
|
49
|
+
* Borrowed from https://github.com/bubkoo/natsort
|
|
50
|
+
* So we don't have to install a package for this
|
|
51
|
+
*/
|
|
45
52
|
export declare const natsort: (options?: sortOptions) => (a: string | number, b: string | number) => number;
|
|
46
53
|
export declare const bindKey: (key: KeyCode, fun: () => void, element?: HTMLElement) => void;
|
|
54
|
+
export declare const camelCase: (str: string) => string;
|
|
55
|
+
export declare const pluralize: (word: string, count: number) => string;
|