@jsonforms/core 3.0.0-alpha.0 → 3.0.0-beta.0

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 (268) hide show
  1. package/README.md +1 -1
  2. package/docs/assets/js/search.json +1 -1
  3. package/docs/enums/ruleeffect.html +4 -4
  4. package/docs/globals.html +1095 -703
  5. package/docs/index.html +70 -43
  6. package/docs/interfaces/addcellrendereraction.html +3 -3
  7. package/docs/interfaces/addrendereraction.html +3 -3
  8. package/docs/interfaces/adduischemaaction.html +3 -3
  9. package/docs/interfaces/andcondition.html +2 -2
  10. package/docs/interfaces/arraycontrolprops.html +22 -22
  11. package/docs/interfaces/arraylayoutprops.html +22 -22
  12. package/docs/interfaces/categorization.html +5 -5
  13. package/docs/interfaces/category.html +5 -5
  14. package/docs/interfaces/cellprops.html +14 -14
  15. package/docs/interfaces/combinatorrendererprops.html +13 -13
  16. package/docs/interfaces/combinatorsubschemarenderinfo.html +3 -3
  17. package/docs/interfaces/composablecondition.html +2 -2
  18. package/docs/interfaces/condition.html +1 -1
  19. package/docs/interfaces/controlelement.html +5 -5
  20. package/docs/interfaces/controlprops.html +17 -17
  21. package/docs/interfaces/controlstate.html +2 -2
  22. package/docs/interfaces/controlwithdetailprops.html +18 -18
  23. package/docs/interfaces/dispatchcellprops.html +13 -13
  24. package/docs/interfaces/dispatchcellstateprops.html +13 -13
  25. package/docs/interfaces/dispatchpropsofarraycontrol.html +4 -4
  26. package/docs/interfaces/dispatchpropsofcontrol.html +1 -1
  27. package/docs/interfaces/dispatchpropsofmultienumcontrol.html +2 -2
  28. package/docs/interfaces/enumcellprops.html +15 -15
  29. package/docs/interfaces/enumoption.html +2 -2
  30. package/docs/interfaces/formatted.html +2 -2
  31. package/docs/interfaces/grouplayout.html +5 -5
  32. package/docs/interfaces/horizontallayout.html +4 -4
  33. package/docs/interfaces/initaction.html +6 -6
  34. package/docs/interfaces/initactionoptions.html +3 -3
  35. package/docs/interfaces/jsonformscellrendererregistryentry.html +2 -2
  36. package/docs/interfaces/jsonformscore.html +7 -7
  37. package/docs/interfaces/jsonformsdefaultdataregistryentry.html +2 -2
  38. package/docs/interfaces/jsonformsextendedstate.html +1 -1
  39. package/docs/interfaces/{jsonformslocalestate.html → jsonformsi18nstate.html} +20 -20
  40. package/docs/interfaces/jsonformsprops.html +9 -9
  41. package/docs/interfaces/jsonformsrendererregistryentry.html +2 -2
  42. package/docs/interfaces/jsonformsstate.html +1 -1
  43. package/docs/interfaces/jsonformsstore.html +5 -5
  44. package/docs/interfaces/jsonformssubstates.html +18 -8
  45. package/docs/interfaces/jsonformsuischemaregistryentry.html +2 -2
  46. package/docs/interfaces/labeldescription.html +2 -2
  47. package/docs/interfaces/labelelement.html +4 -4
  48. package/docs/interfaces/layout.html +4 -4
  49. package/docs/interfaces/layoutprops.html +10 -10
  50. package/docs/interfaces/leafcondition.html +3 -3
  51. package/docs/interfaces/orcondition.html +2 -2
  52. package/docs/interfaces/ownpropsofcell.html +10 -10
  53. package/docs/interfaces/ownpropsofcontrol.html +9 -9
  54. package/docs/interfaces/ownpropsofenum.html +1 -1
  55. package/docs/interfaces/ownpropsofenumcell.html +11 -11
  56. package/docs/interfaces/ownpropsofjsonformsrenderer.html +8 -8
  57. package/docs/interfaces/ownpropsoflayout.html +9 -9
  58. package/docs/interfaces/ownpropsofmasterlistitem.html +6 -6
  59. package/docs/interfaces/ownpropsofrenderer.html +8 -8
  60. package/docs/interfaces/registerdefaultdataaction.html +3 -3
  61. package/docs/interfaces/removecellrendereraction.html +3 -3
  62. package/docs/interfaces/removerendereraction.html +3 -3
  63. package/docs/interfaces/removeuischemaaction.html +2 -2
  64. package/docs/interfaces/rendererprops.html +9 -9
  65. package/docs/interfaces/rule.html +2 -2
  66. package/docs/interfaces/schemabasedcondition.html +3 -3
  67. package/docs/interfaces/scopable.html +1 -1
  68. package/docs/interfaces/setajvaction.html +3 -3
  69. package/docs/interfaces/setconfigaction.html +2 -2
  70. package/docs/interfaces/setlocaleaction.html +3 -3
  71. package/docs/interfaces/setschemaaction.html +2 -2
  72. package/docs/interfaces/{setlocalizedschemasaction.html → settranslatoraction.html} +29 -15
  73. package/docs/interfaces/setuischemaaction.html +2 -2
  74. package/docs/interfaces/setvalidationmodeaction.html +2 -2
  75. package/docs/interfaces/statepropsofarraycontrol.html +18 -18
  76. package/docs/interfaces/statepropsofarraylayout.html +18 -18
  77. package/docs/interfaces/statepropsofcell.html +13 -13
  78. package/docs/interfaces/statepropsofcombinator.html +12 -12
  79. package/docs/interfaces/statepropsofcontrol.html +16 -16
  80. package/docs/interfaces/statepropsofcontrolwithdetail.html +17 -17
  81. package/docs/interfaces/statepropsofenumcell.html +14 -14
  82. package/docs/interfaces/statepropsofjsonformsrenderer.html +9 -9
  83. package/docs/interfaces/statepropsoflayout.html +10 -10
  84. package/docs/interfaces/statepropsofmasteritem.html +7 -7
  85. package/docs/interfaces/statepropsofrenderer.html +9 -9
  86. package/docs/interfaces/statepropsofscopedrenderer.html +12 -12
  87. package/docs/interfaces/uischemaelement.html +3 -3
  88. package/docs/interfaces/unregisterdefaultdataaction.html +2 -2
  89. package/docs/interfaces/updateaction.html +3 -3
  90. package/docs/interfaces/updatecoreaction.html +6 -6
  91. package/docs/interfaces/updateerrorsaction.html +2 -2
  92. package/docs/interfaces/{setlocalizeduischemasaction.html → updatei18naction.html} +43 -15
  93. package/docs/interfaces/verticallayout.html +4 -4
  94. package/docs/interfaces/withclassname.html +1 -1
  95. package/lib/Helpers.d.ts +5 -0
  96. package/lib/actions/actions.d.ts +181 -0
  97. package/lib/actions/index.d.ts +1 -178
  98. package/lib/configDefault.d.ts +6 -6
  99. package/lib/generators/Generate.d.ts +6 -0
  100. package/lib/generators/index.d.ts +3 -10
  101. package/lib/generators/schema.d.ts +8 -8
  102. package/lib/generators/uischema.d.ts +12 -13
  103. package/lib/i18n/i18nTypes.d.ts +15 -0
  104. package/lib/i18n/i18nUtil.d.ts +18 -0
  105. package/lib/i18n/index.d.ts +2 -0
  106. package/lib/index.d.ts +11 -23
  107. package/lib/jsonforms-core.cjs.js +2445 -0
  108. package/lib/jsonforms-core.cjs.js.map +1 -0
  109. package/lib/jsonforms-core.esm.js +2164 -0
  110. package/lib/jsonforms-core.esm.js.map +1 -0
  111. package/lib/models/draft4.d.ts +198 -198
  112. package/lib/models/index.d.ts +5 -0
  113. package/lib/models/jsonSchema.d.ts +3 -3
  114. package/lib/models/jsonSchema4.d.ts +110 -110
  115. package/lib/models/jsonSchema7.d.ts +119 -119
  116. package/lib/models/uischema.d.ts +201 -201
  117. package/lib/reducers/cells.d.ts +11 -11
  118. package/lib/reducers/config.d.ts +3 -3
  119. package/lib/reducers/core.d.ts +24 -23
  120. package/lib/reducers/default-data.d.ts +10 -10
  121. package/lib/reducers/i18n.d.ts +8 -11
  122. package/lib/reducers/index.d.ts +9 -47
  123. package/lib/reducers/reducers.d.ts +29 -0
  124. package/lib/reducers/renderers.d.ts +10 -10
  125. package/lib/reducers/selectors.d.ts +15 -0
  126. package/lib/reducers/uischemas.d.ts +10 -10
  127. package/lib/store.d.ts +53 -56
  128. package/lib/testers/index.d.ts +1 -204
  129. package/lib/testers/testers.d.ts +203 -0
  130. package/lib/util/Formatted.d.ts +19 -19
  131. package/lib/util/array.d.ts +3 -3
  132. package/lib/util/cell.d.ts +79 -79
  133. package/lib/util/combinators.d.ts +10 -11
  134. package/lib/util/ids.d.ts +3 -3
  135. package/lib/util/index.d.ts +15 -49
  136. package/lib/util/label.d.ts +9 -10
  137. package/lib/util/path.d.ts +25 -24
  138. package/lib/util/renderer.d.ts +398 -395
  139. package/lib/util/resolvers.d.ts +25 -25
  140. package/lib/util/runtime.d.ts +18 -19
  141. package/lib/util/schema.d.ts +1 -1
  142. package/lib/util/type.d.ts +174 -174
  143. package/lib/util/uischema.d.ts +5 -5
  144. package/lib/util/util.d.ts +31 -0
  145. package/lib/util/validator.d.ts +3 -2
  146. package/package.json +18 -14
  147. package/rollup.config.js +44 -0
  148. package/{lib/models/jsonSchema4.js → src/Helpers.ts} +16 -8
  149. package/src/actions/actions.ts +345 -0
  150. package/src/actions/index.ts +1 -310
  151. package/src/configDefault.ts +1 -0
  152. package/{lib/util/validator.js → src/generators/Generate.ts} +18 -11
  153. package/src/generators/index.ts +3 -21
  154. package/src/generators/schema.ts +1 -1
  155. package/src/generators/uischema.ts +4 -4
  156. package/src/i18n/i18nTypes.ts +17 -0
  157. package/src/i18n/i18nUtil.ts +105 -0
  158. package/src/i18n/index.ts +2 -0
  159. package/src/index.ts +7 -31
  160. package/src/models/draft4.ts +1 -0
  161. package/{lib/util/type.js → src/models/index.ts} +10 -7
  162. package/src/models/jsonSchema.ts +1 -0
  163. package/src/models/uischema.ts +1 -0
  164. package/src/reducers/cells.ts +2 -1
  165. package/src/reducers/config.ts +2 -1
  166. package/src/reducers/core.ts +74 -52
  167. package/src/reducers/default-data.ts +2 -1
  168. package/src/reducers/i18n.ts +42 -35
  169. package/src/reducers/index.ts +9 -154
  170. package/src/reducers/reducers.ts +128 -0
  171. package/src/reducers/renderers.ts +2 -1
  172. package/src/reducers/selectors.ts +65 -0
  173. package/src/reducers/uischemas.ts +4 -2
  174. package/src/store.ts +11 -8
  175. package/src/testers/index.ts +1 -516
  176. package/src/testers/testers.ts +547 -0
  177. package/src/util/Formatted.ts +1 -0
  178. package/src/util/array.ts +25 -0
  179. package/src/util/cell.ts +45 -10
  180. package/src/util/combinators.ts +2 -4
  181. package/src/util/ids.ts +1 -0
  182. package/src/util/index.ts +11 -123
  183. package/src/util/label.ts +2 -2
  184. package/src/util/path.ts +4 -1
  185. package/src/util/renderer.ts +139 -66
  186. package/src/util/resolvers.ts +2 -1
  187. package/src/util/runtime.ts +3 -2
  188. package/src/util/schema.ts +26 -1
  189. package/src/util/uischema.ts +2 -1
  190. package/src/util/util.ts +127 -0
  191. package/src/util/validator.ts +5 -8
  192. package/stats.html +3279 -0
  193. package/{lib/configDefault.js → test/i18n/i18nUtil.test.ts} +25 -24
  194. package/test/reducers/core.test.ts +31 -44
  195. package/test/util/cell.test.ts +2 -2
  196. package/test/util/renderer.test.ts +543 -31
  197. package/docs/interfaces/labels.html +0 -157
  198. package/lib/actions/index.js +0 -125
  199. package/lib/actions/index.js.map +0 -1
  200. package/lib/configDefault.js.map +0 -1
  201. package/lib/generators/index.js +0 -12
  202. package/lib/generators/index.js.map +0 -1
  203. package/lib/generators/schema.js +0 -152
  204. package/lib/generators/schema.js.map +0 -1
  205. package/lib/generators/uischema.js +0 -167
  206. package/lib/generators/uischema.js.map +0 -1
  207. package/lib/index.js +0 -45
  208. package/lib/index.js.map +0 -1
  209. package/lib/jsonforms-core.js +0 -19
  210. package/lib/jsonforms-core.js.map +0 -1
  211. package/lib/models/draft4.js +0 -173
  212. package/lib/models/draft4.js.map +0 -1
  213. package/lib/models/jsonSchema.js +0 -3
  214. package/lib/models/jsonSchema.js.map +0 -1
  215. package/lib/models/jsonSchema4.js.map +0 -1
  216. package/lib/models/jsonSchema7.js +0 -30
  217. package/lib/models/jsonSchema7.js.map +0 -1
  218. package/lib/models/uischema.js +0 -31
  219. package/lib/models/uischema.js.map +0 -1
  220. package/lib/reducers/cells.js +0 -16
  221. package/lib/reducers/cells.js.map +0 -1
  222. package/lib/reducers/config.js +0 -44
  223. package/lib/reducers/config.js.map +0 -1
  224. package/lib/reducers/core.js +0 -259
  225. package/lib/reducers/core.js.map +0 -1
  226. package/lib/reducers/default-data.js +0 -42
  227. package/lib/reducers/default-data.js.map +0 -1
  228. package/lib/reducers/i18n.js +0 -66
  229. package/lib/reducers/i18n.js.map +0 -1
  230. package/lib/reducers/index.js +0 -92
  231. package/lib/reducers/index.js.map +0 -1
  232. package/lib/reducers/renderers.js +0 -17
  233. package/lib/reducers/renderers.js.map +0 -1
  234. package/lib/reducers/uischemas.js +0 -57
  235. package/lib/reducers/uischemas.js.map +0 -1
  236. package/lib/store.js +0 -3
  237. package/lib/store.js.map +0 -1
  238. package/lib/testers/index.js +0 -402
  239. package/lib/testers/index.js.map +0 -1
  240. package/lib/util/Formatted.js +0 -3
  241. package/lib/util/Formatted.js.map +0 -1
  242. package/lib/util/array.js +0 -19
  243. package/lib/util/array.js.map +0 -1
  244. package/lib/util/cell.js +0 -133
  245. package/lib/util/cell.js.map +0 -1
  246. package/lib/util/combinators.js +0 -56
  247. package/lib/util/combinators.js.map +0 -1
  248. package/lib/util/ids.js +0 -50
  249. package/lib/util/ids.js.map +0 -1
  250. package/lib/util/index.js +0 -132
  251. package/lib/util/index.js.map +0 -1
  252. package/lib/util/label.js +0 -70
  253. package/lib/util/label.js.map +0 -1
  254. package/lib/util/path.js +0 -84
  255. package/lib/util/path.js.map +0 -1
  256. package/lib/util/renderer.js +0 -447
  257. package/lib/util/renderer.js.map +0 -1
  258. package/lib/util/resolvers.js +0 -165
  259. package/lib/util/resolvers.js.map +0 -1
  260. package/lib/util/runtime.js +0 -159
  261. package/lib/util/runtime.js.map +0 -1
  262. package/lib/util/schema.js +0 -16
  263. package/lib/util/schema.js.map +0 -1
  264. package/lib/util/type.js.map +0 -1
  265. package/lib/util/uischema.js +0 -52
  266. package/lib/util/uischema.js.map +0 -1
  267. package/lib/util/validator.js.map +0 -1
  268. package/webpack.build.js +0 -13
