@kdcloudjs/kdesign 1.7.35 → 1.7.37

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 (88) hide show
  1. package/dist/kdesign-complete.less +185 -26
  2. package/dist/kdesign.css +228 -24
  3. package/dist/kdesign.css.map +1 -1
  4. package/dist/kdesign.js +565 -119
  5. package/dist/kdesign.js.map +1 -1
  6. package/dist/kdesign.min.css +3 -3
  7. package/dist/kdesign.min.js +5 -5
  8. package/dist/kdesign.min.js.map +1 -1
  9. package/es/city-picker/city-picker.js +1 -1
  10. package/es/clipboard/clipboard.d.ts +21 -0
  11. package/es/clipboard/clipboard.js +106 -0
  12. package/es/clipboard/index.d.ts +4 -0
  13. package/es/clipboard/index.js +3 -0
  14. package/es/clipboard/style/css.js +2 -0
  15. package/es/clipboard/style/index.css +190 -0
  16. package/es/clipboard/style/index.d.ts +2 -0
  17. package/es/clipboard/style/index.js +2 -0
  18. package/es/clipboard/style/index.less +32 -0
  19. package/es/clipboard/style/mixin.less +39 -0
  20. package/es/clipboard/style/token.less +52 -0
  21. package/es/clipboard/util.d.ts +13 -0
  22. package/es/clipboard/util.js +197 -0
  23. package/es/config-provider/compDefaultProps.d.ts +5 -0
  24. package/es/config-provider/compDefaultProps.js +5 -0
  25. package/es/index.d.ts +1 -0
  26. package/es/index.js +2 -1
  27. package/es/message/content.js +1 -4
  28. package/es/select/interface.d.ts +1 -0
  29. package/es/select/select.js +3 -8
  30. package/es/select/style/index.css +7 -4
  31. package/es/select/style/index.less +12 -4
  32. package/es/select/style/token.less +1 -0
  33. package/es/tree/style/index.css +22 -15
  34. package/es/tree/style/index.less +33 -18
  35. package/es/tree/tree.d.ts +1 -0
  36. package/es/tree/tree.js +29 -13
  37. package/es/tree/treeHooks.d.ts +2 -2
  38. package/es/tree/treeHooks.js +11 -6
  39. package/es/tree/treeNode.d.ts +2 -3
  40. package/es/tree/treeNode.js +6 -5
  41. package/es/tree/utils/treeUtils.d.ts +2 -2
  42. package/es/tree/utils/treeUtils.js +5 -6
  43. package/es/tree-select/interface.d.ts +1 -0
  44. package/es/tree-select/style/index.css +7 -4
  45. package/es/tree-select/style/index.less +12 -4
  46. package/es/tree-select/style/token.less +1 -0
  47. package/es/tree-select/tree-select.js +6 -2
  48. package/lib/city-picker/city-picker.js +1 -1
  49. package/lib/clipboard/clipboard.d.ts +21 -0
  50. package/lib/clipboard/clipboard.js +121 -0
  51. package/lib/clipboard/index.d.ts +4 -0
  52. package/lib/clipboard/index.js +11 -0
  53. package/lib/clipboard/style/css.js +4 -0
  54. package/lib/clipboard/style/index.css +190 -0
  55. package/lib/clipboard/style/index.d.ts +2 -0
  56. package/lib/clipboard/style/index.js +4 -0
  57. package/lib/clipboard/style/index.less +32 -0
  58. package/lib/clipboard/style/mixin.less +39 -0
  59. package/lib/clipboard/style/token.less +52 -0
  60. package/lib/clipboard/util.d.ts +13 -0
  61. package/lib/clipboard/util.js +204 -0
  62. package/lib/config-provider/compDefaultProps.d.ts +5 -0
  63. package/lib/config-provider/compDefaultProps.js +5 -0
  64. package/lib/index.d.ts +1 -0
  65. package/lib/index.js +7 -0
  66. package/lib/message/content.js +1 -4
  67. package/lib/select/interface.d.ts +1 -0
  68. package/lib/select/select.js +3 -8
  69. package/lib/select/style/index.css +7 -4
  70. package/lib/select/style/index.less +12 -4
  71. package/lib/select/style/token.less +1 -0
  72. package/lib/style/components.less +1 -0
  73. package/lib/tree/style/index.css +22 -15
  74. package/lib/tree/style/index.less +33 -18
  75. package/lib/tree/tree.d.ts +1 -0
  76. package/lib/tree/tree.js +28 -12
  77. package/lib/tree/treeHooks.d.ts +2 -2
  78. package/lib/tree/treeHooks.js +10 -5
  79. package/lib/tree/treeNode.d.ts +2 -3
  80. package/lib/tree/treeNode.js +6 -5
  81. package/lib/tree/utils/treeUtils.d.ts +2 -2
  82. package/lib/tree/utils/treeUtils.js +5 -6
  83. package/lib/tree-select/interface.d.ts +1 -0
  84. package/lib/tree-select/style/index.css +7 -4
  85. package/lib/tree-select/style/index.less +12 -4
  86. package/lib/tree-select/style/token.less +1 -0
  87. package/lib/tree-select/tree-select.js +6 -2
  88. package/package.json +1 -1
