@formio/js 5.1.0-dev.6146.88a0cfd → 5.1.0-dev.6150.1c5377f

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.
@@ -2375,12 +2375,14 @@ class Component extends Element_1.default {
2375
2375
  ckeditor: {
2376
2376
  image: {
2377
2377
  toolbar: [
2378
+ 'toggleImageCaption',
2378
2379
  'imageTextAlternative',
2379
2380
  '|',
2380
- 'imageStyle:full',
2381
- 'imageStyle:alignLeft',
2382
- 'imageStyle:alignCenter',
2383
- 'imageStyle:alignRight'
2381
+ 'imageStyle:inline',
2382
+ 'imageStyle:wrapText',
2383
+ 'imageStyle:breakText',
2384
+ '|',
2385
+ 'resizeImage'
2384
2386
  ],
2385
2387
  styles: [
2386
2388
  'full',
@@ -2402,7 +2404,10 @@ class Component extends Element_1.default {
2402
2404
  if (this.component.isUploadEnabled) {
2403
2405
  settings.extraPlugins.push((0, uploadAdapter_1.getFormioUploadAdapterPlugin)(this.fileService, this));
2404
2406
  }
2405
- return Formio_1.Formio.requireLibrary('ckeditor', isIEBrowser ? 'CKEDITOR' : 'ClassicEditor', lodash_1.default.get(this.options, 'editors.ckeditor.src', `${Formio_1.Formio.cdn.ckeditor}/ckeditor.js`), true)
2407
+ Formio_1.Formio.requireLibrary(`ckeditor-css`, isIEBrowser ? 'CKEDITOR' : 'ClassicEditor', [
2408
+ { type: 'styles', src: `${Formio_1.Formio.cdn.ckeditor}/ckeditor.css` }
2409
+ ], true);
2410
+ return Formio_1.Formio.requireLibrary('ckeditor', isIEBrowser ? 'CKEDITOR' : 'ClassicEditor', lodash_1.default.get(this.options, 'editors.ckeditor.src', `${Formio_1.Formio.cdn.ckeditor}/ckeditor.umd.js`), true)
2406
2411
  .then(() => {
2407
2412
  if (!element.parentNode) {
2408
2413
  return Promise.reject();
@@ -3210,6 +3215,9 @@ class Component extends Element_1.default {
3210
3215
  data = data || this.rootValue;
3211
3216
  flags = flags || {};
3212
3217
  row = row || this.data;
3218
+ if (flags.noCheck) {
3219
+ return true;
3220
+ }
3213
3221
  // Some components (for legacy reasons) have calls to "checkData" in inappropriate places such
3214
3222
  // as setValue. Historically, this was bypassed by a series of cached states around the data model
3215
3223
  // which caused its own problems. We need to ensure that premium and custom components do not fall into
@@ -3224,9 +3232,6 @@ class Component extends Element_1.default {
3224
3232
  if (!flags.fromBlur) {
3225
3233
  this.checkRefreshOn(flags.changes, flags);
3226
3234
  }
3227
- if (flags.noCheck) {
3228
- return true;
3229
- }
3230
3235
  this.checkComponentConditions(data, flags, row);
3231
3236
  if (this.id !== flags.triggeredComponentId) {
3232
3237
  this.calculateComponentValue(data, flags, row);
@@ -1,5 +1,5 @@
1
1
  export default class DataMapComponent extends DataGridComponent {
2
- static savedValueTypes(schema: any): any;
2
+ static savedValueTypes(schema: any): string[];
3
3
  constructor(component: any, options: any, data: any);
4
4
  get schema(): any;
5
5
  get emptyValue(): {};
@@ -7,7 +7,7 @@ const Component_1 = __importDefault(require("../_classes/component/Component"));
7
7
  const DataGrid_1 = __importDefault(require("../datagrid/DataGrid"));
8
8
  const lodash_1 = __importDefault(require("lodash"));
9
9
  const eventemitter3_1 = __importDefault(require("eventemitter3"));
10
- const formUtils_1 = require("../../utils/formUtils");
10
+ const utils_1 = require("../../utils/utils");
11
11
  class DataMapComponent extends DataGrid_1.default {
12
12
  static schema(...extend) {
13
13
  return Component_1.default.schema({
@@ -50,7 +50,7 @@ class DataMapComponent extends DataGrid_1.default {
50
50
  return lodash_1.default.omit(schema, 'components');
51
51
  }
52
52
  static savedValueTypes(schema) {
53
- return (0, formUtils_1.getComponentSavedTypes)(schema) || [formUtils_1.componentValueTypes.object];
53
+ return (0, utils_1.getComponentSavedTypes)(schema) || [utils_1.componentValueTypes.object];
54
54
  }
55
55
  constructor(component, options, data) {
56
56
  super(component, options, data);
@@ -149,7 +149,7 @@ class DataMapComponent extends DataGrid_1.default {
149
149
  getRowKey(rowIndex) {
150
150
  const keys = Object.keys(this.dataValue);
151
151
  if (!keys[rowIndex]) {
152
- keys[rowIndex] = (0, formUtils_1.uniqueKey)(this.dataValue, this.defaultRowKey);
152
+ keys[rowIndex] = (0, utils_1.uniqueKey)(this.dataValue, this.defaultRowKey);
153
153
  }
154
154
  return keys[rowIndex];
155
155
  }
@@ -232,7 +232,7 @@ class DataMapComponent extends DataGrid_1.default {
232
232
  components['__key'] = this.createComponent(this.keySchema, options, { __key: this.builderMode ? this.defaultRowKey : key });
233
233
  components['__key'].on('componentChange', (event) => {
234
234
  const dataValue = this.dataValue;
235
- const newKey = (0, formUtils_1.uniqueKey)(dataValue, event.value);
235
+ const newKey = (0, utils_1.uniqueKey)(dataValue, event.value);
236
236
  dataValue[newKey] = dataValue[key];
237
237
  delete dataValue[key];
238
238
  const comp = components[this.valueKey];
@@ -53,7 +53,7 @@ class DayComponent extends Field_1.default {
53
53
  return (0, utils_1.getComponentSavedTypes)(schema) || [utils_1.componentValueTypes.string];
54
54
  }
55
55
  constructor(component, options, data) {
56
- if (!options.inFormBuilder && !options.building) {
56
+ if (options && !options.inFormBuilder && !options.building) {
57
57
  if (component.maxDate && component.maxDate.indexOf('moment(') === -1) {
58
58
  component.maxDate = (0, moment_1.default)(component.maxDate, 'YYYY-MM-DD').toISOString();
59
59
  }
@@ -193,7 +193,12 @@ class TextAreaComponent extends TextField_1.default {
193
193
  const editorHeight = (numRows * 31) + 14;
194
194
  editor.ui.view.editable.editableElement.style.height = `${(editorHeight)}px`;
195
195
  }
196
- editor.isReadOnly = isReadOnly;
196
+ if (isReadOnly) {
197
+ editor.enableReadOnlyMode(this.id);
198
+ }
199
+ else {
200
+ editor.disableReadOnlyMode(this.id);
201
+ }
197
202
  editor.data.set(value);
198
203
  }
199
204
  editorReady(editor);
@@ -1,3 +1,10 @@
1
+ /**
2
+ * For backwards compatibility we a standalone interpolate function. This merely calls the
3
+ * global mutable Evaluator instance's interpolate function.
4
+ * @param {...any} args - interpolate arguments, typically "rawTemplate", "data", and "options"
5
+ * @returns {any} the interpolation result.
6
+ */
7
+ export function interpolate(...args: any[]): any;
1
8
  /**
2
9
  * Set the evaluator to use for evaluating expressions.
3
10
  * @param {CoreEvaluator} override - The new evaluator instance to use.
@@ -11,5 +18,4 @@ export class DefaultEvaluator extends CoreEvaluator {
11
18
  interpolate(rawTemplate: any, data: any, _options: any): any;
12
19
  }
13
20
  export let Evaluator: DefaultEvaluator;
14
- export function interpolate(rawTemplate: any, data: any, _options: any): any;
15
21
  import { DefaultEvaluator as CoreEvaluator } from '@formio/core';
@@ -62,7 +62,16 @@ class DefaultEvaluator extends core_1.DefaultEvaluator {
62
62
  exports.DefaultEvaluator = DefaultEvaluator;
63
63
  exports.Evaluator = new DefaultEvaluator();
64
64
  // preserve the standalone interpolate function for backwards compatibility
65
- exports.interpolate = exports.Evaluator.interpolate;
65
+ /**
66
+ * For backwards compatibility we a standalone interpolate function. This merely calls the
67
+ * global mutable Evaluator instance's interpolate function.
68
+ * @param {...any} args - interpolate arguments, typically "rawTemplate", "data", and "options"
69
+ * @returns {any} the interpolation result.
70
+ */
71
+ function interpolate(...args) {
72
+ return exports.Evaluator.interpolate(...args);
73
+ }
74
+ exports.interpolate = interpolate;
66
75
  /**
67
76
  * Set the evaluator to use for evaluating expressions.
68
77
  * @param {CoreEvaluator} override - The new evaluator instance to use.
@@ -3,7 +3,12 @@ export * from "./formUtils";
3
3
  export default FormioUtils;
4
4
  declare const FormioUtils: {
5
5
  Evaluator: import("./Evaluator").DefaultEvaluator;
6
- interpolate: (rawTemplate: any, data: any, _options: any) => any;
6
+ interpolate: typeof interpolate;
7
+ ConditionOperators: {
8
+ [x: string]: typeof import("./conditionOperators/IsEqualTo").default | typeof import("./conditionOperators/DateGreaterThan").default;
9
+ };
10
+ _: any;
11
+ moment: typeof moment;
7
12
  flattenComponents: typeof import("@formio/core/lib/utils/formUtil").flattenComponents;
8
13
  guid: typeof import("@formio/core/lib/utils/formUtil").guid;
9
14
  uniqueName: typeof import("@formio/core/lib/utils/formUtil").uniqueName;
@@ -160,4 +165,6 @@ declare const FormioUtils: {
160
165
  };
161
166
  import { Evaluator } from './Evaluator';
162
167
  import { registerEvaluator } from './Evaluator';
168
+ import { interpolate } from './Evaluator';
169
+ import moment from 'moment';
163
170
  export { FormioUtils as Utils, Evaluator, registerEvaluator };
@@ -25,6 +25,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
26
26
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
27
27
  };
28
+ var __importDefault = (this && this.__importDefault) || function (mod) {
29
+ return (mod && mod.__esModule) ? mod : { "default": mod };
30
+ };
28
31
  Object.defineProperty(exports, "__esModule", { value: true });
29
32
  exports.registerEvaluator = exports.Evaluator = exports.Utils = void 0;
30
33
  const utils = __importStar(require("./utils"));
@@ -32,8 +35,14 @@ const formUtils = __importStar(require("./formUtils"));
32
35
  const Evaluator_1 = require("./Evaluator");
33
36
  Object.defineProperty(exports, "Evaluator", { enumerable: true, get: function () { return Evaluator_1.Evaluator; } });
34
37
  Object.defineProperty(exports, "registerEvaluator", { enumerable: true, get: function () { return Evaluator_1.registerEvaluator; } });
38
+ const conditionOperators_1 = __importDefault(require("./conditionOperators"));
39
+ const lodash_1 = __importDefault(require("lodash"));
40
+ const moment_1 = __importDefault(require("moment"));
35
41
  const FormioUtils = Object.assign(Object.assign(Object.assign({}, utils), formUtils), { Evaluator: Evaluator_1.Evaluator,
36
- interpolate: Evaluator_1.interpolate });
42
+ interpolate: Evaluator_1.interpolate,
43
+ ConditionOperators: conditionOperators_1.default,
44
+ _: lodash_1.default,
45
+ moment: moment_1.default });
37
46
  exports.Utils = FormioUtils;
38
47
  if (typeof global === 'object') {
39
48
  global.FormioUtils = FormioUtils;
@@ -265,9 +265,7 @@ class CalendarWidget extends InputWidget_1.default {
265
265
  }
266
266
  // If the component is a textfield that does not have timezone information included in the string value then skip
267
267
  // the timezone offset
268
- if (this.component.type === 'textfield' && !(0, utils_1.hasEncodedTimezone)(value)) {
269
- this.settings.skipOffset = true;
270
- }
268
+ this.settings.skipOffset = this.component.type === 'textfield' && !(0, utils_1.hasEncodedTimezone)(value);
271
269
  if (value) {
272
270
  if (!saveAsText && this.settings.readOnly) {
273
271
  this.calendar.setDate((0, utils_1.dayjsDate)(value, this.valueFormat, this.timezone).format(), false);
@@ -2364,12 +2364,14 @@ export default class Component extends Element {
2364
2364
  ckeditor: {
2365
2365
  image: {
2366
2366
  toolbar: [
2367
+ 'toggleImageCaption',
2367
2368
  'imageTextAlternative',
2368
2369
  '|',
2369
- 'imageStyle:full',
2370
- 'imageStyle:alignLeft',
2371
- 'imageStyle:alignCenter',
2372
- 'imageStyle:alignRight'
2370
+ 'imageStyle:inline',
2371
+ 'imageStyle:wrapText',
2372
+ 'imageStyle:breakText',
2373
+ '|',
2374
+ 'resizeImage'
2373
2375
  ],
2374
2376
  styles: [
2375
2377
  'full',
@@ -2391,7 +2393,10 @@ export default class Component extends Element {
2391
2393
  if (this.component.isUploadEnabled) {
2392
2394
  settings.extraPlugins.push(getFormioUploadAdapterPlugin(this.fileService, this));
2393
2395
  }
2394
- return Formio.requireLibrary('ckeditor', isIEBrowser ? 'CKEDITOR' : 'ClassicEditor', _.get(this.options, 'editors.ckeditor.src', `${Formio.cdn.ckeditor}/ckeditor.js`), true)
2396
+ Formio.requireLibrary(`ckeditor-css`, isIEBrowser ? 'CKEDITOR' : 'ClassicEditor', [
2397
+ { type: 'styles', src: `${Formio.cdn.ckeditor}/ckeditor.css` }
2398
+ ], true);
2399
+ return Formio.requireLibrary('ckeditor', isIEBrowser ? 'CKEDITOR' : 'ClassicEditor', _.get(this.options, 'editors.ckeditor.src', `${Formio.cdn.ckeditor}/ckeditor.umd.js`), true)
2395
2400
  .then(() => {
2396
2401
  if (!element.parentNode) {
2397
2402
  return Promise.reject();
@@ -3198,6 +3203,9 @@ export default class Component extends Element {
3198
3203
  data = data || this.rootValue;
3199
3204
  flags = flags || {};
3200
3205
  row = row || this.data;
3206
+ if (flags.noCheck) {
3207
+ return true;
3208
+ }
3201
3209
  // Some components (for legacy reasons) have calls to "checkData" in inappropriate places such
3202
3210
  // as setValue. Historically, this was bypassed by a series of cached states around the data model
3203
3211
  // which caused its own problems. We need to ensure that premium and custom components do not fall into
@@ -3212,9 +3220,6 @@ export default class Component extends Element {
3212
3220
  if (!flags.fromBlur) {
3213
3221
  this.checkRefreshOn(flags.changes, flags);
3214
3222
  }
3215
- if (flags.noCheck) {
3216
- return true;
3217
- }
3218
3223
  this.checkComponentConditions(data, flags, row);
3219
3224
  if (this.id !== flags.triggeredComponentId) {
3220
3225
  this.calculateComponentValue(data, flags, row);
@@ -1,5 +1,5 @@
1
1
  export default class DataMapComponent extends DataGridComponent {
2
- static savedValueTypes(schema: any): any;
2
+ static savedValueTypes(schema: any): string[];
3
3
  constructor(component: any, options: any, data: any);
4
4
  get schema(): any;
5
5
  get emptyValue(): {};
@@ -2,7 +2,7 @@ import Component from '../_classes/component/Component';
2
2
  import DataGridComponent from '../datagrid/DataGrid';
3
3
  import _ from 'lodash';
4
4
  import EventEmitter from 'eventemitter3';
5
- import { componentValueTypes, getComponentSavedTypes, uniqueKey } from '../../utils/formUtils';
5
+ import { componentValueTypes, getComponentSavedTypes, uniqueKey } from '../../utils/utils';
6
6
  export default class DataMapComponent extends DataGridComponent {
7
7
  static schema(...extend) {
8
8
  return Component.schema({
@@ -53,7 +53,7 @@ export default class DayComponent extends Field {
53
53
  // Empty value used before 9.3.x
54
54
  static oldEmptyValue = '00/00/0000';
55
55
  constructor(component, options, data) {
56
- if (!options.inFormBuilder && !options.building) {
56
+ if (options && !options.inFormBuilder && !options.building) {
57
57
  if (component.maxDate && component.maxDate.indexOf('moment(') === -1) {
58
58
  component.maxDate = moment(component.maxDate, 'YYYY-MM-DD').toISOString();
59
59
  }
@@ -188,7 +188,12 @@ export default class TextAreaComponent extends TextFieldComponent {
188
188
  const editorHeight = (numRows * 31) + 14;
189
189
  editor.ui.view.editable.editableElement.style.height = `${(editorHeight)}px`;
190
190
  }
191
- editor.isReadOnly = isReadOnly;
191
+ if (isReadOnly) {
192
+ editor.enableReadOnlyMode(this.id);
193
+ }
194
+ else {
195
+ editor.disableReadOnlyMode(this.id);
196
+ }
192
197
  editor.data.set(value);
193
198
  }
194
199
  editorReady(editor);
@@ -1,3 +1,10 @@
1
+ /**
2
+ * For backwards compatibility we a standalone interpolate function. This merely calls the
3
+ * global mutable Evaluator instance's interpolate function.
4
+ * @param {...any} args - interpolate arguments, typically "rawTemplate", "data", and "options"
5
+ * @returns {any} the interpolation result.
6
+ */
7
+ export function interpolate(...args: any[]): any;
1
8
  /**
2
9
  * Set the evaluator to use for evaluating expressions.
3
10
  * @param {CoreEvaluator} override - The new evaluator instance to use.
@@ -11,5 +18,4 @@ export class DefaultEvaluator extends CoreEvaluator {
11
18
  interpolate(rawTemplate: any, data: any, _options: any): any;
12
19
  }
13
20
  export let Evaluator: DefaultEvaluator;
14
- export function interpolate(rawTemplate: any, data: any, _options: any): any;
15
21
  import { DefaultEvaluator as CoreEvaluator } from '@formio/core';
@@ -52,7 +52,15 @@ export class DefaultEvaluator extends CoreEvaluator {
52
52
  }
53
53
  export let Evaluator = new DefaultEvaluator();
54
54
  // preserve the standalone interpolate function for backwards compatibility
55
- export const interpolate = Evaluator.interpolate;
55
+ /**
56
+ * For backwards compatibility we a standalone interpolate function. This merely calls the
57
+ * global mutable Evaluator instance's interpolate function.
58
+ * @param {...any} args - interpolate arguments, typically "rawTemplate", "data", and "options"
59
+ * @returns {any} the interpolation result.
60
+ */
61
+ export function interpolate(...args) {
62
+ return Evaluator.interpolate(...args);
63
+ }
56
64
  /**
57
65
  * Set the evaluator to use for evaluating expressions.
58
66
  * @param {CoreEvaluator} override - The new evaluator instance to use.
@@ -3,7 +3,12 @@ export * from "./formUtils";
3
3
  export default FormioUtils;
4
4
  declare const FormioUtils: {
5
5
  Evaluator: import("./Evaluator").DefaultEvaluator;
6
- interpolate: (rawTemplate: any, data: any, _options: any) => any;
6
+ interpolate: typeof interpolate;
7
+ ConditionOperators: {
8
+ [x: string]: typeof import("./conditionOperators/IsEqualTo").default | typeof import("./conditionOperators/DateGreaterThan").default;
9
+ };
10
+ _: any;
11
+ moment: typeof moment;
7
12
  flattenComponents: typeof import("@formio/core/lib/utils/formUtil").flattenComponents;
8
13
  guid: typeof import("@formio/core/lib/utils/formUtil").guid;
9
14
  uniqueName: typeof import("@formio/core/lib/utils/formUtil").uniqueName;
@@ -160,4 +165,6 @@ declare const FormioUtils: {
160
165
  };
161
166
  import { Evaluator } from './Evaluator';
162
167
  import { registerEvaluator } from './Evaluator';
168
+ import { interpolate } from './Evaluator';
169
+ import moment from 'moment';
163
170
  export { FormioUtils as Utils, Evaluator, registerEvaluator };
@@ -1,11 +1,17 @@
1
1
  import * as utils from './utils';
2
2
  import * as formUtils from './formUtils';
3
3
  import { Evaluator, registerEvaluator, interpolate } from './Evaluator';
4
+ import ConditionOperators from './conditionOperators';
5
+ import _ from 'lodash';
6
+ import moment from 'moment';
4
7
  const FormioUtils = {
5
8
  ...utils,
6
9
  ...formUtils,
7
10
  Evaluator,
8
- interpolate
11
+ interpolate,
12
+ ConditionOperators,
13
+ _,
14
+ moment
9
15
  };
10
16
  if (typeof global === 'object') {
11
17
  global.FormioUtils = FormioUtils;
@@ -257,9 +257,7 @@ export default class CalendarWidget extends InputWidget {
257
257
  }
258
258
  // If the component is a textfield that does not have timezone information included in the string value then skip
259
259
  // the timezone offset
260
- if (this.component.type === 'textfield' && !hasEncodedTimezone(value)) {
261
- this.settings.skipOffset = true;
262
- }
260
+ this.settings.skipOffset = this.component.type === 'textfield' && !hasEncodedTimezone(value);
263
261
  if (value) {
264
262
  if (!saveAsText && this.settings.readOnly) {
265
263
  this.calendar.setDate(dayjsDate(value, this.valueFormat, this.timezone).format(), false);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.1.0-dev.6146.88a0cfd",
3
+ "version": "5.1.0-dev.6150.1c5377f",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {