SelectionEditorWidget

Source

DepthMatchingRender.js
import React from 'react';
import PropTypes from 'prop-types';

import style from 'PVWStyle/ReactWidgets/SelectionEditorWidget.mcss';

export default function DepthMatchingRender(props) {
if (props.depth < props.maxDepth) {
return (
<DepthMatchingRender depth={props.depth + 1} maxDepth={props.maxDepth}>
<table className={style.table}>
<tbody>
<tr>
<td className={style.operationCell} />
<td className={style.groupTableCellPadding} />
<td>
<table className={style.table}>
<tbody>
<tr>
<td className={style.tableCell}>{props.children}</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</DepthMatchingRender>
);
}

return props.children;
}

DepthMatchingRender.propTypes = {
children: PropTypes.object,
depth: PropTypes.number,
maxDepth: PropTypes.number,
};

DepthMatchingRender.defaultProps = {
children: undefined,
depth: undefined,
maxDepth: undefined,
};
LegendIcon.js
import React from 'react';
import PropTypes from 'prop-types';

import SvgIconWidget from '../SvgIconWidget';

export default function render(props) {
if (!props.getLegend) {
return <span>{props.name}</span>;
}
const style = { fill: props.getLegend(props.name).color };
const newStyle = Object.assign(
{ stroke: 'black', strokeWidth: 1 },
style,
props.style
);

return (
<SvgIconWidget
icon={props.getLegend(props.name).shape}
width={props.width}
height={props.height}
style={newStyle}
onClick={props.onClick}
/>
);
}

render.propTypes = {
name: PropTypes.string,
getLegend: PropTypes.func,

width: PropTypes.string,
height: PropTypes.string,
style: PropTypes.object,

onClick: PropTypes.func,
};

render.defaultProps = {
name: undefined,
getLegend: undefined,

width: undefined,
height: undefined,
style: undefined,

onClick: undefined,
};
index.js
import React from 'react';
import PropTypes from 'prop-types';

import WidgetTypes from './types';

export default function render(props) {
const SelectionWidget =
WidgetTypes[props.selection ? props.selection.type : 'empty'];
return <SelectionWidget {...props} />;
}

render.propTypes = {
selection: PropTypes.object,
ranges: PropTypes.object,
onChange: PropTypes.func,
getLegend: PropTypes.func,
className: PropTypes.string,
};

render.defaultProps = {
onChange(selection, isEditDone) {},

selection: undefined,
ranges: undefined,
getLegend: undefined,
className: undefined,
};
types.js
import empty from './empty';
import partition from './partition';
import range from './range';
import rule from './rule';

export default {
empty,
partition,
range,
rule,
};