kitzo 2.0.24 → 2.0.26

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 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.24/dist/kitzo.umd.min.js"></script>
28
+ <script src="https://cdn.jsdelivr.net/npm/kitzo@2.0.26/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.
package/dist/kitzo.esm.js CHANGED
@@ -455,7 +455,7 @@ function clippath(element, config = {}) {
455
455
  class: '',
456
456
  style: {},
457
457
  },
458
- config
458
+ config,
459
459
  );
460
460
 
461
461
  const allButtons = getButtons(element);
@@ -494,22 +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
- Object.assign(cloned.style, {
502
- backgroundColor: '#01c2b8',
503
- color: 'white',
504
- fontFamily: getComputedStyle(btn).fontFamily || 'inherit',
505
- ...style,
506
- });
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);
507
514
 
508
515
  if (textOption && textOption instanceof Object) {
509
- const target = cloned.querySelector(textOption.selector);
510
- if (target && (typeof textOption.value === 'string' || typeof textOption.value === 'number')) {
511
- target.textContent = textOption.value;
512
- }
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
+ });
513
523
  }
514
524
 
515
525
  clippathDiv.style.width = `${width}px`;
@@ -523,6 +533,7 @@ function clippath(element, config = {}) {
523
533
  });
524
534
  }
525
535
  });
536
+
526
537
  document.addEventListener('mouseout', (e) => {
527
538
  const btn = e.target.closest('[data-kitzo-clippath]');
528
539
  if (btn) {
@@ -532,7 +543,7 @@ function clippath(element, config = {}) {
532
543
  () => {
533
544
  clippathDiv.querySelectorAll('[data-temp-clippath-el]').forEach((el) => el.remove());
534
545
  },
535
- smooth ? 150 : 150
546
+ smooth ? 150 : 150,
536
547
  );
537
548
  }
538
549
  });
@@ -546,8 +557,10 @@ function clippath(element, config = {}) {
546
557
  const x = e.clientX - left;
547
558
  const y = e.clientY - top;
548
559
 
549
- clippathDiv.style.setProperty('--kitzo-clippath-pos-x', `${x}px`);
550
- clippathDiv.style.setProperty('--kitzo-clippath-pos-y', `${y}px`);
560
+ requestAnimationFrame(() => {
561
+ clippathDiv.style.setProperty('--kitzo-clippath-pos-x', `${x}px`);
562
+ clippathDiv.style.setProperty('--kitzo-clippath-pos-y', `${y}px`);
563
+ });
551
564
  }
552
565
  });
553
566
 
package/dist/kitzo.umd.js CHANGED
@@ -461,7 +461,7 @@
461
461
  class: '',
462
462
  style: {},
463
463
  },
464
- config
464
+ config,
465
465
  );
466
466
 
467
467
  const allButtons = getButtons(element);
@@ -500,22 +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
- Object.assign(cloned.style, {
508
- backgroundColor: '#01c2b8',
509
- color: 'white',
510
- fontFamily: getComputedStyle(btn).fontFamily || 'inherit',
511
- ...style,
512
- });
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);
513
520
 
514
521
  if (textOption && textOption instanceof Object) {
515
- const target = cloned.querySelector(textOption.selector);
516
- if (target && (typeof textOption.value === 'string' || typeof textOption.value === 'number')) {
517
- target.textContent = textOption.value;
518
- }
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
+ });
519
529
  }
520
530
 
521
531
  clippathDiv.style.width = `${width}px`;
@@ -529,6 +539,7 @@
529
539
  });
530
540
  }
531
541
  });
542
+
532
543
  document.addEventListener('mouseout', (e) => {
533
544
  const btn = e.target.closest('[data-kitzo-clippath]');
534
545
  if (btn) {
@@ -538,7 +549,7 @@
538
549
  () => {
539
550
  clippathDiv.querySelectorAll('[data-temp-clippath-el]').forEach((el) => el.remove());
540
551
  },
541
- smooth ? 150 : 150
552
+ smooth ? 150 : 150,
542
553
  );
543
554
  }
544
555
  });
@@ -552,8 +563,10 @@
552
563
  const x = e.clientX - left;
553
564
  const y = e.clientY - top;
554
565
 
555
- clippathDiv.style.setProperty('--kitzo-clippath-pos-x', `${x}px`);
556
- clippathDiv.style.setProperty('--kitzo-clippath-pos-y', `${y}px`);
566
+ requestAnimationFrame(() => {
567
+ clippathDiv.style.setProperty('--kitzo-clippath-pos-x', `${x}px`);
568
+ clippathDiv.style.setProperty('--kitzo-clippath-pos-y', `${y}px`);
569
+ });
557
570
  }
558
571
  });
559
572
 
package/package.json CHANGED
@@ -1,60 +1,61 @@
1
- {
2
- "name": "kitzo",
3
- "version": "2.0.24",
4
- "description": "A lightweight JavaScript UI micro-library.",
5
- "type": "module",
6
- "main": "./dist/kitzo.umd.js",
7
- "exports": {
8
- ".": {
9
- "import": "./dist/kitzo.esm.js",
10
- "require": "./dist/kitzo.umd.js",
11
- "types": "./dist/kitzo.d.ts"
12
- },
13
- "./react": {
14
- "import": "./dist/react.esm.js",
15
- "types": "./dist/react.d.ts"
16
- }
17
- },
18
- "files": [
19
- "dist"
20
- ],
21
- "scripts": {
22
- "dev": "vite",
23
- "build": "rollup -c",
24
- "preview": "vite preview"
25
- },
26
- "keywords": [
27
- "tooltip",
28
- "ripple",
29
- "copy-button",
30
- "micro-library",
31
- "modular",
32
- "ui",
33
- "javascript",
34
- "react",
35
- "kitzo"
36
- ],
37
- "author": "Riyad",
38
- "license": "MIT",
39
- "repository": {
40
- "type": "git",
41
- "url": "https://github.com/riyad-96/kitzo"
42
- },
43
- "homepage": "https://github.com/riyad-96/kitzo#readme",
44
- "devDependencies": {
45
- "@rollup/plugin-commonjs": "^28.0.6",
46
- "@rollup/plugin-node-resolve": "^16.0.1",
47
- "@babel/core": "^7.28.4",
48
- "@babel/preset-react": "^7.27.1",
49
- "@rollup/plugin-babel": "^6.0.4",
50
- "@vitejs/plugin-react": "^5.0.4",
51
- "react": "^19.1.1",
52
- "react-dom": "^19.1.1",
53
- "rollup": "^4.46.2",
54
- "vite": "^7.0.4"
55
- },
56
- "peerDependencies": {
57
- "react": ">=17",
58
- "react-dom": ">=17"
59
- }
60
- }
1
+ {
2
+ "name": "kitzo",
3
+ "version": "2.0.26",
4
+ "description": "A lightweight JavaScript UI micro-library.",
5
+ "type": "module",
6
+ "main": "./dist/kitzo.umd.js",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./dist/kitzo.esm.js",
10
+ "require": "./dist/kitzo.umd.js",
11
+ "types": "./dist/kitzo.d.ts"
12
+ },
13
+ "./react": {
14
+ "import": "./dist/react.esm.js",
15
+ "types": "./dist/react.d.ts"
16
+ }
17
+ },
18
+ "files": [
19
+ "dist"
20
+ ],
21
+ "scripts": {
22
+ "dev": "vite",
23
+ "build": "rollup -c",
24
+ "preview": "vite preview"
25
+ },
26
+ "keywords": [
27
+ "tooltip",
28
+ "ripple",
29
+ "copy-button",
30
+ "micro-library",
31
+ "modular",
32
+ "ui",
33
+ "javascript",
34
+ "react",
35
+ "kitzo"
36
+ ],
37
+ "author": "Riyad",
38
+ "license": "MIT",
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "https://github.com/riyad-96/kitzo"
42
+ },
43
+ "homepage": "https://github.com/riyad-96/kitzo#readme",
44
+ "devDependencies": {
45
+ "@babel/core": "^7.28.4",
46
+ "@babel/preset-react": "^7.27.1",
47
+ "@rollup/plugin-babel": "^6.0.4",
48
+ "@rollup/plugin-commonjs": "^28.0.6",
49
+ "@rollup/plugin-node-resolve": "^16.0.1",
50
+ "@vitejs/plugin-react": "^5.0.4",
51
+ "prettier": "^3.6.2",
52
+ "react": "^19.1.1",
53
+ "react-dom": "^19.1.1",
54
+ "rollup": "^4.46.2",
55
+ "vite": "^7.0.4"
56
+ },
57
+ "peerDependencies": {
58
+ "react": ">=17",
59
+ "react-dom": ">=17"
60
+ }
61
+ }