@scenid/react-formulator 0.5.3 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -1
- package/.babelrc +0 -30
- package/.eslintignore +0 -22
- package/.eslintrc +0 -70
- package/.firebaserc +0 -5
- package/.storybook/main.js +0 -12
- package/.storybook/preview.js +0 -9
- package/firebase.json +0 -22
- package/functions/.eslintignore +0 -1
- package/functions/.eslintrc.js +0 -29
- package/functions/index.js +0 -32
- package/functions/package-lock.json +0 -6810
- package/functions/package.json +0 -29
- package/rollup.config.js +0 -40
- package/src/Components/HiddenData.jsx +0 -24
- package/src/Components/SelectOrCreate.jsx +0 -156
- package/src/Editable/FormAutocomplete/FormAutocomplete.jsx +0 -155
- package/src/Editable/FormAutocomplete/useFetchOptions.js +0 -83
- package/src/Editable/FormBoolean.jsx +0 -46
- package/src/Editable/FormCatalogType.jsx +0 -29
- package/src/Editable/FormField.jsx +0 -231
- package/src/Editable/FormNumber.jsx +0 -36
- package/src/Editable/FormRepeater.jsx +0 -218
- package/src/Editable/FormSelect.jsx +0 -52
- package/src/Editable/FormText.jsx +0 -20
- package/src/FormGroupHeader.jsx +0 -85
- package/src/FormHelpers.js +0 -191
- package/src/FormSectionBlock.jsx +0 -71
- package/src/FormSectionCard.jsx +0 -62
- package/src/FormulatorForm.jsx +0 -539
- package/src/FormulatorFormSection.jsx +0 -456
- package/src/ReadOnly/FormReadOnlyBoolean.jsx +0 -36
- package/src/ReadOnly/FormReadOnlyField.jsx +0 -126
- package/src/ReadOnly/FormReadOnlyMarkdown.jsx +0 -20
- package/src/ReadOnly/FormReadOnlyNumber.jsx +0 -17
- package/src/ReadOnly/FormReadOnlyRepeater.jsx +0 -52
- package/src/ReadOnly/FormReadOnlySelect.jsx +0 -18
- package/src/ReadOnly/FormReadOnlyText.jsx +0 -45
- package/src/helpers.js +0 -13
- package/src/index.js +0 -20
- package/stories/CustomRenderField.jsx +0 -46
- package/stories/Forms.stories.jsx +0 -283
- package/stories/Introduction.stories.mdx +0 -206
- package/stories/StoryBase.jsx +0 -35
- package/stories/assets/code-brackets.svg +0 -1
- package/stories/assets/colors.svg +0 -1
- package/stories/assets/comments.svg +0 -1
- package/stories/assets/direction.svg +0 -1
- package/stories/assets/flow.svg +0 -1
- package/stories/assets/plugin.svg +0 -1
- package/stories/assets/repo.svg +0 -1
- package/stories/assets/stackalt.svg +0 -1
- package/stories/forms/login.render.schema.json +0 -23
- package/stories/forms/login.validation.schema.json +0 -29
- package/stories/forms/markdown.render.schema.json +0 -30
- package/stories/forms/markdown.validation.schema.json +0 -18
- package/stories/forms/register.render.schema.json +0 -32
- package/stories/forms/register.validation.schema.json +0 -34
- package/stories/forms/rlp.render.schema.json +0 -153
- package/stories/forms/rlp.translations.json +0 -883
- package/stories/forms/rlp.validation.schema.json +0 -1631
- package/stories/forms/types.schemas.js +0 -319
|
@@ -1,319 +0,0 @@
|
|
|
1
|
-
const inputs = [
|
|
2
|
-
{
|
|
3
|
-
label: 'Simple Text',
|
|
4
|
-
key: 'simpleText',
|
|
5
|
-
render: ['simpleText'],
|
|
6
|
-
validation: { type: 'string' }
|
|
7
|
-
},
|
|
8
|
-
{
|
|
9
|
-
label: 'Multiline Text',
|
|
10
|
-
key: 'multilineText',
|
|
11
|
-
render: [
|
|
12
|
-
[
|
|
13
|
-
'multilineText',
|
|
14
|
-
{
|
|
15
|
-
multiline: true,
|
|
16
|
-
minRows: 5
|
|
17
|
-
}
|
|
18
|
-
]
|
|
19
|
-
],
|
|
20
|
-
validation: { type: 'string' }
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
label: 'Required Input',
|
|
24
|
-
key: 'requiredInput',
|
|
25
|
-
render: ['requiredInput'],
|
|
26
|
-
validation: { type: 'string', required: true }
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
label: 'Input with hidden data in readonly',
|
|
30
|
-
key: 'hiddenDataInput',
|
|
31
|
-
render: ['hiddenDataInput'],
|
|
32
|
-
validation: { type: 'string' }
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
label: 'InputGroup that is hidden in readonly',
|
|
36
|
-
key: 'hiddenInputGroup',
|
|
37
|
-
render: [
|
|
38
|
-
'hiddenGroupInput1',
|
|
39
|
-
'hiddenGroupInput2',
|
|
40
|
-
'hiddenGroupInput3'
|
|
41
|
-
],
|
|
42
|
-
validation: [
|
|
43
|
-
{ key: 'hiddenGroupInput1', value: { type: 'string' } },
|
|
44
|
-
{ key: 'hiddenGroupInput2', value: { type: 'string' } },
|
|
45
|
-
{ key: 'hiddenGroupInput3', value: { type: 'string' } }
|
|
46
|
-
]
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
label: 'Simple Boolean Switch',
|
|
50
|
-
desc: 'Checkbox vs. Switch\nhttps://uxplanet.org/checkbox-vs-toggle-switch-7fc6e83f10b8',
|
|
51
|
-
key: 'simpleSwitch',
|
|
52
|
-
validation: { type: 'boolean' },
|
|
53
|
-
render: [
|
|
54
|
-
'simpleSwitch'
|
|
55
|
-
]
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
label: 'Simple Boolean Checkbox',
|
|
59
|
-
desc: 'Checkbox vs. Switch\nhttps://uxplanet.org/checkbox-vs-toggle-switch-7fc6e83f10b8',
|
|
60
|
-
key: 'simpleCheckbox',
|
|
61
|
-
validation: { type: 'boolean' },
|
|
62
|
-
render: [
|
|
63
|
-
[
|
|
64
|
-
'simpleCheckbox',
|
|
65
|
-
{ variant: 'checkbox' }
|
|
66
|
-
]
|
|
67
|
-
]
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
label: 'Boolean Label Placement',
|
|
71
|
-
key: 'booleanLabelPlace',
|
|
72
|
-
validation: { type: 'boolean' },
|
|
73
|
-
render: [
|
|
74
|
-
[
|
|
75
|
-
'booleanLabelPlace',
|
|
76
|
-
{ labelPlacement: 'start' }
|
|
77
|
-
]
|
|
78
|
-
]
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
label: 'Simple Number',
|
|
82
|
-
key: 'simpleNumber',
|
|
83
|
-
render: ['simpleNumber'],
|
|
84
|
-
validation: { type: 'number' }
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
label: 'Advanced Number',
|
|
88
|
-
key: 'advancedNumber',
|
|
89
|
-
render: [
|
|
90
|
-
[
|
|
91
|
-
'advancedNumber',
|
|
92
|
-
{
|
|
93
|
-
min: 0,
|
|
94
|
-
max: 2,
|
|
95
|
-
step: 0.25
|
|
96
|
-
}
|
|
97
|
-
]
|
|
98
|
-
],
|
|
99
|
-
validation: { type: 'number' }
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
label: 'Simple Select',
|
|
103
|
-
desc: 'Values are automatically sorted with [localeCompare](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare).',
|
|
104
|
-
key: 'simpleSelect',
|
|
105
|
-
render: ['simpleSelect'],
|
|
106
|
-
validation: { type: ['Citrus', 'Banana', 'Apple', 'Date'] }
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
label: 'Date',
|
|
110
|
-
key: 'dateInput',
|
|
111
|
-
desc: 'Output can be formatted using all options of [luxon\'s .toLocaleString](https://moment.github.io/luxon/#/formatting?id=tolocalestring-strings-for-humans)',
|
|
112
|
-
render: [
|
|
113
|
-
[
|
|
114
|
-
'dateInput1',
|
|
115
|
-
{ type: 'date' }
|
|
116
|
-
],
|
|
117
|
-
[
|
|
118
|
-
'dateInput2',
|
|
119
|
-
{
|
|
120
|
-
type: 'date',
|
|
121
|
-
renderFormat: 'DATE_MED_WITH_WEEKDAY'
|
|
122
|
-
}
|
|
123
|
-
],
|
|
124
|
-
[
|
|
125
|
-
'dateInput3',
|
|
126
|
-
{
|
|
127
|
-
type: 'date',
|
|
128
|
-
renderFormat: { month: 'long', day: 'numeric' }
|
|
129
|
-
}
|
|
130
|
-
]
|
|
131
|
-
],
|
|
132
|
-
validation: [
|
|
133
|
-
{ key: 'dateInput1', value: { type: 'string' } },
|
|
134
|
-
{ key: 'dateInput2', value: { type: 'string' } },
|
|
135
|
-
{ key: 'dateInput3', value: { type: 'string' } }
|
|
136
|
-
]
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
label: 'Local DateTime',
|
|
140
|
-
key: 'localDateTime',
|
|
141
|
-
desc: 'Output can be formatted using all options of [luxon\'s .toLocaleString](https://moment.github.io/luxon/#/formatting?id=tolocalestring-strings-for-humans)',
|
|
142
|
-
render: [
|
|
143
|
-
[
|
|
144
|
-
'localDateTime1',
|
|
145
|
-
{ type: 'datetime-local' }
|
|
146
|
-
],
|
|
147
|
-
[
|
|
148
|
-
'localDateTime2',
|
|
149
|
-
{
|
|
150
|
-
type: 'datetime-local',
|
|
151
|
-
renderFormat: 'DATETIME_MED_WITH_SECONDS'
|
|
152
|
-
}
|
|
153
|
-
],
|
|
154
|
-
[
|
|
155
|
-
'localDateTime3',
|
|
156
|
-
{
|
|
157
|
-
type: 'datetime-local',
|
|
158
|
-
renderFormat: { hour: 'numeric', minute: '2-digit' }
|
|
159
|
-
}
|
|
160
|
-
]
|
|
161
|
-
],
|
|
162
|
-
validation: [
|
|
163
|
-
{ key: 'localDateTime1', value: { type: 'string' } },
|
|
164
|
-
{ key: 'localDateTime2', value: { type: 'string' } },
|
|
165
|
-
{ key: 'localDateTime3', value: { type: 'string' } }
|
|
166
|
-
]
|
|
167
|
-
},
|
|
168
|
-
{
|
|
169
|
-
label: 'Array as Repeater',
|
|
170
|
-
key: 'arrayRepeater',
|
|
171
|
-
render: ['arrayRepeater'],
|
|
172
|
-
validation: { type: 'array' }
|
|
173
|
-
},
|
|
174
|
-
{
|
|
175
|
-
label: 'Repeater with Catalog',
|
|
176
|
-
key: 'arrayCatalogRepeater',
|
|
177
|
-
render: ['arrayCatalogRepeater'],
|
|
178
|
-
validation: {
|
|
179
|
-
type: 'array',
|
|
180
|
-
validator: 'In',
|
|
181
|
-
options: [
|
|
182
|
-
'cat',
|
|
183
|
-
'dog',
|
|
184
|
-
'fish',
|
|
185
|
-
'horse'
|
|
186
|
-
]
|
|
187
|
-
}
|
|
188
|
-
},
|
|
189
|
-
{
|
|
190
|
-
label: 'Autocomplete Field',
|
|
191
|
-
desc: 'You can supply an array of options or an async function to fetch options on the fly.',
|
|
192
|
-
key: 'autoCompleteFields',
|
|
193
|
-
render: [
|
|
194
|
-
[
|
|
195
|
-
'autocompleteField1',
|
|
196
|
-
{ autocomplete: true }
|
|
197
|
-
],
|
|
198
|
-
[
|
|
199
|
-
'@@render',
|
|
200
|
-
'autocompleteField2'
|
|
201
|
-
],
|
|
202
|
-
[
|
|
203
|
-
'@@render',
|
|
204
|
-
'autocompleteField3',
|
|
205
|
-
{ allowCreate: true }
|
|
206
|
-
]
|
|
207
|
-
],
|
|
208
|
-
validation: [
|
|
209
|
-
{
|
|
210
|
-
key: 'autocompleteField1',
|
|
211
|
-
value: {
|
|
212
|
-
type: [
|
|
213
|
-
'Abyssinian',
|
|
214
|
-
'Bengal',
|
|
215
|
-
'Birman',
|
|
216
|
-
'Burmese',
|
|
217
|
-
'Chartreux',
|
|
218
|
-
'Egyptian Mau',
|
|
219
|
-
'German Rex',
|
|
220
|
-
'Khao Manee',
|
|
221
|
-
'Korean Bobtail',
|
|
222
|
-
'Maine Coon',
|
|
223
|
-
'Nebelung',
|
|
224
|
-
'Ocicat',
|
|
225
|
-
'Oriental Shorthair',
|
|
226
|
-
'Siamese'
|
|
227
|
-
],
|
|
228
|
-
required: true
|
|
229
|
-
}
|
|
230
|
-
},
|
|
231
|
-
{
|
|
232
|
-
key: 'autocompleteField2',
|
|
233
|
-
value: {
|
|
234
|
-
type: 'string',
|
|
235
|
-
required: true
|
|
236
|
-
}
|
|
237
|
-
},
|
|
238
|
-
{ key: 'autocompleteField3', value: { type: 'string' } }
|
|
239
|
-
]
|
|
240
|
-
},
|
|
241
|
-
{
|
|
242
|
-
label: 'Custom Render Field',
|
|
243
|
-
desc: 'Try typing something, it might surprise you ;)',
|
|
244
|
-
key: 'customRenderField',
|
|
245
|
-
render: [
|
|
246
|
-
[
|
|
247
|
-
'@@render',
|
|
248
|
-
'customRenderField'
|
|
249
|
-
]
|
|
250
|
-
],
|
|
251
|
-
validation: { type: 'string' }
|
|
252
|
-
}
|
|
253
|
-
]
|
|
254
|
-
|
|
255
|
-
export default () => {
|
|
256
|
-
const renderSchema = {
|
|
257
|
-
properties: {},
|
|
258
|
-
groups: []
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
const validationSchema = {
|
|
262
|
-
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
263
|
-
$id: 'http://scenid.com/crm/register.schema.json',
|
|
264
|
-
title: 'Types',
|
|
265
|
-
type: 'object',
|
|
266
|
-
properties: {}
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
const translations = { labels: {} }
|
|
270
|
-
|
|
271
|
-
inputs.forEach(({ key, label, desc, validation, render }) => {
|
|
272
|
-
const validationJSON = (
|
|
273
|
-
Array.isArray(validation)
|
|
274
|
-
? JSON.stringify(validation.reduce((l, r) => ({ ...l, [r.key]: r.value }), {}), null, ' ')
|
|
275
|
-
: JSON.stringify({ [key]: validation }, null, ' ')
|
|
276
|
-
)
|
|
277
|
-
const renderJSON = JSON.stringify(render, null, ' ')
|
|
278
|
-
|
|
279
|
-
const renderEntry = {
|
|
280
|
-
id: key,
|
|
281
|
-
label,
|
|
282
|
-
fields: [
|
|
283
|
-
[
|
|
284
|
-
'@@markdown',
|
|
285
|
-
'mmd-id',
|
|
286
|
-
`\`\`\`json\n/* validation schema */\n${validationJSON}\n\n/* render schema */\n${renderJSON}\n\`\`\``
|
|
287
|
-
]
|
|
288
|
-
]
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
if (desc) {
|
|
292
|
-
renderEntry.fields.unshift([
|
|
293
|
-
'@@markdown',
|
|
294
|
-
'mmd-desc-id',
|
|
295
|
-
desc
|
|
296
|
-
])
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
if (Array.isArray(validation)) {
|
|
300
|
-
validation.forEach((e, index) => {
|
|
301
|
-
validationSchema.properties[e.key] = e.value
|
|
302
|
-
translations.labels[e.key] = e.key
|
|
303
|
-
renderEntry.fields.push(render[index])
|
|
304
|
-
})
|
|
305
|
-
} else {
|
|
306
|
-
validationSchema.properties[key] = validation
|
|
307
|
-
translations.labels[key] = label
|
|
308
|
-
renderEntry.fields.push(render[0])
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
renderSchema.groups.push(renderEntry)
|
|
312
|
-
})
|
|
313
|
-
|
|
314
|
-
return {
|
|
315
|
-
render: renderSchema,
|
|
316
|
-
validation: validationSchema,
|
|
317
|
-
translations
|
|
318
|
-
}
|
|
319
|
-
}
|