@@ -0,0 +1,190 @@
1
+ /* ----------- color ——————---- start */
2
+ /* ----------- color ——————---- end */
3
+ /* ----------- motion ——————---- start */
4
+ /* ----------- motion ——————---- end */
5
+ /* ----------- transition ——————---- start */
6
+ /* ----------- transition ——————---- end */
7
+ /* ----------- font ——————---- start */
8
+ /* ----------- font ——————---- end */
9
+ /* ----------- zIndex ——————---- start */
10
+ /*
11
+ 普通组件内部自身层级应设置在0-100间
12
+ */
13
+ /* ----------- zIndex ——————---- end */
14
+ /* ----------- Button ——————---- start */
15
+ /* ----------- Button ——————---- end */
16
+ /* ----------- Collapse ——————---- start */
17
+ /* ----------- Collapse ——————---- end */
18
+ /* ----------- Card ——————---- start */
19
+ /* ----------- Card ——————---- end */
20
+ /* ----------- Carousel ——————---- start */
21
+ /* ----------- Carousel ——————---- end */
22
+ /* ----------- Cascader ——————---- start */
23
+ /* ----------- Cascader ——————---- end */
24
+ /* ----------- Switch ——————---- start */
25
+ /* ----------- Switch ——————---- end */
26
+ /* ----------- Input ——————---- start */
27
+ /* ----------- Input ——————---- end */
28
+ /* ----------- InputNumber ——————---- start */
29
+ /* ----------- InputNumber ——————---- end */
30
+ /* ----------- checkbox ——————---- start */
31
+ /* ----------- checkbox ——————---- start */
32
+ /* ----------- checkbox ——————---- end */
33
+ /* ----------- Radio ——————---- start */
34
+ /* ----------- Radio ——————---- end */
35
+ /* ----------- icon ——————---- start */
36
+ /* ----------- icon ——————---- end */
37
+ /* ----------- Popconfirm ——————---- start */
38
+ /* ----------- Popconfirm ——————---- end */
39
+ /* ----------- Progress ——————---- start */
40
+ /* ----------- Progress ——————---- end */
41
+ /* ----------- Pagination ——————---- start */
42
+ /* ----------- Pagination ——————---- end */
43
+ /* ----------- Timeline ——————---- start */
44
+ /* ----------- Timeline ——————---- end */
45
+ /* ----------- Tabs ——————---- start */
46
+ /* ----------- Tabs ——————---- end */
47
+ /* ----------- Select ——————---- start */
48
+ /* ----------- Select ——————---- end */
49
+ /* ----------- Rate ——————---- start */
50
+ /* ----------- Rate ——————---- end */
51
+ /* ----------- Dropdown ——————---- start */
52
+ /* ----------- Dropdown ——————---- end */
53
+ /* ----------- Tooltip ——————---- start */
54
+ /* ----------- Tooltip ——————---- end */
55
+ /* ----------- Transfer ——————---- start */
56
+ /* ----------- Transfer ——————---- end */
57
+ /* ----------- DatePicker ——————---- start */
58
+ /* ----------- DatePicker ——————---- end */
59
+ /* ----------- ColorPicker ——————---- start */
60
+ /* ----------- ColorPicker ——————---- end */
61
+ /* ----------- Tree ——————---- start */
62
+ /* ----------- Tree ——————---- end */
63
+ /* ----------- Alert ——————---- start */
64
+ /* ----------- Alert ——————---- end */
65
+ /* ----------- Split-Panel ——————---- start */
66
+ /* ----------- Split-Panel ——————---- end */
67
+ /* ----------- Modal ——————---- start */
68
+ /* ----------- Modal ——————---- end */
69
+ /* ----------- Steps ——————---- start */
70
+ /* ----------- Steps ——————---- end */
71
+ /* ----------- Form ——————---- start */
72
+ /* ----------- Form ——————---- end */
73
+ /* ----------- Tag ——————---- start */
74
+ /* ----------- Tag ——————---- end */
75
+ /* ----------- Menu ——————---- start */
76
+ /* ----------- Menu ——————---- end */
77
+ /* ----------- notice ——————---- start */
78
+ /* ----------- message ——————---- end */
79
+ /* ----------- Spin ——————---- start */
80
+ /* ----------- Spin ——————---- end */
81
+ /* ----------- Spin ——————---- start */
82
+ /* ----------- Spin ——————---- end */
83
+ /* ----------- Layout ——————---- start */
84
+ /* ----------- Layout ——————---- end */
85
+ /* ----------- Typography ——————---- start */
86
+ /* ----------- Typography ——————---- start */
87
+ /* ----------- Search ——————---- start */
88
+ /* ----------- Search ——————---- start */
89
+ /* ----------- Badge ——————---- start */
90
+ /* ----------- Badge ——————---- end */
91
+ /* ----------- Anchor ——————---- start */
92
+ /* ----------- Anchor ——————---- end */
93
+ /* ----------- Avatar ——————---- start */
94
+ /* ----------- Avatar ——————---- end */
95
+ /* ----------- AdvancedSelector ——————---- start */
96
+ /* ----------- AdvancedSelector ——————---- end */
97
+ /* ----------- motion ——————---- start */
98
+ /* ----------- motion ——————---- end */
99
+ /* ----------- transition ——————---- start */
100
+ /* ----------- transition ——————---- end */
101
+ /* ----------- zIndex ——————---- start */
102
+ /*
103
+ 普通组件内部自身层级应设置在0-100间
104
+ */
105
+ /* ----------- zIndex ——————---- end */
106
+ .kd-clipboard {
107
+ padding: 0;
108
+ position: relative;
109
+ display: inline-block;
110
+ vertical-align: middle;
111
+ -webkit-box-sizing: border-box;
112
+ box-sizing: border-box;
113
+ font-weight: var(--kd-c-clipboard-font-weight, var(--kd-g-font-weight, 400));
114
+ color: #bbbbbb;
115
+ cursor: pointer;
116
+ white-space: nowrap;
117
+ overflow: hidden;
118
+ -webkit-user-select: none;
119
+ -moz-user-select: none;
120
+ -ms-user-select: none;
121
+ user-select: none;
122
+ }
123
+ .kd-clipboard:hover {
124
+ color: #5582f3;
125
+ }
126
+ .kd-clipboard:disabled,
127
+ .kd-clipboard[disabled] {
128
+ color: #bbbbbb;
129
+ cursor: not-allowed;
130
+ }
131
+ .kd-clipboard-size-small {
132
+ height: var(--kd-c-clipboard-sizing-height-small, 24px);
133
+ padding: var(--kd-c-clipboard-spacing-padding-vertical-small, 3px) var(--kd-c-clipboard-spacing-padding-horizontal-small, 8px);
134
+ font-size: var(--kd-c-clipboard-font-size-small, var(--kd-g-font-size-small, 12px));
135
+ line-height: calc(var(--kd-c-clipboard-sizing-height-small, 24px) - (var(--kd-c-clipboard-spacing-padding-vertical-small, 3px)) * 2);
136
+ }
137
+ .kd-clipboard-size-small.kd-clipboard-icon-only {
138
+ font-size: var(--kd-c-clipboard-icon-font-size-small, 14px);
139
+ padding: 0 var(--kd-c-clipboard-icon-spacing-padding-horizontal, 4px);
140
+ display: -webkit-inline-box;
141
+ display: -ms-inline-flexbox;
142
+ display: inline-flex;
143
+ -webkit-box-pack: center;
144
+ -ms-flex-pack: center;
145
+ justify-content: center;
146
+ -webkit-box-align: center;
147
+ -ms-flex-align: center;
148
+ align-items: center;
149
+ }
150
+ .kd-clipboard-size-middle {
151
+ height: var(--kd-c-clipboard-sizing-height-middle, 28px);
152
+ padding: var(--kd-c-clipboard-spacing-padding-vertical-middle, 5px) var(--kd-c-clipboard-spacing-padding-horizontal-middle, 8px);
153
+ font-size: var(--kd-c-clipboard-font-size-middle, var(--kd-g-font-size-middle, 14px));
154
+ line-height: calc(var(--kd-c-clipboard-sizing-height-middle, 28px) - (var(--kd-c-clipboard-spacing-padding-vertical-middle, 5px)) * 2);
155
+ }
156
+ .kd-clipboard-size-middle.kd-clipboard-icon-only {
157
+ font-size: var(--kd-c-clipboard-icon-font-size-middle, 16px);
158
+ padding: 0 var(--kd-c-clipboard-icon-spacing-padding-horizontal, 4px);
159
+ display: -webkit-inline-box;
160
+ display: -ms-inline-flexbox;
161
+ display: inline-flex;
162
+ -webkit-box-pack: center;
163
+ -ms-flex-pack: center;
164
+ justify-content: center;
165
+ -webkit-box-align: center;
166
+ -ms-flex-align: center;
167
+ align-items: center;
168
+ }
169
+ .kd-clipboard-size-large {
170
+ height: var(--kd-c-clipboard-sizing-height-large, 32px);
171
+ padding: var(--kd-c-clipboard-spacing-padding-vertical-large, 6px) var(--kd-c-clipboard-spacing-padding-horizontal-large, 8px);
172
+ font-size: var(--kd-c-clipboard-font-size-large, var(--kd-g-font-size-large, 16px));
173
+ line-height: calc(var(--kd-c-clipboard-sizing-height-large, 32px) - (var(--kd-c-clipboard-spacing-padding-vertical-large, 6px)) * 2);
174
+ }
175
+ .kd-clipboard-size-large.kd-clipboard-icon-only {
176
+ font-size: var(--kd-c-clipboard-icon-font-size-large, 18px);
177
+ padding: 0 var(--kd-c-clipboard-icon-spacing-padding-horizontal, 4px);
178
+ display: -webkit-inline-box;
179
+ display: -ms-inline-flexbox;
180
+ display: inline-flex;
181
+ -webkit-box-pack: center;
182
+ -ms-flex-pack: center;
183
+ justify-content: center;
184
+ -webkit-box-align: center;
185
+ -ms-flex-align: center;
186
+ align-items: center;
187
+ }
188
+ .kd-clipboard:not(.kd-clipboard-icon-only) > i:not(:last-child) {
189
+ margin-right: 2px;
190
+ }
@@ -0,0 +1,2 @@
1
+ import '../../style/index.less';
2
+ import './index.less';
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ require("../../style/index.less");
4
+ require("./index.less");
@@ -0,0 +1,32 @@
1
+ @import '../../style/themes/index';
2
+ @import './mixin.less';
3
+ @clipboard-prefix-cls: ~'@{kd-prefix}-clipboard';
4
+
5
+ .@{clipboard-prefix-cls} {
6
+ .clipboard;
7
+
8
+ &-size-small {
9
+ .clipboard-size(@clipboard-small-height, @clipboard-small-font-size, @clipboard-small-padding-vertical, @clipboard-small-padding-horizontal);
10
+ &.@{clipboard-prefix-cls}-icon-only {
11
+ .clipboard-icon-only(@clipboard-icon-small-font-size, @clipboard-icon-padding-horizontal);
12
+ }
13
+ }
14
+
15
+ &-size-middle {
16
+ .clipboard-size(@clipboard-middle-height, @clipboard-middle-font-size, @clipboard-middle-padding-vertical, @clipboard-middle-padding-horizontal);
17
+ &.@{clipboard-prefix-cls}-icon-only {
18
+ .clipboard-icon-only(@clipboard-icon-middle-font-size, @clipboard-icon-padding-horizontal);
19
+ }
20
+ }
21
+
22
+ &-size-large {
23
+ .clipboard-size(@clipboard-large-height, @clipboard-large-font-size, @clipboard-large-padding-vertical, @clipboard-large-padding-horizontal);
24
+ &.@{clipboard-prefix-cls}-icon-only {
25
+ .clipboard-icon-only(@clipboard-icon-large-font-size, @clipboard-icon-padding-horizontal);
26
+ }
27
+ }
28
+
29
+ &:not(.@{clipboard-prefix-cls}-icon-only) > i:not(:last-child) {
30
+ margin-right: 2px;
31
+ }
32
+ }
@@ -0,0 +1,39 @@
1
+ @import './token.less';
2
+
3
+ .clipboard() {
4
+ padding: 0;
5
+ position: relative;
6
+ display: inline-block;
7
+ vertical-align: middle;
8
+ box-sizing: border-box;
9
+ font-weight: @clipboard-g-font-weight;
10
+ color: #bbbbbb;
11
+ cursor: pointer;
12
+ white-space: nowrap;
13
+ overflow: hidden;
14
+ user-select: none;
15
+
16
+ &:hover {
17
+ color: #5582f3;
18
+ }
19
+ &:disabled,
20
+ &[disabled] {
21
+ color: #bbbbbb;
22
+ cursor: not-allowed;
23
+ }
24
+ }
25
+
26
+ .clipboard-size(@height, @font-size, @padding-vertical, @padding-horizontal) {
27
+ height: @height;
28
+ padding: @padding-vertical @padding-horizontal;
29
+ font-size: @font-size;
30
+ line-height: calc(@height - (@padding-vertical) * 2);
31
+ }
32
+
33
+ .clipboard-icon-only(@font-size, @padding-horizontal) {
34
+ font-size: @font-size;
35
+ padding: 0 @padding-horizontal;
36
+ display: inline-flex;
37
+ justify-content: center;
38
+ align-items: center;
39
+ }
@@ -0,0 +1,52 @@
1
+ @import '../../style/themes/token.less';
2
+
3
+ @clipboard-custom-prefix: ~'--@{kd-prefix}-c-clipboard';
4
+
5
+ // color
6
+ @clipboard-font-color: var(~'@{clipboard-custom-prefix}-color-text', @color-theme); // color-theme为全局token
7
+
8
+ // font
9
+ @clipboard-g-font-weight: var(~'@{clipboard-custom-prefix}-font-weight', @font-weight-light); // 字体粗细
10
+ @clipboard-small-font-size: var(~'@{clipboard-custom-prefix}-font-size-small', @font-size-small); // 小号 文字大小
11
+ @clipboard-middle-font-size: var(~'@{clipboard-custom-prefix}-font-size-middle', @font-size-middle); // 中号 文字大小
12
+ @clipboard-large-font-size: var(~'@{clipboard-custom-prefix}-font-size-large', @font-size-large); // 大号 文字大小
13
+
14
+ @clipboard-icon-small-font-size: var(~'@{clipboard-custom-prefix}-icon-font-size-small', 14px); // 小号 图标大小
15
+ @clipboard-icon-middle-font-size: var(~'@{clipboard-custom-prefix}-icon-font-size-middle', 16px); // 中号 图标大小
16
+ @clipboard-icon-large-font-size: var(~'@{clipboard-custom-prefix}-icon-font-size-large', 18px); // 大号 图标大小
17
+
18
+ // motion
19
+ @clipboard-duration-fade: var(~'@{clipboard-custom-prefix}-motion-duration-fade', @duration-slowly);
20
+ @clipboard-duration-wave: var(~'@{clipboard-custom-prefix}-motion-duration-wave', @duration-quickly);
21
+
22
+ // sizing
23
+ @clipboard-small-height: var(~'@{clipboard-custom-prefix}-sizing-height-small', 24px); // 小号 高度
24
+ @clipboard-middle-height: var(~'@{clipboard-custom-prefix}-sizing-height-middle', 28px); // 中号 高度
25
+ @clipboard-large-height: var(~'@{clipboard-custom-prefix}-sizing-height-large', 32px); // 大号 高度
26
+
27
+ // spacing
28
+ @clipboard-small-padding-vertical: var(
29
+ ~'@{clipboard-custom-prefix}-spacing-padding-vertical-small',
30
+ 3px
31
+ ); // 小号 内间距 纵向
32
+ @clipboard-small-padding-horizontal: var(
33
+ ~'@{clipboard-custom-prefix}-spacing-padding-horizontal-small',
34
+ 8px
35
+ ); // 小号 内间距 横向
36
+ @clipboard-middle-padding-vertical: var(
37
+ ~'@{clipboard-custom-prefix}-spacing-padding-vertical-middle',
38
+ 5px
39
+ ); // 中号 内间距 纵向
40
+ @clipboard-middle-padding-horizontal: var(
41
+ ~'@{clipboard-custom-prefix}-spacing-padding-horizontal-middle',
42
+ 8px
43
+ ); // 中号 内间距 横向
44
+ @clipboard-large-padding-vertical: var(
45
+ ~'@{clipboard-custom-prefix}-spacing-padding-vertical-large',
46
+ 6px
47
+ ); // 大号 内间距 纵向
48
+ @clipboard-large-padding-horizontal: var(
49
+ ~'@{clipboard-custom-prefix}-spacing-padding-horizontal-large',
50
+ 8px
51
+ ); // 大号 内间距 横向
52
+ @clipboard-icon-padding-horizontal: var(~'@{clipboard-custom-prefix}-icon-spacing-padding-horizontal', 4px);
@@ -0,0 +1,13 @@
1
+ /**
2
+ * 剪贴板复制操作
3
+ * @param {string | HTMLElement} target
4
+ * @return {string}
5
+ */
6
+ declare const onClipboardCopy: (target: string | HTMLElement) => string;
7
+ /**
8
+ * 剪贴板剪切操作
9
+ * @param {HTMLElement} target
10
+ * @return {string}
11
+ */
12
+ declare const onClipboardCut: (target: HTMLElement) => string;
13
+ export { onClipboardCopy, onClipboardCut };
@@ -0,0 +1,204 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.onClipboardCut = exports.onClipboardCopy = void 0;
7
+ /**
8
+ * 获取元素的内容
9
+ * @param {HTMLElement} element
10
+ * @return {string}
11
+ */
12
+ var getContent = function getContent(element) {
13
+ var content;
14
+ if (element.nodeName === 'SELECT') {
15
+ content = element.value;
16
+ } else if (element.nodeName === 'INPUT') {
17
+ content = element.value;
18
+ } else if (element.nodeName === 'TEXTAREA') {
19
+ content = element.value;
20
+ } else {
21
+ // 其他类型通过 select 与 range 来获取文本
22
+ // 获取 select
23
+ var selection = window.getSelection();
24
+ // 创建 range
25
+ var range = document.createRange();
26
+ // 设置 range 的元素
27
+ range.selectNodeContents(element);
28
+ // 重置 select
29
+ selection.removeAllRanges();
30
+ // 设置 select 的 range
31
+ selection.addRange(range);
32
+ // 获取选中的文本
33
+ content = selection.toString();
34
+ // 获取到文本后清空选中范围
35
+ selection.removeAllRanges();
36
+ }
37
+ return content;
38
+ };
39
+ /**
40
+ * 清空元素的内容
41
+ * @param {HTMLElement} element
42
+ */
43
+ var clearElement = function clearElement(element) {
44
+ if (element.nodeName === 'SELECT') {
45
+ ;
46
+ element.value = '';
47
+ } else if (element.nodeName === 'INPUT') {
48
+ ;
49
+ element.value = '';
50
+ } else if (element.nodeName === 'TEXTAREA') {
51
+ ;
52
+ element.value = '';
53
+ } else {
54
+ element.innerHTML = '';
55
+ }
56
+ };
57
+ /**
58
+ * 由将被复制的文本为 value 创建一个 HTMLTextAreaElement 容器
59
+ * @param {String} value
60
+ * @return {HTMLTextAreaElement}
61
+ */
62
+ var createContainer = function createContainer(value) {
63
+ var isRTL = document.documentElement.getAttribute('dir') === 'rtl';
64
+ var container = document.createElement('textarea');
65
+ // 防止在 ios 上缩放
66
+ container.style.fontSize = '12pt';
67
+ // 重置样式
68
+ container.style.border = '0';
69
+ container.style.padding = '0';
70
+ container.style.margin = '0';
71
+ // 把元素定位在视窗外
72
+ container.style.position = 'absolute';
73
+ container.style[isRTL ? 'right' : 'left'] = '-9999px';
74
+ var yPosition = window.pageYOffset || document.documentElement.scrollTop;
75
+ container.style.top = "".concat(yPosition, "px");
76
+ // 设置为只读
77
+ container.setAttribute('readonly', '');
78
+ // 将文本赋值给元素
79
+ container.value = value;
80
+ document.body.appendChild(container);
81
+ return container;
82
+ };
83
+ /**
84
+ * 删除元素
85
+ * @param {HTMLElement} container
86
+ */
87
+ var removeContainer = function removeContainer(container) {
88
+ document.body.removeChild(container);
89
+ };
90
+ /**
91
+ * 添加选中状态
92
+ * @param {HTMLElement} element
93
+ */
94
+ var addSelection = function addSelection(element) {
95
+ // 在 Firefox, Edge (非 Chromium 版本) 及 Internet Explorer 中,getSelection() 对 <textarea> 及 <input> 元素不起作用
96
+ // 使用 select 对 <textarea> 及 <input> 单独处理
97
+ if (element.nodeName === 'INPUT') {
98
+ ;
99
+ element.select();
100
+ } else if (element.nodeName === 'TEXTAREA') {
101
+ ;
102
+ element.select();
103
+ } else {
104
+ var selection = window.getSelection();
105
+ var range = document.createRange();
106
+ range.selectNodeContents(element);
107
+ selection.removeAllRanges();
108
+ selection.addRange(range);
109
+ }
110
+ };
111
+ /**
112
+ * 移除选中状态
113
+ * @param {HTMLElement} element
114
+ */
115
+ var removeSelection = function removeSelection(element) {
116
+ var _a;
117
+ // 在 Firefox, Edge (非 Chromium 版本) 及 Internet Explorer 中,getSelection() 对 <textarea> 及 <input> 元素不起作用
118
+ // 使用 setSelectRange 对 <textarea> 及 <input> 单独处理
119
+ if (element.nodeName === 'INPUT') {
120
+ ;
121
+ element.setSelectionRange(0, 0);
122
+ } else if (element.nodeName === 'TEXTAREA') {
123
+ ;
124
+ element.setSelectionRange(0, 0);
125
+ } else {
126
+ (_a = window.getSelection()) === null || _a === void 0 ? void 0 : _a.removeAllRanges();
127
+ }
128
+ };
129
+ /**
130
+ * 剪贴板复制操作
131
+ * @param {string | HTMLElement} target
132
+ * @return {string}
133
+ */
134
+ var onClipboardCopy = function onClipboardCopy(target) {
135
+ var copiedValue;
136
+ if (typeof target === 'string') {
137
+ // 如果传的是字符串,直接复制值
138
+ copiedValue = target;
139
+ if (navigator.clipboard) {
140
+ // navigator.clipboard api 存在时,优先使用其进行复制操作
141
+ if (copiedValue !== '') {
142
+ navigator.clipboard.writeText(copiedValue).then(null, function () {
143
+ throw new Error("failed to copy to clipboard of value '".concat(copiedValue, "'"));
144
+ });
145
+ }
146
+ } else {
147
+ var container = createContainer(copiedValue);
148
+ addSelection(container);
149
+ document.execCommand('copy');
150
+ removeSelection(container);
151
+ removeContainer(container);
152
+ }
153
+ } else {
154
+ // 通过元素来复制
155
+ copiedValue = getContent(target);
156
+ if (navigator.clipboard) {
157
+ if (copiedValue !== '') {
158
+ navigator.clipboard.writeText(copiedValue).then(null, function () {
159
+ throw new Error("failed to copy to clipboard of value '".concat(copiedValue, "'"));
160
+ });
161
+ }
162
+ } else {
163
+ addSelection(target);
164
+ document.execCommand('copy');
165
+ removeSelection(target);
166
+ }
167
+ }
168
+ return copiedValue;
169
+ };
170
+ /**
171
+ * 剪贴板剪切操作
172
+ * @param {HTMLElement} target
173
+ * @return {string}
174
+ */
175
+ exports.onClipboardCopy = onClipboardCopy;
176
+ var onClipboardCut = function onClipboardCut(target) {
177
+ var cutValue = getContent(target);
178
+ if (target.nodeName === 'SELECT' || target.nodeName === 'INPUT' || target.nodeName === 'TEXTAREA') {
179
+ // 对于输入框,使用 document.execCommand('cut') 来剪切,防止受控的输入框无法清空内容
180
+ if (document.execCommand) {
181
+ addSelection(target);
182
+ document.execCommand('cut');
183
+ removeSelection(target);
184
+ } else {
185
+ // document.execCommand 命令不兼容,则抛出异常,因为受控的输入框无法清空元素内容
186
+ throw new Error("failed to cut to clipboard through unavailable api \"document.execCommand\"");
187
+ }
188
+ } else {
189
+ // 对于其他标签的元素,使用 navigator 写入剪贴板,并手动清空内容,防止其他标签无法清空内容
190
+ if (navigator.clipboard) {
191
+ if (cutValue !== '') {
192
+ navigator.clipboard.writeText(cutValue).then(null, function () {
193
+ throw new Error("failed to cut to clipboard of value '".concat(cutValue, "'"));
194
+ });
195
+ }
196
+ clearElement(target);
197
+ } else {
198
+ // navigator.clipboard 命令不兼容,则抛出异常,因为非输入框无法适用 document.execCommand('cut')
199
+ throw new Error("failed to cut to clipboard through unavailable api \"navigator.clipboard\"");
200
+ }
201
+ }
202
+ return cutValue;
203
+ };
204
+ exports.onClipboardCut = onClipboardCut;
@@ -462,5 +462,10 @@ declare const compDefaultProps: {
462
462
  optionHighlightProps: string;
463
463
  allowClear: boolean;
464
464
  };
