sculp-js 1.13.3-beta.0 → 1.13.6

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 (119) hide show
  1. package/dist/cjs/_virtual/_commonjsHelpers.js +3 -3
  2. package/dist/cjs/array.js +36 -46
  3. package/dist/cjs/async.js +41 -43
  4. package/dist/cjs/base64.js +77 -66
  5. package/dist/cjs/clipboard.js +54 -53
  6. package/dist/cjs/cloneDeep.js +90 -91
  7. package/dist/cjs/cookie.js +27 -30
  8. package/dist/cjs/date.js +101 -98
  9. package/dist/cjs/dom.js +114 -121
  10. package/dist/cjs/download.js +77 -78
  11. package/dist/cjs/easing.js +29 -32
  12. package/dist/cjs/file.js +147 -152
  13. package/dist/cjs/func.js +64 -78
  14. package/dist/cjs/index.js +1 -3
  15. package/dist/cjs/math.js +32 -38
  16. package/dist/cjs/node_modules/bezier-easing/src/index.js +35 -23
  17. package/dist/cjs/number.js +58 -61
  18. package/dist/cjs/object.js +112 -126
  19. package/dist/cjs/path.js +39 -43
  20. package/dist/cjs/qs.js +34 -41
  21. package/dist/cjs/random.js +31 -34
  22. package/dist/cjs/string.js +62 -63
  23. package/dist/cjs/tooltip.js +66 -69
  24. package/dist/cjs/tree.js +265 -263
  25. package/dist/cjs/type.js +42 -46
  26. package/dist/cjs/unique.js +39 -42
  27. package/dist/cjs/url.js +47 -48
  28. package/dist/cjs/validator.js +38 -38
  29. package/dist/cjs/variable.js +27 -21
  30. package/dist/cjs/watermark.js +78 -67
  31. package/dist/esm/array.js +36 -46
  32. package/dist/esm/async.js +41 -43
  33. package/dist/esm/base64.js +77 -66
  34. package/dist/esm/clipboard.js +55 -54
  35. package/dist/esm/cloneDeep.js +90 -91
  36. package/dist/esm/cookie.js +27 -30
  37. package/dist/esm/date.js +101 -98
  38. package/dist/esm/dom.js +114 -121
  39. package/dist/esm/download.js +78 -79
  40. package/dist/esm/easing.js +29 -32
  41. package/dist/esm/file.js +147 -152
  42. package/dist/esm/func.js +64 -78
  43. package/dist/esm/index.js +96 -8
  44. package/dist/esm/math.js +32 -38
  45. package/dist/esm/number.js +58 -61
  46. package/dist/esm/object.js +124 -127
  47. package/dist/esm/path.js +39 -43
  48. package/dist/esm/qs.js +34 -41
  49. package/dist/esm/random.js +31 -34
  50. package/dist/esm/string.js +74 -64
  51. package/dist/esm/tooltip.js +66 -69
  52. package/dist/esm/tree.js +265 -263
  53. package/dist/esm/type.js +68 -47
  54. package/dist/esm/unique.js +39 -42
  55. package/dist/esm/url.js +47 -48
  56. package/dist/esm/validator.js +56 -39
  57. package/dist/esm/variable.js +27 -21
  58. package/dist/esm/watermark.js +79 -68
  59. package/dist/types/array.d.ts +0 -1
  60. package/dist/types/async.d.ts +0 -1
  61. package/dist/types/base64.d.ts +0 -1
  62. package/dist/types/clipboard.d.ts +0 -1
  63. package/dist/types/cloneDeep.d.ts +0 -1
  64. package/dist/types/cookie.d.ts +0 -1
  65. package/dist/types/date.d.ts +0 -1
  66. package/dist/types/dom.d.ts +0 -1
  67. package/dist/types/download.d.ts +0 -1
  68. package/dist/types/easing.d.ts +0 -1
  69. package/dist/types/file.d.ts +0 -1
  70. package/dist/types/func.d.ts +0 -1
  71. package/dist/types/index.d.ts +0 -1
  72. package/dist/types/math.d.ts +0 -1
  73. package/dist/types/number.d.ts +0 -1
  74. package/dist/types/object.d.ts +0 -1
  75. package/dist/types/path.d.ts +0 -1
  76. package/dist/types/qs.d.ts +0 -1
  77. package/dist/types/random.d.ts +0 -1
  78. package/dist/types/string.d.ts +0 -1
  79. package/dist/types/tooltip.d.ts +0 -1
  80. package/dist/types/tree.d.ts +2 -2
  81. package/dist/types/type.d.ts +0 -1
  82. package/dist/types/unique.d.ts +0 -1
  83. package/dist/types/url.d.ts +0 -1
  84. package/dist/types/validator.d.ts +0 -1
  85. package/dist/types/variable.d.ts +0 -1
  86. package/dist/types/watermark.d.ts +0 -1
  87. package/dist/umd/index.min.js +2 -2
  88. package/package.json +12 -6
  89. package/dist/types/array.d.ts.map +0 -1
  90. package/dist/types/async.d.ts.map +0 -1
  91. package/dist/types/base64.d.ts.map +0 -1
  92. package/dist/types/clipboard.d.ts.map +0 -1
  93. package/dist/types/cloneDeep.d.ts.map +0 -1
  94. package/dist/types/cookie.d.ts.map +0 -1
  95. package/dist/types/core-index.d.ts +0 -17
  96. package/dist/types/core-index.d.ts.map +0 -1
  97. package/dist/types/date.d.ts.map +0 -1
  98. package/dist/types/dom.d.ts.map +0 -1
  99. package/dist/types/download.d.ts.map +0 -1
  100. package/dist/types/easing.d.ts.map +0 -1
  101. package/dist/types/file.d.ts.map +0 -1
  102. package/dist/types/func.d.ts.map +0 -1
  103. package/dist/types/index.d.ts.map +0 -1
  104. package/dist/types/index.js +0 -3278
  105. package/dist/types/math.d.ts.map +0 -1
  106. package/dist/types/number.d.ts.map +0 -1
  107. package/dist/types/object.d.ts.map +0 -1
  108. package/dist/types/path.d.ts.map +0 -1
  109. package/dist/types/qs.d.ts.map +0 -1
  110. package/dist/types/random.d.ts.map +0 -1
  111. package/dist/types/string.d.ts.map +0 -1
  112. package/dist/types/tooltip.d.ts.map +0 -1
  113. package/dist/types/tree.d.ts.map +0 -1
  114. package/dist/types/type.d.ts.map +0 -1
  115. package/dist/types/unique.d.ts.map +0 -1
  116. package/dist/types/url.d.ts.map +0 -1
  117. package/dist/types/validator.d.ts.map +0 -1
  118. package/dist/types/variable.d.ts.map +0 -1
  119. package/dist/types/watermark.d.ts.map +0 -1
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.13.3-beta.0
2
+ * sculp-js v1.13.6
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -11,12 +11,12 @@
11
11
  * @returns {string}
