MCPcopy Create free account
hub / github.com/Lobos/react-ui / formatData

Method formatData

src/CheckboxGroup.js:46–71  ·  view source on GitHub ↗
(data, value=this.state.value)

Source from the content-addressed store, hash-verified

44 }
45
46 formatData (data, value=this.state.value) {
47 data = toTextValue(data, this.props.textTpl, this.props.valueTpl).map((d) => {
48 d.$checked = value.indexOf(d.$value) >= 0;
49 return d;
50 });
51
52 Children.map(this.props.children, (child) => {
53 if (typeof child === 'object') {
54 let position = child.props.position;
55 if (position === undefined) {
56 position = data.length;
57 }
58 data = [
59 ...data.slice(0, position),
60 {
61 $checked: value.indexOf(child.props.checkValue) >= 0,
62 $value: child.props.checkValue,
63 $text: child.props.children || child.props.text,
64 $key: hashcode(`${child.props.checkValue}-${child.props.text}`)
65 },
66 ...data.slice(position)
67 ];
68 }
69 });
70 return data;
71 }
72
73 getValue (sep=this.props.sep, data=this.state.data) {
74 let value = [],

Callers 2

constructorMethod · 0.95

Calls 2

toTextValueFunction · 0.90
hashcodeFunction · 0.90

Tested by

no test coverage detected