@snack-uikit/list 0.7.2 → 0.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/CHANGELOG.md +22 -0
- package/dist/components/Items/BaseItem/BaseItem.js +3 -2
- package/dist/components/Items/types.d.ts +4 -0
- package/dist/helperComponents/Separator/Separator.js +2 -1
- package/dist/helperComponents/Separator/styles.module.css +11 -1
- package/package.json +2 -2
- package/src/components/Items/BaseItem/BaseItem.tsx +11 -3
- package/src/components/Items/types.ts +4 -0
- package/src/helperComponents/Separator/Separator.tsx +4 -2
- package/src/helperComponents/Separator/styles.module.scss +12 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,28 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 0.8.1 (2024-03-19)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **FF-4559:** truncate long group label ([4862a19](https://github.com/cloud-ru-tech/snack-uikit/commit/4862a192452c6e3b735ec0da0218e0af028dc127))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# 0.8.0 (2024-03-11)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* **FF-4491:** add truncate prop to droplist items, add test-ids to caption and description ([c321e1b](https://github.com/cloud-ru-tech/snack-uikit/commit/c321e1bb199fc7997a0cfb8467f98b0acd7f8b6a))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
6
28
|
## 0.7.2 (2024-03-07)
|
|
7
29
|
|
|
8
30
|
|
|
@@ -19,8 +19,9 @@ import commonStyles from '../styles.module.css';
|
|
|
19
19
|
import { CHECKBOX_SIZE_MAP } from './constants';
|
|
20
20
|
import styles from './styles.module.css';
|
|
21
21
|
export function BaseItem(_a) {
|
|
22
|
+
var _b, _c;
|
|
22
23
|
var { beforeContent, afterContent, content, onClick, onMouseDown, id, expandIcon, disabled, open, itemRef, switch: switchProp, onKeyDown, onFocus, indeterminate, onSelect, isParentNode, className, inactive, itemWrapRender } = _a, rest = __rest(_a, ["beforeContent", "afterContent", "content", "onClick", "onMouseDown", "id", "expandIcon", "disabled", "open", "itemRef", "switch", "onKeyDown", "onFocus", "indeterminate", "onSelect", "isParentNode", "className", "inactive", "itemWrapRender"]);
|
|
23
|
-
const { option, caption, description } = content || {};
|
|
24
|
+
const { option, caption, description, truncate: contentTruncate } = content || {};
|
|
24
25
|
const interactive = !inactive;
|
|
25
26
|
const { parentResetActiveFocusIndex } = useParentListContext();
|
|
26
27
|
const { size, marker, parent } = useListContext();
|
|
@@ -70,7 +71,7 @@ export function BaseItem(_a) {
|
|
|
70
71
|
e.stopPropagation();
|
|
71
72
|
};
|
|
72
73
|
const props = extractSupportProps(rest);
|
|
73
|
-
const item = (_jsxs("li", { role: 'menuitem', "data-test-id": props['data-test-id'] || 'list__base-item_' + id, ref: itemRef, className: cn(commonStyles.listItem, styles.droplistItem, className), "data-size": size, onClick: handleItemClick, onMouseDown: onMouseDown, tabIndex: -1, "data-non-pointer": inactive && !onClick, "data-inactive": inactive || undefined, "data-checked": (isParentNode && (indeterminate || isChecked)) || (isChecked && !switchProp) || undefined, "data-variant": mode || undefined, "data-open": open || undefined, "data-disabled": disabled || undefined, "aria-disabled": disabled || undefined, "data-parent": parent || 'list', onKeyDown: handleItemKeyDown, onFocus: handleItemFocus, style: { '--level': level }, children: [!switchProp && isSelectionSingle && marker && !isParentNode && interactive && (_jsx("div", { className: styles.markerContainer, "data-test-id": 'list__base-item-marker' })), !switchProp && isSelectionMultiple && interactive && (_jsx("div", { className: styles.checkbox, children: _jsx(Checkbox, { size: CHECKBOX_SIZE_MAP[size !== null && size !== void 0 ? size : 's'], disabled: disabled, tabIndex: -1, onChange: handleCheckboxChange, checked: isChecked, "data-test-id": 'list__base-item-checkbox', onClick: handleCheckboxClick, indeterminate: indeterminate }) })), beforeContent && _jsx("div", { className: styles.beforeContent, children: beforeContent }), _jsxs("div", { className: styles.content, children: [_jsxs("div", { className: styles.headline, children: [_jsx("span", { className: styles.option, children: _jsx(TruncateString, { text: option, maxLines: 1 }) }), caption && _jsx("span", { className: styles.caption, children: caption })] }), description && (_jsx("div", { className: styles.description, children: _jsx(TruncateString, { text: description, maxLines: 2 }) }))] }), afterContent, switchProp && interactive && (_jsx(Switch, { disabled: disabled, checked: isChecked, "data-test-id": 'list__base-item-switch' })), !switchProp && expandIcon && _jsx("span", { className: styles.expandableIcon, children: expandIcon })] }));
|
|
74
|
+
const item = (_jsxs("li", { role: 'menuitem', "data-test-id": props['data-test-id'] || 'list__base-item_' + id, ref: itemRef, className: cn(commonStyles.listItem, styles.droplistItem, className), "data-size": size, onClick: handleItemClick, onMouseDown: onMouseDown, tabIndex: -1, "data-non-pointer": inactive && !onClick, "data-inactive": inactive || undefined, "data-checked": (isParentNode && (indeterminate || isChecked)) || (isChecked && !switchProp) || undefined, "data-variant": mode || undefined, "data-open": open || undefined, "data-disabled": disabled || undefined, "aria-disabled": disabled || undefined, "data-parent": parent || 'list', onKeyDown: handleItemKeyDown, onFocus: handleItemFocus, style: { '--level': level }, children: [!switchProp && isSelectionSingle && marker && !isParentNode && interactive && (_jsx("div", { className: styles.markerContainer, "data-test-id": 'list__base-item-marker' })), !switchProp && isSelectionMultiple && interactive && (_jsx("div", { className: styles.checkbox, children: _jsx(Checkbox, { size: CHECKBOX_SIZE_MAP[size !== null && size !== void 0 ? size : 's'], disabled: disabled, tabIndex: -1, onChange: handleCheckboxChange, checked: isChecked, "data-test-id": 'list__base-item-checkbox', onClick: handleCheckboxClick, indeterminate: indeterminate }) })), beforeContent && _jsx("div", { className: styles.beforeContent, children: beforeContent }), _jsxs("div", { className: styles.content, children: [_jsxs("div", { className: styles.headline, children: [_jsx("span", { className: styles.option, children: _jsx(TruncateString, { text: option, maxLines: (_b = contentTruncate === null || contentTruncate === void 0 ? void 0 : contentTruncate.option) !== null && _b !== void 0 ? _b : 1, "data-test-id": 'list__base-item-option' }) }), caption && _jsx("span", { className: styles.caption, children: caption })] }), description && (_jsx("div", { className: styles.description, children: _jsx(TruncateString, { text: description, maxLines: (_c = contentTruncate === null || contentTruncate === void 0 ? void 0 : contentTruncate.description) !== null && _c !== void 0 ? _c : 2, "data-test-id": 'list__base-item-description' }) }))] }), afterContent, switchProp && interactive && (_jsx(Switch, { disabled: disabled, checked: isChecked, "data-test-id": 'list__base-item-switch' })), !switchProp && expandIcon && _jsx("span", { className: styles.expandableIcon, children: expandIcon })] }));
|
|
74
75
|
if (!itemWrapRender) {
|
|
75
76
|
return item;
|
|
76
77
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Divider } from '@snack-uikit/divider';
|
|
3
|
+
import { TruncateString } from '@snack-uikit/truncate-string';
|
|
3
4
|
import styles from './styles.module.css';
|
|
4
5
|
export function Separator({ label, divider, mode = 'secondary', size = 's' }) {
|
|
5
6
|
if (label) {
|
|
6
|
-
return (_jsxs("div", { className: styles.separatorWithLabel, "data-size": size, children: [_jsx("span", { className: styles.label, "data-mode": mode, children: label }), divider && _jsx(Divider, { weight: mode === 'primary' ? 'regular' : 'light' })] }));
|
|
7
|
+
return (_jsxs("div", { className: styles.separatorWithLabel, "data-size": size, children: [_jsx("span", { className: styles.label, "data-mode": mode, children: _jsx(TruncateString, { text: label, maxLines: 1 }) }), divider && _jsx(Divider, { weight: mode === 'primary' ? 'regular' : 'light', className: styles.divider })] }));
|
|
7
8
|
}
|
|
8
9
|
if (divider) {
|
|
9
10
|
return (_jsx("div", { className: styles.separatorWithoutLabel, "data-size": size, children: _jsx(Divider, { weight: 'regular' }) }));
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
.separatorWithLabel{
|
|
2
|
+
overflow:hidden;
|
|
2
3
|
display:flex;
|
|
3
4
|
gap:var(--dimension-1m, 8px);
|
|
4
5
|
align-items:flex-end;
|
|
5
6
|
box-sizing:border-box;
|
|
7
|
+
width:100%;
|
|
8
|
+
min-width:100%;
|
|
6
9
|
}
|
|
7
10
|
.separatorWithLabel[data-size=s]{
|
|
8
11
|
padding-top:var(--space-drop-list-item-s-container-separator-subheader-vertical-padding, 4px);
|
|
@@ -102,11 +105,18 @@
|
|
|
102
105
|
}
|
|
103
106
|
|
|
104
107
|
.label{
|
|
105
|
-
|
|
108
|
+
overflow:hidden;
|
|
109
|
+
flex-shrink:1;
|
|
106
110
|
}
|
|
107
111
|
.label[data-mode=primary]{
|
|
108
112
|
color:var(--sys-neutral-text-main, #33333b);
|
|
109
113
|
}
|
|
110
114
|
.label[data-mode=secondary]{
|
|
111
115
|
color:var(--sys-neutral-text-light, #868892);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
hr.divider{
|
|
119
|
+
flex:1;
|
|
120
|
+
width:auto;
|
|
121
|
+
min-width:0;
|
|
112
122
|
}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "List",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.8.1",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"@snack-uikit/locale": "*"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "886b294a5276c22c27fe63aaf6f71b0ab3f5e63f"
|
|
58
58
|
}
|
|
@@ -36,7 +36,7 @@ export function BaseItem({
|
|
|
36
36
|
itemWrapRender,
|
|
37
37
|
...rest
|
|
38
38
|
}: AllBaseItemProps) {
|
|
39
|
-
const { option, caption, description } = content || {};
|
|
39
|
+
const { option, caption, description, truncate: contentTruncate } = content || {};
|
|
40
40
|
const interactive = !inactive;
|
|
41
41
|
|
|
42
42
|
const { parentResetActiveFocusIndex } = useParentListContext();
|
|
@@ -145,14 +145,22 @@ export function BaseItem({
|
|
|
145
145
|
<div className={styles.content}>
|
|
146
146
|
<div className={styles.headline}>
|
|
147
147
|
<span className={styles.option}>
|
|
148
|
-
<TruncateString
|
|
148
|
+
<TruncateString
|
|
149
|
+
text={option}
|
|
150
|
+
maxLines={contentTruncate?.option ?? 1}
|
|
151
|
+
data-test-id='list__base-item-option'
|
|
152
|
+
/>
|
|
149
153
|
</span>
|
|
150
154
|
{caption && <span className={styles.caption}>{caption}</span>}
|
|
151
155
|
</div>
|
|
152
156
|
|
|
153
157
|
{description && (
|
|
154
158
|
<div className={styles.description}>
|
|
155
|
-
<TruncateString
|
|
159
|
+
<TruncateString
|
|
160
|
+
text={description}
|
|
161
|
+
maxLines={contentTruncate?.description ?? 2}
|
|
162
|
+
data-test-id='list__base-item-description'
|
|
163
|
+
/>
|
|
156
164
|
</div>
|
|
157
165
|
)}
|
|
158
166
|
</div>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Divider } from '@snack-uikit/divider';
|
|
2
|
+
import { TruncateString } from '@snack-uikit/truncate-string';
|
|
2
3
|
|
|
3
4
|
import styles from './styles.module.scss';
|
|
4
5
|
|
|
@@ -14,9 +15,10 @@ export function Separator({ label, divider, mode = 'secondary', size = 's' }: Se
|
|
|
14
15
|
return (
|
|
15
16
|
<div className={styles.separatorWithLabel} data-size={size}>
|
|
16
17
|
<span className={styles.label} data-mode={mode}>
|
|
17
|
-
{label}
|
|
18
|
+
<TruncateString text={label} maxLines={1} />
|
|
18
19
|
</span>
|
|
19
|
-
|
|
20
|
+
|
|
21
|
+
{divider && <Divider weight={mode === 'primary' ? 'regular' : 'light'} className={styles.divider} />}
|
|
20
22
|
</div>
|
|
21
23
|
);
|
|
22
24
|
}
|
|
@@ -16,10 +16,14 @@ $typography-secondary: (
|
|
|
16
16
|
);
|
|
17
17
|
|
|
18
18
|
.separatorWithLabel {
|
|
19
|
+
overflow: hidden;
|
|
19
20
|
display: flex;
|
|
20
21
|
gap: $dimension-1m;
|
|
21
22
|
align-items: flex-end;
|
|
23
|
+
|
|
22
24
|
box-sizing: border-box;
|
|
25
|
+
width: 100%;
|
|
26
|
+
min-width: 100%;
|
|
23
27
|
|
|
24
28
|
@each $size in $sizes {
|
|
25
29
|
&[data-size='#{$size}'] {
|
|
@@ -51,7 +55,8 @@ $typography-secondary: (
|
|
|
51
55
|
}
|
|
52
56
|
|
|
53
57
|
.label {
|
|
54
|
-
|
|
58
|
+
overflow: hidden;
|
|
59
|
+
flex-shrink: 1;
|
|
55
60
|
|
|
56
61
|
&[data-mode='primary'] {
|
|
57
62
|
color: $sys-neutral-text-main;
|
|
@@ -61,3 +66,9 @@ $typography-secondary: (
|
|
|
61
66
|
color: $sys-neutral-text-light;
|
|
62
67
|
}
|
|
63
68
|
}
|
|
69
|
+
|
|
70
|
+
hr.divider {
|
|
71
|
+
flex: 1;
|
|
72
|
+
width: auto;
|
|
73
|
+
min-width: 0;
|
|
74
|
+
}
|