PluginProbe
WP Ultimate Post Grid / 4.1.1
WP Ultimate Post Grid v4.1.1
4.1.1 trunk 1.5 1.6 1.7 1.7.1 1.7.2 1.8 1.9 2.0 2.1 2.2 2.3 2.4.0 2.5.0 2.6.0 2.7.0 2.8.0 2.8.2 3.0.0 3.3.0 3.4.0 3.5.0 3.6.0 3.7.0 All 32 releases
wp-ultimate-post-grid / assets / js / admin-modal / field / index.js

index.js in WP Ultimate Post Grid 4.1.1, at assets/js/admin-modal/field/index.js

138 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import React, { Fragment } from 'react';
2
3 import Icon from 'Shared/Icon';
4
5 import FieldColor from './FieldColor';
6 import FieldColors from './FieldColors';
7 import FieldColumns from './FieldColumns';
8 import FieldDropdown from './FieldDropdown';
9 import FieldOrder from './FieldOrder';
10 import FieldRadio from './FieldRadio';
11 import FieldSlug from './FieldSlug';
12 import FieldFilter from './FieldFilter';
13 import FieldTinymce from './FieldTinymce';
14
15 const fields = {
16 text: (props) => (
17 <input
18 type="text"
19 value={props.value}
20 placeholder={props.placeholder}
21 onChange={(e) => {
22 props.onChange(e.target.value);
23 }}
24 />
25 ),
26 number: (props) => (
27 <Fragment>
28 <input
29 type="number"
30 value={props.value}
31 placeholder={props.placeholder}
32 min={props.min}
33 max={props.max}
34 onChange={(e) => {
35 props.onChange(e.target.value);
36 }}
37 />
38 {
39 props.hasOwnProperty( 'suffix' )
40 ?
41 <span className="wpupg-admin-modal-field-number-suffix">{ props.suffix }</span>
42 :
43 null
44 }
45 </Fragment>
46 ),
47 textarea: (props) => (
48 <textarea
49 value={props.value}
50 onChange={(e) => {
51 props.onChange(e.target.value);
52 }}
53 />
54 ),
55 checkbox: (props) => (
56 <input
57 type="checkbox"
58 checked={props.value}
59 onChange={(e) => {
60 props.onChange(e.target.checked);
61 }}
62 />
63 ),
64 color: (props) => (
65 <FieldColor
66 { ...props }
67 />
68 ),
69 colors: (props) => (
70 <FieldColors
71 { ...props }
72 />
73 ),
74 columns: (props) => (
75 <FieldColumns
76 { ...props }
77 />
78 ),
79 dropdown: (props) => (
80 <FieldDropdown
81 { ...props }
82 />
83 ),
84 order: (props) => (
85 <FieldOrder
86 { ...props }
87 />
88 ),
89 radio: (props) => (
90 <FieldRadio
91 { ...props }
92 />
93 ),
94 slug: (props) => (
95 <FieldSlug
96 { ...props }
97 />
98 ),
99 filter: (props) => (
100 <FieldFilter
101 { ...props }
102 />
103 ),
104 tinymce: (props) => (
105 <FieldTinymce
106 { ...props }
107 />
108 ),
109 custom: (props) => (
110 <Fragment>{ props.children }</Fragment>
111 ),
112 }
113
114 const Field = (props) => {
115 let helpIcon = null;
116 if ( props.help ) {
117 helpIcon = (
118 <Icon
119 type="question"
120 title={ props.help }
121 className="wpupg-admin-icon-help"
122 />
123 );
124 }
125
126 let field = null;
127 if ( fields.hasOwnProperty( props.type) ) {
128 field = fields[ props.type ];
129 }
130
131 return (
132 <div className={`wpupg-admin-modal-field-container wpupg-admin-modal-field-container-${props.type}`}>
133 <div className="wpupg-admin-modal-field-label">{ props.label }{ helpIcon }</div>
134 <div className="wpupg-admin-modal-field">{ null !== field && field( props ) }</div>
135 </div>
136 );
137 }
138 export default Field;