@formio/js 5.0.0-rc.14 → 5.0.0-rc.15

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,6 @@
1
1
  export default class WebformBuilder extends Component {
2
2
  constructor(...args: any[]);
3
+ dragulaLib: any;
3
4
  builderHeight: number;
4
5
  schemas: {};
5
6
  repeatablePaths: any[];
@@ -16,6 +16,10 @@ const lodash_1 = __importDefault(require("lodash"));
16
16
  const dom_autoscroller_1 = __importDefault(require("dom-autoscroller"));
17
17
  const Templates_1 = __importDefault(require("./templates/Templates"));
18
18
  require("./components/builder");
19
+ // We need this here because dragula pulls in CustomEvent class that requires global to exist.
20
+ if (typeof window !== 'undefined' && typeof window.global === 'undefined') {
21
+ window.global = window;
22
+ }
19
23
  const dragula_1 = __importDefault(require("dragula"));
20
24
  class WebformBuilder extends Component_1.default {
21
25
  // eslint-disable-next-line max-statements
@@ -46,6 +50,7 @@ class WebformBuilder extends Component_1.default {
46
50
  }
47
51
  };
48
52
  this.setElement(element);
53
+ this.dragulaLib = dragula_1.default;
49
54
  this.builderHeight = 0;
50
55
  this.schemas = {};
51
56
  this.repeatablePaths = [];
@@ -8,7 +8,6 @@ const Webform_1 = __importDefault(require("./Webform"));
8
8
  const builder_1 = __importDefault(require("./utils/builder"));
9
9
  const lodash_1 = __importDefault(require("lodash"));
10
10
  const utils_1 = require("./utils/utils");
11
- const dragula_1 = __importDefault(require("dragula"));
12
11
  class WizardBuilder extends WebformBuilder_1.default {
13
12
  constructor() {
14
13
  let element, options;
@@ -148,8 +147,8 @@ class WizardBuilder extends WebformBuilder_1.default {
148
147
  this.refs.gotoPage.forEach((page, index) => {
149
148
  page.parentNode.dragInfo = { index };
150
149
  });
151
- if (dragula_1.default) {
152
- (0, dragula_1.default)([this.element.querySelector('.wizard-pages')])
150
+ if (this.dragulaLib) {
151
+ this.dragulaLib([this.element.querySelector('.wizard-pages')])
153
152
  .on('drop', this.onReorder.bind(this));
154
153
  }
155
154
  this.refs.addPage.forEach(link => {
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const lodash_1 = __importDefault(require("lodash"));
7
7
  const NestedArrayComponent_1 = __importDefault(require("../_classes/nestedarray/NestedArrayComponent"));
8
8
  const utils_1 = require("../../utils/utils");
9
- const dragula_1 = __importDefault(require("dragula"));
10
9
  class DataGridComponent extends NestedArrayComponent_1.default {
11
10
  static schema(...extend) {
12
11
  return NestedArrayComponent_1.default.schema({
@@ -270,8 +269,8 @@ class DataGridComponent extends NestedArrayComponent_1.default {
270
269
  this.refs[`${this.datagridKey}-row`].forEach((row, index) => {
271
270
  row.dragInfo = { index };
272
271
  });
273
- if (dragula_1.default) {
274
- this.dragula = (0, dragula_1.default)([this.refs[`${this.datagridKey}-tbody`]], {
272
+ if (this.root.dragulaLib) {
273
+ this.dragula = this.root.dragulaLib([this.refs[`${this.datagridKey}-tbody`]], {
275
274
  moves: (_draggedElement, _oldParent, clickedElement) => {
276
275
  const clickedElementKey = clickedElement.getAttribute('data-key');
277
276
  const oldParentKey = _oldParent.getAttribute('data-key');
@@ -3,13 +3,9 @@ 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
- const index_1 = __importDefault(require("./index"));
7
6
  const lodash_1 = __importDefault(require("lodash"));
8
7
  class Templates {
9
8
  static get templates() {
10
- if (!Templates._templates) {
11
- Templates._templates = index_1.default;
12
- }
13
9
  return Templates._templates;
14
10
  }
15
11
  static addTemplate(name, template) {
@@ -32,7 +28,7 @@ class Templates {
32
28
  return Templates.defaultTemplates;
33
29
  }
34
30
  static get defaultTemplates() {
35
- return Templates.templates.bootstrap;
31
+ return Templates.templates.hasOwnProperty('bootstrap') ? Templates.templates.bootstrap : {};
36
32
  }
37
33
  static set framework(framework) {
38
34
  if (Templates.templates.hasOwnProperty(framework)) {
@@ -1,5 +1,6 @@
1
1
  export default class WebformBuilder extends Component {
2
2
  constructor(...args: any[]);
3
+ dragulaLib: any;
3
4
  builderHeight: number;
4
5
  schemas: {};
5
6
  repeatablePaths: any[];
@@ -11,6 +11,10 @@ import _ from 'lodash';
11
11
  import autoScroll from 'dom-autoscroller';
12
12
  import Templates from './templates/Templates';
13
13
  import './components/builder';
14
+ // We need this here because dragula pulls in CustomEvent class that requires global to exist.
15
+ if (typeof window !== 'undefined' && typeof window.global === 'undefined') {
16
+ window.global = window;
17
+ }
14
18
  import dragula from 'dragula';
15
19
  export default class WebformBuilder extends Component {
16
20
  // eslint-disable-next-line max-statements
@@ -28,6 +32,7 @@ export default class WebformBuilder extends Component {
28
32
  options.display = options.display || 'form';
29
33
  super(null, options);
30
34
  this.setElement(element);
35
+ this.dragulaLib = dragula;
31
36
  this.builderHeight = 0;
32
37
  this.schemas = {};
33
38
  this.repeatablePaths = [];
@@ -3,7 +3,6 @@ import Webform from './Webform';
3
3
  import BuilderUtils from './utils/builder';
4
4
  import _ from 'lodash';
5
5
  import { fastCloneDeep } from './utils/utils';
6
- import dragula from 'dragula';
7
6
  export default class WizardBuilder extends WebformBuilder {
8
7
  constructor() {
9
8
  let element, options;
@@ -143,8 +142,8 @@ export default class WizardBuilder extends WebformBuilder {
143
142
  this.refs.gotoPage.forEach((page, index) => {
144
143
  page.parentNode.dragInfo = { index };
145
144
  });
146
- if (dragula) {
147
- dragula([this.element.querySelector('.wizard-pages')])
145
+ if (this.dragulaLib) {
146
+ this.dragulaLib([this.element.querySelector('.wizard-pages')])
148
147
  .on('drop', this.onReorder.bind(this));
149
148
  }
150
149
  this.refs.addPage.forEach(link => {
@@ -1,7 +1,6 @@
1
1
  import _ from 'lodash';
2
2
  import NestedArrayComponent from '../_classes/nestedarray/NestedArrayComponent';
3
3
  import { fastCloneDeep, getFocusableElements } from '../../utils/utils';
4
- import dragula from 'dragula';
5
4
  export default class DataGridComponent extends NestedArrayComponent {
6
5
  static schema(...extend) {
7
6
  return NestedArrayComponent.schema({
@@ -268,8 +267,8 @@ export default class DataGridComponent extends NestedArrayComponent {
268
267
  this.refs[`${this.datagridKey}-row`].forEach((row, index) => {
269
268
  row.dragInfo = { index };
270
269
  });
271
- if (dragula) {
272
- this.dragula = dragula([this.refs[`${this.datagridKey}-tbody`]], {
270
+ if (this.root.dragulaLib) {
271
+ this.dragula = this.root.dragulaLib([this.refs[`${this.datagridKey}-tbody`]], {
273
272
  moves: (_draggedElement, _oldParent, clickedElement) => {
274
273
  const clickedElementKey = clickedElement.getAttribute('data-key');
275
274
  const oldParentKey = _oldParent.getAttribute('data-key');
@@ -1,10 +1,6 @@
1
- import templates from './index';
2
1
  import _ from 'lodash';
3
2
  export default class Templates {
4
3
  static get templates() {
5
- if (!Templates._templates) {
6
- Templates._templates = templates;
7
- }
8
4
  return Templates._templates;
9
5
  }
10
6
  static addTemplate(name, template) {
@@ -27,7 +23,7 @@ export default class Templates {
27
23
  return Templates.defaultTemplates;
28
24
  }
29
25
  static get defaultTemplates() {
30
- return Templates.templates.bootstrap;
26
+ return Templates.templates.hasOwnProperty('bootstrap') ? Templates.templates.bootstrap : {};
31
27
  }
32
28
  static set framework(framework) {
33
29
  if (Templates.templates.hasOwnProperty(framework)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.0.0-rc.14",
3
+ "version": "5.0.0-rc.15",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -93,7 +93,7 @@
93
93
  "fast-deep-equal": "^3.1.3",
94
94
  "fast-json-patch": "^3.1.1",
95
95
  "fetch-ponyfill": "^7.1.0",
96
- "i18next": "22.4.12",
96
+ "i18next": "22.5.1",
97
97
  "idb": "^7.1.1",
98
98
  "ismobilejs": "^1.1.1",
99
99
  "json-logic-js": "^2.0.2",
@@ -160,7 +160,7 @@
160
160
  "pretty": "^2.0.0",
161
161
  "pygments-css": "^1.0.0",
162
162
  "raw-loader": "^4.0.2",
163
- "sass": "^1.62.1",
163
+ "sass": "^1.63.2",
164
164
  "shortcut-buttons-flatpickr": "^0.4.0",
165
165
  "sinon": "^15.1.0",
166
166
  "string-replace-loader": "^3.1.0",