@cloud-ru/ds-tag 1.2.7-preview-2df639a4.0 → 1.2.7-preview-87a0f601.0
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/README.md +2 -2
- package/dist/cjs/components/TagBase/TagBase.js +1 -1
- package/dist/cjs/constants.d.ts +0 -4
- package/dist/cjs/constants.js +0 -4
- package/dist/cjs/helperComponents/TagList/TagList.js +1 -1
- package/dist/cjs/helperComponents/TagMore/TagMore.js +1 -1
- package/dist/cjs/helperComponents/TagRowSimple/TagRowSimple.d.ts +2 -3
- package/dist/esm/components/TagBase/TagBase.js +1 -1
- package/dist/esm/constants.d.ts +0 -4
- package/dist/esm/constants.js +0 -4
- package/dist/esm/helperComponents/TagList/TagList.js +2 -2
- package/dist/esm/helperComponents/TagMore/TagMore.js +1 -1
- package/dist/esm/helperComponents/TagRowSimple/TagRowSimple.d.ts +2 -3
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +8 -8
- package/src/components/TagBase/TagBase.tsx +0 -1
- package/src/constants.ts +0 -4
- package/src/helperComponents/TagList/TagList.tsx +2 -7
- package/src/helperComponents/TagMore/TagMore.tsx +1 -7
- package/src/helperComponents/TagRowSimple/TagRowSimple.tsx +3 -3
package/README.md
CHANGED
|
@@ -71,7 +71,7 @@ export function Removable() {
|
|
|
71
71
|
| `appearance` | `"blue"` \| `"green"` \| `"neutral"` \| `"orange"` \| `"pink"` \| `"primary"` \| `"red"` \| `"violet"` \| `"yellow"` | — | |
|
|
72
72
|
| `as` | `"a"` | — | Элемент или компонент для рендера: 'a' \| ComponentType (например Link из react-router-dom) |
|
|
73
73
|
| `className` | `string` | — | |
|
|
74
|
-
| `data-test-id` | `string` | — |
|
|
74
|
+
| `data-test-id` | `string` | — | |
|
|
75
75
|
| `innerRef` | `((instance: HTMLAnchorElement \| null) => void) \| RefObject<HTMLAnchorElement> \| Ref<HTMLSpanElement>` | — | Ref на корневой DOM-элемент. <br/> Используем явный проп, чтобы не зависеть от `forwardRef` и не тащить type-assertions на экспорт. <br/> Ref на реальный DOM-элемент/инстанс, который рендерится через `as`. <br/> Используем явный проп, чтобы не зависеть от `forwardRef` и не тащить type-assertions на экспорт. |
|
|
76
76
|
| `label` | `string` | — | |
|
|
77
77
|
| `onDelete` | `MouseEventHandler<HTMLButtonElement>` | — | Обработчик удаления тега. Если задан — отображается крестик-remove |
|
|
@@ -136,7 +136,7 @@ export function RowTruncated() {
|
|
|
136
136
|
| Prop | Type | Default | Description |
|
|
137
137
|
|------|------|---------|-------------|
|
|
138
138
|
| `className` | `string` | — | |
|
|
139
|
-
| `data-test-id` | `string` | — |
|
|
139
|
+
| `data-test-id` | `string` | — | |
|
|
140
140
|
| `items` | `TagRowItem[]` | — | |
|
|
141
141
|
| `moreButtonLabel` | `string` | — | |
|
|
142
142
|
| `onItemRemove` | `((item: string) => void)` | — | |
|
|
@@ -14,6 +14,6 @@ const constants_2 = require("./constants");
|
|
|
14
14
|
const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
15
15
|
function TagBase({ label, truncateVariant, size = constants_1.SIZE.S, appearance = constants_1.APPEARANCE.Neutral, onDelete, className, tabIndex, innerRef, changeRestrictTooltipState, hideTruncateTooltip, ...rest }) {
|
|
16
16
|
const isRemovable = Boolean(onDelete);
|
|
17
|
-
return ((0, jsx_runtime_1.jsxs)("span", { ref: innerRef, ...rest, className: (0, classnames_1.default)(styles_module_scss_1.default.tag, className), "data-size": size, "data-appearance": appearance, "data-removable": isRemovable, children: [(0, jsx_runtime_1.jsx)("span", { className: styles_module_scss_1.default.textWrapper, children: (0, jsx_runtime_1.jsx)(truncate_string_1.TruncateString, {
|
|
17
|
+
return ((0, jsx_runtime_1.jsxs)("span", { ref: innerRef, ...rest, className: (0, classnames_1.default)(styles_module_scss_1.default.tag, className), "data-size": size, "data-appearance": appearance, "data-removable": isRemovable, children: [(0, jsx_runtime_1.jsx)("span", { className: styles_module_scss_1.default.textWrapper, children: (0, jsx_runtime_1.jsx)(truncate_string_1.TruncateString, { className: styles_module_scss_1.default.label, text: label, variant: truncateVariant, hideTooltip: hideTruncateTooltip }) }), isRemovable && ((0, jsx_runtime_1.jsx)("button", { type: 'button', className: styles_module_scss_1.default.tagButton, onClick: onDelete, onMouseEnter: () => changeRestrictTooltipState?.(true), onMouseLeave: () => changeRestrictTooltipState?.(false), "data-test-id": constants_1.TEST_IDS.tag.removeButton, tabIndex: tabIndex, children: (0, jsx_runtime_1.jsx)("span", { className: styles_module_scss_1.default.icon, children: (0, jsx_runtime_1.jsx)(system_1.CrossSVG, { size: constants_2.ICON_SIZE[size] }) }) }))] }));
|
|
18
18
|
}
|
|
19
19
|
(0, utils_1.withInnerRefSupport)(TagBase);
|
package/dist/cjs/constants.d.ts
CHANGED
|
@@ -21,10 +21,6 @@ export declare const APPEARANCE: {
|
|
|
21
21
|
* источника.
|
|
22
22
|
*/
|
|
23
23
|
export declare const TEST_IDS: {
|
|
24
|
-
readonly tagBaseTruncateString: "tag-base__truncate-string";
|
|
25
|
-
readonly tagListTag: "tag-list__tag";
|
|
26
|
-
readonly tagMoreDropdown: "tag-more__dropdown";
|
|
27
|
-
readonly tagMoreTagRowDroplistScroll: "tag-more__tag-row-droplist-scroll";
|
|
28
24
|
readonly tag: {
|
|
29
25
|
readonly removeButton: "tag-remove-button";
|
|
30
26
|
};
|
package/dist/cjs/constants.js
CHANGED
|
@@ -24,10 +24,6 @@ exports.APPEARANCE = {
|
|
|
24
24
|
* источника.
|
|
25
25
|
*/
|
|
26
26
|
exports.TEST_IDS = {
|
|
27
|
-
tagBaseTruncateString: 'tag-base__truncate-string',
|
|
28
|
-
tagListTag: 'tag-list__tag',
|
|
29
|
-
tagMoreDropdown: 'tag-more__dropdown',
|
|
30
|
-
tagMoreTagRowDroplistScroll: 'tag-more__tag-row-droplist-scroll',
|
|
31
27
|
tag: {
|
|
32
28
|
removeButton: 'tag-remove-button',
|
|
33
29
|
},
|
|
@@ -10,7 +10,7 @@ const constants_1 = require("../../constants");
|
|
|
10
10
|
const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
11
11
|
function renderTag(size, handleRemoveItem, setRef) {
|
|
12
12
|
return function TagRowItem(item) {
|
|
13
|
-
return ((0, jsx_runtime_1.jsx)("div", { ref: setRef?.(item), className: styles_module_scss_1.default.tagWrapper, children: (0, jsx_runtime_1.jsx)(Tag_1.Tag, {
|
|
13
|
+
return ((0, jsx_runtime_1.jsx)("div", { ref: setRef?.(item), className: styles_module_scss_1.default.tagWrapper, children: (0, jsx_runtime_1.jsx)(Tag_1.Tag, { size: size, ...(item.href ? {} : { onDelete: handleRemoveItem?.(item) }), ...item }) }, item.id ?? item.label));
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
function TagList({ items, size = constants_1.SIZE.S, onItemRemove, setTagRef }) {
|
|
@@ -13,5 +13,5 @@ const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
|
13
13
|
function TagMore({ items, text = '', size = constants_1.SIZE.S, buttonRef, onItemRemove }) {
|
|
14
14
|
return (
|
|
15
15
|
// TODO: replace with Popover
|
|
16
|
-
(0, jsx_runtime_1.jsx)(dropdown_1.Dropdown, {
|
|
16
|
+
(0, jsx_runtime_1.jsx)(dropdown_1.Dropdown, { placement: 'bottom-end', trigger: 'hoverAndFocusVisible', triggerClassName: styles_module_scss_1.default.moreTrigger, content: (0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.tagRowDroplistContainer, "data-size": size, children: (0, jsx_runtime_1.jsx)(scroll_1.Scroll, { className: styles_module_scss_1.default.tagRowDroplistScroll, size: 's', barHideStrategy: 'move', children: (0, jsx_runtime_1.jsx)(TagRowSimple_1.TagRowSimple, { items: items, size: size, onItemRemove: onItemRemove, "data-test-id": constants_1.TEST_IDS.tagRow.droplistTagsWrapper }) }) }), children: (0, jsx_runtime_1.jsx)("button", { type: 'button', className: styles_module_scss_1.default.button, ref: buttonRef, "data-size": size, "data-test-id": constants_1.TEST_IDS.tagRow.moreButton, children: (0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.textWrapper, children: `${text}${items.length}` }) }) }));
|
|
17
17
|
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { WithSupportProps } from '@cloud-ru/ds-utils';
|
|
2
1
|
import { Ref } from 'react';
|
|
3
2
|
import { Size, TagRowItemInner } from '../../types';
|
|
4
|
-
type TagRowSimpleProps =
|
|
3
|
+
type TagRowSimpleProps = {
|
|
5
4
|
items: TagRowItemInner[];
|
|
6
5
|
size: Size;
|
|
7
6
|
onItemRemove?(item: string): void;
|
|
8
7
|
setTagRef?: (item: TagRowItemInner) => Ref<HTMLDivElement>;
|
|
9
8
|
className?: string;
|
|
10
|
-
}
|
|
9
|
+
};
|
|
11
10
|
export declare function TagRowSimple({ items, size, onItemRemove, setTagRef, className, ...rest }: TagRowSimpleProps): import("react/jsx-runtime").JSX.Element;
|
|
12
11
|
export {};
|
|
@@ -8,6 +8,6 @@ import { ICON_SIZE } from './constants.js';
|
|
|
8
8
|
import styles from './styles.module.css';
|
|
9
9
|
export function TagBase({ label, truncateVariant, size = SIZE.S, appearance = APPEARANCE.Neutral, onDelete, className, tabIndex, innerRef, changeRestrictTooltipState, hideTruncateTooltip, ...rest }) {
|
|
10
10
|
const isRemovable = Boolean(onDelete);
|
|
11
|
-
return (_jsxs("span", { ref: innerRef, ...rest, className: cn(styles.tag, className), "data-size": size, "data-appearance": appearance, "data-removable": isRemovable, children: [_jsx("span", { className: styles.textWrapper, children: _jsx(TruncateString, {
|
|
11
|
+
return (_jsxs("span", { ref: innerRef, ...rest, className: cn(styles.tag, className), "data-size": size, "data-appearance": appearance, "data-removable": isRemovable, children: [_jsx("span", { className: styles.textWrapper, children: _jsx(TruncateString, { className: styles.label, text: label, variant: truncateVariant, hideTooltip: hideTruncateTooltip }) }), isRemovable && (_jsx("button", { type: 'button', className: styles.tagButton, onClick: onDelete, onMouseEnter: () => changeRestrictTooltipState?.(true), onMouseLeave: () => changeRestrictTooltipState?.(false), "data-test-id": TEST_IDS.tag.removeButton, tabIndex: tabIndex, children: _jsx("span", { className: styles.icon, children: _jsx(CrossSVG, { size: ICON_SIZE[size] }) }) }))] }));
|
|
12
12
|
}
|
|
13
13
|
withInnerRefSupport(TagBase);
|
package/dist/esm/constants.d.ts
CHANGED
|
@@ -21,10 +21,6 @@ export declare const APPEARANCE: {
|
|
|
21
21
|
* источника.
|
|
22
22
|
*/
|
|
23
23
|
export declare const TEST_IDS: {
|
|
24
|
-
readonly tagBaseTruncateString: "tag-base__truncate-string";
|
|
25
|
-
readonly tagListTag: "tag-list__tag";
|
|
26
|
-
readonly tagMoreDropdown: "tag-more__dropdown";
|
|
27
|
-
readonly tagMoreTagRowDroplistScroll: "tag-more__tag-row-droplist-scroll";
|
|
28
24
|
readonly tag: {
|
|
29
25
|
readonly removeButton: "tag-remove-button";
|
|
30
26
|
};
|
package/dist/esm/constants.js
CHANGED
|
@@ -21,10 +21,6 @@ export const APPEARANCE = {
|
|
|
21
21
|
* источника.
|
|
22
22
|
*/
|
|
23
23
|
export const TEST_IDS = {
|
|
24
|
-
tagBaseTruncateString: 'tag-base__truncate-string',
|
|
25
|
-
tagListTag: 'tag-list__tag',
|
|
26
|
-
tagMoreDropdown: 'tag-more__dropdown',
|
|
27
|
-
tagMoreTagRowDroplistScroll: 'tag-more__tag-row-droplist-scroll',
|
|
28
24
|
tag: {
|
|
29
25
|
removeButton: 'tag-remove-button',
|
|
30
26
|
},
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { Tag } from '../../components/Tag/index.js';
|
|
3
|
-
import { SIZE
|
|
3
|
+
import { SIZE } from '../../constants.js';
|
|
4
4
|
import styles from './styles.module.css';
|
|
5
5
|
function renderTag(size, handleRemoveItem, setRef) {
|
|
6
6
|
return function TagRowItem(item) {
|
|
7
|
-
return (_jsx("div", { ref: setRef?.(item), className: styles.tagWrapper, children: _jsx(Tag, {
|
|
7
|
+
return (_jsx("div", { ref: setRef?.(item), className: styles.tagWrapper, children: _jsx(Tag, { size: size, ...(item.href ? {} : { onDelete: handleRemoveItem?.(item) }), ...item }) }, item.id ?? item.label));
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
10
|
export function TagList({ items, size = SIZE.S, onItemRemove, setTagRef }) {
|
|
@@ -7,5 +7,5 @@ import styles from './styles.module.css';
|
|
|
7
7
|
export function TagMore({ items, text = '', size = SIZE.S, buttonRef, onItemRemove }) {
|
|
8
8
|
return (
|
|
9
9
|
// TODO: replace with Popover
|
|
10
|
-
_jsx(Dropdown, {
|
|
10
|
+
_jsx(Dropdown, { placement: 'bottom-end', trigger: 'hoverAndFocusVisible', triggerClassName: styles.moreTrigger, content: _jsx("div", { className: styles.tagRowDroplistContainer, "data-size": size, children: _jsx(Scroll, { className: styles.tagRowDroplistScroll, size: 's', barHideStrategy: 'move', children: _jsx(TagRowSimple, { items: items, size: size, onItemRemove: onItemRemove, "data-test-id": TEST_IDS.tagRow.droplistTagsWrapper }) }) }), children: _jsx("button", { type: 'button', className: styles.button, ref: buttonRef, "data-size": size, "data-test-id": TEST_IDS.tagRow.moreButton, children: _jsx("div", { className: styles.textWrapper, children: `${text}${items.length}` }) }) }));
|
|
11
11
|
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { WithSupportProps } from '@cloud-ru/ds-utils';
|
|
2
1
|
import { Ref } from 'react';
|
|
3
2
|
import { Size, TagRowItemInner } from '../../types.js';
|
|
4
|
-
type TagRowSimpleProps =
|
|
3
|
+
type TagRowSimpleProps = {
|
|
5
4
|
items: TagRowItemInner[];
|
|
6
5
|
size: Size;
|
|
7
6
|
onItemRemove?(item: string): void;
|
|
8
7
|
setTagRef?: (item: TagRowItemInner) => Ref<HTMLDivElement>;
|
|
9
8
|
className?: string;
|
|
10
|
-
}
|
|
9
|
+
};
|
|
11
10
|
export declare function TagRowSimple({ items, size, onItemRemove, setTagRef, className, ...rest }: TagRowSimpleProps): import("react/jsx-runtime").JSX.Element;
|
|
12
11
|
export {};
|