465
+ Clipboard: {
466
+ action: string;
467
+ disabled: boolean;
468
+ size: string;
469
+ };
465
470
  };
466
471
  export default compDefaultProps;
@@ -490,6 +490,11 @@ var compDefaultProps = {
490
490
  showDescription: true,
491
491
  optionHighlightProps: 'highlightText',
492
492
  allowClear: true
493
+ },
494
+ Clipboard: {
495
+ action: 'copy',
496
+ disabled: false,
497
+ size: 'middle'
493
498
  }
494
499
  };
495
500
  var _default = compDefaultProps;
package/lib/index.d.ts CHANGED
@@ -55,3 +55,4 @@ export { default as BaseData } from './base-data';
55
55
  export { default as Link } from './link';
56
56
  export { default as TreeSelect } from './tree-select';
57
57
  export { default as ColorPicker } from './color-picker';
58
+ export { default as Clipboard } from './clipboard';
package/lib/index.js CHANGED
@@ -73,6 +73,12 @@ Object.defineProperty(exports, "CityPicker", {
73
73
  return _cityPicker.default;
74
74
  }
75
75
  });
76
+ Object.defineProperty(exports, "Clipboard", {
77
+ enumerable: true,
78
+ get: function get() {
79
+ return _clipboard.default;
80
+ }
81
+ });
76
82
  Object.defineProperty(exports, "Col", {
77
83
  enumerable: true,
78
84
  get: function get() {
@@ -430,6 +436,7 @@ var _baseData = _interopRequireDefault(require("./base-data"));
430
436
  var _link = _interopRequireDefault(require("./link"));
431
437
  var _treeSelect = _interopRequireDefault(require("./tree-select"));
432
438
  var _colorPicker = _interopRequireDefault(require("./color-picker"));
439
+ var _clipboard = _interopRequireDefault(require("./clipboard"));
433
440
  function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
434
441
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
435
442
  /* @remove-on-es-build-begin */
@@ -70,16 +70,13 @@ var Content = function Content(args) {
70
70
  }));
71
71
  };
