@mui/x-tree-view 7.18.0 → 7.19.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/CHANGELOG.md +110 -0
- package/RichTreeView/RichTreeView.plugins.d.ts +1 -1
- package/SimpleTreeView/SimpleTreeView.plugins.d.ts +1 -1
- package/TreeItem/TreeItem.js +7 -1
- package/TreeItem/TreeItemContent.js +1 -1
- package/TreeItem2/TreeItem2.d.ts +6 -6
- package/hooks/useTreeItem2Utils/useTreeItem2Utils.d.ts +24 -6
- package/hooks/useTreeItem2Utils/useTreeItem2Utils.js +10 -8
- package/index.js +1 -1
- package/internals/TreeViewProvider/TreeViewChildrenItemProvider.js +7 -1
- package/internals/TreeViewProvider/TreeViewProvider.js +2 -1
- package/internals/TreeViewProvider/TreeViewProvider.types.d.ts +2 -1
- package/internals/TreeViewProvider/useTreeViewContext.d.ts +1 -1
- package/internals/corePlugins/corePlugins.d.ts +1 -1
- package/internals/corePlugins/useTreeViewId/useTreeViewId.js +28 -7
- package/internals/corePlugins/useTreeViewId/useTreeViewId.types.d.ts +11 -13
- package/internals/corePlugins/useTreeViewId/useTreeViewId.utils.d.ts +17 -0
- package/internals/corePlugins/useTreeViewId/useTreeViewId.utils.js +26 -0
- package/internals/models/plugin.d.ts +4 -1
- package/internals/plugins/useTreeViewExpansion/useTreeViewExpansion.js +3 -1
- package/internals/plugins/useTreeViewFocus/useTreeViewFocus.js +1 -1
- package/internals/plugins/useTreeViewItems/useTreeViewItems.js +9 -2
- package/internals/plugins/useTreeViewJSXItems/useTreeViewJSXItems.js +11 -5
- package/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.js +6 -0
- package/internals/plugins/useTreeViewLabel/useTreeViewLabel.js +16 -8
- package/internals/plugins/useTreeViewLabel/useTreeViewLabel.types.d.ts +3 -2
- package/internals/plugins/useTreeViewSelection/useTreeViewSelection.js +3 -1
- package/internals/useTreeView/extractPluginParamsFromProps.d.ts +1 -1
- package/internals/useTreeView/extractPluginParamsFromProps.js +7 -3
- package/modern/TreeItem/TreeItem.js +7 -1
- package/modern/TreeItem/TreeItemContent.js +1 -1
- package/modern/hooks/useTreeItem2Utils/useTreeItem2Utils.js +10 -8
- package/modern/index.js +1 -1
- package/modern/internals/TreeViewProvider/TreeViewChildrenItemProvider.js +7 -1
- package/modern/internals/TreeViewProvider/TreeViewProvider.js +2 -1
- package/modern/internals/corePlugins/useTreeViewId/useTreeViewId.js +28 -7
- package/modern/internals/corePlugins/useTreeViewId/useTreeViewId.utils.js +26 -0
- package/modern/internals/plugins/useTreeViewExpansion/useTreeViewExpansion.js +3 -1
- package/modern/internals/plugins/useTreeViewFocus/useTreeViewFocus.js +1 -1
- package/modern/internals/plugins/useTreeViewItems/useTreeViewItems.js +9 -2
- package/modern/internals/plugins/useTreeViewJSXItems/useTreeViewJSXItems.js +11 -5
- package/modern/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.js +6 -0
- package/modern/internals/plugins/useTreeViewLabel/useTreeViewLabel.js +16 -8
- package/modern/internals/plugins/useTreeViewSelection/useTreeViewSelection.js +3 -1
- package/modern/internals/useTreeView/extractPluginParamsFromProps.js +7 -3
- package/modern/useTreeItem2/useTreeItem2.js +7 -1
- package/node/TreeItem/TreeItem.js +7 -1
- package/node/TreeItem/TreeItemContent.js +1 -1
- package/node/hooks/useTreeItem2Utils/useTreeItem2Utils.js +10 -9
- package/node/index.js +1 -1
- package/node/internals/TreeViewProvider/TreeViewChildrenItemProvider.js +7 -1
- package/node/internals/TreeViewProvider/TreeViewProvider.js +2 -1
- package/node/internals/corePlugins/useTreeViewId/useTreeViewId.js +29 -8
- package/node/internals/corePlugins/useTreeViewId/useTreeViewId.utils.js +34 -0
- package/node/internals/plugins/useTreeViewExpansion/useTreeViewExpansion.js +3 -1
- package/node/internals/plugins/useTreeViewFocus/useTreeViewFocus.js +1 -1
- package/node/internals/plugins/useTreeViewItems/useTreeViewItems.js +9 -2
- package/node/internals/plugins/useTreeViewJSXItems/useTreeViewJSXItems.js +11 -5
- package/node/internals/plugins/useTreeViewKeyboardNavigation/useTreeViewKeyboardNavigation.js +6 -0
- package/node/internals/plugins/useTreeViewLabel/useTreeViewLabel.js +16 -8
- package/node/internals/plugins/useTreeViewSelection/useTreeViewSelection.js +3 -1
- package/node/internals/useTreeView/extractPluginParamsFromProps.js +7 -3
- package/node/useTreeItem2/useTreeItem2.js +7 -1
- package/package.json +1 -1
- package/useTreeItem2/index.d.ts +2 -2
- package/useTreeItem2/useTreeItem2.js +7 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,116 @@
|
|
|
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
|
+
## 7.19.0
|
|
7
|
+
|
|
8
|
+
_Oct 4, 2024_
|
|
9
|
+
|
|
10
|
+
We'd like to offer a big thanks to the 26 contributors who made this release possible. Here are some highlights ✨:
|
|
11
|
+
|
|
12
|
+
- 🔁 Automatic parents and children selection for Data Grid ["tree data"](https://mui.com/x/react-data-grid/tree-data/) and ["row grouping"](https://mui.com/x/react-data-grid/row-grouping/) features
|
|
13
|
+
- 💫 Support `minHeight` and `maxHeight` on flex parent container for the Data Grid component
|
|
14
|
+
- 🎁 Export `publicAPI` from the `useTreeItem2Utils` hook for the Tree View
|
|
15
|
+
- 🌍 Improve Bulgarian (bg-BG), Croatian (hr-HR), French (fr-FR), German (de-DE), Japanese (ja-JP) and Vietnamese (vi-VN) locales and add Portuguese (pt-PT) locale on the Data Grid component
|
|
16
|
+
- 🌏 Improve Czech (cs-CZ) and Portuguese (pt-BR) locales and add Bulgarian (bg-BG), Croatian (hr-HR) and Portuguese (pt-PT) locales on the Pickers components
|
|
17
|
+
- 🐞 Bugfixes
|
|
18
|
+
- 📚 Documentation improvements
|
|
19
|
+
|
|
20
|
+
Special thanks goes out to our community contributors who have helped make this release possible:
|
|
21
|
+
@AWAIS97, @chucamphong, @GMchris, @JakubSveda, @k-rajat19, @k725, @lhilgert9, @ruiaraujo012, @Sanderand, @thomasmoon, @vallereaugabriel.
|
|
22
|
+
Following are all team members who have contributed to this release:
|
|
23
|
+
@alexfauquette, @arminmeh, @arthurbalduini, @cherniavskii, @flaviendelangle, @Janpot, @JCQuintas, @KenanYusuf, @MBilalShafi, @michelengelen, @noraleonte, @oliviertassinari, @romgrk, @sai6855, @samuelsycamore.
|
|
24
|
+
|
|
25
|
+
<!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
|
|
26
|
+
|
|
27
|
+
### Data Grid
|
|
28
|
+
|
|
29
|
+
#### `@mui/x-data-grid@7.19.0`
|
|
30
|
+
|
|
31
|
+
- [DataGrid] Fix column definition `undefined` value (#14456) @sai6855
|
|
32
|
+
- [DataGrid] Fix `checkboxSelectionVisibleOnly` reset the selection on filtering (#14677) @MBilalShafi
|
|
33
|
+
- [DataGrid] Fix background colors when `CSSVarsProvider` is used (#12901) @cherniavskii
|
|
34
|
+
- [DataGrid] Fix error when initializing aggregation with row spanning (#14710) @MBilalShafi
|
|
35
|
+
- [DataGrid] Fix scroll to cell logic for keyboard navigating cells and drag selection with pinned columns (#14550) @KenanYusuf
|
|
36
|
+
- [DataGrid] Support `minHeight` and `maxHeight` on flex parent container (#14614) @cherniavskii
|
|
37
|
+
- [l10n] Add missing Portuguese (pt-PT) translations (#14707) @ruiaraujo012
|
|
38
|
+
- [l10n] Improve Bulgarian (bg-BG) locale (#14451) @GMchris
|
|
39
|
+
- [l10n] Improve Croatian (hr-HR) locale (#14794) @arminmeh
|
|
40
|
+
- [l10n] Improve French (fr-FR) locale (#14750) @vallereaugabriel
|
|
41
|
+
- [l10n] Improve German (de-DE) locale (#14755) @lhilgert9
|
|
42
|
+
- [l10n] Improve Japanese (ja-JP) locale (#14381) @k725
|
|
43
|
+
- [l10n] Improve Vietnamese (vi-VN) locale (#14769) @chucamphong
|
|
44
|
+
|
|
45
|
+
#### `@mui/x-data-grid-pro@7.19.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
46
|
+
|
|
47
|
+
Same changes as in `@mui/x-data-grid@7.19.0`, plus:
|
|
48
|
+
|
|
49
|
+
- [DataGridPro] Fix dragging styles removal in column reorder (#14680) @k-rajat19
|
|
50
|
+
- [DataGridPro] Fix row pre-processing running with a stale data source (#14810) @MBilalShafi
|
|
51
|
+
- [DataGridPro] Fix `onRowsScrollEnd` not firing on very fast scrolling (#14171) @arminmeh
|
|
52
|
+
|
|
53
|
+
#### `@mui/x-data-grid-premium@7.19.0` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
54
|
+
|
|
55
|
+
Same changes as in `@mui/x-data-grid-pro@7.19.0`, plus:
|
|
56
|
+
|
|
57
|
+
- [DataGridPremium] Automatic parents and children selection (#13757) @MBilalShafi
|
|
58
|
+
|
|
59
|
+
### Date and Time Pickers
|
|
60
|
+
|
|
61
|
+
#### `@mui/x-date-pickers@7.19.0`
|
|
62
|
+
|
|
63
|
+
- [pickers] Fix left-right keyboard nav with `yearsOrder="desc"` and `direction="rtl"` (#14682) @thomasmoon
|
|
64
|
+
- [pickers] Improve `PickerValidDate` type (#14771) @flaviendelangle
|
|
65
|
+
- [pickers] Improve typing of the range pickers (#14716) @flaviendelangle
|
|
66
|
+
- [l10n] Add Bulgarian (bg-BG) locale (#14469) @GMchris
|
|
67
|
+
- [l10n] Add Croatian (hr-HR) locale (#14795) @arminmeh
|
|
68
|
+
- [l10n] Add Portuguese (pt-PT) locale (#14722) @ruiaraujo012
|
|
69
|
+
- [l10n] Improve Czech (cs-CZ) locale (#14732) @JakubSveda
|
|
70
|
+
- [l10n] Improve Portuguese (pt-BR) locale (#14725) @arthurbalduini
|
|
71
|
+
|
|
72
|
+
#### `@mui/x-date-pickers-pro@7.19.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
73
|
+
|
|
74
|
+
Same changes as in `@mui/x-date-pickers@7.19.0`.
|
|
75
|
+
|
|
76
|
+
### Charts
|
|
77
|
+
|
|
78
|
+
#### `@mui/x-charts@7.19.0`
|
|
79
|
+
|
|
80
|
+
- [charts] Fix `LineChart` area animation being stuck when resizing container (#14711) @alexfauquette
|
|
81
|
+
- [charts] Improve types and start using `warnOnce` (#14792) @JCQuintas
|
|
82
|
+
|
|
83
|
+
#### `@mui/x-charts-pro@7.0.0-beta.3` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
84
|
+
|
|
85
|
+
Same changes as in `@mui/x-charts@7.19.0`.
|
|
86
|
+
|
|
87
|
+
### Tree View
|
|
88
|
+
|
|
89
|
+
#### `@mui/x-tree-view@7.19.0`
|
|
90
|
+
|
|
91
|
+
- [TreeView] Apply experimental features in `getDefaultizedParams` instead of in the plugin render (#14661) @flaviendelangle
|
|
92
|
+
- [TreeView] Export `publicAPI` form `useTreeItem2Utils` (#14729) @noraleonte
|
|
93
|
+
- [TreeView] Fix cursor navigation interfering with browser shortcut keys (#14798) @sai6855
|
|
94
|
+
- [TreeView] Fix invalid test for items reordering (#14665) @flaviendelangle
|
|
95
|
+
- [TreeView] Remove `instance.getTreeItemIdAttribute` (#14667) @flaviendelangle
|
|
96
|
+
|
|
97
|
+
### Docs
|
|
98
|
+
|
|
99
|
+
- [docs] Added warning callout for Firefox reordering bug (#14516) @michelengelen
|
|
100
|
+
- [docs] Copyedit `pages.ts` navigation (#14782) @samuelsycamore
|
|
101
|
+
- [docs] Fix typo in row spanning doc (#14770) @flaviendelangle
|
|
102
|
+
- [docs] Fix typo in the Tree View migration guide to v7 (#14727) @Sanderand
|
|
103
|
+
- [docs] Fix typo in usage of Moment guide for UTC and timezones (#14780) @AWAIS97
|
|
104
|
+
- [docs] Fix what's new link to use absolute URL (#14543) @oliviertassinari
|
|
105
|
+
|
|
106
|
+
### Core
|
|
107
|
+
|
|
108
|
+
- [core] Fix class name composition order (#14775) @oliviertassinari
|
|
109
|
+
- [core] Replace minWidth, maxWidth with width (#14776) @oliviertassinari
|
|
110
|
+
- [code-infra] Remove custom playwright installation steps (#14728) @Janpot
|
|
111
|
+
- [code-infra] Replace or remove all instances of `e` identifier (#14724) @samuelsycamore
|
|
112
|
+
- [infra] Adds community contribution section to the changelog script (#14799) @michelengelen
|
|
113
|
+
- [infra] Fix line break in Stack Overflow message @oliviertassinari
|
|
114
|
+
- [test] Fix `Escape` event firing event (#14797) @oliviertassinari
|
|
115
|
+
|
|
6
116
|
## 7.18.0
|
|
7
117
|
|
|
8
118
|
_Sep 20, 2024_
|
|
@@ -6,7 +6,7 @@ import { UseTreeViewFocusParameters } from '../internals/plugins/useTreeViewFocu
|
|
|
6
6
|
import { UseTreeViewIconsParameters } from '../internals/plugins/useTreeViewIcons';
|
|
7
7
|
import { ConvertPluginsIntoSignatures, MergeSignaturesProperty } from '../internals/models';
|
|
8
8
|
import { UseTreeViewLabelParameters } from '../internals/plugins/useTreeViewLabel';
|
|
9
|
-
export declare const RICH_TREE_VIEW_PLUGINS: readonly [import("../internals
|
|
9
|
+
export declare const RICH_TREE_VIEW_PLUGINS: readonly [import("../internals").TreeViewPlugin<import("../internals").UseTreeViewItemsSignature>, import("../internals").TreeViewPlugin<import("../internals").UseTreeViewExpansionSignature>, import("../internals").TreeViewPlugin<import("../internals").UseTreeViewSelectionSignature>, import("../internals").TreeViewPlugin<import("../internals").UseTreeViewFocusSignature>, import("../internals").TreeViewPlugin<import("../internals").UseTreeViewKeyboardNavigationSignature>, import("../internals").TreeViewPlugin<import("../internals").UseTreeViewIconsSignature>, import("../internals").TreeViewPlugin<import("../internals").UseTreeViewLabelSignature>];
|
|
10
10
|
export type RichTreeViewPluginSignatures = ConvertPluginsIntoSignatures<typeof RICH_TREE_VIEW_PLUGINS>;
|
|
11
11
|
export type RichTreeViewPluginSlots = MergeSignaturesProperty<RichTreeViewPluginSignatures, 'slots'>;
|
|
12
12
|
export type RichTreeViewPluginSlotProps = MergeSignaturesProperty<RichTreeViewPluginSignatures, 'slotProps'>;
|
|
@@ -5,7 +5,7 @@ import { UseTreeViewSelectionParameters } from '../internals/plugins/useTreeView
|
|
|
5
5
|
import { UseTreeViewFocusParameters } from '../internals/plugins/useTreeViewFocus';
|
|
6
6
|
import { UseTreeViewIconsParameters } from '../internals/plugins/useTreeViewIcons';
|
|
7
7
|
import { ConvertPluginsIntoSignatures, MergeSignaturesProperty } from '../internals/models';
|
|
8
|
-
export declare const SIMPLE_TREE_VIEW_PLUGINS: readonly [import("../internals
|
|
8
|
+
export declare const SIMPLE_TREE_VIEW_PLUGINS: readonly [import("../internals").TreeViewPlugin<import("../internals").UseTreeViewItemsSignature>, import("../internals").TreeViewPlugin<import("../internals").UseTreeViewExpansionSignature>, import("../internals").TreeViewPlugin<import("../internals").UseTreeViewSelectionSignature>, import("../internals").TreeViewPlugin<import("../internals").UseTreeViewFocusSignature>, import("../internals").TreeViewPlugin<import("../internals").UseTreeViewKeyboardNavigationSignature>, import("../internals").TreeViewPlugin<import("../internals").UseTreeViewIconsSignature>, import("../internals").TreeViewPlugin<import("../internals").UseTreeViewJSXItemsSignature>];
|
|
9
9
|
export type SimpleTreeViewPluginSignatures = ConvertPluginsIntoSignatures<typeof SIMPLE_TREE_VIEW_PLUGINS>;
|
|
10
10
|
export type SimpleTreeViewPluginSlots = MergeSignaturesProperty<SimpleTreeViewPluginSignatures, 'slots'>;
|
|
11
11
|
export type SimpleTreeViewPluginSlotProps = MergeSignaturesProperty<SimpleTreeViewPluginSignatures, 'slotProps'>;
|
package/TreeItem/TreeItem.js
CHANGED
|
@@ -28,6 +28,7 @@ import { TreeItem2Provider } from "../TreeItem2Provider/index.js";
|
|
|
28
28
|
import { TreeViewItemDepthContext } from "../internals/TreeViewItemDepthContext/index.js";
|
|
29
29
|
import { useTreeItemState } from "./useTreeItemState.js";
|
|
30
30
|
import { isTargetInDescendants } from "../internals/utils/tree.js";
|
|
31
|
+
import { generateTreeItemIdAttribute } from "../internals/corePlugins/useTreeViewId/useTreeViewId.utils.js";
|
|
31
32
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
32
33
|
const useThemeProps = createUseThemeProps('MuiTreeItem');
|
|
33
34
|
const useUtilityClasses = ownerState => {
|
|
@@ -185,6 +186,7 @@ export const TreeItem = /*#__PURE__*/React.forwardRef(function TreeItem(inProps,
|
|
|
185
186
|
expansion: {
|
|
186
187
|
expansionTrigger
|
|
187
188
|
},
|
|
189
|
+
treeId,
|
|
188
190
|
instance
|
|
189
191
|
} = useTreeViewContext();
|
|
190
192
|
const depthContext = React.useContext(TreeViewItemDepthContext);
|
|
@@ -341,7 +343,11 @@ export const TreeItem = /*#__PURE__*/React.forwardRef(function TreeItem(inProps,
|
|
|
341
343
|
}
|
|
342
344
|
instance.handleItemKeyDown(event, itemId);
|
|
343
345
|
};
|
|
344
|
-
const idAttribute =
|
|
346
|
+
const idAttribute = generateTreeItemIdAttribute({
|
|
347
|
+
itemId,
|
|
348
|
+
treeId,
|
|
349
|
+
id
|
|
350
|
+
});
|
|
345
351
|
const tabIndex = instance.canItemBeTabbed(itemId) ? 0 : -1;
|
|
346
352
|
const sharedPropsEnhancerParams = {
|
|
347
353
|
rootRefObject,
|
|
@@ -77,7 +77,7 @@ const TreeItemContent = /*#__PURE__*/React.forwardRef(function TreeItemContent(p
|
|
|
77
77
|
/*#__PURE__*/
|
|
78
78
|
/* eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions -- Key event is handled by the TreeView */
|
|
79
79
|
_jsxs("div", _extends({}, other, {
|
|
80
|
-
className: clsx(
|
|
80
|
+
className: clsx(classes.root, className, expanded && classes.expanded, selected && classes.selected, focused && classes.focused, disabled && classes.disabled, editing && classes.editing, editable && classes.editable),
|
|
81
81
|
onClick: handleClick,
|
|
82
82
|
onMouseDown: handleMouseDown,
|
|
83
83
|
ref: ref,
|
package/TreeItem2/TreeItem2.d.ts
CHANGED
|
@@ -2,21 +2,21 @@ import * as React from 'react';
|
|
|
2
2
|
import { CheckboxProps } from '@mui/material/Checkbox';
|
|
3
3
|
import { TreeItem2Props } from './TreeItem2.types';
|
|
4
4
|
import { UseTreeItem2Status } from '../useTreeItem2';
|
|
5
|
-
export declare const TreeItem2Root: import("@emotion/styled").StyledComponent<import("@mui/system
|
|
6
|
-
export declare const TreeItem2Content: import("@emotion/styled").StyledComponent<import("@mui/system
|
|
5
|
+
export declare const TreeItem2Root: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, Pick<React.DetailedHTMLProps<React.LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, keyof React.ClassAttributes<HTMLLIElement> | keyof React.LiHTMLAttributes<HTMLLIElement>>, {}>;
|
|
6
|
+
export declare const TreeItem2Content: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
|
|
7
7
|
status: UseTreeItem2Status;
|
|
8
8
|
indentationAtItemLevel?: true;
|
|
9
9
|
}, React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
10
|
-
export declare const TreeItem2Label: import("@emotion/styled").StyledComponent<import("@mui/system
|
|
10
|
+
export declare const TreeItem2Label: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
|
|
11
11
|
editable?: boolean;
|
|
12
12
|
}, React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
13
|
-
export declare const TreeItem2IconContainer: import("@emotion/styled").StyledComponent<import("@mui/system
|
|
14
|
-
export declare const TreeItem2GroupTransition: import("@emotion/styled").StyledComponent<import("@mui/material
|
|
13
|
+
export declare const TreeItem2IconContainer: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.ClassAttributes<HTMLDivElement> | keyof React.HTMLAttributes<HTMLDivElement>>, {}>;
|
|
14
|
+
export declare const TreeItem2GroupTransition: import("@emotion/styled").StyledComponent<import("@mui/material").CollapseProps & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
|
|
15
15
|
indentationAtItemLevel?: true;
|
|
16
16
|
}, {}, {}>;
|
|
17
17
|
export declare const TreeItem2Checkbox: import("@emotion/styled").StyledComponent<Pick<Omit<CheckboxProps & {
|
|
18
18
|
visible: boolean;
|
|
19
|
-
}, "ref"> & React.RefAttributes<HTMLButtonElement>, "hidden" | "visible" | "color" | "content" | "size" | "style" | "icon" | "translate" | "disabled" | "form" | "slot" | "title" | "suppressHydrationWarning" | "className" | "id" | "lang" | "name" | "role" | "tabIndex" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-braillelabel" | "aria-brailleroledescription" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colindextext" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-description" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowindextext" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onResize" | "onResizeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerLeave" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "accessKey" | "autoFocus" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "nonce" | "spellCheck" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "rel" | "resource" | "rev" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "value" | "readOnly" | "required" | "action" | "checked" | "component" | "sx" | "classes" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "disableFocusRipple" | "edge" | "checkedIcon" | "inputProps" | "inputRef" | "indeterminate" | "indeterminateIcon" | keyof React.RefAttributes<HTMLButtonElement>> & import("@mui/system
|
|
19
|
+
}, "ref"> & React.RefAttributes<HTMLButtonElement>, "hidden" | "visible" | "color" | "content" | "size" | "style" | "icon" | "translate" | "disabled" | "form" | "slot" | "title" | "suppressHydrationWarning" | "className" | "id" | "lang" | "name" | "role" | "tabIndex" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-braillelabel" | "aria-brailleroledescription" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colindextext" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-description" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowindextext" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onResize" | "onResizeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerLeave" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "accessKey" | "autoFocus" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "nonce" | "spellCheck" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "rel" | "resource" | "rev" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "value" | "readOnly" | "required" | "action" | "checked" | "component" | "sx" | "classes" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "disableFocusRipple" | "edge" | "checkedIcon" | "inputProps" | "inputRef" | "indeterminate" | "indeterminateIcon" | keyof React.RefAttributes<HTMLButtonElement>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
20
20
|
type TreeItem2Component = ((props: TreeItem2Props & React.RefAttributes<HTMLLIElement>) => React.JSX.Element) & {
|
|
21
21
|
propTypes?: any;
|
|
22
22
|
};
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { UseTreeViewSelectionSignature } from '../../internals/plugins/useTreeViewSelection';
|
|
3
|
+
import { UseTreeViewExpansionSignature } from '../../internals/plugins/useTreeViewExpansion';
|
|
4
|
+
import { UseTreeViewItemsSignature } from '../../internals/plugins/useTreeViewItems';
|
|
5
|
+
import { UseTreeViewFocusSignature } from '../../internals/plugins/useTreeViewFocus';
|
|
2
6
|
import { UseTreeViewLabelSignature } from '../../internals/plugins/useTreeViewLabel';
|
|
3
7
|
import type { UseTreeItem2Status } from '../../useTreeItem2';
|
|
8
|
+
import { TreeViewPublicAPI } from '../../internals/models';
|
|
4
9
|
export interface UseTreeItem2Interactions {
|
|
5
10
|
handleExpansion: (event: React.MouseEvent) => void;
|
|
6
11
|
handleSelection: (event: React.MouseEvent) => void;
|
|
@@ -9,16 +14,29 @@ export interface UseTreeItem2Interactions {
|
|
|
9
14
|
handleSaveItemLabel: (event: React.SyntheticEvent, label: string) => void;
|
|
10
15
|
handleCancelItemLabelEditing: (event: React.SyntheticEvent) => void;
|
|
11
16
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Plugins that need to be present in the Tree View in order for `useTreeItem2Utils` to work correctly.
|
|
19
|
+
*/
|
|
20
|
+
type UseTreeItem2UtilsMinimalPlugins = readonly [
|
|
21
|
+
UseTreeViewSelectionSignature,
|
|
22
|
+
UseTreeViewExpansionSignature,
|
|
23
|
+
UseTreeViewItemsSignature,
|
|
24
|
+
UseTreeViewFocusSignature
|
|
25
|
+
];
|
|
16
26
|
/**
|
|
17
27
|
* Plugins that `useTreeItem2Utils` can use if they are present, but are not required.
|
|
18
28
|
*/
|
|
19
29
|
export type UseTreeItem2UtilsOptionalPlugins = readonly [UseTreeViewLabelSignature];
|
|
20
|
-
|
|
30
|
+
interface UseTreeItem2UtilsReturnValue<TSignatures extends UseTreeItem2UtilsMinimalPlugins, TOptionalSignatures extends UseTreeItem2UtilsOptionalPlugins> {
|
|
31
|
+
interactions: UseTreeItem2Interactions;
|
|
32
|
+
status: UseTreeItem2Status;
|
|
33
|
+
/**
|
|
34
|
+
* The object the allows Tree View manipulation.
|
|
35
|
+
*/
|
|
36
|
+
publicAPI: TreeViewPublicAPI<TSignatures, TOptionalSignatures>;
|
|
37
|
+
}
|
|
38
|
+
export declare const useTreeItem2Utils: <TSignatures extends UseTreeItem2UtilsMinimalPlugins = UseTreeItem2UtilsMinimalPlugins, TOptionalSignatures extends UseTreeItem2UtilsOptionalPlugins = UseTreeItem2UtilsOptionalPlugins>({ itemId, children, }: {
|
|
21
39
|
itemId: string;
|
|
22
40
|
children: React.ReactNode;
|
|
23
|
-
}) => UseTreeItem2UtilsReturnValue
|
|
41
|
+
}) => UseTreeItem2UtilsReturnValue<TSignatures, TOptionalSignatures>;
|
|
24
42
|
export {};
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { useTreeViewContext } from "../../internals/TreeViewProvider/index.js";
|
|
2
2
|
import { useTreeViewLabel } from "../../internals/plugins/useTreeViewLabel/index.js";
|
|
3
3
|
import { hasPlugin } from "../../internals/utils/plugins.js";
|
|
4
|
-
const isItemExpandable = reactChildren => {
|
|
5
|
-
if (Array.isArray(reactChildren)) {
|
|
6
|
-
return reactChildren.length > 0 && reactChildren.some(isItemExpandable);
|
|
7
|
-
}
|
|
8
|
-
return Boolean(reactChildren);
|
|
9
|
-
};
|
|
10
4
|
|
|
11
5
|
/**
|
|
12
6
|
* Plugins that need to be present in the Tree View in order for `useTreeItem2Utils` to work correctly.
|
|
@@ -16,6 +10,12 @@ const isItemExpandable = reactChildren => {
|
|
|
16
10
|
* Plugins that `useTreeItem2Utils` can use if they are present, but are not required.
|
|
17
11
|
*/
|
|
18
12
|
|
|
13
|
+
const isItemExpandable = reactChildren => {
|
|
14
|
+
if (Array.isArray(reactChildren)) {
|
|
15
|
+
return reactChildren.length > 0 && reactChildren.some(isItemExpandable);
|
|
16
|
+
}
|
|
17
|
+
return Boolean(reactChildren);
|
|
18
|
+
};
|
|
19
19
|
export const useTreeItem2Utils = ({
|
|
20
20
|
itemId,
|
|
21
21
|
children
|
|
@@ -24,7 +24,8 @@ export const useTreeItem2Utils = ({
|
|
|
24
24
|
instance,
|
|
25
25
|
selection: {
|
|
26
26
|
multiSelect
|
|
27
|
-
}
|
|
27
|
+
},
|
|
28
|
+
publicAPI
|
|
28
29
|
} = useTreeViewContext();
|
|
29
30
|
const status = {
|
|
30
31
|
expandable: isItemExpandable(children),
|
|
@@ -134,6 +135,7 @@ export const useTreeItem2Utils = ({
|
|
|
134
135
|
};
|
|
135
136
|
return {
|
|
136
137
|
interactions,
|
|
137
|
-
status
|
|
138
|
+
status,
|
|
139
|
+
publicAPI
|
|
138
140
|
};
|
|
139
141
|
};
|
package/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { useTreeViewContext } from "./useTreeViewContext.js";
|
|
4
4
|
import { escapeOperandAttributeSelector } from "../utils/utils.js";
|
|
5
|
+
import { generateTreeItemIdAttribute } from "../corePlugins/useTreeViewId/useTreeViewId.utils.js";
|
|
5
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
7
|
export const TreeViewChildrenItemContext = /*#__PURE__*/React.createContext(null);
|
|
7
8
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -14,6 +15,7 @@ export function TreeViewChildrenItemProvider(props) {
|
|
|
14
15
|
} = props;
|
|
15
16
|
const {
|
|
16
17
|
instance,
|
|
18
|
+
treeId,
|
|
17
19
|
rootRef
|
|
18
20
|
} = useTreeViewContext();
|
|
19
21
|
const childrenIdAttrToIdRef = React.useRef(new Map());
|
|
@@ -28,7 +30,11 @@ export function TreeViewChildrenItemProvider(props) {
|
|
|
28
30
|
// Undefined during 1st render
|
|
29
31
|
const itemMeta = instance.getItemMeta(itemId);
|
|
30
32
|
if (itemMeta !== undefined) {
|
|
31
|
-
idAttr =
|
|
33
|
+
idAttr = generateTreeItemIdAttribute({
|
|
34
|
+
itemId,
|
|
35
|
+
treeId,
|
|
36
|
+
id: itemMeta.idAttribute
|
|
37
|
+
});
|
|
32
38
|
}
|
|
33
39
|
}
|
|
34
40
|
if (idAttr == null) {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { MergeSignaturesProperty, TreeItemWrapper, TreeRootWrapper, TreeViewAnyPluginSignature, TreeViewInstance, TreeViewItemPluginResponse, TreeViewPublicAPI } from '../models';
|
|
3
|
+
import { TreeViewCorePluginSignatures } from '../corePlugins';
|
|
3
4
|
export type TreeViewItemPluginsRunner = <TProps extends {}>(props: TProps) => Required<TreeViewItemPluginResponse>;
|
|
4
|
-
export type TreeViewContextValue<TSignatures extends readonly TreeViewAnyPluginSignature[], TOptionalSignatures extends readonly TreeViewAnyPluginSignature[] = []> = MergeSignaturesProperty<TSignatures, 'contextValue'> & Partial<MergeSignaturesProperty<TOptionalSignatures, 'contextValue'>> & {
|
|
5
|
+
export type TreeViewContextValue<TSignatures extends readonly TreeViewAnyPluginSignature[], TOptionalSignatures extends readonly TreeViewAnyPluginSignature[] = []> = MergeSignaturesProperty<[...TreeViewCorePluginSignatures, ...TSignatures], 'contextValue'> & Partial<MergeSignaturesProperty<TOptionalSignatures, 'contextValue'>> & {
|
|
5
6
|
instance: TreeViewInstance<TSignatures, TOptionalSignatures>;
|
|
6
7
|
publicAPI: TreeViewPublicAPI<TSignatures, TOptionalSignatures>;
|
|
7
8
|
rootRef: React.RefObject<HTMLUListElement>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { TreeViewAnyPluginSignature } from '../models';
|
|
2
2
|
import { TreeViewContextValue } from './TreeViewProvider.types';
|
|
3
|
-
export declare const useTreeViewContext: <TSignatures extends readonly TreeViewAnyPluginSignature[], TOptionalSignatures extends readonly TreeViewAnyPluginSignature[] = []>() =>
|
|
3
|
+
export declare const useTreeViewContext: <TSignatures extends readonly TreeViewAnyPluginSignature[], TOptionalSignatures extends readonly TreeViewAnyPluginSignature[] = []>() => TreeViewContextValue<TSignatures, TOptionalSignatures>;
|
|
@@ -4,7 +4,7 @@ import { ConvertPluginsIntoSignatures } from '../models';
|
|
|
4
4
|
* Internal plugins that create the tools used by the other plugins.
|
|
5
5
|
* These plugins are used by the tree view components.
|
|
6
6
|
*/
|
|
7
|
-
export declare const TREE_VIEW_CORE_PLUGINS: readonly [import("
|
|
7
|
+
export declare const TREE_VIEW_CORE_PLUGINS: readonly [import("..").TreeViewPlugin<import("./useTreeViewInstanceEvents").UseTreeViewInstanceEventsSignature>, import("..").TreeViewPlugin<import("./useTreeViewOptionalPlugins").UseTreeViewOptionalPluginsSignature>, import("..").TreeViewPlugin<import("./useTreeViewId").UseTreeViewIdSignature>];
|
|
8
8
|
export type TreeViewCorePluginSignatures = ConvertPluginsIntoSignatures<typeof TREE_VIEW_CORE_PLUGINS>;
|
|
9
9
|
export interface TreeViewCorePluginParameters extends UseTreeViewIdParameters {
|
|
10
10
|
}
|
|
@@ -1,19 +1,40 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
1
2
|
import * as React from 'react';
|
|
2
|
-
import
|
|
3
|
+
import { createTreeViewDefaultId } from "./useTreeViewId.utils.js";
|
|
3
4
|
export const useTreeViewId = ({
|
|
4
|
-
params
|
|
5
|
+
params,
|
|
6
|
+
state,
|
|
7
|
+
setState
|
|
5
8
|
}) => {
|
|
6
|
-
const treeId =
|
|
7
|
-
|
|
9
|
+
const treeId = state.id.treeId;
|
|
10
|
+
React.useEffect(() => {
|
|
11
|
+
setState(prevState => {
|
|
12
|
+
if (prevState.id.treeId === params.id) {
|
|
13
|
+
return prevState;
|
|
14
|
+
}
|
|
15
|
+
return _extends({}, prevState, {
|
|
16
|
+
id: _extends({}, prevState.id, {
|
|
17
|
+
treeId: params.id ?? createTreeViewDefaultId()
|
|
18
|
+
})
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
}, [setState, params.id]);
|
|
8
22
|
return {
|
|
9
23
|
getRootProps: () => ({
|
|
10
24
|
id: treeId
|
|
11
25
|
}),
|
|
12
|
-
|
|
13
|
-
|
|
26
|
+
contextValue: {
|
|
27
|
+
treeId
|
|
14
28
|
}
|
|
15
29
|
};
|
|
16
30
|
};
|
|
17
31
|
useTreeViewId.params = {
|
|
18
32
|
id: true
|
|
19
|
-
};
|
|
33
|
+
};
|
|
34
|
+
useTreeViewId.getInitialState = ({
|
|
35
|
+
id
|
|
36
|
+
}) => ({
|
|
37
|
+
id: {
|
|
38
|
+
treeId: id ?? createTreeViewDefaultId()
|
|
39
|
+
}
|
|
40
|
+
});
|
|
@@ -1,16 +1,4 @@
|
|
|
1
1
|
import { TreeViewPluginSignature } from '../../models';
|
|
2
|
-
import { TreeViewItemId } from '../../../models';
|
|
3
|
-
export interface UseTreeViewIdInstance {
|
|
4
|
-
/**
|
|
5
|
-
* Get the id attribute (i.e.: the `id` attribute passed to the DOM element) of a tree item.
|
|
6
|
-
* If the user explicitly defined an id attribute, it will be returned.
|
|
7
|
-
* Otherwise, the method created a unique id for the item based on the Tree View id attribute and the item `itemId`
|
|
8
|
-
* @param {TreeViewItemId} itemId The id of the item to get the id attribute of.
|
|
9
|
-
* @param {string | undefined} idAttribute The id attribute of the item if explicitly defined by the user.
|
|
10
|
-
* @returns {string} The id attribute of the item.
|
|
11
|
-
*/
|
|
12
|
-
getTreeItemIdAttribute: (itemId: TreeViewItemId, idAttribute: string | undefined) => string;
|
|
13
|
-
}
|
|
14
2
|
export interface UseTreeViewIdParameters {
|
|
15
3
|
/**
|
|
16
4
|
* This prop is used to help implement the accessibility logic.
|
|
@@ -19,8 +7,18 @@ export interface UseTreeViewIdParameters {
|
|
|
19
7
|
id?: string;
|
|
20
8
|
}
|
|
21
9
|
export type UseTreeViewIdDefaultizedParameters = UseTreeViewIdParameters;
|
|
10
|
+
export interface UseTreeViewIdState {
|
|
11
|
+
id: {
|
|
12
|
+
treeId: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
interface UseTreeViewIdContextValue {
|
|
16
|
+
treeId: string | undefined;
|
|
17
|
+
}
|
|
22
18
|
export type UseTreeViewIdSignature = TreeViewPluginSignature<{
|
|
23
19
|
params: UseTreeViewIdParameters;
|
|
24
20
|
defaultizedParams: UseTreeViewIdDefaultizedParameters;
|
|
25
|
-
|
|
21
|
+
state: UseTreeViewIdState;
|
|
22
|
+
contextValue: UseTreeViewIdContextValue;
|
|
26
23
|
}>;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { TreeViewItemId } from '../../../models';
|
|
2
|
+
export declare const createTreeViewDefaultId: () => string;
|
|
3
|
+
/**
|
|
4
|
+
* Generate the id attribute (i.e.: the `id` attribute passed to the DOM element) of a tree item.
|
|
5
|
+
* If the user explicitly defined an id attribute, it will be returned.
|
|
6
|
+
* Otherwise, the method creates a unique id for the item based on the Tree View id attribute and the item `itemId`
|
|
7
|
+
* @param {object} params The parameters to determine the id attribute of the item.
|
|
8
|
+
* @param {TreeViewItemId} params.itemId The id of the item to get the id attribute of.
|
|
9
|
+
* @param {string | undefined} params.idAttribute The id attribute of the item if explicitly defined by the user.
|
|
10
|
+
* @param {string} params.treeId The id attribute of the Tree View.
|
|
11
|
+
* @returns {string} The id attribute of the item.
|
|
12
|
+
*/
|
|
13
|
+
export declare const generateTreeItemIdAttribute: ({ id, treeId, itemId, }: {
|
|
14
|
+
id: TreeViewItemId | undefined;
|
|
15
|
+
treeId: string | undefined;
|
|
16
|
+
itemId: string;
|
|
17
|
+
}) => string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
let globalTreeViewDefaultId = 0;
|
|
2
|
+
export const createTreeViewDefaultId = () => {
|
|
3
|
+
globalTreeViewDefaultId += 1;
|
|
4
|
+
return `mui-tree-view-${globalTreeViewDefaultId}`;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Generate the id attribute (i.e.: the `id` attribute passed to the DOM element) of a tree item.
|
|
9
|
+
* If the user explicitly defined an id attribute, it will be returned.
|
|
10
|
+
* Otherwise, the method creates a unique id for the item based on the Tree View id attribute and the item `itemId`
|
|
11
|
+
* @param {object} params The parameters to determine the id attribute of the item.
|
|
12
|
+
* @param {TreeViewItemId} params.itemId The id of the item to get the id attribute of.
|
|
13
|
+
* @param {string | undefined} params.idAttribute The id attribute of the item if explicitly defined by the user.
|
|
14
|
+
* @param {string} params.treeId The id attribute of the Tree View.
|
|
15
|
+
* @returns {string} The id attribute of the item.
|
|
16
|
+
*/
|
|
17
|
+
export const generateTreeItemIdAttribute = ({
|
|
18
|
+
id,
|
|
19
|
+
treeId = '',
|
|
20
|
+
itemId
|
|
21
|
+
}) => {
|
|
22
|
+
if (id != null) {
|
|
23
|
+
return id;
|
|
24
|
+
}
|
|
25
|
+
return `${treeId}-${itemId}`;
|
|
26
|
+
};
|
|
@@ -138,7 +138,10 @@ export type TreeRootWrapper<TSignatures extends readonly TreeViewAnyPluginSignat
|
|
|
138
138
|
}) => React.ReactNode;
|
|
139
139
|
export type TreeViewPlugin<TSignature extends TreeViewAnyPluginSignature> = {
|
|
140
140
|
(options: TreeViewPluginOptions<TSignature>): TreeViewResponse<TSignature>;
|
|
141
|
-
getDefaultizedParams?: (
|
|
141
|
+
getDefaultizedParams?: (options: {
|
|
142
|
+
params: TreeViewUsedParams<TSignature>;
|
|
143
|
+
experimentalFeatures: TreeViewUsedExperimentalFeatures<TSignature>;
|
|
144
|
+
}) => TSignature['defaultizedParams'];
|
|
142
145
|
getInitialState?: (params: TreeViewUsedDefaultizedParams<TSignature>) => TSignature['state'];
|
|
143
146
|
models?: TreeViewModelsInitializer<TSignature>;
|
|
144
147
|
params: Record<keyof TSignature['params'], true>;
|
|
@@ -86,7 +86,9 @@ useTreeViewExpansion.models = {
|
|
|
86
86
|
}
|
|
87
87
|
};
|
|
88
88
|
const DEFAULT_EXPANDED_ITEMS = [];
|
|
89
|
-
useTreeViewExpansion.getDefaultizedParams =
|
|
89
|
+
useTreeViewExpansion.getDefaultizedParams = ({
|
|
90
|
+
params
|
|
91
|
+
}) => _extends({}, params, {
|
|
90
92
|
defaultExpandedItems: params.defaultExpandedItems ?? DEFAULT_EXPANDED_ITEMS
|
|
91
93
|
});
|
|
92
94
|
useTreeViewExpansion.params = {
|
|
@@ -64,7 +64,7 @@ export const useTreeViewFocus = ({
|
|
|
64
64
|
}
|
|
65
65
|
const itemMeta = instance.getItemMeta(state.focusedItemId);
|
|
66
66
|
if (itemMeta) {
|
|
67
|
-
const itemElement =
|
|
67
|
+
const itemElement = instance.getItemDOMElement(state.focusedItemId);
|
|
68
68
|
if (itemElement) {
|
|
69
69
|
itemElement.blur();
|
|
70
70
|
}
|
|
@@ -5,6 +5,7 @@ import * as React from 'react';
|
|
|
5
5
|
import { publishTreeViewEvent } from "../../utils/publishTreeViewEvent.js";
|
|
6
6
|
import { buildSiblingIndexes, TREE_VIEW_ROOT_PARENT_ID } from "./useTreeViewItems.utils.js";
|
|
7
7
|
import { TreeViewItemDepthContext } from "../../TreeViewItemDepthContext/index.js";
|
|
8
|
+
import { generateTreeItemIdAttribute } from "../../corePlugins/useTreeViewId/useTreeViewId.utils.js";
|
|
8
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
10
|
const updateItemsState = ({
|
|
10
11
|
items,
|
|
@@ -110,7 +111,11 @@ export const useTreeViewItems = ({
|
|
|
110
111
|
if (itemMeta == null) {
|
|
111
112
|
return null;
|
|
112
113
|
}
|
|
113
|
-
return document.getElementById(
|
|
114
|
+
return document.getElementById(generateTreeItemIdAttribute({
|
|
115
|
+
treeId: state.id.treeId,
|
|
116
|
+
itemId,
|
|
117
|
+
id: itemMeta.idAttribute
|
|
118
|
+
}));
|
|
114
119
|
};
|
|
115
120
|
const isItemNavigable = itemId => {
|
|
116
121
|
if (params.disabledItemsFocusable) {
|
|
@@ -200,7 +205,9 @@ useTreeViewItems.getInitialState = params => ({
|
|
|
200
205
|
getItemLabel: params.getItemLabel
|
|
201
206
|
})
|
|
202
207
|
});
|
|
203
|
-
useTreeViewItems.getDefaultizedParams =
|
|
208
|
+
useTreeViewItems.getDefaultizedParams = ({
|
|
209
|
+
params
|
|
210
|
+
}) => _extends({}, params, {
|
|
204
211
|
disabledItemsFocusable: params.disabledItemsFocusable ?? false,
|
|
205
212
|
itemChildrenIndentation: params.itemChildrenIndentation ?? '12px'
|
|
206
213
|
});
|