@zuzjs/ui 0.5.4 → 0.5.5
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 +26 -0
- package/dist/comps/accordion.d.ts +12 -0
- package/dist/comps/accordion.js +13 -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 +2 -2
- package/dist/comps/box.js +10 -3
- package/dist/comps/button.d.ts +3 -5
- package/dist/comps/button.js +12 -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 +35 -5
- package/dist/comps/form.js +67 -21
- package/dist/comps/heading.js +13 -0
- package/dist/comps/icon.d.ts +4 -5
- package/dist/comps/icon.js +15 -3
- package/dist/comps/image.d.ts +1 -1
- package/dist/comps/input.d.ts +2 -8
- package/dist/comps/input.js +5 -5
- package/dist/comps/password.d.ts +3 -0
- package/dist/comps/password.js +30 -0
- package/dist/comps/select.d.ts +2 -1
- package/dist/comps/select.js +28 -3
- package/dist/comps/sheet.js +3 -0
- package/dist/comps/spinner.d.ts +1 -1
- package/dist/comps/spinner.js +1 -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 +64 -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.js +127 -17
- package/dist/funs/events.js +3 -0
- package/dist/funs/index.d.ts +4 -0
- package/dist/funs/index.js +28 -2
- package/dist/funs/stylesheet.js +15 -1
- 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 +3 -0
- package/dist/index.js +3 -0
- 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 +11 -2
- package/package.json +1 -1
package/dist/funs/css.js
CHANGED
|
@@ -40,11 +40,11 @@ class CSS {
|
|
|
40
40
|
xl: `Extra Large Devices (Large Desktops)`,
|
|
41
41
|
};
|
|
42
42
|
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)`,
|
|
43
|
+
ph: `(max-width: 599px)`, /* Extra Small Devices (Phones) */
|
|
44
|
+
sm: `(min-width: 600px) and (max-width: 767px)`, /* Small Devices (Tablets) */
|
|
45
|
+
md: `(min-width: 768px) and (max-width: 991px)`, /* Medium Devices (Small Laptops) */
|
|
46
|
+
lg: `(min-width: 992px) and (max-width: 1199px)`, /* Large Devices (Laptops and Desktops) */
|
|
47
|
+
xl: `(min-width: 1200px)`, /* Extra Large Devices (Large Desktops) */
|
|
48
48
|
};
|
|
49
49
|
this.cx = [];
|
|
50
50
|
this.cache = {};
|
|
@@ -61,9 +61,9 @@ class CSS {
|
|
|
61
61
|
`flex`, `opacity`, `z-index`, `zIndex`, `color`, `line-height`, `anim`, `scale`, `saturate`
|
|
62
62
|
];
|
|
63
63
|
this.keysWithoutCommaToSpace = [
|
|
64
|
-
`transform`, `translate`, `color`, `background`, `background-color`, `backgroundColor`,
|
|
64
|
+
`transform`, `translate`, `color`, `background`, `background-color`, `backgroundColor`, `backgroundImage`, `background-image`,
|
|
65
65
|
`border`, `border-bottom`, `border-top`, `border-left`, `border-right`,
|
|
66
|
-
`grid-template-rows`, `grid-template-columns`
|
|
66
|
+
`grid-template-rows`, `grid-template-columns`, `clip-path`, `clipPath`,
|
|
67
67
|
];
|
|
68
68
|
this.propCounter = {};
|
|
69
69
|
this.ids = [];
|
|
@@ -80,6 +80,7 @@ class CSS {
|
|
|
80
80
|
arr.push(cssDirect[k].replace(/\s+/g, ``));
|
|
81
81
|
return arr;
|
|
82
82
|
}, []);
|
|
83
|
+
// extendGlobals()
|
|
83
84
|
}
|
|
84
85
|
buildMediaQueries(queries) {
|
|
85
86
|
const self = this;
|
|
@@ -95,7 +96,9 @@ class CSS {
|
|
|
95
96
|
styleSheet(cache, pseudo = ``) {
|
|
96
97
|
const self = this;
|
|
97
98
|
const scss = [];
|
|
99
|
+
// console.log(cache)
|
|
98
100
|
const build = (key, value) => {
|
|
101
|
+
// console.log(`build`, key, value)
|
|
99
102
|
const __build = (_key, _value) => {
|
|
100
103
|
let _css = `${self.pseudoList.includes(`@${_key}`) ? `&:` : `.`}${_key}{`;
|
|
101
104
|
if (`object` == typeof _value) {
|
|
@@ -117,6 +120,7 @@ class CSS {
|
|
|
117
120
|
let css = ``;
|
|
118
121
|
if (`object` == typeof value && Object.keys(value)[0] in this.mediaQueries) {
|
|
119
122
|
const mq = Object.keys(value)[0];
|
|
123
|
+
// css += `@media screen and ${this.mediaQueries[mq]}{`
|
|
120
124
|
let __css = `.${key}{`;
|
|
121
125
|
const _value = value[mq];
|
|
122
126
|
for (const prop in _value) {
|
|
@@ -131,6 +135,8 @@ class CSS {
|
|
|
131
135
|
this._mediaQueries[mq] = this._mediaQueries[mq] || [];
|
|
132
136
|
this._mediaQueries[mq].push(__css);
|
|
133
137
|
}
|
|
138
|
+
// else if ( key in self.mediaQueries ){
|
|
139
|
+
// }
|
|
134
140
|
else {
|
|
135
141
|
css += __build(key, value);
|
|
136
142
|
}
|
|
@@ -184,9 +190,11 @@ class CSS {
|
|
|
184
190
|
for (const prop in value) {
|
|
185
191
|
if (`string` === typeof value[prop]) {
|
|
186
192
|
_extend.push(`.${prop}`);
|
|
193
|
+
// _extend.push(self.buildCache[prop])
|
|
187
194
|
}
|
|
188
195
|
}
|
|
189
196
|
if (_extend.length > 0)
|
|
197
|
+
// css += _extend.join(``)
|
|
190
198
|
css += `@extend ${_extend.join(`, `)};`;
|
|
191
199
|
for (const prop in value) {
|
|
192
200
|
if (`object` === typeof value[prop]) {
|
|
@@ -197,6 +205,9 @@ class CSS {
|
|
|
197
205
|
css += `}`;
|
|
198
206
|
return css;
|
|
199
207
|
};
|
|
208
|
+
/**
|
|
209
|
+
* Build Master Keys
|
|
210
|
+
*/
|
|
200
211
|
for (const key in cache) {
|
|
201
212
|
if (key == FIELNAME_KEY) {
|
|
202
213
|
scss.push(`/**\n* @file ${cache[key]}\n*/`);
|
|
@@ -204,17 +215,24 @@ class CSS {
|
|
|
204
215
|
}
|
|
205
216
|
extractMasterKeys(key, cache[key]);
|
|
206
217
|
}
|
|
218
|
+
/**
|
|
219
|
+
* Extract LINE_KEY
|
|
220
|
+
*/
|
|
207
221
|
for (const key in cache) {
|
|
208
222
|
if (key.startsWith(LINE_KEY)) {
|
|
209
223
|
scss.push(cache[key]);
|
|
210
224
|
delete cache[key];
|
|
211
225
|
}
|
|
212
226
|
}
|
|
227
|
+
/**
|
|
228
|
+
* Build Extends
|
|
229
|
+
*/
|
|
213
230
|
for (const key in cache) {
|
|
214
231
|
if (`object` == typeof cache[key]) {
|
|
215
232
|
scss.push(build(key, cache[key]));
|
|
216
233
|
}
|
|
217
234
|
}
|
|
235
|
+
// scss.push(self.classLine)
|
|
218
236
|
return scss.join(`\n`);
|
|
219
237
|
}
|
|
220
238
|
cleanKey(key) {
|
|
@@ -237,6 +255,7 @@ class CSS {
|
|
|
237
255
|
const __k = self.cleanKey(_k);
|
|
238
256
|
if (`object` == typeof cache[_k]) {
|
|
239
257
|
const _d = oid(_k, cache[_k]);
|
|
258
|
+
// console.log(_d)
|
|
240
259
|
let _indices = 0;
|
|
241
260
|
for (let i = 0; i < _d.length; i++) {
|
|
242
261
|
_indices += self.chars.indexOf(_d.charAt(i));
|
|
@@ -260,6 +279,7 @@ class CSS {
|
|
|
260
279
|
return _;
|
|
261
280
|
}
|
|
262
281
|
makeUnit(k, v) {
|
|
282
|
+
// console.log(`unit`, k, v)
|
|
263
283
|
if (k == `rotate`) {
|
|
264
284
|
return `deg`;
|
|
265
285
|
}
|
|
@@ -287,6 +307,7 @@ class CSS {
|
|
|
287
307
|
return v.trim();
|
|
288
308
|
}
|
|
289
309
|
makeValue(k, v) {
|
|
310
|
+
// const hasGradient = v.includes(`gradient`)
|
|
290
311
|
const self = this;
|
|
291
312
|
if (k in this.PROPS) {
|
|
292
313
|
const key = this.PROPS[k];
|
|
@@ -295,11 +316,17 @@ class CSS {
|
|
|
295
316
|
let hasImportant = v.charAt(v.length - 1) == `!`;
|
|
296
317
|
v = hasImportant ? v.slice(0, -1) : v;
|
|
297
318
|
let important = hasImportant ? ` !important` : ``;
|
|
298
|
-
|
|
319
|
+
let isGradient = v.startsWith(`gradient`) || v.startsWith(`linear-gradient`) || v.startsWith(`radial-gradient`);
|
|
320
|
+
/**
|
|
321
|
+
* Gradients
|
|
322
|
+
*/
|
|
323
|
+
if (isGradient) {
|
|
299
324
|
if (v.startsWith(`gradient`)) {
|
|
300
325
|
v = `linear-${v}`;
|
|
301
326
|
}
|
|
327
|
+
//linear-gradient-to-bottom-blue-green
|
|
302
328
|
const [_gtype, _xyz, _gto, _gdeg, ..._colors] = v.split(`-`);
|
|
329
|
+
// const _gdegree = _gdeg.isNumber() ? `${_gdeg}deg` : `to ${_gto}`
|
|
303
330
|
const _gdegree = /^[+-]?\d+(\.\d+)?$/.test(_gdeg) ? `${_gdeg}deg` : `to ${_gdeg}`;
|
|
304
331
|
const _gcolors = _colors.reduce((arr, val) => {
|
|
305
332
|
arr.push(self.makeColor(val));
|
|
@@ -310,24 +337,33 @@ class CSS {
|
|
|
310
337
|
value = `linear-gradient(${_gdegree}, ${_gcolors})`;
|
|
311
338
|
break;
|
|
312
339
|
case `radial`:
|
|
340
|
+
// value = `radial-gradient(${_gparts[1]})`
|
|
313
341
|
break;
|
|
314
342
|
default:
|
|
315
343
|
value = v;
|
|
316
344
|
break;
|
|
317
345
|
}
|
|
318
346
|
}
|
|
347
|
+
/**
|
|
348
|
+
* Variable
|
|
349
|
+
*/
|
|
319
350
|
else if (v.charAt(0) == `$`) {
|
|
320
351
|
value = `var(--${v.replace(`$`, ``)})`;
|
|
321
352
|
}
|
|
322
353
|
else if (v.trim() == `transparent`) {
|
|
323
354
|
value = `rgba(0,0,0,0)`;
|
|
324
355
|
}
|
|
356
|
+
/**
|
|
357
|
+
* border
|
|
358
|
+
*/
|
|
325
359
|
else if ([`border`, `borderBottom`, `borderTop`, `borderLeft`, `borderRight`].includes(k)) {
|
|
326
360
|
const _parts = [];
|
|
361
|
+
// console.log(`--border`, key, v)
|
|
327
362
|
if (v.match(this.rgbaRegex)) {
|
|
328
363
|
_parts.push(v.match(this.rgbaRegex)[0].replace(`[`, `(`).replace(`]`, `)`));
|
|
329
364
|
v = v.replace(this.rgbaRegex, ``).trim().replace(`,,`, `,`);
|
|
330
365
|
}
|
|
366
|
+
// console.log(`-border`, key, v, _parts)
|
|
331
367
|
v.split(`,`).map((p) => {
|
|
332
368
|
if (p.includes(`rgb`) || p.includes(`rgba`) || isColor(`#${p}`) || p.startsWith(`$`)) {
|
|
333
369
|
if (p.includes(`rgb`) || p.includes(`rgba`)) {
|
|
@@ -349,8 +385,13 @@ class CSS {
|
|
|
349
385
|
}
|
|
350
386
|
});
|
|
351
387
|
value = _parts.join(` `);
|
|
388
|
+
// console.log(`border`, value)
|
|
352
389
|
}
|
|
390
|
+
/**
|
|
391
|
+
* Color
|
|
392
|
+
*/
|
|
353
393
|
else if ([`color`, `bg`, `background`, `background-color`, `backgroundColor`].includes(key)) {
|
|
394
|
+
// else if ( [`color`].includes( key ) ){
|
|
354
395
|
if (v.charAt(0) == `#`) {
|
|
355
396
|
v = v.substring(1);
|
|
356
397
|
}
|
|
@@ -364,9 +405,15 @@ class CSS {
|
|
|
364
405
|
else
|
|
365
406
|
value = v.trim();
|
|
366
407
|
}
|
|
408
|
+
/**
|
|
409
|
+
* FontWeight
|
|
410
|
+
*/
|
|
367
411
|
else if (key == `font-weight`) {
|
|
368
412
|
value = v;
|
|
369
413
|
}
|
|
414
|
+
/**
|
|
415
|
+
* value with brackets like calc(), var() should be passed as calc[value]
|
|
416
|
+
*/
|
|
370
417
|
else if (v.match(/\[(.*?)\]/g)) {
|
|
371
418
|
try {
|
|
372
419
|
const vs = v.match(/\[(.*?)\]/g)[0].slice(1, -1);
|
|
@@ -376,16 +423,22 @@ class CSS {
|
|
|
376
423
|
catch (e) { }
|
|
377
424
|
}
|
|
378
425
|
else {
|
|
426
|
+
// ${v.charAt(0) == `$` ? `var(--${v.substring(1)})` : v}
|
|
427
|
+
// if ( key.includes(`padding`) ) console.log(`->padding`, v)
|
|
379
428
|
if (v.includes(`,`)) {
|
|
429
|
+
// console.log(`vwithcomma`, v)
|
|
380
430
|
let __v = [];
|
|
381
431
|
v.split(`,`).map((_) => {
|
|
382
432
|
if (_.charAt(0) == `#`) {
|
|
383
433
|
_ = _.substring(1);
|
|
384
434
|
}
|
|
435
|
+
//Variable
|
|
385
436
|
if (_.startsWith(`$`)) {
|
|
386
437
|
__v.push(`var(--${_.substring(1)})`);
|
|
387
438
|
}
|
|
439
|
+
//Color
|
|
388
440
|
else if (cssPropsWithColor.includes(_) && isColor(`#${_}`)) {
|
|
441
|
+
// else if ( isColor(_) ){
|
|
389
442
|
if (_.includes(`rgb`) || _.includes(`rgba`)) {
|
|
390
443
|
__v.push(_.replace(`[`, `(`).replace(`]`, `)`));
|
|
391
444
|
}
|
|
@@ -394,19 +447,28 @@ class CSS {
|
|
|
394
447
|
}
|
|
395
448
|
}
|
|
396
449
|
else {
|
|
450
|
+
// console.log(`comma`, key, v, this.makeUnit(key, v))
|
|
397
451
|
__v.push(`${_}${this.makeUnit(key, _)}`);
|
|
398
452
|
}
|
|
399
453
|
});
|
|
400
454
|
value = __v.join(` `);
|
|
455
|
+
// console.log(key, value)
|
|
456
|
+
// if( k == `shadow` || k == `box-shadow` ) console.log(value)
|
|
401
457
|
}
|
|
402
458
|
else
|
|
403
459
|
value = `${v}${this.makeUnit(key, v)}`;
|
|
404
460
|
}
|
|
405
461
|
if (!value)
|
|
406
462
|
return ``;
|
|
463
|
+
// if ( key == `clip` || key == `clip-path` ) console.log(`makevalue`, key, value)
|
|
464
|
+
// if ( key.includes(`border`) ) console.log(`--border`, `${key}: ${value}${important};`)
|
|
407
465
|
value = value.includes(`,`) && !this.keysWithoutCommaToSpace.includes(key) ? value.replace(`,`, ` `) : value;
|
|
466
|
+
// if ( key.includes(`padding`) ) console.log(`->padding`, `${key}: ${value}${important};`)
|
|
408
467
|
if (key == `content`)
|
|
409
468
|
value = `"${value}"`;
|
|
469
|
+
// if ( key == `extend` ){
|
|
470
|
+
// value = value.split(`,`).reduce((acc: string[], v: string) => acc.push(`${v.startsWith(`.`) ? `` : `.`}${v}`) && acc, []).join(`,`)
|
|
471
|
+
// }
|
|
410
472
|
return `${key}: ${value}${important};`;
|
|
411
473
|
}
|
|
412
474
|
return ``;
|
|
@@ -423,7 +485,9 @@ class CSS {
|
|
|
423
485
|
const md = md5(_out);
|
|
424
486
|
let _ = [];
|
|
425
487
|
const _mi = (_k, _v) => {
|
|
488
|
+
// console.log(_k, _v, Math.abs(self.DIRECT_KEYS.indexOf(_k)) + Math.abs(self.PROPS_VALUES.indexOf(_k)))
|
|
426
489
|
let i = Math.abs(self.DIRECT_KEYS.indexOf(_k)) + Math.abs(self.PROPS_VALUES.indexOf(_k));
|
|
490
|
+
// _k in self.DIRECT ? self.DIRECT_KEYS.indexOf(_k) : _k in self.PROPS_VALUES ? self.PROPS_VALUES.indexOf(_k) : 0
|
|
427
491
|
_.push(i);
|
|
428
492
|
const nums = _v.match(/[0-9]/g);
|
|
429
493
|
if (nums) {
|
|
@@ -446,7 +510,9 @@ class CSS {
|
|
|
446
510
|
if (ov == ``) {
|
|
447
511
|
console.log(pc.yellow(`[${self._currentFile}]`), pc.cyan(k), pc.red(`value is empty.`));
|
|
448
512
|
return ``;
|
|
513
|
+
// throw new TypeError()
|
|
449
514
|
}
|
|
515
|
+
/**Prefix */
|
|
450
516
|
let _cp = ok.charAt(0);
|
|
451
517
|
if (self.PROPS[ok]?.indexOf("-") > -1) {
|
|
452
518
|
_cp = "";
|
|
@@ -499,15 +565,23 @@ class CSS {
|
|
|
499
565
|
processWord();
|
|
500
566
|
}
|
|
501
567
|
else {
|
|
568
|
+
//SKIPABLE
|
|
569
|
+
// if([`(`].includes(char) && level == 0 ){
|
|
570
|
+
// //DON'T ADD
|
|
571
|
+
// }
|
|
502
572
|
if ([`&`].includes(char)) {
|
|
503
573
|
isLevel = true;
|
|
504
574
|
}
|
|
575
|
+
//Level Start
|
|
505
576
|
else if ([`(`].includes(char) && isLevel) {
|
|
506
577
|
processWord();
|
|
507
578
|
}
|
|
579
|
+
//Level End
|
|
508
580
|
else if ([`)`].includes(char)) {
|
|
509
581
|
processWord();
|
|
582
|
+
// console.log(`before->`, levels)
|
|
510
583
|
levels.splice(-1, 1);
|
|
584
|
+
// console.log(`after->`, levels)
|
|
511
585
|
isLevel = false;
|
|
512
586
|
}
|
|
513
587
|
else {
|
|
@@ -546,8 +620,10 @@ class CSS {
|
|
|
546
620
|
if (key in self.PROPS) {
|
|
547
621
|
const _out = self.makeValue(key, _val);
|
|
548
622
|
const _id = self.makeID(key, _val + pseudo, _out);
|
|
623
|
+
// console.log(`props`, _k, _id)
|
|
549
624
|
if (pseudo == ``)
|
|
550
625
|
self.cx.push(_id);
|
|
626
|
+
// console.log(`_build`, key, _val, _id, _out)
|
|
551
627
|
if (_mediaQuery) {
|
|
552
628
|
self.mediaQueries[_mediaQuery].push({ [_id]: _out });
|
|
553
629
|
return {};
|
|
@@ -559,6 +635,9 @@ class CSS {
|
|
|
559
635
|
const important = hasImportant ? ` !important` : ``;
|
|
560
636
|
let val = hasImportant ? _val.slice(0, -1) : _val;
|
|
561
637
|
var _out = ``;
|
|
638
|
+
// if ( key == `ratio` ){
|
|
639
|
+
// console.log(`RatioFound`, key, val)
|
|
640
|
+
// }
|
|
562
641
|
if (key == `extend`) {
|
|
563
642
|
val = val.split(`,`).reduce((acc, v) => {
|
|
564
643
|
acc.push(`${v.startsWith(`.`) ? `` : `.`}${v.trim()}`);
|
|
@@ -578,6 +657,8 @@ class CSS {
|
|
|
578
657
|
const [_duration, ..._rest] = val.split(`,`);
|
|
579
658
|
let rest = _rest.join(",").trim();
|
|
580
659
|
duration = _duration;
|
|
660
|
+
// if ( rest.includes(`],`) ){
|
|
661
|
+
// }
|
|
581
662
|
if (rest.includes(`[`) && rest.includes(`]`)) {
|
|
582
663
|
for (const curv in cssAnimationCurves) {
|
|
583
664
|
if (rest.startsWith(curv)) {
|
|
@@ -594,11 +675,14 @@ class CSS {
|
|
|
594
675
|
_out = _out.replace(`;`, `${important};`);
|
|
595
676
|
}
|
|
596
677
|
else {
|
|
678
|
+
// const __value = `${val}${key == `extend` ? `` : self.makeUnit(key, val)}`
|
|
597
679
|
const __value = `${val}${self.IGNORE.includes(key) ? `` : self.makeUnit(key, val)}`;
|
|
598
680
|
_out = self.DIRECT[key].includes(`__VALUE__`) ?
|
|
599
681
|
self.DIRECT[key].replace(/__VALUE__/g, __value).replace(`;`, `${important};`) : self.DIRECT[key];
|
|
600
682
|
}
|
|
683
|
+
// console.log(`_build`, key, _val)
|
|
601
684
|
const _id = self.makeID(key, key + pseudo, _out);
|
|
685
|
+
// console.log(`_buildid`, key, _id)
|
|
602
686
|
if (pseudo == ``)
|
|
603
687
|
self.cx.push(_id);
|
|
604
688
|
if (_mediaQuery) {
|
|
@@ -611,6 +695,7 @@ class CSS {
|
|
|
611
695
|
else if (_k in self.DIRECT) {
|
|
612
696
|
const _out = self.DIRECT[_k];
|
|
613
697
|
const _id = self.makeID(_k, _k + pseudo, _out);
|
|
698
|
+
// console.log(_k, _id)
|
|
614
699
|
if (pseudo == ``)
|
|
615
700
|
self.cx.push(_id);
|
|
616
701
|
if (_mediaQuery) {
|
|
@@ -621,6 +706,7 @@ class CSS {
|
|
|
621
706
|
}
|
|
622
707
|
else if (_k.trim().match(/^[a-zA-Z0-9\-]+$/g)) {
|
|
623
708
|
self.cx.push(_k.trim());
|
|
709
|
+
// self.cx.push(`--${_k.trim()}`)
|
|
624
710
|
}
|
|
625
711
|
return {};
|
|
626
712
|
};
|
|
@@ -637,6 +723,8 @@ class CSS {
|
|
|
637
723
|
return out;
|
|
638
724
|
};
|
|
639
725
|
const _built = build(self.lexer(line));
|
|
726
|
+
// console.log(line, _built)
|
|
727
|
+
// console.log(line, self.lexer(line))
|
|
640
728
|
self.cache = { ...self.cache, ..._built };
|
|
641
729
|
}
|
|
642
730
|
}
|
|
@@ -661,13 +749,31 @@ class CSS {
|
|
|
661
749
|
self.processLine(line);
|
|
662
750
|
});
|
|
663
751
|
});
|
|
752
|
+
// console.log(self.deepClean(self.cache))
|
|
753
|
+
// const _ = cli ? {
|
|
754
|
+
// cx: [],
|
|
755
|
+
// sheet: self.styleSheet(self.deepClean(self.cache))
|
|
756
|
+
// } : {
|
|
757
|
+
// cx: self.cx,
|
|
758
|
+
// sheet: ``
|
|
759
|
+
// }
|
|
664
760
|
const _cleaned = self.deepClean(self.cache);
|
|
665
761
|
const _stylesheet = self.styleSheet(_cleaned);
|
|
762
|
+
// const _mediaQueries : dynamicObject = {}
|
|
763
|
+
// if ( !cli ){
|
|
764
|
+
// console.log(css, self.cx, self.styleSheet(_cleaned))
|
|
765
|
+
// }
|
|
766
|
+
// console.log(`[${cli}]`, self.cx)
|
|
767
|
+
// console.log(`[${cli}]`, self.cache)
|
|
768
|
+
// console.log(`[${cli}]`, _cleaned)
|
|
769
|
+
// console.log(_stylesheet)
|
|
770
|
+
// console.log(self._mediaQueries)
|
|
666
771
|
const _ = {
|
|
667
772
|
cx: self.cx,
|
|
668
773
|
sheet: _stylesheet,
|
|
669
774
|
mediaQuery: self._mediaQueries
|
|
670
775
|
};
|
|
776
|
+
// console.log(css, _)
|
|
671
777
|
return _;
|
|
672
778
|
}
|
|
673
779
|
}
|
|
@@ -696,6 +802,7 @@ export const buildWithStyles = (source) => {
|
|
|
696
802
|
if (_transform.length > 0) {
|
|
697
803
|
_.transform = _transform.join(` `);
|
|
698
804
|
}
|
|
805
|
+
// console.log(_, _transform)
|
|
699
806
|
}
|
|
700
807
|
return _;
|
|
701
808
|
};
|
|
@@ -704,19 +811,22 @@ export const getAnimationCurve = (curve) => {
|
|
|
704
811
|
return `linear`;
|
|
705
812
|
switch (curve.toUpperCase()) {
|
|
706
813
|
case TRANSITION_CURVES.Bounce:
|
|
707
|
-
return `
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
814
|
+
return `var(--bounce)`;
|
|
815
|
+
// return `linear( 0, 0.0039, 0.0157, 0.0352, 0.0625 9.09%,
|
|
816
|
+
// 0.1407, 0.25, 0.3908, 0.5625, 0.7654,
|
|
817
|
+
// 1, 0.8907, 0.8125 45.45%, 0.7852, 0.7657,
|
|
818
|
+
// 0.7539, 0.75, 0.7539, 0.7657, 0.7852,
|
|
819
|
+
// 0.8125 63.64%, 0.8905, 1 72.73%, 0.9727, 0.9532,
|
|
820
|
+
// 0.9414, 0.9375, 0.9414, 0.9531, 0.9726,
|
|
821
|
+
// 1, 0.9883, 0.9844, 0.9883, 1 )`
|
|
714
822
|
break;
|
|
715
823
|
case TRANSITION_CURVES.Spring:
|
|
716
|
-
return `cubic-bezier(0.2, -0.36, 0, 1.46)
|
|
824
|
+
// return `cubic-bezier(0.2, -0.36, 0, 1.46)`
|
|
825
|
+
return `var(--spring)`;
|
|
717
826
|
break;
|
|
718
827
|
case TRANSITION_CURVES.EaseInOut:
|
|
719
|
-
return `cubic-bezier(0.42, 0, 0.58, 1)
|
|
828
|
+
// return `cubic-bezier(0.42, 0, 0.58, 1)`
|
|
829
|
+
return `ease-in-out`;
|
|
720
830
|
break;
|
|
721
831
|
default:
|
|
722
832
|
return `linear`;
|
package/dist/funs/events.js
CHANGED
|
@@ -4,6 +4,7 @@ class Events {
|
|
|
4
4
|
this._events = [];
|
|
5
5
|
}
|
|
6
6
|
addEvent(event, fun, context) {
|
|
7
|
+
// console.log(`addEvent`, context)
|
|
7
8
|
const evt = this._events.find(x => x.event == event);
|
|
8
9
|
if (!evt) {
|
|
9
10
|
return this._events.push({ event: event, listeners: [fun], context });
|
|
@@ -27,8 +28,10 @@ class Events {
|
|
|
27
28
|
emit(event, ...args) {
|
|
28
29
|
const evt = this._events.find(x => x.event == event);
|
|
29
30
|
if (evt) {
|
|
31
|
+
// console.log(evt)
|
|
30
32
|
evt.listeners.forEach((f) => {
|
|
31
33
|
try {
|
|
34
|
+
// f(args)
|
|
32
35
|
f.apply(evt.context || self, args);
|
|
33
36
|
}
|
|
34
37
|
catch (e) {
|
package/dist/funs/index.d.ts
CHANGED
|
@@ -42,5 +42,9 @@ export declare const arrayRand: (arr: any[]) => any;
|
|
|
42
42
|
export declare const formatNumber: ({ number, locale, style, decimal, currency }: FormatNumberParams) => string;
|
|
43
43
|
export declare const formatSize: (bytes: number | string) => string;
|
|
44
44
|
export declare const copyToClipboard: (text: string) => Promise<unknown>;
|
|
45
|
+
/**
|
|
46
|
+
* Borrowed from https://github.com/bubkoo/natsort
|
|
47
|
+
* So we don't have to install a package for this
|
|
48
|
+
*/
|
|
45
49
|
export declare const natsort: (options?: sortOptions) => (a: string | number, b: string | number) => number;
|
|
46
50
|
export declare const bindKey: (key: KeyCode, fun: () => void, element?: HTMLElement) => void;
|
package/dist/funs/index.js
CHANGED
|
@@ -19,12 +19,17 @@ export const numberInRange = (min, max) => {
|
|
|
19
19
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
20
20
|
};
|
|
21
21
|
export const toLowerCase = String.prototype.toLocaleLowerCase || String.prototype.toLowerCase;
|
|
22
|
+
// Hex color regex (#RGB, #RRGGBB)
|
|
22
23
|
export const hexColorRegex = /^#([A-Fa-f0-9]{3}){1,2}$/;
|
|
24
|
+
// export const hexColorRegex3 = /^#([A-Fa-f0-9]{3}){1,2}$/;
|
|
25
|
+
// RGBA color regex (rgba(255, 255, 255, 1))
|
|
23
26
|
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*))?\)$/;
|
|
27
|
+
// HSL color regex (hsl(360, 100%, 100%))
|
|
24
28
|
export const hslColorRegex = /^hsl\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*\)$/;
|
|
25
29
|
export const isHexColor = (color) => hexColorRegex.test(color);
|
|
26
30
|
export const isRgbaColor = (color) => rgbaColorRegex.test(color);
|
|
27
31
|
export const isHslColor = (color) => hslColorRegex.test(color);
|
|
32
|
+
// Function to validate a color string
|
|
28
33
|
export const isColor = (color) => colorNames.includes(color) || isHexColor(color) || isRgbaColor(color) || isHslColor(color);
|
|
29
34
|
export const isUrl = (u) => {
|
|
30
35
|
let url;
|
|
@@ -41,11 +46,15 @@ export const isIPv4 = (ipaddress) => {
|
|
|
41
46
|
return /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(ipaddress);
|
|
42
47
|
};
|
|
43
48
|
export const isNumber = (v) => /\d+(\.\d+)?$/g.test(v);
|
|
49
|
+
// Convert hex to rgba
|
|
44
50
|
export const hexToRgba = (hex, alpha = 1) => {
|
|
51
|
+
// Remove the hash symbol if present
|
|
45
52
|
hex = hex.replace(/^#/, '');
|
|
53
|
+
// If shorthand hex (#RGB), expand it to full form (#RRGGBB)
|
|
46
54
|
if (hex.length === 3) {
|
|
47
55
|
hex = hex.split('').map(char => char + char).join('');
|
|
48
56
|
}
|
|
57
|
+
// Convert to integer values for RGB
|
|
49
58
|
const bigint = parseInt(hex, 16);
|
|
50
59
|
const r = (bigint >> 16) & 255;
|
|
51
60
|
const g = (bigint >> 8) & 255;
|
|
@@ -67,6 +76,10 @@ export const cleanProps = (props, withProps = []) => {
|
|
|
67
76
|
_extras.map(x => x in _props && delete _props[x]);
|
|
68
77
|
return _props;
|
|
69
78
|
};
|
|
79
|
+
// export const withZuz = (cx : string | string[]) : string => {
|
|
80
|
+
// console.log(cx)
|
|
81
|
+
// return ``
|
|
82
|
+
// }
|
|
70
83
|
export const withZuz = (cx) => css().Build([[`string` == typeof cx ? cx : cx.join(` `)]]).cx.join(` `);
|
|
71
84
|
export const setDeep = (object, path, value, seperator = `.`) => {
|
|
72
85
|
const _path = path.split(seperator);
|
|
@@ -77,6 +90,7 @@ export const setDeep = (object, path, value, seperator = `.`) => {
|
|
|
77
90
|
if (!object.hasOwnProperty(base)) {
|
|
78
91
|
object[base] = {};
|
|
79
92
|
}
|
|
93
|
+
// Determine if there is still layers to traverse
|
|
80
94
|
value = _path.length <= 1 ? value : setDeep(object[base], _path.slice(1).join(seperator), value, seperator);
|
|
81
95
|
return {
|
|
82
96
|
...object,
|
|
@@ -213,7 +227,7 @@ export const copyToClipboard = (text) => {
|
|
|
213
227
|
return new Promise((resolve, reject) => {
|
|
214
228
|
const textarea = document.createElement("textarea");
|
|
215
229
|
textarea.value = text;
|
|
216
|
-
textarea.style.position = "fixed";
|
|
230
|
+
textarea.style.position = "fixed"; // Prevent scrolling to bottom of page in MS Edge.
|
|
217
231
|
document.body.appendChild(textarea);
|
|
218
232
|
textarea.focus();
|
|
219
233
|
textarea.select();
|
|
@@ -222,12 +236,17 @@ export const copyToClipboard = (text) => {
|
|
|
222
236
|
resolve(`Copied to clipboard`);
|
|
223
237
|
}
|
|
224
238
|
catch (err) {
|
|
239
|
+
// console.error("Fallback: Oops, unable to copy", err);
|
|
225
240
|
reject(err);
|
|
226
241
|
}
|
|
227
242
|
document.body.removeChild(textarea);
|
|
228
243
|
});
|
|
229
244
|
}
|
|
230
245
|
};
|
|
246
|
+
/**
|
|
247
|
+
* Borrowed from https://github.com/bubkoo/natsort
|
|
248
|
+
* So we don't have to install a package for this
|
|
249
|
+
*/
|
|
231
250
|
export const natsort = (options = {
|
|
232
251
|
direction: SORT.Asc,
|
|
233
252
|
caseSensitive: false,
|
|
@@ -235,10 +254,14 @@ export const natsort = (options = {
|
|
|
235
254
|
const ore = /^0/;
|
|
236
255
|
const sre = /\s+/g;
|
|
237
256
|
const tre = /^\s+|\s+$/g;
|
|
257
|
+
// unicode
|
|
238
258
|
const ure = /[^\x00-\x80]/;
|
|
259
|
+
// hex
|
|
239
260
|
const hre = /^0x[0-9a-f]+$/i;
|
|
261
|
+
// numeric
|
|
240
262
|
const nre = /(0x[\da-fA-F]+|(^[\+\-]?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?(?=\D|\s|$))|\d+)/g;
|
|
241
|
-
|
|
263
|
+
// datetime
|
|
264
|
+
const dre = /(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/; // tslint:disable-line
|
|
242
265
|
const GREATER = options.direction == SORT.Desc ? -1 : 1;
|
|
243
266
|
const SMALLER = -GREATER;
|
|
244
267
|
const _normalize = !options.caseSensitive
|
|
@@ -270,12 +293,14 @@ export const natsort = (options = {
|
|
|
270
293
|
}
|
|
271
294
|
const aArr = _tokenize(aa);
|
|
272
295
|
const bArr = _tokenize(bb);
|
|
296
|
+
// hex or date detection
|
|
273
297
|
const aHex = aa.match(hre);
|
|
274
298
|
const bHex = bb.match(hre);
|
|
275
299
|
const av = (aHex && bHex) ? parseInt(aHex[0], 16) : (aArr.length !== 1 && Date.parse(aa));
|
|
276
300
|
const bv = (aHex && bHex)
|
|
277
301
|
? parseInt(bHex[0], 16)
|
|
278
302
|
: av && bb.match(dre) && Date.parse(bb) || null;
|
|
303
|
+
// try and sort Hex codes or Dates
|
|
279
304
|
if (bv) {
|
|
280
305
|
if (av === bv) {
|
|
281
306
|
return 0;
|
|
@@ -289,6 +314,7 @@ export const natsort = (options = {
|
|
|
289
314
|
}
|
|
290
315
|
const al = aArr.length;
|
|
291
316
|
const bl = bArr.length;
|
|
317
|
+
// handle numeric strings and default strings
|
|
292
318
|
for (let i = 0, l = Math.max(al, bl); i < l; i += 1) {
|
|
293
319
|
const af = _parse(aArr[i] || '', al);
|
|
294
320
|
const bf = _parse(bArr[i] || '', bl);
|