@@ -0,0 +1,345 @@
1
+ /*
2
+ The MIT License
3
+
4
+ Copyright (c) 2017-2019 EclipseSource Munich
5
+ https://github.com/eclipsesource/jsonforms
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in
15
+ all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ THE SOFTWARE.
24
+ */
25
+
26
+ import AJV, { ErrorObject } from 'ajv';
27
+ import { JsonSchema, UISchemaElement } from '../models';
28
+ import { generateDefaultUISchema, generateJsonSchema } from '../generators';
29
+
30
+ import { RankedTester } from '../testers';
31
+ import { UISchemaTester, ValidationMode } from '../reducers';
32
+ import { ErrorTranslator, Translator } from '../i18n';
33
+
34
+ export const INIT: 'jsonforms/INIT' = 'jsonforms/INIT';
35
+ export const UPDATE_CORE: 'jsonforms/UPDATE_CORE' = `jsonforms/UPDATE_CORE`;
36
+ export const SET_AJV: 'jsonforms/SET_AJV' = 'jsonforms/SET_AJV';
37
+ export const UPDATE_DATA: 'jsonforms/UPDATE' = 'jsonforms/UPDATE';
38
+ export const UPDATE_ERRORS: 'jsonforms/UPDATE_ERRORS' =
39
+ 'jsonforms/UPDATE_ERRORS';
40
+ export const VALIDATE: 'jsonforms/VALIDATE' = 'jsonforms/VALIDATE';
41
+ export const ADD_RENDERER: 'jsonforms/ADD_RENDERER' = 'jsonforms/ADD_RENDERER';
42
+ export const REMOVE_RENDERER: 'jsonforms/REMOVE_RENDERER' =
43
+ 'jsonforms/REMOVE_RENDERER';
44
+ export const ADD_CELL: 'jsonforms/ADD_CELL' = 'jsonforms/ADD_CELL';
45
+ export const REMOVE_CELL: 'jsonforms/REMOVE_CELL' = 'jsonforms/REMOVE_CELL';
46
+ export const SET_CONFIG: 'jsonforms/SET_CONFIG' = 'jsonforms/SET_CONFIG';
47
+ export const ADD_UI_SCHEMA: 'jsonforms/ADD_UI_SCHEMA' = `jsonforms/ADD_UI_SCHEMA`;
48
+ export const REMOVE_UI_SCHEMA: 'jsonforms/REMOVE_UI_SCHEMA' = `jsonforms/REMOVE_UI_SCHEMA`;
49
+ export const SET_SCHEMA: 'jsonforms/SET_SCHEMA' = `jsonforms/SET_SCHEMA`;
50
+ export const SET_UISCHEMA: 'jsonforms/SET_UISCHEMA' = `jsonforms/SET_UISCHEMA`;
51
+ export const SET_VALIDATION_MODE: 'jsonforms/SET_VALIDATION_MODE' =
52
+ 'jsonforms/SET_VALIDATION_MODE';
53
+
54
+ export const SET_LOCALE: 'jsonforms/SET_LOCALE' = `jsonforms/SET_LOCALE`;
55
+ export const SET_TRANSLATOR: 'jsonforms/SET_TRANSLATOR' =
56
+ 'jsonforms/SET_TRANSLATOR';
57
+ export const UPDATE_I18N: 'jsonforms/UPDATE_I18N' =
58
+ 'jsonforms/UPDATE_I18N';
59
+
60
+ export const ADD_DEFAULT_DATA: 'jsonforms/ADD_DEFAULT_DATA' = `jsonforms/ADD_DEFAULT_DATA`;
61
+ export const REMOVE_DEFAULT_DATA: 'jsonforms/REMOVE_DEFAULT_DATA' = `jsonforms/REMOVE_DEFAULT_DATA`;
62
+
63
+ export type CoreActions =
64
+ | InitAction
65
+ | UpdateCoreAction
66
+ | UpdateAction
67
+ | UpdateErrorsAction
68
+ | SetAjvAction
69
+ | SetSchemaAction
70
+ | SetUISchemaAction
71
+ | SetValidationModeAction;
72
+
73
+ export interface UpdateAction {
74
+ type: 'jsonforms/UPDATE';
75
+ path: string;
76
+ updater(existingData?: any): any;
77
+ }
78
+
79
+ export interface UpdateErrorsAction {
80
+ type: 'jsonforms/UPDATE_ERRORS';
81
+ errors: ErrorObject[];
82
+ }
83
+
84
+ export interface InitAction {
85
+ type: 'jsonforms/INIT';
86
+ data: any;
87
+ schema: JsonSchema;
88
+ uischema: UISchemaElement;
89
+ options?: InitActionOptions | AJV;
90
+ }
91
+
92
+ export interface UpdateCoreAction {
93
+ type: 'jsonforms/UPDATE_CORE';
94
+ data?: any;
95
+ schema?: JsonSchema;
96
+ uischema?: UISchemaElement;
97
+ options?: InitActionOptions | AJV;
98
+ }
99
+
100
+ export interface InitActionOptions {
101
+ ajv?: AJV;
102
+ validationMode?: ValidationMode;
103
+ }
104
+
105
+ export interface SetValidationModeAction {
106
+ type: 'jsonforms/SET_VALIDATION_MODE'
107
+ validationMode: ValidationMode
108
+ }
109
+
110
+ export const init = (
111
+ data: any,
112
+ schema: JsonSchema = generateJsonSchema(data),
113
+ uischema?: UISchemaElement,
114
+ options?: InitActionOptions | AJV
115
+ ) => ({
116
+ type: INIT,
117
+ data,
118
+ schema,
119
+ uischema:
120
+ typeof uischema === 'object' ? uischema : generateDefaultUISchema(schema),
121
+ options
122
+ });
123
+
124
+ export const updateCore = (
125
+ data: any,
126
+ schema: JsonSchema,
127
+ uischema?: UISchemaElement,
128
+ options?: AJV | InitActionOptions
129
+ ): UpdateCoreAction => ({
130
+ type: UPDATE_CORE,
131
+ data,
132
+ schema,
133
+ uischema,
134
+ options
135
+ });
136
+
137
+ export interface RegisterDefaultDataAction {
138
+ type: 'jsonforms/ADD_DEFAULT_DATA';
139
+ schemaPath: string;
140
+ data: any;
141
+ }
142
+
143
+ export const registerDefaultData = (schemaPath: string, data: any) => ({
144
+ type: ADD_DEFAULT_DATA,
145
+ schemaPath,
146
+ data
147
+ });
148
+
149
+ export interface UnregisterDefaultDataAction {
150
+ type: 'jsonforms/REMOVE_DEFAULT_DATA';
151
+ schemaPath: string;
152
+ }
153
+
154
+ export const unregisterDefaultData = (schemaPath: string) => ({
155
+ type: REMOVE_DEFAULT_DATA,
156
+ schemaPath
157
+ });
158
+
159
+ export interface SetAjvAction {
160
+ type: 'jsonforms/SET_AJV';
161
+ ajv: AJV;
162
+ }
163
+
164
+ export const setAjv = (ajv: AJV) => ({
165
+ type: SET_AJV,
166
+ ajv
167
+ });
168
+
169
+ export const update = (
170
+ path: string,
171
+ updater: (existingData: any) => any
172
+ ): UpdateAction => ({
173
+ type: UPDATE_DATA,
174
+ path,
175
+ updater
176
+ });
177
+
178
+ export const updateErrors = (errors: ErrorObject[]): UpdateErrorsAction => ({
179
+ type: UPDATE_ERRORS,
180
+ errors
181
+ });
182
+
183
+ export interface AddRendererAction {
184
+ type: 'jsonforms/ADD_RENDERER';
185
+ tester: RankedTester;
186
+ renderer: any;
187
+ }
188
+
189
+ export const registerRenderer = (tester: RankedTester, renderer: any) => ({
190
+ type: ADD_RENDERER,
191
+ tester,
192
+ renderer
193
+ });
194
+
195
+ export interface AddCellRendererAction {
196
+ type: 'jsonforms/ADD_CELL';
197
+ tester: RankedTester;
198
+ cell: any;
199
+ }
200
+
201
+ export const registerCell = (tester: RankedTester, cell: any) => ({
202
+ type: ADD_CELL,
203
+ tester,
204
+ cell
205
+ });
206
+
207
+ export interface RemoveCellRendererAction {
208
+ type: 'jsonforms/REMOVE_CELL';
209
+ tester: RankedTester;
210
+ cell: any;
211
+ }
212
+
213
+ export const unregisterCell = (tester: RankedTester, cell: any) => ({
214
+ type: REMOVE_CELL,
215
+ tester,
216
+ cell
217
+ });
218
+
219
+ export interface RemoveRendererAction {
220
+ type: 'jsonforms/REMOVE_RENDERER';
221
+ tester: RankedTester;
222
+ renderer: any;
223
+ }
224
+
225
+ export const unregisterRenderer = (tester: RankedTester, renderer: any) => ({
226
+ type: REMOVE_RENDERER,
227
+ tester,
228
+ renderer
229
+ });
230
+
231
+ export interface SetConfigAction {
232
+ type: 'jsonforms/SET_CONFIG';
233
+ config: any;
234
+ }
235
+
236
+ export const setConfig = (config: any): SetConfigAction => ({
237
+ type: SET_CONFIG,
238
+ config
239
+ });
240
+
241
+ export const setValidationMode = (validationMode: ValidationMode): SetValidationModeAction => ({
242
+ type: SET_VALIDATION_MODE,
243
+ validationMode
244
+ })
245
+
246
+ export type UISchemaActions = AddUISchemaAction | RemoveUISchemaAction;
247
+
248
+ export interface AddUISchemaAction {
249
+ type: 'jsonforms/ADD_UI_SCHEMA';
250
+ tester: UISchemaTester;
251
+ uischema: UISchemaElement;
252
+ }
253
+
254
+ export const registerUISchema = (
255
+ tester: UISchemaTester,
256
+ uischema: UISchemaElement
257
+ ): AddUISchemaAction => {
258
+ return {
259
+ type: ADD_UI_SCHEMA,
260
+ tester,
261
+ uischema
262
+ };
263
+ };
264
+
265
+ export interface RemoveUISchemaAction {
266
+ type: 'jsonforms/REMOVE_UI_SCHEMA';
267
+ tester: UISchemaTester;
268
+ }
269
+
270
+ export const unregisterUISchema = (
271
+ tester: UISchemaTester
272
+ ): RemoveUISchemaAction => {
273
+ return {
274
+ type: REMOVE_UI_SCHEMA,
275
+ tester
276
+ };
277
+ };
278
+
279
+ export type I18nActions =
280
+ | SetLocaleAction
281
+ | SetTranslatorAction
282
+ | UpdateI18nAction
283
+
284
+ export interface SetLocaleAction {
285
+ type: 'jsonforms/SET_LOCALE';
286
+ locale: string | undefined;
287
+ }
288
+
289
+ export const setLocale = (locale: string | undefined): SetLocaleAction => ({
290
+ type: SET_LOCALE,
291
+ locale
292
+ });
293
+
294
+ export interface SetSchemaAction {
295
+ type: 'jsonforms/SET_SCHEMA';
296
+ schema: JsonSchema;
297
+ }
298
+
299
+ export const setSchema = (schema: JsonSchema): SetSchemaAction => ({
300
+ type: SET_SCHEMA,
301
+ schema
302
+ });
303
+
304
+ export interface SetTranslatorAction {
305
+ type: 'jsonforms/SET_TRANSLATOR';
306
+ translator?: Translator;
307
+ errorTranslator?: ErrorTranslator;
308
+ }
309
+
310
+ export const setTranslator = (
311
+ translator?: Translator,
312
+ errorTranslator?: ErrorTranslator
313
+ ): SetTranslatorAction => ({
314
+ type: SET_TRANSLATOR,
315
+ translator,
316
+ errorTranslator
317
+ });
318
+
319
+ export interface UpdateI18nAction {
320
+ type: 'jsonforms/UPDATE_I18N';
321
+ locale: string | undefined;
322
+ translator: Translator | undefined;
323
+ errorTranslator: ErrorTranslator | undefined;
324
+ }
325
+
326
+ export const updateI18n = (
327
+ locale: string | undefined,
328
+ translator: Translator | undefined,
329
+ errorTranslator: ErrorTranslator | undefined
330
+ ): UpdateI18nAction => ({
331
+ type: UPDATE_I18N,
332
+ locale,
333
+ translator,
334
+ errorTranslator
335
+ });
336
+
337
+ export interface SetUISchemaAction {
338
+ type: 'jsonforms/SET_UISCHEMA';
339
+ uischema: UISchemaElement;
340
+ }
341
+
342
+ export const setUISchema = (uischema: UISchemaElement): SetUISchemaAction => ({
343
+ type: SET_UISCHEMA,
344
+ uischema
345
+ });
@@ -22,314 +22,5 @@
22
22
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
23
  THE SOFTWARE.
