@ultraviolet/ui 1.8.0 → 1.8.1
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/index.d.ts
CHANGED
|
@@ -2237,7 +2237,10 @@ type TagListProps = {
|
|
|
2237
2237
|
* This property define maximum characters length of all tags until it hide tags into tooltip.
|
|
2238
2238
|
*/
|
|
2239
2239
|
maxLength?: number;
|
|
2240
|
-
tags?: string
|
|
2240
|
+
tags?: (string | {
|
|
2241
|
+
label: string;
|
|
2242
|
+
icon: NonNullable<ComponentProps<typeof Tag>['icon']>;
|
|
2243
|
+
})[];
|
|
2241
2244
|
/**
|
|
2242
2245
|
* This property define maximum characters length of all tags until it hide tags into tooltip.
|
|
2243
2246
|
*/
|
|
@@ -42,6 +42,7 @@ const StyledTagContainer = /*#__PURE__*/_styled("div", {
|
|
|
42
42
|
return multiline && `flex-wrap: wrap;`;
|
|
43
43
|
}, ";");
|
|
44
44
|
const DEFAULT_TAGS = [];
|
|
45
|
+
const getTagLabel = tag => typeof tag === 'object' ? tag.label : tag;
|
|
45
46
|
const TagList = _ref5 => {
|
|
46
47
|
let {
|
|
47
48
|
maxLength = 600,
|
|
@@ -56,7 +57,7 @@ const TagList = _ref5 => {
|
|
|
56
57
|
'data-testid': dataTestId
|
|
57
58
|
} = _ref5;
|
|
58
59
|
let tmpThreshold = threshold;
|
|
59
|
-
if (tags.length > 0 && tags.slice(0, tmpThreshold).reduce((
|
|
60
|
+
if (tags.length > 0 && tags.slice(0, tmpThreshold).reduce((acc, tag) => acc + getTagLabel(tag), '').length > maxLength) {
|
|
60
61
|
// If total tags length in characters is above maxLength,
|
|
61
62
|
// threshold is decremented in order to prevent too many long tags displayed.
|
|
62
63
|
tmpThreshold -= 1;
|
|
@@ -79,9 +80,10 @@ const TagList = _ref5 => {
|
|
|
79
80
|
copiable: copiable,
|
|
80
81
|
copyText: copyText,
|
|
81
82
|
copiedText: copiedText,
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
icon: typeof tag === 'object' ? tag.icon : undefined,
|
|
84
|
+
children: getTagLabel(tag)
|
|
85
|
+
}, `${getTagLabel(tag)}-${index}`))
|
|
86
|
+
}), hasManyTags ? jsx(Popover, {
|
|
85
87
|
title: popoverTitle,
|
|
86
88
|
visible: isVisible,
|
|
87
89
|
size: "small",
|
|
@@ -95,15 +97,16 @@ const TagList = _ref5 => {
|
|
|
95
97
|
copiable: copiable,
|
|
96
98
|
copyText: copyText,
|
|
97
99
|
copiedText: copiedText,
|
|
98
|
-
|
|
99
|
-
|
|
100
|
+
icon: typeof tag === 'object' ? tag.icon : undefined,
|
|
101
|
+
children: getTagLabel(tag)
|
|
102
|
+
}, `${getTagLabel(tag)}-${index}`))
|
|
100
103
|
}),
|
|
101
104
|
children: jsxs(TagsWrapper, {
|
|
102
105
|
"data-testid": `${dataTestId ?? 'taglist'}-open`,
|
|
103
106
|
onClick: () => setIsVisible(true),
|
|
104
107
|
children: ["+", tags.length - tmpThreshold]
|
|
105
108
|
})
|
|
106
|
-
})]
|
|
109
|
+
}) : null]
|
|
107
110
|
});
|
|
108
111
|
};
|
|
109
112
|
|