@formio/js 5.0.0-rc.28 → 5.0.0-rc.29

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. package/dist/formio.embed.js +1 -1
  2. package/dist/formio.embed.min.js +1 -1
  3. package/dist/formio.embed.min.js.LICENSE.txt +1 -1
  4. package/dist/formio.form.js +730 -2064
  5. package/dist/formio.form.min.js +1 -1
  6. package/dist/formio.form.min.js.LICENSE.txt +3 -1
  7. package/dist/formio.full.js +741 -1999
  8. package/dist/formio.full.min.js +1 -1
  9. package/dist/formio.full.min.js.LICENSE.txt +3 -1
  10. package/dist/formio.js +98 -2358
  11. package/dist/formio.min.js +1 -1
  12. package/dist/formio.min.js.LICENSE.txt +1 -3
  13. package/dist/formio.utils.js +131 -111
  14. package/dist/formio.utils.min.js +1 -1
  15. package/dist/formio.utils.min.js.LICENSE.txt +3 -1
  16. package/lib/cjs/CDN.d.ts +1 -1
  17. package/lib/cjs/CDN.js +2 -2
  18. package/lib/cjs/Embed.d.ts +15 -6
  19. package/lib/cjs/Embed.js +63 -19
  20. package/lib/cjs/Formio.d.ts +0 -1
  21. package/lib/cjs/Formio.js +27 -19
  22. package/lib/cjs/Webform.d.ts +3 -4
  23. package/lib/cjs/WebformBuilder.js +6 -6
  24. package/lib/cjs/Wizard.d.ts +3 -4
  25. package/lib/cjs/components/_classes/component/Component.d.ts +1 -1
  26. package/lib/cjs/components/_classes/component/Component.js +6 -6
  27. package/lib/cjs/components/_classes/nested/NestedComponent.js +2 -2
  28. package/lib/cjs/components/editgrid/EditGrid.js +2 -2
  29. package/lib/cjs/formio.form.js +1 -0
  30. package/lib/cjs/index.js +1 -0
  31. package/lib/cjs/templates/Templates.d.ts +1 -11
  32. package/lib/cjs/templates/Templates.js +4 -41
  33. package/lib/cjs/utils/index.d.ts +1 -0
  34. package/lib/cjs/utils/index.js +2 -0
  35. package/lib/mjs/CDN.d.ts +1 -1
  36. package/lib/mjs/CDN.js +2 -2
  37. package/lib/mjs/Embed.d.ts +15 -6
  38. package/lib/mjs/Embed.js +62 -13
  39. package/lib/mjs/Formio.d.ts +0 -1
  40. package/lib/mjs/Formio.js +11 -3
  41. package/lib/mjs/Webform.d.ts +3 -4
  42. package/lib/mjs/WebformBuilder.js +3 -3
  43. package/lib/mjs/Wizard.d.ts +3 -4
  44. package/lib/mjs/components/_classes/component/Component.d.ts +1 -1
  45. package/lib/mjs/components/_classes/component/Component.js +1 -1
  46. package/lib/mjs/components/_classes/nested/NestedComponent.js +1 -1
  47. package/lib/mjs/components/editgrid/EditGrid.js +1 -1
  48. package/lib/mjs/formio.form.js +1 -0
  49. package/lib/mjs/index.js +1 -0
  50. package/lib/mjs/templates/Templates.d.ts +1 -11
  51. package/lib/mjs/templates/Templates.js +4 -40
  52. package/lib/mjs/utils/index.d.ts +1 -0
  53. package/lib/mjs/utils/index.js +1 -0
  54. package/package.json +10 -10
