sculp-js 1.10.4 → 1.11.0

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.
Files changed (63) hide show
  1. package/lib/cjs/array.js +7 -9
  2. package/lib/cjs/async.js +1 -1
  3. package/lib/cjs/base64.js +1 -1
  4. package/lib/cjs/clipboard.js +42 -5
  5. package/lib/cjs/cloneDeep.js +1 -1
  6. package/lib/cjs/cookie.js +1 -1
  7. package/lib/cjs/date.js +1 -1
  8. package/lib/cjs/dom.js +1 -1
  9. package/lib/cjs/download.js +1 -1
  10. package/lib/cjs/easing.js +1 -1
  11. package/lib/cjs/file.js +1 -1
  12. package/lib/cjs/func.js +1 -1
  13. package/lib/cjs/index.js +2 -1
  14. package/lib/cjs/isEqual.js +1 -1
  15. package/lib/cjs/math.js +1 -1
  16. package/lib/cjs/number.js +1 -1
  17. package/lib/cjs/object.js +10 -2
  18. package/lib/cjs/path.js +1 -1
  19. package/lib/cjs/qs.js +1 -1
  20. package/lib/cjs/random.js +1 -1
  21. package/lib/cjs/string.js +1 -1
  22. package/lib/cjs/tooltip.js +1 -1
  23. package/lib/cjs/tree.js +7 -1
  24. package/lib/cjs/type.js +9 -4
  25. package/lib/cjs/unique.js +1 -1
  26. package/lib/cjs/url.js +1 -1
  27. package/lib/cjs/validator.js +1 -1
  28. package/lib/cjs/variable.js +1 -1
  29. package/lib/cjs/watermark.js +1 -1
  30. package/lib/cjs/we-decode.js +1 -1
  31. package/lib/es/array.js +7 -9
  32. package/lib/es/async.js +1 -1
  33. package/lib/es/base64.js +1 -1
  34. package/lib/es/clipboard.js +42 -6
  35. package/lib/es/cloneDeep.js +1 -1
  36. package/lib/es/cookie.js +1 -1
  37. package/lib/es/date.js +1 -1
  38. package/lib/es/dom.js +1 -1
  39. package/lib/es/download.js +1 -1
  40. package/lib/es/easing.js +1 -1
  41. package/lib/es/file.js +1 -1
  42. package/lib/es/func.js +1 -1
  43. package/lib/es/index.js +2 -2
  44. package/lib/es/isEqual.js +1 -1
  45. package/lib/es/math.js +1 -1
  46. package/lib/es/number.js +1 -1
  47. package/lib/es/object.js +10 -2
  48. package/lib/es/path.js +1 -1
  49. package/lib/es/qs.js +1 -1
  50. package/lib/es/random.js +1 -1
  51. package/lib/es/string.js +1 -1
  52. package/lib/es/tooltip.js +1 -1
  53. package/lib/es/tree.js +7 -1
  54. package/lib/es/type.js +9 -4
  55. package/lib/es/unique.js +1 -1
  56. package/lib/es/url.js +1 -1
  57. package/lib/es/validator.js +1 -1
  58. package/lib/es/variable.js +1 -1
  59. package/lib/es/watermark.js +1 -1
  60. package/lib/es/we-decode.js +1 -1
  61. package/lib/index.d.ts +18 -8
  62. package/lib/umd/index.js +2 -2
  63. package/package.json +1 -1
