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

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 (228) hide show
  1. package/docs/assets/js/search.json +1 -1
  2. package/docs/globals.html +822 -405
  3. package/docs/index.html +69 -36
  4. package/docs/interfaces/addcellrendereraction.html +3 -3
  5. package/docs/interfaces/addrendereraction.html +3 -3
  6. package/docs/interfaces/adduischemaaction.html +3 -3
  7. package/docs/interfaces/arraycontrolprops.html +21 -21
  8. package/docs/interfaces/arraylayoutprops.html +21 -21
  9. package/docs/interfaces/cellprops.html +14 -14
  10. package/docs/interfaces/combinatorrendererprops.html +13 -13
  11. package/docs/interfaces/controlprops.html +16 -16
  12. package/docs/interfaces/controlstate.html +2 -2
  13. package/docs/interfaces/controlwithdetailprops.html +17 -17
  14. package/docs/interfaces/dispatchcellprops.html +13 -13
  15. package/docs/interfaces/dispatchcellstateprops.html +13 -13
  16. package/docs/interfaces/dispatchpropsofarraycontrol.html +4 -4
  17. package/docs/interfaces/dispatchpropsofcontrol.html +1 -1
  18. package/docs/interfaces/dispatchpropsofmultienumcontrol.html +2 -2
  19. package/docs/interfaces/enumcellprops.html +15 -15
  20. package/docs/interfaces/enumoption.html +2 -2
  21. package/docs/interfaces/initaction.html +6 -6
  22. package/docs/interfaces/initactionoptions.html +3 -3
  23. package/docs/interfaces/jsonformscore.html +7 -7
  24. package/docs/interfaces/{jsonformslocalestate.html → jsonformsi18nstate.html} +20 -20
  25. package/docs/interfaces/jsonformsprops.html +9 -9
  26. package/docs/interfaces/jsonformssubstates.html +11 -1
  27. package/docs/interfaces/layoutprops.html +10 -10
  28. package/docs/interfaces/ownpropsofcell.html +10 -10
  29. package/docs/interfaces/ownpropsofcontrol.html +9 -9
  30. package/docs/interfaces/ownpropsofenum.html +1 -1
  31. package/docs/interfaces/ownpropsofenumcell.html +11 -11
  32. package/docs/interfaces/ownpropsofjsonformsrenderer.html +8 -8
  33. package/docs/interfaces/ownpropsoflayout.html +9 -9
  34. package/docs/interfaces/ownpropsofmasterlistitem.html +6 -6
  35. package/docs/interfaces/ownpropsofrenderer.html +8 -8
  36. package/docs/interfaces/registerdefaultdataaction.html +3 -3
  37. package/docs/interfaces/removecellrendereraction.html +3 -3
  38. package/docs/interfaces/removerendereraction.html +3 -3
  39. package/docs/interfaces/removeuischemaaction.html +2 -2
  40. package/docs/interfaces/rendererprops.html +9 -9
  41. package/docs/interfaces/setajvaction.html +3 -3
  42. package/docs/interfaces/setconfigaction.html +2 -2
  43. package/docs/interfaces/setlocaleaction.html +3 -3
  44. package/docs/interfaces/setschemaaction.html +2 -2
  45. package/docs/interfaces/{setlocalizedschemasaction.html → settranslatoraction.html} +29 -15
  46. package/docs/interfaces/setuischemaaction.html +2 -2
  47. package/docs/interfaces/setvalidationmodeaction.html +2 -2
  48. package/docs/interfaces/statepropsofarraycontrol.html +17 -17
  49. package/docs/interfaces/statepropsofarraylayout.html +17 -17
  50. package/docs/interfaces/statepropsofcell.html +13 -13
  51. package/docs/interfaces/statepropsofcombinator.html +12 -12
  52. package/docs/interfaces/statepropsofcontrol.html +15 -15
  53. package/docs/interfaces/statepropsofcontrolwithdetail.html +16 -16
  54. package/docs/interfaces/statepropsofenumcell.html +14 -14
  55. package/docs/interfaces/statepropsofjsonformsrenderer.html +9 -9
  56. package/docs/interfaces/statepropsoflayout.html +10 -10
  57. package/docs/interfaces/statepropsofmasteritem.html +7 -7
  58. package/docs/interfaces/statepropsofrenderer.html +9 -9
  59. package/docs/interfaces/statepropsofscopedrenderer.html +12 -12
  60. package/docs/interfaces/unregisterdefaultdataaction.html +2 -2
  61. package/docs/interfaces/updateaction.html +3 -3
  62. package/docs/interfaces/updatecoreaction.html +6 -6
  63. package/docs/interfaces/updateerrorsaction.html +2 -2
  64. package/docs/interfaces/{setlocalizeduischemasaction.html → updatei18naction.html} +43 -15
  65. package/docs/interfaces/withclassname.html +1 -1
  66. package/lib/Helpers.d.ts +5 -5
  67. package/lib/actions/actions.d.ts +181 -177
  68. package/lib/actions/index.d.ts +1 -1
  69. package/lib/configDefault.d.ts +6 -6
  70. package/lib/generators/Generate.d.ts +6 -6
  71. package/lib/generators/index.d.ts +3 -3
  72. package/lib/generators/schema.d.ts +8 -8
  73. package/lib/generators/uischema.d.ts +12 -12
  74. package/lib/i18n/i18nTypes.d.ts +15 -0
  75. package/lib/i18n/i18nUtil.d.ts +18 -0
  76. package/lib/i18n/index.d.ts +2 -0
  77. package/lib/index.d.ts +11 -10
  78. package/lib/jsonforms-core.cjs.js +2445 -0
  79. package/lib/jsonforms-core.cjs.js.map +1 -0
  80. package/lib/jsonforms-core.esm.js +2164 -0
  81. package/lib/jsonforms-core.esm.js.map +1 -0
  82. package/lib/models/draft4.d.ts +198 -198
  83. package/lib/models/index.d.ts +5 -5
  84. package/lib/models/jsonSchema.d.ts +3 -3
  85. package/lib/models/jsonSchema4.d.ts +110 -110
  86. package/lib/models/jsonSchema7.d.ts +119 -119
  87. package/lib/models/uischema.d.ts +201 -201
  88. package/lib/reducers/cells.d.ts +11 -11
  89. package/lib/reducers/config.d.ts +3 -3
  90. package/lib/reducers/core.d.ts +24 -23
  91. package/lib/reducers/default-data.d.ts +10 -10
  92. package/lib/reducers/i18n.d.ts +8 -11
  93. package/lib/reducers/index.d.ts +9 -9
  94. package/lib/reducers/reducers.d.ts +29 -36
  95. package/lib/reducers/renderers.d.ts +10 -10
  96. package/lib/reducers/selectors.d.ts +15 -15
  97. package/lib/reducers/uischemas.d.ts +10 -10
  98. package/lib/store.d.ts +53 -52
  99. package/lib/testers/index.d.ts +1 -1
  100. package/lib/testers/testers.d.ts +203 -203
  101. package/lib/util/Formatted.d.ts +19 -19
  102. package/lib/util/array.d.ts +3 -3
  103. package/lib/util/cell.d.ts +79 -79
  104. package/lib/util/combinators.d.ts +10 -10
  105. package/lib/util/ids.d.ts +3 -3
  106. package/lib/util/index.d.ts +15 -15
  107. package/lib/util/label.d.ts +9 -9
  108. package/lib/util/path.d.ts +25 -25
  109. package/lib/util/renderer.d.ts +398 -387
  110. package/lib/util/resolvers.d.ts +25 -25
  111. package/lib/util/runtime.d.ts +18 -19
  112. package/lib/util/schema.d.ts +1 -1
  113. package/lib/util/type.d.ts +174 -174
  114. package/lib/util/uischema.d.ts +5 -5
  115. package/lib/util/util.d.ts +31 -31
  116. package/lib/util/validator.d.ts +3 -2
  117. package/package.json +18 -14
  118. package/rollup.config.js +44 -0
  119. package/src/actions/actions.ts +46 -36
  120. package/src/i18n/i18nTypes.ts +17 -0
  121. package/src/i18n/i18nUtil.ts +105 -0
  122. package/src/i18n/index.ts +2 -0
  123. package/src/index.ts +1 -0
  124. package/src/reducers/core.ts +70 -48
  125. package/src/reducers/i18n.ts +41 -35
  126. package/src/reducers/reducers.ts +10 -29
  127. package/src/reducers/selectors.ts +1 -1
  128. package/src/store.ts +4 -4
  129. package/src/util/cell.ts +26 -6
  130. package/src/util/renderer.ts +127 -38
  131. package/src/util/runtime.ts +1 -1
  132. package/src/util/util.ts +1 -1
  133. package/src/util/validator.ts +5 -9
  134. package/stats.html +3279 -0
  135. package/{lib/reducers/cells.js → test/i18n/i18nUtil.test.ts} +25 -17
  136. package/test/reducers/core.test.ts +31 -44
  137. package/test/util/cell.test.ts +2 -2
  138. package/test/util/renderer.test.ts +488 -35
  139. package/lib/Helpers.js +0 -32
  140. package/lib/Helpers.js.map +0 -1
  141. package/lib/actions/actions.js +0 -149
  142. package/lib/actions/actions.js.map +0 -1
  143. package/lib/actions/index.js +0 -29
  144. package/lib/actions/index.js.map +0 -1
  145. package/lib/configDefault.js +0 -47
  146. package/lib/configDefault.js.map +0 -1
  147. package/lib/generators/Generate.js +0 -34
  148. package/lib/generators/Generate.js.map +0 -1
  149. package/lib/generators/index.js +0 -31
  150. package/lib/generators/index.js.map +0 -1
  151. package/lib/generators/schema.js +0 -152
  152. package/lib/generators/schema.js.map +0 -1
  153. package/lib/generators/uischema.js +0 -166
  154. package/lib/generators/uischema.js.map +0 -1
  155. package/lib/index.js +0 -37
  156. package/lib/index.js.map +0 -1
  157. package/lib/jsonforms-core.js +0 -19
  158. package/lib/jsonforms-core.js.map +0 -1
  159. package/lib/models/draft4.js +0 -173
  160. package/lib/models/draft4.js.map +0 -1
  161. package/lib/models/index.js +0 -30
  162. package/lib/models/index.js.map +0 -1
  163. package/lib/models/jsonSchema.js +0 -27
  164. package/lib/models/jsonSchema.js.map +0 -1
  165. package/lib/models/jsonSchema4.js +0 -30
  166. package/lib/models/jsonSchema4.js.map +0 -1
  167. package/lib/models/jsonSchema7.js +0 -30
  168. package/lib/models/jsonSchema7.js.map +0 -1
  169. package/lib/models/uischema.js +0 -55
  170. package/lib/models/uischema.js.map +0 -1
  171. package/lib/reducers/cells.js.map +0 -1
  172. package/lib/reducers/config.js +0 -44
  173. package/lib/reducers/config.js.map +0 -1
  174. package/lib/reducers/core.js +0 -259
  175. package/lib/reducers/core.js.map +0 -1
  176. package/lib/reducers/default-data.js +0 -42
  177. package/lib/reducers/default-data.js.map +0 -1
  178. package/lib/reducers/i18n.js +0 -65
  179. package/lib/reducers/i18n.js.map +0 -1
  180. package/lib/reducers/index.js +0 -37
  181. package/lib/reducers/index.js.map +0 -1
  182. package/lib/reducers/reducers.js +0 -99
  183. package/lib/reducers/reducers.js.map +0 -1
  184. package/lib/reducers/renderers.js +0 -41
  185. package/lib/reducers/renderers.js.map +0 -1
  186. package/lib/reducers/selectors.js +0 -47
  187. package/lib/reducers/selectors.js.map +0 -1
  188. package/lib/reducers/uischemas.js +0 -57
  189. package/lib/reducers/uischemas.js.map +0 -1
  190. package/lib/store.js +0 -27
  191. package/lib/store.js.map +0 -1
  192. package/lib/testers/index.js +0 -29
  193. package/lib/testers/index.js.map +0 -1
  194. package/lib/testers/testers.js +0 -401
  195. package/lib/testers/testers.js.map +0 -1
  196. package/lib/util/Formatted.js +0 -27
  197. package/lib/util/Formatted.js.map +0 -1
  198. package/lib/util/array.js +0 -43
  199. package/lib/util/array.js.map +0 -1
  200. package/lib/util/cell.js +0 -133
  201. package/lib/util/cell.js.map +0 -1
  202. package/lib/util/combinators.js +0 -56
  203. package/lib/util/combinators.js.map +0 -1
  204. package/lib/util/ids.js +0 -50
  205. package/lib/util/ids.js.map +0 -1
  206. package/lib/util/index.js +0 -41
  207. package/lib/util/index.js.map +0 -1
  208. package/lib/util/label.js +0 -70
  209. package/lib/util/label.js.map +0 -1
  210. package/lib/util/path.js +0 -85
  211. package/lib/util/path.js.map +0 -1
  212. package/lib/util/renderer.js +0 -451
  213. package/lib/util/renderer.js.map +0 -1
  214. package/lib/util/resolvers.js +0 -165
  215. package/lib/util/resolvers.js.map +0 -1
  216. package/lib/util/runtime.js +0 -159
  217. package/lib/util/runtime.js.map +0 -1
  218. package/lib/util/schema.js +0 -40
  219. package/lib/util/schema.js.map +0 -1
  220. package/lib/util/type.js +0 -27
  221. package/lib/util/type.js.map +0 -1
  222. package/lib/util/uischema.js +0 -52
  223. package/lib/util/uischema.js.map +0 -1
  224. package/lib/util/util.js +0 -107
  225. package/lib/util/util.js.map +0 -1
  226. package/lib/util/validator.js +0 -36
  227. package/lib/util/validator.js.map +0 -1
  228. package/webpack.build.js +0 -13