@@ -1,18 +1,26 @@
1
1
  export class Formio {
2
+ static FormioClass: null;
2
3
  static baseUrl: any;
3
4
  static projectUrl: any;
5
+ static pathType: any;
4
6
  static language: any;
5
7
  static config: {};
6
- static cdn: null;
7
- static proxy: boolean;
8
+ static cdn: CDN;
9
+ static modules: any[];
10
+ static icons: string;
11
+ static formioReady: Promise<any>;
8
12
  static version: string;
9
- static setBaseUrl(url: any): Promise<void>;
10
- static setProjectUrl(url: any): Promise<void>;
13
+ static setBaseUrl(url: any, norecurse: any): void;
14
+ static setApiUrl(url: any, norecurse: any): void;
15
+ static setProjectUrl(url: any, norecurse: any): void;
16
+ static setAppUrl(url: any, norecurse: any): void;
17
+ static setPathType(type: any, norecurse: any): void;
11
18
  static debug(...args: any[]): void;
12
19
  static clearCache(): void;
13
- static global(prop: any): any;
20
+ static global(prop: any, flag?: string): any;
21
+ static use(module: any): void;
14
22
  static createElement(type: any, attrs: any, children: any): any;
15
- static addScript(wrapper: any, src: any, name: any): Promise<any>;
23
+ static addScript(wrapper: any, src: any, name: any, flag?: string): Promise<any>;
16
24
  static addStyles(wrapper: any, href: any): Promise<void>;
17
25
  static submitDone(instance: any, submission: any): Promise<void>;
18
26
  static formioScript(script: any, builder: any): any;
@@ -41,3 +49,4 @@ export class Form {
41
49
  }
42
50
  export class FormBuilder extends Form {
43
51
  }
52
+ import CDN from './CDN.js';
package/lib/mjs/Embed.js CHANGED
@@ -1,17 +1,48 @@
1
1
  import CDN from './CDN.js';
2
2
  class Formio {
3
+ static FormioClass = null;
3
4
  static baseUrl;
4
5
  static projectUrl;
6
+ static pathType;
5
7
  static language;
6
8
  static config = {};
7
- static cdn = null;
8
- static proxy = true;
9
+ static cdn = new CDN();
10
+ static modules = [];
11
+ static icons = '';
12
+ static formioReady = new Promise((ready, reject) => {
13
+ Formio._formioReady = ready;
14
+ Formio._formioReadyReject = reject;
15
+ });
9
16
  static version = 'FORMIO_VERSION';
10
- static async setBaseUrl(url) {
17
+ static setBaseUrl(url, norecurse) {
11
18
  Formio.baseUrl = url;
19
+ if (!norecurse && Formio.FormioClass) {
20
+ Formio.FormioClass.setBaseUrl(url);
21
+ }
22
+ }
23
+ static setApiUrl(url, norecurse) {
24
+ Formio.baseUrl = url;
25
+ if (!norecurse && Formio.FormioClass) {
26
+ Formio.FormioClass.setApiUrl(url);
27
+ }
12
28
  }
13
- static async setProjectUrl(url) {
29
+ static setProjectUrl(url, norecurse) {
14
30
  Formio.projectUrl = url;
31
+ if (!norecurse && Formio.FormioClass) {
32
+ Formio.FormioClass.setProjectUrl(url);
33
+ }
34
+ }
35
+ static setAppUrl(url, norecurse) {
36
+ Formio.projectUrl = url;
37
+ if (!norecurse && Formio.FormioClass) {
38
+ Formio.FormioClass.setAppUrl(url);
39
+ }
40
+ }
41
+ static setPathType(type, norecurse) {
42
+ Formio.pathType = type;
43
+ if (!norecurse && Formio.FormioClass) {
44
+ Formio.FormioClass.setPathType(type);
45
+ }
15
46
  }
16
47
  static debug(...args) {
17
48
  if (Formio.config.debug) {
@@ -23,14 +54,22 @@ class Formio {
23
54
  Formio.FormioClass.clearCache();
24
55
  }
25
56
  }
26
- static global(prop) {
57
+ static global(prop, flag = '') {
27
58
  const globalValue = window[prop];
28
- if (globalValue && globalValue.proxy) {
59
+ if (flag && globalValue && !globalValue[flag]) {
29
60
  return null;
30
61
  }
31
62
  Formio.debug(`Getting global ${prop}`, globalValue);
32
63
  return globalValue;
33
64
  }
65
+ static use(module) {
66
+ if (Formio.FormioClass && Formio.FormioClass.isRenderer) {
67
+ Formio.FormioClass.use(module);
68
+ }
69
+ else {
70
+ Formio.modules.push(module);
71
+ }
72
+ }
34
73
  static createElement(type, attrs, children) {
35
74
  const element = document.createElement(type);
36
75
  Object.keys(attrs).forEach(key => {
@@ -41,14 +80,14 @@ class Formio {
41
80
  });
42
81
  return element;
43
82
  }
44
- static async addScript(wrapper, src, name) {
83
+ static async addScript(wrapper, src, name, flag = '') {
45
84
  if (!src) {
46
85
  return Promise.resolve();
47
86
  }
48
87
  if (typeof src !== 'string' && src.length) {
49
88
  return Promise.all(src.map(ref => Formio.addScript(wrapper, ref)));
50
89
  }
51
- if (name && Formio.global(name)) {
90
+ if (name && Formio.global(name, flag)) {
52
91
  Formio.debug(`${name} already loaded.`);
53
92
  return Promise.resolve(Formio.global(name));
54
93
  }
@@ -62,7 +101,7 @@ class Formio {
62
101
  return new Promise((resolve) => {
63
102
  Formio.debug(`Waiting to load ${name}`);
64
103
  const wait = setInterval(() => {
65
- if (Formio.global(name)) {
104
+ if (Formio.global(name, flag)) {
66
105
  clearInterval(wait);
67
106
  Formio.debug(`${name} loaded.`);
68
107
  resolve(Formio.global(name));
@@ -126,7 +165,7 @@ class Formio {
126
165
  }
127
166
  // eslint-disable-next-line max-statements
128
167
  static async init(element, options = {}, builder = false) {
129
- Formio.cdn = new CDN(Formio.config.cdn);
168
+ Formio.cdn = new CDN(Formio.config.cdn, Formio.config.cdnUrls || {});
130
169
  Formio.config.libs = Formio.config.libs || {
131
170
  uswds: {
132
171
  fa: true,
@@ -173,10 +212,19 @@ class Formio {
173
212
  }]
174
213
  }]));
175
214
  const renderer = Formio.config.debug ? 'formio.form' : 'formio.form.min';
176
- Formio.FormioClass = await Formio.addScript(wrapper, Formio.formioScript(Formio.config.script || `${Formio.cdn.js}/${renderer}.js`, builder), 'Formio');
177
- Formio.FormioClass.setBaseUrl(Formio.baseUrl || Formio.config.base);
178
- Formio.FormioClass.setProjectUrl(Formio.projectUrl || Formio.config.project);
215
+ Formio.FormioClass = await Formio.addScript(wrapper, Formio.formioScript(Formio.config.script || `${Formio.cdn.js}/${renderer}.js`, builder), 'Formio', builder ? 'isBuilder' : 'isRenderer');
216
+ Formio.FormioClass.setBaseUrl(options.baseUrl || Formio.baseUrl || Formio.config.base);
217
+ Formio.FormioClass.setProjectUrl(options.projectUrl || Formio.projectUrl || Formio.config.project);
179
218
  Formio.FormioClass.language = Formio.language;
219
+ Formio.modules.forEach((module) => {
220
+ Formio.FormioClass.use(module);
221
+ });
222
+ if (Formio.icons) {
223
+ Formio.FormioClass.icons = Formio.icons;
224
+ }
225
+ if (Formio.pathType) {
226
+ Formio.FormioClass.setPathType(Formio.pathType);
227
+ }
180
228
  // Add premium modules
181
229
  if (Formio.global('premium')) {
182
230
  Formio.debug('Using premium module.');
@@ -220,6 +268,7 @@ class Formio {
220
268
  await Formio.config.before(Formio.FormioClass, element, Formio.config);
221
269
  }
222
270
  Formio.FormioClass.license = true;
271
+ Formio._formioReady(Formio.FormioClass);
223
272
  return wrapper;
224
273
  }
225
274
  static async createForm(element, form, options) {
@@ -1,2 +1 @@
1
1
  export { Formio };
2
- import { Formio } from '@formio/core';
package/lib/mjs/Formio.js CHANGED
@@ -1,11 +1,12 @@
1
- import { Formio } from '@formio/core';
1
+ import { Formio } from '@formio/core/sdk';
2
+ import { Formio as FormioEmbed } from './Embed';
2
3
  import CDN from './CDN';
3
4
  import Providers from './providers';
4
5
  Formio.cdn = new CDN();
5
6
  Formio.Providers = Providers;
6
7
  Formio.version = 'FORMIO_VERSION';
7
8
  const isNil = (val) => val === null || val === undefined;
8
- Formio.prototype.uploadFile = function (storage, file, fileName, dir, progressCallback, url, options, fileKey, groupPermissions, groupId, uploadStartCallback, abortCallback) {
9
+ Formio.prototype.uploadFile = function (storage, file, fileName, dir, progressCallback, url, options, fileKey, groupPermissions, groupId, uploadStartCallback, abortCallback, multipartOptions) {
9
10
  const requestArgs = {
10
11
  provider: storage,
11
12
  method: 'upload',
@@ -25,7 +26,7 @@ Formio.prototype.uploadFile = function (storage, file, fileName, dir, progressCa
25
26
  if (uploadStartCallback) {
26
27
  uploadStartCallback();
27
28
  }
28
- return provider.uploadFile(file, fileName, dir, progressCallback, url, options, fileKey, groupPermissions, groupId, abortCallback);
29
+ return provider.uploadFile(file, fileName, dir, progressCallback, url, options, fileKey, groupPermissions, groupId, abortCallback, multipartOptions);
29
30
  }
30
31
  else {
31
32
  throw ('Storage provider not found');
@@ -86,4 +87,11 @@ Formio.prototype.deleteFile = function (file, options) {
86
87
  };
87
88
  // For reverse compatability.
88
89
  Formio.Promise = Promise;
90
+ Formio.formioReady = FormioEmbed.formioReady;
91
+ Formio.config = FormioEmbed.config;
92
+ Formio.builder = FormioEmbed.builder;
93
+ Formio.Form = FormioEmbed.Form;
94
+ Formio.FormBuilder = FormioEmbed.FormBuilder;
95
+ Formio.use = FormioEmbed.use;
96
+ Formio.createForm = FormioEmbed.createForm;
89
97
  export { Formio };
@@ -394,10 +394,9 @@ declare class Webform extends NestedDataComponent {
394
394
  get variables(): any;
395
395
  }
396
396
  declare namespace Webform {
397
- const setBaseUrl: typeof Formio.setBaseUrl;
398
- const setApiUrl: typeof Formio.setApiUrl;
399
- const setAppUrl: typeof Formio.setAppUrl;
397
+ const setBaseUrl: any;
398
+ const setApiUrl: any;
399
+ const setAppUrl: any;
400
400
  }
401
401
  export default Webform;
402
402
  import NestedDataComponent from './components/_classes/nesteddata/NestedDataComponent';
403
- import { Formio } from './Formio';
@@ -14,7 +14,7 @@ import './components/builder';
14
14
  if (typeof window !== 'undefined' && typeof window.global === 'undefined') {
15
15
  window.global = window;
16
16
  }
17
- import dragula from 'dragula/dist/dragula.min.js';
17
+ import dragula from 'dragula';
18
18
  export default class WebformBuilder extends Component {
19
19
  // eslint-disable-next-line max-statements
20
20
  constructor() {
@@ -1126,8 +1126,8 @@ export default class WebformBuilder extends Component {
1126
1126
  comp = component;
1127
1127
  }
1128
1128
  });
1129
- const originalComp = comp.component;
1130
- const originalComponentSchema = comp.schema;
1129
+ const originalComp = comp?.component;
1130
+ const originalComponentSchema = comp?.schema;
1131
1131
  const isParentSaveChildMethod = this.isParentSaveChildMethod(parent.formioComponent);
1132
1132
  if (parentContainer && !isParentSaveChildMethod) {
1133
1133
  parentContainer[index] = submissionData;
@@ -89,10 +89,9 @@ declare class Wizard extends Webform {
89
89
  focusOnComponent(key: any): any;
90
90
  }
91
91
  declare namespace Wizard {
92
- const setBaseUrl: typeof Formio.setBaseUrl;
93
- const setApiUrl: typeof Formio.setApiUrl;
94
- const setAppUrl: typeof Formio.setAppUrl;
92
+ const setBaseUrl: any;
93
+ const setApiUrl: any;
94
+ const setAppUrl: any;
95
95
  }
96
96
  export default Wizard;
97
97
  import Webform from './Webform';
98
- import { Formio } from './Formio';
@@ -725,7 +725,7 @@ declare class Component extends Element {
725
725
  * @param {*} flags - The flags to control the behavior of the validation.
726
726
  * @returns
727
727
  */
728
- validateComponent(data: any, row: any, flags?: any): any[] | Promise<any[]>;
728
+ validateComponent(data: any, row: any, flags?: any): any;
729
729
  /**
730
730
  * Checks the validity of this component and sets the error message if it is invalid.
731
731
  *
@@ -3,7 +3,7 @@ import { conformToMask } from '@formio/vanilla-text-mask';
3
3
  import tippy from 'tippy.js';
4
4
  import _ from 'lodash';
5
5
  import isMobile from 'ismobilejs';
6
- import { processOne, processOneSync, validateProcess, validateProcessSync } from '@formio/core';
6
+ import { processOne, processOneSync, validateProcess, validateProcessSync } from '@formio/core/process';
7
7
  import { Formio } from '../../../Formio';
8
8
  import * as FormioUtils from '../../../utils/utils';
9
9
  import { fastCloneDeep, boolValue, getComponentPath, isInsideScopingComponent, currentTimezone } from '../../../utils/utils';
@@ -3,7 +3,7 @@ import _ from 'lodash';
3
3
  import Field from '../field/Field';
4
4
  import Components from '../../Components';
5
5
  import { getArrayFromComponentPath, getStringFromComponentPath, getRandomComponentId } from '../../../utils/utils';
6
- import { process as processAsync, processSync } from '@formio/core';
6
+ import { process as processAsync, processSync } from '@formio/core/process';
7
7
  export default class NestedComponent extends Field {
8
8
  static schema(...extend) {
9
9
  return Field.schema({
@@ -1,5 +1,5 @@
1
1
  import _ from 'lodash';
2
- import { processSync } from '@formio/core';
2
+ import { processSync } from '@formio/core/process';
3
3
  import { editgrid as templates } from '@formio/bootstrap/components';
4
4
  import NestedArrayComponent from '../_classes/nestedarray/NestedArrayComponent';
5
5
  import Component from '../_classes/component/Component';
@@ -17,6 +17,7 @@ Formio.loadModules = (path = `${Formio.getApiUrl()}/externalModules.js`, name =
17
17
  });
18
18
  };
19
19
  // This is needed to maintain correct imports using the "dist" file.
20
+ Formio.isRenderer = true;
20
21
  Formio.Components = Components;
21
22
  Formio.Templates = Templates;
22
23
  Formio.Utils = Utils;
package/lib/mjs/index.js CHANGED
@@ -2,6 +2,7 @@ import FormBuilder from './FormBuilder';
2
2
  import Builders from './builders/Builders';
3
3
  import { Formio, useModule } from './formio.form';
4
4
  Formio.Builders = Builders;
5
+ Formio.isBuilder = true;
5
6
  Formio.use = useModule((key, mod) => {
6
7
  if (key === 'builders') {
7
8
  Formio.Builders.addBuilders(mod.builders);
@@ -1,11 +1 @@
1
- export default class Templates {
2
- static get templates(): any;
3
- static addTemplate(name: any, template: any): void;
4
- static extendTemplate(name: any, template: any): void;
5
- static setTemplate(name: any, template: any): void;
6
- static set current(arg: any);
7
- static get current(): any;
8
- static get defaultTemplates(): any;
9
- static set framework(arg: any);
10
- static get framework(): any;
11
- }
1
+ export default Template;
@@ -1,41 +1,5 @@
1
- import _ from 'lodash';
2
1
  import templates from './index';
3
- export default class Templates {
4
- static get templates() {
5
- if (!Templates._templates) {
6
- Templates._templates = templates;
7
- }
8
- return Templates._templates;
9
- }
10
- static addTemplate(name, template) {
11
- Templates.templates[name] = template;
12
- }
13
- static extendTemplate(name, template) {
14
- Templates.templates[name] = _.merge({}, Templates.templates[name], template);
15
- }
16
- static setTemplate(name, template) {
17
- Templates.addTemplate(name, template);
18
- }
19
- static set current(templates) {
20
- const defaultTemplates = Templates.current;
21
- Templates._current = _.merge({}, defaultTemplates, templates);
22
- }
23
- static get current() {
24
- if (Templates._current) {
25
- return Templates._current;
26
- }
27
- return Templates.defaultTemplates;
28
- }
29
- static get defaultTemplates() {
30
- return Templates.templates.hasOwnProperty('bootstrap') ? Templates.templates.bootstrap : {};
31
- }
32
- static set framework(framework) {
33
- if (Templates.templates.hasOwnProperty(framework)) {
34
- Templates._framework = framework;
35
- Templates._current = Templates.templates[framework];
36
- }
37
- }
38
- static get framework() {
39
- return Templates._framework;
40
- }
41
- }
2
+ import { Template } from '@formio/core/template';
3
+ Template.addTemplates(templates);
4
+ Template.defaultTemplates = templates.bootstrap;
5
+ export default Template;
@@ -1,2 +1,3 @@
1
+ export { FormioUtils as Utils };
1
2
  export default FormioUtils;
2
3
  import * as FormioUtils from './utils';
@@ -2,4 +2,5 @@ import * as FormioUtils from './utils';
2
2
  if (typeof global === 'object') {
3
3
  global.FormioUtils = FormioUtils;
4
4
  }
5
+ export { FormioUtils as Utils };
5
6
  export default FormioUtils;
package/package.json CHANGED
@@ -1,30 +1,30 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.0.0-rc.28",
3
+ "version": "5.0.0-rc.29",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
- "module": "lib/mjs/index.js",
7
6
  "exports": {
8
7
  ".": {
9
- "import": "./lib/mjs/index.js",
8
+ "import": "./lib/cjs/index.js",
10
9
  "require": "./lib/cjs/index.js"
11
10
  },
12
11
  "./sdk": {
13
- "import": "./lib/mjs/Formio.js",
12
+ "import": "./lib/cjs/Formio.js",
14
13
  "require": "./lib/cjs/Formio.js"
15
14
  },
16
15
  "./utils": {
17
- "import": "./lib/mjs/utils/index.js",
16
+ "import": "./lib/cjs/utils/index.js",
18
17
  "require": "./lib/cjs/utils/index.js"
19
18
  },
20
19
  "./form": {
21
- "import": "./lib/mjs/formio.form.js",
20
+ "import": "./lib/cjs/formio.form.js",
22
21
  "require": "./lib/cjs/formio.form.js"
23
22
  },
24
23
  "./embed": {
25
- "import": "./lib/mjs/formio.embed.js",
26
- "require": "./lib/cjs/formio.embed.js"
27
- }
24
+ "import": "./lib/cjs/Embed.js",
25
+ "require": "./lib/cjs/Embed.js"
26
+ },
27
+ "./dist/*": "./dist/*"
28
28
  },
29
29
  "types": "index.d.ts",
30
30
  "files": [
@@ -80,7 +80,7 @@
80
80
  "dependencies": {
81
81
  "@formio/bootstrap": "^3.0.0-rc.13",
82
82
  "@formio/choices.js": "^10.2.0",
83
- "@formio/core": "^1.3.0-rc.19",
83
+ "@formio/core": "^1.3.0-rc.21",
84
84
  "@formio/text-mask-addons": "^3.8.0-formio.2",
85
85
  "@formio/vanilla-text-mask": "^5.1.1-formio.1",
86
86
  "autocompleter": "^8.0.4",