@mui/x-tree-view 7.9.0 → 7.11.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 +159 -0
- package/RichTreeView/RichTreeView.js +2 -0
- package/SimpleTreeView/SimpleTreeView.js +2 -0
- package/TreeItem2/TreeItem2.d.ts +1 -1
- package/TreeView/TreeView.js +2 -0
- package/index.js +1 -1
- package/internals/corePlugins/corePlugins.d.ts +1 -1
- package/internals/corePlugins/corePlugins.js +2 -1
- package/internals/corePlugins/useTreeViewInstanceEvents/useTreeViewInstanceEvents.js +1 -1
- package/internals/corePlugins/useTreeViewOptionalPlugins/index.d.ts +2 -0
- package/internals/corePlugins/useTreeViewOptionalPlugins/index.js +1 -0
- package/internals/corePlugins/useTreeViewOptionalPlugins/useTreeViewOptionalPlugins.d.ts +3 -0
- package/internals/corePlugins/useTreeViewOptionalPlugins/useTreeViewOptionalPlugins.js +12 -0
- package/internals/corePlugins/useTreeViewOptionalPlugins/useTreeViewOptionalPlugins.types.d.ts +8 -0
- package/internals/corePlugins/useTreeViewOptionalPlugins/useTreeViewOptionalPlugins.types.js +1 -0
- package/internals/models/plugin.d.ts +1 -0
- package/internals/plugins/useTreeViewItems/useTreeViewItems.js +19 -3
- package/internals/plugins/useTreeViewItems/useTreeViewItems.types.d.ts +13 -8
- package/internals/useTreeView/useTreeView.js +9 -63
- package/internals/useTreeView/useTreeViewBuildContext.d.ts +10 -0
- package/internals/useTreeView/useTreeViewBuildContext.js +73 -0
- package/internals/useTreeView/useTreeViewPlugins.d.ts +0 -0
- package/internals/useTreeView/useTreeViewPlugins.js +0 -0
- package/internals/utils/plugins.d.ts +2 -0
- package/internals/utils/plugins.js +4 -0
- package/modern/RichTreeView/RichTreeView.js +2 -0
- package/modern/SimpleTreeView/SimpleTreeView.js +2 -0
- package/modern/TreeView/TreeView.js +2 -0
- package/modern/index.js +1 -1
- package/modern/internals/corePlugins/corePlugins.js +2 -1
- package/modern/internals/corePlugins/useTreeViewInstanceEvents/useTreeViewInstanceEvents.js +1 -1
- package/modern/internals/corePlugins/useTreeViewOptionalPlugins/index.js +1 -0
- package/modern/internals/corePlugins/useTreeViewOptionalPlugins/useTreeViewOptionalPlugins.js +12 -0
- package/modern/internals/corePlugins/useTreeViewOptionalPlugins/useTreeViewOptionalPlugins.types.js +1 -0
- package/modern/internals/plugins/useTreeViewItems/useTreeViewItems.js +19 -3
- package/modern/internals/useTreeView/useTreeView.js +9 -63
- package/modern/internals/useTreeView/useTreeViewBuildContext.js +73 -0
- package/modern/internals/useTreeView/useTreeViewPlugins.js +0 -0
- package/modern/internals/utils/plugins.js +4 -0
- package/node/RichTreeView/RichTreeView.js +2 -0
- package/node/SimpleTreeView/SimpleTreeView.js +2 -0
- package/node/TreeView/TreeView.js +2 -0
- package/node/index.js +1 -1
- package/node/internals/corePlugins/corePlugins.js +2 -1
- package/node/internals/corePlugins/useTreeViewInstanceEvents/useTreeViewInstanceEvents.js +1 -1
- package/node/internals/corePlugins/useTreeViewOptionalPlugins/index.js +12 -0
- package/node/internals/corePlugins/useTreeViewOptionalPlugins/useTreeViewOptionalPlugins.js +19 -0
- package/node/internals/corePlugins/useTreeViewOptionalPlugins/useTreeViewOptionalPlugins.types.js +5 -0
- package/node/internals/plugins/useTreeViewItems/useTreeViewItems.js +19 -3
- package/node/internals/useTreeView/useTreeView.js +9 -63
- package/node/internals/useTreeView/useTreeViewBuildContext.js +80 -0
- package/node/internals/useTreeView/useTreeViewPlugins.js +1 -0
- package/node/internals/utils/plugins.js +11 -0
- package/package.json +6 -5
- package/internals/utils/EventManager.d.ts +0 -29
- package/internals/utils/EventManager.js +0 -69
- package/modern/internals/utils/EventManager.js +0 -69
- package/node/internals/utils/EventManager.js +0 -76
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,165 @@
|
|
|
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.11.0
|
|
7
|
+
|
|
8
|
+
_Jul 18, 2024_
|
|
9
|
+
|
|
10
|
+
We'd like to offer a big thanks to the 13 contributors who made this release possible. Here are some highlights ✨:
|
|
11
|
+
|
|
12
|
+
- 🎨 Add [color legend](https://mui.com/x/react-charts/legend/#color-legend) for charts (#13700) @alexfauquette
|
|
13
|
+
- 🌍 Improve Korean (ko-KR) locale on the Date and Time Pickers
|
|
14
|
+
- 🌍 Improve Russian (ru-RU) locale on the Date and Time Pickers and Data Grid
|
|
15
|
+
- 🐞 Bugfixes
|
|
16
|
+
- 📚 Documentation improvements
|
|
17
|
+
|
|
18
|
+
<!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
|
|
19
|
+
|
|
20
|
+
### Data Grid
|
|
21
|
+
|
|
22
|
+
#### `@mui/x-data-grid@7.11.0`
|
|
23
|
+
|
|
24
|
+
- [DataGrid] Expose `gridEditRowsStateSelector` (#13877) @romgrk
|
|
25
|
+
- [DataGrid] Fix `columnResizeStop` event not emitted when column is not resized (#13307) @mateuseap
|
|
26
|
+
- [DataGrid] Fix delete filter inconsistent behavior (#13353) @oukunan
|
|
27
|
+
- [DataGrid] Enable flip on preferences panel (#13803) @romgrk
|
|
28
|
+
- [DataGrid] Support `date` and `datetime-local` input types in `GridFilterInputMultipleValue` type (#13411) @karudedios
|
|
29
|
+
- [l10n] Improve Russian (ru-RU) locale (#13735) @diro-atk
|
|
30
|
+
|
|
31
|
+
#### `@mui/x-data-grid-pro@7.11.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
32
|
+
|
|
33
|
+
Same changes as in `@mui/x-data-grid@7.11.0`.
|
|
34
|
+
|
|
35
|
+
#### `@mui/x-data-grid-premium@7.11.0` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
36
|
+
|
|
37
|
+
Same changes as in `@mui/x-data-grid-pro@7.11.0`.
|
|
38
|
+
|
|
39
|
+
### Date and Time Pickers
|
|
40
|
+
|
|
41
|
+
#### `@mui/x-date-pickers@7.11.0`
|
|
42
|
+
|
|
43
|
+
- [l10n] Improve Korean (ko-KR) locale (#13651) @100pearlcent
|
|
44
|
+
- [l10n] Improve Russian (ru-RU) locale (#13871) @Inv1x
|
|
45
|
+
- [pickers] Add more conformance tests improving API docs precision (#13800) @LukasTy
|
|
46
|
+
- [TimePicker] Add `Mui-selected` class to `TimeClock` meridiem buttons (#13848) @LukasTy
|
|
47
|
+
|
|
48
|
+
#### `@mui/x-date-pickers-pro@7.11.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
49
|
+
|
|
50
|
+
Same changes as in `@mui/x-date-pickers@7.11.0`, plus:
|
|
51
|
+
|
|
52
|
+
- [DateRangePicker] Fix `name` prop propagation regression (#13821) @LukasTy
|
|
53
|
+
|
|
54
|
+
### Charts
|
|
55
|
+
|
|
56
|
+
#### `@mui/x-charts@7.11.0`
|
|
57
|
+
|
|
58
|
+
- [charts] Create color legend (#13700) @alexfauquette
|
|
59
|
+
- [charts] Defaultize axis on top level `useChartContainerProps` (#13817) @JCQuintas
|
|
60
|
+
- [charts] Fix charts not passing `className` to root element (#13647) @JCQuintas
|
|
61
|
+
- [charts] Generate API documentation for pro components (#13822) @alexfauquette
|
|
62
|
+
- [charts] Improve zoomed highlight behaviour (unreleased) (#13868) @JCQuintas
|
|
63
|
+
- [charts] Allow zoom on Y axis and add zoom options to configure zooming behaviour (unreleased) (#13726) @JCQuintas
|
|
64
|
+
- [charts] Disable animations while zooming (unreleased) (#13807) @JCQuintas
|
|
65
|
+
|
|
66
|
+
### Tree View
|
|
67
|
+
|
|
68
|
+
#### `@mui/x-tree-view@7.11.0`
|
|
69
|
+
|
|
70
|
+
- [TreeView] Extract some logic outside of the `useTreeView` hook (#13845) @flaviendelangle
|
|
71
|
+
|
|
72
|
+
### Docs
|
|
73
|
+
|
|
74
|
+
- [docs] Add warning about `process.env.NODE_ENV` in production (#13869) @cherniavskii
|
|
75
|
+
- [docs] Allow controlling the demo form from the example (#13796) @JCQuintas
|
|
76
|
+
- [docs] Clarify Pickers clearable behavior not working on mobile (#13786) @lnhrdt
|
|
77
|
+
- [docs] Improve the documentation of the picker's `onChange` and `onAccept` props (#13543) @flaviendelangle
|
|
78
|
+
- [docs] Replace company name with project name @oliviertassinari
|
|
79
|
+
- [docs] Sort Pickers & Charts API slots alphabetically (#13843) @LukasTy
|
|
80
|
+
|
|
81
|
+
### Core
|
|
82
|
+
|
|
83
|
+
- [core] Add MUI Internal `renovate` group (#13846) @LukasTy
|
|
84
|
+
- [core] Link GitHub issue for `import/prefer-default-export` rule @oliviertassinari
|
|
85
|
+
- [core] Normalize `...other` and test imports in charts (#13844) @JCQuintas
|
|
86
|
+
- [core] Normalize rest / other to match the most common used @oliviertassinari
|
|
87
|
+
- [code-infra] Follow `next` tag for `@mui/docs` package bumps (#13813) @LukasTy
|
|
88
|
+
- [code-infra] Use specific version for `@mui/docs` dependency (#13760) @LukasTy
|
|
89
|
+
- [internals] Move `EventManager` to `@mui/x-internals` package (#13815) @flaviendelangle
|
|
90
|
+
|
|
91
|
+
## 7.10.0
|
|
92
|
+
|
|
93
|
+
_Jul 11, 2024_
|
|
94
|
+
|
|
95
|
+
We'd like to offer a big thanks to the 12 contributors who made this release possible. Here are some highlights ✨:
|
|
96
|
+
|
|
97
|
+
- 🎁 Add selectors to support showing child row count in footer in the Data Grid
|
|
98
|
+
- ✨ New APIs for retrieving current item tree and item's children IDs in the Tree View
|
|
99
|
+
- 🌍 Improve Spanish (es-ES) locale on the Data Grid
|
|
100
|
+
- 🐞 Bugfixes
|
|
101
|
+
- 📚 Documentation improvements
|
|
102
|
+
|
|
103
|
+
<!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
|
|
104
|
+
|
|
105
|
+
### Data Grid
|
|
106
|
+
|
|
107
|
+
#### `@mui/x-data-grid@7.10.0`
|
|
108
|
+
|
|
109
|
+
- [DataGrid] Add selectors to support showing child row count in footer (#13725) @KenanYusuf
|
|
110
|
+
- [DataGrid] Fix incorrect panels position when using a toolbar (#13474) @oukunan
|
|
111
|
+
- [DataGrid] Set default variant to `'standard'` in `GridFilterInputMultipleValue` (#13129) @tarunrajput
|
|
112
|
+
- [DataGrid] Use `readonly` on more array props (#13331) @pcorpet
|
|
113
|
+
- [l10n] Improve Spanish (es-ES) locale (#13772) @joserealdev
|
|
114
|
+
|
|
115
|
+
#### `@mui/x-data-grid-pro@7.10.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
116
|
+
|
|
117
|
+
Same changes as in `@mui/x-data-grid@7.10.0`, plus:
|
|
118
|
+
|
|
119
|
+
- [DataGridPro] Keep bottom pinned row at the bottom (#13313) @romgrk
|
|
120
|
+
|
|
121
|
+
#### `@mui/x-data-grid-premium@7.10.0` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
122
|
+
|
|
123
|
+
Same changes as in `@mui/x-data-grid-pro@7.10.0`.
|
|
124
|
+
|
|
125
|
+
### Date and Time Pickers
|
|
126
|
+
|
|
127
|
+
#### `@mui/x-date-pickers@7.10.0`
|
|
128
|
+
|
|
129
|
+
- [fields] Prevent infinite recursion when ensuring selection (#13779) @LukasTy
|
|
130
|
+
- [fields] Unify fields behavior regardless of the `readOnly` flag (#13688) @LukasTy
|
|
131
|
+
|
|
132
|
+
#### `@mui/x-date-pickers-pro@7.10.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
133
|
+
|
|
134
|
+
Same changes as in `@mui/x-date-pickers@7.10.0`, plus:
|
|
135
|
+
|
|
136
|
+
- [DateRangePicker] Fix `calendarHeader` slot props propagation (#13780) @LukasTy
|
|
137
|
+
- [DateTimeRangePicker] Resolve `format` from given `views` (#13743) @LukasTy
|
|
138
|
+
|
|
139
|
+
### Charts
|
|
140
|
+
|
|
141
|
+
#### `@mui/x-charts@7.10.0`
|
|
142
|
+
|
|
143
|
+
- [charts] Fix displaying area of a `LineChart` when using the `log` scale (#13791) @alexfauquette
|
|
144
|
+
- [charts] Use correct click handler prop on pie chart `OnSeriesItemClick` documentation (#13761) @tonyhallett
|
|
145
|
+
|
|
146
|
+
### Tree View
|
|
147
|
+
|
|
148
|
+
#### `@mui/x-tree-view@7.10.0`
|
|
149
|
+
|
|
150
|
+
- [TreeView] Add `getItemTree` and `getItemOrderedChildrenIds` methods to the public API (#13804) @flaviendelangle
|
|
151
|
+
- [TreeView] Add utility function to check if an optional plugin is present (#13788) @flaviendelangle
|
|
152
|
+
|
|
153
|
+
### Docs
|
|
154
|
+
|
|
155
|
+
- [docs] Add missing default `loading` prop value (#13604) @oliviertassinari
|
|
156
|
+
- [docs] Add the `DateTimeRangePicker` to the "Commonly used components" demo (#13775) @flaviendelangle
|
|
157
|
+
- [docs] Fix Pickers customization playground overflow (#13742) @LukasTy
|
|
158
|
+
- [docs] Move Pickers dialog guidelines to accessibility page (#13778) @arthurbalduini
|
|
159
|
+
|
|
160
|
+
### Core
|
|
161
|
+
|
|
162
|
+
- [core] Sort `DATA_GRID_PROPS_DEFAULT_VALUES` alphabetically (#13783) @oliviertassinari
|
|
163
|
+
- [test] Fix split infinitive use in tests @oliviertassinari
|
|
164
|
+
|
|
6
165
|
## 7.9.0
|
|
7
166
|
|
|
8
167
|
_Jul 5, 2024_
|
|
@@ -138,6 +138,8 @@ process.env.NODE_ENV !== "production" ? RichTreeView.propTypes = {
|
|
|
138
138
|
focusItem: PropTypes.func.isRequired,
|
|
139
139
|
getItem: PropTypes.func.isRequired,
|
|
140
140
|
getItemDOMElement: PropTypes.func.isRequired,
|
|
141
|
+
getItemOrderedChildrenIds: PropTypes.func.isRequired,
|
|
142
|
+
getItemTree: PropTypes.func.isRequired,
|
|
141
143
|
selectItem: PropTypes.func.isRequired,
|
|
142
144
|
setItemExpansion: PropTypes.func.isRequired
|
|
143
145
|
})
|
|
@@ -96,6 +96,8 @@ process.env.NODE_ENV !== "production" ? SimpleTreeView.propTypes = {
|
|
|
96
96
|
focusItem: PropTypes.func.isRequired,
|
|
97
97
|
getItem: PropTypes.func.isRequired,
|
|
98
98
|
getItemDOMElement: PropTypes.func.isRequired,
|
|
99
|
+
getItemOrderedChildrenIds: PropTypes.func.isRequired,
|
|
100
|
+
getItemTree: PropTypes.func.isRequired,
|
|
99
101
|
selectItem: PropTypes.func.isRequired,
|
|
100
102
|
setItemExpansion: PropTypes.func.isRequired
|
|
101
103
|
})
|
package/TreeItem2/TreeItem2.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export declare const TreeItem2GroupTransition: import("@emotion/styled").StyledC
|
|
|
14
14
|
}, {}, {}>;
|
|
15
15
|
export declare const TreeItem2Checkbox: import("@emotion/styled").StyledComponent<Pick<Omit<CheckboxProps & {
|
|
16
16
|
visible: boolean;
|
|
17
|
-
}, "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" | "
|
|
17
|
+
}, "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/createStyled").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {}>;
|
|
18
18
|
type TreeItem2Component = ((props: TreeItem2Props & React.RefAttributes<HTMLLIElement>) => React.JSX.Element) & {
|
|
19
19
|
propTypes?: any;
|
|
20
20
|
};
|
package/TreeView/TreeView.js
CHANGED
|
@@ -73,6 +73,8 @@ process.env.NODE_ENV !== "production" ? TreeView.propTypes = {
|
|
|
73
73
|
focusItem: PropTypes.func.isRequired,
|
|
74
74
|
getItem: PropTypes.func.isRequired,
|
|
75
75
|
getItemDOMElement: PropTypes.func.isRequired,
|
|
76
|
+
getItemOrderedChildrenIds: PropTypes.func.isRequired,
|
|
77
|
+
getItemTree: PropTypes.func.isRequired,
|
|
76
78
|
selectItem: PropTypes.func.isRequired,
|
|
77
79
|
setItemExpansion: PropTypes.func.isRequired
|
|
78
80
|
})
|
package/index.js
CHANGED
|
@@ -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("../models").TreeViewPlugin<import("./useTreeViewInstanceEvents").UseTreeViewInstanceEventsSignature>, import("../models").TreeViewPlugin<import("./useTreeViewId").UseTreeViewIdSignature>];
|
|
7
|
+
export declare const TREE_VIEW_CORE_PLUGINS: readonly [import("../models").TreeViewPlugin<import("./useTreeViewInstanceEvents").UseTreeViewInstanceEventsSignature>, import("../models").TreeViewPlugin<import("./useTreeViewOptionalPlugins").UseTreeViewOptionalPluginsSignature>, import("../models").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,7 +1,8 @@
|
|
|
1
1
|
import { useTreeViewInstanceEvents } from './useTreeViewInstanceEvents';
|
|
2
|
+
import { useTreeViewOptionalPlugins } from './useTreeViewOptionalPlugins';
|
|
2
3
|
import { useTreeViewId } from './useTreeViewId';
|
|
3
4
|
/**
|
|
4
5
|
* Internal plugins that create the tools used by the other plugins.
|
|
5
6
|
* These plugins are used by the tree view components.
|
|
6
7
|
*/
|
|
7
|
-
export const TREE_VIEW_CORE_PLUGINS = [useTreeViewInstanceEvents, useTreeViewId];
|
|
8
|
+
export const TREE_VIEW_CORE_PLUGINS = [useTreeViewInstanceEvents, useTreeViewOptionalPlugins, useTreeViewId];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useTreeViewOptionalPlugins } from './useTreeViewOptionalPlugins';
|
package/internals/corePlugins/useTreeViewOptionalPlugins/useTreeViewOptionalPlugins.types.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TreeViewPlugin, TreeViewAnyPluginSignature, TreeViewPluginSignature } from '../../models';
|
|
2
|
+
interface UseTreeViewOptionalPluginsInstance {
|
|
3
|
+
getAvailablePlugins: () => Set<TreeViewPlugin<TreeViewAnyPluginSignature>>;
|
|
4
|
+
}
|
|
5
|
+
export type UseTreeViewOptionalPluginsSignature = TreeViewPluginSignature<{
|
|
6
|
+
instance: UseTreeViewOptionalPluginsInstance;
|
|
7
|
+
}>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -15,6 +15,7 @@ export interface TreeViewPluginOptions<TSignature extends TreeViewAnyPluginSigna
|
|
|
15
15
|
models: TreeViewUsedModels<TSignature>;
|
|
16
16
|
setState: React.Dispatch<React.SetStateAction<TreeViewUsedState<TSignature>>>;
|
|
17
17
|
rootRef: React.RefObject<HTMLUListElement>;
|
|
18
|
+
plugins: TreeViewPlugin<TreeViewAnyPluginSignature>[];
|
|
18
19
|
}
|
|
19
20
|
type TreeViewModelsInitializer<TSignature extends TreeViewAnyPluginSignature> = {
|
|
20
21
|
[TControlled in keyof TSignature['models']]: {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["children"];
|
|
2
4
|
import * as React from 'react';
|
|
3
5
|
import { publishTreeViewEvent } from '../../utils/publishTreeViewEvent';
|
|
4
6
|
import { buildSiblingIndexes, TREE_VIEW_ROOT_PARENT_ID } from './useTreeViewItems.utils';
|
|
@@ -37,7 +39,6 @@ const updateItemsState = ({
|
|
|
37
39
|
depth
|
|
38
40
|
};
|
|
39
41
|
itemMap[id] = item;
|
|
40
|
-
itemOrderedChildrenIds[id] = [];
|
|
41
42
|
const parentIdWithDefault = parentId ?? TREE_VIEW_ROOT_PARENT_ID;
|
|
42
43
|
if (!itemOrderedChildrenIds[parentIdWithDefault]) {
|
|
43
44
|
itemOrderedChildrenIds[parentIdWithDefault] = [];
|
|
@@ -66,6 +67,18 @@ export const useTreeViewItems = ({
|
|
|
66
67
|
}) => {
|
|
67
68
|
const getItemMeta = React.useCallback(itemId => state.items.itemMetaMap[itemId], [state.items.itemMetaMap]);
|
|
68
69
|
const getItem = React.useCallback(itemId => state.items.itemMap[itemId], [state.items.itemMap]);
|
|
70
|
+
const getItemTree = React.useCallback(() => {
|
|
71
|
+
const getItemFromItemId = id => {
|
|
72
|
+
const _state$items$itemMap$ = state.items.itemMap[id],
|
|
73
|
+
item = _objectWithoutPropertiesLoose(_state$items$itemMap$, _excluded);
|
|
74
|
+
const newChildren = state.items.itemOrderedChildrenIds[id];
|
|
75
|
+
if (newChildren) {
|
|
76
|
+
item.children = newChildren.map(getItemFromItemId);
|
|
77
|
+
}
|
|
78
|
+
return item;
|
|
79
|
+
};
|
|
80
|
+
return state.items.itemOrderedChildrenIds[TREE_VIEW_ROOT_PARENT_ID].map(getItemFromItemId);
|
|
81
|
+
}, [state.items.itemMap, state.items.itemOrderedChildrenIds]);
|
|
69
82
|
const isItemDisabled = React.useCallback(itemId => {
|
|
70
83
|
if (itemId == null) {
|
|
71
84
|
return false;
|
|
@@ -140,7 +153,7 @@ export const useTreeViewItems = ({
|
|
|
140
153
|
label: item.label,
|
|
141
154
|
itemId: item.id,
|
|
142
155
|
id: item.idAttribute,
|
|
143
|
-
children: state.items.itemOrderedChildrenIds[id]
|
|
156
|
+
children: state.items.itemOrderedChildrenIds[id]?.map(getPropsFromItemId)
|
|
144
157
|
};
|
|
145
158
|
};
|
|
146
159
|
return state.items.itemOrderedChildrenIds[TREE_VIEW_ROOT_PARENT_ID].map(getPropsFromItemId);
|
|
@@ -153,11 +166,14 @@ export const useTreeViewItems = ({
|
|
|
153
166
|
}),
|
|
154
167
|
publicAPI: {
|
|
155
168
|
getItem,
|
|
156
|
-
getItemDOMElement
|
|
169
|
+
getItemDOMElement,
|
|
170
|
+
getItemTree,
|
|
171
|
+
getItemOrderedChildrenIds
|
|
157
172
|
},
|
|
158
173
|
instance: {
|
|
159
174
|
getItemMeta,
|
|
160
175
|
getItem,
|
|
176
|
+
getItemTree,
|
|
161
177
|
getItemsToRender,
|
|
162
178
|
getItemIndex,
|
|
163
179
|
getItemDOMElement,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TreeViewItemMeta, DefaultizedProps, TreeViewPluginSignature } from '../../models';
|
|
2
|
-
import { TreeViewItemId } from '../../../models';
|
|
2
|
+
import { TreeViewBaseItem, TreeViewItemId } from '../../../models';
|
|
3
3
|
interface TreeViewItemProps {
|
|
4
4
|
label: string;
|
|
5
5
|
itemId: string;
|
|
@@ -20,6 +20,18 @@ export interface UseTreeViewItemsPublicAPI<R extends {}> {
|
|
|
20
20
|
* @returns {HTMLElement | null} The DOM element of the item with the given id.
|
|
21
21
|
*/
|
|
22
22
|
getItemDOMElement: (itemId: TreeViewItemId) => HTMLElement | null;
|
|
23
|
+
/**
|
|
24
|
+
* Get the ids of a given item's children.
|
|
25
|
+
* Those ids are returned in the order they should be rendered.
|
|
26
|
+
* @param {TreeViewItemId | null} itemId The id of the item to get the children of.
|
|
27
|
+
* @returns {TreeViewItemId[]} The ids of the item's children.
|
|
28
|
+
*/
|
|
29
|
+
getItemOrderedChildrenIds: (itemId: TreeViewItemId | null) => TreeViewItemId[];
|
|
30
|
+
/**
|
|
31
|
+
* Get all the items in the same format as provided by `props.items`.
|
|
32
|
+
* @returns {TreeViewItemProps[]} The items in the tree.
|
|
33
|
+
*/
|
|
34
|
+
getItemTree: () => TreeViewBaseItem[];
|
|
23
35
|
}
|
|
24
36
|
export interface UseTreeViewItemsInstance<R extends {}> extends UseTreeViewItemsPublicAPI<R> {
|
|
25
37
|
/**
|
|
@@ -36,13 +48,6 @@ export interface UseTreeViewItemsInstance<R extends {}> extends UseTreeViewItems
|
|
|
36
48
|
* @returns {TreeViewItemProps[]} The items to render.
|
|
37
49
|
*/
|
|
38
50
|
getItemsToRender: () => TreeViewItemProps[];
|
|
39
|
-
/**
|
|
40
|
-
* Get the ids of a given item's children.
|
|
41
|
-
* Those ids are returned in the order they should be rendered.
|
|
42
|
-
* @param {TreeViewItemId | null} itemId The id of the item to get the children of.
|
|
43
|
-
* @returns {TreeViewItemId[]} The ids of the item's children.
|
|
44
|
-
*/
|
|
45
|
-
getItemOrderedChildrenIds: (itemId: TreeViewItemId | null) => TreeViewItemId[];
|
|
46
51
|
/**
|
|
47
52
|
* Check if a given item is disabled.
|
|
48
53
|
* An item is disabled if it was marked as disabled or if one of its ancestors is disabled.
|
|
@@ -4,6 +4,7 @@ import useForkRef from '@mui/utils/useForkRef';
|
|
|
4
4
|
import { useTreeViewModels } from './useTreeViewModels';
|
|
5
5
|
import { TREE_VIEW_CORE_PLUGINS } from '../corePlugins';
|
|
6
6
|
import { extractPluginParamsFromProps } from './extractPluginParamsFromProps';
|
|
7
|
+
import { useTreeViewBuildContext } from './useTreeViewBuildContext';
|
|
7
8
|
export function useTreeViewApiInitialization(inputApiRef) {
|
|
8
9
|
const fallbackPublicApiRef = React.useRef({});
|
|
9
10
|
if (inputApiRef) {
|
|
@@ -37,6 +38,12 @@ export const useTreeView = ({
|
|
|
37
38
|
const publicAPI = useTreeViewApiInitialization(apiRef);
|
|
38
39
|
const innerRootRef = React.useRef(null);
|
|
39
40
|
const handleRootRef = useForkRef(innerRootRef, rootRef);
|
|
41
|
+
const contextValue = useTreeViewBuildContext({
|
|
42
|
+
plugins,
|
|
43
|
+
instance,
|
|
44
|
+
publicAPI,
|
|
45
|
+
rootRef: innerRootRef
|
|
46
|
+
});
|
|
40
47
|
const [state, setState] = React.useState(() => {
|
|
41
48
|
const temp = {};
|
|
42
49
|
plugins.forEach(plugin => {
|
|
@@ -46,68 +53,6 @@ export const useTreeView = ({
|
|
|
46
53
|
});
|
|
47
54
|
return temp;
|
|
48
55
|
});
|
|
49
|
-
const itemWrappers = plugins.map(plugin => plugin.wrapItem).filter(wrapItem => !!wrapItem);
|
|
50
|
-
const wrapItem = ({
|
|
51
|
-
itemId,
|
|
52
|
-
children
|
|
53
|
-
}) => {
|
|
54
|
-
let finalChildren = children;
|
|
55
|
-
itemWrappers.forEach(itemWrapper => {
|
|
56
|
-
finalChildren = itemWrapper({
|
|
57
|
-
itemId,
|
|
58
|
-
children: finalChildren,
|
|
59
|
-
instance
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
return finalChildren;
|
|
63
|
-
};
|
|
64
|
-
const rootWrappers = plugins.map(plugin => plugin.wrapRoot).filter(wrapRoot => !!wrapRoot)
|
|
65
|
-
// The wrappers are reversed to ensure that the first wrapper is the outermost one.
|
|
66
|
-
.reverse();
|
|
67
|
-
const wrapRoot = ({
|
|
68
|
-
children
|
|
69
|
-
}) => {
|
|
70
|
-
let finalChildren = children;
|
|
71
|
-
rootWrappers.forEach(rootWrapper => {
|
|
72
|
-
finalChildren = rootWrapper({
|
|
73
|
-
children: finalChildren,
|
|
74
|
-
instance
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
return finalChildren;
|
|
78
|
-
};
|
|
79
|
-
const runItemPlugins = itemPluginProps => {
|
|
80
|
-
let finalRootRef = null;
|
|
81
|
-
let finalContentRef = null;
|
|
82
|
-
plugins.forEach(plugin => {
|
|
83
|
-
if (!plugin.itemPlugin) {
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
const itemPluginResponse = plugin.itemPlugin({
|
|
87
|
-
props: itemPluginProps,
|
|
88
|
-
rootRef: finalRootRef,
|
|
89
|
-
contentRef: finalContentRef
|
|
90
|
-
});
|
|
91
|
-
if (itemPluginResponse?.rootRef) {
|
|
92
|
-
finalRootRef = itemPluginResponse.rootRef;
|
|
93
|
-
}
|
|
94
|
-
if (itemPluginResponse?.contentRef) {
|
|
95
|
-
finalContentRef = itemPluginResponse.contentRef;
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
return {
|
|
99
|
-
contentRef: finalContentRef,
|
|
100
|
-
rootRef: finalRootRef
|
|
101
|
-
};
|
|
102
|
-
};
|
|
103
|
-
const contextValue = {
|
|
104
|
-
publicAPI,
|
|
105
|
-
wrapItem,
|
|
106
|
-
wrapRoot,
|
|
107
|
-
runItemPlugins,
|
|
108
|
-
instance: instance,
|
|
109
|
-
rootRef: innerRootRef
|
|
110
|
-
};
|
|
111
56
|
const rootPropsGetters = [];
|
|
112
57
|
const runPlugin = plugin => {
|
|
113
58
|
const pluginResponse = plugin({
|
|
@@ -119,7 +64,8 @@ export const useTreeView = ({
|
|
|
119
64
|
state,
|
|
120
65
|
setState,
|
|
121
66
|
rootRef: innerRootRef,
|
|
122
|
-
models
|
|
67
|
+
models,
|
|
68
|
+
plugins
|
|
123
69
|
});
|
|
124
70
|
if (pluginResponse.getRootProps) {
|
|
125
71
|
rootPropsGetters.push(pluginResponse.getRootProps);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { TreeViewContextValue } from '../TreeViewProvider';
|
|
3
|
+
import { ConvertSignaturesIntoPlugins, TreeViewAnyPluginSignature, TreeViewInstance, TreeViewPublicAPI } from '../models';
|
|
4
|
+
import { TreeViewCorePluginSignatures } from '../corePlugins';
|
|
5
|
+
export declare const useTreeViewBuildContext: <TSignatures extends readonly TreeViewAnyPluginSignature[]>({ plugins, instance, publicAPI, rootRef, }: {
|
|
6
|
+
plugins: ConvertSignaturesIntoPlugins<readonly [...TreeViewCorePluginSignatures, ...TSignatures]>;
|
|
7
|
+
instance: TreeViewInstance<TSignatures>;
|
|
8
|
+
publicAPI: TreeViewPublicAPI<TSignatures>;
|
|
9
|
+
rootRef: React.RefObject<HTMLUListElement>;
|
|
10
|
+
}) => TreeViewContextValue<TSignatures>;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
export const useTreeViewBuildContext = ({
|
|
2
|
+
plugins,
|
|
3
|
+
instance,
|
|
4
|
+
publicAPI,
|
|
5
|
+
rootRef
|
|
6
|
+
}) => {
|
|
7
|
+
const runItemPlugins = itemPluginProps => {
|
|
8
|
+
let finalRootRef = null;
|
|
9
|
+
let finalContentRef = null;
|
|
10
|
+
plugins.forEach(plugin => {
|
|
11
|
+
if (!plugin.itemPlugin) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const itemPluginResponse = plugin.itemPlugin({
|
|
15
|
+
props: itemPluginProps,
|
|
16
|
+
rootRef: finalRootRef,
|
|
17
|
+
contentRef: finalContentRef
|
|
18
|
+
});
|
|
19
|
+
if (itemPluginResponse?.rootRef) {
|
|
20
|
+
finalRootRef = itemPluginResponse.rootRef;
|
|
21
|
+
}
|
|
22
|
+
if (itemPluginResponse?.contentRef) {
|
|
23
|
+
finalContentRef = itemPluginResponse.contentRef;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
return {
|
|
27
|
+
contentRef: finalContentRef,
|
|
28
|
+
rootRef: finalRootRef
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
const wrapItem = ({
|
|
32
|
+
itemId,
|
|
33
|
+
children
|
|
34
|
+
}) => {
|
|
35
|
+
let finalChildren = children;
|
|
36
|
+
// The wrappers are reversed to ensure that the first wrapper is the outermost one.
|
|
37
|
+
for (let i = plugins.length - 1; i >= 0; i -= 1) {
|
|
38
|
+
const plugin = plugins[i];
|
|
39
|
+
if (plugin.wrapItem) {
|
|
40
|
+
finalChildren = plugin.wrapItem({
|
|
41
|
+
itemId,
|
|
42
|
+
children: finalChildren,
|
|
43
|
+
instance
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return finalChildren;
|
|
48
|
+
};
|
|
49
|
+
const wrapRoot = ({
|
|
50
|
+
children
|
|
51
|
+
}) => {
|
|
52
|
+
let finalChildren = children;
|
|
53
|
+
// The wrappers are reversed to ensure that the first wrapper is the outermost one.
|
|
54
|
+
for (let i = plugins.length - 1; i >= 0; i -= 1) {
|
|
55
|
+
const plugin = plugins[i];
|
|
56
|
+
if (plugin.wrapRoot) {
|
|
57
|
+
finalChildren = plugin.wrapRoot({
|
|
58
|
+
children: finalChildren,
|
|
59
|
+
instance
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return finalChildren;
|
|
64
|
+
};
|
|
65
|
+
return {
|
|
66
|
+
runItemPlugins,
|
|
67
|
+
wrapItem,
|
|
68
|
+
wrapRoot,
|
|
69
|
+
instance,
|
|
70
|
+
rootRef,
|
|
71
|
+
publicAPI
|
|
72
|
+
};
|
|
73
|
+
};
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { TreeViewAnyPluginSignature, TreeViewInstance, TreeViewPlugin } from '../models';
|
|
2
|
+
export declare const hasPlugin: <TSignature extends TreeViewAnyPluginSignature, TInstance extends TreeViewInstance<[], [TSignature]>>(instance: TInstance, plugin: TreeViewPlugin<TSignature>) => instance is Omit<TInstance, keyof TSignature["instance"]> & TSignature["instance"];
|
|
@@ -138,6 +138,8 @@ process.env.NODE_ENV !== "production" ? RichTreeView.propTypes = {
|
|
|
138
138
|
focusItem: PropTypes.func.isRequired,
|
|
139
139
|
getItem: PropTypes.func.isRequired,
|
|
140
140
|
getItemDOMElement: PropTypes.func.isRequired,
|
|
141
|
+
getItemOrderedChildrenIds: PropTypes.func.isRequired,
|
|
142
|
+
getItemTree: PropTypes.func.isRequired,
|
|
141
143
|
selectItem: PropTypes.func.isRequired,
|
|
142
144
|
setItemExpansion: PropTypes.func.isRequired
|
|
143
145
|
})
|
|
@@ -96,6 +96,8 @@ process.env.NODE_ENV !== "production" ? SimpleTreeView.propTypes = {
|
|
|
96
96
|
focusItem: PropTypes.func.isRequired,
|
|
97
97
|
getItem: PropTypes.func.isRequired,
|
|
98
98
|
getItemDOMElement: PropTypes.func.isRequired,
|
|
99
|
+
getItemOrderedChildrenIds: PropTypes.func.isRequired,
|
|
100
|
+
getItemTree: PropTypes.func.isRequired,
|
|
99
101
|
selectItem: PropTypes.func.isRequired,
|
|
100
102
|
setItemExpansion: PropTypes.func.isRequired
|
|
101
103
|
})
|
|
@@ -73,6 +73,8 @@ process.env.NODE_ENV !== "production" ? TreeView.propTypes = {
|
|
|
73
73
|
focusItem: PropTypes.func.isRequired,
|
|
74
74
|
getItem: PropTypes.func.isRequired,
|
|
75
75
|
getItemDOMElement: PropTypes.func.isRequired,
|
|
76
|
+
getItemOrderedChildrenIds: PropTypes.func.isRequired,
|
|
77
|
+
getItemTree: PropTypes.func.isRequired,
|
|
76
78
|
selectItem: PropTypes.func.isRequired,
|
|
77
79
|
setItemExpansion: PropTypes.func.isRequired
|
|
78
80
|
})
|