Files
flipper/src/ui/components/elements-inspector/ElementsInspector.js
Daniel Büchele 66e77075be Rename package to 'flipper'
Summary:
- rename package `'sonar'` > `'flipper'`
- rename package `'sonar-static'` > `'flipper-static'`
- rename package export from `window.Sonar` to `window.Flipper`

Reviewed By: passy

Differential Revision: D9851181

fbshipit-source-id: 34d4447c3b287496b3d20ddb54471ce777ec74e1
2018-09-18 07:01:16 -07:00

104 lines
2.4 KiB
JavaScript

/**
* Copyright 2018-present Facebook.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
* @format
*/
import {Component} from 'react';
import FlexRow from '../FlexRow.js';
import {Elements} from './elements.js';
import type {ContextMenuExtension} from 'flipper';
export type ElementID = string;
export type ElementSearchResultSet = {|
query: string,
matches: Set<ElementID>,
|};
export type ElementData = {
[name: ElementID]: {
[key: string]:
| string
| number
| boolean
| {|
__type__: string,
value: any,
|},
},
};
export type ElementAttribute = {|
name: string,
value: string,
|};
export type ElementExtraInfo = {|
nonAXWithAXChild?: boolean,
linkedAXNode?: string,
focused?: boolean,
|};
export type Element = {|
id: ElementID,
name: string,
expanded: boolean,
children: Array<ElementID>,
attributes: Array<ElementAttribute>,
data: ElementData,
decoration: string,
extraInfo: ElementExtraInfo,
|};
export default class ElementsInspector extends Component<{
onElementExpanded: (key: ElementID, deep: boolean) => void,
onElementSelected: (key: ElementID) => void,
onElementHovered: ?(key: ?ElementID) => void,
onValueChanged: ?(path: Array<string>, val: any) => void,
selected: ?ElementID,
focused?: ?ElementID,
searchResults?: ?ElementSearchResultSet,
root: ?ElementID,
elements: {[key: ElementID]: Element},
useAppSidebar?: boolean,
alternateRowColor?: boolean,
contextMenuExtensions?: Array<ContextMenuExtension>,
}> {
static defaultProps = {
alternateRowColor: true,
};
render() {
const {
selected,
focused,
elements,
root,
onElementExpanded,
onElementSelected,
onElementHovered,
searchResults,
alternateRowColor,
contextMenuExtensions,
} = this.props;
return (
<FlexRow fill={true}>
<Elements
onElementExpanded={onElementExpanded}
onElementSelected={onElementSelected}
onElementHovered={onElementHovered}
selected={selected}
focused={focused}
searchResults={searchResults}
root={root}
elements={elements}
alternateRowColor={alternateRowColor}
contextMenuExtensions={contextMenuExtensions}
/>
</FlexRow>
);
}
}