12
12
  */
13
13
  function stringCamelCase(string, bigger) {
14
- let string2 = string;
15
- if (bigger) {
16
- string2 = string.replace(/^./, origin => origin.toUpperCase());
17
- }
18
- const HUMP_RE = /[\s_-](.)/g;
19
- return string2.replace(HUMP_RE, (orign, char) => char.toUpperCase());
14
+ let string2 = string;
15
+ if (bigger) {
16
+ string2 = string.replace(/^./, origin => origin.toUpperCase());
17
+ }
18
+ const HUMP_RE = /[\s_-](.)/g;
19
+ return string2.replace(HUMP_RE, (orign, char) => char.toUpperCase());
20
20
  }
21
21
  /**
22
22
  * 将字符串转换为连字格式
@@ -25,8 +25,8 @@ function stringCamelCase(string, bigger) {
25
25
  * @returns {string}
26
26
  */
27
27
  function stringKebabCase(string, separator = '-') {
28
- const string2 = string.replace(/^./, origin => origin.toLowerCase());
29
- return string2.replace(/[A-Z]/g, origin => `${separator}${origin.toLowerCase()}`);
28
+ const string2 = string.replace(/^./, origin => origin.toLowerCase());
29
+ return string2.replace(/[A-Z]/g, origin => `${separator}${origin.toLowerCase()}`);
30
30
  }
