MCPcopy Create free account
hub / github.com/flyfloor/react-component / getNodesAndLabel

Function getNodesAndLabel

component/DropDown.js:138–171  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

136 },
137
138 getNodesAndLabel(){
139 const {labelName, valueName, searchable, multi, placeHolder} = this.props;
140 const {filterText, value, options} = this.state;
141 let displayLabels = [], node = null, optionNodes = [];
142 if (!multi) displayLabels = placeHolder;
143
144 for (let i = 0; i < options.length; i++) {
145 const pair = options[i];
146 const pair_val = pair[valueName];
147 const pair_label = pair[labelName];
148 let selected = false;
149 if (multi) {
150 for (let j = 0; j < value.length; j++) {
151 selected = value[j] === pair_val;
152 if (selected) {
153 if (displayLabels.indexOf(pair_label) === -1) displayLabels[value.indexOf(pair_val)] = pair_label;
154 break;
155 }
156 }
157 } else {
158 selected = value === pair_val;
159 if (selected) displayLabels = pair_label;
160 }
161
162 node = this.formatOptionCell({ label: pair_label, value: pair_val, selected, children: pair.children, disabled: pair.disabled });
163
164 if (multi || searchable) {
165 if (this.getFilterStatus(filterText, pair_val, pair_label)) optionNodes.push(node);
166 } else {
167 optionNodes.push(node);
168 }
169 }
170 return {optionNodes, displayLabels};
171 },
172
173 formatOptions(){
174 let {className, style} = this.props;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…