@snack-uikit/list 0.27.0 → 0.27.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 +11 -0
- package/dist/cjs/components/Items/BaseItem/BaseItem.d.ts +1 -1
- package/dist/cjs/components/Items/BaseItem/BaseItem.js +4 -2
- package/dist/cjs/components/Items/GroupSelectItem/GroupSelectItem.d.ts +1 -1
- package/dist/cjs/components/Items/GroupSelectItem/GroupSelectItem.js +4 -2
- package/dist/cjs/components/Items/types.d.ts +5 -0
- package/dist/esm/components/Items/BaseItem/BaseItem.d.ts +1 -1
- package/dist/esm/components/Items/BaseItem/BaseItem.js +2 -2
- package/dist/esm/components/Items/GroupSelectItem/GroupSelectItem.d.ts +1 -1
- package/dist/esm/components/Items/GroupSelectItem/GroupSelectItem.js +2 -1
- package/dist/esm/components/Items/types.d.ts +5 -0
- package/package.json +2 -2
- package/src/components/Items/BaseItem/BaseItem.tsx +7 -1
- package/src/components/Items/GroupSelectItem/GroupSelectItem.tsx +2 -0
- package/src/components/Items/types.ts +5 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
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.27.1 (2025-03-06)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **PDS-1483:** ability to provide label for toggle button for list ([bc76b1f](https://github.com/cloud-ru-tech/snack-uikit/commit/bc76b1f07a342c73809bc69816cd11423b1c6454))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# 0.27.0 (2025-03-05)
|
|
7
18
|
|
|
8
19
|
|
|
@@ -8,5 +8,5 @@ type AllBaseItemProps = FlattenBaseItem & {
|
|
|
8
8
|
isParentNode?: boolean;
|
|
9
9
|
onOpenNestedList?(e?: KeyboardEvent<HTMLElement>): void;
|
|
10
10
|
};
|
|
11
|
-
export declare function BaseItem({ beforeContent, afterContent, content, onClick, onMouseDown, id, expandIcon, disabled, open, itemRef, switch: switchProp, onKeyDown, onFocus, indeterminate, checked: checkedProp, onSelect, onOpenNestedList, isParentNode, className, inactive, itemWrapRender, ...rest }: AllBaseItemProps): string | number | boolean | Iterable<ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
11
|
+
export declare function BaseItem({ beforeContent, afterContent, content, onClick, onMouseDown, id, expandIcon, disabled, open, itemRef, switch: switchProp, showSwitchIcon, onKeyDown, onFocus, indeterminate, checked: checkedProp, onSelect, onOpenNestedList, isParentNode, className, inactive, itemWrapRender, ...rest }: AllBaseItemProps): string | number | boolean | Iterable<ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
12
12
|
export {};
|
|
@@ -41,6 +41,7 @@ function BaseItem(_a) {
|
|
|
41
41
|
open,
|
|
42
42
|
itemRef,
|
|
43
43
|
switch: switchProp,
|
|
44
|
+
showSwitchIcon,
|
|
44
45
|
onKeyDown,
|
|
45
46
|
onFocus,
|
|
46
47
|
indeterminate,
|
|
@@ -52,7 +53,7 @@ function BaseItem(_a) {
|
|
|
52
53
|
inactive,
|
|
53
54
|
itemWrapRender
|
|
54
55
|
} = _a,
|
|
55
|
-
rest = __rest(_a, ["beforeContent", "afterContent", "content", "onClick", "onMouseDown", "id", "expandIcon", "disabled", "open", "itemRef", "switch", "onKeyDown", "onFocus", "indeterminate", "checked", "onSelect", "onOpenNestedList", "isParentNode", "className", "inactive", "itemWrapRender"]);
|
|
56
|
+
rest = __rest(_a, ["beforeContent", "afterContent", "content", "onClick", "onMouseDown", "id", "expandIcon", "disabled", "open", "itemRef", "switch", "showSwitchIcon", "onKeyDown", "onFocus", "indeterminate", "checked", "onSelect", "onOpenNestedList", "isParentNode", "className", "inactive", "itemWrapRender"]);
|
|
56
57
|
const interactive = !inactive;
|
|
57
58
|
const {
|
|
58
59
|
size = 's',
|
|
@@ -189,7 +190,8 @@ function BaseItem(_a) {
|
|
|
189
190
|
}), afterContent, switchProp && interactive && (0, jsx_runtime_1.jsx)(toggles_1.Switch, {
|
|
190
191
|
disabled: disabled,
|
|
191
192
|
checked: isChecked,
|
|
192
|
-
"data-test-id": 'list__base-item-switch'
|
|
193
|
+
"data-test-id": 'list__base-item-switch',
|
|
194
|
+
showIcon: showSwitchIcon
|
|
193
195
|
}), !switchProp && expandIcon && (0, jsx_runtime_1.jsx)("span", {
|
|
194
196
|
className: styles_module_scss_2.default.expandableIcon,
|
|
195
197
|
children: expandIcon
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { CommonFlattenProps, FlattenGroupSelectListItem } from '../types';
|
|
2
2
|
type GroupSelectItemProps = Omit<FlattenGroupSelectListItem, 'type'> & CommonFlattenProps;
|
|
3
|
-
export declare function GroupSelectItem({ label, truncate, divider, items, mode, id, itemRef, allChildIds, }: GroupSelectItemProps): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare function GroupSelectItem({ label, truncate, divider, items, mode, id, itemRef, allChildIds, selectButtonLabel, }: GroupSelectItemProps): import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
export {};
|
|
@@ -16,7 +16,8 @@ function GroupSelectItem(_ref) {
|
|
|
16
16
|
mode,
|
|
17
17
|
id,
|
|
18
18
|
itemRef,
|
|
19
|
-
allChildIds
|
|
19
|
+
allChildIds,
|
|
20
|
+
selectButtonLabel
|
|
20
21
|
} = _ref;
|
|
21
22
|
const {
|
|
22
23
|
indeterminate,
|
|
@@ -39,7 +40,8 @@ function GroupSelectItem(_ref) {
|
|
|
39
40
|
indeterminate,
|
|
40
41
|
checked,
|
|
41
42
|
itemRef,
|
|
42
|
-
onClick: handleOnSelect
|
|
43
|
+
onClick: handleOnSelect,
|
|
44
|
+
label: selectButtonLabel
|
|
43
45
|
}
|
|
44
46
|
}), itemsJSX]
|
|
45
47
|
});
|
|
@@ -49,6 +49,10 @@ export type BaseItem = WithSupportProps<{
|
|
|
49
49
|
* Флаг отображения состояния выбранного элемента через switch
|
|
50
50
|
*/
|
|
51
51
|
switch?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Флаг отображения иконки у чекбоксов
|
|
54
|
+
*/
|
|
55
|
+
showSwitchIcon?: boolean;
|
|
52
56
|
itemWrapRender?(item: ReactNode): ReactNode;
|
|
53
57
|
checked?: boolean;
|
|
54
58
|
}>;
|
|
@@ -83,6 +87,7 @@ export type GroupItem = CommonGroupItem & {
|
|
|
83
87
|
export type GroupSelectItem = CommonGroupItem & {
|
|
84
88
|
items: Item[];
|
|
85
89
|
type: 'group-select';
|
|
90
|
+
selectButtonLabel?: string;
|
|
86
91
|
id?: ItemId;
|
|
87
92
|
itemRef?: RefObject<HTMLElement>;
|
|
88
93
|
};
|
|
@@ -8,5 +8,5 @@ type AllBaseItemProps = FlattenBaseItem & {
|
|
|
8
8
|
isParentNode?: boolean;
|
|
9
9
|
onOpenNestedList?(e?: KeyboardEvent<HTMLElement>): void;
|
|
10
10
|
};
|
|
11
|
-
export declare function BaseItem({ beforeContent, afterContent, content, onClick, onMouseDown, id, expandIcon, disabled, open, itemRef, switch: switchProp, onKeyDown, onFocus, indeterminate, checked: checkedProp, onSelect, onOpenNestedList, isParentNode, className, inactive, itemWrapRender, ...rest }: AllBaseItemProps): string | number | boolean | Iterable<ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
11
|
+
export declare function BaseItem({ beforeContent, afterContent, content, onClick, onMouseDown, id, expandIcon, disabled, open, itemRef, switch: switchProp, showSwitchIcon, onKeyDown, onFocus, indeterminate, checked: checkedProp, onSelect, onOpenNestedList, isParentNode, className, inactive, itemWrapRender, ...rest }: AllBaseItemProps): string | number | boolean | Iterable<ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
12
12
|
export {};
|
|
@@ -21,7 +21,7 @@ import { CHECKBOX_SIZE_MAP } from './constants';
|
|
|
21
21
|
import styles from './styles.module.css';
|
|
22
22
|
export function BaseItem(_a) {
|
|
23
23
|
var _b;
|
|
24
|
-
var { beforeContent, afterContent, content, onClick, onMouseDown, id, expandIcon, disabled, open, itemRef, switch: switchProp, onKeyDown, onFocus, indeterminate, checked: checkedProp, onSelect, onOpenNestedList, isParentNode, className, inactive, itemWrapRender } = _a, rest = __rest(_a, ["beforeContent", "afterContent", "content", "onClick", "onMouseDown", "id", "expandIcon", "disabled", "open", "itemRef", "switch", "onKeyDown", "onFocus", "indeterminate", "checked", "onSelect", "onOpenNestedList", "isParentNode", "className", "inactive", "itemWrapRender"]);
|
|
24
|
+
var { beforeContent, afterContent, content, onClick, onMouseDown, id, expandIcon, disabled, open, itemRef, switch: switchProp, showSwitchIcon, onKeyDown, onFocus, indeterminate, checked: checkedProp, onSelect, onOpenNestedList, isParentNode, className, inactive, itemWrapRender } = _a, rest = __rest(_a, ["beforeContent", "afterContent", "content", "onClick", "onMouseDown", "id", "expandIcon", "disabled", "open", "itemRef", "switch", "showSwitchIcon", "onKeyDown", "onFocus", "indeterminate", "checked", "onSelect", "onOpenNestedList", "isParentNode", "className", "inactive", "itemWrapRender"]);
|
|
25
25
|
const interactive = !inactive;
|
|
26
26
|
const { size = 's', marker, contentRender, firstItemId, focusFlattenItems } = useNewListContext();
|
|
27
27
|
const { level = 0 } = useCollapseLevelContext();
|
|
@@ -86,7 +86,7 @@ export function BaseItem(_a) {
|
|
|
86
86
|
}
|
|
87
87
|
};
|
|
88
88
|
const props = extractSupportProps(rest);
|
|
89
|
-
const itemJSX = (_jsx("div", { className: cn(commonStyles.itemWrapper, styles.innerWrapper, className), "data-inactive": inactive || undefined, "data-disabled": disabled || undefined, "data-variant": mode || undefined, "data-checked": (isParentNode && isChecked) || (!isParentNode && isChecked && !switchProp) || undefined, children: _jsxs("li", { "data-type": 'outside', role: 'menuitem', "data-test-id": props['data-test-id'] || 'list__base-item_' + id, ref: itemRef, className: cn(commonStyles.listItem, styles.droplistItem), "data-size": size, onClick: handleItemClick, onMouseDown: handleItemMouseDown, tabIndex: firstItemId && id === focusFlattenItems[firstItemId].originalId ? 0 : -1, "data-non-pointer": inactive && !onClick, "data-variant": mode || undefined, "data-open": open || undefined, onKeyDown: handleItemKeyDown, onFocus: handleItemFocus, style: { '--level': level }, "data-level-one": level === 1 || undefined, "data-level-more-one": level > 1 || undefined, "data-checked": (isParentNode && (indeterminate || isChecked)) || (isChecked && !switchProp) || undefined, 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: isParentNode ? handleCheckboxChange : undefined, checked: isChecked, "data-test-id": 'list__base-item-checkbox', onClick: handleCheckboxClick, indeterminate: indeterminate }) })), beforeContent && _jsx("div", { className: styles.beforeContent, children: beforeContent }), content && isContentItem(content) ? (((_b = contentRender === null || contentRender === void 0 ? void 0 : contentRender({ id, content, disabled })) !== null && _b !== void 0 ? _b : _jsx(ItemContent, Object.assign({ disabled: disabled }, content)))) : (_jsxs("div", { className: styles.content, children: [" ", content, " "] })), 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 })] }) }));
|
|
89
|
+
const itemJSX = (_jsx("div", { className: cn(commonStyles.itemWrapper, styles.innerWrapper, className), "data-inactive": inactive || undefined, "data-disabled": disabled || undefined, "data-variant": mode || undefined, "data-checked": (isParentNode && isChecked) || (!isParentNode && isChecked && !switchProp) || undefined, children: _jsxs("li", { "data-type": 'outside', role: 'menuitem', "data-test-id": props['data-test-id'] || 'list__base-item_' + id, ref: itemRef, className: cn(commonStyles.listItem, styles.droplistItem), "data-size": size, onClick: handleItemClick, onMouseDown: handleItemMouseDown, tabIndex: firstItemId && id === focusFlattenItems[firstItemId].originalId ? 0 : -1, "data-non-pointer": inactive && !onClick, "data-variant": mode || undefined, "data-open": open || undefined, onKeyDown: handleItemKeyDown, onFocus: handleItemFocus, style: { '--level': level }, "data-level-one": level === 1 || undefined, "data-level-more-one": level > 1 || undefined, "data-checked": (isParentNode && (indeterminate || isChecked)) || (isChecked && !switchProp) || undefined, 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: isParentNode ? handleCheckboxChange : undefined, checked: isChecked, "data-test-id": 'list__base-item-checkbox', onClick: handleCheckboxClick, indeterminate: indeterminate }) })), beforeContent && _jsx("div", { className: styles.beforeContent, children: beforeContent }), content && isContentItem(content) ? (((_b = contentRender === null || contentRender === void 0 ? void 0 : contentRender({ id, content, disabled })) !== null && _b !== void 0 ? _b : _jsx(ItemContent, Object.assign({ disabled: disabled }, content)))) : (_jsxs("div", { className: styles.content, children: [" ", content, " "] })), afterContent, switchProp && interactive && (_jsx(Switch, { disabled: disabled, checked: isChecked, "data-test-id": 'list__base-item-switch', showIcon: showSwitchIcon })), !switchProp && expandIcon && _jsx("span", { className: styles.expandableIcon, children: expandIcon })] }) }));
|
|
90
90
|
if (!itemWrapRender) {
|
|
91
91
|
return itemJSX;
|
|
92
92
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { CommonFlattenProps, FlattenGroupSelectListItem } from '../types';
|
|
2
2
|
type GroupSelectItemProps = Omit<FlattenGroupSelectListItem, 'type'> & CommonFlattenProps;
|
|
3
|
-
export declare function GroupSelectItem({ label, truncate, divider, items, mode, id, itemRef, allChildIds, }: GroupSelectItemProps): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare function GroupSelectItem({ label, truncate, divider, items, mode, id, itemRef, allChildIds, selectButtonLabel, }: GroupSelectItemProps): import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Separator } from '../../../helperComponents';
|
|
3
3
|
import { useGroupItemSelection, useRenderItems } from '../hooks';
|
|
4
|
-
export function GroupSelectItem({ label, truncate, divider, items, mode, id, itemRef, allChildIds, }) {
|
|
4
|
+
export function GroupSelectItem({ label, truncate, divider, items, mode, id, itemRef, allChildIds, selectButtonLabel, }) {
|
|
5
5
|
const { indeterminate, checked, handleOnSelect } = useGroupItemSelection({
|
|
6
6
|
items,
|
|
7
7
|
id,
|
|
@@ -14,5 +14,6 @@ export function GroupSelectItem({ label, truncate, divider, items, mode, id, ite
|
|
|
14
14
|
checked,
|
|
15
15
|
itemRef,
|
|
16
16
|
onClick: handleOnSelect,
|
|
17
|
+
label: selectButtonLabel,
|
|
17
18
|
} }), itemsJSX] }));
|
|
18
19
|
}
|
|
@@ -49,6 +49,10 @@ export type BaseItem = WithSupportProps<{
|
|
|
49
49
|
* Флаг отображения состояния выбранного элемента через switch
|
|
50
50
|
*/
|
|
51
51
|
switch?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Флаг отображения иконки у чекбоксов
|
|
54
|
+
*/
|
|
55
|
+
showSwitchIcon?: boolean;
|
|
52
56
|
itemWrapRender?(item: ReactNode): ReactNode;
|
|
53
57
|
checked?: boolean;
|
|
54
58
|
}>;
|
|
@@ -83,6 +87,7 @@ export type GroupItem = CommonGroupItem & {
|
|
|
83
87
|
export type GroupSelectItem = CommonGroupItem & {
|
|
84
88
|
items: Item[];
|
|
85
89
|
type: 'group-select';
|
|
90
|
+
selectButtonLabel?: string;
|
|
86
91
|
id?: ItemId;
|
|
87
92
|
itemRef?: RefObject<HTMLElement>;
|
|
88
93
|
};
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "List",
|
|
7
|
-
"version": "0.27.
|
|
7
|
+
"version": "0.27.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": "cafb29b74a6ac4d38594e9d46599617925165935"
|
|
58
58
|
}
|
|
@@ -38,6 +38,7 @@ export function BaseItem({
|
|
|
38
38
|
open,
|
|
39
39
|
itemRef,
|
|
40
40
|
switch: switchProp,
|
|
41
|
+
showSwitchIcon,
|
|
41
42
|
onKeyDown,
|
|
42
43
|
onFocus,
|
|
43
44
|
indeterminate,
|
|
@@ -188,7 +189,12 @@ export function BaseItem({
|
|
|
188
189
|
{afterContent}
|
|
189
190
|
|
|
190
191
|
{switchProp && interactive && (
|
|
191
|
-
<Switch
|
|
192
|
+
<Switch
|
|
193
|
+
disabled={disabled}
|
|
194
|
+
checked={isChecked}
|
|
195
|
+
data-test-id='list__base-item-switch'
|
|
196
|
+
showIcon={showSwitchIcon}
|
|
197
|
+
/>
|
|
192
198
|
)}
|
|
193
199
|
|
|
194
200
|
{!switchProp && expandIcon && <span className={styles.expandableIcon}>{expandIcon}</span>}
|
|
@@ -13,6 +13,7 @@ export function GroupSelectItem({
|
|
|
13
13
|
id,
|
|
14
14
|
itemRef,
|
|
15
15
|
allChildIds,
|
|
16
|
+
selectButtonLabel,
|
|
16
17
|
}: GroupSelectItemProps) {
|
|
17
18
|
const { indeterminate, checked, handleOnSelect } = useGroupItemSelection({
|
|
18
19
|
items,
|
|
@@ -35,6 +36,7 @@ export function GroupSelectItem({
|
|
|
35
36
|
checked,
|
|
36
37
|
itemRef,
|
|
37
38
|
onClick: handleOnSelect,
|
|
39
|
+
label: selectButtonLabel,
|
|
38
40
|
}}
|
|
39
41
|
/>
|
|
40
42
|
|
|
@@ -58,6 +58,10 @@ export type BaseItem = WithSupportProps<{
|
|
|
58
58
|
* Флаг отображения состояния выбранного элемента через switch
|
|
59
59
|
*/
|
|
60
60
|
switch?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Флаг отображения иконки у чекбоксов
|
|
63
|
+
*/
|
|
64
|
+
showSwitchIcon?: boolean;
|
|
61
65
|
|
|
62
66
|
itemWrapRender?(item: ReactNode): ReactNode;
|
|
63
67
|
|
|
@@ -106,6 +110,7 @@ export type GroupItem = CommonGroupItem & {
|
|
|
106
110
|
export type GroupSelectItem = CommonGroupItem & {
|
|
107
111
|
items: Item[];
|
|
108
112
|
type: 'group-select';
|
|
113
|
+
selectButtonLabel?: string;
|
|
109
114
|
|
|
110
115
|
id?: ItemId;
|
|
111
116
|
itemRef?: RefObject<HTMLElement>;
|