kitzo 2.0.25 → 2.0.27
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 +11 -1
- package/dist/kitzo.esm.js +39 -13
- package/dist/kitzo.umd.js +38 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@ npm i kitzo
|
|
|
25
25
|
or
|
|
26
26
|
|
|
27
27
|
```javascript
|
|
28
|
-
<script src="https://cdn.jsdelivr.net/npm/kitzo@2.0.
|
|
28
|
+
<script src="https://cdn.jsdelivr.net/npm/kitzo@2.0.27/dist/kitzo.umd.min.js"></script>
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
> Attach this script tag in the html head tag and you are good to go.
|
|
@@ -41,6 +41,7 @@ or
|
|
|
41
41
|
| [`kitzo.ripple()`](#ripple-api) |
|
|
42
42
|
| [`kitzo.debounce()`](#debounce-api) |
|
|
43
43
|
| [`kitzo.clippath()`](#clippath-api) |
|
|
44
|
+
| [`kitzo.getType()`](#typecheck-api) |
|
|
44
45
|
|
|
45
46
|
#### Vanilla APIs
|
|
46
47
|
|
|
@@ -53,6 +54,7 @@ kitzo.tooltip();
|
|
|
53
54
|
kitzo.ripple();
|
|
54
55
|
kitzo.debounce();
|
|
55
56
|
kitzo.clippath();
|
|
57
|
+
kitzo.getType();
|
|
56
58
|
```
|
|
57
59
|
|
|
58
60
|
> Use a modern build tool. **vite** - recommended
|
|
@@ -124,6 +126,14 @@ kitzo.clippath(selectors | element | NodeList, {
|
|
|
124
126
|
style: object,
|
|
125
127
|
});
|
|
126
128
|
```
|
|
129
|
+
##### TypeCheck API:
|
|
130
|
+
|
|
131
|
+
```javascript
|
|
132
|
+
kitzo.getType(type);
|
|
133
|
+
|
|
134
|
+
const data = [];
|
|
135
|
+
console.log(kitzo.getType(data)) // 'array'
|
|
136
|
+
```
|
|
127
137
|
|
|
128
138
|
---
|
|
129
139
|
|
package/dist/kitzo.esm.js
CHANGED
|
@@ -494,23 +494,32 @@ function clippath(element, config = {}) {
|
|
|
494
494
|
const { textOption, clippathSize, smooth, style } = clippathConfigMap.get(btn);
|
|
495
495
|
|
|
496
496
|
const { top, left, width, height } = btn.getBoundingClientRect();
|
|
497
|
+
|
|
497
498
|
const cloned = btn.cloneNode(true);
|
|
498
499
|
cloned.className = cloned.className + ` ${clippathConfigMap.get(btn).class}`;
|
|
499
500
|
cloned.removeAttribute('data-kitzo-clippath');
|
|
500
501
|
cloned.setAttribute('data-temp-clippath-el', true);
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
502
|
+
|
|
503
|
+
setTimeout(() => {
|
|
504
|
+
const fontFamily = window.getComputedStyle(btn).fontFamily;
|
|
505
|
+
Object.assign(cloned.style, {
|
|
506
|
+
backgroundColor: '#01c2b8',
|
|
507
|
+
color: 'white',
|
|
508
|
+
fontFamily,
|
|
509
|
+
margin: 0,
|
|
510
|
+
width: '100%',
|
|
511
|
+
...style,
|
|
512
|
+
});
|
|
513
|
+
}, 0);
|
|
508
514
|
|
|
509
515
|
if (textOption && textOption instanceof Object) {
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
516
|
+
requestAnimationFrame(() => {
|
|
517
|
+
const target = typeof textOption.selector === 'string' ? clippathDiv.querySelector(textOption.selector.trim() ? textOption.selector.trim() : cloned.tagName) : cloned;
|
|
518
|
+
|
|
519
|
+
if (target && (typeof textOption.value === 'string' || typeof textOption.value === 'number')) {
|
|
520
|
+
target.textContent = textOption.value;
|
|
521
|
+
}
|
|
522
|
+
});
|
|
514
523
|
}
|
|
515
524
|
|
|
516
525
|
clippathDiv.style.width = `${width}px`;
|
|
@@ -524,6 +533,7 @@ function clippath(element, config = {}) {
|
|
|
524
533
|
});
|
|
525
534
|
}
|
|
526
535
|
});
|
|
536
|
+
|
|
527
537
|
document.addEventListener('mouseout', (e) => {
|
|
528
538
|
const btn = e.target.closest('[data-kitzo-clippath]');
|
|
529
539
|
if (btn) {
|
|
@@ -558,6 +568,22 @@ function clippath(element, config = {}) {
|
|
|
558
568
|
}
|
|
559
569
|
}
|
|
560
570
|
|
|
561
|
-
|
|
571
|
+
function getType(value) {
|
|
572
|
+
if (value === null) return 'null';
|
|
573
|
+
|
|
574
|
+
if (Array.isArray(value)) return 'array';
|
|
575
|
+
|
|
576
|
+
if (value instanceof Date) return 'date';
|
|
577
|
+
|
|
578
|
+
if (value instanceof RegExp) return 'regexp';
|
|
579
|
+
|
|
580
|
+
if (typeof value === 'object') return 'object';
|
|
581
|
+
|
|
582
|
+
return typeof value;
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
// button effects
|
|
586
|
+
|
|
587
|
+
const kitzo = { copy, debounce, ripple, tooltip, clippath, getType };
|
|
562
588
|
|
|
563
|
-
export { clippath, copy, debounce, kitzo as default, ripple, tooltip };
|
|
589
|
+
export { clippath, copy, debounce, kitzo as default, getType, ripple, tooltip };
|
package/dist/kitzo.umd.js
CHANGED
|
@@ -500,23 +500,32 @@
|
|
|
500
500
|
const { textOption, clippathSize, smooth, style } = clippathConfigMap.get(btn);
|
|
501
501
|
|
|
502
502
|
const { top, left, width, height } = btn.getBoundingClientRect();
|
|
503
|
+
|
|
503
504
|
const cloned = btn.cloneNode(true);
|
|
504
505
|
cloned.className = cloned.className + ` ${clippathConfigMap.get(btn).class}`;
|
|
505
506
|
cloned.removeAttribute('data-kitzo-clippath');
|
|
506
507
|
cloned.setAttribute('data-temp-clippath-el', true);
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
508
|
+
|
|
509
|
+
setTimeout(() => {
|
|
510
|
+
const fontFamily = window.getComputedStyle(btn).fontFamily;
|
|
511
|
+
Object.assign(cloned.style, {
|
|
512
|
+
backgroundColor: '#01c2b8',
|
|
513
|
+
color: 'white',
|
|
514
|
+
fontFamily,
|
|
515
|
+
margin: 0,
|
|
516
|
+
width: '100%',
|
|
517
|
+
...style,
|
|
518
|
+
});
|
|
519
|
+
}, 0);
|
|
514
520
|
|
|
515
521
|
if (textOption && textOption instanceof Object) {
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
522
|
+
requestAnimationFrame(() => {
|
|
523
|
+
const target = typeof textOption.selector === 'string' ? clippathDiv.querySelector(textOption.selector.trim() ? textOption.selector.trim() : cloned.tagName) : cloned;
|
|
524
|
+
|
|
525
|
+
if (target && (typeof textOption.value === 'string' || typeof textOption.value === 'number')) {
|
|
526
|
+
target.textContent = textOption.value;
|
|
527
|
+
}
|
|
528
|
+
});
|
|
520
529
|
}
|
|
521
530
|
|
|
522
531
|
clippathDiv.style.width = `${width}px`;
|
|
@@ -530,6 +539,7 @@
|
|
|
530
539
|
});
|
|
531
540
|
}
|
|
532
541
|
});
|
|
542
|
+
|
|
533
543
|
document.addEventListener('mouseout', (e) => {
|
|
534
544
|
const btn = e.target.closest('[data-kitzo-clippath]');
|
|
535
545
|
if (btn) {
|
|
@@ -564,7 +574,23 @@
|
|
|
564
574
|
}
|
|
565
575
|
}
|
|
566
576
|
|
|
567
|
-
|
|
577
|
+
function getType(value) {
|
|
578
|
+
if (value === null) return 'null';
|
|
579
|
+
|
|
580
|
+
if (Array.isArray(value)) return 'array';
|
|
581
|
+
|
|
582
|
+
if (value instanceof Date) return 'date';
|
|
583
|
+
|
|
584
|
+
if (value instanceof RegExp) return 'regexp';
|
|
585
|
+
|
|
586
|
+
if (typeof value === 'object') return 'object';
|
|
587
|
+
|
|
588
|
+
return typeof value;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
// button effects
|
|
592
|
+
|
|
593
|
+
const kitzo = { copy, debounce, ripple, tooltip, clippath, getType };
|
|
568
594
|
|
|
569
595
|
return kitzo;
|
|
570
596
|
|