@formio/js 5.0.0-rc.22 → 5.0.0-rc.23
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 +2 -0
- package/dist/formio.builder.min.css +1 -1
- package/dist/formio.embed.min.js.LICENSE.txt +1 -1
- package/dist/formio.form.css +2 -0
- package/dist/formio.form.js +8 -8
- 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 +2 -0
- package/dist/formio.full.js +8 -8
- 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 +1 -1
- 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.LICENSE.txt +1 -1
- package/lib/cjs/components/_classes/component/Component.js +3 -3
- package/lib/cjs/components/_classes/field/Field.d.ts +1 -0
- package/lib/cjs/components/_classes/field/Field.js +14 -0
- package/lib/cjs/components/_classes/multivalue/Multivalue.d.ts +0 -1
- package/lib/cjs/components/_classes/multivalue/Multivalue.js +0 -14
- package/lib/cjs/components/day/Day.d.ts +0 -1
- package/lib/cjs/components/day/Day.js +34 -14
- package/lib/cjs/components/day/fixtures/comp6.d.ts +81 -0
- package/lib/cjs/components/day/fixtures/comp6.js +76 -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/utils/utils.js +3 -3
- package/lib/mjs/components/_classes/component/Component.js +3 -3
- package/lib/mjs/components/_classes/field/Field.d.ts +1 -0
- package/lib/mjs/components/_classes/field/Field.js +13 -0
- package/lib/mjs/components/_classes/multivalue/Multivalue.d.ts +0 -1
- package/lib/mjs/components/_classes/multivalue/Multivalue.js +0 -13
- package/lib/mjs/components/day/Day.d.ts +0 -1
- package/lib/mjs/components/day/Day.js +33 -14
- package/lib/mjs/components/day/fixtures/comp6.d.ts +81 -0
- package/lib/mjs/components/day/fixtures/comp6.js +74 -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/utils/utils.js +3 -3
- package/package.json +2 -2
@@ -0,0 +1,76 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.default = {
|
4
|
+
type: 'form',
|
5
|
+
display: 'form',
|
6
|
+
components: [
|
7
|
+
{
|
8
|
+
label: 'Text Field',
|
9
|
+
applyMaskOn: 'change',
|
10
|
+
tableView: true,
|
11
|
+
key: 'textField',
|
12
|
+
type: 'textfield',
|
13
|
+
input: true,
|
14
|
+
},
|
15
|
+
{
|
16
|
+
label: 'Day',
|
17
|
+
hideInputLabels: false,
|
18
|
+
inputsLabelPosition: 'top',
|
19
|
+
useLocaleSettings: false,
|
20
|
+
tableView: false,
|
21
|
+
fields: {
|
22
|
+
day: {
|
23
|
+
hide: true,
|
24
|
+
},
|
25
|
+
month: {
|
26
|
+
hide: false,
|
27
|
+
},
|
28
|
+
year: {
|
29
|
+
hide: false,
|
30
|
+
},
|
31
|
+
},
|
32
|
+
defaultValue: '00/00/0000',
|
33
|
+
key: 'day',
|
34
|
+
logic: [
|
35
|
+
{
|
36
|
+
name: 'Disable when Test is empty',
|
37
|
+
trigger: {
|
38
|
+
type: 'simple',
|
39
|
+
simple: {
|
40
|
+
show: true,
|
41
|
+
conjunction: 'all',
|
42
|
+
conditions: [
|
43
|
+
{
|
44
|
+
component: 'textField',
|
45
|
+
operator: 'isEmpty',
|
46
|
+
},
|
47
|
+
],
|
48
|
+
},
|
49
|
+
},
|
50
|
+
actions: [
|
51
|
+
{
|
52
|
+
name: 'Disable',
|
53
|
+
type: 'property',
|
54
|
+
property: {
|
55
|
+
label: 'Disabled',
|
56
|
+
value: 'disabled',
|
57
|
+
type: 'boolean',
|
58
|
+
},
|
59
|
+
state: true,
|
60
|
+
},
|
61
|
+
],
|
62
|
+
},
|
63
|
+
],
|
64
|
+
type: 'day',
|
65
|
+
input: true,
|
66
|
+
},
|
67
|
+
{
|
68
|
+
type: 'button',
|
69
|
+
label: 'Submit',
|
70
|
+
key: 'submit',
|
71
|
+
disableOnInvalid: true,
|
72
|
+
input: true,
|
73
|
+
tableView: false,
|
74
|
+
},
|
75
|
+
],
|
76
|
+
};
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.comp5 = exports.comp4 = exports.comp3 = exports.comp2 = exports.comp1 = void 0;
|
6
|
+
exports.comp6 = exports.comp5 = exports.comp4 = exports.comp3 = exports.comp2 = exports.comp1 = void 0;
|
7
7
|
const comp1_1 = __importDefault(require("./comp1"));
|
8
8
|
exports.comp1 = comp1_1.default;
|
9
9
|
const comp2_1 = __importDefault(require("./comp2"));
|
@@ -14,3 +14,5 @@ const comp4_1 = __importDefault(require("./comp4"));
|
|
14
14
|
exports.comp4 = comp4_1.default;
|
15
15
|
const comp5_1 = __importDefault(require("./comp5"));
|
16
16
|
exports.comp5 = comp5_1.default;
|
17
|
+
const comp6_1 = __importDefault(require("./comp6"));
|
18
|
+
exports.comp6 = comp6_1.default;
|
package/lib/cjs/utils/utils.js
CHANGED
@@ -258,9 +258,9 @@ function checkSimpleConditional(component, condition, row, data, instance) {
|
|
258
258
|
return true;
|
259
259
|
}
|
260
260
|
const value = getComponentActualValue(conditionComponentPath, data, row);
|
261
|
-
const
|
262
|
-
return
|
263
|
-
? new
|
261
|
+
const ConditionOperator = conditionOperators_1.default[operator];
|
262
|
+
return ConditionOperator
|
263
|
+
? new ConditionOperator().getResult({ value, comparedValue, instance, component, conditionComponentPath })
|
264
264
|
: true;
|
265
265
|
});
|
266
266
|
let result = false;
|
@@ -1506,16 +1506,16 @@ export default class Component extends Element {
|
|
1506
1506
|
if (this.refs.input?.length) {
|
1507
1507
|
const { selection, index } = this.root.currentSelection;
|
1508
1508
|
let input = this.refs.input[index];
|
1509
|
-
const isInputRangeSelectable = /text|search|password|tel|url/i.test(
|
1509
|
+
const isInputRangeSelectable = (i) => /text|search|password|tel|url/i.test(i?.type || '');
|
1510
1510
|
if (input) {
|
1511
|
-
if (isInputRangeSelectable) {
|
1511
|
+
if (isInputRangeSelectable(input)) {
|
1512
1512
|
input.setSelectionRange(...selection);
|
1513
1513
|
}
|
1514
1514
|
}
|
1515
1515
|
else {
|
1516
1516
|
input = this.refs.input[this.refs.input.length];
|
1517
1517
|
const lastCharacter = input.value?.length || 0;
|
1518
|
-
if (isInputRangeSelectable) {
|
1518
|
+
if (isInputRangeSelectable(input)) {
|
1519
1519
|
input.setSelectionRange(lastCharacter, lastCharacter);
|
1520
1520
|
}
|
1521
1521
|
}
|
@@ -18,4 +18,17 @@ export default class Field extends Component {
|
|
18
18
|
}));
|
19
19
|
}
|
20
20
|
}
|
21
|
+
// Saves current caret position to restore it after the component is redrawn
|
22
|
+
saveCaretPosition(element, index) {
|
23
|
+
if (this.root?.focusedComponent?.path === this.path) {
|
24
|
+
try {
|
25
|
+
this.root.currentSelection = { selection: [element.selectionStart, element.selectionEnd], index };
|
26
|
+
}
|
27
|
+
catch (e) {
|
28
|
+
if (!(e instanceof DOMException)) {
|
29
|
+
console.debug(e);
|
30
|
+
}
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}
|
21
34
|
}
|
@@ -12,7 +12,6 @@ export default class Multivalue extends Field {
|
|
12
12
|
* @param index
|
13
13
|
*/
|
14
14
|
attachElement(element: any, index: any): void;
|
15
|
-
saveCaretPosition(element: any, index: any): void;
|
16
15
|
onSelectMaskHandler(event: any): void;
|
17
16
|
getMaskPattern(maskName: any): any;
|
18
17
|
multiMasks: {} | undefined;
|
@@ -177,19 +177,6 @@ export default class Multivalue extends Field {
|
|
177
177
|
}
|
178
178
|
}
|
179
179
|
}
|
180
|
-
// Saves current caret position to restore it after the component is redrawn
|
181
|
-
saveCaretPosition(element, index) {
|
182
|
-
if (this.root?.focusedComponent?.path === this.path) {
|
183
|
-
try {
|
184
|
-
this.root.currentSelection = { selection: [element.selectionStart, element.selectionEnd], index };
|
185
|
-
}
|
186
|
-
catch (e) {
|
187
|
-
if (!(e instanceof DOMException)) {
|
188
|
-
console.debug(e);
|
189
|
-
}
|
190
|
-
}
|
191
|
-
}
|
192
|
-
}
|
193
180
|
onSelectMaskHandler(event) {
|
194
181
|
this.updateMask(event.target.maskInput, this.getMaskPattern(event.target.value));
|
195
182
|
}
|
@@ -1,7 +1,6 @@
|
|
1
1
|
import _ from 'lodash';
|
2
2
|
import moment from 'moment';
|
3
3
|
import Field from '../_classes/field/Field';
|
4
|
-
import Input from '../_classes/input/Input';
|
5
4
|
import { boolValue, componentValueTypes, getComponentSavedTypes, getLocaleDateFormatInfo } from '../../utils/utils';
|
6
5
|
export default class DayComponent extends Field {
|
7
6
|
static schema(...extend) {
|
@@ -256,6 +255,17 @@ export default class DayComponent extends Field {
|
|
256
255
|
attach(element) {
|
257
256
|
this.loadRefs(element, { day: 'single', month: 'single', year: 'single', input: 'multiple' });
|
258
257
|
const superAttach = super.attach(element);
|
258
|
+
const updateValueAndSaveFocus = (element, name) => () => {
|
259
|
+
try {
|
260
|
+
this.saveCaretPosition(element, name);
|
261
|
+
}
|
262
|
+
catch (err) {
|
263
|
+
console.warn('An error occurred while trying to save caret position', err);
|
264
|
+
}
|
265
|
+
this.updateValue(null, {
|
266
|
+
modified: true,
|
267
|
+
});
|
268
|
+
};
|
259
269
|
if (this.shouldDisabled) {
|
260
270
|
this.setDisabled(this.refs.day, true);
|
261
271
|
this.setDisabled(this.refs.month, true);
|
@@ -265,9 +275,7 @@ export default class DayComponent extends Field {
|
|
265
275
|
}
|
266
276
|
}
|
267
277
|
else {
|
268
|
-
this.addEventListener(this.refs.day, 'input', (
|
269
|
-
modified: true
|
270
|
-
}));
|
278
|
+
this.addEventListener(this.refs.day, 'input', updateValueAndSaveFocus(this.refs.day, 'day'));
|
271
279
|
// TODO: Need to rework this to work with day select as well.
|
272
280
|
// Change day max input when month changes.
|
273
281
|
this.addEventListener(this.refs.month, 'input', () => {
|
@@ -280,18 +288,14 @@ export default class DayComponent extends Field {
|
|
280
288
|
if (maxDay && day > maxDay) {
|
281
289
|
this.refs.day.value = this.refs.day.max;
|
282
290
|
}
|
283
|
-
this.
|
284
|
-
modified: true
|
285
|
-
});
|
291
|
+
updateValueAndSaveFocus(this.refs.month, 'month')();
|
286
292
|
});
|
287
|
-
this.addEventListener(this.refs.year, 'input', (
|
288
|
-
modified: true
|
289
|
-
}));
|
293
|
+
this.addEventListener(this.refs.year, 'input', updateValueAndSaveFocus(this.refs.year, 'year'));
|
290
294
|
this.addEventListener(this.refs.input, this.info.changeEvent, () => this.updateValue(null, {
|
291
295
|
modified: true
|
292
296
|
}));
|
293
|
-
[this.refs.day, this.refs.month, this.refs.year].forEach((element) => {
|
294
|
-
|
297
|
+
[this.refs.day, this.refs.month, this.refs.year].filter((element) => !!element).forEach((element) => {
|
298
|
+
super.addFocusBlurEvents(element);
|
295
299
|
});
|
296
300
|
}
|
297
301
|
this.setValue(this.dataValue);
|
@@ -524,8 +528,11 @@ export default class DayComponent extends Field {
|
|
524
528
|
getValueAsString(value) {
|
525
529
|
return this.getDate(value) || '';
|
526
530
|
}
|
527
|
-
focus() {
|
528
|
-
if (
|
531
|
+
focus(field) {
|
532
|
+
if (field && typeof field === 'string' && this.refs[field]) {
|
533
|
+
this.refs[field].focus();
|
534
|
+
}
|
535
|
+
else if (this.dayFirst && this.showDay || !this.dayFirst && !this.showMonth && this.showDay) {
|
529
536
|
this.refs.day?.focus();
|
530
537
|
}
|
531
538
|
else if (this.dayFirst && !this.showDay && this.showMonth || !this.dayFirst && this.showMonth) {
|
@@ -535,6 +542,18 @@ export default class DayComponent extends Field {
|
|
535
542
|
this.refs.year?.focus();
|
536
543
|
}
|
537
544
|
}
|
545
|
+
restoreCaretPosition() {
|
546
|
+
if (this.root?.currentSelection) {
|
547
|
+
const { selection, index } = this.root.currentSelection;
|
548
|
+
if (this.refs[index]) {
|
549
|
+
const input = this.refs[index];
|
550
|
+
const isInputRangeSelectable = (i) => /text|search|password|tel|url/i.test(i?.type || '');
|
551
|
+
if (isInputRangeSelectable(input)) {
|
552
|
+
input.setSelectionRange(...selection);
|
553
|
+
}
|
554
|
+
}
|
555
|
+
}
|
556
|
+
}
|
538
557
|
isPartialDay(value) {
|
539
558
|
if (!value) {
|
540
559
|
return false;
|
@@ -0,0 +1,81 @@
|
|
1
|
+
declare namespace _default {
|
2
|
+
const type: string;
|
3
|
+
const display: string;
|
4
|
+
const components: ({
|
5
|
+
label: string;
|
6
|
+
applyMaskOn: string;
|
7
|
+
tableView: boolean;
|
8
|
+
key: string;
|
9
|
+
type: string;
|
10
|
+
input: boolean;
|
11
|
+
hideInputLabels?: undefined;
|
12
|
+
inputsLabelPosition?: undefined;
|
13
|
+
useLocaleSettings?: undefined;
|
14
|
+
fields?: undefined;
|
15
|
+
defaultValue?: undefined;
|
16
|
+
logic?: undefined;
|
17
|
+
disableOnInvalid?: undefined;
|
18
|
+
} | {
|
19
|
+
label: string;
|
20
|
+
hideInputLabels: boolean;
|
21
|
+
inputsLabelPosition: string;
|
22
|
+
useLocaleSettings: boolean;
|
23
|
+
tableView: boolean;
|
24
|
+
fields: {
|
25
|
+
day: {
|
26
|
+
hide: boolean;
|
27
|
+
};
|
28
|
+
month: {
|
29
|
+
hide: boolean;
|
30
|
+
};
|
31
|
+
year: {
|
32
|
+
hide: boolean;
|
33
|
+
};
|
34
|
+
};
|
35
|
+
defaultValue: string;
|
36
|
+
key: string;
|
37
|
+
logic: {
|
38
|
+
name: string;
|
39
|
+
trigger: {
|
40
|
+
type: string;
|
41
|
+
simple: {
|
42
|
+
show: boolean;
|
43
|
+
conjunction: string;
|
44
|
+
conditions: {
|
45
|
+
component: string;
|
46
|
+
operator: string;
|
47
|
+
}[];
|
48
|
+
};
|
49
|
+
};
|
50
|
+
actions: {
|
51
|
+
name: string;
|
52
|
+
type: string;
|
53
|
+
property: {
|
54
|
+
label: string;
|
55
|
+
value: string;
|
56
|
+
type: string;
|
57
|
+
};
|
58
|
+
state: boolean;
|
59
|
+
}[];
|
60
|
+
}[];
|
61
|
+
type: string;
|
62
|
+
input: boolean;
|
63
|
+
applyMaskOn?: undefined;
|
64
|
+
disableOnInvalid?: undefined;
|
65
|
+
} | {
|
66
|
+
type: string;
|
67
|
+
label: string;
|
68
|
+
key: string;
|
69
|
+
disableOnInvalid: boolean;
|
70
|
+
input: boolean;
|
71
|
+
tableView: boolean;
|
72
|
+
applyMaskOn?: undefined;
|
73
|
+
hideInputLabels?: undefined;
|
74
|
+
inputsLabelPosition?: undefined;
|
75
|
+
useLocaleSettings?: undefined;
|
76
|
+
fields?: undefined;
|
77
|
+
defaultValue?: undefined;
|
78
|
+
logic?: undefined;
|
79
|
+
})[];
|
80
|
+
}
|
81
|
+
export default _default;
|
@@ -0,0 +1,74 @@
|
|
1
|
+
export default {
|
2
|
+
type: 'form',
|
3
|
+
display: 'form',
|
4
|
+
components: [
|
5
|
+
{
|
6
|
+
label: 'Text Field',
|
7
|
+
applyMaskOn: 'change',
|
8
|
+
tableView: true,
|
9
|
+
key: 'textField',
|
10
|
+
type: 'textfield',
|
11
|
+
input: true,
|
12
|
+
},
|
13
|
+
{
|
14
|
+
label: 'Day',
|
15
|
+
hideInputLabels: false,
|
16
|
+
inputsLabelPosition: 'top',
|
17
|
+
useLocaleSettings: false,
|
18
|
+
tableView: false,
|
19
|
+
fields: {
|
20
|
+
day: {
|
21
|
+
hide: true,
|
22
|
+
},
|
23
|
+
month: {
|
24
|
+
hide: false,
|
25
|
+
},
|
26
|
+
year: {
|
27
|
+
hide: false,
|
28
|
+
},
|
29
|
+
},
|
30
|
+
defaultValue: '00/00/0000',
|
31
|
+
key: 'day',
|
32
|
+
logic: [
|
33
|
+
{
|
34
|
+
name: 'Disable when Test is empty',
|
35
|
+
trigger: {
|
36
|
+
type: 'simple',
|
37
|
+
simple: {
|
38
|
+
show: true,
|
39
|
+
conjunction: 'all',
|
40
|
+
conditions: [
|
41
|
+
{
|
42
|
+
component: 'textField',
|
43
|
+
operator: 'isEmpty',
|
44
|
+
},
|
45
|
+
],
|
46
|
+
},
|
47
|
+
},
|
48
|
+
actions: [
|
49
|
+
{
|
50
|
+
name: 'Disable',
|
51
|
+
type: 'property',
|
52
|
+
property: {
|
53
|
+
label: 'Disabled',
|
54
|
+
value: 'disabled',
|
55
|
+
type: 'boolean',
|
56
|
+
},
|
57
|
+
state: true,
|
58
|
+
},
|
59
|
+
],
|
60
|
+
},
|
61
|
+
],
|
62
|
+
type: 'day',
|
63
|
+
input: true,
|
64
|
+
},
|
65
|
+
{
|
66
|
+
type: 'button',
|
67
|
+
label: 'Submit',
|
68
|
+
key: 'submit',
|
69
|
+
disableOnInvalid: true,
|
70
|
+
input: true,
|
71
|
+
tableView: false,
|
72
|
+
},
|
73
|
+
],
|
74
|
+
};
|
package/lib/mjs/utils/utils.js
CHANGED
@@ -214,9 +214,9 @@ export function checkSimpleConditional(component, condition, row, data, instance
|
|
214
214
|
return true;
|
215
215
|
}
|
216
216
|
const value = getComponentActualValue(conditionComponentPath, data, row);
|
217
|
-
const
|
218
|
-
return
|
219
|
-
? new
|
217
|
+
const ConditionOperator = ConditionOperators[operator];
|
218
|
+
return ConditionOperator
|
219
|
+
? new ConditionOperator().getResult({ value, comparedValue, instance, component, conditionComponentPath })
|
220
220
|
: true;
|
221
221
|
});
|
222
222
|
let result = false;
|
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.23",
|
4
4
|
"description": "JavaScript powered Forms with JSON Form Builder",
|
5
5
|
"main": "lib/cjs/index.js",
|
6
6
|
"module": "lib/mjs/index.js",
|
@@ -51,7 +51,7 @@
|
|
51
51
|
"invalidate": "VERSION=$(yarn version);aws cloudfront create-invalidation --distribution-id E1MXNA5A4ZKRMZ --paths \"/$VERSION/*\"",
|
52
52
|
"release": "yarn build-app && yarn deploy-s3",
|
53
53
|
"tag": "VERSION=$(yarn version);git add -A; git commit -m \"Build $Version\";git push origin master;git tag v$VERSION;git push origin --tags;",
|
54
|
-
"dopublish": "npm
|
54
|
+
"dopublish": "npm run build && npm run tag && npm publish",
|
55
55
|
"lint": "gulp eslint",
|
56
56
|
"serve": "jekyll serve --config _config.yml,_config.dev.yml",
|
57
57
|
"test": "mocha 'src/**/*.unit.js'",
|