@formio/js 5.0.0-dev.5759.a3476ed → 5.0.0-dev.5760.bdc64e2

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.
@@ -30,7 +30,8 @@ class DayComponent extends Field_1.default {
30
30
  required: false
31
31
  }
32
32
  },
33
- dayFirst: false
33
+ dayFirst: false,
34
+ defaultValue: ''
34
35
  }, ...extend);
35
36
  }
36
37
  static get builderInfo() {
@@ -343,15 +344,21 @@ class DayComponent extends Field_1.default {
343
344
  const valueParts = value.split('/');
344
345
  const [DAY, MONTH, YEAR] = this.component.dayFirst ? [0, 1, 2] : [1, 0, 2];
345
346
  const defaultValue = this.component.defaultValue ? this.component.defaultValue.split('/') : '';
346
- const getNextPart = (shouldTake, defaultValue) => dateParts.push(shouldTake ? valueParts.shift() : defaultValue);
347
+ const getNextPart = (shouldTake, defaultValue) => {
348
+ // Only push the part if it's not an empty string
349
+ const part = shouldTake ? valueParts.shift() : defaultValue;
350
+ if (part !== '') {
351
+ dateParts.push(part);
352
+ }
353
+ };
347
354
  if (this.dayFirst) {
348
- getNextPart(this.showDay, defaultValue ? defaultValue[DAY] : '00');
355
+ getNextPart(this.showDay, defaultValue ? defaultValue[DAY] : '');
349
356
  }
350
- getNextPart(this.showMonth, defaultValue ? defaultValue[MONTH] : '00');
357
+ getNextPart(this.showMonth, defaultValue ? defaultValue[MONTH] : '');
351
358
  if (!this.dayFirst) {
352
- getNextPart(this.showDay, defaultValue ? defaultValue[DAY] : '00');
359
+ getNextPart(this.showDay, defaultValue ? defaultValue[DAY] : '');
353
360
  }
354
- getNextPart(this.showYear, defaultValue ? defaultValue[YEAR] : '0000');
361
+ getNextPart(this.showYear, defaultValue ? defaultValue[YEAR] : '');
355
362
  return dateParts.join('/');
356
363
  }
357
364
  /**
@@ -558,7 +565,13 @@ class DayComponent extends Field_1.default {
558
565
  }
559
566
  const [DAY, MONTH, YEAR] = this.component.dayFirst ? [0, 1, 2] : [1, 0, 2];
560
567
  const values = value.split('/');
561
- return (values[DAY] === '00' || values[MONTH] === '00' || values[YEAR] === '0000');
568
+ // return (values[DAY] === '00' || values[MONTH] === '00' || values[YEAR] === '0000');
569
+ return (values[DAY] === '00' ||
570
+ values[MONTH] === '00' ||
571
+ values[YEAR] === '0000' ||
572
+ values[DAY] === '' ||
573
+ values[MONTH] === '' ||
574
+ values[YEAR] === '');
562
575
  }
563
576
  getValidationFormat() {
564
577
  return this.dayFirst ? 'DD-MM-YYYY' : 'MM-DD-YYYY';
@@ -7,6 +7,7 @@ declare const _default: ({
7
7
  placeholder: string;
8
8
  weight: number;
9
9
  conditional?: undefined;
10
+ customConditional?: undefined;
10
11
  ignore?: undefined;
11
12
  } | {
12
13
  type: string;
@@ -23,6 +24,7 @@ declare const _default: ({
23
24
  };
24
25
  };
25
26
  weight: number;
27
+ customConditional?: undefined;
26
28
  ignore?: undefined;
27
29
  } | {
28
30
  weight: number;
@@ -30,6 +32,9 @@ declare const _default: ({
30
32
  label: string;
31
33
  tooltip: string;
32
34
  key: string;
35
+ customConditional: ({ options }: {
36
+ options: any;
37
+ }) => boolean;
33
38
  input: boolean;
34
39
  placeholder?: undefined;
35
40
  conditional?: undefined;
@@ -44,5 +49,6 @@ declare const _default: ({
44
49
  placeholder?: undefined;
45
50
  weight?: undefined;
46
51
  conditional?: undefined;
52
+ customConditional?: undefined;
47
53
  })[];
48
54
  export default _default;
@@ -39,6 +39,7 @@ exports.default = [
39
39
  label: 'Keep Overlay Aspect Ratio',
40
40
  tooltip: 'If checked, the field will have the same aspect ratio as its preview.',
41
41
  key: 'keepOverlayRatio',
42
+ customConditional: ({ options }) => { var _a; return (((_a = options === null || options === void 0 ? void 0 : options.editForm) === null || _a === void 0 ? void 0 : _a.display) === 'pdf'); },
42
43
  input: true
43
44
  },
44
45
  {
@@ -25,7 +25,8 @@ export default class DayComponent extends Field {
25
25
  required: false
26
26
  }
27
27
  },
28
- dayFirst: false
28
+ dayFirst: false,
29
+ defaultValue: ''
29
30
  }, ...extend);
30
31
  }
31
32
  static get builderInfo() {
@@ -341,15 +342,21 @@ export default class DayComponent extends Field {
341
342
  const valueParts = value.split('/');
342
343
  const [DAY, MONTH, YEAR] = this.component.dayFirst ? [0, 1, 2] : [1, 0, 2];
343
344
  const defaultValue = this.component.defaultValue ? this.component.defaultValue.split('/') : '';
344
- const getNextPart = (shouldTake, defaultValue) => dateParts.push(shouldTake ? valueParts.shift() : defaultValue);
345
+ const getNextPart = (shouldTake, defaultValue) => {
346
+ // Only push the part if it's not an empty string
347
+ const part = shouldTake ? valueParts.shift() : defaultValue;
348
+ if (part !== '') {
349
+ dateParts.push(part);
350
+ }
351
+ };
345
352
  if (this.dayFirst) {
346
- getNextPart(this.showDay, defaultValue ? defaultValue[DAY] : '00');
353
+ getNextPart(this.showDay, defaultValue ? defaultValue[DAY] : '');
347
354
  }
348
- getNextPart(this.showMonth, defaultValue ? defaultValue[MONTH] : '00');
355
+ getNextPart(this.showMonth, defaultValue ? defaultValue[MONTH] : '');
349
356
  if (!this.dayFirst) {
350
- getNextPart(this.showDay, defaultValue ? defaultValue[DAY] : '00');
357
+ getNextPart(this.showDay, defaultValue ? defaultValue[DAY] : '');
351
358
  }
352
- getNextPart(this.showYear, defaultValue ? defaultValue[YEAR] : '0000');
359
+ getNextPart(this.showYear, defaultValue ? defaultValue[YEAR] : '');
353
360
  return dateParts.join('/');
354
361
  }
355
362
  /**
@@ -554,7 +561,13 @@ export default class DayComponent extends Field {
554
561
  }
555
562
  const [DAY, MONTH, YEAR] = this.component.dayFirst ? [0, 1, 2] : [1, 0, 2];
556
563
  const values = value.split('/');
557
- return (values[DAY] === '00' || values[MONTH] === '00' || values[YEAR] === '0000');
564
+ // return (values[DAY] === '00' || values[MONTH] === '00' || values[YEAR] === '0000');
565
+ return (values[DAY] === '00' ||
566
+ values[MONTH] === '00' ||
567
+ values[YEAR] === '0000' ||
568
+ values[DAY] === '' ||
569
+ values[MONTH] === '' ||
570
+ values[YEAR] === '');
558
571
  }
559
572
  getValidationFormat() {
560
573
  return this.dayFirst ? 'DD-MM-YYYY' : 'MM-DD-YYYY';
@@ -7,6 +7,7 @@ declare const _default: ({
7
7
  placeholder: string;
8
8
  weight: number;
9
9
  conditional?: undefined;
10
+ customConditional?: undefined;
10
11
  ignore?: undefined;
11
12
  } | {
12
13
  type: string;
@@ -23,6 +24,7 @@ declare const _default: ({
23
24
  };
24
25
  };
25
26
  weight: number;
27
+ customConditional?: undefined;
26
28
  ignore?: undefined;
27
29
  } | {
28
30
  weight: number;
@@ -30,6 +32,9 @@ declare const _default: ({
30
32
  label: string;
31
33
  tooltip: string;
32
34
  key: string;
35
+ customConditional: ({ options }: {
36
+ options: any;
37
+ }) => boolean;
33
38
  input: boolean;
34
39
  placeholder?: undefined;
35
40
  conditional?: undefined;
@@ -44,5 +49,6 @@ declare const _default: ({
44
49
  placeholder?: undefined;
45
50
  weight?: undefined;
46
51
  conditional?: undefined;
52
+ customConditional?: undefined;
47
53
  })[];
48
54
  export default _default;
@@ -37,6 +37,7 @@ export default [
37
37
  label: 'Keep Overlay Aspect Ratio',
38
38
  tooltip: 'If checked, the field will have the same aspect ratio as its preview.',
39
39
  key: 'keepOverlayRatio',
40
+ customConditional: ({ options }) => (options?.editForm?.display === 'pdf'),
40
41
  input: true
41
42
  },
42
43
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.0.0-dev.5759.a3476ed",
3
+ "version": "5.0.0-dev.5760.bdc64e2",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {