@snack-uikit/list 0.9.1 → 0.9.2-preview-cc3d0341.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/dist/components/Items/NextListItem/NextListItem.d.ts +1 -1
- package/dist/components/Items/NextListItem/NextListItem.js +3 -2
- package/dist/components/Items/types.d.ts +1 -0
- package/package.json +2 -2
- package/src/components/Items/NextListItem/NextListItem.tsx +3 -1
- package/src/components/Items/types.ts +1 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { NextListItemProps } from '../types';
|
|
2
|
-
export declare function NextListItem({ items: itemsProp, placement, id, search, scroll, scrollRef, disabled, ...option }: NextListItemProps): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare function NextListItem({ items: itemsProp, placement, id, search, scroll, scrollRef, disabled, onSublistOpenChanged, ...option }: NextListItemProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -28,7 +28,7 @@ const FALLBACK_PLACEMENTS = [
|
|
|
28
28
|
'left-end',
|
|
29
29
|
];
|
|
30
30
|
export function NextListItem(_a) {
|
|
31
|
-
var { items: itemsProp, placement = 'right-start', id, search, scroll, scrollRef, disabled } = _a, option = __rest(_a, ["items", "placement", "id", "search", "scroll", "scrollRef", "disabled"]);
|
|
31
|
+
var { items: itemsProp, placement = 'right-start', id, search, scroll, scrollRef, disabled, onSublistOpenChanged } = _a, option = __rest(_a, ["items", "placement", "id", "search", "scroll", "scrollRef", "disabled", "onSublistOpenChanged"]);
|
|
32
32
|
const listRef = useRef(null);
|
|
33
33
|
const [openCollapsedItems, setOpenCollapsedItems] = useState([]);
|
|
34
34
|
const { items, itemRefs, ids, expandedIds } = useMemo(() => withCollapsedItems({
|
|
@@ -44,8 +44,9 @@ export function NextListItem(_a) {
|
|
|
44
44
|
resetNestedIndex();
|
|
45
45
|
setOpenCollapsedItems([]);
|
|
46
46
|
}
|
|
47
|
+
onSublistOpenChanged === null || onSublistOpenChanged === void 0 ? void 0 : onSublistOpenChanged(open, id);
|
|
47
48
|
setOpen(open);
|
|
48
|
-
}, [resetActiveFocusIndex, resetNestedIndex, setOpen]);
|
|
49
|
+
}, [id, onSublistOpenChanged, resetActiveFocusIndex, resetNestedIndex, setOpen]);
|
|
49
50
|
const handleOutsideClick = useCallback(() => {
|
|
50
51
|
parentResetNestedIndex === null || parentResetNestedIndex === void 0 ? void 0 : parentResetNestedIndex();
|
|
51
52
|
parentResetActiveFocusIndex === null || parentResetActiveFocusIndex === void 0 ? void 0 : parentResetActiveFocusIndex();
|
|
@@ -70,6 +70,7 @@ export type NextListItemProps = BaseItemsWithoutNonGroupProps & {
|
|
|
70
70
|
type: 'next-list';
|
|
71
71
|
placement?: 'right-start' | 'left-start' | 'left' | 'right' | 'left-end' | 'right-end';
|
|
72
72
|
search?: SearchState;
|
|
73
|
+
onSublistOpenChanged?(open: boolean, id?: string | number): void;
|
|
73
74
|
} & ScrollProps;
|
|
74
75
|
export type GroupItemProps = Omit<SeparatorProps, 'size'> & {
|
|
75
76
|
items: ItemProps[];
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "List",
|
|
7
|
-
"version": "0.9.
|
|
7
|
+
"version": "0.9.2-preview-cc3d0341.0",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"@snack-uikit/locale": "*"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "607d11f81bc54f36f16e2c45f3df031eb904d5cd"
|
|
58
58
|
}
|
|
@@ -28,6 +28,7 @@ export function NextListItem({
|
|
|
28
28
|
scroll,
|
|
29
29
|
scrollRef,
|
|
30
30
|
disabled,
|
|
31
|
+
onSublistOpenChanged,
|
|
31
32
|
...option
|
|
32
33
|
}: NextListItemProps) {
|
|
33
34
|
const listRef = useRef<HTMLUListElement>(null);
|
|
@@ -65,9 +66,10 @@ export function NextListItem({
|
|
|
65
66
|
resetNestedIndex();
|
|
66
67
|
setOpenCollapsedItems([]);
|
|
67
68
|
}
|
|
69
|
+
onSublistOpenChanged?.(open, id);
|
|
68
70
|
setOpen(open);
|
|
69
71
|
},
|
|
70
|
-
[resetActiveFocusIndex, resetNestedIndex, setOpen],
|
|
72
|
+
[id, onSublistOpenChanged, resetActiveFocusIndex, resetNestedIndex, setOpen],
|
|
71
73
|
);
|
|
72
74
|
|
|
73
75
|
const handleOutsideClick = useCallback(() => {
|
|
@@ -87,6 +87,7 @@ export type NextListItemProps = BaseItemsWithoutNonGroupProps & {
|
|
|
87
87
|
type: 'next-list';
|
|
88
88
|
placement?: 'right-start' | 'left-start' | 'left' | 'right' | 'left-end' | 'right-end';
|
|
89
89
|
search?: SearchState;
|
|
90
|
+
onSublistOpenChanged?(open: boolean, id?: string | number): void;
|
|
90
91
|
} & ScrollProps;
|
|
91
92
|
|
|
92
93
|
export type GroupItemProps = Omit<SeparatorProps, 'size'> & {
|