mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2025-11-05 02:17:27 +03:00
* chore(deps): update dependency prettier to v3 * Format --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Nathan Bierema <nbierema@gmail.com>
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import React, { ReactNode, PureComponent } from 'react';
|
|
import type { ShouldExpandNodeInitially } from 'react-json-tree';
|
|
import { QueryPreviewTabs, RtkResourceInfo } from '../types';
|
|
import { renderTabPanelButtonId, renderTabPanelId } from '../utils/a11y';
|
|
import { TreeView, TreeViewProps } from './TreeView';
|
|
|
|
export interface QueryPreviewDataProps {
|
|
data: RtkResourceInfo['state']['data'];
|
|
isWideLayout: boolean;
|
|
}
|
|
|
|
const rootProps: TreeViewProps['rootProps'] = {
|
|
'aria-labelledby': renderTabPanelButtonId(QueryPreviewTabs.data),
|
|
id: renderTabPanelId(QueryPreviewTabs.data),
|
|
role: 'tabpanel',
|
|
};
|
|
|
|
export class QueryPreviewData extends PureComponent<QueryPreviewDataProps> {
|
|
shouldExpandNodeInitially: ShouldExpandNodeInitially = (
|
|
keyPath,
|
|
value,
|
|
layer,
|
|
) => {
|
|
return layer <= 1;
|
|
};
|
|
|
|
render(): ReactNode {
|
|
const { data, isWideLayout } = this.props;
|
|
|
|
return (
|
|
<TreeView
|
|
rootProps={rootProps}
|
|
data={data}
|
|
isWideLayout={isWideLayout}
|
|
shouldExpandNodeInitially={this.shouldExpandNodeInitially}
|
|
/>
|
|
);
|
|
}
|
|
}
|