package/lib/cjs/array.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.10.4
2
+ * sculp-js v1.11.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -17,8 +17,7 @@
17
17
  function arrayEach(array, iterator, reverse = false) {
18
18
  if (reverse) {
19
19
  for (let idx = array.length - 1; idx >= 0; idx--) {
20
- const val = array[idx];
21
- const re = iterator(val, idx, array);
20
+ const re = iterator(array[idx], idx, array);
22
21
  if (re === false)
23
22
  break;
24
23
  else if (re === true)
@@ -27,14 +26,15 @@ function arrayEach(array, iterator, reverse = false) {
27
26
  }
28
27
  else {
29
28
  for (let idx = 0, len = array.length; idx < len; idx++) {
30
- const val = array[idx];
31
- const re = iterator(val, idx, array);
29
+ const re = iterator(array[idx], idx, array);
32
30
  if (re === false)
33
31
  break;
34
32
  else if (re === true)
35
33
  continue;
36
34
  }
37
35
  }
36
+ // @ts-ignore
37
+ array = null;
38
38
  }
39
39
  /**
40
40
  * 异步遍历数组,返回 false 中断遍历
@@ -62,15 +62,13 @@ function arrayEach(array, iterator, reverse = false) {
62
62
  async function arrayEachAsync(array, iterator, reverse = false) {
63
63
  if (reverse) {
64
64
  for (let idx = array.length - 1; idx >= 0; idx--) {
65
- const val = array[idx];
66
- if ((await iterator(val, idx)) === false)
65
+ if ((await iterator(array[idx], idx)) === false)
67
66
  break;
68
67
  }
69
68
  }
70
69
  else {
71
70
  for (let idx = 0, len = array.length; idx < len; idx++) {
72
- const val = array[idx];
73
- if ((await iterator(val, idx)) === false)
71
+ if ((await iterator(array[idx], idx)) === false)
74
72
  break;
75
73
  }
76
74
  }
package/lib/cjs/async.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.10.4
2
+ * sculp-js v1.11.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
package/lib/cjs/base64.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.10.4
2
+ * sculp-js v1.11.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,20 +1,49 @@
1
1
  /*!
2
- * sculp-js v1.10.4
2
+ * sculp-js v1.11.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
6
6
 
7
7
  'use strict';
8
8
 
9
+ var type = require('./type.js');
10
+
9
11
  /**
10
- * 复制文本
12
+ * 复制文本,优先使用navigator.clipboard,若不支持则回退使用execCommand方式
11
13
  * @param {string} text
14
+ * @param {AsyncCallback} options 可选参数:成功回调、失败回调
12
15
  */
13
- function copyText(text) {
16
+ function copyText(text, options) {
17
+ const { successCallback = void 0, failCallback = void 0 } = type.isNullOrUnDef(options) ? {} : options;
18
+ if (navigator.clipboard) {
19
+ navigator.clipboard
20
+ .writeText(text)
21
+ .then(() => {
22
+ if (type.isFunction(successCallback)) {
23
+ successCallback();
24
+ }
25
+ })
26
+ .catch(err => {
27
+ fallbackCopyText(text, options);
28
+ });
29
+ }
30
+ else {
31
+ // 使用旧版execCommand方法
32
+ fallbackCopyText(text, options);
33
+ }
34
+ }
35
+ /**
36
+ * 使用execCommand方式复制文本
37
+ * @param text
38
+ * @param options
39
+ */
40
+ function fallbackCopyText(text, options) {
41
+ const { successCallback = void 0, failCallback = void 0 } = type.isNullOrUnDef(options) ? {} : options;
14
42
  const textEl = document.createElement('textarea');
15
43
  textEl.style.position = 'absolute';
16
44
  textEl.style.top = '-9999px';
17
45
  textEl.style.left = '-9999px';
46
+ textEl.style.opacity = '0';
18
47
  textEl.value = text;
19
48
  document.body.appendChild(textEl);
20
49
  textEl.focus({ preventScroll: true });
@@ -22,11 +51,19 @@ function copyText(text) {
22
51
  try {
23
52
  document.execCommand('copy');
24
53
  textEl.blur();
25
- document.body.removeChild(textEl);
54
+ if (type.isFunction(successCallback)) {
55
+ successCallback();
56
+ }
26
57
  }
27
58
  catch (err) {
28
- // ignore
59
+ if (type.isFunction(failCallback)) {
60
+ failCallback(err);
61
+ }
62
+ }
63
+ finally {
64
+ document.body.removeChild(textEl);
29
65
  }
30
66
  }
31
67
 
32
68
  exports.copyText = copyText;
69
+ exports.fallbackCopyText = fallbackCopyText;
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.10.4
2
+ * sculp-js v1.11.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
package/lib/cjs/cookie.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.10.4
2
+ * sculp-js v1.11.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
package/lib/cjs/date.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.10.4
2
+ * sculp-js v1.11.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
package/lib/cjs/dom.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.10.4
2
+ * sculp-js v1.11.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.10.4
2
+ * sculp-js v1.11.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
package/lib/cjs/easing.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.10.4
2
+ * sculp-js v1.11.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
package/lib/cjs/file.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.10.4
2
+ * sculp-js v1.11.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
package/lib/cjs/func.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.10.4
2
+ * sculp-js v1.11.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
package/lib/cjs/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.10.4
2
+ * sculp-js v1.11.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -42,6 +42,7 @@ exports.arrayEachAsync = array.arrayEachAsync;
42
42
  exports.arrayInsertBefore = array.arrayInsertBefore;
43
43
  exports.arrayRemove = array.arrayRemove;
44
44
  exports.copyText = clipboard.copyText;
45
+ exports.fallbackCopyText = clipboard.fallbackCopyText;
45
46
  exports.cookieDel = cookie.cookieDel;
46
47
  exports.cookieGet = cookie.cookieGet;
47
48
  exports.cookieSet = cookie.cookieSet;
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.10.4
2
+ * sculp-js v1.11.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
package/lib/cjs/math.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.10.4
2
+ * sculp-js v1.11.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
package/lib/cjs/number.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.10.4
2
+ * sculp-js v1.11.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
package/lib/cjs/object.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.10.4
2
+ * sculp-js v1.11.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -35,6 +35,8 @@ function objectEach(obj, iterator) {
35
35
  if (iterator(obj[key], key) === false)
36
36
  break;
37
37
  }
38
+ // @ts-ignore
39
+ obj = null;
38
40
  }
39
41
  /**
40
42
  * 异步遍历对象,返回 false 中断遍历
@@ -62,6 +64,8 @@ function objectMap(obj, iterator) {
62
64
  continue;
63
65
  obj2[key] = iterator(obj[key], key);
64
66
  }
67
+ // @ts-ignore
68
+ obj = null;
65
69
  return obj2;
66
70
  }
67
71
  /**
@@ -78,6 +82,8 @@ function objectPick(obj, keys) {
78
82
  obj2[k] = v;
79
83
  }
80
84
  });
85
+ // @ts-ignore
86
+ obj = null;
81
87
  return obj2;
82
88
  }
83
89
  /**
@@ -94,6 +100,8 @@ function objectOmit(obj, keys) {
94
100
  obj2[k] = v;
95
101
  }
96
102
  });
103
+ // @ts-ignore
104
+ obj = null;
97
105
  return obj2;
98
106
  }
99
107
  const merge = (map, source, target) => {
@@ -165,7 +173,7 @@ function objectFill(source, target, fillable) {
165
173
  return source;
166
174
  }
167
175
  /**
168
- * 获取对象指定层级下的属性值(现在可用ES6+的可选链?.来替代)
176
+ * 获取对象/数组指定层级下的属性值(现在可用ES6+的可选链?.来替代)
169
177
  * @param {AnyObject} obj
170
178
  * @param {string} path
171
179
  * @param {boolean} strict
package/lib/cjs/path.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.10.4
2
+ * sculp-js v1.11.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
package/lib/cjs/qs.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.10.4
2
+ * sculp-js v1.11.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
package/lib/cjs/random.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.10.4
2
+ * sculp-js v1.11.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
package/lib/cjs/string.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.10.4
2
+ * sculp-js v1.11.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.10.4
2
+ * sculp-js v1.11.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
package/lib/cjs/tree.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.10.4
2
+ * sculp-js v1.11.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -70,6 +70,8 @@ function forEachDeep(tree, iterator, children = 'children', isReverse = false) {
70
70
  }
71
71
  };
72
72
  walk(tree, null);
73
+ // @ts-ignore
74
+ tree = null;
73
75
  }
74
76
  /**
75
77
  * 创建一个新数组, 深度优先遍历的Map函数(支持continue和break操作), 可用于insert tree item 和 remove tree item
@@ -139,6 +141,8 @@ function mapDeep(tree, iterator, children = 'children', isReverse = false) {
139
141
  }
140
142
  };
141
143
  walk(tree, null, newTree);
144
+ // @ts-ignore
145
+ tree = null;
142
146
  return newTree;
143
147
  }
144
148
  /**
@@ -196,6 +200,8 @@ function formatTree(list, options = defaultFieldOptions) {
196
200
  treeArr.push(item);
197
201
  }
198
202
  });
203
+ // @ts-ignore
204
+ list = null;
199
205
  return treeArr;
200
206
  }
201
207
  /**
package/lib/cjs/type.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.10.4
2
+ * sculp-js v1.11.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -9,6 +9,7 @@
9
9
  Object.defineProperty(exports, '__esModule', { value: true });
10
10
 
11
11
  // 常用类型定义
12
+ const { toString, hasOwnProperty, propertyIsEnumerable } = Object.prototype;
12
13
  /**
13
14
  * 判断对象内是否有该静态属性
14
15
  * @param {object} obj
@@ -16,7 +17,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
16
17
  * @returns {boolean}
17
18
  */
18
19
  function objectHas(obj, key) {
19
- return Object.prototype.hasOwnProperty.call(obj, key);
20
+ return hasOwnProperty.call(obj, key);
20
21
  }
21
22
  /**
22
23
  * 判断一个对象是否为类数组
@@ -43,7 +44,7 @@ function arrayLike(any) {
43
44
  * @returns
44
45
  */
45
46
  function typeIs(any) {
46
- return Object.prototype.toString.call(any).slice(8, -1);
47
+ return toString.call(any).slice(8, -1);
47
48
  }
48
49
  // 基本数据类型判断
49
50
  const isString = (any) => typeof any === 'string';
@@ -118,9 +119,13 @@ function isEmpty(value) {
118
119
  if (isNullOrUnDef(value) || Number.isNaN(value)) {
119
120
  return true;
120
121
  }
121
- if (arrayLike(value) && (isArray(value) || isString(value) || isFunction(value.splice))) {
122
+ const tag = typeIs(value);
123
+ if (arrayLike(value) || 'Arguments' === tag) {
122
124
  return !value.length;
123
125
  }
126
+ if ('Set' === tag || 'Map' === tag) {
127
+ return !value.size;
128
+ }
124
129
  return !Object.keys(value).length;
125
130
  }
126
131
 
package/lib/cjs/unique.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.10.4
2
+ * sculp-js v1.11.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
package/lib/cjs/url.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.10.4
2
+ * sculp-js v1.11.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.10.4
2
+ * sculp-js v1.11.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.10.4
2
+ * sculp-js v1.11.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.10.4
2
+ * sculp-js v1.11.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.10.4
2
+ * sculp-js v1.11.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
package/lib/es/array.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.10.4
2
+ * sculp-js v1.11.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -15,8 +15,7 @@
15
15
  function arrayEach(array, iterator, reverse = false) {
16
16
  if (reverse) {
17
17
  for (let idx = array.length - 1; idx >= 0; idx--) {
18
- const val = array[idx];
19
- const re = iterator(val, idx, array);
18
+ const re = iterator(array[idx], idx, array);
20
19
  if (re === false)
21
20
  break;
22
21
  else if (re === true)
@@ -25,14 +24,15 @@ function arrayEach(array, iterator, reverse = false) {
25
24
  }
26
25
  else {
27
26
  for (let idx = 0, len = array.length; idx < len; idx++) {
28
- const val = array[idx];
29
- const re = iterator(val, idx, array);
27
+ const re = iterator(array[idx], idx, array);
30
28
  if (re === false)
31
29
  break;
32
30
  else if (re === true)
33
31
  continue;
34
32
  }
35
33
  }
34
+ // @ts-ignore
35
+ array = null;
36
36
  }
37
37
  /**
38
38
  * 异步遍历数组,返回 false 中断遍历
@@ -60,15 +60,13 @@ function arrayEach(array, iterator, reverse = false) {
60
60
  async function arrayEachAsync(array, iterator, reverse = false) {
61
61
  if (reverse) {
62
62
  for (let idx = array.length - 1; idx >= 0; idx--) {
63
- const val = array[idx];
64
- if ((await iterator(val, idx)) === false)
63
+ if ((await iterator(array[idx], idx)) === false)
65
64
  break;
66
65
  }
67
66
  }
68
67
  else {
69
68
  for (let idx = 0, len = array.length; idx < len; idx++) {
70
- const val = array[idx];
71
- if ((await iterator(val, idx)) === false)
69
+ if ((await iterator(array[idx], idx)) === false)
72
70
  break;
73
71
  }
74
72
  }
package/lib/es/async.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.10.4
2
+ * sculp-js v1.11.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
package/lib/es/base64.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.10.4
2
+ * sculp-js v1.11.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,18 +1,47 @@
1
1
  /*!
2
- * sculp-js v1.10.4
2
+ * sculp-js v1.11.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
6
6
 
7
+ import { isFunction, isNullOrUnDef } from './type.js';
8
+
7
9
  /**
8
- * 复制文本
10
+ * 复制文本,优先使用navigator.clipboard,若不支持则回退使用execCommand方式
9
11
  * @param {string} text
12
+ * @param {AsyncCallback} options 可选参数:成功回调、失败回调
10
13
  */
11
- function copyText(text) {
14
+ function copyText(text, options) {
15
+ const { successCallback = void 0, failCallback = void 0 } = isNullOrUnDef(options) ? {} : options;
16
+ if (navigator.clipboard) {
17
+ navigator.clipboard
18
+ .writeText(text)
19
+ .then(() => {
20
+ if (isFunction(successCallback)) {
21
+ successCallback();
22
+ }
23
+ })
24
+ .catch(err => {
25
+ fallbackCopyText(text, options);
26
+ });
27
+ }
28
+ else {
29
+ // 使用旧版execCommand方法
30
+ fallbackCopyText(text, options);
31
+ }
32
+ }
33
+ /**
34
+ * 使用execCommand方式复制文本
35
+ * @param text
36
+ * @param options
37
+ */
38
+ function fallbackCopyText(text, options) {
39
+ const { successCallback = void 0, failCallback = void 0 } = isNullOrUnDef(options) ? {} : options;
12
40
  const textEl = document.createElement('textarea');
13
41
  textEl.style.position = 'absolute';
14
42
  textEl.style.top = '-9999px';
15
43
  textEl.style.left = '-9999px';
44
+ textEl.style.opacity = '0';
16
45
  textEl.value = text;
17
46
  document.body.appendChild(textEl);
18
47
  textEl.focus({ preventScroll: true });
@@ -20,11 +49,18 @@ function copyText(text) {
20
49
  try {
21
50
  document.execCommand('copy');
22
51
  textEl.blur();
23
- document.body.removeChild(textEl);
52
+ if (isFunction(successCallback)) {
53
+ successCallback();
54
+ }
24
55
  }
25
56
  catch (err) {
26
- // ignore
57
+ if (isFunction(failCallback)) {
58
+ failCallback(err);
59
+ }
60
+ }
61
+ finally {
62
+ document.body.removeChild(textEl);
27
63
  }
28
64
  }
29
65
 
30
- export { copyText };
66
+ export { copyText, fallbackCopyText };
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.10.4
2
+ * sculp-js v1.11.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
package/lib/es/cookie.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.10.4
2
+ * sculp-js v1.11.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
package/lib/es/date.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.10.4
2
+ * sculp-js v1.11.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
package/lib/es/dom.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.10.4
2
+ * sculp-js v1.11.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.10.4
2
+ * sculp-js v1.11.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
package/lib/es/easing.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.10.4
2
+ * sculp-js v1.11.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
package/lib/es/file.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.10.4
2
+ * sculp-js v1.11.0
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */