@formio/js 5.0.0-rc.20 → 5.0.0-rc.22
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/dist/formio.embed.css +1 -39
- package/dist/formio.embed.js +2 -90
- package/dist/formio.embed.min.js +1 -1
- package/dist/formio.embed.min.js.LICENSE.txt +1 -1
- package/dist/formio.form.js +58 -36
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +1 -1
- package/dist/formio.full.js +59 -37
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +1 -1
- package/dist/formio.js +2 -2
- package/dist/formio.min.js +1 -1
- package/dist/formio.min.js.LICENSE.txt +1 -1
- package/dist/formio.utils.js +1 -1
- package/dist/formio.utils.min.js +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +1 -1
- package/lib/cjs/CDN.d.ts +1 -0
- package/lib/cjs/CDN.js +1 -0
- package/lib/cjs/Element.js +5 -0
- package/lib/cjs/Embed.d.ts +21 -1
- package/lib/cjs/Embed.js +211 -308
- package/lib/cjs/Form.d.ts +1 -1
- package/lib/cjs/Form.js +1 -1
- package/lib/cjs/Webform.d.ts +6 -6
- package/lib/cjs/Webform.js +6 -6
- package/lib/cjs/WebformBuilder.js +1 -1
- package/lib/cjs/components/_classes/component/Component.d.ts +16 -6
- package/lib/cjs/components/_classes/component/Component.js +26 -6
- package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +1 -0
- package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +4 -0
- package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.d.ts +1 -0
- package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.js +4 -0
- package/lib/cjs/components/address/Address.js +5 -0
- package/lib/cjs/components/button/Button.d.ts +1 -0
- package/lib/cjs/components/button/Button.js +3 -0
- package/lib/cjs/components/checkbox/Checkbox.d.ts +28 -0
- package/lib/cjs/components/checkbox/Checkbox.js +17 -2
- package/lib/cjs/components/columns/Columns.d.ts +1 -0
- package/lib/cjs/components/columns/Columns.js +3 -0
- package/lib/cjs/components/container/Container.js +3 -0
- package/lib/cjs/components/content/Content.d.ts +1 -0
- package/lib/cjs/components/content/Content.js +3 -0
- package/lib/cjs/components/datamap/DataMap.d.ts +1 -0
- package/lib/cjs/components/datamap/DataMap.js +3 -0
- package/lib/cjs/components/datetime/DateTime.d.ts +19 -0
- package/lib/cjs/components/datetime/DateTime.js +9 -10
- package/lib/cjs/components/day/Day.d.ts +21 -0
- package/lib/cjs/components/day/Day.js +12 -10
- package/lib/cjs/components/day/fixtures/comp5.d.ts +29 -0
- package/lib/cjs/components/day/fixtures/comp5.js +32 -0
- package/lib/cjs/components/day/fixtures/index.d.ts +2 -1
- package/lib/cjs/components/day/fixtures/index.js +3 -1
- package/lib/cjs/components/fieldset/Fieldset.d.ts +1 -0
- package/lib/cjs/components/fieldset/Fieldset.js +3 -0
- package/lib/cjs/components/file/File.d.ts +21 -1
- package/lib/cjs/components/file/File.js +15 -7
- package/lib/cjs/components/form/Form.d.ts +1 -0
- package/lib/cjs/components/form/Form.js +5 -1
- package/lib/cjs/components/html/HTML.d.ts +1 -0
- package/lib/cjs/components/html/HTML.js +3 -0
- package/lib/cjs/components/number/Number.d.ts +20 -1
- package/lib/cjs/components/number/Number.js +10 -15
- package/lib/cjs/components/panel/Panel.d.ts +1 -0
- package/lib/cjs/components/panel/Panel.js +3 -0
- package/lib/cjs/components/radio/Radio.d.ts +19 -0
- package/lib/cjs/components/radio/Radio.js +30 -0
- package/lib/cjs/components/recaptcha/ReCaptcha.d.ts +1 -0
- package/lib/cjs/components/recaptcha/ReCaptcha.js +3 -0
- package/lib/cjs/components/select/Select.d.ts +19 -1
- package/lib/cjs/components/select/Select.js +39 -4
- package/lib/cjs/components/select/fixtures/comp19.d.ts +23 -0
- package/lib/cjs/components/select/fixtures/comp19.js +36 -0
- package/lib/cjs/components/select/fixtures/index.d.ts +2 -1
- package/lib/cjs/components/select/fixtures/index.js +3 -1
- package/lib/cjs/components/selectboxes/SelectBoxes.d.ts +26 -1
- package/lib/cjs/components/selectboxes/SelectBoxes.js +8 -1
- package/lib/cjs/components/signature/Signature.d.ts +21 -0
- package/lib/cjs/components/signature/Signature.js +9 -1
- package/lib/cjs/components/survey/Survey.d.ts +21 -0
- package/lib/cjs/components/survey/Survey.js +7 -1
- package/lib/cjs/components/table/Table.d.ts +1 -0
- package/lib/cjs/components/table/Table.js +3 -0
- package/lib/cjs/components/tabs/Tabs.d.ts +1 -0
- package/lib/cjs/components/tabs/Tabs.js +3 -0
- package/lib/cjs/components/tags/Tags.d.ts +21 -0
- package/lib/cjs/components/tags/Tags.js +11 -1
- package/lib/cjs/components/tags/fixtures/comp6.d.ts +17 -0
- package/lib/cjs/components/tags/fixtures/comp6.js +20 -0
- package/lib/cjs/components/tags/fixtures/index.d.ts +2 -1
- package/lib/cjs/components/tags/fixtures/index.js +3 -1
- package/lib/cjs/components/textfield/TextField.d.ts +21 -0
- package/lib/cjs/components/textfield/TextField.js +7 -1
- package/lib/cjs/components/time/Time.d.ts +8 -1
- package/lib/cjs/components/well/Well.d.ts +1 -0
- package/lib/cjs/components/well/Well.js +3 -0
- package/lib/cjs/formio.embed.d.ts +2 -1
- package/lib/cjs/formio.embed.js +96 -1
- package/lib/cjs/formio.form.d.ts +4 -3
- package/lib/cjs/formio.form.js +17 -8
- package/lib/cjs/licenses/Licenses.d.ts +7 -0
- package/lib/cjs/licenses/Licenses.js +22 -0
- package/lib/cjs/licenses/index.d.ts +2 -0
- package/lib/cjs/licenses/index.js +7 -0
- package/lib/cjs/utils/utils.d.ts +10 -0
- package/lib/cjs/utils/utils.js +21 -1
- package/lib/mjs/CDN.d.ts +1 -0
- package/lib/mjs/CDN.js +1 -0
- package/lib/mjs/Element.js +5 -0
- package/lib/mjs/Embed.d.ts +21 -1
- package/lib/mjs/Embed.js +208 -322
- package/lib/mjs/Form.d.ts +1 -1
- package/lib/mjs/Form.js +1 -1
- package/lib/mjs/Webform.d.ts +6 -6
- package/lib/mjs/Webform.js +6 -6
- package/lib/mjs/WebformBuilder.js +1 -1
- package/lib/mjs/components/_classes/component/Component.d.ts +16 -6
- package/lib/mjs/components/_classes/component/Component.js +26 -6
- package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +1 -0
- package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +4 -0
- package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.d.ts +1 -0
- package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.js +4 -0
- package/lib/mjs/components/address/Address.js +5 -0
- package/lib/mjs/components/button/Button.d.ts +1 -0
- package/lib/mjs/components/button/Button.js +4 -1
- package/lib/mjs/components/checkbox/Checkbox.d.ts +28 -0
- package/lib/mjs/components/checkbox/Checkbox.js +18 -3
- package/lib/mjs/components/columns/Columns.d.ts +1 -0
- package/lib/mjs/components/columns/Columns.js +3 -0
- package/lib/mjs/components/container/Container.js +4 -1
- package/lib/mjs/components/content/Content.d.ts +1 -0
- package/lib/mjs/components/content/Content.js +3 -0
- package/lib/mjs/components/datamap/DataMap.d.ts +1 -0
- package/lib/mjs/components/datamap/DataMap.js +4 -1
- package/lib/mjs/components/datetime/DateTime.d.ts +19 -0
- package/lib/mjs/components/datetime/DateTime.js +11 -12
- package/lib/mjs/components/day/Day.d.ts +21 -0
- package/lib/mjs/components/day/Day.js +16 -14
- package/lib/mjs/components/day/fixtures/comp5.d.ts +29 -0
- package/lib/mjs/components/day/fixtures/comp5.js +30 -0
- package/lib/mjs/components/day/fixtures/index.d.ts +2 -1
- package/lib/mjs/components/day/fixtures/index.js +2 -1
- package/lib/mjs/components/fieldset/Fieldset.d.ts +1 -0
- package/lib/mjs/components/fieldset/Fieldset.js +3 -0
- package/lib/mjs/components/file/File.d.ts +21 -1
- package/lib/mjs/components/file/File.js +16 -8
- package/lib/mjs/components/form/Form.d.ts +1 -0
- package/lib/mjs/components/form/Form.js +6 -2
- package/lib/mjs/components/html/HTML.d.ts +1 -0
- package/lib/mjs/components/html/HTML.js +3 -0
- package/lib/mjs/components/number/Number.d.ts +20 -1
- package/lib/mjs/components/number/Number.js +11 -12
- package/lib/mjs/components/panel/Panel.d.ts +1 -0
- package/lib/mjs/components/panel/Panel.js +3 -0
- package/lib/mjs/components/radio/Radio.d.ts +19 -0
- package/lib/mjs/components/radio/Radio.js +34 -1
- package/lib/mjs/components/recaptcha/ReCaptcha.d.ts +1 -0
- package/lib/mjs/components/recaptcha/ReCaptcha.js +3 -0
- package/lib/mjs/components/select/Select.d.ts +19 -1
- package/lib/mjs/components/select/Select.js +41 -6
- package/lib/mjs/components/select/fixtures/comp19.d.ts +23 -0
- package/lib/mjs/components/select/fixtures/comp19.js +34 -0
- package/lib/mjs/components/select/fixtures/index.d.ts +2 -1
- package/lib/mjs/components/select/fixtures/index.js +2 -1
- package/lib/mjs/components/selectboxes/SelectBoxes.d.ts +26 -1
- package/lib/mjs/components/selectboxes/SelectBoxes.js +8 -1
- package/lib/mjs/components/signature/Signature.d.ts +21 -0
- package/lib/mjs/components/signature/Signature.js +9 -1
- package/lib/mjs/components/survey/Survey.d.ts +21 -0
- package/lib/mjs/components/survey/Survey.js +8 -2
- package/lib/mjs/components/table/Table.d.ts +1 -0
- package/lib/mjs/components/table/Table.js +3 -0
- package/lib/mjs/components/tabs/Tabs.d.ts +1 -0
- package/lib/mjs/components/tabs/Tabs.js +3 -0
- package/lib/mjs/components/tags/Tags.d.ts +21 -0
- package/lib/mjs/components/tags/Tags.js +12 -2
- package/lib/mjs/components/tags/fixtures/comp6.d.ts +17 -0
- package/lib/mjs/components/tags/fixtures/comp6.js +18 -0
- package/lib/mjs/components/tags/fixtures/index.d.ts +2 -1
- package/lib/mjs/components/tags/fixtures/index.js +2 -1
- package/lib/mjs/components/textfield/TextField.d.ts +21 -0
- package/lib/mjs/components/textfield/TextField.js +8 -2
- package/lib/mjs/components/time/Time.d.ts +8 -1
- package/lib/mjs/components/well/Well.d.ts +1 -0
- package/lib/mjs/components/well/Well.js +3 -0
- package/lib/mjs/formio.embed.d.ts +2 -1
- package/lib/mjs/formio.embed.js +96 -2
- package/lib/mjs/formio.form.d.ts +4 -3
- package/lib/mjs/formio.form.js +16 -8
- package/lib/mjs/licenses/Licenses.d.ts +7 -0
- package/lib/mjs/licenses/Licenses.js +17 -0
- package/lib/mjs/licenses/index.d.ts +2 -0
- package/lib/mjs/licenses/index.js +2 -0
- package/lib/mjs/utils/utils.d.ts +10 -0
- package/lib/mjs/utils/utils.js +19 -0
- package/package.json +5 -1
- package/types/index.d.ts +1 -0
- package/types/licenses.d.ts +7 -0
- package/types/utils.d.ts +2 -0
@@ -2,6 +2,7 @@ import SignaturePad from 'signature_pad';
|
|
2
2
|
import _ResizeObserver from 'resize-observer-polyfill';
|
3
3
|
import Input from '../_classes/input/Input';
|
4
4
|
import _ from 'lodash';
|
5
|
+
import { componentValueTypes, getComponentSavedTypes } from '../../utils/utils';
|
5
6
|
export default class SignatureComponent extends Input {
|
6
7
|
static schema(...extend) {
|
7
8
|
return Input.schema({
|
@@ -29,11 +30,18 @@ export default class SignatureComponent extends Input {
|
|
29
30
|
};
|
30
31
|
}
|
31
32
|
static get serverConditionSettings() {
|
33
|
+
return SignatureComponent.conditionOperatorsSettings;
|
34
|
+
}
|
35
|
+
static get conditionOperatorsSettings() {
|
32
36
|
return {
|
33
|
-
...super.
|
37
|
+
...super.conditionOperatorsSettings,
|
34
38
|
operators: ['isEmpty', 'isNotEmpty'],
|
35
39
|
};
|
36
40
|
}
|
41
|
+
static savedValueTypes(schema) {
|
42
|
+
schema = schema || {};
|
43
|
+
return getComponentSavedTypes(schema) || [componentValueTypes.string];
|
44
|
+
}
|
37
45
|
init() {
|
38
46
|
super.init();
|
39
47
|
this.currentWidth = 0;
|
@@ -7,6 +7,27 @@ export default class SurveyComponent extends Field {
|
|
7
7
|
documentation: string;
|
8
8
|
schema: any;
|
9
9
|
};
|
10
|
+
static get serverConditionSettings(): {
|
11
|
+
operators: string[];
|
12
|
+
constructor: Function;
|
13
|
+
toString(): string;
|
14
|
+
toLocaleString(): string;
|
15
|
+
valueOf(): Object;
|
16
|
+
hasOwnProperty(v: PropertyKey): boolean;
|
17
|
+
isPrototypeOf(v: Object): boolean;
|
18
|
+
propertyIsEnumerable(v: PropertyKey): boolean;
|
19
|
+
};
|
20
|
+
static get conditionOperatorsSettings(): {
|
21
|
+
operators: string[];
|
22
|
+
constructor: Function;
|
23
|
+
toString(): string;
|
24
|
+
toLocaleString(): string;
|
25
|
+
valueOf(): Object;
|
26
|
+
hasOwnProperty(v: PropertyKey): boolean;
|
27
|
+
isPrototypeOf(v: Object): boolean;
|
28
|
+
propertyIsEnumerable(v: PropertyKey): boolean;
|
29
|
+
};
|
30
|
+
static savedValueTypes(schema: any): string[];
|
10
31
|
render(): any;
|
11
32
|
setValue(value: any, flags?: {}): boolean;
|
12
33
|
get emptyValue(): {};
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import _ from 'lodash';
|
2
2
|
import Field from '../_classes/field/Field';
|
3
|
-
import { boolValue } from '../../utils/utils';
|
3
|
+
import { boolValue, componentValueTypes, getComponentSavedTypes } from '../../utils/utils';
|
4
4
|
export default class SurveyComponent extends Field {
|
5
5
|
static schema(...extend) {
|
6
6
|
return Field.schema({
|
@@ -22,11 +22,17 @@ export default class SurveyComponent extends Field {
|
|
22
22
|
};
|
23
23
|
}
|
24
24
|
static get serverConditionSettings() {
|
25
|
+
return SurveyComponent.conditionOperatorsSettings;
|
26
|
+
}
|
27
|
+
static get conditionOperatorsSettings() {
|
25
28
|
return {
|
26
|
-
...super.
|
29
|
+
...super.conditionOperatorsSettings,
|
27
30
|
operators: ['isEmpty', 'isNotEmpty'],
|
28
31
|
};
|
29
32
|
}
|
33
|
+
static savedValueTypes(schema) {
|
34
|
+
return getComponentSavedTypes(schema) || [componentValueTypes.object];
|
35
|
+
}
|
30
36
|
get defaultSchema() {
|
31
37
|
return SurveyComponent.schema();
|
32
38
|
}
|
@@ -7,6 +7,27 @@ export default class TagsComponent extends Input {
|
|
7
7
|
weight: number;
|
8
8
|
schema: any;
|
9
9
|
};
|
10
|
+
static get serverConditionSettings(): {
|
11
|
+
operators: any[];
|
12
|
+
constructor: Function;
|
13
|
+
toString(): string;
|
14
|
+
toLocaleString(): string;
|
15
|
+
valueOf(): Object;
|
16
|
+
hasOwnProperty(v: PropertyKey): boolean;
|
17
|
+
isPrototypeOf(v: Object): boolean;
|
18
|
+
propertyIsEnumerable(v: PropertyKey): boolean;
|
19
|
+
};
|
20
|
+
static get conditionOperatorsSettings(): {
|
21
|
+
operators: any[];
|
22
|
+
constructor: Function;
|
23
|
+
toString(): string;
|
24
|
+
toLocaleString(): string;
|
25
|
+
valueOf(): Object;
|
26
|
+
hasOwnProperty(v: PropertyKey): boolean;
|
27
|
+
isPrototypeOf(v: Object): boolean;
|
28
|
+
propertyIsEnumerable(v: PropertyKey): boolean;
|
29
|
+
};
|
30
|
+
static savedValueTypes(schema: any): any[];
|
10
31
|
get emptyValue(): "" | never[];
|
11
32
|
get delimiter(): any;
|
12
33
|
attachElement(element: any, index: any): void;
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { componentValueTypes, getComponentSavedTypes } from '../../utils/utils';
|
1
2
|
import Input from '../_classes/input/Input';
|
2
3
|
import Choices from '@formio/choices.js';
|
3
4
|
export default class TagsComponent extends Input {
|
@@ -22,11 +23,18 @@ export default class TagsComponent extends Input {
|
|
22
23
|
};
|
23
24
|
}
|
24
25
|
static get serverConditionSettings() {
|
26
|
+
return TagsComponent.conditionOperatorsSettings;
|
27
|
+
}
|
28
|
+
static get conditionOperatorsSettings() {
|
25
29
|
return {
|
26
|
-
...super.
|
27
|
-
operators: [...super.
|
30
|
+
...super.conditionOperatorsSettings,
|
31
|
+
operators: [...super.conditionOperatorsSettings.operators, 'includes', 'notIncludes'],
|
28
32
|
};
|
29
33
|
}
|
34
|
+
static savedValueTypes(schema) {
|
35
|
+
schema = schema || {};
|
36
|
+
return getComponentSavedTypes(schema) || [componentValueTypes[schema.storeas] || componentValueTypes.string];
|
37
|
+
}
|
30
38
|
init() {
|
31
39
|
super.init();
|
32
40
|
}
|
@@ -74,6 +82,8 @@ export default class TagsComponent extends Input {
|
|
74
82
|
});
|
75
83
|
this.choices.itemList.element.tabIndex = element.tabIndex;
|
76
84
|
this.addEventListener(this.choices.input.element, 'blur', () => {
|
85
|
+
// Emit event to the native Formio input, so the listener attached in the Input.js will be invoked
|
86
|
+
element.dispatchEvent(new Event('blur'));
|
77
87
|
const value = this.choices.input.value;
|
78
88
|
const maxTagsNumber = this.component.maxTags;
|
79
89
|
const valuesCount = this.choices.getValue(true).length;
|
@@ -0,0 +1,17 @@
|
|
1
|
+
declare namespace _default {
|
2
|
+
const type: string;
|
3
|
+
const display: string;
|
4
|
+
const components: {
|
5
|
+
label: string;
|
6
|
+
tableView: boolean;
|
7
|
+
storeas: string;
|
8
|
+
validate: {
|
9
|
+
custom: string;
|
10
|
+
};
|
11
|
+
validateOn: string;
|
12
|
+
key: string;
|
13
|
+
type: string;
|
14
|
+
input: boolean;
|
15
|
+
}[];
|
16
|
+
}
|
17
|
+
export default _default;
|
@@ -0,0 +1,18 @@
|
|
1
|
+
export default {
|
2
|
+
type: 'form',
|
3
|
+
display: 'form',
|
4
|
+
components: [
|
5
|
+
{
|
6
|
+
label: 'Tags',
|
7
|
+
tableView: false,
|
8
|
+
storeas: 'array',
|
9
|
+
validate: {
|
10
|
+
custom: "valid = data && data.tags.length <= 2 ? true : 'You cannot add more than 2 items'"
|
11
|
+
},
|
12
|
+
validateOn: 'blur',
|
13
|
+
key: 'tags',
|
14
|
+
type: 'tags',
|
15
|
+
input: true
|
16
|
+
},
|
17
|
+
]
|
18
|
+
};
|
@@ -7,6 +7,27 @@ export default class TextFieldComponent extends Input {
|
|
7
7
|
weight: number;
|
8
8
|
schema: any;
|
9
9
|
};
|
10
|
+
static get serverConditionSettings(): {
|
11
|
+
operators: any[];
|
12
|
+
constructor: Function;
|
13
|
+
toString(): string;
|
14
|
+
toLocaleString(): string;
|
15
|
+
valueOf(): Object;
|
16
|
+
hasOwnProperty(v: PropertyKey): boolean;
|
17
|
+
isPrototypeOf(v: Object): boolean;
|
18
|
+
propertyIsEnumerable(v: PropertyKey): boolean;
|
19
|
+
};
|
20
|
+
static get conditionOperatorsSettings(): {
|
21
|
+
operators: any[];
|
22
|
+
constructor: Function;
|
23
|
+
toString(): string;
|
24
|
+
toLocaleString(): string;
|
25
|
+
valueOf(): Object;
|
26
|
+
hasOwnProperty(v: PropertyKey): boolean;
|
27
|
+
isPrototypeOf(v: Object): boolean;
|
28
|
+
propertyIsEnumerable(v: PropertyKey): boolean;
|
29
|
+
};
|
30
|
+
static savedValueTypes(schema: any): string[];
|
10
31
|
get emptyValue(): string;
|
11
32
|
/**
|
12
33
|
* Returns the mask value object.
|
@@ -33,11 +33,17 @@ export default class TextFieldComponent extends Input {
|
|
33
33
|
};
|
34
34
|
}
|
35
35
|
static get serverConditionSettings() {
|
36
|
+
return TextFieldComponent.conditionOperatorsSettings;
|
37
|
+
}
|
38
|
+
static get conditionOperatorsSettings() {
|
36
39
|
return {
|
37
|
-
...super.
|
38
|
-
operators: [...super.
|
40
|
+
...super.conditionOperatorsSettings,
|
41
|
+
operators: [...super.conditionOperatorsSettings.operators, 'includes', 'notIncludes', 'endsWith', 'startsWith'],
|
39
42
|
};
|
40
43
|
}
|
44
|
+
static savedValueTypes(schema) {
|
45
|
+
return FormioUtils.getComponentSavedTypes(schema) || [FormioUtils.componentValueTypes.string];
|
46
|
+
}
|
41
47
|
get defaultSchema() {
|
42
48
|
return TextFieldComponent.schema();
|
43
49
|
}
|
@@ -1,7 +1,14 @@
|
|
1
1
|
export default class TimeComponent extends TextFieldComponent {
|
2
2
|
static get serverConditionSettings(): {
|
3
3
|
valueComponent(classComp: any): any;
|
4
|
-
operators:
|
4
|
+
operators: any[];
|
5
|
+
constructor: Function;
|
6
|
+
toString(): string;
|
7
|
+
toLocaleString(): string;
|
8
|
+
valueOf(): Object;
|
9
|
+
hasOwnProperty(v: PropertyKey): boolean;
|
10
|
+
isPrototypeOf(v: Object): boolean;
|
11
|
+
propertyIsEnumerable(v: PropertyKey): boolean;
|
5
12
|
};
|
6
13
|
rawData: string | never[];
|
7
14
|
get dataFormat(): any;
|
@@ -1 +1,2 @@
|
|
1
|
-
export {};
|
1
|
+
export { Formio };
|
2
|
+
import { Formio } from './Embed';
|
package/lib/mjs/formio.embed.js
CHANGED
@@ -1,2 +1,96 @@
|
|
1
|
-
import {
|
2
|
-
|
1
|
+
import { Formio } from './Embed';
|
2
|
+
const scripts = document.getElementsByTagName('script');
|
3
|
+
const config = window.FormioConfig || {};
|
4
|
+
let thisScript = null;
|
5
|
+
let i = scripts.length;
|
6
|
+
const scriptName = config.scriptName || 'formio.embed.';
|
7
|
+
while (i--) {
|
8
|
+
if (scripts[i].src && (scripts[i].src.indexOf(scriptName) !== -1)) {
|
9
|
+
thisScript = scripts[i];
|
10
|
+
break;
|
11
|
+
}
|
12
|
+
}
|
13
|
+
if (thisScript) {
|
14
|
+
const query = {};
|
15
|
+
const queryString = thisScript.src.replace(/^[^?]+\??/, '');
|
16
|
+
queryString.replace(/\?/g, '&').split('&').forEach((item) => {
|
17
|
+
query[item.split('=')[0]] = item.split('=')[1] && decodeURIComponent(item.split('=')[1]);
|
18
|
+
});
|
19
|
+
let scriptSrc = thisScript.src.replace(/^([^?]+).*/, '$1').split('/');
|
20
|
+
scriptSrc.pop();
|
21
|
+
if (config.formioPath) {
|
22
|
+
config.formioPath(scriptSrc);
|
23
|
+
}
|
24
|
+
scriptSrc = scriptSrc.join('/');
|
25
|
+
Formio.config = Object.assign({
|
26
|
+
script: query.script || (`${config.updatePath ? config.updatePath() : scriptSrc}/formio.form.min.js`),
|
27
|
+
style: query.styles || (`${config.updatePath ? config.updatePath() : scriptSrc}/formio.form.min.css`),
|
28
|
+
cdn: query.cdn,
|
29
|
+
class: (query.class || 'formio-form-wrapper'),
|
30
|
+
src: query.src,
|
31
|
+
form: null,
|
32
|
+
submission: null,
|
33
|
+
project: query.project,
|
34
|
+
base: query.base || 'https://api.form.io',
|
35
|
+
submit: query.submit,
|
36
|
+
includeLibs: (query.libs === 'true' || query.libs === '1'),
|
37
|
+
template: query.template,
|
38
|
+
debug: (query.debug === 'true' || query.debug === '1'),
|
39
|
+
config: {},
|
40
|
+
redirect: (query.return || query.redirect),
|
41
|
+
embedCSS: (`${config.updatePath ? config.updatePath() : scriptSrc}/formio.embed.css`),
|
42
|
+
before: null,
|
43
|
+
after: null
|
44
|
+
}, config);
|
45
|
+
const form = (Formio.config.form || Formio.config.src);
|
46
|
+
if (form) {
|
47
|
+
Formio.debug('Embedding Configuration', config);
|
48
|
+
if (Formio.config.addPremiumLib) {
|
49
|
+
Formio.config.addPremiumLib(Formio.config, scriptSrc);
|
50
|
+
}
|
51
|
+
// The id for this embedded form.
|
52
|
+
Formio.config.id = `formio-${Math.random().toString(36).substring(7)}`;
|
53
|
+
Formio.debug('Creating form element');
|
54
|
+
const element = Formio.createElement('div', {
|
55
|
+
'id': Formio.config.id,
|
56
|
+
class: Formio.config.class
|
57
|
+
});
|
58
|
+
// insertAfter doesn't exist, but effect is identical.
|
59
|
+
thisScript.parentNode.insertBefore(element, thisScript.parentNode.firstElementChild.nextSibling);
|
60
|
+
Formio.createForm(element, form, Formio.config.config).then((instance) => {
|
61
|
+
if (Formio.config.submit) {
|
62
|
+
instance.nosubmit = true;
|
63
|
+
}
|
64
|
+
// Configure a redirect.
|
65
|
+
instance.on('submit', (submission) => {
|
66
|
+
Formio.debug("on('submit')", submission);
|
67
|
+
if (Formio.config.submit) {
|
68
|
+
Formio.debug(`Sending submission to ${Formio.config.submit}`);
|
69
|
+
const headers = {
|
70
|
+
'content-type': 'application/json'
|
71
|
+
};
|
72
|
+
const token = Formio.FormioClass.getToken();
|
73
|
+
if (token) {
|
74
|
+
headers['x-jwt-token'] = token;
|
75
|
+
}
|
76
|
+
Formio.FormioClass.fetch(Formio.config.submit, {
|
77
|
+
body: JSON.stringify(submission),
|
78
|
+
headers: headers,
|
79
|
+
method: 'POST',
|
80
|
+
mode: 'cors',
|
81
|
+
})
|
82
|
+
.then(resp => resp.json())
|
83
|
+
.then(submission => Formio.submitDone(instance, submission));
|
84
|
+
}
|
85
|
+
else {
|
86
|
+
Formio.submitDone(instance, submission);
|
87
|
+
}
|
88
|
+
});
|
89
|
+
});
|
90
|
+
}
|
91
|
+
}
|
92
|
+
else {
|
93
|
+
// Show an error if the script cannot be found.
|
94
|
+
document.write('<span>Could not locate the Embedded form.</span>');
|
95
|
+
}
|
96
|
+
export { Formio };
|
package/lib/mjs/formio.form.d.ts
CHANGED
@@ -3,8 +3,8 @@
|
|
3
3
|
* @param {*} plugin
|
4
4
|
* @returns
|
5
5
|
*/
|
6
|
-
export function registerModule(mod: any, defaultFn?: null): void;
|
7
|
-
export function useModule(defaultFn?: null): (
|
6
|
+
export function registerModule(mod: any, defaultFn?: null, options?: {}): void;
|
7
|
+
export function useModule(defaultFn?: null): (plugins: any, options?: {}) => void;
|
8
8
|
import Components from './components/Components';
|
9
9
|
import Displays from './displays/Displays';
|
10
10
|
import Providers from './providers';
|
@@ -19,4 +19,5 @@ import ValueSources from './validator/valueSources';
|
|
19
19
|
import Utils from './utils';
|
20
20
|
import Form from './Form';
|
21
21
|
import { Formio } from './Formio';
|
22
|
-
|
22
|
+
import Licenses from './licenses';
|
23
|
+
export { Components, Displays, Providers, Rules, Widgets, Templates, Conjunctions, Operators, QuickRules, Transformers, ValueSources, Utils, Form, Formio, Licenses };
|
package/lib/mjs/formio.form.js
CHANGED
@@ -15,6 +15,7 @@ import Widgets from './widgets';
|
|
15
15
|
import Form from './Form';
|
16
16
|
import Utils from './utils';
|
17
17
|
import Evaluator from './utils/Evaluator';
|
18
|
+
import Licenses from './licenses';
|
18
19
|
Formio.loadModules = (path = `${Formio.getApiUrl()}/externalModules.js`, name = 'externalModules') => {
|
19
20
|
Formio.requireLibrary(name, name, path, true)
|
20
21
|
.then((modules) => {
|
@@ -37,6 +38,7 @@ Formio.QuickRules = QuickRules;
|
|
37
38
|
Formio.Transformers = Transformers;
|
38
39
|
Formio.ValueSources = ValueSources;
|
39
40
|
Formio.AllComponents = AllComponents;
|
41
|
+
Formio.Licenses = Licenses;
|
40
42
|
// This is strange, but is needed for "premium" components to import correctly.
|
41
43
|
Formio.Formio = Formio;
|
42
44
|
Formio.Components.setComponents(AllComponents);
|
@@ -45,7 +47,7 @@ Formio.Components.setComponents(AllComponents);
|
|
45
47
|
* @param {*} plugin
|
46
48
|
* @returns
|
47
49
|
*/
|
48
|
-
export function registerModule(mod, defaultFn = null) {
|
50
|
+
export function registerModule(mod, defaultFn = null, options = {}) {
|
49
51
|
// Sanity check.
|
50
52
|
if (typeof mod !== 'object') {
|
51
53
|
return;
|
@@ -104,6 +106,11 @@ export function registerModule(mod, defaultFn = null) {
|
|
104
106
|
case 'valueSources':
|
105
107
|
Formio.ValueSources.addValueSources(mod.valueSources);
|
106
108
|
break;
|
109
|
+
case 'library':
|
110
|
+
options.license
|
111
|
+
? Formio.Licenses.addLicense(mod.library, mod.license)
|
112
|
+
: Formio.Licenses.removeLicense(mod.library);
|
113
|
+
break;
|
107
114
|
default:
|
108
115
|
if (defaultFn) {
|
109
116
|
if (!defaultFn(key, mod)) {
|
@@ -116,23 +123,24 @@ export function registerModule(mod, defaultFn = null) {
|
|
116
123
|
}
|
117
124
|
}
|
118
125
|
export function useModule(defaultFn = null) {
|
119
|
-
return (
|
126
|
+
return (plugins, options = {}) => {
|
127
|
+
plugins = _.isArray(plugins) ? plugins : [plugins];
|
120
128
|
plugins.forEach((plugin) => {
|
121
129
|
if (Array.isArray(plugin)) {
|
122
|
-
plugin.forEach(p => registerModule(p, defaultFn));
|
130
|
+
plugin.forEach(p => registerModule(p, defaultFn, options));
|
123
131
|
}
|
124
132
|
else {
|
125
|
-
registerModule(plugin, defaultFn);
|
133
|
+
registerModule(plugin, defaultFn, options);
|
126
134
|
}
|
127
135
|
});
|
128
136
|
};
|
129
137
|
}
|
130
138
|
/**
|
131
|
-
* Allows passing in plugins as
|
139
|
+
* Allows passing in plugins as an array of plugins or a single plugin.
|
132
140
|
*
|
133
|
-
* Formio.plugins(plugin1,
|
134
|
-
* Formio.plugins([plugin1, plugin2, etc]);
|
141
|
+
* Formio.plugins(plugin1, options);
|
142
|
+
* Formio.plugins([plugin1, plugin2, etc], options);
|
135
143
|
*/
|
136
144
|
Formio.use = useModule();
|
137
145
|
// Export the components.
|
138
|
-
export { Components, Displays, Providers, Rules, Widgets, Templates, Conjunctions, Operators, QuickRules, Transformers, ValueSources, Utils, Form, Formio };
|
146
|
+
export { Components, Displays, Providers, Rules, Widgets, Templates, Conjunctions, Operators, QuickRules, Transformers, ValueSources, Utils, Form, Formio, Licenses };
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import _ from 'lodash';
|
2
|
+
class Licenses {
|
3
|
+
static licenses = {};
|
4
|
+
static addLicense(name, license) {
|
5
|
+
Licenses.licenses[name] = license;
|
6
|
+
}
|
7
|
+
static getLicense(name) {
|
8
|
+
return Licenses.licenses[name];
|
9
|
+
}
|
10
|
+
static removeLicense(name) {
|
11
|
+
_.unset(Licenses.licenses, name);
|
12
|
+
}
|
13
|
+
static getLicenses() {
|
14
|
+
return Licenses.licenses;
|
15
|
+
}
|
16
|
+
}
|
17
|
+
export default Licenses;
|
package/lib/mjs/utils/utils.d.ts
CHANGED
@@ -349,6 +349,7 @@ export function isPromise(value: any): boolean;
|
|
349
349
|
*/
|
350
350
|
export function isInsideScopingComponent(componentInstance: any, firstPass?: boolean): boolean | boolean | any;
|
351
351
|
export function getFocusableElements(element: any): any;
|
352
|
+
export function getComponentSavedTypes(fullSchema: any): string[] | null;
|
352
353
|
export * from "./formUtils";
|
353
354
|
/**
|
354
355
|
* Map values through unfold and return first non-nil value.
|
@@ -357,6 +358,15 @@ export * from "./formUtils";
|
|
357
358
|
* @return {T}
|
358
359
|
*/
|
359
360
|
export const firstNonNil: any;
|
361
|
+
export namespace componentValueTypes {
|
362
|
+
const number: string;
|
363
|
+
const string: string;
|
364
|
+
const boolean: string;
|
365
|
+
const array: string;
|
366
|
+
const object: string;
|
367
|
+
const date: string;
|
368
|
+
const any: string;
|
369
|
+
}
|
360
370
|
import jsonLogic from 'json-logic-js';
|
361
371
|
import ConditionOperators from './conditionOperators';
|
362
372
|
import Evaluator from './Evaluator';
|
package/lib/mjs/utils/utils.js
CHANGED
@@ -1365,3 +1365,22 @@ export function getFocusableElements(element) {
|
|
1365
1365
|
}
|
1366
1366
|
// Export lodash to save space with other libraries.
|
1367
1367
|
export { _ };
|
1368
|
+
export const componentValueTypes = {
|
1369
|
+
number: 'number',
|
1370
|
+
string: 'string',
|
1371
|
+
boolean: 'boolean',
|
1372
|
+
array: 'array',
|
1373
|
+
object: 'object',
|
1374
|
+
date: 'date',
|
1375
|
+
any: 'any',
|
1376
|
+
};
|
1377
|
+
export function getComponentSavedTypes(fullSchema) {
|
1378
|
+
const schema = fullSchema || {};
|
1379
|
+
if (schema.persistent !== true) {
|
1380
|
+
return [];
|
1381
|
+
}
|
1382
|
+
if (schema.multiple) {
|
1383
|
+
return [componentValueTypes.array];
|
1384
|
+
}
|
1385
|
+
return null;
|
1386
|
+
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@formio/js",
|
3
|
-
"version": "5.0.0-rc.
|
3
|
+
"version": "5.0.0-rc.22",
|
4
4
|
"description": "JavaScript powered Forms with JSON Form Builder",
|
5
5
|
"main": "lib/cjs/index.js",
|
6
6
|
"module": "lib/mjs/index.js",
|
@@ -9,6 +9,10 @@
|
|
9
9
|
"import": "./lib/mjs/index.js",
|
10
10
|
"require": "./lib/cjs/index.js"
|
11
11
|
},
|
12
|
+
"./sdk": {
|
13
|
+
"import": "./lib/mjs/Formio.js",
|
14
|
+
"require": "./lib/cjs/Formio.js"
|
15
|
+
},
|
12
16
|
"./utils": {
|
13
17
|
"import": "./lib/mjs/utils/index.js",
|
14
18
|
"require": "./lib/cjs/utils/index.js"
|
package/types/index.d.ts
CHANGED
package/types/utils.d.ts
CHANGED
@@ -4,8 +4,10 @@ export type AnyForJSON = { [key: string]: any } | any;
|
|
4
4
|
|
5
5
|
export namespace Utils {
|
6
6
|
const ConditionOperators: any;
|
7
|
+
const componentValueTypes: { [key: string]: string };
|
7
8
|
const Evaluator: any;
|
8
9
|
const _: any;
|
10
|
+
function getComponentSavedTypes(schema: object): Array<any> | null;
|
9
11
|
function evaluate(
|
10
12
|
func: any,
|
11
13
|
args: { component: any; form: any; instance: any; row: any; data: any } | any,
|