MCPcopy Create free account
hub / github.com/reactstrap/reactstrap / render

Method render

src/Input.js:47–137  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

45 }
46
47 render() {
48 let {
49 className,
50 cssModule,
51 type = 'text',
52 bsSize,
53 valid,
54 invalid,
55 tag,
56 addon,
57 plaintext,
58 innerRef,
59 ...attributes
60 } = this.props;
61
62 const checkInput = ['switch', 'radio', 'checkbox'].indexOf(type) > -1;
63 const isNotaNumber = /\D/g;
64
65 const textareaInput = type === 'textarea';
66 const selectInput = type === 'select';
67 const rangeInput = type === 'range';
68 let Tag = tag || (selectInput || textareaInput ? type : 'input');
69
70 let formControlClass = 'form-control';
71
72 if (plaintext) {
73 formControlClass = `${formControlClass}-plaintext`;
74 Tag = tag || 'input';
75 } else if (rangeInput) {
76 formControlClass = 'form-range';
77 } else if (selectInput) {
78 formControlClass = 'form-select';
79 } else if (checkInput) {
80 if (addon) {
81 formControlClass = null;
82 } else {
83 formControlClass = 'form-check-input';
84 }
85 }
86
87 if (attributes.size && isNotaNumber.test(attributes.size)) {
88 warnOnce(
89 'Please use the prop "bsSize" instead of the "size" to bootstrap\'s input sizing.',
90 );
91 bsSize = attributes.size;
92 delete attributes.size;
93 }
94
95 const classes = mapToCssModules(
96 classNames(
97 className,
98 invalid && 'is-invalid',
99 valid && 'is-valid',
100 bsSize
101 ? selectInput
102 ? `form-select-${bsSize}`
103 : `form-control-${bsSize}`
104 : false,

Callers

nothing calls this directly

Calls 2

warnOnceFunction · 0.90
mapToCssModulesFunction · 0.90

Tested by

no test coverage detected