@@ -1,387 +1,398 @@
1
- import { ControlElement, JsonSchema, UISchemaElement } from '../models';
2
- import { JsonFormsCellRendererRegistryEntry, JsonFormsRendererRegistryEntry, JsonFormsUISchemaRegistryEntry } from '../reducers';
3
- import { RankedTester } from '../testers';
4
- import { AnyAction, Dispatch } from './type';
5
- import { CoreActions } from '../actions';
6
- import { ErrorObject } from 'ajv';
7
- import { JsonFormsState } from '../store';
8
- export { JsonFormsRendererRegistryEntry, JsonFormsCellRendererRegistryEntry };
9
- /**
10
- * Adds an asterisk to the given label string based
11
- * on the required parameter.
12
- *
13
- * @param {string} label the label string
14
- * @param {boolean} required whether the label belongs to a control which is required
15
- * @returns {string} the label string
16
- */
17
- export declare const computeLabel: (label: string, required: boolean, hideRequiredAsterisk: boolean) => string;
18
- /**
19
- * Create a default value based on the given scheam.
20
- * @param schema the schema for which to create a default value.
21
- * @returns {any}
22
- */
23
- export declare const createDefaultValue: (schema: JsonSchema) => {};
24
- /**
25
- * Whether an element's description should be hidden.
26
- *
27
- * @param visible whether an element is visible
28
- * @param description the element's description
29
- * @param isFocused whether the element is focused
30
- *
31
- * @returns {boolean} true, if the description is to be hidden, false otherwise
32
- */
33
- export declare const isDescriptionHidden: (visible: boolean, description: string, isFocused: boolean, showUnfocusedDescription: boolean) => boolean;
34
- export interface WithClassname {
35
- className?: string;
36
- }
37
- export interface EnumOption {
38
- label: string;
39
- value: any;
40
- }
41
- export declare const enumToEnumOptionMapper: (e: any) => EnumOption;
42
- export declare const oneOfToEnumOptionMapper: (e: any) => EnumOption;
43
- export interface OwnPropsOfRenderer {
44
- /**
45
- * The UI schema to be rendered.
46
- */
47
- uischema?: UISchemaElement;
48
- /**
49
- * The JSON schema that describes the data.
50
- */
51
- schema?: JsonSchema;
52
- /**
53
- * Whether the rendered element should be enabled.
54
- */
55
- enabled?: boolean;
56
- /**
57
- * Whether the rendered element should be visible.
58
- */
59
- visible?: boolean;
60
- /**
61
- * Optional instance path. Necessary when the actual data
62
- * path can not be inferred via the UI schema element as
63
- * it is the case with nested controls.
64
- */
65
- path?: string;
66
- renderers?: JsonFormsRendererRegistryEntry[];
67
- cells?: JsonFormsCellRendererRegistryEntry[];
68
- uischemas?: JsonFormsUISchemaRegistryEntry[];
69
- }
70
- export interface OwnPropsOfControl extends OwnPropsOfRenderer {
71
- id?: string;
72
- uischema?: ControlElement;
73
- }
74
- export interface OwnPropsOfEnum {
75
- options?: EnumOption[];
76
- }
77
- export interface OwnPropsOfLayout extends OwnPropsOfRenderer {
78
- direction?: 'row' | 'column';
79
- }
80
- /**
81
- * State-based props of a {@link Renderer}.
82
- */
83
- export interface StatePropsOfRenderer {
84
- /**
85
- * Any configuration options for the element.
86
- */
87
- config?: any;
88
- /**
89
- * The UI schema to be rendered.
90
- */
91
- uischema: UISchemaElement;
92
- /**
93
- * The JSON schema that describes the data.
94
- */
95
- schema: JsonSchema;
96
- /**
97
- * The data to be rendered.
98
- */
99
- data?: any;
100
- /**
101
- * Whether the rendered element should be enabled.
102
- */
103
- enabled: boolean;
104
- /**
105
- * Whether the rendered element should be visible.
106
- */
107
- visible: boolean;
108
- /**
109
- * Instance path the data is written to, in case of a control.
110
- */
111
- path: string;
112
- /**
113
- * All available renderers.
114
- */
115
- renderers?: JsonFormsRendererRegistryEntry[];
116
- /**
117
- * All available cell renderers.
118
- */
119
- cells?: JsonFormsCellRendererRegistryEntry[];
120
- }
121
- /**
122
- * State-based properties for UI schema elements that have a scope.
123
- */
124
- export interface StatePropsOfScopedRenderer extends StatePropsOfRenderer {
125
- uischema: ControlElement;
126
- /**
127
- * Any validation errors that are caused by the data to be rendered.
128
- */
129
- errors: string;
130
- /**
131
- * The data to be rendered.
132
- */
133
- data: any;
134
- /**
135
- * The root schema as returned by the store.
136
- */
137
- rootSchema: JsonSchema;
138
- /**
139
- * A unique ID that should be used for rendering the scoped UI schema element.
140
- */
141
- id: string;
142
- }
143
- /**
144
- * Props of a {@link Renderer}.
145
- */
146
- export interface RendererProps extends StatePropsOfRenderer {
147
- }
148
- /**
149
- * State-based props of a Control
150
- */
151
- export interface StatePropsOfControl extends StatePropsOfScopedRenderer {
152
- cells?: {
153
- tester: RankedTester;
154
- cell: any;
155
- }[];
156
- /**
157
- * The label for the rendered element.
158
- */
159
- label: string;
160
- /**
161
- * Description of input cell
162
- */
163
- description?: string;
164
- /**
165
- * Whether the rendered data is required.
166
- */
167
- required?: boolean;
168
- }
169
- /**
170
- * Dispatch-based props of a Control.
171
- */
172
- export interface DispatchPropsOfControl {
173
- /**
174
- * Update handler that emits a data change
175
- *
176
- * @param {string} path the path to the data to be updated
177
- * @param {any} value the new value that should be written to the given path
178
- */
179
- handleChange(path: string, value: any): void;
180
- }
181
- /**
182
- * Props of a Control.
183
- */
184
- export interface ControlProps extends StatePropsOfControl, DispatchPropsOfControl {
185
- }
186
- /**
187
- * State props of a layout;
188
- */
189
- export interface StatePropsOfLayout extends StatePropsOfRenderer {
190
- /**
191
- * Direction for the layout to flow
192
- */
193
- direction: 'row' | 'column';
194
- }
195
- export interface LayoutProps extends StatePropsOfLayout {
196
- }
197
- /**
198
- * The state of a control.
199
- */
200
- export interface ControlState {
201
- /**
202
- * The current value.
203
- */
204
- value: any;
205
- /**
206
- * Whether the control is focused.
207
- */
208
- isFocused: boolean;
209
- }
210
- /**
211
- * Map state to control props.
212
- * @param state the store's state
213
- * @param ownProps any own props
214
- * @returns {StatePropsOfControl} state props for a control
215
- */
216
- export declare const mapStateToControlProps: (state: JsonFormsState, ownProps: OwnPropsOfControl) => StatePropsOfControl;
217
- /**
218
- *
219
- * Map dispatch to control props.
220
- *
221
- * @param dispatch the store's dispatch method
222
- * @returns {DispatchPropsOfControl} dispatch props for a control
223
- */
224
- export declare const mapDispatchToControlProps: (dispatch: Dispatch<AnyAction>) => DispatchPropsOfControl;
225
- /**
226
- * Default mapStateToCellProps for enum control. Options is used for populating dropdown list
227
- * @param state
228
- * @param ownProps
229
- * @returns {StatePropsOfControl & OwnPropsOfEnum}
230
- */
231
- export declare const mapStateToEnumControlProps: (state: JsonFormsState, ownProps: OwnPropsOfControl & OwnPropsOfEnum) => StatePropsOfControl & OwnPropsOfEnum;
232
- /**
233
- * Default mapStateToCellProps for enum control based on oneOf. Options is used for populating dropdown list
234
- * @param state
235
- * @param ownProps
236
- * @returns {StatePropsOfControl & OwnPropsOfEnum}
237
- */
238
- export declare const mapStateToOneOfEnumControlProps: (state: JsonFormsState, ownProps: OwnPropsOfControl & OwnPropsOfEnum) => StatePropsOfControl & OwnPropsOfEnum;
239
- /**
240
- * Default mapStateToCellProps for multi enum control. Options is used for populating dropdown list
241
- * @param state
242
- * @param ownProps
243
- * @returns {StatePropsOfControl & OwnPropsOfEnum}
244
- */
245
- export declare const mapStateToMultiEnumControlProps: (state: JsonFormsState, ownProps: OwnPropsOfControl & OwnPropsOfEnum) => StatePropsOfControl & OwnPropsOfEnum;
246
- /**
247
- * Map state to control props.
248
- * @param state the store's state
249
- * @param ownProps any own props
250
- * @returns {StatePropsOfControl} state props for a control
251
- */
252
- export declare const mapStateToMasterListItemProps: (state: JsonFormsState, ownProps: OwnPropsOfMasterListItem) => StatePropsOfMasterItem;
253
- /**
254
- * State-based props of a table control.
255
- */
256
- export interface StatePropsOfControlWithDetail extends StatePropsOfControl {
257
- uischemas?: JsonFormsUISchemaRegistryEntry[];
258
- renderers?: JsonFormsRendererRegistryEntry[];
259
- cells?: JsonFormsCellRendererRegistryEntry[];
260
- }
261
- export interface OwnPropsOfMasterListItem {
262
- index: number;
263
- selected: boolean;
264
- path: string;
265
- schema: JsonSchema;
266
- handleSelect(index: number): () => void;
267
- removeItem(path: string, value: number): () => void;
268
- }
269
- export interface StatePropsOfMasterItem extends OwnPropsOfMasterListItem {
270
- childLabel: string;
271
- }
272
- /**
273
- * Map state to control with detail props
274
- *
275
- * @param state the store's state
276
- * @param ownProps any element's own props
277
- * @returns {StatePropsOfArrayControl} state props for a table control
278
- */
279
- export declare const mapStateToControlWithDetailProps: (state: JsonFormsState, ownProps: OwnPropsOfControl) => StatePropsOfControlWithDetail;
280
- export interface ControlWithDetailProps extends StatePropsOfControlWithDetail, DispatchPropsOfControl {
281
- }
282
- /**
283
- * State-based props of a table control.
284
- */
285
- export interface StatePropsOfArrayControl extends StatePropsOfControlWithDetail {
286
- childErrors?: ErrorObject[];
287
- }
288
- /**
289
- * Map state to table props
290
- *
291
- * @param state the store's state
292
- * @param ownProps any element's own props
293
- * @returns {StatePropsOfArrayControl} state props for a table control
294
- */
295
- export declare const mapStateToArrayControlProps: (state: JsonFormsState, ownProps: OwnPropsOfControl) => StatePropsOfArrayControl;
296
- /**
297
- * Dispatch props of a table control
298
- */
299
- export interface DispatchPropsOfArrayControl {
300
- addItem(path: string, value: any): () => void;
301
- removeItems?(path: string, toDelete: number[]): () => void;
302
- moveUp?(path: string, toMove: number): () => void;
303
- moveDown?(path: string, toMove: number): () => void;
304
- }
305
- /**
306
- * Maps state to dispatch properties of an array control.
307
- *
308
- * @param dispatch the store's dispatch method
309
- * @returns {DispatchPropsOfArrayControl} dispatch props of an array control
310
- */
311
- export declare const mapDispatchToArrayControlProps: (dispatch: Dispatch<CoreActions>) => DispatchPropsOfArrayControl;
312
- export interface DispatchPropsOfMultiEnumControl {
313
- addItem: (path: string, value: any) => void;
314
- removeItem?: (path: string, toDelete: any) => void;
315
- }
316
- export declare const mapDispatchToMultiEnumProps: (dispatch: Dispatch<CoreActions>) => DispatchPropsOfMultiEnumControl;
317
- /**
318
- * Props of an array control.
319
- */
320
- export interface ArrayControlProps extends StatePropsOfArrayControl, DispatchPropsOfArrayControl {
321
- }
322
- export declare const layoutDefaultProps: {
323
- visible: boolean;
324
- enabled: boolean;
325
- path: string;
326
- direction: 'row' | 'column';
327
- };
328
- /**
329
- * Map state to layout props.
330
- * @param state JSONForms state tree
331
- * @param ownProps any own props
332
- * @returns {StatePropsOfLayout}
333
- */
334
- export declare const mapStateToLayoutProps: (state: JsonFormsState, ownProps: OwnPropsOfLayout) => LayoutProps;
335
- export declare type RefResolver = (schema: JsonSchema) => Promise<JsonSchema>;
336
- export interface OwnPropsOfJsonFormsRenderer extends OwnPropsOfRenderer {
337
- }
338
- export interface StatePropsOfJsonFormsRenderer extends OwnPropsOfJsonFormsRenderer {
339
- rootSchema: JsonSchema;
340
- }
341
- export interface JsonFormsProps extends StatePropsOfJsonFormsRenderer {
342
- }
343
- export declare const mapStateToJsonFormsRendererProps: (state: JsonFormsState, ownProps: OwnPropsOfJsonFormsRenderer) => StatePropsOfJsonFormsRenderer;
344
- export declare const controlDefaultProps: {
345
- errors: string[];
346
- visible: boolean;
347
- enabled: boolean;
348
- path: string;
349
- direction: "row" | "column";
350
- };
351
- export interface StatePropsOfCombinator extends OwnPropsOfControl {
352
- rootSchema: JsonSchema;
353
- path: string;
354
- id: string;
355
- indexOfFittingSchema: number;
356
- uischemas: JsonFormsUISchemaRegistryEntry[];
357
- data: any;
358
- }
359
- export interface CombinatorRendererProps extends StatePropsOfCombinator, DispatchPropsOfControl {
360
- }
361
- /**
362
- * Map state to all of renderer props.
363
- * @param state the store's state
364
- * @param ownProps any own props
365
- * @returns {StatePropsOfCombinator} state props for a combinator
366
- */
367
- export declare const mapStateToAllOfProps: (state: JsonFormsState, ownProps: OwnPropsOfControl) => StatePropsOfCombinator;
368
- export declare const mapStateToAnyOfProps: (state: JsonFormsState, ownProps: OwnPropsOfControl) => StatePropsOfCombinator;
369
- export declare const mapStateToOneOfProps: (state: JsonFormsState, ownProps: OwnPropsOfControl) => StatePropsOfCombinator;
370
- export interface StatePropsOfArrayLayout extends StatePropsOfControlWithDetail {
371
- data: number;
372
- minItems?: number;
373
- }
374
- /**
375
- * Map state to table props
376
- *
377
- * @param state the store's state
378
- * @param ownProps any element's own props
379
- * @returns {StatePropsOfArrayControl} state props for a table control
380
- */
381
- export declare const mapStateToArrayLayoutProps: (state: JsonFormsState, ownProps: OwnPropsOfControl) => StatePropsOfArrayLayout;
382
- export declare type CombinatorProps = StatePropsOfCombinator & DispatchPropsOfControl;
383
- /**
384
- * Props of an array control.
385
- */
386
- export interface ArrayLayoutProps extends StatePropsOfArrayLayout, DispatchPropsOfArrayControl {
387
- }
1
+ import { ControlElement, JsonSchema, UISchemaElement } from '../models';
2
+ import type { JsonFormsCellRendererRegistryEntry, JsonFormsRendererRegistryEntry } from '../reducers';
3
+ import { JsonFormsUISchemaRegistryEntry } from '../reducers';
4
+ import { RankedTester } from '../testers';
5
+ import { CombinatorKeyword } from './combinators';
6
+ import { AnyAction, Dispatch } from './type';
7
+ import { CoreActions } from '../actions';
8
+ import { ErrorObject } from 'ajv';
9
+ import { JsonFormsState } from '../store';
10
+ import { Translator } from '../i18n';
11
+ /**
12
+ * Adds an asterisk to the given label string based
13
+ * on the required parameter.
14
+ *
15
+ * @param {string | undefined} label the label string
16
+ * @param {boolean} required whether the label belongs to a control which is required
17
+ * @param {boolean} hideRequiredAsterisk applied UI Schema option
18
+ * @returns {string} the label string
19
+ */
20
+ export declare const computeLabel: (label: string | undefined, required: boolean, hideRequiredAsterisk: boolean) => string;
21
+ /**
22
+ * Indicates whether to mark a field as required.
23
+ *
24
+ * @param {boolean} required whether the label belongs to a control which is required
25
+ * @param {boolean} hideRequiredAsterisk applied UI Schema option
26
+ * @returns {boolean} should the field be marked as required
27
+ */
28
+ export declare const showAsRequired: (required: boolean, hideRequiredAsterisk: boolean) => boolean;
29
+ /**
30
+ * Create a default value based on the given scheam.
31
+ * @param schema the schema for which to create a default value.
32
+ * @returns {any}
33
+ */
34
+ export declare const createDefaultValue: (schema: JsonSchema) => {};
35
+ /**
36
+ * Whether an element's description should be hidden.
37
+ *
38
+ * @param visible whether an element is visible
39
+ * @param description the element's description
40
+ * @param isFocused whether the element is focused
41
+ *
42
+ * @returns {boolean} true, if the description is to be hidden, false otherwise
43
+ */
44
+ export declare const isDescriptionHidden: (visible: boolean, description: string | undefined, isFocused: boolean, showUnfocusedDescription: boolean) => boolean;
45
+ export interface WithClassname {
46
+ className?: string;
47
+ }
48
+ export interface EnumOption {
49
+ label: string;
50
+ value: any;
51
+ }
52
+ export declare const enumToEnumOptionMapper: (e: any, t?: Translator, i18nKey?: string) => EnumOption;
53
+ export declare const oneOfToEnumOptionMapper: (e: any, t?: Translator, fallbackI18nKey?: string) => EnumOption;
54
+ export interface OwnPropsOfRenderer {
55
+ /**
56
+ * The UI schema to be rendered.
57
+ */
58
+ uischema?: UISchemaElement;
59
+ /**
60
+ * The JSON schema that describes the data.
61
+ */
62
+ schema?: JsonSchema;
63
+ /**
64
+ * Whether the rendered element should be enabled.
65
+ */
66
+ enabled?: boolean;
67
+ /**
68
+ * Whether the rendered element should be visible.
69
+ */
70
+ visible?: boolean;
71
+ /**
72
+ * Optional instance path. Necessary when the actual data
73
+ * path can not be inferred via the UI schema element as
74
+ * it is the case with nested controls.
75
+ */
76
+ path?: string;
77
+ renderers?: JsonFormsRendererRegistryEntry[];
78
+ cells?: JsonFormsCellRendererRegistryEntry[];
79
+ uischemas?: JsonFormsUISchemaRegistryEntry[];
80
+ }
81
+ export interface OwnPropsOfControl extends OwnPropsOfRenderer {
82
+ id?: string;
83
+ uischema?: ControlElement;
84
+ }
85
+ export interface OwnPropsOfEnum {
86
+ options?: EnumOption[];
87
+ }
88
+ export interface OwnPropsOfLayout extends OwnPropsOfRenderer {
89
+ direction?: 'row' | 'column';
90
+ }
91
+ /**
92
+ * State-based props of a {@link Renderer}.
93
+ */
94
+ export interface StatePropsOfRenderer {
95
+ /**
96
+ * Any configuration options for the element.
97
+ */
98
+ config?: any;
99
+ /**
100
+ * The UI schema to be rendered.
101
+ */
102
+ uischema: UISchemaElement;
103
+ /**
104
+ * The JSON schema that describes the data.
105
+ */
106
+ schema: JsonSchema;
107
+ /**
108
+ * The data to be rendered.
109
+ */
110
+ data?: any;
111
+ /**
112
+ * Whether the rendered element should be enabled.
113
+ */
114
+ enabled: boolean;
115
+ /**
116
+ * Whether the rendered element should be visible.
117
+ */
118
+ visible: boolean;
119
+ /**
120
+ * Instance path the data is written to, in case of a control.
121
+ */
122
+ path: string;
123
+ /**
124
+ * All available renderers.
125
+ */
126
+ renderers?: JsonFormsRendererRegistryEntry[];
127
+ /**
128
+ * All available cell renderers.
129
+ */
130
+ cells?: JsonFormsCellRendererRegistryEntry[];
131
+ }
132
+ /**
133
+ * State-based properties for UI schema elements that have a scope.
134
+ */
135
+ export interface StatePropsOfScopedRenderer extends StatePropsOfRenderer {
136
+ uischema: ControlElement;
137
+ /**
138
+ * Any validation errors that are caused by the data to be rendered.
139
+ */
140
+ errors: string;
141
+ /**
142
+ * The data to be rendered.
143
+ */
144
+ data: any;
145
+ /**
146
+ * The root schema as returned by the store.
147
+ */
148
+ rootSchema: JsonSchema;
149
+ /**
150
+ * A unique ID that should be used for rendering the scoped UI schema element.
151
+ */
152
+ id: string;
153
+ }
154
+ /**
155
+ * Props of a {@link Renderer}.
156
+ */
157
+ export interface RendererProps extends StatePropsOfRenderer {
158
+ }
159
+ /**
160
+ * State-based props of a Control
161
+ */
162
+ export interface StatePropsOfControl extends StatePropsOfScopedRenderer {
163
+ cells?: {
164
+ tester: RankedTester;
165
+ cell: any;
166
+ }[];
167
+ /**
168
+ * The label for the rendered element.
169
+ */
170
+ label: string;
171
+ /**
172
+ * Description of input cell
173
+ */
174
+ description?: string;
175
+ /**
176
+ * Whether the rendered data is required.
177
+ */
178
+ required?: boolean;
179
+ }
180
+ /**
181
+ * Dispatch-based props of a Control.
182
+ */
183
+ export interface DispatchPropsOfControl {
184
+ /**
185
+ * Update handler that emits a data change
186
+ *
187
+ * @param {string} path the path to the data to be updated
188
+ * @param {any} value the new value that should be written to the given path
189
+ */
190
+ handleChange(path: string, value: any): void;
191
+ }
192
+ /**
193
+ * Props of a Control.
194
+ */
195
+ export interface ControlProps extends StatePropsOfControl, DispatchPropsOfControl {
196
+ }
197
+ /**
198
+ * State props of a layout;
199
+ */
200
+ export interface StatePropsOfLayout extends StatePropsOfRenderer {
201
+ /**
202
+ * Direction for the layout to flow
203
+ */
204
+ direction: 'row' | 'column';
205
+ }
206
+ export interface LayoutProps extends StatePropsOfLayout {
207
+ }
208
+ /**
209
+ * The state of a control.
210
+ */
211
+ export interface ControlState {
212
+ /**
213
+ * The current value.
214
+ */
215
+ value: any;
216
+ /**
217
+ * Whether the control is focused.
218
+ */
219
+ isFocused: boolean;
220
+ }
221
+ /**
222
+ * Map state to control props.
223
+ * @param state the store's state
224
+ * @param ownProps any own props
225
+ * @returns {StatePropsOfControl} state props for a control
226
+ */
227
+ export declare const mapStateToControlProps: (state: JsonFormsState, ownProps: OwnPropsOfControl) => StatePropsOfControl;
228
+ /**
229
+ *
230
+ * Map dispatch to control props.
231
+ *
232
+ * @param dispatch the store's dispatch method
233
+ * @returns {DispatchPropsOfControl} dispatch props for a control
234
+ */
235
+ export declare const mapDispatchToControlProps: (dispatch: Dispatch<AnyAction>) => DispatchPropsOfControl;
236
+ /**
237
+ * Default mapStateToCellProps for enum control. Options is used for populating dropdown list
238
+ * @param state
239
+ * @param ownProps
240
+ * @returns {StatePropsOfControl & OwnPropsOfEnum}
241
+ */
242
+ export declare const mapStateToEnumControlProps: (state: JsonFormsState, ownProps: OwnPropsOfControl & OwnPropsOfEnum) => StatePropsOfControl & OwnPropsOfEnum;
243
+ /**
244
+ * Default mapStateToCellProps for enum control based on oneOf. Options is used for populating dropdown list
245
+ * @param state
246
+ * @param ownProps
247
+ * @returns {StatePropsOfControl & OwnPropsOfEnum}
248
+ */
249
+ export declare const mapStateToOneOfEnumControlProps: (state: JsonFormsState, ownProps: OwnPropsOfControl & OwnPropsOfEnum) => StatePropsOfControl & OwnPropsOfEnum;
250
+ /**
251
+ * Default mapStateToCellProps for multi enum control. Options is used for populating dropdown list
252
+ * @param state
253
+ * @param ownProps
254
+ * @returns {StatePropsOfControl & OwnPropsOfEnum}
255
+ */
256
+ export declare const mapStateToMultiEnumControlProps: (state: JsonFormsState, ownProps: OwnPropsOfControl & OwnPropsOfEnum) => StatePropsOfControl & OwnPropsOfEnum;
257
+ /**
258
+ * Map state to control props.
259
+ * @param state the store's state
260
+ * @param ownProps any own props
261
+ * @returns {StatePropsOfControl} state props for a control
262
+ */
263
+ export declare const mapStateToMasterListItemProps: (state: JsonFormsState, ownProps: OwnPropsOfMasterListItem) => StatePropsOfMasterItem;
264
+ /**
265
+ * State-based props of a table control.
266
+ */
267
+ export interface StatePropsOfControlWithDetail extends StatePropsOfControl {
268
+ uischemas?: JsonFormsUISchemaRegistryEntry[];
269
+ renderers?: JsonFormsRendererRegistryEntry[];
270
+ cells?: JsonFormsCellRendererRegistryEntry[];
271
+ }
272
+ export interface OwnPropsOfMasterListItem {
273
+ index: number;
274
+ selected: boolean;
275
+ path: string;
276
+ schema: JsonSchema;
277
+ handleSelect(index: number): () => void;
278
+ removeItem(path: string, value: number): () => void;
279
+ }
280
+ export interface StatePropsOfMasterItem extends OwnPropsOfMasterListItem {
281
+ childLabel: string;
282
+ }
283
+ /**
284
+ * Map state to control with detail props
285
+ *
286
+ * @param state the store's state
287
+ * @param ownProps any element's own props
288
+ * @returns {StatePropsOfArrayControl} state props for a table control
289
+ */
290
+ export declare const mapStateToControlWithDetailProps: (state: JsonFormsState, ownProps: OwnPropsOfControl) => StatePropsOfControlWithDetail;
291
+ export interface ControlWithDetailProps extends StatePropsOfControlWithDetail, DispatchPropsOfControl {
292
+ }
293
+ /**
294
+ * State-based props of a table control.
295
+ */
296
+ export interface StatePropsOfArrayControl extends StatePropsOfControlWithDetail {
297
+ childErrors?: ErrorObject[];
298
+ }
299
+ /**
300
+ * Map state to table props
301
+ *
302
+ * @param state the store's state
303
+ * @param ownProps any element's own props
304
+ * @returns {StatePropsOfArrayControl} state props for a table control
305
+ */
306
+ export declare const mapStateToArrayControlProps: (state: JsonFormsState, ownProps: OwnPropsOfControl) => StatePropsOfArrayControl;
307
+ /**
308
+ * Dispatch props of a table control
309
+ */
310
+ export interface DispatchPropsOfArrayControl {
311
+ addItem(path: string, value: any): () => void;
312
+ removeItems?(path: string, toDelete: number[]): () => void;
313
+ moveUp?(path: string, toMove: number): () => void;
314
+ moveDown?(path: string, toMove: number): () => void;
315
+ }
316
+ /**
317
+ * Maps state to dispatch properties of an array control.
318
+ *
319
+ * @param dispatch the store's dispatch method
320
+ * @returns {DispatchPropsOfArrayControl} dispatch props of an array control
321
+ */
322
+ export declare const mapDispatchToArrayControlProps: (dispatch: Dispatch<CoreActions>) => DispatchPropsOfArrayControl;
323
+ export interface DispatchPropsOfMultiEnumControl {
324
+ addItem: (path: string, value: any) => void;
325
+ removeItem?: (path: string, toDelete: any) => void;
326
+ }
327
+ export declare const mapDispatchToMultiEnumProps: (dispatch: Dispatch<CoreActions>) => DispatchPropsOfMultiEnumControl;
328
+ /**
329
+ * Props of an array control.
330
+ */
331
+ export interface ArrayControlProps extends StatePropsOfArrayControl, DispatchPropsOfArrayControl {
332
+ }
333
+ export declare const layoutDefaultProps: {
334
+ visible: boolean;
335
+ enabled: boolean;
336
+ path: string;
337
+ direction: 'row' | 'column';
338
+ };
339
+ /**
340
+ * Map state to layout props.
341
+ * @param state JSONForms state tree
342
+ * @param ownProps any own props
343
+ * @returns {StatePropsOfLayout}
344
+ */
345
+ export declare const mapStateToLayoutProps: (state: JsonFormsState, ownProps: OwnPropsOfLayout) => LayoutProps;
346
+ export declare type RefResolver = (schema: JsonSchema) => Promise<JsonSchema>;
347
+ export interface OwnPropsOfJsonFormsRenderer extends OwnPropsOfRenderer {
348
+ }
349
+ export interface StatePropsOfJsonFormsRenderer extends OwnPropsOfJsonFormsRenderer {
350
+ rootSchema: JsonSchema;
351
+ }
352
+ export interface JsonFormsProps extends StatePropsOfJsonFormsRenderer {
353
+ }
354
+ export declare const mapStateToJsonFormsRendererProps: (state: JsonFormsState, ownProps: OwnPropsOfJsonFormsRenderer) => StatePropsOfJsonFormsRenderer;
355
+ export declare const controlDefaultProps: {
356
+ errors: string[];
357
+ visible: boolean;
358
+ enabled: boolean;
359
+ path: string;
360
+ direction: 'row' | 'column';
361
+ };
362
+ export interface StatePropsOfCombinator extends OwnPropsOfControl {
363
+ rootSchema: JsonSchema;
364
+ path: string;
365
+ id: string;
366
+ indexOfFittingSchema: number;
367
+ uischemas: JsonFormsUISchemaRegistryEntry[];
368
+ data: any;
369
+ }
370
+ export declare const mapStateToCombinatorRendererProps: (state: JsonFormsState, ownProps: OwnPropsOfControl, keyword: CombinatorKeyword) => StatePropsOfCombinator;
371
+ export interface CombinatorRendererProps extends StatePropsOfCombinator, DispatchPropsOfControl {
372
+ }
373
+ /**
374
+ * Map state to all of renderer props.
375
+ * @param state the store's state
376
+ * @param ownProps any own props
377
+ * @returns {StatePropsOfCombinator} state props for a combinator
378
+ */
379
+ export declare const mapStateToAllOfProps: (state: JsonFormsState, ownProps: OwnPropsOfControl) => StatePropsOfCombinator;
380
+ export declare const mapStateToAnyOfProps: (state: JsonFormsState, ownProps: OwnPropsOfControl) => StatePropsOfCombinator;
381
+ export declare const mapStateToOneOfProps: (state: JsonFormsState, ownProps: OwnPropsOfControl) => StatePropsOfCombinator;
382
+ export interface StatePropsOfArrayLayout extends StatePropsOfControlWithDetail {
383
+ data: number;
384
+ minItems?: number;
385
+ }
386
+ /**
387
+ * Map state to table props
388
+ *
389
+ * @param state the store's state
390
+ * @param ownProps any element's own props
391
+ * @returns {StatePropsOfArrayControl} state props for a table control
392
+ */
393
+ export declare const mapStateToArrayLayoutProps: (state: JsonFormsState, ownProps: OwnPropsOfControl) => StatePropsOfArrayLayout;
394
+ /**
395
+ * Props of an array control.
396
+ */
397
+ export interface ArrayLayoutProps extends StatePropsOfArrayLayout, DispatchPropsOfArrayControl {
398
+ }