@snack-uikit/list 0.11.0 → 0.11.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 +13 -0
- package/README.md +22 -61
- 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 +20 -119
- 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 +55 -45
- package/dist/components/Items/NextListItem/constants.d.ts +2 -0
- package/dist/components/Items/NextListItem/constants.js +10 -0
- package/dist/components/Items/PinGroupItem/PinGroupItem.js +7 -3
- package/dist/components/Items/PinGroupItem/styles.module.css +26 -14
- 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/styles.module.css +33 -26
- package/dist/components/Items/types.d.ts +68 -34
- package/dist/components/Items/utils.d.ts +34 -16
- package/dist/components/Items/utils.js +135 -37
- package/dist/components/Lists/Droplist/DropList.d.ts +1 -1
- package/dist/components/Lists/Droplist/DropList.js +78 -50
- package/dist/components/Lists/List/List.d.ts +5 -9
- package/dist/components/Lists/List/List.js +61 -54
- package/dist/components/Lists/ListPrivate/ListPrivate.d.ts +6 -20
- package/dist/components/Lists/ListPrivate/ListPrivate.js +9 -8
- package/dist/components/Lists/ListPrivate/styles.module.css +1 -0
- 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 +3 -2
- package/dist/components/Lists/contexts/index.js +3 -2
- package/dist/components/Lists/hooks.d.ts +10 -12
- package/dist/components/Lists/hooks.js +73 -40
- package/dist/components/Lists/index.d.ts +2 -1
- package/dist/components/Lists/index.js +1 -0
- 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 +22 -2
- package/dist/helperComponents/Separator/constants.d.ts +2 -0
- package/dist/helperComponents/Separator/constants.js +5 -0
- package/dist/helperComponents/Separator/styles.module.css +20 -1
- package/dist/helperComponents/index.d.ts +1 -0
- package/dist/helperComponents/index.js +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/types.d.ts +1 -1
- package/package.json +13 -18
- package/src/components/Items/AccordionItem/AccordionItem.tsx +24 -20
- package/src/components/Items/BaseItem/BaseItem.tsx +91 -82
- package/src/components/Items/BaseItem/styles.module.scss +19 -77
- 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 +88 -85
- package/src/components/Items/NextListItem/constants.ts +12 -0
- package/src/components/Items/PinGroupItem/PinGroupItem.tsx +14 -4
- package/src/components/Items/PinGroupItem/styles.module.scss +14 -14
- 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/styles.module.scss +36 -25
- package/src/components/Items/types.ts +91 -42
- package/src/components/Items/utils.ts +199 -52
- package/src/components/Lists/Droplist/DropList.tsx +155 -98
- package/src/components/Lists/List/List.tsx +129 -104
- package/src/components/Lists/ListPrivate/ListPrivate.tsx +19 -20
- package/src/components/Lists/ListPrivate/styles.module.scss +1 -0
- package/src/components/Lists/contexts/CollapseProvider.tsx +22 -0
- package/src/components/Lists/contexts/FocusListProvider.tsx +15 -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/index.ts +2 -2
- package/src/components/Lists/types.ts +20 -24
- package/src/components/index.ts +17 -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 +49 -3
- package/src/helperComponents/Separator/constants.ts +7 -0
- package/src/helperComponents/Separator/styles.module.scss +41 -1
- package/src/helperComponents/index.ts +1 -0
- package/src/index.ts +4 -2
- 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/dist/hooks.d.ts +0 -5
- package/dist/hooks.js +0 -15
- package/dist/utils.d.ts +0 -30
- package/dist/utils.js +0 -115
- 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/src/hooks.ts +0 -27
- package/src/utils.ts +0 -175
|
@@ -1,33 +1,36 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MouseEvent, useCallback } from 'react';
|
|
2
2
|
|
|
3
3
|
import { ChevronDownSVG, ChevronUpSVG } from '@snack-uikit/icons';
|
|
4
4
|
|
|
5
5
|
import { CollapseBlockPrivate } from '../../../helperComponents';
|
|
6
|
-
import {
|
|
6
|
+
import { CollapseLevelContext, useCollapseContext, useCollapseLevelContext } from '../../Lists/contexts';
|
|
7
7
|
import { BaseItem } from '../BaseItem';
|
|
8
8
|
import { useGroupItemSelection, useRenderItems } from '../hooks';
|
|
9
|
-
import {
|
|
9
|
+
import { CommonFlattenProps, FlattenAccordionItem } from '../types';
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
const { level = 1 } = useCollapseContext();
|
|
13
|
-
const { toggleOpenCollapsedItems, openCollapsedItems } = useParentListContext();
|
|
14
|
-
const { isIndeterminate, checked, handleOnSelect } = useGroupItemSelection({ items: itemsProp, id, disabled });
|
|
11
|
+
type AccordionItemProps = Omit<FlattenAccordionItem, 'type>'> & CommonFlattenProps;
|
|
15
12
|
|
|
16
|
-
|
|
13
|
+
export function AccordionItem({ id, disabled, allChildIds, items, ...option }: AccordionItemProps) {
|
|
14
|
+
const { level = 1 } = useCollapseLevelContext();
|
|
15
|
+
const { openCollapseItems = [], toggleOpenCollapseItem } = useCollapseContext();
|
|
17
16
|
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
const { indeterminate, checked, handleOnSelect } = useGroupItemSelection({
|
|
18
|
+
items,
|
|
19
|
+
id,
|
|
20
|
+
disabled,
|
|
21
|
+
allChildIds,
|
|
22
|
+
});
|
|
21
23
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
const isOpen = Boolean(openCollapseItems.includes(id ?? ''));
|
|
25
|
+
|
|
26
|
+
const handleKeyDown = useCallback(() => {
|
|
27
|
+
toggleOpenCollapseItem?.(id ?? '');
|
|
28
|
+
}, [id, toggleOpenCollapseItem]);
|
|
26
29
|
|
|
27
|
-
const itemsJSX = useRenderItems(
|
|
30
|
+
const itemsJSX = useRenderItems(items);
|
|
28
31
|
|
|
29
32
|
const handleItemClick = (e: MouseEvent<HTMLElement>) => {
|
|
30
|
-
|
|
33
|
+
toggleOpenCollapseItem?.(id ?? '');
|
|
31
34
|
option.onClick?.(e);
|
|
32
35
|
};
|
|
33
36
|
|
|
@@ -41,15 +44,16 @@ export function AccordionItem({ items: itemsProp, id, disabled, ...option }: Acc
|
|
|
41
44
|
expandIcon={isOpen ? <ChevronUpSVG /> : <ChevronDownSVG />}
|
|
42
45
|
onClick={handleItemClick}
|
|
43
46
|
isParentNode
|
|
44
|
-
|
|
45
|
-
|
|
47
|
+
onOpenNestedList={handleKeyDown}
|
|
48
|
+
checked={checked}
|
|
49
|
+
indeterminate={indeterminate}
|
|
46
50
|
onSelect={!disabled ? handleOnSelect : undefined}
|
|
47
51
|
/>
|
|
48
52
|
}
|
|
49
53
|
expanded={isOpen}
|
|
50
54
|
data-test-id={`list__accordion-item-${id}`}
|
|
51
55
|
>
|
|
52
|
-
<
|
|
56
|
+
<CollapseLevelContext.Provider value={{ level: level + 1 }}>{itemsJSX}</CollapseLevelContext.Provider>
|
|
53
57
|
</CollapseBlockPrivate>
|
|
54
58
|
);
|
|
55
59
|
}
|
|
@@ -1,18 +1,31 @@
|
|
|
1
1
|
import cn from 'classnames';
|
|
2
|
-
import { FocusEvent, KeyboardEvent, MouseEvent, RefObject } from 'react';
|
|
2
|
+
import { FocusEvent, KeyboardEvent, MouseEvent, ReactNode, RefObject } from 'react';
|
|
3
3
|
|
|
4
4
|
import { Checkbox, Switch } from '@snack-uikit/toggles';
|
|
5
|
-
import { TruncateString } from '@snack-uikit/truncate-string';
|
|
6
5
|
import { extractSupportProps } from '@snack-uikit/utils';
|
|
7
6
|
|
|
8
|
-
import {
|
|
7
|
+
import { ItemContent } from '../../../helperComponents';
|
|
8
|
+
import {
|
|
9
|
+
useCollapseLevelContext,
|
|
10
|
+
useFocusListContext,
|
|
11
|
+
useNewListContext,
|
|
12
|
+
useSelectionContext,
|
|
13
|
+
} from '../../Lists/contexts';
|
|
9
14
|
import commonStyles from '../styles.module.scss';
|
|
10
|
-
import {
|
|
15
|
+
import { FlattenBaseItem } from '../types';
|
|
16
|
+
import { isContentItem } from '../utils';
|
|
11
17
|
import { CHECKBOX_SIZE_MAP } from './constants';
|
|
12
18
|
import styles from './styles.module.scss';
|
|
13
19
|
|
|
14
|
-
type AllBaseItemProps =
|
|
15
|
-
|
|
20
|
+
type AllBaseItemProps = FlattenBaseItem & {
|
|
21
|
+
expandIcon?: ReactNode;
|
|
22
|
+
open?: boolean;
|
|
23
|
+
indeterminate?: boolean;
|
|
24
|
+
checked?: boolean;
|
|
25
|
+
onSelect?(): void;
|
|
26
|
+
isParentNode?: boolean;
|
|
27
|
+
onOpenNestedList?(e?: KeyboardEvent<HTMLElement>): void;
|
|
28
|
+
};
|
|
16
29
|
|
|
17
30
|
export function BaseItem({
|
|
18
31
|
beforeContent,
|
|
@@ -29,44 +42,54 @@ export function BaseItem({
|
|
|
29
42
|
onKeyDown,
|
|
30
43
|
onFocus,
|
|
31
44
|
indeterminate,
|
|
45
|
+
checked: checkedProp,
|
|
32
46
|
onSelect,
|
|
47
|
+
onOpenNestedList,
|
|
33
48
|
isParentNode,
|
|
34
49
|
className,
|
|
35
50
|
inactive,
|
|
36
51
|
itemWrapRender,
|
|
37
52
|
...rest
|
|
38
53
|
}: AllBaseItemProps) {
|
|
39
|
-
const { option, caption, description, truncate: contentTruncate } = content || {};
|
|
40
54
|
const interactive = !inactive;
|
|
41
55
|
|
|
42
|
-
const {
|
|
43
|
-
const {
|
|
44
|
-
const {
|
|
56
|
+
const { size = 's', marker, contentRender } = useNewListContext();
|
|
57
|
+
const { level = 0 } = useCollapseLevelContext();
|
|
58
|
+
const { forceUpdateActiveItemId } = useFocusListContext();
|
|
45
59
|
const { value, onChange, mode, isSelectionSingle, isSelectionMultiple } = useSelectionContext();
|
|
46
60
|
|
|
47
|
-
const isChecked = isSelectionSingle ? value === id : value?.includes(id);
|
|
61
|
+
const isChecked = isSelectionSingle ? value === id : checkedProp ?? value?.includes(id ?? '');
|
|
48
62
|
|
|
49
63
|
const handleChange = () => {
|
|
50
|
-
onChange?.(id
|
|
64
|
+
onChange?.(id);
|
|
51
65
|
};
|
|
52
66
|
|
|
53
67
|
const handleItemMouseDown = (e: MouseEvent<HTMLElement>) => {
|
|
54
68
|
if (disabled) return;
|
|
55
69
|
|
|
56
70
|
if (interactive) {
|
|
57
|
-
parentResetActiveFocusIndex?.();
|
|
58
|
-
|
|
59
71
|
if (!isParentNode) {
|
|
60
72
|
handleChange();
|
|
61
73
|
}
|
|
62
74
|
}
|
|
63
75
|
|
|
64
76
|
onMouseDown?.(e);
|
|
77
|
+
|
|
78
|
+
forceUpdateActiveItemId?.('~drop-focus');
|
|
65
79
|
};
|
|
66
80
|
|
|
67
81
|
const handleItemKeyDown = (e: KeyboardEvent<HTMLElement>) => {
|
|
68
82
|
onKeyDown?.(e);
|
|
69
83
|
|
|
84
|
+
if (e.key === 'ArrowRight') {
|
|
85
|
+
onOpenNestedList?.(e);
|
|
86
|
+
|
|
87
|
+
e.preventDefault();
|
|
88
|
+
e.stopPropagation();
|
|
89
|
+
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
70
93
|
if (e.code === 'Space' || e.key === 'Enter') {
|
|
71
94
|
if (isSelectionMultiple && isParentNode && onSelect) {
|
|
72
95
|
onSelect();
|
|
@@ -100,85 +123,71 @@ export function BaseItem({
|
|
|
100
123
|
|
|
101
124
|
const props = extractSupportProps(rest);
|
|
102
125
|
|
|
103
|
-
const
|
|
104
|
-
<
|
|
105
|
-
|
|
106
|
-
role={'menuitem'}
|
|
107
|
-
data-test-id={props['data-test-id'] || 'list__base-item_' + id}
|
|
108
|
-
ref={itemRef as unknown as RefObject<HTMLLIElement>}
|
|
109
|
-
className={cn(commonStyles.listItem, styles.droplistItem, className)}
|
|
110
|
-
data-size={size}
|
|
111
|
-
onClick={onClick}
|
|
112
|
-
onMouseDown={handleItemMouseDown}
|
|
113
|
-
tabIndex={-1}
|
|
114
|
-
data-non-pointer={inactive && !onClick}
|
|
126
|
+
const itemJSX = (
|
|
127
|
+
<div
|
|
128
|
+
className={cn(commonStyles.itemWrapper, styles.innerWrapper, className)}
|
|
115
129
|
data-inactive={inactive || undefined}
|
|
116
|
-
data-checked={(isParentNode && (indeterminate || isChecked)) || (isChecked && !switchProp) || undefined}
|
|
117
|
-
data-variant={mode || undefined}
|
|
118
|
-
data-open={open || undefined}
|
|
119
130
|
data-disabled={disabled || undefined}
|
|
120
|
-
|
|
121
|
-
data-
|
|
122
|
-
onKeyDown={handleItemKeyDown}
|
|
123
|
-
onFocus={handleItemFocus}
|
|
124
|
-
style={{ '--level': level }}
|
|
131
|
+
data-variant={mode || undefined}
|
|
132
|
+
data-checked={(isParentNode && (indeterminate || isChecked)) || (isChecked && !switchProp) || undefined}
|
|
125
133
|
>
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
{description && (
|
|
160
|
-
<div className={styles.description}>
|
|
161
|
-
<TruncateString
|
|
162
|
-
text={description}
|
|
163
|
-
maxLines={contentTruncate?.description ?? 2}
|
|
164
|
-
data-test-id='list__base-item-description'
|
|
134
|
+
<li
|
|
135
|
+
data-type='outside'
|
|
136
|
+
role={'menuitem'}
|
|
137
|
+
data-test-id={props['data-test-id'] || 'list__base-item_' + id}
|
|
138
|
+
data-checked={(isParentNode && (indeterminate || isChecked)) || (isChecked && !switchProp) || undefined}
|
|
139
|
+
ref={itemRef as unknown as RefObject<HTMLLIElement>}
|
|
140
|
+
className={cn(commonStyles.listItem, styles.droplistItem)}
|
|
141
|
+
data-size={size}
|
|
142
|
+
onClick={onClick}
|
|
143
|
+
onMouseDown={handleItemMouseDown}
|
|
144
|
+
tabIndex={-1}
|
|
145
|
+
data-non-pointer={inactive && !onClick}
|
|
146
|
+
data-variant={mode || undefined}
|
|
147
|
+
data-open={open || undefined}
|
|
148
|
+
onKeyDown={handleItemKeyDown}
|
|
149
|
+
onFocus={handleItemFocus}
|
|
150
|
+
style={{ '--level': level }}
|
|
151
|
+
>
|
|
152
|
+
{!switchProp && isSelectionSingle && marker && !isParentNode && interactive && (
|
|
153
|
+
<div className={styles.markerContainer} data-test-id='list__base-item-marker' />
|
|
154
|
+
)}
|
|
155
|
+
|
|
156
|
+
{!switchProp && isSelectionMultiple && interactive && (
|
|
157
|
+
<div className={styles.checkbox}>
|
|
158
|
+
<Checkbox
|
|
159
|
+
size={CHECKBOX_SIZE_MAP[size ?? 's']}
|
|
160
|
+
disabled={disabled}
|
|
161
|
+
tabIndex={-1}
|
|
162
|
+
onChange={isParentNode ? handleCheckboxChange : undefined}
|
|
163
|
+
checked={isChecked}
|
|
164
|
+
data-test-id='list__base-item-checkbox'
|
|
165
|
+
onClick={handleCheckboxClick}
|
|
166
|
+
indeterminate={indeterminate}
|
|
165
167
|
/>
|
|
166
168
|
</div>
|
|
167
169
|
)}
|
|
168
|
-
</div>
|
|
169
170
|
|
|
170
|
-
|
|
171
|
+
{beforeContent && <div className={styles.beforeContent}>{beforeContent}</div>}
|
|
172
|
+
{content && isContentItem(content) ? (
|
|
173
|
+
contentRender?.({ id, content }) ?? <ItemContent disabled={disabled} {...content} />
|
|
174
|
+
) : (
|
|
175
|
+
<div className={styles.content}> {content} </div>
|
|
176
|
+
)}
|
|
177
|
+
{afterContent}
|
|
178
|
+
|
|
179
|
+
{switchProp && interactive && (
|
|
180
|
+
<Switch disabled={disabled} checked={isChecked} data-test-id='list__base-item-switch' />
|
|
181
|
+
)}
|
|
171
182
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
{!switchProp && expandIcon && <span className={styles.expandableIcon}>{expandIcon}</span>}
|
|
176
|
-
</li>
|
|
183
|
+
{!switchProp && expandIcon && <span className={styles.expandableIcon}>{expandIcon}</span>}
|
|
184
|
+
</li>
|
|
185
|
+
</div>
|
|
177
186
|
);
|
|
178
187
|
|
|
179
188
|
if (!itemWrapRender) {
|
|
180
|
-
return
|
|
189
|
+
return itemJSX;
|
|
181
190
|
}
|
|
182
191
|
|
|
183
|
-
return itemWrapRender(
|
|
192
|
+
return itemWrapRender(itemJSX);
|
|
184
193
|
}
|
|
@@ -2,48 +2,6 @@
|
|
|
2
2
|
@import '@snack-uikit/figma-tokens/build/scss/components/styles-tokens-element';
|
|
3
3
|
|
|
4
4
|
$sizes: 's', 'm', 'l';
|
|
5
|
-
$typography: (
|
|
6
|
-
's': (
|
|
7
|
-
'label': $sans-body-s,
|
|
8
|
-
'caption': $sans-body-s,
|
|
9
|
-
'description': $sans-body-s,
|
|
10
|
-
'separator': $light-label-m,
|
|
11
|
-
),
|
|
12
|
-
'm': (
|
|
13
|
-
'label': $sans-body-m,
|
|
14
|
-
'caption': $sans-body-s,
|
|
15
|
-
'description': $sans-body-s,
|
|
16
|
-
'separator': $light-label-l,
|
|
17
|
-
),
|
|
18
|
-
'l': (
|
|
19
|
-
'label': $sans-body-l,
|
|
20
|
-
'caption': $sans-body-m,
|
|
21
|
-
'description': $sans-body-m,
|
|
22
|
-
'separator': $light-label-l,
|
|
23
|
-
),
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
.headline {
|
|
27
|
-
display: flex;
|
|
28
|
-
align-items: center;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.option {
|
|
32
|
-
overflow: hidden;
|
|
33
|
-
flex: 1;
|
|
34
|
-
color: $sys-neutral-text-main;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.caption {
|
|
38
|
-
overflow: hidden;
|
|
39
|
-
color: $sys-neutral-text-light;
|
|
40
|
-
text-overflow: ellipsis;
|
|
41
|
-
white-space: nowrap;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.description {
|
|
45
|
-
color: $sys-neutral-text-support;
|
|
46
|
-
}
|
|
47
5
|
|
|
48
6
|
.checkbox {
|
|
49
7
|
display: inline-flex;
|
|
@@ -69,8 +27,8 @@ $typography: (
|
|
|
69
27
|
color: $sys-neutral-text-light;
|
|
70
28
|
|
|
71
29
|
svg {
|
|
72
|
-
width: 100
|
|
73
|
-
height: 100
|
|
30
|
+
max-width: 100%;
|
|
31
|
+
max-height: 100%;
|
|
74
32
|
}
|
|
75
33
|
}
|
|
76
34
|
|
|
@@ -101,14 +59,6 @@ $typography: (
|
|
|
101
59
|
height: 100%;
|
|
102
60
|
}
|
|
103
61
|
}
|
|
104
|
-
|
|
105
|
-
.content {
|
|
106
|
-
overflow: hidden;
|
|
107
|
-
flex-grow: 1;
|
|
108
|
-
flex-shrink: 1;
|
|
109
|
-
box-sizing: border-box;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
62
|
.droplistItem {
|
|
113
63
|
width: 100%;
|
|
114
64
|
|
|
@@ -121,30 +71,16 @@ $typography: (
|
|
|
121
71
|
.headline {
|
|
122
72
|
@include composite-var($drop-list, 'item', $size, 'headline');
|
|
123
73
|
}
|
|
124
|
-
|
|
125
|
-
.option {
|
|
126
|
-
@include composite-var($typography, $size, 'label');
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
.caption {
|
|
130
|
-
@include composite-var($typography, $size, 'caption');
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
.description {
|
|
134
|
-
@include composite-var($typography, $size, 'description');
|
|
135
|
-
}
|
|
136
74
|
}
|
|
137
75
|
}
|
|
138
76
|
|
|
139
77
|
&[data-non-pointer] {
|
|
140
78
|
cursor: inherit;
|
|
141
79
|
}
|
|
80
|
+
}
|
|
142
81
|
|
|
143
|
-
|
|
82
|
+
.innerWrapper {
|
|
144
83
|
&[data-disabled] {
|
|
145
|
-
.option,
|
|
146
|
-
.description,
|
|
147
|
-
.caption,
|
|
148
84
|
.expandableIcon {
|
|
149
85
|
color: $sys-neutral-text-disabled;
|
|
150
86
|
}
|
|
@@ -152,17 +88,22 @@ $typography: (
|
|
|
152
88
|
.beforeContent {
|
|
153
89
|
opacity: $opacity-a064;
|
|
154
90
|
}
|
|
91
|
+
|
|
92
|
+
.droplistItem {
|
|
93
|
+
cursor: not-allowed;
|
|
94
|
+
}
|
|
155
95
|
}
|
|
156
96
|
|
|
157
97
|
&[data-has-checked],
|
|
158
98
|
&[data-checked] {
|
|
159
99
|
&[data-variant='single'] {
|
|
160
|
-
&::
|
|
100
|
+
&::before {
|
|
161
101
|
opacity: $opacity-a008;
|
|
162
102
|
background-color: $sys-primary-accent-default;
|
|
163
103
|
}
|
|
104
|
+
|
|
164
105
|
&:hover {
|
|
165
|
-
&::
|
|
106
|
+
&::before {
|
|
166
107
|
opacity: $opacity-a016;
|
|
167
108
|
background-color: $sys-primary-accent-default;
|
|
168
109
|
}
|
|
@@ -173,22 +114,23 @@ $typography: (
|
|
|
173
114
|
background-color: $sys-primary-accent-default;
|
|
174
115
|
}
|
|
175
116
|
|
|
176
|
-
|
|
117
|
+
.droplistItem:focus-visible {
|
|
177
118
|
&[data-variant='single'] {
|
|
178
119
|
outline-color: $sys-primary-accent-default;
|
|
179
120
|
}
|
|
180
121
|
}
|
|
181
122
|
|
|
182
123
|
&[data-disabled] {
|
|
183
|
-
&[data-variant='single'] {
|
|
184
|
-
&::before {
|
|
185
|
-
display: none;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
124
|
.markerContainer:before {
|
|
190
125
|
background-color: $sys-neutral-text-disabled;
|
|
191
126
|
}
|
|
192
127
|
}
|
|
193
128
|
}
|
|
194
129
|
}
|
|
130
|
+
|
|
131
|
+
.content {
|
|
132
|
+
overflow: hidden;
|
|
133
|
+
flex-grow: 1;
|
|
134
|
+
flex-shrink: 1;
|
|
135
|
+
box-sizing: border-box;
|
|
136
|
+
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { Separator } from '../../../helperComponents';
|
|
2
|
-
import { useListContext } from '../../Lists/contexts';
|
|
3
2
|
import { useRenderItems } from '../hooks';
|
|
4
|
-
import {
|
|
3
|
+
import { FlattenGroupListItem, ItemId } from '../types';
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
const { size } = useListContext();
|
|
5
|
+
type GroupItemProps = Omit<FlattenGroupListItem, 'type'> & { items: ItemId[] };
|
|
8
6
|
|
|
7
|
+
export function GroupItem({ label, truncate, divider, items, mode }: GroupItemProps) {
|
|
9
8
|
const itemsJSX = useRenderItems(items);
|
|
10
9
|
|
|
11
10
|
return (
|
|
12
11
|
<>
|
|
13
|
-
<Separator label={label} truncate={truncate} divider={divider} mode={mode}
|
|
12
|
+
<Separator label={label} truncate={truncate} divider={divider} mode={mode} />
|
|
13
|
+
|
|
14
14
|
{itemsJSX}
|
|
15
15
|
</>
|
|
16
16
|
);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Separator } from '../../../helperComponents';
|
|
2
|
+
import { useGroupItemSelection, useRenderItems } from '../hooks';
|
|
3
|
+
import { CommonFlattenProps, FlattenGroupSelectListItem } from '../types';
|
|
4
|
+
|
|
5
|
+
type GroupSelectItemProps = Omit<FlattenGroupSelectListItem, 'type'> & CommonFlattenProps;
|
|
6
|
+
|
|
7
|
+
export function GroupSelectItem({
|
|
8
|
+
label,
|
|
9
|
+
truncate,
|
|
10
|
+
divider,
|
|
11
|
+
items,
|
|
12
|
+
mode,
|
|
13
|
+
id,
|
|
14
|
+
itemRef,
|
|
15
|
+
allChildIds,
|
|
16
|
+
}: GroupSelectItemProps) {
|
|
17
|
+
const { indeterminate, checked, handleOnSelect } = useGroupItemSelection({
|
|
18
|
+
items,
|
|
19
|
+
id,
|
|
20
|
+
disabled: false,
|
|
21
|
+
allChildIds,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const itemsJSX = useRenderItems(items);
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<>
|
|
28
|
+
<Separator
|
|
29
|
+
label={label}
|
|
30
|
+
truncate={truncate}
|
|
31
|
+
divider={divider}
|
|
32
|
+
mode={mode}
|
|
33
|
+
selectButton={{
|
|
34
|
+
indeterminate,
|
|
35
|
+
checked,
|
|
36
|
+
itemRef,
|
|
37
|
+
onClick: handleOnSelect,
|
|
38
|
+
}}
|
|
39
|
+
/>
|
|
40
|
+
|
|
41
|
+
{itemsJSX}
|
|
42
|
+
</>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './GroupSelectItem';
|