Skip to content

Commit

Permalink
[TreeView] Support experimental features from plugin's dependencies (m…
Browse files Browse the repository at this point in the history
  • Loading branch information
flaviendelangle authored and thomasmoon committed Sep 6, 2024
1 parent e1386ec commit 1f44de8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion packages/x-tree-view/src/internals/models/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ export type TreeViewPluginSignature<
>;
}
: {};
experimentalFeatures: T['experimentalFeatures'];
experimentalFeatures: T extends { experimentalFeatures: string }
? { [key in T['experimentalFeatures']]?: boolean }
: {};
dependencies: T extends { dependencies: Array<any> } ? T['dependencies'] : [];
optionalDependencies: T extends { optionalDependencies: Array<any> }
? T['optionalDependencies']
Expand Down
3 changes: 2 additions & 1 deletion packages/x-tree-view/src/internals/models/treeView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ export type TreeViewPublicAPI<

export type TreeViewExperimentalFeatures<
TSignatures extends readonly TreeViewAnyPluginSignature[],
> = { [key in MergeSignaturesProperty<TSignatures, 'experimentalFeatures'>]?: boolean };
TOptionalSignatures extends readonly TreeViewAnyPluginSignature[] = [],
> = MergeSignaturesProperty<[...TSignatures, ...TOptionalSignatures], 'experimentalFeatures'>;
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@ export const extractPluginParamsFromProps = <
pluginParams: defaultizedPluginParams,
slots: slots ?? ({} as any),
slotProps: slotProps ?? ({} as any),
experimentalFeatures: experimentalFeatures ?? {},
experimentalFeatures: experimentalFeatures ?? ({} as any),
};
};

0 comments on commit 1f44de8

Please sign in to comment.