@snack-uikit/list 0.33.3-preview-02d918ac.0 → 0.33.3
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/AccordionItem/AccordionItem.js +24 -28
- package/dist/cjs/components/Items/BaseItem/BaseItem.js +41 -45
- package/dist/cjs/components/Items/GroupSelectItem/GroupSelectItem.js +18 -21
- package/dist/cjs/components/Items/NextListItem/NextListItem.js +61 -60
- package/dist/cjs/components/Items/PinGroupItem/PinGroupItem.js +9 -13
- package/dist/cjs/components/Items/SearchItem/SearchItem.js +6 -8
- package/dist/cjs/components/Items/hooks.js +25 -36
- package/dist/cjs/components/Items/utils.js +32 -41
- package/dist/cjs/components/Lists/Droplist/DropList.js +95 -88
- package/dist/cjs/components/Lists/List/List.js +79 -76
- package/dist/cjs/components/Lists/ListPrivate/ListPrivate.js +75 -71
- package/dist/cjs/components/Lists/contexts/NewListProvider.js +8 -12
- package/dist/cjs/components/Lists/contexts/SelectionProvider.js +29 -29
- package/dist/cjs/components/Lists/hooks.js +12 -9
- package/dist/cjs/helperComponents/CollapseBlockPrivate/CollapseBlockPrivate.js +4 -6
- package/dist/cjs/helperComponents/HiddenTabButton/HiddenTabButton.js +2 -4
- package/dist/cjs/helperComponents/ItemContent/ItemContent.js +9 -11
- package/dist/cjs/helperComponents/ListEmptyState/ListEmptyState.js +6 -8
- package/dist/cjs/helperComponents/ListEmptyState/hooks.js +5 -8
- package/dist/cjs/helperComponents/Separator/Separator.js +15 -19
- package/dist/cjs/helpers.js +1 -1
- package/package.json +5 -5
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.33.3 (2026-07-03)
|
|
7
|
+
|
|
8
|
+
### Only dependencies have been changed
|
|
9
|
+
* [@snack-uikit/dropdown@0.5.8]($PUBLIC_PROJECT_URL/blob/master/packages/dropdown/CHANGELOG.md)
|
|
10
|
+
* [@snack-uikit/info-block@0.6.43]($PUBLIC_PROJECT_URL/blob/master/packages/info-block/CHANGELOG.md)
|
|
11
|
+
* [@snack-uikit/truncate-string@0.7.14]($PUBLIC_PROJECT_URL/blob/master/packages/truncate-string/CHANGELOG.md)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## 0.33.2 (2026-06-24)
|
|
7
18
|
|
|
8
19
|
|
|
@@ -20,35 +20,31 @@ const contexts_1 = require("../../Lists/contexts");
|
|
|
20
20
|
const BaseItem_1 = require("../BaseItem");
|
|
21
21
|
const hooks_1 = require("../hooks");
|
|
22
22
|
function AccordionItem(_a) {
|
|
23
|
-
var
|
|
23
|
+
var id = _a.id,
|
|
24
|
+
disabled = _a.disabled,
|
|
25
|
+
allChildIds = _a.allChildIds,
|
|
26
|
+
items = _a.items,
|
|
27
|
+
option = __rest(_a, ["id", "disabled", "allChildIds", "items"]);
|
|
28
|
+
const _ref = (0, contexts_1.useCollapseLevelContext)(),
|
|
29
|
+
_ref$level = _ref.level,
|
|
30
|
+
level = _ref$level === void 0 ? 0 : _ref$level;
|
|
31
|
+
const _ref2 = (0, contexts_1.useCollapseContext)(),
|
|
32
|
+
_ref2$openCollapseIte = _ref2.openCollapseItems,
|
|
33
|
+
openCollapseItems = _ref2$openCollapseIte === void 0 ? [] : _ref2$openCollapseIte,
|
|
34
|
+
toggleOpenCollapseItem = _ref2.toggleOpenCollapseItem;
|
|
35
|
+
const _ref3 = (0, contexts_1.useSelectionContext)(),
|
|
36
|
+
value = _ref3.value,
|
|
37
|
+
isSelectionSingle = _ref3.isSelectionSingle,
|
|
38
|
+
isSelectionMultiple = _ref3.isSelectionMultiple;
|
|
39
|
+
const _ref4 = (0, hooks_1.useGroupItemSelection)({
|
|
40
|
+
items,
|
|
24
41
|
id,
|
|
25
42
|
disabled,
|
|
26
|
-
allChildIds
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
level = 0
|
|
32
|
-
} = (0, contexts_1.useCollapseLevelContext)();
|
|
33
|
-
const {
|
|
34
|
-
openCollapseItems = [],
|
|
35
|
-
toggleOpenCollapseItem
|
|
36
|
-
} = (0, contexts_1.useCollapseContext)();
|
|
37
|
-
const {
|
|
38
|
-
value,
|
|
39
|
-
isSelectionSingle,
|
|
40
|
-
isSelectionMultiple
|
|
41
|
-
} = (0, contexts_1.useSelectionContext)();
|
|
42
|
-
const {
|
|
43
|
-
indeterminate,
|
|
44
|
-
handleOnSelect,
|
|
45
|
-
checked: checkedProp
|
|
46
|
-
} = (0, hooks_1.useGroupItemSelection)({
|
|
47
|
-
items,
|
|
48
|
-
id,
|
|
49
|
-
disabled,
|
|
50
|
-
allChildIds
|
|
51
|
-
});
|
|
43
|
+
allChildIds
|
|
44
|
+
}),
|
|
45
|
+
indeterminate = _ref4.indeterminate,
|
|
46
|
+
handleOnSelect = _ref4.handleOnSelect,
|
|
47
|
+
checkedProp = _ref4.checked;
|
|
52
48
|
const isOpen = Boolean(openCollapseItems.includes(id !== null && id !== void 0 ? id : ''));
|
|
53
49
|
const checked = Boolean(indeterminate && !isOpen && isSelectionSingle && value && allChildIds.includes(value) || isSelectionMultiple && checkedProp);
|
|
54
50
|
const handleKeyDown = (0, react_1.useCallback)(() => {
|
|
@@ -73,7 +69,7 @@ function AccordionItem(_a) {
|
|
|
73
69
|
onSelect: !disabled ? handleOnSelect : undefined
|
|
74
70
|
})),
|
|
75
71
|
expanded: isOpen,
|
|
76
|
-
"data-test-id":
|
|
72
|
+
"data-test-id": "list__accordion-item-".concat(id),
|
|
77
73
|
children: (0, jsx_runtime_1.jsx)(contexts_1.CollapseLevelContext.Provider, {
|
|
78
74
|
value: {
|
|
79
75
|
level: level + 1
|
|
@@ -29,53 +29,49 @@ const constants_1 = require("./constants");
|
|
|
29
29
|
const styles_module_scss_2 = __importDefault(require('./styles.module.css'));
|
|
30
30
|
function BaseItem(_a) {
|
|
31
31
|
var _b;
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
itemWrapRender
|
|
55
|
-
} = _a,
|
|
32
|
+
var beforeContent = _a.beforeContent,
|
|
33
|
+
afterContent = _a.afterContent,
|
|
34
|
+
content = _a.content,
|
|
35
|
+
onClick = _a.onClick,
|
|
36
|
+
onMouseDown = _a.onMouseDown,
|
|
37
|
+
id = _a.id,
|
|
38
|
+
expandIcon = _a.expandIcon,
|
|
39
|
+
disabled = _a.disabled,
|
|
40
|
+
open = _a.open,
|
|
41
|
+
itemRef = _a.itemRef,
|
|
42
|
+
switchProp = _a.switch,
|
|
43
|
+
showSwitchIcon = _a.showSwitchIcon,
|
|
44
|
+
onKeyDown = _a.onKeyDown,
|
|
45
|
+
onFocus = _a.onFocus,
|
|
46
|
+
indeterminate = _a.indeterminate,
|
|
47
|
+
checkedProp = _a.checked,
|
|
48
|
+
onSelect = _a.onSelect,
|
|
49
|
+
onOpenNestedList = _a.onOpenNestedList,
|
|
50
|
+
isParentNode = _a.isParentNode,
|
|
51
|
+
className = _a.className,
|
|
52
|
+
inactive = _a.inactive,
|
|
53
|
+
itemWrapRender = _a.itemWrapRender,
|
|
56
54
|
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"]);
|
|
57
55
|
const interactive = !inactive;
|
|
58
|
-
const
|
|
59
|
-
size =
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
level =
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
closeDroplist,
|
|
70
|
-
closeDroplistOnItemClick
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
isSelectionMultiple
|
|
78
|
-
} = (0, contexts_1.useSelectionContext)();
|
|
56
|
+
const _ref = (0, contexts_1.useNewListContext)(),
|
|
57
|
+
_ref$size = _ref.size,
|
|
58
|
+
size = _ref$size === void 0 ? 's' : _ref$size,
|
|
59
|
+
marker = _ref.marker,
|
|
60
|
+
contentRender = _ref.contentRender,
|
|
61
|
+
firstItemId = _ref.firstItemId,
|
|
62
|
+
focusFlattenItems = _ref.focusFlattenItems;
|
|
63
|
+
const _ref2 = (0, contexts_1.useCollapseLevelContext)(),
|
|
64
|
+
_ref2$level = _ref2.level,
|
|
65
|
+
level = _ref2$level === void 0 ? 0 : _ref2$level;
|
|
66
|
+
const _ref3 = (0, contexts_1.useOpenListContext)(),
|
|
67
|
+
closeDroplist = _ref3.closeDroplist,
|
|
68
|
+
closeDroplistOnItemClick = _ref3.closeDroplistOnItemClick;
|
|
69
|
+
const _ref4 = (0, contexts_1.useSelectionContext)(),
|
|
70
|
+
value = _ref4.value,
|
|
71
|
+
onChange = _ref4.onChange,
|
|
72
|
+
mode = _ref4.mode,
|
|
73
|
+
isSelectionSingle = _ref4.isSelectionSingle,
|
|
74
|
+
isSelectionMultiple = _ref4.isSelectionMultiple;
|
|
79
75
|
const isChecked = isSelectionSingle ? checkedProp !== null && checkedProp !== void 0 ? checkedProp : value === id : checkedProp !== null && checkedProp !== void 0 ? checkedProp : value === null || value === void 0 ? void 0 : value.includes(id !== null && id !== void 0 ? id : '');
|
|
80
76
|
const handleChange = () => {
|
|
81
77
|
onChange === null || onChange === void 0 ? void 0 : onChange(id);
|
|
@@ -8,27 +8,24 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
8
8
|
const helperComponents_1 = require("../../../helperComponents");
|
|
9
9
|
const hooks_1 = require("../hooks");
|
|
10
10
|
function GroupSelectItem(_ref) {
|
|
11
|
-
let
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
disabled: false,
|
|
30
|
-
allChildIds
|
|
31
|
-
});
|
|
11
|
+
let label = _ref.label,
|
|
12
|
+
truncate = _ref.truncate,
|
|
13
|
+
divider = _ref.divider,
|
|
14
|
+
items = _ref.items,
|
|
15
|
+
mode = _ref.mode,
|
|
16
|
+
id = _ref.id,
|
|
17
|
+
itemRef = _ref.itemRef,
|
|
18
|
+
allChildIds = _ref.allChildIds,
|
|
19
|
+
selectButtonLabel = _ref.selectButtonLabel;
|
|
20
|
+
const _ref2 = (0, hooks_1.useGroupItemSelection)({
|
|
21
|
+
items,
|
|
22
|
+
id,
|
|
23
|
+
disabled: false,
|
|
24
|
+
allChildIds
|
|
25
|
+
}),
|
|
26
|
+
indeterminate = _ref2.indeterminate,
|
|
27
|
+
checked = _ref2.checked,
|
|
28
|
+
handleOnSelect = _ref2.handleOnSelect;
|
|
32
29
|
const itemsJSX = (0, hooks_1.useRenderItems)(items);
|
|
33
30
|
return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, {
|
|
34
31
|
children: [(0, jsx_runtime_1.jsx)(helperComponents_1.Separator, {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
|
|
3
5
|
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
4
6
|
var t = {};
|
|
5
7
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
@@ -24,58 +26,58 @@ const hooks_1 = require("../hooks");
|
|
|
24
26
|
const utils_1 = require("../utils");
|
|
25
27
|
const constants_2 = require("./constants");
|
|
26
28
|
function NextListItem(_a) {
|
|
27
|
-
var
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
29
|
+
var items = _a.items,
|
|
30
|
+
_a$placement = _a.placement,
|
|
31
|
+
placement = _a$placement === void 0 ? 'right-start' : _a$placement,
|
|
32
|
+
id = _a.id,
|
|
33
|
+
scroll = _a.scroll,
|
|
34
|
+
scrollRef = _a.scrollRef,
|
|
35
|
+
disabled = _a.disabled,
|
|
36
|
+
onSublistOpenChanged = _a.onSublistOpenChanged,
|
|
37
|
+
allChildIds = _a.allChildIds,
|
|
38
|
+
_a$loading = _a.loading,
|
|
39
|
+
loading = _a$loading === void 0 ? false : _a$loading,
|
|
40
|
+
_a$focusId = _a.focusId,
|
|
41
|
+
focusId = _a$focusId === void 0 ? id : _a$focusId,
|
|
42
|
+
_a$untouchableScrollb = _a.untouchableScrollbars,
|
|
43
|
+
untouchableScrollbars = _a$untouchableScrollb === void 0 ? false : _a$untouchableScrollb,
|
|
40
44
|
option = __rest(_a, ["items", "placement", "id", "scroll", "scrollRef", "disabled", "onSublistOpenChanged", "allChildIds", "loading", "focusId", "untouchableScrollbars"]);
|
|
41
|
-
const
|
|
42
|
-
flattenItems,
|
|
43
|
-
focusFlattenItems,
|
|
44
|
-
virtualized
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
openCollapseItems = []
|
|
53
|
-
} = (0, contexts_1.useCollapseContext)();
|
|
45
|
+
const _ref = (0, contexts_1.useNewListContext)(),
|
|
46
|
+
flattenItems = _ref.flattenItems,
|
|
47
|
+
focusFlattenItems = _ref.focusFlattenItems,
|
|
48
|
+
virtualized = _ref.virtualized;
|
|
49
|
+
const _ref2 = (0, contexts_1.useSelectionContext)(),
|
|
50
|
+
value = _ref2.value,
|
|
51
|
+
isSelectionSingle = _ref2.isSelectionSingle,
|
|
52
|
+
isSelectionMultiple = _ref2.isSelectionMultiple;
|
|
53
|
+
const _ref3 = (0, contexts_1.useCollapseContext)(),
|
|
54
|
+
_ref3$openCollapseIte = _ref3.openCollapseItems,
|
|
55
|
+
openCollapseItems = _ref3$openCollapseIte === void 0 ? [] : _ref3$openCollapseIte;
|
|
54
56
|
const item = flattenItems[id];
|
|
55
|
-
const {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
57
|
+
const _ref4 = (0, react_1.useMemo)(() => {
|
|
58
|
+
const _ref5 = (0, utils_1.extractActiveItems)({
|
|
59
|
+
focusCloseChildIds: items,
|
|
60
|
+
focusFlattenItems,
|
|
61
|
+
openCollapseItems,
|
|
62
|
+
isSelectionMultiple
|
|
63
|
+
}),
|
|
64
|
+
ids = _ref5.ids,
|
|
65
|
+
expandedIds = _ref5.expandedIds;
|
|
66
|
+
return {
|
|
67
|
+
ids,
|
|
68
|
+
expandedIds: expandedIds.concat([id])
|
|
69
|
+
};
|
|
70
|
+
}, [focusFlattenItems, id, isSelectionMultiple, items, openCollapseItems]),
|
|
71
|
+
ids = _ref4.ids,
|
|
72
|
+
expandedIds = _ref4.expandedIds;
|
|
73
|
+
const _ref6 = (0, contexts_1.useFocusListContext)(),
|
|
74
|
+
handleListKeyDownFactory = _ref6.handleListKeyDownFactory,
|
|
75
|
+
activeItemId = _ref6.activeItemId,
|
|
76
|
+
forceUpdateActiveItemId = _ref6.forceUpdateActiveItemId;
|
|
77
|
+
const _ref7 = (0, react_1.useState)(),
|
|
78
|
+
_ref8 = (0, _slicedToArray2.default)(_ref7, 2),
|
|
79
|
+
open = _ref8[0],
|
|
80
|
+
setOpen = _ref8[1];
|
|
79
81
|
const handleListKeyDown = (0, react_1.useCallback)(e => {
|
|
80
82
|
handleListKeyDownFactory(ids, expandedIds)(e);
|
|
81
83
|
if (e.key === 'ArrowLeft') {
|
|
@@ -85,16 +87,15 @@ function NextListItem(_a) {
|
|
|
85
87
|
return;
|
|
86
88
|
}
|
|
87
89
|
}, [handleListKeyDownFactory, ids, expandedIds, forceUpdateActiveItemId, focusId]);
|
|
88
|
-
const {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
});
|
|
90
|
+
const _ref9 = (0, hooks_1.useGroupItemSelection)({
|
|
91
|
+
items: (0, utils_1.isNextListItem)(item) ? item.items : [],
|
|
92
|
+
id,
|
|
93
|
+
disabled,
|
|
94
|
+
allChildIds
|
|
95
|
+
}),
|
|
96
|
+
indeterminate = _ref9.indeterminate,
|
|
97
|
+
checkedProp = _ref9.checked,
|
|
98
|
+
handleOnSelect = _ref9.handleOnSelect;
|
|
98
99
|
const handleOutsideClick = (0, react_1.useCallback)(() => {
|
|
99
100
|
forceUpdateActiveItemId === null || forceUpdateActiveItemId === void 0 ? void 0 : forceUpdateActiveItemId(constants_1.ITEM_PREFIXES.dropFocus);
|
|
100
101
|
setOpen(false);
|
|
@@ -16,12 +16,10 @@ const divider_1 = require("@snack-uikit/divider");
|
|
|
16
16
|
const contexts_1 = require("../../Lists/contexts");
|
|
17
17
|
const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
18
18
|
function PinTopGroupItem(_ref) {
|
|
19
|
-
let
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
size = 's'
|
|
24
|
-
} = (0, contexts_1.useNewListContext)();
|
|
19
|
+
let children = _ref.children;
|
|
20
|
+
const _ref2 = (0, contexts_1.useNewListContext)(),
|
|
21
|
+
_ref2$size = _ref2.size,
|
|
22
|
+
size = _ref2$size === void 0 ? 's' : _ref2$size;
|
|
25
23
|
if (!children) {
|
|
26
24
|
return null;
|
|
27
25
|
}
|
|
@@ -36,13 +34,11 @@ function PinTopGroupItem(_ref) {
|
|
|
36
34
|
})]
|
|
37
35
|
});
|
|
38
36
|
}
|
|
39
|
-
function PinBottomGroupItem(
|
|
40
|
-
let
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
size = 's'
|
|
45
|
-
} = (0, contexts_1.useNewListContext)();
|
|
37
|
+
function PinBottomGroupItem(_ref3) {
|
|
38
|
+
let children = _ref3.children;
|
|
39
|
+
const _ref4 = (0, contexts_1.useNewListContext)(),
|
|
40
|
+
_ref4$size = _ref4.size,
|
|
41
|
+
size = _ref4$size === void 0 ? 's' : _ref4$size;
|
|
46
42
|
if (!children) {
|
|
47
43
|
return null;
|
|
48
44
|
}
|
|
@@ -18,14 +18,12 @@ const contexts_1 = require("../../Lists/contexts");
|
|
|
18
18
|
const styles_module_scss_1 = __importDefault(require('../styles.module.css'));
|
|
19
19
|
const styles_module_scss_2 = __importDefault(require('./styles.module.css'));
|
|
20
20
|
function SearchItem(_ref) {
|
|
21
|
-
let
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
firstItemId
|
|
28
|
-
} = (0, contexts_1.useNewListContext)();
|
|
21
|
+
let search = _ref.search,
|
|
22
|
+
itemRef = _ref.itemRef;
|
|
23
|
+
const _ref2 = (0, contexts_1.useNewListContext)(),
|
|
24
|
+
_ref2$size = _ref2.size,
|
|
25
|
+
size = _ref2$size === void 0 ? 's' : _ref2$size,
|
|
26
|
+
firstItemId = _ref2.firstItemId;
|
|
29
27
|
const handleKeyDown = e => {
|
|
30
28
|
var _a;
|
|
31
29
|
if (['ArrowDown', 'ArrowUp'].includes(e.key)) {
|
|
@@ -19,22 +19,19 @@ const GroupSelectItem_1 = require("./GroupSelectItem");
|
|
|
19
19
|
const NextListItem_1 = require("./NextListItem");
|
|
20
20
|
const utils_1 = require("./utils");
|
|
21
21
|
function getRenderItems(_ref) {
|
|
22
|
-
let
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
isSelectionMultiple
|
|
27
|
-
} = _ref;
|
|
22
|
+
let focusCloseChildIds = _ref.focusCloseChildIds,
|
|
23
|
+
focusFlattenItems = _ref.focusFlattenItems,
|
|
24
|
+
flattenItems = _ref.flattenItems,
|
|
25
|
+
isSelectionMultiple = _ref.isSelectionMultiple;
|
|
28
26
|
if (!focusCloseChildIds) {
|
|
29
27
|
return [null];
|
|
30
28
|
}
|
|
31
29
|
return focusCloseChildIds.flatMap(id => {
|
|
32
|
-
const
|
|
33
|
-
itemRef,
|
|
34
|
-
key,
|
|
35
|
-
originalId,
|
|
36
|
-
items
|
|
37
|
-
} = focusFlattenItems[id];
|
|
30
|
+
const _focusFlattenItems$id = focusFlattenItems[id],
|
|
31
|
+
itemRef = _focusFlattenItems$id.itemRef,
|
|
32
|
+
key = _focusFlattenItems$id.key,
|
|
33
|
+
originalId = _focusFlattenItems$id.originalId,
|
|
34
|
+
items = _focusFlattenItems$id.items;
|
|
38
35
|
const flattenItem = flattenItems[originalId];
|
|
39
36
|
if ((0, utils_1.isGroupItem)(flattenItem) || !isSelectionMultiple && (0, utils_1.isGroupSelectItem)(flattenItem)) {
|
|
40
37
|
const innerItemsJSX = getRenderItems({
|
|
@@ -79,13 +76,11 @@ function getRenderItems(_ref) {
|
|
|
79
76
|
});
|
|
80
77
|
}
|
|
81
78
|
function useRenderItems(focusCloseChildIds) {
|
|
82
|
-
const
|
|
83
|
-
focusFlattenItems,
|
|
84
|
-
flattenItems
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
isSelectionMultiple
|
|
88
|
-
} = (0, contexts_1.useSelectionContext)();
|
|
79
|
+
const _ref2 = (0, contexts_1.useNewListContext)(),
|
|
80
|
+
focusFlattenItems = _ref2.focusFlattenItems,
|
|
81
|
+
flattenItems = _ref2.flattenItems;
|
|
82
|
+
const _ref3 = (0, contexts_1.useSelectionContext)(),
|
|
83
|
+
isSelectionMultiple = _ref3.isSelectionMultiple;
|
|
89
84
|
return (0, react_2.useMemo)(() => getRenderItems({
|
|
90
85
|
flattenItems,
|
|
91
86
|
focusFlattenItems,
|
|
@@ -93,10 +88,8 @@ function useRenderItems(focusCloseChildIds) {
|
|
|
93
88
|
isSelectionMultiple
|
|
94
89
|
}), [flattenItems, focusCloseChildIds, focusFlattenItems, isSelectionMultiple]);
|
|
95
90
|
}
|
|
96
|
-
function useCreateBaseItems(
|
|
97
|
-
let
|
|
98
|
-
footerActiveElementsRefs
|
|
99
|
-
} = _ref2;
|
|
91
|
+
function useCreateBaseItems(_ref4) {
|
|
92
|
+
let footerActiveElementsRefs = _ref4.footerActiveElementsRefs;
|
|
100
93
|
return (0, react_2.useMemo)(() => {
|
|
101
94
|
var _a;
|
|
102
95
|
return {
|
|
@@ -117,19 +110,15 @@ function useCreateBaseItems(_ref2) {
|
|
|
117
110
|
};
|
|
118
111
|
}, [footerActiveElementsRefs]);
|
|
119
112
|
}
|
|
120
|
-
function useGroupItemSelection(
|
|
121
|
-
let
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
} = (0, contexts_1.useSelectionContext)();
|
|
130
|
-
const {
|
|
131
|
-
flattenItems
|
|
132
|
-
} = (0, contexts_1.useNewListContext)();
|
|
113
|
+
function useGroupItemSelection(_ref5) {
|
|
114
|
+
let id = _ref5.id,
|
|
115
|
+
allChildIds = _ref5.allChildIds;
|
|
116
|
+
const _ref6 = (0, contexts_1.useSelectionContext)(),
|
|
117
|
+
value = _ref6.value,
|
|
118
|
+
setValue = _ref6.setValue,
|
|
119
|
+
isSelectionMultiple = _ref6.isSelectionMultiple;
|
|
120
|
+
const _ref7 = (0, contexts_1.useNewListContext)(),
|
|
121
|
+
flattenItems = _ref7.flattenItems;
|
|
133
122
|
const baseChildIds = (0, react_2.useMemo)(() => allChildIds.filter(itemId => {
|
|
134
123
|
const item = flattenItems[itemId];
|
|
135
124
|
return item && !('type' in item);
|
|
@@ -46,20 +46,17 @@ exports.isAccordionItemProps = isAccordionItem;
|
|
|
46
46
|
exports.isNextListItemProps = isNextListItem;
|
|
47
47
|
exports.isGroupItemProps = isGroupItem;
|
|
48
48
|
function kindFlattenItems(_ref) {
|
|
49
|
-
let
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
parentId
|
|
53
|
-
} = _ref;
|
|
49
|
+
let items = _ref.items,
|
|
50
|
+
prefix = _ref.prefix,
|
|
51
|
+
parentId = _ref.parentId;
|
|
54
52
|
const flattenItems = {};
|
|
55
53
|
const focusFlattenItems = {};
|
|
56
54
|
function flatten(_ref2) {
|
|
57
|
-
let
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
parentId = constants_1.ITEM_PREFIXES.default
|
|
62
|
-
} = _ref2;
|
|
55
|
+
let item = _ref2.item,
|
|
56
|
+
idx = _ref2.idx,
|
|
57
|
+
prefix = _ref2.prefix,
|
|
58
|
+
_ref2$parentId = _ref2.parentId,
|
|
59
|
+
parentId = _ref2$parentId === void 0 ? constants_1.ITEM_PREFIXES.default : _ref2$parentId;
|
|
63
60
|
var _a, _b;
|
|
64
61
|
const autoId = prefix !== undefined ? (0, helpers_1.getItemAutoId)(prefix, idx) : String(idx);
|
|
65
62
|
const itemId = (_a = !isGroupItem(item) ? item.id : undefined) !== null && _a !== void 0 ? _a : autoId;
|
|
@@ -90,24 +87,21 @@ function kindFlattenItems(_ref) {
|
|
|
90
87
|
let allFocusChildIds = [];
|
|
91
88
|
const closeChildIds = [];
|
|
92
89
|
const autoChildIds = [];
|
|
93
|
-
const
|
|
94
|
-
items
|
|
95
|
-
} = item,
|
|
90
|
+
const items = item.items,
|
|
96
91
|
rest = __rest(item, ["items"]);
|
|
97
92
|
const childActiveParent = isGroupItem(item) ? parentId !== null && parentId !== void 0 ? parentId : constants_1.ITEM_PREFIXES.default : autoId;
|
|
98
93
|
const filteredItems = items.filter(item => !item.hidden);
|
|
99
94
|
for (let idx = 0; idx < filteredItems.length; idx++) {
|
|
100
|
-
const {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
});
|
|
95
|
+
const _flatten = flatten({
|
|
96
|
+
item: filteredItems[idx],
|
|
97
|
+
idx,
|
|
98
|
+
prefix: itemId,
|
|
99
|
+
parentId: childActiveParent
|
|
100
|
+
}),
|
|
101
|
+
id = _flatten.id,
|
|
102
|
+
children = _flatten.children,
|
|
103
|
+
autoId = _flatten.autoId,
|
|
104
|
+
focusChildren = _flatten.focusChildren;
|
|
111
105
|
autoChildIds.push(autoId);
|
|
112
106
|
closeChildIds.push(id);
|
|
113
107
|
allChildIds = allChildIds.concat(children);
|
|
@@ -143,16 +137,15 @@ function kindFlattenItems(_ref) {
|
|
|
143
137
|
let allChildIds = [];
|
|
144
138
|
const filteredItems = items.filter(item => !item.hidden);
|
|
145
139
|
for (let idx = 0; idx < filteredItems.length; idx++) {
|
|
146
|
-
const {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
});
|
|
140
|
+
const _flatten2 = flatten({
|
|
141
|
+
item: filteredItems[idx],
|
|
142
|
+
idx,
|
|
143
|
+
prefix,
|
|
144
|
+
parentId
|
|
145
|
+
}),
|
|
146
|
+
id = _flatten2.id,
|
|
147
|
+
children = _flatten2.children,
|
|
148
|
+
autoId = _flatten2.autoId;
|
|
156
149
|
autoChildIds.push(autoId);
|
|
157
150
|
closeChildIds.push(id);
|
|
158
151
|
allChildIds.push(id);
|
|
@@ -167,12 +160,10 @@ function kindFlattenItems(_ref) {
|
|
|
167
160
|
};
|
|
168
161
|
}
|
|
169
162
|
function extractActiveItems(_ref3) {
|
|
170
|
-
let
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
isSelectionMultiple
|
|
175
|
-
} = _ref3;
|
|
163
|
+
let focusFlattenItems = _ref3.focusFlattenItems,
|
|
164
|
+
focusCloseChildIds = _ref3.focusCloseChildIds,
|
|
165
|
+
openCollapseItems = _ref3.openCollapseItems,
|
|
166
|
+
isSelectionMultiple = _ref3.isSelectionMultiple;
|
|
176
167
|
const ids = [];
|
|
177
168
|
const expandedIds = [];
|
|
178
169
|
function internalFn(focusCloseChildIds) {
|