@snack-uikit/list 0.3.2-preview-ff0b5a40.0 → 0.3.2
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 +9 -0
- package/dist/components/Items/BaseItem/BaseItem.js +2 -2
- package/dist/components/Items/BaseItem/styles.module.css +8 -0
- package/dist/components/Lists/Droplist/DropList.js +1 -1
- package/dist/components/Lists/List/List.js +1 -1
- package/dist/components/Lists/ListPrivate/ListPrivate.d.ts +1 -1
- package/dist/components/Lists/ListPrivate/ListPrivate.js +3 -3
- package/dist/components/Lists/ListPrivate/styles.module.css +0 -3
- package/dist/components/Lists/contexts/ListProvider.d.ts +6 -3
- package/dist/components/Lists/contexts/ListProvider.js +2 -2
- package/dist/components/Lists/types.d.ts +2 -2
- package/package.json +3 -3
- package/src/components/Items/BaseItem/BaseItem.tsx +2 -1
- package/src/components/Items/BaseItem/styles.module.scss +9 -0
- package/src/components/Lists/Droplist/DropList.tsx +3 -2
- package/src/components/Lists/List/List.tsx +1 -0
- package/src/components/Lists/ListPrivate/ListPrivate.tsx +4 -7
- package/src/components/Lists/ListPrivate/styles.module.scss +0 -4
- package/src/components/Lists/contexts/ListProvider.tsx +8 -4
- package/src/components/Lists/types.ts +11 -10
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,15 @@
|
|
|
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.3.2 (2024-02-09)
|
|
7
|
+
|
|
8
|
+
### Only dependencies have been changed
|
|
9
|
+
* [@snack-uikit/scroll@0.5.1](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/scroll/CHANGELOG.md)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
6
15
|
## 0.3.1 (2024-02-08)
|
|
7
16
|
|
|
8
17
|
### Only dependencies have been changed
|
|
@@ -23,7 +23,7 @@ export function BaseItem(_a) {
|
|
|
23
23
|
const { option, caption, description } = content || {};
|
|
24
24
|
const interactive = !inactive;
|
|
25
25
|
const { parentResetActiveFocusIndex } = useParentListContext();
|
|
26
|
-
const { size, marker } = useListContext();
|
|
26
|
+
const { size, marker, parent } = useListContext();
|
|
27
27
|
const { level = 0 } = useCollapseContext();
|
|
28
28
|
const { value, onChange, mode, isSelectionSingle, isSelectionMultiple } = useSelectionContext();
|
|
29
29
|
const isChecked = isSelectionSingle ? value === id : value === null || value === void 0 ? void 0 : value.includes(id);
|
|
@@ -68,7 +68,7 @@ export function BaseItem(_a) {
|
|
|
68
68
|
e.stopPropagation();
|
|
69
69
|
};
|
|
70
70
|
const props = extractSupportProps(rest);
|
|
71
|
-
const item = (_jsxs("li", { role: 'menuitem', "data-test-id": props['data-test-id'] || 'list__base-item_' + id, ref: itemRef, className: cn(commonStyles.listItem, styles.droplistItem, className), "data-size": size, onClick: handleItemClick, 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, "aria-disabled": disabled || undefined, onKeyDown: handleItemKeyDown, onFocus: handleItemFocus, style: { '--level': level }, children: [!switchProp && isSelectionSingle && marker && !isParentNode && interactive && (_jsx("div", { className: styles.markerContainer, "data-test-id": 'list__base-item-marker' })), !switchProp && isSelectionMultiple && interactive && (_jsx("div", { className: styles.checkbox, children: _jsx(Checkbox, { size: CHECKBOX_SIZE_MAP[size !== null && size !== void 0 ? size : 's'], disabled: disabled, tabIndex: -1, onChange: handleCheckboxChange, checked: isChecked, "data-test-id": 'list__base-item-checkbox', onClick: handleCheckboxClick, indeterminate: indeterminate }) })), beforeContent && _jsx("div", { className: styles.beforeContent, children: beforeContent }), _jsxs("div", { className: styles.content, children: [_jsxs("div", { className: styles.headline, children: [_jsx("span", { className: styles.option, children: _jsx(TruncateString, { text: option, maxLines: 1 }) }), caption && _jsx("span", { className: styles.caption, children: caption })] }), description && (_jsx("div", { className: styles.description, children: _jsx(TruncateString, { text: description, maxLines: 2 }) }))] }), afterContent, switchProp && interactive && (_jsx(Switch, { disabled: disabled, checked: isChecked, "data-test-id": 'list__base-item-switch' })), !switchProp && expandIcon && _jsx("span", { className: styles.expandableIcon, children: expandIcon })] }));
|
|
71
|
+
const item = (_jsxs("li", { role: 'menuitem', "data-test-id": props['data-test-id'] || 'list__base-item_' + id, ref: itemRef, className: cn(commonStyles.listItem, styles.droplistItem, className), "data-size": size, onClick: handleItemClick, 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, "aria-disabled": disabled || undefined, "data-parent": parent || 'list', onKeyDown: handleItemKeyDown, onFocus: handleItemFocus, style: { '--level': level }, children: [!switchProp && isSelectionSingle && marker && !isParentNode && interactive && (_jsx("div", { className: styles.markerContainer, "data-test-id": 'list__base-item-marker' })), !switchProp && isSelectionMultiple && interactive && (_jsx("div", { className: styles.checkbox, children: _jsx(Checkbox, { size: CHECKBOX_SIZE_MAP[size !== null && size !== void 0 ? size : 's'], disabled: disabled, tabIndex: -1, onChange: handleCheckboxChange, checked: isChecked, "data-test-id": 'list__base-item-checkbox', onClick: handleCheckboxClick, indeterminate: indeterminate }) })), beforeContent && _jsx("div", { className: styles.beforeContent, children: beforeContent }), _jsxs("div", { className: styles.content, children: [_jsxs("div", { className: styles.headline, children: [_jsx("span", { className: styles.option, children: _jsx(TruncateString, { text: option, maxLines: 1 }) }), caption && _jsx("span", { className: styles.caption, children: caption })] }), description && (_jsx("div", { className: styles.description, children: _jsx(TruncateString, { text: description, maxLines: 2 }) }))] }), afterContent, switchProp && interactive && (_jsx(Switch, { disabled: disabled, checked: isChecked, "data-test-id": 'list__base-item-switch' })), !switchProp && expandIcon && _jsx("span", { className: styles.expandableIcon, children: expandIcon })] }));
|
|
72
72
|
if (!itemWrapRender) {
|
|
73
73
|
return item;
|
|
74
74
|
}
|
|
@@ -72,6 +72,7 @@
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
.content{
|
|
75
|
+
overflow:hidden;
|
|
75
76
|
flex-grow:1;
|
|
76
77
|
flex-shrink:1;
|
|
77
78
|
box-sizing:border-box;
|
|
@@ -170,6 +171,13 @@
|
|
|
170
171
|
letter-spacing:var(--sans-body-m-letter-spacing, 0.1px);
|
|
171
172
|
paragraph-spacing:var(--sans-body-m-paragraph-spacing, 7.7px);
|
|
172
173
|
}
|
|
174
|
+
.droplistItem[data-parent=list]{
|
|
175
|
+
width:100%;
|
|
176
|
+
}
|
|
177
|
+
.droplistItem[data-parent=droplist]{
|
|
178
|
+
width:-moz-max-content;
|
|
179
|
+
width:max-content;
|
|
180
|
+
}
|
|
173
181
|
.droplistItem[data-non-pointer]{
|
|
174
182
|
cursor:inherit;
|
|
175
183
|
}
|
|
@@ -95,7 +95,7 @@ export function Droplist(_a) {
|
|
|
95
95
|
parentResetNestedIndex: resetNestedIndex,
|
|
96
96
|
parentResetActiveFocusIndex: resetActiveFocusIndex,
|
|
97
97
|
toggleOpenCollapsedItems: id => setOpenCollapsedItems((items = []) => items.includes(id) ? items.filter(item => item !== id) : items === null || items === void 0 ? void 0 : items.concat([id])),
|
|
98
|
-
}, children: _jsx(Dropdown, Object.assign({ content: _jsx(ListPrivate, Object.assign({ onKeyDown: handleListKeyDown, tabIndex: 0, ref: listRef, search: search, limitedScrollHeight: true
|
|
98
|
+
}, children: _jsx(Dropdown, Object.assign({ content: _jsx(ListPrivate, Object.assign({}, slicedItems, props, { onKeyDown: handleListKeyDown, tabIndex: 0, ref: listRef, search: search, limitedScrollHeight: true, parent: 'droplist' })), trigger: trigger, placement: placement, widthStrategy: widthStrategy }, (triggerElemRefProp
|
|
99
99
|
? {}
|
|
100
100
|
: {
|
|
101
101
|
triggerRef: triggerElemRef,
|
|
@@ -87,5 +87,5 @@ export const List = forwardRef((_a, ref) => {
|
|
|
87
87
|
parentResetActiveFocusIndex: resetActiveFocusIndex,
|
|
88
88
|
openCollapsedItems,
|
|
89
89
|
toggleOpenCollapsedItems: id => setOpenCollapsedItems((items = []) => items.includes(id) ? items.filter(item => item !== id) : items === null || items === void 0 ? void 0 : items.concat([id])),
|
|
90
|
-
}, children: _jsxs("div", { className: cn(styles.wrapper, className), "data-active": isActive || undefined, children: [_jsx(ListPrivate, Object.assign({}, props, slicedItems, { ref: mergeRefs(ref, listRef), onFocus: handleOnFocus, onKeyDown: mergedHandlerKeyDown, tabIndex: tabIndex, search: search, nested: false })), _jsx(HiddenTabButton, { ref: btnRef, listRef: listRef, tabIndex: tabIndex })] }) }) })));
|
|
90
|
+
}, children: _jsxs("div", { className: cn(styles.wrapper, className), "data-active": isActive || undefined, children: [_jsx(ListPrivate, Object.assign({}, props, slicedItems, { ref: mergeRefs(ref, listRef), onFocus: handleOnFocus, onKeyDown: mergedHandlerKeyDown, tabIndex: tabIndex, search: search, nested: false, parent: 'list' })), _jsx(HiddenTabButton, { ref: btnRef, listRef: listRef, tabIndex: tabIndex })] }) }) })));
|
|
91
91
|
});
|
|
@@ -19,7 +19,7 @@ export declare const ListPrivate: import("react").ForwardRefExoticComponent<{
|
|
|
19
19
|
} | undefined;
|
|
20
20
|
className?: string | undefined;
|
|
21
21
|
onKeyDown?(e: import("react").KeyboardEvent<HTMLElement>): void;
|
|
22
|
-
} & import("../contexts").SelectionState & import("../contexts").ListContextType & import("../../../types").ScrollProps & {
|
|
22
|
+
} & import("../contexts").SelectionState & import("../contexts").ListContextType & import("../../../types").ScrollProps & import("../contexts").ListContextPrivateType & {
|
|
23
23
|
nested?: boolean | undefined;
|
|
24
24
|
active?: boolean | undefined;
|
|
25
25
|
tabIndex?: number | undefined;
|
|
@@ -22,7 +22,7 @@ import commonStyles from '../styles.module.css';
|
|
|
22
22
|
import styles from './styles.module.css';
|
|
23
23
|
export const ListPrivate = forwardRef((_a, ref) => {
|
|
24
24
|
var _b, _c;
|
|
25
|
-
var { items, pinTop, pinBottom, onKeyDown, onBlur, onFocus, tabIndex, active, scroll, nested, search, scrollRef, scrollContainerRef, footer, loading, noData = 'No data', noResults = 'No results', size = 's', marker, limitedScrollHeight, className } = _a, props = __rest(_a, ["items", "pinTop", "pinBottom", "onKeyDown", "onBlur", "onFocus", "tabIndex", "active", "scroll", "nested", "search", "scrollRef", "scrollContainerRef", "footer", "loading", "noData", "noResults", "size", "marker", "limitedScrollHeight", "className"]);
|
|
25
|
+
var { items, pinTop, pinBottom, onKeyDown, onBlur, onFocus, tabIndex, active, scroll, nested, search, scrollRef, scrollContainerRef, footer, loading, noData = 'No data', noResults = 'No results', size = 's', marker, limitedScrollHeight, className, parent = 'list' } = _a, props = __rest(_a, ["items", "pinTop", "pinBottom", "onKeyDown", "onBlur", "onFocus", "tabIndex", "active", "scroll", "nested", "search", "scrollRef", "scrollContainerRef", "footer", "loading", "noData", "noResults", "size", "marker", "limitedScrollHeight", "className", "parent"]);
|
|
26
26
|
const itemsJSX = useRenderItems(items);
|
|
27
27
|
const itemsPinTopJSX = useRenderItems(pinTop !== null && pinTop !== void 0 ? pinTop : []);
|
|
28
28
|
const itemsPinBottomJSX = useRenderItems(pinBottom !== null && pinBottom !== void 0 ? pinBottom : []);
|
|
@@ -33,9 +33,9 @@ export const ListPrivate = forwardRef((_a, ref) => {
|
|
|
33
33
|
[commonStyles.scrollContainerS]: scroll && limitedScrollHeight && size === 's',
|
|
34
34
|
[commonStyles.scrollContainerM]: scroll && limitedScrollHeight && size === 'm',
|
|
35
35
|
[commonStyles.scrollContainerL]: scroll && limitedScrollHeight && size === 'l',
|
|
36
|
-
}), barHideStrategy: 'leave', size: size === 's' ? 's' : 'm', ref: scrollContainerRef, children: [content, _jsx("div", { className: styles.scrollStub, ref: scrollRef })] })) : (_jsx(_Fragment, { children: content })),
|
|
36
|
+
}), barHideStrategy: 'leave', size: size === 's' ? 's' : 'm', ref: scrollContainerRef, children: [content, _jsx("div", { className: styles.scrollStub, ref: scrollRef })] })) : (_jsx(_Fragment, { children: content })), Number(pinBottom === null || pinBottom === void 0 ? void 0 : pinBottom.length) > 0 && _jsx(PinBottomGroupItem, { children: itemsPinBottomJSX }), footer && _jsx("div", { className: styles.footer, children: footer })] }) })));
|
|
37
37
|
if (!nested) {
|
|
38
|
-
return (_jsx(ListContextProvider, { size: size, marker: marker, children: listJSX }));
|
|
38
|
+
return (_jsx(ListContextProvider, { size: size, marker: marker, parent: parent, children: listJSX }));
|
|
39
39
|
}
|
|
40
40
|
return (_jsx("li", { style: { listStyleType: 'none' }, role: 'menuitem', children: listJSX }));
|
|
41
41
|
});
|
|
@@ -5,10 +5,13 @@ export type ListContextType = {
|
|
|
5
5
|
/** Отображать ли маркер у выбранного жлемента списка */
|
|
6
6
|
marker?: boolean;
|
|
7
7
|
};
|
|
8
|
+
export type ListContextPrivateType = {
|
|
9
|
+
parent?: 'list' | 'droplist';
|
|
10
|
+
};
|
|
8
11
|
type Child = {
|
|
9
12
|
children: ReactNode;
|
|
10
13
|
};
|
|
11
|
-
export declare const ListContext: import("react").Context<ListContextType>;
|
|
12
|
-
export declare const useListContext: () => ListContextType;
|
|
13
|
-
export declare function ListContextProvider({ children, ...props }: ListContextType & Child): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export declare const ListContext: import("react").Context<ListContextType & ListContextPrivateType>;
|
|
15
|
+
export declare const useListContext: () => ListContextType & ListContextPrivateType;
|
|
16
|
+
export declare function ListContextProvider({ children, ...props }: ListContextType & Child & ListContextPrivateType): import("react/jsx-runtime").JSX.Element;
|
|
14
17
|
export {};
|
|
@@ -13,8 +13,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
13
13
|
import { createContext, useContext } from 'react';
|
|
14
14
|
export const ListContext = createContext({});
|
|
15
15
|
export const useListContext = () => useContext(ListContext);
|
|
16
|
-
function extractListProps({ size, marker }) {
|
|
17
|
-
return { size, marker };
|
|
16
|
+
function extractListProps({ size, marker, parent }) {
|
|
17
|
+
return { size, marker, parent };
|
|
18
18
|
}
|
|
19
19
|
export function ListContextProvider(_a) {
|
|
20
20
|
var { children } = _a, props = __rest(_a, ["children"]);
|
|
@@ -3,7 +3,7 @@ import { DropdownProps } from '@snack-uikit/dropdown';
|
|
|
3
3
|
import { WithSupportProps } from '@snack-uikit/utils';
|
|
4
4
|
import { ScrollProps, SearchState } from '../../types';
|
|
5
5
|
import { ItemProps } from '../Items';
|
|
6
|
-
import { ListContextType, SelectionState } from './contexts';
|
|
6
|
+
import { ListContextPrivateType, ListContextType, SelectionState } from './contexts';
|
|
7
7
|
type CollapseState = {
|
|
8
8
|
value?: (string | number)[];
|
|
9
9
|
onChange?(value: (string | number)[]): void;
|
|
@@ -45,7 +45,7 @@ export type DroplistProps = {
|
|
|
45
45
|
/** Триггер для дроплиста */
|
|
46
46
|
children?: ReactNode;
|
|
47
47
|
} & Pick<DropdownProps, 'trigger' | 'placement' | 'widthStrategy' | 'open' | 'onOpenChange'> & Omit<ListProps, 'tabIndex' | 'onKeyDown'>;
|
|
48
|
-
export type ListPrivateProps = ListProps & {
|
|
48
|
+
export type ListPrivateProps = ListProps & ListContextPrivateType & {
|
|
49
49
|
nested?: boolean;
|
|
50
50
|
active?: boolean;
|
|
51
51
|
tabIndex?: number;
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "List",
|
|
7
|
-
"version": "0.3.2
|
|
7
|
+
"version": "0.3.2",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@snack-uikit/dropdown": "0.2.0",
|
|
37
37
|
"@snack-uikit/icons": "0.20.1",
|
|
38
38
|
"@snack-uikit/loaders": "0.5.0",
|
|
39
|
-
"@snack-uikit/scroll": "0.5.1
|
|
39
|
+
"@snack-uikit/scroll": "0.5.1",
|
|
40
40
|
"@snack-uikit/search-private": "0.1.4",
|
|
41
41
|
"@snack-uikit/toggles": "0.9.5",
|
|
42
42
|
"@snack-uikit/truncate-string": "0.4.7",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"merge-refs": "1.2.2",
|
|
46
46
|
"uncontrollable": "8.0.4"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "3da1fb6b1253a73f4e2d7afb5494b64bbfdd6508"
|
|
49
49
|
}
|
|
@@ -39,7 +39,7 @@ export function BaseItem({
|
|
|
39
39
|
const interactive = !inactive;
|
|
40
40
|
|
|
41
41
|
const { parentResetActiveFocusIndex } = useParentListContext();
|
|
42
|
-
const { size, marker } = useListContext();
|
|
42
|
+
const { size, marker, parent } = useListContext();
|
|
43
43
|
const { level = 0 } = useCollapseContext();
|
|
44
44
|
const { value, onChange, mode, isSelectionSingle, isSelectionMultiple } = useSelectionContext();
|
|
45
45
|
|
|
@@ -112,6 +112,7 @@ export function BaseItem({
|
|
|
112
112
|
data-variant={mode || undefined}
|
|
113
113
|
data-open={open || undefined}
|
|
114
114
|
aria-disabled={disabled || undefined}
|
|
115
|
+
data-parent={parent || 'list'}
|
|
115
116
|
onKeyDown={handleItemKeyDown}
|
|
116
117
|
onFocus={handleItemFocus}
|
|
117
118
|
style={{ '--level': level }}
|
|
@@ -104,6 +104,7 @@ $typography: (
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
.content {
|
|
107
|
+
overflow: hidden;
|
|
107
108
|
flex-grow: 1;
|
|
108
109
|
flex-shrink: 1;
|
|
109
110
|
box-sizing: border-box;
|
|
@@ -134,6 +135,14 @@ $typography: (
|
|
|
134
135
|
}
|
|
135
136
|
}
|
|
136
137
|
|
|
138
|
+
&[data-parent='list'] {
|
|
139
|
+
width: 100%;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
&[data-parent='droplist'] {
|
|
143
|
+
width: max-content;
|
|
144
|
+
}
|
|
145
|
+
|
|
137
146
|
&[data-non-pointer] {
|
|
138
147
|
cursor: inherit;
|
|
139
148
|
}
|
|
@@ -147,13 +147,14 @@ export function Droplist({
|
|
|
147
147
|
<Dropdown
|
|
148
148
|
content={
|
|
149
149
|
<ListPrivate
|
|
150
|
+
{...slicedItems}
|
|
151
|
+
{...props}
|
|
150
152
|
onKeyDown={handleListKeyDown}
|
|
151
153
|
tabIndex={0}
|
|
152
154
|
ref={listRef}
|
|
153
155
|
search={search}
|
|
154
156
|
limitedScrollHeight
|
|
155
|
-
|
|
156
|
-
{...props}
|
|
157
|
+
parent='droplist'
|
|
157
158
|
/>
|
|
158
159
|
}
|
|
159
160
|
trigger={trigger}
|
|
@@ -36,6 +36,7 @@ export const ListPrivate = forwardRef<HTMLElement, ListPrivateProps>(
|
|
|
36
36
|
marker,
|
|
37
37
|
limitedScrollHeight,
|
|
38
38
|
className,
|
|
39
|
+
parent = 'list',
|
|
39
40
|
...props
|
|
40
41
|
},
|
|
41
42
|
ref,
|
|
@@ -122,20 +123,16 @@ export const ListPrivate = forwardRef<HTMLElement, ListPrivateProps>(
|
|
|
122
123
|
<>{content}</>
|
|
123
124
|
)}
|
|
124
125
|
|
|
125
|
-
{
|
|
126
|
-
<PinBottomGroupItem>
|
|
127
|
-
{Number(pinBottom?.length) > 0 && itemsPinBottomJSX}
|
|
126
|
+
{Number(pinBottom?.length) > 0 && <PinBottomGroupItem>{itemsPinBottomJSX}</PinBottomGroupItem>}
|
|
128
127
|
|
|
129
|
-
|
|
130
|
-
</PinBottomGroupItem>
|
|
131
|
-
)}
|
|
128
|
+
{footer && <div className={styles.footer}>{footer}</div>}
|
|
132
129
|
</ToggleGroup>
|
|
133
130
|
</ul>
|
|
134
131
|
);
|
|
135
132
|
|
|
136
133
|
if (!nested) {
|
|
137
134
|
return (
|
|
138
|
-
<ListContextProvider size={size} marker={marker}>
|
|
135
|
+
<ListContextProvider size={size} marker={marker} parent={parent}>
|
|
139
136
|
{listJSX}
|
|
140
137
|
</ListContextProvider>
|
|
141
138
|
);
|
|
@@ -7,18 +7,22 @@ export type ListContextType = {
|
|
|
7
7
|
marker?: boolean;
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
+
export type ListContextPrivateType = {
|
|
11
|
+
parent?: 'list' | 'droplist';
|
|
12
|
+
};
|
|
13
|
+
|
|
10
14
|
type Child = {
|
|
11
15
|
children: ReactNode;
|
|
12
16
|
};
|
|
13
17
|
|
|
14
|
-
export const ListContext = createContext<ListContextType>({});
|
|
18
|
+
export const ListContext = createContext<ListContextType & ListContextPrivateType>({});
|
|
15
19
|
|
|
16
20
|
export const useListContext = () => useContext(ListContext);
|
|
17
21
|
|
|
18
|
-
function extractListProps<T extends ListContextType>({ size, marker }: T) {
|
|
19
|
-
return { size, marker };
|
|
22
|
+
function extractListProps<T extends ListContextType & ListContextPrivateType>({ size, marker, parent }: T) {
|
|
23
|
+
return { size, marker, parent };
|
|
20
24
|
}
|
|
21
25
|
|
|
22
|
-
export function ListContextProvider({ children, ...props }: ListContextType & Child) {
|
|
26
|
+
export function ListContextProvider({ children, ...props }: ListContextType & Child & ListContextPrivateType) {
|
|
23
27
|
return <ListContext.Provider value={extractListProps(props)}>{children}</ListContext.Provider>;
|
|
24
28
|
}
|
|
@@ -5,7 +5,7 @@ import { WithSupportProps } from '@snack-uikit/utils';
|
|
|
5
5
|
|
|
6
6
|
import { ScrollProps, SearchState } from '../../types';
|
|
7
7
|
import { ItemProps } from '../Items';
|
|
8
|
-
import { ListContextType, SelectionState } from './contexts';
|
|
8
|
+
import { ListContextPrivateType, ListContextType, SelectionState } from './contexts';
|
|
9
9
|
|
|
10
10
|
type CollapseState = {
|
|
11
11
|
value?: (string | number)[];
|
|
@@ -56,12 +56,13 @@ export type DroplistProps = {
|
|
|
56
56
|
} & Pick<DropdownProps, 'trigger' | 'placement' | 'widthStrategy' | 'open' | 'onOpenChange'> &
|
|
57
57
|
Omit<ListProps, 'tabIndex' | 'onKeyDown'>;
|
|
58
58
|
|
|
59
|
-
export type ListPrivateProps = ListProps &
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
59
|
+
export type ListPrivateProps = ListProps &
|
|
60
|
+
ListContextPrivateType & {
|
|
61
|
+
nested?: boolean;
|
|
62
|
+
active?: boolean;
|
|
63
|
+
tabIndex?: number;
|
|
64
|
+
onFocus?(e: FocusEvent<HTMLElement>): void;
|
|
65
|
+
onBlur?(e: FocusEvent<HTMLElement>): void;
|
|
66
|
+
onKeyDown?(e: KeyboardEvent<HTMLElement>): void;
|
|
67
|
+
limitedScrollHeight?: boolean;
|
|
68
|
+
};
|