@jsonforms/examples 3.1.0-alpha.1 → 3.1.0-alpha.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 (110) hide show
  1. package/.eslintrc.js +29 -0
  2. package/.prettierrc.js +6 -0
  3. package/README.md +1 -1
  4. package/docs/assets/js/search.json +1 -1
  5. package/docs/globals.html +1860 -3124
  6. package/docs/index.html +0 -30
  7. package/lib/examples/1884.d.ts +8 -0
  8. package/lib/examples/additional-errors.d.ts +16 -1
  9. package/lib/examples/anyOf.d.ts +15 -2
  10. package/lib/examples/arraysI18n.d.ts +52 -0
  11. package/lib/examples/dates.d.ts +115 -1
  12. package/lib/examples/enum.d.ts +3 -0
  13. package/lib/examples/generate-dynamic.d.ts +15 -0
  14. package/lib/examples/list-with-detail-primitives.d.ts +36 -0
  15. package/lib/examples/list-with-detail-registered.d.ts +55 -1
  16. package/lib/examples/list-with-detail.d.ts +191 -1
  17. package/lib/examples/nestedCategorization.d.ts +57 -0
  18. package/lib/examples/radioGroup.d.ts +42 -1
  19. package/lib/index.d.ts +8 -19
  20. package/lib/jsonforms-examples.cjs.js +2279 -2873
  21. package/lib/jsonforms-examples.cjs.js.map +1 -1
  22. package/lib/jsonforms-examples.esm.js +2271 -2882
  23. package/lib/jsonforms-examples.esm.js.map +1 -1
  24. package/package.json +13 -6
  25. package/rollup.config.js +12 -12
  26. package/src/example.ts +3 -3
  27. package/src/examples/1884.ts +52 -48
  28. package/src/examples/1948.ts +19 -19
  29. package/src/examples/additional-errors.ts +28 -25
  30. package/src/examples/allOf.ts +18 -18
  31. package/src/examples/anyOf-oneOf-allOf-resolve.ts +21 -21
  32. package/src/examples/anyOf.ts +42 -24
  33. package/src/examples/arrays-with-custom-element-label.ts +21 -21
  34. package/src/examples/arrays-with-detail-and-rule.ts +28 -28
  35. package/src/examples/arrays-with-detail.ts +21 -21
  36. package/src/examples/arrays-with-sorting.ts +35 -35
  37. package/src/examples/arrays.ts +35 -35
  38. package/src/examples/arraysI18n.ts +107 -0
  39. package/src/examples/{steppershownav.ts → categorization-stepper-nav-buttons.ts} +6 -6
  40. package/src/examples/{stepper.ts → categorization-stepper.ts} +5 -5
  41. package/src/examples/categorization.ts +119 -119
  42. package/src/examples/conditional-schema-compositions.ts +20 -20
  43. package/src/examples/config.ts +15 -15
  44. package/src/examples/control-options.ts +81 -82
  45. package/src/examples/dates.ts +34 -34
  46. package/src/examples/default.ts +22 -22
  47. package/src/examples/{multi-enum.ts → enum-multi.ts} +14 -14
  48. package/src/examples/enum.ts +40 -33
  49. package/src/examples/enumInArray.ts +10 -10
  50. package/src/examples/{dynamic.ts → generate-dynamic.ts} +10 -10
  51. package/src/examples/generate.ts +2 -2
  52. package/src/examples/generateUI.ts +2 -2
  53. package/src/examples/huge.ts +381 -377
  54. package/src/examples/i18n.ts +37 -28
  55. package/src/examples/if_then_else.ts +4 -4
  56. package/src/examples/layout.ts +29 -29
  57. package/src/examples/{booleanToggle.ts → list-with-detail-primitives.ts} +46 -33
  58. package/src/examples/list-with-detail-registered.ts +26 -26
  59. package/src/examples/list-with-detail.ts +82 -82
  60. package/src/examples/nestedArrays.ts +40 -35
  61. package/src/examples/nestedCategorization.ts +175 -0
  62. package/src/examples/numbers.ts +17 -17
  63. package/src/examples/object.ts +24 -24
  64. package/src/examples/onChange.ts +28 -22
  65. package/src/examples/oneOf-recursive.ts +15 -15
  66. package/src/examples/oneOf.ts +99 -96
  67. package/src/examples/oneOfArray.ts +20 -20
  68. package/src/examples/person.ts +35 -35
  69. package/src/examples/radioGroup.ts +52 -53
  70. package/src/examples/readonly.ts +14 -14
  71. package/src/examples/rule.ts +26 -26
  72. package/src/examples/ruleInheritance.ts +37 -34
  73. package/src/examples/scope.ts +26 -26
  74. package/src/examples/stringArray.ts +10 -10
  75. package/src/examples/text.ts +19 -19
  76. package/src/index.ts +11 -33
  77. package/src/register.ts +6 -3
  78. package/stats.html +2462 -329
  79. package/tsconfig.json +2 -6
  80. package/lib/examples/1169.d.ts +0 -24
  81. package/lib/examples/1220.d.ts +0 -4
  82. package/lib/examples/1253.d.ts +0 -16
  83. package/lib/examples/1254.d.ts +0 -21
  84. package/lib/examples/1645.d.ts +0 -68
  85. package/lib/examples/1779.d.ts +0 -1
  86. package/lib/examples/1996.d.ts +0 -31
  87. package/lib/examples/booleanToggle.d.ts +0 -62
  88. package/lib/examples/day1.d.ts +0 -23
  89. package/lib/examples/day2.d.ts +0 -42
  90. package/lib/examples/day3.d.ts +0 -51
  91. package/lib/examples/day4.d.ts +0 -72
  92. package/lib/examples/day5.d.ts +0 -133
  93. package/lib/examples/day6.d.ts +0 -85
  94. package/lib/examples/dynamic.d.ts +0 -1
  95. package/src/examples/1169.ts +0 -62
  96. package/src/examples/1220.ts +0 -146
  97. package/src/examples/1253.ts +0 -212
  98. package/src/examples/1254.ts +0 -67
  99. package/src/examples/1645.ts +0 -66
  100. package/src/examples/1779.ts +0 -83
  101. package/src/examples/1996.ts +0 -102
  102. package/src/examples/day1.ts +0 -61
  103. package/src/examples/day2.ts +0 -62
  104. package/src/examples/day3.ts +0 -76
  105. package/src/examples/day4.ts +0 -83
  106. package/src/examples/day5.ts +0 -169
  107. package/src/examples/day6.ts +0 -44
  108. /package/lib/examples/{steppershownav.d.ts → categorization-stepper-nav-buttons.d.ts} +0 -0
  109. /package/lib/examples/{stepper.d.ts → categorization-stepper.d.ts} +0 -0
  110. /package/lib/examples/{multi-enum.d.ts → enum-multi.d.ts} +0 -0