72
72
  var getMainElement = function getMainElement() {
73
- if (typeof content === 'string') {
73
+ if (typeof content === 'string' || /*#__PURE__*/_react.default.isValidElement(content)) {
74
74
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
75
75
  className: "".concat(classPrefix, "-main")
76
76
  }, renderIcon(), /*#__PURE__*/_react.default.createElement("div", {
77
77
  className: "".concat(classPrefix, "-text")
78
78
  }, content)), renderCloseIcon());
79
79
  }
80
- if ( /*#__PURE__*/_react.default.isValidElement(content)) {
81
- return content;
82
- }
83
80
  return null;
84
81
  };
85
82
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, getMainElement());
@@ -53,6 +53,7 @@ export interface ISelectProps<T extends SelectValue> extends AbstractSelectProps
53
53
  defaultValue?: T;
54
54
  mode?: Mode;
55
55
  autoFocus?: boolean;
56
+ status?: 'error';
56
57
  onChange?: (value?: T, option?: React.ReactElement<any> | React.ReactElement<any>[]) => void;
57
58
  onSelect?: (value?: T extends (infer I)[] ? I : T, option?: React.ReactElement<any>) => void;
58
59
  onDeselect?: (value?: T extends (infer I)[] ? I : T, option?: React.ReactElement<any>) => void;
