@jsonforms/core 2.5.2-alpha.0 → 3.0.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.
- package/README.md +1 -1
- package/docs/assets/js/search.json +1 -1
- package/docs/enums/ruleeffect.html +4 -4
- package/docs/globals.html +1061 -1120
- package/docs/index.html +64 -91
- package/docs/interfaces/addcellrendereraction.html +3 -3
- package/docs/interfaces/addrendereraction.html +3 -3
- package/docs/interfaces/adduischemaaction.html +3 -3
- package/docs/interfaces/andcondition.html +2 -2
- package/docs/interfaces/arraycontrolprops.html +22 -22
- package/docs/interfaces/arraylayoutprops.html +22 -22
- package/docs/interfaces/categorization.html +5 -5
- package/docs/interfaces/category.html +5 -5
- package/docs/interfaces/cellprops.html +14 -14
- package/docs/interfaces/combinatorrendererprops.html +13 -13
- package/docs/interfaces/combinatorsubschemarenderinfo.html +3 -3
- package/docs/interfaces/composablecondition.html +2 -2
- package/docs/interfaces/condition.html +1 -1
- package/docs/interfaces/controlelement.html +5 -5
- package/docs/interfaces/controlprops.html +17 -17
- package/docs/interfaces/controlstate.html +2 -2
- package/docs/interfaces/controlwithdetailprops.html +18 -18
- package/docs/interfaces/dispatchcellprops.html +13 -13
- package/docs/interfaces/dispatchcellstateprops.html +13 -13
- package/docs/interfaces/dispatchpropsofarraycontrol.html +4 -4
- package/docs/interfaces/dispatchpropsofcontrol.html +1 -1
- package/docs/interfaces/dispatchpropsofmultienumcontrol.html +2 -2
- package/docs/interfaces/enumcellprops.html +15 -15
- package/docs/interfaces/enumoption.html +2 -2
- package/docs/interfaces/formatted.html +2 -2
- package/docs/interfaces/grouplayout.html +5 -5
- package/docs/interfaces/horizontallayout.html +4 -4
- package/docs/interfaces/initaction.html +6 -6
- package/docs/interfaces/initactionoptions.html +3 -17
- package/docs/interfaces/jsonformscellrendererregistryentry.html +2 -2
- package/docs/interfaces/jsonformscore.html +7 -21
- package/docs/interfaces/jsonformsdefaultdataregistryentry.html +2 -2
- package/docs/interfaces/jsonformsextendedstate.html +1 -1
- package/docs/interfaces/{jsonformslocalestate.html → jsonformsi18nstate.html} +20 -20
- package/docs/interfaces/jsonformsprops.html +9 -24
- package/docs/interfaces/jsonformsrendererregistryentry.html +2 -2
- package/docs/interfaces/jsonformsstate.html +1 -1
- package/docs/interfaces/jsonformsstore.html +5 -5
- package/docs/interfaces/jsonformssubstates.html +18 -8
- package/docs/interfaces/jsonformsuischemaregistryentry.html +2 -2
- package/docs/interfaces/labeldescription.html +2 -2
- package/docs/interfaces/labelelement.html +4 -4
- package/docs/interfaces/layout.html +4 -4
- package/docs/interfaces/layoutprops.html +10 -10
- package/docs/interfaces/leafcondition.html +3 -3
- package/docs/interfaces/orcondition.html +2 -2
- package/docs/interfaces/ownpropsofcell.html +10 -10
- package/docs/interfaces/ownpropsofcontrol.html +9 -9
- package/docs/interfaces/ownpropsofenum.html +1 -1
- package/docs/interfaces/ownpropsofenumcell.html +11 -11
- package/docs/interfaces/ownpropsofjsonformsrenderer.html +8 -8
- package/docs/interfaces/ownpropsoflayout.html +9 -9
- package/docs/interfaces/ownpropsofmasterlistitem.html +6 -6
- package/docs/interfaces/ownpropsofrenderer.html +8 -8
- package/docs/interfaces/registerdefaultdataaction.html +3 -3
- package/docs/interfaces/removecellrendereraction.html +3 -3
- package/docs/interfaces/removerendereraction.html +3 -3
- package/docs/interfaces/removeuischemaaction.html +2 -2
- package/docs/interfaces/rendererprops.html +9 -9
- package/docs/interfaces/rule.html +2 -2
- package/docs/interfaces/schemabasedcondition.html +3 -3
- package/docs/interfaces/scopable.html +1 -1
- package/docs/interfaces/setajvaction.html +3 -3
- package/docs/interfaces/setconfigaction.html +2 -2
- package/docs/interfaces/setlocaleaction.html +3 -3
- package/docs/interfaces/setschemaaction.html +2 -2
- package/docs/interfaces/{setlocalizeduischemasaction.html → settranslatoraction.html} +29 -15
- package/docs/interfaces/setuischemaaction.html +2 -2
- package/docs/interfaces/setvalidationmodeaction.html +2 -2
- package/docs/interfaces/statepropsofarraycontrol.html +18 -18
- package/docs/interfaces/statepropsofarraylayout.html +18 -18
- package/docs/interfaces/statepropsofcell.html +13 -13
- package/docs/interfaces/statepropsofcombinator.html +12 -12
- package/docs/interfaces/statepropsofcontrol.html +16 -16
- package/docs/interfaces/statepropsofcontrolwithdetail.html +17 -17
- package/docs/interfaces/statepropsofenumcell.html +14 -14
- package/docs/interfaces/statepropsofjsonformsrenderer.html +9 -23
- package/docs/interfaces/statepropsoflayout.html +10 -10
- package/docs/interfaces/statepropsofmasteritem.html +7 -7
- package/docs/interfaces/statepropsofrenderer.html +9 -9
- package/docs/interfaces/statepropsofscopedrenderer.html +12 -12
- package/docs/interfaces/uischemaelement.html +3 -3
- package/docs/interfaces/unregisterdefaultdataaction.html +2 -2
- package/docs/interfaces/updateaction.html +3 -3
- package/docs/interfaces/updatecoreaction.html +6 -6
- package/docs/interfaces/updateerrorsaction.html +2 -2
- package/docs/interfaces/{setlocalizedschemasaction.html → updatei18naction.html} +43 -15
- package/docs/interfaces/verticallayout.html +4 -4
- package/docs/interfaces/withclassname.html +1 -1
- package/lib/Helpers.d.ts +5 -0
- package/lib/Helpers.js +33 -0
- package/lib/Helpers.js.map +1 -0
- package/lib/actions/actions.d.ts +181 -0
- package/lib/actions/actions.js +173 -0
- package/lib/actions/actions.js.map +1 -0
- package/lib/actions/index.d.ts +1 -180
- package/lib/actions/index.js +26 -122
- package/lib/actions/index.js.map +1 -1
- package/lib/configDefault.js +2 -1
- package/lib/configDefault.js.map +1 -1
- package/lib/generators/Generate.d.ts +6 -0
- package/lib/generators/Generate.js +35 -0
- package/lib/generators/Generate.js.map +1 -0
- package/lib/generators/index.d.ts +3 -10
- package/lib/generators/index.js +28 -9
- package/lib/generators/index.js.map +1 -1
- package/lib/generators/schema.d.ts +1 -1
- package/lib/generators/schema.js +3 -1
- package/lib/generators/schema.js.map +1 -1
- package/lib/generators/uischema.d.ts +1 -2
- package/lib/generators/uischema.js +12 -10
- package/lib/generators/uischema.js.map +1 -1
- package/lib/i18n/i18nTypes.d.ts +15 -0
- package/lib/i18n/i18nTypes.js +3 -0
- package/lib/i18n/i18nTypes.js.map +1 -0
- package/lib/i18n/i18nUtil.d.ts +11 -0
- package/lib/i18n/i18nUtil.js +58 -0
- package/lib/i18n/i18nUtil.js.map +1 -0
- package/lib/i18n/index.d.ts +2 -0
- package/lib/i18n/index.js +6 -0
- package/lib/i18n/index.js.map +1 -0
- package/lib/index.d.ts +6 -18
- package/lib/index.js +10 -15
- package/lib/index.js.map +1 -1
- package/lib/jsonforms-core.js +9 -12
- package/lib/jsonforms-core.js.map +1 -1
- package/lib/models/draft4.js +2 -1
- package/lib/models/draft4.js.map +1 -1
- package/lib/models/index.d.ts +5 -0
- package/lib/models/index.js +33 -0
- package/lib/models/index.js.map +1 -0
- package/lib/models/jsonSchema.js +24 -0
- package/lib/models/jsonSchema.js.map +1 -1
- package/lib/models/uischema.js +29 -2
- package/lib/models/uischema.js.map +1 -1
- package/lib/reducers/cells.d.ts +1 -1
- package/lib/reducers/cells.js +27 -1
- package/lib/reducers/cells.js.map +1 -1
- package/lib/reducers/config.d.ts +1 -1
- package/lib/reducers/config.js +5 -3
- package/lib/reducers/config.js.map +1 -1
- package/lib/reducers/core.d.ts +5 -7
- package/lib/reducers/core.js +78 -63
- package/lib/reducers/core.js.map +1 -1
- package/lib/reducers/default-data.d.ts +1 -1
- package/lib/reducers/default-data.js +6 -3
- package/lib/reducers/default-data.js.map +1 -1
- package/lib/reducers/i18n.d.ts +8 -11
- package/lib/reducers/i18n.js +40 -23
- package/lib/reducers/i18n.js.map +1 -1
- package/lib/reducers/index.d.ts +9 -49
- package/lib/reducers/index.js +33 -91
- package/lib/reducers/index.js.map +1 -1
- package/lib/reducers/reducers.d.ts +37 -0
- package/lib/reducers/reducers.js +107 -0
- package/lib/reducers/reducers.js.map +1 -0
- package/lib/reducers/renderers.d.ts +1 -1
- package/lib/reducers/renderers.js +27 -1
- package/lib/reducers/renderers.js.map +1 -1
- package/lib/reducers/selectors.d.ts +15 -0
- package/lib/reducers/selectors.js +56 -0
- package/lib/reducers/selectors.js.map +1 -0
- package/lib/reducers/uischemas.d.ts +2 -2
- package/lib/reducers/uischemas.js +9 -6
- package/lib/reducers/uischemas.js.map +1 -1
- package/lib/store.d.ts +5 -8
- package/lib/store.js +24 -0
- package/lib/store.js.map +1 -1
- package/lib/testers/index.d.ts +1 -204
- package/lib/testers/index.js +3 -376
- package/lib/testers/index.js.map +1 -1
- package/lib/testers/testers.d.ts +203 -0
- package/lib/testers/testers.js +421 -0
- package/lib/testers/testers.js.map +1 -0
- package/lib/util/Formatted.js +24 -0
- package/lib/util/Formatted.js.map +1 -1
- package/lib/util/array.js +25 -0
- package/lib/util/array.js.map +1 -1
- package/lib/util/cell.d.ts +11 -4
- package/lib/util/cell.js +61 -17
- package/lib/util/cell.js.map +1 -1
- package/lib/util/combinators.d.ts +2 -3
- package/lib/util/combinators.js +5 -2
- package/lib/util/combinators.js.map +1 -1
- package/lib/util/ids.js +8 -4
- package/lib/util/ids.js.map +1 -1
- package/lib/util/index.d.ts +11 -45
- package/lib/util/index.js +14 -104
- package/lib/util/index.js.map +1 -1
- package/lib/util/label.d.ts +1 -2
- package/lib/util/label.js +7 -4
- package/lib/util/label.js.map +1 -1
- package/lib/util/path.d.ts +2 -1
- package/lib/util/path.js +12 -6
- package/lib/util/path.js.map +1 -1
- package/lib/util/renderer.d.ts +17 -17
- package/lib/util/renderer.js +163 -76
- package/lib/util/renderer.js.map +1 -1
- package/lib/util/resolvers.d.ts +1 -14
- package/lib/util/resolvers.js +9 -215
- package/lib/util/resolvers.js.map +1 -1
- package/lib/util/runtime.d.ts +12 -2
- package/lib/util/runtime.js +59 -17
- package/lib/util/runtime.js.map +1 -1
- package/lib/util/schema.js +27 -1
- package/lib/util/schema.js.map +1 -1
- package/lib/util/uischema.d.ts +1 -1
- package/lib/util/uischema.js +11 -7
- package/lib/util/uischema.js.map +1 -1
- package/lib/util/util.d.ts +31 -0
- package/lib/util/util.js +112 -0
- package/lib/util/util.js.map +1 -0
- package/lib/util/validator.d.ts +3 -2
- package/lib/util/validator.js +6 -5
- package/lib/util/validator.js.map +1 -1
- package/package.json +7 -9
- package/src/Helpers.ts +38 -0
- package/src/actions/actions.ts +345 -0
- package/src/actions/index.ts +1 -312
- package/src/configDefault.ts +1 -0
- package/src/generators/Generate.ts +43 -0
- package/src/generators/index.ts +3 -21
- package/src/generators/schema.ts +1 -1
- package/src/generators/uischema.ts +4 -4
- package/src/i18n/i18nTypes.ts +17 -0
- package/src/i18n/i18nUtil.ts +76 -0
- package/src/i18n/index.ts +2 -0
- package/src/index.ts +7 -31
- package/src/models/draft4.ts +1 -0
- package/src/models/index.ts +30 -0
- package/src/models/jsonSchema.ts +1 -0
- package/src/models/uischema.ts +1 -0
- package/src/reducers/cells.ts +2 -1
- package/src/reducers/config.ts +2 -1
- package/src/reducers/core.ts +74 -81
- package/src/reducers/default-data.ts +2 -1
- package/src/reducers/i18n.ts +42 -35
- package/src/reducers/index.ts +9 -158
- package/src/reducers/reducers.ts +148 -0
- package/src/reducers/renderers.ts +2 -1
- package/src/reducers/selectors.ts +65 -0
- package/src/reducers/uischemas.ts +4 -2
- package/src/store.ts +11 -8
- package/src/testers/index.ts +1 -516
- package/src/testers/testers.ts +547 -0
- package/src/util/Formatted.ts +1 -0
- package/src/util/array.ts +25 -0
- package/src/util/cell.ts +91 -19
- package/src/util/combinators.ts +2 -4
- package/src/util/ids.ts +1 -0
- package/src/util/index.ts +11 -126
- package/src/util/label.ts +2 -2
- package/src/util/path.ts +4 -1
- package/src/util/renderer.ts +168 -85
- package/src/util/resolvers.ts +2 -261
- package/src/util/runtime.ts +46 -2
- package/src/util/schema.ts +26 -1
- package/src/util/uischema.ts +2 -1
- package/src/util/util.ts +127 -0
- package/src/util/validator.ts +5 -8
- package/test/reducers/core.test.ts +31 -223
- package/test/util/cell.test.ts +33 -2
- package/test/util/renderer.test.ts +483 -3
- package/test/util/resolvers.test.ts +1 -59
- package/test/util/runtime.test.ts +264 -4
- package/docs/interfaces/labels.html +0 -157
- package/docs/interfaces/schemaref.html +0 -160
- package/docs/interfaces/schemarefs.html +0 -138
package/src/util/cell.ts
CHANGED
|
@@ -22,29 +22,40 @@
|
|
|
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
|
import isEmpty from 'lodash/isEmpty';
|
|
26
27
|
import union from 'lodash/union';
|
|
27
|
-
import { getConfig, getData, getErrorAt, getSchema, getAjv } from '../reducers';
|
|
28
28
|
import {
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
getConfig,
|
|
30
|
+
getData,
|
|
31
|
+
getErrorAt,
|
|
32
|
+
getSchema,
|
|
33
|
+
getAjv,
|
|
34
|
+
JsonFormsCellRendererRegistryEntry,
|
|
35
|
+
getTranslator
|
|
36
|
+
} from '../reducers';
|
|
37
|
+
import { AnyAction, Dispatch } from './type';
|
|
38
|
+
import {
|
|
31
39
|
formatErrorMessage,
|
|
32
|
-
isEnabled,
|
|
33
|
-
isVisible,
|
|
34
|
-
OwnPropsOfControl,
|
|
35
|
-
OwnPropsOfEnum,
|
|
36
40
|
Resolve,
|
|
37
|
-
|
|
38
|
-
|
|
41
|
+
} from './util';
|
|
42
|
+
import {
|
|
43
|
+
isInherentlyEnabled,
|
|
44
|
+
isVisible,
|
|
45
|
+
} from './runtime';
|
|
39
46
|
import {
|
|
40
47
|
DispatchPropsOfControl,
|
|
41
48
|
EnumOption,
|
|
42
49
|
enumToEnumOptionMapper,
|
|
43
50
|
mapDispatchToControlProps,
|
|
51
|
+
oneOfToEnumOptionMapper,
|
|
52
|
+
OwnPropsOfControl,
|
|
53
|
+
OwnPropsOfEnum,
|
|
54
|
+
StatePropsOfScopedRenderer,
|
|
44
55
|
} from './renderer';
|
|
45
56
|
import { JsonFormsState } from '../store';
|
|
46
|
-
import {
|
|
47
|
-
import {
|
|
57
|
+
import { JsonSchema } from '../models';
|
|
58
|
+
import { i18nJsonSchema } from '..';
|
|
48
59
|
|
|
49
60
|
export { JsonFormsCellRendererRegistryEntry };
|
|
50
61
|
|
|
@@ -109,16 +120,38 @@ export const mapStateToCellProps = (
|
|
|
109
120
|
ownProps.visible !== undefined
|
|
110
121
|
? ownProps.visible
|
|
111
122
|
: isVisible(uischema, rootData, undefined, getAjv(state));
|
|
112
|
-
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
123
|
+
|
|
124
|
+
const rootSchema = getSchema(state);
|
|
125
|
+
const config = getConfig(state);
|
|
126
|
+
|
|
127
|
+
/* When determining the enabled state of cells we take a shortcut: At the
|
|
128
|
+
* moment it's only possible to configure enablement and disablement at the
|
|
129
|
+
* control level. Therefore the renderer using the cell, for example a
|
|
130
|
+
* table renderer, determines whether a cell is enabled and should hand
|
|
131
|
+
* over the prop themselves. If that prop was given, we prefer it over
|
|
132
|
+
* anything else to save evaluation effort (except for the global readonly
|
|
133
|
+
* flag). For example it would be quite expensive to evaluate the same ui schema
|
|
134
|
+
* rule again and again for each cell of a table. */
|
|
135
|
+
let enabled;
|
|
136
|
+
if (state.jsonforms.readonly === true) {
|
|
137
|
+
enabled = false;
|
|
138
|
+
} else if (typeof ownProps.enabled === 'boolean') {
|
|
139
|
+
enabled = ownProps.enabled;
|
|
140
|
+
} else {
|
|
141
|
+
enabled = isInherentlyEnabled(
|
|
142
|
+
state,
|
|
143
|
+
ownProps,
|
|
144
|
+
uischema,
|
|
145
|
+
schema || rootSchema,
|
|
146
|
+
rootData,
|
|
147
|
+
config
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
|
|
117
151
|
const errors = formatErrorMessage(
|
|
118
152
|
union(getErrorAt(path, schema)(state).map(error => error.message))
|
|
119
153
|
);
|
|
120
154
|
const isValid = isEmpty(errors);
|
|
121
|
-
const rootSchema = getSchema(state);
|
|
122
155
|
|
|
123
156
|
return {
|
|
124
157
|
data: Resolve.data(rootData, path),
|
|
@@ -165,14 +198,53 @@ export const defaultMapStateToEnumCellProps = (
|
|
|
165
198
|
const props: StatePropsOfCell = mapStateToCellProps(state, ownProps);
|
|
166
199
|
const options: EnumOption[] =
|
|
167
200
|
ownProps.options ||
|
|
168
|
-
props.schema.enum?.map(
|
|
169
|
-
|
|
201
|
+
props.schema.enum?.map(e =>
|
|
202
|
+
enumToEnumOptionMapper(
|
|
203
|
+
e,
|
|
204
|
+
getTranslator()(state),
|
|
205
|
+
props.uischema?.options?.i18n ?? (props.schema as i18nJsonSchema).i18n
|
|
206
|
+
)
|
|
207
|
+
) ||
|
|
208
|
+
(props.schema.const && [
|
|
209
|
+
enumToEnumOptionMapper(
|
|
210
|
+
props.schema.const,
|
|
211
|
+
getTranslator()(state),
|
|
212
|
+
props.uischema?.options?.i18n ?? (props.schema as i18nJsonSchema).i18n
|
|
213
|
+
)
|
|
214
|
+
]);
|
|
215
|
+
return {
|
|
216
|
+
...props,
|
|
217
|
+
options
|
|
218
|
+
};
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* mapStateToOneOfEnumCellProps for one of enum cell. Options is used for populating dropdown list from oneOf
|
|
223
|
+
* @param state
|
|
224
|
+
* @param ownProps
|
|
225
|
+
* @returns {StatePropsOfEnumCell}
|
|
226
|
+
*/
|
|
227
|
+
export const mapStateToOneOfEnumCellProps = (
|
|
228
|
+
state: JsonFormsState,
|
|
229
|
+
ownProps: OwnPropsOfEnumCell
|
|
230
|
+
): StatePropsOfEnumCell => {
|
|
231
|
+
const props: StatePropsOfCell = mapStateToCellProps(state, ownProps);
|
|
232
|
+
const options: EnumOption[] =
|
|
233
|
+
ownProps.options ||
|
|
234
|
+
(props.schema.oneOf as JsonSchema[])?.map(oneOfSubSchema =>
|
|
235
|
+
oneOfToEnumOptionMapper(
|
|
236
|
+
oneOfSubSchema,
|
|
237
|
+
getTranslator()(state),
|
|
238
|
+
props.uischema?.options?.i18n
|
|
239
|
+
)
|
|
240
|
+
);
|
|
170
241
|
return {
|
|
171
242
|
...props,
|
|
172
243
|
options
|
|
173
244
|
};
|
|
174
245
|
};
|
|
175
246
|
|
|
247
|
+
|
|
176
248
|
/**
|
|
177
249
|
* Synonym for mapDispatchToControlProps.
|
|
178
250
|
*
|
package/src/util/combinators.ts
CHANGED
|
@@ -23,11 +23,9 @@
|
|
|
23
23
|
THE SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
import { JsonSchema } from '../models
|
|
27
|
-
import { ControlElement, UISchemaElement } from '../models/uischema';
|
|
26
|
+
import { ControlElement, JsonSchema, UISchemaElement } from '../models';
|
|
28
27
|
import { resolveSchema } from './resolvers';
|
|
29
|
-
import { findUISchema } from '../reducers';
|
|
30
|
-
import { JsonFormsUISchemaRegistryEntry } from '../reducers/uischemas';
|
|
28
|
+
import { findUISchema, JsonFormsUISchemaRegistryEntry } from '../reducers';
|
|
31
29
|
|
|
32
30
|
export interface CombinatorSubSchemaRenderInfo {
|
|
33
31
|
schema: JsonSchema;
|
package/src/util/ids.ts
CHANGED
package/src/util/index.ts
CHANGED
|
@@ -22,134 +22,19 @@
|
|
|
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 isEmpty from 'lodash/isEmpty';
|
|
26
|
-
import isArray from 'lodash/isArray';
|
|
27
|
-
import includes from 'lodash/includes';
|
|
28
|
-
import find from 'lodash/find';
|
|
29
|
-
import { JsonSchema, Scopable, UISchemaElement } from '../';
|
|
30
|
-
import { resolveData, resolveSchema } from './resolvers';
|
|
31
|
-
import {
|
|
32
|
-
compose as composePaths,
|
|
33
|
-
composeWithUi,
|
|
34
|
-
toDataPath,
|
|
35
|
-
toDataPathSegments
|
|
36
|
-
} from './path';
|
|
37
|
-
import { isEnabled, isVisible } from './runtime';
|
|
38
|
-
import { Ajv } from 'ajv';
|
|
39
25
|
|
|
40
|
-
export
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Escape the given string such that it can be used as a class name,
|
|
44
|
-
* i.e. hashes and slashes will be replaced.
|
|
45
|
-
*
|
|
46
|
-
* @param {string} s the string that should be converted to a valid class name
|
|
47
|
-
* @returns {string} the escaped string
|
|
48
|
-
*/
|
|
49
|
-
export const convertToValidClassName = (s: string): string =>
|
|
50
|
-
s.replace('#', 'root').replace(new RegExp('/', 'g'), '_');
|
|
51
|
-
|
|
52
|
-
export const formatErrorMessage = (errors: string[]) => {
|
|
53
|
-
if (errors === undefined || errors === null) {
|
|
54
|
-
return '';
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return errors.join('\n');
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const hasType = (jsonSchema: JsonSchema, expected: string): boolean => {
|
|
61
|
-
return includes(deriveTypes(jsonSchema), expected);
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Derives the type of the jsonSchema element
|
|
66
|
-
*/
|
|
67
|
-
const deriveTypes = (jsonSchema: JsonSchema): string[] => {
|
|
68
|
-
if (isEmpty(jsonSchema)) {
|
|
69
|
-
return [];
|
|
70
|
-
}
|
|
71
|
-
if (!isEmpty(jsonSchema.type) && typeof jsonSchema.type === 'string') {
|
|
72
|
-
return [jsonSchema.type];
|
|
73
|
-
}
|
|
74
|
-
if (isArray(jsonSchema.type)) {
|
|
75
|
-
return jsonSchema.type;
|
|
76
|
-
}
|
|
77
|
-
if (
|
|
78
|
-
!isEmpty(jsonSchema.properties) ||
|
|
79
|
-
!isEmpty(jsonSchema.additionalProperties)
|
|
80
|
-
) {
|
|
81
|
-
return ['object'];
|
|
82
|
-
}
|
|
83
|
-
if (!isEmpty(jsonSchema.items)) {
|
|
84
|
-
return ['array'];
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if (!isEmpty(jsonSchema.allOf)) {
|
|
88
|
-
const allOfType = find(
|
|
89
|
-
jsonSchema.allOf,
|
|
90
|
-
(schema: JsonSchema) => deriveTypes(schema).length !== 0
|
|
91
|
-
);
|
|
92
|
-
|
|
93
|
-
if (allOfType) {
|
|
94
|
-
return deriveTypes(allOfType);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
// ignore all remaining cases
|
|
98
|
-
return [];
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Convenience wrapper around resolveData and resolveSchema.
|
|
103
|
-
*/
|
|
104
|
-
const Resolve: {
|
|
105
|
-
schema(
|
|
106
|
-
schema: JsonSchema,
|
|
107
|
-
schemaPath: string,
|
|
108
|
-
rootSchema?: JsonSchema
|
|
109
|
-
): JsonSchema;
|
|
110
|
-
data(data: any, path: string): any;
|
|
111
|
-
} = {
|
|
112
|
-
schema: resolveSchema,
|
|
113
|
-
data: resolveData
|
|
114
|
-
};
|
|
115
|
-
export {
|
|
116
|
-
resolveData,
|
|
117
|
-
resolveSchema,
|
|
118
|
-
findRefs,
|
|
119
|
-
SchemaRef,
|
|
120
|
-
SchemaRefs
|
|
121
|
-
} from './resolvers';
|
|
122
|
-
export { Resolve };
|
|
123
|
-
|
|
124
|
-
// Paths --
|
|
125
|
-
const fromScopable = (scopable: Scopable) =>
|
|
126
|
-
toDataPathSegments(scopable.scope).join('.');
|
|
127
|
-
|
|
128
|
-
const Paths = {
|
|
129
|
-
compose: composePaths,
|
|
130
|
-
fromScopable
|
|
131
|
-
};
|
|
132
|
-
export { composePaths, composeWithUi, Paths, toDataPath };
|
|
133
|
-
|
|
134
|
-
// Runtime --
|
|
135
|
-
const Runtime = {
|
|
136
|
-
isEnabled(uischema: UISchemaElement, data: any, ajv: Ajv): boolean {
|
|
137
|
-
return isEnabled(uischema, data,undefined, ajv);
|
|
138
|
-
},
|
|
139
|
-
isVisible(uischema: UISchemaElement, data: any, ajv: Ajv): boolean {
|
|
140
|
-
return isVisible(uischema, data, undefined, ajv);
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
export { isEnabled, isVisible, Runtime, deriveTypes, hasType };
|
|
144
|
-
|
|
145
|
-
export * from './renderer';
|
|
26
|
+
export * from './array';
|
|
146
27
|
export * from './cell';
|
|
147
|
-
export * from './
|
|
28
|
+
export * from './combinators';
|
|
148
29
|
export * from './Formatted';
|
|
149
30
|
export * from './ids';
|
|
150
|
-
export * from './
|
|
151
|
-
export * from './
|
|
152
|
-
export * from './
|
|
153
|
-
export * from './
|
|
154
|
-
export * from './
|
|
31
|
+
export * from './label';
|
|
32
|
+
export * from './path';
|
|
33
|
+
export * from './renderer';
|
|
34
|
+
export * from './resolvers';
|
|
35
|
+
export * from './runtime';
|
|
155
36
|
export * from './schema';
|
|
37
|
+
export * from './type';
|
|
38
|
+
export * from './uischema';
|
|
39
|
+
export * from './util';
|
|
40
|
+
export * from './validator';
|
package/src/util/label.ts
CHANGED
|
@@ -22,10 +22,10 @@
|
|
|
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
|
import startCase from 'lodash/startCase';
|
|
26
27
|
|
|
27
|
-
import { ControlElement, LabelDescription } from '../models
|
|
28
|
-
import { JsonSchema } from '../models/jsonSchema';
|
|
28
|
+
import { ControlElement, JsonSchema, LabelDescription } from '../models';
|
|
29
29
|
|
|
30
30
|
const deriveLabel = (
|
|
31
31
|
controlElement: ControlElement,
|
package/src/util/path.ts
CHANGED
|
@@ -22,9 +22,10 @@
|
|
|
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
|
import isEmpty from 'lodash/isEmpty';
|
|
26
27
|
import range from 'lodash/range';
|
|
27
|
-
import { Scopable } from '../';
|
|
28
|
+
import { Scopable } from '../models';
|
|
28
29
|
|
|
29
30
|
export const compose = (path1: string, path2: string) => {
|
|
30
31
|
let p1 = path1;
|
|
@@ -41,6 +42,8 @@ export const compose = (path1: string, path2: string) => {
|
|
|
41
42
|
}
|
|
42
43
|
};
|
|
43
44
|
|
|
45
|
+
export { compose as composePaths };
|
|
46
|
+
|
|
44
47
|
/**
|
|
45
48
|
* Convert a schema path (i.e. JSON pointer) to an array by splitting
|
|
46
49
|
* at the '/' character and removing all schema-specific keywords.
|