@mui/x-tree-view 8.0.0-beta.1 → 8.0.0-beta.3
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 +235 -0
- package/RichTreeView/RichTreeView.js +17 -5
- package/RichTreeView/richTreeViewClasses.d.ts +2 -4
- package/RichTreeView/richTreeViewClasses.js +1 -1
- package/SimpleTreeView/SimpleTreeView.js +17 -5
- package/SimpleTreeView/simpleTreeViewClasses.d.ts +2 -4
- package/SimpleTreeView/simpleTreeViewClasses.js +1 -1
- package/TreeItem/TreeItem.d.ts +1 -1
- package/TreeItem/TreeItem.js +45 -49
- package/TreeItem/index.d.ts +2 -1
- package/TreeItem/index.js +13 -21
- package/TreeItem/treeItemClasses.d.ts +40 -18
- package/TreeItem/treeItemClasses.js +3 -1
- package/TreeItemLabelInput/TreeItemLabelInput.js +2 -2
- package/esm/RichTreeView/RichTreeView.js +17 -5
- package/esm/RichTreeView/richTreeViewClasses.d.ts +2 -4
- package/esm/RichTreeView/richTreeViewClasses.js +1 -1
- package/esm/SimpleTreeView/SimpleTreeView.js +17 -5
- package/esm/SimpleTreeView/simpleTreeViewClasses.d.ts +2 -4
- package/esm/SimpleTreeView/simpleTreeViewClasses.js +1 -1
- package/esm/TreeItem/TreeItem.d.ts +1 -1
- package/esm/TreeItem/TreeItem.js +45 -49
- package/esm/TreeItem/index.d.ts +2 -1
- package/esm/TreeItem/index.js +1 -1
- package/esm/TreeItem/treeItemClasses.d.ts +40 -18
- package/esm/TreeItem/treeItemClasses.js +3 -1
- package/esm/TreeItemLabelInput/TreeItemLabelInput.js +2 -2
- package/esm/index.js +1 -1
- package/esm/internals/TreeViewProvider/TreeViewChildrenItemProvider.js +1 -1
- package/esm/internals/TreeViewProvider/TreeViewContext.d.ts +3 -1
- package/esm/internals/TreeViewProvider/TreeViewContext.js +8 -1
- package/esm/internals/TreeViewProvider/TreeViewProvider.d.ts +1 -1
- package/esm/internals/TreeViewProvider/TreeViewProvider.js +17 -5
- package/esm/internals/TreeViewProvider/TreeViewProvider.types.d.ts +3 -1
- package/esm/internals/TreeViewProvider/TreeViewStyleContext.d.ts +33 -0
- package/esm/internals/TreeViewProvider/TreeViewStyleContext.js +13 -0
- package/esm/internals/TreeViewProvider/index.d.ts +1 -1
- package/esm/internals/TreeViewProvider/index.js +1 -1
- package/esm/internals/index.d.ts +2 -1
- package/esm/internals/plugins/useTreeViewItemCustomization/index.d.ts +2 -0
- package/esm/internals/plugins/useTreeViewItemCustomization/index.js +1 -0
- package/esm/internals/plugins/useTreeViewItemCustomization/useTreeViewItemCustomization.d.ts +3 -0
- package/esm/internals/plugins/useTreeViewItemCustomization/useTreeViewItemCustomization.js +24 -0
- package/esm/internals/plugins/useTreeViewItemCustomization/useTreeViewItemCustomization.types.d.ts +42 -0
- package/esm/internals/plugins/useTreeViewItemCustomization/useTreeViewItemCustomization.types.js +1 -0
- package/esm/internals/plugins/useTreeViewLazyLoading/useTreeViewLazyLoading.types.d.ts +2 -3
- package/esm/useTreeItem/useTreeItem.js +5 -0
- package/esm/useTreeItem/useTreeItem.types.d.ts +9 -0
- package/index.js +1 -1
- package/internals/TreeViewProvider/TreeViewChildrenItemProvider.js +2 -2
- package/internals/TreeViewProvider/TreeViewContext.d.ts +3 -1
- package/internals/TreeViewProvider/TreeViewContext.js +10 -2
- package/internals/TreeViewProvider/TreeViewProvider.d.ts +1 -1
- package/internals/TreeViewProvider/TreeViewProvider.js +17 -5
- package/internals/TreeViewProvider/TreeViewProvider.types.d.ts +3 -1
- package/internals/TreeViewProvider/TreeViewStyleContext.d.ts +33 -0
- package/internals/TreeViewProvider/TreeViewStyleContext.js +21 -0
- package/internals/TreeViewProvider/index.d.ts +1 -1
- package/internals/TreeViewProvider/index.js +2 -2
- package/internals/index.d.ts +2 -1
- package/internals/plugins/useTreeViewItemCustomization/index.d.ts +2 -0
- package/internals/plugins/useTreeViewItemCustomization/index.js +12 -0
- package/internals/plugins/useTreeViewItemCustomization/useTreeViewItemCustomization.d.ts +3 -0
- package/internals/plugins/useTreeViewItemCustomization/useTreeViewItemCustomization.js +32 -0
- package/internals/plugins/useTreeViewItemCustomization/useTreeViewItemCustomization.types.d.ts +42 -0
- package/internals/plugins/useTreeViewItemCustomization/useTreeViewItemCustomization.types.js +5 -0
- package/internals/plugins/useTreeViewLazyLoading/useTreeViewLazyLoading.types.d.ts +2 -3
- package/modern/RichTreeView/RichTreeView.js +17 -5
- package/modern/RichTreeView/richTreeViewClasses.d.ts +2 -4
- package/modern/RichTreeView/richTreeViewClasses.js +1 -1
- package/modern/SimpleTreeView/SimpleTreeView.js +17 -5
- package/modern/SimpleTreeView/simpleTreeViewClasses.d.ts +2 -4
- package/modern/SimpleTreeView/simpleTreeViewClasses.js +1 -1
- package/modern/TreeItem/TreeItem.d.ts +1 -1
- package/modern/TreeItem/TreeItem.js +45 -49
- package/modern/TreeItem/index.d.ts +2 -1
- package/modern/TreeItem/index.js +1 -1
- package/modern/TreeItem/treeItemClasses.d.ts +40 -18
- package/modern/TreeItem/treeItemClasses.js +3 -1
- package/modern/TreeItemLabelInput/TreeItemLabelInput.js +2 -2
- package/modern/index.js +1 -1
- package/modern/internals/TreeViewProvider/TreeViewChildrenItemProvider.js +1 -1
- package/modern/internals/TreeViewProvider/TreeViewContext.d.ts +3 -1
- package/modern/internals/TreeViewProvider/TreeViewContext.js +8 -1
- package/modern/internals/TreeViewProvider/TreeViewProvider.d.ts +1 -1
- package/modern/internals/TreeViewProvider/TreeViewProvider.js +17 -5
- package/modern/internals/TreeViewProvider/TreeViewProvider.types.d.ts +3 -1
- package/modern/internals/TreeViewProvider/TreeViewStyleContext.d.ts +33 -0
- package/modern/internals/TreeViewProvider/TreeViewStyleContext.js +13 -0
- package/modern/internals/TreeViewProvider/index.d.ts +1 -1
- package/modern/internals/TreeViewProvider/index.js +1 -1
- package/modern/internals/index.d.ts +2 -1
- package/modern/internals/plugins/useTreeViewItemCustomization/index.d.ts +2 -0
- package/modern/internals/plugins/useTreeViewItemCustomization/index.js +1 -0
- package/modern/internals/plugins/useTreeViewItemCustomization/useTreeViewItemCustomization.d.ts +3 -0
- package/modern/internals/plugins/useTreeViewItemCustomization/useTreeViewItemCustomization.js +24 -0
- package/modern/internals/plugins/useTreeViewItemCustomization/useTreeViewItemCustomization.types.d.ts +42 -0
- package/modern/internals/plugins/useTreeViewItemCustomization/useTreeViewItemCustomization.types.js +1 -0
- package/modern/internals/plugins/useTreeViewLazyLoading/useTreeViewLazyLoading.types.d.ts +2 -3
- package/modern/useTreeItem/useTreeItem.js +5 -0
- package/modern/useTreeItem/useTreeItem.types.d.ts +9 -0
- package/package.json +6 -6
- package/tsconfig.build.tsbuildinfo +1 -1
- package/useTreeItem/useTreeItem.js +5 -0
- package/useTreeItem/useTreeItem.types.d.ts +9 -0
- package/esm/internals/TreeViewProvider/useTreeViewContext.d.ts +0 -3
- package/esm/internals/TreeViewProvider/useTreeViewContext.js +0 -9
- package/internals/TreeViewProvider/useTreeViewContext.d.ts +0 -3
- package/internals/TreeViewProvider/useTreeViewContext.js +0 -17
- package/modern/internals/TreeViewProvider/useTreeViewContext.d.ts +0 -3
- package/modern/internals/TreeViewProvider/useTreeViewContext.js +0 -9
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export interface TreeViewClasses {
|
|
3
|
+
/** Styles applied to the root element. */
|
|
4
|
+
root: string;
|
|
5
|
+
/** Styles applied to the item's root element. */
|
|
6
|
+
item: string;
|
|
7
|
+
/** Styles applied to the item's content element. */
|
|
8
|
+
itemContent: string;
|
|
9
|
+
/** Styles applied to the item's transition element. */
|
|
10
|
+
itemGroupTransition: string;
|
|
11
|
+
/** Styles applied to the item's icon container element icon. */
|
|
12
|
+
itemIconContainer: string;
|
|
13
|
+
/** Styles applied to the item's label element. */
|
|
14
|
+
itemLabel: string;
|
|
15
|
+
/** Styles applied to the item's label input element (visible only when editing is enabled). */
|
|
16
|
+
itemLabelInput: string;
|
|
17
|
+
/** Styles applied to the item's checkbox element. */
|
|
18
|
+
itemCheckbox: string;
|
|
19
|
+
/** Styles applied to the item's drag and drop overlay element. */
|
|
20
|
+
itemDragAndDropOverlay: string;
|
|
21
|
+
/** Styles applied to the item's error icon element */
|
|
22
|
+
itemErrorIcon: string;
|
|
23
|
+
/** Styles applied to the item's loading icon element */
|
|
24
|
+
itemLoadingIcon: string;
|
|
25
|
+
}
|
|
26
|
+
export interface TreeViewStyleContextValue {
|
|
27
|
+
classes: Partial<TreeViewClasses>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* @ignore - internal component.
|
|
31
|
+
*/
|
|
32
|
+
export declare const TreeViewStyleContext: React.Context<TreeViewStyleContextValue>;
|
|
33
|
+
export declare const useTreeViewStyleContext: () => TreeViewStyleContextValue;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* @ignore - internal component.
|
|
4
|
+
*/
|
|
5
|
+
export const TreeViewStyleContext = /*#__PURE__*/React.createContext({
|
|
6
|
+
classes: {}
|
|
7
|
+
});
|
|
8
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
9
|
+
TreeViewStyleContext.displayName = 'TreeViewStyleContext';
|
|
10
|
+
}
|
|
11
|
+
export const useTreeViewStyleContext = () => {
|
|
12
|
+
return React.useContext(TreeViewStyleContext);
|
|
13
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { TreeViewProvider } from "./TreeViewProvider.js";
|
|
2
|
-
export { useTreeViewContext } from "./
|
|
2
|
+
export { useTreeViewContext } from "./TreeViewContext.js";
|
|
3
3
|
export type { TreeViewProviderProps, TreeViewContextValue, TreeViewItemPluginsRunner } from './TreeViewProvider.types';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { TreeViewProvider } from "./TreeViewProvider.js";
|
|
2
|
-
export { useTreeViewContext } from "./
|
|
2
|
+
export { useTreeViewContext } from "./TreeViewContext.js";
|
package/esm/internals/index.d.ts
CHANGED
|
@@ -30,4 +30,5 @@ export { useTreeViewJSXItems } from "./plugins/useTreeViewJSXItems/index.js";
|
|
|
30
30
|
export type { UseTreeViewJSXItemsSignature, UseTreeViewJSXItemsParameters } from './plugins/useTreeViewJSXItems';
|
|
31
31
|
export { createSelector } from "./utils/selectors.js";
|
|
32
32
|
export { isTargetInDescendants } from "./utils/tree.js";
|
|
33
|
-
export { TreeViewStore } from "./utils/TreeViewStore.js";
|
|
33
|
+
export { TreeViewStore } from "./utils/TreeViewStore.js";
|
|
34
|
+
export type { TreeViewClasses } from './TreeViewProvider/TreeViewStyleContext';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useTreeViewItemCustomization } from "./useTreeViewItemCustomization.js";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export const useTreeViewItemCustomization = ({
|
|
3
|
+
slots,
|
|
4
|
+
slotProps
|
|
5
|
+
}) => {
|
|
6
|
+
const pluginContextValue = React.useMemo(() => ({
|
|
7
|
+
icons: {
|
|
8
|
+
slots: {
|
|
9
|
+
collapseIcon: slots.collapseIcon,
|
|
10
|
+
expandIcon: slots.expandIcon,
|
|
11
|
+
endIcon: slots.endIcon
|
|
12
|
+
},
|
|
13
|
+
slotProps: {
|
|
14
|
+
collapseIcon: slotProps.collapseIcon,
|
|
15
|
+
expandIcon: slotProps.expandIcon,
|
|
16
|
+
endIcon: slotProps.endIcon
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}), [slots.collapseIcon, slots.expandIcon, slots.endIcon, slotProps.collapseIcon, slotProps.expandIcon, slotProps.endIcon]);
|
|
20
|
+
return {
|
|
21
|
+
contextValue: pluginContextValue
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
useTreeViewItemCustomization.params = {};
|
package/esm/internals/plugins/useTreeViewItemCustomization/useTreeViewItemCustomization.types.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { SlotComponentProps } from '@mui/utils/types';
|
|
3
|
+
import { TreeViewPluginSignature } from "../../models/index.js";
|
|
4
|
+
import { UseTreeViewItemsSignature } from "../useTreeViewItems/index.js";
|
|
5
|
+
import { UseTreeViewSelectionSignature } from "../useTreeViewSelection/index.js";
|
|
6
|
+
export interface UseTreeViewItemCustomizationParameters {}
|
|
7
|
+
export type UseTreeViewItemCustomizationDefaultizedParameters = UseTreeViewItemCustomizationParameters;
|
|
8
|
+
interface UseTreeViewItemCustomizationSlots {
|
|
9
|
+
/**
|
|
10
|
+
* The default icon used to collapse the item.
|
|
11
|
+
*/
|
|
12
|
+
collapseIcon?: React.ElementType;
|
|
13
|
+
/**
|
|
14
|
+
* The default icon used to expand the item.
|
|
15
|
+
*/
|
|
16
|
+
expandIcon?: React.ElementType;
|
|
17
|
+
/**
|
|
18
|
+
* The default icon displayed next to an end item.
|
|
19
|
+
* This is applied to all Tree Items and can be overridden by the TreeItem `icon` slot prop.
|
|
20
|
+
*/
|
|
21
|
+
endIcon?: React.ElementType;
|
|
22
|
+
}
|
|
23
|
+
interface UseTreeViewItemCustomizationSlotProps {
|
|
24
|
+
collapseIcon?: SlotComponentProps<'svg', {}, {}>;
|
|
25
|
+
expandIcon?: SlotComponentProps<'svg', {}, {}>;
|
|
26
|
+
endIcon?: SlotComponentProps<'svg', {}, {}>;
|
|
27
|
+
}
|
|
28
|
+
interface UseTreeViewItemCustomizationContextValue {
|
|
29
|
+
icons: {
|
|
30
|
+
slots: UseTreeViewItemCustomizationSlots;
|
|
31
|
+
slotProps: UseTreeViewItemCustomizationSlotProps;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export type UseTreeViewItemCustomizationSignature = TreeViewPluginSignature<{
|
|
35
|
+
params: UseTreeViewItemCustomizationParameters;
|
|
36
|
+
defaultizedParams: UseTreeViewItemCustomizationDefaultizedParameters;
|
|
37
|
+
contextValue: UseTreeViewItemCustomizationContextValue;
|
|
38
|
+
slots: UseTreeViewItemCustomizationSlots;
|
|
39
|
+
slotProps: UseTreeViewItemCustomizationSlotProps;
|
|
40
|
+
dependencies: [UseTreeViewItemsSignature, UseTreeViewSelectionSignature];
|
|
41
|
+
}>;
|
|
42
|
+
export {};
|
package/esm/internals/plugins/useTreeViewItemCustomization/useTreeViewItemCustomization.types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -13,9 +13,8 @@ type DataSource<R extends {}> = {
|
|
|
13
13
|
* @template R
|
|
14
14
|
* @param {R} item The item to check.
|
|
15
15
|
* @returns {number} The number of children.
|
|
16
|
-
* @default (item) => number
|
|
17
16
|
*/
|
|
18
|
-
getChildrenCount
|
|
17
|
+
getChildrenCount: (item: R) => number;
|
|
19
18
|
/**
|
|
20
19
|
* Method used for fetching the items.
|
|
21
20
|
* Only relevant for lazy-loaded tree views.
|
|
@@ -24,7 +23,7 @@ type DataSource<R extends {}> = {
|
|
|
24
23
|
* @param {TreeViewItemId} parentId The id of the item the children belong to.
|
|
25
24
|
* @returns { Promise<R[]>} The children of the item.
|
|
26
25
|
*/
|
|
27
|
-
getTreeItems
|
|
26
|
+
getTreeItems: (parentId?: TreeViewItemId) => Promise<R[]>;
|
|
28
27
|
};
|
|
29
28
|
export interface UseTreeViewLazyLoadingPublicAPI {}
|
|
30
29
|
export interface UseTreeViewLazyLoadingInstance extends UseTreeViewLazyLoadingPublicAPI {
|
|
@@ -189,6 +189,11 @@ export const useTreeItem = parameters => {
|
|
|
189
189
|
onMouseDown: createContentHandleMouseDown(externalEventHandlers),
|
|
190
190
|
status
|
|
191
191
|
});
|
|
192
|
+
['expanded', 'selected', 'focused', 'disabled', 'editing', 'editable'].forEach(key => {
|
|
193
|
+
if (status[key]) {
|
|
194
|
+
props[`data-${key}`] = '';
|
|
195
|
+
}
|
|
196
|
+
});
|
|
192
197
|
const enhancedContentProps = propsEnhancers.content?.(_extends({}, sharedPropsEnhancerParams, {
|
|
193
198
|
externalEventHandlers
|
|
194
199
|
})) ?? {};
|
|
@@ -55,7 +55,16 @@ export interface UseTreeItemContentSlotPropsFromUseTreeItem {
|
|
|
55
55
|
onClick: TreeViewCancellableEventHandler<React.MouseEvent>;
|
|
56
56
|
onMouseDown: TreeViewCancellableEventHandler<React.MouseEvent>;
|
|
57
57
|
ref: React.RefCallback<HTMLDivElement> | null;
|
|
58
|
+
/**
|
|
59
|
+
* @deprecated Will be removed in the next major version. Please use the data-attrs instead.
|
|
60
|
+
*/
|
|
58
61
|
status: UseTreeItemStatus;
|
|
62
|
+
'data-expanded'?: '';
|
|
63
|
+
'data-selected'?: '';
|
|
64
|
+
'data-focused'?: '';
|
|
65
|
+
'data-disabled'?: '';
|
|
66
|
+
'data-editing'?: '';
|
|
67
|
+
'data-editable'?: '';
|
|
59
68
|
}
|
|
60
69
|
export interface UseTreeItemContentSlotOwnProps extends UseTreeItemContentSlotPropsFromUseTreeItem {}
|
|
61
70
|
export type UseTreeItemContentSlotProps<ExternalProps = {}> = ExternalProps & UseTreeItemContentSlotOwnProps;
|
package/index.js
CHANGED
|
@@ -9,7 +9,7 @@ exports.TreeViewChildrenItemContext = void 0;
|
|
|
9
9
|
exports.TreeViewChildrenItemProvider = TreeViewChildrenItemProvider;
|
|
10
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
|
-
var
|
|
12
|
+
var _TreeViewContext = require("./TreeViewContext");
|
|
13
13
|
var _utils = require("../utils/utils");
|
|
14
14
|
var _useTreeViewItems = require("../plugins/useTreeViewItems/useTreeViewItems.selectors");
|
|
15
15
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
@@ -27,7 +27,7 @@ function TreeViewChildrenItemProvider(props) {
|
|
|
27
27
|
instance,
|
|
28
28
|
store,
|
|
29
29
|
rootRef
|
|
30
|
-
} = (0,
|
|
30
|
+
} = (0, _TreeViewContext.useTreeViewContext)();
|
|
31
31
|
const childrenIdAttrToIdRef = React.useRef(new Map());
|
|
32
32
|
React.useEffect(() => {
|
|
33
33
|
if (!rootRef.current) {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { TreeViewAnyPluginSignature } from "../models/index.js";
|
|
2
3
|
import { TreeViewContextValue } from "./TreeViewProvider.types.js";
|
|
3
4
|
/**
|
|
4
5
|
* @ignore - internal component.
|
|
5
6
|
*/
|
|
6
|
-
export declare const TreeViewContext: React.Context<TreeViewContextValue<any> | null>;
|
|
7
|
+
export declare const TreeViewContext: React.Context<TreeViewContextValue<any> | null>;
|
|
8
|
+
export declare const useTreeViewContext: <TSignatures extends readonly TreeViewAnyPluginSignature[], TOptionalSignatures extends readonly TreeViewAnyPluginSignature[] = []>() => TreeViewContextValue<TSignatures, TOptionalSignatures>;
|
|
@@ -4,7 +4,7 @@ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWild
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.TreeViewContext = void 0;
|
|
7
|
+
exports.useTreeViewContext = exports.TreeViewContext = void 0;
|
|
8
8
|
var React = _interopRequireWildcard(require("react"));
|
|
9
9
|
/**
|
|
10
10
|
* @ignore - internal component.
|
|
@@ -12,4 +12,12 @@ var React = _interopRequireWildcard(require("react"));
|
|
|
12
12
|
const TreeViewContext = exports.TreeViewContext = /*#__PURE__*/React.createContext(null);
|
|
13
13
|
if (process.env.NODE_ENV !== 'production') {
|
|
14
14
|
TreeViewContext.displayName = 'TreeViewContext';
|
|
15
|
-
}
|
|
15
|
+
}
|
|
16
|
+
const useTreeViewContext = () => {
|
|
17
|
+
const context = React.useContext(TreeViewContext);
|
|
18
|
+
if (context == null) {
|
|
19
|
+
throw new Error(['MUI X: Could not find the Tree View context.', 'It looks like you rendered your component outside of a SimpleTreeView or RichTreeView parent component.', 'This can also happen if you are bundling multiple versions of the Tree View.'].join('\n'));
|
|
20
|
+
}
|
|
21
|
+
return context;
|
|
22
|
+
};
|
|
23
|
+
exports.useTreeViewContext = useTreeViewContext;
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { TreeViewProviderProps } from "./TreeViewProvider.types.js";
|
|
3
3
|
import { TreeViewAnyPluginSignature } from "../models/index.js";
|
|
4
4
|
/**
|
|
5
|
-
* Sets up the contexts for the underlying
|
|
5
|
+
* Sets up the contexts for the underlying Tree Item components.
|
|
6
6
|
*
|
|
7
7
|
* @ignore - do not document.
|
|
8
8
|
*/
|
|
@@ -7,21 +7,33 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.TreeViewProvider = TreeViewProvider;
|
|
8
8
|
var React = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _TreeViewContext = require("./TreeViewContext");
|
|
10
|
+
var _TreeViewStyleContext = require("./TreeViewStyleContext");
|
|
10
11
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
+
const EMPTY_OBJECT = {};
|
|
13
|
+
|
|
11
14
|
/**
|
|
12
|
-
* Sets up the contexts for the underlying
|
|
15
|
+
* Sets up the contexts for the underlying Tree Item components.
|
|
13
16
|
*
|
|
14
17
|
* @ignore - do not document.
|
|
15
18
|
*/
|
|
16
19
|
function TreeViewProvider(props) {
|
|
17
20
|
const {
|
|
18
|
-
|
|
21
|
+
contextValue,
|
|
22
|
+
classes = EMPTY_OBJECT,
|
|
19
23
|
children
|
|
20
24
|
} = props;
|
|
25
|
+
|
|
26
|
+
// TODO: Add the icons to this context and drop useTreeViewIcons
|
|
27
|
+
const styleContextValue = React.useMemo(() => ({
|
|
28
|
+
classes
|
|
29
|
+
}), [classes]);
|
|
21
30
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_TreeViewContext.TreeViewContext.Provider, {
|
|
22
|
-
value:
|
|
23
|
-
children:
|
|
24
|
-
|
|
31
|
+
value: contextValue,
|
|
32
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_TreeViewStyleContext.TreeViewStyleContext.Provider, {
|
|
33
|
+
value: styleContextValue,
|
|
34
|
+
children: contextValue.wrapRoot({
|
|
35
|
+
children
|
|
36
|
+
})
|
|
25
37
|
})
|
|
26
38
|
});
|
|
27
39
|
}
|
|
@@ -3,6 +3,7 @@ import { MergeSignaturesProperty, TreeItemWrapper, TreeRootWrapper, TreeViewAnyP
|
|
|
3
3
|
import { TreeViewStore } from "../utils/TreeViewStore.js";
|
|
4
4
|
import { TreeViewCorePluginSignatures } from "../corePlugins/index.js";
|
|
5
5
|
import type { TreeItemProps } from '../../TreeItem/TreeItem.types';
|
|
6
|
+
import { TreeViewClasses } from "./TreeViewStyleContext.js";
|
|
6
7
|
export type TreeViewItemPluginsRunner = (props: TreeItemProps) => Required<TreeViewItemPluginResponse>;
|
|
7
8
|
export type TreeViewContextValue<TSignatures extends readonly TreeViewAnyPluginSignature[], TOptionalSignatures extends readonly TreeViewAnyPluginSignature[] = []> = MergeSignaturesProperty<[...TreeViewCorePluginSignatures, ...TSignatures], 'contextValue'> & Partial<MergeSignaturesProperty<TOptionalSignatures, 'contextValue'>> & {
|
|
8
9
|
instance: TreeViewInstance<TSignatures, TOptionalSignatures>;
|
|
@@ -14,6 +15,7 @@ export type TreeViewContextValue<TSignatures extends readonly TreeViewAnyPluginS
|
|
|
14
15
|
runItemPlugins: TreeViewItemPluginsRunner;
|
|
15
16
|
};
|
|
16
17
|
export interface TreeViewProviderProps<TSignatures extends readonly TreeViewAnyPluginSignature[]> {
|
|
17
|
-
|
|
18
|
+
contextValue: TreeViewContextValue<TSignatures>;
|
|
18
19
|
children: React.ReactNode;
|
|
20
|
+
classes: Partial<TreeViewClasses> | undefined;
|
|
19
21
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export interface TreeViewClasses {
|
|
3
|
+
/** Styles applied to the root element. */
|
|
4
|
+
root: string;
|
|
5
|
+
/** Styles applied to the item's root element. */
|
|
6
|
+
item: string;
|
|
7
|
+
/** Styles applied to the item's content element. */
|
|
8
|
+
itemContent: string;
|
|
9
|
+
/** Styles applied to the item's transition element. */
|
|
10
|
+
itemGroupTransition: string;
|
|
11
|
+
/** Styles applied to the item's icon container element icon. */
|
|
12
|
+
itemIconContainer: string;
|
|
13
|
+
/** Styles applied to the item's label element. */
|
|
14
|
+
itemLabel: string;
|
|
15
|
+
/** Styles applied to the item's label input element (visible only when editing is enabled). */
|
|
16
|
+
itemLabelInput: string;
|
|
17
|
+
/** Styles applied to the item's checkbox element. */
|
|
18
|
+
itemCheckbox: string;
|
|
19
|
+
/** Styles applied to the item's drag and drop overlay element. */
|
|
20
|
+
itemDragAndDropOverlay: string;
|
|
21
|
+
/** Styles applied to the item's error icon element */
|
|
22
|
+
itemErrorIcon: string;
|
|
23
|
+
/** Styles applied to the item's loading icon element */
|
|
24
|
+
itemLoadingIcon: string;
|
|
25
|
+
}
|
|
26
|
+
export interface TreeViewStyleContextValue {
|
|
27
|
+
classes: Partial<TreeViewClasses>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* @ignore - internal component.
|
|
31
|
+
*/
|
|
32
|
+
export declare const TreeViewStyleContext: React.Context<TreeViewStyleContextValue>;
|
|
33
|
+
export declare const useTreeViewStyleContext: () => TreeViewStyleContextValue;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.useTreeViewStyleContext = exports.TreeViewStyleContext = void 0;
|
|
8
|
+
var React = _interopRequireWildcard(require("react"));
|
|
9
|
+
/**
|
|
10
|
+
* @ignore - internal component.
|
|
11
|
+
*/
|
|
12
|
+
const TreeViewStyleContext = exports.TreeViewStyleContext = /*#__PURE__*/React.createContext({
|
|
13
|
+
classes: {}
|
|
14
|
+
});
|
|
15
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
16
|
+
TreeViewStyleContext.displayName = 'TreeViewStyleContext';
|
|
17
|
+
}
|
|
18
|
+
const useTreeViewStyleContext = () => {
|
|
19
|
+
return React.useContext(TreeViewStyleContext);
|
|
20
|
+
};
|
|
21
|
+
exports.useTreeViewStyleContext = useTreeViewStyleContext;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { TreeViewProvider } from "./TreeViewProvider.js";
|
|
2
|
-
export { useTreeViewContext } from "./
|
|
2
|
+
export { useTreeViewContext } from "./TreeViewContext.js";
|
|
3
3
|
export type { TreeViewProviderProps, TreeViewContextValue, TreeViewItemPluginsRunner } from './TreeViewProvider.types';
|
|
@@ -12,8 +12,8 @@ Object.defineProperty(exports, "TreeViewProvider", {
|
|
|
12
12
|
Object.defineProperty(exports, "useTreeViewContext", {
|
|
13
13
|
enumerable: true,
|
|
14
14
|
get: function () {
|
|
15
|
-
return
|
|
15
|
+
return _TreeViewContext.useTreeViewContext;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
18
|
var _TreeViewProvider = require("./TreeViewProvider");
|
|
19
|
-
var
|
|
19
|
+
var _TreeViewContext = require("./TreeViewContext");
|
package/internals/index.d.ts
CHANGED
|
@@ -30,4 +30,5 @@ export { useTreeViewJSXItems } from "./plugins/useTreeViewJSXItems/index.js";
|
|
|
30
30
|
export type { UseTreeViewJSXItemsSignature, UseTreeViewJSXItemsParameters } from './plugins/useTreeViewJSXItems';
|
|
31
31
|
export { createSelector } from "./utils/selectors.js";
|
|
32
32
|
export { isTargetInDescendants } from "./utils/tree.js";
|
|
33
|
-
export { TreeViewStore } from "./utils/TreeViewStore.js";
|
|
33
|
+
export { TreeViewStore } from "./utils/TreeViewStore.js";
|
|
34
|
+
export type { TreeViewClasses } from './TreeViewProvider/TreeViewStyleContext';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "useTreeViewItemCustomization", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _useTreeViewItemCustomization.useTreeViewItemCustomization;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _useTreeViewItemCustomization = require("./useTreeViewItemCustomization");
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.useTreeViewItemCustomization = void 0;
|
|
8
|
+
var React = _interopRequireWildcard(require("react"));
|
|
9
|
+
const useTreeViewItemCustomization = ({
|
|
10
|
+
slots,
|
|
11
|
+
slotProps
|
|
12
|
+
}) => {
|
|
13
|
+
const pluginContextValue = React.useMemo(() => ({
|
|
14
|
+
icons: {
|
|
15
|
+
slots: {
|
|
16
|
+
collapseIcon: slots.collapseIcon,
|
|
17
|
+
expandIcon: slots.expandIcon,
|
|
18
|
+
endIcon: slots.endIcon
|
|
19
|
+
},
|
|
20
|
+
slotProps: {
|
|
21
|
+
collapseIcon: slotProps.collapseIcon,
|
|
22
|
+
expandIcon: slotProps.expandIcon,
|
|
23
|
+
endIcon: slotProps.endIcon
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}), [slots.collapseIcon, slots.expandIcon, slots.endIcon, slotProps.collapseIcon, slotProps.expandIcon, slotProps.endIcon]);
|
|
27
|
+
return {
|
|
28
|
+
contextValue: pluginContextValue
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
exports.useTreeViewItemCustomization = useTreeViewItemCustomization;
|
|
32
|
+
useTreeViewItemCustomization.params = {};
|
package/internals/plugins/useTreeViewItemCustomization/useTreeViewItemCustomization.types.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { SlotComponentProps } from '@mui/utils/types';
|
|
3
|
+
import { TreeViewPluginSignature } from "../../models/index.js";
|
|
4
|
+
import { UseTreeViewItemsSignature } from "../useTreeViewItems/index.js";
|
|
5
|
+
import { UseTreeViewSelectionSignature } from "../useTreeViewSelection/index.js";
|
|
6
|
+
export interface UseTreeViewItemCustomizationParameters {}
|
|
7
|
+
export type UseTreeViewItemCustomizationDefaultizedParameters = UseTreeViewItemCustomizationParameters;
|
|
8
|
+
interface UseTreeViewItemCustomizationSlots {
|
|
9
|
+
/**
|
|
10
|
+
* The default icon used to collapse the item.
|
|
11
|
+
*/
|
|
12
|
+
collapseIcon?: React.ElementType;
|
|
13
|
+
/**
|
|
14
|
+
* The default icon used to expand the item.
|
|
15
|
+
*/
|
|
16
|
+
expandIcon?: React.ElementType;
|
|
17
|
+
/**
|
|
18
|
+
* The default icon displayed next to an end item.
|
|
19
|
+
* This is applied to all Tree Items and can be overridden by the TreeItem `icon` slot prop.
|
|
20
|
+
*/
|
|
21
|
+
endIcon?: React.ElementType;
|
|
22
|
+
}
|
|
23
|
+
interface UseTreeViewItemCustomizationSlotProps {
|
|
24
|
+
collapseIcon?: SlotComponentProps<'svg', {}, {}>;
|
|
25
|
+
expandIcon?: SlotComponentProps<'svg', {}, {}>;
|
|
26
|
+
endIcon?: SlotComponentProps<'svg', {}, {}>;
|
|
27
|
+
}
|
|
28
|
+
interface UseTreeViewItemCustomizationContextValue {
|
|
29
|
+
icons: {
|
|
30
|
+
slots: UseTreeViewItemCustomizationSlots;
|
|
31
|
+
slotProps: UseTreeViewItemCustomizationSlotProps;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export type UseTreeViewItemCustomizationSignature = TreeViewPluginSignature<{
|
|
35
|
+
params: UseTreeViewItemCustomizationParameters;
|
|
36
|
+
defaultizedParams: UseTreeViewItemCustomizationDefaultizedParameters;
|
|
37
|
+
contextValue: UseTreeViewItemCustomizationContextValue;
|
|
38
|
+
slots: UseTreeViewItemCustomizationSlots;
|
|
39
|
+
slotProps: UseTreeViewItemCustomizationSlotProps;
|
|
40
|
+
dependencies: [UseTreeViewItemsSignature, UseTreeViewSelectionSignature];
|
|
41
|
+
}>;
|
|
42
|
+
export {};
|
|
@@ -13,9 +13,8 @@ type DataSource<R extends {}> = {
|
|
|
13
13
|
* @template R
|
|
14
14
|
* @param {R} item The item to check.
|
|
15
15
|
* @returns {number} The number of children.
|
|
16
|
-
* @default (item) => number
|
|
17
16
|
*/
|
|
18
|
-
getChildrenCount
|
|
17
|
+
getChildrenCount: (item: R) => number;
|
|
19
18
|
/**
|
|
20
19
|
* Method used for fetching the items.
|
|
21
20
|
* Only relevant for lazy-loaded tree views.
|
|
@@ -24,7 +23,7 @@ type DataSource<R extends {}> = {
|
|
|
24
23
|
* @param {TreeViewItemId} parentId The id of the item the children belong to.
|
|
25
24
|
* @returns { Promise<R[]>} The children of the item.
|
|
26
25
|
*/
|
|
27
|
-
getTreeItems
|
|
26
|
+
getTreeItems: (parentId?: TreeViewItemId) => Promise<R[]>;
|
|
28
27
|
};
|
|
29
28
|
export interface UseTreeViewLazyLoadingPublicAPI {}
|
|
30
29
|
export interface UseTreeViewLazyLoadingInstance extends UseTreeViewLazyLoadingPublicAPI {
|
|
@@ -22,10 +22,21 @@ const useUtilityClasses = ownerState => {
|
|
|
22
22
|
const {
|
|
23
23
|
classes
|
|
24
24
|
} = ownerState;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
return React.useMemo(() => {
|
|
26
|
+
const slots = {
|
|
27
|
+
root: ['root'],
|
|
28
|
+
item: ['item'],
|
|
29
|
+
itemContent: ['itemContent'],
|
|
30
|
+
itemGroupTransition: ['itemGroupTransition'],
|
|
31
|
+
itemIconContainer: ['itemIconContainer'],
|
|
32
|
+
itemLabel: ['itemLabel'],
|
|
33
|
+
itemLabelInput: ['itemLabelInput'],
|
|
34
|
+
itemCheckbox: ['itemCheckbox']
|
|
35
|
+
// itemDragAndDropOverlay: ['itemDragAndDropOverlay'], => feature not available on this component
|
|
36
|
+
// itemErrorIcon: ['itemErrorIcon'], => feature not available on this component
|
|
37
|
+
};
|
|
38
|
+
return composeClasses(slots, getRichTreeViewUtilityClass, classes);
|
|
39
|
+
}, [classes]);
|
|
29
40
|
};
|
|
30
41
|
export const RichTreeViewRoot = styled('ul', {
|
|
31
42
|
name: 'MuiRichTreeView',
|
|
@@ -93,7 +104,8 @@ const RichTreeView = /*#__PURE__*/React.forwardRef(function RichTreeView(inProps
|
|
|
93
104
|
});
|
|
94
105
|
}
|
|
95
106
|
return /*#__PURE__*/_jsx(TreeViewProvider, {
|
|
96
|
-
|
|
107
|
+
contextValue: contextValue,
|
|
108
|
+
classes: classes,
|
|
97
109
|
children: /*#__PURE__*/_jsx(Root, _extends({}, rootProps, {
|
|
98
110
|
children: /*#__PURE__*/_jsx(RichTreeViewItems, {
|
|
99
111
|
slots: slots,
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
root: string;
|
|
4
|
-
}
|
|
1
|
+
import { TreeViewClasses } from "../internals/TreeViewProvider/TreeViewStyleContext.js";
|
|
2
|
+
export interface RichTreeViewClasses extends Omit<TreeViewClasses, 'itemDragAndDropOverlay' | 'itemErrorIcon' | 'itemLoadingIcon'> {}
|
|
5
3
|
export type RichTreeViewClassKey = keyof RichTreeViewClasses;
|
|
6
4
|
export declare function getRichTreeViewUtilityClass(slot: string): string;
|
|
7
5
|
export declare const richTreeViewClasses: RichTreeViewClasses;
|
|
@@ -3,4 +3,4 @@ import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
|
3
3
|
export function getRichTreeViewUtilityClass(slot) {
|
|
4
4
|
return generateUtilityClass('MuiRichTreeView', slot);
|
|
5
5
|
}
|
|
6
|
-
export const richTreeViewClasses = generateUtilityClasses('MuiRichTreeView', ['root']);
|
|
6
|
+
export const richTreeViewClasses = generateUtilityClasses('MuiRichTreeView', ['root', 'item', 'itemContent', 'itemGroupTransition', 'itemIconContainer', 'itemLabel', 'itemCheckbox', 'itemLabelInput']);
|
|
@@ -17,10 +17,21 @@ const useUtilityClasses = ownerState => {
|
|
|
17
17
|
const {
|
|
18
18
|
classes
|
|
19
19
|
} = ownerState;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
return React.useMemo(() => {
|
|
21
|
+
const slots = {
|
|
22
|
+
root: ['root'],
|
|
23
|
+
item: ['item'],
|
|
24
|
+
itemContent: ['itemContent'],
|
|
25
|
+
itemGroupTransition: ['itemGroupTransition'],
|
|
26
|
+
itemIconContainer: ['itemIconContainer'],
|
|
27
|
+
itemLabel: ['itemLabel'],
|
|
28
|
+
// itemLabelInput: ['itemLabelInput'], => feature not available on this component
|
|
29
|
+
itemCheckbox: ['itemCheckbox']
|
|
30
|
+
// itemDragAndDropOverlay: ['itemDragAndDropOverlay'], => feature not available on this component
|
|
31
|
+
// itemErrorIcon: ['itemErrorIcon'], => feature not available on this component
|
|
32
|
+
};
|
|
33
|
+
return composeClasses(slots, getSimpleTreeViewUtilityClass, classes);
|
|
34
|
+
}, [classes]);
|
|
24
35
|
};
|
|
25
36
|
export const SimpleTreeViewRoot = styled('ul', {
|
|
26
37
|
name: 'MuiSimpleTreeView',
|
|
@@ -80,7 +91,8 @@ const SimpleTreeView = /*#__PURE__*/React.forwardRef(function SimpleTreeView(inP
|
|
|
80
91
|
ownerState
|
|
81
92
|
});
|
|
82
93
|
return /*#__PURE__*/_jsx(TreeViewProvider, {
|
|
83
|
-
|
|
94
|
+
contextValue: contextValue,
|
|
95
|
+
classes: classes,
|
|
84
96
|
children: /*#__PURE__*/_jsx(Root, _extends({}, rootProps))
|
|
85
97
|
});
|
|
86
98
|
});
|