@@ -24,20 +24,29 @@
24
24
  */
25
25
  import { registerExamples } from '../register';
26
26
  import { personCoreSchema } from './person';
27
- import { JsonFormsCore, updateErrors, AnyAction, Dispatch, Translator } from '@jsonforms/core';
27
+ import {
28
+ JsonFormsCore,
29
+ updateErrors,
30
+ AnyAction,
31
+ Dispatch,
32
+ Translator,
33
+ } from '@jsonforms/core';
28
34
  import get from 'lodash/get';
35
+ // TODO change import when types are available for ajv-i18n (from v4.x)
36
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
29
37
  const localize = require('ajv-i18n');
30
38
 
31
- export const onChange = (dispatch: Dispatch<AnyAction>) => (
32
- extensionState: any
33
- ) => ({ errors }: Pick<JsonFormsCore, 'data' | 'errors'>) => {
34
- if (!extensionState) {
35
- return;
36
- }
37
- const localiseFunc = localize[extensionState.locale.split('-')[0]];
38
- localiseFunc(errors);
39
- dispatch(updateErrors(errors));
40
- };
39
+ export const onChange =
40
+ (dispatch: Dispatch<AnyAction>) =>
41
+ (extensionState: any) =>
42
+ ({ errors }: Pick<JsonFormsCore, 'data' | 'errors'>) => {
43
+ if (!extensionState) {
44
+ return;
45
+ }
46
+ const localiseFunc = localize[extensionState.locale.split('-')[0]];
47
+ localiseFunc(errors);
48
+ dispatch(updateErrors(errors));
49
+ };
41
50
 
