MCPcopy Create free account
hub / github.com/AllenFang/react-bootstrap-table / editor

Function editor

src/Editor.js:4–123  ·  view source on GitHub ↗
(editable, attr, format, editorClass, defaultValue, ignoreEditable, row)

Source from the content-addressed store, hash-verified

2import React from 'react';
3
4const editor = function(editable, attr, format, editorClass, defaultValue, ignoreEditable, row) {
5 if (editable === true ||
6 (editable === false && ignoreEditable) ||
7 typeof editable === 'string') { // simple declare
8 const type = editable ? 'text' : editable;
9 return (
10 <input { ...attr } type={ type } defaultValue={ defaultValue }
11 className={ ( editorClass || '') + ' form-control editor edit-text' } />
12 );
13 } else if (!editable) {
14 const type = editable ? 'text' : editable;
15 return (
16 <input { ...attr } type={ type } defaultValue={ defaultValue }
17 disabled='disabled'
18 className={ ( editorClass || '') + ' form-control editor edit-text' } />
19 );
20 } else if (editable && (editable.type === undefined ||
21 editable.type === null ||
22 editable.type.trim() === '')) {
23 const type = editable ? 'text' : editable;
24 return (
25 <input { ...attr } type={ type } defaultValue={ defaultValue }
26 className={ ( editorClass || '') + ' form-control editor edit-text' } />
27 );
28 } else if (editable.type) {// standard declare
29 // put style if exist
30 editable.style && (attr.style = editable.style);
31 // put class if exist
32 attr.className = (editorClass || '') +
33 ' form-control editor edit-' +
34 editable.type +
35 (editable.className ? (' ' + editable.className) : '');
36
37 if (editable.type === 'select') {// process select input
38 let options = [];
39 let { values } = editable.options;
40 const { textKey, valueKey } = editable.options;
41 if (Utils.isFunction(values)) {
42 values = values(row);
43 }
44 if (Array.isArray(values)) {// only can use arrray data for options
45 let text;
46 let value;
47 options = values.map((option, i) => {
48 if (typeof option === 'object') {
49 text = textKey ? option[textKey] : option.text;
50 value = valueKey ? option[valueKey] : option.value;
51 } else {
52 text = format ? format(option) : option;
53 value = option;
54 }
55 return (
56 <option key={ 'option' + i } value={ value }>{ text }</option>
57 );
58 }
59 );
60 }
61 return (

Callers 2

renderMethod · 0.85
InsertModalBody.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…