24
24
  */
25
- import AJV, { ErrorObject } from 'ajv';
26
- import { JsonSchema, UISchemaElement } from '../';
27
- import { generateDefaultUISchema, generateJsonSchema } from '../generators';
28
25
 
29
- import { RankedTester } from '../testers';
30
- import { UISchemaTester } from '../reducers/uischemas';
31
- import { ValidationMode } from '../reducers/core';
32
-
33
- export const INIT: 'jsonforms/INIT' = 'jsonforms/INIT';
34
- export const UPDATE_CORE: 'jsonforms/UPDATE_CORE' = `jsonforms/UPDATE_CORE`;
35
- export const SET_AJV: 'jsonforms/SET_AJV' = 'jsonforms/SET_AJV';
36
- export const UPDATE_DATA: 'jsonforms/UPDATE' = 'jsonforms/UPDATE';
37
- export const UPDATE_ERRORS: 'jsonforms/UPDATE_ERRORS' =
38
- 'jsonforms/UPDATE_ERRORS';
39
- export const VALIDATE: 'jsonforms/VALIDATE' = 'jsonforms/VALIDATE';
40
- export const ADD_RENDERER: 'jsonforms/ADD_RENDERER' = 'jsonforms/ADD_RENDERER';
41
- export const REMOVE_RENDERER: 'jsonforms/REMOVE_RENDERER' =
42
- 'jsonforms/REMOVE_RENDERER';
43
- export const ADD_CELL: 'jsonforms/ADD_CELL' = 'jsonforms/ADD_CELL';
44
- export const REMOVE_CELL: 'jsonforms/REMOVE_CELL' = 'jsonforms/REMOVE_CELL';
45
- export const SET_CONFIG: 'jsonforms/SET_CONFIG' = 'jsonforms/SET_CONFIG';
46
- export const ADD_UI_SCHEMA: 'jsonforms/ADD_UI_SCHEMA' = `jsonforms/ADD_UI_SCHEMA`;
47
- export const REMOVE_UI_SCHEMA: 'jsonforms/REMOVE_UI_SCHEMA' = `jsonforms/REMOVE_UI_SCHEMA`;
48
- export const SET_SCHEMA: 'jsonforms/SET_SCHEMA' = `jsonforms/SET_SCHEMA`;
49
- export const SET_UISCHEMA: 'jsonforms/SET_UISCHEMA' = `jsonforms/SET_UISCHEMA`;
50
- export const SET_VALIDATION_MODE: 'jsonforms/SET_VALIDATION_MODE' =
51
- 'jsonforms/SET_VALIDATION_MODE';
52
-
53
- export const SET_LOCALE: 'jsonforms/SET_LOCALE' = `jsonforms/SET_LOCALE`;
54
- export const SET_LOCALIZED_SCHEMAS: 'jsonforms/SET_LOCALIZED_SCHEMAS' =
55
- 'jsonforms/SET_LOCALIZED_SCHEMAS';
56
- export const SET_LOCALIZED_UISCHEMAS: 'jsonforms/SET_LOCALIZED_UISCHEMAS' =
57
- 'jsonforms/SET_LOCALIZED_UISCHEMAS';
58
-
59
- export const ADD_DEFAULT_DATA: 'jsonforms/ADD_DEFAULT_DATA' = `jsonforms/ADD_DEFAULT_DATA`;
60
- export const REMOVE_DEFAULT_DATA: 'jsonforms/REMOVE_DEFAULT_DATA' = `jsonforms/REMOVE_DEFAULT_DATA`;
61
-
62
- export type CoreActions =
63
- | InitAction
64
- | UpdateCoreAction
65
- | UpdateAction
66
- | UpdateErrorsAction
67
- | SetAjvAction
68
- | SetSchemaAction
69
- | SetUISchemaAction
70
- | SetValidationModeAction;
71
-
72
- export interface UpdateAction {
73
- type: 'jsonforms/UPDATE';
74
- path: string;
75
- updater(existingData?: any): any;
76
- }
77
-
78
- export interface UpdateErrorsAction {
79
- type: 'jsonforms/UPDATE_ERRORS';
80
- errors: ErrorObject[];
81
- }
82
-
83
- export interface InitAction {
84
- type: 'jsonforms/INIT';
85
- data: any;
86
- schema: JsonSchema;
87
- uischema: UISchemaElement;
88
- options?: InitActionOptions | AJV.Ajv;
89
- }
90
-
91
- export interface UpdateCoreAction {
92
- type: 'jsonforms/UPDATE_CORE';
93
- data?: any;
94
- schema?: JsonSchema;
95
- uischema?: UISchemaElement;
96
- options?: InitActionOptions | AJV.Ajv;
97
- }
98
-
99
- export interface InitActionOptions {
100
- ajv?: AJV.Ajv;
101
- validationMode?: ValidationMode;
102
- }
103
-
104
- export interface SetValidationModeAction {
105
- type: 'jsonforms/SET_VALIDATION_MODE'
106
- validationMode: ValidationMode
107
- }
108
-
109
- export const init = (
110
- data: any,
111
- schema: JsonSchema = generateJsonSchema(data),
112
- uischema?: UISchemaElement,
113
- options?: InitActionOptions | AJV.Ajv
114
- ) => ({
115
- type: INIT,
116
- data,
117
- schema,
118
- uischema:
119
- typeof uischema === 'object' ? uischema : generateDefaultUISchema(schema),
120
- options
121
- });
122
-
123
- export const updateCore = (
124
- data: any,
125
- schema: JsonSchema,
126
- uischema?: UISchemaElement,
127
- options?: AJV.Ajv | InitActionOptions
128
- ): UpdateCoreAction => ({
129
- type: UPDATE_CORE,
130
- data,
131
- schema,
132
- uischema,
133
- options
134
- });
135
-
136
- export interface RegisterDefaultDataAction {
137
- type: 'jsonforms/ADD_DEFAULT_DATA';
138
- schemaPath: string;
139
- data: any;
140
- }
141
-
142
- export const registerDefaultData = (schemaPath: string, data: any) => ({
143
- type: ADD_DEFAULT_DATA,
144
- schemaPath,
145
- data
146
- });
147
-
148
- export interface UnregisterDefaultDataAction {
149
- type: 'jsonforms/REMOVE_DEFAULT_DATA';
150
- schemaPath: string;
151
- }
152
-
153
- export const unregisterDefaultData = (schemaPath: string) => ({
154
- type: REMOVE_DEFAULT_DATA,
155
- schemaPath
156
- });
157
-
158
- export interface SetAjvAction {
159
- type: 'jsonforms/SET_AJV';
160
- ajv: AJV.Ajv;
161
- }
162
-
163
- export const setAjv = (ajv: AJV.Ajv) => ({
164
- type: SET_AJV,
165
- ajv
166
- });
167
-
168
- export const update = (
169
- path: string,
170
- updater: (existingData: any) => any
171
- ): UpdateAction => ({
172
- type: UPDATE_DATA,
173
- path,
174
- updater
175
- });
176
-
177
- export const updateErrors = (errors: ErrorObject[]): UpdateErrorsAction => ({
178
- type: UPDATE_ERRORS,
179
- errors
180
- });
181
-
182
- export interface AddRendererAction {
183
- type: 'jsonforms/ADD_RENDERER';
184
- tester: RankedTester;
185
- renderer: any;
186
- }
187
-
188
- export const registerRenderer = (tester: RankedTester, renderer: any) => ({
189
- type: ADD_RENDERER,
190
- tester,
191
- renderer
192
- });
193
-
194
- export interface AddCellRendererAction {
195
- type: 'jsonforms/ADD_CELL';
196
- tester: RankedTester;
197
- cell: any;
198
- }
199
-
200
- export const registerCell = (tester: RankedTester, cell: any) => ({
201
- type: ADD_CELL,
202
- tester,
203
- cell
204
- });
205
-
206
- export interface RemoveCellRendererAction {
207
- type: 'jsonforms/REMOVE_CELL';
208
- tester: RankedTester;
209
- cell: any;
210
- }
211
-
212
- export const unregisterCell = (tester: RankedTester, cell: any) => ({
213
- type: REMOVE_CELL,
214
- tester,
215
- cell
216
- });
217
-
218
- export interface RemoveRendererAction {
219
- type: 'jsonforms/REMOVE_RENDERER';
220
- tester: RankedTester;
221
- renderer: any;
222
- }
223
-
224
- export const unregisterRenderer = (tester: RankedTester, renderer: any) => ({
225
- type: REMOVE_RENDERER,
226
- tester,
227
- renderer
228
- });
229
-
230
- export interface SetConfigAction {
231
- type: 'jsonforms/SET_CONFIG';
232
- config: any;
233
- }
234
-
235
- export const setConfig = (config: any): SetConfigAction => ({
236
- type: SET_CONFIG,
237
- config
238
- });
239
-
240
- export const setValidationMode = (validationMode: ValidationMode): SetValidationModeAction => ({
241
- type: SET_VALIDATION_MODE,
242
- validationMode
243
- })
244
-
245
- export type UISchemaActions = AddUISchemaAction | RemoveUISchemaAction;
246
-
247
- export interface AddUISchemaAction {
248
- type: 'jsonforms/ADD_UI_SCHEMA';
249
- tester: UISchemaTester;
250
- uischema: UISchemaElement;
251
- }
252
-
253
- export const registerUISchema = (
254
- tester: UISchemaTester,
255
- uischema: UISchemaElement
256
- ): AddUISchemaAction => {
257
- return {
258
- type: ADD_UI_SCHEMA,
259
- tester,
260
- uischema
261
- };
262
- };
263
-
264
- export interface RemoveUISchemaAction {
265
- type: 'jsonforms/REMOVE_UI_SCHEMA';
266
- tester: UISchemaTester;
267
- }
268
-
269
- export const unregisterUISchema = (
270
- tester: UISchemaTester
271
- ): RemoveUISchemaAction => {
272
- return {
273
- type: REMOVE_UI_SCHEMA,
274
- tester
275
- };
276
- };
277
-
278
- export type LocaleActions =
279
- | SetLocaleAction
280
- | SetLocalizedSchemasAction
281
- | SetLocalizedUISchemasAction;
282
-
283
- export interface SetLocaleAction {
284
- type: 'jsonforms/SET_LOCALE';
285
- locale: string;
286
- }
287
-
288
- export const setLocale = (locale: string): SetLocaleAction => ({
289
- type: SET_LOCALE,
290
- locale
291
- });
292
-
293
- export interface SetLocalizedSchemasAction {
294
- type: 'jsonforms/SET_LOCALIZED_SCHEMAS';
295
- localizedSchemas: Map<string, JsonSchema>;
296
- }
297
-
298
- export const setLocalizedSchemas = (
299
- localizedSchemas: Map<string, JsonSchema>
300
- ): SetLocalizedSchemasAction => ({
301
- type: SET_LOCALIZED_SCHEMAS,
302
- localizedSchemas
303
- });
304
-
305
- export interface SetSchemaAction {
306
- type: 'jsonforms/SET_SCHEMA';
307
- schema: JsonSchema;
308
- }
309
-
310
- export const setSchema = (schema: JsonSchema): SetSchemaAction => ({
311
- type: SET_SCHEMA,
312
- schema
313
- });
314
-
315
- export interface SetLocalizedUISchemasAction {
316
- type: 'jsonforms/SET_LOCALIZED_UISCHEMAS';
317
- localizedUISchemas: Map<string, UISchemaElement>;
318
- }
319
-
320
- export const setLocalizedUISchemas = (
321
- localizedUISchemas: Map<string, UISchemaElement>
322
- ): SetLocalizedUISchemasAction => ({
323
- type: SET_LOCALIZED_UISCHEMAS,
324
- localizedUISchemas
325
- });
326
-
327
- export interface SetUISchemaAction {
328
- type: 'jsonforms/SET_UISCHEMA';
329
- uischema: UISchemaElement;
330
- }
331
-
332
- export const setUISchema = (uischema: UISchemaElement): SetUISchemaAction => ({
333
- type: SET_UISCHEMA,
334
- uischema
335
- });
26
+ export * from './actions';
@@ -22,6 +22,7 @@
22
22
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
23
  THE SOFTWARE.
