one-design-next 0.0.65 → 0.0.66
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/dist/select/index.js +2 -2
- package/dist/select/style/index.css +88 -6
- package/dist/select/tokenUtils.d.ts +2 -0
- package/dist/select/tokenUtils.js +33 -28
- package/dist/style/base.css +10 -5
- package/package.json +1 -5
package/dist/select/index.js
CHANGED
|
@@ -14,7 +14,7 @@ import Icon from "../icon";
|
|
|
14
14
|
import Popover from "../popover";
|
|
15
15
|
import SelectFeedback from "./SelectFeedback";
|
|
16
16
|
import "./style";
|
|
17
|
-
import { formatTokenPasteFeedback, readClipboardText, resolveTokenPaste, splitByTokenSeparators, toRawValueList } from "./tokenUtils";
|
|
17
|
+
import { countValidValues, formatTokenPasteFeedback, readClipboardText, resolveTokenPaste, splitByTokenSeparators, toRawValueList } from "./tokenUtils";
|
|
18
18
|
import useIcons from "./useIcons";
|
|
19
19
|
var InternalSelect = function InternalSelect(props, ref) {
|
|
20
20
|
var className = props.className,
|
|
@@ -332,7 +332,7 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
332
332
|
var suffixIconFinal = typeof _suffixIcon === 'function' ? _suffixIcon(suffixIconProps) : _suffixIcon;
|
|
333
333
|
return /*#__PURE__*/React.createElement(React.Fragment, null, !!maxCount && mode === 'multiple' && Array.isArray(value) && /*#__PURE__*/React.createElement("span", {
|
|
334
334
|
className: "odn-select-max-count"
|
|
335
|
-
}, value
|
|
335
|
+
}, countValidValues(toRawValueList(value), invalidValues), " /", ' ', maxCount), suffixIconFinal);
|
|
336
336
|
},
|
|
337
337
|
menuItemSelectedIcon: mode === 'multiple' ? function (iconProps) {
|
|
338
338
|
var optionDisabled = iconProps.disabled,
|
|
@@ -5,6 +5,13 @@ html {
|
|
|
5
5
|
--odn-select-border-radius-sm: 4px;
|
|
6
6
|
--odn-select-internal_fixed_item_margin: 2px;
|
|
7
7
|
--odn-select-multiple-item-height: 22px;
|
|
8
|
+
--odn-select-multiple-selector-max-height: calc(
|
|
9
|
+
8px + 5 *
|
|
10
|
+
(
|
|
11
|
+
var(--odn-select-multiple-item-height) +
|
|
12
|
+
var(--odn-select-internal_fixed_item_margin) * 4
|
|
13
|
+
)
|
|
14
|
+
);
|
|
8
15
|
--odn-select-multiple-item-bg: var(--odn-color-black-1);
|
|
9
16
|
--odn-select-multiple-item-border-color: var(--odn-color-border);
|
|
10
17
|
--odn-select-popup-padding-block: 8px;
|
|
@@ -567,6 +574,11 @@ html {
|
|
|
567
574
|
display: inline-flex;
|
|
568
575
|
}
|
|
569
576
|
|
|
577
|
+
.odn-select-multiple .odn-select-selection-overflow-item > span {
|
|
578
|
+
max-width: 100%;
|
|
579
|
+
min-width: 0;
|
|
580
|
+
}
|
|
581
|
+
|
|
570
582
|
.odn-select-multiple .odn-select-selection-overflow .odn-select-selection-item {
|
|
571
583
|
display: flex;
|
|
572
584
|
align-self: center;
|
|
@@ -625,12 +637,35 @@ html {
|
|
|
625
637
|
|
|
626
638
|
.odn-select-multiple .odn-select-selector {
|
|
627
639
|
display: flex;
|
|
628
|
-
align-items:
|
|
640
|
+
align-items: flex-start;
|
|
629
641
|
width: 100%;
|
|
630
|
-
height: 100%;
|
|
631
642
|
padding-inline: 12px;
|
|
632
643
|
padding-block: 4px;
|
|
633
644
|
border-radius: var(--odn-select-border-radius);
|
|
645
|
+
max-height: var(--odn-select-multiple-selector-max-height);
|
|
646
|
+
overflow-x: hidden;
|
|
647
|
+
overflow-y: auto;
|
|
648
|
+
}
|
|
649
|
+
.odn-select-multiple .odn-select-selector::-webkit-scrollbar {
|
|
650
|
+
width: 14px;
|
|
651
|
+
height: 14px;
|
|
652
|
+
}
|
|
653
|
+
.odn-select-multiple .odn-select-selector::-webkit-scrollbar-thumb {
|
|
654
|
+
min-width: 14px;
|
|
655
|
+
min-height: 14px;
|
|
656
|
+
background-color: rgba(0, 0, 0, 0.1);
|
|
657
|
+
background-clip: content-box;
|
|
658
|
+
border: 4px solid transparent;
|
|
659
|
+
border-radius: 14px;
|
|
660
|
+
}
|
|
661
|
+
.odn-select-multiple .odn-select-selector::-webkit-scrollbar-track {
|
|
662
|
+
background-color: rgba(0, 0, 0, 0);
|
|
663
|
+
}
|
|
664
|
+
.odn-select-multiple .odn-select-selector::-webkit-scrollbar-thumb:hover {
|
|
665
|
+
background-color: rgba(0, 0, 0, 0.2);
|
|
666
|
+
}
|
|
667
|
+
.odn-select-multiple .odn-select-selector::-webkit-scrollbar-thumb:active {
|
|
668
|
+
background-color: rgba(0, 0, 0, 0.3);
|
|
634
669
|
}
|
|
635
670
|
|
|
636
671
|
.odn-select-disabled.odn-select-multiple .odn-select-selector {
|
|
@@ -801,12 +836,35 @@ html {
|
|
|
801
836
|
|
|
802
837
|
.odn-select-multiple.odn-select-sm .odn-select-selector {
|
|
803
838
|
display: flex;
|
|
804
|
-
align-items:
|
|
839
|
+
align-items: flex-start;
|
|
805
840
|
width: 100%;
|
|
806
|
-
height: 100%;
|
|
807
841
|
padding-inline: 12px;
|
|
808
842
|
padding-block: max(max(var(--odn-padding-xxs) - 1px, 0px) - var(--odn-select-internal_fixed_item_margin), 0px);
|
|
809
843
|
border-radius: var(--odn-select-border-radius-sm);
|
|
844
|
+
max-height: var(--odn-select-multiple-selector-max-height);
|
|
845
|
+
overflow-x: hidden;
|
|
846
|
+
overflow-y: auto;
|
|
847
|
+
}
|
|
848
|
+
.odn-select-multiple.odn-select-sm .odn-select-selector::-webkit-scrollbar {
|
|
849
|
+
width: 14px;
|
|
850
|
+
height: 14px;
|
|
851
|
+
}
|
|
852
|
+
.odn-select-multiple.odn-select-sm .odn-select-selector::-webkit-scrollbar-thumb {
|
|
853
|
+
min-width: 14px;
|
|
854
|
+
min-height: 14px;
|
|
855
|
+
background-color: rgba(0, 0, 0, 0.1);
|
|
856
|
+
background-clip: content-box;
|
|
857
|
+
border: 4px solid transparent;
|
|
858
|
+
border-radius: 14px;
|
|
859
|
+
}
|
|
860
|
+
.odn-select-multiple.odn-select-sm .odn-select-selector::-webkit-scrollbar-track {
|
|
861
|
+
background-color: rgba(0, 0, 0, 0);
|
|
862
|
+
}
|
|
863
|
+
.odn-select-multiple.odn-select-sm .odn-select-selector::-webkit-scrollbar-thumb:hover {
|
|
864
|
+
background-color: rgba(0, 0, 0, 0.2);
|
|
865
|
+
}
|
|
866
|
+
.odn-select-multiple.odn-select-sm .odn-select-selector::-webkit-scrollbar-thumb:active {
|
|
867
|
+
background-color: rgba(0, 0, 0, 0.3);
|
|
810
868
|
}
|
|
811
869
|
|
|
812
870
|
.odn-select-disabled.odn-select-multiple.odn-select-sm .odn-select-selector {
|
|
@@ -983,12 +1041,35 @@ html {
|
|
|
983
1041
|
|
|
984
1042
|
.odn-select-multiple.odn-select-lg .odn-select-selector {
|
|
985
1043
|
display: flex;
|
|
986
|
-
align-items:
|
|
1044
|
+
align-items: flex-start;
|
|
987
1045
|
width: 100%;
|
|
988
|
-
height: 100%;
|
|
989
1046
|
padding-inline: 12px;
|
|
990
1047
|
padding-block: max(max(var(--odn-padding-xxs) - 1px, 0px) - var(--odn-select-internal_fixed_item_margin), 0px);
|
|
991
1048
|
border-radius: var(--odn-select-border-radius-lg);
|
|
1049
|
+
max-height: var(--odn-select-multiple-selector-max-height);
|
|
1050
|
+
overflow-x: hidden;
|
|
1051
|
+
overflow-y: auto;
|
|
1052
|
+
}
|
|
1053
|
+
.odn-select-multiple.odn-select-lg .odn-select-selector::-webkit-scrollbar {
|
|
1054
|
+
width: 14px;
|
|
1055
|
+
height: 14px;
|
|
1056
|
+
}
|
|
1057
|
+
.odn-select-multiple.odn-select-lg .odn-select-selector::-webkit-scrollbar-thumb {
|
|
1058
|
+
min-width: 14px;
|
|
1059
|
+
min-height: 14px;
|
|
1060
|
+
background-color: rgba(0, 0, 0, 0.1);
|
|
1061
|
+
background-clip: content-box;
|
|
1062
|
+
border: 4px solid transparent;
|
|
1063
|
+
border-radius: 14px;
|
|
1064
|
+
}
|
|
1065
|
+
.odn-select-multiple.odn-select-lg .odn-select-selector::-webkit-scrollbar-track {
|
|
1066
|
+
background-color: rgba(0, 0, 0, 0);
|
|
1067
|
+
}
|
|
1068
|
+
.odn-select-multiple.odn-select-lg .odn-select-selector::-webkit-scrollbar-thumb:hover {
|
|
1069
|
+
background-color: rgba(0, 0, 0, 0.2);
|
|
1070
|
+
}
|
|
1071
|
+
.odn-select-multiple.odn-select-lg .odn-select-selector::-webkit-scrollbar-thumb:active {
|
|
1072
|
+
background-color: rgba(0, 0, 0, 0.3);
|
|
992
1073
|
}
|
|
993
1074
|
|
|
994
1075
|
.odn-select-disabled.odn-select-multiple.odn-select-lg .odn-select-selector {
|
|
@@ -1795,6 +1876,7 @@ html {
|
|
|
1795
1876
|
}
|
|
1796
1877
|
|
|
1797
1878
|
.odn-select-selection-overflow-item-rest > span {
|
|
1879
|
+
max-width: 100%;
|
|
1798
1880
|
min-width: 0;
|
|
1799
1881
|
}
|
|
1800
1882
|
|
|
@@ -23,6 +23,8 @@ export declare function readClipboardText(clipboardData: DataTransfer | null): s
|
|
|
23
23
|
export declare function splitByTokenSeparators(text: string, separators: string[]): string[] | null;
|
|
24
24
|
export declare function flattenSelectOptions(options?: DefaultOptionType[]): DefaultOptionType[];
|
|
25
25
|
export declare function matchOptionByToken(token: string, options: DefaultOptionType[]): DefaultOptionType | null;
|
|
26
|
+
/** 有效选中数:不含 invalid chip(未匹配保留项) */
|
|
27
|
+
export declare function countValidValues(values: RawValue[], invalid: RawValue[]): number;
|
|
26
28
|
export declare function toRawValueList(value: unknown): RawValue[];
|
|
27
29
|
export declare function resolveTokenPaste(params: {
|
|
28
30
|
tokens: string[];
|
|
@@ -63,6 +63,17 @@ export function matchOptionByToken(token, options) {
|
|
|
63
63
|
return String(value).toLowerCase() === normalized || String(label !== null && label !== void 0 ? label : '').toLowerCase() === normalized;
|
|
64
64
|
})) !== null && _flat$find !== void 0 ? _flat$find : null;
|
|
65
65
|
}
|
|
66
|
+
|
|
67
|
+
/** 有效选中数:不含 invalid chip(未匹配保留项) */
|
|
68
|
+
export function countValidValues(values, invalid) {
|
|
69
|
+
if (!invalid.length) {
|
|
70
|
+
return values.length;
|
|
71
|
+
}
|
|
72
|
+
var invalidSet = new Set(invalid.map(String));
|
|
73
|
+
return values.filter(function (v) {
|
|
74
|
+
return !invalidSet.has(String(v));
|
|
75
|
+
}).length;
|
|
76
|
+
}
|
|
66
77
|
export function toRawValueList(value) {
|
|
67
78
|
if (value === undefined || value === null || value === '') {
|
|
68
79
|
return [];
|
|
@@ -136,23 +147,23 @@ function _resolveTokenPaste() {
|
|
|
136
147
|
while (1) switch (_context.prev = _context.next) {
|
|
137
148
|
case 0:
|
|
138
149
|
item = _step.value;
|
|
139
|
-
if (!(typeof maxCount === 'number' && nextValue.length >= maxCount)) {
|
|
140
|
-
_context.next = 3;
|
|
141
|
-
break;
|
|
142
|
-
}
|
|
143
|
-
return _context.abrupt("return", 0);
|
|
144
|
-
case 3:
|
|
145
150
|
if (!item.valid) {
|
|
146
151
|
_context.next = 13;
|
|
147
152
|
break;
|
|
148
153
|
}
|
|
154
|
+
if (!(typeof maxCount === 'number' && countValidValues(nextValue, nextInvalid) >= maxCount)) {
|
|
155
|
+
_context.next = 4;
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
return _context.abrupt("return", 0);
|
|
159
|
+
case 4:
|
|
149
160
|
_value = (_item$value = item.value) !== null && _item$value !== void 0 ? _item$value : item.token;
|
|
150
161
|
if (!hasValue(_value)) {
|
|
151
162
|
_context.next = 8;
|
|
152
163
|
break;
|
|
153
164
|
}
|
|
154
165
|
duplicated.push(item.token);
|
|
155
|
-
return _context.abrupt("return",
|
|
166
|
+
return _context.abrupt("return", 0);
|
|
156
167
|
case 8:
|
|
157
168
|
nextValue.push(_value);
|
|
158
169
|
added.push(_value);
|
|
@@ -163,7 +174,7 @@ function _resolveTokenPaste() {
|
|
|
163
174
|
if (idx >= 0) {
|
|
164
175
|
nextInvalid.splice(idx, 1);
|
|
165
176
|
}
|
|
166
|
-
return _context.abrupt("return",
|
|
177
|
+
return _context.abrupt("return", 0);
|
|
167
178
|
case 13:
|
|
168
179
|
// 未匹配
|
|
169
180
|
invalid.push(item.token);
|
|
@@ -171,7 +182,7 @@ function _resolveTokenPaste() {
|
|
|
171
182
|
_context.next = 16;
|
|
172
183
|
break;
|
|
173
184
|
}
|
|
174
|
-
return _context.abrupt("return",
|
|
185
|
+
return _context.abrupt("return", 0);
|
|
175
186
|
case 16:
|
|
176
187
|
value = (_item$value2 = item.value) !== null && _item$value2 !== void 0 ? _item$value2 : item.token;
|
|
177
188
|
if (!hasValue(value)) {
|
|
@@ -179,7 +190,7 @@ function _resolveTokenPaste() {
|
|
|
179
190
|
break;
|
|
180
191
|
}
|
|
181
192
|
duplicated.push(item.token);
|
|
182
|
-
return _context.abrupt("return",
|
|
193
|
+
return _context.abrupt("return", 0);
|
|
183
194
|
case 20:
|
|
184
195
|
nextValue.push(value);
|
|
185
196
|
added.push(value);
|
|
@@ -197,7 +208,7 @@ function _resolveTokenPaste() {
|
|
|
197
208
|
_iterator.s();
|
|
198
209
|
case 19:
|
|
199
210
|
if ((_step = _iterator.n()).done) {
|
|
200
|
-
_context2.next =
|
|
211
|
+
_context2.next = 26;
|
|
201
212
|
break;
|
|
202
213
|
}
|
|
203
214
|
return _context2.delegateYield(_loop(), "t1", 21);
|
|
@@ -207,28 +218,22 @@ function _resolveTokenPaste() {
|
|
|
207
218
|
_context2.next = 24;
|
|
208
219
|
break;
|
|
209
220
|
}
|
|
210
|
-
return _context2.abrupt("
|
|
221
|
+
return _context2.abrupt("continue", 24);
|
|
211
222
|
case 24:
|
|
212
|
-
if (!(_ret === 1)) {
|
|
213
|
-
_context2.next = 26;
|
|
214
|
-
break;
|
|
215
|
-
}
|
|
216
|
-
return _context2.abrupt("continue", 26);
|
|
217
|
-
case 26:
|
|
218
223
|
_context2.next = 19;
|
|
219
224
|
break;
|
|
220
|
-
case
|
|
221
|
-
_context2.next =
|
|
225
|
+
case 26:
|
|
226
|
+
_context2.next = 31;
|
|
222
227
|
break;
|
|
223
|
-
case
|
|
224
|
-
_context2.prev =
|
|
228
|
+
case 28:
|
|
229
|
+
_context2.prev = 28;
|
|
225
230
|
_context2.t2 = _context2["catch"](16);
|
|
226
231
|
_iterator.e(_context2.t2);
|
|
227
|
-
case
|
|
228
|
-
_context2.prev =
|
|
232
|
+
case 31:
|
|
233
|
+
_context2.prev = 31;
|
|
229
234
|
_iterator.f();
|
|
230
|
-
return _context2.finish(
|
|
231
|
-
case
|
|
235
|
+
return _context2.finish(31);
|
|
236
|
+
case 34:
|
|
232
237
|
return _context2.abrupt("return", {
|
|
233
238
|
added: added,
|
|
234
239
|
duplicated: duplicated,
|
|
@@ -236,11 +241,11 @@ function _resolveTokenPaste() {
|
|
|
236
241
|
nextValue: nextValue,
|
|
237
242
|
nextInvalid: nextInvalid
|
|
238
243
|
});
|
|
239
|
-
case
|
|
244
|
+
case 35:
|
|
240
245
|
case "end":
|
|
241
246
|
return _context2.stop();
|
|
242
247
|
}
|
|
243
|
-
}, _callee, null, [[16,
|
|
248
|
+
}, _callee, null, [[16, 28, 31, 34]]);
|
|
244
249
|
}));
|
|
245
250
|
return _resolveTokenPaste.apply(this, arguments);
|
|
246
251
|
}
|
package/dist/style/base.css
CHANGED
|
@@ -243,12 +243,14 @@ a[disabled] {
|
|
|
243
243
|
pointer-events: none;
|
|
244
244
|
}
|
|
245
245
|
|
|
246
|
-
[data-scrollbar-custom]::-webkit-scrollbar
|
|
246
|
+
[data-scrollbar-custom]::-webkit-scrollbar,
|
|
247
|
+
.scrollbar-custom::-webkit-scrollbar {
|
|
247
248
|
width: 14px;
|
|
248
249
|
height: 14px;
|
|
249
250
|
}
|
|
250
251
|
|
|
251
|
-
[data-scrollbar-custom]::-webkit-scrollbar-thumb
|
|
252
|
+
[data-scrollbar-custom]::-webkit-scrollbar-thumb,
|
|
253
|
+
.scrollbar-custom::-webkit-scrollbar-thumb {
|
|
252
254
|
min-width: 14px;
|
|
253
255
|
min-height: 14px;
|
|
254
256
|
background-color: rgba(0, 0, 0, 10%);
|
|
@@ -257,15 +259,18 @@ a[disabled] {
|
|
|
257
259
|
border-radius: 14px;
|
|
258
260
|
}
|
|
259
261
|
|
|
260
|
-
[data-scrollbar-custom]::-webkit-scrollbar-track
|
|
262
|
+
[data-scrollbar-custom]::-webkit-scrollbar-track,
|
|
263
|
+
.scrollbar-custom::-webkit-scrollbar-track {
|
|
261
264
|
background-color: rgba(0, 0, 0, 0%);
|
|
262
265
|
}
|
|
263
266
|
|
|
264
|
-
[data-scrollbar-custom]::-webkit-scrollbar-thumb:hover
|
|
267
|
+
[data-scrollbar-custom]::-webkit-scrollbar-thumb:hover,
|
|
268
|
+
.scrollbar-custom::-webkit-scrollbar-thumb:hover {
|
|
265
269
|
background-color: rgba(0, 0, 0, 20%);
|
|
266
270
|
}
|
|
267
271
|
|
|
268
|
-
[data-scrollbar-custom]::-webkit-scrollbar-thumb:active
|
|
272
|
+
[data-scrollbar-custom]::-webkit-scrollbar-thumb:active,
|
|
273
|
+
.scrollbar-custom::-webkit-scrollbar-thumb:active {
|
|
269
274
|
background-color: rgba(0, 0, 0, 30%);
|
|
270
275
|
}
|
|
271
276
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "one-design-next",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.66",
|
|
4
4
|
"description": "One Design Next from TAD@tencent.com",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -56,10 +56,6 @@
|
|
|
56
56
|
"*.{md,json}": [
|
|
57
57
|
"prettier --write --no-error-on-unmatched-pattern"
|
|
58
58
|
],
|
|
59
|
-
"{components,test}/**/*.{css,scss}": [
|
|
60
|
-
"stylelint --fix",
|
|
61
|
-
"prettier --write"
|
|
62
|
-
],
|
|
63
59
|
"{components,test}/**/*.{js,jsx}": [
|
|
64
60
|
"eslint --fix",
|
|
65
61
|
"prettier --write"
|