31
31
  const STRING_ARABIC_NUMERALS = '0123456789';
32
32
  const STRING_LOWERCASE_ALPHA = 'abcdefghijklmnopqrstuvwxyz';
@@ -44,36 +44,37 @@ const placeholderRE = /%[%sdo]/g;
44
44
  * @returns {string}
45
45
  */
46
46
  function stringFormat(string, ...args) {
47
- let index = 0;
48
- const result = string.replace(placeholderRE, (origin) => {
49
- const arg = args[index++];
50
- switch (origin) {
51
- case '%%':
52
- index--;
53
- return '%';
54
- default:
55
- case '%s':
56
- return String(arg);
57
- case '%d':
58
- return String(Number(arg));
59
- case '%o':
60
- return JSON.stringify(arg);
61
- }
62
- });
63
- return [result, ...args.splice(index).map(String)].join(' ');
47
+ let index = 0;
48
+ const result = string.replace(placeholderRE, origin => {
49
+ const arg = args[index++];
50
+ switch (origin) {
51
+ case '%%':
52
+ index--;
53
+ return '%';
54
+ default:
55
+ case '%s':
56
+ return String(arg);
57
+ case '%d':
58
+ return String(Number(arg));
59
+ case '%o':
60
+ return JSON.stringify(arg);
61
+ }
62
+ });
63
+ return [result, ...args.splice(index).map(String)].join(' ');
64
64
  }
65
65
  const ev = (expression, data) => {
66
- try {
67
- // eslint-disable-next-line @typescript-eslint/no-implied-eval,@typescript-eslint/no-unsafe-return
68
- return new Function('with(arguments[0]){' +
69
- /****/ `if(arguments[0].${expression} === undefined)throw "";` +
70
- /****/
71
- /****/ `return String(arguments[0].${expression})` +
72
- '}')(data);
73
- }
74
- catch (err) {
75
- throw new SyntaxError(`无法执行表达式:${expression}`);
76
- }
66
+ try {
67
+ // eslint-disable-next-line @typescript-eslint/no-implied-eval,@typescript-eslint/no-unsafe-return
68
+ return new Function(
69
+ 'with(arguments[0]){' +
70
+ /****/ `if(arguments[0].${expression} === undefined)throw "";` +
71
+ /****/
72
+ /****/ `return String(arguments[0].${expression})` +
73
+ '}'
74
+ )(data);
75
+ } catch (err) {
76
+ throw new SyntaxError(`无法执行表达式:${expression}`);
77
+ }
77
78
  };
78
79
  const templateRE = /\${(.*?)}/g;
79
80
  /**
@@ -88,7 +89,7 @@ const templateRE = /\${(.*?)}/g;
88
89
  * @returns {string}
89
90
  */
90
91
  const stringAssign = (template, data) => {
91
- return template.replace(templateRE, (origin, expression) => ev(expression, data));
92
+ return template.replace(templateRE, (origin, expression) => ev(expression, data));
92
93
  };
93
94
  /**
94
95
  * 字符串编码 HTML
@@ -100,18 +101,18 @@ const stringAssign = (template, data) => {
100
101
  * @param {string} html
101
102
  * @returns {string}
102
103
  */