24
24
  */
25
+
25
26
  export const configDefault = {
26
27
  /*
27
28
  * [text] whether to restrict the number of characters to maxLength,
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
1
  /*
5
2
  The MIT License
6
3
 
@@ -25,12 +22,22 @@ var tslib_1 = require("tslib");
25
22
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26
23
  THE SOFTWARE.
27
24
  */
28
- var ajv_1 = tslib_1.__importDefault(require("ajv"));
29
- var draft4_1 = require("../models/draft4");
30
- exports.createAjv = function (options) {
31
- var ajv = new ajv_1.default(tslib_1.__assign({ schemaId: 'auto', allErrors: true, jsonPointers: true, errorDataPath: 'property', verbose: true }, options));
32
- ajv.addFormat('time', '^([0-1][0-9]|2[0-3]):[0-5][0-9]$');
33
- ajv.addMetaSchema(draft4_1.Draft4);
34
- return ajv;
25
+
26
+ import { generateJsonSchema } from './schema';
27
+ import { createControlElement, generateDefaultUISchema } from './uischema';
28
+ import { ControlElement, JsonSchema, UISchemaElement } from '../';
29
+
30
+ export const Generate: {
31
+ jsonSchema(instance: Object, options?: any): JsonSchema;
32
+ uiSchema(
33
+ jsonSchema: JsonSchema,
34
+ layoutType?: string,
35
+ prefix?: string,
36
+ rootSchema?: JsonSchema
37
+ ): UISchemaElement;
38
+ controlElement(ref: string): ControlElement;
39
+ } = {
40
+ jsonSchema: generateJsonSchema,
41
+ uiSchema: generateDefaultUISchema,
42
+ controlElement: createControlElement
35
43
  };
36
- //# sourceMappingURL=validator.js.map