react-magma-dom 4.6.0 → 4.7.0-next.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/dist/components/TreeView/TreeItemContext.d.ts +0 -2
- package/dist/components/TreeView/TreeView.stories.d.ts +2 -0
- package/dist/components/TreeView/TreeViewContext.d.ts +10 -7
- package/dist/components/TreeView/index.d.ts +1 -0
- package/dist/components/TreeView/types.d.ts +5 -0
- package/dist/components/TreeView/useTreeItem.d.ts +0 -10
- package/dist/components/TreeView/useTreeView.d.ts +18 -13
- package/dist/components/TreeView/utils.d.ts +22 -16
- package/dist/esm/index.js +979 -1337
- package/dist/esm/index.js.map +1 -1
- package/dist/i18n/interface.d.ts +0 -4
- package/dist/properties.json +80 -67
- package/dist/react-magma-dom.cjs.development.js +977 -1347
- package/dist/react-magma-dom.cjs.development.js.map +1 -1
- package/dist/react-magma-dom.cjs.production.min.js +1 -1
- package/dist/react-magma-dom.cjs.production.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -6,9 +6,7 @@ interface TreeItemContextInterface {
|
|
|
6
6
|
setExpanded: React.Dispatch<React.SetStateAction<boolean>>;
|
|
7
7
|
checkedStatus: IndeterminateCheckboxStatus;
|
|
8
8
|
checkboxChangeHandler: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
9
|
-
numberOfTreeItemChildren: number;
|
|
10
9
|
hasOwnTreeItems: boolean;
|
|
11
|
-
updateCheckedStatusFromChild: (index: number, status: IndeterminateCheckboxStatus) => void;
|
|
12
10
|
parentDepth: number;
|
|
13
11
|
}
|
|
14
12
|
export declare const TreeItemContext: React.Context<TreeItemContextInterface>;
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { TreeViewSelectable } from './
|
|
2
|
+
import { TreeViewSelectable } from './types';
|
|
3
3
|
import { IndeterminateCheckboxStatus } from '../IndeterminateCheckbox';
|
|
4
4
|
export interface TreeItemSelectedInterface {
|
|
5
5
|
itemId?: string;
|
|
6
6
|
checkedStatus: IndeterminateCheckboxStatus;
|
|
7
7
|
}
|
|
8
|
+
export interface TreeViewItemInterface {
|
|
9
|
+
itemId?: string;
|
|
10
|
+
parentId?: string | null;
|
|
11
|
+
icon?: React.ReactNode;
|
|
12
|
+
checkedStatus: IndeterminateCheckboxStatus;
|
|
13
|
+
hasOwnTreeItems: boolean;
|
|
14
|
+
}
|
|
8
15
|
export interface TreeViewContextInterface {
|
|
9
16
|
children?: React.ReactNode[];
|
|
10
17
|
hasIcons: boolean;
|
|
@@ -12,19 +19,15 @@ export interface TreeViewContextInterface {
|
|
|
12
19
|
initialExpandedItemsNeedUpdate: boolean;
|
|
13
20
|
onExpandedChange?: (event: React.SyntheticEvent) => void;
|
|
14
21
|
onSelectedItemChange?: (selectedItems: Array<TreeItemSelectedInterface>) => void;
|
|
15
|
-
preselectedItemsNeedUpdate: boolean;
|
|
16
22
|
registerTreeItem: (itemRefArray: React.MutableRefObject<React.MutableRefObject<Element>[]>, itemRef: React.MutableRefObject<Element>) => void;
|
|
17
23
|
selectable: TreeViewSelectable;
|
|
18
24
|
selectedItems: Array<TreeItemSelectedInterface>;
|
|
19
|
-
selectedItemsChanged: boolean;
|
|
20
|
-
setHasIcons: React.Dispatch<React.SetStateAction<boolean>>;
|
|
21
25
|
setInitialExpandedItemsNeedUpdate: React.Dispatch<React.SetStateAction<any>>;
|
|
22
|
-
setPreselectedItemsNeedUpdate: React.Dispatch<React.SetStateAction<any>>;
|
|
23
|
-
setSelectedItems: React.Dispatch<React.SetStateAction<any>>;
|
|
24
|
-
setSelectedItemsChanged: React.Dispatch<React.SetStateAction<any>>;
|
|
25
26
|
treeItemRefArray?: React.MutableRefObject<React.MutableRefObject<Element>[]>;
|
|
26
27
|
itemToFocus?: string;
|
|
27
28
|
checkParents: boolean;
|
|
28
29
|
checkChildren: boolean;
|
|
30
|
+
items: TreeViewItemInterface[];
|
|
31
|
+
selectItem: (data: Pick<TreeViewItemInterface, 'itemId' | 'checkedStatus'>) => void;
|
|
29
32
|
}
|
|
30
33
|
export declare const TreeViewContext: React.Context<TreeViewContextInterface>;
|
|
@@ -28,14 +28,8 @@ export interface UseTreeItemProps extends React.HTMLAttributes<HTMLLIElement> {
|
|
|
28
28
|
*/
|
|
29
29
|
icon?: React.ReactElement<IconProps>;
|
|
30
30
|
/**
|
|
31
|
-
* Indeterminate Checkbox status
|
|
32
31
|
* @internal
|
|
33
32
|
*/
|
|
34
|
-
parentCheckedStatus?: IndeterminateCheckboxStatus;
|
|
35
|
-
/**
|
|
36
|
-
* @internal
|
|
37
|
-
*/
|
|
38
|
-
updateParentCheckStatus?: (index: number, status: IndeterminateCheckboxStatus, isInitialRender?: boolean) => void;
|
|
39
33
|
/**
|
|
40
34
|
* @internal
|
|
41
35
|
*/
|
|
@@ -69,16 +63,12 @@ export declare function useTreeItem(props: UseTreeItemProps, forwardedRef: any):
|
|
|
69
63
|
hasOwnTreeItems: boolean;
|
|
70
64
|
itemDepth: number;
|
|
71
65
|
itemId: string;
|
|
72
|
-
numberOfTreeItemChildren: number;
|
|
73
|
-
parentCheckedStatus: IndeterminateCheckboxStatus;
|
|
74
66
|
parentDepth: number;
|
|
75
67
|
ref: (node: any) => void;
|
|
76
68
|
selectedItems: import("./TreeViewContext").TreeItemSelectedInterface[];
|
|
77
69
|
setExpanded: React.Dispatch<React.SetStateAction<boolean>>;
|
|
78
|
-
updateCheckedStatusFromChild: (index: number, status: IndeterminateCheckboxStatus, isInitialRender?: boolean) => void;
|
|
79
70
|
treeItemChildren: (string | number | {} | React.ReactElement<any, string | ((props: any) => React.ReactElement<any, any>) | (new (props: any) => React.Component<any, any, any>)> | React.ReactNodeArray | React.ReactPortal)[];
|
|
80
71
|
};
|
|
81
72
|
handleClick: (event: any, itemId: any) => void;
|
|
82
73
|
handleKeyDown: (event: React.KeyboardEvent) => void;
|
|
83
74
|
};
|
|
84
|
-
export declare type UseTreeItemReturn = ReturnType<typeof useTreeItem>;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { TreeItemSelectedInterface } from './TreeViewContext';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import { TreeItemSelectedInterface, TreeViewItemInterface } from './TreeViewContext';
|
|
3
|
+
import { TreeViewSelectable } from './types';
|
|
4
|
+
export interface TreeViewApi {
|
|
5
|
+
selectItem({ itemId, checkedStatus }: Pick<TreeViewItemInterface, 'itemId' | 'checkedStatus'>): void;
|
|
6
|
+
selectAll(): void;
|
|
7
|
+
clearAll(): void;
|
|
7
8
|
}
|
|
8
9
|
export interface UseTreeViewProps {
|
|
9
10
|
/**
|
|
@@ -63,28 +64,32 @@ export interface UseTreeViewProps {
|
|
|
63
64
|
*/
|
|
64
65
|
checkChildren?: boolean;
|
|
65
66
|
children?: React.ReactNode[];
|
|
67
|
+
/**
|
|
68
|
+
* The ref object that allows TreeView manipulation.
|
|
69
|
+
* Actions available:
|
|
70
|
+
* selectItem({ itemId, checkedStatus }: Pick<TreeViewItemInterface, 'itemId' | 'checkedStatus'>): void - action that allows to change item selection,
|
|
71
|
+
* selectAll(): void - action that allows to select all items,
|
|
72
|
+
* clearAll(): void - action that allows to unselect all items.
|
|
73
|
+
*/
|
|
74
|
+
apiRef?: React.MutableRefObject<TreeViewApi>;
|
|
66
75
|
}
|
|
67
76
|
export declare function useTreeView(props: UseTreeViewProps): {
|
|
68
77
|
contextValue: {
|
|
69
|
-
hasIcons:
|
|
78
|
+
hasIcons: any;
|
|
70
79
|
itemToFocus: any;
|
|
71
80
|
onSelectedItemChange: (selectedItems: TreeItemSelectedInterface[]) => void;
|
|
72
81
|
onExpandedChange: (event: React.SyntheticEvent<Element, Event>) => void;
|
|
73
82
|
selectable: TreeViewSelectable;
|
|
74
|
-
|
|
75
|
-
selectedItems: TreeItemSelectedInterface[];
|
|
76
|
-
setSelectedItems: React.Dispatch<React.SetStateAction<TreeItemSelectedInterface[]>>;
|
|
83
|
+
selectedItems: any;
|
|
77
84
|
initialExpandedItems: string[];
|
|
78
85
|
treeItemRefArray: React.MutableRefObject<React.MutableRefObject<Element>[]>;
|
|
79
86
|
registerTreeItem: (refArray: React.MutableRefObject<React.MutableRefObject<Element>[]>, ref: React.MutableRefObject<Element>) => void;
|
|
80
|
-
preselectedItemsNeedUpdate: boolean;
|
|
81
|
-
setPreselectedItemsNeedUpdate: React.Dispatch<React.SetStateAction<boolean>>;
|
|
82
87
|
initialExpandedItemsNeedUpdate: boolean;
|
|
83
88
|
setInitialExpandedItemsNeedUpdate: React.Dispatch<React.SetStateAction<boolean>>;
|
|
84
|
-
selectedItemsChanged: boolean;
|
|
85
|
-
setSelectedItemsChanged: React.Dispatch<React.SetStateAction<boolean>>;
|
|
86
89
|
checkChildren: boolean;
|
|
87
90
|
checkParents: boolean;
|
|
91
|
+
items: any;
|
|
92
|
+
selectItem: ({ itemId, checkedStatus }: Pick<TreeViewItemInterface, 'itemId' | 'checkedStatus'>) => void;
|
|
88
93
|
};
|
|
89
94
|
};
|
|
90
95
|
export declare type UseTreeViewReturn = ReturnType<typeof useTreeView>;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { ThemeInterface } from '../../theme/magma';
|
|
2
|
-
import {
|
|
2
|
+
import { UseTreeViewProps } from './useTreeView';
|
|
3
|
+
import { TreeViewSelectable } from './types';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { IndeterminateCheckboxStatus } from '../IndeterminateCheckbox';
|
|
6
|
+
import { TreeViewItemInterface } from './TreeViewContext';
|
|
3
7
|
export declare enum TreeNodeType {
|
|
4
8
|
branch = "branch",
|
|
5
9
|
leaf = "leaf"
|
|
@@ -19,26 +23,28 @@ export declare enum TreeNodeType {
|
|
|
19
23
|
export declare function calculateOffset(type: TreeNodeType, depth?: number, labelElem?: boolean, negative?: boolean): string;
|
|
20
24
|
export declare function getTreeItemLabelColor(isInverse: boolean, disabled: boolean, theme: ThemeInterface): string;
|
|
21
25
|
export declare function getTreeItemWrapperCursor(disabled: boolean, selectable: TreeViewSelectable, nodeType: TreeNodeType): "not-allowed" | "pointer" | "default";
|
|
22
|
-
export declare function arrayIncludesId(itemsArray: any, itemId: any): any;
|
|
23
26
|
export declare function getChildrenItemIds(children: any, status?: string): any[];
|
|
24
27
|
export declare function getChildrenItemIdsFlat(children: any): any[];
|
|
25
28
|
export declare function getChildrenItemIdsInTree(children: any): any[];
|
|
26
|
-
export declare function getAllParentIds(childrenArr: any, itemId: any, parentItemIds?: any[]): any;
|
|
27
|
-
export declare function findChildByItemId(children: any, itemId: any): any;
|
|
28
|
-
export declare function getAllChildrenEnabled(children: any): boolean;
|
|
29
|
-
export declare function filterSelectedItems(selectedItems: any, childrenIds: any, itemId: any): any;
|
|
30
|
-
export declare function getMissingChildrenIds(selectedItems: any, childrenIds: any): any;
|
|
31
|
-
export declare function getChildrenCheckedStatus(childrenIds: any, status: any): any;
|
|
32
|
-
export declare function getEnabledTreeItemChildrenLength(treeItemChildren: any): any;
|
|
33
|
-
export declare function getUpdatedSelectedItems(selectedItems: any, itemId: any, checkedStatus: any): any;
|
|
34
|
-
export declare function getUniqueSelectedItemsArray(itemArr0: any, itemArr1: any, itemArr2: any): any[];
|
|
35
|
-
export declare function findCommonItems(initialItemsArr: any, childrenItemsArr: any): any[];
|
|
36
|
-
export declare function areArraysEqual(array1: any, array2: any): boolean;
|
|
37
|
-
export declare function getCheckedStatus(itemId: any, selectedItems: any): any;
|
|
38
|
-
export declare function findFirstBranchNode(children: any): any;
|
|
39
|
-
export declare function getFirstItemInTree(arr: any, children: any): any;
|
|
40
29
|
export declare function filterNullEntries(obj: any): {
|
|
41
30
|
current: any;
|
|
42
31
|
} | {
|
|
43
32
|
current?: undefined;
|
|
44
33
|
};
|
|
34
|
+
export declare const getInitialItems: ({ children, preselectedItems: rawPreselectedItems, checkParents, selectable }: Pick<UseTreeViewProps, 'children' | 'preselectedItems' | 'checkParents' | 'selectable'>) => any;
|
|
35
|
+
export declare const selectSingle: ({ items, itemId, checkedStatus }: {
|
|
36
|
+
items: TreeViewItemInterface[];
|
|
37
|
+
itemId: TreeViewItemInterface['itemId'];
|
|
38
|
+
checkedStatus: TreeViewItemInterface['checkedStatus'];
|
|
39
|
+
}) => {
|
|
40
|
+
checkedStatus: IndeterminateCheckboxStatus;
|
|
41
|
+
itemId?: string;
|
|
42
|
+
parentId?: string;
|
|
43
|
+
icon?: React.ReactNode;
|
|
44
|
+
hasOwnTreeItems: boolean;
|
|
45
|
+
}[];
|
|
46
|
+
export declare const selectMulti: ({ items, itemId, checkedStatus, checkChildren, checkParents }: {
|
|
47
|
+
items: TreeViewItemInterface[];
|
|
48
|
+
itemId: TreeViewItemInterface['itemId'];
|
|
49
|
+
checkedStatus: TreeViewItemInterface['checkedStatus'];
|
|
50
|
+
} & Pick<UseTreeViewProps, "checkParents" | "checkChildren">) => any;
|