42
51
  export const uischema = {
43
52
  type: 'VerticalLayout',
@@ -48,13 +57,13 @@ export const uischema = {
48
57
  elements: [
49
58
  {
50
59
  type: 'Control',
51
- scope: '#/properties/name'
60
+ scope: '#/properties/name',
52
61
  },
53
62
  {
54
63
  type: 'Control',
55
- scope: '#/properties/birthDate'
56
- }
57
- ]
64
+ scope: '#/properties/birthDate',
65
+ },
66
+ ],
58
67
  },
59
68
  {
60
69
  type: 'Label',
@@ -65,31 +74,31 @@ export const uischema = {
65
74
  elements: [
66
75
  {
67
76
  type: 'Control',
68
- scope: '#/properties/nationality'
77
+ scope: '#/properties/nationality',
69
78
  },
70
79
  {
71
80
  type: 'Control',
72
- scope: '#/properties/vegetarian'
73
- }
74
- ]
75
- }
76
- ]
81
+ scope: '#/properties/vegetarian',
82
+ },
83
+ ],
84
+ },
85
+ ],
77
86
  };
78
87
 
79
88
  export const data = {
80
89
  vegetarian: false,
81
90
  birthDate: '1985-06-02',
82
91
  personalData: {
83
- age: 34
92
+ age: 34,
84
93
  },
85
- postalCode: '12345'
94
+ postalCode: '12345',
86
95
  };
87
96
 
88
97
  export const translations = {
89
98
  basicInfoGroup: {
90
- label: 'Basic Information'
99
+ label: 'Basic Information',
91
100
  },
92
- additionalInformationLabel: 'Additional Information'
101
+ additionalInformationLabel: 'Additional Information',
93
102
  };
94
103
  export const translate: Translator = (key: string, defaultMessage: string) => {
95
104
  return get(translations, key) ?? defaultMessage;
@@ -104,7 +113,7 @@ registerExamples([
104
113
  uischema,
105
114
  i18n: {
106
115
  translate: translate,
107
- locale: 'en'
108
- }
109
- }
116
+ locale: 'en',
117
+ },
118
+ },
110
119
  ]);
@@ -29,10 +29,10 @@ export const schema = {
29
29
  type: 'object',
30
30
  properties: {
31
31
  b: { type: 'boolean' },
32
- c: { type: 'string', minLength: 1 }
32
+ c: { type: 'string', minLength: 1 },
33
33
  },
34
34
  if: { properties: { b: { enum: [false] } } },
35
- then: { required: ['c'] }
35
+ then: { required: ['c'] },
36
36
  };
37
37
 
38
38
  export const uischema: UISchemaElement = undefined;
@@ -45,6 +45,6 @@ registerExamples([
45
45
  label: 'If Then Else',
46
46
  data,
47
47
  schema,
48
- uischema
49
- }
48
+ uischema,
49
+ },
50
50
  ]);
@@ -33,14 +33,14 @@ export const uischemaVertical = {
33
33
  {
34
34
  type: 'Control',
35
35
  label: 'Name',
36
- scope: '#/properties/name'
36
+ scope: '#/properties/name',
37
37
  },
38
38
  {
39
39
  type: 'Control',
40
40
  label: 'Birth Date',
41
- scope: '#/properties/birthDate'
42
- }
43
- ]
41
+ scope: '#/properties/birthDate',
42
+ },
43
+ ],
44
44
  };
45
45
  export const uischemaHorizontal = {
46
46
  type: 'HorizontalLayout',
@@ -48,14 +48,14 @@ export const uischemaHorizontal = {
48
48
  {
49
49
  type: 'Control',
50
50
  label: 'Name',
51
- scope: '#/properties/name'
51
+ scope: '#/properties/name',
52
52
  },
53
53
  {
54
54
  type: 'Control',
55
55
  label: 'Birth Date',
56
- scope: '#/properties/birthDate'
57
- }
58
- ]
56
+ scope: '#/properties/birthDate',
57
+ },
58
+ ],
59
59
  };
