@rockshin/tao-ui 0.0.54 → 0.0.56
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/components/select/mobile-select.css +19 -0
- package/dist/components/select/mobile-select.d.ts +2 -1
- package/dist/components/select/mobile-select.js +3 -2
- package/dist/components/select/select-searchable-list.d.ts +2 -1
- package/dist/components/select/select-searchable-list.js +4 -2
- package/dist/components/select/select-types.d.ts +2 -0
- package/dist/components/select/select.css +36 -3
- package/dist/components/select/select.js +16 -4
- package/package.json +1 -1
|
@@ -106,6 +106,25 @@
|
|
|
106
106
|
overflow: hidden;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
+
[data-tao-sheet-item][data-tao-label-wrap] {
|
|
110
|
+
padding-block: var(--tao-padding-xs);
|
|
111
|
+
line-height: var(--tao-line-height);
|
|
112
|
+
align-items: flex-start;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
[data-tao-sheet-item][data-tao-label-wrap] [data-tao-sheet-item-label] {
|
|
116
|
+
white-space: normal;
|
|
117
|
+
overflow-wrap: anywhere;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
[data-tao-sheet-item][data-tao-label-wrap] [data-tao-sheet-item-check] {
|
|
121
|
+
height: 1lh;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
[data-tao-sheet-item][data-tao-label-wrap]:not([data-tao-selected]) [data-tao-sheet-item-check] {
|
|
125
|
+
visibility: hidden;
|
|
126
|
+
}
|
|
127
|
+
|
|
109
128
|
[data-tao-sheet-item-desc] {
|
|
110
129
|
font-size: var(--tao-font-size-sm);
|
|
111
130
|
line-height: var(--tao-line-height-sm);
|
|
@@ -17,6 +17,7 @@ interface MobileSelectContentProps extends Pick<SelectProps, 'classNames' | 'sty
|
|
|
17
17
|
optionRender?: (option: SelectOption, info: {
|
|
18
18
|
index: number;
|
|
19
19
|
}) => ReactNode;
|
|
20
|
+
optionLabelWrap?: boolean;
|
|
20
21
|
onClose: () => void;
|
|
21
22
|
/** Enable multi-select checkboxes + Done button flow. */
|
|
22
23
|
multiple?: boolean;
|
|
@@ -26,7 +27,7 @@ interface MobileSelectContentProps extends Pick<SelectProps, 'classNames' | 'sty
|
|
|
26
27
|
tokenSeparators?: string[];
|
|
27
28
|
onSearchClear: () => void;
|
|
28
29
|
}
|
|
29
|
-
declare function MobileSelectContentInner({ options, value, onChange, onMultiChange, showSearch, searchValue: search, onSearch, filterOption, notFoundContent: notFoundContentProp, optionRender, onClose, multiple, hideSelected, maxCount, mode, tokenSeparators, onSearchClear, disabled, classNames, styles, }: MobileSelectContentProps): import("react").JSX.Element;
|
|
30
|
+
declare function MobileSelectContentInner({ options, value, onChange, onMultiChange, showSearch, searchValue: search, onSearch, filterOption, notFoundContent: notFoundContentProp, optionRender, optionLabelWrap, onClose, multiple, hideSelected, maxCount, mode, tokenSeparators, onSearchClear, disabled, classNames, styles, }: MobileSelectContentProps): import("react").JSX.Element;
|
|
30
31
|
export { MobileSelectContentInner as MobileSelectContent };
|
|
31
32
|
export interface MobileSelectDrawerProps extends MobileSelectContentProps {
|
|
32
33
|
direction?: 'ltr' | 'rtl';
|
|
@@ -9,7 +9,7 @@ import { SearchIcon } from "./select-icons.js";
|
|
|
9
9
|
import { countLeafOptions, defaultFilter, filterTree, flattenLeafOptions } from "./select-model.js";
|
|
10
10
|
import { useSelectSelection } from "./use-select-selection.js";
|
|
11
11
|
import "./mobile-select.css";
|
|
12
|
-
function MobileSelectContentInner({ options, value, onChange, onMultiChange, showSearch, searchValue: search, onSearch, filterOption, notFoundContent: notFoundContentProp, optionRender, onClose, multiple, hideSelected, maxCount, mode, tokenSeparators, onSearchClear, disabled, classNames, styles }) {
|
|
12
|
+
function MobileSelectContentInner({ options, value, onChange, onMultiChange, showSearch, searchValue: search, onSearch, filterOption, notFoundContent: notFoundContentProp, optionRender, optionLabelWrap, onClose, multiple, hideSelected, maxCount, mode, tokenSeparators, onSearchClear, disabled, classNames, styles }) {
|
|
13
13
|
const { locale } = useTaoConfig();
|
|
14
14
|
const notFoundContent = void 0 === notFoundContentProp ? locale.noResults : notFoundContentProp;
|
|
15
15
|
const valueArray = useMemo(()=>{
|
|
@@ -102,6 +102,7 @@ function MobileSelectContentInner({ options, value, onChange, onMultiChange, sho
|
|
|
102
102
|
return /*#__PURE__*/ jsxs("button", {
|
|
103
103
|
type: "button",
|
|
104
104
|
"data-tao-sheet-item": "",
|
|
105
|
+
"data-tao-label-wrap": optionLabelWrap || void 0,
|
|
105
106
|
className: classNames?.item,
|
|
106
107
|
style: styles?.item,
|
|
107
108
|
"data-tao-selected": isSelected || void 0,
|
|
@@ -142,7 +143,7 @@ function MobileSelectContentInner({ options, value, onChange, onMultiChange, sho
|
|
|
142
143
|
})
|
|
143
144
|
]
|
|
144
145
|
}),
|
|
145
|
-
isSelected && /*#__PURE__*/ jsx("span", {
|
|
146
|
+
(isSelected || optionLabelWrap) && /*#__PURE__*/ jsx("span", {
|
|
146
147
|
"data-tao-sheet-item-check": "",
|
|
147
148
|
children: /*#__PURE__*/ jsx(CheckIcon, {})
|
|
148
149
|
})
|
|
@@ -13,11 +13,12 @@ interface SearchableSelectListProps {
|
|
|
13
13
|
listHeight: number;
|
|
14
14
|
notFoundContent: ReactNode;
|
|
15
15
|
optionRender?: SelectProps['optionRender'];
|
|
16
|
+
optionLabelWrap?: boolean;
|
|
16
17
|
classNames?: SelectProps['classNames'];
|
|
17
18
|
styles?: SelectProps['styles'];
|
|
18
19
|
onActiveIndexChange: (index: number) => void;
|
|
19
20
|
onValueChange: (value: string) => void;
|
|
20
21
|
onClose: () => void;
|
|
21
22
|
}
|
|
22
|
-
export declare function SearchableSelectList({ id, options, resultCount, searchableOptions, activeValue, selectedValues, multiple, disabled, maxCountReached, listHeight, notFoundContent, optionRender, classNames, styles, onActiveIndexChange, onValueChange, onClose, }: SearchableSelectListProps): import("react").JSX.Element;
|
|
23
|
+
export declare function SearchableSelectList({ id, options, resultCount, searchableOptions, activeValue, selectedValues, multiple, disabled, maxCountReached, listHeight, notFoundContent, optionRender, optionLabelWrap, classNames, styles, onActiveIndexChange, onValueChange, onClose, }: SearchableSelectListProps): import("react").JSX.Element;
|
|
23
24
|
export {};
|
|
@@ -2,7 +2,7 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useMemo } from "react";
|
|
3
3
|
import { cx } from "../../utils/semantic.js";
|
|
4
4
|
import { CheckIcon } from "./select-icons.js";
|
|
5
|
-
function SearchableSelectList({ id, options, resultCount, searchableOptions, activeValue, selectedValues, multiple, disabled, maxCountReached, listHeight, notFoundContent, optionRender, classNames, styles, onActiveIndexChange, onValueChange, onClose }) {
|
|
5
|
+
function SearchableSelectList({ id, options, resultCount, searchableOptions, activeValue, selectedValues, multiple, disabled, maxCountReached, listHeight, notFoundContent, optionRender, optionLabelWrap, classNames, styles, onActiveIndexChange, onValueChange, onClose }) {
|
|
6
6
|
const indexByValue = useMemo(()=>{
|
|
7
7
|
const index = new Map();
|
|
8
8
|
searchableOptions.forEach((option, position)=>{
|
|
@@ -30,6 +30,7 @@ function SearchableSelectList({ id, options, resultCount, searchableOptions, act
|
|
|
30
30
|
disabled: isDisabled,
|
|
31
31
|
"data-disabled": isDisabled || void 0,
|
|
32
32
|
"data-tao-select-item": "",
|
|
33
|
+
"data-tao-label-wrap": optionLabelWrap || void 0,
|
|
33
34
|
"data-tao-selected": multiple && isSelected ? '' : void 0,
|
|
34
35
|
"data-tao-has-desc": null != option_0.description || void 0,
|
|
35
36
|
"data-state": isSelected ? 'checked' : 'unchecked',
|
|
@@ -62,6 +63,7 @@ function SearchableSelectList({ id, options, resultCount, searchableOptions, act
|
|
|
62
63
|
style: styles?.itemLabel,
|
|
63
64
|
children: [
|
|
64
65
|
/*#__PURE__*/ jsx("span", {
|
|
66
|
+
"data-tao-select-item-label": "",
|
|
65
67
|
children: option_0.label
|
|
66
68
|
}),
|
|
67
69
|
null != option_0.description && /*#__PURE__*/ jsx("span", {
|
|
@@ -74,7 +76,7 @@ function SearchableSelectList({ id, options, resultCount, searchableOptions, act
|
|
|
74
76
|
})
|
|
75
77
|
]
|
|
76
78
|
}),
|
|
77
|
-
isSelected && /*#__PURE__*/ jsx("span", {
|
|
79
|
+
(isSelected || optionLabelWrap) && /*#__PURE__*/ jsx("span", {
|
|
78
80
|
"data-tao-select-check": "",
|
|
79
81
|
children: /*#__PURE__*/ jsx(CheckIcon, {})
|
|
80
82
|
})
|
|
@@ -99,6 +99,8 @@ export interface SelectProps extends Pick<AriaAttributes, 'aria-label' | 'aria-l
|
|
|
99
99
|
optionRender?: (option: SelectOption, info: {
|
|
100
100
|
index: number;
|
|
101
101
|
}) => ReactNode;
|
|
102
|
+
/** Wrap built-in option labels without truncation on desktop and mobile. Defaults to false; custom optionRender controls its own content. */
|
|
103
|
+
optionLabelWrap?: boolean;
|
|
102
104
|
/** Customize the selected option's label. */
|
|
103
105
|
labelRender?: (option: SelectOption) => ReactNode;
|
|
104
106
|
/** Wrap or extend the desktop menu or mobile drawer content. */
|
|
@@ -231,6 +231,7 @@ button[data-tao-select-clear] {
|
|
|
231
231
|
}
|
|
232
232
|
|
|
233
233
|
[data-tao-select-content] {
|
|
234
|
+
--tao-select-available-width: var(--radix-popover-content-available-width, var(--radix-select-content-available-width));
|
|
234
235
|
--tao-select-height: var(--tao-control-height);
|
|
235
236
|
--tao-select-font-size: var(--tao-font-size-base);
|
|
236
237
|
font-size: var(--tao-select-font-size);
|
|
@@ -341,6 +342,7 @@ legend[data-tao-select-group-label] {
|
|
|
341
342
|
padding-inline: var(--tao-padding-sm);
|
|
342
343
|
font-size: var(--tao-select-font-size);
|
|
343
344
|
font-family: var(--tao-font-family);
|
|
345
|
+
line-height: var(--tao-line-height);
|
|
344
346
|
color: var(--tao-color-text);
|
|
345
347
|
text-align: start;
|
|
346
348
|
border-radius: var(--tao-radius-sm);
|
|
@@ -353,7 +355,6 @@ legend[data-tao-select-group-label] {
|
|
|
353
355
|
border: 0;
|
|
354
356
|
outline: none;
|
|
355
357
|
align-items: center;
|
|
356
|
-
line-height: 1;
|
|
357
358
|
display: flex;
|
|
358
359
|
}
|
|
359
360
|
|
|
@@ -396,11 +397,11 @@ legend[data-tao-select-group-label] {
|
|
|
396
397
|
}
|
|
397
398
|
|
|
398
399
|
[data-tao-select-item-main] {
|
|
400
|
+
min-width: 0;
|
|
401
|
+
line-height: inherit;
|
|
399
402
|
flex-direction: column;
|
|
400
403
|
flex: 1;
|
|
401
404
|
justify-content: center;
|
|
402
|
-
min-width: 0;
|
|
403
|
-
line-height: 1;
|
|
404
405
|
display: flex;
|
|
405
406
|
}
|
|
406
407
|
|
|
@@ -414,8 +415,38 @@ legend[data-tao-select-group-label] {
|
|
|
414
415
|
overflow: hidden;
|
|
415
416
|
}
|
|
416
417
|
|
|
418
|
+
[data-tao-select-item-label] {
|
|
419
|
+
text-overflow: ellipsis;
|
|
420
|
+
white-space: nowrap;
|
|
421
|
+
overflow: hidden;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
[data-tao-select-item][data-tao-label-wrap] {
|
|
425
|
+
padding-block: var(--tao-padding-xs);
|
|
426
|
+
line-height: var(--tao-line-height);
|
|
427
|
+
align-items: flex-start;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
[data-tao-select-item][data-tao-label-wrap] [data-tao-select-item-main] {
|
|
431
|
+
line-height: inherit;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
[data-tao-select-item][data-tao-label-wrap] [data-tao-select-item-label] {
|
|
435
|
+
white-space: normal;
|
|
436
|
+
overflow-wrap: anywhere;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
[data-tao-select-item][data-tao-label-wrap] [data-tao-select-check] {
|
|
440
|
+
height: 1lh;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
[data-tao-select-item][data-tao-label-wrap][data-state="unchecked"]:not([data-tao-selected]) [data-tao-select-check] {
|
|
444
|
+
visibility: hidden;
|
|
445
|
+
}
|
|
446
|
+
|
|
417
447
|
[data-tao-select-check] {
|
|
418
448
|
color: var(--tao-primary);
|
|
449
|
+
flex-shrink: 0;
|
|
419
450
|
align-items: center;
|
|
420
451
|
margin-inline-start: auto;
|
|
421
452
|
padding-inline-start: var(--tao-padding-xs);
|
|
@@ -459,6 +490,7 @@ legend[data-tao-select-group-label] {
|
|
|
459
490
|
|
|
460
491
|
[data-tao-select-tag] {
|
|
461
492
|
box-sizing: border-box;
|
|
493
|
+
min-width: 0;
|
|
462
494
|
max-width: 160px;
|
|
463
495
|
font-size: var(--tao-font-size-sm);
|
|
464
496
|
height: 24px;
|
|
@@ -507,6 +539,7 @@ legend[data-tao-select-group-label] {
|
|
|
507
539
|
[data-tao-select-tag-rest] {
|
|
508
540
|
cursor: default;
|
|
509
541
|
color: var(--tao-color-text-tertiary);
|
|
542
|
+
flex-shrink: 0;
|
|
510
543
|
}
|
|
511
544
|
|
|
512
545
|
[data-tao-select-item][data-tao-selected] {
|
|
@@ -32,7 +32,7 @@ const PLACEMENT_MAP = {
|
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
34
|
const select_Select = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
35
|
-
const { options, mode, placeholder, size, variant, disabled, status, showSearch, filterOption, searchValue: searchValueProp, onSearch, allowClear, loading, loadingIcon, notFoundContent: notFoundContentProp, prefix, suffixIcon, removeIcon, autoFocus, id, name, open: openProp, defaultOpen, onOpenChange, placement, popupMatchSelectWidth = true, listHeight = 256, getPopupContainer, optionRender, labelRender, popupRender, tagRender, maxTagCount, maxTagPlaceholder, maxTagTextLength, maxCount, autoClearSearchValue = true, tokenSeparators, hideSelected, mobile, className, style, classNames, styles } = props;
|
|
35
|
+
const { options, mode, placeholder, size, variant, disabled, status, showSearch, filterOption, searchValue: searchValueProp, onSearch, allowClear, loading, loadingIcon, notFoundContent: notFoundContentProp, prefix, suffixIcon, removeIcon, autoFocus, id, name, open: openProp, defaultOpen, onOpenChange, placement, popupMatchSelectWidth = true, listHeight = 256, getPopupContainer, optionRender, optionLabelWrap = false, labelRender, popupRender, tagRender, maxTagCount, maxTagPlaceholder, maxTagTextLength, maxCount, autoClearSearchValue = true, tokenSeparators, hideSelected, mobile, className, style, classNames, styles } = props;
|
|
36
36
|
const ctx = useTaoConfig();
|
|
37
37
|
const notFoundContent = void 0 === notFoundContentProp ? ctx.locale.noResults : notFoundContentProp;
|
|
38
38
|
const resolvedSize = size ?? ctx.size;
|
|
@@ -381,6 +381,7 @@ const select_Select = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
381
381
|
filterOption: filterOption,
|
|
382
382
|
notFoundContent: notFoundContent,
|
|
383
383
|
optionRender: optionRender,
|
|
384
|
+
optionLabelWrap: optionLabelWrap,
|
|
384
385
|
multiple: isMultiple,
|
|
385
386
|
hideSelected: hideSelected,
|
|
386
387
|
maxCount: maxCount,
|
|
@@ -399,6 +400,14 @@ const select_Select = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
399
400
|
...styles?.popup
|
|
400
401
|
};
|
|
401
402
|
if ('number' == typeof popupMatchSelectWidth) contentStyle.width = popupMatchSelectWidth;
|
|
403
|
+
if (optionLabelWrap) {
|
|
404
|
+
contentStyle.maxWidth = 'var(--tao-select-available-width)';
|
|
405
|
+
contentStyle.minWidth = 'min(var(--radix-select-trigger-width), var(--tao-select-available-width))';
|
|
406
|
+
if (false === popupMatchSelectWidth) {
|
|
407
|
+
contentStyle.minWidth = 0;
|
|
408
|
+
contentStyle.width = 'max-content';
|
|
409
|
+
}
|
|
410
|
+
}
|
|
402
411
|
const radixValue = isMultiple ? '' : value ?? '';
|
|
403
412
|
const resultCount = filteredFlatOptions.length;
|
|
404
413
|
const overMaxCount = isMultiple && null != maxCount && valueArray.length >= maxCount;
|
|
@@ -412,6 +421,7 @@ const select_Select = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
412
421
|
value: opt.value,
|
|
413
422
|
disabled: itemDisabled,
|
|
414
423
|
"data-tao-select-item": "",
|
|
424
|
+
"data-tao-label-wrap": optionLabelWrap || void 0,
|
|
415
425
|
"data-tao-has-desc": null != opt.description || void 0,
|
|
416
426
|
"data-tao-selected": isMultiple && isSelected ? '' : void 0,
|
|
417
427
|
className: cx(classNames?.item),
|
|
@@ -443,6 +453,7 @@ const select_Select = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
443
453
|
style: styles?.itemLabel,
|
|
444
454
|
children: [
|
|
445
455
|
/*#__PURE__*/ jsx(__rspack_external__radix_ui_react_select_4606f4d3.ItemText, {
|
|
456
|
+
"data-tao-select-item-label": "",
|
|
446
457
|
children: opt.label
|
|
447
458
|
}),
|
|
448
459
|
null != opt.description && /*#__PURE__*/ jsx("span", {
|
|
@@ -455,7 +466,7 @@ const select_Select = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
455
466
|
})
|
|
456
467
|
]
|
|
457
468
|
}),
|
|
458
|
-
isMultiple ? isSelected && /*#__PURE__*/ jsx("span", {
|
|
469
|
+
isMultiple || optionLabelWrap ? (isSelected || optionLabelWrap) && /*#__PURE__*/ jsx("span", {
|
|
459
470
|
"data-tao-select-check": "",
|
|
460
471
|
children: /*#__PURE__*/ jsx(CheckIcon, {})
|
|
461
472
|
}) : /*#__PURE__*/ jsx(__rspack_external__radix_ui_react_select_4606f4d3.ItemIndicator, {
|
|
@@ -515,6 +526,7 @@ const select_Select = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
515
526
|
listHeight: listHeight,
|
|
516
527
|
notFoundContent: notFoundContent,
|
|
517
528
|
optionRender: optionRender,
|
|
529
|
+
optionLabelWrap: optionLabelWrap,
|
|
518
530
|
classNames: classNames,
|
|
519
531
|
styles: styles,
|
|
520
532
|
onActiveIndexChange: setActiveSearchIndex,
|
|
@@ -600,8 +612,8 @@ const select_Select = /*#__PURE__*/ forwardRef(function(props, ref) {
|
|
|
600
612
|
const searchableContentStyle = {
|
|
601
613
|
...contentStyle
|
|
602
614
|
};
|
|
603
|
-
if (true === popupMatchSelectWidth) searchableContentStyle.minWidth = 'var(--radix-popover-trigger-width)';
|
|
604
|
-
else if (false === popupMatchSelectWidth) searchableContentStyle.minWidth = 'max-content';
|
|
615
|
+
if (true === popupMatchSelectWidth) searchableContentStyle.minWidth = optionLabelWrap ? 'min(var(--radix-popover-trigger-width), var(--tao-select-available-width))' : 'var(--radix-popover-trigger-width)';
|
|
616
|
+
else if (false === popupMatchSelectWidth && !optionLabelWrap) searchableContentStyle.minWidth = 'max-content';
|
|
605
617
|
return /*#__PURE__*/ jsxs(__rspack_external__radix_ui_react_popover_c8444160.Root, {
|
|
606
618
|
open: open,
|
|
607
619
|
onOpenChange: handleOpenChange,
|