-
Notifications
You must be signed in to change notification settings - Fork 0
/
samples.json
369 lines (369 loc) · 10.4 KB
/
samples.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
[
{
"title": "Layout Grid",
"description": [
"It has 12 columns. Also you can specify phoneColumns,",
"tableColumns, desktopColumns. It supports nested grids"
],
"lines": [
"<One fields={[",
" {",
" type: FieldType.Group,",
" columns: '12',",
" fields: [",
" {",
" type: FieldType.Component,",
" compute: () => <Rect>12 total</Rect>,",
" },",
" ]",
" },",
" {",
" type: FieldType.Group,",
" desktopColumns: '12',",
" phoneColumns: '6',",
" tabletColumns: '6',",
" fields: [",
" {",
" type: FieldType.Component,",
" compute: () => <Rect>6 phone 6 tabled 12 desktop</Rect>,",
" }",
" ],",
" },",
" {",
" type: FieldType.Group,",
" desktopColumns: '12',",
" phoneColumns: '6',",
" tabletColumns: '6',",
" fields: [",
" {",
" type: FieldType.Component,",
" compute: () => <Rect>6 phone 6 tabled 12 desktop</Rect>,",
" }",
" ],",
" },",
" {",
" type: FieldType.Group,",
" desktopColumns: '6',",
" phoneColumns: '4',",
" tabletColumns: '4',",
" fields: [",
" {",
" type: FieldType.Component,",
" compute: () => <Rect>4 phone 4 tabled 6 desktop</Rect>,",
" }",
" ],",
" },",
" {",
" type: FieldType.Group,",
" desktopColumns: '6',",
" phoneColumns: '4',",
" tabletColumns: '4',",
" fields: [",
" {",
" type: FieldType.Component,",
" compute: () => <Rect>4 phone 4 tabled 6 desktop</Rect>,",
" }",
" ],",
" },",
" {",
" type: FieldType.Group,",
" desktopColumns: '6',",
" phoneColumns: '4',",
" tabletColumns: '4',",
" fields: [",
" {",
" type: FieldType.Component,",
" compute: () => <Rect>4 phone 4 tabled 6 desktop</Rect>,",
" }",
" ],",
" },",
"]}/>",
""
]
},
{
"title": "State by pure functions",
"description": [
"Code split convention will keep your code",
"pure after extending view by other fields"
],
"lines": [
"<One",
" handler={() => Promise.resolve({",
" items: ['a', 'b', 'c']",
" })}",
" fields={[",
" {",
" type: FieldType.Items,",
" title: 'A sample field',",
" placeholder: 'Multiple selection',",
" name: 'items',",
" itemList: ['a', 'b', 'c'],",
" isVisible: (obj) => obj.visible,",
" isDisabled: (obj) => obj.disabled,",
" },",
" {",
" type: FieldType.Checkbox,",
" title: 'Mark as visible',",
" defaultValue: true,",
" name: 'visible',",
" },",
" {",
" type: FieldType.Checkbox,",
" title: 'Mark as disabled',",
" defaultValue: false,",
" name: 'disabled',",
" },",
" ]}",
"/>",
""
]
},
{
"title": "Validation optimisation",
"description": [
"It includes input debouncing and data filtering",
"which prevents submit of invalid input"
],
"lines": [
"<One",
" handler={{",
" text: '42',",
" }}",
" change={({}, initial) => {",
" if (!initial) {",
" snack(`",
" It looks like form has raised",
" change callback. Should enable",
" save button",
" `);",
" }",
" }}",
" fields={[",
" {",
" type: FieldType.Text,",
" // inputType: 'number',",
" title: 'Only number allowed',",
" description: 'Which will not be greater or lower than 42',",
" name: 'text',",
" isInvalid(obj) {",
" if (isNaN(obj.text)) {",
" return 'It is not a number';",
" }",
" if (obj.text != 42) {",
" return 'The number is greater or lower than 42';",
" }",
" return null;",
" },",
" invalidity() {",
" snack(`",
" It looks like form has invalid value",
" in the field. The save button should be",
" disabled",
" `);",
" },",
" }",
" ]}",
"/>",
""
]
},
{
"title": "Focus-blur monitoring",
"description": [
"There is automatic monitor for focus/blur of",
"field, group and full component with bubbling",
"support"
],
"lines": [
"<One blur={() => snack('blur c')} fields={[",
" {",
" type: FieldType.Text,",
" name: 'a',",
" focus() { snack('focus a') },",
" blur() { snack('blur a') },",
" },",
" {",
" type: FieldType.Text,",
" name: 'b',",
" focus() { snack('focus b') },",
" }",
"]}/>",
""
]
},
{
"title": "Two-way value binding",
"description": [
"Completely Bugless"
],
"lines": [
"<One fields={[",
" {",
" type: FieldType.Progress,",
" showPercentLabel: true,",
" maxPercent: 100,",
" name: 'slider',",
" },",
" {",
" type: FieldType.Slider,",
" name: 'slider',",
" leadingIcon: VolumeDown,",
" trailingIcon: VolumeUp,",
" defaultValue: 30,",
" leadingIconClick(v, onChange) { onChange(v - 10) },",
" trailingIconClick(v, onChange) { onChange(v + 10) },",
" },",
"]}/>",
""
]
},
{
"title": "Computed values",
"description": [
"Much better than redux selectors"
],
"lines": [
"<One fields={[",
" {",
" type: FieldType.Text,",
" title: 'Computed value',",
" compute(obj) {",
" if (obj.radio === 'first') {",
" return 'It looks like radio #1 was cheched';",
" } else if (obj.radio === 'second') {",
" return 'It looks like radio #2 was cheched';",
" } else if (obj.radio === 'third') {",
" return 'It looks like radio #3 was cheched';",
" } else {",
" return 'Please mark radio button';",
" }",
" },",
" },",
" {",
" type: FieldType.Radio,",
" title: 'First radio button',",
" name: 'radio',",
" radioValue: 'first',",
" },",
" {",
" type: FieldType.Radio,",
" title: 'Second radio button',",
" name: 'radio',",
" radioValue: 'second',",
" },",
" {",
" type: FieldType.Radio,",
" title: 'Third radio button',",
" name: 'radio',",
" radioValue: 'third',",
" },",
"]}/>",
""
]
},
{
"title": "Modal pickers",
"description": [
"Mobile-first modal date and time pickers. Also there is \"One\" component based",
"user input dialog which helps keep single responsibility principle on page"
],
"lines": [
"<One fields={[",
" {",
" type: FieldType.Text,",
" title: 'Pick date',",
" description: 'By using trailing icon',",
" name: 'date',",
" trailingIcon: CalendarToday,",
" readonly: true,",
" trailingIconClick: (v, onChange) => pickDate().then((d) => {",
" if (d) {",
" onChange(d.format('MM-DD-YYYY'));",
" } else {",
" onChange('Rejected :-(');",
" }",
" }),",
" },",
" {",
" type: FieldType.Text,",
" title: 'Pick time',",
" description: 'By using leading icon',",
" name: 'time',",
" leadingIcon: Alarm,",
" readonly: true,",
" defaultValue: '12:00',",
" leadingIconClick: (v, onChange) => pickTime().then((t) => {",
" if (t) {",
" onChange(t.format('H:mm'));",
" } else {",
" onChange('Rejected :-(');",
" }",
" }),",
" },",
" {",
" type: FieldType.Text,",
" title: 'Pick name',",
" description: 'Firstname, Lastname, Patronymic',",
" name: 'fio',",
" trailingIcon: Face,",
" readonly: true,",
" trailingIconClick: (v, onChange) => pickOne('Waiting for user input', [",
" {type: FieldType.Text, title: 'Firstname', defaultValue: 'Петр', name: 'f'},",
" {type: FieldType.Text, title: 'Lastname', name: 'l'},",
" {type: FieldType.Text, title: 'Patronymic', name: 'p'},",
" ]).then((input) => {",
" if (input) {",
" const {f, l, p} = input;",
" onChange([f, l, p].join(' '));",
" } else {",
" onChange('Rejected :-(');",
" }",
" }),",
" },",
"]}/>",
""
]
},
{
"title": "Demos",
"description": [
"Applications created with One component"
],
"lines": [
"<div style={{height: '100%', width: '100%'}}>",
" <Typography>",
" <Link onClick={() => openBlank('./wordpress-interop/')}>",
" Wordpress interop",
" </Link>",
" </Typography>",
" <Typography>",
" <Link onClick={() => openBlank('./form-generator/')}>",
" Form generator",
" </Link>",
" </Typography>",
" <Typography>",
" <Link onClick={() => openBlank('./amazing-settings/')}>",
" Settings panel",
" </Link>",
" </Typography>",
" <Typography>",
" <Link onClick={() => openBlank('./amazing-search/')}>",
" Search example",
" </Link>",
" </Typography>",
" <Typography>",
" <Link onClick={() => openBlank('./amazing-typography/')}>",
" Typography",
" </Link>",
" </Typography>",
" <Typography>",
" <Link onClick={() => openBlank('https://github.com/tripolskypetr/react-view-builder')}>",
" NPM package",
" </Link>",
" </Typography>",
"</div>",
""
]
}
]