60
60
  export const uischemaGroup = {
61
61
  type: 'Group',
@@ -64,14 +64,14 @@ export const uischemaGroup = {
64
64
  {
65
65
  type: 'Control',
66
66
  label: 'Name',
67
- scope: '#/properties/name'
67
+ scope: '#/properties/name',
68
68
  },
69
69
  {
70
70
  type: 'Control',
71
71
  label: 'Birth Date',
72
- scope: '#/properties/birthDate'
73
- }
74
- ]
72
+ scope: '#/properties/birthDate',
73
+ },
74
+ ],
75
75
  };
76
76
  export const uischemaComplex = {
77
77
  type: 'Group',
@@ -86,14 +86,14 @@ export const uischemaComplex = {
86
86
  {
87
87
  type: 'Control',
88
88
  label: 'Name',
89
- scope: '#/properties/name'
89
+ scope: '#/properties/name',
90
90
  },
91
91
  {
92
92
  type: 'Control',
93
93
  label: 'Birth Date',
94
- scope: '#/properties/birthDate'
95
- }
96
- ]
94
+ scope: '#/properties/birthDate',
95
+ },
96
+ ],
97
97
  },
98
98
  {
99
99
  type: 'VerticalLayout',
@@ -101,18 +101,18 @@ export const uischemaComplex = {
101
101
  {
102
102
  type: 'Control',
103
103
  label: 'Name',
104
- scope: '#/properties/name'
104
+ scope: '#/properties/name',
105
105
  },
106
106
  {
107
107
  type: 'Control',
108
108
  label: 'Birth Date',
109
- scope: '#/properties/birthDate'
110
- }
111
- ]
112
- }
113
- ]
114
- }
115
- ]
109
+ scope: '#/properties/birthDate',
110
+ },
111
+ ],
112
+ },
113
+ ],
114
+ },
115
+ ],
116
116
  };
117
117
  export const data = personData;
118
118
 
@@ -122,27 +122,27 @@ registerExamples([
122
122
  label: 'Layout Vertical',
123
123
  data,
124
124
  schema,
125
- uischema: uischemaVertical
125
+ uischema: uischemaVertical,
126
126
  },
127
127
  {
128
128
  name: 'layout-horizontal',
129
129
  label: 'Layout Horizontal',
130
130
  data,
131
131
  schema,
132
- uischema: uischemaHorizontal
132
+ uischema: uischemaHorizontal,
133
133
  },
134
134
  {
135
135
  name: 'layout-group',
136
136
  label: 'Layout Group',
137
137
  data,
138
138
  schema,
139
- uischema: uischemaGroup
139
+ uischema: uischemaGroup,
140
140
  },
141
141
  {
142
142
  name: 'layout-complex',
143
143
  label: 'Layout Complex',
144
144
  data,
145
145
  schema,
146
- uischema: uischemaComplex
147
- }
146
+ uischema: uischemaComplex,
147
+ },
148
148
  ]);
@@ -22,49 +22,62 @@
22
22
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
23
  THE SOFTWARE.
24
24
  */
25
-
26
25
  import { registerExamples } from '../register';
27
26
 
27
+ export const data = {
28
+ 'an-array-of-strings': ['foo', 'bar', 'foobar'],
29
+ };
28
30
  export const schema = {
29
31
  type: 'object',
30
32
  properties: {
31
- checkbox: {
32
- type: 'boolean'
33
+ 'an-array-of-strings': {
34
+ type: 'array',
35
+ items: {
36
+ type: 'string',
37
+ },
33
38
  },
34
- toggle: {
35
- type: 'boolean'
36
- }
37
- }
39
+ },
38
40
  };
39
-
40
41
  export const uischema = {
41
- type: 'VerticalLayout',
42
- elements: [
43
- {
44
- type: 'Control',
45
- scope: '#/properties/checkbox'
46
- },
47
- {
48
- type: 'Control',
49
- scope: '#/properties/toggle',
50
- options: {
51
- toggle: true
52
- }
53
- }
54
- ]
42
+ type: 'ListWithDetail',
43
+ scope: '#/properties/an-array-of-strings',
55
44
  };
56
45
 
57
- export const data = {
58
- checkbox: false,
59
- toggle: false
60
- };
46
+ registerExamples([
47
+ {
48
+ name: 'list-with-detail-primitive-string',
49
+ label: 'List With Detail primitive (string)',
50
+ data,
51
+ schema,
52
+ uischema,
53
+ },
54
+ ]);
61
55
 