103
- const stringEscapeHtml = (html) => {
104
- const htmlCharRE = /[&<>"]/g;
105
- const htmlCharReplacements = {
106
- '&': '&amp;',
107
- '<': '&lt;',
108
- '>': '&gt;',
109
- '"': '&quot;'
110
- };
111
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
112
- // @ts-ignore
113
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
114
- return html.replace(htmlCharRE, $0 => htmlCharReplacements[$0]);
104
+ const stringEscapeHtml = html => {
105
+ const htmlCharRE = /[&<>"]/g;
106
+ const htmlCharReplacements = {
107
+ '&': '&amp;',
108
+ '<': '&lt;',
109
+ '>': '&gt;',
110
+ '"': '&quot;'
111
+ };
112
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
113
+ // @ts-ignore
114
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
115
+ return html.replace(htmlCharRE, $0 => htmlCharReplacements[$0]);
115
116
  };
116
117
  /**
117
118
  * 字符串填充
@@ -126,19 +127,28 @@ const stringFill = (length, value = ' ') => new Array(length).fill(value).join('
126
127
  * @returns {Record<string, string | string[]>}
127
128
  */
128
129
  function parseQueryParams(searchStr = location.search) {
129
- const queryObj = {};
130
- Array.from(searchStr.matchAll(/[&?]?([^=&]+)=?([^=&]*)/g)).forEach((item, i) => {
131
- if (!queryObj[item[1]]) {
132
- queryObj[item[1]] = item[2];
133
- }
134
- else if (typeof queryObj[item[1]] === 'string') {
135
- queryObj[item[1]] = [queryObj[item[1]], item[2]];
136
- }
137
- else {
138
- queryObj[item[1]].push(item[2]);
139
- }
140
- });
141
- return queryObj;
130
+ const queryObj = {};
131
+ Array.from(searchStr.matchAll(/[&?]?([^=&]+)=?([^=&]*)/g)).forEach((item, i) => {
132
+ if (!queryObj[item[1]]) {
133
+ queryObj[item[1]] = item[2];
134
+ } else if (typeof queryObj[item[1]] === 'string') {
135
+ queryObj[item[1]] = [queryObj[item[1]], item[2]];
136
+ } else {
137
+ queryObj[item[1]].push(item[2]);
138
+ }
139
+ });
140
+ return queryObj;
142
141
  }
143
142
 
144
- export { STRING_ARABIC_NUMERALS, STRING_LOWERCASE_ALPHA, STRING_UPPERCASE_ALPHA, parseQueryParams, stringAssign, stringCamelCase, stringEscapeHtml, stringFill, stringFormat, stringKebabCase };
143
+ export {
144
+ STRING_ARABIC_NUMERALS,
145
+ STRING_LOWERCASE_ALPHA,
146
+ STRING_UPPERCASE_ALPHA,
147
+ parseQueryParams,
148
+ stringAssign,
149
+ stringCamelCase,
150
+ stringEscapeHtml,
151
+ stringFill,
152
+ stringFormat,
153
+ stringKebabCase
154
+ };
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.13.3-beta.0
2
+ * sculp-js v1.13.6
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -24,19 +24,19 @@ import { isString } from './type.js';
24
24
  * @returns {*}
25
25
  */
26
26
  function handleMouseEnter({ rootContainer = '#root', title, event, bgColor = '#000', color = '#fff' }) {
27
- try {
28
- const $rootEl = isString(rootContainer) ? document.querySelector(rootContainer) : rootContainer;
29
- if (!$rootEl) {
30
- throw new Error(`${rootContainer} is not valid Html Element or element selector`);
31
- }
32
- let $customTitle = null;
33
- const styleId = 'style-tooltip-inner1494304949567';
34
- // 动态创建class样式,并加入到head中
35
- if (!document.querySelector(`#${styleId}`)) {
36
- const tooltipWrapperClass = document.createElement('style');
37
- tooltipWrapperClass.type = 'text/css';
38
- tooltipWrapperClass.id = styleId;
39
- tooltipWrapperClass.innerHTML = `
27
+ try {
28
+ const $rootEl = isString(rootContainer) ? document.querySelector(rootContainer) : rootContainer;
29
+ if (!$rootEl) {
30
+ throw new Error(`${rootContainer} is not valid Html Element or element selector`);
31
+ }
32
+ let $customTitle = null;
33
+ const styleId = 'style-tooltip-inner1494304949567';
34
+ // 动态创建class样式,并加入到head中
35
+ if (!document.querySelector(`#${styleId}`)) {
36
+ const tooltipWrapperClass = document.createElement('style');
37
+ tooltipWrapperClass.type = 'text/css';
38
+ tooltipWrapperClass.id = styleId;
39
+ tooltipWrapperClass.innerHTML = `
40
40
  .tooltip-inner1494304949567 {
41
41
  max-width: 250px;
42
42
  padding: 3px 8px;
@@ -47,30 +47,28 @@ function handleMouseEnter({ rootContainer = '#root', title, event, bgColor = '#0
47
47
  background-color: ${bgColor};
48
48
  }
49
49
  `;
50
- document.querySelector('head').appendChild(tooltipWrapperClass);
51
- }
52
- $customTitle = document.querySelector('#customTitle1494304949567');
53
- if ($customTitle) {
54
- mouseenter($customTitle, title, event);
55
- }
56
- else {
57
- const $contentContainer = document.createElement('div');
58
- $contentContainer.id = 'customTitle1494304949567';
59
- $contentContainer.style.cssText = 'z-index: 99999999; visibility: hidden; position: absolute;';
60
- $contentContainer.innerHTML =
61
- '<div class="tooltip-inner1494304949567" style="word-wrap: break-word; max-width: 44px;">皮肤</div>';
62
- $rootEl.appendChild($contentContainer);
63
- $customTitle = document.querySelector('#customTitle1494304949567');
64
- if (title) {
65
- //判断div显示的内容是否为空
66
- mouseenter($customTitle, title, event);
67
- $customTitle.style.visibility = 'visible';
68
- }
69
- }
50
+ document.querySelector('head').appendChild(tooltipWrapperClass);
70
51
  }
71
- catch (e) {
72
- console.error(e.message);
52
+ $customTitle = document.querySelector('#customTitle1494304949567');
53
+ if ($customTitle) {
54
+ mouseenter($customTitle, title, event);
55
+ } else {
56
+ const $contentContainer = document.createElement('div');
57
+ $contentContainer.id = 'customTitle1494304949567';
58
+ $contentContainer.style.cssText = 'z-index: 99999999; visibility: hidden; position: absolute;';
59
+ $contentContainer.innerHTML =
60
+ '<div class="tooltip-inner1494304949567" style="word-wrap: break-word; max-width: 44px;">皮肤</div>';
61
+ $rootEl.appendChild($contentContainer);
62
+ $customTitle = document.querySelector('#customTitle1494304949567');
63
+ if (title) {
64
+ //判断div显示的内容是否为空
65
+ mouseenter($customTitle, title, event);
66
+ $customTitle.style.visibility = 'visible';
67
+ }
73
68
  }
69
+ } catch (e) {
70
+ console.error(e.message);
71
+ }
74
72
  }
75
73
  /**
76
74
  * 提示文案dom渲染的处理函数
@@ -80,32 +78,31 @@ function handleMouseEnter({ rootContainer = '#root', title, event, bgColor = '#0
80
78
  * @returns {*}
81
79
  */
82
80
  function mouseenter($customTitle, title, e) {
83
- let diffValueX = 200 + 50; //默认设置弹出div的宽度为250px
84
- let x = 13;
85
- const y = 23;
86
- const $contentEle = $customTitle.children[0];
87
- if (getStrWidthPx(title, 12) < 180 + 50) {
88
- //【弹出div自适应字符串宽度】若显示的字符串占用宽度小于180,则设置弹出div的宽度为“符串占用宽度”+20
89
- $contentEle.style.maxWidth = getStrWidthPx(title, 12) + 20 + 50 + 'px';
90
- diffValueX = e.clientX + (getStrWidthPx(title, 12) + 50) - document.body.offsetWidth;
91
- }
92
- else {
93
- $contentEle.style.maxWidth = '250px';
94
- diffValueX = e.clientX + 230 - document.body.offsetWidth; //计算div水平方向显示的内容超出屏幕多少宽度
95
- }
96
- $contentEle.innerHTML = title; //html方法可解析内容中换行标签,text方法不能
97
- if (diffValueX > 0) {
98
- //水平方向超出可见区域时
99
- x -= diffValueX;
100
- }
101
- $customTitle.style.top = e.clientY + y + 'px';
102
- $customTitle.style.left = e.clientX + x + 'px';
103
- $customTitle.style.maxWidth = '250px';
104
- const diffValueY = $customTitle.getBoundingClientRect().top + $contentEle.offsetHeight - document.body.offsetHeight;
105
- if (diffValueY > 0) {
106
- //垂直方向超出可见区域时
107
- $customTitle.style.top = e.clientY - diffValueY + 'px';
108
- }
81
+ let diffValueX = 200 + 50; //默认设置弹出div的宽度为250px
82
+ let x = 13;
83
+ const y = 23;
84
+ const $contentEle = $customTitle.children[0];
85
+ if (getStrWidthPx(title, 12) < 180 + 50) {
86
+ //【弹出div自适应字符串宽度】若显示的字符串占用宽度小于180,则设置弹出div的宽度为“符串占用宽度”+20
87
+ $contentEle.style.maxWidth = getStrWidthPx(title, 12) + 20 + 50 + 'px';
88
+ diffValueX = e.clientX + (getStrWidthPx(title, 12) + 50) - document.body.offsetWidth;
89
+ } else {
90
+ $contentEle.style.maxWidth = '250px';
91
+ diffValueX = e.clientX + 230 - document.body.offsetWidth; //计算div水平方向显示的内容超出屏幕多少宽度
92
+ }
93
+ $contentEle.innerHTML = title; //html方法可解析内容中换行标签,text方法不能
94
+ if (diffValueX > 0) {
95
+ //水平方向超出可见区域时
96
+ x -= diffValueX;
97
+ }
98
+ $customTitle.style.top = e.clientY + y + 'px';
99
+ $customTitle.style.left = e.clientX + x + 'px';
100
+ $customTitle.style.maxWidth = '250px';
101
+ const diffValueY = $customTitle.getBoundingClientRect().top + $contentEle.offsetHeight - document.body.offsetHeight;
102
+ if (diffValueY > 0) {
103
+ //垂直方向超出可见区域时
104
+ $customTitle.style.top = e.clientY - diffValueY + 'px';
105
+ }
109
106
  }
110
107
  /**
111
108
  * 移除提示文案dom的事件句柄
@@ -113,13 +110,13 @@ function mouseenter($customTitle, title, e) {
113
110
  * @returns {*}
114
111
  */
115
112
  function handleMouseLeave(rootContainer = '#root') {
116
- const rootEl = isString(rootContainer) ? document.querySelector(rootContainer) : rootContainer;
117
- let titleEl = document.querySelector('#customTitle1494304949567');
118
- if (rootEl && titleEl) {
119
- rootEl.removeChild(titleEl);
120
- // @ts-ignore
121
- titleEl = null;
122
- }
113
+ const rootEl = isString(rootContainer) ? document.querySelector(rootContainer) : rootContainer;
114
+ let titleEl = document.querySelector('#customTitle1494304949567');
115
+ if (rootEl && titleEl) {
116
+ rootEl.removeChild(titleEl);
117
+ // @ts-ignore
118
+ titleEl = null;
119
+ }
123
120
  }
124
121
  const tooltipEvent = { handleMouseEnter, handleMouseLeave };
125
122