@tsed/schema-formio 6.88.0 → 6.91.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.
- package/lib/{components → cjs/components}/anyToComponent.d.ts +0 -0
- package/lib/cjs/components/anyToComponent.js +29 -0
- package/lib/cjs/components/anyToComponent.js.map +1 -0
- package/lib/{components → cjs/components}/arrayToComponent.d.ts +0 -0
- package/lib/cjs/components/arrayToComponent.js +40 -0
- package/lib/cjs/components/arrayToComponent.js.map +1 -0
- package/lib/{components → cjs/components}/booleanToComponent.d.ts +0 -0
- package/lib/cjs/components/booleanToComponent.js +14 -0
- package/lib/cjs/components/booleanToComponent.js.map +1 -0
- package/lib/{components → cjs/components}/dateToComponent.d.ts +0 -0
- package/lib/cjs/components/dateToComponent.js +57 -0
- package/lib/cjs/components/dateToComponent.js.map +1 -0
- package/lib/{components → cjs/components}/defaultToComponent.d.ts +0 -0
- package/lib/cjs/components/defaultToComponent.js +18 -0
- package/lib/cjs/components/defaultToComponent.js.map +1 -0
- package/lib/{components → cjs/components}/enumToComponent.d.ts +0 -0
- package/lib/cjs/components/enumToComponent.js +34 -0
- package/lib/cjs/components/enumToComponent.js.map +1 -0
- package/lib/{components → cjs/components}/index.d.ts +0 -0
- package/lib/cjs/components/index.js +17 -0
- package/lib/cjs/components/index.js.map +1 -0
- package/lib/{components → cjs/components}/mapToComponent.d.ts +0 -0
- package/lib/cjs/components/mapToComponent.js +20 -0
- package/lib/cjs/components/mapToComponent.js.map +1 -0
- package/lib/{components → cjs/components}/nestedToComponent.d.ts +0 -0
- package/lib/cjs/components/nestedToComponent.js +25 -0
- package/lib/cjs/components/nestedToComponent.js.map +1 -0
- package/lib/{components → cjs/components}/numberToComponent.d.ts +0 -0
- package/lib/cjs/components/numberToComponent.js +21 -0
- package/lib/cjs/components/numberToComponent.js.map +1 -0
- package/lib/{components → cjs/components}/objectToEditGrid.d.ts +0 -0
- package/lib/cjs/components/objectToEditGrid.js +16 -0
- package/lib/cjs/components/objectToEditGrid.js.map +1 -0
- package/lib/{components → cjs/components}/panelToComponent.d.ts +0 -0
- package/lib/cjs/components/panelToComponent.js +16 -0
- package/lib/cjs/components/panelToComponent.js.map +1 -0
- package/lib/{components → cjs/components}/propertiesToComponents.d.ts +0 -0
- package/lib/cjs/components/propertiesToComponents.js +88 -0
- package/lib/cjs/components/propertiesToComponents.js.map +1 -0
- package/lib/{components → cjs/components}/stringToComponent.d.ts +0 -0
- package/lib/cjs/components/stringToComponent.js +43 -0
- package/lib/cjs/components/stringToComponent.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/component.d.ts +0 -0
- package/lib/cjs/decorators/component.js +35 -0
- package/lib/cjs/decorators/component.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/conditional.d.ts +0 -0
- package/lib/cjs/decorators/conditional.js +53 -0
- package/lib/cjs/decorators/conditional.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/currency.d.ts +0 -0
- package/lib/cjs/decorators/currency.js +24 -0
- package/lib/cjs/decorators/currency.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/customClass.d.ts +0 -0
- package/lib/cjs/decorators/customClass.js +18 -0
- package/lib/cjs/decorators/customClass.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/customConditional.d.ts +0 -0
- package/lib/cjs/decorators/customConditional.js +33 -0
- package/lib/cjs/decorators/customConditional.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/dataSourceJson.d.ts +0 -0
- package/lib/cjs/decorators/dataSourceJson.js +27 -0
- package/lib/cjs/decorators/dataSourceJson.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/dataSourceUrl.d.ts +0 -0
- package/lib/cjs/decorators/dataSourceUrl.js +22 -0
- package/lib/cjs/decorators/dataSourceUrl.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/errorLabel.d.ts +0 -0
- package/lib/cjs/decorators/errorLabel.js +18 -0
- package/lib/cjs/decorators/errorLabel.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/errorMessage.d.ts +0 -0
- package/lib/cjs/decorators/errorMessage.js +17 -0
- package/lib/cjs/decorators/errorMessage.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/form.d.ts +0 -0
- package/lib/cjs/decorators/form.js +21 -0
- package/lib/cjs/decorators/form.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/hidden.d.ts +0 -0
- package/lib/cjs/decorators/hidden.js +22 -0
- package/lib/cjs/decorators/hidden.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/index.d.ts +0 -0
- package/lib/cjs/decorators/index.js +34 -0
- package/lib/cjs/decorators/index.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/inputTags.d.ts +0 -0
- package/lib/cjs/decorators/inputTags.js +23 -0
- package/lib/cjs/decorators/inputTags.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/label.d.ts +0 -0
- package/lib/cjs/decorators/label.js +19 -0
- package/lib/cjs/decorators/label.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/mask.d.ts +0 -0
- package/lib/cjs/decorators/mask.js +50 -0
- package/lib/cjs/decorators/mask.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/maxWords.d.ts +0 -0
- package/lib/cjs/decorators/maxWords.js +17 -0
- package/lib/cjs/decorators/maxWords.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/minWords.d.ts +0 -0
- package/lib/cjs/decorators/minWords.js +17 -0
- package/lib/cjs/decorators/minWords.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/modalEdit.d.ts +0 -0
- package/lib/cjs/decorators/modalEdit.js +18 -0
- package/lib/cjs/decorators/modalEdit.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/multiple.d.ts +0 -0
- package/lib/cjs/decorators/multiple.js +18 -0
- package/lib/cjs/decorators/multiple.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/openWhenEmpty.d.ts +0 -0
- package/lib/cjs/decorators/openWhenEmpty.js +18 -0
- package/lib/cjs/decorators/openWhenEmpty.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/password.d.ts +0 -0
- package/lib/cjs/decorators/password.js +20 -0
- package/lib/cjs/decorators/password.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/placeholder.d.ts +0 -0
- package/lib/cjs/decorators/placeholder.js +19 -0
- package/lib/cjs/decorators/placeholder.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/prefix.d.ts +0 -0
- package/lib/cjs/decorators/prefix.js +18 -0
- package/lib/cjs/decorators/prefix.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/select.d.ts +0 -0
- package/lib/cjs/decorators/select.js +22 -0
- package/lib/cjs/decorators/select.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/suffix.d.ts +0 -0
- package/lib/cjs/decorators/suffix.js +18 -0
- package/lib/cjs/decorators/suffix.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/tableView.d.ts +0 -0
- package/lib/cjs/decorators/tableView.js +19 -0
- package/lib/cjs/decorators/tableView.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/tabs.d.ts +0 -0
- package/lib/cjs/decorators/tabs.js +22 -0
- package/lib/cjs/decorators/tabs.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/textCase.d.ts +0 -0
- package/lib/cjs/decorators/textCase.js +19 -0
- package/lib/cjs/decorators/textCase.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/textarea.d.ts +0 -0
- package/lib/cjs/decorators/textarea.js +20 -0
- package/lib/cjs/decorators/textarea.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/tooltip.d.ts +0 -0
- package/lib/cjs/decorators/tooltip.js +19 -0
- package/lib/cjs/decorators/tooltip.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/validate.d.ts +0 -0
- package/lib/cjs/decorators/validate.js +22 -0
- package/lib/cjs/decorators/validate.js.map +1 -0
- package/lib/{domain → cjs/domain}/FormioDataResolver.d.ts +0 -0
- package/lib/cjs/domain/FormioDataResolver.js +3 -0
- package/lib/cjs/domain/FormioDataResolver.js.map +1 -0
- package/lib/{index.d.ts → cjs/index.d.ts} +0 -0
- package/lib/cjs/index.js +8 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/{registries → cjs/registries}/FormioMappersContainer.d.ts +0 -0
- package/lib/cjs/registries/FormioMappersContainer.js +21 -0
- package/lib/cjs/registries/FormioMappersContainer.js.map +1 -0
- package/lib/{registries → cjs/registries}/FormsContainer.d.ts +0 -0
- package/lib/cjs/registries/FormsContainer.js +6 -0
- package/lib/cjs/registries/FormsContainer.js.map +1 -0
- package/lib/{utils → cjs/utils}/getFormioProps.d.ts +0 -0
- package/lib/cjs/utils/getFormioProps.js +17 -0
- package/lib/cjs/utils/getFormioProps.js.map +1 -0
- package/lib/{utils → cjs/utils}/getFormioSchema.d.ts +0 -0
- package/lib/cjs/utils/getFormioSchema.js +42 -0
- package/lib/cjs/utils/getFormioSchema.js.map +1 -0
- package/lib/{utils → cjs/utils}/getRef.d.ts +0 -0
- package/lib/cjs/utils/getRef.js +12 -0
- package/lib/cjs/utils/getRef.js.map +1 -0
- package/lib/esm/components/anyToComponent.js +25 -0
- package/lib/esm/components/anyToComponent.js.map +1 -0
- package/lib/esm/components/arrayToComponent.js +36 -0
- package/lib/esm/components/arrayToComponent.js.map +1 -0
- package/lib/esm/components/booleanToComponent.js +12 -0
- package/lib/esm/components/booleanToComponent.js.map +1 -0
- package/lib/esm/components/dateToComponent.js +55 -0
- package/lib/esm/components/dateToComponent.js.map +1 -0
- package/lib/esm/components/defaultToComponent.js +14 -0
- package/lib/esm/components/defaultToComponent.js.map +1 -0
- package/lib/esm/components/enumToComponent.js +30 -0
- package/lib/esm/components/enumToComponent.js.map +1 -0
- package/lib/esm/components/index.js +14 -0
- package/lib/esm/components/index.js.map +1 -0
- package/lib/esm/components/mapToComponent.js +16 -0
- package/lib/esm/components/mapToComponent.js.map +1 -0
- package/lib/esm/components/nestedToComponent.js +21 -0
- package/lib/esm/components/nestedToComponent.js.map +1 -0
- package/lib/esm/components/numberToComponent.js +17 -0
- package/lib/esm/components/numberToComponent.js.map +1 -0
- package/lib/esm/components/objectToEditGrid.js +12 -0
- package/lib/esm/components/objectToEditGrid.js.map +1 -0
- package/lib/esm/components/panelToComponent.js +12 -0
- package/lib/esm/components/panelToComponent.js.map +1 -0
- package/lib/esm/components/propertiesToComponents.js +84 -0
- package/lib/esm/components/propertiesToComponents.js.map +1 -0
- package/lib/esm/components/stringToComponent.js +39 -0
- package/lib/esm/components/stringToComponent.js.map +1 -0
- package/lib/esm/decorators/component.js +31 -0
- package/lib/esm/decorators/component.js.map +1 -0
- package/lib/esm/decorators/conditional.js +47 -0
- package/lib/esm/decorators/conditional.js.map +1 -0
- package/lib/esm/decorators/currency.js +20 -0
- package/lib/esm/decorators/currency.js.map +1 -0
- package/lib/esm/decorators/customClass.js +14 -0
- package/lib/esm/decorators/customClass.js.map +1 -0
- package/lib/esm/decorators/customConditional.js +29 -0
- package/lib/esm/decorators/customConditional.js.map +1 -0
- package/lib/esm/decorators/dataSourceJson.js +23 -0
- package/lib/esm/decorators/dataSourceJson.js.map +1 -0
- package/lib/esm/decorators/dataSourceUrl.js +18 -0
- package/lib/esm/decorators/dataSourceUrl.js.map +1 -0
- package/lib/esm/decorators/errorLabel.js +14 -0
- package/lib/esm/decorators/errorLabel.js.map +1 -0
- package/lib/esm/decorators/errorMessage.js +13 -0
- package/lib/esm/decorators/errorMessage.js.map +1 -0
- package/lib/esm/decorators/form.js +17 -0
- package/lib/esm/decorators/form.js.map +1 -0
- package/lib/esm/decorators/hidden.js +18 -0
- package/lib/esm/decorators/hidden.js.map +1 -0
- package/lib/esm/decorators/index.js +31 -0
- package/lib/esm/decorators/index.js.map +1 -0
- package/lib/esm/decorators/inputTags.js +19 -0
- package/lib/esm/decorators/inputTags.js.map +1 -0
- package/lib/esm/decorators/label.js +15 -0
- package/lib/esm/decorators/label.js.map +1 -0
- package/lib/esm/decorators/mask.js +45 -0
- package/lib/esm/decorators/mask.js.map +1 -0
- package/lib/esm/decorators/maxWords.js +13 -0
- package/lib/esm/decorators/maxWords.js.map +1 -0
- package/lib/esm/decorators/minWords.js +13 -0
- package/lib/esm/decorators/minWords.js.map +1 -0
- package/lib/esm/decorators/modalEdit.js +14 -0
- package/lib/esm/decorators/modalEdit.js.map +1 -0
- package/lib/esm/decorators/multiple.js +14 -0
- package/lib/esm/decorators/multiple.js.map +1 -0
- package/lib/esm/decorators/openWhenEmpty.js +14 -0
- package/lib/esm/decorators/openWhenEmpty.js.map +1 -0
- package/lib/esm/decorators/password.js +16 -0
- package/lib/esm/decorators/password.js.map +1 -0
- package/lib/esm/decorators/placeholder.js +15 -0
- package/lib/esm/decorators/placeholder.js.map +1 -0
- package/lib/esm/decorators/prefix.js +14 -0
- package/lib/esm/decorators/prefix.js.map +1 -0
- package/lib/esm/decorators/select.js +18 -0
- package/lib/esm/decorators/select.js.map +1 -0
- package/lib/esm/decorators/suffix.js +14 -0
- package/lib/esm/decorators/suffix.js.map +1 -0
- package/lib/esm/decorators/tableView.js +15 -0
- package/lib/esm/decorators/tableView.js.map +1 -0
- package/lib/esm/decorators/tabs.js +18 -0
- package/lib/esm/decorators/tabs.js.map +1 -0
- package/lib/esm/decorators/textCase.js +15 -0
- package/lib/esm/decorators/textCase.js.map +1 -0
- package/lib/esm/decorators/textarea.js +16 -0
- package/lib/esm/decorators/textarea.js.map +1 -0
- package/lib/esm/decorators/tooltip.js +15 -0
- package/lib/esm/decorators/tooltip.js.map +1 -0
- package/lib/esm/decorators/validate.js +18 -0
- package/lib/esm/decorators/validate.js.map +1 -0
- package/lib/esm/domain/FormioDataResolver.js +2 -0
- package/lib/esm/domain/FormioDataResolver.js.map +1 -0
- package/lib/esm/index.js +5 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/registries/FormioMappersContainer.js +15 -0
- package/lib/esm/registries/FormioMappersContainer.js.map +1 -0
- package/lib/esm/registries/FormsContainer.js +3 -0
- package/lib/esm/registries/FormsContainer.js.map +1 -0
- package/lib/esm/utils/getFormioProps.js +13 -0
- package/lib/esm/utils/getFormioProps.js.map +1 -0
- package/lib/esm/utils/getFormioSchema.js +38 -0
- package/lib/esm/utils/getFormioSchema.js.map +1 -0
- package/lib/esm/utils/getRef.js +8 -0
- package/lib/esm/utils/getRef.js.map +1 -0
- package/lib/types/components/anyToComponent.d.ts +1 -0
- package/lib/types/components/arrayToComponent.d.ts +1 -0
- package/lib/types/components/booleanToComponent.d.ts +1 -0
- package/lib/types/components/dateToComponent.d.ts +1 -0
- package/lib/types/components/defaultToComponent.d.ts +1 -0
- package/lib/types/components/enumToComponent.d.ts +1 -0
- package/lib/types/components/index.d.ts +13 -0
- package/lib/types/components/mapToComponent.d.ts +1 -0
- package/lib/types/components/nestedToComponent.d.ts +1 -0
- package/lib/types/components/numberToComponent.d.ts +1 -0
- package/lib/types/components/objectToEditGrid.d.ts +1 -0
- package/lib/types/components/panelToComponent.d.ts +1 -0
- package/lib/types/components/propertiesToComponents.d.ts +1 -0
- package/lib/types/components/stringToComponent.d.ts +1 -0
- package/lib/types/decorators/component.d.ts +8 -0
- package/lib/types/decorators/conditional.d.ts +33 -0
- package/lib/types/decorators/currency.d.ts +8 -0
- package/lib/types/decorators/customClass.d.ts +8 -0
- package/lib/types/decorators/customConditional.d.ts +59 -0
- package/lib/types/decorators/dataSourceJson.d.ts +8 -0
- package/lib/types/decorators/dataSourceUrl.d.ts +8 -0
- package/lib/types/decorators/errorLabel.d.ts +8 -0
- package/lib/types/decorators/errorMessage.d.ts +9 -0
- package/lib/types/decorators/form.d.ts +6 -0
- package/lib/types/decorators/hidden.d.ts +12 -0
- package/lib/types/decorators/index.d.ts +30 -0
- package/lib/types/decorators/inputTags.d.ts +8 -0
- package/lib/types/decorators/label.d.ts +9 -0
- package/lib/types/decorators/mask.d.ts +37 -0
- package/lib/types/decorators/maxWords.d.ts +9 -0
- package/lib/types/decorators/minWords.d.ts +9 -0
- package/lib/types/decorators/modalEdit.d.ts +8 -0
- package/lib/types/decorators/multiple.d.ts +8 -0
- package/lib/types/decorators/openWhenEmpty.d.ts +8 -0
- package/lib/types/decorators/password.d.ts +12 -0
- package/lib/types/decorators/placeholder.d.ts +9 -0
- package/lib/types/decorators/prefix.d.ts +8 -0
- package/lib/types/decorators/select.d.ts +14 -0
- package/lib/types/decorators/suffix.d.ts +8 -0
- package/lib/types/decorators/tableView.d.ts +9 -0
- package/lib/types/decorators/tabs.d.ts +8 -0
- package/lib/types/decorators/textCase.d.ts +9 -0
- package/lib/types/decorators/textarea.d.ts +12 -0
- package/lib/types/decorators/tooltip.d.ts +9 -0
- package/lib/types/decorators/validate.d.ts +10 -0
- package/lib/types/domain/FormioDataResolver.d.ts +7 -0
- package/lib/types/index.d.ts +4 -0
- package/lib/types/registries/FormioMappersContainer.d.ts +6 -0
- package/lib/types/registries/FormsContainer.d.ts +2 -0
- package/lib/types/utils/getFormioProps.d.ts +1 -0
- package/lib/types/utils/getFormioSchema.d.ts +4 -0
- package/lib/types/utils/getRef.d.ts +1 -0
- package/package.json +20 -16
- package/tsconfig.compile.esm.json +23 -0
- package/lib/index.js +0 -1070
- package/lib/index.js.map +0 -1
- package/lib/index.modern.js +0 -1025
- package/lib/index.modern.js.map +0 -1
package/lib/index.js
DELETED
|
@@ -1,1070 +0,0 @@
|
|
|
1
|
-
var core = require('@tsed/core');
|
|
2
|
-
var changeCase = require('change-case');
|
|
3
|
-
var schema = require('@tsed/schema');
|
|
4
|
-
|
|
5
|
-
const FormioMappersContainer = new Map();
|
|
6
|
-
function registerFormioMapper(type, mapper) {
|
|
7
|
-
return FormioMappersContainer.set(type, mapper);
|
|
8
|
-
}
|
|
9
|
-
function getFormioMapper(type) {
|
|
10
|
-
// istanbul ignore next
|
|
11
|
-
if (!FormioMappersContainer.has(type)) {
|
|
12
|
-
throw new Error(`Formio ${type} mapper doesn't exists`);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return FormioMappersContainer.get(type);
|
|
16
|
-
}
|
|
17
|
-
function execMapper(type, schema, options) {
|
|
18
|
-
return getFormioMapper(type)(schema, options);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function getRef(schema, options) {
|
|
22
|
-
if (schema.$ref) {
|
|
23
|
-
return core.getValue(options, schema.$ref.replace("#/", "").replace(/\//g, "."));
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return schema;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function anyToComponent(schema, options) {
|
|
30
|
-
schema = getRef(schema, options);
|
|
31
|
-
|
|
32
|
-
switch (schema.type) {
|
|
33
|
-
case "object":
|
|
34
|
-
if (!schema.properties && !schema.$ref) {
|
|
35
|
-
return execMapper("map", schema, options);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return execMapper("nested", schema, options);
|
|
39
|
-
|
|
40
|
-
case "array":
|
|
41
|
-
return execMapper("array", schema, options);
|
|
42
|
-
|
|
43
|
-
case "string":
|
|
44
|
-
return execMapper("string", schema, options);
|
|
45
|
-
|
|
46
|
-
case "boolean":
|
|
47
|
-
return execMapper("boolean", schema, options);
|
|
48
|
-
|
|
49
|
-
case "integer":
|
|
50
|
-
case "number":
|
|
51
|
-
return execMapper("number", schema, options);
|
|
52
|
-
// default:
|
|
53
|
-
// return execMapper("default", schema, options);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
registerFormioMapper("any", anyToComponent);
|
|
57
|
-
|
|
58
|
-
function _extends() {
|
|
59
|
-
_extends = Object.assign || function (target) {
|
|
60
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
61
|
-
var source = arguments[i];
|
|
62
|
-
|
|
63
|
-
for (var key in source) {
|
|
64
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
65
|
-
target[key] = source[key];
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return target;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
return _extends.apply(this, arguments);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function arrayToComponent(schema, options) {
|
|
77
|
-
const itemSchema = schema.items.$ref ? getRef(schema.items, options) : schema.items;
|
|
78
|
-
const {
|
|
79
|
-
type
|
|
80
|
-
} = itemSchema;
|
|
81
|
-
|
|
82
|
-
switch (type) {
|
|
83
|
-
case "object":
|
|
84
|
-
// editgrid
|
|
85
|
-
return _extends({}, execMapper("default", schema, options), execMapper("editgrid", itemSchema, options));
|
|
86
|
-
|
|
87
|
-
case "string":
|
|
88
|
-
// tag or enum?
|
|
89
|
-
if (itemSchema.enum) {
|
|
90
|
-
const component = execMapper("enum", itemSchema, options);
|
|
91
|
-
return _extends({}, component, {
|
|
92
|
-
inline: false,
|
|
93
|
-
type: "selectboxes"
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const component = execMapper(type, itemSchema, options);
|
|
98
|
-
return core.cleanObject(_extends({}, component, {
|
|
99
|
-
multiple: component.type === "tags" ? undefined : true
|
|
100
|
-
}));
|
|
101
|
-
|
|
102
|
-
default:
|
|
103
|
-
case "number":
|
|
104
|
-
return _extends({}, execMapper(type, itemSchema, options), {
|
|
105
|
-
multiple: true
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
registerFormioMapper("array", arrayToComponent);
|
|
110
|
-
|
|
111
|
-
function booleanToComponent(schema, options) {
|
|
112
|
-
const component = execMapper("default", schema, options);
|
|
113
|
-
return core.cleanObject(_extends({}, component, {
|
|
114
|
-
input: true,
|
|
115
|
-
type: component.type || "checkbox"
|
|
116
|
-
}));
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
registerFormioMapper("boolean", booleanToComponent);
|
|
120
|
-
|
|
121
|
-
function dateToComponent(schema, options) {
|
|
122
|
-
const component = execMapper("default", schema, options);
|
|
123
|
-
|
|
124
|
-
const base = _extends({}, component, {
|
|
125
|
-
enableMinDateInput: false,
|
|
126
|
-
datePicker: {
|
|
127
|
-
disableWeekends: false,
|
|
128
|
-
disableWeekdays: false
|
|
129
|
-
},
|
|
130
|
-
enableMaxDateInput: false,
|
|
131
|
-
enableTime: false,
|
|
132
|
-
type: "datetime",
|
|
133
|
-
input: true,
|
|
134
|
-
widget: {
|
|
135
|
-
type: "calendar",
|
|
136
|
-
displayInTimezone: "viewer",
|
|
137
|
-
locale: "en",
|
|
138
|
-
useLocaleSettings: false,
|
|
139
|
-
allowInput: true,
|
|
140
|
-
mode: "single",
|
|
141
|
-
noCalendar: false,
|
|
142
|
-
hourIncrement: 1,
|
|
143
|
-
minuteIncrement: 1,
|
|
144
|
-
minDate: null,
|
|
145
|
-
disableWeekends: false,
|
|
146
|
-
disableWeekdays: false,
|
|
147
|
-
maxDate: null
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
if (schema.format === "date") {
|
|
152
|
-
return _extends({}, base, {
|
|
153
|
-
format: "yyyy-MM-dd",
|
|
154
|
-
enableTime: false,
|
|
155
|
-
widget: _extends({}, base.widget, {
|
|
156
|
-
enableTime: false,
|
|
157
|
-
format: "yyyy-MM-dd"
|
|
158
|
-
})
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
return _extends({}, base, {
|
|
163
|
-
timePicker: {
|
|
164
|
-
showMeridian: false
|
|
165
|
-
},
|
|
166
|
-
widget: {
|
|
167
|
-
enableTime: true,
|
|
168
|
-
time_24hr: true
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
registerFormioMapper("date", dateToComponent);
|
|
174
|
-
|
|
175
|
-
function getFormioProps(schema) {
|
|
176
|
-
const formioProps = Object.entries(schema).reduce((props, [key, value]) => {
|
|
177
|
-
if (key.startsWith("x-formio-")) {
|
|
178
|
-
return _extends({}, props, {
|
|
179
|
-
[key.replace("x-formio-", "")]: value
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
return props;
|
|
184
|
-
}, {});
|
|
185
|
-
return formioProps;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
function defaultToComponent(schema, options) {
|
|
189
|
-
const formioProps = getFormioProps(schema);
|
|
190
|
-
return core.cleanObject(_extends({}, formioProps, {
|
|
191
|
-
disabled: !!schema.readOnly,
|
|
192
|
-
description: schema.description,
|
|
193
|
-
defaultValue: schema.default
|
|
194
|
-
}));
|
|
195
|
-
}
|
|
196
|
-
registerFormioMapper("default", defaultToComponent);
|
|
197
|
-
|
|
198
|
-
function enumToComponent(schema, options) {
|
|
199
|
-
const component = execMapper("default", schema, options);
|
|
200
|
-
const values = schema.enum.map(value => {
|
|
201
|
-
return {
|
|
202
|
-
label: changeCase.sentenceCase(value),
|
|
203
|
-
value
|
|
204
|
-
};
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
if (component.type === "select") {
|
|
208
|
-
return core.cleanObject(_extends({}, component, {
|
|
209
|
-
data: {
|
|
210
|
-
json: JSON.stringify(values)
|
|
211
|
-
},
|
|
212
|
-
dataSrc: "json",
|
|
213
|
-
idPath: "value",
|
|
214
|
-
valueProperty: "value",
|
|
215
|
-
template: "<span>{{ item.label }}</span>"
|
|
216
|
-
}));
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
return core.cleanObject(_extends({}, component, {
|
|
220
|
-
values: schema["x-values"] || values.map(value => _extends({}, value, {
|
|
221
|
-
shortcut: ""
|
|
222
|
-
}))
|
|
223
|
-
}));
|
|
224
|
-
}
|
|
225
|
-
registerFormioMapper("enum", enumToComponent);
|
|
226
|
-
|
|
227
|
-
function mapToComponent(schema, options) {
|
|
228
|
-
return _extends({}, execMapper("default", schema, options), {
|
|
229
|
-
type: "datamap",
|
|
230
|
-
tableView: false,
|
|
231
|
-
input: true,
|
|
232
|
-
valueComponent: _extends({}, schema.additionalProperties ? execMapper("any", schema.additionalProperties, options) : {}, {
|
|
233
|
-
hideLabel: true,
|
|
234
|
-
tableView: true
|
|
235
|
-
})
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
registerFormioMapper("map", mapToComponent);
|
|
239
|
-
|
|
240
|
-
function nestedToComponent(schema, options) {
|
|
241
|
-
return _extends({}, execMapper("default", schema, options), {
|
|
242
|
-
label: false,
|
|
243
|
-
tableView: false,
|
|
244
|
-
type: "form",
|
|
245
|
-
display: "form",
|
|
246
|
-
input: true,
|
|
247
|
-
components: [_extends({
|
|
248
|
-
key: "panel",
|
|
249
|
-
label: options.parentKey && changeCase.sentenceCase(options.parentKey)
|
|
250
|
-
}, execMapper("panel", schema, options))]
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
registerFormioMapper("nested", nestedToComponent);
|
|
254
|
-
|
|
255
|
-
function numberToComponent(schema, options) {
|
|
256
|
-
const component = execMapper("default", schema, options);
|
|
257
|
-
return core.cleanObject(_extends({}, component, {
|
|
258
|
-
input: true,
|
|
259
|
-
delimiter: core.getValue(component, "delimiter", false),
|
|
260
|
-
inputFormat: core.getValue(component, "inputFormat", "plain"),
|
|
261
|
-
mask: core.getValue(component, "mask", false),
|
|
262
|
-
requireDecimal: false,
|
|
263
|
-
type: "number"
|
|
264
|
-
}));
|
|
265
|
-
}
|
|
266
|
-
registerFormioMapper("number", numberToComponent);
|
|
267
|
-
registerFormioMapper("integer", numberToComponent);
|
|
268
|
-
|
|
269
|
-
function objectToEditGrid(schema, options) {
|
|
270
|
-
return _extends({}, execMapper("default", schema, options), {
|
|
271
|
-
rowDrafts: false,
|
|
272
|
-
type: "editgrid",
|
|
273
|
-
input: true,
|
|
274
|
-
components: execMapper("properties", schema, options)
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
registerFormioMapper("editgrid", objectToEditGrid);
|
|
278
|
-
|
|
279
|
-
function panelToComponent(schema, options) {
|
|
280
|
-
return _extends({}, execMapper("default", schema, options), {
|
|
281
|
-
collapsible: false,
|
|
282
|
-
input: false,
|
|
283
|
-
tableView: false,
|
|
284
|
-
components: execMapper("properties", schema, options)
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
registerFormioMapper("panel", panelToComponent);
|
|
288
|
-
|
|
289
|
-
function bindResolvers(component, options) {
|
|
290
|
-
if (component.data) {
|
|
291
|
-
const data = component.data;
|
|
292
|
-
Object.entries(data).forEach(([key, resolver]) => {
|
|
293
|
-
if (core.isFunction(resolver)) {
|
|
294
|
-
options.resolvers.push(async form => {
|
|
295
|
-
data[key] = await resolver(_extends({}, options, {
|
|
296
|
-
component,
|
|
297
|
-
form
|
|
298
|
-
}));
|
|
299
|
-
});
|
|
300
|
-
}
|
|
301
|
-
});
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
function mapValidation(key, base, schema, propSchema) {
|
|
306
|
-
const required = (schema.required || []).includes(key);
|
|
307
|
-
|
|
308
|
-
const validate = _extends({}, base.validate || {}, {
|
|
309
|
-
required,
|
|
310
|
-
pattern: propSchema.pattern,
|
|
311
|
-
minLength: !required || required && propSchema.minLength > 1 ? propSchema.minLength : undefined,
|
|
312
|
-
maxLength: propSchema.maxLength,
|
|
313
|
-
min: propSchema.minimum,
|
|
314
|
-
max: propSchema.maximum
|
|
315
|
-
});
|
|
316
|
-
|
|
317
|
-
switch (propSchema.type) {
|
|
318
|
-
case "string":
|
|
319
|
-
if (propSchema.minLength === 0 && validate.required) {
|
|
320
|
-
validate.minLength = undefined;
|
|
321
|
-
validate.required = false;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
break;
|
|
325
|
-
|
|
326
|
-
case "boolean":
|
|
327
|
-
validate.required = false;
|
|
328
|
-
break;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
return core.cleanObject(validate);
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
function propertiesToComponents(schema, options) {
|
|
335
|
-
const tabs = {
|
|
336
|
-
label: "Tabs",
|
|
337
|
-
key: "tabs",
|
|
338
|
-
type: "tabs",
|
|
339
|
-
input: false,
|
|
340
|
-
tableView: false,
|
|
341
|
-
components: new Map(),
|
|
342
|
-
pushed: false
|
|
343
|
-
};
|
|
344
|
-
const components = [];
|
|
345
|
-
Object.entries(schema.properties).forEach(([key, propSchema]) => {
|
|
346
|
-
const tabsOptions = propSchema["x-formiotabs"];
|
|
347
|
-
const base = execMapper("any", propSchema, _extends({
|
|
348
|
-
parentKey: key
|
|
349
|
-
}, options));
|
|
350
|
-
const component = core.cleanObject(_extends({
|
|
351
|
-
key
|
|
352
|
-
}, base, {
|
|
353
|
-
label: base.label == false ? undefined : base.label || propSchema.title || changeCase.sentenceCase(key),
|
|
354
|
-
validate: mapValidation(key, base, schema, propSchema)
|
|
355
|
-
}));
|
|
356
|
-
bindResolvers(component, options);
|
|
357
|
-
|
|
358
|
-
if (tabsOptions) {
|
|
359
|
-
if (!tabs.pushed) {
|
|
360
|
-
components.push(tabs);
|
|
361
|
-
tabs.pushed = true;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
if (!tabs.components.has(tabsOptions.key)) {
|
|
365
|
-
tabs.components.set(tabsOptions.key, _extends({}, tabsOptions, {
|
|
366
|
-
components: []
|
|
367
|
-
}));
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
tabs.components.get(tabsOptions.key).components.push(component);
|
|
371
|
-
} else {
|
|
372
|
-
components.push(component);
|
|
373
|
-
}
|
|
374
|
-
});
|
|
375
|
-
|
|
376
|
-
if (tabs.components.size) {
|
|
377
|
-
tabs.components = [...tabs.components.values()];
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
return components;
|
|
381
|
-
}
|
|
382
|
-
registerFormioMapper("properties", propertiesToComponents);
|
|
383
|
-
|
|
384
|
-
function stringToComponent(schema, options) {
|
|
385
|
-
if (schema.format) {
|
|
386
|
-
const component = execMapper("default", schema, options);
|
|
387
|
-
|
|
388
|
-
switch (schema.format) {
|
|
389
|
-
case "date":
|
|
390
|
-
case "date-time":
|
|
391
|
-
return execMapper("date", schema, options);
|
|
392
|
-
|
|
393
|
-
case "uri":
|
|
394
|
-
return core.cleanObject(_extends({
|
|
395
|
-
input: true
|
|
396
|
-
}, component, {
|
|
397
|
-
type: component.type || "url"
|
|
398
|
-
}));
|
|
399
|
-
|
|
400
|
-
default:
|
|
401
|
-
return core.cleanObject(_extends({
|
|
402
|
-
input: true
|
|
403
|
-
}, component, {
|
|
404
|
-
type: component.type || schema.format
|
|
405
|
-
}));
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
if (schema.enum) {
|
|
410
|
-
const component = execMapper("enum", schema, options);
|
|
411
|
-
return _extends({}, component, {
|
|
412
|
-
type: component.type || "radio"
|
|
413
|
-
});
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
const component = execMapper("default", schema, options);
|
|
417
|
-
return core.cleanObject(_extends({
|
|
418
|
-
input: true,
|
|
419
|
-
type: component.type || "textfield"
|
|
420
|
-
}, component));
|
|
421
|
-
}
|
|
422
|
-
registerFormioMapper("string", stringToComponent);
|
|
423
|
-
|
|
424
|
-
/**
|
|
425
|
-
* Declare a formio Component schema on the decorated propertyKey.
|
|
426
|
-
* @decorator
|
|
427
|
-
* @formio
|
|
428
|
-
* @property
|
|
429
|
-
* @schema
|
|
430
|
-
*/
|
|
431
|
-
|
|
432
|
-
function Component(component) {
|
|
433
|
-
component = Object.entries(component).reduce((component, [key, value]) => {
|
|
434
|
-
if (key === "validate") {
|
|
435
|
-
component["x-formio-validate"] = _extends({}, component["x-formio-validate"] || {}, value);
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
return _extends({}, component, {
|
|
439
|
-
[`x-formio-${key}`]: value
|
|
440
|
-
});
|
|
441
|
-
}, {});
|
|
442
|
-
return schema.JsonEntityFn(store => {
|
|
443
|
-
Object.entries(component).forEach(([key, value]) => {
|
|
444
|
-
store.itemSchema.customKey(key, value);
|
|
445
|
-
|
|
446
|
-
if (store.isCollection) {
|
|
447
|
-
store.schema.customKey(key, value);
|
|
448
|
-
}
|
|
449
|
-
});
|
|
450
|
-
});
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
/**
|
|
454
|
-
* Configure the property as Currency component.
|
|
455
|
-
* @decorator
|
|
456
|
-
* @formio
|
|
457
|
-
* @property
|
|
458
|
-
* @schema
|
|
459
|
-
*/
|
|
460
|
-
|
|
461
|
-
function Currency(props = {}) {
|
|
462
|
-
return Component(_extends({
|
|
463
|
-
currency: "USD",
|
|
464
|
-
inputFormat: "plain",
|
|
465
|
-
mask: false,
|
|
466
|
-
spellcheck: true,
|
|
467
|
-
delimiter: true
|
|
468
|
-
}, props, {
|
|
469
|
-
type: "currency"
|
|
470
|
-
}));
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
const wrap = resolver => async opts => {
|
|
474
|
-
const result = await resolver(opts);
|
|
475
|
-
return JSON.stringify(result);
|
|
476
|
-
};
|
|
477
|
-
/**
|
|
478
|
-
* Set custom json data source
|
|
479
|
-
* @param data
|
|
480
|
-
* @param props
|
|
481
|
-
* @constructor
|
|
482
|
-
*/
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
function DataSourceJson(data, props = {}) {
|
|
486
|
-
return Component(_extends({}, props, {
|
|
487
|
-
dataSrc: "json",
|
|
488
|
-
data: _extends({}, props.data, {
|
|
489
|
-
json: core.isFunction(data) ? wrap(data) : JSON.stringify(data)
|
|
490
|
-
})
|
|
491
|
-
}));
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
/**
|
|
495
|
-
* Set URL data on the current component.
|
|
496
|
-
* @param url
|
|
497
|
-
* @param props
|
|
498
|
-
* @constructor
|
|
499
|
-
*/
|
|
500
|
-
|
|
501
|
-
function DataSourceUrl(url, props = {}) {
|
|
502
|
-
return Component(_extends({}, props, {
|
|
503
|
-
dataSrc: "url",
|
|
504
|
-
data: _extends({}, props.data, {
|
|
505
|
-
url
|
|
506
|
-
})
|
|
507
|
-
}));
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
/**
|
|
511
|
-
* Set hidden field.
|
|
512
|
-
*
|
|
513
|
-
* A hidden field is still a part of the form, but is hidden from view.
|
|
514
|
-
*
|
|
515
|
-
* @param bool
|
|
516
|
-
* @decorator
|
|
517
|
-
* @formio
|
|
518
|
-
* @property
|
|
519
|
-
* @schema
|
|
520
|
-
*/
|
|
521
|
-
|
|
522
|
-
function Hidden(bool = true) {
|
|
523
|
-
return Component({
|
|
524
|
-
hidden: bool
|
|
525
|
-
});
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
/**
|
|
529
|
-
* Configure the property as Tags component.
|
|
530
|
-
* @decorator
|
|
531
|
-
* @formio
|
|
532
|
-
* @property
|
|
533
|
-
* @schema
|
|
534
|
-
*/
|
|
535
|
-
|
|
536
|
-
function InputTags(props = {}) {
|
|
537
|
-
return core.useDecorators(schema.CollectionOf(String), Component(_extends({}, props, {
|
|
538
|
-
tableView: false,
|
|
539
|
-
storeas: "array",
|
|
540
|
-
type: "tags"
|
|
541
|
-
})));
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
/**
|
|
545
|
-
* Change the multiple value on the decorated property.
|
|
546
|
-
* @decorator
|
|
547
|
-
* @formio
|
|
548
|
-
* @property
|
|
549
|
-
* @schema
|
|
550
|
-
*/
|
|
551
|
-
|
|
552
|
-
function Multiple(multiple = false) {
|
|
553
|
-
return Component({
|
|
554
|
-
multiple
|
|
555
|
-
});
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
/**
|
|
559
|
-
* Configure the property as Password component.
|
|
560
|
-
* @decorator
|
|
561
|
-
* @formio
|
|
562
|
-
* @property
|
|
563
|
-
* @schema
|
|
564
|
-
*/
|
|
565
|
-
|
|
566
|
-
function Password(props = {}) {
|
|
567
|
-
return Component(_extends({}, props, {
|
|
568
|
-
type: "password",
|
|
569
|
-
protected: true
|
|
570
|
-
}));
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
/**
|
|
574
|
-
* Configure the property as Select component.
|
|
575
|
-
* @decorator
|
|
576
|
-
* @formio
|
|
577
|
-
* @property
|
|
578
|
-
* @schema
|
|
579
|
-
*/
|
|
580
|
-
|
|
581
|
-
function Select(props = {}) {
|
|
582
|
-
return Component(_extends({
|
|
583
|
-
selectThreshold: 0.3,
|
|
584
|
-
input: true,
|
|
585
|
-
widget: "choicesjs"
|
|
586
|
-
}, props, {
|
|
587
|
-
type: "select"
|
|
588
|
-
}));
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
/**
|
|
592
|
-
* Change the visibility of the current property on a table.
|
|
593
|
-
* @param bool
|
|
594
|
-
* @decorator
|
|
595
|
-
* @formio
|
|
596
|
-
* @property
|
|
597
|
-
* @schema
|
|
598
|
-
*/
|
|
599
|
-
|
|
600
|
-
function TableView(bool) {
|
|
601
|
-
return Component({
|
|
602
|
-
tableView: bool
|
|
603
|
-
});
|
|
604
|
-
}
|
|
605
|
-
|
|
606
|
-
/**
|
|
607
|
-
* Configure the property as Textarea component.
|
|
608
|
-
* @decorator
|
|
609
|
-
* @formio
|
|
610
|
-
* @property
|
|
611
|
-
* @schema
|
|
612
|
-
*/
|
|
613
|
-
|
|
614
|
-
function Textarea(props = {}) {
|
|
615
|
-
return Component(_extends({
|
|
616
|
-
autoExpand: false
|
|
617
|
-
}, props, {
|
|
618
|
-
type: "textarea"
|
|
619
|
-
}));
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
/**
|
|
623
|
-
* Add validation rules.
|
|
624
|
-
* @decorator
|
|
625
|
-
* @formio
|
|
626
|
-
* @property
|
|
627
|
-
* @schema
|
|
628
|
-
* @param key
|
|
629
|
-
* @param value
|
|
630
|
-
*/
|
|
631
|
-
|
|
632
|
-
function Validate(key, value) {
|
|
633
|
-
return Component({
|
|
634
|
-
validate: {
|
|
635
|
-
[key]: value
|
|
636
|
-
}
|
|
637
|
-
});
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
/**
|
|
641
|
-
* Add error message when an error occur.
|
|
642
|
-
* @decorator
|
|
643
|
-
* @formio
|
|
644
|
-
* @property
|
|
645
|
-
* @schema
|
|
646
|
-
* @param message
|
|
647
|
-
*/
|
|
648
|
-
|
|
649
|
-
function ErrorMessage(message) {
|
|
650
|
-
return Validate("customMessage", message);
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
/**
|
|
654
|
-
* Set the error label when an error occur.
|
|
655
|
-
* @decorator
|
|
656
|
-
* @formio
|
|
657
|
-
* @property
|
|
658
|
-
* @schema
|
|
659
|
-
*/
|
|
660
|
-
|
|
661
|
-
function ErrorLabel(message) {
|
|
662
|
-
return Component({
|
|
663
|
-
errorLabel: message
|
|
664
|
-
});
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
/**
|
|
668
|
-
* Add the maximum amount of words that can be added to this field.
|
|
669
|
-
* @decorator
|
|
670
|
-
* @formio
|
|
671
|
-
* @property
|
|
672
|
-
* @schema
|
|
673
|
-
* @param value
|
|
674
|
-
*/
|
|
675
|
-
|
|
676
|
-
function MinWords(value) {
|
|
677
|
-
return Validate("minWords", value);
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
/**
|
|
681
|
-
* Add the minimum amount of words that can be added to this field.
|
|
682
|
-
* @decorator
|
|
683
|
-
* @formio
|
|
684
|
-
* @property
|
|
685
|
-
* @schema
|
|
686
|
-
* @param value
|
|
687
|
-
*/
|
|
688
|
-
|
|
689
|
-
function MaxWords(value) {
|
|
690
|
-
return Validate("maxWords", value);
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
// tslint:disable-next-line:variable-name
|
|
694
|
-
const FormsContainer = new Map();
|
|
695
|
-
|
|
696
|
-
/**
|
|
697
|
-
* Expose the model as Formio Form.
|
|
698
|
-
* @param form
|
|
699
|
-
*/
|
|
700
|
-
|
|
701
|
-
function Form(form = {}) {
|
|
702
|
-
return core.useDecorators(target => {
|
|
703
|
-
const name = form.name || core.nameOf(target);
|
|
704
|
-
const machineName = changeCase.paramCase(name);
|
|
705
|
-
FormsContainer.set(name, target);
|
|
706
|
-
FormsContainer.set(machineName, target);
|
|
707
|
-
}, form.name && schema.Name(form.name), form && core.StoreSet("formio:form", form));
|
|
708
|
-
}
|
|
709
|
-
|
|
710
|
-
/**
|
|
711
|
-
* Group the current property in tabs components.
|
|
712
|
-
* @decorator
|
|
713
|
-
* @formio
|
|
714
|
-
* @property
|
|
715
|
-
* @schema
|
|
716
|
-
*/
|
|
717
|
-
|
|
718
|
-
function Tabs(label) {
|
|
719
|
-
return schema.JsonEntityFn(store => {
|
|
720
|
-
store.schema.customKey("x-formiotabs", {
|
|
721
|
-
key: changeCase.camelCase(label),
|
|
722
|
-
label
|
|
723
|
-
});
|
|
724
|
-
});
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
/**
|
|
728
|
-
* The placeholder text that will appear when this field is empty.
|
|
729
|
-
* @decorator
|
|
730
|
-
* @formio
|
|
731
|
-
* @property
|
|
732
|
-
* @schema
|
|
733
|
-
* @param placeholder
|
|
734
|
-
*/
|
|
735
|
-
|
|
736
|
-
function Placeholder(placeholder) {
|
|
737
|
-
return Component({
|
|
738
|
-
placeholder
|
|
739
|
-
});
|
|
740
|
-
}
|
|
741
|
-
|
|
742
|
-
/**
|
|
743
|
-
* Adds a tooltip to the side of this field.
|
|
744
|
-
* @decorator
|
|
745
|
-
* @formio
|
|
746
|
-
* @property
|
|
747
|
-
* @schema
|
|
748
|
-
* @param tooltip
|
|
749
|
-
*/
|
|
750
|
-
|
|
751
|
-
function Tooltip(tooltip) {
|
|
752
|
-
return Component({
|
|
753
|
-
tooltip
|
|
754
|
-
});
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
/**
|
|
758
|
-
* Change the label field
|
|
759
|
-
* @decorator
|
|
760
|
-
* @formio
|
|
761
|
-
* @property
|
|
762
|
-
* @schema
|
|
763
|
-
* @param label
|
|
764
|
-
*/
|
|
765
|
-
|
|
766
|
-
function Label(label) {
|
|
767
|
-
return Component({
|
|
768
|
-
label
|
|
769
|
-
});
|
|
770
|
-
}
|
|
771
|
-
|
|
772
|
-
/**
|
|
773
|
-
* Add a custom css class.
|
|
774
|
-
* @decorator
|
|
775
|
-
* @formio
|
|
776
|
-
* @property
|
|
777
|
-
* @schema
|
|
778
|
-
*/
|
|
779
|
-
|
|
780
|
-
function CustomClass(customClass) {
|
|
781
|
-
return Component({
|
|
782
|
-
customClass
|
|
783
|
-
});
|
|
784
|
-
}
|
|
785
|
-
|
|
786
|
-
/**
|
|
787
|
-
* Opens up a modal to edit the value of this component.
|
|
788
|
-
* @decorator
|
|
789
|
-
* @formio
|
|
790
|
-
* @property
|
|
791
|
-
* @schema
|
|
792
|
-
*/
|
|
793
|
-
|
|
794
|
-
function ModalEdit(modalEdit = true) {
|
|
795
|
-
return Component({
|
|
796
|
-
modalEdit
|
|
797
|
-
});
|
|
798
|
-
}
|
|
799
|
-
|
|
800
|
-
/**
|
|
801
|
-
* An input mask helps the user with input by ensuring a predefined format.
|
|
802
|
-
*
|
|
803
|
-
* - 9: numeric
|
|
804
|
-
* - a: alphabetical
|
|
805
|
-
* - *: alphanumeric
|
|
806
|
-
*
|
|
807
|
-
* Example telephone mask: (999) 999-9999
|
|
808
|
-
*
|
|
809
|
-
* See the [jquery.inputmask](https://github.com/RobinHerbots/Inputmask) documentation for more information.
|
|
810
|
-
*
|
|
811
|
-
* @decorator
|
|
812
|
-
* @formio
|
|
813
|
-
* @property
|
|
814
|
-
* @schema
|
|
815
|
-
*/
|
|
816
|
-
|
|
817
|
-
function Mask(inputMask, inputMaskPlaceholderChar = "") {
|
|
818
|
-
return Component({
|
|
819
|
-
inputMask,
|
|
820
|
-
inputMaskPlaceholderChar
|
|
821
|
-
});
|
|
822
|
-
}
|
|
823
|
-
/**
|
|
824
|
-
* An input mask helps the user with input by ensuring a predefined format.
|
|
825
|
-
*
|
|
826
|
-
* - 9: numeric
|
|
827
|
-
* - a: alphabetical
|
|
828
|
-
* - *: alphanumeric
|
|
829
|
-
*
|
|
830
|
-
* Example telephone mask: (999) 999-9999
|
|
831
|
-
*
|
|
832
|
-
* See the [jquery.inputmask](https://github.com/RobinHerbots/Inputmask) documentation for more information.
|
|
833
|
-
*
|
|
834
|
-
* @decorator
|
|
835
|
-
* @formio
|
|
836
|
-
* @property
|
|
837
|
-
* @schema
|
|
838
|
-
*/
|
|
839
|
-
|
|
840
|
-
function Masks(...inputMasks) {
|
|
841
|
-
return Component({
|
|
842
|
-
inputMasks
|
|
843
|
-
});
|
|
844
|
-
}
|
|
845
|
-
|
|
846
|
-
/**
|
|
847
|
-
* Add prefix word on the decorated field.
|
|
848
|
-
* @decorator
|
|
849
|
-
* @formio
|
|
850
|
-
* @property
|
|
851
|
-
* @schema
|
|
852
|
-
*/
|
|
853
|
-
|
|
854
|
-
function Prefix(prefix) {
|
|
855
|
-
return Component({
|
|
856
|
-
prefix
|
|
857
|
-
});
|
|
858
|
-
}
|
|
859
|
-
|
|
860
|
-
/**
|
|
861
|
-
* Add suffix word on the decorated field.
|
|
862
|
-
* @decorator
|
|
863
|
-
* @formio
|
|
864
|
-
* @property
|
|
865
|
-
* @schema
|
|
866
|
-
*/
|
|
867
|
-
|
|
868
|
-
function Suffix(suffix) {
|
|
869
|
-
return Component({
|
|
870
|
-
suffix
|
|
871
|
-
});
|
|
872
|
-
}
|
|
873
|
-
|
|
874
|
-
/**
|
|
875
|
-
* Force the output of this field to be sanitized in a specific format.
|
|
876
|
-
* @decorator
|
|
877
|
-
* @formio
|
|
878
|
-
* @property
|
|
879
|
-
* @schema
|
|
880
|
-
* @param textCase
|
|
881
|
-
*/
|
|
882
|
-
|
|
883
|
-
function TextCase(textCase) {
|
|
884
|
-
return Component({
|
|
885
|
-
case: textCase
|
|
886
|
-
});
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
/**
|
|
890
|
-
* Adds a conditional display rule on the input form.
|
|
891
|
-
* @decorator
|
|
892
|
-
* @formio
|
|
893
|
-
* @property
|
|
894
|
-
* @schema
|
|
895
|
-
* @param conditional
|
|
896
|
-
*/
|
|
897
|
-
|
|
898
|
-
function Conditional(conditional) {
|
|
899
|
-
return Component({
|
|
900
|
-
conditional
|
|
901
|
-
});
|
|
902
|
-
}
|
|
903
|
-
/**
|
|
904
|
-
* Adds a conditional display rule on the input form.
|
|
905
|
-
* @decorator
|
|
906
|
-
* @formio
|
|
907
|
-
* @property
|
|
908
|
-
* @schema
|
|
909
|
-
* @param property
|
|
910
|
-
* @param eq
|
|
911
|
-
*/
|
|
912
|
-
|
|
913
|
-
function ShowWhen(property, eq) {
|
|
914
|
-
return Conditional({
|
|
915
|
-
show: true,
|
|
916
|
-
when: property,
|
|
917
|
-
eq
|
|
918
|
-
});
|
|
919
|
-
}
|
|
920
|
-
/**
|
|
921
|
-
* Adds a conditional display rule on the input form.
|
|
922
|
-
* @decorator
|
|
923
|
-
* @formio
|
|
924
|
-
* @property
|
|
925
|
-
* @schema
|
|
926
|
-
* @param property
|
|
927
|
-
* @param eq
|
|
928
|
-
*/
|
|
929
|
-
|
|
930
|
-
function HideWhen(property, eq) {
|
|
931
|
-
return Conditional({
|
|
932
|
-
show: false,
|
|
933
|
-
when: property,
|
|
934
|
-
eq
|
|
935
|
-
});
|
|
936
|
-
}
|
|
937
|
-
|
|
938
|
-
function sanitize(customConditional) {
|
|
939
|
-
const str = customConditional.toString();
|
|
940
|
-
const [signature, ...fn] = str.split("=>");
|
|
941
|
-
let content = fn.join("=>");
|
|
942
|
-
|
|
943
|
-
if (!signature.includes("{")) {
|
|
944
|
-
const reg = `${signature.trim()}\.`;
|
|
945
|
-
content = content.replace(new RegExp(reg, "gi"), "");
|
|
946
|
-
}
|
|
947
|
-
|
|
948
|
-
return `show = ${content.trim()}`;
|
|
949
|
-
}
|
|
950
|
-
/**
|
|
951
|
-
* Adds custom conditional rule to display or not the input form.
|
|
952
|
-
* @decorator
|
|
953
|
-
* @formio
|
|
954
|
-
* @property
|
|
955
|
-
* @schema
|
|
956
|
-
* @param customConditional
|
|
957
|
-
*/
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
function CustomConditional(customConditional) {
|
|
961
|
-
if (core.isArrowFn(customConditional)) {
|
|
962
|
-
customConditional = sanitize(customConditional);
|
|
963
|
-
}
|
|
964
|
-
|
|
965
|
-
return Component({
|
|
966
|
-
customConditional
|
|
967
|
-
});
|
|
968
|
-
}
|
|
969
|
-
|
|
970
|
-
/**
|
|
971
|
-
* Open automatically the editgrid when the list is empty.
|
|
972
|
-
* @decorator
|
|
973
|
-
* @formio
|
|
974
|
-
* @property
|
|
975
|
-
* @schema
|
|
976
|
-
*/
|
|
977
|
-
|
|
978
|
-
function OpenWhenEmpty(openWhenEmpty = true) {
|
|
979
|
-
return Component({
|
|
980
|
-
openWhenEmpty
|
|
981
|
-
});
|
|
982
|
-
}
|
|
983
|
-
|
|
984
|
-
async function getFormioSchema(model, options = {}) {
|
|
985
|
-
if (!model) {
|
|
986
|
-
return undefined;
|
|
987
|
-
}
|
|
988
|
-
|
|
989
|
-
if (core.isString(model)) {
|
|
990
|
-
return getFormioSchema(FormsContainer.get(model), options);
|
|
991
|
-
}
|
|
992
|
-
|
|
993
|
-
const entity = schema.JsonEntityStore.from(model);
|
|
994
|
-
const schema$1 = schema.getJsonSchema(entity, _extends({}, options, {
|
|
995
|
-
customKeys: true
|
|
996
|
-
}));
|
|
997
|
-
const name = entity.schema.getName();
|
|
998
|
-
const machineName = changeCase.paramCase(name);
|
|
999
|
-
const resolvers = [];
|
|
1000
|
-
const components = execMapper("properties", schema$1, _extends({}, options, {
|
|
1001
|
-
definitions: schema$1.definitions,
|
|
1002
|
-
resolvers
|
|
1003
|
-
}));
|
|
1004
|
-
|
|
1005
|
-
const form = _extends({
|
|
1006
|
-
title: name,
|
|
1007
|
-
type: "form",
|
|
1008
|
-
display: "form",
|
|
1009
|
-
tags: [],
|
|
1010
|
-
access: [],
|
|
1011
|
-
submissionAccess: []
|
|
1012
|
-
}, entity.store.get("formio:form", {}), {
|
|
1013
|
-
name: machineName,
|
|
1014
|
-
machineName,
|
|
1015
|
-
components
|
|
1016
|
-
});
|
|
1017
|
-
|
|
1018
|
-
await Promise.all(resolvers.map(resolver => resolver(form, options)));
|
|
1019
|
-
return form;
|
|
1020
|
-
}
|
|
1021
|
-
|
|
1022
|
-
exports.Component = Component;
|
|
1023
|
-
exports.Conditional = Conditional;
|
|
1024
|
-
exports.Currency = Currency;
|
|
1025
|
-
exports.CustomClass = CustomClass;
|
|
1026
|
-
exports.CustomConditional = CustomConditional;
|
|
1027
|
-
exports.DataSourceJson = DataSourceJson;
|
|
1028
|
-
exports.DataSourceUrl = DataSourceUrl;
|
|
1029
|
-
exports.ErrorLabel = ErrorLabel;
|
|
1030
|
-
exports.ErrorMessage = ErrorMessage;
|
|
1031
|
-
exports.Form = Form;
|
|
1032
|
-
exports.Hidden = Hidden;
|
|
1033
|
-
exports.HideWhen = HideWhen;
|
|
1034
|
-
exports.InputTags = InputTags;
|
|
1035
|
-
exports.Label = Label;
|
|
1036
|
-
exports.Mask = Mask;
|
|
1037
|
-
exports.Masks = Masks;
|
|
1038
|
-
exports.MaxWords = MaxWords;
|
|
1039
|
-
exports.MinWords = MinWords;
|
|
1040
|
-
exports.ModalEdit = ModalEdit;
|
|
1041
|
-
exports.Multiple = Multiple;
|
|
1042
|
-
exports.OpenWhenEmpty = OpenWhenEmpty;
|
|
1043
|
-
exports.Password = Password;
|
|
1044
|
-
exports.Placeholder = Placeholder;
|
|
1045
|
-
exports.Prefix = Prefix;
|
|
1046
|
-
exports.Select = Select;
|
|
1047
|
-
exports.ShowWhen = ShowWhen;
|
|
1048
|
-
exports.Suffix = Suffix;
|
|
1049
|
-
exports.TableView = TableView;
|
|
1050
|
-
exports.Tabs = Tabs;
|
|
1051
|
-
exports.TextCase = TextCase;
|
|
1052
|
-
exports.Textarea = Textarea;
|
|
1053
|
-
exports.Tooltip = Tooltip;
|
|
1054
|
-
exports.Validate = Validate;
|
|
1055
|
-
exports.anyToComponent = anyToComponent;
|
|
1056
|
-
exports.arrayToComponent = arrayToComponent;
|
|
1057
|
-
exports.defaultToComponent = defaultToComponent;
|
|
1058
|
-
exports.enumToComponent = enumToComponent;
|
|
1059
|
-
exports.execMapper = execMapper;
|
|
1060
|
-
exports.getFormioMapper = getFormioMapper;
|
|
1061
|
-
exports.getFormioSchema = getFormioSchema;
|
|
1062
|
-
exports.mapToComponent = mapToComponent;
|
|
1063
|
-
exports.nestedToComponent = nestedToComponent;
|
|
1064
|
-
exports.numberToComponent = numberToComponent;
|
|
1065
|
-
exports.objectToEditGrid = objectToEditGrid;
|
|
1066
|
-
exports.panelToComponent = panelToComponent;
|
|
1067
|
-
exports.propertiesToComponents = propertiesToComponents;
|
|
1068
|
-
exports.registerFormioMapper = registerFormioMapper;
|
|
1069
|
-
exports.stringToComponent = stringToComponent;
|
|
1070
|
-
//# sourceMappingURL=index.js.map
|