@formio/js 5.1.0-dev.6152.95f2394 → 5.1.0-dev.6155.8178240

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.
@@ -51,5 +51,6 @@ export default class PDFBuilder extends WebformBuilder {
51
51
  onDropzoneDrop(e: any): boolean;
52
52
  dropEvent: any;
53
53
  onDragEnd(e: any): void;
54
+ repeatablePathsComps: any[] | undefined;
54
55
  }
55
56
  import WebformBuilder from './WebformBuilder';
@@ -451,21 +451,21 @@ class PDFBuilder extends WebformBuilder_1.default {
451
451
  e.target.style.cursor = 'default';
452
452
  }
453
453
  highlightInvalidComponents() {
454
- const repeatablePaths = this.findRepeatablePaths();
454
+ const repeatablePathsComps = this.findComponentsWithRepeatablePaths();
455
455
  // update elements which path was duplicated if any pathes have been changed
456
- if (!lodash_1.default.isEqual(this.repeatablePaths, repeatablePaths)) {
457
- (0, utils_1.eachComponent)(this.webform.getComponents(), (comp, path) => {
458
- if (this.repeatablePaths.includes(path)) {
456
+ if (!lodash_1.default.isEqual(this.repeatablePathsComps, repeatablePathsComps)) {
457
+ (0, utils_1.eachComponent)(this.webform.getComponents(), (comp) => {
458
+ if (this.repeatablePathsComps.includes(comp.component)) {
459
459
  this.webform.postMessage({ name: 'updateElement', data: comp.component });
460
460
  }
461
461
  });
462
- this.repeatablePaths = repeatablePaths;
462
+ this.repeatablePathsComps = repeatablePathsComps;
463
463
  }
464
- if (!repeatablePaths.length) {
464
+ if (!repeatablePathsComps.length) {
465
465
  return;
466
466
  }
467
- (0, utils_1.eachComponent)(this.webform.getComponents(), (comp, path) => {
468
- if (this.repeatablePaths.includes(path)) {
467
+ (0, utils_1.eachComponent)(this.webform.getComponents(), (comp) => {
468
+ if (this.repeatablePathsComps.includes(comp)) {
469
469
  this.webform.postMessage({
470
470
  name: 'showBuilderErrors',
471
471
  data: {
@@ -78,7 +78,7 @@ export default class WebformBuilder extends Component {
78
78
  replaceDoubleQuotes(data: any, fieldsToRemoveDoubleQuotes?: any[]): any;
79
79
  updateComponent(component: any, changed: any): void;
80
80
  originalDefaultValue: any;
81
- findRepeatablePaths(): any[];
81
+ findComponentsWithRepeatablePaths(): any[];
82
82
  highlightInvalidComponents(): void;
83
83
  /**
84
84
  * Called when a new component is saved.
@@ -1125,25 +1125,37 @@ class WebformBuilder extends Component_1.default {
1125
1125
  // Called when we update a component.
1126
1126
  this.emit('updateComponent', component);
1127
1127
  }
1128
- findRepeatablePaths() {
1129
- const repeatablePaths = [];
1128
+ findComponentsWithRepeatablePaths() {
1129
+ const repeatablePaths = {};
1130
1130
  const keys = new Map();
1131
1131
  (0, utils_1.eachComponent)(this.form.components, (comp, path, components, parent, paths) => {
1132
+ var _a, _b;
1133
+ const isRadioCheckbox = comp.type === 'checkbox' && comp.inputType === 'radio';
1132
1134
  if (keys.has(paths.dataPath)) {
1133
- repeatablePaths.push(paths.dataPath);
1135
+ const onlyRadioCheckboxes = ((_a = repeatablePaths[paths.dataPath]) === null || _a === void 0 ? void 0 : _a.onlyRadioCheckboxes) === false ? false : isRadioCheckbox;
1136
+ repeatablePaths[paths.dataPath] = {
1137
+ comps: [...(((_b = repeatablePaths[paths.dataPath]) === null || _b === void 0 ? void 0 : _b.comps) || []), keys.get(paths.dataPath), comp],
1138
+ onlyRadioCheckboxes,
1139
+ };
1134
1140
  }
1135
1141
  else {
1136
- keys.set(paths.dataPath, true);
1142
+ keys.set(paths.dataPath, comp);
1137
1143
  }
1138
1144
  }, true);
1139
- return repeatablePaths;
1145
+ const componentsWithRepeatablePaths = [];
1146
+ Object.keys(repeatablePaths).forEach((path) => {
1147
+ const { comps, onlyRadioCheckboxes } = repeatablePaths[path];
1148
+ if (!onlyRadioCheckboxes) {
1149
+ componentsWithRepeatablePaths.push(...comps);
1150
+ }
1151
+ });
1152
+ return componentsWithRepeatablePaths;
1140
1153
  }
1141
1154
  highlightInvalidComponents() {
1142
- const repeatablePaths = this.findRepeatablePaths();
1155
+ const repeatablePathsComps = this.findComponentsWithRepeatablePaths();
1143
1156
  let hasInvalidComponents = false;
1144
1157
  this.webform.everyComponent((comp) => {
1145
- const path = comp.path;
1146
- if (repeatablePaths.includes(path)) {
1158
+ if (repeatablePathsComps.includes(comp.component)) {
1147
1159
  comp.setCustomValidity(this.t('apiKey', { key: comp.key }));
1148
1160
  hasInvalidComponents = true;
1149
1161
  }
@@ -7,7 +7,7 @@ export default class ButtonComponent extends Field {
7
7
  weight: number;
8
8
  schema: any;
9
9
  };
10
- static savedValueTypes(schema: any): any;
10
+ static savedValueTypes(schema: any): string[];
11
11
  constructor(component: any, options: any, data: any);
12
12
  filesUploading: number;
13
13
  get inputInfo(): any;
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const lodash_1 = __importDefault(require("lodash"));
7
7
  const Field_1 = __importDefault(require("../_classes/field/Field"));
8
8
  const Input_1 = __importDefault(require("../_classes/input/Input"));
9
- const formUtils_1 = require("../../utils/formUtils");
9
+ const utils_1 = require("../../utils");
10
10
  class ButtonComponent extends Field_1.default {
11
11
  static schema(...extend) {
12
12
  return Input_1.default.schema({
@@ -35,7 +35,7 @@ class ButtonComponent extends Field_1.default {
35
35
  };
36
36
  }
37
37
  static savedValueTypes(schema) {
38
- return (0, formUtils_1.getComponentSavedTypes)(schema) || [formUtils_1.componentValueTypes.boolean];
38
+ return (0, utils_1.getComponentSavedTypes)(schema) || [utils_1.componentValueTypes.boolean];
39
39
  }
40
40
  constructor(component, options, data) {
41
41
  super(component, options, data);
@@ -306,7 +306,7 @@ class ButtonComponent extends Field_1.default {
306
306
  const form = this.getRoot();
307
307
  const flattened = {};
308
308
  const components = {};
309
- (0, formUtils_1.eachComponent)(form.components, (componentWrapper, path) => {
309
+ (0, utils_1.eachComponent)(form.components, (componentWrapper, path) => {
310
310
  const component = componentWrapper.component || componentWrapper;
311
311
  flattened[path] = component;
312
312
  components[component.key] = component;
@@ -447,7 +447,7 @@ class ButtonComponent extends Field_1.default {
447
447
  }, 100);
448
448
  }
449
449
  get oauthComponentPath() {
450
- const pathArray = (0, formUtils_1.getArrayFromComponentPath)(this.path);
450
+ const pathArray = (0, utils_1.getArrayFromComponentPath)(this.path);
451
451
  return lodash_1.default.chain(pathArray).filter(pathPart => !lodash_1.default.isNumber(pathPart)).join('.').value();
452
452
  }
453
453
  focus() {
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.translateHTMLTemplate = exports.getContextButtons = exports.getContextComponents = exports.observeOverload = exports.withSwitch = exports.firstNonNil = exports.unfold = exports.bootstrapVersion = exports.uniqueKey = exports.iterateKey = exports.delay = exports.fieldData = exports.getCurrencyAffixes = exports.getNumberDecimalLimit = exports.getNumberSeparators = exports.matchInputMask = exports.unmaskValue = exports.getInputMask = exports.convertFormatToMask = exports.convertFormatToDayjs = exports.convertFormatToFlatpickr = exports.getLocaleDateFormatInfo = exports.formatOffset = exports.formatDate = exports.dayjsDate = exports.shouldHandleTimezone = exports.offsetDate = exports.currentTimezone = exports.isValidDate = exports.getDateSetting = exports.guid = exports.uniqueName = exports.convertStringToHTMLElement = exports.unescapeHTML = exports.removeHTML = exports.setActionProperty = exports.checkTrigger = exports.checkCondition = exports.checkJsonConditional = exports.checkCustomConditional = exports.getComponentActualValue = exports.checkSimpleConditional = exports.checkCalculated = exports.isMongoId = exports.boolValue = exports.getScriptPlugin = exports.getElementRect = exports.getPropertyValue = exports.getRandomComponentId = exports.evaluate = void 0;
7
7
  exports.hasEncodedTimezone = exports.interpolateErrors = exports.getComponentSavedTypes = exports.componentValueTypes = exports.getFocusableElements = exports.isPromise = exports.getDataParentComponent = exports.getComponentPath = exports.getComponentPathWithoutIndicies = exports.getBrowserInfo = exports.getIEBrowserVersion = exports.round = exports.getStringFromComponentPath = exports.isChildOf = exports.getArrayFromComponentPath = exports.isInputComponent = exports.fastCloneDeep = exports.sanitize = void 0;
8
+ /* global jQuery */
8
9
  const lodash_1 = __importDefault(require("lodash"));
9
10
  const moment_timezone_1 = __importDefault(require("moment-timezone/moment-timezone"));
10
11
  const jstimezonedetect_1 = __importDefault(require("jstimezonedetect"));
@@ -1056,6 +1057,9 @@ function bootstrapVersion(options) {
1056
1057
  if (options.bootstrap) {
1057
1058
  return options.bootstrap;
1058
1059
  }
1060
+ if ((typeof jQuery === 'function') && (typeof jQuery().collapse === 'function')) {
1061
+ return parseInt(jQuery.fn.collapse.Constructor.VERSION.split('.')[0], 10);
1062
+ }
1059
1063
  if (window.bootstrap && window.bootstrap.Collapse) {
1060
1064
  return parseInt(window.bootstrap.Collapse.VERSION.split('.')[0], 10);
1061
1065
  }
@@ -51,5 +51,6 @@ export default class PDFBuilder extends WebformBuilder {
51
51
  onDropzoneDrop(e: any): boolean;
52
52
  dropEvent: any;
53
53
  onDragEnd(e: any): void;
54
+ repeatablePathsComps: any[] | undefined;
54
55
  }
55
56
  import WebformBuilder from './WebformBuilder';
@@ -444,21 +444,21 @@ export default class PDFBuilder extends WebformBuilder {
444
444
  e.target.style.cursor = 'default';
445
445
  }
446
446
  highlightInvalidComponents() {
447
- const repeatablePaths = this.findRepeatablePaths();
447
+ const repeatablePathsComps = this.findComponentsWithRepeatablePaths();
448
448
  // update elements which path was duplicated if any pathes have been changed
449
- if (!_.isEqual(this.repeatablePaths, repeatablePaths)) {
450
- eachComponent(this.webform.getComponents(), (comp, path) => {
451
- if (this.repeatablePaths.includes(path)) {
449
+ if (!_.isEqual(this.repeatablePathsComps, repeatablePathsComps)) {
450
+ eachComponent(this.webform.getComponents(), (comp) => {
451
+ if (this.repeatablePathsComps.includes(comp.component)) {
452
452
  this.webform.postMessage({ name: 'updateElement', data: comp.component });
453
453
  }
454
454
  });
455
- this.repeatablePaths = repeatablePaths;
455
+ this.repeatablePathsComps = repeatablePathsComps;
456
456
  }
457
- if (!repeatablePaths.length) {
457
+ if (!repeatablePathsComps.length) {
458
458
  return;
459
459
  }
460
- eachComponent(this.webform.getComponents(), (comp, path) => {
461
- if (this.repeatablePaths.includes(path)) {
460
+ eachComponent(this.webform.getComponents(), (comp) => {
461
+ if (this.repeatablePathsComps.includes(comp)) {
462
462
  this.webform.postMessage({
463
463
  name: 'showBuilderErrors',
464
464
  data: {
@@ -78,7 +78,7 @@ export default class WebformBuilder extends Component {
78
78
  replaceDoubleQuotes(data: any, fieldsToRemoveDoubleQuotes?: any[]): any;
79
79
  updateComponent(component: any, changed: any): void;
80
80
  originalDefaultValue: any;
81
- findRepeatablePaths(): any[];
81
+ findComponentsWithRepeatablePaths(): any[];
82
82
  highlightInvalidComponents(): void;
83
83
  /**
84
84
  * Called when a new component is saved.
@@ -1108,25 +1108,36 @@ export default class WebformBuilder extends Component {
1108
1108
  // Called when we update a component.
1109
1109
  this.emit('updateComponent', component);
1110
1110
  }
1111
- findRepeatablePaths() {
1112
- const repeatablePaths = [];
1111
+ findComponentsWithRepeatablePaths() {
1112
+ const repeatablePaths = {};
1113
1113
  const keys = new Map();
1114
1114
  eachComponent(this.form.components, (comp, path, components, parent, paths) => {
1115
+ const isRadioCheckbox = comp.type === 'checkbox' && comp.inputType === 'radio';
1115
1116
  if (keys.has(paths.dataPath)) {
1116
- repeatablePaths.push(paths.dataPath);
1117
+ const onlyRadioCheckboxes = repeatablePaths[paths.dataPath]?.onlyRadioCheckboxes === false ? false : isRadioCheckbox;
1118
+ repeatablePaths[paths.dataPath] = {
1119
+ comps: [...(repeatablePaths[paths.dataPath]?.comps || []), keys.get(paths.dataPath), comp],
1120
+ onlyRadioCheckboxes,
1121
+ };
1117
1122
  }
1118
1123
  else {
1119
- keys.set(paths.dataPath, true);
1124
+ keys.set(paths.dataPath, comp);
1120
1125
  }
1121
1126
  }, true);
1122
- return repeatablePaths;
1127
+ const componentsWithRepeatablePaths = [];
1128
+ Object.keys(repeatablePaths).forEach((path) => {
1129
+ const { comps, onlyRadioCheckboxes } = repeatablePaths[path];
1130
+ if (!onlyRadioCheckboxes) {
1131
+ componentsWithRepeatablePaths.push(...comps);
1132
+ }
1133
+ });
1134
+ return componentsWithRepeatablePaths;
1123
1135
  }
1124
1136
  highlightInvalidComponents() {
1125
- const repeatablePaths = this.findRepeatablePaths();
1137
+ const repeatablePathsComps = this.findComponentsWithRepeatablePaths();
1126
1138
  let hasInvalidComponents = false;
1127
1139
  this.webform.everyComponent((comp) => {
1128
- const path = comp.path;
1129
- if (repeatablePaths.includes(path)) {
1140
+ if (repeatablePathsComps.includes(comp.component)) {
1130
1141
  comp.setCustomValidity(this.t('apiKey', { key: comp.key }));
1131
1142
  hasInvalidComponents = true;
1132
1143
  }
@@ -7,7 +7,7 @@ export default class ButtonComponent extends Field {
7
7
  weight: number;
8
8
  schema: any;
9
9
  };
10
- static savedValueTypes(schema: any): any;
10
+ static savedValueTypes(schema: any): string[];
11
11
  constructor(component: any, options: any, data: any);
12
12
  filesUploading: number;
13
13
  get inputInfo(): any;
@@ -1,7 +1,7 @@
1
1
  import _ from 'lodash';
2
2
  import Field from '../_classes/field/Field';
3
3
  import Input from '../_classes/input/Input';
4
- import { componentValueTypes, eachComponent, getArrayFromComponentPath, getComponentSavedTypes } from '../../utils/formUtils';
4
+ import { componentValueTypes, eachComponent, getArrayFromComponentPath, getComponentSavedTypes } from '../../utils';
5
5
  export default class ButtonComponent extends Field {
6
6
  static schema(...extend) {
7
7
  return Input.schema({
@@ -1,3 +1,4 @@
1
+ /* global jQuery */
1
2
  import _ from 'lodash';
2
3
  import moment from 'moment-timezone/moment-timezone';
3
4
  import jtz from 'jstimezonedetect';
@@ -1005,6 +1006,9 @@ export function bootstrapVersion(options) {
1005
1006
  if (options.bootstrap) {
1006
1007
  return options.bootstrap;
1007
1008
  }
1009
+ if ((typeof jQuery === 'function') && (typeof jQuery().collapse === 'function')) {
1010
+ return parseInt(jQuery.fn.collapse.Constructor.VERSION.split('.')[0], 10);
1011
+ }
1008
1012
  if (window.bootstrap && window.bootstrap.Collapse) {
1009
1013
  return parseInt(window.bootstrap.Collapse.VERSION.split('.')[0], 10);
1010
1014
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.1.0-dev.6152.95f2394",
3
+ "version": "5.1.0-dev.6155.8178240",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {