@scenid/react-formulator 0.0.2

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.
Files changed (54) hide show
  1. package/.eslintignore +21 -0
  2. package/.eslintrc +70 -0
  3. package/.firebase/hosting.c3Rvcnlib29rLXN0YXRpYw.cache +38 -0
  4. package/.firebaserc +5 -0
  5. package/.storybook/main.js +12 -0
  6. package/.storybook/preview.js +9 -0
  7. package/README.md +29 -0
  8. package/dist/index.cjs.css +96 -0
  9. package/dist/index.cjs.js +25 -0
  10. package/dist/index.esm.css +96 -0
  11. package/dist/index.esm.js +25 -0
  12. package/firebase.json +17 -0
  13. package/package.json +74 -0
  14. package/rollup.config.js +35 -0
  15. package/src/Editable/FormBoolean.jsx +44 -0
  16. package/src/Editable/FormField.jsx +223 -0
  17. package/src/Editable/FormNumber.jsx +36 -0
  18. package/src/Editable/FormRepeater.jsx +190 -0
  19. package/src/Editable/FormSelect.jsx +49 -0
  20. package/src/Editable/FormTextfield.jsx +13 -0
  21. package/src/FormGroupHeader.jsx +85 -0
  22. package/src/FormHelpers.js +191 -0
  23. package/src/FormSectionBlock.jsx +70 -0
  24. package/src/FormSectionCard.jsx +62 -0
  25. package/src/FormulatorForm.jsx +537 -0
  26. package/src/FormulatorFormSection.jsx +494 -0
  27. package/src/HiddenData.jsx +24 -0
  28. package/src/ReadOnly/FormBoolean.jsx +36 -0
  29. package/src/ReadOnly/FormField.jsx +126 -0
  30. package/src/ReadOnly/FormMarkdown.jsx +20 -0
  31. package/src/ReadOnly/FormNumber.jsx +17 -0
  32. package/src/ReadOnly/FormReadOnlyText.jsx +19 -0
  33. package/src/ReadOnly/FormRepeater.jsx +36 -0
  34. package/src/ReadOnly/FormSelect.jsx +18 -0
  35. package/src/helpers.js +13 -0
  36. package/src/index.js +3 -0
  37. package/stories/Forms.stories.jsx +126 -0
  38. package/stories/Introduction.stories.mdx +206 -0
  39. package/stories/StoryBase.jsx +35 -0
  40. package/stories/assets/code-brackets.svg +1 -0
  41. package/stories/assets/colors.svg +1 -0
  42. package/stories/assets/comments.svg +1 -0
  43. package/stories/assets/direction.svg +1 -0
  44. package/stories/assets/flow.svg +1 -0
  45. package/stories/assets/plugin.svg +1 -0
  46. package/stories/assets/repo.svg +1 -0
  47. package/stories/assets/stackalt.svg +1 -0
  48. package/stories/forms/login.render.schema.json +23 -0
  49. package/stories/forms/login.validation.schema.json +29 -0
  50. package/stories/forms/markdown.render.schema.json +30 -0
  51. package/stories/forms/markdown.validation.schema.json +18 -0
  52. package/stories/forms/register.render.schema.json +32 -0
  53. package/stories/forms/register.validation.schema.json +34 -0
  54. package/stories/forms/types.schemas.js +171 -0