62
- export const booleanToggleExample = {
63
- name: 'booleanToggle',
64
- label: 'Boolean Toggle',
65
- data,
66
- schema,
67
- uischema
56
+ export const data_number = {
57
+ 'an-array-of-numbers': [1, 2, 3],
58
+ };
59
+ export const schema_number = {
60
+ type: 'object',
61
+ properties: {
62
+ 'an-array-of-numbers': {
63
+ type: 'array',
64
+ items: {
65
+ type: 'number',
66
+ },
67
+ },
68
+ },
69
+ };
70
+ export const uischema_number = {
71
+ type: 'ListWithDetail',
72
+ scope: '#/properties/an-array-of-numbers',
68
73
  };
69
74
 
70
- registerExamples([booleanToggleExample]);
75
+ registerExamples([
76
+ {
77
+ name: 'list-with-detail-primitive-number',
78
+ label: 'List With Detail primitive (number)',
79
+ data: data_number,
80
+ schema: schema_number,
81
+ uischema: uischema_number,
82
+ },
83
+ ]);
@@ -24,36 +24,36 @@
24
24
  */
25
25
  import { registerExamples } from '../register';
26
26
 
27
- const data = {
27
+ export const data = {
28
28
  warehouseitems: [
29
29
  {
30
30
  name: 'Fantasy Book',
31
31
  buyer: {
32
32
  email: 'buyerA@info.org',
33
- age: 18
33
+ age: 18,
34
34
  },
35
- status: 'warehouse'
35
+ status: 'warehouse',
36
36
  },
37
37
  {
38
38
  name: 'Boardgame',
39
39
  buyer: {
40
40
  email: 'buyerB@info.org',
41
- age: 45
41
+ age: 45,
42
42
  },
43
- status: 'shipping'
43
+ status: 'shipping',
44
44
  },
45
45
  {
46
46
  name: 'Energy Drink',
47
47
  buyer: {
48
48
  email: 'buyerC@info.org',
49
- age: 90
49
+ age: 90,
50
50
  },
51
- status: 'delivered'
52
- }
53
- ]
51
+ status: 'delivered',
52
+ },
53
+ ],
54
54
  };
55
55
 
56
- const schema = {
56
+ export const schema = {
57
57
  definitions: {
58
58
  warehouseitem: {
59
59
  type: 'object',
@@ -63,43 +63,43 @@ const schema = {
63
63
  type: 'object',
64
64
  properties: {
65
65
  email: { type: 'string', format: 'email' },
66
- age: { type: 'number' }
67
- }
66
+ age: { type: 'number' },
67
+ },
68
68
  },
69
69
  status: {
70
70
  type: 'string',
71
- enum: ['warehouse', 'shipping', 'delivered']
72
- }
71
+ enum: ['warehouse', 'shipping', 'delivered'],
72
+ },
73
73
  },
74
- required: ['name']
75
- }
74
+ required: ['name'],
75
+ },
76
76
  },
77
77
  type: 'object',
78
78
  properties: {
79
79
  warehouseitems: {
80
80
  type: 'array',
81
81
  items: {
82
- $ref: '#/definitions/warehouseitem'
83
- }
84
- }
85
- }
82
+ $ref: '#/definitions/warehouseitem',
83
+ },
84
+ },
85
+ },
86
86
  };
87
87
 
88
- const uischema = {
88
+ export const uischema = {
89
89
  type: 'ListWithDetail',
90
90
  scope: '#/properties/warehouseitems',
91
91
  options: {
92
- labelRef: '#/items/properties/name'
92
+ labelRef: '#/items/properties/name',
93
93
  // detail uischema is registered in example itself
94
- }
94
+ },
95
95
  };
96
96
 
97
97
  registerExamples([
98
98
  {
99
99
  name: 'list-with-detail-registered',
100
- label: 'List With Detail (Registered)',
100
+ label: 'List With Detail (Registered Detail UISchema)',
101
101
  data,
102
102
  schema,
103
- uischema
104
- }
103
+ uischema,
104
+ },
105
105
  ]);