kitzo 2.0.17 → 2.0.19
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 +4 -7
- package/dist/kitzo.d.ts +1 -14
- package/dist/kitzo.esm.js +46 -113
- package/dist/kitzo.umd.js +52 -121
- package/dist/react.d.ts +1 -1
- 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.19/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.
|
|
@@ -60,13 +60,10 @@ kitzo.clippath();
|
|
|
60
60
|
##### Copy API:
|
|
61
61
|
|
|
62
62
|
```javascript
|
|
63
|
-
kitzo.copy(
|
|
64
|
-
doc: string,
|
|
65
|
-
event: 'click' | 'dblclick' | 'contextmenu' | 'mouseup' | 'touchend',
|
|
66
|
-
});
|
|
63
|
+
kitzo.copy(doc);
|
|
67
64
|
```
|
|
68
65
|
|
|
69
|
-
>
|
|
66
|
+
> Copy functionality on call.
|
|
70
67
|
|
|
71
68
|
##### Tooltip API:
|
|
72
69
|
|
|
@@ -94,7 +91,7 @@ kitzo.ripple(selectors | element | NodeList, {
|
|
|
94
91
|
});
|
|
95
92
|
```
|
|
96
93
|
|
|
97
|
-
> Adds a lightweight, clean ripple effect to your
|
|
94
|
+
> Adds a lightweight, clean ripple effect to your elements on click.
|
|
98
95
|
|
|
99
96
|
##### Debounce API:
|
|
100
97
|
|
package/dist/kitzo.d.ts
CHANGED
|
@@ -53,20 +53,7 @@ export type ripple = (
|
|
|
53
53
|
) => void;
|
|
54
54
|
|
|
55
55
|
// Copy
|
|
56
|
-
export type copy = (
|
|
57
|
-
element: string | Element | NodeListOf<Element>,
|
|
58
|
-
config?: {
|
|
59
|
-
/** The text to copy to clipboard (default: element textContent) */
|
|
60
|
-
doc?: string;
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* The DOM event that triggers the copy action
|
|
64
|
-
* Only allowed: 'click' | 'dblclick' | 'contextmenu' | 'mouseup' | 'touchend'
|
|
65
|
-
* Default: 'click'
|
|
66
|
-
*/
|
|
67
|
-
event?: 'click' | 'dblclick' | 'contextmenu' | 'mouseup' | 'touchend';
|
|
68
|
-
}
|
|
69
|
-
) => void;
|
|
56
|
+
export type copy = (doc?: any) => void;
|
|
70
57
|
|
|
71
58
|
// Debounce
|
|
72
59
|
export type debounce = <Args extends any[]>(fn: (...args: Args) => any, delay?: number) => (...args: Args) => void;
|
package/dist/kitzo.esm.js
CHANGED
|
@@ -1,3 +1,48 @@
|
|
|
1
|
+
//! Copy function
|
|
2
|
+
function legecyCopy(docs) {
|
|
3
|
+
try {
|
|
4
|
+
const textarea = document.createElement('textarea');
|
|
5
|
+
textarea.value = docs;
|
|
6
|
+
document.body.appendChild(textarea);
|
|
7
|
+
textarea.select();
|
|
8
|
+
document.execCommand('copy');
|
|
9
|
+
document.body.removeChild(textarea);
|
|
10
|
+
} catch (error) {
|
|
11
|
+
alert('Couldn’t complete. Please copy manually.');
|
|
12
|
+
console.error(error);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async function copyText(docs) {
|
|
17
|
+
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
18
|
+
try {
|
|
19
|
+
await navigator.clipboard.writeText(docs);
|
|
20
|
+
} catch (error) {
|
|
21
|
+
legecyCopy(docs);
|
|
22
|
+
console.error(error);
|
|
23
|
+
}
|
|
24
|
+
} else {
|
|
25
|
+
legecyCopy(docs);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function copy(doc) {
|
|
30
|
+
if (typeof doc === 'string' || typeof doc === 'number') {
|
|
31
|
+
copyText(doc);
|
|
32
|
+
} else {
|
|
33
|
+
copyText(JSON.stringify(doc));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function debounce(fn, delay = 300) {
|
|
38
|
+
let timer;
|
|
39
|
+
|
|
40
|
+
return (...args) => {
|
|
41
|
+
clearTimeout(timer);
|
|
42
|
+
timer = setTimeout(() => fn(...args), delay);
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
1
46
|
//! Helper functions
|
|
2
47
|
// Get elements from dom
|
|
3
48
|
function getButtons(element) {
|
|
@@ -38,118 +83,6 @@ function addStyleTagToHtmlHead(type, styles) {
|
|
|
38
83
|
}
|
|
39
84
|
}
|
|
40
85
|
|
|
41
|
-
//! Copy function
|
|
42
|
-
function legecyCopy(docs) {
|
|
43
|
-
try {
|
|
44
|
-
const textarea = document.createElement('textarea');
|
|
45
|
-
textarea.value = docs;
|
|
46
|
-
document.body.appendChild(textarea);
|
|
47
|
-
textarea.select();
|
|
48
|
-
document.execCommand('copy');
|
|
49
|
-
document.body.removeChild(textarea);
|
|
50
|
-
} catch (error) {
|
|
51
|
-
alert('Couldn’t copy automatically. Please copy manually.');
|
|
52
|
-
console.error(error);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
async function copyText(docs) {
|
|
57
|
-
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
58
|
-
try {
|
|
59
|
-
await navigator.clipboard.writeText(docs);
|
|
60
|
-
} catch (error) {
|
|
61
|
-
legecyCopy(docs);
|
|
62
|
-
console.error(error);
|
|
63
|
-
}
|
|
64
|
-
} else {
|
|
65
|
-
legecyCopy(docs);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const copyConfigMap = new WeakMap();
|
|
70
|
-
const allowedEvents = ['click', 'dblclick', 'contextmenu', 'mouseup', 'touchend'];
|
|
71
|
-
const attachedEvents = new Set();
|
|
72
|
-
|
|
73
|
-
function copy(element, config = {}) {
|
|
74
|
-
config = Object.assign(
|
|
75
|
-
{
|
|
76
|
-
doc: '',
|
|
77
|
-
event: 'click',
|
|
78
|
-
},
|
|
79
|
-
config
|
|
80
|
-
);
|
|
81
|
-
|
|
82
|
-
const { doc, event } = config;
|
|
83
|
-
|
|
84
|
-
if (!element) {
|
|
85
|
-
console.error('A button element/selector is expected');
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
if (!doc) {
|
|
90
|
-
console.error('doc cannot be empty');
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (typeof doc !== 'string') {
|
|
95
|
-
console.error('Doc should be in string format');
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if (typeof event !== 'string') {
|
|
100
|
-
console.error('Only strings are allowed as events');
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
if (!event.trim()) {
|
|
105
|
-
console.error('event cannot be empty');
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
const allButtons = getButtons(element);
|
|
110
|
-
if (!allButtons) {
|
|
111
|
-
console.error('No elements found for kitzoCopy');
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
if (!allowedEvents.includes(event)) {
|
|
116
|
-
console.warn(`[kitzo.copy] "${event}" is not allowed. Defaulting to "click".`);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
const safeEvent = allowedEvents.includes(event) ? event : 'click';
|
|
120
|
-
|
|
121
|
-
allButtons.forEach((btn) => {
|
|
122
|
-
btn.setAttribute('data-kitzo-copy', 'true');
|
|
123
|
-
|
|
124
|
-
copyConfigMap.set(btn, {
|
|
125
|
-
doc,
|
|
126
|
-
event: safeEvent,
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
if (!attachedEvents.has(safeEvent)) {
|
|
131
|
-
document.addEventListener(safeEvent, (e) => {
|
|
132
|
-
const btn = e.target.closest('[data-kitzo-copy]');
|
|
133
|
-
if (!btn) return;
|
|
134
|
-
|
|
135
|
-
const { doc, event } = copyConfigMap.get(btn);
|
|
136
|
-
if (event && event === safeEvent) {
|
|
137
|
-
copyText(doc);
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
attachedEvents.add(safeEvent);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
function debounce(fn, delay = 300) {
|
|
145
|
-
let timer;
|
|
146
|
-
|
|
147
|
-
return (...args) => {
|
|
148
|
-
clearTimeout(timer);
|
|
149
|
-
timer = setTimeout(() => fn(...args), delay);
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
|
|
153
86
|
function rippleStyles() {
|
|
154
87
|
return `.kitzo-ripples {
|
|
155
88
|
display: block;
|
|
@@ -622,4 +555,4 @@ function clippath(element, config = {}) {
|
|
|
622
555
|
|
|
623
556
|
const kitzo = { copy, debounce, ripple, tooltip, clippath };
|
|
624
557
|
|
|
625
|
-
export { kitzo as default };
|
|
558
|
+
export { clippath, copy, debounce, kitzo as default, ripple, tooltip };
|
package/dist/kitzo.umd.js
CHANGED
|
@@ -1,8 +1,53 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(
|
|
3
|
-
typeof define === 'function' && define.amd ? define(
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self,
|
|
5
|
-
})(this, (function (
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.kitzo = factory());
|
|
5
|
+
})(this, (function () { 'use strict';
|
|
6
|
+
|
|
7
|
+
//! Copy function
|
|
8
|
+
function legecyCopy(docs) {
|
|
9
|
+
try {
|
|
10
|
+
const textarea = document.createElement('textarea');
|
|
11
|
+
textarea.value = docs;
|
|
12
|
+
document.body.appendChild(textarea);
|
|
13
|
+
textarea.select();
|
|
14
|
+
document.execCommand('copy');
|
|
15
|
+
document.body.removeChild(textarea);
|
|
16
|
+
} catch (error) {
|
|
17
|
+
alert('Couldn’t complete. Please copy manually.');
|
|
18
|
+
console.error(error);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async function copyText(docs) {
|
|
23
|
+
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
24
|
+
try {
|
|
25
|
+
await navigator.clipboard.writeText(docs);
|
|
26
|
+
} catch (error) {
|
|
27
|
+
legecyCopy(docs);
|
|
28
|
+
console.error(error);
|
|
29
|
+
}
|
|
30
|
+
} else {
|
|
31
|
+
legecyCopy(docs);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function copy(doc) {
|
|
36
|
+
if (typeof doc === 'string' || typeof doc === 'number') {
|
|
37
|
+
copyText(doc);
|
|
38
|
+
} else {
|
|
39
|
+
copyText(JSON.stringify(doc));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function debounce(fn, delay = 300) {
|
|
44
|
+
let timer;
|
|
45
|
+
|
|
46
|
+
return (...args) => {
|
|
47
|
+
clearTimeout(timer);
|
|
48
|
+
timer = setTimeout(() => fn(...args), delay);
|
|
49
|
+
};
|
|
50
|
+
}
|
|
6
51
|
|
|
7
52
|
//! Helper functions
|
|
8
53
|
// Get elements from dom
|
|
@@ -44,118 +89,6 @@
|
|
|
44
89
|
}
|
|
45
90
|
}
|
|
46
91
|
|
|
47
|
-
//! Copy function
|
|
48
|
-
function legecyCopy(docs) {
|
|
49
|
-
try {
|
|
50
|
-
const textarea = document.createElement('textarea');
|
|
51
|
-
textarea.value = docs;
|
|
52
|
-
document.body.appendChild(textarea);
|
|
53
|
-
textarea.select();
|
|
54
|
-
document.execCommand('copy');
|
|
55
|
-
document.body.removeChild(textarea);
|
|
56
|
-
} catch (error) {
|
|
57
|
-
alert('Couldn’t copy automatically. Please copy manually.');
|
|
58
|
-
console.error(error);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
async function copyText(docs) {
|
|
63
|
-
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
64
|
-
try {
|
|
65
|
-
await navigator.clipboard.writeText(docs);
|
|
66
|
-
} catch (error) {
|
|
67
|
-
legecyCopy(docs);
|
|
68
|
-
console.error(error);
|
|
69
|
-
}
|
|
70
|
-
} else {
|
|
71
|
-
legecyCopy(docs);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const copyConfigMap = new WeakMap();
|
|
76
|
-
const allowedEvents = ['click', 'dblclick', 'contextmenu', 'mouseup', 'touchend'];
|
|
77
|
-
const attachedEvents = new Set();
|
|
78
|
-
|
|
79
|
-
function copy(element, config = {}) {
|
|
80
|
-
config = Object.assign(
|
|
81
|
-
{
|
|
82
|
-
doc: '',
|
|
83
|
-
event: 'click',
|
|
84
|
-
},
|
|
85
|
-
config
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
const { doc, event } = config;
|
|
89
|
-
|
|
90
|
-
if (!element) {
|
|
91
|
-
console.error('A button element/selector is expected');
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (!doc) {
|
|
96
|
-
console.error('doc cannot be empty');
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
if (typeof doc !== 'string') {
|
|
101
|
-
console.error('Doc should be in string format');
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (typeof event !== 'string') {
|
|
106
|
-
console.error('Only strings are allowed as events');
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
if (!event.trim()) {
|
|
111
|
-
console.error('event cannot be empty');
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
const allButtons = getButtons(element);
|
|
116
|
-
if (!allButtons) {
|
|
117
|
-
console.error('No elements found for kitzoCopy');
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
if (!allowedEvents.includes(event)) {
|
|
122
|
-
console.warn(`[kitzo.copy] "${event}" is not allowed. Defaulting to "click".`);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const safeEvent = allowedEvents.includes(event) ? event : 'click';
|
|
126
|
-
|
|
127
|
-
allButtons.forEach((btn) => {
|
|
128
|
-
btn.setAttribute('data-kitzo-copy', 'true');
|
|
129
|
-
|
|
130
|
-
copyConfigMap.set(btn, {
|
|
131
|
-
doc,
|
|
132
|
-
event: safeEvent,
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
if (!attachedEvents.has(safeEvent)) {
|
|
137
|
-
document.addEventListener(safeEvent, (e) => {
|
|
138
|
-
const btn = e.target.closest('[data-kitzo-copy]');
|
|
139
|
-
if (!btn) return;
|
|
140
|
-
|
|
141
|
-
const { doc, event } = copyConfigMap.get(btn);
|
|
142
|
-
if (event && event === safeEvent) {
|
|
143
|
-
copyText(doc);
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
attachedEvents.add(safeEvent);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
function debounce(fn, delay = 300) {
|
|
151
|
-
let timer;
|
|
152
|
-
|
|
153
|
-
return (...args) => {
|
|
154
|
-
clearTimeout(timer);
|
|
155
|
-
timer = setTimeout(() => fn(...args), delay);
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
|
|
159
92
|
function rippleStyles() {
|
|
160
93
|
return `.kitzo-ripples {
|
|
161
94
|
display: block;
|
|
@@ -626,10 +559,8 @@
|
|
|
626
559
|
}
|
|
627
560
|
}
|
|
628
561
|
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
exports.ripple = ripple;
|
|
633
|
-
exports.tooltip = tooltip;
|
|
562
|
+
const kitzo = { copy, debounce, ripple, tooltip, clippath };
|
|
563
|
+
|
|
564
|
+
return kitzo;
|
|
634
565
|
|
|
635
566
|
}));
|
package/dist/react.d.ts
CHANGED