@snack-uikit/list 0.7.1 → 0.8.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/CHANGELOG.md +22 -0
- package/dist/components/Items/BaseItem/BaseItem.js +3 -2
- package/dist/components/Items/BaseItem/styles.module.css +3 -7
- package/dist/components/Items/types.d.ts +4 -0
- package/package.json +2 -2
- package/src/components/Items/BaseItem/BaseItem.tsx +11 -3
- package/src/components/Items/BaseItem/styles.module.scss +2 -8
- package/src/components/Items/types.ts +4 -0
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.0 (2024-03-11)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **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))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## 0.7.2 (2024-03-07)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* **FF-4473:** droplist item width ([99f5f25](https://github.com/cloud-ru-tech/snack-uikit/commit/99f5f251ac176ae3c6c9d2c9b78c31890aea0317))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
6
28
|
## 0.7.1 (2024-02-29)
|
|
7
29
|
|
|
8
30
|
### Only dependencies have been changed
|
|
@@ -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
|
}
|
|
@@ -78,6 +78,9 @@
|
|
|
78
78
|
box-sizing:border-box;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
.droplistItem{
|
|
82
|
+
width:100%;
|
|
83
|
+
}
|
|
81
84
|
.droplistItem[data-size=s]{
|
|
82
85
|
padding-left:calc(var(--level, 0) * var(--dimension-050m, 4px) + var(--space-drop-list-item-s-container-horizontal-padding, 8px));
|
|
83
86
|
}
|
|
@@ -171,13 +174,6 @@
|
|
|
171
174
|
letter-spacing:var(--sans-body-m-letter-spacing, 0.1px);
|
|
172
175
|
paragraph-spacing:var(--sans-body-m-paragraph-spacing, 7.7px);
|
|
173
176
|
}
|
|
174
|
-
.droplistItem[data-parent=list]{
|
|
175
|
-
width:100%;
|
|
176
|
-
}
|
|
177
|
-
.droplistItem[data-parent=droplist]{
|
|
178
|
-
width:-moz-max-content;
|
|
179
|
-
width:max-content;
|
|
180
|
-
}
|
|
181
177
|
.droplistItem[data-non-pointer]{
|
|
182
178
|
cursor:inherit;
|
|
183
179
|
}
|
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.0",
|
|
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": "113e80e60c1a5ce1ce6957d48d37a6181991c5fd"
|
|
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>
|
|
@@ -110,6 +110,8 @@ $typography: (
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
.droplistItem {
|
|
113
|
+
width: 100%;
|
|
114
|
+
|
|
113
115
|
@each $size in $sizes {
|
|
114
116
|
&[data-size='#{$size}'] {
|
|
115
117
|
padding-left: calc(
|
|
@@ -134,14 +136,6 @@ $typography: (
|
|
|
134
136
|
}
|
|
135
137
|
}
|
|
136
138
|
|
|
137
|
-
&[data-parent='list'] {
|
|
138
|
-
width: 100%;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
&[data-parent='droplist'] {
|
|
142
|
-
width: max-content;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
139
|
&[data-non-pointer] {
|
|
146
140
|
cursor: inherit;
|
|
147
141
|
}
|