@snack-uikit/list 0.10.0 → 0.10.1-preview-80576138.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 +56 -24
- package/dist/components/Items/AccordionItem/AccordionItem.d.ts +4 -2
- package/dist/components/Items/AccordionItem/AccordionItem.js +18 -16
- package/dist/components/Items/BaseItem/BaseItem.d.ts +8 -4
- package/dist/components/Items/BaseItem/BaseItem.js +20 -14
- package/dist/components/Items/BaseItem/styles.module.css +9 -122
- package/dist/components/Items/GroupItem/GroupItem.d.ts +5 -1
- package/dist/components/Items/GroupItem/GroupItem.js +1 -3
- package/dist/components/Items/GroupSelectItem/GroupSelectItem.d.ts +4 -0
- package/dist/components/Items/GroupSelectItem/GroupSelectItem.js +18 -0
- package/dist/components/Items/GroupSelectItem/index.d.ts +1 -0
- package/dist/components/Items/GroupSelectItem/index.js +1 -0
- package/dist/components/Items/NextListItem/NextListItem.d.ts +6 -2
- package/dist/components/Items/NextListItem/NextListItem.js +53 -45
- package/dist/components/Items/NextListItem/constants.d.ts +2 -0
- package/dist/components/Items/NextListItem/constants.js +10 -0
- package/dist/components/Items/SearchItem/SearchItem.d.ts +3 -1
- package/dist/components/Items/SearchItem/SearchItem.js +5 -8
- package/dist/components/Items/hooks.d.ts +11 -10
- package/dist/components/Items/hooks.js +64 -46
- package/dist/components/Items/index.d.ts +1 -5
- package/dist/components/Items/index.js +1 -5
- package/dist/components/Items/types.d.ts +68 -34
- package/dist/components/Items/utils.d.ts +33 -16
- package/dist/components/Items/utils.js +132 -37
- package/dist/components/Lists/Droplist/DropList.d.ts +1 -1
- package/dist/components/Lists/Droplist/DropList.js +73 -50
- package/dist/components/Lists/List/List.d.ts +5 -9
- package/dist/components/Lists/List/List.js +56 -54
- package/dist/components/Lists/ListPrivate/ListPrivate.d.ts +6 -20
- package/dist/components/Lists/ListPrivate/ListPrivate.js +9 -8
- package/dist/components/Lists/contexts/CollapseProvider.d.ts +13 -1
- package/dist/components/Lists/contexts/CollapseProvider.js +2 -0
- package/dist/components/Lists/contexts/FocusListProvider.d.ts +9 -0
- package/dist/components/Lists/contexts/FocusListProvider.js +5 -0
- package/dist/components/Lists/contexts/NewListProvider.d.ts +32 -0
- package/dist/components/Lists/contexts/{ListProvider.js → NewListProvider.js} +10 -5
- package/dist/components/Lists/contexts/SelectionProvider.d.ts +25 -15
- package/dist/components/Lists/contexts/SelectionProvider.js +17 -13
- package/dist/components/Lists/contexts/index.d.ts +2 -2
- package/dist/components/Lists/contexts/index.js +2 -2
- package/dist/components/Lists/hooks.d.ts +10 -12
- package/dist/components/Lists/hooks.js +73 -40
- package/dist/components/Lists/types.d.ts +12 -14
- package/dist/components/index.d.ts +2 -2
- package/dist/components/index.js +1 -1
- package/dist/helperComponents/ItemContent/ItemContent.d.ts +15 -0
- package/dist/helperComponents/ItemContent/ItemContent.js +23 -0
- package/dist/helperComponents/ItemContent/index.d.ts +1 -0
- package/dist/helperComponents/ItemContent/index.js +1 -0
- package/dist/helperComponents/ItemContent/styles.module.css +117 -0
- package/dist/helperComponents/ListEmptyState/ListEmptyState.d.ts +2 -2
- package/dist/helperComponents/ListEmptyState/ListEmptyState.js +13 -4
- package/dist/helperComponents/Separator/Separator.d.ts +8 -2
- package/dist/helperComponents/Separator/Separator.js +29 -2
- package/dist/helperComponents/index.d.ts +1 -0
- package/dist/helperComponents/index.js +1 -0
- package/dist/hooks.d.ts +1 -1
- package/dist/hooks.js +15 -10
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/legacy/components/Items/hooks.d.ts +12 -0
- package/dist/legacy/components/Items/hooks.js +33 -0
- package/dist/legacy/components/index.d.ts +1 -0
- package/dist/legacy/components/index.js +1 -0
- package/dist/legacy/hooks.d.ts +5 -0
- package/dist/legacy/hooks.js +15 -0
- package/dist/legacy/index.d.ts +3 -0
- package/dist/legacy/index.js +3 -0
- package/dist/{utils.d.ts → legacy/utils.d.ts} +2 -3
- package/dist/{utils.js → legacy/utils.js} +4 -12
- package/dist/types.d.ts +1 -1
- package/package.json +14 -14
- package/src/components/Items/AccordionItem/AccordionItem.tsx +24 -20
- package/src/components/Items/BaseItem/BaseItem.tsx +48 -43
- package/src/components/Items/BaseItem/styles.module.scss +8 -70
- package/src/components/Items/GroupItem/GroupItem.tsx +5 -5
- package/src/components/Items/GroupSelectItem/GroupSelectItem.tsx +44 -0
- package/src/components/Items/GroupSelectItem/index.ts +1 -0
- package/src/components/Items/NextListItem/NextListItem.tsx +86 -85
- package/src/components/Items/NextListItem/constants.ts +12 -0
- package/src/components/Items/SearchItem/SearchItem.tsx +6 -8
- package/src/components/Items/hooks.tsx +86 -66
- package/src/components/Items/index.ts +1 -5
- package/src/components/Items/types.ts +91 -42
- package/src/components/Items/utils.ts +193 -52
- package/src/components/Lists/Droplist/DropList.tsx +151 -98
- package/src/components/Lists/List/List.tsx +124 -104
- package/src/components/Lists/ListPrivate/ListPrivate.tsx +19 -20
- package/src/components/Lists/contexts/CollapseProvider.tsx +22 -0
- package/src/components/Lists/contexts/FocusListProvider.tsx +16 -0
- package/src/components/Lists/contexts/NewListProvider.tsx +54 -0
- package/src/components/Lists/contexts/SelectionProvider.tsx +56 -39
- package/src/components/Lists/contexts/index.ts +3 -2
- package/src/components/Lists/hooks.ts +124 -75
- package/src/components/Lists/types.ts +20 -24
- package/src/components/index.ts +16 -2
- package/src/helperComponents/ItemContent/ItemContent.tsx +63 -0
- package/src/helperComponents/ItemContent/index.ts +1 -0
- package/src/helperComponents/ItemContent/styles.module.scss +78 -0
- package/src/helperComponents/ListEmptyState/ListEmptyState.tsx +26 -12
- package/src/helperComponents/Separator/Separator.tsx +65 -8
- package/src/helperComponents/index.ts +1 -0
- package/src/hooks.ts +21 -15
- package/src/index.ts +5 -2
- package/src/legacy/components/Items/hooks.tsx +53 -0
- package/src/legacy/components/index.ts +1 -0
- package/src/legacy/hooks.ts +27 -0
- package/src/legacy/index.ts +3 -0
- package/src/{utils.ts → legacy/utils.ts} +4 -13
- package/src/types.ts +1 -1
- package/dist/components/Items/NextListItem/hooks.d.ts +0 -19
- package/dist/components/Items/NextListItem/hooks.js +0 -80
- package/dist/components/Lists/contexts/ListProvider.d.ts +0 -17
- package/dist/components/Lists/contexts/ParentListProvider.d.ts +0 -18
- package/dist/components/Lists/contexts/ParentListProvider.js +0 -12
- package/src/components/Items/NextListItem/hooks.ts +0 -105
- package/src/components/Lists/contexts/CollapseProvider.ts +0 -9
- package/src/components/Lists/contexts/ListProvider.tsx +0 -28
- package/src/components/Lists/contexts/ParentListProvider.tsx +0 -35
package/README.md
CHANGED
|
@@ -8,33 +8,30 @@
|
|
|
8
8
|
|
|
9
9
|
[//]: DOCUMENTATION_SECTION_START
|
|
10
10
|
[//]: THIS_SECTION_IS_AUTOGENERATED_PLEASE_DONT_EDIT_IT
|
|
11
|
-
##
|
|
12
|
-
Нечеткий поиск среди айтемов по полям 'content.option', 'content.caption', 'content.description', 'label'
|
|
11
|
+
## kindFlattenItems
|
|
13
12
|
### Props
|
|
14
13
|
| name | type | default value | description |
|
|
15
14
|
|------|------|---------------|-------------|
|
|
16
|
-
|
|
15
|
+
| items* | `Item[]` | - | |
|
|
16
|
+
| prefix | `ItemId` | - | |
|
|
17
|
+
| parentId | `ItemId` | - | |
|
|
18
|
+
## isAccordionItem
|
|
17
19
|
### Props
|
|
18
20
|
| name | type | default value | description |
|
|
19
21
|
|------|------|---------------|-------------|
|
|
20
|
-
|
|
21
|
-
## flattenItems
|
|
22
|
-
`flattenItems`
|
|
23
|
-
|
|
24
|
-
Функция разворачивает массив айтемов в плоский список
|
|
25
|
-
## isAccordionItemProps
|
|
22
|
+
## isBaseItem
|
|
26
23
|
### Props
|
|
27
24
|
| name | type | default value | description |
|
|
28
25
|
|------|------|---------------|-------------|
|
|
29
|
-
##
|
|
26
|
+
## isGroupItem
|
|
30
27
|
### Props
|
|
31
28
|
| name | type | default value | description |
|
|
32
29
|
|------|------|---------------|-------------|
|
|
33
|
-
##
|
|
30
|
+
## isNextListItem
|
|
34
31
|
### Props
|
|
35
32
|
| name | type | default value | description |
|
|
36
33
|
|------|------|---------------|-------------|
|
|
37
|
-
##
|
|
34
|
+
## isGroupSelectItem
|
|
38
35
|
### Props
|
|
39
36
|
| name | type | default value | description |
|
|
40
37
|
|------|------|---------------|-------------|
|
|
@@ -42,8 +39,9 @@
|
|
|
42
39
|
### Props
|
|
43
40
|
| name | type | default value | description |
|
|
44
41
|
|------|------|---------------|-------------|
|
|
45
|
-
|
|
|
46
|
-
|
|
|
42
|
+
| id* | `ItemId` | - | |
|
|
43
|
+
| items* | `ItemId[]` | - | |
|
|
44
|
+
| allChildIds* | `ItemId[]` | - | |
|
|
47
45
|
| disabled | `boolean` | - | |
|
|
48
46
|
## isSelectionSingleProps
|
|
49
47
|
### Props
|
|
@@ -57,25 +55,27 @@
|
|
|
57
55
|
### Props
|
|
58
56
|
| name | type | default value | description |
|
|
59
57
|
|------|------|---------------|-------------|
|
|
60
|
-
| items* | `
|
|
58
|
+
| items* | `Item[]` | - | Основные элементы списка |
|
|
61
59
|
| children* | `ReactNode \| ({onKeyDown}) => ReactNode * Рендер функция принимает аргументы `onKeyDown` - хендлер ввода, для поддержки управления с клавиатуры` | - | Триггер для дроплиста |
|
|
62
60
|
| triggerElemRef | `RefObject<HTMLElement>` | - | Ссылка на элемент-триггер для дроплиста |
|
|
61
|
+
| triggerClassName | `string` | - | CSS-класс триггера |
|
|
63
62
|
| open | `boolean` | - | Управляет состоянием показан/не показан. |
|
|
64
63
|
| onOpenChange | `(isOpen: boolean) => void` | - | Колбек отображения компонента. Срабатывает при изменении состояния open. |
|
|
65
64
|
| widthStrategy | enum PopoverWidthStrategy: `"auto"`, `"gte"`, `"eq"` | auto | Стратегия управления шириной контейнера поповера <br> - `auto` - соответствует ширине контента, <br> - `gte` - Great Than or Equal, равен ширине таргета или больше ее, если контент в поповере шире, <br> - `eq` - Equal, строго равен ширине таргета. |
|
|
66
65
|
| trigger | enum Trigger: `"click"`, `"hover"`, `"focusVisible"`, `"focus"`, `"hoverAndFocusVisible"`, `"hoverAndFocus"`, `"clickAndFocusVisible"` | - | Условие отображения поповера: <br> - `click` - открывать по клику <br> - `hover` - открывать по ховеру <br> - `focusVisible` - открывать по focus-visible <br> - `focus` - открывать по фокусу <br> - `hoverAndFocusVisible` - открывать по ховеру и focus-visible <br> - `hoverAndFocus` - открывать по ховеру и фокусу <br> - `clickAndFocusVisible` - открывать по клику и focus-visible |
|
|
67
66
|
| placement | enum Placement: `"left"`, `"left-start"`, `"left-end"`, `"right"`, `"right-start"`, `"right-end"`, `"top"`, `"top-start"`, `"top-end"`, `"bottom"`, `"bottom-start"`, `"bottom-end"` | top | Положение поповера относительно своего триггера (children). |
|
|
68
67
|
| className | `string` | - | CSS-класс |
|
|
69
|
-
|
|
|
70
|
-
|
|
|
71
|
-
| pinBottom | `ItemProps[]` | - | Элементы списка, закрепленные снизу |
|
|
68
|
+
| pinTop | `Item[]` | - | Элементы списка, закрепленные сверху |
|
|
69
|
+
| pinBottom | `Item[]` | - | Элементы списка, закрепленные снизу |
|
|
72
70
|
| footer | `ReactNode ;` | - | Кастомизируемый элемент в конце списка |
|
|
73
71
|
| footerActiveElementsRefs | `RefObject<HTMLElement>[]` | - | Список ссылок на кастомные элементы, помещенные в специальную секцию внизу списка |
|
|
74
72
|
| search | `SearchState` | - | Настройки поисковой строки |
|
|
75
73
|
| collapse | `CollapseState` | {} | Настройки раскрытия элементов |
|
|
76
74
|
| loading | `boolean` | - | Флаг, отвещающий за состояние загрузки списка |
|
|
77
75
|
| selection | `SelectionSingleState \| SelectionMultipleState` | - | |
|
|
78
|
-
|
|
|
76
|
+
| size | "s" \| "m" \| "l" | s | Размер списка |
|
|
77
|
+
| marker | `boolean` | true | Отображать ли маркер у выбранного жлемента списка |
|
|
78
|
+
| contentRender | `(props: ContentRenderProps) => ReactNode` | - | Рендер функция основного контента айтема |
|
|
79
79
|
| scroll | `boolean` | - | Включить ли скролл для основной части списка |
|
|
80
80
|
| scrollRef | `RefObject<HTMLElement>` | - | Ссылка на элемент, обозначающий самый конец прокручиваемого списка |
|
|
81
81
|
| scrollContainerRef | `RefObject<HTMLElement>` | - | Ссылка на контейнер, который скроллится |
|
|
@@ -88,9 +88,9 @@
|
|
|
88
88
|
### Props
|
|
89
89
|
| name | type | default value | description |
|
|
90
90
|
|------|------|---------------|-------------|
|
|
91
|
-
| items* | `
|
|
92
|
-
| pinTop | `
|
|
93
|
-
| pinBottom | `
|
|
91
|
+
| items* | `Item[]` | - | Основные элементы списка |
|
|
92
|
+
| pinTop | `Item[]` | - | Элементы списка, закрепленные сверху |
|
|
93
|
+
| pinBottom | `Item[]` | - | Элементы списка, закрепленные снизу |
|
|
94
94
|
| footer | `ReactNode ;` | - | Кастомизируемый элемент в конце списка |
|
|
95
95
|
| footerActiveElementsRefs | `RefObject<HTMLElement>[]` | - | Список ссылок на кастомные элементы, помещенные в специальную секцию внизу списка |
|
|
96
96
|
| search | `SearchState` | - | Настройки поисковой строки |
|
|
@@ -100,8 +100,9 @@
|
|
|
100
100
|
| onKeyDown | `(e: KeyboardEvent<HTMLElement>) => void` | - | |
|
|
101
101
|
| loading | `boolean` | - | Флаг, отвещающий за состояние загрузки списка |
|
|
102
102
|
| selection | `SelectionSingleState \| SelectionMultipleState` | - | |
|
|
103
|
-
| size | "s" \| "m" \| "l" |
|
|
104
|
-
| marker | `boolean` |
|
|
103
|
+
| size | "s" \| "m" \| "l" | s | Размер списка |
|
|
104
|
+
| marker | `boolean` | true | Отображать ли маркер у выбранного жлемента списка |
|
|
105
|
+
| contentRender | `(props: ContentRenderProps) => ReactNode` | - | Рендер функция основного контента айтема |
|
|
105
106
|
| scroll | `boolean` | - | Включить ли скролл для основной части списка |
|
|
106
107
|
| scrollRef | `RefObject<HTMLElement>` | - | Ссылка на элемент, обозначающий самый конец прокручиваемого списка |
|
|
107
108
|
| scrollContainerRef | `RefObject<HTMLElement>` | - | Ссылка на контейнер, который скроллится |
|
|
@@ -112,6 +113,37 @@
|
|
|
112
113
|
| errorDataState | `EmptyStateProps` | - | Экран при ошибке запроса |
|
|
113
114
|
| ref | `Ref<HTMLElement>` | - | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). @see https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom |
|
|
114
115
|
| key | `Key` | - | |
|
|
116
|
+
## ItemContent
|
|
117
|
+
### Props
|
|
118
|
+
| name | type | default value | description |
|
|
119
|
+
|------|------|---------------|-------------|
|
|
120
|
+
| option* | `string \| number` | - | |
|
|
121
|
+
| caption | `string` | - | |
|
|
122
|
+
| description | `string` | - | |
|
|
123
|
+
| truncate | `{ option?: number; description?: number; variant?: "end" \| "middle"; }` | - | |
|
|
124
|
+
| disabled | `boolean` | - | |
|
|
125
|
+
| className | `string` | - | CSS-класс |
|
|
126
|
+
## useFuzzySearch
|
|
127
|
+
Нечеткий поиск среди айтемов по полям 'content.option', 'content.caption', 'content.description', 'label'
|
|
128
|
+
### Props
|
|
129
|
+
| name | type | default value | description |
|
|
130
|
+
|------|------|---------------|-------------|
|
|
131
|
+
## extractChildIds
|
|
132
|
+
### Props
|
|
133
|
+
| name | type | default value | description |
|
|
134
|
+
|------|------|---------------|-------------|
|
|
135
|
+
| items* | `Item[]` | - | |
|
|
136
|
+
## flattenItems
|
|
137
|
+
`flattenItems`
|
|
138
|
+
|
|
139
|
+
Функция разворачивает массив айтемов в плоский список
|
|
140
|
+
## useLegacyGroupItemSelection
|
|
141
|
+
### Props
|
|
142
|
+
| name | type | default value | description |
|
|
143
|
+
|------|------|---------------|-------------|
|
|
144
|
+
| items* | `Item[]` | - | |
|
|
145
|
+
| id | `string \| number` | - | |
|
|
146
|
+
| disabled | `boolean` | - | |
|
|
115
147
|
|
|
116
148
|
|
|
117
149
|
[//]: DOCUMENTATION_SECTION_END
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { CommonFlattenProps, FlattenAccordionItem } from '../types';
|
|
2
|
+
type AccordionItemProps = Omit<FlattenAccordionItem, 'type>'> & CommonFlattenProps;
|
|
3
|
+
export declare function AccordionItem({ id, disabled, allChildIds, items, ...option }: AccordionItemProps): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export {};
|
|
@@ -10,29 +10,31 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { useCallback } from 'react';
|
|
13
14
|
import { ChevronDownSVG, ChevronUpSVG } from '@snack-uikit/icons';
|
|
14
15
|
import { CollapseBlockPrivate } from '../../../helperComponents';
|
|
15
|
-
import {
|
|
16
|
+
import { CollapseLevelContext, useCollapseContext, useCollapseLevelContext } from '../../Lists/contexts';
|
|
16
17
|
import { BaseItem } from '../BaseItem';
|
|
17
18
|
import { useGroupItemSelection, useRenderItems } from '../hooks';
|
|
18
19
|
export function AccordionItem(_a) {
|
|
19
|
-
var {
|
|
20
|
-
const { level = 1 } =
|
|
21
|
-
const {
|
|
22
|
-
const {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
20
|
+
var { id, disabled, allChildIds, items } = _a, option = __rest(_a, ["id", "disabled", "allChildIds", "items"]);
|
|
21
|
+
const { level = 1 } = useCollapseLevelContext();
|
|
22
|
+
const { openCollapseItems = [], toggleOpenCollapseItem } = useCollapseContext();
|
|
23
|
+
const { indeterminate, checked, handleOnSelect } = useGroupItemSelection({
|
|
24
|
+
items,
|
|
25
|
+
id,
|
|
26
|
+
disabled,
|
|
27
|
+
allChildIds,
|
|
28
|
+
});
|
|
29
|
+
const isOpen = Boolean(openCollapseItems.includes(id !== null && id !== void 0 ? id : ''));
|
|
30
|
+
const handleKeyDown = useCallback(() => {
|
|
31
|
+
toggleOpenCollapseItem === null || toggleOpenCollapseItem === void 0 ? void 0 : toggleOpenCollapseItem(id !== null && id !== void 0 ? id : '');
|
|
32
|
+
}, [id, toggleOpenCollapseItem]);
|
|
33
|
+
const itemsJSX = useRenderItems(items);
|
|
32
34
|
const handleItemClick = (e) => {
|
|
33
35
|
var _a;
|
|
34
|
-
|
|
36
|
+
toggleOpenCollapseItem === null || toggleOpenCollapseItem === void 0 ? void 0 : toggleOpenCollapseItem(id !== null && id !== void 0 ? id : '');
|
|
35
37
|
(_a = option.onClick) === null || _a === void 0 ? void 0 : _a.call(option, e);
|
|
36
38
|
};
|
|
37
|
-
return (_jsx(CollapseBlockPrivate, { header: _jsx(BaseItem, Object.assign({}, option, { id: id, disabled: disabled, expandIcon: isOpen ? _jsx(ChevronUpSVG, {}) : _jsx(ChevronDownSVG, {}), onClick: handleItemClick, isParentNode: true,
|
|
39
|
+
return (_jsx(CollapseBlockPrivate, { header: _jsx(BaseItem, Object.assign({}, option, { id: id, disabled: disabled, expandIcon: isOpen ? _jsx(ChevronUpSVG, {}) : _jsx(ChevronDownSVG, {}), onClick: handleItemClick, isParentNode: true, onOpenNestedList: handleKeyDown, checked: checked, indeterminate: indeterminate, onSelect: !disabled ? handleOnSelect : undefined })), expanded: isOpen, "data-test-id": `list__accordion-item-${id}`, children: _jsx(CollapseLevelContext.Provider, { value: { level: level + 1 }, children: itemsJSX }) }));
|
|
38
40
|
}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
type AllBaseItemProps =
|
|
1
|
+
import { KeyboardEvent, ReactNode } from 'react';
|
|
2
|
+
import { FlattenBaseItem } from '../types';
|
|
3
|
+
type AllBaseItemProps = FlattenBaseItem & {
|
|
4
|
+
expandIcon?: ReactNode;
|
|
5
|
+
open?: boolean;
|
|
4
6
|
indeterminate?: boolean;
|
|
7
|
+
checked?: boolean;
|
|
5
8
|
onSelect?(): void;
|
|
6
9
|
isParentNode?: boolean;
|
|
10
|
+
onOpenNestedList?(e?: KeyboardEvent<HTMLElement>): void;
|
|
7
11
|
};
|
|
8
|
-
export declare function BaseItem({ beforeContent, afterContent, content, onClick, onMouseDown, id, expandIcon, disabled, open, itemRef, switch: switchProp, onKeyDown, onFocus, indeterminate, onSelect, isParentNode, className, inactive, itemWrapRender, ...rest }: AllBaseItemProps): string | number | boolean | Iterable<
|
|
12
|
+
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;
|
|
9
13
|
export {};
|
|
@@ -12,38 +12,44 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
import cn from 'classnames';
|
|
14
14
|
import { Checkbox, Switch } from '@snack-uikit/toggles';
|
|
15
|
-
import { TruncateString } from '@snack-uikit/truncate-string';
|
|
16
15
|
import { extractSupportProps } from '@snack-uikit/utils';
|
|
17
|
-
import {
|
|
16
|
+
import { ItemContent } from '../../../helperComponents';
|
|
17
|
+
import { useCollapseLevelContext, useFocusListContext, useNewListContext, useSelectionContext, } from '../../Lists/contexts';
|
|
18
18
|
import commonStyles from '../styles.module.css';
|
|
19
|
+
import { isContentItem } from '../utils';
|
|
19
20
|
import { CHECKBOX_SIZE_MAP } from './constants';
|
|
20
21
|
import styles from './styles.module.css';
|
|
21
22
|
export function BaseItem(_a) {
|
|
22
|
-
var _b
|
|
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"]);
|
|
24
|
-
const { option, caption, description, truncate: contentTruncate } = content || {};
|
|
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"]);
|
|
25
25
|
const interactive = !inactive;
|
|
26
|
-
const {
|
|
27
|
-
const {
|
|
28
|
-
const {
|
|
26
|
+
const { size = 's', marker, contentRender } = useNewListContext();
|
|
27
|
+
const { level = 0 } = useCollapseLevelContext();
|
|
28
|
+
const { forceUpdateActiveItemId } = useFocusListContext();
|
|
29
29
|
const { value, onChange, mode, isSelectionSingle, isSelectionMultiple } = useSelectionContext();
|
|
30
|
-
const isChecked = isSelectionSingle ? value === id : value === null || value === void 0 ? void 0 : value.includes(id);
|
|
30
|
+
const isChecked = isSelectionSingle ? value === id : checkedProp !== null && checkedProp !== void 0 ? checkedProp : value === null || value === void 0 ? void 0 : value.includes(id !== null && id !== void 0 ? id : '');
|
|
31
31
|
const handleChange = () => {
|
|
32
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(id
|
|
32
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(id);
|
|
33
33
|
};
|
|
34
34
|
const handleItemMouseDown = (e) => {
|
|
35
35
|
if (disabled)
|
|
36
36
|
return;
|
|
37
37
|
if (interactive) {
|
|
38
|
-
parentResetActiveFocusIndex === null || parentResetActiveFocusIndex === void 0 ? void 0 : parentResetActiveFocusIndex();
|
|
39
38
|
if (!isParentNode) {
|
|
40
39
|
handleChange();
|
|
41
40
|
}
|
|
42
41
|
}
|
|
43
42
|
onMouseDown === null || onMouseDown === void 0 ? void 0 : onMouseDown(e);
|
|
43
|
+
forceUpdateActiveItemId === null || forceUpdateActiveItemId === void 0 ? void 0 : forceUpdateActiveItemId('~drop-focus');
|
|
44
44
|
};
|
|
45
45
|
const handleItemKeyDown = (e) => {
|
|
46
46
|
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(e);
|
|
47
|
+
if (e.code === 'ArrowRight') {
|
|
48
|
+
onOpenNestedList === null || onOpenNestedList === void 0 ? void 0 : onOpenNestedList(e);
|
|
49
|
+
e.preventDefault();
|
|
50
|
+
e.stopPropagation();
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
47
53
|
if (e.code === 'Space' || e.key === 'Enter') {
|
|
48
54
|
if (isSelectionMultiple && isParentNode && onSelect) {
|
|
49
55
|
onSelect();
|
|
@@ -71,9 +77,9 @@ export function BaseItem(_a) {
|
|
|
71
77
|
e.stopPropagation();
|
|
72
78
|
};
|
|
73
79
|
const props = extractSupportProps(rest);
|
|
74
|
-
const
|
|
80
|
+
const itemJSX = (_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, className), "data-size": size, onClick: onClick, onMouseDown: handleItemMouseDown, 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: 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 })) !== 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 })] }));
|
|
75
81
|
if (!itemWrapRender) {
|
|
76
|
-
return
|
|
82
|
+
return itemJSX;
|
|
77
83
|
}
|
|
78
|
-
return itemWrapRender(
|
|
84
|
+
return itemWrapRender(itemJSX);
|
|
79
85
|
}
|
|
@@ -1,25 +1,3 @@
|
|
|
1
|
-
.headline{
|
|
2
|
-
display:flex;
|
|
3
|
-
align-items:center;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
.option{
|
|
7
|
-
overflow:hidden;
|
|
8
|
-
flex:1;
|
|
9
|
-
color:var(--sys-neutral-text-main, #33333b);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.caption{
|
|
13
|
-
overflow:hidden;
|
|
14
|
-
color:var(--sys-neutral-text-light, #868892);
|
|
15
|
-
text-overflow:ellipsis;
|
|
16
|
-
white-space:nowrap;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.description{
|
|
20
|
-
color:var(--sys-neutral-text-support, #656771);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
1
|
.checkbox{
|
|
24
2
|
display:inline-flex;
|
|
25
3
|
flex-grow:0;
|
|
@@ -41,8 +19,8 @@
|
|
|
41
19
|
color:var(--sys-neutral-text-light, #868892);
|
|
42
20
|
}
|
|
43
21
|
.beforeContent svg{
|
|
44
|
-
width:100
|
|
45
|
-
height:100
|
|
22
|
+
max-width:100%;
|
|
23
|
+
max-height:100%;
|
|
46
24
|
}
|
|
47
25
|
|
|
48
26
|
.expandableIcon{
|
|
@@ -71,119 +49,22 @@
|
|
|
71
49
|
height:100%;
|
|
72
50
|
}
|
|
73
51
|
|
|
74
|
-
.content{
|
|
75
|
-
overflow:hidden;
|
|
76
|
-
flex-grow:1;
|
|
77
|
-
flex-shrink:1;
|
|
78
|
-
box-sizing:border-box;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
52
|
.droplistItem{
|
|
82
53
|
width:100%;
|
|
83
54
|
}
|
|
84
55
|
.droplistItem[data-size=s]{
|
|
85
56
|
padding-left:calc(var(--level, 0) * var(--dimension-050m, 4px) + var(--space-drop-list-item-s-container-horizontal-padding, 8px));
|
|
86
57
|
}
|
|
87
|
-
.droplistItem[data-size=s] .headline{
|
|
88
|
-
gap:var(--space-drop-list-item-s-container-headline-gap, 8px);
|
|
89
|
-
height:var(--size-drop-list-item-headline, 24px);
|
|
90
|
-
}
|
|
91
|
-
.droplistItem[data-size=s] .option{
|
|
92
|
-
font-family:var(--sans-body-s-font-family, SB Sans Interface);
|
|
93
|
-
font-weight:var(--sans-body-s-font-weight, Regular);
|
|
94
|
-
line-height:var(--sans-body-s-line-height, 16px);
|
|
95
|
-
font-size:var(--sans-body-s-font-size, 12px);
|
|
96
|
-
letter-spacing:var(--sans-body-s-letter-spacing, 0.1px);
|
|
97
|
-
paragraph-spacing:var(--sans-body-s-paragraph-spacing, 6.6px);
|
|
98
|
-
}
|
|
99
|
-
.droplistItem[data-size=s] .caption{
|
|
100
|
-
font-family:var(--sans-body-s-font-family, SB Sans Interface);
|
|
101
|
-
font-weight:var(--sans-body-s-font-weight, Regular);
|
|
102
|
-
line-height:var(--sans-body-s-line-height, 16px);
|
|
103
|
-
font-size:var(--sans-body-s-font-size, 12px);
|
|
104
|
-
letter-spacing:var(--sans-body-s-letter-spacing, 0.1px);
|
|
105
|
-
paragraph-spacing:var(--sans-body-s-paragraph-spacing, 6.6px);
|
|
106
|
-
}
|
|
107
|
-
.droplistItem[data-size=s] .description{
|
|
108
|
-
font-family:var(--sans-body-s-font-family, SB Sans Interface);
|
|
109
|
-
font-weight:var(--sans-body-s-font-weight, Regular);
|
|
110
|
-
line-height:var(--sans-body-s-line-height, 16px);
|
|
111
|
-
font-size:var(--sans-body-s-font-size, 12px);
|
|
112
|
-
letter-spacing:var(--sans-body-s-letter-spacing, 0.1px);
|
|
113
|
-
paragraph-spacing:var(--sans-body-s-paragraph-spacing, 6.6px);
|
|
114
|
-
}
|
|
115
58
|
.droplistItem[data-size=m]{
|
|
116
59
|
padding-left:calc(var(--level, 0) * var(--dimension-050m, 4px) + var(--space-drop-list-item-m-container-horizontal-padding, 10px));
|
|
117
60
|
}
|
|
118
|
-
.droplistItem[data-size=m] .headline{
|
|
119
|
-
gap:var(--space-drop-list-item-m-container-headline-gap, 8px);
|
|
120
|
-
height:var(--size-drop-list-item-headline, 24px);
|
|
121
|
-
}
|
|
122
|
-
.droplistItem[data-size=m] .option{
|
|
123
|
-
font-family:var(--sans-body-m-font-family, SB Sans Interface);
|
|
124
|
-
font-weight:var(--sans-body-m-font-weight, Regular);
|
|
125
|
-
line-height:var(--sans-body-m-line-height, 20px);
|
|
126
|
-
font-size:var(--sans-body-m-font-size, 14px);
|
|
127
|
-
letter-spacing:var(--sans-body-m-letter-spacing, 0.1px);
|
|
128
|
-
paragraph-spacing:var(--sans-body-m-paragraph-spacing, 7.7px);
|
|
129
|
-
}
|
|
130
|
-
.droplistItem[data-size=m] .caption{
|
|
131
|
-
font-family:var(--sans-body-s-font-family, SB Sans Interface);
|
|
132
|
-
font-weight:var(--sans-body-s-font-weight, Regular);
|
|
133
|
-
line-height:var(--sans-body-s-line-height, 16px);
|
|
134
|
-
font-size:var(--sans-body-s-font-size, 12px);
|
|
135
|
-
letter-spacing:var(--sans-body-s-letter-spacing, 0.1px);
|
|
136
|
-
paragraph-spacing:var(--sans-body-s-paragraph-spacing, 6.6px);
|
|
137
|
-
}
|
|
138
|
-
.droplistItem[data-size=m] .description{
|
|
139
|
-
font-family:var(--sans-body-s-font-family, SB Sans Interface);
|
|
140
|
-
font-weight:var(--sans-body-s-font-weight, Regular);
|
|
141
|
-
line-height:var(--sans-body-s-line-height, 16px);
|
|
142
|
-
font-size:var(--sans-body-s-font-size, 12px);
|
|
143
|
-
letter-spacing:var(--sans-body-s-letter-spacing, 0.1px);
|
|
144
|
-
paragraph-spacing:var(--sans-body-s-paragraph-spacing, 6.6px);
|
|
145
|
-
}
|
|
146
61
|
.droplistItem[data-size=l]{
|
|
147
62
|
padding-left:calc(var(--level, 0) * var(--dimension-050m, 4px) + var(--space-drop-list-item-l-container-horizontal-padding, 12px));
|
|
148
63
|
}
|
|
149
|
-
.droplistItem[data-size=l] .headline{
|
|
150
|
-
gap:var(--space-drop-list-item-l-container-headline-gap, 8px);
|
|
151
|
-
height:var(--size-drop-list-item-headline, 24px);
|
|
152
|
-
}
|
|
153
|
-
.droplistItem[data-size=l] .option{
|
|
154
|
-
font-family:var(--sans-body-l-font-family, SB Sans Interface);
|
|
155
|
-
font-weight:var(--sans-body-l-font-weight, Regular);
|
|
156
|
-
line-height:var(--sans-body-l-line-height, 24px);
|
|
157
|
-
font-size:var(--sans-body-l-font-size, 16px);
|
|
158
|
-
letter-spacing:var(--sans-body-l-letter-spacing, 0.1px);
|
|
159
|
-
paragraph-spacing:var(--sans-body-l-paragraph-spacing, 8.8px);
|
|
160
|
-
}
|
|
161
|
-
.droplistItem[data-size=l] .caption{
|
|
162
|
-
font-family:var(--sans-body-m-font-family, SB Sans Interface);
|
|
163
|
-
font-weight:var(--sans-body-m-font-weight, Regular);
|
|
164
|
-
line-height:var(--sans-body-m-line-height, 20px);
|
|
165
|
-
font-size:var(--sans-body-m-font-size, 14px);
|
|
166
|
-
letter-spacing:var(--sans-body-m-letter-spacing, 0.1px);
|
|
167
|
-
paragraph-spacing:var(--sans-body-m-paragraph-spacing, 7.7px);
|
|
168
|
-
}
|
|
169
|
-
.droplistItem[data-size=l] .description{
|
|
170
|
-
font-family:var(--sans-body-m-font-family, SB Sans Interface);
|
|
171
|
-
font-weight:var(--sans-body-m-font-weight, Regular);
|
|
172
|
-
line-height:var(--sans-body-m-line-height, 20px);
|
|
173
|
-
font-size:var(--sans-body-m-font-size, 14px);
|
|
174
|
-
letter-spacing:var(--sans-body-m-letter-spacing, 0.1px);
|
|
175
|
-
paragraph-spacing:var(--sans-body-m-paragraph-spacing, 7.7px);
|
|
176
|
-
}
|
|
177
64
|
.droplistItem[data-non-pointer]{
|
|
178
65
|
cursor:inherit;
|
|
179
66
|
}
|
|
180
|
-
.droplistItem[aria-disabled] .
|
|
181
|
-
.droplistItem[aria-disabled] .description,
|
|
182
|
-
.droplistItem[aria-disabled] .caption,
|
|
183
|
-
.droplistItem[aria-disabled] .expandableIcon, .droplistItem[data-disabled] .option,
|
|
184
|
-
.droplistItem[data-disabled] .description,
|
|
185
|
-
.droplistItem[data-disabled] .caption,
|
|
186
|
-
.droplistItem[data-disabled] .expandableIcon{
|
|
67
|
+
.droplistItem[aria-disabled] .expandableIcon, .droplistItem[data-disabled] .expandableIcon{
|
|
187
68
|
color:var(--sys-neutral-text-disabled, #b3b6bf);
|
|
188
69
|
}
|
|
189
70
|
.droplistItem[aria-disabled] .beforeContent, .droplistItem[data-disabled] .beforeContent{
|
|
@@ -208,4 +89,10 @@
|
|
|
208
89
|
}
|
|
209
90
|
.droplistItem[data-has-checked][data-disabled] .markerContainer:before, .droplistItem[data-checked][data-disabled] .markerContainer:before{
|
|
210
91
|
background-color:var(--sys-neutral-text-disabled, #b3b6bf);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.content{
|
|
95
|
+
flex-grow:1;
|
|
96
|
+
flex-shrink:1;
|
|
97
|
+
box-sizing:border-box;
|
|
211
98
|
}
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FlattenGroupListItem, ItemId } from '../types';
|
|
2
|
+
type GroupItemProps = Omit<FlattenGroupListItem, 'type'> & {
|
|
3
|
+
items: ItemId[];
|
|
4
|
+
};
|
|
2
5
|
export declare function GroupItem({ label, truncate, divider, items, mode }: GroupItemProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export {};
|
|
@@ -1,9 +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
|
-
import { useListContext } from '../../Lists/contexts';
|
|
4
3
|
import { useRenderItems } from '../hooks';
|
|
5
4
|
export function GroupItem({ label, truncate, divider, items, mode }) {
|
|
6
|
-
const { size } = useListContext();
|
|
7
5
|
const itemsJSX = useRenderItems(items);
|
|
8
|
-
return (_jsxs(_Fragment, { children: [_jsx(Separator, { label: label, truncate: truncate, divider: divider, mode: mode
|
|
6
|
+
return (_jsxs(_Fragment, { children: [_jsx(Separator, { label: label, truncate: truncate, divider: divider, mode: mode }), itemsJSX] }));
|
|
9
7
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { CommonFlattenProps, FlattenGroupSelectListItem } from '../types';
|
|
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;
|
|
4
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Separator } from '../../../helperComponents';
|
|
3
|
+
import { useGroupItemSelection, useRenderItems } from '../hooks';
|
|
4
|
+
export function GroupSelectItem({ label, truncate, divider, items, mode, id, itemRef, allChildIds, }) {
|
|
5
|
+
const { indeterminate, checked, handleOnSelect } = useGroupItemSelection({
|
|
6
|
+
items,
|
|
7
|
+
id,
|
|
8
|
+
disabled: false,
|
|
9
|
+
allChildIds,
|
|
10
|
+
});
|
|
11
|
+
const itemsJSX = useRenderItems(items);
|
|
12
|
+
return (_jsxs(_Fragment, { children: [_jsx(Separator, { label: label, truncate: truncate, divider: divider, mode: mode, selectButton: {
|
|
13
|
+
indeterminate,
|
|
14
|
+
checked,
|
|
15
|
+
itemRef,
|
|
16
|
+
onMouseDown: handleOnSelect,
|
|
17
|
+
} }), itemsJSX] }));
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './GroupSelectItem';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './GroupSelectItem';
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { CommonFlattenProps, FlattenNextListItem, ItemId } from '../types';
|
|
2
|
+
type NextListItemProps = Omit<FlattenNextListItem, 'type'> & CommonFlattenProps & {
|
|
3
|
+
focusId?: ItemId;
|
|
4
|
+
};
|
|
5
|
+
export declare function NextListItem({ items, placement, id, scroll, scrollRef, disabled, onSublistOpenChanged, allChildIds, loading, focusId, ...option }: NextListItemProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export {};
|