devextreme-angular
Version:
Angular UI and visualization components based on DevExtreme widgets
1,070 lines (1,057 loc) • 70.2 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/platform-browser'), require('devextreme/core/dom_adapter'), require('devextreme/events'), require('devextreme/core/renderer'), require('devextreme/core/utils/common'), require('devextreme/core/http_request'), require('devextreme/core/utils/ready_callbacks'), require('devextreme/events/core/events_engine'), require('devextreme/core/utils/ajax'), require('devextreme/core/utils/deferred')) :
typeof define === 'function' && define.amd ? define('devextreme-angular/core', ['exports', '@angular/core', '@angular/common', '@angular/platform-browser', 'devextreme/core/dom_adapter', 'devextreme/events', 'devextreme/core/renderer', 'devextreme/core/utils/common', 'devextreme/core/http_request', 'devextreme/core/utils/ready_callbacks', 'devextreme/events/core/events_engine', 'devextreme/core/utils/ajax', 'devextreme/core/utils/deferred'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global["devextreme-angular"] = global["devextreme-angular"] || {}, global["devextreme-angular"].core = {}), global.ng.core, global.ng.common, global.ng.platformBrowser, global.domAdapter, global.events, global.render, global.common, global.httpRequest, global.readyCallbacks, global.eventsEngine, global.ajax, global.deferred));
})(this, (function (exports, i0, i1, i3, domAdapter, events, render, common, httpRequest, readyCallbacks, eventsEngine, ajax, deferred) { 'use strict';
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
function _interopNamespace(e) {
if (e && e.__esModule) return e;
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n["default"] = e;
return Object.freeze(n);
}
var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
var i3__namespace = /*#__PURE__*/_interopNamespace(i3);
var domAdapter__default = /*#__PURE__*/_interopDefaultLegacy(domAdapter);
var render__default = /*#__PURE__*/_interopDefaultLegacy(render);
var httpRequest__default = /*#__PURE__*/_interopDefaultLegacy(httpRequest);
var readyCallbacks__default = /*#__PURE__*/_interopDefaultLegacy(readyCallbacks);
var eventsEngine__default = /*#__PURE__*/_interopDefaultLegacy(eventsEngine);
var ajax__default = /*#__PURE__*/_interopDefaultLegacy(ajax);
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b)
if (b.hasOwnProperty(p))
d[p] = b[p]; };
return extendStatics(d, b);
};
function __extends(d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
var __assign = function () {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s)
if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
function __rest(s, e) {
var t = {};
for (var p in s)
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
}
function __decorate(decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
r = Reflect.decorate(decorators, target, key, desc);
else
for (var i = decorators.length - 1; i >= 0; i--)
if (d = decorators[i])
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
}
function __param(paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); };
}
function __metadata(metadataKey, metadataValue) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
return Reflect.metadata(metadataKey, metadataValue);
}
function __awaiter(thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try {
step(generator.next(value));
}
catch (e) {
reject(e);
} }
function rejected(value) { try {
step(generator["throw"](value));
}
catch (e) {
reject(e);
} }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
function __generator(thisArg, body) {
var _ = { label: 0, sent: function () { if (t[0] & 1)
throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f)
throw new TypeError("Generator is already executing.");
while (_)
try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
return t;
if (y = 0, t)
op = [op[0] & 2, t.value];
switch (op[0]) {
case 0:
case 1:
t = op;
break;
case 4:
_.label++;
return { value: op[1], done: false };
case 5:
_.label++;
y = op[1];
op = [0];
continue;
case 7:
op = _.ops.pop();
_.trys.pop();
continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
_ = 0;
continue;
}
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
_.label = op[1];
break;
}
if (op[0] === 6 && _.label < t[1]) {
_.label = t[1];
t = op;
break;
}
if (t && _.label < t[2]) {
_.label = t[2];
_.ops.push(op);
break;
}
if (t[2])
_.ops.pop();
_.trys.pop();
continue;
}
op = body.call(thisArg, _);
}
catch (e) {
op = [6, e];
y = 0;
}
finally {
f = t = 0;
}
if (op[0] & 5)
throw op[1];
return { value: op[0] ? op[1] : void 0, done: true };
}
}
function __createBinding(o, m, k, k2) {
if (k2 === undefined)
k2 = k;
o[k2] = m[k];
}
function __exportStar(m, exports) {
for (var p in m)
if (p !== "default" && !exports.hasOwnProperty(p))
exports[p] = m[p];
}
function __values(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m)
return m.call(o);
if (o && typeof o.length === "number")
return {
next: function () {
if (o && i >= o.length)
o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
}
function __read(o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m)
return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
ar.push(r.value);
}
catch (error) {
e = { error: error };
}
finally {
try {
if (r && !r.done && (m = i["return"]))
m.call(i);
}
finally {
if (e)
throw e.error;
}
}
return ar;
}
function __spread() {
for (var ar = [], i = 0; i < arguments.length; i++)
ar = ar.concat(__read(arguments[i]));
return ar;
}
function __spreadArrays() {
for (var s = 0, i = 0, il = arguments.length; i < il; i++)
s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
}
;
function __await(v) {
return this instanceof __await ? (this.v = v, this) : new __await(v);
}
function __asyncGenerator(thisArg, _arguments, generator) {
if (!Symbol.asyncIterator)
throw new TypeError("Symbol.asyncIterator is not defined.");
var g = generator.apply(thisArg, _arguments || []), i, q = [];
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
function verb(n) { if (g[n])
i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
function resume(n, v) { try {
step(g[n](v));
}
catch (e) {
settle(q[0][3], e);
} }
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
function fulfill(value) { resume("next", value); }
function reject(value) { resume("throw", value); }
function settle(f, v) { if (f(v), q.shift(), q.length)
resume(q[0][0], q[0][1]); }
}
function __asyncDelegator(o) {
var i, p;
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
}
function __asyncValues(o) {
if (!Symbol.asyncIterator)
throw new TypeError("Symbol.asyncIterator is not defined.");
var m = o[Symbol.asyncIterator], i;
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
}
function __makeTemplateObject(cooked, raw) {
if (Object.defineProperty) {
Object.defineProperty(cooked, "raw", { value: raw });
}
else {
cooked.raw = raw;
}
return cooked;
}
;
function __importStar(mod) {
if (mod && mod.__esModule)
return mod;
var result = {};
if (mod != null)
for (var k in mod)
if (Object.hasOwnProperty.call(mod, k))
result[k] = mod[k];
result.default = mod;
return result;
}
function __importDefault(mod) {
return (mod && mod.__esModule) ? mod : { default: mod };
}
function __classPrivateFieldGet(receiver, privateMap) {
if (!privateMap.has(receiver)) {
throw new TypeError("attempted to get private field on non-instance");
}
return privateMap.get(receiver);
}
function __classPrivateFieldSet(receiver, privateMap, value) {
if (!privateMap.has(receiver)) {
throw new TypeError("attempted to set private field on non-instance");
}
privateMap.set(receiver, value);
return value;
}
/*!
* devextreme-angular
* Version: 22.1.14
* Build date: Mon Apr 29 2024
*
* Copyright (c) 2012 - 2024 Developer Express Inc. ALL RIGHTS RESERVED
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file in the root of the project for details.
*
* https://github.com/DevExpress/devextreme-angular
*/
var NgEventsStrategy = /** @class */ (function () {
function NgEventsStrategy(instance, zone) {
this.instance = instance;
this.zone = zone;
this.subscriptions = {};
this.events = {};
}
NgEventsStrategy.prototype.hasEvent = function (name) {
return this.getEmitter(name).observers.length !== 0;
};
NgEventsStrategy.prototype.fireEvent = function (name, args) {
var emitter = this.getEmitter(name);
if (emitter.observers.length) {
var internalSubs = this.subscriptions[name] || [];
if (internalSubs.length === emitter.observers.length) {
emitter.next(args && args[0]);
}
else {
this.zone.run(function () { return emitter.next(args && args[0]); });
}
}
};
NgEventsStrategy.prototype.on = function (name, handler) {
var _this = this;
if (typeof name === 'string') {
var eventSubscriptions = this.subscriptions[name] || [], subcription = this.getEmitter(name).subscribe(handler.bind(this.instance)), unsubscribe = subcription.unsubscribe.bind(subcription);
eventSubscriptions.push({ handler: handler, unsubscribe: unsubscribe });
this.subscriptions[name] = eventSubscriptions;
}
else {
var handlersObj_1 = name;
Object.keys(handlersObj_1).forEach(function (event) { return _this.on(event, handlersObj_1[event]); });
}
};
NgEventsStrategy.prototype.off = function (name, handler) {
var eventSubscriptions = this.subscriptions[name] || [];
if (handler) {
eventSubscriptions.some(function (subscription, i) {
if (subscription.handler === handler) {
subscription.unsubscribe();
eventSubscriptions.splice(i, 1);
return true;
}
});
}
else {
eventSubscriptions.forEach(function (subscription) {
subscription.unsubscribe();
});
eventSubscriptions.splice(0, eventSubscriptions.length);
}
};
NgEventsStrategy.prototype.dispose = function () { };
NgEventsStrategy.prototype.addEmitter = function (eventName, emitter) {
this.events[eventName] = emitter;
};
NgEventsStrategy.prototype.getEmitter = function (eventName) {
if (!this.events[eventName]) {
this.events[eventName] = new i0.EventEmitter();
}
return this.events[eventName];
};
return NgEventsStrategy;
}());
var EmitterHelper = /** @class */ (function () {
function EmitterHelper(zone, component) {
this.zone = zone;
this.component = component;
this.lockedValueChangeEvent = false;
}
EmitterHelper.prototype.fireNgEvent = function (eventName, eventArgs) {
if (this.lockedValueChangeEvent && eventName === 'valueChange') {
return;
}
var emitter = this.component[eventName];
if (emitter && emitter.observers.length) {
this.zone.run(function () {
emitter.next(eventArgs && eventArgs[0]);
});
}
};
EmitterHelper.prototype.createEmitters = function (events) {
var _this = this;
events.forEach(function (event) {
_this.component[event.emit] = new i0.EventEmitter();
});
};
return EmitterHelper;
}());
/*!
* devextreme-angular
* Version: 22.1.14
* Build date: Mon Apr 29 2024
*
* Copyright (c) 2012 - 2024 Developer Express Inc. ALL RIGHTS RESERVED
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file in the root of the project for details.
*
* https://github.com/DevExpress/devextreme-angular
*/
function getElement(element) {
return element.get ? element.get(0) : element;
}
;
/*!
* devextreme-angular
* Version: 22.1.14
* Build date: Mon Apr 29 2024
*
* Copyright (c) 2012 - 2024 Developer Express Inc. ALL RIGHTS RESERVED
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file in the root of the project for details.
*
* https://github.com/DevExpress/devextreme-angular
*/
;
var DxTemplateHost = /** @class */ (function () {
function DxTemplateHost() {
}
DxTemplateHost.prototype.setHost = function (host) {
this.host = host;
};
DxTemplateHost.prototype.setTemplate = function (template) {
this.host.setTemplate(template);
};
return DxTemplateHost;
}());
/*!
* devextreme-angular
* Version: 22.1.14
* Build date: Mon Apr 29 2024
*
* Copyright (c) 2012 - 2024 Developer Express Inc. ALL RIGHTS RESERVED
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file in the root of the project for details.
*
* https://github.com/DevExpress/devextreme-angular
*/
var DX_TEMPLATE_WRAPPER_CLASS = 'dx-template-wrapper';
var RenderData = /** @class */ (function () {
function RenderData() {
}
return RenderData;
}());
var DxTemplateDirective = /** @class */ (function () {
function DxTemplateDirective(templateRef, viewContainerRef, templateHost, renderer, zone) {
this.templateRef = templateRef;
this.viewContainerRef = viewContainerRef;
this.renderer = renderer;
this.zone = zone;
templateHost.setTemplate(this);
}
Object.defineProperty(DxTemplateDirective.prototype, "dxTemplateOf", {
set: function (value) {
this.name = value;
},
enumerable: false,
configurable: true
});
;
DxTemplateDirective.prototype.renderTemplate = function (renderData) {
var _this = this;
var childView = this.viewContainerRef.createEmbeddedView(this.templateRef, {
'$implicit': renderData.model,
index: renderData.index
});
var container = getElement(renderData.container);
if (renderData.container) {
childView.rootNodes.forEach(function (element) {
_this.renderer.appendChild(container, element);
});
}
return childView;
};
DxTemplateDirective.prototype.render = function (renderData) {
var _this = this;
var childView;
if (this.zone.isStable) {
childView = this.zone.run(function () {
return _this.renderTemplate(renderData);
});
}
else {
childView = this.renderTemplate(renderData);
}
// =========== WORKAROUND =============
// https://github.com/angular/angular/issues/12243
childView['detectChanges']();
// =========== /WORKAROUND =============
childView.rootNodes.forEach(function (element) {
if (element.nodeType === 1) {
domAdapter__default["default"].setClass(element, DX_TEMPLATE_WRAPPER_CLASS, true);
}
events.one(element, 'dxremove', function (_a, params) {
if (!params || !params._angularIntegration) {
childView.destroy();
}
});
});
return childView.rootNodes;
};
return DxTemplateDirective;
}());
/** @nocollapse */ DxTemplateDirective.ɵfac = function DxTemplateDirective_Factory(t) { return new (t || DxTemplateDirective)(i0__namespace.ɵɵdirectiveInject(i0__namespace.TemplateRef), i0__namespace.ɵɵdirectiveInject(i0__namespace.ViewContainerRef), i0__namespace.ɵɵdirectiveInject(DxTemplateHost), i0__namespace.ɵɵdirectiveInject(i0__namespace.Renderer2), i0__namespace.ɵɵdirectiveInject(i0__namespace.NgZone)); };
/** @nocollapse */ DxTemplateDirective.ɵdir = /** @pureOrBreakMyCode */ i0__namespace.ɵɵdefineDirective({ type: DxTemplateDirective, selectors: [["", "dxTemplate", ""]], inputs: { dxTemplateOf: "dxTemplateOf" } });
(function () {
(typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(DxTemplateDirective, [{
type: i0.Directive,
args: [{
selector: '[dxTemplate]'
}]
}], function () { return [{ type: i0__namespace.TemplateRef }, { type: i0__namespace.ViewContainerRef }, { type: DxTemplateHost }, { type: i0__namespace.Renderer2 }, { type: i0__namespace.NgZone }]; }, { dxTemplateOf: [{
type: i0.Input
}] });
})();
var DxTemplateModule = /** @class */ (function () {
function DxTemplateModule() {
}
return DxTemplateModule;
}());
/** @nocollapse */ DxTemplateModule.ɵfac = function DxTemplateModule_Factory(t) { return new (t || DxTemplateModule)(); };
/** @nocollapse */ DxTemplateModule.ɵmod = /** @pureOrBreakMyCode */ i0__namespace.ɵɵdefineNgModule({ type: DxTemplateModule });
/** @nocollapse */ DxTemplateModule.ɵinj = /** @pureOrBreakMyCode */ i0__namespace.ɵɵdefineInjector({});
(function () {
(typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(DxTemplateModule, [{
type: i0.NgModule,
args: [{
declarations: [DxTemplateDirective],
exports: [DxTemplateDirective]
}]
}], null, null);
})();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0__namespace.ɵɵsetNgModuleScope(DxTemplateModule, { declarations: [DxTemplateDirective], exports: [DxTemplateDirective] }); })();
var VISIBILITY_CHANGE_SELECTOR = 'dx-visibility-change-handler';
var BaseNestedOption = /** @class */ (function () {
function BaseNestedOption() {
this._initialOptions = {};
this._collectionContainerImpl = new CollectionNestedOptionContainerImpl(this._setOption.bind(this), this._filterItems.bind(this));
}
BaseNestedOption.prototype._optionChangedHandler = function (e) {
var fullOptionPath = this._fullOptionPath();
if (e.fullName.indexOf(fullOptionPath) === 0) {
var optionName = e.fullName.slice(fullOptionPath.length);
var emitter = this[optionName + 'Change'];
if (emitter) {
emitter.next(e.value);
}
}
};
BaseNestedOption.prototype._createEventEmitters = function (events) {
var _this = this;
events.forEach(function (event) {
_this[event.emit] = new i0.EventEmitter();
});
};
BaseNestedOption.prototype._getOption = function (name) {
if (this.isLinked) {
return this.instance.option(this._fullOptionPath() + name);
}
else {
return this._initialOptions[name];
}
};
BaseNestedOption.prototype._setOption = function (name, value) {
if (this.isLinked) {
var fullPath = this._fullOptionPath() + name;
this.instance.option(fullPath, value);
}
else {
this._initialOptions[name] = value;
}
};
BaseNestedOption.prototype._addRemovedOption = function (name) {
if (this.instance && this.removedNestedComponents) {
this.removedNestedComponents.push(name);
}
};
BaseNestedOption.prototype._deleteRemovedOptions = function (name) {
if (this.instance && this.removedNestedComponents) {
this.removedNestedComponents = this.removedNestedComponents.filter(function (x) { return !x.startsWith(name); });
}
};
BaseNestedOption.prototype._addRecreatedComponent = function () {
var _this = this;
if (this.instance && this.recreatedNestedComponents) {
this.recreatedNestedComponents.push({ getOptionPath: function () { return _this._getOptionPath(); } });
}
};
BaseNestedOption.prototype._getOptionPath = function () {
return this._hostOptionPath() + this._optionPath;
};
BaseNestedOption.prototype.setHost = function (host, optionPath) {
this._host = host;
this._hostOptionPath = optionPath;
this.optionChangedHandlers.subscribe(this._optionChangedHandler.bind(this));
};
BaseNestedOption.prototype.setChildren = function (propertyName, items) {
this.resetOptions(propertyName);
return this._collectionContainerImpl.setChildren(propertyName, items);
};
BaseNestedOption.prototype._filterItems = function (items) {
var _this = this;
return items.filter(function (item) { return item !== _this; });
};
Object.defineProperty(BaseNestedOption.prototype, "instance", {
get: function () {
return this._host && this._host.instance;
},
enumerable: false,
configurable: true
});
Object.defineProperty(BaseNestedOption.prototype, "resetOptions", {
get: function () {
return this._host && this._host.resetOptions;
},
enumerable: false,
configurable: true
});
Object.defineProperty(BaseNestedOption.prototype, "isRecreated", {
get: function () {
return this._host && this._host.isRecreated;
},
enumerable: false,
configurable: true
});
Object.defineProperty(BaseNestedOption.prototype, "removedNestedComponents", {
get: function () {
return this._host && this._host.removedNestedComponents;
},
set: function (value) {
this._host.removedNestedComponents = value;
},
enumerable: false,
configurable: true
});
Object.defineProperty(BaseNestedOption.prototype, "recreatedNestedComponents", {
get: function () {
return this._host && this._host.recreatedNestedComponents;
},
set: function (value) {
this._host.recreatedNestedComponents = value;
},
enumerable: false,
configurable: true
});
Object.defineProperty(BaseNestedOption.prototype, "isLinked", {
get: function () {
return !!this.instance && this._host.isLinked;
},
enumerable: false,
configurable: true
});
Object.defineProperty(BaseNestedOption.prototype, "optionChangedHandlers", {
get: function () {
return this._host && this._host.optionChangedHandlers;
},
enumerable: false,
configurable: true
});
return BaseNestedOption;
}());
/** @nocollapse */ BaseNestedOption.ɵfac = function BaseNestedOption_Factory(t) { return new (t || BaseNestedOption)(); };
/** @nocollapse */ BaseNestedOption.ɵcmp = /** @pureOrBreakMyCode */ i0__namespace.ɵɵdefineComponent({ type: BaseNestedOption, selectors: [["ng-component"]], decls: 0, vars: 0, template: function BaseNestedOption_Template(rf, ctx) { }, encapsulation: 2 });
(function () {
(typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(BaseNestedOption, [{
type: i0.Component,
args: [{
template: ''
}]
}], function () { return []; }, null);
})();
var CollectionNestedOptionContainerImpl = /** @class */ (function () {
function CollectionNestedOptionContainerImpl(_setOption, _filterItems) {
this._setOption = _setOption;
this._filterItems = _filterItems;
this._activatedQueries = {};
}
CollectionNestedOptionContainerImpl.prototype.setChildren = function (propertyName, items) {
if (this._filterItems) {
items = this._filterItems(items);
}
if (items.length) {
this._activatedQueries[propertyName] = true;
}
if (this._activatedQueries[propertyName]) {
var widgetItems = items.map(function (item, index) {
item._index = index;
return item._value;
});
this._setOption(propertyName, widgetItems);
}
};
return CollectionNestedOptionContainerImpl;
}());
var NestedOption = /** @class */ (function (_super) {
__extends(NestedOption, _super);
function NestedOption() {
return _super !== null && _super.apply(this, arguments) || this;
}
NestedOption.prototype.setHost = function (host, optionPath) {
_super.prototype.setHost.call(this, host, optionPath);
this._host[this._optionPath] = this._initialOptions;
};
NestedOption.prototype._fullOptionPath = function () {
return this._getOptionPath() + '.';
};
return NestedOption;
}(BaseNestedOption));
/** @nocollapse */ NestedOption.ɵfac = /** @pureOrBreakMyCode */ function () { var ɵNestedOption_BaseFactory; return function NestedOption_Factory(t) { return (ɵNestedOption_BaseFactory || (ɵNestedOption_BaseFactory = i0__namespace.ɵɵgetInheritedFactory(NestedOption)))(t || NestedOption); }; }();
/** @nocollapse */ NestedOption.ɵcmp = /** @pureOrBreakMyCode */ i0__namespace.ɵɵdefineComponent({ type: NestedOption, selectors: [["ng-component"]], features: [i0__namespace.ɵɵInheritDefinitionFeature], decls: 0, vars: 0, template: function NestedOption_Template(rf, ctx) { }, encapsulation: 2 });
(function () {
(typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(NestedOption, [{
type: i0.Component,
args: [{
template: ''
}]
}], null, null);
})();
var CollectionNestedOption = /** @class */ (function (_super) {
__extends(CollectionNestedOption, _super);
function CollectionNestedOption() {
return _super !== null && _super.apply(this, arguments) || this;
}
CollectionNestedOption.prototype._fullOptionPath = function () {
return this._getOptionPath() + "[" + this._index + "].";
};
Object.defineProperty(CollectionNestedOption.prototype, "_value", {
get: function () {
return this._initialOptions;
},
enumerable: false,
configurable: true
});
Object.defineProperty(CollectionNestedOption.prototype, "isLinked", {
get: function () {
return this._index !== undefined && !!this.instance && this._host.isLinked;
},
enumerable: false,
configurable: true
});
return CollectionNestedOption;
}(BaseNestedOption));
/** @nocollapse */ CollectionNestedOption.ɵfac = /** @pureOrBreakMyCode */ function () { var ɵCollectionNestedOption_BaseFactory; return function CollectionNestedOption_Factory(t) { return (ɵCollectionNestedOption_BaseFactory || (ɵCollectionNestedOption_BaseFactory = i0__namespace.ɵɵgetInheritedFactory(CollectionNestedOption)))(t || CollectionNestedOption); }; }();
/** @nocollapse */ CollectionNestedOption.ɵcmp = /** @pureOrBreakMyCode */ i0__namespace.ɵɵdefineComponent({ type: CollectionNestedOption, selectors: [["ng-component"]], features: [i0__namespace.ɵɵInheritDefinitionFeature], decls: 0, vars: 0, template: function CollectionNestedOption_Template(rf, ctx) { }, encapsulation: 2 });
(function () {
(typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(CollectionNestedOption, [{
type: i0.Component,
args: [{
template: ''
}]
}], null, null);
})();
var triggerShownEvent = function (element) {
var changeHandlers = [];
if (!render__default["default"](element).hasClass(VISIBILITY_CHANGE_SELECTOR)) {
changeHandlers.push(element);
}
changeHandlers.push.apply(changeHandlers, element.querySelectorAll('.' + VISIBILITY_CHANGE_SELECTOR));
for (var i = 0; i < changeHandlers.length; i++) {
events.triggerHandler(changeHandlers[i], 'dxshown');
}
};
function extractTemplate(option, element, renderer, document) {
if (!option.template === undefined || !element.nativeElement.hasChildNodes()) {
return;
}
var childNodes = [].slice.call(element.nativeElement.childNodes);
var userContent = childNodes.filter(function (n) {
if (n.tagName) {
var tagNamePrefix = n.tagName.toLowerCase().substr(0, 3);
return !(tagNamePrefix === 'dxi' || tagNamePrefix === 'dxo');
}
else {
return n.nodeName !== '#comment' && n.textContent.replace(/\s/g, '').length;
}
});
if (!userContent.length) {
return;
}
option.template = {
render: function (renderData) {
var result = element.nativeElement;
domAdapter__default["default"].setClass(result, DX_TEMPLATE_WRAPPER_CLASS, true);
if (renderData.container) {
var container = getElement(renderData.container);
var resultInContainer = container.contains(element.nativeElement);
renderer.appendChild(container, element.nativeElement);
if (!resultInContainer) {
var resultInBody = document.body.contains(container);
if (resultInBody) {
triggerShownEvent(result);
}
}
}
return result;
}
};
}
var NestedOptionHost = /** @class */ (function () {
function NestedOptionHost() {
}
NestedOptionHost.prototype.getHost = function () {
return this._host;
};
NestedOptionHost.prototype.setHost = function (host, optionPath) {
this._host = host;
this._optionPath = optionPath || (function () { return ''; });
};
NestedOptionHost.prototype.setNestedOption = function (nestedOption) {
nestedOption.setHost(this._host, this._optionPath);
};
return NestedOptionHost;
}());
var WatcherHelper = /** @class */ (function () {
function WatcherHelper() {
this._watchers = [];
}
WatcherHelper.prototype.getWatchMethod = function () {
var _this = this;
var watchMethod = function (valueGetter, valueChangeCallback, options) {
var oldValue = valueGetter();
options = options || {};
if (!options.skipImmediate) {
valueChangeCallback(oldValue);
}
var watcher = function () {
var newValue = valueGetter();
if (_this._isDifferentValues(oldValue, newValue, options.deep)) {
valueChangeCallback(newValue);
oldValue = newValue;
}
};
_this._watchers.push(watcher);
return function () {
var index = _this._watchers.indexOf(watcher);
if (index !== -1) {
_this._watchers.splice(index, 1);
}
};
};
return watchMethod;
};
WatcherHelper.prototype._isDifferentValues = function (oldValue, newValue, deepCheck) {
var comparableNewValue = this._toComparable(newValue);
var comparableOldValue = this._toComparable(oldValue);
var isObjectValues = comparableNewValue instanceof Object && comparableOldValue instanceof Object;
if (deepCheck && isObjectValues) {
return this._checkObjectsFields(newValue, oldValue);
}
return comparableNewValue !== comparableOldValue;
};
WatcherHelper.prototype._toComparable = function (value) {
if (value instanceof Date) {
return value.getTime();
}
return value;
};
WatcherHelper.prototype._checkObjectsFields = function (checkingFromObject, checkingToObject) {
for (var field in checkingFromObject) {
var oldValue = this._toComparable(checkingFromObject[field]);
var newValue = this._toComparable(checkingToObject[field]);
var isEqualObjects = false;
if (typeof oldValue === 'object' && typeof newValue === 'object') {
isEqualObjects = common.equalByValue(oldValue, newValue);
}
if (oldValue !== newValue && !isEqualObjects) {
return true;
}
}
};
WatcherHelper.prototype.checkWatchers = function () {
var e_1, _a;
try {
for (var _b = __values(this._watchers), _c = _b.next(); !_c.done; _c = _b.next()) {
var watcher = _c.value;
watcher();
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_1) throw e_1.error; }
}
};
return WatcherHelper;
}());
/** @nocollapse */ WatcherHelper.ɵfac = function WatcherHelper_Factory(t) { return new (t || WatcherHelper)(); };
/** @nocollapse */ WatcherHelper.ɵprov = /** @pureOrBreakMyCode */ i0__namespace.ɵɵdefineInjectable({ token: WatcherHelper, factory: WatcherHelper.ɵfac });
(function () {
(typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(WatcherHelper, [{
type: i0.Injectable
}], null, null);
})();
var serverStateKey;
var getServerStateKey = function () {
if (!serverStateKey) {
serverStateKey = i3.makeStateKey('DX_isPlatformServer');
}
return serverStateKey;
};
var DxComponent = /** @class */ (function () {
function DxComponent(element, ngZone, templateHost, watcherHelper, transferState, platformId) {
this.element = element;
this.ngZone = ngZone;
this.watcherHelper = watcherHelper;
this.transferState = transferState;
this.platformId = platformId;
this._initialOptions = {};
this._optionsToUpdate = {};
this.optionChangedHandlers = new i0.EventEmitter();
this.isLinked = true;
this.changedOptions = {};
this.removedNestedComponents = [];
this.widgetUpdateLocked = false;
this.templateUpdateRequired = false;
this.templates = [];
templateHost.setHost(this);
this._collectionContainerImpl = new CollectionNestedOptionContainerImpl(this._setOption.bind(this));
this.eventHelper = new EmitterHelper(ngZone, this);
}
DxComponent.prototype._updateTemplates = function () {
if (this.templates.length && this.templateUpdateRequired) {
var updatedTemplates_1 = {};
this.templates.forEach(function (template) {
updatedTemplates_1[template.name] = template;
});
this.instance.option('integrationOptions.templates', updatedTemplates_1);
this.templates = Object.values(updatedTemplates_1);
this.templateUpdateRequired = false;
}
};
DxComponent.prototype._initEvents = function () {
var _this = this;
this.instance.on('optionChanged', function (e) {
_this.changedOptions[e.name] = e.value;
var value = e.name === e.fullName ? e.value : e.component.option(e.name);
_this.eventHelper.fireNgEvent(e.name + 'Change', [value]);
_this.optionChangedHandlers.emit(e);
});
};
DxComponent.prototype._initOptions = function () {
this._initialOptions.integrationOptions.watchMethod = this.watcherHelper.getWatchMethod();
};
DxComponent.prototype._initPlatform = function () {
if (this.transferState.hasKey(getServerStateKey())) {
this._initialOptions.integrationOptions.renderedOnServer = this.transferState.get(getServerStateKey(), null);
}
else if (i1.isPlatformServer(this.platformId)) {
this.transferState.set(getServerStateKey(), true);
}
};
DxComponent.prototype._createEventEmitters = function (events) {
var _this = this;
var zone = this.ngZone;
this.eventHelper.createEmitters(events);
this._initialOptions.eventsStrategy = function (instance) {
var strategy = new NgEventsStrategy(instance, zone);
events.filter(function (event) { return event.subscribe; }).forEach(function (event) {
strategy.addEmitter(event.subscribe, _this[event.emit]);
});
return strategy;
};
this._initialOptions.nestedComponentOptions = function (component) {
return {
eventsStrategy: function (instance) { return new NgEventsStrategy(instance, zone); },
nestedComponentOptions: component.option('nestedComponentOptions')
};
};
};
DxComponent.prototype._shouldOptionChange = function (name, value) {
if (this.changedOptions.hasOwnProperty(name)) {
var prevValue = this.changedOptions[name];
delete this.changedOptions[name];
return value !== prevValue;
}
return true;
};
DxComponent.prototype.clearChangedOptions = function () {
this.changedOptions = {};
};
DxComponent.prototype._getOption = function (name) {
return this.instance ?
this.instance.option(name) :
this._initialOptions[name];
};
DxComponent.prototype.lockWidgetUpdate = function () {
if (!this.widgetUpdateLocked && this.instance) {
this.instance.beginUpdate();
this.widgetUpdateLocked = true;
}
};
DxComponent.prototype.unlockWidgetUpdate = function () {
if (this.widgetUpdateLocked) {
this.widgetUpdateLocked = false;
this.instance.endUpdate();
}
};
DxComponent.prototype._setOption = function (name, value) {
this.lockWidgetUpdate();
if (!this._shouldOptionChange(name, value)) {
return;
}
if (this.instance) {
this.instance.option(name, value);
}
else {
this._initialOptions[name] = value;
}
};
DxComponent.prototype._createWidget = function (element) {
this._initialOptions.integrationOptions = {};
this._initPlatform();
this._initOptions();
this._initialOptions.onInitializing = function () {
this.beginUpdate();
};
this.instance = this._createInstance(element, this._initialOptions);
this._initEvents();
this._initia