@@ -0,0 +1,34 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "http://scenid.com/crm/register.schema.json",
4
+ "title": "Register",
5
+ "description": "Register for Scenid Customers",
6
+ "type": "object",
7
+ "properties": {
8
+ "tenantName": {
9
+ "type": "string",
10
+ "validator": "RegExp",
11
+ "options": {
12
+ "pattern": "^[a-z]{3, 10}+$",
13
+ "rule": "match",
14
+ "human": "only 3 to 10 letters from a-z in lower case are allowed"
15
+ },
16
+ "required": true
17
+ },
18
+ "email": {
19
+ "type": "string",
20
+ "validator": "Email",
21
+ "required": true
22
+ },
23
+ "password": {
24
+ "type": "string",
25
+ "required": true
26
+ },
27
+ "passwordConfirm": {
28
+ "type": "string",
29
+ "validator": "same",
30
+ "options": { "as": "password" },
31
+ "required": true
32
+ }
33
+ }
34
+ }
@@ -0,0 +1,171 @@
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: 'Simple Boolean Switch',
30
+ desc: 'Checkbox vs. Switch\nhttps://uxplanet.org/checkbox-vs-toggle-switch-7fc6e83f10b8',
31
+ key: 'simpleSwitch',
32
+ validation: { type: 'boolean' },
33
+ render: [
34
+ 'simpleSwitch'
35
+ ]
36
+ },
37
+ {
38
+ label: 'Simple Boolean Checkbox',
39
+ desc: 'Checkbox vs. Switch\nhttps://uxplanet.org/checkbox-vs-toggle-switch-7fc6e83f10b8',
40
+ key: 'simpleCheckbox',
41
+ validation: { type: 'boolean' },
42
+ render: [
43
+ [
44
+ 'simpleCheckbox',
45
+ { variant: 'checkbox' }
46
+ ]
47
+ ]
48
+ },
49
+ {
50
+ label: 'Boolean Label Placement',
51
+ key: 'booleanLabelPlace',
52
+ validation: { type: 'boolean' },
53
+ render: [
54
+ [
55
+ 'booleanLabelPlace',
56
+ { labelPlacement: 'start' }
57
+ ]
58
+ ]
59
+ },
60
+ {
61
+ label: 'Simple Number',
62
+ key: 'simpleNumber',
63
+ render: ['simpleNumber'],
64
+ validation: { type: 'number' }
65
+ },
66
+ {
67
+ label: 'Advanced Number',
68
+ key: 'advancedNumber',
69
+ render: [
70
+ [
71
+ 'advancedNumber',
72
+ {
73
+ min: 0,
74
+ max: 2,
75
+ step: 0.25
76
+ }
77
+ ]
78
+ ],
79
+ validation: { type: 'number' }
80
+ },
81
+ {
82
+ label: 'Simple Select',
83
+ desc: 'Values are automatically sorted with [localeCompare](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare).',
84
+ key: 'simpleSelect',
85
+ render: ['simpleSelect'],
86
+ validation: {
87
+ type: ['Citrus', 'Banana', 'Apple', 'Date']
88
+ }
89
+ },
90
+ {
91
+ label: 'Date',
92
+ key: 'dateInput',
93
+ render: [
94
+ [
95
+ 'dateInput',
96
+ { type: 'date' }
97
+ ]
98
+ ],
99
+ validation: { type: 'string' }
100
+ },
101
+ {
102
+ label: 'Local DateTime',
103
+ key: 'localDateTime',
104
+ render: [
105
+ [
106
+ 'localDateTime',
107
+ { type: 'datetime-local' }
108
+ ]
109
+ ],
110
+ validation: { type: 'string' }
111
+ },
112
+ {
113
+ label: 'Array as Repeater',
114
+ key: 'arrayRepeater',
115
+ render: ['arrayRepeater'],
116
+ validation: { type: 'array' }
117
+ }
118
+ ]
119
+
120
+ export default () => {
121
+ const renderSchema = {
122
+ properties: {},
123
+ groups: []
124
+ }
125
+
126
+ const validationSchema = {
127
+ $schema: 'http://json-schema.org/draft-07/schema#',
128
+ $id: 'http://scenid.com/crm/register.schema.json',
129
+ title: 'Types',
130
+ type: 'object',
131
+ properties: {}
132
+ }
133
+
134
+ const translations = { labels: {} }
135
+
136
+ inputs.forEach(({ key, label, desc, validation, render }) => {
137
+ const validationJSON = JSON.stringify({ [key]: validation }, null, ' ')
138
+ const renderJSON = JSON.stringify(render, null, ' ')
139
+
140
+ const renderEntry = {
141
+ id: key,
142
+ label,
143
+ fields: [
144
+ [
145
+ "@@markdown",
146
+ "mmd-id",
147
+ `\`\`\`json\n/* validation schema */\n${validationJSON}\n\n/* render schema */\n${renderJSON}\n\`\`\``
148
+ ],
149
+ render[0]
150
+ ]
151
+ }
152
+
153
+ if (desc) {
154
+ renderEntry.fields.unshift([
155
+ "@@markdown",
156
+ "mmd-desc-id",
157
+ desc
158
+ ])
159
+ }
160
+
161
+ renderSchema.groups.push(renderEntry)
162
+ validationSchema.properties[key] = validation
163
+ translations.labels[key] = label
164
+ })
165
+
166
+ return {
167
+ render: renderSchema,
168
+ validation: validationSchema,
169
+ translations
170
+ }
171
+ }