@formio/js 5.3.0-rc.4 → 5.3.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/dist/formio.builder.css +8 -0
- package/dist/formio.builder.min.css +1 -1
- package/dist/formio.embed.js +1 -1
- package/dist/formio.embed.min.js +1 -1
- package/dist/formio.embed.min.js.LICENSE.txt +1 -1
- package/dist/formio.form.css +8 -0
- package/dist/formio.form.js +28 -28
- package/dist/formio.form.min.css +1 -1
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +1 -1
- package/dist/formio.full.css +8 -0
- package/dist/formio.full.js +29 -29
- package/dist/formio.full.min.css +1 -1
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +1 -1
- package/dist/formio.js +6 -6
- package/dist/formio.min.js +1 -1
- package/dist/formio.min.js.LICENSE.txt +1 -1
- package/dist/formio.utils.js +5 -5
- package/dist/formio.utils.min.js +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +1 -1
- package/lib/cjs/Element.js +6 -3
- package/lib/cjs/Embed.js +3 -2
- package/lib/cjs/Formio.js +1 -1
- package/lib/cjs/Webform.js +4 -2
- package/lib/cjs/WebformBuilder.js +8 -4
- package/lib/cjs/Wizard.js +3 -3
- package/lib/cjs/components/_classes/component/Component.js +38 -25
- package/lib/cjs/components/address/Address.js +7 -5
- package/lib/cjs/components/button/Button.js +21 -15
- package/lib/cjs/components/datagrid/DataGrid.js +9 -4
- package/lib/cjs/components/datamap/DataMap.d.ts +0 -4
- package/lib/cjs/components/datamap/DataMap.js +9 -8
- package/lib/cjs/components/day/Day.js +2 -1
- package/lib/cjs/components/editgrid/EditGrid.js +12 -8
- package/lib/cjs/components/file/File.js +11 -6
- package/lib/cjs/components/form/Form.js +6 -3
- package/lib/cjs/components/radio/Radio.js +6 -3
- package/lib/cjs/components/recaptcha/ReCaptcha.js +5 -3
- package/lib/cjs/components/select/Select.js +25 -15
- package/lib/cjs/components/selectboxes/SelectBoxes.js +2 -1
- package/lib/cjs/components/signature/Signature.js +2 -1
- package/lib/cjs/components/table/Table.js +2 -1
- package/lib/cjs/components/tabs/Tabs.js +2 -1
- package/lib/cjs/components/textfield/TextField.js +9 -2
- package/lib/cjs/package.json +1 -1
- package/lib/cjs/utils/index.d.ts +1 -0
- package/lib/cjs/utils/utils.d.ts +5 -0
- package/lib/cjs/utils/utils.js +18 -1
- package/lib/mjs/Element.js +3 -3
- package/lib/mjs/Embed.js +2 -2
- package/lib/mjs/Formio.js +1 -1
- package/lib/mjs/Webform.js +2 -2
- package/lib/mjs/WebformBuilder.js +4 -4
- package/lib/mjs/Wizard.js +1 -1
- package/lib/mjs/components/_classes/component/Component.js +29 -24
- package/lib/mjs/components/address/Address.js +3 -3
- package/lib/mjs/components/button/Button.js +15 -15
- package/lib/mjs/components/datagrid/DataGrid.js +8 -4
- package/lib/mjs/components/datamap/DataMap.d.ts +0 -4
- package/lib/mjs/components/datamap/DataMap.js +7 -8
- package/lib/mjs/components/day/Day.js +1 -1
- package/lib/mjs/components/editgrid/EditGrid.js +8 -6
- package/lib/mjs/components/file/File.js +6 -6
- package/lib/mjs/components/form/Form.js +3 -3
- package/lib/mjs/components/radio/Radio.js +3 -3
- package/lib/mjs/components/recaptcha/ReCaptcha.js +3 -3
- package/lib/mjs/components/select/Select.js +25 -15
- package/lib/mjs/components/selectboxes/SelectBoxes.js +1 -1
- package/lib/mjs/components/signature/Signature.js +1 -1
- package/lib/mjs/components/table/Table.js +1 -1
- package/lib/mjs/components/tabs/Tabs.js +1 -1
- package/lib/mjs/components/textfield/TextField.js +9 -2
- package/lib/mjs/package.json +1 -1
- package/lib/mjs/utils/index.d.ts +1 -0
- package/lib/mjs/utils/utils.d.ts +5 -0
- package/lib/mjs/utils/utils.js +16 -0
- package/package.json +3 -3
|
@@ -246,7 +246,14 @@ export default class SelectComponent extends ListComponent {
|
|
|
246
246
|
return this.component.dataSrc === 'resource' && this.valueProperty === 'data';
|
|
247
247
|
}
|
|
248
248
|
selectValueAndLabel(data) {
|
|
249
|
-
|
|
249
|
+
let value;
|
|
250
|
+
// If the select is a resource reference, use the actual object value
|
|
251
|
+
if (this.component.reference && this.isSelectResource) {
|
|
252
|
+
value = this.getOptionValue(data);
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
value = this.getOptionValue(this.isEntireObjectDisplay() && !this.itemValue(data) ? data : this.itemValue(data));
|
|
256
|
+
}
|
|
250
257
|
return {
|
|
251
258
|
value,
|
|
252
259
|
label: this.itemTemplate(this.isEntireObjectDisplay() && !_.isObject(data.data) ? { data: data } : data, value),
|
|
@@ -285,6 +292,10 @@ export default class SelectComponent extends ListComponent {
|
|
|
285
292
|
else {
|
|
286
293
|
data = selectData;
|
|
287
294
|
}
|
|
295
|
+
// use template data for reference fields to make sure the data is updated
|
|
296
|
+
if (this.component.reference && this.templateData[templateValue]) {
|
|
297
|
+
data = this.templateData[templateValue];
|
|
298
|
+
}
|
|
288
299
|
}
|
|
289
300
|
}
|
|
290
301
|
if (typeof data === 'string' || typeof data === 'number') {
|
|
@@ -902,15 +913,8 @@ export default class SelectComponent extends ListComponent {
|
|
|
902
913
|
if (!input) {
|
|
903
914
|
return;
|
|
904
915
|
}
|
|
905
|
-
this.addEventListener(input, this.inputInfo.changeEvent, (
|
|
906
|
-
|
|
907
|
-
if (this.component.widget === "html5") {
|
|
908
|
-
value = event.target.value;
|
|
909
|
-
if (this.component.multiple) {
|
|
910
|
-
value = Array.from(event.target.selectedOptions).map(opt => opt.value);
|
|
911
|
-
}
|
|
912
|
-
}
|
|
913
|
-
this.updateValue(value, {
|
|
916
|
+
this.addEventListener(input, this.inputInfo.changeEvent, () => {
|
|
917
|
+
this.updateValue(null, {
|
|
914
918
|
modified: true
|
|
915
919
|
});
|
|
916
920
|
});
|
|
@@ -1223,14 +1227,20 @@ export default class SelectComponent extends ListComponent {
|
|
|
1223
1227
|
}
|
|
1224
1228
|
}
|
|
1225
1229
|
else if (this.refs.selectContainer) {
|
|
1226
|
-
value = this.refs.selectContainer.value;
|
|
1227
|
-
if (this.valueProperty === '' || this.isEntireObjectDisplay()) {
|
|
1230
|
+
value = this.component.multiple ? value : this.refs.selectContainer.value;
|
|
1231
|
+
if (this.valueProperty === '' || this.isEntireObjectDisplay() || this.component.multiple) {
|
|
1228
1232
|
if (value === '') {
|
|
1229
1233
|
return {};
|
|
1230
1234
|
}
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1235
|
+
if (!this.component.multiple) {
|
|
1236
|
+
const option = this.selectOptions[value] || this.selectOptions.find((option) => option.id === value);
|
|
1237
|
+
if (option && _.isObject(option.value)) {
|
|
1238
|
+
value = option.value;
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
else {
|
|
1242
|
+
const options = this.selectOptions.filter((option) => option.element.selected);
|
|
1243
|
+
value = options.map((option) => option.value);
|
|
1234
1244
|
}
|
|
1235
1245
|
}
|
|
1236
1246
|
}
|
|
@@ -140,7 +140,7 @@ export default class SelectBoxesComponent extends RadioComponent {
|
|
|
140
140
|
if (this.isSelectURL &&
|
|
141
141
|
this.templateData &&
|
|
142
142
|
_.every(checkedValues, (val) => this.templateData[val])) {
|
|
143
|
-
const submission = this.root
|
|
143
|
+
const submission = this.root?.submission;
|
|
144
144
|
if (!submission.metadata.selectData) {
|
|
145
145
|
submission.metadata.selectData = {};
|
|
146
146
|
}
|
|
@@ -122,7 +122,7 @@ export default class TableComponent extends NestedComponent {
|
|
|
122
122
|
}
|
|
123
123
|
else if (lastNonEmptyRow[colIndex]) {
|
|
124
124
|
column.components = _.cloneDeep(lastNonEmptyRow[colIndex].components);
|
|
125
|
-
BuilderUtils.uniquify(this.root
|
|
125
|
+
BuilderUtils.uniquify(this.root?._form.components, column);
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
_.each(column.components, (comp) => {
|
|
@@ -145,7 +145,7 @@ export default class TabsComponent extends NestedComponent {
|
|
|
145
145
|
this.addClass(this.refs[this.tabLinkKey][index], 'formio-tab-link-active');
|
|
146
146
|
}
|
|
147
147
|
this.setValue(this.data);
|
|
148
|
-
this.triggerChange();
|
|
148
|
+
this.triggerChange?.();
|
|
149
149
|
}
|
|
150
150
|
beforeFocus(component) {
|
|
151
151
|
if ('beforeFocus' in this.parent) {
|
|
@@ -121,8 +121,15 @@ export default class TextFieldComponent extends Input {
|
|
|
121
121
|
}
|
|
122
122
|
// If no value is provided, then set the defaultValue.
|
|
123
123
|
if (!value.value) {
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
let defaultValue = flags.noDefault ? this.emptyValue : this.defaultValue;
|
|
125
|
+
if (Array.isArray(defaultValue)) {
|
|
126
|
+
defaultValue = defaultValue[0];
|
|
127
|
+
}
|
|
128
|
+
// Extract string if defaultValue is a mask object to prevent nesting
|
|
129
|
+
if (defaultValue && typeof defaultValue === 'object' && defaultValue.hasOwnProperty('value')) {
|
|
130
|
+
defaultValue = defaultValue.value;
|
|
131
|
+
}
|
|
132
|
+
value.value = defaultValue;
|
|
126
133
|
}
|
|
127
134
|
return value;
|
|
128
135
|
}
|
package/lib/mjs/package.json
CHANGED
package/lib/mjs/utils/index.d.ts
CHANGED
|
@@ -150,6 +150,7 @@ declare const FormioUtils: {
|
|
|
150
150
|
getFocusableElements(element: HTMLElement): NodeList<HTMLElement>;
|
|
151
151
|
getComponentSavedTypes(fullSchema: import("@formio/core").Component): string[] | null;
|
|
152
152
|
hasEncodedTimezone(value: string): boolean;
|
|
153
|
+
screenReaderSpeech(text: string): void;
|
|
153
154
|
firstNonNil: any;
|
|
154
155
|
componentValueTypes: {
|
|
155
156
|
number: string;
|
package/lib/mjs/utils/utils.d.ts
CHANGED
|
@@ -499,6 +499,11 @@ export function getComponentSavedTypes(fullSchema: import('@formio/core').Compon
|
|
|
499
499
|
* @returns {boolean} if value has encoded timezone
|
|
500
500
|
*/
|
|
501
501
|
export function hasEncodedTimezone(value: string): boolean;
|
|
502
|
+
/**
|
|
503
|
+
* Outputs text to screen reader
|
|
504
|
+
* @param {string} text The text to output to screen readers
|
|
505
|
+
*/
|
|
506
|
+
export function screenReaderSpeech(text: string): void;
|
|
502
507
|
/**
|
|
503
508
|
* Map values through unfold and return first non-nil value.
|
|
504
509
|
* @param {Array<T>} collection - The collection to map through unfold.;
|
package/lib/mjs/utils/utils.js
CHANGED
|
@@ -1619,3 +1619,19 @@ export function hasEncodedTimezone(value) {
|
|
|
1619
1619
|
value.substring(value.length - 1) === 'Z' ||
|
|
1620
1620
|
value.match(/[+|-][0-9]{2}:[0-9]{2}$/));
|
|
1621
1621
|
}
|
|
1622
|
+
/**
|
|
1623
|
+
* Outputs text to screen reader
|
|
1624
|
+
* @param {string} text The text to output to screen readers
|
|
1625
|
+
*/
|
|
1626
|
+
export function screenReaderSpeech(text) {
|
|
1627
|
+
const ariaSpeechElement = document.createElement('div');
|
|
1628
|
+
ariaSpeechElement.setAttribute("style", "border: 0;clip: rect(0 0 0 0);height: 1px;margin: -1px;overflow: hidden;padding: 0;position: absolute;width: 1px;white-space: nowrap;");
|
|
1629
|
+
document.body.append(ariaSpeechElement);
|
|
1630
|
+
ariaSpeechElement.ariaLive = 'assertive';
|
|
1631
|
+
setTimeout(() => {
|
|
1632
|
+
ariaSpeechElement.textContent = text;
|
|
1633
|
+
setTimeout(() => {
|
|
1634
|
+
ariaSpeechElement.remove();
|
|
1635
|
+
}, 1000);
|
|
1636
|
+
}, 100);
|
|
1637
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formio/js",
|
|
3
|
-
"version": "5.3.0
|
|
3
|
+
"version": "5.3.0",
|
|
4
4
|
"description": "JavaScript powered Forms with JSON Form Builder",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -88,8 +88,8 @@
|
|
|
88
88
|
"tippy.js": "^6.3.7",
|
|
89
89
|
"uuid": "^9.0.0",
|
|
90
90
|
"vanilla-picker": "^2.12.3",
|
|
91
|
-
"@formio/
|
|
92
|
-
"@formio/
|
|
91
|
+
"@formio/core": "^2.6.0",
|
|
92
|
+
"@formio/bootstrap": "^3.2.0"
|
|
93
93
|
},
|
|
94
94
|
"devDependencies": {
|
|
95
95
|
"@types/node": "^22.15.19",
|