@formio/js 5.0.0-dev.5614.ea3660d → 5.0.0-dev.5615.4672b8c
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.
- package/dist/formio.form.js +17 -17
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.full.js +19 -19
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.utils.js +1 -1
- package/dist/formio.utils.min.js +1 -1
- package/lib/cjs/Element.d.ts +2 -1
- package/lib/cjs/Element.js +17 -8
- package/lib/cjs/Form.js +15 -1
- package/lib/cjs/PDF.js +8 -1
- package/lib/cjs/PDFBuilder.js +3 -3
- package/lib/cjs/Webform.d.ts +0 -1
- package/lib/cjs/Webform.js +17 -12
- package/lib/cjs/WebformBuilder.d.ts +0 -1
- package/lib/cjs/WebformBuilder.js +4 -4
- package/lib/cjs/Wizard.js +1 -1
- package/lib/cjs/addons/FormioAddon.d.ts +1 -0
- package/lib/cjs/components/_classes/component/Component.d.ts +2 -1
- package/lib/cjs/components/_classes/component/Component.js +44 -6
- package/lib/cjs/components/_classes/input/Input.js +16 -1
- package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +2 -2
- package/lib/cjs/components/_classes/nested/NestedComponent.js +8 -7
- package/lib/cjs/components/columns/Columns.js +2 -2
- package/lib/cjs/components/editgrid/EditGrid.d.ts +1 -1
- package/lib/cjs/components/editgrid/EditGrid.js +21 -7
- package/lib/cjs/components/file/File.d.ts +1 -0
- package/lib/cjs/components/file/File.js +2 -2
- package/lib/cjs/components/form/Form.js +3 -3
- package/lib/cjs/components/select/Select.js +4 -2
- package/lib/cjs/components/table/Table.d.ts +0 -1
- package/lib/cjs/components/table/Table.js +1 -1
- package/lib/cjs/components/tags/Tags.js +4 -2
- package/lib/cjs/utils/utils.d.ts +1 -1
- package/lib/cjs/utils/utils.js +14 -2
- package/lib/cjs/widgets/CalendarWidget.js +2 -2
- package/lib/mjs/Element.d.ts +2 -1
- package/lib/mjs/Element.js +17 -8
- package/lib/mjs/Form.js +15 -1
- package/lib/mjs/PDF.js +8 -1
- package/lib/mjs/PDFBuilder.js +3 -3
- package/lib/mjs/Webform.d.ts +0 -1
- package/lib/mjs/Webform.js +17 -12
- package/lib/mjs/WebformBuilder.d.ts +0 -1
- package/lib/mjs/WebformBuilder.js +4 -4
- package/lib/mjs/Wizard.js +1 -1
- package/lib/mjs/addons/FormioAddon.d.ts +1 -0
- package/lib/mjs/components/_classes/component/Component.d.ts +2 -1
- package/lib/mjs/components/_classes/component/Component.js +44 -6
- package/lib/mjs/components/_classes/input/Input.js +16 -1
- package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +2 -2
- package/lib/mjs/components/_classes/nested/NestedComponent.js +8 -7
- package/lib/mjs/components/columns/Columns.js +2 -2
- package/lib/mjs/components/editgrid/EditGrid.d.ts +1 -1
- package/lib/mjs/components/editgrid/EditGrid.js +20 -7
- package/lib/mjs/components/file/File.d.ts +1 -0
- package/lib/mjs/components/file/File.js +2 -2
- package/lib/mjs/components/form/Form.js +3 -3
- package/lib/mjs/components/select/Select.js +4 -2
- package/lib/mjs/components/table/Table.d.ts +0 -1
- package/lib/mjs/components/table/Table.js +1 -1
- package/lib/mjs/components/tags/Tags.js +4 -2
- package/lib/mjs/utils/utils.d.ts +1 -1
- package/lib/mjs/utils/utils.js +2 -1
- package/lib/mjs/widgets/CalendarWidget.js +2 -2
- package/package.json +1 -1
package/lib/cjs/utils/utils.d.ts
CHANGED
|
@@ -374,4 +374,4 @@ import jsonLogic from 'json-logic-js';
|
|
|
374
374
|
import ConditionOperators from './conditionOperators';
|
|
375
375
|
import Evaluator from './Evaluator';
|
|
376
376
|
export const interpolate: (rawTemplate: any, data: any, _options: any) => any;
|
|
377
|
-
export { jsonLogic,
|
|
377
|
+
export { jsonLogic, ConditionOperators, Evaluator, _ };
|
package/lib/cjs/utils/utils.js
CHANGED
|
@@ -11,14 +11,26 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
11
11
|
if (k2 === undefined) k2 = k;
|
|
12
12
|
o[k2] = m[k];
|
|
13
13
|
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
14
19
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
20
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
21
|
};
|
|
22
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
23
|
+
if (mod && mod.__esModule) return mod;
|
|
24
|
+
var result = {};
|
|
25
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
26
|
+
__setModuleDefault(result, mod);
|
|
27
|
+
return result;
|
|
28
|
+
};
|
|
17
29
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
30
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
31
|
};
|
|
20
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
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.convertFormatToMoment = exports.convertFormatToFlatpickr = exports.getLocaleDateFormatInfo = exports.formatOffset = exports.formatDate = exports.momentDate = exports.loadZones = exports.shouldLoadZones = exports.zonesLoaded = exports.offsetDate = exports.currentTimezone = exports.isValidDate = exports.getDateSetting = exports.guid = exports.uniqueName = exports.convertStringToHTMLElement = exports.unescapeHTML = exports.setActionProperty = exports.checkTrigger = exports.checkCondition = exports.checkJsonConditional = exports.checkCustomConditional = exports.getComponentActualValue = exports.checkSimpleConditional = exports.checkCalculated = exports.isMongoId = exports.boolValue = exports.getElementRect = exports.getPropertyValue = exports.getRandomComponentId = exports.evaluate = exports.
|
|
33
|
+
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.convertFormatToMoment = exports.convertFormatToFlatpickr = exports.getLocaleDateFormatInfo = exports.formatOffset = exports.formatDate = exports.momentDate = exports.loadZones = exports.shouldLoadZones = exports.zonesLoaded = exports.offsetDate = exports.currentTimezone = exports.isValidDate = exports.getDateSetting = exports.guid = exports.uniqueName = exports.convertStringToHTMLElement = exports.unescapeHTML = exports.setActionProperty = exports.checkTrigger = exports.checkCondition = exports.checkJsonConditional = exports.checkCustomConditional = exports.getComponentActualValue = exports.checkSimpleConditional = exports.checkCalculated = exports.isMongoId = exports.boolValue = exports.getElementRect = exports.getPropertyValue = exports.getRandomComponentId = exports.evaluate = exports.moment = exports.ConditionOperators = exports.jsonLogic = void 0;
|
|
22
34
|
exports.isSelectResourceWithObjectValue = exports.getItemTemplateKeys = exports.interpolateErrors = exports.getComponentSavedTypes = exports.componentValueTypes = exports._ = exports.getFocusableElements = exports.isInsideScopingComponent = exports.isPromise = exports.getDataParentComponent = exports.getComponentPath = exports.getComponentPathWithoutIndicies = exports.getBrowserInfo = exports.getIEBrowserVersion = exports.round = exports.getStringFromComponentPath = exports.isChildOf = exports.getArrayFromComponentPath = exports.isInputComponent = exports.interpolate = exports.Evaluator = exports.fastCloneDeep = exports.sanitize = exports.translateHTMLTemplate = exports.getContextButtons = exports.getContextComponents = void 0;
|
|
23
35
|
const lodash_1 = __importDefault(require("lodash"));
|
|
24
36
|
exports._ = lodash_1.default;
|
|
@@ -26,7 +38,6 @@ const fetch_ponyfill_1 = __importDefault(require("fetch-ponyfill"));
|
|
|
26
38
|
const json_logic_js_1 = __importDefault(require("json-logic-js"));
|
|
27
39
|
exports.jsonLogic = json_logic_js_1.default;
|
|
28
40
|
const moment_timezone_1 = __importDefault(require("moment-timezone/moment-timezone"));
|
|
29
|
-
exports.moment = moment_timezone_1.default;
|
|
30
41
|
const jstimezonedetect_1 = __importDefault(require("jstimezonedetect"));
|
|
31
42
|
const operators_1 = require("./jsonlogic/operators");
|
|
32
43
|
const dompurify_1 = __importDefault(require("dompurify"));
|
|
@@ -55,6 +66,7 @@ json_logic_js_1.default.add_operation('relativeMinDate', (relativeMinDate) => {
|
|
|
55
66
|
json_logic_js_1.default.add_operation('relativeMaxDate', (relativeMaxDate) => {
|
|
56
67
|
return (0, moment_timezone_1.default)().add(relativeMaxDate, 'days').toISOString();
|
|
57
68
|
});
|
|
69
|
+
exports.moment = __importStar(require("moment-timezone/moment-timezone"));
|
|
58
70
|
function setPathToComponentAndPerentSchema(component) {
|
|
59
71
|
component.path = getComponentPath(component);
|
|
60
72
|
const dataParent = getDataParentComponent(component);
|
|
@@ -467,11 +467,11 @@ class CalendarWidget extends InputWidget_1.default {
|
|
|
467
467
|
return Flatpickr.formatDate(date, format);
|
|
468
468
|
};
|
|
469
469
|
}
|
|
470
|
-
destroy() {
|
|
471
|
-
super.destroy();
|
|
470
|
+
destroy(all = false) {
|
|
472
471
|
if (this.calendar) {
|
|
473
472
|
this.calendar.destroy();
|
|
474
473
|
}
|
|
474
|
+
super.destroy(all);
|
|
475
475
|
}
|
|
476
476
|
}
|
|
477
477
|
exports.default = CalendarWidget;
|
package/lib/mjs/Element.d.ts
CHANGED
|
@@ -117,10 +117,11 @@ export default class Element {
|
|
|
117
117
|
removeEventListener(obj: any, type: any, func?: null): this | undefined;
|
|
118
118
|
removeEventListeners(): void;
|
|
119
119
|
removeAllEvents(includeExternal: any): void;
|
|
120
|
+
teardown(): void;
|
|
120
121
|
/**
|
|
121
122
|
* Removes all event listeners attached to this component.
|
|
122
123
|
*/
|
|
123
|
-
destroy(): void;
|
|
124
|
+
destroy(all?: boolean): void;
|
|
124
125
|
/**
|
|
125
126
|
* Append an HTML DOM element to a container.
|
|
126
127
|
*
|
package/lib/mjs/Element.js
CHANGED
|
@@ -230,20 +230,29 @@ export default class Element {
|
|
|
230
230
|
this.eventHandlers = [];
|
|
231
231
|
}
|
|
232
232
|
removeAllEvents(includeExternal) {
|
|
233
|
-
|
|
234
|
-
_.each(events, (
|
|
235
|
-
|
|
236
|
-
this.
|
|
237
|
-
|
|
233
|
+
if (this.events) {
|
|
234
|
+
_.each(this.events._events, (events, type) => {
|
|
235
|
+
_.each(events, (listener) => {
|
|
236
|
+
if (listener && (this.id === listener.id) && (includeExternal || listener.internal)) {
|
|
237
|
+
this.events.off(type, listener);
|
|
238
|
+
}
|
|
239
|
+
});
|
|
238
240
|
});
|
|
239
|
-
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
teardown() {
|
|
244
|
+
delete this.i18next;
|
|
245
|
+
delete this.events;
|
|
240
246
|
}
|
|
241
247
|
/**
|
|
242
248
|
* Removes all event listeners attached to this component.
|
|
243
249
|
*/
|
|
244
|
-
destroy() {
|
|
250
|
+
destroy(all = false) {
|
|
245
251
|
this.removeEventListeners();
|
|
246
252
|
this.removeAllEvents();
|
|
253
|
+
if (all) {
|
|
254
|
+
this.teardown();
|
|
255
|
+
}
|
|
247
256
|
}
|
|
248
257
|
/**
|
|
249
258
|
* Append an HTML DOM element to a container.
|
|
@@ -387,7 +396,7 @@ export default class Element {
|
|
|
387
396
|
* @param {Object} params - The i18n parameters to use for translation.
|
|
388
397
|
*/
|
|
389
398
|
t(text, ...args) {
|
|
390
|
-
return this.i18next.t(text, ...args);
|
|
399
|
+
return this.i18next ? this.i18next.t(text, ...args) : text;
|
|
391
400
|
}
|
|
392
401
|
/**
|
|
393
402
|
* Alias to create a text node.
|
package/lib/mjs/Form.js
CHANGED
|
@@ -35,6 +35,9 @@ export default class Form extends Element {
|
|
|
35
35
|
});
|
|
36
36
|
this.instance = null;
|
|
37
37
|
if (args[0] instanceof HTMLElement) {
|
|
38
|
+
if (this.element) {
|
|
39
|
+
delete this.element.component;
|
|
40
|
+
}
|
|
38
41
|
this.element = args[0];
|
|
39
42
|
this.options = args[2] || {};
|
|
40
43
|
this.options.events = this.events;
|
|
@@ -126,7 +129,7 @@ export default class Form extends Element {
|
|
|
126
129
|
* @return {*}
|
|
127
130
|
*/
|
|
128
131
|
set form(formParam) {
|
|
129
|
-
|
|
132
|
+
this.setForm(formParam);
|
|
130
133
|
}
|
|
131
134
|
errorForm(err) {
|
|
132
135
|
return {
|
|
@@ -224,6 +227,9 @@ export default class Form extends Element {
|
|
|
224
227
|
}
|
|
225
228
|
// A redraw has occurred so save off the new element in case of a setDisplay causing a rebuild.
|
|
226
229
|
return result.then(() => {
|
|
230
|
+
if (this.element) {
|
|
231
|
+
delete this.element.component;
|
|
232
|
+
}
|
|
227
233
|
this.element = this.instance.element;
|
|
228
234
|
return this.instance;
|
|
229
235
|
});
|
|
@@ -344,6 +350,9 @@ export default class Form extends Element {
|
|
|
344
350
|
if (!this.instance) {
|
|
345
351
|
return Promise.reject('Form not ready. Use form.ready promise');
|
|
346
352
|
}
|
|
353
|
+
if (this.element) {
|
|
354
|
+
delete this.element.component;
|
|
355
|
+
}
|
|
347
356
|
this.element = element;
|
|
348
357
|
return this.instance.attach(this.element)
|
|
349
358
|
.then((param) => {
|
|
@@ -351,6 +360,11 @@ export default class Form extends Element {
|
|
|
351
360
|
return param;
|
|
352
361
|
});
|
|
353
362
|
}
|
|
363
|
+
teardown() {
|
|
364
|
+
super.teardown();
|
|
365
|
+
delete this.instance;
|
|
366
|
+
delete this.ready;
|
|
367
|
+
}
|
|
354
368
|
}
|
|
355
369
|
// Allow simple embedding.
|
|
356
370
|
Formio.embedForm = (embed) => Form.embed(embed);
|
package/lib/mjs/PDF.js
CHANGED
|
@@ -57,8 +57,15 @@ export default class PDF extends Webform {
|
|
|
57
57
|
this.postMessage({ name: 'redraw' });
|
|
58
58
|
return this.builderMode ? Promise.resolve() : super.redraw();
|
|
59
59
|
}
|
|
60
|
+
destroy(all = false) {
|
|
61
|
+
if (this.iframeElement) {
|
|
62
|
+
delete this.iframeElement.formioComponent;
|
|
63
|
+
this.iframeElement.formioComponent = null;
|
|
64
|
+
}
|
|
65
|
+
super.destroy(all);
|
|
66
|
+
}
|
|
60
67
|
rebuild() {
|
|
61
|
-
if (this.builderMode && this.component.components) {
|
|
68
|
+
if (this.attached && this.builderMode && this.component.components) {
|
|
62
69
|
this.destroyComponents();
|
|
63
70
|
this.addComponents();
|
|
64
71
|
return Promise.resolve();
|
package/lib/mjs/PDFBuilder.js
CHANGED
|
@@ -251,9 +251,9 @@ export default class PDFBuilder extends WebformBuilder {
|
|
|
251
251
|
});
|
|
252
252
|
return this.webform;
|
|
253
253
|
}
|
|
254
|
-
destroy(
|
|
255
|
-
super.destroy(
|
|
256
|
-
this.webform.destroy(
|
|
254
|
+
destroy(all = false) {
|
|
255
|
+
super.destroy(all);
|
|
256
|
+
this.webform.destroy(all);
|
|
257
257
|
}
|
|
258
258
|
// d8b 8888888888 888
|
|
259
259
|
// Y8P 888 888
|
package/lib/mjs/Webform.d.ts
CHANGED
|
@@ -382,7 +382,6 @@ declare class Webform extends NestedDataComponent {
|
|
|
382
382
|
*/
|
|
383
383
|
init(): Promise<any>;
|
|
384
384
|
executeFormController(): false | undefined;
|
|
385
|
-
destroy(deleteFromGlobal?: boolean): void;
|
|
386
385
|
build(element: any): Promise<any>;
|
|
387
386
|
getClassName(): string;
|
|
388
387
|
render(): any;
|
package/lib/mjs/Webform.js
CHANGED
|
@@ -142,7 +142,7 @@ export default class Webform extends NestedDataComponent {
|
|
|
142
142
|
formOptions = elementOrOptions;
|
|
143
143
|
}
|
|
144
144
|
super(null, getOptions(formOptions));
|
|
145
|
-
this.element
|
|
145
|
+
this.setElement(element);
|
|
146
146
|
// Keep track of all available forms globally.
|
|
147
147
|
Formio.forms[this.id] = this;
|
|
148
148
|
// Set the base url.
|
|
@@ -331,10 +331,12 @@ export default class Webform extends NestedDataComponent {
|
|
|
331
331
|
* @return {*}
|
|
332
332
|
*/
|
|
333
333
|
addLanguage(code, lang, active = false) {
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
334
|
+
if (this.i18next) {
|
|
335
|
+
var translations = _.assign(fastCloneDeep(i18nDefaults.resources.en.translation), lang);
|
|
336
|
+
this.i18next.addResourceBundle(code, 'translation', translations, true, true);
|
|
337
|
+
if (active) {
|
|
338
|
+
this.language = code;
|
|
339
|
+
}
|
|
338
340
|
}
|
|
339
341
|
}
|
|
340
342
|
keyboardCatchableElement(element) {
|
|
@@ -913,18 +915,21 @@ export default class Webform extends NestedDataComponent {
|
|
|
913
915
|
});
|
|
914
916
|
});
|
|
915
917
|
}
|
|
916
|
-
|
|
918
|
+
teardown() {
|
|
919
|
+
this.emit('formDelete', this.id);
|
|
920
|
+
delete Formio.forms[this.id];
|
|
921
|
+
delete this.executeShortcuts;
|
|
922
|
+
delete this.triggerSaveDraft;
|
|
923
|
+
super.teardown();
|
|
924
|
+
}
|
|
925
|
+
destroy(all = false) {
|
|
917
926
|
this.off('submitButton');
|
|
918
927
|
this.off('checkValidity');
|
|
919
928
|
this.off('requestUrl');
|
|
920
929
|
this.off('resetForm');
|
|
921
930
|
this.off('deleteSubmission');
|
|
922
931
|
this.off('refreshData');
|
|
923
|
-
|
|
924
|
-
this.emit('formDelete', this.id);
|
|
925
|
-
delete Formio.forms[this.id];
|
|
926
|
-
}
|
|
927
|
-
return super.destroy();
|
|
932
|
+
return super.destroy(all);
|
|
928
933
|
}
|
|
929
934
|
build(element) {
|
|
930
935
|
if (element || this.element) {
|
|
@@ -958,7 +963,7 @@ export default class Webform extends NestedDataComponent {
|
|
|
958
963
|
return this.attach(this.element);
|
|
959
964
|
}
|
|
960
965
|
attach(element) {
|
|
961
|
-
this.element
|
|
966
|
+
this.setElement(element);
|
|
962
967
|
this.loadRefs(element, { webform: 'single' });
|
|
963
968
|
const childPromise = this.attachComponents(this.refs.webform);
|
|
964
969
|
this.addEventListener(document, 'keydown', this.executeShortcuts);
|
|
@@ -118,7 +118,6 @@ export default class WebformBuilder extends Component {
|
|
|
118
118
|
isParentSaveChildMethod(parentComp: any): boolean;
|
|
119
119
|
getParentElement(element: any): any;
|
|
120
120
|
addBuilderComponentInfo(component: any): any;
|
|
121
|
-
destroy(deleteFromGlobal: any): void;
|
|
122
121
|
addBuilderGroup(name: any, group: any): void;
|
|
123
122
|
updateBuilderGroup(name: any, group: any): void;
|
|
124
123
|
generateKey(info: any): any;
|
|
@@ -30,7 +30,7 @@ export default class WebformBuilder extends Component {
|
|
|
30
30
|
options.skipInit = false;
|
|
31
31
|
options.display = options.display || 'form';
|
|
32
32
|
super(null, options);
|
|
33
|
-
this.element
|
|
33
|
+
this.setElement(element);
|
|
34
34
|
this.dragulaLib = dragula;
|
|
35
35
|
this.builderHeight = 0;
|
|
36
36
|
this.schemas = {};
|
|
@@ -1584,11 +1584,11 @@ export default class WebformBuilder extends Component {
|
|
|
1584
1584
|
this.webform.clear();
|
|
1585
1585
|
}
|
|
1586
1586
|
}
|
|
1587
|
-
destroy(
|
|
1587
|
+
destroy(all = false) {
|
|
1588
1588
|
if (this.webform.initialized) {
|
|
1589
|
-
this.webform.destroy(
|
|
1589
|
+
this.webform.destroy(all);
|
|
1590
1590
|
}
|
|
1591
|
-
super.destroy(
|
|
1591
|
+
super.destroy(all);
|
|
1592
1592
|
}
|
|
1593
1593
|
addBuilderGroup(name, group) {
|
|
1594
1594
|
if (!this.groups[name]) {
|
package/lib/mjs/Wizard.js
CHANGED
|
@@ -335,7 +335,6 @@ declare class Component extends Element {
|
|
|
335
335
|
createComponentModal(element: any, modalShouldBeOpened: any, currentValue: any): ComponentModal;
|
|
336
336
|
attach(element: any): Promise<void>;
|
|
337
337
|
componentModal: any;
|
|
338
|
-
element: any;
|
|
339
338
|
restoreFocus(): void;
|
|
340
339
|
addShortcut(element: any, shortcut: any): void;
|
|
341
340
|
removeShortcut(element: any, shortcut: any): void;
|
|
@@ -364,6 +363,8 @@ declare class Component extends Element {
|
|
|
364
363
|
*/
|
|
365
364
|
inContext(component: any): boolean;
|
|
366
365
|
get viewOnly(): any;
|
|
366
|
+
setElement(element: any): void;
|
|
367
|
+
element: any;
|
|
367
368
|
createViewOnlyElement(): any;
|
|
368
369
|
get defaultViewOnlyValue(): string;
|
|
369
370
|
/**
|
|
@@ -498,10 +498,30 @@ export default class Component extends Element {
|
|
|
498
498
|
}
|
|
499
499
|
return addon;
|
|
500
500
|
}
|
|
501
|
-
|
|
502
|
-
|
|
501
|
+
teardown() {
|
|
502
|
+
if (this.element) {
|
|
503
|
+
delete this.element.component;
|
|
504
|
+
delete this.element;
|
|
505
|
+
}
|
|
506
|
+
delete this._currentForm;
|
|
507
|
+
delete this.parent;
|
|
508
|
+
delete this.root;
|
|
509
|
+
delete this.triggerChange;
|
|
510
|
+
delete this.triggerRedraw;
|
|
511
|
+
if (this.options) {
|
|
512
|
+
delete this.options.root;
|
|
513
|
+
delete this.options.parent;
|
|
514
|
+
delete this.options.i18next;
|
|
515
|
+
}
|
|
516
|
+
super.teardown();
|
|
517
|
+
}
|
|
518
|
+
destroy(all = false) {
|
|
519
|
+
super.destroy(all);
|
|
503
520
|
this.detach();
|
|
504
521
|
this.addons.forEach((addon) => addon.destroy());
|
|
522
|
+
if (all) {
|
|
523
|
+
this.teardown();
|
|
524
|
+
}
|
|
505
525
|
}
|
|
506
526
|
get shouldDisabled() {
|
|
507
527
|
return this.options.readOnly || this.component.disabled || (this.options.hasOwnProperty('disabled') && this.options.disabled[this.key]);
|
|
@@ -1052,7 +1072,7 @@ export default class Component extends Element {
|
|
|
1052
1072
|
this.setOpenModalElement(openModalTemplate);
|
|
1053
1073
|
}
|
|
1054
1074
|
this.attached = true;
|
|
1055
|
-
this.element
|
|
1075
|
+
this.setElement(element);
|
|
1056
1076
|
element.component = this;
|
|
1057
1077
|
// If this already has an id, get it from the dom. If SSR, it could be different from the initiated id.
|
|
1058
1078
|
if (this.element.id) {
|
|
@@ -1110,6 +1130,17 @@ export default class Component extends Element {
|
|
|
1110
1130
|
* Remove all event handlers.
|
|
1111
1131
|
*/
|
|
1112
1132
|
detach() {
|
|
1133
|
+
// First iterate through each ref and delete the component so there are no dangling component references.
|
|
1134
|
+
_.each(this.refs, (ref) => {
|
|
1135
|
+
if (typeof ref === NodeList) {
|
|
1136
|
+
ref.forEach((elem) => {
|
|
1137
|
+
delete elem.component;
|
|
1138
|
+
});
|
|
1139
|
+
}
|
|
1140
|
+
else if (ref) {
|
|
1141
|
+
delete ref.component;
|
|
1142
|
+
}
|
|
1143
|
+
});
|
|
1113
1144
|
this.refs = {};
|
|
1114
1145
|
this.removeEventListeners();
|
|
1115
1146
|
this.detachLogic();
|
|
@@ -1197,10 +1228,17 @@ export default class Component extends Element {
|
|
|
1197
1228
|
get viewOnly() {
|
|
1198
1229
|
return this.options.readOnly && this.options.viewAsHtml;
|
|
1199
1230
|
}
|
|
1231
|
+
setElement(element) {
|
|
1232
|
+
if (this.element) {
|
|
1233
|
+
delete this.element.component;
|
|
1234
|
+
delete this.element;
|
|
1235
|
+
}
|
|
1236
|
+
this.element = element;
|
|
1237
|
+
}
|
|
1200
1238
|
createViewOnlyElement() {
|
|
1201
|
-
this.
|
|
1239
|
+
this.setElement(this.ce('dl', {
|
|
1202
1240
|
id: this.id
|
|
1203
|
-
});
|
|
1241
|
+
}));
|
|
1204
1242
|
if (this.element) {
|
|
1205
1243
|
// Ensure you can get the component info from the element.
|
|
1206
1244
|
this.element.component = this;
|
|
@@ -1518,7 +1556,7 @@ export default class Component extends Element {
|
|
|
1518
1556
|
const parent = this.element.parentNode;
|
|
1519
1557
|
const index = Array.prototype.indexOf.call(parent.children, this.element);
|
|
1520
1558
|
this.element.outerHTML = this.sanitize(this.render());
|
|
1521
|
-
this.
|
|
1559
|
+
this.setElement(parent.children[index]);
|
|
1522
1560
|
return this.attach(this.element);
|
|
1523
1561
|
}
|
|
1524
1562
|
rebuild() {
|
|
@@ -266,8 +266,22 @@ export default class Input extends Multivalue {
|
|
|
266
266
|
widget.on('redraw', () => this.redraw(), true);
|
|
267
267
|
return widget;
|
|
268
268
|
}
|
|
269
|
+
teardown() {
|
|
270
|
+
if (this.element && this.element.widget) {
|
|
271
|
+
this.element.widget.destroy();
|
|
272
|
+
delete this.element.widget;
|
|
273
|
+
}
|
|
274
|
+
if (this.refs && this.refs.input) {
|
|
275
|
+
for (let i = 0; i <= this.refs.input.length; i++) {
|
|
276
|
+
const widget = this.getWidget(i);
|
|
277
|
+
if (widget) {
|
|
278
|
+
widget.destroy();
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
super.teardown();
|
|
283
|
+
}
|
|
269
284
|
detach() {
|
|
270
|
-
super.detach();
|
|
271
285
|
if (this.refs && this.refs.input) {
|
|
272
286
|
for (let i = 0; i <= this.refs.input.length; i++) {
|
|
273
287
|
const widget = this.getWidget(i);
|
|
@@ -277,5 +291,6 @@ export default class Input extends Multivalue {
|
|
|
277
291
|
}
|
|
278
292
|
}
|
|
279
293
|
this.refs.input = [];
|
|
294
|
+
super.detach();
|
|
280
295
|
}
|
|
281
296
|
}
|
|
@@ -82,7 +82,7 @@ export default class NestedComponent extends Field {
|
|
|
82
82
|
* @param {Component} component - The component to remove from the components.
|
|
83
83
|
* @param {Array<Component>} components - An array of components to remove this component from.
|
|
84
84
|
*/
|
|
85
|
-
removeComponent(component: Component, components: Array<Component
|
|
85
|
+
removeComponent(component: Component, components: Array<Component>, all?: boolean): void;
|
|
86
86
|
/**
|
|
87
87
|
* Removes a component provided the API key of that component.
|
|
88
88
|
*
|
|
@@ -140,7 +140,7 @@ export default class NestedComponent extends Field {
|
|
|
140
140
|
checkAsyncValidity(data: any, dirty: any, row: any, silentCheck: any): Promise<any>;
|
|
141
141
|
setPristine(pristine: any): void;
|
|
142
142
|
get isPristine(): any;
|
|
143
|
-
destroyComponents(): void;
|
|
143
|
+
destroyComponents(all?: boolean): void;
|
|
144
144
|
get visibleErrors(): any;
|
|
145
145
|
get errors(): any;
|
|
146
146
|
get dataReady(): Promise<any[]>;
|
|
@@ -325,6 +325,7 @@ export default class NestedComponent extends Field {
|
|
|
325
325
|
*/
|
|
326
326
|
addComponents(data, options) {
|
|
327
327
|
data = data || this.data;
|
|
328
|
+
this.components = this.components || [];
|
|
328
329
|
options = options || this.options;
|
|
329
330
|
if (options.components) {
|
|
330
331
|
this.components = options.components;
|
|
@@ -436,9 +437,9 @@ export default class NestedComponent extends Field {
|
|
|
436
437
|
* @param {Component} component - The component to remove from the components.
|
|
437
438
|
* @param {Array<Component>} components - An array of components to remove this component from.
|
|
438
439
|
*/
|
|
439
|
-
removeComponent(component, components) {
|
|
440
|
+
removeComponent(component, components, all = false) {
|
|
440
441
|
components = components || this.components;
|
|
441
|
-
component.destroy();
|
|
442
|
+
component.destroy(all);
|
|
442
443
|
_.remove(components, { id: component.id });
|
|
443
444
|
if (this.componentsMap[component.path]) {
|
|
444
445
|
delete this.componentsMap[component.path];
|
|
@@ -663,13 +664,13 @@ export default class NestedComponent extends Field {
|
|
|
663
664
|
});
|
|
664
665
|
super.clear();
|
|
665
666
|
}
|
|
666
|
-
destroy() {
|
|
667
|
-
this.destroyComponents();
|
|
668
|
-
super.destroy();
|
|
667
|
+
destroy(all = false) {
|
|
668
|
+
this.destroyComponents(all);
|
|
669
|
+
super.destroy(all);
|
|
669
670
|
}
|
|
670
|
-
destroyComponents() {
|
|
671
|
+
destroyComponents(all = false) {
|
|
671
672
|
const components = this.getComponents().slice();
|
|
672
|
-
components.forEach((comp) => this.removeComponent(comp, this.components));
|
|
673
|
+
components.forEach((comp) => this.removeComponent(comp, this.components, all));
|
|
673
674
|
this.components = [];
|
|
674
675
|
}
|
|
675
676
|
get visibleErrors() {
|
|
@@ -52,7 +52,7 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
|
52
52
|
renderRow(row: any, rowIndex: any): any;
|
|
53
53
|
eachComponent(fn: any, rowIndex: any): void;
|
|
54
54
|
flattenComponents(rowIndex: any): {};
|
|
55
|
-
destroyComponents(rowIndex
|
|
55
|
+
destroyComponents(all?: boolean, rowIndex?: number): void;
|
|
56
56
|
createRow(dataObj: any, rowIndex: any): {
|
|
57
57
|
components: any;
|
|
58
58
|
data: any;
|
|
@@ -567,15 +567,19 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
|
567
567
|
return this.builderMode
|
|
568
568
|
? super.getComponents()
|
|
569
569
|
: _.isNumber(rowIndex)
|
|
570
|
-
? (this.editRows[rowIndex]
|
|
570
|
+
? (this.editRows[rowIndex]?.components || [])
|
|
571
571
|
: this.editRows.reduce((result, row) => result.concat(row.components || []), []);
|
|
572
572
|
}
|
|
573
|
-
|
|
573
|
+
destroy(all = false) {
|
|
574
|
+
this.calculatedValue = undefined;
|
|
575
|
+
super.destroy(all);
|
|
576
|
+
}
|
|
577
|
+
destroyComponents(all = false, rowIndex = 0) {
|
|
574
578
|
if (this.builderMode) {
|
|
575
|
-
return super.destroyComponents();
|
|
579
|
+
return super.destroyComponents(all);
|
|
576
580
|
}
|
|
577
581
|
const components = this.getComponents(rowIndex).slice();
|
|
578
|
-
components.forEach((comp) => this.removeComponent(comp, this.components));
|
|
582
|
+
components.forEach((comp) => this.removeComponent(comp, this.components, all));
|
|
579
583
|
}
|
|
580
584
|
createRow(dataObj, rowIndex) {
|
|
581
585
|
const editRow = {
|
|
@@ -748,7 +752,7 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
|
748
752
|
case EditRowState.New: {
|
|
749
753
|
editRow.state = EditRowState.Removed;
|
|
750
754
|
this.clearErrors(rowIndex);
|
|
751
|
-
this.destroyComponents(rowIndex);
|
|
755
|
+
this.destroyComponents(false, rowIndex);
|
|
752
756
|
if (this.inlineEditMode) {
|
|
753
757
|
this.splice(rowIndex);
|
|
754
758
|
}
|
|
@@ -866,7 +870,7 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
|
866
870
|
baseRemoveRow(rowIndex) {
|
|
867
871
|
const editRow = this.editRows[rowIndex];
|
|
868
872
|
editRow.state = EditRowState.Removed;
|
|
869
|
-
this.destroyComponents(rowIndex);
|
|
873
|
+
this.destroyComponents(false, rowIndex);
|
|
870
874
|
return editRow;
|
|
871
875
|
}
|
|
872
876
|
removeRow(rowIndex, modified) {
|
|
@@ -889,6 +893,15 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
|
889
893
|
this.redraw();
|
|
890
894
|
}
|
|
891
895
|
createRowComponents(row, rowIndex, recreatePartially) {
|
|
896
|
+
// Iterate through existing components and destroy the ones with the same rowIndex.
|
|
897
|
+
if (this.components) {
|
|
898
|
+
for (let i = 0; i < this.components.length; i++) {
|
|
899
|
+
if (this.components[i].rowIndex === rowIndex) {
|
|
900
|
+
this.components[i].destroy();
|
|
901
|
+
this.components.splice(i, 1);
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
}
|
|
892
905
|
const currentRowComponents = _.get(this.editRows, `[${rowIndex}].components`, null);
|
|
893
906
|
return this.component.components.map((col, colIndex) => {
|
|
894
907
|
if (recreatePartially && currentRowComponents && this.variableTypeComponentsIndexes.length) {
|
|
@@ -1168,7 +1181,7 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
|
1168
1181
|
});
|
|
1169
1182
|
}
|
|
1170
1183
|
emptyRows() {
|
|
1171
|
-
this.editRows.forEach((editRow, index) => this.destroyComponents(index));
|
|
1184
|
+
this.editRows.forEach((editRow, index) => this.destroyComponents(false, index));
|
|
1172
1185
|
this.editRows = [];
|
|
1173
1186
|
}
|
|
1174
1187
|
resetValue() {
|
|
@@ -329,13 +329,13 @@ export default class FormComponent extends Component {
|
|
|
329
329
|
&& _.isNumber(this.formObj._vid)
|
|
330
330
|
&& this.formObj._vid !== this.subFormRevision;
|
|
331
331
|
}
|
|
332
|
-
destroy() {
|
|
332
|
+
destroy(all = false) {
|
|
333
333
|
if (this.subForm) {
|
|
334
|
-
this.subForm.destroy();
|
|
334
|
+
this.subForm.destroy(all);
|
|
335
335
|
this.subForm = null;
|
|
336
336
|
this.subFormReady = null;
|
|
337
337
|
}
|
|
338
|
-
super.destroy();
|
|
338
|
+
super.destroy(all);
|
|
339
339
|
}
|
|
340
340
|
redraw() {
|
|
341
341
|
if (this.subForm) {
|