@@ -79,7 +79,8 @@ var InternalSelect = function InternalSelect(props, ref) {
79
79
  _selectProps$popperSt = selectProps.popperStyle,
80
80
  popperStyle = _selectProps$popperSt === void 0 ? {} : _selectProps$popperSt,
81
81
  tagRender = selectProps.tagRender,
82
- virtualListProps = selectProps.virtualListProps;
82
+ virtualListProps = selectProps.virtualListProps,
83
+ status = selectProps.status;
83
84
  var isMultiple = mode === 'multiple'; // 是否多选
84
85
  var _useMergedState = (0, _hooks.useMergedState)(undefined, {
85
86
  value: value,
@@ -139,7 +140,7 @@ var InternalSelect = function InternalSelect(props, ref) {
139
140
  // 多选底部样式
140
141
  var multipleFooterCls = (0, _classnames.default)((0, _defineProperty2.default)({}, "".concat(selectPrefixCls, "-multiple-footer"), true));
141
142
  // 多选,单选公共样式
142
- var commCls = (0, _classnames.default)((_classNames6 = {}, (0, _defineProperty2.default)(_classNames6, "".concat(selectPrefixCls, "-bordered"), borderType === 'bordered'), (0, _defineProperty2.default)(_classNames6, "".concat(selectPrefixCls, "-underline"), borderType === 'underline'), (0, _defineProperty2.default)(_classNames6, "".concat(selectPrefixCls, "-borderless"), borderType === 'none'), (0, _defineProperty2.default)(_classNames6, (0, _concat.default)(_context = "".concat(selectPrefixCls, "-size-")).call(_context, size), size), (0, _defineProperty2.default)(_classNames6, "".concat(selectPrefixCls, "-wrapper"), true), (0, _defineProperty2.default)(_classNames6, "".concat(selectPrefixCls, "-show-search"), isShowSearch && focusd), _classNames6));
143
+ var commCls = (0, _classnames.default)((_classNames6 = {}, (0, _defineProperty2.default)(_classNames6, "".concat(selectPrefixCls, "-bordered"), borderType === 'bordered'), (0, _defineProperty2.default)(_classNames6, "".concat(selectPrefixCls, "-underline"), borderType === 'underline'), (0, _defineProperty2.default)(_classNames6, "".concat(selectPrefixCls, "-borderless"), borderType === 'none'), (0, _defineProperty2.default)(_classNames6, (0, _concat.default)(_context = "".concat(selectPrefixCls, "-size-")).call(_context, size), size), (0, _defineProperty2.default)(_classNames6, "".concat(selectPrefixCls, "-wrapper"), true), (0, _defineProperty2.default)(_classNames6, "".concat(selectPrefixCls, "-show-search"), isShowSearch && focusd), (0, _defineProperty2.default)(_classNames6, "".concat(selectPrefixCls, "-error"), status === 'error'), _classNames6));
143
144
  (0, _react.useEffect)(function () {
144
145
  if (typeof props.visible !== 'undefined') {
145
146
  setOptionShow(props.visible);
@@ -798,12 +799,6 @@ var InternalSelect = function InternalSelect(props, ref) {
798
799
  (0, _splice.default)(selectMulOpts).call(selectMulOpts, -1, 1);
799
800
  setMulOptions((0, _toConsumableArray2.default)(selectMulOpts));
800
801
  onChange && onChange(labelInValue ? selectMulOpts : selectedVal, selectMulOpts);
801
- // !isMultiple
802
- } else if (which === _KeyCode.default.BACKSPACE && allowClear && !isMultiple) {
803
- setInitValue('');
804
- onClear && onClear('');
805
- setSearchValue('');
806
- onChange && onChange(undefined);
807
802
  }
808
803
  // optionsList: up、down、enter
809
804
  if (optionShow) {