ng2-qgrid
Version:
Angular Grid
42,178 lines • 1.22 MB
JavaScript
import { Injectable, EventEmitter, Component, Input, Output, ViewEncapsulation, ElementRef, NgZone, Inject, ChangeDetectionStrategy, SkipSelf, Optional, ChangeDetectorRef, ViewChild, Directive, NgModule, Renderer2, Pipe, TemplateRef, ViewContainerRef, HostListener, ContentChild } from '@angular/core';
import { DOCUMENT } from '@angular/platform-browser';
import { DOCUMENT as DOCUMENT$1, CommonModule, DatePipe, DecimalPipe, CurrencyPipe } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { HttpClient, HttpClientModule } from '@angular/common/http';
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
var jsx = function () {
var REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol.for && Symbol.for("react.element") || 0xeac7;
return function createRawReactElement(type, props, key, children) {
var defaultProps = type && type.defaultProps;
var childrenLength = arguments.length - 3;
if (!props && childrenLength !== 0) {
props = {};
}
if (props && defaultProps) {
for (var propName in defaultProps) {
if (props[propName] === void 0) {
props[propName] = defaultProps[propName];
}
}
} else if (!props) {
props = defaultProps || {};
}
if (childrenLength === 1) {
props.children = children;
} else if (childrenLength > 1) {
var childArray = Array(childrenLength);
for (var i = 0; i < childrenLength; i++) {
childArray[i] = arguments[i + 3];
}
props.children = childArray;
}
return {
$$typeof: REACT_ELEMENT_TYPE,
type: type,
key: key === undefined ? null : '' + key,
ref: null,
props: props,
_owner: null
};
};
}();
var asyncIterator = function (iterable) {
if (typeof Symbol === "function") {
if (Symbol.asyncIterator) {
var method = iterable[Symbol.asyncIterator];
if (method != null) return method.call(iterable);
}
if (Symbol.iterator) {
return iterable[Symbol.iterator]();
}
}
throw new TypeError("Object is not async iterable");
};
var asyncGenerator = function () {
function AwaitValue(value) {
this.value = value;
}
function AsyncGenerator(gen) {
var front, back;
function send(key, arg) {
return new Promise(function (resolve, reject) {
var request = {
key: key,
arg: arg,
resolve: resolve,
reject: reject,
next: null
};
if (back) {
back = back.next = request;
} else {
front = back = request;
resume(key, arg);
}
});
}
function resume(key, arg) {
try {
var result = gen[key](arg);
var value = result.value;
if (value instanceof AwaitValue) {
Promise.resolve(value.value).then(function (arg) {
resume("next", arg);
}, function (arg) {
resume("throw", arg);
});
} else {
settle(result.done ? "return" : "normal", result.value);
}
} catch (err) {
settle("throw", err);
}
}
function settle(type, value) {
switch (type) {
case "return":
front.resolve({
value: value,
done: true
});
break;
case "throw":
front.reject(value);
break;
default:
front.resolve({
value: value,
done: false
});
break;
}
front = front.next;
if (front) {
resume(front.key, front.arg);
} else {
back = null;
}
}
this._invoke = send;
if (typeof gen.return !== "function") {
this.return = undefined;
}
}
if (typeof Symbol === "function" && Symbol.asyncIterator) {
AsyncGenerator.prototype[Symbol.asyncIterator] = function () {
return this;
};
}
AsyncGenerator.prototype.next = function (arg) {
return this._invoke("next", arg);
};
AsyncGenerator.prototype.throw = function (arg) {
return this._invoke("throw", arg);
};
AsyncGenerator.prototype.return = function (arg) {
return this._invoke("return", arg);
};
return {
wrap: function (fn) {
return function () {
return new AsyncGenerator(fn.apply(this, arguments));
};
},
await: function (value) {
return new AwaitValue(value);
}
};
}();
var asyncGeneratorDelegate = function (inner, awaitWrap) {
var iter = {},
waiting = false;
function pump(key, value) {
waiting = true;
value = new Promise(function (resolve) {
resolve(inner[key](value));
});
return {
done: false,
value: awaitWrap(value)
};
}
if (typeof Symbol === "function" && Symbol.iterator) {
iter[Symbol.iterator] = function () {
return this;
};
}
iter.next = function (value) {
if (waiting) {
waiting = false;
return value;
}
return pump("next", value);
};
if (typeof inner.throw === "function") {
iter.throw = function (value) {
if (waiting) {
waiting = false;
throw value;
}
return pump("throw", value);
};
}
if (typeof inner.return === "function") {
iter.return = function (value) {
return pump("return", value);
};
}
return iter;
};
var asyncToGenerator = function (fn) {
return function () {
var gen = fn.apply(this, arguments);
return new Promise(function (resolve, reject) {
function step(key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
return Promise.resolve(value).then(function (value) {
step("next", value);
}, function (err) {
step("throw", err);
});
}
}
return step("next");
});
};
};
var classCallCheck = function (instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
};
var createClass = function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
var defineEnumerableProperties = function (obj, descs) {
for (var key in descs) {
var desc = descs[key];
desc.configurable = desc.enumerable = true;
if ("value" in desc) desc.writable = true;
Object.defineProperty(obj, key, desc);
}
return obj;
};
var defaults = function (obj, defaults) {
var keys = Object.getOwnPropertyNames(defaults);
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
var value = Object.getOwnPropertyDescriptor(defaults, key);
if (value && value.configurable && obj[key] === undefined) {
Object.defineProperty(obj, key, value);
}
}
return obj;
};
var defineProperty = function (obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
};
var _extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
var get = function get(object, property, receiver) {
if (object === null) object = Function.prototype;
var desc = Object.getOwnPropertyDescriptor(object, property);
if (desc === undefined) {
var parent = Object.getPrototypeOf(object);
if (parent === null) {
return undefined;
} else {
return get(parent, property, receiver);
}
} else if ("value" in desc) {
return desc.value;
} else {
var getter = desc.get;
if (getter === undefined) {
return undefined;
}
return getter.call(receiver);
}
};
var inherits = function (subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
};
var _instanceof = function (left, right) {
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
return right[Symbol.hasInstance](left);
} else {
return left instanceof right;
}
};
var interopRequireDefault = function (obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
};
var interopRequireWildcard = function (obj) {
if (obj && obj.__esModule) {
return obj;
} else {
var newObj = {};
if (obj != null) {
for (var key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
}
}
newObj.default = obj;
return newObj;
}
};
var newArrowCheck = function (innerThis, boundThis) {
if (innerThis !== boundThis) {
throw new TypeError("Cannot instantiate an arrow function");
}
};
var objectDestructuringEmpty = function (obj) {
if (obj == null) throw new TypeError("Cannot destructure undefined");
};
var objectWithoutProperties = function (obj, keys) {
var target = {};
for (var i in obj) {
if (keys.indexOf(i) >= 0) continue;
if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
target[i] = obj[i];
}
return target;
};
var possibleConstructorReturn = function (self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && (typeof call === "object" || typeof call === "function") ? call : self;
};
var selfGlobal = typeof global === "undefined" ? self : global;
var set = function set(object, property, value, receiver) {
var desc = Object.getOwnPropertyDescriptor(object, property);
if (desc === undefined) {
var parent = Object.getPrototypeOf(object);
if (parent !== null) {
set(parent, property, value, receiver);
}
} else if ("value" in desc && desc.writable) {
desc.value = value;
} else {
var setter = desc.set;
if (setter !== undefined) {
setter.call(receiver, value);
}
}
return value;
};
var slicedToArray = function () {
function sliceIterator(arr, i) {
var _arr = [];
var _n = true;
var _d = false;
var _e = undefined;
try {
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value);
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"]) _i["return"]();
} finally {
if (_d) throw _e;
}
}
return _arr;
}
return function (arr, i) {
if (Array.isArray(arr)) {
return arr;
} else if (Symbol.iterator in Object(arr)) {
return sliceIterator(arr, i);
} else {
throw new TypeError("Invalid attempt to destructure non-iterable instance");
}
};
}();
var slicedToArrayLoose = function (arr, i) {
if (Array.isArray(arr)) {
return arr;
} else if (Symbol.iterator in Object(arr)) {
var _arr = [];
for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
_arr.push(_step.value);
if (i && _arr.length === i) break;
}
return _arr;
} else {
throw new TypeError("Invalid attempt to destructure non-iterable instance");
}
};
var taggedTemplateLiteral = function (strings, raw) {
return Object.freeze(Object.defineProperties(strings, {
raw: {
value: Object.freeze(raw)
}
}));
};
var taggedTemplateLiteralLoose = function (strings, raw) {
strings.raw = raw;
return strings;
};
var temporalRef = function (val, name, undef) {
if (val === undef) {
throw new ReferenceError(name + " is not defined - temporal dead zone");
} else {
return val;
}
};
var temporalUndefined = {};
var toArray = function (arr) {
return Array.isArray(arr) ? arr : Array.from(arr);
};
var toConsumableArray = function (arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
return arr2;
} else {
return Array.from(arr);
}
};
var Middleware = function () {
function Middleware(pipes) {
classCallCheck(this, Middleware);
this.pipes = pipes;
}
createClass(Middleware, [{
key: "run",
value: function run(context) {
var memo = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
var tasks = this.pipes.map(function (pipe) {
return function (memo) {
return new Promise(function (resolve, reject) {
return pipe(memo, context, resolve, reject);
});
};
});
return start(tasks, memo);
}
}]);
return Middleware;
}();
function start(tasks, memo) {
tasks = Array.from(tasks);
return new Promise(function (resolve, reject) {
invoke(memo);
function invoke(memo) {
if (tasks.length) {
var task = tasks.shift();
var promise = task(memo);
promise.then(invoke).catch(function (ex) {
reject(ex);
throw ex;
});
} else {
resolve(memo);
}
}
});
}
/**
* Checks if `value` is the
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
* @example
*
* _.isObject({});
* // => true
*
* _.isObject([1, 2, 3]);
* // => true
*
* _.isObject(_.noop);
* // => true
*
* _.isObject(null);
* // => false
*/
function isObject(value) {
var type = typeof value === 'undefined' ? 'undefined' : _typeof(value);
return value != null && (type == 'object' || type == 'function');
}
/** Detect free variable `global` from Node.js. */
var freeGlobal = (typeof global === 'undefined' ? 'undefined' : _typeof(global)) == 'object' && global && global.Object === Object && global;
/** Detect free variable `self`. */
var freeSelf = (typeof self === 'undefined' ? 'undefined' : _typeof(self)) == 'object' && self && self.Object === Object && self;
/** Used as a reference to the global object. */
var root = freeGlobal || freeSelf || Function('return this')();
/** Built-in value references. */
var _Symbol = root.Symbol;
/** Used for built-in method references. */
var objectProto = Object.prototype;
/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;
/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var nativeObjectToString = objectProto.toString;
/** Built-in value references. */
var symToStringTag = _Symbol ? _Symbol.toStringTag : undefined;
/**
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
*
* @private
* @param {*} value The value to query.
* @returns {string} Returns the raw `toStringTag`.
*/
function getRawTag(value) {
var isOwn = hasOwnProperty.call(value, symToStringTag),
tag = value[symToStringTag];
try {
value[symToStringTag] = undefined;
var unmasked = true;
} catch (e) {}
var result = nativeObjectToString.call(value);
if (unmasked) {
if (isOwn) {
value[symToStringTag] = tag;
} else {
delete value[symToStringTag];
}
}
return result;
}
/** Used for built-in method references. */
var objectProto$1 = Object.prototype;
/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var nativeObjectToString$1 = objectProto$1.toString;
/**
* Converts `value` to a string using `Object.prototype.toString`.
*
* @private
* @param {*} value The value to convert.
* @returns {string} Returns the converted string.
*/
function objectToString(value) {
return nativeObjectToString$1.call(value);
}
/** `Object#toString` result references. */
var nullTag = '[object Null]',
undefinedTag = '[object Undefined]';
/** Built-in value references. */
var symToStringTag$1 = _Symbol ? _Symbol.toStringTag : undefined;
/**
* The base implementation of `getTag` without fallbacks for buggy environments.
*
* @private
* @param {*} value The value to query.
* @returns {string} Returns the `toStringTag`.
*/
function baseGetTag(value) {
if (value == null) {
return value === undefined ? undefinedTag : nullTag;
}
return symToStringTag$1 && symToStringTag$1 in Object(value) ? getRawTag(value) : objectToString(value);
}
/** `Object#toString` result references. */
var asyncTag = '[object AsyncFunction]',
funcTag = '[object Function]',
genTag = '[object GeneratorFunction]',
proxyTag = '[object Proxy]';
/**
* Checks if `value` is classified as a `Function` object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
* @example
*
* _.isFunction(_);
* // => true
*
* _.isFunction(/abc/);
* // => false
*/
function isFunction(value) {
if (!isObject(value)) {
return false;
}
// The use of `Object#toString` avoids issues with the `typeof` operator
// in Safari 9 which returns 'object' for typed arrays and other constructors.
var tag = baseGetTag(value);
return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
}
/**
* Checks if `value` is classified as an `Array` object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
* @example
*
* _.isArray([1, 2, 3]);
* // => true
*
* _.isArray(document.body.children);
* // => false
*
* _.isArray('abc');
* // => false
*
* _.isArray(_.noop);
* // => false
*/
var isArray = Array.isArray;
/**
* Removes all key-value entries from the list cache.
*
* @private
* @name clear
* @memberOf ListCache
*/
function listCacheClear() {
this.__data__ = [];
this.size = 0;
}
/**
* Performs a
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* comparison between two values to determine if they are equivalent.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
* @example
*
* var object = { 'a': 1 };
* var other = { 'a': 1 };
*
* _.eq(object, object);
* // => true
*
* _.eq(object, other);
* // => false
*
* _.eq('a', 'a');
* // => true
*
* _.eq('a', Object('a'));
* // => false
*
* _.eq(NaN, NaN);
* // => true
*/
function eq(value, other) {
return value === other || value !== value && other !== other;
}
/**
* Gets the index at which the `key` is found in `array` of key-value pairs.
*
* @private
* @param {Array} array The array to inspect.
* @param {*} key The key to search for.
* @returns {number} Returns the index of the matched value, else `-1`.
*/
function assocIndexOf(array, key) {
var length = array.length;
while (length--) {
if (eq(array[length][0], key)) {
return length;
}
}
return -1;
}
/** Used for built-in method references. */
var arrayProto = Array.prototype;
/** Built-in value references. */
var splice = arrayProto.splice;
/**
* Removes `key` and its value from the list cache.
*
* @private
* @name delete
* @memberOf ListCache
* @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/
function listCacheDelete(key) {
var data = this.__data__,
index = assocIndexOf(data, key);
if (index < 0) {
return false;
}
var lastIndex = data.length - 1;
if (index == lastIndex) {
data.pop();
} else {
splice.call(data, index, 1);
}
--this.size;
return true;
}
/**
* Gets the list cache value for `key`.
*
* @private
* @name get
* @memberOf ListCache
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/
function listCacheGet(key) {
var data = this.__data__,
index = assocIndexOf(data, key);
return index < 0 ? undefined : data[index][1];
}
/**
* Checks if a list cache value for `key` exists.
*
* @private
* @name has
* @memberOf ListCache
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/
function listCacheHas(key) {
return assocIndexOf(this.__data__, key) > -1;
}
/**
* Sets the list cache `key` to `value`.
*
* @private
* @name set
* @memberOf ListCache
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
* @returns {Object} Returns the list cache instance.
*/
function listCacheSet(key, value) {
var data = this.__data__,
index = assocIndexOf(data, key);
if (index < 0) {
++this.size;
data.push([key, value]);
} else {
data[index][1] = value;
}
return this;
}
/**
* Creates an list cache object.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
function ListCache(entries) {
var index = -1,
length = entries == null ? 0 : entries.length;
this.clear();
while (++index < length) {
var entry = entries[index];
this.set(entry[0], entry[1]);
}
}
// Add methods to `ListCache`.
ListCache.prototype.clear = listCacheClear;
ListCache.prototype['delete'] = listCacheDelete;
ListCache.prototype.get = listCacheGet;
ListCache.prototype.has = listCacheHas;
ListCache.prototype.set = listCacheSet;
/**
* Removes all key-value entries from the stack.
*
* @private
* @name clear
* @memberOf Stack
*/
function stackClear() {
this.__data__ = new ListCache();
this.size = 0;
}
/**
* Removes `key` and its value from the stack.
*
* @private
* @name delete
* @memberOf Stack
* @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/
function stackDelete(key) {
var data = this.__data__,
result = data['delete'](key);
this.size = data.size;
return result;
}
/**
* Gets the stack value for `key`.
*
* @private
* @name get
* @memberOf Stack
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/
function stackGet(key) {
return this.__data__.get(key);
}
/**
* Checks if a stack value for `key` exists.
*
* @private
* @name has
* @memberOf Stack
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/
function stackHas(key) {
return this.__data__.has(key);
}
/** Used to detect overreaching core-js shims. */
var coreJsData = root['__core-js_shared__'];
/** Used to detect methods masquerading as native. */
var maskSrcKey = function () {
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
return uid ? 'Symbol(src)_1.' + uid : '';
}();
/**
* Checks if `func` has its source masked.
*
* @private
* @param {Function} func The function to check.
* @returns {boolean} Returns `true` if `func` is masked, else `false`.
*/
function isMasked(func) {
return !!maskSrcKey && maskSrcKey in func;
}
/** Used for built-in method references. */
var funcProto = Function.prototype;
/** Used to resolve the decompiled source of functions. */
var funcToString = funcProto.toString;
/**
* Converts `func` to its source code.
*
* @private
* @param {Function} func The function to convert.
* @returns {string} Returns the source code.
*/
function toSource(func) {
if (func != null) {
try {
return funcToString.call(func);
} catch (e) {}
try {
return func + '';
} catch (e) {}
}
return '';
}
/**
* Used to match `RegExp`
* [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
*/
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
/** Used to detect host constructors (Safari). */
var reIsHostCtor = /^\[object .+?Constructor\]$/;
/** Used for built-in method references. */
var funcProto$1 = Function.prototype,
objectProto$2 = Object.prototype;
/** Used to resolve the decompiled source of functions. */
var funcToString$1 = funcProto$1.toString;
/** Used to check objects for own properties. */
var hasOwnProperty$1 = objectProto$2.hasOwnProperty;
/** Used to detect if a method is native. */
var reIsNative = RegExp('^' + funcToString$1.call(hasOwnProperty$1).replace(reRegExpChar, '\\$&').replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$');
/**
* The base implementation of `_.isNative` without bad shim checks.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a native function,
* else `false`.
*/
function baseIsNative(value) {
if (!isObject(value) || isMasked(value)) {
return false;
}
var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
return pattern.test(toSource(value));
}
/**
* Gets the value at `key` of `object`.
*
* @private
* @param {Object} [object] The object to query.
* @param {string} key The key of the property to get.
* @returns {*} Returns the property value.
*/
function getValue$1(object, key) {
return object == null ? undefined : object[key];
}
/**
* Gets the native function at `key` of `object`.
*
* @private
* @param {Object} object The object to query.
* @param {string} key The key of the method to get.
* @returns {*} Returns the function if it's native, else `undefined`.
*/
function getNative(object, key) {
var value = getValue$1(object, key);
return baseIsNative(value) ? value : undefined;
}
/* Built-in method references that are verified to be native. */
var Map$1 = getNative(root, 'Map');
/* Built-in method references that are verified to be native. */
var nativeCreate = getNative(Object, 'create');
/**
* Removes all key-value entries from the hash.
*
* @private
* @name clear
* @memberOf Hash
*/
function hashClear() {
this.__data__ = nativeCreate ? nativeCreate(null) : {};
this.size = 0;
}
/**
* Removes `key` and its value from the hash.
*
* @private
* @name delete
* @memberOf Hash
* @param {Object} hash The hash to modify.
* @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/
function hashDelete(key) {
var result = this.has(key) && delete this.__data__[key];
this.size -= result ? 1 : 0;
return result;
}
/** Used to stand-in for `undefined` hash values. */
var HASH_UNDEFINED = '__lodash_hash_undefined__';
/** Used for built-in method references. */
var objectProto$3 = Object.prototype;
/** Used to check objects for own properties. */
var hasOwnProperty$2 = objectProto$3.hasOwnProperty;
/**
* Gets the hash value for `key`.
*
* @private
* @name get
* @memberOf Hash
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/
function hashGet(key) {
var data = this.__data__;
if (nativeCreate) {
var result = data[key];
return result === HASH_UNDEFINED ? undefined : result;
}
return hasOwnProperty$2.call(data, key) ? data[key] : undefined;
}
/** Used for built-in method references. */
var objectProto$4 = Object.prototype;
/** Used to check objects for own properties. */
var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
/**
* Checks if a hash value for `key` exists.
*
* @private
* @name has
* @memberOf Hash
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/
function hashHas(key) {
var data = this.__data__;
return nativeCreate ? data[key] !== undefined : hasOwnProperty$3.call(data, key);
}
/** Used to stand-in for `undefined` hash values. */
var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
/**
* Sets the hash `key` to `value`.
*
* @private
* @name set
* @memberOf Hash
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
* @returns {Object} Returns the hash instance.
*/
function hashSet(key, value) {
var data = this.__data__;
this.size += this.has(key) ? 0 : 1;
data[key] = nativeCreate && value === undefined ? HASH_UNDEFINED$1 : value;
return this;
}
/**
* Creates a hash object.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
function Hash(entries) {
var index = -1,
length = entries == null ? 0 : entries.length;
this.clear();
while (++index < length) {
var entry = entries[index];
this.set(entry[0], entry[1]);
}
}
// Add methods to `Hash`.
Hash.prototype.clear = hashClear;
Hash.prototype['delete'] = hashDelete;
Hash.prototype.get = hashGet;
Hash.prototype.has = hashHas;
Hash.prototype.set = hashSet;
/**
* Removes all key-value entries from the map.
*
* @private
* @name clear
* @memberOf MapCache
*/
function mapCacheClear() {
this.size = 0;
this.__data__ = {
'hash': new Hash(),
'map': new (Map$1 || ListCache)(),
'string': new Hash()
};
}
/**
* Checks if `value` is suitable for use as unique object key.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is suitable, else `false`.
*/
function isKeyable(value) {
var type = typeof value === 'undefined' ? 'undefined' : _typeof(value);
return type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean' ? value !== '__proto__' : value === null;
}
/**
* Gets the data for `map`.
*
* @private
* @param {Object} map The map to query.
* @param {string} key The reference key.
* @returns {*} Returns the map data.
*/
function getMapData(map, key) {
var data = map.__data__;
return isKeyable(key) ? data[typeof key == 'string' ? 'string' : 'hash'] : data.map;
}
/**
* Removes `key` and its value from the map.
*
* @private
* @name delete
* @memberOf MapCache
* @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/
function mapCacheDelete(key) {
var result = getMapData(this, key)['delete'](key);
this.size -= result ? 1 : 0;
return result;
}
/**
* Gets the map value for `key`.
*
* @private
* @name get
* @memberOf MapCache
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/
function mapCacheGet(key) {
return getMapData(this, key).get(key);
}
/**
* Checks if a map value for `key` exists.
*
* @private
* @name has
* @memberOf MapCache
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/
function mapCacheHas(key) {
return getMapData(this, key).has(key);
}
/**
* Sets the map `key` to `value`.
*
* @private
* @name set
* @memberOf MapCache
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
* @returns {Object} Returns the map cache instance.
*/
function mapCacheSet(key, value) {
var data = getMapData(this, key),
size = data.size;
data.set(key, value);
this.size += data.size == size ? 0 : 1;
return this;
}
/**
* Creates a map cache object to store key-value pairs.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
function MapCache(entries) {
var index = -1,
length = entries == null ? 0 : entries.length;
this.clear();
while (++index < length) {
var entry = entries[index];
this.set(entry[0], entry[1]);
}
}
// Add methods to `MapCache`.
MapCache.prototype.clear = mapCacheClear;
MapCache.prototype['delete'] = mapCacheDelete;
MapCache.prototype.get = mapCacheGet;
MapCache.prototype.has = mapCacheHas;
MapCache.prototype.set = mapCacheSet;
/** Used as the size to enable large array optimizations. */
var LARGE_ARRAY_SIZE = 200;
/**
* Sets the stack `key` to `value`.
*
* @private
* @name set
* @memberOf Stack
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
* @returns {Object} Returns the stack cache instance.
*/
function stackSet(key, value) {
var data = this.__data__;
if (data instanceof ListCache) {
var pairs = data.__data__;
if (!Map$1 || pairs.length < LARGE_ARRAY_SIZE - 1) {
pairs.push([key, value]);
this.size = ++data.size;
return this;
}
data = this.__data__ = new MapCache(pairs);
}
data.set(key, value);
this.size = data.size;
return this;
}
/**
* Creates a stack cache object to store key-value pairs.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
function Stack(entries) {
var data = this.__data__ = new ListCache(entries);
this.size = data.size;
}
// Add methods to `Stack`.
Stack.prototype.clear = stackClear;
Stack.prototype['delete'] = stackDelete;
Stack.prototype.get = stackGet;
Stack.prototype.has = stackHas;
Stack.prototype.set = stackSet;
/** Used to stand-in for `undefined` hash values. */
var HASH_UNDEFINED$2 = '__lodash_hash_undefined__';
/**
* Adds `value` to the array cache.
*
* @private
* @name add
* @memberOf SetCache
* @alias push
* @param {*} value The value to cache.
* @returns {Object} Returns the cache instance.
*/
function setCacheAdd(value) {
this.__data__.set(value, HASH_UNDEFINED$2);
return this;
}
/**
* Checks if `value` is in the array cache.
*
* @private
* @name has
* @memberOf SetCache
* @param {*} value The value to search for.
* @returns {number} Returns `true` if `value` is found, else `false`.
*/
function setCacheHas(value) {
return this.__data__.has(value);
}
/**
*
* Creates an array cache object to store unique values.
*
* @private
* @constructor
* @param {Array} [values] The values to cache.
*/
function SetCache(values) {
var index = -1,
length = values == null ? 0 : values.length;
this.__data__ = new MapCache();
while (++index < length) {
this.add(values[index]);
}
}
// Add methods to `SetCache`.
SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
SetCache.prototype.has = setCacheHas;
/**
* A specialized version of `_.some` for arrays without support for iteratee
* shorthands.
*
* @private
* @param {Array} [array] The array to iterate over.
* @param {Function} predicate The function invoked per iteration.
* @returns {boolean} Returns `true` if any element passes the predicate check,
* else `false`.
*/
function arraySome(array, predicate) {
var index = -1,
length = array == null ? 0 : array.length;
while (++index < length) {
if (predicate(array[index], index, array)) {
return true;
}
}
return false;
}
/**
* Checks if a `cache` value for `key` exists.
*
* @private
* @param {Object} cache The cache to query.
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/
function cacheHas(cache, key) {
return cache.has(key);
}
/** Used to compose bitmasks for value comparisons. */
var COMPARE_PARTIAL_FLAG = 1,
COMPARE_UNORDERED_FLAG = 2;
/**
* A specialized version of `baseIsEqualDeep` for arrays with support for
* partial deep comparisons.
*
* @private
* @param {Array} array The array to compare.
* @param {Array} other The other array to compare.
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
* @param {Function} customizer The function to customize comparisons.
* @param {Function} equalFunc The function to determine equivalents of values.
* @param {Object} stack Tracks traversed `array` and `other` objects.
* @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
*/
function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
arrLength = array.length,
othLength = other.length;
if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
return false;
}
// Assume cyclic values are equal.
var stacked = stack.get(array);
if (stacked && stack.get(other)) {
return stacked == other;
}
var index = -1,
result = true,
seen = bitmask & COMPARE_UNORDERED_FLAG ? new SetCache() : undefined;
stack.set(array, other);
stack.set(other, array);
// Ignore non-index properties.
while (++index < arrLength) {
var arrValue = array[index],
othValue = other[index];
if (customizer) {
var compared = isPartial ? customizer(othValue, arrValue, index, other, array, stack) : customizer(arrValue, othValue, index, array, other, stack);
}
if (compared !== undefined) {
if (compared) {
continue;
}
result = false;
break;
}
// Recursively compare arrays (susceptible to call stack limits).
if (seen) {
if (!arraySome(other, function (othValue, othIndex) {
if (!cacheHas(seen, othIndex) && (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
return seen.push(othIndex);
}
})) {
result = false;
break;
}
} else if (!(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
result = false;
break;
}
}
stack['delete'](array);
stack['delete'](other);
return result;
}
/** Built-in value references. */
var Uint8Array$1 = root.Uint8Array;
/**
* Converts `map` to its key-value pairs.
*
* @private
* @param {Object} map The map to convert.
* @returns {Array} Returns the key-value pairs.
*/
function mapToArray(map) {
var index = -1,
result = Array(map.size);
map.forEach(function (value, key) {
result[++index] = [key, value];
});
return result;
}
/**
* Converts `set` to an array of its values.
*
* @private
* @param {Object} set The set to convert.
* @returns {Array} Returns the values.
*/
function setToArray(set) {
var index = -1,
result = Array(set.size);
set.forEach(function (value) {
result[++index] = value;
});
return result;
}
/** Used to compose bitmasks for value comparisons. */
var COMPARE_PARTIAL_FLAG$1 = 1,
COMPARE_UNORDERED_FLAG$1 = 2;
/** `Object#toString` result references. */
var boolTag = '[object Boolean]',
dateTag = '[object Date]',
errorTag = '[object Error]',
mapTag = '[object Map]',
numberTag = '[object Number]',
regexpTag = '[object RegExp]',
setTag = '[object Set]',
stringTag = '[object String]',
symbolTag = '[object Symbol]';
var arrayBufferTag = '[object ArrayBuffer]',
dataViewTag = '[object DataView]';
/** Used to convert symbols to primitives and strings. */
var symbolProto = _Symbol ? _Symbol.prototype : undefined,
symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
/**
* A specialized version of `baseIsEqualDeep` for comparing objects of
* the same `toStringTag`.
*
* **Note:** This function only supports comparing values with tags of
* `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
*
* @private
* @param {Object} object The object to compare.
* @param {Object} other The other object to compare.
* @param {string} tag The `toStringTag` of the objects to compare.
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
* @param {Function} customizer The function to customize comparisons.
* @param {Function} equalFunc The function to determine equivalents of values.
* @param {Object} stack Tracks traversed `object` and `other` objects.
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
*/
function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
switch (tag) {
case dataViewTag:
if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) {
return false;
}
object = object.buffer;
other = other.buffer;
case arrayBufferTag:
if (object.byteLength != other.byteLength || !equalFunc(new Uint8Array$1(object), new Uint8Array$1(other))) {
return false;
}
return true;
case boolTag:
case dateTag:
case numberTag:
// Coerce booleans to `1` or `0` and dates to milliseconds.
// Invalid dates are coerced to `NaN`.
return eq(+object, +other);
case errorTag:
return object.name == other.name && object.message == other.message;
case regexpTag:
case stringTag:
// Coerce regexes to strings and treat strings, primitives and objects,
// as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
// for more details.
return object == other + '';
case mapTag:
var convert = mapToArray;
case setTag:
var isPartial = bitmask & COMPARE_PARTIAL_FLAG$1;
convert || (convert = setToArray);
if (object.size != other.size && !isPartial) {
return false;
}
// Assume cyclic values are equal.
var stacked = stack.get(object);
if (stacked) {
return stacked == other;
}
bitmask |= COMPARE_UNORDERED_FLAG$1;
// Recursively compare objects (susceptible to call stack limits).
stack.set(object, other);
var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
stack['delete'](object);
return result;
case symbolTag:
if (symbolValueOf) {
return symbolValueOf.call(object) == symbolValueOf.call(other);
}
}
return false;
}
/**
* Appends the elements of `values` to `array`.
*
* @private
* @param {Array} array The array to modify.
* @param {Array} values The values to append.
* @returns {Array} Returns `array`.
*/
function arrayPush(array, values) {
var index = -1,
length = values.length,
offset = array.length;
while (++index < length) {
array[offset + index] = values[index];
}
return array;
}
/**
* The base implementation of `getAllKeys` and `getAllKeysIn` which uses
* `keysFunc` and `symbolsFunc` to get the enumerable property names and
* symbols of `object`.
*
* @private
* @param {Object} object The object to query.
* @param {Function} keysFunc The function to get the keys of `object`.
* @param {Function} symbolsFunc The function to get the symbols of `object`.
* @returns {Array} Returns the array of property names and symbols.
*/
function baseGetAllKeys(object, keysFunc, symbolsFunc) {
var result = keysFunc(object);
return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
}
/**
* A specialized version of `_.filter` for arrays without support for
* iteratee shorthands.
*
* @private
* @param {Array} [array] The array to iterate over.
* @param {Function} predicate The function invoked per iteration.
* @returns {Array} Returns the new filtered array.
*/
function arrayFilter(array, predicate) {
var index = -1,
length = array == null ? 0 : array.length,
resIndex = 0,
result = [];
while (++index < length) {
var value = array[index];
if (predicate(value, index, array)) {
result[resIndex++] = value;
}
}
return result;
}
/**
* This method returns a new empty array.
*
* @static
* @memberOf _
* @since 4.13.0
* @category Util
* @returns {Array} Returns the new empty array.
* @example
*
* var arrays = _.times(2, _.stubArray);
*
* console.log(arrays);
* // => [[], []]
*
* console.log(arrays[0] === arrays[1]);
* // => false
*/
function stubArray() {
return [];
}
/** Used for built-in method references. */
var objectProto$5 = Object.prototype;
/** Built-in value references. */
var propertyIsEnumerable = objectProto$5.propertyIsEnumerable;
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeGetSymbols = Object.getOwnPropertySymbols;
/**
* Creates an array of the own enumerable symbols of `object`.
*
* @private
* @param {Object} object The object to query.
* @returns {Array} Returns the array of symbols.
*/
var getSymbols = !nativeGetSymbols ? stubArray : function (object) {
if (object == null) {
return [];
}
object = Object(object);
return arrayFilter(nativeGetSymbols(object), function (symbol) {
return propertyIsEnumerable.call(object, symbol);
});
};
/**
* The base implementation of `_.times` without support for iteratee shorthands
* or max array length checks.
*
* @private
* @param {number} n The number of times to invoke `iteratee`.
* @param {Function} iteratee The function invoked per iteration.
* @returns {Array} Returns the array of results.
*/
function baseTimes(n, iteratee) {
var index = -1,
result = Array(n);
while (++index < n) {
result[index] = iteratee(index);
}
return result;
}
/**
* Checks if `value` is object-like. A value is object-like if it's not `null`
* and has a `typeof` result of "object".
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
* @example
*
* _.isObjectLike({});
* // => true
*
* _.isObjectLike([1, 2, 3]);
* // => true
*
* _.isObjectLike(_.noop);
* // => false
*
* _.isObjectLike(null);
* // => false
*/
function isObjectLike(value) {
return value != null && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) == 'object';
}
/** `Object#toString` result references. */
var argsTag = '[object Arguments]';
/**
* The base implementation of `_.isArguments`.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
*/
function baseIsArguments(value) {
return isObjectLike(value) && baseGetTag(value) == argsTag;
}
/** Used for built-in method references. */
var objectProto$6 = Object.prototype;
/** Used to check objects for own properties. */
var hasOwnProperty$4 = objectProto$6.hasOwnProperty;
/** Built-in value references. */
var propertyIsEnumerable$1 = objectProto$6.propertyIsEnumerable;
/**
* Checks if `value` is likely an `arguments` object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
* else `false`.
* @example
*
* _.isArguments(function() { return arguments; }());
* // => true
*
* _.isArguments([1, 2, 3]);
* // => false
*/
var isArguments = baseIsArguments(function () {
return arguments;
}()) ? baseIsArguments : function (value) {
return isObjectLike(value) && hasOwnProperty$4.call(value, 'callee') && !propertyIsEnumerable$1.call(value, 'callee');
};
/**
* This method returns `false`.
*
* @static
* @memberOf _
* @since 4.13.0
* @category Util
* @returns {boolean} Returns `false`.
* @example
*
* _.times(2, _.stubFalse);
* // => [false, false]
*/
function stubFalse() {
return false;
}
/** Detect free variable `exports`. */
var freeExports = (typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) == 'object' && exports && !exports.nodeType && exports;
/** Detect free variable `module`. */
var freeModule = freeExports && (typeof module === 'undefined' ? 'undefined' : _typeof(module)) == 'object' && module && !module.nodeType && module;
/** Detect the popular CommonJS extension `module.exports`. */
var moduleExports = freeModule && freeModule.exports === freeExports;
/** Built-in value references. */
var Buffer = moduleExports ? root.Buffer : undefined;
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
/**
* Checks if `value` is a buffer.
*
* @static
* @memberOf _
* @since 4.3.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
* @example
*
* _.isBuffer(new Buffer(2));
* // => true
*
* _.isBuffer(new Uint8Array(2));
* // => false
*/
var isBuffer = nativeIsBuffer || stubFalse;
/** Used as references for various `Number` constants. */
var MAX_SAFE_INTEGER = 9007199254740991;
/** Used to detect unsigned integer values. */
var reIsUint = /^(?:0|[1-9]\d*)$/;
/**
* Checks if `value` is a valid array-like index.
*
* @private
* @param {*} value The value to check.
* @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
*/
function isIndex(value, length) {
var type = typeof value === 'undefined' ? 'undefined' : _typeof(value);
length = length == null ? MAX_SAFE_INTEGER : length;
return !!length && (type == 'number' || type != 'symbol' && reIsUint.test(value)) && value > -1 && value % 1 == 0 && value < length;
}
/** Used as references for various `Number` constants. */
var MAX_SAFE_INTEGER$1 = 9007199254740991;
/**
* Checks if `value` is a valid array-like length.
*
* **Note:** This method is loosely based on
* [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
* @example
*
* _.isLength(3);
* // => true
*
* _.isLength(Number.MIN_VALUE);
* // => false
*
* _.isLength(Infinity);
* // => false
*
* _.isLength('3');
* // => false
*/
function isLength(value) {
return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER$1;
}
/** `Object#toString` result references. */
var argsTag$1 = '[object Arguments]',
arrayTag = '[object Array]',
boolTag$1 = '[object Boolean]',
dateTag$1 = '[object Date]',
errorTag$1 = '[object Error]',
funcTag$1 = '[object Function]',
mapTag$1 = '[object Map]',
numberTag$1 = '[object Number]',
objectTag = '[object Object]',
regexpTag$1 = '[object RegExp]',
setTag$1 = '[object Set]',
stringTag$1 = '[object String]',
weakMapTag = '[object WeakMap]';
var arrayBufferTag$1 = '[object ArrayBuffer]',
dataViewTag$1 = '[object DataView]',
float32Tag = '[object Float32Array]',
float64Tag = '[object Float64Array]',
int8Tag = '[object Int8Array]',
int16Tag = '[object Int16Array]',
int32Tag = '[object Int32Array]',
uint8Tag = '[object Uint8Array]',
uint8ClampedTag = '[object Uint8ClampedArray]',
uint16Tag = '[object Uint16Array]',
uint32Tag = '[object Uint32Array]';
/** Used to identify `toStringTag` values of typed arrays. */
var typedArrayTags = {};
typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true;
typedArrayTags[argsTag$1] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag$1] = typedArrayTags[boolTag$1] = typedArrayTags[dataViewTag$1] = typedArrayTags[dateTag$1] = typedArrayTags[errorTag$1] = typedArrayTags[funcTag$1] = typedArrayTags[mapTag$1] = typedArrayTags[numberTag$1] = typedArrayTags[objectTag] = typedArrayTags[regexpTag$1] = typedArrayTags[setTag$1] = typedArrayTags[stringTag$1] = typedArrayTags[weakMapTag] = false;
/**
* The base implementation of `_.isTypedArray` without Node.js optimizations.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
*/
function baseIsTypedArray(value) {
return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
}
/**
* The base implementation of `_.unary` without support for storing metadata.
*
* @private
* @param {Function} func The function to cap arguments for.
* @returns {Function} Returns the new capped function.
*/
function baseUnary(func) {
return function (value) {
return func(value);
};
}
/** Detect free variable `exports`. */
var freeExports$1 = (typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) == 'object' && exports && !exports.nodeType && exports;
/** Detect free variable `module`. */
var freeModule$1 = freeExports$1 && (typeof module === 'undefined' ? 'undefined' : _typeof(module)) == 'object' && module && !module.nodeType && module;
/** Detect the popular CommonJS extension `module.exports`. */
var moduleExports$1 = freeModule$1 && freeModule$1.exports === freeExports$1;
/** Detect free variable `process` from Node.js. */
var freeProcess = moduleExports$1 && freeGlobal.process;
/** Used to access faster Node.js helpers. */
var nodeUtil = function () {
try {
// Use `util.types` for Node.js 10+.
var types = freeModule$1 && freeModule$1.require && freeModule$1.require('util').types;
if (types) {
return types;
}
// Legacy `process.binding('util')` for Node.js < 10.
return freeProcess && freeProcess.binding && freeProcess.binding('util');
} catch (e) {}
}();
/* Node.js helper references. */
var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
/**
* Checks if `value` is classified as a typed array.
*
* @static
* @memberOf _
* @since 3.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
* @example
*
* _.isTypedArray(new Uint8Array);
* // => true
*
* _.isTypedArray([]);
* // => false
*/
var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
/** Used for built-in method references. */
var objectProto$7 = Object.prototype;
/** Used to check objects for own properties. */
var hasOwnProperty$5 = objectProto$7.hasOwnProperty;
/**
* Creates an array of the enumerable property names of the array-like `value`.
*
* @private
* @param {*} value The value to query.
* @param {boolean} inherited Specify returning inherited property names.
* @returns {Array} Returns the array of property names.
*/
function arrayLikeKeys(value, inherited) {
var isArr = isArray(value),
isArg = !isArr && isArguments(value),
isBuff = !isArr && !isArg && isBuffer(value),
isType = !isArr && !isArg && !isBuff && isTypedArray(value),
skipIndexes = isArr || isArg || isBuff || isType,
result = skipIndexes ? baseTimes(value.length, String) : [],
length = result.length;
for (var key in value) {
if ((inherited || hasOwnProperty$5.call(value, key)) && !(skipIndexes && (
// Safari 9 has enumerable `arguments.length` in strict mode.
key == 'length' ||
// Node.js 0.10 has enumerable non-index properties on buffers.
isBuff && (key == 'offset' || key == 'parent') ||
// PhantomJS 2 has enumerable non-index properties on typed arrays.
isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset') ||
// Skip index properties.
isIndex(key, length)))) {
result.push(key);
}
}
return result;
}
/** Used for built-in method references. */
var objectProto$8 = Object.prototype;
/**
* Checks if `value` is likely a prototype object.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
*/
function isPrototype(value) {
var Ctor = value && value.constructor,
proto = typeof Ctor == 'function' && Ctor.prototype || objectProto$8;
return value === proto;
}
/**
* Creates a unary function that invokes `func` with its argument transformed.
*
* @private
* @param {Function} func The function to wrap.
* @param {Function} transform The argument transform.
* @returns {Function} Returns the new function.
*/
function overArg(func, transform) {
return function (arg) {
return func(transform(arg));
};
}
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeKeys = overArg(Object.keys, Object);
/** Used for built-in method references. */
var objectProto$9 = Object.prototype;
/** Used to check objects for own properties. */
var hasOwnProperty$6 = objectProto$9.hasOwnProperty;
/**
* The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
*
* @private
* @param {Object} object The object to query.
* @returns {Array} Returns the array of property names.
*/
function baseKeys(object) {
if (!isPrototype(object)) {
return nativeKeys(object);
}
var result = [];
for (var key in Object(object)) {
if (hasOwnProperty$6.call(object, key) && key != 'constructor') {
result.push(key);
}
}
return result;
}
/**
* Checks if `value` is array-like. A value is considered array-like if it's
* not a function and has a `value.length` that's an integer greater than or
* equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is array-like, else `false`.
* @example
*
* _.isArrayLike([1, 2, 3]);
* // => true
*
* _.isArrayLike(document.body.children);
* // => true
*
* _.isArrayLike('abc');
* // => true
*
* _.isArrayLike(_.noop);
* // => false
*/
function isArrayLike(value) {
return value != null && isLength(value.length) && !isFunction(value);
}
/**
* Creates an array of the own enumerable property names of `object`.
*
* **Note:** Non-object values are coerced to objects. See the
* [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
* for more details.
*
* @static
* @since 0.1.0
* @memberOf _
* @category Object
* @param {Object} object The object to query.
* @returns {Array} Returns the array of property names.
* @example
*
* function Foo() {
* this.a = 1;
* this.b = 2;
* }
*
* Foo.prototype.c = 3;
*
* _.keys(new Foo);
* // => ['a', 'b'] (iteration order is not guaranteed)
*
* _.keys('hi');
* // => ['0', '1']
*/
function keys(object) {
return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
}
/**
* Creates an array of own enumerable property names and symbols of `object`.
*
* @private
* @param {Object} object The object to query.
* @returns {Array} Returns the array of property names and symbols.
*/
function getAllKeys(object) {
return baseGetAllKeys(object, keys, getSymbols);
}
/** Used to compose bitmasks for value comparisons. */
var COMPARE_PARTIAL_FLAG$2 = 1;
/** Used for built-in method references. */
var objectProto$a = Object.prototype;
/** Used to check objects for own properties. */
var hasOwnProperty$7 = objectProto$a.hasOwnProperty;
/**
* A specialized version of `baseIsEqualDeep` for objects with support for
* partial deep comparisons.
*
* @private
* @param {Object} object The object to compare.
* @param {Object} other The other object to compare.
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
* @param {Function} customizer The function to customize comparisons.
* @param {Function} equalFunc The function to determine equivalents of values.
* @param {Object} stack Tracks traversed `object` and `other` objects.
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
*/
function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
var isPartial = bitmask & COMPARE_PARTIAL_FLAG$2,
objProps = getAllKeys(object),
objLength = objProps.length,
othProps = getAllKeys(other),
othLength = othProps.length;
if (objLength != othLength && !isPartial) {
return false;
}
var index = objLength;
while (index--) {
var key = objProps[index];
if (!(isPartial ? key in other : hasOwnProperty$7.call(other, key))) {
return false;
}
}
// Assume cyclic values are equal.
var stacked = stack.get(object);
if (stacked && stack.get(other)) {
return stacked == other;
}
var result = true;
stack.set(object, other);
stack.set(other, object);
var skipCtor = isPartial;
while (++index < objLength) {
key = objProps[index];
var objValue = object[key],
othValue = other[key];
if (customizer) {
var compared = isPartial ? customizer(othValue, objValue, key, other, object, stack) : customizer(objValue, othValue, key, object, other, stack);
}
// Recursively compare objects (susceptible to call stack limits).
if (!(compared === undefined ? objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack) : compared)) {
result = false;
break;
}
skipCtor || (skipCtor = key == 'constructor');
}
if (result && !skipCtor) {
var objCtor = object.constructor,
othCtor = other.constructor;
// Non `Object` object instances with different constructors are not equal.
if (objCtor != othCtor && 'constructor' in object && 'constructor' in other && !(typeof objCtor == 'function' && objCtor instanceof objCtor && typeof othCtor == 'function' && othCtor instanceof othCtor)) {
result = false;
}
}
stack['delete'](object);
stack['delete'](other);
return result;
}
/* Built-in method references that are verified to be native. */
var DataView = getNative(root, 'DataView');
/* Built-in method references that are verified to be native. */
var Promise$1 = getNative(root, 'Promise');
/* Built-in method references that are verified to be native. */
var Set$1 = getNative(root, 'Set');
/* Built-in method references that are verified to be native. */
var WeakMap = getNative(root, 'WeakMap');
/** `Object#toString` result references. */
var mapTag$2 = '[object Map]',
objectTag$1 = '[object Object]',
promiseTag = '[object Promise]',
setTag$2 = '[object Set]',
weakMapTag$1 = '[object WeakMap]';
var dataViewTag$2 = '[object DataView]';
/** Used to detect maps, sets, and weakmaps. */
var dataViewCtorString = toSource(DataView),
mapCtorString = toSource(Map$1),
promiseCtorString = toSource(Promise$1),
setCtorString = toSource(Set$1),
weakMapCtorString = toSource(WeakMap);
/**
* Gets the `toStringTag` of `value`.
*
* @private
* @param {*} value The value to query.
* @returns {string} Returns the `toStringTag`.
*/
var getTag = baseGetTag;
// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
if (DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag$2 || Map$1 && getTag(new Map$1()) != mapTag$2 || Promise$1 && getTag(Promise$1.resolve()) != promiseTag || Set$1 && getTag(new Set$1()) != setTag$2 || WeakMap && getTag(new WeakMap()) != weakMapTag$1) {
getTag = function getTag(value) {
var result = baseGetTag(value),
Ctor = result == objectTag$1 ? value.constructor : undefined,
ctorString = Ctor ? toSource(Ctor) : '';
if (ctorString) {
switch (ctorString) {
case dataViewCtorString:
return dataViewTag$2;
case mapCtorString:
return mapTag$2;
case promiseCtorString:
return promiseTag;
case setCtorString:
return setTag$2;
case weakMapCtorString:
return weakMapTag$1;
}
}
return result;
};
}
var getTag$1 = getTag;
/** Used to compose bitmasks for value comparisons. */
var COMPARE_PARTIAL_FLAG$3 = 1;
/** `Object#toString` result references. */
var argsTag$2 = '[object Arguments]',
arrayTag$1 = '[object Array]',
objectTag$2 = '[object Object]';
/** Used for built-in method references. */
var objectProto$b = Object.prototype;
/** Used to check objects for own properties. */
var hasOwnProperty$8 = objectProto$b.hasOwnProperty;
/**
* A specialized version of `baseIsEqual` for arrays and objects which performs
* deep comparisons and tracks traversed objects enabling objects with circular
* references to be compared.
*
* @private
* @param {Object} object The object to compare.
* @param {Object} other The other object to compare.
* @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
* @param {Function} customizer The function to customize comparisons.
* @param {Function} equalFunc The function to determine equivalents of values.
* @param {Object} [stack] Tracks traversed `object` and `other` objects.
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
*/
function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
var objIsArr = isArray(object),
othIsArr = isArray(other),
objTag = objIsArr ? arrayTag$1 : getTag$1(object),
othTag = othIsArr ? arrayTag$1 : getTag$1(other);
objTag = objTag == argsTag$2 ? objectTag$2 : objTag;
othTag = othTag == argsTag$2 ? objectTag$2 : othTag;
var objIsObj = objTag == objectTag$2,
othIsObj = othTag == objectTag$2,
isSameTag = objTag == othTag;
if (isSameTag && isBuffer(object)) {
if (!isBuffer(other)) {
return false;
}
objIsArr = true;
objIsObj = false;
}
if (isSameTag && !objIsObj) {
stack || (stack = new Stack());
return objIsArr || isTypedArray(object) ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
}
if (!(bitmask & COMPARE_PARTIAL_FLAG$3)) {
var objIsWrapped = objIsObj && hasOwnProperty$8.call(object, '__wrapped__'),
othIsWrapped = othIsObj && hasOwnProperty$8.call(other, '__wrapped__');
if (objIsWrapped || othIsWrapped) {
var objUnwrapped = objIsWrapped ? object.value() : object,
othUnwrapped = othIsWrapped ? other.value() : other;
stack || (stack = new Stack());
return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
}
}
if (!isSameTag) {
return false;
}
stack || (stack = new Stack());
return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
}
/**
* The base implementation of `_.isEqual` which supports partial comparisons
* and tracks traversed objects.
*
* @private
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @param {boolean} bitmask The bitmask flags.
* 1 - Unordered comparison
* 2 - Partial comparison
* @param {Function} [customizer] The function to customize comparisons.
* @param {Object} [stack] Tracks traversed `value` and `other` objects.
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
*/
function baseIsEqual(value, other, bitmask, customizer, stack) {
if (value === other) {
return true;
}
if (value == null || other == null || !isObjectLike(value) && !isObjectLike(other)) {
return value !== value && other !== other;
}
return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
}
/**
* Performs a deep comparison between two values to determine if they are
* equivalent.
*
* **Note:** This method supports comparing arrays, array buffers, booleans,
* date objects, error objects, maps, numbers, `Object` objects, regexes,
* sets, strings, symbols, and typed arrays. `Object` objects are compared
* by their own, not inherited, enumerable properties. Functions and DOM
* nodes are compared by strict equality, i.e. `===`.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
* @example
*
* var object = { 'a': 1 };
* var other = { 'a': 1 };
*
* _.isEqual(object, other);
* // => true
*
* object === other;
* // => false
*/
function isEqual(value, other) {
return baseIsEqual(value, other);
}
/** `Object#toString` result references. */
var stringTag$2 = '[object String]';
/**
* Checks if `value` is classified as a `String` primitive or object.
*
* @static
* @since 0.1.0
* @memberOf _
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a string, else `false`.
* @example
*
* _.isString('abc');
* // => true
*
* _.isString(1);
* // => false
*/
function isString(value) {
return typeof value == 'string' || !isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag$2;
}
/** `Object#toString` result references. */
var boolTag$2 = '[object Boolean]';
/**
* Checks if `value` is classified as a boolean primitive or object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
* @example
*
* _.isBoolean(false);
* // => true
*
* _.isBoolean(null);
* // => false
*/
function isBoolean(value) {
return value === true || value === false || isObjectLike(value) && baseGetTag(value) == boolTag$2;
}
/** `Object#toString` result references. */
var numberTag$2 = '[object Number]';
/**
* Checks if `value` is classified as a `Number` primitive or object.
*
* **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
* classified as numbers, use the `_.isFinite` method.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a number, else `false`.
* @example
*
* _.isNumber(3);
* // => true
*
* _.isNumber(Number.MIN_VALUE);
* // => true
*
* _.isNumber(Infinity);
* // => true
*
* _.isNumber('3');
* // => false
*/
function isNumber(value) {
return typeof value == 'number' || isObjectLike(value) && baseGetTag(value) == numberTag$2;
}
/** `Object#toString` result references. */
var dateTag$2 = '[object Date]';
/**
* The base implementation of `_.isDate` without Node.js optimizations.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a date object, else `false`.
*/
function baseIsDate(value) {
return isObjectLike(value) && baseGetTag(value) == dateTag$2;
}
/* Node.js helper references. */
var nodeIsDate = nodeUtil && nodeUtil.isDate;
/**
* Checks if `value` is classified as a `Date` object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a date object, else `false`.
* @example
*
* _.isDate(new Date);
* // => true
*
* _.isDate('Mon April 23 2012');
* // => false
*/
var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
/**
* A specialized version of `_.forEach` for arrays without support for
* iteratee shorthands.
*
* @private
* @param {Array} [array] The array to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @returns {Array} Returns `array`.
*/
function arrayEach(array, iteratee) {
var index = -1,
length = array == null ? 0 : array.length;
while (++index < length) {
if (iteratee(array[index], index, array) === false) {
break;
}
}
return array;
}
var defineProperty$1 = function () {
try {
var func = getNative(Object, 'defineProperty');
func({}, '', {});
return func;
} catch (e) {}
}();
/**
* The base implementation of `assignValue` and `assignMergeValue` without
* value checks.
*
* @private
* @param {Object} object The object to modify.
* @param {string} key The key of the property to assign.
* @param {*} value The value to assign.
*/
function baseAssignValue(object, key, value) {
if (key == '__proto__' && defineProperty$1) {
defineProperty$1(object, key, {
'configurable': true,
'enumerable': true,
'value': value,
'writable': true
});
} else {
object[key] = value;
}
}
/** Used for built-in method references. */
var objectProto$c = Object.prototype;
/** Used to check objects for own properties. */
var hasOwnProperty$9 = objectProto$c.hasOwnProperty;
/**
* Assigns `value` to `key` of `object` if the existing value is not equivalent
* using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* for equality comparisons.
*
* @private
* @param {Object} object The object to modify.
* @param {string} key The key of the property to assign.
* @param {*} value The value to assign.
*/
function assignValue(object, key, value) {
var objValue = object[key];
if (!(hasOwnProperty$9.call(object, key) && eq(objValue, value)) || value === undefined && !(key in object)) {
baseAssignValue(object, key, value);
}
}
/**
* Copies properties of `source` to `object`.
*
* @private
* @param {Object} source The object to copy properties from.
* @param {Array} props The property identifiers to copy.
* @param {Object} [object={}] The object to copy properties to.
* @param {Function} [customizer] The function to customize copied values.
* @returns {Object} Returns `object`.
*/
function copyObject(source, props, object, customizer) {
var isNew = !object;
object || (object = {});
var index = -1,
length = props.length;
while (++index < length) {
var key = props[index];
var newValue = customizer ? customizer(object[key], source[key], key, object, source) : undefined;
if (newValue === undefined) {
newValue = source[key];
}
if (isNew) {
baseAssignValue(object, key, newValue);
} else {
assignValue(object, key, newValue);
}
}
return object;
}
/**
* The base implementation of `_.assign` without support for multiple sources
* or `customizer` functions.
*
* @private
* @param {Object} object The destination object.
* @param {Object} source The source object.
* @returns {Object} Returns `object`.
*/
function baseAssign(object, source) {
return object && copyObject(source, keys(source), object);
}
/**
* This function is like
* [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
* except that it includes inherited enumerable properties.
*
* @private
* @param {Object} object The object to query.
* @returns {Array} Returns the array of property names.
*/
function nativeKeysIn(object) {
var result = [];
if (object != null) {
for (var key in Object(object)) {
result.push(key);
}
}
return result;
}
/** Used for built-in method references. */
var objectProto$d = Object.prototype;
/** Used to check objects for own properties. */
var hasOwnProperty$a = objectProto$d.hasOwnProperty;
/**
* The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
*
* @private
* @param {Object} object The object to query.
* @returns {Array} Returns the array of property names.
*/
function baseKeysIn(object) {
if (!isObject(object)) {
return nativeKeysIn(object);
}
var isProto = isPrototype(object),
result = [];
for (var key in object) {
if (!(key == 'constructor' && (isProto || !hasOwnProperty$a.call(object, key)))) {
result.push(key);
}
}
return result;
}
/**
* Creates an array of the own and inherited enumerable property names of `object`.
*
* **Note:** Non-object values are coerced to objects.
*
* @static
* @memberOf _
* @since 3.0.0
* @category Object
* @param {Object} object The object to query.
* @returns {Array} Returns the array of property names.
* @example
*
* function Foo() {
* this.a = 1;
* this.b = 2;
* }
*
* Foo.prototype.c = 3;
*
* _.keysIn(new Foo);
* // => ['a', 'b', 'c'] (iteration order is not guaranteed)
*/
function keysIn$1(object) {
return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
}
/**
* The base implementation of `_.assignIn` without support for multiple sources
* or `customizer` functions.
*
* @private
* @param {Object} object The destination object.
* @param {Object} source The source object.
* @returns {Object} Returns `object`.
*/
function baseAssignIn(object, source) {
return object && copyObject(source, keysIn$1(source), object);
}
/** Detect free variable `exports`. */
var freeExports$2 = (typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) == 'object' && exports && !exports.nodeType && exports;
/** Detect free variable `module`. */
var freeModule$2 = freeExports$2 && (typeof module === 'undefined' ? 'undefined' : _typeof(module)) == 'object' && module && !module.nodeType && module;
/** Detect the popular CommonJS extension `module.exports`. */
var moduleExports$2 = freeModule$2 && freeModule$2.exports === freeExports$2;
/** Built-in value references. */
var Buffer$1 = moduleExports$2 ? root.Buffer : undefined,
allocUnsafe = Buffer$1 ? Buffer$1.allocUnsafe : undefined;
/**
* Creates a clone of `buffer`.
*
* @private
* @param {Buffer} buffer The buffer to clone.
* @param {boolean} [isDeep] Specify a deep clone.
* @returns {Buffer} Returns the cloned buffer.
*/
function cloneBuffer(buffer, isDeep) {
if (isDeep) {
return buffer.slice();
}
var length = buffer.length,
result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
buffer.copy(result);
return result;
}
/**
* Copies the values of `source` to `array`.
*
* @private
* @param {Array} source The array to copy values from.
* @param {Array} [array=[]] The array to copy values to.
* @returns {Array} Returns `array`.
*/
function copyArray(source, array) {
var index = -1,
length = source.length;
array || (array = Array(length));
while (++index < length) {
array[index] = source[index];
}
return array;
}
/**
* Copies own symbols of `source` to `object`.
*
* @private
* @param {Object} source The object to copy symbols from.
* @param {Object} [object={}] The object to copy symbols to.
* @returns {Object} Returns `object`.
*/
function copySymbols(source, object) {
return copyObject(source, getSymbols(source), object);
}
/** Built-in value references. */
var getPrototype = overArg(Object.getPrototypeOf, Object);
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeGetSymbols$1 = Object.getOwnPropertySymbols;
/**
* Creates an array of the own and inherited enumerable symbols of `object`.
*
* @private
* @param {Object} object The object to query.
* @returns {Array} Returns the array of symbols.
*/
var getSymbolsIn = !nativeGetSymbols$1 ? stubArray : function (object) {
var result = [];
while (object) {
arrayPush(result, getSymbols(object));
object = getPrototype(object);
}
return result;
};
/**
* Copies own and inherited symbols of `source` to `object`.
*
* @private
* @param {Object} source The object to copy symbols from.
* @param {Object} [object={}] The object to copy symbols to.
* @returns {Object} Returns `object`.
*/
function copySymbolsIn(source, object) {
return copyObject(source, getSymbolsIn(source), object);
}
/**
* Creates an array of own and inherited enumerable property names and
* symbols of `object`.
*
* @private
* @param {Object} object The object to query.
* @returns {Array} Returns the array of property names and symbols.
*/
function getAllKeysIn(object) {
return baseGetAllKeys(object, keysIn$1, getSymbolsIn);
}
/** Used for built-in method references. */
var objectProto$e = Object.prototype;
/** Used to check objects for own properties. */
var hasOwnProperty$b = objectProto$e.hasOwnProperty;
/**
* Initializes an array clone.
*
* @private
* @param {Array} array The array to clone.
* @returns {Array} Returns the initialized clone.
*/
function initCloneArray(array) {
var length = array.length,
result = new array.constructor(length);
// Add properties assigned by `RegExp#exec`.
if (length && typeof array[0] == 'string' && hasOwnProperty$b.call(array, 'index')) {
result.index = array.index;
result.input = array.input;
}
return result;
}
/**
* Creates a clone of `arrayBuffer`.
*
* @private
* @param {ArrayBuffer} arrayBuffer The array buffer to clone.
* @returns {ArrayBuffer} Returns the cloned array buffer.
*/
function cloneArrayBuffer(arrayBuffer) {
var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
new Uint8Array$1(result).set(new Uint8Array$1(arrayBuffer));
return result;
}
/**
* Creates a clone of `dataView`.
*
* @private
* @param {Object} dataView The data view to clone.
* @param {boolean} [isDeep] Specify a deep clone.
* @returns {Object} Returns the cloned data view.
*/
function cloneDataView(dataView, isDeep) {
var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
}
/** Used to match `RegExp` flags from their coerced string values. */
var reFlags = /\w*$/;
/**
* Creates a clone of `regexp`.
*
* @private
* @param {Object} regexp The regexp to clone.
* @returns {Object} Returns the cloned regexp.
*/
function cloneRegExp(regexp) {
var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
result.lastIndex = regexp.lastIndex;
return result;
}
/** Used to convert symbols to primitives and strings. */
var symbolProto$1 = _Symbol ? _Symbol.prototype : undefined,
symbolValueOf$1 = symbolProto$1 ? symbolProto$1.valueOf : undefined;
/**
* Creates a clone of the `symbol` object.
*
* @private
* @param {Object} symbol The symbol object to clone.
* @returns {Object} Returns the cloned symbol object.
*/
function cloneSymbol(symbol) {
return symbolValueOf$1 ? Object(symbolValueOf$1.call(symbol)) : {};
}
/**
* Creates a clone of `typedArray`.
*
* @private
* @param {Object} typedArray The typed array to clone.
* @param {boolean} [isDeep] Specify a deep clone.
* @returns {Object} Returns the cloned typed array.
*/
function cloneTypedArray(typedArray, isDeep) {
var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
}
/** `Object#toString` result references. */
var boolTag$3 = '[object Boolean]',
dateTag$3 = '[object Date]',
mapTag$3 = '[object Map]',
numberTag$3 = '[object Number]',
regexpTag$2 = '[object RegExp]',
setTag$3 = '[object Set]',
stringTag$3 = '[object String]',
symbolTag$1 = '[object Symbol]';
var arrayBufferTag$2 = '[object ArrayBuffer]',
dataViewTag$3 = '[object DataView]',
float32Tag$1 = '[object Float32Array]',
float64Tag$1 = '[object Float64Array]',
int8Tag$1 = '[object Int8Array]',
int16Tag$1 = '[object Int16Array]',
int32Tag$1 = '[object Int32Array]',
uint8Tag$1 = '[object Uint8Array]',
uint8ClampedTag$1 = '[object Uint8ClampedArray]',
uint16Tag$1 = '[object Uint16Array]',
uint32Tag$1 = '[object Uint32Array]';
/**
* Initializes an object clone based on its `toStringTag`.
*
* **Note:** This function only supports cloning values with tags of
* `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
*
* @private
* @param {Object} object The object to clone.
* @param {string} tag The `toStringTag` of the object to clone.
* @param {boolean} [isDeep] Specify a deep clone.
* @returns {Object} Returns the initialized clone.
*/
function initCloneByTag(object, tag, isDeep) {
var Ctor = object.constructor;
switch (tag) {
case arrayBufferTag$2:
return cloneArrayBuffer(object);
case boolTag$3:
case dateTag$3:
return new Ctor(+object);
case dataViewTag$3:
return cloneDataView(object, isDeep);
case float32Tag$1:case float64Tag$1:
case int8Tag$1:case int16Tag$1:case int32Tag$1:
case uint8Tag$1:case uint8ClampedTag$1:case uint16Tag$1:case uint32Tag$1:
return cloneTypedArray(object, isDeep);
case mapTag$3:
return new Ctor();
case numberTag$3:
case stringTag$3:
return new Ctor(object);
case regexpTag$2:
return cloneRegExp(object);
case setTag$3:
return new Ctor();
case symbolTag$1:
return cloneSymbol(object);
}
}
/** Built-in value references. */
var objectCreate = Object.create;
/**
* The base implementation of `_.create` without support for assigning
* properties to the created object.
*
* @private
* @param {Object} proto The object to inherit from.
* @returns {Object} Returns the new object.
*/
var baseCreate = function () {
function object() {}
return function (proto) {
if (!isObject(proto)) {
return {};
}
if (objectCreate) {
return objectCreate(proto);
}
object.prototype = proto;
var result = new object();
object.prototype = undefined;
return result;
};
}();
/**
* Initializes an object clone.
*
* @private
* @param {Object} object The object to clone.
* @returns {Object} Returns the initialized clone.
*/
function initCloneObject(object) {
return typeof object.constructor == 'function' && !isPrototype(object) ? baseCreate(getPrototype(object)) : {};
}
/** `Object#toString` result references. */
var mapTag$4 = '[object Map]';
/**
* The base implementation of `_.isMap` without Node.js optimizations.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a map, else `false`.
*/
function baseIsMap(value) {
return isObjectLike(value) && getTag$1(value) == mapTag$4;
}
/* Node.js helper references. */
var nodeIsMap = nodeUtil && nodeUtil.isMap;
/**
* Checks if `value` is classified as a `Map` object.
*
* @static
* @memberOf _
* @since 4.3.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a map, else `false`.
* @example
*
* _.isMap(new Map);
* // => true
*
* _.isMap(new WeakMap);
* // => false
*/
var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
/** `Object#toString` result references. */
var setTag$4 = '[object Set]';
/**
* The base implementation of `_.isSet` without Node.js optimizations.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a set, else `false`.
*/
function baseIsSet(value) {
return isObjectLike(value) && getTag$1(value) == setTag$4;
}
/* Node.js helper references. */
var nodeIsSet = nodeUtil && nodeUtil.isSet;
/**
* Checks if `value` is classified as a `Set` object.
*
* @static
* @memberOf _
* @since 4.3.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a set, else `false`.
* @example
*
* _.isSet(new Set);
* // => true
*
* _.isSet(new WeakSet);
* // => false
*/
var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
/** Used to compose bitmasks for cloning. */
var CLONE_DEEP_FLAG = 1,
CLONE_FLAT_FLAG = 2,
CLONE_SYMBOLS_FLAG = 4;
/** `Object#toString` result references. */
var argsTag$3 = '[object Arguments]',
arrayTag$2 = '[object Array]',
boolTag$4 = '[object Boolean]',
dateTag$4 = '[object Date]',
errorTag$2 = '[object Error]',
funcTag$2 = '[object Function]',
genTag$1 = '[object GeneratorFunction]',
mapTag$5 = '[object Map]',
numberTag$4 = '[object Number]',
objectTag$3 = '[object Object]',
regexpTag$3 = '[object RegExp]',
setTag$5 = '[object Set]',
stringTag$4 = '[object String]',
symbolTag$2 = '[object Symbol]',
weakMapTag$2 = '[object WeakMap]';
var arrayBufferTag$3 = '[object ArrayBuffer]',
dataViewTag$4 = '[object DataView]',
float32Tag$2 = '[object Float32Array]',
float64Tag$2 = '[object Float64Array]',
int8Tag$2 = '[object Int8Array]',
int16Tag$2 = '[object Int16Array]',
int32Tag$2 = '[object Int32Array]',
uint8Tag$2 = '[object Uint8Array]',
uint8ClampedTag$2 = '[object Uint8ClampedArray]',
uint16Tag$2 = '[object Uint16Array]',
uint32Tag$2 = '[object Uint32Array]';
/** Used to identify `toStringTag` values supported by `_.clone`. */
var cloneableTags = {};
cloneableTags[argsTag$3] = cloneableTags[arrayTag$2] = cloneableTags[arrayBufferTag$3] = cloneableTags[dataViewTag$4] = cloneableTags[boolTag$4] = cloneableTags[dateTag$4] = cloneableTags[float32Tag$2] = cloneableTags[float64Tag$2] = cloneableTags[int8Tag$2] = cloneableTags[int16Tag$2] = cloneableTags[int32Tag$2] = cloneableTags[mapTag$5] = cloneableTags[numberTag$4] = cloneableTags[objectTag$3] = cloneableTags[regexpTag$3] = cloneableTags[setTag$5] = cloneableTags[stringTag$4] = cloneableTags[symbolTag$2] = cloneableTags[uint8Tag$2] = cloneableTags[uint8ClampedTag$2] = cloneableTags[uint16Tag$2] = cloneableTags[uint32Tag$2] = true;
cloneableTags[errorTag$2] = cloneableTags[funcTag$2] = cloneableTags[weakMapTag$2] = false;
/**
* The base implementation of `_.clone` and `_.cloneDeep` which tracks
* traversed objects.
*
* @private
* @param {*} value The value to clone.
* @param {boolean} bitmask The bitmask flags.
* 1 - Deep clone
* 2 - Flatten inherited properties
* 4 - Clone symbols
* @param {Function} [customizer] The function to customize cloning.
* @param {string} [key] The key of `value`.
* @param {Object} [object] The parent object of `value`.
* @param {Object} [stack] Tracks traversed objects and their clone counterparts.
* @returns {*} Returns the cloned value.
*/
function baseClone(value, bitmask, customizer, key, object, stack) {
var result,
isDeep = bitmask & CLONE_DEEP_FLAG,
isFlat = bitmask & CLONE_FLAT_FLAG,
isFull = bitmask & CLONE_SYMBOLS_FLAG;
if (customizer) {
result = object ? customizer(value, key, object, stack) : customizer(value);
}
if (result !== undefined) {
return result;
}
if (!isObject(value)) {
return value;
}
var isArr = isArray(value);
if (isArr) {
result = initCloneArray(value);
if (!isDeep) {
return copyArray(value, result);
}
} else {
var tag = getTag$1(value),
isFunc = tag == funcTag$2 || tag == genTag$1;
if (isBuffer(value)) {
return cloneBuffer(value, isDeep);
}
if (tag == objectTag$3 || tag == argsTag$3 || isFunc && !object) {
result = isFlat || isFunc ? {} : initCloneObject(value);
if (!isDeep) {
return isFlat ? copySymbolsIn(value, baseAssignIn(result, value)) : copySymbols(value, baseAssign(result, value));
}
} else {
if (!cloneableTags[tag]) {
return object ? value : {};
}
result = initCloneByTag(value, tag, isDeep);
}
}
// Check for circular references and return its corresponding clone.
stack || (stack = new Stack());
var stacked = stack.get(value);
if (stacked) {
return stacked;
}
stack.set(value, result);
if (isSet(value)) {
value.forEach(function (subValue) {
result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
});
return result;
}
if (isMap(value)) {
value.forEach(function (subValue, key) {
result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
});
return result;
}
var keysFunc = isFull ? isFlat ? getAllKeysIn : getAllKeys : isFlat ? keysIn : keys;
var props = isArr ? undefined : keysFunc(value);
arrayEach(props || value, function (subValue, key) {
if (props) {
key = subValue;
subValue = value[key];
}
// Recursively populate clone (susceptible to call stack limits).
assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
});
return result;
}
/** Used to compose bitmasks for cloning. */
var CLONE_SYMBOLS_FLAG$1 = 4;
/**
* Creates a shallow clone of `value`.
*
* **Note:** This method is loosely based on the
* [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
* and supports cloning arrays, array buffers, booleans, date objects, maps,
* numbers, `Object` objects, regexes, sets, strings, symbols, and typed
* arrays. The own enumerable properties of `arguments` objects are cloned
* as plain objects. An empty object is returned for uncloneable values such
* as error objects, functions, DOM nodes, and WeakMaps.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to clone.
* @returns {*} Returns the cloned value.
* @see _.cloneDeep
* @example
*
* var objects = [{ 'a': 1 }, { 'b': 2 }];
*
* var shallow = _.clone(objects);
* console.log(shallow[0] === objects[0]);
* // => true
*/
function clone(value) {
return baseClone(value, CLONE_SYMBOLS_FLAG$1);
}
/** Used to compose bitmasks for cloning. */
var CLONE_DEEP_FLAG$1 = 1,
CLONE_SYMBOLS_FLAG$2 = 4;
/**
* This method is like `_.cloneWith` except that it recursively clones `value`.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to recursively clone.
* @param {Function} [customizer] The function to customize cloning.
* @returns {*} Returns the deep cloned value.
* @see _.cloneWith
* @example
*
* function customizer(value) {
* if (_.isElement(value)) {
* return value.cloneNode(true);
* }
* }
*
* var el = _.cloneDeepWith(document.body, customizer);
*
* console.log(el === document.body);
* // => false
* console.log(el.nodeName);
* // => 'BODY'
* console.log(el.childNodes.length);
* // => 20
*/
function cloneDeepWith(value, customizer) {
customizer = typeof customizer == 'function' ? customizer : undefined;
return baseClone(value, CLONE_DEEP_FLAG$1 | CLONE_SYMBOLS_FLAG$2, customizer);
}
/**
* Checks if `value` is `undefined`.
*
* @static
* @since 0.1.0
* @memberOf _
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
* @example
*
* _.isUndefined(void 0);
* // => true
*
* _.isUndefined(null);
* // => false
*/
function isUndefined(value) {
return value === undefined;
}
/**
* Gets the timestamp of the number of milliseconds that have elapsed since
* the Unix epoch (1 January 1970 00:00:00 UTC).
*
* @static
* @memberOf _
* @since 2.4.0
* @category Date
* @returns {number} Returns the timestamp.
* @example
*
* _.defer(function(stamp) {
* console.log(_.now() - stamp);
* }, _.now());
* // => Logs the number of milliseconds it took for the deferred invocation.
*/
var now = function now() {
return root.Date.now();
};
/** `Object#toString` result references. */
var symbolTag$3 = '[object Symbol]';
/**
* Checks if `value` is classified as a `Symbol` primitive or object.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
* @example
*
* _.isSymbol(Symbol.iterator);
* // => true
*
* _.isSymbol('abc');
* // => false
*/
function isSymbol(value) {
return (typeof value === 'undefined' ? 'undefined' : _typeof(value)) == 'symbol' || isObjectLike(value) && baseGetTag(value) == symbolTag$3;
}
/** Used as references for various `Number` constants. */
var NAN = 0 / 0;
/** Used to match leading and trailing whitespace. */
var reTrim = /^\s+|\s+$/g;
/** Used to detect bad signed hexadecimal string values. */
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
/** Used to detect binary string values. */
var reIsBinary = /^0b[01]+$/i;
/** Used to detect octal string values. */
var reIsOctal = /^0o[0-7]+$/i;
/** Built-in method references without a dependency on `root`. */
var freeParseInt = parseInt;
/**
* Converts `value` to a number.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to process.
* @returns {number} Returns the number.
* @example
*
* _.toNumber(3.2);
* // => 3.2
*
* _.toNumber(Number.MIN_VALUE);
* // => 5e-324
*
* _.toNumber(Infinity);
* // => Infinity
*
* _.toNumber('3.2');
* // => 3.2
*/
function toNumber(value) {
if (typeof value == 'number') {
return value;
}
if (isSymbol(value)) {
return NAN;
}
if (isObject(value)) {
var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
value = isObject(other) ? other + '' : other;
}
if (typeof value != 'string') {
return value === 0 ? value : +value;
}
value = value.replace(reTrim, '');
var isBinary = reIsBinary.test(value);
return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
}
/** Error message constants. */
var FUNC_ERROR_TEXT = 'Expected a function';
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeMax = Math.max,
nativeMin = Math.min;
/**
* Creates a debounced function that delays invoking `func` until after `wait`
* milliseconds have elapsed since the last time the debounced function was
* invoked. The debounced function comes with a `cancel` method to cancel
* delayed `func` invocations and a `flush` method to immediately invoke them.
* Provide `options` to indicate whether `func` should be invoked on the
* leading and/or trailing edge of the `wait` timeout. The `func` is invoked
* with the last arguments provided to the debounced function. Subsequent
* calls to the debounced function return the result of the last `func`
* invocation.
*
* **Note:** If `leading` and `trailing` options are `true`, `func` is
* invoked on the trailing edge of the timeout only if the debounced function
* is invoked more than once during the `wait` timeout.
*
* If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
* until to the next tick, similar to `setTimeout` with a timeout of `0`.
*
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
* for details over the differences between `_.debounce` and `_.throttle`.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Function
* @param {Function} func The function to debounce.
* @param {number} [wait=0] The number of milliseconds to delay.
* @param {Object} [options={}] The options object.
* @param {boolean} [options.leading=false]
* Specify invoking on the leading edge of the timeout.
* @param {number} [options.maxWait]
* The maximum time `func` is allowed to be delayed before it's invoked.
* @param {boolean} [options.trailing=true]
* Specify invoking on the trailing edge of the timeout.
* @returns {Function} Returns the new debounced function.
* @example
*
* // Avoid costly calculations while the window size is in flux.
* jQuery(window).on('resize', _.debounce(calculateLayout, 150));
*
* // Invoke `sendMail` when clicked, debouncing subsequent calls.
* jQuery(element).on('click', _.debounce(sendMail, 300, {
* 'leading': true,
* 'trailing': false
* }));
*
* // Ensure `batchLog` is invoked once after 1 second of debounced calls.
* var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
* var source = new EventSource('/stream');
* jQuery(source).on('message', debounced);
*
* // Cancel the trailing debounced invocation.
* jQuery(window).on('popstate', debounced.cancel);
*/
function debounce(func, wait, options) {
var lastArgs,
lastThis,
maxWait,
result,
timerId,
lastCallTime,
lastInvokeTime = 0,
leading = false,
maxing = false,
trailing = true;
if (typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
wait = toNumber(wait) || 0;
if (isObject(options)) {
leading = !!options.leading;
maxing = 'maxWait' in options;
maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
trailing = 'trailing' in options ? !!options.trailing : trailing;
}
function invokeFunc(time) {
var args = lastArgs,
thisArg = lastThis;
lastArgs = lastThis = undefined;
lastInvokeTime = time;
result = func.apply(thisArg, args);
return result;
}
function leadingEdge(time) {
// Reset any `maxWait` timer.
lastInvokeTime = time;
// Start the timer for the trailing edge.
timerId = setTimeout(timerExpired, wait);
// Invoke the leading edge.
return leading ? invokeFunc(time) : result;
}
function remainingWait(time) {
var timeSinceLastCall = time - lastCallTime,
timeSinceLastInvoke = time - lastInvokeTime,
timeWaiting = wait - timeSinceLastCall;
return maxing ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
}
function shouldInvoke(time) {
var timeSinceLastCall = time - lastCallTime,
timeSinceLastInvoke = time - lastInvokeTime;
// Either this is the first call, activity has stopped and we're at the
// trailing edge, the system time has gone backwards and we're treating
// it as the trailing edge, or we've hit the `maxWait` limit.
return lastCallTime === undefined || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
}
function timerExpired() {
var time = now();
if (shouldInvoke(time)) {
return trailingEdge(time);
}
// Restart the timer.
timerId = setTimeout(timerExpired, remainingWait(time));
}
function trailingEdge(time) {
timerId = undefined;
// Only invoke if we have `lastArgs` which means `func` has been
// debounced at least once.
if (trailing && lastArgs) {
return invokeFunc(time);
}
lastArgs = lastThis = undefined;
return result;
}
function cancel() {
if (timerId !== undefined) {
clearTimeout(timerId);
}
lastInvokeTime = 0;
lastArgs = lastCallTime = lastThis = timerId = undefined;
}
function flush() {
return timerId === undefined ? result : trailingEdge(now());
}
function debounced() {
var time = now(),
isInvoking = shouldInvoke(time);
lastArgs = arguments;
lastThis = this;
lastCallTime = time;
if (isInvoking) {
if (timerId === undefined) {
return leadingEdge(lastCallTime);
}
if (maxing) {
// Handle invocations in a tight loop.
timerId = setTimeout(timerExpired, wait);
return invokeFunc(lastCallTime);
}
}
if (timerId === undefined) {
timerId = setTimeout(timerExpired, wait);
}
return result;
}
debounced.cancel = cancel;
debounced.flush = flush;
return debounced;
}
/**
* This function is like `assignValue` except that it doesn't assign
* `undefined` values.
*
* @private
* @param {Object} object The object to modify.
* @param {string} key The key of the property to assign.
* @param {*} value The value to assign.
*/
function assignMergeValue(object, key, value) {
if (value !== undefined && !eq(object[key], value) || value === undefined && !(key in object)) {
baseAssignValue(object, key, value);
}
}
/**
* Creates a base function for methods like `_.forIn` and `_.forOwn`.
*
* @private
* @param {boolean} [fromRight] Specify iterating from right to left.
* @returns {Function} Returns the new base function.
*/
function createBaseFor(fromRight) {
return function (object, iteratee, keysFunc) {
var index = -1,
iterable = Object(object),
props = keysFunc(object),
length = props.length;
while (length--) {
var key = props[fromRight ? length : ++index];
if (iteratee(iterable[key], key, iterable) === false) {
break;
}
}
return object;
};
}
/**
* The base implementation of `baseForOwn` which iterates over `object`
* properties returned by `keysFunc` and invokes `iteratee` for each property.
* Iteratee functions may exit iteration early by explicitly returning `false`.
*
* @private
* @param {Object} object The object to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @param {Function} keysFunc The function to get the keys of `object`.
* @returns {Object} Returns `object`.
*/
var baseFor = createBaseFor();
/**
* This method is like `_.isArrayLike` except that it also checks if `value`
* is an object.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an array-like object,
* else `false`.
* @example
*
* _.isArrayLikeObject([1, 2, 3]);
* // => true
*
* _.isArrayLikeObject(document.body.children);
* // => true
*
* _.isArrayLikeObject('abc');
* // => false
*
* _.isArrayLikeObject(_.noop);
* // => false
*/
function isArrayLikeObject(value) {
return isObjectLike(value) && isArrayLike(value);
}
/** `Object#toString` result references. */
var objectTag$4 = '[object Object]';
/** Used for built-in method references. */
var funcProto$2 = Function.prototype,
objectProto$f = Object.prototype;
/** Used to resolve the decompiled source of functions. */
var funcToString$2 = funcProto$2.toString;
/** Used to check objects for own properties. */
var hasOwnProperty$c = objectProto$f.hasOwnProperty;
/** Used to infer the `Object` constructor. */
var objectCtorString = funcToString$2.call(Object);
/**
* Checks if `value` is a plain object, that is, an object created by the
* `Object` constructor or one with a `[[Prototype]]` of `null`.
*
* @static
* @memberOf _
* @since 0.8.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
* @example
*
* function Foo() {
* this.a = 1;
* }
*
* _.isPlainObject(new Foo);
* // => false
*
* _.isPlainObject([1, 2, 3]);
* // => false
*
* _.isPlainObject({ 'x': 0, 'y': 0 });
* // => true
*
* _.isPlainObject(Object.create(null));
* // => true
*/
function isPlainObject(value) {
if (!isObjectLike(value) || baseGetTag(value) != objectTag$4) {
return false;
}
var proto = getPrototype(value);
if (proto === null) {
return true;
}
var Ctor = hasOwnProperty$c.call(proto, 'constructor') && proto.constructor;
return typeof Ctor == 'function' && Ctor instanceof Ctor && funcToString$2.call(Ctor) == objectCtorString;
}
/**
* Gets the value at `key`, unless `key` is "__proto__".
*
* @private
* @param {Object} object The object to query.
* @param {string} key The key of the property to get.
* @returns {*} Returns the property value.
*/
function safeGet(object, key) {
return key == '__proto__' ? undefined : object[key];
}
/**
* Converts `value` to a plain object flattening inherited enumerable string
* keyed properties of `value` to own properties of the plain object.
*
* @static
* @memberOf _
* @since 3.0.0
* @category Lang
* @param {*} value The value to convert.
* @returns {Object} Returns the converted plain object.
* @example
*
* function Foo() {
* this.b = 2;
* }
*
* Foo.prototype.c = 3;
*
* _.assign({ 'a': 1 }, new Foo);
* // => { 'a': 1, 'b': 2 }
*
* _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
* // => { 'a': 1, 'b': 2, 'c': 3 }
*/
function toPlainObject(value) {
return copyObject(value, keysIn$1(value));
}
/**
* A specialized version of `baseMerge` for arrays and objects which performs
* deep merges and tracks traversed objects enabling objects with circular
* references to be merged.
*
* @private
* @param {Object} object The destination object.
* @param {Object} source The source object.
* @param {string} key The key of the value to merge.
* @param {number} srcIndex The index of `source`.
* @param {Function} mergeFunc The function to merge values.
* @param {Function} [customizer] The function to customize assigned values.
* @param {Object} [stack] Tracks traversed source values and their merged
* counterparts.
*/
function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
var objValue = safeGet(object, key),
srcValue = safeGet(source, key),
stacked = stack.get(srcValue);
if (stacked) {
assignMergeValue(object, key, stacked);
return;
}
var newValue = customizer ? customizer(objValue, srcValue, key + '', object, source, stack) : undefined;
var isCommon = newValue === undefined;
if (isCommon) {
var isArr = isArray(srcValue),
isBuff = !isArr && isBuffer(srcValue),
isTyped = !isArr && !isBuff && isTypedArray(srcValue);
newValue = srcValue;
if (isArr || isBuff || isTyped) {
if (isArray(objValue)) {
newValue = objValue;
} else if (isArrayLikeObject(objValue)) {
newValue = copyArray(objValue);
} else if (isBuff) {
isCommon = false;
newValue = cloneBuffer(srcValue, true);
} else if (isTyped) {
isCommon = false;
newValue = cloneTypedArray(srcValue, true);
} else {
newValue = [];
}
} else if (isPlainObject(srcValue) || isArguments(srcValue)) {
newValue = objValue;
if (isArguments(objValue)) {
newValue = toPlainObject(objValue);
} else if (!isObject(objValue) || srcIndex && isFunction(objValue)) {
newValue = initCloneObject(srcValue);
}
} else {
isCommon = false;
}
}
if (isCommon) {
// Recursively merge objects and arrays (susceptible to call stack limits).
stack.set(srcValue, newValue);
mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
stack['delete'](srcValue);
}
assignMergeValue(object, key, newValue);
}
/**
* The base implementation of `_.merge` without support for multiple sources.
*
* @private
* @param {Object} object The destination object.
* @param {Object} source The source object.
* @param {number} srcIndex The index of `source`.
* @param {Function} [customizer] The function to customize merged values.
* @param {Object} [stack] Tracks traversed source values and their merged
* counterparts.
*/
function baseMerge(object, source, srcIndex, customizer, stack) {
if (object === source) {
return;
}
baseFor(source, function (srcValue, key) {
if (isObject(srcValue)) {
stack || (stack = new Stack());
baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
} else {
var newValue = customizer ? customizer(safeGet(object, key), srcValue, key + '', object, source, stack) : undefined;
if (newValue === undefined) {
newValue = srcValue;
}
assignMergeValue(object, key, newValue);
}
}, keysIn$1);
}
/**
* This method returns the first argument it receives.
*
* @static
* @since 0.1.0
* @memberOf _
* @category Util
* @param {*} value Any value.
* @returns {*} Returns `value`.
* @example
*
* var object = { 'a': 1 };
*
* console.log(_.identity(object) === object);
* // => true
*/
function identity(value) {
return value;
}
/**
* A faster alternative to `Function#apply`, this function invokes `func`
* with the `this` binding of `thisArg` and the arguments of `args`.
*
* @private
* @param {Function} func The function to invoke.
* @param {*} thisArg The `this` binding of `func`.
* @param {Array} args The arguments to invoke `func` with.
* @returns {*} Returns the result of `func`.
*/
function apply(func, thisArg, args) {
switch (args.length) {
case 0:
return func.call(thisArg);
case 1:
return func.call(thisArg, args[0]);
case 2:
return func.call(thisArg, args[0], args[1]);
case 3:
return func.call(thisArg, args[0], args[1], args[2]);
}
return func.apply(thisArg, args);
}
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeMax$1 = Math.max;
/**
* A specialized version of `baseRest` which transforms the rest array.
*
* @private
* @param {Function} func The function to apply a rest parameter to.
* @param {number} [start=func.length-1] The start position of the rest parameter.
* @param {Function} transform The rest array transform.
* @returns {Function} Returns the new function.
*/
function overRest(func, start, transform) {
start = nativeMax$1(start === undefined ? func.length - 1 : start, 0);
return function () {
var args = arguments,
index = -1,
length = nativeMax$1(args.length - start, 0),
array = Array(length);
while (++index < length) {
array[index] = args[start + index];
}
index = -1;
var otherArgs = Array(start + 1);
while (++index < start) {
otherArgs[index] = args[index];
}
otherArgs[start] = transform(array);
return apply(func, this, otherArgs);
};
}
/**
* Creates a function that returns `value`.
*
* @static
* @memberOf _
* @since 2.4.0
* @category Util
* @param {*} value The value to return from the new function.
* @returns {Function} Returns the new constant function.
* @example
*
* var objects = _.times(2, _.constant({ 'a': 1 }));
*
* console.log(objects);
* // => [{ 'a': 1 }, { 'a': 1 }]
*
* console.log(objects[0] === objects[1]);
* // => true
*/
function constant(value) {
return function () {
return value;
};
}
/**
* The base implementation of `setToString` without support for hot loop shorting.
*
* @private
* @param {Function} func The function to modify.
* @param {Function} string The `toString` result.
* @returns {Function} Returns `func`.
*/
var baseSetToString = !defineProperty$1 ? identity : function (func, string) {
return defineProperty$1(func, 'toString', {
'configurable': true,
'enumerable': false,
'value': constant(string),
'writable': true
});
};
/** Used to detect hot functions by number of calls within a span of milliseconds. */
var HOT_COUNT = 800,
HOT_SPAN = 16;
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeNow = Date.now;
/**
* Creates a function that'll short out and invoke `identity` instead
* of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
* milliseconds.
*
* @private
* @param {Function} func The function to restrict.
* @returns {Function} Returns the new shortable function.
*/
function shortOut(func) {
var count = 0,
lastCalled = 0;
return function () {
var stamp = nativeNow(),
remaining = HOT_SPAN - (stamp - lastCalled);
lastCalled = stamp;
if (remaining > 0) {
if (++count >= HOT_COUNT) {
return arguments[0];
}
} else {
count = 0;
}
return func.apply(undefined, arguments);
};
}
/**
* Sets the `toString` method of `func` to return `string`.
*
* @private
* @param {Function} func The function to modify.
* @param {Function} string The `toString` result.
* @returns {Function} Returns `func`.
*/
var setToString = shortOut(baseSetToString);
/**
* The base implementation of `_.rest` which doesn't validate or coerce arguments.
*
* @private
* @param {Function} func The function to apply a rest parameter to.
* @param {number} [start=func.length-1] The start position of the rest parameter.
* @returns {Function} Returns the new function.
*/
function baseRest(func, start) {
return setToString(overRest(func, start, identity), func + '');
}
/**
* Checks if the given arguments are from an iteratee call.
*
* @private
* @param {*} value The potential iteratee value argument.
* @param {*} index The potential iteratee index or key argument.
* @param {*} object The potential iteratee object argument.
* @returns {boolean} Returns `true` if the arguments are from an iteratee call,
* else `false`.
*/
function isIterateeCall(value, index, object) {
if (!isObject(object)) {
return false;
}
var type = typeof index === 'undefined' ? 'undefined' : _typeof(index);
if (type == 'number' ? isArrayLike(object) && isIndex(index, object.length) : type == 'string' && index in object) {
return eq(object[index], value);
}
return false;
}
/**
* Creates a function like `_.assign`.
*
* @private
* @param {Function} assigner The function to assign values.
* @returns {Function} Returns the new assigner function.
*/
function createAssigner(assigner) {
return baseRest(function (object, sources) {
var index = -1,
length = sources.length,
customizer = length > 1 ? sources[length - 1] : undefined,
guard = length > 2 ? sources[2] : undefined;
customizer = assigner.length > 3 && typeof customizer == 'function' ? (length--, customizer) : undefined;
if (guard && isIterateeCall(sources[0], sources[1], guard)) {
customizer = length < 3 ? undefined : customizer;
length = 1;
}
object = Object(object);
while (++index < length) {
var source = sources[index];
if (source) {
assigner(object, source, index, customizer);
}
}
return object;
});
}
/**
* This method is like `_.assign` except that it recursively merges own and
* inherited enumerable string keyed properties of source objects into the
* destination object. Source properties that resolve to `undefined` are
* skipped if a destination value exists. Array and plain object properties
* are merged recursively. Other objects and value types are overridden by
* assignment. Source objects are applied from left to right. Subsequent
* sources overwrite property assignments of previous sources.
*
* **Note:** This method mutates `object`.
*
* @static
* @memberOf _
* @since 0.5.0
* @category Object
* @param {Object} object The destination object.
* @param {...Object} [sources] The source objects.
* @returns {Object} Returns `object`.
* @example
*
* var object = {
* 'a': [{ 'b': 2 }, { 'd': 4 }]
* };
*
* var other = {
* 'a': [{ 'c': 3 }, { 'e': 5 }]
* };
*
* _.merge(object, other);
* // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
*/
var merge = createAssigner(function (object, source, srcIndex) {
baseMerge(object, source, srcIndex);
});
/** Built-in value references. */
var spreadableSymbol = _Symbol ? _Symbol.isConcatSpreadable : undefined;
/**
* Checks if `value` is a flattenable `arguments` object or array.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
*/
function isFlattenable(value) {
return isArray(value) || isArguments(value) || !!(spreadableSymbol && value && value[spreadableSymbol]);
}
/**
* The base implementation of `_.flatten` with support for restricting flattening.
*
* @private
* @param {Array} array The array to flatten.
* @param {number} depth The maximum recursion depth.
* @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
* @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
* @param {Array} [result=[]] The initial result value.
* @returns {Array} Returns the new flattened array.
*/
function baseFlatten(array, depth, predicate, isStrict, result) {
var index = -1,
length = array.length;
predicate || (predicate = isFlattenable);
result || (result = []);
while (++index < length) {
var value = array[index];
if (depth > 0 && predicate(value)) {
if (depth > 1) {
// Recursively flatten arrays (susceptible to call stack limits).
baseFlatten(value, depth - 1, predicate, isStrict, result);
} else {
arrayPush(result, value);
}
} else if (!isStrict) {
result[result.length] = value;
}
}
return result;
}
/**
* Flattens `array` a single level deep.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Array
* @param {Array} array The array to flatten.
* @returns {Array} Returns the new flattened array.
* @example
*
* _.flatten([1, [2, [3, [4]], 5]]);
* // => [1, 2, [3, [4]], 5]
*/
function flatten(array) {
var length = array == null ? 0 : array.length;
return length ? baseFlatten(array, 1) : [];
}
/**
* A specialized version of `_.reduce` for arrays without support for
* iteratee shorthands.
*
* @private
* @param {Array} [array] The array to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @param {*} [accumulator] The initial value.
* @param {boolean} [initAccum] Specify using the first element of `array` as
* the initial value.
* @returns {*} Returns the accumulated value.
*/
function arrayReduce(array, iteratee, accumulator, initAccum) {
var index = -1,
length = array == null ? 0 : array.length;
if (initAccum && length) {
accumulator = array[++index];
}
while (++index < length) {
accumulator = iteratee(accumulator, array[index], index, array);
}
return accumulator;
}
/**
* The base implementation of `_.propertyOf` without support for deep paths.
*
* @private
* @param {Object} object The object to query.
* @returns {Function} Returns the new accessor function.
*/
function basePropertyOf(object) {
return function (key) {
return object == null ? undefined : object[key];
};
}
/** Used to map Latin Unicode letters to basic Latin letters. */
var deburredLetters = {
// Latin-1 Supplement block.
'\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
'\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
'\xc7': 'C', '\xe7': 'c',
'\xd0': 'D', '\xf0': 'd',
'\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
'\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
'\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
'\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
'\xd1': 'N', '\xf1': 'n',
'\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
'\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
'\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
'\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
'\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
'\xc6': 'Ae', '\xe6': 'ae',
'\xde': 'Th', '\xfe': 'th',
'\xdf': 'ss',
// Latin Extended-A block.
'\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
'\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
'\u0106': 'C', '\u0108': 'C', '\u010A': 'C', '\u010C': 'C',
'\u0107': 'c', '\u0109': 'c', '\u010B': 'c', '\u010D': 'c',
'\u010E': 'D', '\u0110': 'D', '\u010F': 'd', '\u0111': 'd',
'\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011A': 'E',
'\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011B': 'e',
'\u011C': 'G', '\u011E': 'G', '\u0120': 'G', '\u0122': 'G',
'\u011D': 'g', '\u011F': 'g', '\u0121': 'g', '\u0123': 'g',
'\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
'\u0128': 'I', '\u012A': 'I', '\u012C': 'I', '\u012E': 'I', '\u0130': 'I',
'\u0129': 'i', '\u012B': 'i', '\u012D': 'i', '\u012F': 'i', '\u0131': 'i',
'\u0134': 'J', '\u0135': 'j',
'\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
'\u0139': 'L', '\u013B': 'L', '\u013D': 'L', '\u013F': 'L', '\u0141': 'L',
'\u013A': 'l', '\u013C': 'l', '\u013E': 'l', '\u0140': 'l', '\u0142': 'l',
'\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014A': 'N',
'\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014B': 'n',
'\u014C': 'O', '\u014E': 'O', '\u0150': 'O',
'\u014D': 'o', '\u014F': 'o', '\u0151': 'o',
'\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
'\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
'\u015A': 'S', '\u015C': 'S', '\u015E': 'S', '\u0160': 'S',
'\u015B': 's', '\u015D': 's', '\u015F': 's', '\u0161': 's',
'\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
'\u0163': 't', '\u0165': 't', '\u0167': 't',
'\u0168': 'U', '\u016A': 'U', '\u016C': 'U', '\u016E': 'U', '\u0170': 'U', '\u0172': 'U',
'\u0169': 'u', '\u016B': 'u', '\u016D': 'u', '\u016F': 'u', '\u0171': 'u', '\u0173': 'u',
'\u0174': 'W', '\u0175': 'w',
'\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
'\u0179': 'Z', '\u017B': 'Z', '\u017D': 'Z',
'\u017A': 'z', '\u017C': 'z', '\u017E': 'z',
'\u0132': 'IJ', '\u0133': 'ij',
'\u0152': 'Oe', '\u0153': 'oe',
'\u0149': "'n", '\u017F': 's'
};
/**
* Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
* letters to basic Latin letters.
*
* @private
* @param {string} letter The matched letter to deburr.
* @returns {string} Returns the deburred letter.
*/
var deburrLetter = basePropertyOf(deburredLetters);
/**
* A specialized version of `_.map` for arrays without support for iteratee
* shorthands.
*
* @private
* @param {Array} [array] The array to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @returns {Array} Returns the new mapped array.
*/
function arrayMap(array, iteratee) {
var index = -1,
length = array == null ? 0 : array.length,
result = Array(length);
while (++index < length) {
result[index] = iteratee(array[index], index, array);
}
return result;
}
/** Used as references for various `Number` constants. */
var INFINITY = 1 / 0;
/** Used to convert symbols to primitives and strings. */
var symbolProto$2 = _Symbol ? _Symbol.prototype : undefined,
symbolToString = symbolProto$2 ? symbolProto$2.toString : undefined;
/**
* The base implementation of `_.toString` which doesn't convert nullish
* values to empty strings.
*
* @private
* @param {*} value The value to process.
* @returns {string} Returns the string.
*/
function baseToString(value) {
// Exit early for strings to avoid a performance hit in some environments.
if (typeof value == 'string') {
return value;
}
if (isArray(value)) {
// Recursively convert values (susceptible to call stack limits).
return arrayMap(value, baseToString) + '';
}
if (isSymbol(value)) {
return symbolToString ? symbolToString.call(value) : '';
}
var result = value + '';
return result == '0' && 1 / value == -INFINITY ? '-0' : result;
}
/**
* Converts `value` to a string. An empty string is returned for `null`
* and `undefined` values. The sign of `-0` is preserved.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to convert.
* @returns {string} Returns the converted string.
* @example
*
* _.toString(null);
* // => ''
*
* _.toString(-0);
* // => '-0'
*
* _.toString([1, 2, 3]);
* // => '1,2,3'
*/
function toString(value) {
return value == null ? '' : baseToString(value);
}
/** Used to match Latin Unicode letters (excluding mathematical operators). */
var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
/** Used to compose unicode character classes. */
var rsComboMarksRange = '\\u0300-\\u036f',
reComboHalfMarksRange = '\\ufe20-\\ufe2f',
rsComboSymbolsRange = '\\u20d0-\\u20ff',
rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange;
/** Used to compose unicode capture groups. */
var rsCombo = '[' + rsComboRange + ']';
/**
* Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
* [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
*/
var reComboMark = RegExp(rsCombo, 'g');
/**
* Deburrs `string` by converting
* [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
* and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
* letters to basic Latin letters and removing
* [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
*
* @static
* @memberOf _
* @since 3.0.0
* @category String
* @param {string} [string=''] The string to deburr.
* @returns {string} Returns the deburred string.
* @example
*
* _.deburr('déjà vu');
* // => 'deja vu'
*/
function deburr(string) {
string = toString(string);
return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
}
/** Used to match words composed of alphanumeric characters. */
var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
/**
* Splits an ASCII `string` into an array of its words.
*
* @private
* @param {string} The string to inspect.
* @returns {Array} Returns the words of `string`.
*/
function asciiWords(string) {
return string.match(reAsciiWord) || [];
}
/** Used to detect strings that need a more robust regexp to match words. */
var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
/**
* Checks if `string` contains a word composed of Unicode symbols.
*
* @private
* @param {string} string The string to inspect.
* @returns {boolean} Returns `true` if a word is found, else `false`.
*/
function hasUnicodeWord(string) {
return reHasUnicodeWord.test(string);
}
/** Used to compose unicode character classes. */
var rsAstralRange = '\\ud800-\\udfff',
rsComboMarksRange$1 = '\\u0300-\\u036f',
reComboHalfMarksRange$1 = '\\ufe20-\\ufe2f',
rsComboSymbolsRange$1 = '\\u20d0-\\u20ff',
rsComboRange$1 = rsComboMarksRange$1 + reComboHalfMarksRange$1 + rsComboSymbolsRange$1,
rsDingbatRange = '\\u2700-\\u27bf',
rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
rsPunctuationRange = '\\u2000-\\u206f',
rsSpaceRange = ' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000',
rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
rsVarRange = '\\ufe0e\\ufe0f',
rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
/** Used to compose unicode capture groups. */
var rsApos = '[\'\u2019]',
rsBreak = '[' + rsBreakRange + ']',
rsCombo$1 = '[' + rsComboRange$1 + ']',
rsDigits = '\\d+',
rsDingbat = '[' + rsDingbatRange + ']',
rsLower = '[' + rsLowerRange + ']',
rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
rsFitz = '\\ud83c[\\udffb-\\udfff]',
rsModifier = '(?:' + rsCombo$1 + '|' + rsFitz + ')',
rsNonAstral = '[^' + rsAstralRange + ']',
rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
rsUpper = '[' + rsUpperRange + ']',
rsZWJ = '\\u200d';
/** Used to compose unicode regexes. */
var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
reOptMod = rsModifier + '?',
rsOptVar = '[' + rsVarRange + ']?',
rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
rsSeq = rsOptVar + reOptMod + rsOptJoin,
rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq;
/** Used to match complex or compound words. */
var reUnicodeWord = RegExp([rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')', rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')', rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower, rsUpper + '+' + rsOptContrUpper, rsOrdUpper, rsOrdLower, rsDigits, rsEmoji].join('|'), 'g');
/**
* Splits a Unicode `string` into an array of its words.
*
* @private
* @param {string} The string to inspect.
* @returns {Array} Returns the words of `string`.
*/
function unicodeWords(string) {
return string.match(reUnicodeWord) || [];
}
/**
* Splits `string` into an array of its words.
*
* @static
* @memberOf _
* @since 3.0.0
* @category String
* @param {string} [string=''] The string to inspect.
* @param {RegExp|string} [pattern] The pattern to match words.
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
* @returns {Array} Returns the words of `string`.
* @example
*
* _.words('fred, barney, & pebbles');
* // => ['fred', 'barney', 'pebbles']
*
* _.words('fred, barney, & pebbles', /[^, ]+/g);
* // => ['fred', 'barney', '&', 'pebbles']
*/
function words(string, pattern, guard) {
string = toString(string);
pattern = guard ? undefined : pattern;
if (pattern === undefined) {
return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
}
return string.match(pattern) || [];
}
/** Used to compose unicode capture groups. */
var rsApos$1 = '[\'\u2019]';
/** Used to match apostrophes. */
var reApos = RegExp(rsApos$1, 'g');
/**
* Creates a function like `_.camelCase`.
*
* @private
* @param {Function} callback The function to combine each word.
* @returns {Function} Returns the new compounder function.
*/
function createCompounder(callback) {
return function (string) {
return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
};
}
/**
* The base implementation of `_.slice` without an iteratee call guard.
*
* @private
* @param {Array} array The array to slice.
* @param {number} [start=0] The start position.
* @param {number} [end=array.length] The end position.
* @returns {Array} Returns the slice of `array`.
*/
function baseSlice(array, start, end) {
var index = -1,
length = array.length;
if (start < 0) {
start = -start > length ? 0 : length + start;
}
end = end > length ? length : end;
if (end < 0) {
end += length;
}
length = start > end ? 0 : end - start >>> 0;
start >>>= 0;
var result = Array(length);
while (++index < length) {
result[index] = array[index + start];
}
return result;
}
/**
* Casts `array` to a slice if it's needed.
*
* @private
* @param {Array} array The array to inspect.
* @param {number} start The start position.
* @param {number} [end=array.length] The end position.
* @returns {Array} Returns the cast slice.
*/
function castSlice(array, start, end) {
var length = array.length;
end = end === undefined ? length : end;
return !start && end >= length ? array : baseSlice(array, start, end);
}
/** Used to compose unicode character classes. */
var rsAstralRange$1 = '\\ud800-\\udfff',
rsComboMarksRange$2 = '\\u0300-\\u036f',
reComboHalfMarksRange$2 = '\\ufe20-\\ufe2f',
rsComboSymbolsRange$2 = '\\u20d0-\\u20ff',
rsComboRange$2 = rsComboMarksRange$2 + reComboHalfMarksRange$2 + rsComboSymbolsRange$2,
rsVarRange$1 = '\\ufe0e\\ufe0f';
/** Used to compose unicode capture groups. */
var rsZWJ$1 = '\\u200d';
/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
var reHasUnicode = RegExp('[' + rsZWJ$1 + rsAstralRange$1 + rsComboRange$2 + rsVarRange$1 + ']');
/**
* Checks if `string` contains Unicode symbols.
*
* @private
* @param {string} string The string to inspect.
* @returns {boolean} Returns `true` if a symbol is found, else `false`.
*/
function hasUnicode(string) {
return reHasUnicode.test(string);
}
/**
* Converts an ASCII `string` to an array.
*
* @private
* @param {string} string The string to convert.
* @returns {Array} Returns the converted array.
*/
function asciiToArray(string) {
return string.split('');
}
/** Used to compose unicode character classes. */
var rsAstralRange$2 = '\\ud800-\\udfff',
rsComboMarksRange$3 = '\\u0300-\\u036f',
reComboHalfMarksRange$3 = '\\ufe20-\\ufe2f',
rsComboSymbolsRange$3 = '\\u20d0-\\u20ff',
rsComboRange$3 = rsComboMarksRange$3 + reComboHalfMarksRange$3 + rsComboSymbolsRange$3,
rsVarRange$2 = '\\ufe0e\\ufe0f';
/** Used to compose unicode capture groups. */
var rsAstral = '[' + rsAstralRange$2 + ']',
rsCombo$2 = '[' + rsComboRange$3 + ']',
rsFitz$1 = '\\ud83c[\\udffb-\\udfff]',
rsModifier$1 = '(?:' + rsCombo$2 + '|' + rsFitz$1 + ')',
rsNonAstral$1 = '[^' + rsAstralRange$2 + ']',
rsRegional$1 = '(?:\\ud83c[\\udde6-\\uddff]){2}',
rsSurrPair$1 = '[\\ud800-\\udbff][\\udc00-\\udfff]',
rsZWJ$2 = '\\u200d';
/** Used to compose unicode regexes. */
var reOptMod$1 = rsModifier$1 + '?',
rsOptVar$1 = '[' + rsVarRange$2 + ']?',
rsOptJoin$1 = '(?:' + rsZWJ$2 + '(?:' + [rsNonAstral$1, rsRegional$1, rsSurrPair$1].join('|') + ')' + rsOptVar$1 + reOptMod$1 + ')*',
rsSeq$1 = rsOptVar$1 + reOptMod$1 + rsOptJoin$1,
rsSymbol = '(?:' + [rsNonAstral$1 + rsCombo$2 + '?', rsCombo$2, rsRegional$1, rsSurrPair$1, rsAstral].join('|') + ')';
/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
var reUnicode = RegExp(rsFitz$1 + '(?=' + rsFitz$1 + ')|' + rsSymbol + rsSeq$1, 'g');
/**
* Converts a Unicode `string` to an array.
*
* @private
* @param {string} string The string to convert.
* @returns {Array} Returns the converted array.
*/
function unicodeToArray(string) {
return string.match(reUnicode) || [];
}
/**
* Converts `string` to an array.
*
* @private
* @param {string} string The string to convert.
* @returns {Array} Returns the converted array.
*/
function stringToArray(string) {
return hasUnicode(string) ? unicodeToArray(string) : asciiToArray(string);
}
/**
* Creates a function like `_.lowerFirst`.
*
* @private
* @param {string} methodName The name of the `String` case method to use.
* @returns {Function} Returns the new case function.
*/
function createCaseFirst(methodName) {
return function (string) {
string = toString(string);
var strSymbols = hasUnicode(string) ? stringToArray(string) : undefined;
var chr = strSymbols ? strSymbols[0] : string.charAt(0);
var trailing = strSymbols ? castSlice(strSymbols, 1).join('') : string.slice(1);
return chr[methodName]() + trailing;
};
}
/**
* Converts the first character of `string` to upper case.
*
* @static
* @memberOf _
* @since 4.0.0
* @category String
* @param {string} [string=''] The string to convert.
* @returns {string} Returns the converted string.
* @example
*
* _.upperFirst('fred');
* // => 'Fred'
*
* _.upperFirst('FRED');
* // => 'FRED'
*/
var upperFirst = createCaseFirst('toUpperCase');
/**
* Converts `string` to
* [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
*
* @static
* @memberOf _
* @since 3.1.0
* @category String
* @param {string} [string=''] The string to convert.
* @returns {string} Returns the start cased string.
* @example
*
* _.startCase('--foo-bar--');
* // => 'Foo Bar'
*
* _.startCase('fooBar');
* // => 'Foo Bar'
*
* _.startCase('__FOO_BAR__');
* // => 'FOO BAR'
*/
var startCase = createCompounder(function (result, word, index) {
return result + (index ? ' ' : '') + upperFirst(word);
});
/**
* This method is like `_.assign` except that it accepts `customizer`
* which is invoked to produce the assigned values. If `customizer` returns
* `undefined`, assignment is handled by the method instead. The `customizer`
* is invoked with five arguments: (objValue, srcValue, key, object, source).
*
* **Note:** This method mutates `object`.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Object
* @param {Object} object The destination object.
* @param {...Object} sources The source objects.
* @param {Function} [customizer] The function to customize assigned values.
* @returns {Object} Returns `object`.
* @see _.assignInWith
* @example
*
* function customizer(objValue, srcValue) {
* return _.isUndefined(objValue) ? srcValue : objValue;
* }
*
* var defaults = _.partialRight(_.assignWith, customizer);
*
* defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
* // => { 'a': 1, 'b': 2 }
*/
var assignWith = createAssigner(function (object, source, srcIndex, customizer) {
copyObject(source, keys(source), object, customizer);
});
/**
* The base implementation of `_.findIndex` and `_.findLastIndex` without
* support for iteratee shorthands.
*
* @private
* @param {Array} array The array to inspect.
* @param {Function} predicate The function invoked per iteration.
* @param {number} fromIndex The index to search from.
* @param {boolean} [fromRight] Specify iterating from right to left.
* @returns {number} Returns the index of the matched value, else `-1`.
*/
function baseFindIndex(array, predicate, fromIndex, fromRight) {
var length = array.length,
index = fromIndex + (fromRight ? 1 : -1);
while (fromRight ? index-- : ++index < length) {
if (predicate(array[index], index, array)) {
return index;
}
}
return -1;
}
/**
* The base implementation of `_.isNaN` without support for number objects.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
*/
function baseIsNaN(value) {
return value !== value;
}
/**
* A specialized version of `_.indexOf` which performs strict equality
* comparisons of values, i.e. `===`.
*
* @private
* @param {Array} array The array to inspect.
* @param {*} value The value to search for.
* @param {number} fromIndex The index to search from.
* @returns {number} Returns the index of the matched value, else `-1`.
*/
function strictIndexOf(array, value, fromIndex) {
var index = fromIndex - 1,
length = array.length;
while (++index < length) {
if (array[index] === value) {
return index;
}
}
return -1;
}
/**
* The base implementation of `_.indexOf` without `fromIndex` bounds checks.
*
* @private
* @param {Array} array The array to inspect.
* @param {*} value The value to search for.
* @param {number} fromIndex The index to search from.
* @returns {number} Returns the index of the matched value, else `-1`.
*/
function baseIndexOf(array, value, fromIndex) {
return value === value ? strictIndexOf(array, value, fromIndex) : baseFindIndex(array, baseIsNaN, fromIndex);
}
/**
* A specialized version of `_.includes` for arrays without support for
* specifying an index to search from.
*
* @private
* @param {Array} [array] The array to inspect.
* @param {*} target The value to search for.
* @returns {boolean} Returns `true` if `target` is found, else `false`.
*/
function arrayIncludes(array, value) {
var length = array == null ? 0 : array.length;
return !!length && baseIndexOf(array, value, 0) > -1;
}
/**
* This function is like `arrayIncludes` except that it accepts a comparator.
*
* @private
* @param {Array} [array] The array to inspect.
* @param {*} target The value to search for.
* @param {Function} comparator The comparator invoked per element.
* @returns {boolean} Returns `true` if `target` is found, else `false`.
*/
function arrayIncludesWith(array, value, comparator) {
var index = -1,
length = array == null ? 0 : array.length;
while (++index < length) {
if (comparator(value, array[index])) {
return true;
}
}
return false;
}
/**
* This method returns `undefined`.
*
* @static
* @memberOf _
* @since 2.3.0
* @category Util
* @example
*
* _.times(2, _.noop);
* // => [undefined, undefined]
*/
function noop() {
// No operation performed.
}
/** Used as references for various `Number` constants. */
var INFINITY$1 = 1 / 0;
/**
* Creates a set object of `values`.
*
* @private
* @param {Array} values The values to add to the set.
* @returns {Object} Returns the new set.
*/
var createSet = !(Set$1 && 1 / setToArray(new Set$1([, -0]))[1] == INFINITY$1) ? noop : function (values) {
return new Set$1(values);
};
/** Used as the size to enable large array optimizations. */
var LARGE_ARRAY_SIZE$1 = 200;
/**
* The base implementation of `_.uniqBy` without support for iteratee shorthands.
*
* @private
* @param {Array} array The array to inspect.
* @param {Function} [iteratee] The iteratee invoked per element.
* @param {Function} [comparator] The comparator invoked per element.
* @returns {Array} Returns the new duplicate free array.
*/
function baseUniq(array, iteratee, comparator) {
var index = -1,
includes = arrayIncludes,
length = array.length,
isCommon = true,
result = [],
seen = result;
if (comparator) {
isCommon = false;
includes = arrayIncludesWith;
} else if (length >= LARGE_ARRAY_SIZE$1) {
var set = iteratee ? null : createSet(array);
if (set) {
return setToArray(set);
}
isCommon = false;
includes = cacheHas;
seen = new SetCache();
} else {
seen = iteratee ? [] : result;
}
outer: while (++index < length) {
var value = array[index],
computed = iteratee ? iteratee(value) : value;
value = comparator || value !== 0 ? value : 0;
if (isCommon && computed === computed) {
var seenIndex = seen.length;
while (seenIndex--) {
if (seen[seenIndex] === computed) {
continue outer;
}
}
if (iteratee) {
seen.push(computed);
}
result.push(value);
} else if (!includes(seen, computed, comparator)) {
if (seen !== result) {
seen.push(computed);
}
result.push(value);
}
}
return result;
}
/**
* Creates a duplicate-free version of an array, using
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* for equality comparisons, in which only the first occurrence of each element
* is kept. The order of result values is determined by the order they occur
* in the array.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Array
* @param {Array} array The array to inspect.
* @returns {Array} Returns the new duplicate free array.
* @example
*
* _.uniq([2, 1, 2]);
* // => [2, 1]
*/
function uniq(array) {
return array && array.length ? baseUniq(array) : [];
}
/** Used to compose bitmasks for value comparisons. */
var COMPARE_PARTIAL_FLAG$4 = 1,
COMPARE_UNORDERED_FLAG$2 = 2;
/**
* The base implementation of `_.isMatch` without support for iteratee shorthands.
*
* @private
* @param {Object} object The object to inspect.
* @param {Object} source The object of property values to match.
* @param {Array} matchData The property names, values, and compare flags to match.
* @param {Function} [customizer] The function to customize comparisons.
* @returns {boolean} Returns `true` if `object` is a match, else `false`.
*/
function baseIsMatch(object, source, matchData, customizer) {
var index = matchData.length,
length = index,
noCustomizer = !customizer;
if (object == null) {
return !length;
}
object = Object(object);
while (index--) {
var data = matchData[index];
if (noCustomizer && data[2] ? data[1] !== object[data[0]] : !(data[0] in object)) {
return false;
}
}
while (++index < length) {
data = matchData[index];
var key = data[0],
objValue = object[key],
srcValue = data[1];
if (noCustomizer && data[2]) {
if (objValue === undefined && !(key in object)) {
return false;
}
} else {
var stack = new Stack();
if (customizer) {
var result = customizer(objValue, srcValue, key, object, source, stack);
}
if (!(result === undefined ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG$4 | COMPARE_UNORDERED_FLAG$2, customizer, stack) : result)) {
return false;
}
}
}
return true;
}
/**
* Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` if suitable for strict
* equality comparisons, else `false`.
*/
function isStrictComparable(value) {
return value === value && !isObject(value);
}
/**
* Gets the property names, values, and compare flags of `object`.
*
* @private
* @param {Object} object The object to query.
* @returns {Array} Returns the match data of `object`.
*/
function getMatchData(object) {
var result = keys(object),
length = result.length;
while (length--) {
var key = result[length],
value = object[key];
result[length] = [key, value, isStrictComparable(value)];
}
return result;
}
/**
* A specialized version of `matchesProperty` for source values suitable
* for strict equality comparisons, i.e. `===`.
*
* @private
* @param {string} key The key of the property to get.
* @param {*} srcValue The value to match.
* @returns {Function} Returns the new spec function.
*/
function matchesStrictComparable(key, srcValue) {
return function (object) {
if (object == null) {
return false;
}
return object[key] === srcValue && (srcValue !== undefined || key in Object(object));
};
}
/**
* The base implementation of `_.matches` which doesn't clone `source`.
*
* @private
* @param {Object} source The object of property values to match.
* @returns {Function} Returns the new spec function.
*/
function baseMatches(source) {
var matchData = getMatchData(source);
if (matchData.length == 1 && matchData[0][2]) {
return matchesStrictComparable(matchData[0][0], matchData[0][1]);
}
return function (object) {
return object === source || baseIsMatch(object, source, matchData);
};
}
/** Used to match property names within property paths. */
var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
reIsPlainProp = /^\w*$/;
/**
* Checks if `value` is a property name and not a property path.
*
* @private
* @param {*} value The value to check.
* @param {Object} [object] The object to query keys on.
* @returns {boolean} Returns `true` if `value` is a property name, else `false`.
*/
function isKey(value, object) {
if (isArray(value)) {
return false;
}
var type = typeof value === 'undefined' ? 'undefined' : _typeof(value);
if (type == 'number' || type == 'symbol' || type == 'boolean' || value == null || isSymbol(value)) {
return true;
}
return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object(object);
}
/** Error message constants. */
var FUNC_ERROR_TEXT$1 = 'Expected a function';
/**
* Creates a function that memoizes the result of `func`. If `resolver` is
* provided, it determines the cache key for storing the result based on the
* arguments provided to the memoized function. By default, the first argument
* provided to the memoized function is used as the map cache key. The `func`
* is invoked with the `this` binding of the memoized function.
*
* **Note:** The cache is exposed as the `cache` property on the memoized
* function. Its creation may be customized by replacing the `_.memoize.Cache`
* constructor with one whose instances implement the
* [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
* method interface of `clear`, `delete`, `get`, `has`, and `set`.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Function
* @param {Function} func The function to have its output memoized.
* @param {Function} [resolver] The function to resolve the cache key.
* @returns {Function} Returns the new memoized function.
* @example
*
* var object = { 'a': 1, 'b': 2 };
* var other = { 'c': 3, 'd': 4 };
*
* var values = _.memoize(_.values);
* values(object);
* // => [1, 2]
*
* values(other);
* // => [3, 4]
*
* object.a = 2;
* values(object);
* // => [1, 2]
*
* // Modify the result cache.
* values.cache.set(object, ['a', 'b']);
* values(object);
* // => ['a', 'b']
*
* // Replace `_.memoize.Cache`.
* _.memoize.Cache = WeakMap;
*/
function memoize(func, resolver) {
if (typeof func != 'function' || resolver != null && typeof resolver != 'function') {
throw new TypeError(FUNC_ERROR_TEXT$1);
}
var memoized = function memoized() {
var args = arguments,
key = resolver ? resolver.apply(this, args) : args[0],
cache = memoized.cache;
if (cache.has(key)) {
return cache.get(key);
}
var result = func.apply(this, args);
memoized.cache = cache.set(key, result) || cache;
return result;
};
memoized.cache = new (memoize.Cache || MapCache)();
return memoized;
}
// Expose `MapCache`.
memoize.Cache = MapCache;
/** Used as the maximum memoize cache size. */
var MAX_MEMOIZE_SIZE = 500;
/**
* A specialized version of `_.memoize` which clears the memoized function's
* cache when it exceeds `MAX_MEMOIZE_SIZE`.
*
* @private
* @param {Function} func The function to have its output memoized.
* @returns {Function} Returns the new memoized function.
*/
function memoizeCapped(func) {
var result = memoize(func, function (key) {
if (cache.size === MAX_MEMOIZE_SIZE) {
cache.clear();
}
return key;
});
var cache = result.cache;
return result;
}
/** Used to match property names within property paths. */
var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
/** Used to match backslashes in property paths. */
var reEscapeChar = /\\(\\)?/g;
/**
* Converts `string` to a property path array.
*
* @private
* @param {string} string The string to convert.
* @returns {Array} Returns the property path array.
*/
var stringToPath = memoizeCapped(function (string) {
var result = [];
if (string.charCodeAt(0) === 46 /* . */) {
result.push('');
}
string.replace(rePropName, function (match, number, quote, subString) {
result.push(quote ? subString.replace(reEscapeChar, '$1') : number || match);
});
return result;
});
/**
* Casts `value` to a path array if it's not one.
*
* @private
* @param {*} value The value to inspect.
* @param {Object} [object] The object to query keys on.
* @returns {Array} Returns the cast property path array.
*/
function castPath(value, object) {
if (isArray(value)) {
return value;
}
return isKey(value, object) ? [value] : stringToPath(toString(value));
}
/** Used as references for various `Number` constants. */
var INFINITY$2 = 1 / 0;
/**
* Converts `value` to a string key if it's not a string or symbol.
*
* @private
* @param {*} value The value to inspect.
* @returns {string|symbol} Returns the key.
*/
function toKey(value) {
if (typeof value == 'string' || isSymbol(value)) {
return value;
}
var result = value + '';
return result == '0' && 1 / value == -INFINITY$2 ? '-0' : result;
}
/**
* The base implementation of `_.get` without support for default values.
*
* @private
* @param {Object} object The object to query.
* @param {Array|string} path The path of the property to get.
* @returns {*} Returns the resolved value.
*/
function baseGet(object, path) {
path = castPath(path, object);
var index = 0,
length = path.length;
while (object != null && index < length) {
object = object[toKey(path[index++])];
}
return index && index == length ? object : undefined;
}
/**
* Gets the value at `path` of `object`. If the resolved value is
* `undefined`, the `defaultValue` is returned in its place.
*
* @static
* @memberOf _
* @since 3.7.0
* @category Object
* @param {Object} object The object to query.
* @param {Array|string} path The path of the property to get.
* @param {*} [defaultValue] The value returned for `undefined` resolved values.
* @returns {*} Returns the resolved value.
* @example
*
* var object = { 'a': [{ 'b': { 'c': 3 } }] };
*
* _.get(object, 'a[0].b.c');
* // => 3
*
* _.get(object, ['a', '0', 'b', 'c']);
* // => 3
*
* _.get(object, 'a.b.c', 'default');
* // => 'default'
*/
function get$1(object, path, defaultValue) {
var result = object == null ? undefined : baseGet(object, path);
return result === undefined ? defaultValue : result;
}
/**
* The base implementation of `_.hasIn` without support for deep paths.
*
* @private
* @param {Object} [object] The object to query.
* @param {Array|string} key The key to check.
* @returns {boolean} Returns `true` if `key` exists, else `false`.
*/
function baseHasIn(object, key) {
return object != null && key in Object(object);
}
/**
* Checks if `path` exists on `object`.
*
* @private
* @param {Object} object The object to query.
* @param {Array|string} path The path to check.
* @param {Function} hasFunc The function to check properties.
* @returns {boolean} Returns `true` if `path` exists, else `false`.
*/
function hasPath(object, path, hasFunc) {
path = castPath(path, object);
var index = -1,
length = path.length,
result = false;
while (++index < length) {
var key = toKey(path[index]);
if (!(result = object != null && hasFunc(object, key))) {
break;
}
object = object[key];
}
if (result || ++index != length) {
return result;
}
length = object == null ? 0 : object.length;
return !!length && isLength(length) && isIndex(key, length) && (isArray(object) || isArguments(object));
}
/**
* Checks if `path` is a direct or inherited property of `object`.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Object
* @param {Object} object The object to query.
* @param {Array|string} path The path to check.
* @returns {boolean} Returns `true` if `path` exists, else `false`.
* @example
*
* var object = _.create({ 'a': _.create({ 'b': 2 }) });
*
* _.hasIn(object, 'a');
* // => true
*
* _.hasIn(object, 'a.b');
* // => true
*
* _.hasIn(object, ['a', 'b']);
* // => true
*
* _.hasIn(object, 'b');
* // => false
*/
function hasIn(object, path) {
return object != null && hasPath(object, path, baseHasIn);
}
/** Used to compose bitmasks for value comparisons. */
var COMPARE_PARTIAL_FLAG$5 = 1,
COMPARE_UNORDERED_FLAG$3 = 2;
/**
* The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
*
* @private
* @param {string} path The path of the property to get.
* @param {*} srcValue The value to match.
* @returns {Function} Returns the new spec function.
*/
function baseMatchesProperty(path, srcValue) {
if (isKey(path) && isStrictComparable(srcValue)) {
return matchesStrictComparable(toKey(path), srcValue);
}
return function (object) {
var objValue = get$1(object, path);
return objValue === undefined && objValue === srcValue ? hasIn(object, path) : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG$5 | COMPARE_UNORDERED_FLAG$3);
};
}
/**
* The base implementation of `_.property` without support for deep paths.
*
* @private
* @param {string} key The key of the property to get.
* @returns {Function} Returns the new accessor function.
*/
function baseProperty(key) {
return function (object) {
return object == null ? undefined : object[key];
};
}
/**
* A specialized version of `baseProperty` which supports deep paths.
*
* @private
* @param {Array|string} path The path of the property to get.
* @returns {Function} Returns the new accessor function.
*/
function basePropertyDeep(path) {
return function (object) {
return baseGet(object, path);
};
}
/**
* Creates a function that returns the value at `path` of a given object.
*
* @static
* @memberOf _
* @since 2.4.0
* @category Util
* @param {Array|string} path The path of the property to get.
* @returns {Function} Returns the new accessor function.
* @example
*
* var objects = [
* { 'a': { 'b': 2 } },
* { 'a': { 'b': 1 } }
* ];
*
* _.map(objects, _.property('a.b'));
* // => [2, 1]
*
* _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
* // => [1, 2]
*/
function property(path) {
return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
}
/**
* The base implementation of `_.iteratee`.
*
* @private
* @param {*} [value=_.identity] The value to convert to an iteratee.
* @returns {Function} Returns the iteratee.
*/
function baseIteratee(value) {
// Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
// See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
if (typeof value == 'function') {
return value;
}
if (value == null) {
return identity;
}
if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) == 'object') {
return isArray(value) ? baseMatchesProperty(value[0], value[1]) : baseMatches(value);
}
return property(value);
}
/**
* The base implementation of `_.sum` and `_.sumBy` without support for
* iteratee shorthands.
*
* @private
* @param {Array} array The array to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @returns {number} Returns the sum.
*/
function baseSum(array, iteratee) {
var result,
index = -1,
length = array.length;
while (++index < length) {
var current = iteratee(array[index]);
if (current !== undefined) {
result = result === undefined ? current : result + current;
}
}
return result;
}
/**
* This method is like `_.sum` except that it accepts `iteratee` which is
* invoked for each element in `array` to generate the value to be summed.
* The iteratee is invoked with one argument: (value).
*
* @static
* @memberOf _
* @since 4.0.0
* @category Math
* @param {Array} array The array to iterate over.
* @param {Function} [iteratee=_.identity] The iteratee invoked per element.
* @returns {number} Returns the sum.
* @example
*
* var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
*
* _.sumBy(objects, function(o) { return o.n; });
* // => 20
*
* // The `_.property` iteratee shorthand.
* _.sumBy(objects, 'n');
* // => 20
*/
function sumBy(array, iteratee) {
return array && array.length ? baseSum(array, baseIteratee(iteratee, 2)) : 0;
}
/**
* The base implementation of methods like `_.max` and `_.min` which accepts a
* `comparator` to determine the extremum value.
*
* @private
* @param {Array} array The array to iterate over.
* @param {Function} iteratee The iteratee invoked per iteration.
* @param {Function} comparator The comparator used to compare values.
* @returns {*} Returns the extremum value.
*/
function baseExtremum(array, iteratee, comparator) {
var index = -1,
length = array.length;
while (++index < length) {
var value = array[index],
current = iteratee(value);
if (current != null && (computed === undefined ? current === current && !isSymbol(current) : comparator(current, computed))) {
var computed = current,
result = value;
}
}
return result;
}
/**
* The base implementation of `_.gt` which doesn't coerce arguments.
*
* @private
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @returns {boolean} Returns `true` if `value` is greater than `other`,
* else `false`.
*/
function baseGt(value, other) {
return value > other;
}
/**
* This method is like `_.max` except that it accepts `iteratee` which is
* invoked for each element in `array` to generate the criterion by which
* the value is ranked. The iteratee is invoked with one argument: (value).
*
* @static
* @memberOf _
* @since 4.0.0
* @category Math
* @param {Array} array The array to iterate over.
* @param {Function} [iteratee=_.identity] The iteratee invoked per element.
* @returns {*} Returns the maximum value.
* @example
*
* var objects = [{ 'n': 1 }, { 'n': 2 }];
*
* _.maxBy(objects, function(o) { return o.n; });
* // => { 'n': 2 }
*
* // The `_.property` iteratee shorthand.
* _.maxBy(objects, 'n');
* // => { 'n': 2 }
*/
function maxBy(array, iteratee) {
return array && array.length ? baseExtremum(array, baseIteratee(iteratee, 2), baseGt) : undefined;
}
/**
* The base implementation of `_.lt` which doesn't coerce arguments.
*
* @private
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @returns {boolean} Returns `true` if `value` is less than `other`,
* else `false`.
*/
function baseLt(value, other) {
return value < other;
}
/**
* This method is like `_.min` except that it accepts `iteratee` which is
* invoked for each element in `array` to generate the criterion by which
* the value is ranked. The iteratee is invoked with one argument: (value).
*
* @static
* @memberOf _
* @since 4.0.0
* @category Math
* @param {Array} array The array to iterate over.
* @param {Function} [iteratee=_.identity] The iteratee invoked per element.
* @returns {*} Returns the minimum value.
* @example
*
* var objects = [{ 'n': 1 }, { 'n': 2 }];
*
* _.minBy(objects, function(o) { return o.n; });
* // => { 'n': 1 }
*
* // The `_.property` iteratee shorthand.
* _.minBy(objects, 'n');
* // => { 'n': 1 }
*/
function minBy(array, iteratee) {
return array && array.length ? baseExtremum(array, baseIteratee(iteratee, 2), baseLt) : undefined;
}
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeMax$2 = Math.max;
/**
* This method is like `_.zip` except that it accepts an array of grouped
* elements and creates an array regrouping the elements to their pre-zip
* configuration.
*
* @static
* @memberOf _
* @since 1.2.0
* @category Array
* @param {Array} array The array of grouped elements to process.
* @returns {Array} Returns the new array of regrouped elements.
* @example
*
* var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
* // => [['a', 1, true], ['b', 2, false]]
*
* _.unzip(zipped);
* // => [['a', 'b'], [1, 2], [true, false]]
*/
function unzip(array) {
if (!(array && array.length)) {
return [];
}
var length = 0;
array = arrayFilter(array, function (group) {
if (isArrayLikeObject(group)) {
length = nativeMax$2(group.length, length);
return true;
}
});
return baseTimes(length, function (index) {
return arrayMap(array, baseProperty(index));
});
}
/**
* Creates an array of grouped elements, the first of which contains the
* first elements of the given arrays, the second of which contains the
* second elements of the given arrays, and so on.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Array
* @param {...Array} [arrays] The arrays to process.
* @returns {Array} Returns the new array of grouped elements.
* @example
*
* _.zip(['a', 'b'], [1, 2], [true, false]);
* // => [['a', 1, true], ['b', 2, false]]
*/
var zip = baseRest(unzip);
/**
* The base implementation of methods like `_.dropWhile` and `_.takeWhile`
* without support for iteratee shorthands.
*
* @private
* @param {Array} array The array to query.
* @param {Function} predicate The function invoked per iteration.
* @param {boolean} [isDrop] Specify dropping elements instead of taking them.
* @param {boolean} [fromRight] Specify iterating from right to left.
* @returns {Array} Returns the slice of `array`.
*/
function baseWhile(array, predicate, isDrop, fromRight) {
var length = array.length,
index = fromRight ? length : -1;
while ((fromRight ? index-- : ++index < length) && predicate(array[index], index, array)) {}
return isDrop ? baseSlice(array, fromRight ? 0 : index, fromRight ? index + 1 : length) : baseSlice(array, fromRight ? index + 1 : 0, fromRight ? length : index);
}
/**
* Creates a slice of `array` with elements taken from the beginning. Elements
* are taken until `predicate` returns falsey. The predicate is invoked with
* three arguments: (value, index, array).
*
* @static
* @memberOf _
* @since 3.0.0
* @category Array
* @param {Array} array The array to query.
* @param {Function} [predicate=_.identity] The function invoked per iteration.
* @returns {Array} Returns the slice of `array`.
* @example
*
* var users = [
* { 'user': 'barney', 'active': false },
* { 'user': 'fred', 'active': false },
* { 'user': 'pebbles', 'active': true }
* ];
*
* _.takeWhile(users, function(o) { return !o.active; });
* // => objects for ['barney', 'fred']
*
* // The `_.matches` iteratee shorthand.
* _.takeWhile(users, { 'user': 'barney', 'active': false });
* // => objects for ['barney']
*
* // The `_.matchesProperty` iteratee shorthand.
* _.takeWhile(users, ['active', false]);
* // => objects for ['barney', 'fred']
*
* // The `_.property` iteratee shorthand.
* _.takeWhile(users, 'active');
* // => []
*/
function takeWhile(array, predicate) {
return array && array.length ? baseWhile(array, baseIteratee(predicate, 3)) : [];
}
/**
* Creates a slice of `array` excluding elements dropped from the beginning.
* Elements are dropped until `predicate` returns falsey. The predicate is
* invoked with three arguments: (value, index, array).
*
* @static
* @memberOf _
* @since 3.0.0
* @category Array
* @param {Array} array The array to query.
* @param {Function} [predicate=_.identity] The function invoked per iteration.
* @returns {Array} Returns the slice of `array`.
* @example
*
* var users = [
* { 'user': 'barney', 'active': false },
* { 'user': 'fred', 'active': false },
* { 'user': 'pebbles', 'active': true }
* ];
*
* _.dropWhile(users, function(o) { return !o.active; });
* // => objects for ['pebbles']
*
* // The `_.matches` iteratee shorthand.
* _.dropWhile(users, { 'user': 'barney', 'active': false });
* // => objects for ['fred', 'pebbles']
*
* // The `_.matchesProperty` iteratee shorthand.
* _.dropWhile(users, ['active', false]);
* // => objects for ['pebbles']
*
* // The `_.property` iteratee shorthand.
* _.dropWhile(users, 'active');
* // => objects for ['barney', 'fred', 'pebbles']
*/
function dropWhile(array, predicate) {
return array && array.length ? baseWhile(array, baseIteratee(predicate, 3), true) : [];
}
/**
* A specialized version of `baseAggregator` for arrays.
*
* @private
* @param {Array} [array] The array to iterate over.
* @param {Function} setter The function to set `accumulator` values.
* @param {Function} iteratee The iteratee to transform keys.
* @param {Object} accumulator The initial aggregated object.
* @returns {Function} Returns `accumulator`.
*/
function arrayAggregator(array, setter, iteratee, accumulator) {
var index = -1,
length = array == null ? 0 : array.length;
while (++index < length) {
var value = array[index];
setter(accumulator, value, iteratee(value), array);
}
return accumulator;
}
/**
* The base implementation of `_.forOwn` without support for iteratee shorthands.
*
* @private
* @param {Object} object The object to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @returns {Object} Returns `object`.
*/
function baseForOwn(object, iteratee) {
return object && baseFor(object, iteratee, keys);
}
/**
* Creates a `baseEach` or `baseEachRight` function.
*
* @private
* @param {Function} eachFunc The function to iterate over a collection.
* @param {boolean} [fromRight] Specify iterating from right to left.
* @returns {Function} Returns the new base function.
*/
function createBaseEach(eachFunc, fromRight) {
return function (collection, iteratee) {
if (collection == null) {
return collection;
}
if (!isArrayLike(collection)) {
return eachFunc(collection, iteratee);
}
var length = collection.length,
index = fromRight ? length : -1,
iterable = Object(collection);
while (fromRight ? index-- : ++index < length) {
if (iteratee(iterable[index], index, iterable) === false) {
break;
}
}
return collection;
};
}
/**
* The base implementation of `_.forEach` without support for iteratee shorthands.
*
* @private
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @returns {Array|Object} Returns `collection`.
*/
var baseEach = createBaseEach(baseForOwn);
/**
* Aggregates elements of `collection` on `accumulator` with keys transformed
* by `iteratee` and values set by `setter`.
*
* @private
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} setter The function to set `accumulator` values.
* @param {Function} iteratee The iteratee to transform keys.
* @param {Object} accumulator The initial aggregated object.
* @returns {Function} Returns `accumulator`.
*/
function baseAggregator(collection, setter, iteratee, accumulator) {
baseEach(collection, function (value, key, collection) {
setter(accumulator, value, iteratee(value), collection);
});
return accumulator;
}
/**
* Creates a function like `_.groupBy`.
*
* @private
* @param {Function} setter The function to set accumulator values.
* @param {Function} [initializer] The accumulator object initializer.
* @returns {Function} Returns the new aggregator function.
*/
function createAggregator(setter, initializer) {
return function (collection, iteratee) {
var func = isArray(collection) ? arrayAggregator : baseAggregator,
accumulator = initializer ? initializer() : {};
return func(collection, setter, baseIteratee(iteratee, 2), accumulator);
};
}
/** Used for built-in method references. */
var objectProto$g = Object.prototype;
/** Used to check objects for own properties. */
var hasOwnProperty$d = objectProto$g.hasOwnProperty;
/**
* Creates an object composed of keys generated from the results of running
* each element of `collection` thru `iteratee`. The order of grouped values
* is determined by the order they occur in `collection`. The corresponding
* value of each key is an array of elements responsible for generating the
* key. The iteratee is invoked with one argument: (value).
*
* @static
* @memberOf _
* @since 0.1.0
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
* @param {Function} [iteratee=_.identity] The iteratee to transform keys.
* @returns {Object} Returns the composed aggregate object.
* @example
*
* _.groupBy([6.1, 4.2, 6.3], Math.floor);
* // => { '4': [4.2], '6': [6.1, 6.3] }
*
* // The `_.property` iteratee shorthand.
* _.groupBy(['one', 'two', 'three'], 'length');
* // => { '3': ['one', 'two'], '5': ['three'] }
*/
var groupBy = createAggregator(function (result, value, key) {
if (hasOwnProperty$d.call(result, key)) {
result[key].push(value);
} else {
baseAssignValue(result, key, [value]);
}
});
var noop$1 = function noop() {};
var yes = function yes() {
return true;
};
var no = function no() {
return false;
};
var identity$1 = function identity(arg) {
return arg;
};
var toCamelCase = function toCamelCase() {
for (var _len = arguments.length, names = Array(_len), _key = 0; _key < _len; _key++) {
names[_key] = arguments[_key];
}
var length = names.length;
var nameList = names.map(function (name) {
return '' + name;
});
if (length > 0) {
return nameList[0] + nameList.slice(1).map(function (name) {
return name[0].toUpperCase() + name.substring(1, name.length);
}).join('');
}
return '';
};
var isEmail = function isEmail(value) {
if (value) {
var re = /^(([^<>()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i; // eslint-disable-line no-useless-escape
return re.test(value);
}
return false;
};
function compare(x, y) {
if (x === y) {
return 0;
}
if (x > y) {
return 1;
}
return -1;
}
function orderBy(data, selectors, compares) {
var length = selectors.length;
var result = [];
var count = data.length;
// iterate through data to create array with applied selectors
var index = count;
while (index--) {
var row = data[index];
var criteria = [];
for (var i = 0; i < length; i++) {
var select = selectors[i];
criteria.push(select(row));
}
result.push({ row: row, criteria: criteria, index: index });
}
// multi selector comparator
var compare = function compare(x, y) {
var result = 0;
for (var _i = 0; _i < length; _i++) {
var _compare = compares[_i];
var xv = x.criteria[_i];
var yv = y.criteria[_i];
result = _compare(xv, yv, x.row, y.row);
if (result !== 0) {
return result;
}
}
// ensures a stable sort
return x.index - y.index;
};
result.sort(compare);
// copy origin values to result array
index = count;
while (index--) {
result[index] = result[index].row;
}
return result;
}
function htmlEncode(s) {
return String(s).replace(/&/g, '&').replace(/"/g, '"').replace(/'/g, ''').replace(/</g, '<').replace(/>/g, '>');
}
function escapeRegexp(text) {
if (!text) return text;
return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
}
function binarySearch(list, value) {
var low = 0;
var high = list.length;
while (low < high) {
var mid = low + high >>> 1;
if (list[mid] < value) {
low = mid + 1;
} else {
high = mid;
}
}
return low;
}
function isUrl(value) {
var a = document.createElement('a');
a.href = value;
return a.host && a.host != window.location.host;
}
function isImage(value) {
return ('' + value).match(/\.(jpeg|jpg|gif|png)$/) != null;
}
function compile(path) {
var parts = path.split('.');
var last = parts.length - 1;
var accessor = getAccessor(parts, last);
var key = parts[last];
if (accessor) {
return function (entry, value) {
if (arguments.length === 2) {
accessor(entry)[key] = value;
}
return accessor(entry)[key];
};
}
return function (entry, value) {
if (arguments.length === 2) {
entry[key] = value;
}
return entry[key];
};
}
function compileGet(path) {
var parts = path.split('.');
var last = parts.length - 1;
var accessor = getAccessor(parts, last);
var key = parts[last];
if (accessor) {
return function (entry) {
return accessor(entry)[key];
};
}
return function (entry) {
return entry[key];
};
}
function compileSet(path) {
var parts = path.split('.');
var last = parts.length - 1;
var accessor = getAccessor(parts, last);
var key = parts[last];
if (accessor) {
return function (entry, value) {
accessor(entry)[key] = value;
};
}
return function (entry, value) {
entry[key] = value;
};
}
function getAccessor(parts, last) {
return parts.filter(function (part, index) {
return index !== last;
}).reduce(function (accessor, part) {
return accessor ? function (entry) {
return accessor(entry)[part];
} : function (entry) {
return entry[part];
};
}, null);
}
var AppError = function (_Error) {
inherits(AppError, _Error);
function AppError(name, message) {
classCallCheck(this, AppError);
var _this = possibleConstructorReturn(this, (AppError.__proto__ || Object.getPrototypeOf(AppError)).call(this, message));
_this.name = _this.constructor.name;
_this.message = 'qgrid.' + name + ': ' + message;
if (isFunction(Error.captureStackTrace)) {
Error.captureStackTrace(_this, _this.constructor);
} else {
_this.stack = new Error(message).stack;
}
return _this;
}
return AppError;
}(Error);
function get$2(row, column) {
return column.$value ? column.$value({ $row: row, $column: column }) : column.value ? column.value(row) : column.path ? compileGet(column.path)(row) : row[column.key];
}
function getFactory(column) {
var get = column.$value ? function (row) {
return column.$value({ $row: row, $column: column });
} : column.value ? function (row) {
return column.value(row);
} : column.path ? compileGet(column.path) : function (row) {
return row[column.key];
};
return get;
}
function set$1(row, column, value) {
if (isFunction(column.$value)) {
return column.$value({ $row: row, $value: value, $column: column });
}
if (isFunction(column.value)) {
return column.value(row, value);
}
if (column.path) {
return compileSet(column.path)(row, value);
}
if (row.hasOwnProperty(column.key)) {
return row[column.key] = value;
}
throw new AppError('value', 'Row can\'t be edit on "' + column.key + '" column');
}
function get$3(row, column) {
return column.$label ? isFunction(column.$label) ? column.$label({ $row: row }) : column.$label : column.label ? isFunction(column.label) ? column.label(row) : column.label : column.labelPath ? compileGet(column.labelPath)(row) : get$2(row, column);
}
function getFactory$1(column) {
var get$$1 = column.$label ? isFunction(column.$label) ? function (row) {
return column.$label({ $row: row });
} : function (row) {
return column.label;
} : column.label ? isFunction(column.label) ? function (row) {
return column.label(row);
} : function (row) {
return column.label;
} : column.labelPath ? compileGet(column.labelPath) : function (row) {
return get$2(row, column);
};
return get$$1;
}
function set$2(row, column, label) {
if (isFunction(column.$label)) {
return column.$label({ $row: row, $label: label });
}
if (isFunction(column.label)) {
return column.label(row, label);
}
if (column.labelPath) {
return compileSet(column.labelPath)(row, label);
}
}
function build(model) {
return function run(source, changes, pipe) {
var middleware = new Middleware(pipe);
var context = {
model: model,
source: source,
changes: changes,
valueFactory: getFactory,
labelFactory: getFactory$1
};
var _model$data = model.data(),
rows = _model$data.rows;
return middleware.run(context, rows);
};
}
/*eslint-disable no-console*/
var Log = function () {
function Log() {
classCallCheck(this, Log);
}
createClass(Log, null, [{
key: "info",
value: function info() /*source, message*/{
// console.info(`qgrid.${source}: ${message}`);
}
}, {
key: "warn",
value: function warn() /*source, message*/{
// console.warn(`qgrid.${source}: ${message}`);
}
}, {
key: "error",
value: function error(source, message) {
console.error("qgrid." + source + ": " + message);
}
}]);
return Log;
}();
function guid() {
function p8(s) {
var p = (Math.random().toString(16) + '000000000').substr(2, 8);
return s ? '-' + p.substr(0, 4) + '-' + p.substr(4, 4) : p;
}
return p8() + p8(true) + p8(true) + p8();
}
var Event$1 = function () {
function Event() {
var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function () {
return null;
};
classCallCheck(this, Event);
this.handlers = [];
this.isDirty = false;
this.e = e;
}
createClass(Event, [{
key: 'on',
value: function on(f) {
var lifecycle = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'app';
var handlers = this.handlers;
var handler = { f: f };
var off = function off() {
var index = handlers.indexOf(handler);
if (index >= 0) {
handlers.splice(index, 1);
}
};
handler.off = off;
handler.lifecycle = lifecycle;
handlers.push(handler);
return off;
}
}, {
key: 'watch',
value: function watch(f) {
var lifecycle = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'app';
var off = this.on(f, lifecycle);
if (this.isDirty) {
f(this.e(), off);
}
return off;
}
}, {
key: 'emit',
value: function emit(e) {
this.isDirty = true;
var temp = Array.from(this.handlers);
for (var i = 0, length = temp.length; i < length; i++) {
var handler = temp[i];
handler.f(e, handler.off);
}
}
}, {
key: 'dispose',
value: function dispose() {
var lifecycle = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
var temp = Array.from(this.handlers);
for (var i = 0, length = temp.length; i < length; i++) {
var handler = temp[i];
if (!lifecycle || handler.lifecycle === lifecycle) {
handler.off();
}
}
}
}]);
return Event;
}();
var hasOwnProperty$e = Object.prototype.hasOwnProperty;
var Guard = function () {
function Guard() {
classCallCheck(this, Guard);
}
createClass(Guard, null, [{
key: 'notUndefined',
/**
* If value is undefined exception will be thrown
* @param {any} value - Value to check
* @param {string} name - Argument name
*/
value: function notUndefined(value, name) {
if (isUndefined(value)) {
throw new AppError('guard.notUndefined', name);
}
}
/**
* If value is null or undefined exception will be thrown
* @param {any} value - Value to check
* @param {string} name - Argument name
*/
}, {
key: 'notNull',
value: function notNull(value, name) {
if (value === null || isUndefined(value)) {
throw new AppError('guard.notNull', name);
}
}
/**
* If value is null or undefined or empty exception will be thrown
* @param {any} value - Value to check
* @param {string} name - Argument name
*/
}, {
key: 'notNullOrEmpty',
value: function notNullOrEmpty(value, name) {
if (value === null || isUndefined(value) || value === '') {
throw new AppError('guard.notNullOrEmpty', name);
}
}
/**
* If value is not a function exception will be thrown
* @param {any} value - Value to check
* @param {string} name - Argument name
*/
}, {
key: 'invokable',
value: function invokable(value, name) {
if (!isFunction(value)) {
throw new AppError('guard.invokable', name);
}
}
}, {
key: 'hasProperty',
value: function hasProperty(instance, name) {
Guard.notNull(instance, 'instance');
if (!hasOwnProperty$e.call(instance, name)) {
throw new AppError('guard.hasProperty', name);
}
}
}]);
return Guard;
}();
var models = {};
var close = false;
var Model$1 = function () {
function Model() {
var _this = this;
classCallCheck(this, Model);
close = true;
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
var _loop = function _loop() {
var name = _step.value;
var model = new models[name]();
var changeSet = new Set();
var watchArg = function watchArg() {
var changes = Array.from(changeSet.values()).reduce(function (memo, key) {
var value = model[key];
memo[key] = { newValue: value, oldValue: value };
return memo;
}, {});
return {
state: model,
hasChanges: changes.hasOwnProperty.bind(changes),
changes: changes,
tag: {},
source: 'watch'
};
};
var event = new Event$1(watchArg);
var equals = Model.equals;
_this[name + 'Changed'] = event;
_this[name] = function (state, tag) {
var length = arguments.length;
if (length) {
if (!isObject(state)) {
throw new AppError('model.' + name, '"' + state + '" is not a valid type, should be an object');
}
var hasChanges = false;
var changes = {};
var keys = Object.keys(state);
for (var i = 0, keyLength = keys.length; i < keyLength; i++) {
var key = keys[i];
if (!model.hasOwnProperty(key)) {
throw new AppError('model.' + name, '"' + key + '" is not a valid key, only [' + Object.keys(model).join(', ') + '] keys are supported');
}
var newValue = state[key];
var oldValue = model[key];
if (!equals(newValue, oldValue)) {
// Log.info('model', `value changed - "${name}.${key}"`);
Guard.notUndefined(newValue, 'model.' + name + '.' + key);
model[key] = newValue;
hasChanges = true;
changes[key] = {
newValue: newValue,
oldValue: oldValue
};
changeSet.add(key);
}
// else {
// Log.warn('model', `value was not changed - "${name}.${key}"`);
// }
}
if (hasChanges) {
event.emit({
state: model,
hasChanges: changes.hasOwnProperty.bind(changes),
changes: changes,
tag: length > 1 ? tag : {},
source: 'emit'
});
}
return this;
}
return model;
};
};
for (var _iterator = Object.keys(models)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
_loop();
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
}
createClass(Model, null, [{
key: 'equals',
value: function equals(x, y) {
// TODO: improve equality algo
if (x === y) {
return true;
}
if (isArray(x)) {
if (x.length === 0 && y.length === 0) {
return true;
}
}
if (x instanceof Map) {
if (x.size === 0 && y.size === 0) {
return true;
}
}
if (x instanceof Set) {
if (x.size === 0 && y.size === 0) {
return true;
}
}
return false;
}
}, {
key: 'register',
value: function register(name, model) {
if (models.hasOwnProperty(name)) {
throw new AppError('model', '"' + name + '" is already registered');
}
if (!isFunction(model)) {
throw new AppError('model.' + name, '"' + model + '" is not a valid type, should be an constructor function');
}
if (close) {
throw new AppError('model.' + name, 'can\'t register, registration was closed');
}
models[name] = model;
return Model;
}
}]);
return Model;
}();
var PersistenceService = function () {
function PersistenceService(model) {
classCallCheck(this, PersistenceService);
this.model = model;
}
createClass(PersistenceService, [{
key: 'save',
value: function save(settings) {
var gridModel = this.model;
settings = settings || gridModel.persistence().settings;
var model = {};
for (var key in settings) {
var source = gridModel[key]();
var target = {};
model[key] = target;
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = settings[key][Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var p = _step.value;
var value = source[p];
target[p] = clone(value);
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
}
return model;
}
}, {
key: 'load',
value: function load(model, settings) {
var gridModel = this.model;
settings = settings || gridModel.persistence().settings;
for (var key in settings) {
var source = model[key];
if (source) {
var target = gridModel[key];
target(source, { source: 'persistence.service' });
}
}
return model;
}
}, {
key: 'reset',
value: function reset(settings) {
var defaultModel = new Model$1();
var gridModel = this.model;
settings = settings || gridModel.persistence().settings;
var model = {};
for (var key in settings) {
model[key] = {};
var source = defaultModel[key];
var target = gridModel[key];
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = settings[key][Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var p = _step2.value;
model[key][p] = source()[p];
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
target(model[key], { source: 'behavior.core' });
}
return model;
}
}]);
return PersistenceService;
}();
var Scheduler = function () {
function Scheduler() {
classCallCheck(this, Scheduler);
this.tasks = [];
}
createClass(Scheduler, [{
key: "next",
value: function next() {
this.tasks.shift();
var task = this.tasks[0];
if (task) {
task();
return true;
}
return false;
}
}, {
key: "add",
value: function add(task) {
this.tasks.push(task);
if (this.tasks.length === 1) {
task();
}
return this.tasks.length;
}
}]);
return Scheduler;
}();
var Defer = function () {
function Defer() {
classCallCheck(this, Defer);
this.promise = new DeferPromise();
}
createClass(Defer, [{
key: 'reject',
value: function reject() {
this.promise.reject();
}
}, {
key: 'resolve',
value: function resolve() {
this.promise.resolve();
}
}]);
return Defer;
}();
var DeferPromise = function () {
function DeferPromise() {
classCallCheck(this, DeferPromise);
this.catchEvent = new Event$1();
this.thenEvent = new Event$1();
}
createClass(DeferPromise, [{
key: 'reject',
value: function reject() {
this.catchEvent.emit();
}
}, {
key: 'resolve',
value: function resolve() {
this.thenEvent.emit();
}
}, {
key: 'catch',
value: function _catch(handler) {
this.catchEvent.on(handler);
}
}, {
key: 'then',
value: function then(handler) {
this.thenEvent.on(handler);
}
}]);
return DeferPromise;
}();
var Disposable = function () {
function Disposable() {
classCallCheck(this, Disposable);
this.disposes = [];
}
createClass(Disposable, [{
key: 'using',
value: function using(instance) {
if (instance instanceof Disposable) {
this.disposes.push(function () {
return instance.dispose();
});
return instance;
}
Guard.invokable(instance, 'instance');
this.disposes.push(instance);
return instance;
}
}, {
key: 'dispose',
value: function dispose() {
var temp = this.disposes;
this.disposes = [];
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = temp[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var dispose = _step.value;
dispose();
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
}
}]);
return Disposable;
}();
var FocusService = function () {
function FocusService(model) {
classCallCheck(this, FocusService);
this.model = model;
}
createClass(FocusService, [{
key: 'activate',
value: function activate(rowIndex, columnIndex) {
var _model = this.model,
focus = _model.focus,
scene = _model.scene,
sceneChanged = _model.sceneChanged;
var focusState = clone(focus());
if (!isUndefined(rowIndex)) {
focusState.rowIndex = rowIndex;
}
if (!isUndefined(columnIndex)) {
focusState.columnIndex = columnIndex;
}
var activate = function activate() {
var rowIndex = focusState.rowIndex,
columnIndex = focusState.columnIndex;
if (rowIndex >= 0 && columnIndex >= 0) {
focus({ isActive: true, rowIndex: rowIndex, columnIndex: columnIndex }, { source: 'focus.service' });
} else {
var _columnIndex = scene().column.line.findIndex(function (c) {
return c.model.canFocus;
});
focus({ isActive: true, rowIndex: 0, columnIndex: _columnIndex }, { source: 'focus.service' });
}
};
if (scene().status === 'stop') {
activate();
} else {
sceneChanged.on(function (e, off) {
if (e.hasChanges('status')) {
if (e.state.status === 'stop') {
activate();
off();
}
}
});
}
}
}]);
return FocusService;
}();
var FocusAfterRender = function (_Disposable) {
inherits(FocusAfterRender, _Disposable);
function FocusAfterRender(model, table) {
classCallCheck(this, FocusAfterRender);
var _this = possibleConstructorReturn(this, (FocusAfterRender.__proto__ || Object.getPrototypeOf(FocusAfterRender)).call(this));
_this.using(model.sceneChanged.on(function (e, off) {
if (e.state.status === 'stop') {
table.view.focus();
off();
}
}));
return _this;
}
return FocusAfterRender;
}(Disposable);
var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
function commonjsRequire () {
throw new Error('Dynamic requires are not currently supported by rollup-plugin-commonjs');
}
function unwrapExports (x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
}
function createCommonjsModule(fn, module) {
return module = { exports: {} }, fn(module, module.exports), module.exports;
}
var fastdom = createCommonjsModule(function (module) {
!function (win) {
/**
* FastDom
*
* Eliminates layout thrashing
* by batching DOM read/write
* interactions.
*
* @author Wilson Page <wilsonpage@me.com>
* @author Kornel Lesinski <kornel.lesinski@ft.com>
*/
'use strict';
/**
* Mini logger
*
* @return {Function}
*/
var debug = 0 ? console.log.bind(console, '[fastdom]') : function () {};
/**
* Normalized rAF
*
* @type {Function}
*/
var raf = win.requestAnimationFrame || win.webkitRequestAnimationFrame || win.mozRequestAnimationFrame || win.msRequestAnimationFrame || function (cb) {
return setTimeout(cb, 16);
};
/**
* Initialize a `FastDom`.
*
* @constructor
*/
function FastDom() {
var self = this;
self.reads = [];
self.writes = [];
self.raf = raf.bind(win); // test hook
debug('initialized', self);
}
FastDom.prototype = {
constructor: FastDom,
/**
* Adds a job to the read batch and
* schedules a new frame if need be.
*
* @param {Function} fn
* @param {Object} ctx the context to be bound to `fn` (optional).
* @public
*/
measure: function measure(fn, ctx) {
debug('measure');
var task = !ctx ? fn : fn.bind(ctx);
this.reads.push(task);
scheduleFlush(this);
return task;
},
/**
* Adds a job to the
* write batch and schedules
* a new frame if need be.
*
* @param {Function} fn
* @param {Object} ctx the context to be bound to `fn` (optional).
* @public
*/
mutate: function mutate(fn, ctx) {
debug('mutate');
var task = !ctx ? fn : fn.bind(ctx);
this.writes.push(task);
scheduleFlush(this);
return task;
},
/**
* Clears a scheduled 'read' or 'write' task.
*
* @param {Object} task
* @return {Boolean} success
* @public
*/
clear: function clear(task) {
debug('clear', task);
return remove(this.reads, task) || remove(this.writes, task);
},
/**
* Extend this FastDom with some
* custom functionality.
*
* Because fastdom must *always* be a
* singleton, we're actually extending
* the fastdom instance. This means tasks
* scheduled by an extension still enter
* fastdom's global task queue.
*
* The 'super' instance can be accessed
* from `this.fastdom`.
*
* @example
*
* var myFastdom = fastdom.extend({
* initialize: function() {
* // runs on creation
* },
*
* // override a method
* measure: function(fn) {
* // do extra stuff ...
*
* // then call the original
* return this.fastdom.measure(fn);
* },
*
* ...
* });
*
* @param {Object} props properties to mixin
* @return {FastDom}
*/
extend: function extend(props) {
debug('extend', props);
if ((typeof props === 'undefined' ? 'undefined' : _typeof(props)) != 'object') throw new Error('expected object');
var child = Object.create(this);
mixin(child, props);
child.fastdom = this;
// run optional creation hook
if (child.initialize) child.initialize();
return child;
},
// override this with a function
// to prevent Errors in console
// when tasks throw
catch: null
};
/**
* Schedules a new read/write
* batch if one isn't pending.
*
* @private
*/
function scheduleFlush(fastdom) {
if (!fastdom.scheduled) {
fastdom.scheduled = true;
fastdom.raf(flush.bind(null, fastdom));
debug('flush scheduled');
}
}
/**
* Runs queued `read` and `write` tasks.
*
* Errors are caught and thrown by default.
* If a `.catch` function has been defined
* it is called instead.
*
* @private
*/
function flush(fastdom) {
debug('flush');
var writes = fastdom.writes;
var reads = fastdom.reads;
var error;
try {
debug('flushing reads', reads.length);
runTasks(reads);
debug('flushing writes', writes.length);
runTasks(writes);
} catch (e) {
error = e;
}
fastdom.scheduled = false;
// If the batch errored we may still have tasks queued
if (reads.length || writes.length) scheduleFlush(fastdom);
if (error) {
debug('task errored', error.message);
if (fastdom.catch) fastdom.catch(error);else throw error;
}
}
/**
* We run this inside a try catch
* so that if any jobs error, we
* are able to recover and continue
* to flush the batch until it's empty.
*
* @private
*/
function runTasks(tasks) {
debug('run tasks');
var task;while (task = tasks.shift()) {
task();
}
}
/**
* Remove an item from an Array.
*
* @param {Array} array
* @param {*} item
* @return {Boolean}
*/
function remove(array, item) {
var index = array.indexOf(item);
return !!~index && !!array.splice(index, 1);
}
/**
* Mixin own properties of source
* object into the target.
*
* @param {Object} target
* @param {Object} source
*/
function mixin(target, source) {
for (var key in source) {
if (source.hasOwnProperty(key)) target[key] = source[key];
}
}
// There should never be more than
// one instance of `FastDom` in an app
var exports = win.fastdom = win.fastdom || new FastDom(); // jshint ignore:line
// Expose to CJS & AMD
if (typeof undefined == 'function') undefined(function () {
return exports;
});else if ('object' == 'object') module.exports = exports;
}(typeof window !== 'undefined' ? window : commonjsGlobal);
});
var Fastdom = function () {
function Fastdom() {
classCallCheck(this, Fastdom);
}
createClass(Fastdom, null, [{
key: 'mutate',
value: function mutate(task) {
return Fastdom.invoke(function () {
return fastdom.mutate(task);
});
}
}, {
key: 'measure',
value: function measure(task) {
return Fastdom.invoke(function () {
return fastdom.measure(task);
});
}
}, {
key: 'clear',
value: function clear(task) {
return Fastdom.invoke(function () {
return fastdom.clear(task);
});
}
}, {
key: 'invoke',
value: function invoke(task) {
return task();
}
}]);
return Fastdom;
}();
function invalidateSettings() {
if (arguments.length) {
if (isString(arguments.length <= 0 ? undefined : arguments[0])) {
return {
source: arguments.length <= 0 ? undefined : arguments[0],
changes: (arguments.length <= 1 ? undefined : arguments[1]) || {},
pipe: arguments.length <= 2 ? undefined : arguments[2],
why: 'refresh'
};
}
return Object.assign({
source: 'invalidate',
changes: {},
pipe: null,
why: 'refresh'
}, arguments.length <= 0 ? undefined : arguments[0]);
}
return {
source: 'invalidate',
changes: {},
pipe: null,
why: 'refresh'
};
}
var GridService = function () {
function GridService(model) {
classCallCheck(this, GridService);
this.model = model;
this.scheduler = new Scheduler();
this.state = new PersistenceService(model);
}
createClass(GridService, [{
key: 'invalidate',
value: function invalidate() /*source = 'invalidate', changes = {}, pipe = null*/{
var settings = invalidateSettings.apply(undefined, arguments);
var source = settings.source,
changes = settings.changes,
pipe = settings.pipe,
why = settings.why;
var scheduler = this.scheduler,
model = this.model;
var scene = model.scene;
var runPipe = build(model);
var cancelBusy = why === 'refresh' ? this.busy() : noop$1;
var nextTask = function nextTask() {
cancelBusy();
if (!scheduler.next()) {
scene({ status: 'pull' }, {
source: source,
behavior: 'core'
});
}
};
var defer = new Defer();
var task = function task() {
Log.info('grid', 'start task ' + source);
scene({ status: 'start' }, {
source: source,
behavior: 'core'
});
model.head().cache.clear();
model.body().cache.clear();
model.foot().cache.clear();
return Fastdom.invoke(function () {
return runPipe(source, changes, pipe || model.data().pipe);
}).then(function () {
Log.info('grid', 'finish task ' + source);
nextTask();
defer.resolve();
}).catch(function (ex) {
Log.error('grid', ex);
nextTask();
defer.reject();
});
};
Log.info('grid', 'add task ' + source);
scheduler.add(task);
return defer.promise;
}
}, {
key: 'busy',
value: function busy() {
var id = guid();
var progress = this.model.progress;
var queue = progress().queue.concat([id]);
progress({ queue: queue });
return function () {
var queue = Array.from(progress().queue);
var index = queue.indexOf(id);
if (index >= 0) {
queue.splice(index, 1);
progress({ queue: queue });
}
};
}
}, {
key: 'focus',
value: function focus(rowIndex, columnIndex) {
var focus = new FocusService(this.model);
focus.activate(rowIndex, columnIndex);
}
}]);
return GridService;
}();
var GRID_PREFIX = 'q-grid';
var GridModel = function GridModel() {
classCallCheck(this, GridModel);
this.id = GRID_PREFIX + '-' + guid();
this.status = 'unbound'; //unbound | bound
this.caption = '';
this.interactionMode = 'full' | 'readonly' | 'detached';
// @deprecated
this.title = '';
};
var Command = function () {
function Command() {
var context = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
classCallCheck(this, Command);
this.execute = yes;
this.canExecute = yes;
this.shortcut = '';
this.priority = 0;
this.source = '';
this.sink = null;
Object.assign(this, context);
}
createClass(Command, [{
key: 'clone',
value: function clone$$1() {
var context = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var cmd = new Command(this);
Object.assign(cmd, context);
return cmd;
}
}]);
return Command;
}();
var resolvers = {};
var TemplatePath = function () {
function TemplatePath() {
classCallCheck(this, TemplatePath);
}
createClass(TemplatePath, null, [{
key: 'register',
value: function register(name, resolve) {
if (resolvers.hasOwnProperty(name)) {
throw new AppError('template.path', '"' + name + '" is already registered');
}
resolvers[name] = resolve;
return TemplatePath;
}
}, {
key: 'get',
value: function get$$1(source) {
var path = this.find(source);
if (!path) {
throw new AppError('template.path', 'Template path can\'t be found');
}
return path;
}
}, {
key: 'find',
value: function find(source) {
var getName = this.name;
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = Object.keys(resolvers)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var key = _step.value;
var name = getName(key);
var value = source[name];
if (!isUndefined(value) && value !== null) {
var path = resolvers[key](source, value);
if (path) {
return path;
}
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
return null;
}
}, {
key: 'name',
value: function name(_name) {
return '_' + _name;
}
}, {
key: 'require',
get: function get$$1() {
var getName = this.name;
return Object.keys(resolvers).reduce(function (memo, key) {
memo[getName(key)] = '^^?' + key;
return memo;
}, {});
}
}]);
return TemplatePath;
}();
TemplatePath.register('custom-cell', function (template, column) {
return {
model: template.for,
resource: column.key
};
});
TemplatePath.register('custom-cell-edit', function (template, column) {
return {
model: 'edit',
resource: column.key
};
});
var ColumnModel = function () {
function ColumnModel() {
var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'text';
classCallCheck(this, ColumnModel);
this.key = null;
this.path = null;
this.labelPath = null;
this.type = type;
this.title = null;
this.description = null;
this.pin = null;
this.origin = 'specific';
this.source = 'user';
this.class = 'data';
this.editor = null;
this.editorOptions = {
modelFactory: function modelFactory() {
return new Model();
},
trigger: 'click', // click | custom | focus
cruise: 'control', // control | transparent
label: null,
value: identity$1,
actions: []
};
this.width = null;
this.minWidth = 20;
this.maxWidth = null;
this.viewWidth = null;
this.widthMode = 'relative'; // relative | absolute
this.canEdit = true;
this.canResize = true;
this.canSort = true;
this.canMove = true;
this.canFilter = true;
this.canHighlight = true;
this.canFocus = true;
this.isVisible = true;
this.index = -1;
this.value = null;
this.label = null;
this.compare = compare;
this.children = [];
this.$label = null;
this.$value = null;
}
createClass(ColumnModel, [{
key: 'toString',
value: function toString() {
return this.type + ': ' + this.title;
}
}]);
return ColumnModel;
}();
var ColumnView = function () {
function ColumnView(model) {
classCallCheck(this, ColumnView);
this.model = model;
this.colspan = 1;
this.rowspan = 1;
this.rowIndex = -1;
this.columnIndex = -1;
}
createClass(ColumnView, null, [{
key: 'model',
value: function model(_model) {
if (_model) {
ColumnView.assign(_model);
} else {
_model = new ColumnModel();
}
_model.origin = 'custom';
return _model;
}
}, {
key: 'assign',
value: function assign(body) {
var etalon = this.model();
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = Object.keys(etalon)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var key = _step.value;
if (!body.hasOwnProperty(key)) {
var etalonValue = etalon[key];
if (isFunction(etalonValue)) {
etalonValue = etalonValue.bind(body);
}
body[key] = etalonValue;
} else {
var value = body[key];
if (isArray(value)) {
body[key] = Array.from(value);
} else if (isObject(value) && !isFunction(value)) {
body[key] = Object.assign({}, etalon[key], value);
}
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
return body;
}
}]);
return ColumnView;
}();
var DataColumnModel = function (_ColumnModel) {
inherits(DataColumnModel, _ColumnModel);
function DataColumnModel() {
classCallCheck(this, DataColumnModel);
var _this = possibleConstructorReturn(this, (DataColumnModel.__proto__ || Object.getPrototypeOf(DataColumnModel)).apply(this, arguments));
_this.isDefault = true;
_this.aggregation = null;
_this.aggregationOptions = {
distinct: false,
separator: '; '
};
return _this;
}
return DataColumnModel;
}(ColumnModel);
var FormatService = function () {
function FormatService() {
classCallCheck(this, FormatService);
}
createClass(FormatService, null, [{
key: "number",
value: function number(x, format) {
return x;
}
}, {
key: "date",
value: function date(x, format) {
return x;
}
}, {
key: "currency",
value: function currency(x, format) {
return x;
}
}]);
return FormatService;
}();
TemplatePath.register('array-cell', function (template, column) {
return {
model: template.for,
resource: column.key
};
});
TemplatePath.register('array-cell-edit', function (template, column) {
return {
model: 'edit',
resource: column.key
};
});
var ArrayColumnModel = function (_DataColumnModel) {
inherits(ArrayColumnModel, _DataColumnModel);
function ArrayColumnModel() {
classCallCheck(this, ArrayColumnModel);
var _this = possibleConstructorReturn(this, (ArrayColumnModel.__proto__ || Object.getPrototypeOf(ArrayColumnModel)).call(this, 'array'));
_this.itemType = 'text';
_this.itemLabel = identity$1;
_this.itemFormat = '';
_this.label = function (row) {
var value = get$2(row, this);
if (isArray(value)) {
var formatter = void 0;
switch (this.itemType) {
case 'number':
formatter = FormatService.number;
break;
case 'date':
formatter = FormatService.date;
break;
default:
formatter = this.itemLabel.bind(this);
break;
}
var format = this.itemFormat;
return value.map(function (item) {
return formatter(item, format);
}).join(', ');
}
return value;
};
return _this;
}
return ArrayColumnModel;
}(DataColumnModel);
var ArrayColumn = function (_ColumnView) {
inherits(ArrayColumn, _ColumnView);
function ArrayColumn(model) {
classCallCheck(this, ArrayColumn);
return possibleConstructorReturn(this, (ArrayColumn.__proto__ || Object.getPrototypeOf(ArrayColumn)).call(this, model));
}
createClass(ArrayColumn, null, [{
key: 'model',
value: function model(_model) {
return _model ? ArrayColumn.assign(_model) : new ArrayColumnModel();
}
}]);
return ArrayColumn;
}(ColumnView);
TemplatePath.register('bool-cell', function (template, column) {
return {
model: template.for,
resource: column.key
};
});
TemplatePath.register('bool-cell-edit', function (template, column) {
return {
model: 'edit',
resource: column.key
};
});
var BoolColumnModel = function (_DataColumnModel) {
inherits(BoolColumnModel, _DataColumnModel);
function BoolColumnModel() {
classCallCheck(this, BoolColumnModel);
var _this = possibleConstructorReturn(this, (BoolColumnModel.__proto__ || Object.getPrototypeOf(BoolColumnModel)).call(this, 'bool'));
_this.trueValue = true;
_this.falseValue = false;
_this.editorOptions.cruise = 'transparent';
// as we use 'this' pointer inside, we can't use lambda in 2 here
_this.isIndeterminate = function (value) {
return !(value === this.trueValue || value === this.falseValue);
};
_this.isChecked = function (value) {
return value === this.trueValue;
};
return _this;
}
return BoolColumnModel;
}(DataColumnModel);
var BoolColumn = function (_ColumnView) {
inherits(BoolColumn, _ColumnView);
function BoolColumn(model) {
classCallCheck(this, BoolColumn);
return possibleConstructorReturn(this, (BoolColumn.__proto__ || Object.getPrototypeOf(BoolColumn)).call(this, model));
}
createClass(BoolColumn, null, [{
key: 'model',
value: function model(_model) {
return _model ? BoolColumn.assign(_model) : new BoolColumnModel();
}
}]);
return BoolColumn;
}(ColumnView);
TemplatePath.register('cohort-cell', function (template) {
return {
model: template.for,
resource: template.for + '.' + template.type
};
});
var CohortColumnModel = function (_ColumnModel) {
inherits(CohortColumnModel, _ColumnModel);
function CohortColumnModel() {
classCallCheck(this, CohortColumnModel);
var _this = possibleConstructorReturn(this, (CohortColumnModel.__proto__ || Object.getPrototypeOf(CohortColumnModel)).call(this, 'cohort'));
_this.key = '$cohort';
_this.canEdit = false;
_this.canSort = false;
_this.canResize = false;
_this.canFocus = false;
_this.canFilter = false;
_this.class = 'cohort';
return _this;
}
return CohortColumnModel;
}(ColumnModel);
var CohortColumn = function (_ColumnView) {
inherits(CohortColumn, _ColumnView);
function CohortColumn(model) {
classCallCheck(this, CohortColumn);
return possibleConstructorReturn(this, (CohortColumn.__proto__ || Object.getPrototypeOf(CohortColumn)).call(this, model));
}
createClass(CohortColumn, null, [{
key: 'model',
value: function model(_model) {
return _model ? CohortColumn.assign(_model) : new CohortColumnModel();
}
}]);
return CohortColumn;
}(ColumnView);
TemplatePath.register('currency-cell', function (template, column) {
return {
model: template.for,
resource: column.key
};
});
TemplatePath.register('currency-cell-edit', function (template, column) {
return {
model: 'edit',
resource: column.key
};
});
var CurrencyColumnModel = function (_DataColumnModel) {
inherits(CurrencyColumnModel, _DataColumnModel);
function CurrencyColumnModel() {
classCallCheck(this, CurrencyColumnModel);
var _this = possibleConstructorReturn(this, (CurrencyColumnModel.__proto__ || Object.getPrototypeOf(CurrencyColumnModel)).call(this, 'currency'));
_this.maxLength = 20;
_this.symbol = '$';
_this.code = 'USD';
return _this;
}
return CurrencyColumnModel;
}(DataColumnModel);
var CurrencyColumn = function (_ColumnView) {
inherits(CurrencyColumn, _ColumnView);
function CurrencyColumn(model) {
classCallCheck(this, CurrencyColumn);
return possibleConstructorReturn(this, (CurrencyColumn.__proto__ || Object.getPrototypeOf(CurrencyColumn)).call(this, model));
}
createClass(CurrencyColumn, null, [{
key: 'model',
value: function model(_model) {
return _model ? CurrencyColumn.assign(_model) : new CurrencyColumnModel();
}
}]);
return CurrencyColumn;
}(ColumnView);
TemplatePath.register('date-cell', function (template, column) {
return {
model: template.for,
resource: column.key
};
});
TemplatePath.register('date-cell-edit', function (template, column) {
return {
model: 'edit',
resource: column.key
};
});
var DateColumnModel = function (_DataColumnModel) {
inherits(DateColumnModel, _DataColumnModel);
function DateColumnModel() {
classCallCheck(this, DateColumnModel);
var _this = possibleConstructorReturn(this, (DateColumnModel.__proto__ || Object.getPrototypeOf(DateColumnModel)).call(this, 'date'));
_this.format = 'MM/dd/yyyy';
return _this;
}
return DateColumnModel;
}(DataColumnModel);
var DateColumn = function (_ColumnView) {
inherits(DateColumn, _ColumnView);
function DateColumn(model) {
classCallCheck(this, DateColumn);
return possibleConstructorReturn(this, (DateColumn.__proto__ || Object.getPrototypeOf(DateColumn)).call(this, model));
}
createClass(DateColumn, null, [{
key: 'model',
value: function model(_model) {
return _model ? DateColumn.assign(_model) : new DateColumnModel();
}
}]);
return DateColumn;
}(ColumnView);
TemplatePath.register('email-cell', function (template, column) {
return {
model: template.for,
resource: column.key
};
});
TemplatePath.register('email-cell-edit', function (template, column) {
return {
model: 'edit',
resource: column.key
};
});
var EmailColumnModel = function (_DataColumnModel) {
inherits(EmailColumnModel, _DataColumnModel);
function EmailColumnModel() {
classCallCheck(this, EmailColumnModel);
var _this = possibleConstructorReturn(this, (EmailColumnModel.__proto__ || Object.getPrototypeOf(EmailColumnModel)).call(this, 'email'));
_this.editorOptions.trigger = 'custom';
return _this;
}
return EmailColumnModel;
}(DataColumnModel);
var EmailColumn = function (_ColumnView) {
inherits(EmailColumn, _ColumnView);
function EmailColumn(model) {
classCallCheck(this, EmailColumn);
return possibleConstructorReturn(this, (EmailColumn.__proto__ || Object.getPrototypeOf(EmailColumn)).call(this, model));
}
createClass(EmailColumn, null, [{
key: 'model',
value: function model(_model) {
return _model ? EmailColumn.assign(_model) : new EmailColumnModel();
}
}]);
return EmailColumn;
}(ColumnView);
function isImage$1(name) {
return !!name && name.toLowerCase().search(/png|jpg|jpeg|svg/) > -1;
}
TemplatePath.register('file-cell', function (template, column) {
return {
model: template.for,
resource: column.key
};
});
TemplatePath.register('file-cell-edit', function (template, column) {
return {
model: 'edit',
resource: column.key
};
});
var FileColumnModel = function (_DataColumnModel) {
inherits(FileColumnModel, _DataColumnModel);
function FileColumnModel() {
classCallCheck(this, FileColumnModel);
var _this = possibleConstructorReturn(this, (FileColumnModel.__proto__ || Object.getPrototypeOf(FileColumnModel)).call(this, 'file'));
_this.canUpload = yes;
_this.editorOptions.trigger = 'custom';
_this.hasPreview = function (name) {
return isImage$1(name);
};
_this.canSort = false;
_this.canFilter = false;
return _this;
}
return FileColumnModel;
}(DataColumnModel);
var FileColumn = function (_ColumnView) {
inherits(FileColumn, _ColumnView);
function FileColumn(model) {
classCallCheck(this, FileColumn);
return possibleConstructorReturn(this, (FileColumn.__proto__ || Object.getPrototypeOf(FileColumn)).call(this, model));
}
createClass(FileColumn, null, [{
key: 'model',
value: function model(_model) {
return _model ? FileColumn.assign(_model) : new FileColumnModel();
}
}]);
return FileColumn;
}(ColumnView);
TemplatePath.register('group-cell', function (template, column) {
return {
model: template.for,
resource: column.type
};
});
TemplatePath.register('group-cell-edit', function (template, column) {
return {
model: 'edit',
resource: column.key
};
});
var GroupColumnModel = function (_ColumnModel) {
inherits(GroupColumnModel, _ColumnModel);
function GroupColumnModel() {
classCallCheck(this, GroupColumnModel);
var _this = possibleConstructorReturn(this, (GroupColumnModel.__proto__ || Object.getPrototypeOf(GroupColumnModel)).call(this, 'group'));
_this.key = '$group';
_this.path = 'key';
_this.labelPath = 'key';
_this.title = 'Group';
_this.offset = 24;
_this.canEdit = false;
_this.canSort = false;
_this.canFilter = false;
_this.class = 'control';
_this.by = null;
_this.label = function (node) {
if (node.type === 'row') {
return '';
}
var by = this.by,
labelPath = this.labelPath;
return !by || by === node.source ? node[labelPath] : '';
};
return _this;
}
return GroupColumnModel;
}(ColumnModel);
var GroupColumn = function (_ColumnView) {
inherits(GroupColumn, _ColumnView);
function GroupColumn(model) {
classCallCheck(this, GroupColumn);
return possibleConstructorReturn(this, (GroupColumn.__proto__ || Object.getPrototypeOf(GroupColumn)).call(this, model));
}
createClass(GroupColumn, null, [{
key: 'model',
value: function model(_model) {
return _model ? GroupColumn.assign(_model) : new GroupColumnModel();
}
}]);
return GroupColumn;
}(ColumnView);
TemplatePath.register('group-summary-cell', function (template, column) {
return {
model: template.for,
resource: column.key
};
});
var GroupSummaryColumnModel = function (_DataColumnModel) {
inherits(GroupSummaryColumnModel, _DataColumnModel);
function GroupSummaryColumnModel() {
classCallCheck(this, GroupSummaryColumnModel);
var _this = possibleConstructorReturn(this, (GroupSummaryColumnModel.__proto__ || Object.getPrototypeOf(GroupSummaryColumnModel)).call(this, 'group-summary'));
_this.key = '$group.summary';
_this.class = 'control';
_this.canEdit = false;
_this.canResize = false;
_this.canHighlight = false;
_this.canFilter = false;
_this.canSort = false;
_this.canMove = false;
return _this;
}
return GroupSummaryColumnModel;
}(DataColumnModel);
var GroupSummaryColumn = function (_ColumnView) {
inherits(GroupSummaryColumn, _ColumnView);
function GroupSummaryColumn(model) {
classCallCheck(this, GroupSummaryColumn);
return possibleConstructorReturn(this, (GroupSummaryColumn.__proto__ || Object.getPrototypeOf(GroupSummaryColumn)).call(this, model));
}
createClass(GroupSummaryColumn, null, [{
key: 'model',
value: function model(_model) {
return _model ? GroupSummaryColumn.assign(_model) : new GroupSummaryColumnModel();
}
}]);
return GroupSummaryColumn;
}(ColumnView);
TemplatePath.register('id-cell', function (template, column) {
return {
model: template.for,
resource: column.key
};
});
TemplatePath.register('id-cell-edit', function (template, column) {
return {
model: 'edit',
resource: column.key
};
});
var IdColumnModel = function (_DataColumnModel) {
inherits(IdColumnModel, _DataColumnModel);
function IdColumnModel() {
classCallCheck(this, IdColumnModel);
return possibleConstructorReturn(this, (IdColumnModel.__proto__ || Object.getPrototypeOf(IdColumnModel)).call(this, 'id'));
}
return IdColumnModel;
}(DataColumnModel);
var IdColumn = function (_ColumnView) {
inherits(IdColumn, _ColumnView);
function IdColumn(model) {
classCallCheck(this, IdColumn);
return possibleConstructorReturn(this, (IdColumn.__proto__ || Object.getPrototypeOf(IdColumn)).call(this, model));
}
createClass(IdColumn, null, [{
key: 'model',
value: function model(_model) {
return _model ? IdColumn.assign(_model) : new IdColumnModel();
}
}]);
return IdColumn;
}(ColumnView);
TemplatePath.register('image-cell', function (template, column) {
return {
model: template.for,
resource: column.key
};
});
TemplatePath.register('image-cell-edit', function (template, column) {
return {
model: 'edit',
resource: column.key
};
});
var ImageColumnModel = function (_DataColumnModel) {
inherits(ImageColumnModel, _DataColumnModel);
function ImageColumnModel() {
classCallCheck(this, ImageColumnModel);
var _this = possibleConstructorReturn(this, (ImageColumnModel.__proto__ || Object.getPrototypeOf(ImageColumnModel)).call(this, 'image'));
_this.canSort = false;
_this.canFilter = false;
_this.canUpload = yes;
_this.hasPreview = function (name) {
return isImage$1(name);
};
return _this;
}
return ImageColumnModel;
}(DataColumnModel);
var ImageColumn = function (_ColumnView) {
inherits(ImageColumn, _ColumnView);
function ImageColumn(model) {
classCallCheck(this, ImageColumn);
return possibleConstructorReturn(this, (ImageColumn.__proto__ || Object.getPrototypeOf(ImageColumn)).call(this, model));
}
createClass(ImageColumn, null, [{
key: 'model',
value: function model(_model) {
return _model ? ImageColumn.assign(_model) : new ImageColumnModel();
}
}]);
return ImageColumn;
}(ColumnView);
TemplatePath.register('number-cell', function (template, column) {
return {
model: template.for,
resource: column.key
};
});
TemplatePath.register('number-cell-edit', function (template, column) {
return {
model: 'edit',
resource: column.key
};
});
var NumberColumnModel = function (_DataColumnModel) {
inherits(NumberColumnModel, _DataColumnModel);
function NumberColumnModel() {
classCallCheck(this, NumberColumnModel);
var _this = possibleConstructorReturn(this, (NumberColumnModel.__proto__ || Object.getPrototypeOf(NumberColumnModel)).call(this, 'number'));
_this.format = '';
return _this;
}
return NumberColumnModel;
}(DataColumnModel);
var NumberColumn = function (_ColumnView) {
inherits(NumberColumn, _ColumnView);
function NumberColumn(model) {
classCallCheck(this, NumberColumn);
return possibleConstructorReturn(this, (NumberColumn.__proto__ || Object.getPrototypeOf(NumberColumn)).call(this, model));
}
createClass(NumberColumn, null, [{
key: 'model',
value: function model(_model) {
return _model ? NumberColumn.assign(_model) : new NumberColumnModel();
}
}]);
return NumberColumn;
}(ColumnView);
TemplatePath.register('pad-cell', function (template) {
return {
model: template.for,
resource: template.for + '.' + template.type
};
});
var PadColumnModel = function (_ColumnModel) {
inherits(PadColumnModel, _ColumnModel);
function PadColumnModel() {
classCallCheck(this, PadColumnModel);
var _this = possibleConstructorReturn(this, (PadColumnModel.__proto__ || Object.getPrototypeOf(PadColumnModel)).call(this, 'pad'));
_this.key = '$pad';
_this.class = 'markup';
_this.title = '';
_this.canEdit = false;
_this.canSort = false;
_this.canResize = false;
_this.canHighlight = false;
_this.canFocus = false;
_this.canMove = false;
_this.canFilter = false;
_this.source = 'generation';
return _this;
}
return PadColumnModel;
}(ColumnModel);
var PadColumn = function (_ColumnView) {
inherits(PadColumn, _ColumnView);
function PadColumn(model) {
classCallCheck(this, PadColumn);
return possibleConstructorReturn(this, (PadColumn.__proto__ || Object.getPrototypeOf(PadColumn)).call(this, model));
}
createClass(PadColumn, null, [{
key: 'model',
value: function model(_model) {
return _model ? PadColumn.assign(_model) : new PadColumnModel();
}
}]);
return PadColumn;
}(ColumnView);
TemplatePath.register('password-cell', function (template, column) {
return {
model: template.for,
resource: column.key
};
});
TemplatePath.register('password-cell-edit', function (template, column) {
return {
model: 'edit',
resource: column.key
};
});
var PasswordColumnModel = function (_DataColumnModel) {
inherits(PasswordColumnModel, _DataColumnModel);
function PasswordColumnModel() {
classCallCheck(this, PasswordColumnModel);
var _this = possibleConstructorReturn(this, (PasswordColumnModel.__proto__ || Object.getPrototypeOf(PasswordColumnModel)).call(this, 'password'));
_this.canSort = false;
_this.canFilter = false;
return _this;
}
return PasswordColumnModel;
}(DataColumnModel);
var PasswordColumn = function (_ColumnView) {
inherits(PasswordColumn, _ColumnView);
function PasswordColumn(model) {
classCallCheck(this, PasswordColumn);
return possibleConstructorReturn(this, (PasswordColumn.__proto__ || Object.getPrototypeOf(PasswordColumn)).call(this, model));
}
createClass(PasswordColumn, null, [{
key: 'model',
value: function model(_model) {
return _model ? PasswordColumn.assign(_model) : new PasswordColumnModel();
}
}]);
return PasswordColumn;
}(ColumnView);
TemplatePath.register('pivot-cell', function (template) {
return {
model: 'pivot',
resource: template.for
};
});
var PivotColumnModel = function (_ColumnModel) {
inherits(PivotColumnModel, _ColumnModel);
function PivotColumnModel() {
classCallCheck(this, PivotColumnModel);
var _this = possibleConstructorReturn(this, (PivotColumnModel.__proto__ || Object.getPrototypeOf(PivotColumnModel)).call(this, 'pivot'));
_this.key = '$pivot';
_this.title = 'Pivot';
_this.source = 'generation';
_this.class = 'pivot';
_this.canEdit = false;
_this.canSort = false;
_this.canResize = false;
_this.canFilter = false;
_this.canMove = false;
return _this;
}
return PivotColumnModel;
}(ColumnModel);
var PivotColumn = function (_ColumnView) {
inherits(PivotColumn, _ColumnView);
function PivotColumn(model) {
classCallCheck(this, PivotColumn);
return possibleConstructorReturn(this, (PivotColumn.__proto__ || Object.getPrototypeOf(PivotColumn)).call(this, model));
}
createClass(PivotColumn, null, [{
key: 'model',
value: function model(_model) {
return _model ? PivotColumn.assign(_model) : new PivotColumnModel();
}
}]);
return PivotColumn;
}(ColumnView);
TemplatePath.register('reference-cell', function (template, column) {
return {
model: template.for,
resource: column.key
};
});
TemplatePath.register('reference-cell-edit', function (template, column) {
return {
model: 'edit',
resource: column.key
};
});
var ReferenceColumnModel = function (_DataColumnModel) {
inherits(ReferenceColumnModel, _DataColumnModel);
function ReferenceColumnModel() {
classCallCheck(this, ReferenceColumnModel);
var _this = possibleConstructorReturn(this, (ReferenceColumnModel.__proto__ || Object.getPrototypeOf(ReferenceColumnModel)).call(this, 'reference'));
_this.editorOptions.trigger = 'custom';
return _this;
}
return ReferenceColumnModel;
}(DataColumnModel);
var ReferenceColumn = function (_ColumnView) {
inherits(ReferenceColumn, _ColumnView);
function ReferenceColumn(model) {
classCallCheck(this, ReferenceColumn);
return possibleConstructorReturn(this, (ReferenceColumn.__proto__ || Object.getPrototypeOf(ReferenceColumn)).call(this, model));
}
createClass(ReferenceColumn, null, [{
key: 'model',
value: function model(_model) {
return _model ? ReferenceColumn.assign(_model) : new ReferenceColumnModel();
}
}]);
return ReferenceColumn;
}(ColumnView);
TemplatePath.register('row-details-cell', function (template, column) {
return {
model: template.for,
resource: column.key
};
});
var RowDetailsColumnModel = function (_ColumnModel) {
inherits(RowDetailsColumnModel, _ColumnModel);
function RowDetailsColumnModel() {
classCallCheck(this, RowDetailsColumnModel);
var _this = possibleConstructorReturn(this, (RowDetailsColumnModel.__proto__ || Object.getPrototypeOf(RowDetailsColumnModel)).call(this, 'row-details'));
_this.key = '$row.details';
_this.class = 'control';
_this.canEdit = false;
_this.canResize = false;
_this.canHighlight = false;
_this.canFilter = false;
_this.canSort = false;
_this.canMove = false;
return _this;
}
return RowDetailsColumnModel;
}(ColumnModel);
var RowDetailsColumn = function (_ColumnView) {
inherits(RowDetailsColumn, _ColumnView);
function RowDetailsColumn(model) {
classCallCheck(this, RowDetailsColumn);
return possibleConstructorReturn(this, (RowDetailsColumn.__proto__ || Object.getPrototypeOf(RowDetailsColumn)).call(this, model));
}
createClass(RowDetailsColumn, null, [{
key: 'model',
value: function model(_model) {
return _model ? RowDetailsColumn.assign(_model) : new RowDetailsColumnModel();
}
}]);
return RowDetailsColumn;
}(ColumnView);
TemplatePath.register('row-expand-cell', function (template, column) {
return {
model: template.for,
resource: column.key
};
});
var RowExpandColumnModel = function (_ColumnModel) {
inherits(RowExpandColumnModel, _ColumnModel);
function RowExpandColumnModel() {
classCallCheck(this, RowExpandColumnModel);
var _this = possibleConstructorReturn(this, (RowExpandColumnModel.__proto__ || Object.getPrototypeOf(RowExpandColumnModel)).call(this, 'row-expand'));
_this.key = '$row.expand';
_this.class = 'control';
_this.canEdit = false;
_this.canResize = false;
_this.canFilter = false;
_this.canSort = false;
_this.canHighlight = false;
_this.canMove = false;
return _this;
}
return RowExpandColumnModel;
}(ColumnModel);
var RowExpandColumn = function (_ColumnView) {
inherits(RowExpandColumn, _ColumnView);
function RowExpandColumn(model) {
classCallCheck(this, RowExpandColumn);
return possibleConstructorReturn(this, (RowExpandColumn.__proto__ || Object.getPrototypeOf(RowExpandColumn)).call(this, model));
}
createClass(RowExpandColumn, null, [{
key: 'model',
value: function model(_model) {
return _model ? RowExpandColumn.assign(_model) : new RowExpandColumnModel();
}
}]);
return RowExpandColumn;
}(ColumnView);
TemplatePath.register('row-indicator-cell', function (template, column) {
return {
model: template.for,
resource: column.key
};
});
var RowIndicatorColumnModel = function (_ColumnModel) {
inherits(RowIndicatorColumnModel, _ColumnModel);
function RowIndicatorColumnModel() {
classCallCheck(this, RowIndicatorColumnModel);
var _this = possibleConstructorReturn(this, (RowIndicatorColumnModel.__proto__ || Object.getPrototypeOf(RowIndicatorColumnModel)).call(this, 'row-indicator'));
_this.key = '$row.indicator';
_this.class = 'control';
_this.canEdit = false;
_this.canSort = false;
_this.canResize = false;
_this.canMove = false;
_this.canFocus = false;
_this.canHighlight = false;
_this.canFilter = false;
_this.pin = 'left';
return _this;
}
return RowIndicatorColumnModel;
}(ColumnModel);
var RowIndicatorColumn = function (_ColumnView) {
inherits(RowIndicatorColumn, _ColumnView);
function RowIndicatorColumn(model) {
classCallCheck(this, RowIndicatorColumn);
return possibleConstructorReturn(this, (RowIndicatorColumn.__proto__ || Object.getPrototypeOf(RowIndicatorColumn)).call(this, model));
}
createClass(RowIndicatorColumn, null, [{
key: 'model',
value: function model(_model) {
return _model ? RowIndicatorColumn.assign(_model) : new RowIndicatorColumnModel();
}
}]);
return RowIndicatorColumn;
}(ColumnView);
TemplatePath.register('row-number-cell', function (template, column) {
return {
model: template.for,
resource: column.key
};
});
var RowNumberColumnModel = function (_ColumnModel) {
inherits(RowNumberColumnModel, _ColumnModel);
function RowNumberColumnModel() {
classCallCheck(this, RowNumberColumnModel);
var _this = possibleConstructorReturn(this, (RowNumberColumnModel.__proto__ || Object.getPrototypeOf(RowNumberColumnModel)).call(this, 'row-number'));
_this.pin = 'left';
_this.key = '$row.number';
_this.title = 'No.';
_this.canEdit = false;
_this.canResize = true;
_this.canFocus = false;
_this.canMove = false;
_this.canHighlight = false;
_this.canSort = false;
_this.canFilter = false;
_this.class = 'control';
return _this;
}
return RowNumberColumnModel;
}(ColumnModel);
var RowNumberColumn = function (_ColumnView) {
inherits(RowNumberColumn, _ColumnView);
function RowNumberColumn(model) {
classCallCheck(this, RowNumberColumn);
return possibleConstructorReturn(this, (RowNumberColumn.__proto__ || Object.getPrototypeOf(RowNumberColumn)).call(this, model));
}
createClass(RowNumberColumn, null, [{
key: 'model',
value: function model(_model) {
return _model ? RowNumberColumn.assign(_model) : new RowNumberColumnModel();
}
}]);
return RowNumberColumn;
}(ColumnView);
TemplatePath.register('row-options-cell', function (template, column) {
return {
model: template.for,
resource: column.key
};
});
TemplatePath.register('row-options-cell-edit', function (template, column) {
return {
model: 'edit',
resource: column.key
};
});
var RowOptionsColumnModel = function (_DataColumnModel) {
inherits(RowOptionsColumnModel, _DataColumnModel);
function RowOptionsColumnModel() {
classCallCheck(this, RowOptionsColumnModel);
var _this = possibleConstructorReturn(this, (RowOptionsColumnModel.__proto__ || Object.getPrototypeOf(RowOptionsColumnModel)).call(this, 'row-options'));
_this.key = '$row.options';
_this.class = 'control';
_this.canEdit = true;
_this.canResize = false;
_this.canMove = false;
_this.canHighlight = false;
_this.canFilter = false;
_this.pin = 'right';
return _this;
}
return RowOptionsColumnModel;
}(DataColumnModel);
var RowOptionsColumn = function (_ColumnView) {
inherits(RowOptionsColumn, _ColumnView);
function RowOptionsColumn(model) {
classCallCheck(this, RowOptionsColumn);
return possibleConstructorReturn(this, (RowOptionsColumn.__proto__ || Object.getPrototypeOf(RowOptionsColumn)).call(this, model));
}
createClass(RowOptionsColumn, null, [{
key: 'model',
value: function model(_model) {
return _model ? RowOptionsColumn.assign(_model) : new RowOptionsColumnModel();
}
}]);
return RowOptionsColumn;
}(ColumnView);
TemplatePath.register('select-cell', function (template, column) {
return {
model: template.for,
resource: column.key
};
});
TemplatePath.register('select-cell-edit', function (template, column) {
return {
model: 'edit',
resource: column.key
};
});
var SelectColumnModel = function (_ColumnModel) {
inherits(SelectColumnModel, _ColumnModel);
function SelectColumnModel() {
classCallCheck(this, SelectColumnModel);
var _this = possibleConstructorReturn(this, (SelectColumnModel.__proto__ || Object.getPrototypeOf(SelectColumnModel)).call(this, 'select'));
_this.key = '$select';
_this.title = '';
_this.class = 'control';
_this.canEdit = false;
_this.editorOptions.cruise = 'transparent';
_this.value = noop$1;
_this.canResize = false;
return _this;
}
return SelectColumnModel;
}(ColumnModel);
var SelectColumn = function (_ColumnView) {
inherits(SelectColumn, _ColumnView);
function SelectColumn(model) {
classCallCheck(this, SelectColumn);
return possibleConstructorReturn(this, (SelectColumn.__proto__ || Object.getPrototypeOf(SelectColumn)).call(this, model));
}
createClass(SelectColumn, null, [{
key: 'model',
value: function model(_model) {
return _model ? SelectColumn.assign(_model) : new SelectColumnModel();
}
}]);
return SelectColumn;
}(ColumnView);
TemplatePath.register('text-cell', function (template, column) {
return {
model: template.for,
resource: column.key
};
});
TemplatePath.register('text-cell-edit', function (template, column) {
return {
model: 'edit',
resource: column.key
};
});
TemplatePath.register('text-area-cell-edit', function (template, column) {
return {
model: 'edit',
resource: column.key
};
});
var TextColumnModel = function (_DataColumnModel) {
inherits(TextColumnModel, _DataColumnModel);
function TextColumnModel() {
classCallCheck(this, TextColumnModel);
var _this = possibleConstructorReturn(this, (TextColumnModel.__proto__ || Object.getPrototypeOf(TextColumnModel)).call(this, 'text'));
_this.maxLength = 140;
return _this;
}
return TextColumnModel;
}(DataColumnModel);
var TextColumn = function (_ColumnView) {
inherits(TextColumn, _ColumnView);
function TextColumn(model) {
classCallCheck(this, TextColumn);
return possibleConstructorReturn(this, (TextColumn.__proto__ || Object.getPrototypeOf(TextColumn)).call(this, model));
}
createClass(TextColumn, null, [{
key: 'model',
value: function model(_model) {
return _model ? TextColumn.assign(_model) : new TextColumnModel();
}
}]);
return TextColumn;
}(ColumnView);
TemplatePath.register('time-cell', function (template, column) {
return {
model: template.for,
resource: column.key
};
});
TemplatePath.register('time-cell-edit', function (template, column) {
return {
model: 'edit',
resource: column.key
};
});
var TimeColumnModel = function (_DataColumnModel) {
inherits(TimeColumnModel, _DataColumnModel);
function TimeColumnModel() {
classCallCheck(this, TimeColumnModel);
var _this = possibleConstructorReturn(this, (TimeColumnModel.__proto__ || Object.getPrototypeOf(TimeColumnModel)).call(this, 'time'));
_this.format = 'h:mm a';
return _this;
}
return TimeColumnModel;
}(DataColumnModel);
var TimeColumn = function (_ColumnView) {
inherits(TimeColumn, _ColumnView);
function TimeColumn(model) {
classCallCheck(this, TimeColumn);
return possibleConstructorReturn(this, (TimeColumn.__proto__ || Object.getPrototypeOf(TimeColumn)).call(this, model));
}
createClass(TimeColumn, null, [{
key: 'model',
value: function model(_model) {
return _model ? TimeColumn.assign(_model) : new TimeColumnModel();
}
}]);
return TimeColumn;
}(ColumnView);
TemplatePath.register('url-cell', function (template, column) {
return {
model: template.for,
resource: column.key
};
});
TemplatePath.register('url-cell-edit', function (template, column) {
return {
model: 'edit',
resource: column.key
};
});
var UrlColumnModel = function (_DataColumnModel) {
inherits(UrlColumnModel, _DataColumnModel);
function UrlColumnModel() {
classCallCheck(this, UrlColumnModel);
var _this = possibleConstructorReturn(this, (UrlColumnModel.__proto__ || Object.getPrototypeOf(UrlColumnModel)).call(this, 'url'));
_this.editorOptions.trigger = 'custom';
return _this;
}
return UrlColumnModel;
}(DataColumnModel);
var UrlColumn = function (_ColumnView) {
inherits(UrlColumn, _ColumnView);
function UrlColumn(model) {
classCallCheck(this, UrlColumn);
return possibleConstructorReturn(this, (UrlColumn.__proto__ || Object.getPrototypeOf(UrlColumn)).call(this, model));
}
createClass(UrlColumn, null, [{
key: 'model',
value: function model(_model) {
return _model ? UrlColumn.assign(_model) : new UrlColumnModel();
}
}]);
return UrlColumn;
}(ColumnView);
function merge$1(target, source) {
if (target && source) {
return assignWith(target, source, function (s, t) {
return isUndefined(s) ? t : s;
});
}
return target || clone(source);
}
function columnFactory(model) {
var columnList = model.columnList;
var columnMap = {
'array': ArrayColumn,
'bool': BoolColumn,
'cohort': CohortColumn,
'currency': CurrencyColumn,
'custom': ColumnView,
'date': DateColumn,
'email': EmailColumn,
'file': FileColumn,
'group': GroupColumn,
'id': IdColumn,
'image': ImageColumn,
'number': NumberColumn,
'pad': PadColumn,
'password': PasswordColumn,
'pivot': PivotColumn,
'reference': ReferenceColumn,
'row-details': RowDetailsColumn,
'row-expand': RowExpandColumn,
'row-indicator': RowIndicatorColumn,
'row-number': RowNumberColumn,
'row-options': RowOptionsColumn,
'select': SelectColumn,
'group-summary': GroupSummaryColumn,
'text': TextColumn,
'time': TimeColumn,
'url': UrlColumn
};
var create = function create(entityType, columnType, body) {
var Type = columnMap[entityType];
var _columnList = columnList(),
reference = _columnList.reference;
var defaultSettings = reference['$default'];
body = merge$1(body, defaultSettings);
var typeSettings = reference[columnType];
body = merge$1(body, typeSettings);
var model = Type.model(body);
return new Type(model);
};
return function (type) {
var body = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
if (!type) {
type = 'text';
}
if (columnMap.hasOwnProperty(type)) {
return create(type, type, body);
}
return create('custom', type, body);
};
}
function merge$2(settings) {
var context = assignWith({
equals: function equals(l, r) {
return l === r;
},
update: function update(l, r /*left, i*/) {
assignWith(l, r);
return l;
},
remove: function remove(l, left, i) {
left.splice(i, 1);
return l;
},
insert: function insert(r, left) {
left.push(r);
return r;
}
}, settings);
return function (left, right, result) {
var ls = left.slice();
var rs = right.slice();
var updated = 0;
var removed = 0;
result = result || left;
for (var i = 0, lsLength = ls.length; i < lsLength; i++) {
var l = ls[i];
var matched = false;
for (var j = 0, rsLength = rs.length; j < rsLength; j++) {
var r = rs[j];
if (context.equals(l, r, i, j)) {
context.update(l, r, result, result.indexOf(l));
updated++;
matched = true;
rs.splice(j, 1);
break;
}
}
if (!matched) {
context.remove(l, result, result.indexOf(l));
removed++;
}
}
var inserted = rs.length;
for (var _i = 0; _i < inserted; _i++) {
context.insert(rs[_i], result);
}
if (context.sort) {
left.sort(context.sort(left, right));
}
return { updated: updated, removed: removed, inserted: inserted };
};
}
// TODO: right now we check the empty result on null, we need to have a way to make it more explicitly
function parseFactory(type, editor) {
switch (type) {
case 'id':
{
type = editor ? editor : 'text';
break;
}
}
switch (type) {
case 'text':
case 'email':
case 'url':
case 'password':
return parseText;
case 'number':
case 'currency':
return parseNumber;
case 'time':
case 'date':
return parseDate;
case 'bool':
return parseBool;
case 'array':
return parseArray;
default:
return identity$1;
}
}
function getType(value) {
if (isArray(value)) {
if (value.length) {
var itemType = getType(value[0]);
if (!isPrimitive(itemType)) {
return 'collection';
}
}
return 'array';
}
if (parseNumber(value) !== null && !isNaN(value)) {
return 'number';
}
if (parseBool(value) !== null) {
return 'bool';
}
if (parseDate(value) !== null) {
return 'date';
}
if (isEmail(value)) {
return 'email';
}
if (isImage(value)) {
return 'image';
}
if (isUrl(value)) {
return 'url';
}
if (isString(value)) {
return 'text';
}
if (isObject(value)) {
return 'object';
}
return 'text';
}
function isPrimitive(type) {
switch (type) {
case 'date':
case 'bool':
case 'text':
case 'number':
case 'email':
case 'url':
return true;
default:
return false;
}
}
function parseBool(value) {
return isBoolean(value) ? value : value === 'true' ? true : value === 'false' ? false : null;
}
function parseText(value) {
return value !== null ? '' + value : null;
}
function parseDate(value) {
if (value === null) {
return null;
}
if (value instanceof Date) {
return value;
}
value = '' + value;
var m = value.match(/^(\d{4})(-(\d{2})(-(\d{2})([T ](\d{2}):(\d{2})(:(\d{2})(\.(\d+))?)?(Z|(([-+])(\d{2})(:?(\d{2}))?))?)?)?)?$/);
if (m) {
var utc = Date.UTC(m[1], m[3] ? m[3] - 1 : 0, m[5] || 1, m[7] || 0, m[8] || 0, m[10] || 0, m[12] ? Number('0.' + m[12]) * 1000 : 0);
var date = new Date(utc);
if (m[13]) {
// has gmt offset or Z
if (m[14]) {
// has gmt offset
date.setUTCMinutes(date.getUTCMinutes() + (m[15] == '-' ? 1 : -1) * (Number(m[16]) * 60 + (m[18] ? Number(m[18]) : 0)));
}
}
return date;
}
return null;
}
function parseNumber(value) {
var number = parseFloat(value);
if (!isNaN(number) && isFinite(number)) {
return number;
}
return null;
}
function parseArray(value) {
if (isArray(value)) {
return value;
}
return null;
}
function merge$3(left, right) {
var force = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
var canAssign = void 0;
if (force) {
canAssign = function canAssign(source, target) {
return !isUndefined(target) && target !== null ? target : source;
};
} else {
canAssign = function canAssign(source, target) {
return !isUndefined(target) && target !== null && source === null ? target : source;
};
}
var doMerge = merge$2({
equals: function equals(l, r) {
return l.key === r.key;
},
update: function update(l, r) {
return assignWith(l, r, canAssign);
},
insert: function insert(r, left) {
return left.push(r);
},
remove: noop$1
});
return doMerge(left, right);
}
function hasChanges(statistics) {
return statistics.some(function (st) {
return st.inserted || st.update;
});
}
function generateFactory(model) {
var data = model.data;
var createColumn = columnFactory(model);
return function () {
var _data = data(),
rows = _data.rows;
var htmlColumns = model.columnList().columns;
var spawnColumns = [];
var _model$columnList = model.columnList(),
generation = _model$columnList.generation;
if (generation) {
var settings = {
rows: rows,
columnFactory: createColumn,
deep: false,
cohort: false
};
switch (generation) {
case 'shallow':
{
break;
}
case 'deep':
{
settings.deep = true;
break;
}
case 'cohort':
{
settings.deep = true;
settings.cohort = true;
break;
}
default:
throw new AppError('column.list.generate', 'Invalid generation mode "' + generation + '"');
}
spawnColumns.push.apply(spawnColumns, toConsumableArray(generate(settings)));
}
var columns = Array.from(data().columns);
var statistics = [];
if (spawnColumns.length) {
statistics.push(merge$3(columns, spawnColumns, false));
}
if (htmlColumns.length) {
statistics.push(merge$3(columns, htmlColumns, true));
}
return {
columns: columns,
statistics: statistics,
hasChanges: hasChanges(statistics)
};
};
}
function generate(settings) {
var context = assignWith({
deep: true,
cohort: false,
rows: [],
columnFactory: function columnFactory$$1() {
return new TextColumnModel();
},
title: startCase
}, settings);
if (context.rows.length) {
return build$1(context.rows[0], null, context.columnFactory, context.deep, context.cohort, context.title);
}
return [];
}
function build$1(graph, path, columnFactory$$1, deep, cohort, title) {
var props = Object.getOwnPropertyNames(graph);
return props.reduce(function (memo, prop) {
var propPath = path ? path + '.' + prop : prop;
var value = graph[prop];
var type = getType(value);
switch (type) {
case 'array':
{
var column = columnFactory$$1(type).model;
column.key = propPath;
column.title = title(propPath, graph, column.length);
column.path = propPath;
column.value = compile(propPath);
column.source = 'generation';
if (value.length) {
column.itemType = getType(value[0]);
switch (column.itemType) {
case 'date':
{
column.itemFormat = columnFactory$$1('date').model.format;
break;
}
}
}
memo.push(column);
break;
}
case 'collection':
{
break;
}
case 'object':
{
if (deep) {
var columns = build$1(value, propPath, columnFactory$$1, deep, cohort, title);
if (cohort) {
var _column$children;
var _column = columnFactory$$1('cohort').model;
_column.key = propPath;
_column.title = title(propPath, graph, _column.length);
_column.path = propPath;
_column.value = compile(propPath);
_column.source = 'generation';
(_column$children = _column.children).push.apply(_column$children, toConsumableArray(columns));
memo.push(_column);
} else {
memo.push.apply(memo, toConsumableArray(columns));
}
}
break;
}
default:
{
var _column2 = columnFactory$$1(type).model;
_column2.key = propPath;
_column2.title = title(propPath, graph, _column2.length);
_column2.path = propPath;
_column2.value = compile(propPath);
_column2.source = 'generation';
memo.push(_column2);
break;
}
}
return memo;
}, []);
}
function dataPipe(rows, context, next) {
var model = context.model;
model.pipe({
effect: Object.assign({}, model.pipe().effect, { data: rows })
});
addDataRows(model, rows);
addDataColumns(model);
next(rows);
model.pipe({
effect: Object.assign({}, model.pipe().effect, { data: rows })
}, {
source: 'data.pipe',
behavior: 'core'
});
}
function addDataRows(model, rows) {
model.data({ rows: rows }, { source: 'data.pipe', behavior: 'core' });
}
function addDataColumns(model) {
var getColumns = generateFactory(model);
var createColumn = columnFactory(model);
var result = getColumns();
var columns = result.columns.map(function (columnBody) {
return createColumn(columnBody.type, columnBody).model;
});
if (result.hasChanges) {
model.data({ columns: columns }, { source: 'data.pipe', behavior: 'core' });
}
}
function filterPipe(rows, context, next) {
Guard.notNull(rows, 'rows');
var model = context.model;
var result = [];
if (rows.length) {
var filterState = model.filter();
var test = filterState.match(context);
for (var i = 0, length = rows.length; i < length; i++) {
var row = rows[i];
if (test(row)) {
result.push(row);
}
}
}
model.pipe({
effect: Object.assign({}, model.pipe().effect, { filter: result })
}, {
source: 'filter.pipe',
behavior: 'core'
});
next(result);
}
function paginationPipe(memo, context, next) {
Guard.notNull(memo, 'memo');
var model = context.model;
if (memo.hasOwnProperty('nodes') && memo.nodes.length) {
var _model$group = model.group(),
flattenFactory = _model$group.flattenFactory;
var page = paginate(model, memo.nodes);
var flatten = flattenFactory(model);
memo.rows = flatten(page);
next(memo);
return;
}
if (memo.hasOwnProperty('rows')) {
var _page = paginate(model, memo.rows);
memo.rows = _page;
next(memo);
return;
}
var rows = paginate(model, memo);
next(rows);
}
function paginate(model, rows) {
var _model$pagination = model.pagination(),
size = _model$pagination.size,
current = _model$pagination.current;
var _model$row = model.row(),
pinTop = _model$row.pinTop,
pinBottom = _model$row.pinBottom;
var _model$scroll = model.scroll(),
mode = _model$scroll.mode;
var start = current * size;
var pinned = new Set([].concat(toConsumableArray(pinTop), toConsumableArray(pinBottom)));
if (pinned.size) {
rows = rows.filter(function (row) {
return !pinned.has(row);
});
}
model.pagination({ count: rows.length }, { source: 'pagination.pipe', behavior: 'core' });
return mode === 'virtual' ? rows : rows.slice(start, start + size);
}
var Node$1 = function Node(key) {
var level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'group';
classCallCheck(this, Node);
this.key = key;
this.level = level;
this.rows = [];
this.children = [];
this.type = type;
this.source = null;
this.value = null;
this.state = {
expand: false
};
};
function preOrderDFS(nodes, visit) {
var memo = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
var parent = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
for (var i = 0, length = nodes.length; i < length; i++) {
var node = nodes[i];
var nodeMemo = visit(node, memo, parent, i);
preOrderDFS(node.children, visit, nodeMemo, node);
}
return memo;
}
function filter(node, test) {
var parent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
var _node = node,
children = _node.children;
node = copy(node);
var result = false;
for (var i = 0, length = children.length; i < length; i++) {
var child = children[i];
result = filter(child, test, node) || result;
}
if (parent) {
if (result || test(node)) {
parent.children.push(node);
return true;
}
return false;
}
return node;
}
function findLeaves(node) {
var result = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
var children = node.children;
if (!children.length) {
result.push(node);
return result;
}
for (var i = 0, length = children.length; i < length; i++) {
var child = children[i];
findLeaves(child, result);
}
return result;
}
function find(node, test) {
var parent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
var index = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : -1;
var path = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
if (test(node)) {
return { node: node, parent: parent, index: index, path: path };
}
path = path.slice();
path.push(node);
var children = node.children;
for (var i = 0, length = children.length; i < length; i++) {
var child = children[i];
var result = find(child, test, node, i, path);
if (result) {
return result;
}
}
return null;
}
function calk(node) {
var result = new Node$1(node.key, node.level, node.type);
result.rows = Array.from(node.rows);
result.children = Array.from(node.children);
result.state = cloneDeepWith(node.state);
result.source = node.source;
result.value = node.value;
return result;
}
function copy(node) {
var result = new Node$1(node.key, node.level, node.type);
result.value = node.value;
result.source = node.source;
result.state.expand = node.state.expand;
return result;
}
function bend(line) {
if (line.length === 0) {
throw new AppError('node.service', 'Line have no nodes');
}
var root = copy(line[0]);
var parentStack = [root];
for (var i = 1, length = line.length; i < length; i++) {
var current = line[i];
var parent = parentStack[parentStack.length - 1];
while (current.level <= parent.level) {
parentStack.pop();
parent = parentStack[parentStack.length - 1];
}
var child = copy(current);
child.level = parent.level + 1;
parent.children.push(child);
parentStack.push(child);
}
return root;
}
var key = getKey;
var index = getIndex;
var direction = getDirection;
var map = getMap;
function orderFactory(model) {
var sort = model.sort;
return function (by) {
var _sort = sort(),
trigger = _sort.trigger;
if (trigger.indexOf('reorder') >= 0) {
var _index = 0;
var indexMap = {};
preOrderDFS(model.columnList().index.children, function (node) {
var key = node.key.model.key;
indexMap[key] = _index++;
});
by.sort(function (x, y) {
return indexMap[getKey(x)] - indexMap[getKey(y)];
});
}
return by;
};
}
function getKey(pair) {
var key = void 0;
if (isString(pair)) {
var signedKey = pair.split(/[+-]/);
key = signedKey[1] || signedKey[0];
} else {
key = Object.keys(pair)[0];
}
if (!key) {
throw new AppError('sort.service', 'Key is not defined in "' + pair + '"');
}
return key;
}
function getDirection(pair) {
if (isString(pair)) {
var directions = { '-': 'desc', '+': 'asc' };
return directions[pair[0]] || 'asc';
}
var pairKey = getKey(pair);
return pair[pairKey];
}
function getMap(pairs) {
return pairs.reduce(function (memo, pair) {
var key = getKey(pair);
memo[key] = getDirection(pair);
return memo;
}, {});
}
function getIndex(pairs, key) {
return pairs.map(getKey).findIndex(function (pairKey) {
return pairKey === key;
});
}
function flatten$1(root) {
var rowsToUse = rowsToUseFactory();
function markup(node, rowIndex, columnIndex, rowsLeft, result) {
var view = node.key;
var rowspan = rowsLeft - rowsToUse(node);
view.rowspan = rowspan;
view.rowIndex = rowIndex;
view.columnIndex = columnIndex;
var children = node.children;
if (children.length) {
var width = 0;
var childResult = [];
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = children[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var child = _step.value;
var childView = markup(child, rowIndex + rowspan, columnIndex, rowsLeft - rowspan, childResult);
if (!childView) {
continue;
}
var colspan = childView.colspan;
width += colspan;
columnIndex += colspan;
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
view.colspan = width;
if (width > 0) {
result.push(view);
result.push.apply(result, childResult);
}
} else if (view.model.type !== 'cohort') {
result.push(view);
}
return view;
}
var result = [];
markup(root, 0, 0, rowsToUse(root), result);
// remove root
result.splice(0, 1);
return layout(result);
}
function layout(columns) {
var mx = [];
columns.sort(function (x, y) {
var xc = x.rowIndex - y.rowIndex;
if (xc === 0) {
return x.columnIndex - y.columnIndex;
}
return xc;
});
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = columns[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var column = _step2.value;
if (!mx[column.rowIndex]) {
mx[column.rowIndex] = [];
}
mx[column.rowIndex].push(column);
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
return mx;
}
function rowsToUseFactory() {
var cache = new Map();
return function rowsToUse(node) {
var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
var model = node.key.model;
if (cache.has(model.key)) {
return cache.get(model.key);
}
var children = node.children;
var count = children.length == 0 ? 0 : 1;
var _iteratorNormalCompletion3 = true;
var _didIteratorError3 = false;
var _iteratorError3 = undefined;
try {
for (var _iterator3 = children[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
var child = _step3.value;
count = Math.max(count, rowsToUse(child, depth + 1));
}
} catch (err) {
_didIteratorError3 = true;
_iteratorError3 = err;
} finally {
try {
if (!_iteratorNormalCompletion3 && _iterator3.return) {
_iterator3.return();
}
} finally {
if (_didIteratorError3) {
throw _iteratorError3;
}
}
}
var result = 1 + count;
cache.set(model.key, result);
return result;
};
}
function expand(rows) {
var mx = [];
var offsets = [];
for (var y = 0, height = rows.length; y < height; y++) {
var columns = rows[y];
var offset = offsets.length > y ? offsets[y] : offsets[y] = [0];
for (var x = 0, width = columns.length; x < width; x++) {
var column = columns[x];
var rowspan = column.rowspan,
colspan = column.colspan;
var current = offset[0];
var next = current + colspan;
for (var i = 0; i < rowspan; i++) {
var yi = y + i;
var row = mx.length > yi ? mx[yi] : mx[yi] = [];
for (var j = 0; j < colspan; j++) {
var xj = current + j;
row[xj] = column;
}
var gaps = offsets.length > yi ? offsets[yi] : offsets[yi] = [0];
var index = binarySearch(gaps, current);
if (row[next]) {
gaps.splice(index, 1);
} else {
var xi = gaps[index];
gaps.splice(index, row[xi] ? 1 : 0, next);
}
}
}
}
return mx;
}
function collapse(matrix) {
var line = [];
var height = matrix.length;
if (height) {
var set = new Set();
var lastRow = matrix[height - 1];
var width = lastRow.length;
for (var i = 0; i < width; i++) {
var column = lastRow[i];
if (set.has(column)) {
continue;
}
line.push(column);
set.add(column);
}
}
return line;
}
function flatten$2(columns) {
var result = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
for (var i = 0, length = columns.length; i < length; i++) {
var column = columns[i];
result.push(column);
var children = column.children;
if (children && children.length) {
flatten$2(children, result);
}
}
return result;
}
function findLine(columns, key) {
for (var index = 0, length = columns.length; index < length; index++) {
var column = columns[index];
if (column.key === key) {
return { columns: columns, index: index };
}
var children = column.children;
if (children.length) {
var result = findLine(children, key);
if (result) {
return result;
}
}
}
return null;
}
function map$1(columns) {
return columns.reduce(function (memo, column) {
memo[column.key] = column;
return memo;
}, {});
}
function getValue$2(column) {
return isFunction(column.value) ? function (row) {
return column.value(row);
} : function (row) {
return row[column.key];
};
}
function find$1(columns, key) {
var index = findIndex(columns, key);
return index < 0 ? null : columns[index];
}
function findIndex(columns, key) {
var length = columns.length;
while (length--) {
var column = columns[length];
if (column.key == key) {
return length;
}
}
return -1;
}
function lineView(columnRows) {
var height = columnRows.length;
if (height === 1) {
return Array.from(columnRows[0]);
}
if (height > 1) {
var view = expand(columnRows);
return collapse(view);
}
return [];
}
function widthFactory(table, form) {
var layout = table.model.layout;
var columns = table.data.columns();
var columnMap = map$1(columns);
form = form || layout().columns;
var occupied = columns.filter(function (c) {
return form.has(c.key) || ('' + c.width).indexOf('%') < 0;
}).reduce(function (memo, c) {
var width = getWidth(c);
if (width !== null) {
memo += width;
}
return memo;
}, 0);
var area = void 0;
function getRect() {
if (area) {
return area;
}
area = table.view.rect('head');
return area;
}
function getWidth(column) {
var size = column;
if (form.has(column.key)) {
size = form.get(column.key);
}
var width = size.width;
if (width || width === 0) {
if (('' + width).indexOf('%') >= 0) {
var percent = parseFloat(width);
var rect = getRect();
// 2 because pad column has left padding equals to 1px and width 100%
// that can produce 1.## values
var padSkip = 2;
var skip = column.widthMode === 'relative' ? occupied + padSkip : padSkip;
width = (rect.width - skip) * percent / 100;
}
return Math.max(parseInt(width), parseInt(column.minWidth));
}
return null;
}
return function (key) {
var column = columnMap[key];
if (!column) {
throw new AppError('column.service', 'Column ' + key + ' is not found');
}
return getWidth(column);
};
}
function sortPipe(rows, context, next) {
Guard.notNull(rows, 'rows');
var model = context.model;
var result = rows;
if (rows.length) {
var _model$sort = model.sort(),
by = _model$sort.by;
if (by.length) {
var columns = model.columnList().line;
var mappings = [];
var comparers = [];
var _loop = function _loop(i, length) {
var sortEntry = by[i];
var sortKey = key(sortEntry);
var sortDir = direction(sortEntry);
var sortColumn = find$1(columns, sortKey);
if (!sortColumn) {
throw new AppError('sort.pipe', 'Column "' + sortKey + '" is not found');
}
var getValue = context.valueFactory(sortColumn);
var parseValue = parseFactory(sortColumn.type, sortColumn.editor);
var compare$$1 = sortColumn.compare;
mappings.push(function (row) {
var value = getValue(row);
var result = parseValue(value);
return result === null ? value : result;
});
comparers.push(sortDir === 'asc' ? compare$$1 : function (x, y) {
return -compare$$1(x, y);
});
};
for (var i = 0, length = by.length; i < length; i++) {
_loop(i, length);
}
result = orderBy(rows, mappings, comparers);
}
}
model.pipe({
effect: Object.assign({}, model.pipe().effect, { sort: result })
}, {
source: 'sort.pipe',
behavior: 'core'
});
next(result);
}
function memoPipe(rows, context, next) {
Guard.notNull(rows, 'rows');
var model = context.model;
model.pipe({
effect: Object.assign({}, model.pipe().effect, { memo: rows })
}, {
source: 'memo.pipe',
behavior: 'core'
});
next({
rows: rows,
pivot: { head: new Node$1('$root', 0), rows: [] },
nodes: []
});
}
function nodeBuilder(columnMap, groupBy, valueFactory) {
var level = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
if (groupBy.length === 0) {
return function () {
return [];
};
}
var groupKey = groupBy[0];
if (!columnMap.hasOwnProperty(groupKey)) {
throw new AppError('node.build', 'can\'t find column "' + groupKey + '"');
}
var column = columnMap[groupKey];
var getValue = valueFactory(column);
return function (rows) {
var getRowIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (i) {
return i;
};
var keys = [];
var nodes = [];
var groups = {};
for (var i = 0, length = rows.length; i < length; i++) {
var row = rows[i];
var index = getRowIndex(i);
var key = getValue(row);
if (!groups.hasOwnProperty(key)) {
var node = new Node$1(key, level);
node.source = groupKey;
node.rows.push(index);
keys.push(key);
nodes.push(node);
groups[key] = {
node: node,
rows: [row]
};
} else {
var group = groups[key];
group.node.rows.push(index);
group.rows.push(row);
keys.push(key);
}
}
var nextGroupBy = groupBy.slice(1);
if (nextGroupBy.length) {
var build = nodeBuilder(columnMap, nextGroupBy, valueFactory, level + 1);
var _loop = function _loop(_i, _length) {
var key = keys[_i];
var group = groups[key];
var node = group.node;
var rows = node.rows;
node.children = build(group.rows, function (i) {
return rows[i];
});
};
for (var _i = 0, _length = keys.length; _i < _length; _i++) {
_loop(_i, _length);
}
}
return nodes;
};
}
function groupPipe(memo, context, next) {
Guard.notNull(memo, 'rows');
var model = context.model;
if (memo.rows.length) {
var _model$data = model.data(),
rows = _model$data.rows;
var _model$group = model.group(),
by = _model$group.by;
var columns = model.columnList().line;
var columnMap = map$1(columns);
var build = nodeBuilder(columnMap, by, context.valueFactory);
var memoRows = memo.rows;
memo.nodes = build(memoRows, function (i) {
var row = memoRows[i];
var index = rows.indexOf(row);
return index < 0 ? i : index;
});
}
model.pipe({
effect: Object.assign({}, model.pipe().effect, { group: memo.nodes })
}, {
source: 'group.pipe',
behavior: 'core'
});
next(memo);
}
var Plan = function () {
function Plan(schema) {
classCallCheck(this, Plan);
this.isRoot = !arguments.length;
this.current = this.schema = schema || {};
}
createClass(Plan, [{
key: "branch",
value: function branch() {
return new Plan(this.current);
}
}, {
key: "cursor",
value: function cursor(name) {
var schema = this.schema;
this.current = schema.hasOwnProperty(name) ? schema[name] : schema[name] = {};
}
}, {
key: "compile",
value: function compile(data) {
if (this.isRoot) {
return {
schema: this.schema,
data: data
};
} else {
return data;
}
}
}]);
return Plan;
}();
function factory(plan) {
return function (name) {
plan.cursor(name);
return function (settings) {
return pivot(settings, plan.branch());
};
};
}
function pivot(settings, plan) {
plan = plan || new Plan();
var pivot = factory(plan);
var aggregate = function aggregate(row) {
return settings.selector(row).reduce(function (memo, selection) {
var name = settings.name(selection);
memo[name] = settings.value(selection, row, pivot(name));
return memo;
}, settings.factory(row));
};
return function (rows) {
return plan.compile(plan.isRoot ? rows.map(aggregate) : aggregate(rows));
};
}
function injectData(schema, source, target) {
return Object.keys(source).filter(function (key) {
return !schema.hasOwnProperty(key);
}).reduce(function (memo, key) {
memo[key] = source[key];
return memo;
}, target);
}
function expandData(schema, source) {
var baseline = Object.keys(schema).map(function (key) {
var node = schema[key];
return source && source.hasOwnProperty(key) ? expandData(node, source[key]) : expandData(node);
});
return baseline.length ? flatten(baseline, true) : [source];
}
function liftSchema(schema) {
var baseline = [];
function lift(schema, depth) {
var derivatives = schema ? Object.keys(schema).map(function (key) {
var node = schema[key];
return {
key: key,
value: lift(node, depth + 1)
};
}) : [];
if (derivatives.length > 0) if (!baseline[depth]) {
baseline[depth] = derivatives;
} else {
var _baseline$depth;
(_baseline$depth = baseline[depth]).push.apply(_baseline$depth, toConsumableArray(derivatives));
}
return derivatives.length && derivatives.reduce(function (memo, d) {
return memo + d.value;
}, 0) || 1;
}
lift(schema, 0);
return baseline;
}
function sortSchema(schema, comparator) {
return Object.keys(schema).sort(comparator).reduce(function (memo, key) {
memo[key] = sortSchema(schema[key], comparator);
return memo;
}, {});
}
function reduceSchema(schema) {
var baseline = [];
function lift(schema, node) {
if (schema) {
Object.keys(schema).forEach(function (key) {
var child = new Node$1(key, node.level + 1);
node.children.push(child);
lift(schema[key], child);
return child;
});
}
return node;
}
return lift(schema, new Node$1('$root', 0));
}
function pivotForm(source, comparator) {
if (source.schema && source.data) {
var schema = sortSchema(source.schema, comparator);
var rows = source.data.map(function (row) {
return injectData(schema, row, expandData(schema, row));
});
var head = reduceSchema(schema);
return { head: head, rows: rows };
}
return { head: new Node$1('$root', 0), rows: [] };
}
function buildFactory(columnMap, valueFactory) {
return function run(pivot$$1, pivotBy) {
var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
var key = pivotBy[0];
var column = columnMap[key];
if (!column) {
throw new AppError('pivot.build', 'Invalid key "' + key + '"');
}
var getValue = valueFactory(column);
return pivot$$1({
factory: function factory() {
return {};
},
selector: function selector(row) {
return [getValue(row)];
},
name: identity$1,
value: function value(parent, row, pivot$$1) {
var nextPivotBy = pivotBy.slice(1);
if (nextPivotBy.length) {
return run(pivot$$1, nextPivotBy, level + 1)(row);
}
return true;
}
});
};
}
function build$2(columnMap, pivotBy, valueFactory) {
var doPivot = null;
if (pivotBy.length) {
var doBuild = buildFactory(columnMap, valueFactory);
doPivot = doBuild(pivot, pivotBy);
}
return function (rows) {
if (doPivot) {
var data = doPivot(rows);
return pivotForm(data);
}
return { head: new Node$1('$root', 0), rows: [] };
};
}
function pivotPipe(memo, context, next) {
Guard.hasProperty(memo, 'rows');
var model = context.model;
if (memo.rows.length) {
var valueFactory = context.valueFactory;
var _model$columnList = model.columnList(),
line = _model$columnList.line;
var _model$pivot = model.pivot(),
by = _model$pivot.by;
var build$$1 = build$2(map$1(line), by, valueFactory);
memo.pivot = build$$1(memo.rows);
}
model.pipe({
effect: Object.assign({}, model.pipe().effect, { pivot: memo.pivot })
}, {
source: 'pivot.pipe',
behavior: 'core'
});
next(memo);
}
function columnIndexPipe(root, context, next) {
Guard.notNull(root, 'root');
var model = context.model;
var filteredIndex = filter$1(model, root);
var columnRows = flatten$1(filteredIndex);
next({ columns: columnRows, index: root });
}
function filter$1(model, root) {
var groupBy = new Set(model.group().by);
var pivotBy = new Set(model.pivot().by);
function doFilter(node, newNode) {
var children = node.children;
for (var i = 0, length = children.length; i < length; i++) {
var child = children[i];
var view = child.key;
var _view$model = view.model,
isVisible = _view$model.isVisible,
key = _view$model.key;
if (isVisible && !groupBy.has(key) && !pivotBy.has(key)) {
var newChild = new Node$1(child.key, child.level);
newNode.children.push(newChild);
doFilter(child, newChild);
}
}
return newNode;
}
return doFilter(root, new Node$1(root.key, root.level));
}
function sortIndexFactory(model) {
var templateIndex = model.columnList().columns.map(function (c) {
return c.key;
});
return function (columns, scores) {
var length = columns.length;
scores = Object.assign({
list: function list(column) {
return column.class === 'data' || column.class === 'cohort' ? 0.1 : 0.3;
},
index: function index() {
return 0.2;
},
view: function view(column) {
return length + (column.class !== 'data' && column.class !== 'cohort' ? 0.1 : 0.3);
},
template: function template() {
return length + 0.4;
}
}, scores);
var viewIndex = columns.map(function (c) {
return c.key;
});
var sort = sortFactory(scores)(templateIndex, viewIndex);
var left = sort(columns.filter(function (c) {
return c.pin === 'left';
}));
var center = sort(columns.filter(function (c) {
return !c.pin;
}));
var right = sort(columns.filter(function (c) {
return c.pin === 'right';
}));
return left.concat(center).concat(right);
};
}
function sortFactory(scores) {
return function (templateIndex, viewIndex) {
var compare = compareFactory(scores, templateIndex, viewIndex);
return function (columns) {
var columnIndex = Array.from(columns);
columnIndex.sort(compare);
return columnIndex.map(function (c) {
return c.key;
});
};
};
}
function compareFactory(scoreFor, templateIndex, viewIndex) {
var viewFind = findFactory(viewIndex);
var templateFind = findFactory(templateIndex);
var weightCache = {};
var getWeight = function getWeight(column) {
var key = column.key;
if (weightCache.hasOwnProperty(key)) {
return weightCache[key];
}
var candidates = [column.index + scoreFor.index(column), viewFind(key) + scoreFor.view(column), templateFind(key) + scoreFor.template(column)];
var weights = candidates.filter(function (w) {
return w >= 0;
});
var weight = weights.length ? weights[0] : -1;
weightCache[key] = weight;
return weight;
};
return function (x, y) {
var xi = getWeight(x);
var yi = getWeight(y);
return yi === -1 ? -1 : xi === -1 ? 1 : xi - yi;
};
}
function findFactory(index) {
var map = index.reduce(function (memo, key, i) {
memo.set(key, i);
return memo;
}, new Map());
return function (key) {
return map.has(key) ? map.get(key) : -1;
};
}
function equals(xs, ys) {
var length = xs.length;
if (length !== ys.length) {
return false;
}
for (var i = 0; i < length; i++) {
if (xs[i] !== ys[i]) {
return false;
}
}
return true;
}
function merge$4(newTree, oldTree, buildIndex) {
var current = running(newTree, buildIndex);
var screen = former(oldTree, current);
var insertNear = insertFactory(current, screen);
var insertCohort = insertCohortFactory(current, screen);
var root = current.line[0];
if (!screen.set.has(root.key.model.key)) {
screen.line.unshift(copy(root));
screen.line.forEach(function (n) {
return n.level++;
});
}
for (var i = 1, length = current.line.length; i < length; i++) {
var node = current.line[i];
var model = node.key.model;
if (screen.set.has(model.key)) {
continue;
}
var prevNode = current.line[i - 1];
if (model.type === 'cohort') {
insertCohort(prevNode, node);
} else {
insertNear(prevNode, node, i);
}
}
return bend(screen.line);
}
function running(tree, buildIndex) {
var result = {
line: [],
map: new Map()
};
preOrderDFS([tree], function (node) {
result.line.push(node);
result.map.set(node.key.model.key, node.key);
// As we use pre order direction we can manipulate with children without affecting on algorithm.
// Below we sort columns in appropriate order.
var columns = node.children.map(function (child) {
return child.key.model;
});
var index = buildIndex(columns);
var cursor = 0;
var indexMap = index.reduce(function (memo, key) {
memo[key] = cursor++;
return memo;
}, {});
node.children.sort(function (x, y) {
return indexMap[x.key.model.key] - indexMap[y.key.model.key];
});
});
return result;
}
function former(tree, current) {
var result = {
line: [],
set: new Set()
};
preOrderDFS([tree], function (node) {
// Filter out nodes if they were deleted from newTree.
var key = node.key.model.key;
var view = current.map.get(key);
if (view) {
var newNode = copy(node);
newNode.key = view;
result.line.push(newNode);
result.set.add(key);
}
});
return result;
}
function insertFactory(current, screen) {
var line = screen.line;
return function (prevNode, node, i) {
var pos = line.findIndex(function (n) {
return n.key.model.key === prevNode.key.model.key;
});
var target = copy(node);
target.level = node.level;
if (everyNextIsNew(current, screen, i)) {
line.push(target);
} else {
line.splice(pos + 1, 0, target);
}
};
}
function insertCohortFactory(current, screen) {
var insertNear = insertFactory(current, screen);
var line = screen.line;
return function (prevNode, node) {
var set = new Set(node.children.map(function (n) {
return n.key.model.key;
}));
var index = line.findIndex(function (n) {
return set.has(n.key.model.key);
});
if (index < 0) {
insertNear(prevNode, node);
return;
}
var target = copy(node);
var level = line[index].level;
target.level = level;
line.splice(index, 0, target);
for (var i = index + 1, end = line.length; i < end; i++) {
var child = line[i];
if (child.level !== level) {
break;
}
if (set.has(child.key.model.key)) {
child.level = level + 1;
}
}
};
}
function everyNextIsNew(current, screen, index) {
var line = current.line;
var n = void 0;
while (n = line[++index]) {
if (screen.set.has(n.key.model.key)) {
return false;
}
}
return true;
}
function columnPipe(memo, context, next) {
Guard.hasProperty(memo, 'pivot');
Guard.hasProperty(memo, 'nodes');
var model = context.model;
var pivot = memo.pivot,
nodes = memo.nodes;
var head = pivot.head;
var createColumn = columnFactory(model);
var root = new Node$1(createColumn('cohort', { key: '$root' }), 0);
var addDataColumns = dataColumnsFactory(model);
var addSelectColumn = selectColumnFactory(model);
var addGroupColumn = groupColumnFactory(model, nodes);
var addRowExpandColumn = rowExpandColumnFactory(model);
var addRowIndicatorColumn = rowIndicatorColumnFactory(model);
var addPivotColumns = pivotColumnsFactory(model);
var addPadColumn = padColumnFactory(model);
/*
* We need to invoke addDataColumns earlier that others because it setups data.columns model property
*
*/
addDataColumns(root);
/**
* Control columns should be filled in reverse order because they use unshift inside.
*/
/*
* Add row expand column
*/
addRowExpandColumn(root);
/*
* Add group column with nodes
*
*/
addGroupColumn(root);
/*
* Add column with select boxes
* if selection unit is row
*
*/
addSelectColumn(root);
/*
* Add row indicator column
* if rows can be dragged or resized
*
*/
addRowIndicatorColumn(root);
/*
* Add column rows for pivoted data
* if pivot is turned on
*
*/
addPivotColumns(root, head);
var columnList = model.columnList;
var buildIndex = sortIndexFactory(model);
var tree = merge$4(root, columnList().index, buildIndex);
/*
* Add special column type
* that fills remaining place (width = 100%)
*
*/
addPadColumn(tree);
columnIndexPipe(tree, context, function (_ref) {
var columns = _ref.columns,
index = _ref.index;
memo.columns = columns;
columnList({
index: index
}, {
behavior: 'core',
source: 'column.pipe'
});
next(memo);
});
}
function selectColumnFactory(model) {
var dataColumns = model.columnList().line;
var selection = model.selection();
var selectColumn = dataColumns.find(function (item) {
return item.type === 'select';
});
var indicatorColumn = dataColumns.find(function (item) {
return item.type === 'row-indicator';
});
if (!indicatorColumn && selection.unit === 'mix') {
var createColumn = columnFactory(model);
return function (node) {
var indicatorColumn = createColumn('row-indicator');
indicatorColumn.model.source = 'generation';
if (indicatorColumn.model.isVisible) {
node.children.unshift(new Node$1(indicatorColumn, node.level + 1));
return indicatorColumn;
}
};
}
if (!selectColumn && selection.unit === 'row' && selection.mode !== 'range') {
var _createColumn = columnFactory(model);
return function (node) {
var selectColumn = _createColumn('select');
selectColumn.model.source = 'generation';
if (selectColumn.model.isVisible) {
node.children.unshift(new Node$1(selectColumn, node.level + 1));
return selectColumn;
}
};
}
return noop$1;
}
function groupColumnFactory(model, nodes) {
var dataColumns = model.columnList().line;
var groupColumn = dataColumns.find(function (item) {
return item.type === 'group';
});
var _model$group = model.group(),
by = _model$group.by,
mode = _model$group.mode;
var createColumn = columnFactory(model);
if (!groupColumn && (nodes.length || by.length)) {
switch (mode) {
case 'nest':
{
return function (node) {
var groupColumn = createColumn('group');
groupColumn.model.source = 'generation';
if (groupColumn.model.isVisible) {
node.children.unshift(new Node$1(groupColumn, node.level + 1));
return groupColumn;
}
};
}
case 'rowspan':
case 'flat':
{
return function (node) {
var _node$children;
var nodes = by.map(function (key) {
var groupColumn = createColumn('group');
groupColumn.model.source = 'generation';
groupColumn.model.key = '$group-' + key;
groupColumn.model.title = key;
groupColumn.model.by = key;
return new Node$1(groupColumn, node.level + 1);
}).filter(function (n) {
return n.key.model.isVisible;
});
(_node$children = node.children).splice.apply(_node$children, [0, 0].concat(toConsumableArray(nodes)));
};
}
}
}
return noop$1;
}
function rowExpandColumnFactory(model) {
var dataColumns = model.columnList().line;
var expandColumn = dataColumns.find(function (item) {
return item.type === 'row-expand';
});
if (model.row().unit === 'details' && !expandColumn) {
var createColumn = columnFactory(model);
return function (node) {
var expandColumn = createColumn('row-expand');
expandColumn.model.source = 'generation';
if (expandColumn.model.isVisible) {
node.children.unshift(new Node$1(expandColumn, node.level + 1));
return expandColumn;
}
};
}
return noop$1;
}
function rowIndicatorColumnFactory(model) {
var dataColumns = model.columnList().line;
var rowIndicatorColumn = dataColumns.find(function (item) {
return item.type === 'row-indicator';
});
var _model$row = model.row(),
canMove = _model$row.canMove,
canResize = _model$row.canResize;
if ((canMove || canResize) && !rowIndicatorColumn) {
var createColumn = columnFactory(model);
return function (node) {
var expandColumn = createColumn('row-indicator');
expandColumn.model.source = 'generation';
if (expandColumn.model.isVisible) {
node.children.unshift(new Node$1(expandColumn, node.level + 1));
return expandColumn;
}
};
}
return noop$1;
}
function dataColumnsFactory(model) {
var getColumns = generateFactory(model);
var createColumn = columnFactory(model);
var _getColumns = getColumns(),
hasChanges = _getColumns.hasChanges,
columns = _getColumns.columns;
if (hasChanges) {
model.data({ columns: columns }, { source: 'column.pipe', behavior: 'core' });
}
function fill(node, columns) {
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = columns[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var column = _step.value;
var view = createColumn(column.type, column);
var child = new Node$1(view, node.level + 1);
node.children.push(child);
fill(child, view.model.children);
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
}
return function (node) {
return fill(node, columns);
};
}
function padColumnFactory(model) {
var createColumn = columnFactory(model);
return function (node) {
var padColumn = createColumn('pad');
padColumn.model.key = '$pad';
var index = node.children.findIndex(function (n) {
return n.key.model.pin === 'right';
});
var padNode = new Node$1(padColumn, node.level + 1);
if (index >= 0) {
node.children.splice(index, 0, padNode);
} else {
node.children.push(padNode);
}
return padColumn;
};
}
function pivotColumnsFactory(model) {
var createColumn = columnFactory(model);
return function fill(node, head) {
var children = head.children;
for (var i = 0, length = children.length; i < length; i++) {
var child = children[i];
var pivotColumn = createColumn('pivot');
var pivotColumnModel = pivotColumn.model;
pivotColumnModel.title = child.key;
pivotColumnModel.key = '$pivot-' + child.key;
var pivotNode = new Node$1(pivotColumn, node.level + 1);
node.children.push(pivotNode);
fill(pivotNode, child);
}
};
}
var Scene = function () {
function Scene(model) {
classCallCheck(this, Scene);
this.model = model;
}
createClass(Scene, [{
key: 'rows',
value: function rows(memo) {
var nodes = memo.nodes,
rows = memo.rows;
if (nodes.length) {
if (!(rows.length && rows[0] instanceof Node$1)) {
var _model$group = this.model.group(),
flattenFactory = _model$group.flattenFactory;
var flatten = flattenFactory(this.model);
return flatten(nodes);
}
}
return rows;
}
}, {
key: 'columnRows',
value: function columnRows(items) {
return items;
}
}, {
key: 'columnLine',
value: function columnLine(items) {
return lineView(items);
}
}, {
key: 'columnArea',
value: function columnArea(items) {
var line = lineView(items);
var result = {
left: [],
right: [],
null: []
};
for (var i = 0, length = line.length; i < length; i++) {
var column = line[i];
var pin = column.model.pin;
var area = result[pin];
if (!area) {
throw new AppError('scene', 'Unsupported pin ' + pin);
}
area.push(column);
}
return result;
}
}]);
return Scene;
}();
function sortFactory$1(model) {
var _model$rowList = model.rowList(),
index = _model$rowList.index;
if (!index.size) {
return identity$1;
}
var _model$data = model.data(),
id = _model$data.id;
return function (rows) {
var cursor = 0;
var positions = new Map();
var result = rows.filter(function (row, i) {
var key = id.row(i, row);
var position = index.get(key);
if (position || position === 0) {
positions.set(position, row);
return false;
}
return true;
}).reduce(function (memo, row) {
var indexRow = void 0;
while (indexRow = positions.get(cursor)) {
positions.delete(cursor);
memo.push(indexRow);
cursor++;
}
memo.push(row);
cursor++;
return memo;
}, []);
if (positions.size) {
var remain = Array.from(positions.entries());
remain.sort(function (x, y) {
return x[0] - y[0];
});
return result.concat(remain.map(function (pos) {
return pos[1];
}));
}
return result;
};
}"";
function viewPipe(memo, context, next) {
Guard.hasProperty(memo, 'rows');
Guard.hasProperty(memo, 'nodes');
Guard.hasProperty(memo, 'pivot');
Guard.hasProperty(memo, 'columns');
var tag = {
source: context.source || 'view.pipe',
behavior: 'core'
};
var model = context.model;
var scene = new Scene(model);
var rows = scene.rows(memo);
var columns = memo.columns,
nodes = memo.nodes,
pivot = memo.pivot;
var columnLine = scene.columnLine(columns);
if (!model.sort().by.length) {
var order = sortFactory$1(model);
rows = order(rows);
}
model.view({
rows: rows,
columns: columnLine.map(function (c) {
return c.model;
}),
nodes: nodes,
pivot: pivot
}, tag);
model.scene({
rows: rows,
column: {
rows: scene.columnRows(memo.columns),
area: scene.columnArea(memo.columns),
line: columnLine
}
}, tag);
next(memo);
}
var Pipe$1 = function () {
function Pipe$$1() {
classCallCheck(this, Pipe$$1);
}
createClass(Pipe$$1, null, [{
key: 'data',
get: function get$$1() {
return dataPipe;
}
}, {
key: 'filter',
get: function get$$1() {
return filterPipe;
}
}, {
key: 'pagination',
get: function get$$1() {
return paginationPipe;
}
}, {
key: 'sort',
get: function get$$1() {
return sortPipe;
}
}, {
key: 'memo',
get: function get$$1() {
return memoPipe;
}
}, {
key: 'group',
get: function get$$1() {
return groupPipe;
}
}, {
key: 'pivot',
get: function get$$1() {
return pivotPipe;
}
}, {
key: 'column',
get: function get$$1() {
return columnPipe;
}
}, {
key: 'columnIndex',
get: function get$$1() {
return columnIndexPipe;
}
}, {
key: 'view',
get: function get$$1() {
return viewPipe;
}
}]);
return Pipe$$1;
}();
var columnPipeUnit = [function (_, context, next) {
var view = context.model.view;
var _view = view(),
rows = _view.rows,
pivot = _view.pivot,
nodes = _view.nodes;
next({ rows: rows, pivot: pivot, nodes: nodes });
}, Pipe$1.column, function (memo, context, next) {
Guard.hasProperty(memo, 'columns');
var model = context.model;
var scene = new Scene(model);
var columnLine = scene.columnLine(memo.columns);
var tag = {
source: context.source || 'column.pipe.unit',
behavior: 'core'
};
var columns = columnLine.map(function (c) {
return c.model;
});
model.view({ columns: columns }, tag);
var column = {
rows: scene.columnRows(memo.columns),
area: scene.columnArea(memo.columns),
line: columnLine
};
context.model.scene({ column: column }, tag);
next(memo);
}];
columnPipeUnit.why = 'redraw';
var columnIndexPipeUnit = [function (_, context, next) {
var _context$model$column = context.model.columnList(),
index = _context$model$column.index;
next(index);
}, Pipe$1.columnIndex, function (memo, context, next) {
Guard.hasProperty(memo, 'columns');
var model = context.model;
var scene = new Scene(model);
var columnLine = scene.columnLine(memo.columns);
var tag = {
source: context.source || 'column.pipe.unit',
behavior: 'core'
};
var columns = columnLine.map(function (c) {
return c.model;
});
model.view({ columns: columns }, tag);
var column = {
rows: scene.columnRows(memo.columns),
area: scene.columnArea(memo.columns),
line: columnLine
};
context.model.scene({ column: column }, tag);
next(memo);
}];
columnIndexPipeUnit.why = 'redraw';
var defaultPipeUnit = [Pipe$1.data, Pipe$1.filter, Pipe$1.sort, Pipe$1.memo, Pipe$1.group, Pipe$1.pivot, Pipe$1.column, Pipe$1.pagination, Pipe$1.view];
defaultPipeUnit.why = 'refresh';
var groupPipeUnit = [function (_, context, next) {
var model = context.model;
var _model$view = model.view(),
nodes = _model$view.nodes,
rows = _model$view.rows;
next({ nodes: nodes, rows: rows });
}, Pipe$1.pagination, function (memo, context, next) {
var model = context.model;
var tag = {
source: context.source || 'group.pipe.unit',
behavior: 'core'
};
var rows = memo.rows;
model.view({ rows: rows }, tag);
model.scene({ rows: rows }, tag);
next(memo);
}];
groupPipeUnit.why = 'redraw';
var RowDetails = function RowDetails(item, column) {
classCallCheck(this, RowDetails);
this.item = item;
this.column = column;
};
var RowDetailsStatus = function RowDetailsStatus(expand) {
classCallCheck(this, RowDetailsStatus);
this.expand = expand;
};
function flatView(model, mode) {
var _model$view = model.view(),
rows = _model$view.rows;
var _model$row = model.row(),
status = _model$row.status;
var line = model.scene().column.line;
var showAll = mode === 'all';
var expandColumn = line.find(function (c) {
return c.model.type === 'row-expand';
});
var columnIndex = expandColumn ? expandColumn.columnIndex : 0;
var result = [];
var createColumn = columnFactory(model);
for (var i = 0, length = rows.length; i < length; i++) {
var dataRow = rows[i];
result.push(dataRow);
var nextRow = rows[i + 1];
var detailsRow = nextRow instanceof RowDetails ? nextRow : null;
var state = status.get(dataRow) || showAll && new RowDetailsStatus(true);
if (state instanceof RowDetailsStatus && state.expand) {
if (detailsRow) {
result.push(detailsRow);
i++;
} else {
var column = createColumn('row-details');
column.columnIndex = columnIndex;
result.push(new RowDetails(dataRow, column));
}
continue;
}
if (detailsRow) {
i++;
}
}
return result;
}
function invalidateStatus(rows, status, mode) {
switch (mode) {
case 'all':
status = new Map(status.entries());
rows.forEach(function (row) {
if (!status.has(row)) {
status.set(row, new RowDetailsStatus(true));
}
});
break;
case 'single':
status = new Map(Array.from(status.entries()).filter(function (entry) {
var row = entry[0];
var status = entry[1];
return rows.indexOf(row) >= 0 || !(status instanceof RowDetailsStatus);
}));
break;
case 'multiple':
status = new Map(status.entries());
break;
default:
throw new AppError('row.details.service', 'Invalid mode ' + mode);
}
return status;
}
function toggleStatus(rows, status) {
var mode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'single';
status = invalidateStatus(rows, status, mode);
if (mode !== 'all') {
rows.forEach(function (row) {
var state = status.get(row);
if (!state) {
status.set(row, new RowDetailsStatus(true));
} else {
state.expand = !state.expand;
}
});
}
return status;
}
var rowDetailsPipeUnit = [function (_, context, next) {
var tag = {
source: context.source || 'row.details.pipe.unit',
behavior: 'core'
};
var model = context.model;
var _model$row = model.row(),
mode = _model$row.mode;
var rows = flatView(model, mode);
model.view({ rows: rows }, tag);
model.scene({ rows: rows }, tag);
next(rows);
}];
rowDetailsPipeUnit.why = 'redraw';
var viewPipeUnit = [Pipe$1.data, Pipe$1.memo, Pipe$1.column, Pipe$1.view];
viewPipeUnit.why = 'refresh';
var rowPipeUnit = [function (_, context, next) {
var tag = {
source: context.source || 'row.pipe.unit',
behavior: 'core'
};
var model = context.model;
var order = sortFactory$1(model);
var rows = order(model.view().rows);
model.view({ rows: rows }, tag);
model.scene({ rows: rows }, tag);
next(rows);
}];
rowPipeUnit.why = 'redraw';
var PipeUnit = function () {
function PipeUnit() {
classCallCheck(this, PipeUnit);
}
createClass(PipeUnit, null, [{
key: 'default',
get: function get$$1() {
return defaultPipeUnit;
}
}, {
key: 'view',
get: function get$$1() {
return viewPipeUnit;
}
}, {
key: 'column',
get: function get$$1() {
return columnPipeUnit;
}
}, {
key: 'columnIndex',
get: function get$$1() {
return columnIndexPipeUnit;
}
}, {
key: 'rowDetails',
get: function get$$1() {
return rowDetailsPipeUnit;
}
}, {
key: 'group',
get: function get$$1() {
return groupPipeUnit;
}
}, {
key: 'row',
get: function get$$1() {
return rowPipeUnit;
}
}]);
return PipeUnit;
}();
var PipeModel = function PipeModel() {
classCallCheck(this, PipeModel);
this.reduce = function (units, model) {
var dataPipe = model.data().pipe;
// Change one of default pipes to data pipes - cause default literaly means data
// we can change only one because all other will be moved out during reduce
var index = units.indexOf(PipeUnit.default);
if (index >= 0) {
units[index] = dataPipe;
}
units = uniq(units);
var set$$1 = new Set(units);
var schema = new Map([[PipeUnit.default, dataPipe], [PipeUnit.view, PipeUnit.default], [PipeUnit.column, PipeUnit.view]]);
var shouldKeep = function shouldKeep(unit) {
var next = void 0;
while (next = schema.get(unit)) {
if (next === unit) {
break;
}
if (set$$1.has(next)) {
return false;
}
unit = next;
}
return true;
};
return units.reduce(function (memo, unit) {
if (shouldKeep(unit)) {
memo.push(unit);
}
return memo;
}, []);
};
this.triggers = {
'data': {
'rows': PipeUnit.default,
'columns': PipeUnit.column
},
'pagination': {
'current': PipeUnit.default,
'size': PipeUnit.default
},
'fetch': {
'skip': PipeUnit.default
},
'sort': {
'by': PipeUnit.default
},
'filter': {
'by': PipeUnit.default,
'match': PipeUnit.default,
'unit': PipeUnit.column
},
'group': {
'by': PipeUnit.default
},
'pivot': {
'by': PipeUnit.default
},
'columnList': {
'index': PipeUnit.columnIndex
},
'row': {
'status': PipeUnit.rowDetails,
'unit': PipeUnit.rowDetails,
'canMove': PipeUnit.column,
'canResize': PipeUnit.column
},
'rowList': {
'index': PipeUnit.row
}
};
this.effect = {};
};
var SceneModel = function SceneModel() {
classCallCheck(this, SceneModel);
this.status = 'stop'; // start | pull | push | stop
this.rows = [];
this.column = {
rows: [],
line: [],
area: {
left: [],
null: [],
right: []
}
};
};
var ViewModel = function ViewModel() {
classCallCheck(this, ViewModel);
this.rows = [];
this.columns = [];
this.nodes = [];
this.pivot = { head: new Node$1('$root', 0), rows: [] };
};
var DataModel = function DataModel() {
classCallCheck(this, DataModel);
this.rows = [];
this.columns = [];
this.pipe = PipeUnit.default;
this.id = {
row: function row(index, _row) {
return _row;
},
column: function column(index, _column) {
return _column.key;
}
};
};
var Resource = function Resource() {
var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var scope = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
classCallCheck(this, Resource);
this.data = data;
this.scope = scope;
};
var Cache = function () {
function Cache() {
classCallCheck(this, Cache);
this.items = {};
}
createClass(Cache, [{
key: 'set',
value: function set$$1(key, value) {
this.items[key] = value;
}
}, {
key: 'get',
value: function get$$1(key) {
var entry = this.find(key);
if (!entry) {
throw new AppError('cache.get', 'Entry with key was not found "' + key + '"');
}
return entry;
}
}, {
key: 'has',
value: function has(key) {
var items = this.items;
return items.hasOwnProperty(key);
}
}, {
key: 'find',
value: function find(key) {
var items = this.items;
if (items.hasOwnProperty(key)) {
return items[key];
}
return null;
}
}, {
key: 'remove',
value: function remove(key) {
if (!this.items.hasOwnProperty(key)) {
throw new AppError('cache.remove', 'Entry with key was not found "' + key + '"');
}
delete this.items[key];
}
}, {
key: 'clear',
value: function clear() {
this.items = {};
}
}]);
return Cache;
}();
var HeadModel = function HeadModel() {
classCallCheck(this, HeadModel);
this.resource = new Resource();
this.cache = new Cache();
};
var BodyModel = function BodyModel() {
classCallCheck(this, BodyModel);
this.resource = new Resource();
this.cache = new Cache();
};
var LayoutModel = function LayoutModel() {
classCallCheck(this, LayoutModel);
this.columns = new Map();
this.rows = new Map();
};
var NavigationModel = function () {
function NavigationModel() {
classCallCheck(this, NavigationModel);
this.cell = null;
this.debounce = 100;
this.shortcut = {
up: 'up',
down: 'down',
left: 'left',
right: 'right',
next: 'tab',
previous: 'shift+tab',
home: 'home',
end: 'end',
pageUp: 'pageUp',
pageDown: 'pageDown',
upward: 'shift+pageUp',
downward: 'shift+pageDown'
};
this.go = new Command({ source: 'navigation.model' });
this.prevent = new Set(['space', 'shift+space', 'up', 'down', 'left', 'right', 'tab', 'shift+tab', 'home', 'end', 'pageUp', 'pageDown', 'shift+pageDown', 'shift+pageUp']);
}
createClass(NavigationModel, [{
key: 'rowIndex',
get: function get$$1() {
return this.cell ? this.cell.rowIndex : -1;
}
}, {
key: 'columnIndex',
get: function get$$1() {
return this.cell ? this.cell.columnIndex : -1;
}
}, {
key: 'row',
get: function get$$1() {
return this.cell ? this.cell.row : null;
}
}, {
key: 'column',
get: function get$$1() {
return this.cell ? this.cell.column : null;
}
}]);
return NavigationModel;
}();
var FocusModel = function FocusModel() {
classCallCheck(this, FocusModel);
this.rowIndex = -1;
this.columnIndex = -1;
this.isActive = false;
};
var ColumnListModel = function ColumnListModel() {
classCallCheck(this, ColumnListModel);
this.generation = null; // deep | shallow | cohort
var root = new CohortColumnModel();
root.key = '$root';
this.index = new Node$1(new CohortColumn(root), 0);
this.columns = [];
this.reference = {};
this.line = [];
};
var RowModel = function RowModel() {
classCallCheck(this, RowModel);
this.resource = new Resource();
this.mode = 'single'; // single | multiple | all
this.unit = 'data'; // data | details
this.height = function (element) {
return element && element.offsetHeight || 64;
}; // number | function(element, index)
this.status = new Map();
this.shortcut = {
toggle: 'space|enter'
};
this.canMove = false;
this.canResize = false;
this.pinTop = [];
this.pinBottom = [];
};
var SelectionModel = function SelectionModel() {
classCallCheck(this, SelectionModel);
this.resource = new Resource();
this.unit = 'cell'; //row|cell|column|mix
this.mode = 'single'; //single|multiple|range
this.items = [];
this.area = 'body'; //body, custom
this.toggle = new Command({ source: 'selection.model' });
this.key = {
row: identity$1,
column: identity$1
};
this.shortcut = {
toggleRow: 'shift+space',
togglePreviousRow: 'shift+up',
toggleNextRow: 'shift+down',
toggleColumn: 'ctrl+space',
toggleNextColumn: 'shift+right',
togglePreviousColumn: 'shift+left',
selectAll: 'ctrl+a'
};
};
var EnumerableResource = function (_Resource) {
inherits(EnumerableResource, _Resource);
function EnumerableResource() {
var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var scope = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var count = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
classCallCheck(this, EnumerableResource);
var _this = possibleConstructorReturn(this, (EnumerableResource.__proto__ || Object.getPrototypeOf(EnumerableResource)).call(this, data, scope));
_this.count = count;
return _this;
}
return EnumerableResource;
}(Resource);
var FootModel = function FootModel() {
classCallCheck(this, FootModel);
this.resource = new EnumerableResource();
this.cache = new Cache();
};
var SortModel = function SortModel() {
classCallCheck(this, SortModel);
this.resource = new Resource();
this.by = [];
this.mode = 'multiple';
this.trigger = ['reorder'];
};
function flattenFactory(model) {
var _model$group = model.group(),
mode = _model$group.mode,
summary = _model$group.summary;
var push = function push(node, pos, result) {
return result.push(node);
};
switch (mode) {
case 'rowspan':
{
push = function push(node, pos, result) {
if (node.level === 0 || pos > 0) {
result.push(node);
}
};
break;
}
}
var pushSummary = noop$1;
switch (summary) {
case 'leaf':
{
pushSummary = function pushSummary(node, pos, result, parent, posInParent) {
if (parent && parent.children.length - 1 === posInParent) {
var level = node.level,
key = node.key;
var _summary = new Node$1(key + '-group-summary', level, 'summary');
_summary.rows = Array.from(node.rows);
result.push(_summary);
}
};
break;
}
}
return function flatView(nodes) {
var result = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
var parent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
var pos = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
for (var i = 0, iLength = nodes.length; i < iLength; i++) {
var node = nodes[i];
push(node, i, result, parent, pos);
if (node.state.expand) {
var children = node.children;
if (children.length) {
flatView(children, result, node, i);
} else {
var rows = node.rows,
level = node.level,
key = node.key;
var nextLevel = level + 1;
for (var j = 0, jLength = rows.length; j < jLength; j++) {
var child = new Node$1(key, nextLevel, 'row');
var row = rows[j];
child.rows = [row];
children.push(child);
push(child, j, result, parent, pos);
}
}
pushSummary(node, i, result, parent, pos);
}
}
return result;
};
}
function findFirstLeaf(node) {
if (node.type !== 'group') {
return node;
}
if (!node.state.expand) {
return null;
}
return node.children.length && findFirstLeaf(node.children[0]);
}
var GroupModel = function GroupModel() {
classCallCheck(this, GroupModel);
this.resource = new Resource();
this.mode = 'nest'; // nest | flat | subhead | rowspan
this.summary = null; // null | leaf
this.by = [];
this.shortcut = {
toggle: 'space'
};
this.toggle = new Command({ source: 'group.model' });
this.toggleAll = new Command({ source: 'group.model' });
this.flattenFactory = flattenFactory;
};
var PivotModel = function PivotModel() {
classCallCheck(this, PivotModel);
this.resource = new Resource();
this.by = [];
};
var PluginModel = function PluginModel() {
classCallCheck(this, PluginModel);
this.resource = new Resource();
this.imports = {};
};
var EditModel = function EditModel() {
classCallCheck(this, EditModel);
this.resource = new Resource();
this.mode = null; // cell | row
this.state = 'view'; // view | edit | startBatch | endBatch
this.method = null; // batch
this.enter = new Command({ source: 'edit.model' });
this.commit = new Command({ source: 'edit.model' });
this.cancel = new Command({ source: 'edit.model' });
this.reset = new Command({ source: 'edit.model' });
this.clear = new Command({ source: 'edit.model' });
this.cancelShortcuts = {
'$default': 'escape'
};
this.enterShortcuts = {
'$default': '*',
'row': 'F2|Enter',
'form': 'F2|Enter'
};
this.commitShortcuts = {
'$default': 'tab|shift+tab|enter|ctrl+s',
'reference': 'ctrl+s',
'row': 'ctrl+s',
'form': 'ctrl+s',
'bool': 'tab|shift+tab|left|right|up|down|home|end|pageUp|pageDown',
'text-area': 'ctrl+s'
};
};
var ToolbarModel = function ToolbarModel() {
classCallCheck(this, ToolbarModel);
this.resource = new Resource();
};
var LayerModel = function LayerModel() {
classCallCheck(this, LayerModel);
this.resource = new Resource();
};
var PaginationModel = function PaginationModel() {
classCallCheck(this, PaginationModel);
this.resource = new Resource();
this.current = 0;
this.size = 50;
this.sizeList = [5, 10, 20, 30, 40, 50];
this.count = 0;
this.resetTriggers = {
'data': ['rows'],
'filter': ['by'],
'pivot': ['by'],
'group': ['by']
};
};
var ProgressModel = function ProgressModel() {
classCallCheck(this, ProgressModel);
this.resource = new Resource();
this.isBusy = false;
this.queue = [];
};
var HighlightModel = function HighlightModel() {
classCallCheck(this, HighlightModel);
this.columns = [];
this.rows = [];
this.cell = null;
};
var VisibilityModel = function VisibilityModel() {
classCallCheck(this, VisibilityModel);
this.resource = new Resource();
this.head = true;
this.foot = true;
this.body = true;
this.toolbar = {
top: true,
bottom: true,
right: false,
left: false
};
this.pin = {
left: false,
right: false,
top: false,
bottom: false
};
this.plugin = {};
};
function build$3(filterBy) {
var op = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'and';
var result = [];
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = Object.entries(filterBy)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var _step$value = slicedToArray(_step.value, 2),
key = _step$value[0],
filter = _step$value[1];
if (key === '$expression') {
result.push(filter);
continue;
}
if (filter.expression) {
result.push(filter.expression);
}
var expressions = [];
if (filter.items && filter.items.length) {
expressions.push(toInExpression(key, filter.items));
}
if (filter.blanks) {
expressions.push(toIsEmptyExpression(key));
}
if (expressions.length) {
if (expressions.length === 1) {
result.push(expressions[0]);
} else {
result.push(compile$1(expressions, 'or'));
}
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
return compile$1(result, op);
}
function toIsEmptyExpression(key) {
return {
kind: 'group',
op: 'and',
left: {
kind: 'condition',
left: key,
op: 'isEmpty',
right: null
},
right: null
};
}
function toInExpression(key, items) {
return {
kind: 'group',
op: 'and',
left: {
kind: 'condition',
left: key,
op: 'in',
right: Array.from(items)
},
right: null
};
}
function compile$1(expressions, op) {
var root = {
kind: 'group',
op: op,
left: null,
right: null
};
var current = root;
expressions.forEach(function (expr) {
if (!current.left) {
current.left = expr;
} else {
var next = {
kind: 'group',
op: op,
left: expr,
right: null
};
current.right = next;
current = next;
}
});
return root.left ? root : null;
}
function getType$1(type) {
return {}.toString.call(type).slice('[object]'.length, -1); // returns type of built-in objects
}
function castFactory(r) {
var rt = getType$1(r);
var asString = '' + r;
var asNumber = +r;
var asBool = !!r;
var asDate = new Date(r);
return function (l) {
var lt = getType$1(l);
if (rt === lt) {
return r;
}
switch (lt) {
case 'Number':
return asNumber;
case 'String':
return asString;
case 'Date':
return asDate;
case 'Boolean':
return asBool;
default:
throw AppError('cast.factory', 'Unsupported format ' + lt);
}
};
}
var Visitor = function () {
function Visitor() {
classCallCheck(this, Visitor);
}
createClass(Visitor, [{
key: 'visit',
value: function visit(item) {
var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
switch (item.kind) {
case 'group':
return this.visitGroup(item, depth + 1);
case 'condition':
return this.visitCondition(item, depth);
case 'function':
return this.visitFunction(item, depth);
default:
throw AppError('expression.visitor', 'Invalid kind ' + item.kind);
}
}
}, {
key: 'visitGroup',
value: function visitGroup(group, depth) {
if (group.right) {
this.visit(group.left, depth);
this.visit(group.right, depth);
}
return this.visit(group.left, depth);
}
}, {
key: 'visitCondition',
value: function visitCondition(condition, depth) {
switch (condition.op) {
case 'isNotNull':
case 'isNull':
case 'isNotEmpty':
case 'isEmpty':
case 'isNumeric':
case 'isNotNumeric':
return this.visitUnary(condition, depth);
case 'equals':
case 'notEquals':
case 'greaterThanOrEquals':
case 'greaterThan':
case 'lessThanOrEquals':
case 'lessThan':
case 'like':
case 'notLike':
case 'startsWith':
case 'endsWith':
case 'match':
return this.visitBinary(condition, depth);
case 'between':
return this.visitBetween(condition, depth);
case 'in':
return this.visitIn(condition, depth);
default:
throw new AppError('expression.visitor', 'Invalid operation ' + condition.op);
}
}
}, {
key: 'visitUnary',
value: function visitUnary(condition) {
this.visitLeft(condition.left);
}
}, {
key: 'visitBinary',
value: function visitBinary(condition /*, depth*/) {
this.visitLeft(condition.left);
this.visitRight(condition.right);
}
}, {
key: 'visitLeft',
value: function visitLeft(left) {
if (left.kind) {
switch (left.kind) {
case 'function':
this.visitArguments(left.arguments);
}
}
}
}, {
key: 'visitBetween',
value: function visitBetween() /*condition, depth*/{}
}, {
key: 'visitIn',
value: function visitIn() /*condition, depth*/{}
}, {
key: 'visitFunction',
value: function visitFunction() /*fn*/{}
}, {
key: 'visitArguments',
value: function visitArguments(args) {
var _this = this;
return args.map(function (arg) {
switch (arg.kind) {
case 'condition':
case 'group':
_this.visit(arg);
}
});
}
}]);
return Visitor;
}();
var PredicateVisitor = function (_Visitor) {
inherits(PredicateVisitor, _Visitor);
function PredicateVisitor(valueFactory, assertFactory) {
classCallCheck(this, PredicateVisitor);
var _this = possibleConstructorReturn(this, (PredicateVisitor.__proto__ || Object.getPrototypeOf(PredicateVisitor)).call(this));
_this.valueFactory = valueFactory;
_this.assertFactory = assertFactory;
return _this;
}
createClass(PredicateVisitor, [{
key: 'visitGroup',
value: function visitGroup(group) {
if (group.right) {
var lp = this.visit(group.left);
var rp = this.visit(group.right);
switch (group.op) {
case 'and':
return function (value) {
return lp(value) && rp(value);
};
case 'or':
return function (value) {
return lp(value) || rp(value);
};
default:
throw AppError('predicate.visitor', 'Invalid operation ' + group.op);
}
}
return this.visit(group.left);
}
}, {
key: 'visitCondition',
value: function visitCondition(condition) {
var r = condition.right;
var name = condition.left;
var getValue = this.valueFactory(name);
var assert = this.assertFactory(name);
var map = new Set();
var rCastAs = void 0;
if (isArray(r)) {
if (r.length) {
rCastAs = castFactory(r[0]);
r.forEach(function (x) {
return map.add('' + x);
});
} else {
rCastAs = identity$1;
}
} else {
rCastAs = castFactory(r);
}
var equals = assert.equals;
var isNull = assert.isNull;
var lessThan = assert.lessThan;
var lessThanOrEquals = function lessThanOrEquals(x, y) {
return equals(x, y) || lessThan(x, y);
};
var greaterThan = function greaterThan(x, y) {
return !lessThanOrEquals(x, y);
};
var greaterThanOrEquals = function greaterThanOrEquals(x, y) {
return !lessThan(x, y);
};
var predicate = void 0;
switch (condition.op) {
case 'isNotNull':
case 'isNotEmpty':
predicate = function predicate(l) {
return !isNull(l);
};
break;
case 'isNull':
case 'isEmpty':
predicate = function predicate(l) {
return isNull(l);
};
break;
case 'equals':
predicate = function predicate(l) {
return equals(rCastAs(l), l);
};
break;
case 'notEquals':
predicate = function predicate(l) {
return !equals(rCastAs(l), l);
};
break;
case 'greaterThanOrEquals':
predicate = function predicate(l) {
return greaterThanOrEquals(l, rCastAs(l));
};
break;
case 'greaterThan':
predicate = function predicate(l) {
return greaterThan(l, rCastAs(l));
};
break;
case 'lessThanOrEquals':
predicate = function predicate(l) {
return lessThanOrEquals(l, rCastAs(l));
};
break;
case 'lessThan':
predicate = function predicate(l) {
return lessThan(l, rCastAs(l));
};
break;
case 'between':
predicate = function predicate(l) {
return lessThanOrEquals(castFactory(r[0])(l), l) && greaterThanOrEquals(castFactory(r[1])(l), l);
};
break;
case 'in':
predicate = function predicate(l) {
var v = !l && l !== 0 ? 'null' : '' + l;
return map.has(v);
};
break;
case 'like':
predicate = function predicate(l) {
var r = rCastAs(l);
return l && ('' + l).toLowerCase().includes(('' + r).toLowerCase());
};
break;
case 'notLike':
predicate = function predicate(l) {
var r = rCastAs(l);
return l && !('' + l).toLowerCase().includes(('' + r).toLowerCase());
};
break;
case 'startsWith':
predicate = function predicate(l) {
var r = rCastAs(l);
var substr = l.substr(0, r.length).toLowerCase();
return ('' + r).toLowerCase() === substr;
};
break;
case 'endsWith':
predicate = function predicate(l) {
var r = rCastAs(l);
var substr = l.slice(-r.length).toLowerCase();
return ('' + r).toLowerCase() === substr;
};
break;
default:
throw new AppError('predicate.visitor', 'Invalid operation ' + condition.op);
}
return function (l) {
var v = getValue(l);
return predicate(v);
};
}
}]);
return PredicateVisitor;
}(Visitor);
function match(context) {
var model = context.model;
var expression = build$3(model.filter().by);
if (expression !== null) {
var valueFactory = context.labelFactory;
var assertFactory = model.filter().assertFactory;
var columnMap = map$1(model.columnList().line);
var valueColumnFactory = function valueColumnFactory(key) {
return valueFactory(columnMap[key]);
};
var assertColumnFactory = function assertColumnFactory(key) {
return assertFactory(columnMap[key]);
};
var visitor = new PredicateVisitor(valueColumnFactory, assertColumnFactory);
return visitor.visit(expression);
}
return yes;
}
var FilterModel = function FilterModel() {
classCallCheck(this, FilterModel);
this.resource = new Resource();
this.by = {};
this.match = match;
this.fetch = noop$1;
this.unit = 'default'; // default|row
this.assertFactory = function () {
return {
equals: function equals(x, y) {
return x === y;
},
lessThan: function lessThan(x, y) {
return x < y;
},
isNull: function isNull(x) {
return x === '' || x === null || x === undefined;
}
};
};
};
var DragModel = function DragModel() {
classCallCheck(this, DragModel);
this.isActive = false;
};
var StyleModel = function StyleModel() {
classCallCheck(this, StyleModel);
this.row = noop$1;
this.cell = noop$1;
this.rows = [];
this.cells = [];
this.classList = [];
this.invalidate = new Command({
source: 'style.model',
canExecute: function canExecute(context) {
return context.model.edit().state === 'view';
}
});
};
var ScrollModel = function ScrollModel() {
classCallCheck(this, ScrollModel);
this.mode = 'default';
this.top = 0;
this.left = 0;
this.cursor = 0;
this.map = {
rowToView: identity$1,
viewToRow: identity$1
};
this.resetTriggers = ['sort.view', 'column.filter.view', 'data.manipulation'];
};
var ExportModel = function ExportModel() {
classCallCheck(this, ExportModel);
this.resource = new Resource();
};
var ImportModel = function ImportModel() {
classCallCheck(this, ImportModel);
this.resource = new Resource();
};
var controlSet = new Set(['shift', 'ctrl', 'alt', 'pause', 'break', 'capslock', 'escape', 'insert', 'left', 'right', 'end', 'home', 'pageup', 'pagedown', 'up', 'down', 'f1', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9', 'f10', 'f11', 'f12', 'numlock', 'scrolllock']);
var nonPrintableSet = new Set(['enter']);
var codeMap = new Map().set(8, 'backspace').set(9, 'tab').set(13, 'enter').set(16, 'shift').set(17, 'ctrl').set(20, 'capslock').set(27, 'escape').set(32, 'space').set(33, 'pageup').set(34, 'pagedown').set(35, 'end').set(36, 'home').set(37, 'left').set(38, 'up').set(39, 'right').set(40, 'down').set(45, 'insert').set(46, 'delete').set(96, 'numpad0').set(97, 'numpad1').set(98, 'numpad2').set(99, 'numpad3').set(100, 'numpad4').set(101, 'numpad5').set(102, 'numpad6').set(103, 'numpad7').set(104, 'numpad8').set(105, 'numpad9').set(112, 'f1').set(113, 'f2').set(114, 'f3').set(115, 'f4').set(116, 'f5').set(117, 'f6').set(118, 'f7').set(119, 'f8').set(120, 'f9').set(121, 'f10').set(122, 'f11').set(123, 'f12').set(144, 'numlock').set(145, 'scrolllock');
var codeSet = new Set(codeMap.values());
var printableMap = new Map().set('space', ' ');
var Keyboard = function () {
function Keyboard() {
classCallCheck(this, Keyboard);
}
createClass(Keyboard, null, [{
key: 'isPrintable',
value: function isPrintable(code) {
return !nonPrintableSet.has(code) && !Keyboard.isControl(code);
}
}, {
key: 'isControl',
value: function isControl(code) {
return controlSet.has(code);
}
}, {
key: 'stringify',
value: function stringify(code, key) {
if (codeSet.has(code)) {
return printableMap.get(code) || '';
}
return key;
}
}, {
key: 'translate',
value: function translate(code) {
return codeMap.get(code) || String.fromCharCode(code);
}
}]);
return Keyboard;
}();
var Shortcut = function () {
function Shortcut(dispatcher) {
classCallCheck(this, Shortcut);
this.dispatcher = dispatcher;
this.keyCode = {
key: null,
code: null
};
}
createClass(Shortcut, [{
key: 'factory',
value: function factory(manager) {
var self = this;
return {
register: function register(commands) {
return self.register(manager, commands);
}
};
}
}, {
key: 'keyDown',
value: function keyDown(e, source) {
var code = Shortcut.translate(e);
this.keyCode = {
key: e.key,
code: code
};
return this.dispatcher.execute(code, source);
}
}, {
key: 'register',
value: function register(manager, commands) {
return this.dispatcher.register(manager, commands);
}
}], [{
key: 'isControl',
value: function isControl(keyCode) {
if (!keyCode) {
return false;
}
var code = keyCode.code;
var parts = code.split('+');
return parts.some(function (part) {
return part === 'ctrl' || part === 'alt';
}) || parts.every(function (part) {
return Keyboard.isControl(part);
});
}
}, {
key: 'isPrintable',
value: function isPrintable(keyCode) {
if (!keyCode) {
return false;
}
var code = keyCode.code;
var parts = code.split('+');
return parts.some(function (part) {
return Keyboard.isPrintable(part);
});
}
}, {
key: 'stringify',
value: function stringify(keyCode) {
if (!keyCode) {
return '';
}
return Keyboard.stringify(keyCode.code, keyCode.key);
}
}, {
key: 'translate',
value: function translate(e) {
var codes = [];
var code = Keyboard.translate(e.keyCode).toLowerCase();
if (e.ctrlKey) {
codes.push('ctrl');
}
if (e.shiftKey) {
codes.push('shift');
}
if (e.altKey) {
codes.push('alt');
}
if (code !== 'ctrl' && code !== 'shift' && code !== 'alt') {
codes.push(code);
}
return codes.join('+');
}
}]);
return Shortcut;
}();
var ShortcutDispatcher = function () {
function ShortcutDispatcher() {
classCallCheck(this, ShortcutDispatcher);
this.managerMap = new Map();
}
createClass(ShortcutDispatcher, [{
key: 'register',
value: function register(manager, commands) {
var _this = this;
var cmds = commands.values ? commands.values() : commands;
var context = this.managerMap.get(manager);
if (!context) {
context = {
commands: [],
shortcuts: new Map()
};
this.managerMap.set(manager, context);
}
var disposes = [];
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
var _loop = function _loop() {
var cmd = _step.value;
if (cmd.shortcut) {
if (isFunction(cmd.shortcut)) {
context.commands.push(cmd);
disposes.push(function () {
var index = context.commands.indexOf(cmd);
if (index >= 0) {
context.commands.splice(index, 1);
}
});
} else {
cmd.shortcut.toLowerCase().split('|').forEach(function (shortcut) {
var temp = [];
if (context.shortcuts.has(shortcut)) {
temp = context.shortcuts.get(shortcut);
}
temp.push(cmd);
context.shortcuts.set(shortcut, temp);
disposes.push(function () {
var shortcutCommands = context.shortcuts.get(shortcut);
if (shortcutCommands) {
var index = shortcutCommands.indexOf(cmd);
if (index >= 0) {
shortcutCommands.splice(index, 1);
if (!shortcutCommands.length) {
context.shortcuts.delete(shortcut);
}
}
}
});
});
}
}
};
for (var _iterator = cmds[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
_loop();
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
return function () {
disposes.forEach(function (dispose) {
return dispose();
});
if (context.commands.length === 0 && Object.keys(context.shortcuts).length === 0) {
_this.managerMap.delete(manager);
}
};
}
}, {
key: 'execute',
value: function execute(code, source) {
var activities = this.fetchActivities(code, source);
return activities.reduce(function (memo, activity) {
var commands = activity.commands;
var manager = activity.manager;
var result = manager.invoke(commands, source) || result;
if (result) {
memo.push.apply(memo, toConsumableArray(commands.map(function (cmd) {
return cmd.source;
})));
}
return memo;
}, []);
}
}, {
key: 'canExecute',
value: function canExecute(code, source) {
var activities = this.fetchActivities(code, source);
return activities.length > 0;
}
}, {
key: 'fetchActivities',
value: function fetchActivities(code, source) {
var notWildcard = function notWildcard(cmd) {
return cmd.shortcut !== '*';
};
var search = this.searchFactory(code);
var entries = Array.from(this.managerMap.entries()).map(function (entry) {
var manager = entry[0];
var commands = entry[1];
return {
commands: manager.filter(search(commands), source),
manager: entry[0]
};
}).filter(function (entry) {
return entry.commands.length > 0;
});
var allCommands = flatten(entries.map(function (x) {
return x.commands;
}));
// Skip wildcard commands if there are some explicit shortcuts
var isActive = allCommands.filter(notWildcard).length > 0 ? notWildcard : yes;
return entries.map(function (entry) {
var commands = entry.commands;
var manager = entry.manager;
var activeCommands = commands.filter(isActive);
return {
commands: activeCommands,
manager: manager
};
}).filter(function (entry) {
return entry.commands.length > 0;
});
}
}, {
key: 'searchFactory',
value: function searchFactory(code) {
var _this2 = this;
return function (context) {
var result = [];
if (context.shortcuts.has(code)) {
result = result.concat(context.shortcuts.get(code));
}
result = result.concat(context.commands.map(function (cmd) {
return cmd.clone({ shortcut: cmd.shortcut() });
}).filter(function (cmd) {
return _this2.test(cmd.shortcut, code);
}));
return result;
};
}
}, {
key: 'test',
value: function test(shortcut, code) {
code = code.toLowerCase();
return ('' + shortcut).toLowerCase().split('|').some(function (shct) {
return shct === '*' || code === shct;
});
}
}]);
return ShortcutDispatcher;
}();
var CommandManager = function () {
function CommandManager() {
var apply = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function (f) {
return f();
};
var context = arguments[1];
classCallCheck(this, CommandManager);
this.apply = apply;
this.context = context;
}
createClass(CommandManager, [{
key: "invoke",
value: function invoke(commands) {
var _this = this;
if (commands.length) {
this.apply(function () {
var context = _this.context;
var priorityCommands = Array.from(commands);
priorityCommands.sort(function (x, y) {
return y.priority - x.priority;
});
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = priorityCommands[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var cmd = _step.value;
if (context) {
if (cmd.execute(context) === false) {
break;
}
} else {
if (cmd.execute() === false) {
break;
}
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
});
return true;
}
return false;
}
}, {
key: "filter",
value: function filter(commands) {
return commands.filter(function (cmd) {
return cmd.sink = cmd.canExecute();
});
}
}]);
return CommandManager;
}();
var ActionModel = function ActionModel() {
classCallCheck(this, ActionModel);
this.resource = new Resource();
this.items = [];
this.shortcut = new Shortcut(new ShortcutDispatcher());
this.manager = new CommandManager();
};
var FetchModel = function FetchModel() {
classCallCheck(this, FetchModel);
this.skip = 0;
};
var PersistenceStorage = function () {
function PersistenceStorage(storage) {
classCallCheck(this, PersistenceStorage);
this.storage = storage;
}
createClass(PersistenceStorage, [{
key: "getItem",
value: function getItem(key) {
var _this = this;
return new Promise(function (resolve) {
var item = JSON.parse(_this.storage.getItem(key));
resolve(item);
});
}
}, {
key: "setItem",
value: function setItem(key, value) {
var _this2 = this;
return new Promise(function (resolve) {
var item = _this2.storage.setItem(key, JSON.stringify(value));
resolve(item);
});
}
}]);
return PersistenceStorage;
}();
var PersistenceModel = function PersistenceModel() {
classCallCheck(this, PersistenceModel);
this.id = 'default';
this.defaultGroup = 'My Presets';
this.load = new Command({ source: 'persistence.model' });
this.remove = new Command({ source: 'persistence.model' });
this.create = new Command({ source: 'persistence.model' });
this.modify = new Command({ source: 'persistence.model' });
this.setDefault = new Command({ source: 'persistence.model' });
this.reset = new Command({ source: 'persistence.model' });
this.storage = new PersistenceStorage(localStorage);
this.settings = {
group: ['by'],
sort: ['by'],
pivot: ['by'],
filter: ['by'],
queryBuilder: ['node']
};
};
var ValidationModel = function ValidationModel() {
classCallCheck(this, ValidationModel);
this.resource = new Resource();
this.rules = [];
};
var TemplateModel = function TemplateModel() {
classCallCheck(this, TemplateModel);
this.resource = {};
};
function serialize(model) {
var paginationState = model.pagination();
var sortState = model.sort();
var filterState = model.filter();
return {
order: sortState.by.map(function (item) {
var field = Object.keys(item)[0];
var order = item[field];
return '' + (order === 'asc' ? '+' : '-') + field;
}).join(','),
filter: Object.keys(filterState.by).map(function (field) {
var state = filterState.by[field];
if (field === '$expression') {
return '$expression=where:' + state;
}
if (state.items) {
return field + '=in:' + state.items.join(',');
}
if (state.expression) {
return field + '=where:' + state.expression;
}
return '';
}).filter(function (part) {
return !!part;
}).join(';'),
skip: paginationState.current * paginationState.size,
take: paginationState.size
};
}
var RestModel = function RestModel() {
classCallCheck(this, RestModel);
this.url = '';
this.method = 'get';
this.serialize = serialize;
};
function jobLine(delay) {
var defer = null;
var reset = function reset() {
if (defer) {
defer.reject();
defer = null;
}
};
return function (job) {
reset();
if (!isFunction(job)) {
throw new AppError('job.line', 'job is not invocable');
}
var doJob = function doJob() {
if (defer) {
job();
defer.resolve();
defer = null;
}
};
defer = jobLine.run(doJob, delay);
return defer.promise;
};
}
jobLine.run = function (job, delay) {
var defer = new Defer();
var token = Fastdom.invoke(function () {
return setTimeout(job, delay);
});
defer.promise.catch(function () {
return clearTimeout(token);
});
return defer;
};
var AnimationModel = function AnimationModel() {
classCallCheck(this, AnimationModel);
};
var RowListModel = function RowListModel() {
classCallCheck(this, RowListModel);
this.index = new Map();
};
function setup(model) {
model.register('grid', GridModel).register('pipe', PipeModel).register('scene', SceneModel).register('view', ViewModel).register('data', DataModel).register('selection', SelectionModel).register('head', HeadModel).register('body', BodyModel).register('navigation', NavigationModel).register('focus', FocusModel).register('foot', FootModel).register('layout', LayoutModel).register('row', RowModel).register('columnList', ColumnListModel).register('rowList', RowListModel).register('sort', SortModel).register('group', GroupModel).register('pivot', PivotModel).register('edit', EditModel).register('plugin', PluginModel).register('toolbar', ToolbarModel).register('layer', LayerModel).register('pagination', PaginationModel).register('progress', ProgressModel).register('highlight', HighlightModel).register('visibility', VisibilityModel).register('filter', FilterModel).register('drag', DragModel).register('style', StyleModel).register('scroll', ScrollModel).register('export', ExportModel).register('import', ImportModel).register('action', ActionModel).register('fetch', FetchModel).register('persistence', PersistenceModel).register('validation', ValidationModel).register('template', TemplateModel).register('rest', RestModel).register('animation', AnimationModel);
}
var ModelBinder = function (_Disposable) {
inherits(ModelBinder, _Disposable);
function ModelBinder(host) {
classCallCheck(this, ModelBinder);
var _this = possibleConstructorReturn(this, (ModelBinder.__proto__ || Object.getPrototypeOf(ModelBinder)).call(this));
_this.host = host;
return _this;
}
createClass(ModelBinder, [{
key: 'canWrite',
value: function canWrite(oldValue, newValue, key) {
if (isUndefined(newValue)) {
Log.warn('model.bind', 'can\'t write undefined to the model[' + key + ']');
return false;
}
// As `Observable | async` returns null by default so we need to filter it out
if (isArray(oldValue) && newValue === null) {
Log.warn('model.bind', 'the model[' + key + '] expects array, got ' + newValue);
return false;
}
return true;
}
}, {
key: 'bound',
value: function bound(model, names) {
var _this2 = this;
var run = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
var track = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
if (model) {
var commits = [];
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
var _loop = function _loop() {
var name = _step.value;
var state = model[name];
var pack = _this2.packFactory(name);
var write = _this2.writeFactory(name);
if (run) {
var oldState = state();
var newState = pack(oldState);
var changes = _this2.buildChanges(newState);
write({ changes: changes });
}
if (track) {
_this2.using(model[name + 'Changed'].on(write));
}
commits.push(function () {
Log.info('model.bind', 'to model "' + name + '"');
var oldState = state();
var newState = pack(oldState);
state(newState);
});
};
for (var _iterator = names[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
_loop();
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
return function () {
return commits.forEach(function (commit) {
return commit();
});
};
}
return noop$1;
}
}, {
key: 'writeFactory',
value: function writeFactory(name) {
var host = this.host;
return function (e) {
var changes = Object.keys(e.changes);
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = changes[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var diffKey = _step2.value;
var hostKey = toCamelCase(name, diffKey);
if (host.hasOwnProperty(hostKey)) {
var diff = e.changes[diffKey];
host[hostKey] = diff.newValue;
}
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
};
}
}, {
key: 'packFactory',
value: function packFactory(name) {
var _this3 = this;
return function (state) {
var host = _this3.host;
var newState = {};
var _iteratorNormalCompletion3 = true;
var _didIteratorError3 = false;
var _iteratorError3 = undefined;
try {
for (var _iterator3 = Object.keys(state)[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
var stateKey = _step3.value;
var hostKey = toCamelCase(name, stateKey);
if (host.hasOwnProperty(hostKey)) {
var oldValue = state[stateKey];
var newValue = host[hostKey];
if (_this3.canWrite(oldValue, newValue, stateKey)) {
newState[stateKey] = newValue;
}
}
}
} catch (err) {
_didIteratorError3 = true;
_iteratorError3 = err;
} finally {
try {
if (!_iteratorNormalCompletion3 && _iterator3.return) {
_iterator3.return();
}
} finally {
if (_didIteratorError3) {
throw _iteratorError3;
}
}
}
return newState;
};
}
}, {
key: 'buildChanges',
value: function buildChanges(state) {
return Object.keys(state).reduce(function (memo, key) {
var value = state[key];
memo[key] = {
newValue: value,
oldValue: value
};
return memo;
}, {});
}
}]);
return ModelBinder;
}(Disposable);
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @abstract
*/
var NgComponent = function () {
function NgComponent() {
classCallCheck(this, NgComponent);
this.basket = new Disposable();
}
/**
* @template T
* @param {?} instance
* @return {?}
*/
createClass(NgComponent, [{
key: 'using',
value: function using(instance) {
return (/** @type {?} */this.basket.using(instance)
);
}
/**
* @return {?}
*/
}, {
key: 'ngOnDestroy',
value: function ngOnDestroy() {
this.basket.dispose();
}
}]);
return NgComponent;
}();
function NgComponent_tsickle_Closure_declarations() {
/** @type {?} */
NgComponent.prototype.basket;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var RootComponent = function (_NgComponent) {
inherits(RootComponent, _NgComponent);
function RootComponent() {
classCallCheck(this, RootComponent);
var _this = possibleConstructorReturn(this, (RootComponent.__proto__ || Object.getPrototypeOf(RootComponent)).call(this));
_this.model = null;
_this.modelChanged = new Event$1();
_this.models = [];
_this.binder = new ModelBinder(_this);
return _this;
}
/**
* @param {?} changes
* @return {?}
*/
createClass(RootComponent, [{
key: 'ngOnChanges',
value: function ngOnChanges(changes) {
if (changes.hasOwnProperty('model')) {
this.modelChanged.emit(this.model);
this.commit = this.setup();
this.commit();
return;
}
if (!this.commit) {
this.commit = this.setup();
}
this.commit();
}
/**
* @return {?}
*/
}, {
key: 'ngOnDestroy',
value: function ngOnDestroy() {
get(RootComponent.prototype.__proto__ || Object.getPrototypeOf(RootComponent.prototype), 'ngOnDestroy', this).call(this);
this.binder.dispose();
}
/**
* @return {?}
*/
}, {
key: 'setup',
value: function setup() {
var /** @type {?} */run = true;
if (!this.model) {
this.model = new Model$1();
this.modelChanged.emit(this.model);
run = false;
}
return this.binder.bound(this.model, this.models, run);
}
}]);
return RootComponent;
}(NgComponent);
function RootComponent_tsickle_Closure_declarations() {
/** @type {?} */
RootComponent.prototype.model;
/** @type {?} */
RootComponent.prototype.modelChanged;
/** @type {?} */
RootComponent.prototype.models;
/** @type {?} */
RootComponent.prototype.binder;
/** @type {?} */
RootComponent.prototype.commit;
}
function build$4(style) {
return buildLines(style).join('\n');
}
function buildLines(style) {
return Object.keys(style).reduce(function (memo, key) {
var entry = style[key];
var body = Object.keys(entry).reduce(function (memo, key) {
memo.push('\t' + key + ':' + entry[key] + ' !important;');
return memo;
}, []);
memo.push(key + '{\n' + body.join('\n') + '\n}');
return memo;
}, []);
}
var css_escape = createCommonjsModule(function (module, exports) {
/*! https://mths.be/cssescape v1.5.1 by @mathias | MIT license */
(function (root, factory) {
// https://github.com/umdjs/umd/blob/master/returnExports.js
if ('object' == 'object') {
// For Node.js.
module.exports = factory(root);
} else if (typeof undefined == 'function' && undefined.amd) {
// For AMD. Register as an anonymous module.
undefined([], factory.bind(root, root));
} else {
// For browser globals (not exposing the function separately).
factory(root);
}
})(typeof commonjsGlobal != 'undefined' ? commonjsGlobal : commonjsGlobal, function (root) {
if (root.CSS && root.CSS.escape) {
return root.CSS.escape;
}
// https://drafts.csswg.org/cssom/#serialize-an-identifier
var cssEscape = function cssEscape(value) {
if (arguments.length == 0) {
throw new TypeError('`CSS.escape` requires an argument.');
}
var string = String(value);
var length = string.length;
var index = -1;
var codeUnit;
var result = '';
var firstCodeUnit = string.charCodeAt(0);
while (++index < length) {
codeUnit = string.charCodeAt(index);
// Note: there’s no need to special-case astral symbols, surrogate
// pairs, or lone surrogates.
// If the character is NULL (U+0000), then the REPLACEMENT CHARACTER
// (U+FFFD).
if (codeUnit == 0x0000) {
result += '\uFFFD';
continue;
}
if (
// If the character is in the range [\1-\1F] (U+0001 to U+001F) or is
// U+007F, […]
codeUnit >= 0x0001 && codeUnit <= 0x001F || codeUnit == 0x007F ||
// If the character is the first character and is in the range [0-9]
// (U+0030 to U+0039), […]
index == 0 && codeUnit >= 0x0030 && codeUnit <= 0x0039 ||
// If the character is the second character and is in the range [0-9]
// (U+0030 to U+0039) and the first character is a `-` (U+002D), […]
index == 1 && codeUnit >= 0x0030 && codeUnit <= 0x0039 && firstCodeUnit == 0x002D) {
// https://drafts.csswg.org/cssom/#escape-a-character-as-code-point
result += '\\' + codeUnit.toString(16) + ' ';
continue;
}
if (
// If the character is the first character and is a `-` (U+002D), and
// there is no second character, […]
index == 0 && length == 1 && codeUnit == 0x002D) {
result += '\\' + string.charAt(index);
continue;
}
// If the character is not handled by one of the above rules and is
// greater than or equal to U+0080, is `-` (U+002D) or `_` (U+005F), or
// is in one of the ranges [0-9] (U+0030 to U+0039), [A-Z] (U+0041 to
// U+005A), or [a-z] (U+0061 to U+007A), […]
if (codeUnit >= 0x0080 || codeUnit == 0x002D || codeUnit == 0x005F || codeUnit >= 0x0030 && codeUnit <= 0x0039 || codeUnit >= 0x0041 && codeUnit <= 0x005A || codeUnit >= 0x0061 && codeUnit <= 0x007A) {
// the character itself
result += string.charAt(index);
continue;
}
// Otherwise, the escaped character.
// https://drafts.csswg.org/cssom/#escape-a-character
result += '\\' + string.charAt(index);
}
return result;
};
if (!root.CSS) {
root.CSS = {};
}
root.CSS.escape = cssEscape;
return cssEscape;
});
});
var css_escape_1 = css_escape.cssEscape;
function sheet(id, source) {
var sheetId = id + '-' + source;
var sheet = document.getElementById(sheetId);
var getSheet = function getSheet() {
if (!sheet) {
sheet = document.createElement('style');
sheet.type = 'text/css';
sheet.id = escapeAttr(sheetId);
document.getElementsByTagName('head')[0].appendChild(sheet);
}
return sheet;
};
return {
set: function set(css) {
var sheet = getSheet();
var lines = buildLines(css);
var styleId = '#' + escape(id);
sheet.innerHTML = lines.map(function (line) {
return styleId + ' ' + line;
}).join('\n');
},
remove: function remove() {
if (sheet) {
sheet.parentNode.removeChild(sheet);
}
}
};
}
function escapeAttr(name) {
return ('' + name).replace(/\s|\t|\n|"|'/g, '_');
}
function escape(name) {
return css_escape(escapeAttr(name));
}
var Container = function () {
function Container(elements) {
classCallCheck(this, Container);
this.elements = elements;
}
createClass(Container, [{
key: 'getBoundingClientRect',
value: function getBoundingClientRect() {
var rects = this.elements.map(function (element) {
return element.getBoundingClientRect();
});
var top = minBy(rects.map(function (r) {
return r.top;
}));
var left = minBy(rects.map(function (r) {
return r.left;
}));
var bottom = maxBy(rects.map(function (r) {
return r.bottom;
}));
var right = maxBy(rects.map(function (r) {
return r.right;
}));
return {
height: bottom - top,
width: right - left,
top: top,
left: left,
right: right,
bottom: bottom
};
}
}, {
key: 'addClass',
value: function addClass(name) {
this.elements.forEach(function (element) {
return element.classList.add(escapeAttr(name));
});
}
}, {
key: 'removeClass',
value: function removeClass(name) {
this.elements.forEach(function (element) {
return element.classList.remove(escapeAttr(name));
});
}
}, {
key: 'hasClass',
value: function hasClass(name) {
return this.elements.some(function (element) {
return element.classList.contains(escapeAttr(name));
});
}
}, {
key: 'clientWidth',
get: function get$$1() {
return maxBy(this.elements.map(function (element) {
return element.clientWidth;
}));
}
}, {
key: 'clientHeight',
get: function get$$1() {
return maxBy(this.elements.map(function (element) {
return element.clientHeight;
}));
}
}, {
key: 'offsetWidth',
get: function get$$1() {
return maxBy(this.elements.map(function (element) {
return element.offsetWidth;
}));
}
}, {
key: 'offsetHeight',
get: function get$$1() {
return maxBy(this.elements.map(function (element) {
return element.offsetHeight;
}));
}
}, {
key: 'classList',
get: function get$$1() {
var _this = this;
return {
add: function add(name) {
return _this.addClass(name);
},
remove: function remove(name) {
return _this.removeClass(name);
},
contains: function contains(name) {
return _this.hasClass(name);
}
};
}
}]);
return Container;
}();
var TrContainer = function () {
function TrContainer(elements) {
classCallCheck(this, TrContainer);
this.elements = elements;
}
createClass(TrContainer, [{
key: 'index',
get: function get$$1() {
var tr = this.elements[0];
Guard.notNull(tr, "tr");
return tr.index;
}
}, {
key: 'model',
get: function get$$1() {
var tr = this.elements[0];
Guard.notNull(tr, "tr");
return tr && tr.model;
}
}, {
key: 'element',
get: function get$$1() {
var elements = this.elements;
if (elements.length > 1) {
return new Container(elements.map(function (tr) {
return tr.element;
}));
}
var tr = this.elements[0];
Guard.notNull(tr, "tr");
return tr.element;
}
}]);
return TrContainer;
}();
var Bag = function () {
function Bag() {
classCallCheck(this, Bag);
this.rows = new Set();
this.cells = new Set();
this.elements = new Map();
this.rowContainer = new Map();
}
createClass(Bag, [{
key: 'findModel',
value: function findModel(element) {
return this.elements.get(element);
}
}, {
key: 'hasModel',
value: function hasModel(element) {
return this.elements.has(element);
}
}, {
key: 'getRowElements',
value: function getRowElements() {
return this.rowContainer.values();
}
}, {
key: 'getCellElements',
value: function getCellElements() {
return this.cells;
}
}, {
key: 'addRow',
value: function addRow(tr) {
var rowContainer = this.rowContainer;
var model = tr.model,
element = tr.element;
this.rows.add(tr);
this.elements.set(element, tr);
var container = rowContainer.get(model);
if (container) {
container.elements.push(tr);
} else {
rowContainer.set(model, new TrContainer([tr]));
}
}
}, {
key: 'addCell',
value: function addCell(td) {
this.cells.add(td);
this.elements.set(td.element, td);
}
}, {
key: 'deleteRow',
value: function deleteRow(tr) {
var rowContainer = this.rowContainer;
var model = tr.model,
element = tr.element;
this.rows.delete(tr);
this.elements.delete(element);
var container = rowContainer.get(model);
if (container) {
var elements = container.elements;
var index = elements.indexOf(element);
if (index >= 0) {
elements.splice(index, 1);
if (!element.length) {
rowContainer.delete(model);
}
}
}
}
}, {
key: 'deleteCell',
value: function deleteCell(td) {
this.cells.delete(td);
this.elements.delete(td.element);
}
}]);
return Bag;
}();
var ModelProxy = function (_Disposable) {
inherits(ModelProxy, _Disposable);
function ModelProxy(target, temp) {
classCallCheck(this, ModelProxy);
var _this = possibleConstructorReturn(this, (ModelProxy.__proto__ || Object.getPrototypeOf(ModelProxy)).call(this));
var modelHandler = {
get: function get$$1(target, key) {
Guard.hasProperty(target, key);
var selector = target[key];
if (key.endsWith('Changed')) {
var eventHandler = {
get: function get$$1(event, key) {
return function () {
return _this.using(event[key].apply(event, arguments));
};
}
};
return new Proxy(selector, eventHandler);
}
if (temp) {
var modelGetter = {
get: function get$$1(model, key) {
return function () {
var state = model[key];
if (!arguments.length) {
return state;
}
var value = arguments.length <= 0 ? undefined : arguments[0];
var inst = state();
var originValue = Object.keys(value).reduce(function (memo, key) {
memo[key] = inst[key];
return memo;
}, {});
_this.using(function () {
return state(originValue, { source: 'model.proxy' });
});
return state.apply(undefined, arguments);
};
}
};
return new Proxy(selector, modelGetter);
}
return selector;
}
};
_this.target = target;
_this.subject = new Proxy(target, modelHandler);
return _this;
}
createClass(ModelProxy, [{
key: 'toString',
value: function toString() {
return this.target.toString ? this.target.toString() : JSON.stringify(this.toJSON());
}
}, {
key: 'toJSON',
value: function toJSON() {
return this.target.toJSON ? this.target.toJSON() : this.target;
}
}]);
return ModelProxy;
}(Disposable);
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var RootService = function () {
function RootService() {
classCallCheck(this, RootService);
this.modelProxy = null;
this.markup = {};
this.bag = {
head: new Bag(),
body: new Bag(),
foot: new Bag()
};
this.table = null;
this.commandManager = null;
}
/**
* @return {?}
*/
createClass(RootService, [{
key: 'ngOnDestroy',
/**
* @return {?}
*/
value: function ngOnDestroy() {
if (this.modelProxy) {
this.modelProxy.dispose();
this.modelProxy = null;
}
}
}, {
key: 'isReady',
get: function get$$1() {
return !!this.modelProxy;
}
/**
* @return {?}
*/
}, {
key: 'model',
get: function get$$1() {
Guard.notNull(this.modelProxy, 'model');
return this.modelProxy.subject;
}
/**
* @param {?} value
* @return {?}
*/
,
set: function set$$1(value) {
if (this.modelProxy) {
if (this.modelProxy.target !== value) {
this.modelProxy.dispose();
this.modelProxy = new ModelProxy(value);
return;
}
}
if (value) {
this.modelProxy = new ModelProxy(value);
}
}
}]);
return RootService;
}();
RootService.decorators = [{ type: Injectable }];
/** @nocollapse */
RootService.ctorParameters = function () {
return [];
};
function RootService_tsickle_Closure_declarations() {
/** @type {?} */
RootService.prototype.modelProxy;
/** @type {?} */
RootService.prototype.markup;
/** @type {?} */
RootService.prototype.bag;
/** @type {?} */
RootService.prototype.table;
/** @type {?} */
RootService.prototype.commandManager;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var Layer = function () {
/**
* @param {?} onDestroy
*/
function Layer(onDestroy) {
classCallCheck(this, Layer);
this.onDestroy = onDestroy;
}
/**
* @return {?}
*/
createClass(Layer, [{
key: "destroy",
value: function destroy() {
this.onDestroy();
}
}]);
return Layer;
}();
function Layer_tsickle_Closure_declarations() {
/** @type {?} */
Layer.prototype.onDestroy;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var TemplateLinkService = function () {
function TemplateLinkService() {
classCallCheck(this, TemplateLinkService);
this.cache = new Map();
}
/**
* @param {?} key
* @return {?}
*/
createClass(TemplateLinkService, [{
key: 'get',
value: function get$$1(key) {
return this.cache.get(key);
}
/**
* @param {?} key
* @param {?} value
* @return {?}
*/
}, {
key: 'put',
value: function put(key, value) {
this.cache.set(key, value);
}
}]);
return TemplateLinkService;
}();
TemplateLinkService.decorators = [{ type: Injectable }];
function TemplateLinkService_tsickle_Closure_declarations() {
/** @type {?} */
TemplateLinkService.prototype.cache;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var TemplateCacheService = function () {
function TemplateCacheService() {
classCallCheck(this, TemplateCacheService);
this.cache = new Map();
}
/**
* @param {?} key
* @return {?}
*/
createClass(TemplateCacheService, [{
key: 'get',
value: function get$$1(key) {
return this.cache.get(key);
}
/**
* @param {?} key
* @param {?} value
* @return {?}
*/
}, {
key: 'put',
value: function put(key, value) {
this.cache.set(key, value);
}
}]);
return TemplateCacheService;
}();
TemplateCacheService.decorators = [{ type: Injectable }];
/** @nocollapse */
TemplateCacheService.ctorParameters = function () {
return [];
};
function TemplateCacheService_tsickle_Closure_declarations() {
/** @type {?} */
TemplateCacheService.prototype.cache;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var TemplateService = function () {
/**
* @param {?} templateLink
* @param {?} templateCache
*/
function TemplateService(templateLink, templateCache) {
classCallCheck(this, TemplateService);
this.templateLink = templateLink;
this.templateCache = templateCache;
}
/**
* @param {?} context
* @return {?}
*/
createClass(TemplateService, [{
key: 'viewFactory',
value: function viewFactory(context) {
return function (link, viewContainerRef) {
var template = link.template;
return viewContainerRef.createEmbeddedView(template, context);
};
}
/**
* @param {?} keys
* @return {?}
*/
}, {
key: 'find',
value: function find(keys) {
if (isString(keys)) {
var /** @type {?} */key = /** @type {?} */keys;
var /** @type {?} */link = this.templateCache.get(key) || this.templateLink.get(key);
return link || null;
}
if (isArray(keys)) {
return this.lookInCache(keys) || this.lookInLink(keys);
}
}
/**
* @param {?} keys
* @return {?}
*/
}, {
key: 'lookInCache',
value: function lookInCache(keys) {
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var key = _step.value;
var /** @type {?} */link = this.templateCache.get(key);
if (link) {
return link;
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
return null;
}
/**
* @param {?} keys
* @return {?}
*/
}, {
key: 'lookInLink',
value: function lookInLink(keys) {
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = keys[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var key = _step2.value;
var /** @type {?} */link = this.templateLink.get(key);
if (link) {
return link;
}
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
return null;
}
}]);
return TemplateService;
}();
TemplateService.decorators = [{ type: Injectable }];
/** @nocollapse */
TemplateService.ctorParameters = function () {
return [{ type: TemplateLinkService }, { type: TemplateCacheService }];
};
function TemplateService_tsickle_Closure_declarations() {
/** @type {?} */
TemplateService.prototype.templateLink;
/** @type {?} */
TemplateService.prototype.templateCache;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var LayerService = function () {
/**
* @param {?} templateService
*/
function LayerService(templateService) {
classCallCheck(this, LayerService);
this.templateService = templateService;
this.layers = new Map();
}
/**
* @param {?} container
* @return {?}
*/
createClass(LayerService, [{
key: 'init',
value: function init(container) {
this.container = container;
var /** @type {?} */layers = this.layers;
this.layers = new Map();
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = Array.from(layers.keys())[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var key = _step.value;
this.create(key);
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
}
/**
* @param {?} name
* @return {?}
*/
}, {
key: 'create',
value: function create(name) {
var _this = this;
if (this.layers.has(name)) {
return this.layers.get(name);
}
var /** @type {?} */container = this.container;
var /** @type {?} */link = this.templateService.find('layer-' + name + '.tpl.html');
if (link && container) {
var /** @type {?} */createView = this.templateService.viewFactory({});
createView(link, container);
}
var /** @type {?} */layer = new Layer(function () {
_this.layers.delete(name);
if (_this.container) {
_this.container.clear();
}
});
this.layers.set(name, layer);
return layer;
}
/**
* @return {?}
*/
}, {
key: 'count',
get: function get$$1() {
return this.layers.size;
}
}]);
return LayerService;
}();
LayerService.decorators = [{ type: Injectable }];
/** @nocollapse */
LayerService.ctorParameters = function () {
return [{ type: TemplateService }];
};
function LayerService_tsickle_Closure_declarations() {
/** @type {?} */
LayerService.prototype.container;
/** @type {?} */
LayerService.prototype.layers;
/** @type {?} */
LayerService.prototype.templateService;
}
var Action = function Action(command, title, icon) {
classCallCheck(this, Action);
this.command = command;
this.title = title;
this.icon = icon;
this.id = null;
this.templateUrl = null;
};
var FakeClassList = function () {
function FakeClassList() {
classCallCheck(this, FakeClassList);
}
createClass(FakeClassList, [{
key: "add",
value: function add() {}
}, {
key: "remove",
value: function remove() {}
}]);
return FakeClassList;
}();
var emptyRect = Object.freeze({
left: 0,
right: 0,
top: 0,
bottom: 0,
width: 0,
height: 0
});
var FakeElement = function () {
function FakeElement() {
classCallCheck(this, FakeElement);
this.classList = new FakeClassList();
}
createClass(FakeElement, [{
key: 'getBoundingClientRect',
value: function getBoundingClientRect() {
return emptyRect;
}
}, {
key: 'clientWidth',
get: function get$$1() {
return 0;
}
}, {
key: 'clientHeight',
get: function get$$1() {
return 0;
}
}, {
key: 'offsetWidth',
get: function get$$1() {
return 0;
}
}, {
key: 'offsetHeight',
get: function get$$1() {
return 0;
}
}]);
return FakeElement;
}();
var fakeElement = new FakeElement();
var Unit = function () {
function Unit() {
classCallCheck(this, Unit);
}
createClass(Unit, [{
key: 'rect',
value: function rect() {
return this.getElement().getBoundingClientRect();
}
}, {
key: 'addClass',
value: function addClass(name) {
this.addClassCore(name);
}
}, {
key: 'removeClass',
value: function removeClass(name) {
this.removeClassCore(name);
}
}, {
key: 'hasClass',
value: function hasClass(name) {
return this.hasClassCore(name);
}
}, {
key: 'width',
value: function width() {
return this.getElement().clientWidth;
}
}, {
key: 'height',
value: function height() {
return this.getElement().clientHeight;
}
}, {
key: 'getElement',
value: function getElement() {
return this.getElementCore() || fakeElement;
}
}, {
key: 'addClassCore',
value: function addClassCore(name) {
this.getElement().classList.add(escapeAttr(name));
}
}, {
key: 'removeClassCore',
value: function removeClassCore(name) {
this.getElement().classList.remove(escapeAttr(name));
}
}, {
key: 'hasClassCore',
value: function hasClassCore(name) {
return this.getElement().classList.contains(escapeAttr(name));
}
}, {
key: 'getElementCore',
value: function getElementCore() {
return null;
}
}]);
return Unit;
}();
function isParentOf(parent, element) {
while (element) {
if (element === parent) {
return true;
}
element = element.parentNode;
}
return false;
}
var View = function (_Unit) {
inherits(View, _Unit);
function View(context, model, markup) {
classCallCheck(this, View);
var _this = possibleConstructorReturn(this, (View.__proto__ || Object.getPrototypeOf(View)).call(this));
_this.context = context;
_this.model = model;
_this.markup = markup;
_this.layers = new Map();
return _this;
}
createClass(View, [{
key: 'columns',
value: function columns() {
var _model$scene = this.model.scene(),
column = _model$scene.column;
return column.line;
}
}, {
key: 'focus',
value: function focus() {
var elements = this.getElementsCore('body');
if (elements.length) {
elements[0].focus();
return true;
}
return false;
}
}, {
key: 'blur',
value: function blur() {
this.getElementsCore('body').forEach(function (element) {
return element.blur();
});
}
}, {
key: 'isFocused',
value: function isFocused() {
var _this2 = this;
return this.getElementsCore('view').some(function (element) {
return _this2.isFocusedCore(element);
});
}
}, {
key: 'addLayer',
value: function addLayer(name) {
var layers = this.layers;
if (layers.has(name)) {
return layers.get(name);
}
var layer = this.context.layer(name);
layers.set(name, layer);
return layer;
}
}, {
key: 'removeLayer',
value: function removeLayer(name) {
var layers = this.layers;
if (layers.has(name)) {
var layer = layers.get(name);
layer.destroy();
layers.delete(name);
return true;
}
return false;
}
}, {
key: 'hasLayer',
value: function hasLayer(name) {
return this.layers.has(name);
}
}, {
key: 'addClass',
value: function addClass(name) {
if (this.markup.view) {
this.markup.view.classList.add(escapeAttr(name));
}
}
}, {
key: 'removeClass',
value: function removeClass(name) {
if (this.markup.view) {
this.markup.view.classList.remove(escapeAttr(name));
}
}
}, {
key: 'scrollLeft',
value: function scrollLeft(value) {
var markup = this.markup;
if (arguments.length) {
if (markup.head) {
markup.head.scrollLeft = value;
}
if (markup.foot) {
markup.foot.scrollLeft = value;
}
if (markup.body) {
markup.body.scrollLeft = value;
}
if (markup['body-top']) {
markup['body-top'].scrollLeft = value;
}
if (markup['body-bottom']) {
markup['body-bottom'].scrollLeft = value;
}
return;
}
return this.getElement().scrollLeft;
}
}, {
key: 'scrollTop',
value: function scrollTop(value) {
if (arguments.length) {
this.getElementsCore('body').forEach(function (element) {
return element.scrollTop = value;
});
return;
}
return this.getElement().scrollTop;
}
}, {
key: 'scrollHeight',
value: function scrollHeight() {
return this.getElement().scrollHeight;
}
}, {
key: 'scrollWidth',
value: function scrollWidth() {
return this.getElement().scrollWidth;
}
}, {
key: 'canScrollTo',
value: function canScrollTo(target, direction) {
if (target && !(target.element instanceof FakeElement)) {
switch (direction) {
case 'left':
{
target = target.element;
if (target) {
var markup = this.markup;
if (markup.table) {
return isParentOf(markup.table, target);
}
}
break;
}
case 'top':
return true;
}
}
return false;
}
}, {
key: 'rect',
value: function rect() {
var area = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'body';
var markup = this.markup;
var element = markup[area];
if (element) {
// TODO: get rid of that
var rect = element.getBoundingClientRect();
// Get rect without scrolls
var width = element.clientWidth;
var height = element.clientHeight;
var left = rect.left;
var top = rect.top;
var right = left + width;
var bottom = top + height;
return { left: left, top: top, right: right, bottom: bottom, width: width, height: height };
}
return get(View.prototype.__proto__ || Object.getPrototypeOf(View.prototype), 'rect', this).call(this);
}
}, {
key: 'height',
value: function height() {
var area = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'body';
var markup = this.markup;
var element = markup[area];
if (element) {
return element.clientHeight;
}
return 0;
}
}, {
key: 'width',
value: function width() {
var area = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'body';
var markup = this.markup;
var element = markup[area];
if (element) {
return element.clientWidth;
}
return 0;
}
}, {
key: 'getElementCore',
value: function getElementCore() {
return this.markup.body;
}
}, {
key: 'isFocusedCore',
value: function isFocusedCore(target) {
var markup = this.markup;
var current = markup.document.activeElement;
return isParentOf(target, current);
}
}, {
key: 'getElementsCore',
value: function getElementsCore(key) {
var markup = this.markup;
return [key + '-left', key, key + '-right'].filter(function (key) {
return markup.hasOwnProperty(key);
}).map(function (key) {
return markup[key];
});
}
}]);
return View;
}(Unit);
var Data = function () {
function Data(model) {
classCallCheck(this, Data);
this.model = model;
}
createClass(Data, [{
key: 'columns',
value: function columns() {
return this.model.view().columns;
}
}, {
key: 'columnMap',
value: function columnMap() {
return map$1(this.columns());
}
}, {
key: 'rows',
value: function rows() {
return this.model.view().rows;
}
}]);
return Data;
}();
var FakeLayer = function () {
function FakeLayer() {
classCallCheck(this, FakeLayer);
}
createClass(FakeLayer, [{
key: "resource",
value: function resource() {}
}, {
key: "destroy",
value: function destroy() {}
}]);
return FakeLayer;
}();
var Element = function (_Unit) {
inherits(Element, _Unit);
function Element(element) {
classCallCheck(this, Element);
var _this = possibleConstructorReturn(this, (Element.__proto__ || Object.getPrototypeOf(Element)).call(this));
_this.element = element;
return _this;
}
createClass(Element, [{
key: 'getElementCore',
value: function getElementCore() {
return this.element;
}
}]);
return Element;
}(Unit);
var Tr = function () {
function Tr(tr) {
classCallCheck(this, Tr);
this.tr = tr;
// We need to cache it due to possible virtual mode;
this.index = tr.index;
}
createClass(Tr, [{
key: 'model',
get: function get$$1() {
if (!Tr.equals(this, this.tr)) {
throw new AppError('tr', 'Internal model doesn\'t match container');
}
return this.tr.model;
}
}, {
key: 'element',
get: function get$$1() {
if (!Tr.equals(this, this.tr)) {
throw new AppError('tr', 'Internal model doesn\'t match container');
}
return this.tr.element;
}
}], [{
key: 'equals',
value: function equals(x, y) {
if (x === y) {
return true;
}
if (!x || !y) {
return false;
}
return x.index === y.index;
}
}]);
return Tr;
}();
var Row = function (_Element) {
inherits(Row, _Element);
function Row(box, index) {
var element = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
classCallCheck(this, Row);
var _this = possibleConstructorReturn(this, (Row.__proto__ || Object.getPrototypeOf(Row)).call(this, element));
_this.box = box;
_this.index = index;
return _this;
}
createClass(Row, [{
key: 'model',
value: function model() {
var tr = this.box.context.bag.findModel(this.getKeyElementCore());
if (tr) {
return new Tr(tr);
}
return null;
}
}, {
key: 'cells',
value: function cells() {
return this.box.rowCellsCore(this.index);
}
}, {
key: 'cell',
value: function cell(columnIndex) {
return this.box.cellCore(this.index, columnIndex);
}
}, {
key: 'getKeyElementCore',
value: function getKeyElementCore() {
var element = get(Row.prototype.__proto__ || Object.getPrototypeOf(Row.prototype), 'getElement', this).call(this);
if (element.elements) {
return element.elements[0];
}
return element;
}
}]);
return Row;
}(Element);
var Column = function () {
function Column(box, index) {
classCallCheck(this, Column);
this.box = box;
this.index = index;
}
createClass(Column, [{
key: "model",
value: function model() {
var _box$model$view = this.box.model.view(),
columns = _box$model$view.columns;
var column = columns[this.index];
return column || null;
}
}, {
key: "cells",
value: function cells() {
return this.box.columnCellsCore(this.index);
}
}, {
key: "cell",
value: function cell(rowIndex) {
return this.box.cell(rowIndex, this.index);
}
}, {
key: "addClass",
value: function addClass(name) {
var cells = this.cells();
var length = cells.length;
var i = 0;
while (i < length) {
var cell = cells[i++];
cell.addClass(name);
}
}
}, {
key: "removeClass",
value: function removeClass(name) {
var cells = this.cells();
var length = cells.length;
var i = 0;
while (i < length) {
var cell = cells[i++];
cell.removeClass(name);
}
}
}]);
return Column;
}();
var Td = function () {
function Td(td) {
classCallCheck(this, Td);
this.td = td;
// We need to cache it due to possible virtual mode;
this.rowIndex = td.rowIndex;
this.columnIndex = td.columnIndex;
}
createClass(Td, [{
key: 'mode',
value: function mode(value) {
if (!Td.equals(this, this.td)) {
throw new AppError('td', 'Internal model doesn\'t match container');
}
this.td.mode(value);
}
}, {
key: 'row',
get: function get$$1() {
if (!Td.equals(this, this.td)) {
throw new AppError('td', 'Internal model doesn\'t match container');
}
return this.td.row;
}
}, {
key: 'column',
get: function get$$1() {
if (!Td.equals(this, this.td)) {
throw new AppError('td', 'Internal model doesn\'t match container');
}
return this.td.column;
}
}, {
key: 'value',
get: function get$$1() {
if (!Td.equals(this, this.td)) {
throw new AppError('td', 'Internal model doesn\'t match container');
}
return this.td.value;
},
set: function set$$1(value) {
if (!Td.equals(this, this.td)) {
throw new AppError('td', 'Internal model doesn\'t match container');
}
this.td.value = value;
}
}, {
key: 'label',
get: function get$$1() {
if (!Td.equals(this, this.td)) {
throw new AppError('td', 'Internal model doesn\'t match container');
}
return this.td.label;
},
set: function set$$1(label) {
if (!Td.equals(this, this.td)) {
throw new AppError('td', 'Internal model doesn\'t match container');
}
this.td.label = label;
}
}, {
key: 'element',
get: function get$$1() {
if (!Td.equals(this, this.td)) {
throw new AppError('td', 'Internal model doesn\'t match container');
}
return this.td.element;
}
}], [{
key: 'equals',
value: function equals(x, y) {
if (x === y) {
return true;
}
if (!x || !y) {
return false;
}
return x.rowIndex === y.rowIndex && x.columnIndex === y.columnIndex;
}
}]);
return Td;
}();
var Cell = function (_Element) {
inherits(Cell, _Element);
function Cell(context, rowIndex, columnIndex) {
var element = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
classCallCheck(this, Cell);
var _this = possibleConstructorReturn(this, (Cell.__proto__ || Object.getPrototypeOf(Cell)).call(this, element));
_this.context = context;
_this.rowIndex = rowIndex;
_this.columnIndex = columnIndex;
return _this;
}
createClass(Cell, [{
key: 'model',
value: function model() {
return this.modelCore();
}
}, {
key: 'modelCore',
value: function modelCore() {
var td = this.context.bag.findModel(this.getElement());
return td ? new Td(td) : null;
}
}]);
return Cell;
}(Element);
var Matrix = function () {
function Matrix(isDataRow) {
classCallCheck(this, Matrix);
this.isDataRow = isDataRow;
}
createClass(Matrix, [{
key: 'build',
value: function build(table) {
var rows = table.rows;
var isDataRow = this.isDataRow;
var mx = [];
var offsets = [];
var y = 0;
for (var cursor = 0, height = rows.length; cursor < height; cursor++) {
var tr = rows[cursor];
if (!isDataRow(tr)) {
continue;
}
var offset = offsets.length > y ? offsets[y] : offsets[y] = [0];
var cells = tr.cells;
for (var x = 0, width = cells.length; x < width; x++) {
var td = cells[x];
var rowSpan = td.rowSpan,
colSpan = td.colSpan;
var current = offset[0];
var next = current + colSpan;
for (var i = 0; i < rowSpan; i++) {
var yi = y + i;
var row = mx.length > yi ? mx[yi] : mx[yi] = [];
for (var j = 0; j < colSpan; j++) {
var xj = current + j;
row[xj] = td;
}
var gaps = offsets.length > yi ? offsets[yi] : offsets[yi] = [0];
var index = binarySearch(gaps, current);
if (row[next]) {
gaps.splice(index, 1);
} else {
var xi = gaps[index];
gaps.splice(index, row[xi] ? 1 : 0, next);
}
}
}
y++;
}
return mx;
}
}, {
key: 'assertFlatness',
value: function assertFlatness(matrix) {
if (matrix.length) {
var height = matrix.length;
var width = matrix[0].length;
for (var i = 1; i < height; i++) {
if (matrix[i].length !== width) {
throw new AppError('matrix', 'Matrix is not flat, expect width ' + width + ', actual ' + matrix[i].length);
}
}
}
}
}]);
return Matrix;
}();
var Selector = function () {
function Selector(matrix, bag, factory) {
classCallCheck(this, Selector);
this.matrix = matrix;
this.bag = bag;
this.factory = factory;
}
createClass(Selector, [{
key: 'columnCount',
value: function columnCount(rowIndex) {
var row = this.matrix[rowIndex];
return row ? new Set(row).size : 0;
}
}, {
key: 'columnCells',
value: function columnCells(columnIndex) {
var factory = this.factory;
var matrix = this.matrix;
var result = [];
var set$$1 = new Set();
for (var i = 0, length = matrix.length; i < length; i++) {
var row = matrix[i];
if (row.length > columnIndex) {
var td = row[columnIndex];
if (!set$$1.has(td)) {
set$$1.add(td);
result.push(factory.cell(td, i, columnIndex));
}
}
}
return result;
}
}, {
key: 'rowCount',
value: function rowCount(columnIndex) {
var matrix = this.matrix;
var set$$1 = new Set();
for (var i = 0, length = matrix.length; i < length; i++) {
var row = matrix[i];
if (row.length > columnIndex) {
var td = row[columnIndex];
set$$1.add(td);
}
}
return set$$1.size;
}
}, {
key: 'rows',
value: function rows(columnIndex) {
var matrix = this.matrix,
factory = this.factory,
bag = this.bag;
var set$$1 = new Set();
var result = [];
if (isUndefined(columnIndex)) {
var rows = bag.getRowElements();
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = rows[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var tr = _step.value;
result.push(factory.row(tr.element, tr.index));
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
result.sort(function (x, y) {
return x.index - y.index;
});
} else {
for (var i = 0, length = matrix.length; i < length; i++) {
var row = matrix[i];
if (row.length > columnIndex) {
var _tr = row[columnIndex].parentElement;
if (!set$$1.has(_tr)) {
set$$1.add(_tr);
result.push(factory.row(_tr, i));
}
}
}
}
return result;
}
}, {
key: 'rowCells',
value: function rowCells(rowIndex) {
var matrix = this.matrix;
var row = matrix[rowIndex];
var result = [];
if (row) {
var set$$1 = new Set();
var factory = this.factory;
for (var i = 0, length = row.length; i < length; i++) {
var td = row[i];
if (!set$$1.has(td)) {
set$$1.add(td);
result.push(factory.cell(td, rowIndex, i));
}
}
}
return result;
}
}, {
key: 'row',
value: function row(rowIndex, columnIndex) {
var factory = this.factory;
if (!isUndefined(columnIndex)) {
var td = this.td(rowIndex, columnIndex);
return factory.row(td ? td.parentElement : new FakeElement(), rowIndex);
}
var row = this.matrix[rowIndex];
if (row) {
var set$$1 = new Set();
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = row[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var _td = _step2.value;
set$$1.add(_td.parentElement);
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
var trs = Array.from(set$$1);
return factory.row(trs.length > 1 ? new Container(trs) : trs[0], rowIndex);
}
return factory.row(new FakeElement(), rowIndex);
}
}, {
key: 'cell',
value: function cell(rowIndex, columnIndex) {
var td = this.td(rowIndex, columnIndex);
return this.factory.cell(td || new FakeElement(), rowIndex, columnIndex);
}
}, {
key: 'td',
value: function td(rowIndex, columnIndex) {
var row = this.matrix[rowIndex];
if (row) {
var td = row[columnIndex];
if (td) {
return td;
}
}
return null;
}
}]);
return Selector;
}();
var SelectorMediator = function () {
function SelectorMediator(selectorFactory, factory) {
classCallCheck(this, SelectorMediator);
this.buildSelectors = selectorFactory;
this.factory = factory;
}
createClass(SelectorMediator, [{
key: 'columnCount',
value: function columnCount(rowIndex) {
var selectors = this.buildSelectors({ row: rowIndex });
if (!selectors.length) {
return 0;
}
return sumBy(selectors, function (s) {
return s.invoke(function (s, rowIndex) {
return s.columnCount(rowIndex);
});
});
}
}, {
key: 'columnCells',
value: function columnCells(columnIndex) {
var selectors = this.buildSelectors({ column: columnIndex });
var result = [];
for (var i = 0, length = selectors.length; i < length; i++) {
var selector = selectors[i];
var cells = selector.invoke(function (s, columnIndex) {
return s.columnCells(columnIndex);
});
result.push.apply(result, toConsumableArray(cells));
}
return result;
}
}, {
key: 'rowCount',
value: function rowCount(columnIndex) {
var selectors = this.buildSelectors({ column: columnIndex });
if (!selectors.length) {
return 0;
}
return maxBy(selectors.map(function (s) {
return s.invoke(function (s, columnIndex) {
return s.rowCount(columnIndex);
});
}));
}
}, {
key: 'rows',
value: function rows(columnIndex) {
var context = isUndefined(columnIndex) ? {} : { column: columnIndex };
var selectors = this.buildSelectors(context);
var factory = this.factory;
var areas = [];
for (var i = 0, length = selectors.length; i < length; i++) {
var selector = selectors[i];
var rows = selector.invoke(function (s, columnIndex) {
return s.rows(columnIndex);
});
if (rows.length) {
areas.push(rows);
}
}
var lines = zip.apply(undefined, areas);
var result = [];
for (var _i = 0, _length = lines.length; _i < _length; _i++) {
var line = lines[_i];
var elements = line.map(function (row) {
return row.element;
});
var rowElement = elements.length > 1 ? new Container(elements) : elements[0];
var rowIndex = line[0].index;
var row = factory.row(rowElement, rowIndex);
result.push(row);
}
return result;
}
}, {
key: 'rowCells',
value: function rowCells(rowIndex) {
var selectors = this.buildSelectors({ row: rowIndex });
var result = [];
for (var i = 0, length = selectors.length; i < length; i++) {
var selector = selectors[i];
var cells = selector.invoke(function (s, rowIndex) {
return s.rowCells(rowIndex);
});
result.push.apply(result, toConsumableArray(cells));
}
return result;
}
}, {
key: 'row',
value: function row(rowIndex, columnIndex) {
var context = { row: rowIndex };
if (!isUndefined(columnIndex)) {
context.column = columnIndex;
}
var selectors = this.buildSelectors(context);
var result = [];
for (var i = 0, length = selectors.length; i < length; i++) {
var selector = selectors[i];
var row = selector.invoke(function (s, rowIndex, columnIndex) {
return s.row(rowIndex, columnIndex);
});
result.push(row.element);
}
return this.factory.row(new Container(result), rowIndex);
}
}, {
key: 'cell',
value: function cell(rowIndex, columnIndex) {
var context = { row: rowIndex, column: columnIndex };
var selectors = this.buildSelectors(context);
for (var i = 0, length = selectors.length; i < length; i++) {
var selector = selectors[i];
var cell = selector.invoke(function (s, rowIndex, columnIndex) {
return s.cell(rowIndex, columnIndex);
});
if (!(cell.element instanceof FakeElement)) {
return cell;
}
}
return this.factory.cell(new FakeElement(), rowIndex, columnIndex);
}
}]);
return SelectorMediator;
}();
var UnitFactory = function () {
function UnitFactory(rowRange, columnRange) {
classCallCheck(this, UnitFactory);
this.rowRange = rowRange;
this.columnRange = columnRange;
}
createClass(UnitFactory, [{
key: "cell",
value: function cell(element, rowIndex, columnIndex) {
return {
element: element,
rowIndex: rowIndex + this.rowRange.start,
columnIndex: columnIndex + this.columnRange.start
};
}
}, {
key: "row",
value: function row(element, rowIndex) {
return {
element: element,
index: rowIndex + this.rowRange.start
};
}
}]);
return UnitFactory;
}();
var Range = function Range(start, end) {
classCallCheck(this, Range);
this.start = start;
this.end = end;
};
var SelectorFactory = function () {
function SelectorFactory(bag, selectorMark) {
classCallCheck(this, SelectorFactory);
this.bag = bag;
this.selectorMark = selectorMark;
}
createClass(SelectorFactory, [{
key: 'create',
value: function create() {
var bag = this.bag;
var selectorMark = this.selectorMark;
var matrix = new Matrix(function (tr) {
return bag.elements.has(tr);
});
var entries = selectorMark.select().map(function (_ref) {
var element = _ref.element,
rowRange = _ref.rowRange,
columnRange = _ref.columnRange;
return {
matrix: matrix.build(element),
rowRange: rowRange,
columnRange: columnRange
};
});
var selectorFactory = function selectorFactory(context) {
return entries.map(function (entry) {
return {
invoke: function invoke(f) {
var unitFactory = new UnitFactory(entry.rowRange, entry.columnRange);
var selector = new Selector(entry.matrix, bag, unitFactory);
var args = [];
args.push(selector);
if (context.hasOwnProperty('row')) {
args.push(context.row - entry.rowRange.start);
}
if (context.hasOwnProperty('column')) {
args.push(context.column - entry.columnRange.start);
}
return f.apply(undefined, args);
}
};
});
};
var unitFactory = new UnitFactory(new Range(0, 0), new Range(0, 0));
return new SelectorMediator(selectorFactory, unitFactory);
}
}]);
return SelectorFactory;
}();
var Box = function () {
function Box(context, model, selectorMark) {
var _this = this;
classCallCheck(this, Box);
this.context = context;
this.model = model;
this.selectFactory = new SelectorFactory(context.bag, selectorMark);
this.selector = this.selectFactory.create();
model.sceneChanged.on(function (e) {
if (e.hasChanges('status')) {
if (e.state.status === 'stop') {
_this.selector = _this.selectFactory.create();
}
}
});
}
createClass(Box, [{
key: 'columnCount',
value: function columnCount(rowIndex) {
return this.selector.columnCount(rowIndex);
}
}, {
key: 'column',
value: function column(columnIndex) {
return this.createColumnCore(columnIndex);
}
}, {
key: 'columns',
value: function columns(rowIndex) {
var _this2 = this;
return this.selector.rowCells(rowIndex).map(function (cell) {
return _this2.createColumnCore(cell.columnIndex);
});
}
}, {
key: 'row',
value: function row(rowIndex, columnIndex) {
return this.rowCore(rowIndex, columnIndex);
}
}, {
key: 'rows',
value: function rows(columnIndex) {
var _this3 = this;
return this.selector.rows(columnIndex).map(function (row) {
return _this3.createRowCore(row.index, row.element);
});
}
}, {
key: 'rowCount',
value: function rowCount(columnIndex) {
return this.selector.rowCount(columnIndex);
}
}, {
key: 'cell',
value: function cell(rowIndex, columnIndex) {
return this.cellCore(rowIndex, columnIndex);
}
}, {
key: 'getElements',
value: function getElements() {
return [];
}
}, {
key: 'rowCore',
value: function rowCore(rowIndex, columnIndex) {
return this.createRowCore(rowIndex, this.selector.row(rowIndex, columnIndex).element);
}
}, {
key: 'cellCore',
value: function cellCore(rowIndex, columnIndex) {
var cell = this.selector.cell(rowIndex, columnIndex);
return this.createCellCore(cell.rowIndex, cell.columnIndex, cell.element);
}
}, {
key: 'rowCellsCore',
value: function rowCellsCore(rowIndex) {
var _this4 = this;
return this.selector.rowCells(rowIndex).map(function (cell) {
return _this4.createCellCore(cell.rowIndex, cell.columnIndex, cell.element);
});
}
}, {
key: 'columnCellsCore',
value: function columnCellsCore(columnIndex) {
var _this5 = this;
return this.selector.columnCells(columnIndex).map(function (cell) {
return _this5.createCellCore(cell.rowIndex, cell.columnIndex, cell.element);
});
}
}, {
key: 'createRowCore',
value: function createRowCore(index, element) {
return new Row(this, index, element);
}
}, {
key: 'createColumnCore',
value: function createColumnCore(index) {
return new Column(this, index);
}
}, {
key: 'createCellCore',
value: function createCellCore(rowIndex, columnIndex, element) {
return new Cell(this.context, rowIndex, columnIndex, element);
}
}]);
return Box;
}();
var SelectorMark = function () {
function SelectorMark(model, markup, name) {
classCallCheck(this, SelectorMark);
this.model = model;
this.name = name;
this.markup = markup;
}
createClass(SelectorMark, [{
key: 'select',
value: function select() {
var result = [];
var addNext = this.addFactory(result);
addNext('left');
addNext(null);
addNext('right');
return result;
}
}, {
key: 'addFactory',
value: function addFactory(result) {
var _this = this;
var model = this.model;
var _model$view = model.view(),
rows = _model$view.rows;
var columns = model.scene().column.area;
return function (pin) {
var name = pin ? _this.name + '-' + pin : _this.name;
var element = _this.markup[name];
if (element) {
var prev = result[result.length - 1];
var columnStart = prev ? prev.columnRange.end : 0;
var columnCount = columns[pin].length;
var rowStart = 0;
var rowCount = rows.length;
result.push({
element: element,
columnRange: new Range(columnStart, columnStart + columnCount),
rowRange: new Range(rowStart, rowStart + rowCount)
});
}
return result;
};
}
}]);
return SelectorMark;
}();
var Head = function (_Box) {
inherits(Head, _Box);
function Head(context, model, markup) {
classCallCheck(this, Head);
return possibleConstructorReturn(this, (Head.__proto__ || Object.getPrototypeOf(Head)).call(this, context, model, new SelectorMark(model, markup, 'head')));
}
return Head;
}(Box);
var StyleBox = function () {
function StyleBox(context) {
classCallCheck(this, StyleBox);
this.context = context;
this.entries = new Map();
}
createClass(StyleBox, [{
key: "addClass",
value: function addClass(item, name) {
var key = this.key(item);
if (key !== null) {
var entry = this.entries.get(key);
if (!entry) {
entry = new Set();
this.entries.set(key, entry);
}
entry.add(name);
}
}
}, {
key: "removeClass",
value: function removeClass(item, name) {
var key = this.key(item);
if (key !== null) {
var entry = this.entries.get(key);
if (entry) {
entry.delete(name);
if (!entry.size) {
this.entries.delete(key);
}
return true;
}
}
return false;
}
}, {
key: "key",
value: function key(item) {
return item;
}
}]);
return StyleBox;
}();
var CellBox = function (_StyleBox) {
inherits(CellBox, _StyleBox);
function CellBox(context) {
classCallCheck(this, CellBox);
return possibleConstructorReturn(this, (CellBox.__proto__ || Object.getPrototypeOf(CellBox)).call(this, context));
}
createClass(CellBox, [{
key: 'key',
value: function key(cell) {
return cell.dataRowIndex + 'x' + cell.dataColumnIndex;
}
}]);
return CellBox;
}(StyleBox);
var ColumnBox = function (_StyleBox) {
inherits(ColumnBox, _StyleBox);
function ColumnBox(context) {
classCallCheck(this, ColumnBox);
return possibleConstructorReturn(this, (ColumnBox.__proto__ || Object.getPrototypeOf(ColumnBox)).call(this, context));
}
createClass(ColumnBox, [{
key: 'key',
value: function key(column) {
return column.dataIndex;
}
}]);
return ColumnBox;
}(StyleBox);
var RowBox = function (_StyleBox) {
inherits(RowBox, _StyleBox);
function RowBox(context) {
classCallCheck(this, RowBox);
return possibleConstructorReturn(this, (RowBox.__proto__ || Object.getPrototypeOf(RowBox)).call(this, context));
}
createClass(RowBox, [{
key: 'key',
value: function key(row) {
return row.dataIndex;
}
}]);
return RowBox;
}(StyleBox);
var VirtualTd = function () {
function VirtualTd(selector) {
classCallCheck(this, VirtualTd);
this.selector = selector;
}
createClass(VirtualTd, [{
key: 'mode',
value: function mode(value) {
return this.model.mode(value);
}
}, {
key: 'model',
get: function get$$1() {
var td = this.selector();
if (!td) {
throw new AppError('cell', 'Model is not found');
}
return td;
}
}, {
key: 'value',
get: function get$$1() {
return this.model.value;
},
set: function set$$1(value) {
this.model.value = value;
}
}, {
key: 'label',
get: function get$$1() {
return this.model.label;
},
set: function set$$1(value) {
this.model.label = value;
}
}, {
key: 'element',
get: function get$$1() {
return this.model.element || new FakeElement();
}
}]);
return VirtualTd;
}();
var VirtualCell = function (_Cell) {
inherits(VirtualCell, _Cell);
function VirtualCell(box, rowIndex, columnIndex) {
var element = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
classCallCheck(this, VirtualCell);
var _this = possibleConstructorReturn(this, (VirtualCell.__proto__ || Object.getPrototypeOf(VirtualCell)).call(this, box.context, rowIndex, columnIndex, element));
_this.box = box;
var mapper = box.context.mapper;
_this.dataRowIndex = mapper.viewToRow(rowIndex);
_this.dataColumnIndex = mapper.viewToColumn(columnIndex);
return _this;
}
createClass(VirtualCell, [{
key: 'model',
value: function model() {
var _this2 = this;
var rowIndex = this.dataRowIndex;
var columnIndex = this.dataColumnIndex;
if (rowIndex >= 0 && columnIndex >= 0) {
var gridModel = this.box.model;
var _gridModel$data = gridModel.data(),
rows = _gridModel$data.rows;
var _gridModel$view = gridModel.view(),
columns = _gridModel$view.columns;
if (rows.length > rowIndex && columns.length > columnIndex) {
var selector = function selector() {
return _this2.box.cell(rowIndex, columnIndex).modelCore();
};
var vtd = new VirtualTd(selector);
vtd.rowIndex = rowIndex;
vtd.columnIndex = columnIndex;
vtd.row = rows[rowIndex];
vtd.column = columns[columnIndex];
return new Td(vtd);
}
}
return null;
}
}, {
key: 'addClass',
value: function addClass(name) {
var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
this.box.addCellClass(this, name, force);
}
}, {
key: 'removeClass',
value: function removeClass(name) {
var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
this.box.removeCellClass(this, name, force);
}
}]);
return VirtualCell;
}(Cell);
var VirtualColumn = function (_Column) {
inherits(VirtualColumn, _Column);
function VirtualColumn(box, index) {
classCallCheck(this, VirtualColumn);
var _this = possibleConstructorReturn(this, (VirtualColumn.__proto__ || Object.getPrototypeOf(VirtualColumn)).call(this, box, index));
_this.box = box;
var mapper = box.context.mapper;
_this.dataIndex = mapper.viewToColumn(index);
return _this;
}
createClass(VirtualColumn, [{
key: 'cells',
value: function cells() {
return this.box.columnCellsCore(this.dataIndex);
}
}, {
key: 'cell',
value: function cell(rowIndex) {
return this.box.cell(rowIndex, this.dataIndex);
}
}, {
key: 'addClass',
value: function addClass(name) {
var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
this.box.addColumnClass(this, name, force);
}
}, {
key: 'removeClass',
value: function removeClass(name) {
var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
this.box.removeColumnClass(this, name, force);
}
}]);
return VirtualColumn;
}(Column);
var VirtualElement = function () {
function VirtualElement(getRect) {
classCallCheck(this, VirtualElement);
this.classList = new FakeClassList();
this.getRect = getRect;
}
createClass(VirtualElement, [{
key: 'getBoundingClientRect',
value: function getBoundingClientRect() {
return this.getRect();
}
}, {
key: 'clientWidth',
get: function get$$1() {
return this.getRect().width;
}
}, {
key: 'clientHeight',
get: function get$$1() {
return this.getRect().height;
}
}, {
key: 'offsetWidth',
get: function get$$1() {
return this.getRect().width;
}
}, {
key: 'offsetHeight',
get: function get$$1() {
return this.getRect().height;
}
}]);
return VirtualElement;
}();
var VirtualRow = function (_Row) {
inherits(VirtualRow, _Row);
function VirtualRow(box, index) {
var element = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
classCallCheck(this, VirtualRow);
var _this = possibleConstructorReturn(this, (VirtualRow.__proto__ || Object.getPrototypeOf(VirtualRow)).call(this, box, index, element));
var mapper = box.context.mapper;
_this.dataIndex = mapper.viewToRow(index);
return _this;
}
createClass(VirtualRow, [{
key: 'model',
value: function model() {
var model = get(VirtualRow.prototype.__proto__ || Object.getPrototypeOf(VirtualRow.prototype), 'model', this).call(this);
if (model) {
return model;
}
var index = this.dataIndex;
if (index >= 0) {
var gridModel = this.box.model;
var _gridModel$data = gridModel.data(),
rows = _gridModel$data.rows;
if (rows.length > index) {
return rows[index];
}
}
return null;
}
}, {
key: 'cells',
value: function cells() {
return this.box.rowCellsCore(this.dataIndex);
}
}, {
key: 'cell',
value: function cell(columnIndex) {
return this.box.cellCore(this.dataIndex, columnIndex);
}
}, {
key: 'addClass',
value: function addClass(name) {
var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
this.box.addRowClass(this, name, force);
}
}, {
key: 'removeClass',
value: function removeClass(name) {
var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
this.box.removeRowClass(this, name, force);
}
}]);
return VirtualRow;
}(Row);
var VirtualBox = function (_Box) {
inherits(VirtualBox, _Box);
function VirtualBox(context, model, selectorMark) {
classCallCheck(this, VirtualBox);
var _this = possibleConstructorReturn(this, (VirtualBox.__proto__ || Object.getPrototypeOf(VirtualBox)).call(this, context, model, selectorMark));
_this.cellBox = new CellBox(context);
_this.rowBox = new RowBox(context);
_this.columnBox = new ColumnBox(context);
_this.requestInvalidate = new Event$1();
return _this;
}
createClass(VirtualBox, [{
key: 'addCellClass',
value: function addCellClass(cell, name) {
var force = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
if (force) {
cell.addClassCore(name);
} else {
this.cellBox.addClass(cell, name);
this.requestInvalidate.emit({ source: 'addCellClass' });
}
}
}, {
key: 'removeCellClass',
value: function removeCellClass(cell, name) {
var force = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
if (force) {
cell.removeClassCore(name);
} else {
this.cellBox.removeClass(cell, name);
this.requestInvalidate.emit({ source: 'removeCellClass' });
}
}
}, {
key: 'addRowClass',
value: function addRowClass(row, name) {
var force = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
if (force) {
row.addClassCore(name);
} else {
this.rowBox.addClass(row, name);
this.requestInvalidate.emit({ source: 'addRowClass' });
}
}
}, {
key: 'removeRowClass',
value: function removeRowClass(row, name) {
var force = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
if (force) {
row.removeClassCore(name);
} else {
this.rowBox.removeClass(row, name);
this.requestInvalidate.emit({ source: 'removeRowClass' });
}
}
}, {
key: 'addColumnClass',
value: function addColumnClass(column, name) {
var force = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
if (force) {
column.addClassCore(name);
} else {
this.columnBox.addClass(column, name);
this.requestInvalidate.emit({ source: 'addColumnClass' });
}
}
}, {
key: 'removeColumnClass',
value: function removeColumnClass(column, name) {
var force = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
if (force) {
column.removeClassCore(name);
} else {
this.columnBox.removeClass(column, name);
this.requestInvalidate.emit({ source: 'removeColumnClass' });
}
}
}, {
key: 'columns',
value: function columns() {
var _this2 = this;
var columns = this.context.view.columns();
return columns.map(function (_, i) {
return _this2.createColumnCore(i);
});
}
}, {
key: 'rows',
value: function rows(columnIndex) {
var _this3 = this;
var mapper = this.context.mapper;
return this.selector.rows(columnIndex).map(function (row) {
return _this3.createRowCore(mapper.rowToView(row.index), row.element);
});
}
}, {
key: 'rowCount',
value: function rowCount() {
return this.model.pagination().count;
}
}, {
key: 'rowCore',
value: function rowCore(index) {
var viewIndex = this.context.mapper.rowToView(index);
if (viewIndex >= 0 && viewIndex < get(VirtualBox.prototype.__proto__ || Object.getPrototypeOf(VirtualBox.prototype), 'rowCount', this).call(this, 0)) {
return get(VirtualBox.prototype.__proto__ || Object.getPrototypeOf(VirtualBox.prototype), 'rowCore', this).call(this, viewIndex);
}
var createRect = this.rowRectFactory();
return this.createRowCore(viewIndex, new VirtualElement(createRect(viewIndex)));
}
}, {
key: 'cellCore',
value: function cellCore(rowIndex, columnIndex) {
var mapper = this.context.mapper;
var viewRowIndex = mapper.rowToView(rowIndex);
var viewColumnIndex = mapper.columnToView(columnIndex);
if (viewRowIndex >= 0 && viewRowIndex < get(VirtualBox.prototype.__proto__ || Object.getPrototypeOf(VirtualBox.prototype), 'rowCount', this).call(this, viewColumnIndex)) {
return get(VirtualBox.prototype.__proto__ || Object.getPrototypeOf(VirtualBox.prototype), 'cellCore', this).call(this, viewRowIndex, viewColumnIndex);
}
var createRect = this.cellRectFactory();
return this.createCellCore(viewRowIndex, viewColumnIndex, new VirtualElement(createRect(viewRowIndex, viewColumnIndex)));
}
}, {
key: 'rowCellsCore',
value: function rowCellsCore(index) {
var _this4 = this;
var mapper = this.context.mapper;
var viewIndex = mapper.rowToView(index);
if (viewIndex >= 0 && viewIndex < get(VirtualBox.prototype.__proto__ || Object.getPrototypeOf(VirtualBox.prototype), 'rowCount', this).call(this, 0)) {
return get(VirtualBox.prototype.__proto__ || Object.getPrototypeOf(VirtualBox.prototype), 'rowCellsCore', this).call(this, viewIndex);
}
var createRect = this.cellRectFactory();
return get(VirtualBox.prototype.__proto__ || Object.getPrototypeOf(VirtualBox.prototype), 'rowCellsCore', this).call(this, 0).map(function (cell, columnIndex) {
return _this4.createCellCore(viewIndex, columnIndex, new VirtualElement(createRect(viewIndex, mapper.columnToView(columnIndex))));
});
}
}, {
key: 'createRowCore',
value: function createRowCore(index, element) {
return new VirtualRow(this, index, element);
}
}, {
key: 'createCellCore',
value: function createCellCore(rowIndex, columnIndex, element) {
return new VirtualCell(this, rowIndex, columnIndex, element);
}
}, {
key: 'createColumnCore',
value: function createColumnCore(index) {
return new VirtualColumn(this, index);
}
}, {
key: 'rowRectFactory',
value: function rowRectFactory() {
var _this5 = this;
var _model$row = this.model.row(),
height = _model$row.height;
var getHeight = isFunction(height) ? height : function () {
return height;
};
var rect = null;
// as view.rect() can call getBoundingClientRect that impacts performance
// and as virtual element rect function is used mostly for end/home navigation we make rect lazy
return function (index) {
return function () {
if (!rect) {
rect = _this5.context.view.rect();
}
// TODO: add correct left, right, width
var rowHeight = getHeight(null, index);
return {
left: 0,
right: 0,
top: rect.top + rowHeight * index,
bottom: rect.top + rowHeight * (index + 1),
width: 0,
height: rowHeight
};
};
};
}
}, {
key: 'cellRectFactory',
value: function cellRectFactory() {
var _this6 = this;
var _model$row2 = this.model.row(),
height = _model$row2.height;
var getHeight = isFunction(height) ? height : function () {
return height;
};
var _model$pagination = this.model.pagination(),
count = _model$pagination.count;
var form = this.model.layout().columns;
var _model$view = this.model.view(),
columns = _model$view.columns;
var rect = null;
// as view.rect() can call getBoundingClientRect that impacts performance
// and as virtual element rect function is used mostly for end/home navigation we make rect lazy
return function (rowIndex, columnIndex) {
return function () {
if (!rect) {
rect = _this6.context.view.rect();
}
var column = columns[columnIndex];
// TODO: add correct left, right, width
var height = getHeight(null, rowIndex);
var top = rect.top + height * rowIndex - (rowIndex > 0 ? 0 : (count + rowIndex) * height);
var width = form.has(column.key) ? form.get(column.key).width : 0;
var left = 0;
return {
left: left,
right: left + width,
top: top,
bottom: top + height,
width: width,
height: height
};
};
};
}
}]);
return VirtualBox;
}(Box);
var Body = function (_Box) {
inherits(Body, _Box);
function Body(context, model, markup) {
classCallCheck(this, Body);
return possibleConstructorReturn(this, (Body.__proto__ || Object.getPrototypeOf(Body)).call(this, context, model, new SelectorMark(model, markup, 'body')));
}
return Body;
}(Box);
var VirtualBody = function (_VirtualBox) {
inherits(VirtualBody, _VirtualBox);
function VirtualBody(context, model, markup) {
classCallCheck(this, VirtualBody);
return possibleConstructorReturn(this, (VirtualBody.__proto__ || Object.getPrototypeOf(VirtualBody)).call(this, context, model, new SelectorMark(model, markup, 'body')));
}
return VirtualBody;
}(VirtualBox);
var Foot = function (_Box) {
inherits(Foot, _Box);
function Foot(context, model, markup) {
classCallCheck(this, Foot);
return possibleConstructorReturn(this, (Foot.__proto__ || Object.getPrototypeOf(Foot)).call(this, context, model, new SelectorMark(model, markup, 'foot')));
}
return Foot;
}(Box);
var Table = function () {
function Table(model, markup) {
var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
classCallCheck(this, Table);
this.model = model;
this.markup = markup;
var scroll = model.scroll;
this.context = assignWith({
mapper: {
rowToView: function rowToView(index) {
return scroll().map.rowToView(index);
},
viewToRow: function viewToRow(index) {
return scroll().map.viewToRow(index);
},
columnToView: identity$1,
viewToColumn: identity$1
},
layer: function layer() {
return new FakeLayer();
},
bag: {
head: new Bag(),
body: new Bag(),
foot: new Bag()
}
}, context);
this.head = this.headCore();
this.body = this.bodyCore();
this.foot = this.footCore();
}
createClass(Table, [{
key: 'headCore',
value: function headCore() {
var context = this.box('head');
return new Head(context, this.model, this.markup);
}
}, {
key: 'bodyCore',
value: function bodyCore() {
var context = this.box('body');
if (this.model.scroll().mode === 'virtual') {
return new VirtualBody(context, this.model, this.markup);
}
return new Body(context, this.model, this.markup);
}
}, {
key: 'footCore',
value: function footCore() {
var context = this.box('foot');
return new Foot(context, this.model, this.markup);
}
}, {
key: 'box',
value: function box(source) {
var view = this.view,
data = this.data;
var _context = this.context,
mapper = _context.mapper,
layer = _context.layer,
bag = _context.bag;
switch (source) {
case 'body':
{
return {
mapper: mapper,
layer: layer,
bag: bag[source],
view: view,
data: data
};
}
default:
{
return {
mapper: {
rowToView: identity$1,
viewToRow: identity$1,
columnToView: identity$1,
viewToColumn: identity$1
},
layer: layer,
bag: bag[source],
view: view,
data: data
};
}
}
}
}, {
key: 'view',
get: function get$$1() {
if (this._view) {
return this._view;
}
return this._view = new View(this.context, this.model, this.markup);
}
}, {
key: 'data',
get: function get$$1() {
if (this._data) {
return this._data;
}
return this._data = new Data(this.model);
}
}]);
return Table;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var PluginService = function () {
/**
* @param {?} root
*/
function PluginService(root) {
classCallCheck(this, PluginService);
this.root = root;
this.modelProxy = null;
}
/**
* @return {?}
*/
createClass(PluginService, [{
key: 'keep',
/**
* @param {?} changes
* @param {?} models
* @return {?}
*/
value: function keep(changes, models) {
var /** @type {?} */host = {};
for (var /** @type {?} */key in changes) {
var /** @type {?} */change = changes[key];
host[key] = change.currentValue;
}
var /** @type {?} */binder = new ModelBinder(host);
var /** @type {?} */commit = binder.bound(this.model, models, false, false);
commit();
}
/**
* @return {?}
*/
}, {
key: 'ngOnDestroy',
value: function ngOnDestroy() {
if (this.modelProxy) {
this.modelProxy.dispose();
this.modelProxy = null;
}
}
}, {
key: 'model',
get: function get$$1() {
var model = this.root.model;
if (!this.modelProxy) {
Guard.notNull(model, 'model');
this.modelProxy = new ModelProxy(model);
return this.modelProxy.subject;
}
if (model !== this.modelProxy.target) {
this.modelProxy.dispose();
Guard.notNull(model, 'model');
this.modelProxy = new ModelProxy(model);
return this.modelProxy.subject;
}
return this.modelProxy.subject;
}
/**
* @return {?}
*/
}, {
key: 'table',
get: function get$$1() {
var table = this.root.table;
Guard.notNull(table, 'table');
return table;
}
}]);
return PluginService;
}();
PluginService.decorators = [{ type: Injectable }];
/** @nocollapse */
PluginService.ctorParameters = function () {
return [{ type: RootService }];
};
function PluginService_tsickle_Closure_declarations() {
/** @type {?} */
PluginService.prototype.modelProxy;
/** @type {?} */
PluginService.prototype.root;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var GridService$1 = function () {
function GridService$$1() {
classCallCheck(this, GridService$$1);
}
/**
* @return {?}
*/
createClass(GridService$$1, [{
key: 'model',
value: function model() {
return new Model$1();
}
/**
* @param {?} model
* @return {?}
*/
}, {
key: 'service',
value: function service(model) {
return new GridService(model);
}
/**
* @return {?}
*/
}, {
key: 'noop',
get: function get$$1() {
return noop$1;
}
/**
* @return {?}
*/
}, {
key: 'identity',
get: function get$$1() {
return identity$1;
}
/**
* @return {?}
*/
}, {
key: 'pipe',
get: function get$$1() {
return Pipe$1;
}
/**
* @return {?}
*/
}, {
key: 'pipeUnit',
get: function get$$1() {
return PipeUnit;
}
/**
* @return {?}
*/
}, {
key: 'Command',
get: function get$$1() {
return Command;
}
/**
* @return {?}
*/
}, {
key: 'Action',
get: function get$$1() {
return Action;
}
/**
* @return {?}
*/
}, {
key: 'Node',
get: function get$$1() {
return Node;
}
/**
* @return {?}
*/
}, {
key: 'RowDetailsStatus',
get: function get$$1() {
return RowDetailsStatus;
}
/**
* @return {?}
*/
}, {
key: 'valueFactory',
get: function get$$1() {
return getFactory;
}
/**
* @return {?}
*/
}, {
key: 'labelFactory',
get: function get$$1() {
return getFactory$1;
}
}]);
return GridService$$1;
}();
GridService$1.decorators = [{ type: Injectable }];
/** @nocollapse */
GridService$1.ctorParameters = function () {
return [];
};
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var ThemeService = function () {
function ThemeService() {
classCallCheck(this, ThemeService);
this.themeName = '';
this.changed = new Event$1();
}
/**
* @return {?}
*/
createClass(ThemeService, [{
key: 'name',
get: function get$$1() {
return this.themeName;
}
/**
* @param {?} value
* @return {?}
*/
,
set: function set$$1(value) {
if (value !== this.themeName) {
this.themeName = value;
this.changed.emit({
newValue: value,
oldValue: value
});
}
}
}]);
return ThemeService;
}();
ThemeService.decorators = [{ type: Injectable }];
/** @nocollapse */
ThemeService.ctorParameters = function () {
return [];
};
function ThemeService_tsickle_Closure_declarations() {
/** @type {?} */
ThemeService.prototype.themeName;
/** @type {?} */
ThemeService.prototype.changed;
/** @type {?} */
ThemeService.prototype.component;
}
var CompositeCommandManager = function () {
function CompositeCommandManager(manager) {
classCallCheck(this, CompositeCommandManager);
this.manager = manager;
}
createClass(CompositeCommandManager, [{
key: "filter",
value: function filter(commands) {
return this.manager.filter(commands);
}
}, {
key: "invoke",
value: function invoke(commands) {
return this.manager.invoke(commands);
}
}]);
return CompositeCommandManager;
}();
var SelectionCommandManager = function (_CompositeCommandMana) {
inherits(SelectionCommandManager, _CompositeCommandMana);
function SelectionCommandManager(model, manager) {
classCallCheck(this, SelectionCommandManager);
var _this = possibleConstructorReturn(this, (SelectionCommandManager.__proto__ || Object.getPrototypeOf(SelectionCommandManager)).call(this, manager));
_this.model = model;
return _this;
}
createClass(SelectionCommandManager, [{
key: 'filter',
value: function filter(commands) {
if (this.model.edit().state === 'edit') {
var cell = this.model.navigation().cell;
if (cell && cell.column.type !== 'select') {
return [];
}
}
return get(SelectionCommandManager.prototype.__proto__ || Object.getPrototypeOf(SelectionCommandManager.prototype), 'filter', this).call(this, commands);
}
}]);
return SelectionCommandManager;
}(CompositeCommandManager);
var CacheStrategy = function CacheStrategy(model, strategy) {
var _this = this;
classCallCheck(this, CacheStrategy);
var storage = new Map();
var defaultGetValue = function defaultGetValue(row, column, select, rowIndex, columnIndex) {
var key = 'valueFactory-' + column.key;
select = storage.get(key);
if (!select) {
select = getFactory(column);
storage.set(key, select);
}
return strategy.getValue(row, column, select, rowIndex, columnIndex);
};
var readonlyGetValue = function readonlyGetValue(row, column, select, rowIndex, columnIndex) {
var key = 'getValue-' + rowIndex + 'x' + column.key;
if (storage.has(key)) {
return storage.get(key);
}
var value = defaultGetValue(row, column, select, rowIndex, columnIndex);
storage.set(key, value);
return value;
};
var defaultGetLabel = function defaultGetLabel(row, column, select, rowIndex, columnIndex) {
var key = 'labelFactory-' + column.key;
select = storage.get(key);
if (!select) {
select = getFactory$1(column);
storage.set(key, select);
}
return strategy.getLabel(row, column, select, rowIndex, columnIndex);
};
var readonlyGetLabel = function readonlyGetLabel(row, column, select, rowIndex, columnIndex) {
var key = 'getLabel-' + rowIndex + 'x' + column.key;
if (storage.has(key)) {
return storage.get(key);
}
var value = defaultGetLabel(row, column, select, rowIndex, columnIndex);
storage.set(key, value);
return value;
};
this.getValue = defaultGetValue;
this.getLabel = defaultGetLabel;
this.colspan = function (row, column, rowIndex, columnIndex) {
var key = 'colspan-' + rowIndex + 'x' + column.model.key;
if (storage.has(key)) {
return storage.get(key);
}
var value = strategy.colspan(row, column, rowIndex, columnIndex);
storage.set(key, value);
return value;
};
this.rowspan = function (row, column, rowIndex, columnIndex) {
var key = 'rowspan-' + rowIndex + 'x' + column.model.key;
if (storage.has(key)) {
return storage.get(key);
}
var value = strategy.rowspan(row, column, rowIndex, columnIndex);
storage.set(key, value);
return value;
};
this.columns = function (row, pin, rowIndex) {
var key = 'columns-' + pin + '-' + rowIndex;
if (storage.has(key)) {
return storage.get(key);
}
var value = strategy.columns(row, pin, rowIndex);
storage.set(key, value);
return value;
};
this.setValue = function () {
return strategy.setValue.apply(strategy, arguments);
};
this.setLabel = function () {
return strategy.setLabel.apply(strategy, arguments);
};
this.columnList = function () {
var pin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
var key = 'columnList-' + pin;
if (storage.has(key)) {
return storage.get(key);
}
var value = strategy.columnList(pin);
storage.set(key, value);
return value;
};
model.sceneChanged.watch(function (e) {
if (e.hasChanges('status')) {
if (e.state.status !== 'stop') {
storage = new Map();
}
}
});
model.gridChanged.watch(function (e) {
if (e.hasChanges('isReadonly')) {
storage = new Map();
if (e.state.isReadonly) {
_this.getValue = readonlyGetValue;
_this.getLabel = readonlyGetLabel;
} else {
_this.getValue = getValue;
_this.getLabel = _this.getLabel;
}
}
});
};
function defaultGetValue(row, column, select) {
return select(row, column);
}
// This class is not inheritable, but construct in a way to use it as a composition without binding to `this`.
var DataRow = function DataRow(model) {
classCallCheck(this, DataRow);
var area = {};
var line = [];
model.sceneChanged.watch(function (e) {
if (e.hasChanges('column')) {
area = e.state.column.area;
line = e.state.column.line;
}
});
this.getValue = defaultGetValue;
this.getLabel = defaultGetValue;
this.setValue = set$1;
this.setLabel = set$2;
this.colspan = function (row, column) {
return column.colspan;
};
this.rowspan = function () {
return 1;
};
var columnList = function columnList() {
var pin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
if (isUndefined(pin)) {
return line;
}
return area[pin] || [];
};
this.columnList = columnList;
this.columns = function (row, pin) {
return columnList(pin);
};
};
var DetailsRow = function DetailsRow(dataRow) {
classCallCheck(this, DetailsRow);
this.columns = dataRow.getColumns;
this.rowspan = dataRow.rowspan;
this.colspan = function (rowDetails, column) {
return sumBy(dataRow.columnList(column.model.pin), function (c) {
return c.colspan;
});
};
this.columns = function (rowDetails, pin) {
if (rowDetails.column.model.pin === pin) {
return [rowDetails.column];
}
return dataRow.columnList(pin);
};
this.getValue = function () {
throw new AppError('details.row', 'Can\'t get value from row details');
};
this.getLabel = function () {
throw new AppError('details.row', 'Can\'t get label from row details');
};
this.setValue = function () {
throw new AppError('details.row', 'Can\'t set value to row details');
};
this.setLabel = function () {
throw new AppError('details.row', 'Can\'t set label to row details');
};
};
var Aggregation = function () {
function Aggregation() {
classCallCheck(this, Aggregation);
}
createClass(Aggregation, null, [{
key: 'first',
value: function first(rows, getValue) {
if (!rows.length) {
return null;
}
return getValue(rows[0]);
}
}, {
key: 'last',
value: function last(rows, getValue) {
var length = rows.length;
if (!length) {
return null;
}
return getValue(rows[length - 1]);
}
}, {
key: 'max',
value: function max(rows, getValue) {
var length = rows.length;
if (!length) {
return null;
}
var max = Number.MIN_SAFE_INTEGER;
while (length--) {
max = Math.max(max, getValue(rows[length]));
}
return max;
}
}, {
key: 'min',
value: function min(rows, getValue) {
var length = rows.length;
if (!length) {
return null;
}
var min = Number.MAX_SAFE_INTEGER;
while (length--) {
min = Math.min(min, getValue(rows[length]));
}
return min;
}
}, {
key: 'minMax',
value: function minMax(rows, getValue) {
var length = rows.length;
if (!length) {
return null;
}
var min = Number.MAX_SAFE_INTEGER;
var max = Number.MIN_SAFE_INTEGER;
while (length--) {
var value = getValue(rows[length]);
min = Math.min(min, value);
max = Math.max(max, value);
}
return [min, max];
}
}, {
key: 'avg',
value: function avg(rows, getValue, options) {
var length = rows.length;
if (!length) {
return null;
}
if (options.distinct) {
var set$$1 = new Set();
return Aggregation.sum(rows, getValue, options, set$$1) / set$$1.size;
}
return Aggregation.sum(rows, getValue, options) / length;
}
}, {
key: 'sum',
value: function sum(rows, getValue, options, set$$1) {
var length = rows.length;
if (!length) {
return null;
}
var sum = 0;
if (options.distinct) {
set$$1 = set$$1 || new Set();
while (length--) {
var value = getValue(rows[length]);
if (!set$$1.has(value)) {
sum += value;
set$$1.add(value);
}
}
} else {
while (length--) {
sum += Number(getValue(rows[length]));
}
}
return sum;
}
}, {
key: 'join',
value: function join(rows, getValue, options) {
var length = rows.length;
if (!length) {
return null;
}
var result = getValue(rows[0]);
var separator = options.separator || '';
if (options.distinct) {
var set$$1 = new Set();
var value = result;
set$$1.add(value);
var i = 1;
while (i < length) {
value = getValue(rows[i]);
if (!set$$1.has(value)) {
result += separator + value;
set$$1.add(value);
}
i++;
}
} else {
var _i = 1;
while (_i < length) {
result += separator + getValue(rows[_i]);
_i++;
}
}
return result;
}
}, {
key: 'count',
value: function count(rows, getValue, options) {
var length = rows.length;
if (!length) {
return null;
}
if (options.distinct) {
var set$$1 = new Set();
while (length--) {
var count = Number(getValue(rows[length]));
set$$1.add(count);
}
return set$$1.size;
}
return length;
}
}]);
return Aggregation;
}();
var NodeRow = function NodeRow(model, dataRow) {
classCallCheck(this, NodeRow);
var columnList = dataRow.columnList,
rowspan = dataRow.rowspan;
this.columnList = columnList;
this.rowspan = rowspan;
var createColumn = columnFactory(model);
var reference = {
group: createColumn('group'),
summary: createColumn('group-summary')
};
this.getLabel = this.getValue = function (node, column, select, rowIndex, columnIndex) {
if (column.type === 'pivot') {
return dataRow.getLabel(node, column, select, rowIndex, columnIndex);
}
var _model$data = model.data(),
rows = _model$data.rows;
switch (node.type) {
case 'group':
case 'summary':
{
var agg = column.aggregation;
if (agg) {
if (!Aggregation.hasOwnProperty(agg)) {
throw new AppError('node.row', 'Aggregation ' + agg + ' is not supported');
}
var groupRows = node.rows.map(function (i) {
return rows[i];
});
return Aggregation[agg](groupRows, select, column.aggregationOptions);
}
return null;
}
case 'row':
{
var _rowIndex = node.rows[0];
return select(rows[_rowIndex], column);
}
case 'value':
{
return select(node, column);
}
default:
throw new AppError('node.row', 'Invalid node type ' + node.type);
}
};
this.setValue = function (node, column, value, rowIndex, columnIndex) {
switch (node.type) {
case 'row':
{
var _model$data2 = model.data(),
rows = _model$data2.rows;
var _rowIndex2 = node.rows[0];
dataRow.setValue(rows[_rowIndex2], column, value, _rowIndex2, columnIndex);
break;
}
case 'value':
{
dataRow.setValue(node, column, value, rowIndex, columnIndex);
break;
}
default:
throw new AppError('node.row', 'Can\'t set value to ' + node.type + ' node');
}
};
this.setLabel = function (node, column, value, rowIndex, columnIndex) {
switch (node.type) {
case 'row':
{
var _model$data3 = model.data(),
rows = _model$data3.rows;
var _rowIndex3 = node.rows[0];
dataRow.setLabel(rows[_rowIndex3], column, value, _rowIndex3, columnIndex);
break;
}
case 'value':
{
dataRow.setLabel(node, column, value, rowIndex, columnIndex);
break;
}
default:
throw new AppError('node.row', 'Can\'t set label to ' + node.type + ' node');
}
};
this.colspan = function (node, column) {
if (node.type === 'summary') {
return sumBy(columnList(column.model.pin), function (c) {
return c.colspan;
});
}
return column.colspan;
};
this.columns = function (node, pin) {
if (node.type === 'summary') {
// TODO: add pin support
return [reference.summary];
}
return columnList(pin);
};
this.findGroupColumn = function (pin) {
var columns = columnList();
var groupColumn = columns.find(function (c) {
return c.model.type === 'group';
});
if (!groupColumn) {
groupColumn = reference.group;
if (groupColumn.model.pin === pin) {
var firstColumn = columnList(pin)[0];
groupColumn.columnIndex = firstColumn ? firstColumn.columnIndex : 0;
}
}
return groupColumn.model.pin !== pin ? null : groupColumn;
};
};
var RowspanNodeRow = function RowspanNodeRow(model, nodeRow) {
classCallCheck(this, RowspanNodeRow);
var columnList = nodeRow.columnList,
getValue = nodeRow.getValue,
getLabel = nodeRow.getLabel,
columns = nodeRow.columns;
this.setValue = nodeRow.setValue;
this.setLabel = nodeRow.setLabel;
this.colspan = nodeRow.colspan;
this.columnList = columnList;
var rowspan = function rowspan(node, column) {
var isRoot = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
switch (node.type) {
case 'group':
{
if (column.model.type === 'group') {
if (node.state.expand) {
if (!isRoot || node.source === column.model.by) {
return node.children.reduce(function (memo, child, i) {
return memo + rowspan(child, column, false);
}, 0);
} else {
if (node.children.length) {
return rowspan(node.children[0], column, false);
}
}
}
return 1;
}
}
}
return 1;
};
this.rowspan = rowspan;
var spanValue = function spanValue(getValue) {
return function (node, column, select) {
switch (node.type) {
case 'group':
{
var leaf = findFirstLeaf(node);
if (leaf) {
var _model$data4 = model.data(),
rows = _model$data4.rows;
var rowIndex = leaf.rows[0];
return select(rows[rowIndex], column);
}
return null;
}
}
return getValue(node, column, select);
};
};
this.getLabel = spanValue(getLabel);
this.getValue = spanValue(getValue);
this.columns = function (node, pin) {
switch (node.type) {
case 'group':
{
return dropWhile(columnList(pin), function (c) {
return c.model.type === 'group' && c.model.by !== node.source;
});
}
case 'row':
{
return columnList(pin).filter(function (c) {
return c.model.type !== 'group';
});
}
}
return columns(node, pin);
};
};
var SubheadNodeRow = function SubheadNodeRow(nodeRow) {
classCallCheck(this, SubheadNodeRow);
var columnList = nodeRow.columnList,
columns = nodeRow.columns,
findGroupColumn = nodeRow.findGroupColumn;
this.setValue = nodeRow.setValue;
this.setLabel = nodeRow.setLabel;
this.getValue = nodeRow.getValue;
this.getLabel = nodeRow.getLabel;
this.rowspan = nodeRow.rowspan;
this.columnList = columnList;
this.colspan = function (node, column) {
switch (node.type) {
case 'group':
{
if (column.model.type === 'group') {
var groupColumn = findGroupColumn(column.model.pin);
if (groupColumn) {
var nearGroupColumns = columnList(column.model.pin);
var groupSpan = takeWhile(nearGroupColumns, function (c) {
return !c.model.aggregation;
});
return sumBy(groupSpan, function (c) {
return c.colspan;
});
}
}
break;
}
}
return nodeRow.colspan(node, column);
};
this.columns = function (node, pin) {
switch (node.type) {
case 'group':
{
var groupColumn = findGroupColumn(pin);
if (groupColumn) {
var nextColumns = dropWhile(columnList(pin), function (c) {
return !c.model.aggregation;
});
return [groupColumn].concat(nextColumns);
}
break;
}
}
return columns(node, pin);
};
};
function groupBuilder(model) {
var _model$data = model.data(),
rows = _model$data.rows;
var _model$view = model.view(),
pivot = _model$view.pivot;
var nodes = model.view().rows;
var columns = model.columnList().line;
var pivotRows = pivot.rows;
var pivotRowLength = pivotRows[0].length;
var groupBy = model.group().by;
var groupByLength = groupBy.length;
var columnMap = map$1(columns);
return function (valueFactory) {
var result = [];
var _loop = function _loop(i, nodeLength) {
var node = nodes[i];
var key = groupBy[Math.min(node.level, groupByLength - 1)];
var column = columnMap[key];
if (!column) {
throw new AppError('group.build', 'Invalid key "' + key + '"');
}
var aggregation = column.aggregation || 'count';
if (!Aggregation.hasOwnProperty(aggregation)) {
throw new AppError('group.build', 'Aggregation ' + aggregation + ' is not registered');
}
var getValue = valueFactory(column);
var aggregate = Aggregation[aggregation];
var aggRow = new Array(pivotRowLength);
for (var j = 0, rowLength = node.rows.length; j < rowLength; j++) {
var rowIndex = node.rows[j];
var pivotRow = pivotRows[rowIndex];
var row = rows[rowIndex];
for (var k = 0; k < pivotRowLength; k++) {
if (pivotRow[k]) {
var value = aggRow[k];
if (!value) {
value = [];
aggRow[k] = value;
}
value.push(row);
}
}
}
result.push(aggRow.map(function (rs) {
return aggregate(rs, getValue, column.aggregationOptions);
}));
};
for (var i = 0, nodeLength = nodes.length; i < nodeLength; i++) {
_loop(i, nodeLength);
}
return result;
};
}
var PivotRow = function PivotRow(model, dataRow) {
var _this = this;
classCallCheck(this, PivotRow);
this.columns = dataRow.columns;
this.rowspan = dataRow.rowspan;
this.colspan = dataRow.colspan;
this.getValue = dataRow.getValue;
this.setValue = dataRow.setValue;
this.getLabel = dataRow.getLabel;
this.setLabel = dataRow.setLabel;
this.columnList = dataRow.columnList;
var pivotRows = [];
model.sceneChanged.watch(function (e) {
if (e.hasChanges('column') || e.hasChanges('rows')) {
var rows = model.view().pivot.rows;
if (rows.length) {
if (model.group().by.length) {
var build = groupBuilder(model);
pivotRows = build(getFactory);
} else {
pivotRows = rows;
}
var pivotIndex = e.state.column.line.findIndex(function (c) {
return c.model.type === 'pivot';
});
_this.getValue = function (row, column, select, rowIndex, columnIndex) {
if (column.type === 'pivot') {
var pivotRow = pivotRows[rowIndex];
return pivotRow[columnIndex - pivotIndex];
}
return dataRow.getValue(row, column, select, rowIndex, columnIndex);
};
_this.getLabel = function (row, column, select, rowIndex, columnIndex) {
if (column.type === 'pivot') {
var pivotRow = pivotRows[rowIndex];
return pivotRow[columnIndex - pivotIndex];
}
return dataRow.getLabel(row, column, select, rowIndex, columnIndex);
};
} else {
pivotRows = [];
_this.getValue = dataRow.getValue;
_this.getLabel = dataRow.getLabel;
}
}
});
};
var Renderer = function Renderer(model) {
var _this = this;
classCallCheck(this, Renderer);
var dataRow = new DataRow(model);
var pivotRow = new CacheStrategy(model, new PivotRow(model, dataRow));
var nodeRow = new NodeRow(model, pivotRow);
var nestNodeRow = new CacheStrategy(model, nodeRow);
var subheadNodeRow = new CacheStrategy(model, new SubheadNodeRow(nodeRow));
var rowspanNodeRow = new CacheStrategy(model, new RowspanNodeRow(model, nodeRow));
var rowDetails = new CacheStrategy(model, new DetailsRow(pivotRow));
var defaultStrategy = pivotRow;
var strategies = new Map();
strategies.set(RowDetails, rowDetails);
var selectNodeRowStrategy = function selectNodeRowStrategy() {
var _model$group = model.group(),
mode = _model$group.mode;
switch (mode) {
case 'subhead':
strategies.set(Node$1, subheadNodeRow);
break;
case 'rowspan':
strategies.set(Node$1, rowspanNodeRow);
break;
default:
strategies.set(Node$1, nestNodeRow);
break;
}
};
selectNodeRowStrategy();
model.groupChanged.on(selectNodeRowStrategy);
// Public interface
this.defaultStrategy = defaultStrategy;
this.colspan = function (row, column, rowIndex, columnIndex) {
var strategy = strategies.get(row.constructor) || defaultStrategy;
return strategy.colspan(row, column, rowIndex, columnIndex);
};
this.rowspan = function (row, column, rowIndex, columnIndex) {
var strategy = strategies.get(row.constructor) || defaultStrategy;
return strategy.rowspan(row, column, rowIndex, columnIndex);
};
this.columns = function (row, pin, rowIndex) {
var strategy = strategies.get(row.constructor) || defaultStrategy;
return strategy.columns(row, pin, rowIndex);
};
this.getValue = function (row, column, rowIndex, columnIndex) {
var strategy = strategies.get(row.constructor) || defaultStrategy;
return strategy.getValue(row, column, get$2, rowIndex, columnIndex);
};
this.setValue = function (row, column, value, rowIndex, columnIndex) {
var strategy = strategies.get(row.constructor) || defaultStrategy;
return strategy.setValue(row, column, value, rowIndex, columnIndex);
};
this.getLabel = function (row, column, rowIndex, columnIndex) {
var strategy = strategies.get(row.constructor) || defaultStrategy;
return strategy.getLabel(row, column, get$3, rowIndex, columnIndex);
};
this.setLabel = function (row, column, value, rowIndex, columnIndex) {
var strategy = strategies.get(row.constructor) || defaultStrategy;
return strategy.setLabel(row, column, value, rowIndex, columnIndex);
};
this.rows = {
left: [],
right: [],
null: []
};
var invalidateRows = function invalidateRows() {
var _model$scene = model.scene(),
rows = _model$scene.rows;
var _model$row = model.row(),
pinTop = _model$row.pinTop,
pinBottom = _model$row.pinBottom;
_this.rows = {
top: pinTop,
body: rows,
bottom: pinBottom
};
};
model.sceneChanged.watch(function (e) {
if (e.hasChanges('rows')) {
invalidateRows();
}
});
model.rowChanged.watch(function (e) {
if (e.hasChanges('pinTop') || e.hasChanges('pinBottom')) {
invalidateRows();
}
});
};
var BodyView = function () {
function BodyView(model, table) {
var _this = this;
classCallCheck(this, BodyView);
this.model = model;
this.table = table;
this.rows = [];
var render = new Renderer(model);
this.render = render;
this.columns = function (pin) {
return render.defaultStrategy.columnList(pin);
};
var wasInvalidated = false;
model.sceneChanged.watch(function (e) {
if (e.hasChanges('rows')) {
_this.invalidate();
wasInvalidated = true;
}
});
model.rowChanged.watch(function (e) {
if (e.hasChanges('pinTop') || e.hasChanges('pinBottom')) {
_this.invalidate();
wasInvalidated = true;
}
});
if (!wasInvalidated) {
this.invalidate();
}
}
createClass(BodyView, [{
key: 'invalidate',
value: function invalidate() {
Log.info('view.body', 'invalidate');
var model = this.model;
var table = this.table;
var _model$scene = model.scene(),
rows = _model$scene.rows;
if (!(rows.length || model.data().rows.length)) {
if (!table.view.hasLayer('blank')) {
table.view.addLayer('blank');
}
} else {
if (table.view.hasLayer('blank')) {
table.view.removeLayer('blank');
}
}
}
}]);
return BodyView;
}();
var Fetch = function () {
function Fetch(select) {
classCallCheck(this, Fetch);
this.select = select;
this.busy = null;
this.result = null;
}
createClass(Fetch, [{
key: 'run',
value: function run(item) {
var _this = this,
_arguments = arguments;
var select = this.select;
this.result = null;
var alive = true;
this.busy = new Promise(function (resolveBusy, rejectBusy) {
var resolve = function resolve(data) {
if (alive) {
_this.result = data;
resolveBusy(data);
}
};
if (isFunction(select)) {
var deferred = {
resolve: resolve,
reject: rejectBusy
};
var args = Array.from(_arguments).slice(1) || [];
var result = select.apply(undefined, [item, deferred].concat(toConsumableArray(args)));
if (!isUndefined(result)) {
_this.invoke(result, resolve, rejectBusy);
}
// when user should invoke d.resolve or d.reject
} else {
_this.invoke(select, resolve, rejectBusy);
}
});
return function () {
_this.busy = null;
alive = false;
};
}
}, {
key: 'invoke',
value: function invoke(instance, resolve, reject) {
if (instance && isFunction(instance.then)) {
// when options.fetch returns promise
instance.then(resolve);
if (isFunction(instance.catch)) {
instance.catch(reject);
}
} else if (instance && isFunction(instance.subscribe)) {
// when options.fetch returns observable
var isProcessed = false;
var subscription = void 0;
subscription = instance.subscribe(function () {
resolve.apply(undefined, arguments);
isProcessed = true;
if (subscription && isFunction(subscription.unsubscribe)) {
// when async
subscription.unsubscribe();
subscription = null;
}
}, reject);
if (isProcessed) {
if (subscription && isFunction(subscription.unsubscribe)) {
// when sync
subscription.unsubscribe();
subscription = null;
}
}
} else {
// when options.fetch return result
resolve(instance);
}
}
}]);
return Fetch;
}();
var CellEditorCore = function () {
function CellEditorCore(td) {
classCallCheck(this, CellEditorCore);
this.td = td;
this.value = null;
this.label = null;
this.fetch = noop$1;
this.resetFetch = noop$1;
}
createClass(CellEditorCore, [{
key: 'commit',
value: function commit() {}
}, {
key: 'reset',
value: function reset() {}
}, {
key: 'clear',
value: function clear() {}
}]);
return CellEditorCore;
}();
var empty = new CellEditorCore(null);
var CellEditor = function (_CellEditorCore) {
inherits(CellEditor, _CellEditorCore);
function CellEditor(td) {
classCallCheck(this, CellEditor);
var _this = possibleConstructorReturn(this, (CellEditor.__proto__ || Object.getPrototypeOf(CellEditor)).call(this, td));
_this.fetch = _this.fetchFactory();
_this.resetFetch = _this.fetch.run(td.row);
if (isUndefined(td.value)) {
_this.value = null;
} else {
var parse = parseFactory(td.column.type, td.column.editor);
var typedValue = parse(clone(td.value));
_this.value = typedValue === null ? td.value : typedValue;
}
_this.label = isUndefined(td.label) ? null : clone(td.label);
return _this;
}
createClass(CellEditor, [{
key: 'commit',
value: function commit() {
this.td.value = this.value;
this.td.label = this.label;
this.resetFetch();
this.resetFetch = noop$1;
}
}, {
key: 'reset',
value: function reset() {
this.label = this.td.label;
this.value = this.td.value;
this.resetFetch();
this.resetFetch = noop$1;
}
}, {
key: 'clear',
value: function clear() {
this.label = null;
this.value = null;
this.resetFetch();
this.resetFetch = noop$1;
}
}, {
key: 'fetchFactory',
value: function fetchFactory() {
var editorOptions = this.td.column.editorOptions;
if (editorOptions && editorOptions.fetch) {
return new Fetch(editorOptions.fetch);
}
return new Fetch(this.td.value);
}
}, {
key: 'cell',
get: function get$$1() {
return this.td;
}
}], [{
key: 'empty',
get: function get$$1() {
return empty;
}
}]);
return CellEditor;
}(CellEditorCore);
'use strict';
var util = {
isPrimitiveValue: function isPrimitiveValue(value) {
if (typeof value == 'string') return true;
if (typeof value == 'number' && isFinite(value)) return true;
if (typeof value == 'boolean') return true;
return false;
},
looksLikeNumber: function looksLikeNumber(value) {
if (!isNaN(+value)) return true;
return false;
},
isObject: function isObject(obj) {
return Object(obj) === obj && Object.getPrototypeOf(obj) === Object.prototype;
},
isEmptyObject: function isEmptyObject(map) {
for (var key in map) {
if (map.hasOwnProperty(key)) {
return false;
}
}
return true;
},
escapeRegExp: function escapeRegExp(str) {
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
},
isNoValue: function isNoValue(value) {
return value === undefined || value === null || value === '';
}
};
var util_1 = util.isPrimitiveValue;
var util_2 = util.looksLikeNumber;
var util_3 = util.isObject;
var util_4 = util.isEmptyObject;
var util_5 = util.escapeRegExp;
var util_6 = util.isNoValue;
'use strict';
var Common = {
required: function required() {
return function (value) {
if (util.isNoValue(value)) {
return 'REQUIRED';
}
return;
};
},
not_empty: function not_empty() {
return function (value) {
if (value !== null && value !== undefined && value === '') {
return 'CANNOT_BE_EMPTY';
}
return;
};
},
not_empty_list: function not_empty_list() {
return function (list) {
if (list === undefined || list === '') return 'CANNOT_BE_EMPTY';
if (!Array.isArray(list)) return 'FORMAT_ERROR';
if (list.length < 1) return 'CANNOT_BE_EMPTY';
return;
};
},
any_object: function any_object() {
return function (value) {
if (util.isNoValue(value)) return;
if (!util.isObject(value)) {
return 'FORMAT_ERROR';
}
};
}
};
var Common_1 = Common.required;
var Common_2 = Common.not_empty;
var Common_3 = Common.not_empty_list;
var Common_4 = Common.any_object;
'use strict';
var _String = {
string: function string() {
return function (value, params, outputArr) {
if (value === undefined || value === null || value === '') return;
if (!util.isPrimitiveValue(value)) return 'FORMAT_ERROR';
outputArr.push(value + '');
return;
};
},
eq: function eq(allowedValue) {
return function (value, params, outputArr) {
if (value === undefined || value === null || value === '') return;
if (!util.isPrimitiveValue(value)) return 'FORMAT_ERROR';
if (value + '' === allowedValue + '') {
outputArr.push(allowedValue);
return;
}
return 'NOT_ALLOWED_VALUE';
};
},
one_of: function one_of(allowedValues) {
if (!Array.isArray(allowedValues)) {
allowedValues = Array.prototype.slice.call(arguments);
allowedValues.pop(); // pop ruleBuilders
}
return function (value, params, outputArr) {
if (value === undefined || value === null || value === '') return;
if (!util.isPrimitiveValue(value)) return 'FORMAT_ERROR';
for (var i = 0; i < allowedValues.length; i++) {
if (value + '' === allowedValues[i] + '') {
outputArr.push(allowedValues[i]);
return;
}
}
return 'NOT_ALLOWED_VALUE';
};
},
max_length: function max_length(maxLength) {
return function (value, params, outputArr) {
if (value === undefined || value === null || value === '') return;
if (!util.isPrimitiveValue(value)) return 'FORMAT_ERROR';
value += '';
if (value.length > maxLength) return 'TOO_LONG';
outputArr.push(value);
};
},
min_length: function min_length(minLength) {
return function (value, params, outputArr) {
if (value === undefined || value === null || value === '') return;
if (!util.isPrimitiveValue(value)) return 'FORMAT_ERROR';
value += '';
if (value.length < minLength) return 'TOO_SHORT';
outputArr.push(value);
};
},
length_equal: function length_equal(length) {
return function (value, params, outputArr) {
if (value === undefined || value === null || value === '') return;
if (!util.isPrimitiveValue(value)) return 'FORMAT_ERROR';
value += '';
if (value.length < length) return 'TOO_SHORT';
if (value.length > length) return 'TOO_LONG';
outputArr.push(value);
};
},
length_between: function length_between(minLength, maxLength) {
return function (value, params, outputArr) {
if (value === undefined || value === null || value === '') return;
if (!util.isPrimitiveValue(value)) return 'FORMAT_ERROR';
value += '';
if (value.length < minLength) return 'TOO_SHORT';
if (value.length > maxLength) return 'TOO_LONG';
outputArr.push(value);
};
},
like: function like(reStr, flags) {
var isIgnoreCase = arguments.length === 3 && flags.match('i');
var re = new RegExp(reStr, isIgnoreCase ? 'i' : '');
return function (value, params, outputArr) {
if (value === undefined || value === null || value === '') return;
if (!util.isPrimitiveValue(value)) return 'FORMAT_ERROR';
value += '';
if (!value.match(re)) return 'WRONG_FORMAT';
outputArr.push(value);
};
}
};
var _String_1 = _String.string;
var _String_2 = _String.eq;
var _String_3 = _String.one_of;
var _String_4 = _String.max_length;
var _String_5 = _String.min_length;
var _String_6 = _String.length_equal;
var _String_7 = _String.length_between;
var _String_8 = _String.like;
'use strict';
var Numeric = {
integer: function integer() {
return function (value, params, outputArr) {
if (util.isNoValue(value)) return;
if (!util.isPrimitiveValue(value)) return 'FORMAT_ERROR';
if (!util.looksLikeNumber(value)) return 'NOT_INTEGER';
if (!Number.isInteger(+value)) return 'NOT_INTEGER';
outputArr.push(+value);
};
},
positive_integer: function positive_integer() {
return function (value, params, outputArr) {
if (util.isNoValue(value)) return;
if (!util.isPrimitiveValue(value)) return 'FORMAT_ERROR';
if (!util.looksLikeNumber(value)) return 'NOT_POSITIVE_INTEGER';
if (!Number.isInteger(+value) || +value < 1) return 'NOT_POSITIVE_INTEGER';
outputArr.push(+value);
};
},
decimal: function decimal() {
return function (value, params, outputArr) {
if (util.isNoValue(value)) return;
if (!util.isPrimitiveValue(value)) return 'FORMAT_ERROR';
if (!util.looksLikeNumber(value)) return 'NOT_DECIMAL';
value += '';
if (!/^(?:\-?(?:(?:[0-9]+\.[0-9]+)|(?:[0-9]+)))$/.test(value)) return 'NOT_DECIMAL';
outputArr.push(+value);
};
},
positive_decimal: function positive_decimal() {
return function (value, params, outputArr) {
if (util.isNoValue(value)) return;
if (!util.isPrimitiveValue(value)) return 'FORMAT_ERROR';
if (!util.looksLikeNumber(value)) return 'NOT_POSITIVE_DECIMAL';
value += '';
if (!/^(?:(?:[0-9]*\.[0-9]+)|(?:[1-9][0-9]*))$/.test(value)) return 'NOT_POSITIVE_DECIMAL';
outputArr.push(+value);
};
},
max_number: function max_number(maxNumber) {
return function (value, params, outputArr) {
if (util.isNoValue(value)) return;
if (!util.isPrimitiveValue(value)) return 'FORMAT_ERROR';
if (!util.looksLikeNumber(value)) return 'NOT_NUMBER';
if (+value > +maxNumber) return 'TOO_HIGH';
outputArr.push(+value);
};
},
min_number: function min_number(minNumber) {
return function (value, params, outputArr) {
if (util.isNoValue(value)) return;
if (!util.isPrimitiveValue(value)) return 'FORMAT_ERROR';
if (!util.looksLikeNumber(value)) return 'NOT_NUMBER';
if (+value < +minNumber) return 'TOO_LOW';
outputArr.push(+value);
};
},
number_between: function number_between(minNumber, maxNumber) {
return function (value, params, outputArr) {
if (util.isNoValue(value)) return;
if (!util.isPrimitiveValue(value)) return 'FORMAT_ERROR';
if (!util.looksLikeNumber(value)) return 'NOT_NUMBER';
if (+value < +minNumber) return 'TOO_LOW';
if (+value > +maxNumber) return 'TOO_HIGH';
outputArr.push(+value);
};
}
};
var Numeric_1 = Numeric.integer;
var Numeric_2 = Numeric.positive_integer;
var Numeric_3 = Numeric.decimal;
var Numeric_4 = Numeric.positive_decimal;
var Numeric_5 = Numeric.max_number;
var Numeric_6 = Numeric.min_number;
var Numeric_7 = Numeric.number_between;
'use strict';
var Special = {
email: function email() {
var emailRe = /^([\w\-_+]+(?:\.[\w\-_+]+)*)@((?:[\w\-]+\.)*\w[\w\-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
return function (value) {
if (value === undefined || value === null || value === '') return;
if (!util.isPrimitiveValue(value)) return 'FORMAT_ERROR';
value += '';
if (!emailRe.test(value)) return 'WRONG_EMAIL';
if (/\@.*\@/.test(value)) return 'WRONG_EMAIL';
if (/\@.*_/.test(value)) return 'WRONG_EMAIL';
return;
};
},
equal_to_field: function equal_to_field(field) {
return function (value, params) {
if (value === undefined || value === null || value === '') return;
if (!util.isPrimitiveValue(value)) return 'FORMAT_ERROR';
if (value != params[field]) return 'FIELDS_NOT_EQUAL';
return;
};
},
url: function url() {
var urlReStr = '^(?:(?:http|https)://)(?:\\S+(?::\\S*)?@)?(?:(?:(?:[1-9]\\d?|1\\d\\d|2[0-1]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[0-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))\\.?|localhost)(?::\\d{2,5})?(?:[/?#]\\S*)?$';
var urlRe = new RegExp(urlReStr, 'i');
return function (value) {
if (value === undefined || value === null || value === '') return;
if (!util.isPrimitiveValue(value)) return 'FORMAT_ERROR';
if (value.length < 2083 && urlRe.test(value)) return;
return 'WRONG_URL';
};
},
iso_date: function iso_date() {
return function (value) {
if (value === undefined || value === null || value === '') return;
if (!util.isPrimitiveValue(value)) return 'FORMAT_ERROR';
var matched = value.match(/^(\d{4})-([0-1][0-9])-([0-3][0-9])$/);
if (matched) {
var epoch = Date.parse(value);
if (!epoch && epoch !== 0) return 'WRONG_DATE';
var d = new Date(epoch);
d.setTime(d.getTime() + d.getTimezoneOffset() * 60 * 1000);
if (d.getFullYear() == matched[1] && d.getMonth() + 1 == +matched[2] && d.getDate() == +matched[3]) {
return;
}
}
return 'WRONG_DATE';
};
}
};
var Special_1 = Special.email;
var Special_2 = Special.equal_to_field;
var Special_3 = Special.url;
var Special_4 = Special.iso_date;
'use strict';
var DEFAULT_RULES = {};
var IS_DEFAULT_AUTO_TRIM = 0;
function Validator(livrRules, isAutoTrim) {
this.isPrepared = false;
this.livrRules = livrRules;
this.validators = {};
this.validatorBuilders = {};
this.errors = null;
if (isAutoTrim !== null && isAutoTrim !== undefined) {
this.isAutoTrim = isAutoTrim;
} else {
this.isAutoTrim = IS_DEFAULT_AUTO_TRIM;
}
this.registerRules(DEFAULT_RULES);
}
Validator.registerDefaultRules = function (rules) {
for (var ruleName in rules) {
DEFAULT_RULES[ruleName] = rules[ruleName];
}
};
Validator.getDefaultRules = function () {
return DEFAULT_RULES;
};
Validator.registerAliasedDefaultRule = function (alias) {
if (!alias.name) throw 'Alias name required';
DEFAULT_RULES[alias.name] = Validator._buildAliasedRule(alias);
};
Validator._buildAliasedRule = function (alias) {
if (!alias.name) throw 'Alias name required';
if (!alias.rules) throw 'Alias rules required';
var livr = { value: alias.rules };
return function (ruleBuilders) {
var validator = new Validator(livr).registerRules(ruleBuilders).prepare();
return function (value, params, outputArr) {
var result = validator.validate({ value: value });
if (result) {
outputArr.push(result.value);
return;
} else {
return alias.error || validator.getErrors().value;
}
};
};
};
Validator.defaultAutoTrim = function (isAutoTrim) {
IS_DEFAULT_AUTO_TRIM = !!isAutoTrim;
};
Validator.prototype = {
prepare: function prepare() {
var allRules = this.livrRules;
for (var field in allRules) {
var fieldRules = allRules[field];
if (!Array.isArray(fieldRules)) {
fieldRules = [fieldRules];
}
var validators = [];
for (var i = 0; i < fieldRules.length; i++) {
var parsed = this._parseRule(fieldRules[i]);
validators.push(this._buildValidator(parsed.name, parsed.args));
}
this.validators[field] = validators;
}
this.isPrepared = true;
return this;
},
validate: function validate(data) {
if (!this.isPrepared) this.prepare();
if (!util.isObject(data)) {
this.errors = 'FORMAT_ERROR';
return;
}
if (this.isAutoTrim) {
data = this._autoTrim(data);
}
var errors = {},
result = {};
for (var fieldName in this.validators) {
var validators = this.validators[fieldName];
if (!validators || !validators.length) continue;
var value = data[fieldName];
for (var i = 0; i < validators.length; i++) {
var fieldResultArr = [];
var errCode = validators[i](result.hasOwnProperty(fieldName) ? result[fieldName] : value, data, fieldResultArr);
if (errCode) {
errors[fieldName] = errCode;
break;
} else if (fieldResultArr.length) {
result[fieldName] = fieldResultArr[0];
} else if (data.hasOwnProperty(fieldName) && !result.hasOwnProperty(fieldName)) {
result[fieldName] = value;
}
}
}
if (util.isEmptyObject(errors)) {
this.errors = null;
return result;
} else {
this.errors = errors;
return false;
}
},
getErrors: function getErrors() {
return this.errors;
},
registerRules: function registerRules(rules) {
for (var ruleName in rules) {
this.validatorBuilders[ruleName] = rules[ruleName];
}
return this;
},
registerAliasedRule: function registerAliasedRule(alias) {
if (!alias.name) throw 'Alias name required';
this.validatorBuilders[alias.name] = Validator._buildAliasedRule(alias);
return this;
},
getRules: function getRules() {
return this.validatorBuilders;
},
_parseRule: function _parseRule(livrRule) {
var name, args;
if (util.isObject(livrRule)) {
name = Object.keys(livrRule)[0];
args = livrRule[name];
if (!Array.isArray(args)) args = [args];
} else {
name = livrRule;
args = [];
}
return { name: name, args: args };
},
_buildValidator: function _buildValidator(name, args) {
if (!this.validatorBuilders[name]) {
throw 'Rule [' + name + '] not registered';
}
var allArgs = [];
allArgs.push.apply(allArgs, args);
allArgs.push(this.getRules());
return this.validatorBuilders[name].apply(null, allArgs);
},
_autoTrim: function _autoTrim(data) {
var dataType = typeof data === 'undefined' ? 'undefined' : _typeof(data);
if (dataType !== 'object' && data) {
if (data.replace) {
return data.replace(/^\s*/, '').replace(/\s*$/, '');
} else {
return data;
}
} else if (dataType == 'object' && Array.isArray(data)) {
var trimmedData = [];
for (var i = 0; i < data.length; i++) {
trimmedData[i] = this._autoTrim(data[i]);
}
return trimmedData;
} else if (dataType == 'object' && util.isObject(data)) {
var trimmedData = {};
for (var key in data) {
if (data.hasOwnProperty(key)) {
trimmedData[key] = this._autoTrim(data[key]);
}
}
return trimmedData;
}
return data;
}
};
var Validator_1 = Validator;
'use strict';
var Meta = {
nested_object: function nested_object(livr, ruleBuilders) {
var validator = new Validator_1(livr).registerRules(ruleBuilders).prepare();
return function (nestedObject, params, outputArr) {
if (util.isNoValue(nestedObject)) return;
if (!util.isObject(nestedObject)) return 'FORMAT_ERROR';
var result = validator.validate(nestedObject);
if (result) {
outputArr.push(result);
return;
} else {
return validator.getErrors();
}
};
},
variable_object: function variable_object(selectorField, livrs, ruleBuilders) {
var validators = {};
for (var selectorValue in livrs) {
var validator = new Validator_1(livrs[selectorValue]).registerRules(ruleBuilders).prepare();
validators[selectorValue] = validator;
}
return function (object, params, outputArr) {
if (util.isNoValue(object)) return;
if (!util.isObject(object) || !object[selectorField] || !validators[object[selectorField]]) {
return 'FORMAT_ERROR';
}
var validator = validators[object[selectorField]];
var result = validator.validate(object);
if (result) {
outputArr.push(result);
return;
} else {
return validator.getErrors();
}
};
},
list_of: function list_of(rules, ruleBuilders) {
if (!Array.isArray(rules)) {
rules = Array.prototype.slice.call(arguments);
ruleBuilders = rules.pop();
}
var livr = { field: rules };
var validator = new Validator_1(livr).registerRules(ruleBuilders).prepare();
return function (values, params, outputArr) {
if (util.isNoValue(values)) return;
if (!Array.isArray(values)) return 'FORMAT_ERROR';
var results = [];
var errors = [];
var hasErrors = false;
for (var i = 0; i < values.length; i++) {
var result = validator.validate({ field: values[i] });
if (result) {
results.push(result.field);
errors.push(null);
} else {
hasErrors = true;
errors.push(validator.getErrors().field);
results.push(null);
}
}
if (hasErrors) {
return errors;
} else {
outputArr.push(results);
return;
}
};
},
list_of_objects: function list_of_objects(livr, ruleBuilders) {
var validator = new Validator_1(livr).registerRules(ruleBuilders).prepare();
return function (objects, params, outputArr) {
if (util.isNoValue(objects)) return;
if (!Array.isArray(objects)) return 'FORMAT_ERROR';
var results = [];
var errors = [];
var hasErrors = false;
for (var i = 0; i < objects.length; i++) {
var result = validator.validate(objects[i]);
if (result) {
results.push(result);
errors.push(null);
} else {
hasErrors = true;
errors.push(validator.getErrors());
results.push(null);
}
}
if (hasErrors) {
return errors;
} else {
outputArr.push(results);
return;
}
};
},
list_of_different_objects: function list_of_different_objects(selectorField, livrs, ruleBuilders) {
var validators = {};
for (var selectorValue in livrs) {
var validator = new Validator_1(livrs[selectorValue]).registerRules(ruleBuilders).prepare();
validators[selectorValue] = validator;
}
return function (objects, params, outputArr) {
if (util.isNoValue(objects)) return;
if (!Array.isArray(objects)) return 'FORMAT_ERROR';
var results = [];
var errors = [];
var hasErrors = false;
for (var i = 0; i < objects.length; i++) {
var object = objects[i];
if ((typeof object === 'undefined' ? 'undefined' : _typeof(object)) != 'object' || !object[selectorField] || !validators[object[selectorField]]) {
errors.push('FORMAT_ERROR');
continue;
}
var validator = validators[object[selectorField]];
var result = validator.validate(object);
if (result) {
results.push(result);
errors.push(null);
} else {
hasErrors = true;
errors.push(validator.getErrors());
results.push(null);
}
}
if (hasErrors) {
return errors;
} else {
outputArr.push(results);
return;
}
};
},
or: function or() {
var ruleSets = Array.prototype.slice.call(arguments);
var ruleBuilders = ruleSets.pop();
var validators = ruleSets.map(function (rules) {
var livr = { field: rules };
var validator = new Validator_1(livr).registerRules(ruleBuilders).prepare();
return validator;
});
return function (value, params, outputArr) {
if (util.isNoValue(value)) return;
var lastError;
for (var i = 0; i < validators.length; i++) {
var validator = validators[i];
var result = validator.validate({ field: value });
if (result) {
outputArr.push(result.field);
return;
} else {
lastError = validator.getErrors().field;
}
}
if (lastError) {
return lastError;
}
};
}
};
var Meta_1 = Meta.nested_object;
var Meta_2 = Meta.variable_object;
var Meta_3 = Meta.list_of;
var Meta_4 = Meta.list_of_objects;
var Meta_5 = Meta.list_of_different_objects;
var Meta_6 = Meta.or;
'use strict';
var Modifiers = {
default: function _default(defaultValue) {
return function (value, params, outputArr) {
if (util.isNoValue(value)) {
outputArr.push(defaultValue);
}
};
},
trim: function trim() {
return function (value, params, outputArr) {
if (util.isNoValue(value) || (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object') return;
value += ''; // TODO just do not trim numbers
outputArr.push(value.replace(/^\s*/, '').replace(/\s*$/, ''));
};
},
to_lc: function to_lc() {
return function (value, params, outputArr) {
if (util.isNoValue(value) || (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object') return;
value += ''; // TODO just skip numbers
outputArr.push(value.toLowerCase());
};
},
to_uc: function to_uc() {
return function (value, params, outputArr) {
if (util.isNoValue(value) || (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object') return;
value += ''; // TODO just skip numbers
outputArr.push(value.toUpperCase());
};
},
remove: function remove(chars) {
chars = util.escapeRegExp(chars);
var re = new RegExp('[' + chars + ']', 'g');
return function (value, params, outputArr) {
if (util.isNoValue(value) || (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object') return;
value += ''; // TODO just skip numbers
outputArr.push(value.replace(re, ''));
};
},
leave_only: function leave_only(chars) {
chars = util.escapeRegExp(chars);
var re = new RegExp('[^' + chars + ']', 'g');
return function (value, params, outputArr) {
if (util.isNoValue(value) || (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object') return;
value += ''; // TODO just skip numbers
outputArr.push(value.replace(re, ''));
};
}
};
var Modifiers_1 = Modifiers.trim;
var Modifiers_2 = Modifiers.to_lc;
var Modifiers_3 = Modifiers.to_uc;
var Modifiers_4 = Modifiers.remove;
var Modifiers_5 = Modifiers.leave_only;
'use strict';
var LIVR = { rules: {} };
LIVR.rules.common = Common;
LIVR.rules.string = _String;
LIVR.rules.numeric = Numeric;
LIVR.rules.special = Special;
LIVR.rules.meta = Meta;
LIVR.rules.modifiers = Modifiers;
LIVR.Validator = Validator_1;
LIVR.util = util;
LIVR.Validator.registerDefaultRules({
required: LIVR.rules.common.required,
not_empty: LIVR.rules.common.not_empty,
not_empty_list: LIVR.rules.common.not_empty_list,
any_object: LIVR.rules.common.any_object,
string: LIVR.rules.string.string,
eq: LIVR.rules.string.eq,
one_of: LIVR.rules.string.one_of,
max_length: LIVR.rules.string.max_length,
min_length: LIVR.rules.string.min_length,
length_equal: LIVR.rules.string.length_equal,
length_between: LIVR.rules.string.length_between,
like: LIVR.rules.string.like,
integer: LIVR.rules.numeric.integer,
positive_integer: LIVR.rules.numeric.positive_integer,
decimal: LIVR.rules.numeric.decimal,
positive_decimal: LIVR.rules.numeric.positive_decimal,
max_number: LIVR.rules.numeric.max_number,
min_number: LIVR.rules.numeric.min_number,
number_between: LIVR.rules.numeric.number_between,
email: LIVR.rules.special.email,
equal_to_field: LIVR.rules.special.equal_to_field,
url: LIVR.rules.special.url,
iso_date: LIVR.rules.special.iso_date,
nested_object: LIVR.rules.meta.nested_object,
variable_object: LIVR.rules.meta.variable_object,
list_of: LIVR.rules.meta.list_of,
list_of_objects: LIVR.rules.meta.list_of_objects,
or: LIVR.rules.meta.or,
list_of_different_objects: LIVR.rules.meta.list_of_different_objects,
default: LIVR.rules.modifiers.default,
trim: LIVR.rules.modifiers.trim,
to_lc: LIVR.rules.modifiers.to_lc,
to_uc: LIVR.rules.modifiers.to_uc,
remove: LIVR.rules.modifiers.remove,
leave_only: LIVR.rules.modifiers.leave_only
});
var LIVR_1 = LIVR;
var LIVR_2 = LIVR_1.Validator;
var Validator$1 = LIVR_2;
function toLIVR(rules, key) {
var validationRules = [];
rules.forEach(function (rule) {
if (rule.key === key) {
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = Object.keys(rule)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var name = _step.value;
if (name !== 'key' && name !== 'for') {
validationRules.push(defineProperty({}, name, rule[name]));
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
}
});
return {
hasRules: validationRules.length > 0,
rules: defineProperty({}, key, validationRules)
};
}
function hasRules(rules, key) {
return toLIVR(rules, key).hasRules;
}
function createValidator(rules, key) {
if (arguments.length === 2) {
var settings = toLIVR(rules, key);
return new Validator$1(settings.rules);
}
return new Validator$1(rules);
}
var EditCellView = function () {
function EditCellView(model, table, shortcut) {
var _this = this;
classCallCheck(this, EditCellView);
this.model = model;
this.table = table;
this.shortcut = shortcut;
this.editor = CellEditor.empty;
var commands = this.commands;
shortcut.register(commands);
this.enter = commands.get('enter');
this.commit = commands.get('commit');
this.push = commands.get('push');
this.cancel = commands.get('cancel');
this.reset = commands.get('reset');
this.exit = commands.get('exit');
this.clear = commands.get('clear');
model.navigationChanged.watch(function (e) {
if (e.hasChanges('cell')) {
var oldCell = _this.editor.td;
if (oldCell) {
if (oldCell.column.class === 'data') {
if (_this.commit.canExecute(oldCell)) {
_this.commit.execute(oldCell);
}
} else {
if (_this.cancel.canExecute(oldCell)) {
_this.cancel.execute(oldCell);
}
}
}
var newCell = e.changes.cell.newValue;
if (newCell && newCell.column.editorOptions.trigger === 'focus') {
if (_this.enter.canExecute(newCell)) {
_this.enter.execute(newCell);
}
}
}
});
}
createClass(EditCellView, [{
key: 'mode',
value: function mode(cell, value) {
this.model.edit({ state: value });
cell.mode(value);
}
}, {
key: 'contextFactory',
value: function contextFactory(cell, value, label, tag) {
var column = cell.column,
row = cell.row,
columnIndex = cell.columnIndex,
rowIndex = cell.rowIndex,
oldValue = cell.value,
oldLabel = cell.label;
return {
column: column,
row: row,
columnIndex: columnIndex,
rowIndex: rowIndex,
oldValue: oldValue,
newValue: arguments.length >= 2 ? value : oldValue,
oldLabel: oldLabel,
newLabel: arguments.length >= 3 ? label : oldLabel,
unit: 'cell',
tag: tag,
valueFactory: getFactory,
labelFactory: getFactory$1
};
}
}, {
key: 'canEdit',
value: function canEdit(cell) {
if (cell) {
return cell.column.canEdit && this.model.edit().mode === 'cell';
}
return false;
}
}, {
key: 'shortcutFactory',
value: function shortcutFactory(type) {
var _this2 = this;
var edit = this.model.edit;
return function () {
var shortcuts = edit()[type + 'Shortcuts'];
var td = _this2.editor.td;
if (td) {
var _type = td.column && td.column.editor ? td.column.editor : td.column.type;
if (shortcuts.hasOwnProperty(_type)) {
return shortcuts[_type];
}
}
return shortcuts['$default'];
};
}
}, {
key: 'commands',
get: function get$$1() {
var _this3 = this;
var model = this.model,
table = this.table;
var commands = {
enter: new Command({
priority: 1,
source: 'edit.cell.view',
shortcut: this.shortcutFactory('enter'),
canExecute: function canExecute(cell) {
// TODO: source should be set up from outside
var source = cell ? 'mouse' : 'keyboard';
if (source === 'keyboard' && Shortcut.isControl(_this3.shortcut.keyCode())) {
return false;
}
cell = cell || model.navigation().cell;
return cell && cell.column.canEdit && (cell.column.class === 'control' || model.edit().mode === 'cell') && model.edit().state === 'view' && model.edit().enter.canExecute(_this3.contextFactory(cell));
},
execute: function execute(cell, e) {
Log.info('cell.edit', 'edit mode');
if (e) {
e.stopImmediatePropagation();
}
// TODO: source should be set up from outside
var source = cell ? 'mouse' : 'keyboard';
cell = cell || model.navigation().cell;
if (cell && model.edit().enter.execute(_this3.contextFactory(cell, cell.value, cell.label)) !== false) {
var td = table.body.cell(cell.rowIndex, cell.columnIndex).model();
_this3.editor = new CellEditor(td);
var keyCode = _this3.shortcut.keyCode();
if (source === 'keyboard' && Shortcut.isPrintable(keyCode)) {
var parse = parseFactory(cell.column.type, cell.column.editor);
var value = Shortcut.stringify(keyCode);
var typedValue = parse(value);
if (typedValue !== null) {
_this3.value = typedValue;
}
}
_this3.mode(_this3.editor.td, 'edit');
return true;
}
return false;
}
}),
commit: new Command({
priority: 1,
source: 'edit.cell.view',
shortcut: this.shortcutFactory('commit'),
canExecute: function canExecute(cell) {
cell = cell || _this3.editor.td;
var canEdit = cell && cell === _this3.editor.td && cell.column.canEdit && (cell.column.class === 'control' || model.edit().mode === 'cell') && model.edit().state === 'edit';
if (canEdit) {
var context = _this3.contextFactory(cell);
var key = context.column.key;
var validator = createValidator(model.validation().rules, key);
return model.edit().commit.canExecute(context) && validator.validate(defineProperty({}, key, _this3.value));
}
return false;
},
execute: function execute(cell, e) {
Log.info('cell.edit', 'commit');
if (e) {
e.stopImmediatePropagation();
}
cell = cell || _this3.editor.td;
if (cell && model.edit().commit.execute(_this3.contextFactory(cell, _this3.value, _this3.label, _this3.tag)) !== false) {
_this3.editor.commit();
_this3.editor = CellEditor.empty;
_this3.mode(cell, 'view');
table.view.focus();
return true;
}
return false;
}
}),
push: new Command({
priority: 1,
source: 'edit.cell.view',
canExecute: function canExecute(cell) {
cell = cell || _this3.editor.td;
var canEdit = cell && cell.column.canEdit;
if (canEdit) {
var context = _this3.contextFactory(cell);
var key = context.column.key;
var validator = createValidator(model.validation().rules, key);
return model.edit().commit.canExecute(context) && validator.validate(defineProperty({}, key, _this3.value));
}
return false;
},
execute: function execute(cell, e) {
Log.info('cell.edit', 'batch commit');
if (e) {
e.stopImmediatePropagation();
}
cell = cell || _this3.editor.td;
if (cell && model.edit().commit.execute(_this3.contextFactory(cell, _this3.value, _this3.label, _this3.tag)) !== false) {
_this3.editor.commit();
_this3.editor = CellEditor.empty;
return true;
}
return false;
}
}),
cancel: new Command({
priority: 1,
source: 'edit.cell.view',
shortcut: this.shortcutFactory('cancel'),
canExecute: function canExecute(cell) {
cell = cell || _this3.editor.td;
return cell && cell.column.canEdit && (cell.column.class === 'control' || model.edit().mode === 'cell') && model.edit().state === 'edit' && model.edit().cancel.canExecute(_this3.contextFactory(cell, _this3.value, _this3.label));
},
execute: function execute(cell, e) {
Log.info('cell.edit', 'cancel');
if (e) {
e.stopImmediatePropagation();
}
cell = cell || _this3.editor.td;
if (cell && model.edit().cancel.execute(_this3.contextFactory(cell, cell.value, cell.label)) !== false) {
_this3.editor.reset();
_this3.editor = CellEditor.empty;
_this3.mode(cell, 'view');
table.view.focus();
return true;
}
return false;
}
}),
reset: new Command({
priority: 1,
source: 'edit.cell.view',
canExecute: function canExecute(cell) {
cell = cell || _this3.editor.td;
return cell && cell.column.canEdit && (cell.column.class === 'control' || model.edit().mode === 'cell') && model.edit().state === 'edit' && model.edit().reset.canExecute(_this3.contextFactory(cell, _this3.value, _this3.label));
},
execute: function execute(cell, e) {
Log.info('cell.edit', 'reset');
if (e) {
e.stopImmediatePropagation();
}
cell = cell || _this3.editor.td;
if (cell && model.edit().reset.execute(_this3.contextFactory(cell, _this3.value, _this3.label)) !== false) {
_this3.editor.reset();
return true;
}
return false;
}
}),
exit: new Command({
priority: 1,
source: 'edit.cell.view',
execute: function execute(cell, e) {
Log.info('cell.edit', 'reset');
if (e) {
e.stopImmediatePropagation();
}
cell = cell || _this3.editor.td;
if (cell) {
if (_this3.commit.canExecute(cell, e)) {
var originValue = cell.value;
var editValue = _this3.value;
if (originValue !== editValue) {
_this3.commit.execute(cell, e);
return true;
}
}
if (_this3.cancel.canExecute(cell, e)) {
_this3.cancel.execute(cell, e);
return true;
}
}
return false;
}
}),
clear: new Command({
priority: 1,
source: 'edit.cell.view',
canExecute: function canExecute(cell) {
cell = cell || _this3.editor.td;
return cell && cell.column.canEdit && (cell.column.class === 'control' || model.edit().mode === 'cell') && model.edit().state === 'edit' && model.edit().clear.canExecute(_this3.contextFactory(cell, _this3.value, _this3.label));
},
execute: function execute(cell, e) {
Log.info('cell.edit', 'clear');
if (e) {
e.stopImmediatePropagation();
}
cell = cell || _this3.editor.td;
if (cell && model.edit().clear.execute(_this3.contextFactory(cell, _this3.value, _this3.label)) !== false) {
_this3.editor.clear();
return true;
}
return false;
}
})
};
return new Map(Object.entries(commands));
}
}, {
key: 'fetch',
get: function get$$1() {
return this.editor.fetch;
}
}, {
key: 'value',
get: function get$$1() {
return this.editor.value;
},
set: function set$$1(value) {
this.editor.value = value;
}
}, {
key: 'label',
get: function get$$1() {
return this.editor.label;
},
set: function set$$1(label) {
this.editor.label = label;
}
}, {
key: 'row',
get: function get$$1() {
return this.cell.row;
}
}, {
key: 'column',
get: function get$$1() {
return this.cell.column;
}
}, {
key: 'cell',
get: function get$$1() {
return this.editor.td;
}
}, {
key: 'options',
get: function get$$1() {
return this.column.options;
}
}]);
return EditCellView;
}();
var RowEditorCore = function () {
function RowEditorCore() {
classCallCheck(this, RowEditorCore);
this.editors = [];
}
createClass(RowEditorCore, [{
key: 'commit',
value: function commit() {}
}, {
key: 'reset',
value: function reset() {}
}]);
return RowEditorCore;
}();
var TdView = function () {
function TdView(row, column) {
classCallCheck(this, TdView);
this.row = row;
this.column = column;
}
createClass(TdView, [{
key: 'value',
get: function get$$1() {
return get$2(this.row, this.column);
},
set: function set$$1(value) {
return set$1(this.row, this.column, value);
}
}, {
key: 'label',
get: function get$$1() {
return get$3(this.row, this.column);
},
set: function set$$1(value) {
return set$2(this.row, this.column, value);
}
}]);
return TdView;
}();
var empty$1 = new RowEditorCore();
var RowEditor = function (_RowEditorCore) {
inherits(RowEditor, _RowEditorCore);
function RowEditor(row, columns) {
classCallCheck(this, RowEditor);
var _this = possibleConstructorReturn(this, (RowEditor.__proto__ || Object.getPrototypeOf(RowEditor)).call(this));
_this.value = cloneDeepWith(row);
_this.row = row;
_this.editors = columns.filter(function (column) {
return column.canEdit;
}).map(function (column) {
return new CellEditor(new TdView(_this.value, column));
});
return _this;
}
createClass(RowEditor, [{
key: 'commit',
value: function commit() {
this.editors.forEach(function (editor) {
return editor.commit();
});
Object.assign(this.row, this.value);
}
}, {
key: 'reset',
value: function reset() {
this.editors.forEach(function (editor) {
return editor.reset();
});
this.value = cloneDeepWith(this.row);
}
}], [{
key: 'empty',
get: function get$$1() {
return empty$1;
}
}]);
return RowEditor;
}(RowEditorCore);
var EditRowView = function () {
function EditRowView(model, table, shortcut) {
classCallCheck(this, EditRowView);
this.model = model;
this.table = table;
this.editor = RowEditor.empty;
var commands = this.commands;
shortcut.register(commands);
this.enter = commands.get('enter');
this.commit = commands.get('commit');
this.cancel = commands.get('cancel');
this.reset = commands.get('reset');
}
createClass(EditRowView, [{
key: 'contextFactory',
value: function contextFactory(row) {
return {
row: row,
unit: 'row'
};
}
}, {
key: 'shortcutFactory',
value: function shortcutFactory(type) {
var edit = this.model.edit;
return function () {
var shortcuts = edit()[type + 'Shortcuts'];
return shortcuts['row'] || shortcuts['$default'];
};
}
}, {
key: 'commands',
get: function get$$1() {
var _this = this;
var model = this.model;
var commands = {
enter: new Command({
source: 'edit.row.view',
shortcut: this.shortcutFactory('enter'),
canExecute: function canExecute(row) {
row = row || model.navigation().row;
return row && model.edit().mode === 'row' && model.edit().state === 'view' && model.edit().enter.canExecute(_this.contextFactory(row));
},
execute: function execute(row, e) {
Log.info('row.edit', 'edit mode');
if (e) {
e.stopImmediatePropagation();
}
var columns = _this.model.columnList().line;
_this.editor = new RowEditor(row, columns);
model.edit({ state: 'edit' }, { source: 'edit.row.view' });
}
}),
commit: new Command({
source: 'edit.row.view',
shortcut: this.shortcutFactory('commit'),
// TODO: add validation support
canExecute: function canExecute(row) {
row = row || model.navigation().row;
return row && model.edit().mode === 'row' && model.edit().state === 'edit' && model.edit().commit.canExecute(_this.contextFactory(row));
},
execute: function execute(cell, e) {
Log.info('row.edit', 'commit');
if (e) {
e.stopImmediatePropagation();
}
_this.editor.commit();
_this.editor = RowEditor.empty;
model.edit({ state: 'view' }, { source: 'edit.row.view' });
}
}),
cancel: new Command({
source: 'edit.row.view',
shortcut: this.shortcutFactory('cancel'),
canExecute: function canExecute(row) {
row = row || model.navigation().row;
return row && model.edit().mode === 'row' && model.edit().state === 'edit' && model.edit().cancel.canExecute(_this.contextFactory(row));
},
execute: function execute(row, e) {
Log.info('cell.edit', 'cancel');
if (e) {
e.stopImmediatePropagation();
}
_this.editor.reset();
_this.editor = RowEditor.empty;
model.edit({ state: 'view' }, { source: 'edit.row.view' });
}
}),
reset: new Command({
source: 'edit.row.view',
canExecute: function canExecute(row) {
row = row || model.navigation().row;
return row && model.edit().mode === 'row' && model.edit().state === 'edit' && model.edit().reset.canExecute(_this.contextFactory(row));
},
execute: function execute(row, e) {
Log.info('row.edit', 'reset');
if (e) {
e.stopImmediatePropagation();
}
if (row && model.edit().reset.execute(_this.contextFactory(row)) !== false) {
_this.editor.reset();
return false;
}
}
})
};
return new Map(Object.entries(commands));
}
}]);
return EditRowView;
}();
var EditView = function EditView(model, table, shortcut) {
classCallCheck(this, EditView);
this.cell = new EditCellView(model, table, shortcut);
this.row = new EditRowView(model, table, shortcut);
};
var FilterView = function () {
function FilterView(model) {
classCallCheck(this, FilterView);
this.model = model;
this.column = new Command({
source: 'filter.view',
execute: function execute(column, search) {
var key = column.key;
var filter = model.filter;
var by = clone(filter().by);
if (!isUndefined(search) && search !== '') {
by[key] = {
expression: {
kind: 'group',
op: 'and',
left: {
kind: 'condition',
left: key,
op: 'like',
right: search
},
right: null
}
};
} else {
delete by[key];
}
filter({ by: by });
}
});
}
createClass(FilterView, [{
key: 'has',
value: function has(column) {
var _model$filter = this.model.filter(),
by = _model$filter.by;
return by.hasOwnProperty(column.key);
}
}]);
return FilterView;
}();
var FootView = function () {
function FootView(model, table) {
var _this = this;
classCallCheck(this, FootView);
this.model = model;
this.table = table;
this.rows = [];
this.valueFactory = getFactory;
model.sceneChanged.watch(function (e) {
if (e.hasChanges('column')) {
_this.invalidate();
}
});
}
createClass(FootView, [{
key: 'invalidate',
value: function invalidate() {
Log.info('view.foot', 'invalidate');
this.rows = new Array(this.count);
}
}, {
key: 'columns',
value: function columns(row, pin) {
var model = this.model;
return model.scene().column.area[pin] || [];
}
}, {
key: 'value',
value: function value(column) {
if (column.aggregation) {
var aggregation = column.aggregation;
var aggregationOptions = column.aggregationOptions;
if (!Aggregation.hasOwnProperty(aggregation)) {
throw new AppError('foot', 'Aggregation ' + aggregation + ' is not registered');
}
var _model$data = this.model.data(),
rows = _model$data.rows;
var getValue = this.valueFactory(column);
return Aggregation[aggregation](rows, getValue, aggregationOptions);
}
return null;
}
}, {
key: 'count',
get: function get$$1() {
var model = this.model;
var _model$view = model.view(),
columns = _model$view.columns;
var resourceCount = model.foot().resource.count;
for (var i = 0, length = columns.length; i < length; i++) {
if (columns[i].aggregation) {
return Math.max(resourceCount, 1);
}
}
return resourceCount;
}
}]);
return FootView;
}();
function rowspanGetNode(node, column) {
if (node.source === column.by) {
return node;
}
if (node.children.length) {
return node.children[0];
}
return node;
}
function flatVisible(node, column) {
return column.type !== 'group' || node.source === column.by;
}
function rowspanIsVisible(node, column, parent) {
if (node.source === column.by) {
return !parent || parent.state.expand;
}
if (node.children.length) {
return rowspanIsVisible(node.children[0], column, node);
}
return false;
}
var GroupView = function () {
function GroupView(model, table, service, shortcut) {
var _this = this;
classCallCheck(this, GroupView);
this.model = model;
this.table = table;
this.valueFactory = getFactory;
var toggleStatus = new Command({
source: 'group.view',
execute: function execute(node, column) {
node = node || model.navigation().row;
column = column || model.navigation().column;
node = _this.getNode(node, column);
var toggle = model.group().toggle;
if (toggle.execute(node) !== false) {
node.state.expand = !node.state.expand;
service.invalidate({
source: 'group.view',
pipe: PipeUnit.group,
why: PipeUnit.group.why
});
}
},
canExecute: function canExecute(node, column) {
node = node || model.navigation().row;
column = column || model.navigation().column;
node = _this.getNode(node, column);
var toggle = model.group().toggle;
return node && node.type === 'group' && toggle.canExecute(node);
},
shortcut: model.group().shortcut.toggle
});
var shouldExpand = true;
var toggleAllStatus = new Command({
source: 'group.view',
execute: function execute() {
if (model.group().toggleAll.execute() !== false) {
var _model$view = model.view(),
nodes = _model$view.nodes;
var toggle = model.group().toggle;
preOrderDFS(nodes, function (node) {
if (toggleStatus.canExecute(node)) {
if (toggle.execute(node) !== false) {
node.state.expand = shouldExpand;
}
}
});
shouldExpand = !shouldExpand;
service.invalidate({
source: 'group.view',
pipe: PipeUnit.group,
why: PipeUnit.group.why
});
}
},
canExecute: function canExecute() {
return model.group().toggleAll.canExecute();
}
});
this.toggleStatus = toggleStatus;
this.toggleAllStatus = toggleAllStatus;
shortcut.register([toggleStatus, toggleAllStatus]);
var createColumn = columnFactory(model);
this.reference = {
group: createColumn('group')
};
this.getNode = identity$1;
this.isVisible = yes;
model.groupChanged.watch(function (e) {
if (e.hasChanges('mode')) {
switch (e.state.mode) {
case 'rowspan':
{
_this.getNode = rowspanGetNode;
_this.isVisible = rowspanIsVisible;
break;
}
case 'flat':
_this.getNode = identity$1;
_this.isVisible = flatVisible;
break;
default:
{
_this.getNode = identity$1;
_this.isVisible = yes;
break;
}
}
}
});
}
createClass(GroupView, [{
key: 'count',
value: function count(node, column) {
node = this.getNode(node, column);
return node.children.length || node.rows.length;
}
}, {
key: 'status',
value: function status(node, column) {
node = this.getNode(node, column);
return node.state.expand ? 'expand' : 'collapse';
}
}, {
key: 'offset',
value: function offset(node, column) {
node = this.getNode(node, column);
var _model$group = this.model.group(),
mode = _model$group.mode;
switch (mode) {
case 'nest':
case 'subhead':
{
return column ? column.offset * node.level : 0;
}
default:
{
return 0;
}
}
}
}, {
key: 'value',
value: function value(node, column) {
node = this.getNode(node, column);
if (column) {
var getLabel = getFactory$1(column);
return getLabel(node);
}
return null;
}
}]);
return GroupView;
}();
var PathService = function () {
function PathService(bag) {
classCallCheck(this, PathService);
this.bag = bag;
}
createClass(PathService, [{
key: 'cell',
value: function cell(path) {
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = path[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var node = _step.value;
if (node.nodeName === 'TD' || node.nodeName === 'TH') {
var model = this.bag.findModel(node);
if (!model) {
new AppError('path.find', 'Can\'t find model for ' + node.nodeName);
}
return model;
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
return null;
}
}, {
key: 'row',
value: function row(path) {
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = path[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var node = _step2.value;
if (node.nodeName === 'TR') {
var model = this.bag.findModel(node);
if (!model) {
new AppError('path.find', 'Can\'t find model for ' + node.nodeName);
}
return model;
}
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
return null;
}
}]);
return PathService;
}();
TemplatePath.register('filter-row-cell', function (template, column) {
return {
model: template.for,
resource: column.key
};
});
var FilterRowColumnModel = function (_ColumnModel) {
inherits(FilterRowColumnModel, _ColumnModel);
function FilterRowColumnModel(model) {
classCallCheck(this, FilterRowColumnModel);
var _this = possibleConstructorReturn(this, (FilterRowColumnModel.__proto__ || Object.getPrototypeOf(FilterRowColumnModel)).call(this));
Object.assign(_this, model);
_this.key = '$filter.row.' + model.key;
_this.type = 'filter-row';
_this.class = 'control';
_this.canFilter = model.canFilter && model.class === 'data';
_this.model = model;
return _this;
}
return FilterRowColumnModel;
}(ColumnModel);
var FilterRowColumn = function (_ColumnView) {
inherits(FilterRowColumn, _ColumnView);
function FilterRowColumn(model) {
classCallCheck(this, FilterRowColumn);
return possibleConstructorReturn(this, (FilterRowColumn.__proto__ || Object.getPrototypeOf(FilterRowColumn)).call(this, new FilterRowColumnModel(model)));
}
return FilterRowColumn;
}(ColumnView);
function css(element, property, value) {
var normalizedProperty = normalize(property);
if (isUndefined(value)) {
return element.style[normalizedProperty];
} else {
element.style[normalizedProperty] = value;
return normalizedProperty;
}
}
function normalize(property) {
return property.replace(/-([a-z])/g, upperFirst$1);
}
function upperFirst$1(match, letter) {
return letter.toUpperCase();
}
function parents(element) {
var path = [];
while (element) {
path.unshift(element);
element = element.parentNode;
}
return path;
}
function eventPath(event) {
var path = event.composedPath && event.composedPath() || event.path;
var target = event.target;
if (path) {
// Safari doesn't include Window, but it should.
return path.indexOf(window) < 0 ? path.concat(window) : path;
}
if (target === window) {
return [window];
}
return [target].concat(parents(target), window);
}
var HeadView = function () {
function HeadView(model, table, tagName) {
var _this = this;
classCallCheck(this, HeadView);
this.model = model;
this.table = table;
this.tagName = tagName;
this.rows = [];
var pathFinder = new PathService(table.context.bag.head);
this.drop = new Command({
source: 'head.view',
canExecute: function canExecute(e) {
if (e.action === 'end') {
return true;
}
var cell = pathFinder.cell(eventPath(e));
return cell && cell.column.canMove;
},
execute: function execute(e) {
var sourceKey = e.dragData;
switch (e.action) {
case 'over':
{
var th = pathFinder.cell(eventPath(e));
if (!e.inAreaX(th.element)) {
return;
}
var targetKey = th.column.key;
if (sourceKey !== targetKey) {
var columnList = model.columnList;
var tree = calk(columnList().index);
var oldPos = find(tree, function (node) {
return node.key.model.key === sourceKey;
});
var newPos = find(tree, function (node) {
return node.key.model.key === targetKey;
});
if (oldPos && newPos && newPos.path.indexOf(oldPos.node) < 0) {
var queue = oldPos.path.reverse();
var hostIndex = queue.findIndex(function (node) {
return node.children.length > 1;
});
if (hostIndex >= 0) {
var host = queue[hostIndex];
var target = queue[hostIndex - 1] || oldPos.node;
var index = host.children.indexOf(target);
host.children.splice(index, 1);
newPos.parent.children.splice(newPos.index, 0, target);
target.level = newPos.parent.level + 1;
preOrderDFS(target.children, function (node, root, parent) {
node.level = (root || parent).level + 1;
}, target);
columnList({ index: tree }, { source: 'head.view' });
}
}
}
break;
}
case 'end':
case 'drop':
{
var _model$columnList = model.columnList(),
_index = _model$columnList.index;
var _oldPos = find(_index, function (node) {
return node.key.model.key === sourceKey;
});
if (_oldPos) {
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = findLeaves(_oldPos.node)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var leaf = _step.value;
var oldColumn = table.body.column(leaf.key.columnIndex);
oldColumn.removeClass(GRID_PREFIX + '-drag');
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
}
break;
}
}
}
});
this.drag = new Command({
source: 'head.view',
execute: function execute(e) {
var sourceKey = e.data;
var _model$columnList2 = model.columnList(),
index = _model$columnList2.index;
var pos = find(index, function (node) {
return node.key.model.key === sourceKey;
});
if (pos) {
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = findLeaves(pos.node)[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var leaf = _step2.value;
var column = table.body.column(leaf.key.columnIndex);
column.addClass(GRID_PREFIX + '-drag');
return function () {
return table.head.cell;
};
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
}
},
canExecute: function canExecute(e) {
var sourceKey = e.data;
var _model$columnList3 = model.columnList(),
index = _model$columnList3.index;
var pos = find(index, function (node) {
return node.key.model.key === sourceKey;
});
return pos && pos.node.key.model.canMove;
}
});
this.resize = new Command({
source: 'head.view',
canExecute: function canExecute(e) {
var key = e.data;
var map = table.data.columnMap();
return map.hasOwnProperty(key) && map[key].canResize !== false;
}
});
model.dataChanged.watch(function (e) {
if (e.hasChanges('columns')) {
var line = flatten$2(e.state.columns);
model.columnList({ line: line }, { source: 'head.view' });
}
});
model.sceneChanged.watch(function (e) {
if (e.hasChanges('column')) {
_this.invalidate();
}
});
model.filterChanged.watch(function (e) {
if (e.hasChanges('unit')) {
_this.invalidate();
}
});
}
createClass(HeadView, [{
key: 'columns',
value: function columns(row, pin) {
return row.filter(function (c) {
return c.model.pin === pin;
});
}
}, {
key: 'invalidate',
value: function invalidate() {
Log.info('view.head', 'invalidate');
var model = this.model;
this.rows = Array.from(model.scene().column.rows);
if (this.rows.length > 1) {
this.table.view.addClass(GRID_PREFIX + '-head-span');
} else {
this.table.view.removeClass(GRID_PREFIX + '-head-span');
}
if (model.filter().unit === 'row') {
var filterRow = this.table.data.columns().map(function (c) {
return new FilterRowColumn(c);
});
this.rows.push(filterRow);
}
}
}]);
return HeadView;
}();
var CellSelector = function () {
function CellSelector(model, table) {
classCallCheck(this, CellSelector);
this.model = model;
this.table = table;
}
createClass(CellSelector, [{
key: 'map',
value: function map(items) {
var selectionState = this.model.selection();
switch (selectionState.unit) {
case 'row':
return this.mapFromRows(items);
case 'column':
return this.mapFromColumns(items);
case 'cell':
return this.mapFromCells(items);
case 'mix':
return this.mapFromMix(items);
default:
throw new AppError('cell.selector', 'Invalid unit ' + selectionState.unit);
}
}
}, {
key: 'mapFromRows',
value: function mapFromRows(items) {
var table = this.table;
var result = [];
var rows = table.data.rows();
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = items[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var item = _step.value;
var index = rows.indexOf(item);
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = table.body.row(index).cells()[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var cell = _step2.value;
result.push(cell);
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
return result;
}
}, {
key: 'mapFromColumns',
value: function mapFromColumns(items) {
var table = this.table;
var result = [];
var columns = table.data.columns();
var _iteratorNormalCompletion3 = true;
var _didIteratorError3 = false;
var _iteratorError3 = undefined;
try {
var _loop = function _loop() {
var item = _step3.value;
var index = columns.findIndex(function (c) {
return c === item;
});
result.push.apply(result, toConsumableArray(table.body.column(index).cells()));
};
for (var _iterator3 = items[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
_loop();
}
} catch (err) {
_didIteratorError3 = true;
_iteratorError3 = err;
} finally {
try {
if (!_iteratorNormalCompletion3 && _iterator3.return) {
_iterator3.return();
}
} finally {
if (_didIteratorError3) {
throw _iteratorError3;
}
}
}
return result;
}
}, {
key: 'mapFromCells',
value: function mapFromCells(items) {
var table = this.table;
var result = [];
var rows = table.data.rows();
var columns = table.data.columns();
var _iteratorNormalCompletion4 = true;
var _didIteratorError4 = false;
var _iteratorError4 = undefined;
try {
var _loop2 = function _loop2() {
var item = _step4.value;
var rowIndex = rows.indexOf(item.row);
var columnIndex = columns.findIndex(function (c) {
return c === item.column;
});
result.push(table.body.cell(rowIndex, columnIndex));
};
for (var _iterator4 = items[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
_loop2();
}
} catch (err) {
_didIteratorError4 = true;
_iteratorError4 = err;
} finally {
try {
if (!_iteratorNormalCompletion4 && _iterator4.return) {
_iterator4.return();
}
} finally {
if (_didIteratorError4) {
throw _iteratorError4;
}
}
}
return result;
}
}, {
key: 'mapFromMix',
value: function mapFromMix(items) {
var entries = Array.from(items);
var rows = entries.filter(function (item) {
return item.unit === 'row';
}).map(function (item) {
return item.item;
});
var cells = entries.filter(function (item) {
return item.unit === 'cell';
}).map(function (item) {
return item.item;
});
return [].concat(toConsumableArray(this.mapFromRows(rows)), toConsumableArray(this.mapFromCells(cells)));
}
}]);
return CellSelector;
}();
function hashColumnKeyFactory(model) {
var selectionState = model.selection();
var selectionKey = selectionState.key;
if (selectionKey.column === identity$1) {
return function (column) {
return column.key;
};
}
// TODO: investigate if is it necessary to use JSON.stringify here
return identity$1;
}
function hashRowKeyFactory(model) {
var selectionState = model.selection();
var selectionKey = selectionState.key;
if (selectionKey.row === identity$1) {
var _model$data = model.data(),
rows = _model$data.rows;
var columns = model.columnList().line;
var index = columns.findIndex(function (column) {
return column.type === 'id';
});
if (index >= 0) {
var idColumn = columns[index];
var getId = getFactory(idColumn);
return getId;
}
return function (row) {
return rows.indexOf(row);
};
}
// TODO: investigate if is it necessary to use JSON.stringify here
return identity$1;
}
function hashKeyFactory(model) {
var selectionState = model.selection();
switch (selectionState.unit) {
case 'row':
return hashRowKeyFactory(model);
case 'column':
return hashColumnKeyFactory(model);
case 'cell':
{
var hashColumnKey = hashColumnKeyFactory(model);
var hashRowKey = hashRowKeyFactory(model);
return function (key) {
return hashColumnKey(key.column) + '[' + hashRowKey(key.row) + ']';
};
}
case 'mix':
{
var _hashColumnKey = hashColumnKeyFactory(model);
var _hashRowKey = hashRowKeyFactory(model);
return function (key, entry) {
if (!entry.unit) {
return key;
}
switch (entry.unit) {
case 'column':
return _hashColumnKey(key);
case 'row':
return _hashRowKey(key);
case 'cell':
return _hashColumnKey(key.column) + '[' + _hashRowKey(key.row) + ']';
default:
throw new AppError('selection.service', 'Invalid unit ' + entry.unit);
}
};
}
default:
throw new AppError('selection.service', 'Invalid unit ' + selectionState.unit);
}
}
function cellMatchFactory() {
return function (x, y) {
return x.column === y.column && x.row === y.row;
};
}
function keySelector(unit, selector) {
switch (unit) {
case 'row':
return selector.row;
case 'column':
return selector.column;
case 'cell':
return function (entry) {
if (entry.row && entry.column) {
return {
row: selector.row(entry.row),
column: selector.column(entry.column)
};
}
return entry;
};
default:
throw new AppError('selection.state', 'Invalid unit ' + unit);
}
}
function lookupColumnFactory(model, selectKey) {
var selectionState = model.selection();
if (selectionState.key.column === identity$1) {
return identity$1;
}
var columns = model.columnList().line;
return function (items) {
var result = [];
columns.forEach(function (column) {
var columnKey = selectKey(column);
var found = items.indexOf(columnKey) > -1;
if (found) {
result.push(column);
}
});
return result;
};
}
function lookupRowFactory(model, selectKey) {
var selectionState = model.selection();
if (selectionState.key.row === identity$1) {
return identity$1;
}
var _model$data2 = model.data(),
rows = _model$data2.rows;
return function (items) {
var result = [];
rows.forEach(function (row) {
var rowKey = selectKey(row);
var found = items.indexOf(rowKey) > -1;
if (found) {
result.push(row);
}
});
return result;
};
}
function lookupCellFactory(model, selectKey) {
var selectionState = model.selection();
if (selectionState.key.row === identity$1 && selectionState.key.column === identity$1) {
return identity$1;
}
var _model$data3 = model.data(),
rows = _model$data3.rows;
var columns = model.columnList().line;
var match = cellMatchFactory();
return function (items) {
var result = [];
columns.forEach(function (column) {
rows.forEach(function (row) {
var cell = {
column: column,
row: row
};
var index = items.findIndex(function (item) {
return match(item, selectKey(cell));
});
if (index >= 0) {
result.push(cell);
}
});
});
return result;
};
}
var SelectionService = function () {
function SelectionService(model) {
classCallCheck(this, SelectionService);
this.model = model;
}
createClass(SelectionService, [{
key: 'lookup',
value: function lookup(items, unit) {
var entries = [];
if (items.length === 0) {
return entries;
}
var model = this.model;
if (isUndefined(unit)) {
unit = model.selection().unit;
}
switch (unit) {
case 'column':
{
var selectKey = this.keyFactory('column');
var lookup = lookupColumnFactory(model, selectKey);
entries = lookup(items);
break;
}
case 'row':
{
var _selectKey = this.keyFactory('row');
var _lookup = lookupRowFactory(model, _selectKey);
entries = _lookup(items);
break;
}
case 'cell':
{
var _selectKey2 = this.keyFactory('cell');
var _lookup2 = lookupCellFactory(model, _selectKey2);
entries = _lookup2(items);
break;
}
case 'mix':
{
var _entries, _entries2, _entries3;
var rowKeys = items.filter(function (key) {
return key.unit === 'row';
}).map(function (key) {
return key.item;
});
var columnKeys = items.filter(function (key) {
return key.unit === 'column';
}).map(function (key) {
return key.item;
});
var cellKeys = items.filter(function (key) {
return key.unit === 'cell';
}).map(function (key) {
return key.item;
});
(_entries = entries).push.apply(_entries, toConsumableArray(this.lookup(rowKeys, 'row').map(function (entry) {
return { item: entry, unit: 'row' };
})));
(_entries2 = entries).push.apply(_entries2, toConsumableArray(this.lookup(columnKeys, 'column').map(function (entry) {
return { item: entry, unit: 'column' };
})));
(_entries3 = entries).push.apply(_entries3, toConsumableArray(this.lookup(cellKeys, 'cell').map(function (entry) {
return { item: entry, unit: 'cell' };
})));
break;
}
default:
throw new AppError('selection.state', 'Invalid unit ' + unit);
}
return entries;
}
}, {
key: 'map',
value: function map(entries) {
var selectionState = this.model.selection();
var selectKey = this.keyFactory();
switch (selectionState.unit) {
case 'column':
case 'row':
case 'cell':
return entries.map(selectKey);
case 'mix':
return entries.map(function (entry) {
return {
unit: entry.unit,
item: selectKey(entry)
};
});
default:
throw new AppError('selection.state', 'Invalid unit ' + selectionState.unit);
}
}
}, {
key: 'keyFactory',
value: function keyFactory(unit) {
var selectionState = this.model.selection();
unit = unit || selectionState.unit;
switch (unit) {
case 'column':
case 'row':
case 'cell':
return keySelector(unit, selectionState.key);
case 'mix':
{
var cellKey = keySelector('cell', selectionState.key);
var rowKey = keySelector('row', selectionState.key);
var columnKey = keySelector('column', selectionState.key);
return function (entry) {
if (!entry.unit) {
return identity$1;
}
switch (entry.unit) {
case 'column':
return columnKey(entry.item);
case 'row':
return rowKey(entry.item);
case 'cell':
return cellKey(entry.item);
default:
throw new AppError('selection.service', 'Invalid unit ' + entry.unit);
}
};
}
default:
throw new AppError('selection.service', 'Invalid unit ' + unit);
}
}
}, {
key: 'hashFactory',
value: function hashFactory() {
var selectKey = this.keyFactory();
var selectHash = hashKeyFactory(this.model);
return function (entry) {
var key = selectKey(entry);
var hashKey = selectHash(key, entry);
return hashKey;
};
}
}]);
return SelectionService;
}();
var HighlightView = function () {
function HighlightView(model, table) {
var _this = this;
classCallCheck(this, HighlightView);
this.model = model;
this.table = table;
this.cellSelector = new CellSelector(model, table);
this.selectionService = new SelectionService(model);
var sortBlurs = [];
var columnHoverBlurs = [];
var rowHoverBlurs = [];
var selectionBlurs = [];
var cellHoverBlurs = [];
this.column = new Command({
source: 'highlight.view',
canExecute: function canExecute() {
return !_this.isRendering;
},
execute: function execute(column, state) {
var columns = Array.from(model.highlight().columns);
var index$$1 = columns.indexOf(column.key);
var hasChanges = false;
if (state) {
if (index$$1 < 0) {
columns.push(column.key);
hasChanges = true;
}
} else {
if (index$$1 >= 0) {
columns.splice(index$$1, 1);
hasChanges = true;
}
}
if (hasChanges) {
model.highlight({ columns: columns }, {
source: 'highlight.view'
});
}
}
});
this.row = new Command({
source: 'highlight.view',
canExecute: function canExecute() {
return !_this.isRendering;
},
execute: function execute(row, state) {
var rows = Array.from(model.highlight().rows);
var index$$1 = rows.indexOf(row);
var hasChanges = false;
if (state) {
if (index$$1 < 0) {
rows.push(row);
hasChanges = true;
}
} else {
if (index$$1 >= 0) {
rows.splice(index$$1, 1);
hasChanges = true;
}
}
if (hasChanges) {
model.highlight({ rows: rows }, {
source: 'highlight.view'
});
}
}
});
this.cell = new Command({
source: 'highlight.view',
canExecute: function canExecute() {
return !_this.isRendering;
},
execute: function execute(newCell, state) {
var _model$highlight = model.highlight(),
cell = _model$highlight.cell;
var hasChanges = true;
if (newCell === cell) {
hasChanges = false;
} else if (newCell && cell) {
hasChanges = newCell.rowIndex !== cell.rowIndex || newCell.columnIndex !== cell.columnIndex;
}
if (hasChanges) {
model.highlight({ cell: newCell }, {
source: 'highlight.view'
});
}
}
});
model.selectionChanged.watch(function (e) {
if (e.hasChanges('items')) {
selectionBlurs = _this.invalidateSelection(selectionBlurs);
}
});
model.sceneChanged.watch(function (e) {
if (e.hasChanges('status')) {
if (e.state.status === 'stop') {
columnHoverBlurs = _this.invalidateColumnHover(columnHoverBlurs);
rowHoverBlurs = _this.invalidateRowHover(rowHoverBlurs);
cellHoverBlurs = _this.invalidateCellHover(cellHoverBlurs);
sortBlurs = _this.invalidateSortBy(sortBlurs);
selectionBlurs = _this.invalidateSelection(selectionBlurs);
}
}
});
model.sortChanged.watch(function (e) {
if (!_this.isRendering && e.hasChanges('by')) {
sortBlurs = _this.invalidateSortBy(sortBlurs);
}
});
model.highlightChanged.watch(function (e) {
if (!_this.isRendering) {
if (e.hasChanges('cell')) {
cellHoverBlurs = _this.invalidateCellHover(cellHoverBlurs);
}
if (e.hasChanges('columns')) {
columnHoverBlurs = _this.invalidateColumnHover(columnHoverBlurs);
}
if (e.hasChanges('rows')) {
rowHoverBlurs = _this.invalidateRowHover(rowHoverBlurs);
}
}
});
model.dragChanged.on(function (e) {
if (e.hasChanges('isActive')) {
if (e.state.isActive) {
model.highlight({
columns: [],
rows: [],
cell: null
}, {
source: 'highlight.view'
});
columnHoverBlurs = _this.invalidateColumnHover(columnHoverBlurs);
rowHoverBlurs = _this.invalidateRowHover(rowHoverBlurs);
cellHoverBlurs = _this.invalidateCellHover(cellHoverBlurs);
}
}
});
}
createClass(HighlightView, [{
key: 'invalidateColumnHover',
value: function invalidateColumnHover(dispose) {
dispose.forEach(function (f) {
return f();
});
dispose = [];
var _model$highlight2 = this.model.highlight(),
columns = _model$highlight2.columns;
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = columns[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var columnKey = _step.value;
dispose.push(this.highlightColumn(columnKey, 'highlighted'));
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
return dispose;
}
}, {
key: 'invalidateRowHover',
value: function invalidateRowHover(dispose) {
dispose.forEach(function (f) {
return f();
});
dispose = [];
var _model$highlight3 = this.model.highlight(),
rows = _model$highlight3.rows;
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = rows[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var row = _step2.value;
dispose.push(this.highlightRow(row, 'highlighted'));
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
return dispose;
}
}, {
key: 'invalidateCellHover',
value: function invalidateCellHover(dispose) {
dispose.forEach(function (f) {
return f();
});
dispose = [];
var _model$highlight4 = this.model.highlight(),
cell = _model$highlight4.cell;
if (cell) {
var body = this.table.body;
var rowIndex = cell.rowIndex,
columnIndex = cell.columnIndex;
dispose.push(this.highlightCell(body.cell(rowIndex, columnIndex), 'highlighted'));
}
return dispose;
}
}, {
key: 'invalidateSortBy',
value: function invalidateSortBy(dispose) {
dispose.forEach(function (f) {
return f();
});
dispose = [];
var sortBy = this.model.sort().by;
var _iteratorNormalCompletion3 = true;
var _didIteratorError3 = false;
var _iteratorError3 = undefined;
try {
for (var _iterator3 = sortBy[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
var entry = _step3.value;
var key$$1 = key(entry);
dispose.push(this.highlightColumn(key$$1, 'sorted'));
}
} catch (err) {
_didIteratorError3 = true;
_iteratorError3 = err;
} finally {
try {
if (!_iteratorNormalCompletion3 && _iterator3.return) {
_iterator3.return();
}
} finally {
if (_didIteratorError3) {
throw _iteratorError3;
}
}
}
return dispose;
}
}, {
key: 'invalidateSelection',
value: function invalidateSelection(dispose) {
var _this2 = this;
dispose.forEach(function (f) {
return f();
});
var selectionItems = this.model.selection().items;
var entries = this.selectionService.lookup(selectionItems);
var cells = this.cellSelector.map(entries);
dispose = cells.map(function (cell) {
return _this2.highlightCell(cell, 'selected');
});
return dispose;
}
}, {
key: 'findColumnPosition',
value: function findColumnPosition(key$$1) {
var _model$columnList = this.model.columnList(),
index$$1 = _model$columnList.index;
var pos = find(index$$1, function (node) {
return node.key.model.key === key$$1;
});
if (pos) {
return findLeaves(pos.node).map(function (leaf) {
return leaf.key.columnIndex;
});
}
return [];
}
}, {
key: 'highlightColumn',
value: function highlightColumn(key$$1, cls) {
var position = this.findColumnPosition(key$$1);
if (!position.length) {
return noop$1;
}
var _table = this.table,
head = _table.head,
body = _table.body,
foot = _table.foot;
Fastdom.mutate(function () {
var isLeaf = position.length === 1;
var _iteratorNormalCompletion4 = true;
var _didIteratorError4 = false;
var _iteratorError4 = undefined;
try {
for (var _iterator4 = position[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
var index$$1 = _step4.value;
if (isLeaf) {
head.column(index$$1).addClass(GRID_PREFIX + '-' + cls);
head.column(index$$1 - 1).addClass(GRID_PREFIX + '-' + cls + '-prev');
head.column(index$$1 + 1).addClass(GRID_PREFIX + '-' + cls + '-next');
}
var bodyColumn = body.column(index$$1);
var column = bodyColumn.model();
if (column && column.canHighlight) {
bodyColumn.addClass(GRID_PREFIX + '-' + cls);
foot.column(index$$1).addClass(GRID_PREFIX + '-' + cls);
}
}
} catch (err) {
_didIteratorError4 = true;
_iteratorError4 = err;
} finally {
try {
if (!_iteratorNormalCompletion4 && _iterator4.return) {
_iterator4.return();
}
} finally {
if (_didIteratorError4) {
throw _iteratorError4;
}
}
}
});
return this.blurColumn(key$$1, cls);
}
}, {
key: 'blurColumn',
value: function blurColumn(key$$1, cls) {
var position = this.findColumnPosition(key$$1);
if (!position.length) {
return noop$1;
}
var _table2 = this.table,
head = _table2.head,
body = _table2.body,
foot = _table2.foot;
return function () {
Fastdom.mutate(function () {
var _iteratorNormalCompletion5 = true;
var _didIteratorError5 = false;
var _iteratorError5 = undefined;
try {
for (var _iterator5 = position[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
var index$$1 = _step5.value;
head.column(index$$1).removeClass(GRID_PREFIX + '-' + cls);
head.column(index$$1 - 1).removeClass(GRID_PREFIX + '-' + cls + '-prev');
head.column(index$$1 + 1).removeClass(GRID_PREFIX + '-' + cls + '-next');
body.column(index$$1).removeClass(GRID_PREFIX + '-' + cls);
foot.column(index$$1).removeClass(GRID_PREFIX + '-' + cls);
}
} catch (err) {
_didIteratorError5 = true;
_iteratorError5 = err;
} finally {
try {
if (!_iteratorNormalCompletion5 && _iterator5.return) {
_iterator5.return();
}
} finally {
if (_didIteratorError5) {
throw _iteratorError5;
}
}
}
});
};
}
}, {
key: 'highlightRow',
value: function highlightRow(index$$1, cls) {
if (index$$1 < 0) {
return noop$1;
}
var body = this.table.body;
Fastdom.mutate(function () {
return body.row(index$$1).addClass(GRID_PREFIX + '-' + cls);
});
return this.blurRow(index$$1, cls);
}
}, {
key: 'blurRow',
value: function blurRow(index$$1, cls) {
var table = this.table;
if (index$$1 < 0) {
return noop$1;
}
var row = table.body.row(index$$1);
return function () {
return Fastdom.mutate(function () {
return row.removeClass(GRID_PREFIX + '-' + cls);
});
};
}
}, {
key: 'highlightCell',
value: function highlightCell(cell, cls) {
Fastdom.mutate(function () {
cell.addClass(GRID_PREFIX + '-' + cls);
});
return this.blurCell(cell, cls);
}
}, {
key: 'blurCell',
value: function blurCell(cell, cls) {
return function () {
return Fastdom.mutate(function () {
return cell.removeClass(GRID_PREFIX + '-' + cls);
});
};
}
}, {
key: 'isRendering',
get: function get$$1() {
return this.model.scene().status !== 'stop' || this.model.drag().isActive;
}
}]);
return HighlightView;
}();
var LayoutView = function (_Disposable) {
inherits(LayoutView, _Disposable);
function LayoutView(model, table, service) {
classCallCheck(this, LayoutView);
var _this = possibleConstructorReturn(this, (LayoutView.__proto__ || Object.getPrototypeOf(LayoutView)).call(this));
_this.model = model;
_this.table = table;
_this.service = service;
model.navigationChanged.watch(function (e) {
if (e.hasChanges('cell')) {
var oldColumn = e.changes.cell.oldValue ? e.changes.cell.oldValue.column : {};
var newColumn = e.changes.cell.newValue ? e.changes.cell.newValue.column : {};
if (oldColumn.key !== newColumn.key && (oldColumn.viewWidth || newColumn.viewWidth)) {
var form = _this.updateColumnForm();
_this.invalidateColumns(form);
}
}
});
_this.onInit();
return _this;
}
createClass(LayoutView, [{
key: 'onInit',
value: function onInit() {
var _this2 = this;
var model = this.model;
var styleRow = this.styleRow.bind(this);
model.layoutChanged.watch(function (e) {
if (e.tag.source === 'layout.view') {
return;
}
if (e.hasChanges('columns')) {
var form = _this2.updateColumnForm();
_this2.invalidateColumns(form);
}
});
model.rowChanged.watch(function (e) {
if (e.hasChanges('canResize')) {
var rows = Array.from(model.style().rows);
if (e.state.canResize) {
rows.push(styleRow);
} else {
var index = model.style.rows.indexOf(styleRow);
rows.splice(index, 1);
}
model.style({ rows: rows }, { source: 'layout.view' });
}
});
model.dataChanged.watch(function (e) {
if (e.hasChanges('columns')) {
model.layout({
columns: new Map()
}, {
source: 'layout.view',
behavior: 'core'
});
}
});
model.sceneChanged.watch(function (e) {
if (e.hasChanges('column')) {
_this2.invalidateColumns();
}
if (e.hasChanges('status')) {
if (e.state.status === 'stop') {
_this2.updateColumnForm();
}
}
});
}
}, {
key: 'updateColumnForm',
value: function updateColumnForm() {
var model = this.model;
var head = this.table.head;
var layout = model.layout().columns;
var form = new Map();
var cells = this.table.head.context.bag.cells;
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = cells[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var cell = _step.value;
var _column = cell.column,
rowIndex = cell.rowIndex,
columnIndex = cell.columnIndex;
if (!_column.canResize) {
continue;
}
var key = _column.key;
if (layout.has(key)) {
form.set(key, { width: layout.get(key).width });
} else {
var th = head.cell(rowIndex, columnIndex);
var width = th.width();
// It can be that clientWidth is zero on start, while css is not applied.
if (width) {
form.set(key, { width: width });
}
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
model.layout({ columns: form }, { source: 'layout.view', behavior: 'core' });
var _model$navigation = this.model.navigation(),
column = _model$navigation.column;
if (column && column.viewWidth) {
var viewForm = new Map(form);
var columnForm = form.get(column.key);
viewForm.set(column.key, { width: columnForm ? Math.max(columnForm.width, column.viewWidth) : column.viewWidth });
return viewForm;
}
return form;
}
}, {
key: 'invalidateColumns',
value: function invalidateColumns(form) {
Log.info('layout', 'invalidate columns');
var table = this.table;
var columns = table.data.columns();
var getWidth = widthFactory(table, form);
var style = {};
var length = columns.length;
while (length--) {
var column = columns[length];
var width = getWidth(column.key);
if (null !== width) {
var key = escape(column.key);
var size = width + 'px';
var sizeStyle = {
'width': size,
'min-width': size,
'max-width': size
};
style['td.q-grid-the-' + key] = sizeStyle;
style['th.q-grid-the-' + key] = sizeStyle;
}
}
var sheet$$1 = sheet(this.gridId, 'layout-column');
sheet$$1.set(style);
}
}, {
key: 'styleRow',
value: function styleRow(row, context) {
var model = this.model;
var layout = model.layout;
var form = layout().rows;
var style = form.get(row);
if (style) {
context.class('resized-' + style.height + 'px', { height: style.height + 'px' });
}
}
}, {
key: 'dispose',
value: function dispose() {
get(LayoutView.prototype.__proto__ || Object.getPrototypeOf(LayoutView.prototype), 'dispose', this).call(this);
var sheet$$1 = sheet(this.gridId, 'layout-column');
sheet$$1.remove();
}
}, {
key: 'gridId',
get: function get$$1() {
return this.model.grid().id;
}
}]);
return LayoutView;
}(Disposable);
var Navigation = function () {
function Navigation(model, table) {
classCallCheck(this, Navigation);
this.model = model;
this.table = table;
}
createClass(Navigation, [{
key: 'positon',
value: function positon(y, direction) {
var table = this.table;
var body = table.body;
var lastRow = this.lastRow;
var lower = table.view.scrollHeight() - table.view.height();
var index = 0;
var offset = 0;
// TODO: improve performance
while (index <= lastRow && offset <= y) {
offset += body.row(index).height();
index++;
}
if (direction === 'down' && body.row(index)) {
offset -= body.row(index).height();
index--;
}
var row = Math.max(this.firstRow, Math.min(lastRow, index));
offset = Math.min(offset, lower);
return { row: row, offset: offset };
}
}, {
key: 'goTo',
value: function goTo(rowIndex, columnIndex) {
var source = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'navigation';
var cell = this.cell(rowIndex, columnIndex);
if (!cell) {
// TODO: make it better, right it just a huck for row-details,
// need to support rowspan and colspan
cell = this.cell(rowIndex, this.firstColumn);
}
this.model.navigation({ cell: cell }, { source: source });
return true;
}
}, {
key: 'columns',
value: function columns(rowIndex) {
var columns = this.table.body.columns(rowIndex);
var index = [];
for (var i = 0, length = columns.length; i < length; i++) {
var column = columns[i];
if (column.model().canFocus) {
index.push(column.index);
}
}
return index;
}
}, {
key: 'cell',
value: function cell(rowIndex, columnIndex) {
var cell = this.table.body.cell(rowIndex, columnIndex);
var model = cell.model();
if (model) {
var row = model.row,
column = model.column;
return {
rowIndex: rowIndex,
columnIndex: columnIndex,
row: row,
column: column
};
}
return null;
}
}, {
key: 'context',
value: function context(type, settings) {
var model = this.model;
var oldRow = this.currentRow;
var oldColumn = this.currentColumn;
var keyCode = model.action().shortcut.keyCode;
return Object.assign({
model: model,
type: type,
oldRow: oldRow,
oldColumn: oldColumn,
keyCode: keyCode
}, settings);
}
}, {
key: 'currentColumn',
get: function get$$1() {
var columns = this.columns(this.currentRow);
var columnIndex = this.model.navigation().columnIndex;
var index = columns.indexOf(columnIndex);
return columns.length ? columns[Math.max(index, 0)] : -1;
}
}, {
key: 'nextColumn',
get: function get$$1() {
var columns = this.columns(this.currentRow);
var index = columns.indexOf(this.currentColumn);
return index >= 0 && index < columns.length - 1 ? columns[index + 1] : -1;
}
}, {
key: 'prevColumn',
get: function get$$1() {
var columns = this.columns(this.currentRow);
var index = columns.indexOf(this.currentColumn);
return index > 0 && index < columns.length ? columns[index - 1] : -1;
}
}, {
key: 'lastColumn',
get: function get$$1() {
var columns = this.columns(this.currentRow);
var index = columns.length - 1;
return index >= 0 ? columns[index] : -1;
}
}, {
key: 'firstColumn',
get: function get$$1() {
var columns = this.columns(this.currentRow);
return columns.length ? columns[0] : -1;
}
}, {
key: 'currentRow',
get: function get$$1() {
var _model$navigation = this.model.navigation(),
rowIndex = _model$navigation.rowIndex;
if (rowIndex < 0) {
return this.model.scene().rows.length ? 0 : -1;
}
return rowIndex;
}
}, {
key: 'nextRow',
get: function get$$1() {
var row = this.currentRow + 1;
return row <= this.lastRow ? row : -1;
}
}, {
key: 'prevRow',
get: function get$$1() {
var row = this.currentRow - 1;
return row >= 0 ? row : -1;
}
}, {
key: 'firstRow',
get: function get$$1() {
return Math.min(0, this.lastRow);
}
}, {
key: 'lastRow',
get: function get$$1() {
return this.table.body.rowCount(this.currentColumn) - 1;
}
}, {
key: 'commands',
get: function get$$1() {
var _this = this;
var model = this.model;
var table = this.table;
var shortcut = model.navigation().shortcut;
var edit = model.edit;
var canNavigate = function canNavigate() {
if (edit().state === 'view') {
return true;
}
var column = table.body.column(_this.currentColumn).model();
return column && (column.editorOptions.trigger === 'focus' || column.editorOptions.cruise === 'transparent');
};
var go = this.model.navigation().go;
var commands = {
goDown: new Command({
source: 'navigation',
shortcut: shortcut.down,
canExecute: function canExecute() {
if (canNavigate()) {
var newRow = _this.nextRow;
return newRow >= 0 && go.canExecute(_this.context('down', { newRow: newRow }));
}
return false;
},
execute: function execute() {
var newRow = _this.nextRow;
var newColumn = _this.currentColumn;
return go.execute(_this.context('down', { newRow: newRow, newColumn: newColumn })) && _this.goTo(newRow, newColumn);
}
}),
goUp: new Command({
source: 'navigation',
shortcut: shortcut.up,
canExecute: function canExecute() {
if (canNavigate()) {
var newRow = _this.prevRow;
return newRow >= 0 && go.canExecute(_this.context('up', { newRow: newRow }));
}
return false;
},
execute: function execute() {
var newRow = _this.prevRow;
var newColumn = _this.currentColumn;
return go.execute(_this.context('up', { newRow: newRow, newColumn: newColumn })) && _this.goTo(newRow, newColumn);
}
}),
goRight: new Command({
source: 'navigation',
shortcut: shortcut.right,
canExecute: function canExecute() {
if (canNavigate()) {
var newColumn = _this.nextColumn;
return newColumn >= 0 && go.canExecute(_this.context('right', { newColumn: newColumn }));
}
return false;
},
execute: function execute() {
var newRow = _this.currentRow;
var newColumn = _this.nextColumn;
return go.execute(_this.context('right', { newRow: newRow, newColumn: newColumn })) && _this.goTo(newRow, newColumn);
}
}),
goLeft: new Command({
source: 'navigation',
shortcut: shortcut.left,
canExecute: function canExecute() {
if (canNavigate()) {
var newColumn = _this.prevColumn;
return newColumn >= 0 && go.canExecute(_this.context('left', { newColumn: newColumn }));
}
return false;
},
execute: function execute() {
var newRow = _this.currentRow;
var newColumn = _this.prevColumn;
return go.execute(_this.context('left', { newRow: newRow, newColumn: newColumn })) && _this.goTo(newRow, newColumn);
}
}),
goNext: new Command({
source: 'navigation',
shortcut: shortcut.next,
canExecute: function canExecute() {
var newRow = _this.nextRow;
var newColumn = _this.nextColumn;
var hasNextColumn = newColumn >= 0;
var hasNextRow = newRow >= 0;
return (hasNextColumn || hasNextRow) && go.canExecute(_this.context('next', { newRow: newRow, newColumn: newColumn }));
},
execute: function execute() {
var nextColumn = _this.nextColumn;
var hasNextColumn = nextColumn >= 0;
var newRow = hasNextColumn ? _this.currentRow : _this.nextRow;
var newColumn = hasNextColumn ? nextColumn : _this.firstColumn;
return go.execute(_this.context('next', { newRow: newRow, newColumn: newColumn })) && _this.goTo(newRow, newColumn);
}
}),
goPrevious: new Command({
source: 'navigation',
shortcut: shortcut.previous,
canExecute: function canExecute() {
var newColumn = _this.prevColumn;
var newRow = _this.prevRow;
var hasPrevColumn = newColumn >= 0;
var hasPrevRow = newRow >= 0;
return (hasPrevColumn || hasPrevRow) && go.canExecute(_this.context('previous', { newRow: newRow, newColumn: newColumn }));
},
execute: function execute() {
var prevColumn = _this.prevColumn;
var hasPrevColumn = prevColumn >= 0;
var newColumn = hasPrevColumn ? prevColumn : _this.lastColumn;
var newRow = hasPrevColumn ? _this.currentRow : _this.prevRow;
return go.execute(_this.context('previous', { newRow: newRow, newColumn: newColumn })) && _this.goTo(newRow, newColumn);
}
}),
home: new Command({
source: 'navigation',
shortcut: shortcut.home,
canExecute: function canExecute() {
if (canNavigate()) {
var newColumn = _this.prevColumn;
return newColumn >= 0 && go.canExecute(_this.context('end', { newColumn: newColumn }));
}
return false;
},
execute: function execute() {
var newRow = _this.currentRow;
var newColumn = _this.firstColumn;
return go.execute(_this.context('home', { newRow: newRow, newColumn: newColumn })) && _this.goTo(newRow, newColumn);
}
}),
end: new Command({
source: 'navigation',
shortcut: shortcut.end,
canExecute: function canExecute() {
if (canNavigate()) {
var newColumn = _this.nextColumn;
return newColumn >= 0 && go.canExecute(_this.context('home', { newColumn: newColumn }));
}
return false;
},
execute: function execute() {
var newRow = _this.currentRow;
var newColumn = _this.lastColumn;
return go.execute(_this.context('end', { newRow: newRow, newColumn: newColumn })) && _this.goTo(newRow, newColumn);
}
}),
upward: new Command({
source: 'navigation',
shortcut: shortcut.upward,
canExecute: function canExecute() {
if (canNavigate()) {
var newRow = _this.prevRow;
return newRow >= 0 && go.canExecute(_this.context('upward', { newRow: newRow }));
}
return false;
},
execute: function execute() {
var newRow = _this.firstRow;
var newColumn = _this.currentColumn;
return go.execute(_this.context('upward', { newRow: newRow, newColumn: newColumn })) && _this.goTo(newRow, newColumn);
}
}),
downward: new Command({
source: 'navigation',
shortcut: shortcut.downward,
canExecute: function canExecute() {
if (canNavigate()) {
var newRow = _this.nextRow;
return newRow >= 0 && go.canExecute(_this.context('downward', { newRow: newRow }));
}
return false;
},
execute: function execute() {
var newRow = _this.lastRow;
var newColumn = _this.currentColumn;
return go.execute(_this.context('downward', { newRow: newRow, newColumn: newColumn })) && _this.goTo(newRow, newColumn);
}
}),
pageUp: new Command({
source: 'navigation',
shortcut: shortcut.pageUp,
canExecute: function canExecute() {
if (canNavigate()) {
var newRow = _this.prevRow;
return newRow >= 0 && go.canExecute(_this.context('pageUp', { newRow: newRow }));
}
return false;
},
execute: function execute() {
var view = table.view;
var position = _this.positon(view.scrollTop() - view.height(), 'up');
var newRow = position.row;
var newColumn = _this.currentColumn;
if (go.execute(_this.context('pageUp', { newRow: newRow, newColumn: newColumn }))) {
_this.model.scroll({ top: position.offset }, { source: 'navigation' });
return _this.goTo(newRow, newColumn, 'navigation.scroll');
}
return false;
}
}),
pageDown: new Command({
source: 'navigation',
shortcut: shortcut.pageDown,
canExecute: function canExecute() {
if (canNavigate()) {
var newRow = _this.nextRow;
return newRow >= 0 && go.canExecute(_this.context('pageDown', { newRow: newRow }));
}
return false;
},
execute: function execute() {
var view = table.view;
var position = _this.positon(view.scrollTop() + view.height(), 'down');
var newRow = position.row;
var newColumn = _this.currentColumn;
if (go.execute(_this.context('pageDown', { newRow: newRow, newColumn: newColumn }))) {
_this.model.scroll({ top: position.offset }, { source: 'navigation' });
return _this.goTo(position.row, _this.currentColumn, 'navigation.scroll');
}
return false;
}
})
};
return new Map(Object.entries(commands));
}
}]);
return Navigation;
}();
var NavigationView = function () {
function NavigationView(model, table, shortcut) {
var _this = this;
classCallCheck(this, NavigationView);
this.model = model;
this.table = table;
var navigation = new Navigation(model, table);
var focusBlurs = [];
shortcut.register(navigation.commands);
this.focus = new Command({
source: 'navigation.view',
execute: function execute(e) {
var rowIndex = e.rowIndex,
columnIndex = e.columnIndex,
behavior = e.behavior;
var td = table.body.cell(rowIndex, columnIndex).model();
if (td) {
var row = td.row,
column = td.column;
model.navigation({
cell: {
rowIndex: rowIndex,
columnIndex: columnIndex,
row: row,
column: column
}
}, {
source: 'navigation.view',
behavior: behavior
});
} else {
model.navigation({
cell: null
}, {
source: 'navigation.view',
behavior: behavior
});
}
},
canExecute: function canExecute(newCell) {
var oldCell = model.navigation().cell;
if (newCell && newCell.column.canFocus && !Td.equals(newCell, oldCell)) {
return true;
}
return false;
}
});
this.scrollTo = new Command({
source: 'navigation.view',
execute: function execute(row, column) {
var cell = table.body.cell(row, column);
_this.scroll(table.view, cell);
},
canExecute: function canExecute(row, column) {
return table.body.cell(row, column).model() !== null;
}
});
model.navigationChanged.watch(function (e) {
if (e.hasChanges('cell')) {
if (e.tag.behavior !== 'core') {
// We need this one to toggle focus from details to main grid
// or when user change navigation cell through the model
if (!_this.table.view.isFocused()) {
_this.table.view.focus();
}
}
var _e$state = e.state,
rowIndex = _e$state.rowIndex,
columnIndex = _e$state.columnIndex;
focusBlurs = _this.invalidateFocus(focusBlurs);
if (e.tag.source !== 'navigation.scroll' && _this.scrollTo.canExecute(rowIndex, columnIndex)) {
_this.scrollTo.execute(rowIndex, columnIndex);
}
model.focus({
rowIndex: rowIndex,
columnIndex: columnIndex
}, {
source: 'navigation.view'
});
}
});
model.focusChanged.watch(function (e) {
if (e.tag.source === 'navigation.view') {
return;
}
if (e.hasChanges('isActive')) {
var view = table.view;
var activeClassName = GRID_PREFIX + '-active';
if (e.state.isActive) {
Fastdom.mutate(function () {
return view.addClass(activeClassName);
});
view.focus();
} else {
Fastdom.mutate(function () {
return view.removeClass(activeClassName);
});
}
}
if (e.hasChanges('rowIndex') || e.hasChanges('columnIndex')) {
_this.focus.execute(e.state);
}
});
model.sceneChanged.watch(function (e) {
if (e.hasChanges('status')) {
var status = e.state.status;
switch (status) {
case 'stop':
var _model$navigation = model.navigation(),
row = _model$navigation.row,
column = _model$navigation.column,
columnIndex = _model$navigation.columnIndex,
rowIndex = _model$navigation.rowIndex;
if (row && column) {
var newRowIndex = table.data.rows().indexOf(row);
var newColumnIndex = table.data.columns().findIndex(function (c) {
return c.key === column.key;
});
if (newColumnIndex < 0 && column.class === 'control') {
newColumnIndex = columnIndex;
}
_this.focus.execute({
rowIndex: newRowIndex,
columnIndex: newColumnIndex,
behavior: 'core'
});
}
break;
}
}
});
}
createClass(NavigationView, [{
key: 'invalidateFocus',
value: function invalidateFocus(dispose) {
dispose.forEach(function (f) {
return f();
});
dispose = [];
var _model$navigation2 = this.model.navigation(),
rowIndex = _model$navigation2.rowIndex,
columnIndex = _model$navigation2.columnIndex;
var cell = this.table.body.cell(rowIndex, columnIndex);
if (cell.model()) {
Fastdom.mutate(function () {
return cell.addClass(GRID_PREFIX + '-focused');
});
dispose.push(function () {
return Fastdom.mutate(function () {
return cell.removeClass(GRID_PREFIX + '-focused');
});
});
}
return dispose;
}
}, {
key: 'scroll',
value: function scroll(view, target) {
var scroll = this.model.scroll;
Fastdom.measure(function () {
var tr = target.rect();
var vr = view.rect();
var state = {};
if (view.canScrollTo(target, 'left')) {
if (vr.left > tr.left || vr.left > tr.right || vr.right < tr.left || vr.right < tr.right) {
if (vr.width < tr.width || vr.left > tr.left || vr.left > tr.right) {
state.left = tr.left - vr.left + scroll().left;
} else if (vr.left < tr.left || vr.right < tr.right) {
state.left = tr.right - vr.right + scroll().left;
}
}
}
if (view.canScrollTo(target, 'top')) {
if (vr.top > tr.top || vr.top > tr.bottom || vr.bottom < tr.top || vr.bottom < tr.bottom) {
if (vr.height < tr.height || vr.top > tr.top || vr.top > tr.bottom) {
state.top = tr.top - vr.top + scroll().top;
} else if (vr.top < tr.top || vr.bottom < tr.bottom) {
state.top = tr.bottom - vr.bottom + scroll().top;
}
}
}
if (Object.keys(state).length) {
scroll(state, { behavior: 'core', source: 'navigation.view' });
}
});
}
}]);
return NavigationView;
}();
var PaginationView = function () {
function PaginationView(model) {
classCallCheck(this, PaginationView);
this.model = model;
var triggers = model.pagination().resetTriggers;
Object.keys(triggers).forEach(function (name) {
return model[name + 'Changed'].on(function (e) {
if (e.tag.behavior === 'core') {
return;
}
if (model.scroll().mode === 'virtual') {
return;
}
var trigger = triggers[name];
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = trigger[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var key = _step.value;
if (e.hasChanges(key)) {
model.pagination({ current: 0 }, { source: e.tag.source || 'pagination.view' });
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
});
});
}
createClass(PaginationView, [{
key: 'current',
get: function get$$1() {
return this.model.pagination().current;
}
}, {
key: 'size',
get: function get$$1() {
return this.model.pagination().size;
}
}]);
return PaginationView;
}();
var RowDetailsView = function () {
function RowDetailsView(model, table, shortcut) {
classCallCheck(this, RowDetailsView);
this.model = model;
this.toggleStatus = new Command({
source: 'row.details.view',
execute: function execute(row) {
if (!row) {
var currentRow = model.navigation().row;
row = currentRow;
}
var status = toggleStatus([row], model.row().status, model.row().mode);
model.row({ status: status }, {
source: 'row.details.view'
});
},
canExecute: function canExecute(row) {
if (!row) {
var _model$navigation = model.navigation(),
cell = _model$navigation.cell;
if (cell && cell.column.type === 'row-expand') {
row = cell.row;
}
}
return !!row;
},
shortcut: model.row().shortcut.toggle
});
model.sceneChanged.watch(function (e) {
if (e.tag.source === 'row.details.view') {
return;
}
if (e.hasChanges('rows')) {
var rowState = model.row();
var status = invalidateStatus(model.data().rows, rowState.status, rowState.mode);
model.row({ status: status }, { source: 'row.details.view' });
}
});
shortcut.register([this.toggleStatus]);
}
createClass(RowDetailsView, [{
key: 'status',
value: function status(row) {
if (row instanceof RowDetails) {
return null;
}
var _model$row = this.model.row(),
status = _model$row.status;
var state = status.get(row);
return state && state.expand ? 'expand' : 'collapse';
}
}]);
return RowDetailsView;
}();
var RowView = function () {
function RowView(model, table, tagName) {
classCallCheck(this, RowView);
this.model = model;
this.tagName = tagName;
var pathFinder = new PathService(table.context.bag.body);
this.drop = new Command({
source: 'row.view',
canExecute: function canExecute(e) {
if (e.action === 'end') {
return true;
}
var oldIndex = e.dragData;
var row = pathFinder.row(eventPath(e));
return !!row;
},
execute: function execute(e) {
var oldIndex = e.dragData;
switch (e.action) {
case 'over':
{
var row = pathFinder.row(eventPath(e));
if (!e.inAreaY(row.element)) {
return;
}
var newIndex = row.index;
if (oldIndex !== newIndex) {
if (model.scroll().mode === 'virtual') {
var oldRow = table.body.row(oldIndex);
oldRow.removeClass(GRID_PREFIX + '-drag');
var newRow = table.body.row(newIndex);
newRow.addClass(GRID_PREFIX + '-drag');
}
var tr = table.body.row(oldIndex).model();
var entries = [];
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = model.rowList().index.entries()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var entry = _step.value;
var _index = entry[1];
if (oldIndex < _index && _index <= newIndex) {
entry[1] = _index - 1;
} else if (oldIndex > _index && _index >= newIndex) {
entry[1] = _index + 1;
}
entries.push(entry);
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
var index = new Map(entries);
var _model$data = model.data(),
id = _model$data.id;
var key = id.row(newIndex, tr.model);
index.set(key, newIndex);
model.rowList({ index: index }, { source: 'row.view' });
e.dragData = newIndex;
}
break;
}
case 'drop':
case 'end':
{
var _oldRow = table.body.row(oldIndex);
_oldRow.removeClass(GRID_PREFIX + '-drag');
break;
}
}
}
});
this.drag = new Command({
source: 'row.view',
execute: function execute(e) {
var index = e.data;
var row = table.body.row(index);
row.addClass(GRID_PREFIX + '-drag');
var tr = row.model();
if (tr) {
return tr.element;
}
},
canExecute: function canExecute(e) {
if (isNumber(e.data)) {
var index = e.data;
return index >= 0 && model.view().rows.length > index;
}
return false;
}
});
this.resize = new Command({
source: 'row.view'
});
model.dataChanged.on(function (e) {
if (e.hasChanges('rows')) {
model.rowList({
index: new Map()
}, {
source: 'row.view',
behavior: 'core'
});
}
});
}
createClass(RowView, [{
key: 'canMove',
get: function get$$1() {
return this.model.row().canMove;
}
}, {
key: 'canResize',
get: function get$$1() {
return this.model.row().canResize;
}
}]);
return RowView;
}();
var ScrollView = function () {
function ScrollView(model, table, vscroll, gridService) {
var _this = this;
classCallCheck(this, ScrollView);
this.model = model;
this.table = table;
var scroll = model.scroll;
var rowHeight = model.row().height;
var pagination = model.pagination;
var settings = {
threshold: model.pagination().size,
resetTriggers: []
};
if (rowHeight > 0 || isFunction(rowHeight)) {
settings.rowHeight = rowHeight;
}
this.y = vscroll.factory(settings);
this.y.container.read = Fastdom.measure;
this.y.container.write = Fastdom.mutate;
var subscribe = (this.y.container.drawEvent.on || this.y.container.drawEvent.subscribe).bind(this.y.container.drawEvent);
var updateCurrentPage = function updateCurrentPage(position) {
var _pagination = pagination(),
size = _pagination.size,
current = _pagination.current,
count = _pagination.count;
var newCurrent = size === 0 ? 0 : count - 1 <= position + size ? Math.ceil(count / size) - 1 : Math.floor((position + size / 2) / size);
if (newCurrent !== current) {
pagination({ current: newCurrent }, {
source: 'scroll.view',
behavior: 'core'
});
}
};
var updateTotalCount = function updateTotalCount() {
var _model$pipe = model.pipe(),
effect = _model$pipe.effect;
if (effect.hasOwnProperty('memo')) {
var count = effect.memo.length;
pagination({ count: count }, {
source: 'scroll.view',
behavior: 'core'
});
return count;
}
return pagination().count;
};
subscribe(function (e) {
var position = e.position;
updateCurrentPage(position);
scroll({ cursor: position }, {
source: 'scroll.view',
behavior: 'core'
});
});
switch (scroll().mode) {
case 'virtual':
{
this.y.settings.fetch = function (skip, take, d) {
model.fetch({ skip: skip }, {
source: 'scroll.view',
behavior: 'core'
});
if (skip === 0) {
var count = updateTotalCount();
d.resolve(count);
} else {
gridService.invalidate({
source: 'scroll.view',
why: 'refresh'
}).then(function () {
var count = updateTotalCount();
d.resolve(count);
});
}
};
var startSource = void 0;
var resetTriggers = new Set(scroll().resetTriggers);
model.sceneChanged.watch(function (e) {
if (e.hasChanges('status')) {
var status = e.state.status;
switch (status) {
case 'start':
{
startSource = e.tag.source;
if (resetTriggers.has(startSource)) {
model.fetch({ skip: 0 }, {
source: 'scroll.view',
behavior: 'core'
});
}
break;
}
case 'stop':
{
if (resetTriggers.has(startSource)) {
_this.y.container.reset();
}
break;
}
}
}
});
break;
}
default:
model.paginationChanged.watch(function () {
return _this.y.container.reset();
});
}
model.scrollChanged.watch(function (e) {
if (e.source === 'scroll.view') {
return;
}
if (e.hasChanges('mode')) {
switch (e.state.mode) {
case 'virtual':
{
scroll({
map: {
rowToView: function rowToView(index) {
return index - _this.y.container.position;
},
viewToRow: function viewToRow(index) {
return index + _this.y.container.position;
}
}
}, {
source: 'scroll.view',
behavior: 'core'
});
break;
}
case 'default':
{
scroll({
map: {
rowToView: identity$1,
viewToRow: identity$1
}
});
break;
}
}
}
if (e.hasChanges('left') || e.hasChanges('top')) {
_this.invalidate();
}
});
}
createClass(ScrollView, [{
key: 'invalidate',
value: function invalidate() {
Log.info('layout', 'invalidate scroll');
var table = this.table;
var scroll = this.model.scroll();
Fastdom.mutate(function () {
table.view.scrollLeft(scroll.left);
table.view.scrollTop(scroll.top);
});
}
}, {
key: 'mode',
get: function get$$1() {
return this.model.scroll().mode;
}
}]);
return ScrollView;
}();
var SelectionState = function () {
function SelectionState(model, service) {
classCallCheck(this, SelectionState);
this.model = model;
this.service = service;
}
createClass(SelectionState, [{
key: 'select',
value: function select(item) {
var _this = this;
var state = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
var key = arguments[2];
key = key || this.keyFactory();
if (isArray(item)) {
item.forEach(function (item) {
return _this.select(item, state, key);
});
return;
}
if (item instanceof Node$1) {
var _model$data = this.model.data(),
rows = _model$data.rows;
if (rows.length) {
item.rows.forEach(function (index) {
return _this.select(rows[index], state, key);
});
return;
}
}
this.selectCore(item, state, key);
}
}, {
key: 'toggle',
value: function toggle(item) {
var state = this.state(item);
return this.select(item, state === null || !state);
}
}, {
key: 'state',
value: function state(item, key) {
var _this2 = this;
key = key || this.keyFactory();
if (isArray(item)) {
var all = item.every(function (item) {
return _this2.state(item, key);
});
return all ? true : item.some(function (item) {
return _this2.state(item, key);
}) ? null : false;
}
if (item instanceof Node$1) {
var _model$data2 = this.model.data(),
rows = _model$data2.rows;
if (rows.length) {
var _all = item.rows.length && item.rows.every(function (index) {
return _this2.state(rows[index], key);
});
return _all ? true : item.rows.some(function (index) {
return _this2.state(rows[index], key);
}) ? null : false;
}
}
return this.stateCore(item, key);
}
}, {
key: 'stateAll',
value: function stateAll(items) {
var entries = this.entries();
if (items.length === entries.length) {
return true;
}
return entries.length > 0 ? null : false;
}
}, {
key: 'keyFactory',
value: function keyFactory() {
return this.service.hashFactory();
}
}, {
key: 'clear',
value: function clear() {
this.clearCore();
}
}, {
key: 'entries',
value: function entries() {
return [];
}
}, {
key: 'selectCore',
value: function selectCore() {}
}, {
key: 'clearCore',
value: function clearCore() {}
}, {
key: 'stateCore',
value: function stateCore() {
return false;
}
}]);
return SelectionState;
}();
var SingleSelectionState = function (_SelectionState) {
inherits(SingleSelectionState, _SelectionState);
function SingleSelectionState(model, service) {
classCallCheck(this, SingleSelectionState);
var _this = possibleConstructorReturn(this, (SingleSelectionState.__proto__ || Object.getPrototypeOf(SingleSelectionState)).call(this, model, service));
_this.item = null;
return _this;
}
createClass(SingleSelectionState, [{
key: 'entries',
value: function entries() {
return this.item ? [this.item] : [];
}
}, {
key: 'selectCore',
value: function selectCore(item, state) {
if (state) {
this.item = item;
} else {
this.item = null;
}
}
}, {
key: 'stateCore',
value: function stateCore(item, key) {
return this.item !== null && key(item) === key(this.item);
}
}, {
key: 'clearCore',
value: function clearCore() {
this.item = null;
}
}]);
return SingleSelectionState;
}(SelectionState);
var MultipleSelectionState = function (_SelectionState) {
inherits(MultipleSelectionState, _SelectionState);
function MultipleSelectionState(model, service) {
classCallCheck(this, MultipleSelectionState);
var _this = possibleConstructorReturn(this, (MultipleSelectionState.__proto__ || Object.getPrototypeOf(MultipleSelectionState)).call(this, model, service));
_this.items = new Map();
return _this;
}
createClass(MultipleSelectionState, [{
key: 'entries',
value: function entries() {
return Array.from(this.items.values());
}
}, {
key: 'selectCore',
value: function selectCore(item, state, key) {
if (state) {
this.items.set(key(item), item);
} else {
this.items.delete(key(item));
}
}
}, {
key: 'stateCore',
value: function stateCore(item, key) {
return this.items.has(key(item));
}
}, {
key: 'clearCore',
value: function clearCore() {
this.items = new Map();
}
}]);
return MultipleSelectionState;
}(SelectionState);
var RangeSelectionState = function (_MultipleSelectionSta) {
inherits(RangeSelectionState, _MultipleSelectionSta);
function RangeSelectionState(model, service) {
classCallCheck(this, RangeSelectionState);
return possibleConstructorReturn(this, (RangeSelectionState.__proto__ || Object.getPrototypeOf(RangeSelectionState)).call(this, model, service));
}
createClass(RangeSelectionState, [{
key: 'select',
value: function select(item) {
var state = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
if (isArray(item)) {
this.clear();
}
get(RangeSelectionState.prototype.__proto__ || Object.getPrototypeOf(RangeSelectionState.prototype), 'select', this).call(this, item, state);
}
}]);
return RangeSelectionState;
}(MultipleSelectionState);
function selectionStateFactory(model, service) {
var mode = model.selection().mode;
switch (mode) {
case 'single':
return new SingleSelectionState(model, service);
case 'multiple':
return new MultipleSelectionState(model, service);
case 'range':
return new RangeSelectionState(model, service);
default:
throw new AppError('selection.state.factory', 'Invalid selection mode "' + mode + '"');
}
}
var SelectionRange = function () {
function SelectionRange(model) {
classCallCheck(this, SelectionRange);
this.model = model;
}
createClass(SelectionRange, [{
key: 'build',
value: function build() {
var rangeMap = {
'row': this.buildRows.bind(this),
'column': this.buildColumns.bind(this),
'cell': this.buildCells.bind(this),
'mix': this.buildMix.bind(this)
};
var model = this.model;
return function () {
var selection = model.selection();
var buildRange = rangeMap[selection.unit];
if (!buildRange) {
throw new AppError('range.builder', 'Invalid unit ' + selection.unit);
}
return buildRange.apply(undefined, arguments);
};
}
}, {
key: 'buildRows',
value: function buildRows(startCell, endCell) {
var model = this.model;
var _model$view = model.view(),
rows = _model$view.rows;
if (!endCell) {
return [rows[startCell.rowIndex]];
}
var startIndex = Math.min(startCell.rowIndex, endCell.rowIndex);
var endIndex = Math.max(startCell.rowIndex, endCell.rowIndex);
return rows.slice(startIndex, endIndex + 1);
}
}, {
key: 'buildColumns',
value: function buildColumns(startCell, endCell) {
if (!endCell) {
return [startCell.column];
}
var columns = this.model.columnList().line;
var startIndex = Math.min(startCell.columnIndex, endCell.columnIndex);
var endIndex = Math.max(startCell.columnIndex, endCell.columnIndex);
return columns.slice(startIndex, endIndex + 1);
}
}, {
key: 'buildCells',
value: function buildCells(startCell, endCell) {
if (!endCell) {
return [{
column: startCell.column,
row: startCell.row
}];
}
var model = this.model;
var _model$view2 = model.view(),
rows = _model$view2.rows,
columns = _model$view2.columns;
var startRowIndex = Math.min(startCell.rowIndex, endCell.rowIndex);
var endRowIndex = Math.max(startCell.rowIndex, endCell.rowIndex);
var startColumnIndex = Math.min(startCell.columnIndex, endCell.columnIndex);
var endColumnIndex = Math.max(startCell.columnIndex, endCell.columnIndex);
var selectedRows = rows.slice(startRowIndex, endRowIndex + 1);
var selectedColumns = columns.slice(startColumnIndex, endColumnIndex + 1);
var items = [];
selectedRows.forEach(function (row) {
selectedColumns.filter(function (column) {
return column.class === 'data';
}).forEach(function (column) {
items.push({
column: column,
row: row
});
});
});
return items;
}
}, {
key: 'buildMix',
value: function buildMix(startCell, endCell) {
var mixUnit = startCell.column.type === 'row-indicator' ? 'row' : 'cell';
var range = mixUnit === 'row' ? this.buildRows(startCell, endCell) : this.buildCells(startCell, endCell);
return range.map(function (item) {
return {
item: item,
unit: mixUnit
};
});
}
}]);
return SelectionRange;
}();
var SelectionView = function () {
function SelectionView(model, table, shortcut) {
var _this = this;
classCallCheck(this, SelectionView);
this.model = model;
this.table = table;
this.selectionService = new SelectionService(model);
this.selectionState = selectionStateFactory(model, this.selectionService);
this.selectionRange = new SelectionRange(model);
var commands = this.commands;
shortcut.register(commands);
this.toggleRow = commands.get('toggleRow');
this.toggleColumn = commands.get('toggleColumn');
this.toggleCell = commands.get('toggleCell');
this.reset = commands.get('reset');
model.navigationChanged.watch(function (e) {
if (e.tag.source === 'selection.view') {
return;
}
if (e.hasChanges('cell')) {
if (_this.toggleCell.canExecute(e.state.cell)) {
_this.toggleCell.execute(e.state.cell);
}
}
});
var modeClass = GRID_PREFIX + '-select-' + model.selection().mode;
var unitClass = GRID_PREFIX + '-select-' + model.selection().unit;
var view = table.view;
view.addClass(modeClass);
view.addClass(unitClass);
model.selectionChanged.watch(function (e) {
if (e.hasChanges('mode')) {
var newModeClass = GRID_PREFIX + '-select-' + e.state.mode;
var oldModeClass = GRID_PREFIX + '-select-' + e.changes.mode.oldValue;
view.removeClass(oldModeClass);
view.addClass(newModeClass);
}
if (e.hasChanges('unit')) {
var newUnitClass = GRID_PREFIX + '-select-' + e.state.unit;
var oldUnitClass = GRID_PREFIX + '-select-' + e.changes.unit.oldValue;
view.removeClass(oldUnitClass);
view.addClass(newUnitClass);
}
if (e.hasChanges('unit') || e.hasChanges('mode')) {
if (!e.hasChanges('items')) {
_this.selectionState.clear();
model.selection({ items: [] }, {
source: 'selection.view'
});
_this.selectionState = selectionStateFactory(model, _this.selectionService);
}
}
if (e.hasChanges('items') && e.tag.source !== 'selection.view') {
// Don't use commit it came outside already
var oldEntries = _this.selectionService.lookup(e.changes.items.oldValue);
_this.select(oldEntries, false);
var newEntries = _this.selectionService.lookup(e.state.items);
_this.select(newEntries, true);
}
});
}
createClass(SelectionView, [{
key: 'selectRange',
value: function selectRange(startCell, endCell, source) {
var buildRange = this.selectionRange.build();
var range = buildRange(startCell, endCell);
var commit = this.select(range, true, source);
commit();
}
}, {
key: 'toggle',
value: function toggle(items) {
var _this2 = this;
var source = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'custom';
var toggle = this.model.selection().toggle;
var e = {
items: items,
source: source,
kind: 'toggle'
};
if (toggle.canExecute(e)) {
toggle.execute(e);
var selectionState = this.selectionState;
if (!arguments.length || isUndefined(items)) {
items = this.model.view().rows;
}
selectionState.toggle(items);
return function () {
var items = _this2.selectionService.map(selectionState.entries());
_this2.model.selection({ items: items }, {
source: 'selection.view'
});
};
} else {
return noop$1;
}
}
}, {
key: 'select',
value: function select(items, state) {
var _this3 = this;
var source = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'custom';
var toggle = this.model.selection().toggle;
var e = {
items: items,
state: state,
source: source,
kind: 'select'
};
if (toggle.canExecute(e)) {
toggle.execute(e);
var selectionState = this.selectionState;
selectionState.select(items, state);
return function () {
var items = _this3.selectionService.map(selectionState.entries());
_this3.model.selection({ items: items }, {
source: 'selection.view'
});
};
} else {
return noop$1;
}
}
}, {
key: 'state',
value: function state(item) {
if (!arguments.length) {
return !!this.selectionState.stateAll(this.rows);
}
return this.selectionState.state(item) === true;
}
}, {
key: 'isIndeterminate',
value: function isIndeterminate(item) {
if (!arguments.length) {
return this.selectionState.stateAll(this.rows) === null;
}
return this.selectionState.state(item) === null;
}
}, {
key: 'navigateTo',
value: function navigateTo(rowIndex, columnIndex) {
var _table$body$cell$mode = this.table.body.cell(rowIndex, columnIndex).model(),
row = _table$body$cell$mode.row,
column = _table$body$cell$mode.column;
this.model.navigation({
cell: {
rowIndex: rowIndex,
columnIndex: columnIndex,
row: row,
column: column
}
}, { source: 'selection.view' });
}
}, {
key: 'commands',
get: function get$$1() {
var _this4 = this;
var model = this.model;
var shortcut = model.selection().shortcut;
var toggleActiveRow = new Command({
source: 'selection.view',
canExecute: function canExecute() {
return model.selection().unit === 'row' && _this4.rows.length > 0;
},
execute: function execute() {
var _model$navigation = model.navigation(),
rowIndex = _model$navigation.rowIndex;
var row = _this4.rows[rowIndex >= 0 ? rowIndex : rowIndex + 1];
var commit = _this4.toggle(row);
commit();
},
shortcut: shortcut.toggleRow
});
var commands = {
toggleCell: new Command({
source: 'selection.view',
canExecute: function canExecute(item) {
var selectionState = model.selection();
return item && selectionState.mode !== 'range' && (selectionState.unit === 'cell' || selectionState.unit === 'mix');
},
execute: function execute(item, source) {
var selectionState = model.selection();
switch (selectionState.unit) {
case 'cell':
{
var commit = _this4.toggle(item, source);
commit();
break;
}
case 'mix':
{
if (item.column.type === 'row-indicator') {
var _commit = _this4.toggle({ item: item.row, unit: 'row' }, source);
_commit();
break;
} else {
var _commit2 = _this4.toggle({ item: item, unit: 'cell' }, source);
_commit2();
break;
}
}
}
}
}),
toggleRow: new Command({
source: 'selection.view',
execute: function execute(item, source) {
var commit = _this4.toggle(item, source);
commit();
},
canExecute: function canExecute() {
if (!arguments.length) {
return _this4.mode === 'multiple';
}
return true;
}
}),
toggleColumn: new Command({
source: 'selection.view',
execute: function execute(item, source) {
var commit = _this4.toggle(item, source);
commit();
}
}),
commitRow: new Command({
source: 'selection.view',
canExecute: function canExecute() {
var _model$navigation2 = model.navigation(),
column = _model$navigation2.column;
return column && column.type === 'select';
},
execute: function execute() {
if (toggleActiveRow.canExecute()) {
toggleActiveRow.execute();
}
},
shortcut: model.edit().commitShortcuts['select'] || ''
}),
toggleActiveRow: toggleActiveRow,
togglePrevRow: new Command({
source: 'selection.view',
canExecute: function canExecute() {
return model.selection().unit === 'row' && model.navigation().rowIndex > 0;
},
execute: function execute() {
var _model$navigation3 = model.navigation(),
rowIndex = _model$navigation3.rowIndex,
columnIndex = _model$navigation3.columnIndex;
var row = _this4.rows[rowIndex];
var commit = _this4.toggle(row);
commit();
_this4.navigateTo(rowIndex - 1, columnIndex);
},
shortcut: shortcut.togglePreviousRow
}),
toggleNextRow: new Command({
source: 'selection.view',
canExecute: function canExecute() {
return model.selection().unit === 'row' && model.navigation().rowIndex < _this4.rows.length - 1;
},
execute: function execute() {
var _model$navigation4 = model.navigation(),
rowIndex = _model$navigation4.rowIndex,
columnIndex = _model$navigation4.columnIndex;
var row = _this4.rows[rowIndex];
var commit = _this4.toggle(row);
commit();
_this4.navigateTo(rowIndex + 1, columnIndex);
},
shortcut: shortcut.toggleNextRow
}),
toggleActiveColumn: new Command({
source: 'selection.view',
canExecute: function canExecute() {
return model.selection().unit === 'column' && model.navigation().columnIndex >= 0;
},
execute: function execute() {
var _model$navigation5 = model.navigation(),
columnIndex = _model$navigation5.columnIndex;
var column = _this4.columns[columnIndex];
var commit = _this4.toggle(column);
commit();
},
shortcut: shortcut.toggleColumn
}),
toggleNextColumn: new Command({
source: 'selection.view',
canExecute: function canExecute() {
return model.selection().unit === 'column' && model.navigation().columnIndex < _this4.columns.length - 1;
},
execute: function execute() {
var _model$navigation6 = model.navigation(),
rowIndex = _model$navigation6.rowIndex,
columnIndex = _model$navigation6.columnIndex;
var column = _this4.columns[columnIndex];
var commit = _this4.toggle(column);
commit();
_this4.navigateTo(rowIndex, columnIndex + 1);
},
shortcut: shortcut.toggleNextColumn
}),
togglePrevColumn: new Command({
source: 'selection.view',
canExecute: function canExecute() {
return model.selection().unit === 'column' && model.navigation().columnIndex > 0;
},
execute: function execute() {
var _model$navigation7 = model.navigation(),
rowIndex = _model$navigation7.rowIndex,
columnIndex = _model$navigation7.columnIndex;
var column = _this4.columns[columnIndex];
var commit = _this4.toggle(column);
commit();
_this4.navigateTo(rowIndex, columnIndex - 1);
},
shortcut: shortcut.togglePreviousColumn
}),
selectAll: new Command({
source: 'selection.view',
canExecute: function canExecute() {
return model.selection().mode === 'multiple';
},
execute: function execute() {
var entries = [];
switch (model.selection().unit) {
case 'row':
{
entries = model.data().rows;
break;
}
case 'column':
{
entries = model.columnList().line;
break;
}
case 'cell':
case 'mix':
{
var buildRange = _this4.selectionRange.build();
var body = _this4.table.body;
var startCell = body.cell(0, 0);
var endCell = body.cell(body.rowCount() - 1, body.columnCount() - 1);
entries = buildRange(startCell, endCell);
break;
}
default:
throw new AppError('selection.view', 'Invalid unit ' + model.selection().unit);
}
var commit = _this4.select(entries, true);
commit();
},
shortcut: shortcut.selectAll
})
};
return new Map(Object.entries(commands));
}
}, {
key: 'selection',
get: function get$$1() {
return this.model.selection();
}
}, {
key: 'mode',
get: function get$$1() {
return this.selection.mode;
}
}, {
key: 'items',
get: function get$$1() {
return this.selection.items;
}
}, {
key: 'rows',
get: function get$$1() {
return this.table.data.rows();
}
}, {
key: 'columns',
get: function get$$1() {
return this.table.data.columns();
}
}]);
return SelectionView;
}();
var SortView = function () {
function SortView(model) {
var _this = this;
classCallCheck(this, SortView);
this.model = model;
this.hover = false;
this.toggle = new Command({
source: 'sort.view',
canExecute: function canExecute(column) {
var key$$1 = column.key;
var map$$1 = map$1(model.columnList().line);
return map$$1.hasOwnProperty(key$$1) && map$$1[key$$1].canSort !== false;
},
execute: function execute(column) {
var key$$1 = column.key;
var sort = model.sort;
var sortState = sort();
var by = Array.from(sortState.by);
var index$$1 = index(by, key$$1);
if (index$$1 >= 0) {
var dir = direction(by[index$$1]);
switch (dir) {
case 'desc':
{
by.splice(index$$1, 1);
_this.hover = false;
break;
}
case 'asc':
{
var entry = defineProperty({}, key$$1, 'desc');
by[index$$1] = entry;
_this.hover = false;
break;
}
default:
throw AppError('head.core', 'Invalid sort direction ' + dir);
}
} else {
if (sortState.mode === 'single') {
by.length = 0;
}
var _entry2 = defineProperty({}, key$$1, 'asc');
by.push(_entry2);
var order = orderFactory(model);
order(by);
}
sort({ by: by }, { source: 'sort.view' });
}
});
this.onInit();
}
createClass(SortView, [{
key: 'onInit',
value: function onInit() {
var _this2 = this;
var model = this.model;
var sort = model.sort;
model.columnListChanged.watch(function (e) {
if (e.hasChanges('index')) {
var sortState = sort();
var order = orderFactory(model);
var sortBy = order(Array.from(sortState.by));
if (!_this2.equals(sortBy, sortState.by)) {
sort({ by: sortBy }, { source: 'sort.view' });
}
}
});
model.dataChanged.watch(function (e) {
if (e.hasChanges('columns')) {
var _sort = sort(),
by = _sort.by;
var columnMap = map$1(e.state.columns);
var newBy = by.filter(function (entry) {
return columnMap.hasOwnProperty(key(entry));
});
if (!_this2.equals(newBy, by)) {
sort({ by: newBy }, { source: 'sort.view' });
}
}
});
}
}, {
key: 'equals',
value: function equals(x, y) {
return JSON.stringify(x) === JSON.stringify(y);
}
}, {
key: 'direction',
value: function direction$$1(column) {
var key$$1 = column.key;
var _model$sort = this.model.sort(),
by = _model$sort.by;
return map(by)[key$$1];
}
}, {
key: 'order',
value: function order(column) {
var key$$1 = column.key;
var _model$sort2 = this.model.sort(),
by = _model$sort2.by;
return index(by, key$$1);
}
}]);
return SortView;
}();
var Entry = function () {
function Entry(element, sheets, markDirty) {
classCallCheck(this, Entry);
this.element = element;
this.list = new Set();
this.sheets = sheets;
this.markDirty = markDirty;
}
createClass(Entry, [{
key: 'class',
value: function _class(key, style) {
key = escape(key);
this.list.add(key);
this.markDirty(this);
if (style) {
var sheets = this.sheets;
if (!sheets.has(key)) {
sheets.set(key, style);
}
}
}
}]);
return Entry;
}();
var Monitor = function () {
function Monitor(model) {
classCallCheck(this, Monitor);
this.model = model;
this.entries = new Set();
this.newSheets = new Map();
this.oldSheets = new Map();
}
createClass(Monitor, [{
key: 'enter',
value: function enter() {
var newSheets = this.newSheets;
var entries = this.entries;
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = entries[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var entry = _step.value;
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = entry.list[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var cls = _step2.value;
entry.element.removeClass(cls, true);
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
entries = this.entries = new Set();
var markDirty = function markDirty(entry) {
return entries.add(entry);
};
return function (element) {
var entry = new Entry(element, newSheets, markDirty);
return entry.class.bind(entry);
};
}
}, {
key: 'exit',
value: function exit() {
var entries = this.entries;
var _iteratorNormalCompletion3 = true;
var _didIteratorError3 = false;
var _iteratorError3 = undefined;
try {
for (var _iterator3 = entries[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
var entry = _step3.value;
var _iteratorNormalCompletion6 = true;
var _didIteratorError6 = false;
var _iteratorError6 = undefined;
try {
for (var _iterator6 = entry.list[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) {
var cls = _step6.value;
entry.element.addClass(cls, true);
}
} catch (err) {
_didIteratorError6 = true;
_iteratorError6 = err;
} finally {
try {
if (!_iteratorNormalCompletion6 && _iterator6.return) {
_iterator6.return();
}
} finally {
if (_didIteratorError6) {
throw _iteratorError6;
}
}
}
}
} catch (err) {
_didIteratorError3 = true;
_iteratorError3 = err;
} finally {
try {
if (!_iteratorNormalCompletion3 && _iterator3.return) {
_iterator3.return();
}
} finally {
if (_didIteratorError3) {
throw _iteratorError3;
}
}
}
var newSheets = this.newSheets;
var oldSheets = this.oldSheets;
var id = this.model.grid().id;
var _iteratorNormalCompletion4 = true;
var _didIteratorError4 = false;
var _iteratorError4 = undefined;
try {
for (var _iterator4 = oldSheets.keys()[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
var _cls = _step4.value;
if (!newSheets.has(_cls)) {
var sheet$$1 = sheet(id, _cls);
sheet$$1.remove();
}
}
} catch (err) {
_didIteratorError4 = true;
_iteratorError4 = err;
} finally {
try {
if (!_iteratorNormalCompletion4 && _iterator4.return) {
_iterator4.return();
}
} finally {
if (_didIteratorError4) {
throw _iteratorError4;
}
}
}
var _iteratorNormalCompletion5 = true;
var _didIteratorError5 = false;
var _iteratorError5 = undefined;
try {
for (var _iterator5 = newSheets.entries()[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
var _step5$value = slicedToArray(_step5.value, 2),
_cls2 = _step5$value[0],
style = _step5$value[1];
if (!oldSheets.has(_cls2)) {
var _sheet = sheet(id, _cls2);
_sheet.set(defineProperty({}, '.' + _cls2, style));
}
}
} catch (err) {
_didIteratorError5 = true;
_iteratorError5 = err;
} finally {
try {
if (!_iteratorNormalCompletion5 && _iterator5.return) {
_iterator5.return();
}
} finally {
if (_didIteratorError5) {
throw _iteratorError5;
}
}
}
this.oldSheets = newSheets;
this.newSheets = new Map();
}
}]);
return Monitor;
}();
var VirtualRowStyle = function () {
function VirtualRowStyle(table, style) {
classCallCheck(this, VirtualRowStyle);
this.table = table;
this.style = style;
}
createClass(VirtualRowStyle, [{
key: "visitFactory",
value: function visitFactory() {
var style = this.style;
var rowBox = this.table.body.rowBox;
var entries = rowBox.entries;
return function (row, context) {
var model = {
dataIndex: context.row
};
var key = rowBox.key(model);
var classList = entries.get(key);
if (classList) {
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = classList[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var cls = _step.value;
context.class(cls);
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
}
style(row, context);
};
}
}]);
return VirtualRowStyle;
}();
var VirtualCellStyle = function () {
function VirtualCellStyle(table, style) {
classCallCheck(this, VirtualCellStyle);
this.table = table;
this.style = style;
}
createClass(VirtualCellStyle, [{
key: "visitFactory",
value: function visitFactory() {
var style = this.style;
var cellBox = this.table.body.cellBox;
var columnBox = this.table.body.columnBox;
var cellEntries = cellBox.entries;
var columnEntries = columnBox.entries;
return function (row, column, context) {
// column level
var columnModel = {
dataIndex: context.column
};
var columnKey = columnBox.key(columnModel);
var columnClassList = columnEntries.get(columnKey);
if (columnClassList) {
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = columnClassList[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var cls = _step2.value;
context.class(cls);
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
}
// cell level
var cellModel = {
dataRowIndex: context.row,
dataColumnIndex: context.column
};
var cellKey = cellBox.key(cellModel);
var cellClassList = cellEntries.get(cellKey);
if (cellClassList) {
var _iteratorNormalCompletion3 = true;
var _didIteratorError3 = false;
var _iteratorError3 = undefined;
try {
for (var _iterator3 = cellClassList[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
var _cls = _step3.value;
context.class(_cls);
}
} catch (err) {
_didIteratorError3 = true;
_iteratorError3 = err;
} finally {
try {
if (!_iteratorNormalCompletion3 && _iterator3.return) {
_iterator3.return();
}
} finally {
if (_didIteratorError3) {
throw _iteratorError3;
}
}
}
}
// add classes
style(row, column, context);
};
}
}]);
return VirtualCellStyle;
}();
var Composite = function () {
function Composite() {
classCallCheck(this, Composite);
}
createClass(Composite, null, [{
key: 'func',
value: function func(list) {
var reduce = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop$1;
var memo = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
return function () {
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = list[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var f = _step.value;
memo = reduce(memo, f.apply(undefined, arguments));
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
return memo;
};
}
}, {
key: 'command',
value: function command(list) {
return new Command({
source: 'composite',
canExecute: function canExecute() {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return list.reduce(function (memo, cmd) {
return memo || cmd.canExecute.apply(cmd, args);
}, false);
},
execute: function execute() {
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
return list.filter(function (cmd) {
return cmd.canExecute.apply(cmd, args);
}).reduce(function (memo, cmd) {
return cmd.execute.apply(cmd, args) || memo;
}, undefined);
}
});
}
}, {
key: 'list',
value: function list(_list) {
return _list.reduce(function (memo, xs) {
return memo.concat(xs);
}, []);
}
}, {
key: 'object',
value: function object(list) {
var memo = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
return Object.assign.apply(Object, [memo].concat(toConsumableArray(list)));
}
}]);
return Composite;
}();
var StyleService = function () {
function StyleService(model) {
classCallCheck(this, StyleService);
this.style = model.style;
}
createClass(StyleService, [{
key: 'row',
value: function row() {
var _style = this.style(),
rows = _style.rows,
row = _style.row;
var visitors = row === noop$1 ? rows : rows.concat([row]);
return Composite.func(visitors);
}
}, {
key: 'cell',
value: function cell() {
var _style2 = this.style(),
cells = _style2.cells,
cell = _style2.cell;
if (isFunction(cell)) {
var visitors = cell === noop$1 ? cells : cells.concat([cell]);
return Composite.func(visitors);
}
var keys = Object.keys(cell);
if (keys.length) {
var _visitors = cells.concat(keys.map(function (key) {
var visit = cell[key];
return function (row, column, context) {
if (column.key === key) {
visit(row, column, context);
}
};
}));
return Composite.func(_visitors);
}
return Composite.func(cells);
}
}]);
return StyleService;
}();
var StyleView = function () {
function StyleView(model, table) {
var _this = this;
classCallCheck(this, StyleView);
this.model = model;
this.table = table;
this.valueFactory = getFactory;
this.service = new StyleService(model);
this.active = {
row: false,
cell: false
};
this.monitor = {
row: new Monitor(model),
cell: new Monitor(model)
};
model.styleChanged.watch(function (e) {
if (e.hasChanges('row') || e.hasChanges('rows')) {
_this.active.row = e.state.row !== noop$1 || e.state.rows.length > 0;
}
if (e.hasChanges('cell') || e.hasChanges('cells')) {
_this.active.cell = e.state.cell !== noop$1 || e.state.cells.length > 0;
}
_this.invalidate();
});
}
createClass(StyleView, [{
key: 'needInvalidate',
value: function needInvalidate() {
var model = this.model;
if (model.scene().status !== 'stop') {
return false;
}
var active = this.active;
var isVirtual = model.scroll().mode === 'virtual';
var isActive = isVirtual || active.row || active.cell;
if (!isActive) {
return false;
}
var context = { model: model };
var _model$style = model.style(),
invalidate = _model$style.invalidate;
return invalidate.canExecute(context) && invalidate.execute(context) !== false;
}
}, {
key: 'invalidate',
value: function invalidate(domCell, domRow) {
var active = this.active;
var model = this.model;
var isVirtual = model.scroll().mode === 'virtual';
var table = this.table;
var valueFactory = this.valueFactory;
// TODO: improve performance
var valueCache = new Map();
var value = function value(row, column) {
var getValue = valueCache.get(column);
if (!getValue) {
getValue = valueFactory(column);
valueCache.set(column, getValue);
}
return getValue(row);
};
var columnList = table.data.columns();
var columnMap = map$1(columnList);
var isRowActive = active.row;
var isCellActive = active.cell;
var visitRow = this.service.row();
var visitCell = this.service.cell();
if (isVirtual) {
isRowActive = true;
isCellActive = true;
visitRow = new VirtualRowStyle(table, visitRow).visitFactory();
visitCell = new VirtualCellStyle(table, visitCell).visitFactory();
}
// For performance reason we make rowContext and cellContext the same reference
// for the all style calls.
var rowContext = {
class: noop$1,
row: -1,
value: null,
columns: {
map: columnMap,
list: columnList
}
};
var cellContext = {
class: noop$1,
row: -1,
column: -1,
value: null,
columns: rowContext.columns
};
// To improve performance take rows and cells directly from the bag and not from the DOM table.
var body = table.body;
var _table$context$mapper = table.context.mapper,
rowToView = _table$context$mapper.rowToView,
columnToView = _table$context$mapper.columnToView;
var bag = table.context.bag.body;
if (isRowActive) {
var rows = table.context.bag.body.getRowElements();
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = rows[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var tr = _step.value;
var index = tr.index,
element = tr.element,
_model = tr.model;
// This private method we use only for performance, don't use it in other places.
var row = body.createRowCore(rowToView(index), element);
rowContext.class = domRow(row);
rowContext.row = index;
rowContext.value = value;
visitRow(_model, rowContext);
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
}
if (isCellActive) {
var cells = table.context.bag.body.getCellElements();
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = cells[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var td = _step2.value;
var rowIndex = td.rowIndex,
columnIndex = td.columnIndex,
element = td.element,
_row = td.row,
column = td.column;
// This private method we use only for performance, don't use it in other places.
var cell = body.createCellCore(rowToView(rowIndex), columnToView(columnIndex), element);
cellContext.class = domCell(cell);
cellContext.row = rowIndex;
cellContext.column = columnIndex;
cellContext.value = value;
visitCell(_row, column, cellContext);
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
}
}
}]);
return StyleView;
}();
function viewFactory(model, table, commandManager, gridService, vscroll, selectors) {
var proxy = new ModelProxy(model);
var basket = new Disposable();
var _model$action = model.action(),
shortcut = _model$action.shortcut;
var navigationShortcut = {
register: function register(commands) {
basket.using(shortcut.register(commandManager, commands));
},
keyCode: function keyCode() {
return shortcut.keyCode;
}
};
var selectionCommandManager = new SelectionCommandManager(model, commandManager);
var selectionShortcut = {
register: function register(commands) {
basket.using(shortcut.register(selectionCommandManager, commands));
}
};
return function (host) {
var modelProxy = proxy.subject;
host.head = new HeadView(modelProxy, table, selectors.th);
host.body = new BodyView(modelProxy, table);
host.foot = new FootView(modelProxy, table);
host.row = new RowView(modelProxy, table, selectors.tr);
host.layout = new LayoutView(modelProxy, table, gridService);
host.scroll = new ScrollView(modelProxy, table, vscroll, gridService);
host.highlight = new HighlightView(modelProxy, table);
host.sort = new SortView(modelProxy);
host.pagination = new PaginationView(modelProxy);
host.nav = new NavigationView(modelProxy, table, navigationShortcut);
host.group = new GroupView(modelProxy, table, gridService, navigationShortcut);
host.edit = new EditView(modelProxy, table, navigationShortcut);
host.filter = new FilterView(modelProxy);
host.rowDetails = new RowDetailsView(modelProxy, table, navigationShortcut);
host.selection = new SelectionView(modelProxy, table, selectionShortcut);
host.style = new StyleView(modelProxy, table);
return function () {
host.layout.dispose();
proxy.dispose();
basket.dispose();
};
};
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var /** @type {?} */rAF = window.requestAnimationFrame || window.webkitRequestAnimationFrame;
var VscrollContainer = function () {
/**
* @param {?} settings
*/
function VscrollContainer(settings) {
classCallCheck(this, VscrollContainer);
this.settings = settings;
this.count = 0;
this.total = 0;
this.position = 0;
this.cursor = 0;
this.page = 0;
this.items = [];
this.force = true;
this.resetEvent = new EventEmitter();
this.updateEvent = new EventEmitter();
this.drawEvent = new EventEmitter();
this.deferred = null;
}
/**
* @param {?} f
* @return {?}
*/
createClass(VscrollContainer, [{
key: 'tick',
value: function tick(f) {
rAF(f);
}
/**
* @param {?} f
* @return {?}
*/
}, {
key: 'read',
value: function read(f) {
f();
}
/**
* @param {?} f
* @return {?}
*/
}, {
key: 'write',
value: function write(f) {
f();
}
/**
* @param {?} f
* @param {?} emit
* @return {?}
*/
}, {
key: 'apply',
value: function apply(f, emit) {
emit(f);
}
/**
* @return {?}
*/
}, {
key: 'place',
value: function place() {
var /** @type {?} */threshold = this.settings.threshold;
var /** @type {?} */cursor = this.cursor;
return Math.ceil((cursor + threshold) / threshold) - 1;
}
/**
* @param {?} count
* @param {?=} force
* @return {?}
*/
}, {
key: 'update',
value: function update(count, force) {
var _this = this;
var /** @type {?} */settings = this.settings;
var /** @type {?} */threshold = settings.threshold;
var /** @type {?} */largestPage = this.page;
var /** @type {?} */currentPage = this.place();
if (this.count !== count) {
this.count = count;
this.total = Math.max(this.total, count);
this.updateEvent.emit({
force: isUndefined(force) ? isNumber(settings.rowHeight) && settings.rowHeight > 0 || isNumber(settings.columnWidth) && settings.columnWidth > 0 : force
});
}
if (force || currentPage > largestPage) {
this.page = currentPage;
new Promise(function (resolve, reject) {
var /** @type {?} */deferred = _this.deferred = { resolve: resolve, reject: reject };
if (currentPage === 0) {
settings.fetch(0, threshold, deferred);
} else {
var /** @type {?} */skip = (largestPage + 1) * threshold;
if (_this.total < skip) {
deferred.resolve(_this.total);
} else {
var /** @type {?} */take = (currentPage - largestPage) * threshold;
settings.fetch(skip, take, deferred);
}
}
}).then(function (nextCount) {
_this.force = true;
_this.update(nextCount);
}).catch(function () {
return _this.deferred = null;
});
}
}
/**
* @return {?}
*/
}, {
key: 'reset',
value: function reset() {
if (this.deferred) {
this.deferred = null;
}
this.count = 0;
this.total = 0;
this.position = 0;
this.cursor = 0;
this.page = 0;
this.items = [];
this.force = true;
var /** @type {?} */e = { handled: false, source: 'container' };
this.resetEvent.emit(e);
this.update(this.count, true);
}
}]);
return VscrollContainer;
}();
function VscrollContainer_tsickle_Closure_declarations() {
/** @type {?} */
VscrollContainer.prototype.count;
/** @type {?} */
VscrollContainer.prototype.total;
/** @type {?} */
VscrollContainer.prototype.position;
/** @type {?} */
VscrollContainer.prototype.cursor;
/** @type {?} */
VscrollContainer.prototype.page;
/** @type {?} */
VscrollContainer.prototype.items;
/** @type {?} */
VscrollContainer.prototype.force;
/** @type {?} */
VscrollContainer.prototype.resetEvent;
/** @type {?} */
VscrollContainer.prototype.updateEvent;
/** @type {?} */
VscrollContainer.prototype.drawEvent;
/** @type {?} */
VscrollContainer.prototype.deferred;
/** @type {?} */
VscrollContainer.prototype.settings;
}
/**
* @param {?} size
* @param {?} container
* @param {?} element
* @param {?} index
* @return {?}
*/
function sizeFactory(size, container, element, index) {
if (isFunction(size)) {
return function () {
return (/** @type {?} */size(element, container.position + index)
);
};
}
if (isNumber(size)) {
return function () {
return (/** @type {?} */size
);
};
}
throw new AppError('vscroll.utility', 'Invalid size ' + size);
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @record
*/
function IVscrollSettings() {}
function IVscrollSettings_tsickle_Closure_declarations() {
/** @type {?|undefined} */
IVscrollSettings.prototype.threshold;
/** @type {?|undefined} */
IVscrollSettings.prototype.placeholderHeight;
/** @type {?|undefined} */
IVscrollSettings.prototype.placeholderWidth;
/** @type {?|undefined} */
IVscrollSettings.prototype.resetTriggers;
/** @type {?|undefined} */
IVscrollSettings.prototype.rowHeight;
/** @type {?|undefined} */
IVscrollSettings.prototype.columnWidth;
/** @type {?|undefined} */
IVscrollSettings.prototype.fetch;
}
var VscrollSettings = function () {
/**
* @param {?} getCount
*/
function VscrollSettings(getCount) {
classCallCheck(this, VscrollSettings);
this.getCount = getCount;
this.threshold = 64;
this.placeholderHeight = 0;
this.placeholderWidth = 0;
this.resetTriggers = ['resize'];
}
/**
* @param {?} skip
* @param {?} take
* @param {?} d
* @return {?}
*/
createClass(VscrollSettings, [{
key: 'fetch',
value: function fetch(skip, take, d) {
d.resolve(this.getCount());
}
/**
* @param {?} element
* @return {?}
*/
}, {
key: 'rowHeight',
value: function rowHeight(element) {
var /** @type {?} */height = element.offsetHeight;
var /** @type {?} */style = getComputedStyle(element);
height += Number.parseInt(style.marginTop) + Number.parseInt(style.marginBottom);
return height;
}
/**
* @param {?} element
* @return {?}
*/
}, {
key: 'columnWidth',
value: function columnWidth(element) {
var /** @type {?} */width = element.offsetWidth;
var /** @type {?} */style = getComputedStyle(element);
width += Number.parseInt(style.marginLeft) + Number.parseInt(style.marginRight);
return width;
}
}]);
return VscrollSettings;
}();
function VscrollSettings_tsickle_Closure_declarations() {
/** @type {?} */
VscrollSettings.prototype.threshold;
/** @type {?} */
VscrollSettings.prototype.placeholderHeight;
/** @type {?} */
VscrollSettings.prototype.placeholderWidth;
/** @type {?} */
VscrollSettings.prototype.resetTriggers;
/** @type {?} */
VscrollSettings.prototype.getCount;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var VscrollContext =
/**
* @param {?=} settings
*/
function VscrollContext(settings) {
var _this = this;
classCallCheck(this, VscrollContext);
this.settings = new VscrollSettings(function () {
return _this.container.total;
});
if (settings) {
Object.assign(this.settings, settings);
}
this.container = new VscrollContainer(this.settings);
};
function VscrollContext_tsickle_Closure_declarations() {
/** @type {?} */
VscrollContext.prototype.settings;
/** @type {?} */
VscrollContext.prototype.container;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var VScrollService = function () {
function VScrollService() {
classCallCheck(this, VScrollService);
}
/**
* @param {?} settings
* @return {?}
*/
createClass(VScrollService, [{
key: 'factory',
value: function factory(settings) {
return new VscrollContext(settings);
}
}]);
return VScrollService;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var ViewCoreService = function () {
/**
* @param {?} gridServiceFactory
* @param {?} vscroll
*/
function ViewCoreService(gridServiceFactory, vscroll) {
classCallCheck(this, ViewCoreService);
this.gridServiceFactory = gridServiceFactory;
this.vscroll = vscroll;
this.dispose = null;
this.body = null;
this.edit = null;
this.filter = null;
this.foot = null;
this.group = null;
this.head = null;
this.highlight = null;
this.layout = null;
this.nav = null;
this.pagination = null;
this.rowDetails = null;
this.scroll = null;
this.selection = null;
this.sort = null;
this.style = null;
this.row = null;
}
/**
* @param {?} model
* @param {?} table
* @param {?} commandManager
* @return {?}
*/
createClass(ViewCoreService, [{
key: 'init',
value: function init(model, table, commandManager) {
var /** @type {?} */gridService = this.gridServiceFactory.service(model);
var /** @type {?} */selectors = {
th: 'q-grid-core-th',
tr: 'q-grid-core-tr'
};
var /** @type {?} */injectViewServicesTo = viewFactory(model, table, commandManager, gridService, this.vscroll, selectors);
this.dispose = injectViewServicesTo(this);
}
/**
* @return {?}
*/
}, {
key: 'ngOnDestroy',
value: function ngOnDestroy() {
if (this.dispose) {
this.dispose();
this.dispose = null;
}
}
}]);
return ViewCoreService;
}();
ViewCoreService.decorators = [{ type: Injectable }];
/** @nocollapse */
ViewCoreService.ctorParameters = function () {
return [{ type: GridService$1 }, { type: VScrollService }];
};
function ViewCoreService_tsickle_Closure_declarations() {
/** @type {?} */
ViewCoreService.prototype.dispose;
/** @type {?} */
ViewCoreService.prototype.body;
/** @type {?} */
ViewCoreService.prototype.edit;
/** @type {?} */
ViewCoreService.prototype.filter;
/** @type {?} */
ViewCoreService.prototype.foot;
/** @type {?} */
ViewCoreService.prototype.group;
/** @type {?} */
ViewCoreService.prototype.head;
/** @type {?} */
ViewCoreService.prototype.highlight;
/** @type {?} */
ViewCoreService.prototype.layout;
/** @type {?} */
ViewCoreService.prototype.nav;
/** @type {?} */
ViewCoreService.prototype.pagination;
/** @type {?} */
ViewCoreService.prototype.rowDetails;
/** @type {?} */
ViewCoreService.prototype.scroll;
/** @type {?} */
ViewCoreService.prototype.selection;
/** @type {?} */
ViewCoreService.prototype.sort;
/** @type {?} */
ViewCoreService.prototype.style;
/** @type {?} */
ViewCoreService.prototype.row;
/** @type {?} */
ViewCoreService.prototype.gridServiceFactory;
/** @type {?} */
ViewCoreService.prototype.vscroll;
}
var EventListener = function () {
function EventListener(element, manager) {
classCallCheck(this, EventListener);
this.element = element;
this.manager = manager;
this.handlers = {};
}
createClass(EventListener, [{
key: "on",
value: function on(name, f) {
var _this = this;
var settings = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
var manager = this.manager;
var handler = manager.bind(f);
var handlerSet = this.handlers[name] || (this.handlers[name] = []);
handlerSet.push(handler);
this.element.addEventListener(name, handler, settings);
return function () {
_this.element.removeEventListener(name, handler);
var index = handlerSet.indexOf(handler);
if (index >= 0) {
handlerSet.splice(index, 1);
}
};
}
}, {
key: "off",
value: function off() {
var handlers = this.handlers;
var element = this.element;
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = Object.keys(handlers)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var key = _step.value;
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = Array.from(handlers[key])[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var handler = _step2.value;
element.removeEventListener(key, handler);
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
}
}]);
return EventListener;
}();
var EventManager = function () {
function EventManager(context) {
var apply = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (f) {
return f();
};
classCallCheck(this, EventManager);
this.context = context;
this.apply = apply;
}
createClass(EventManager, [{
key: "bind",
value: function bind(f) {
var handler = f.bind(this.context);
var apply = this.apply;
return function () {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return apply(function () {
return handler.apply(undefined, args);
});
};
}
}]);
return EventManager;
}();
var GridCtrl = function (_Disposable) {
inherits(GridCtrl, _Disposable);
function GridCtrl(model, context) {
classCallCheck(this, GridCtrl);
var _this = possibleConstructorReturn(this, (GridCtrl.__proto__ || Object.getPrototypeOf(GridCtrl)).call(this));
_this.model = model;
var grid = model.grid;
if (grid().status === 'bound') {
throw new AppError('grid.ctrl', 'Model is already used by grid "' + grid().id + '"');
}
_this.markup = { document: document };
_this.bag = {
head: new Bag(),
body: new Bag(),
foot: new Bag()
};
var element = context.element;
if (!element.id) {
element.id = model.grid().id;
}
grid({ status: 'bound' }, { source: 'grid.ctrl' });
var layerFactory = context.layerFactory(_this.markup);
var tableContext = {
layer: function layer(name) {
return layerFactory.create(name);
},
bag: _this.bag
};
_this.table = new Table(model, _this.markup, tableContext);
model.sceneChanged.watch(function (e) {
if (e.hasChanges('column')) {
_this.invalidateVisibility();
}
});
return _this;
}
createClass(GridCtrl, [{
key: 'keyDown',
value: function keyDown(e) {
var source = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'grid';
var model = this.model;
var _model$action = model.action(),
shortcut = _model$action.shortcut;
var result = shortcut.keyDown(e, source);
if (result.length > 0) {
e.preventDefault();
e.stopPropagation();
return result;
}
if (e.target.tagName === 'TBODY') {
var code = Shortcut.translate(e);
var _model$navigation = model.navigation(),
prevent = _model$navigation.prevent;
if (prevent.has(code)) {
e.preventDefault();
e.stopPropagation();
}
}
return result;
}
}, {
key: 'invalidateVisibility',
value: function invalidateVisibility() {
var _model$scene$column$a = this.model.scene().column.area,
left = _model$scene$column$a.left,
right = _model$scene$column$a.right;
var _model$row = this.model.row(),
pinTop = _model$row.pinTop,
pinBottom = _model$row.pinBottom;
this.model.visibility({
pin: {
left: left.length > 0,
right: right.length > 0,
top: pinTop.length > 0,
bottom: pinBottom.length > 0
}
}, {
source: 'grid.ctrl'
});
}
}, {
key: 'invalidateActive',
value: function invalidateActive() {
var _table = this.table,
view = _table.view,
model = _table.model;
if (view.isFocused()) {
model.focus({ isActive: true }, { source: 'grid.ctrl' });
} else {
model.focus({ isActive: false }, { source: 'grid.ctrl' });
}
}
}, {
key: 'dispose',
value: function dispose() {
get(GridCtrl.prototype.__proto__ || Object.getPrototypeOf(GridCtrl.prototype), 'dispose', this).call(this);
this.model.grid({ status: 'unbound' }, { source: 'grid.ctrl' });
}
}]);
return GridCtrl;
}(Disposable);
var TableCommandManager = function (_CommandManager) {
inherits(TableCommandManager, _CommandManager);
function TableCommandManager(apply, table) {
classCallCheck(this, TableCommandManager);
var _this = possibleConstructorReturn(this, (TableCommandManager.__proto__ || Object.getPrototypeOf(TableCommandManager)).call(this, apply));
_this.table = table;
return _this;
}
createClass(TableCommandManager, [{
key: 'filter',
value: function filter(commands, source) {
if (source === 'editor' || this.isViewActive()) {
return get(TableCommandManager.prototype.__proto__ || Object.getPrototypeOf(TableCommandManager.prototype), 'filter', this).call(this, commands, source);
}
return [];
}
}, {
key: 'isViewActive',
value: function isViewActive() {
return this.table.view.isFocused();
}
}]);
return TableCommandManager;
}(CommandManager);
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var GridComponent = function (_RootComponent) {
inherits(GridComponent, _RootComponent);
/**
* @param {?} root
* @param {?} element
* @param {?} zone
* @param {?} layerService
* @param {?} document
* @param {?} theme
*/
function GridComponent(root, element, zone, layerService, document, theme) {
classCallCheck(this, GridComponent);
var _this = possibleConstructorReturn(this, (GridComponent.__proto__ || Object.getPrototypeOf(GridComponent)).call(this));
_this.root = root;
_this.element = element;
_this.zone = zone;
_this.layerService = layerService;
_this.document = document;
_this.selectionChanged = new EventEmitter();
_this.models = ['action', 'data', 'edit', 'filter', 'grid', 'group', 'pivot', 'row', 'selection', 'scroll', 'sort', 'style'];
_this.modelChanged.watch(function (model) {
return _this.root.model = model;
});
if (!theme.component) {
throw new AppError('grid.component', 'Ensure that grid theme module was included');
}
_this.themeComponent = theme.component;
return _this;
}
/**
* @return {?}
*/
createClass(GridComponent, [{
key: 'ngOnInit',
value: function ngOnInit() {
var _this2 = this;
var /** @type {?} */model = this.root.model;
var /** @type {?} */element = this.element.nativeElement;
model.style({
classList: Array.from(element.classList)
});
var /** @type {?} */ctrl = this.using(new GridCtrl(model, {
layerFactory: function layerFactory() {
return _this2.layerService;
},
element: element
}));
this.root.table = ctrl.table;
this.root.bag = ctrl.bag;
this.root.markup = ctrl.markup;
this.root.commandManager = new TableCommandManager(function (f) {
return f();
}, ctrl.table);
var /** @type {?} */listener = new EventListener(element, new EventManager(this));
var /** @type {?} */docListener = new EventListener(this.document, new EventManager(this));
this.zone.runOutsideAngular(function () {
return _this2.using(docListener.on('focusin', function () {
return ctrl.invalidateActive();
}));
});
var _model$navigation = model.navigation(),
debounce$$1 = _model$navigation.debounce;
if (debounce$$1) {
var /** @type {?} */navJob = jobLine(debounce$$1);
this.zone.runOutsideAngular(function () {
listener.on('keydown', function (e) {
var /** @type {?} */result = ctrl.keyDown(e);
if (result.indexOf('navigation') >= 0) {
navJob(function () {
return _this2.zone.run(noop$1);
});
} else if (result.length) {
// app.tick is not working correctly, why?
_this2.zone.run(noop$1);
}
});
});
} else {
listener.on('keydown', function (e) {
var /** @type {?} */result = ctrl.keyDown(e);
if (result.length) {
_this2.zone.run(noop$1);
}
});
}
}
/**
* @return {?}
*/
}, {
key: 'visibility',
get: function get$$1() {
// TODO: get rid of that
return this.root.model.visibility();
}
}]);
return GridComponent;
}(RootComponent);
GridComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid',
providers: [RootService, TemplateCacheService, TemplateService, ViewCoreService, GridService$1, TemplateLinkService, LayerService],
styles: ["/* * * Responsive attributes * * References: * 1) https://scotch.io/tutorials/a-visual-guide-to-css3-flexbox-properties#flex * 2) https://css-tricks.com/almanac/properties/f/flex/ * 3) https://css-tricks.com/snippets/css/a-guide-to-flexbox/ * 4) https://github.com/philipwalton/flexbugs#3-min-height-on-a-flex-container-wont-apply-to-its-flex-items * 5) http://godban.com.ua/projects/flexgrid * * */ /* IE10-IE11 column-flex bug fix (set proper default value) */ /* Apply Mixins to create Layout/Flexbox styles */ .flex-order { order: 0; } .flex-order--20 { order: -20; } .flex-order--19 { order: -19; } .flex-order--18 { order: -18; } .flex-order--17 { order: -17; } .flex-order--16 { order: -16; } .flex-order--15 { order: -15; } .flex-order--14 { order: -14; } .flex-order--13 { order: -13; } .flex-order--12 { order: -12; } .flex-order--11 { order: -11; } .flex-order--10 { order: -10; } .flex-order--9 { order: -9; } .flex-order--8 { order: -8; } .flex-order--7 { order: -7; } .flex-order--6 { order: -6; } .flex-order--5 { order: -5; } .flex-order--4 { order: -4; } .flex-order--3 { order: -3; } .flex-order--2 { order: -2; } .flex-order--1 { order: -1; } .flex-order-0 { order: 0; } .flex-order-1 { order: 1; } .flex-order-2 { order: 2; } .flex-order-3 { order: 3; } .flex-order-4 { order: 4; } .flex-order-5 { order: 5; } .flex-order-6 { order: 6; } .flex-order-7 { order: 7; } .flex-order-8 { order: 8; } .flex-order-9 { order: 9; } .flex-order-10 { order: 10; } .flex-order-11 { order: 11; } .flex-order-12 { order: 12; } .flex-order-13 { order: 13; } .flex-order-14 { order: 14; } .flex-order-15 { order: 15; } .flex-order-16 { order: 16; } .flex-order-17 { order: 17; } .flex-order-18 { order: 18; } .flex-order-19 { order: 19; } .flex-order-20 { order: 20; } .offset-0, .flex-offset-0 { margin-left: 0; } [dir=rtl] .offset-0, [dir=rtl] .flex-offset-0 { margin-left: auto; margin-right: 0; } .offset-5, .flex-offset-5 { margin-left: 5%; } [dir=rtl] .offset-5, [dir=rtl] .flex-offset-5 { margin-left: auto; margin-right: 5%; } .offset-10, .flex-offset-10 { margin-left: 10%; } [dir=rtl] .offset-10, [dir=rtl] .flex-offset-10 { margin-left: auto; margin-right: 10%; } .offset-15, .flex-offset-15 { margin-left: 15%; } [dir=rtl] .offset-15, [dir=rtl] .flex-offset-15 { margin-left: auto; margin-right: 15%; } .offset-20, .flex-offset-20 { margin-left: 20%; } [dir=rtl] .offset-20, [dir=rtl] .flex-offset-20 { margin-left: auto; margin-right: 20%; } .offset-25, .flex-offset-25 { margin-left: 25%; } [dir=rtl] .offset-25, [dir=rtl] .flex-offset-25 { margin-left: auto; margin-right: 25%; } .offset-30, .flex-offset-30 { margin-left: 30%; } [dir=rtl] .offset-30, [dir=rtl] .flex-offset-30 { margin-left: auto; margin-right: 30%; } .offset-35, .flex-offset-35 { margin-left: 35%; } [dir=rtl] .offset-35, [dir=rtl] .flex-offset-35 { margin-left: auto; margin-right: 35%; } .offset-40, .flex-offset-40 { margin-left: 40%; } [dir=rtl] .offset-40, [dir=rtl] .flex-offset-40 { margin-left: auto; margin-right: 40%; } .offset-45, .flex-offset-45 { margin-left: 45%; } [dir=rtl] .offset-45, [dir=rtl] .flex-offset-45 { margin-left: auto; margin-right: 45%; } .offset-50, .flex-offset-50 { margin-left: 50%; } [dir=rtl] .offset-50, [dir=rtl] .flex-offset-50 { margin-left: auto; margin-right: 50%; } .offset-55, .flex-offset-55 { margin-left: 55%; } [dir=rtl] .offset-55, [dir=rtl] .flex-offset-55 { margin-left: auto; margin-right: 55%; } .offset-60, .flex-offset-60 { margin-left: 60%; } [dir=rtl] .offset-60, [dir=rtl] .flex-offset-60 { margin-left: auto; margin-right: 60%; } .offset-65, .flex-offset-65 { margin-left: 65%; } [dir=rtl] .offset-65, [dir=rtl] .flex-offset-65 { margin-left: auto; margin-right: 65%; } .offset-70, .flex-offset-70 { margin-left: 70%; } [dir=rtl] .offset-70, [dir=rtl] .flex-offset-70 { margin-left: auto; margin-right: 70%; } .offset-75, .flex-offset-75 { margin-left: 75%; } [dir=rtl] .offset-75, [dir=rtl] .flex-offset-75 { margin-left: auto; margin-right: 75%; } .offset-80, .flex-offset-80 { margin-left: 80%; } [dir=rtl] .offset-80, [dir=rtl] .flex-offset-80 { margin-left: auto; margin-right: 80%; } .offset-85, .flex-offset-85 { margin-left: 85%; } [dir=rtl] .offset-85, [dir=rtl] .flex-offset-85 { margin-left: auto; margin-right: 85%; } .offset-90, .flex-offset-90 { margin-left: 90%; } [dir=rtl] .offset-90, [dir=rtl] .flex-offset-90 { margin-left: auto; margin-right: 90%; } .offset-95, .flex-offset-95 { margin-left: 95%; } [dir=rtl] .offset-95, [dir=rtl] .flex-offset-95 { margin-left: auto; margin-right: 95%; } .offset-33, .flex-offset-33 { margin-left: calc(100% / 3); } .offset-66, .flex-offset-66 { margin-left: calc(200% / 3); } [dir=rtl] .offset-66, [dir=rtl] .flex-offset-66 { margin-left: auto; margin-right: calc(200% / 3); } .layout-align, .layout-align-start-stretch { justify-content: flex-start; align-content: stretch; align-items: stretch; } .layout-align-start, .layout-align-start-start, .layout-align-start-center, .layout-align-start-end, .layout-align-start-stretch { justify-content: flex-start; } .layout-align-center, .layout-align-center-start, .layout-align-center-center, .layout-align-center-end, .layout-align-center-stretch { justify-content: center; } .layout-align-end, .layout-align-end-start, .layout-align-end-center, .layout-align-end-end, .layout-align-end-stretch { justify-content: flex-end; } .layout-align-space-around, .layout-align-space-around-center, .layout-align-space-around-start, .layout-align-space-around-end, .layout-align-space-around-stretch { justify-content: space-around; } .layout-align-space-between, .layout-align-space-between-center, .layout-align-space-between-start, .layout-align-space-between-end, .layout-align-space-between-stretch { justify-content: space-between; } .layout-align-start-start, .layout-align-center-start, .layout-align-end-start, .layout-align-space-between-start, .layout-align-space-around-start { align-items: flex-start; align-content: flex-start; } .layout-align-start-center, .layout-align-center-center, .layout-align-end-center, .layout-align-space-between-center, .layout-align-space-around-center { align-items: center; align-content: center; max-width: 100%; } .layout-align-start-center > *, .layout-align-center-center > *, .layout-align-end-center > *, .layout-align-space-between-center > *, .layout-align-space-around-center > * { max-width: 100%; box-sizing: border-box; } .layout-align-start-end, .layout-align-center-end, .layout-align-end-end, .layout-align-space-between-end, .layout-align-space-around-end { align-items: flex-end; align-content: flex-end; } .layout-align-start-stretch, .layout-align-center-stretch, .layout-align-end-stretch, .layout-align-space-between-stretch, .layout-align-space-around-stretch { align-items: stretch; align-content: stretch; } .flex { flex: 1; box-sizing: border-box; } .flex-grow { flex: 1 1 100%; box-sizing: border-box; } .flex-initial { flex: 0 1 auto; box-sizing: border-box; } .flex-auto { flex: 1 1 auto; box-sizing: border-box; } .flex-none { flex: 0 0 auto; box-sizing: border-box; } .flex-noshrink { flex: 1 0 auto; box-sizing: border-box; } .flex-nogrow { flex: 0 1 auto; box-sizing: border-box; } .flex-0 { flex: 1 1 0%; max-width: 0%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-0 { flex: 1 1 0%; max-width: 0%; max-height: 100%; box-sizing: border-box; min-width: 0; } .layout-column > .flex-0 { flex: 1 1 0%; max-width: 100%; max-height: 0%; box-sizing: border-box; } .layout-row > .flex-33, .layout-row > .flex-33 { flex: 1 1 33.33%; max-width: 33.33%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-66, .layout-row > .flex-66 { flex: 1 1 66.66%; max-width: 66.66%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-33, .layout-column > .flex-33 { flex: 1 1 33.33%; max-width: 100%; max-height: 33.33%; box-sizing: border-box; } .layout-column > .flex-66, .layout-column > .flex-66 { flex: 1 1 66.66%; max-width: 100%; max-height: 66.66%; box-sizing: border-box; } .layout-row > .flex-0 { flex: 1 1 0%; max-width: 0%; max-height: 100%; box-sizing: border-box; min-width: 0; } .layout-column > .flex-0 { flex: 1 1 0%; max-width: 100%; max-height: 0%; box-sizing: border-box; min-height: 0; } .flex-5 { flex: 1 1 5%; max-width: 5%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-5 { flex: 1 1 5%; max-width: 5%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-5 { flex: 1 1 5%; max-width: 100%; max-height: 5%; box-sizing: border-box; } .layout-row > .flex-33, .layout-row > .flex-33 { flex: 1 1 33.33%; max-width: 33.33%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-66, .layout-row > .flex-66 { flex: 1 1 66.66%; max-width: 66.66%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-33, .layout-column > .flex-33 { flex: 1 1 33.33%; max-width: 100%; max-height: 33.33%; box-sizing: border-box; } .layout-column > .flex-66, .layout-column > .flex-66 { flex: 1 1 66.66%; max-width: 100%; max-height: 66.66%; box-sizing: border-box; } .layout-row > .flex-5 { flex: 1 1 5%; max-width: 5%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-5 { flex: 1 1 5%; max-width: 100%; max-height: 5%; box-sizing: border-box; } .flex-10 { flex: 1 1 10%; max-width: 10%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-10 { flex: 1 1 10%; max-width: 10%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-10 { flex: 1 1 10%; max-width: 100%; max-height: 10%; box-sizing: border-box; } .layout-row > .flex-33, .layout-row > .flex-33 { flex: 1 1 33.33%; max-width: 33.33%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-66, .layout-row > .flex-66 { flex: 1 1 66.66%; max-width: 66.66%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-33, .layout-column > .flex-33 { flex: 1 1 33.33%; max-width: 100%; max-height: 33.33%; box-sizing: border-box; } .layout-column > .flex-66, .layout-column > .flex-66 { flex: 1 1 66.66%; max-width: 100%; max-height: 66.66%; box-sizing: border-box; } .layout-row > .flex-10 { flex: 1 1 10%; max-width: 10%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-10 { flex: 1 1 10%; max-width: 100%; max-height: 10%; box-sizing: border-box; } .flex-15 { flex: 1 1 15%; max-width: 15%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-15 { flex: 1 1 15%; max-width: 15%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-15 { flex: 1 1 15%; max-width: 100%; max-height: 15%; box-sizing: border-box; } .layout-row > .flex-33, .layout-row > .flex-33 { flex: 1 1 33.33%; max-width: 33.33%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-66, .layout-row > .flex-66 { flex: 1 1 66.66%; max-width: 66.66%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-33, .layout-column > .flex-33 { flex: 1 1 33.33%; max-width: 100%; max-height: 33.33%; box-sizing: border-box; } .layout-column > .flex-66, .layout-column > .flex-66 { flex: 1 1 66.66%; max-width: 100%; max-height: 66.66%; box-sizing: border-box; } .layout-row > .flex-15 { flex: 1 1 15%; max-width: 15%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-15 { flex: 1 1 15%; max-width: 100%; max-height: 15%; box-sizing: border-box; } .flex-20 { flex: 1 1 20%; max-width: 20%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-20 { flex: 1 1 20%; max-width: 20%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-20 { flex: 1 1 20%; max-width: 100%; max-height: 20%; box-sizing: border-box; } .layout-row > .flex-33, .layout-row > .flex-33 { flex: 1 1 33.33%; max-width: 33.33%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-66, .layout-row > .flex-66 { flex: 1 1 66.66%; max-width: 66.66%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-33, .layout-column > .flex-33 { flex: 1 1 33.33%; max-width: 100%; max-height: 33.33%; box-sizing: border-box; } .layout-column > .flex-66, .layout-column > .flex-66 { flex: 1 1 66.66%; max-width: 100%; max-height: 66.66%; box-sizing: border-box; } .layout-row > .flex-20 { flex: 1 1 20%; max-width: 20%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-20 { flex: 1 1 20%; max-width: 100%; max-height: 20%; box-sizing: border-box; } .flex-25 { flex: 1 1 25%; max-width: 25%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-25 { flex: 1 1 25%; max-width: 25%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-25 { flex: 1 1 25%; max-width: 100%; max-height: 25%; box-sizing: border-box; } .layout-row > .flex-33, .layout-row > .flex-33 { flex: 1 1 33.33%; max-width: 33.33%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-66, .layout-row > .flex-66 { flex: 1 1 66.66%; max-width: 66.66%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-33, .layout-column > .flex-33 { flex: 1 1 33.33%; max-width: 100%; max-height: 33.33%; box-sizing: border-box; } .layout-column > .flex-66, .layout-column > .flex-66 { flex: 1 1 66.66%; max-width: 100%; max-height: 66.66%; box-sizing: border-box; } .layout-row > .flex-25 { flex: 1 1 25%; max-width: 25%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-25 { flex: 1 1 25%; max-width: 100%; max-height: 25%; box-sizing: border-box; } .flex-30 { flex: 1 1 30%; max-width: 30%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-30 { flex: 1 1 30%; max-width: 30%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-30 { flex: 1 1 30%; max-width: 100%; max-height: 30%; box-sizing: border-box; } .layout-row > .flex-33, .layout-row > .flex-33 { flex: 1 1 33.33%; max-width: 33.33%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-66, .layout-row > .flex-66 { flex: 1 1 66.66%; max-width: 66.66%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-33, .layout-column > .flex-33 { flex: 1 1 33.33%; max-width: 100%; max-height: 33.33%; box-sizing: border-box; } .layout-column > .flex-66, .layout-column > .flex-66 { flex: 1 1 66.66%; max-width: 100%; max-height: 66.66%; box-sizing: border-box; } .layout-row > .flex-30 { flex: 1 1 30%; max-width: 30%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-30 { flex: 1 1 30%; max-width: 100%; max-height: 30%; box-sizing: border-box; } .flex-35 { flex: 1 1 35%; max-width: 35%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-35 { flex: 1 1 35%; max-width: 35%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-35 { flex: 1 1 35%; max-width: 100%; max-height: 35%; box-sizing: border-box; } .layout-row > .flex-33, .layout-row > .flex-33 { flex: 1 1 33.33%; max-width: 33.33%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-66, .layout-row > .flex-66 { flex: 1 1 66.66%; max-width: 66.66%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-33, .layout-column > .flex-33 { flex: 1 1 33.33%; max-width: 100%; max-height: 33.33%; box-sizing: border-box; } .layout-column > .flex-66, .layout-column > .flex-66 { flex: 1 1 66.66%; max-width: 100%; max-height: 66.66%; box-sizing: border-box; } .layout-row > .flex-35 { flex: 1 1 35%; max-width: 35%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-35 { flex: 1 1 35%; max-width: 100%; max-height: 35%; box-sizing: border-box; } .flex-40 { flex: 1 1 40%; max-width: 40%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-40 { flex: 1 1 40%; max-width: 40%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-40 { flex: 1 1 40%; max-width: 100%; max-height: 40%; box-sizing: border-box; } .layout-row > .flex-33, .layout-row > .flex-33 { flex: 1 1 33.33%; max-width: 33.33%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-66, .layout-row > .flex-66 { flex: 1 1 66.66%; max-width: 66.66%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-33, .layout-column > .flex-33 { flex: 1 1 33.33%; max-width: 100%; max-height: 33.33%; box-sizing: border-box; } .layout-column > .flex-66, .layout-column > .flex-66 { flex: 1 1 66.66%; max-width: 100%; max-height: 66.66%; box-sizing: border-box; } .layout-row > .flex-40 { flex: 1 1 40%; max-width: 40%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-40 { flex: 1 1 40%; max-width: 100%; max-height: 40%; box-sizing: border-box; } .flex-45 { flex: 1 1 45%; max-width: 45%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-45 { flex: 1 1 45%; max-width: 45%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-45 { flex: 1 1 45%; max-width: 100%; max-height: 45%; box-sizing: border-box; } .layout-row > .flex-33, .layout-row > .flex-33 { flex: 1 1 33.33%; max-width: 33.33%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-66, .layout-row > .flex-66 { flex: 1 1 66.66%; max-width: 66.66%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-33, .layout-column > .flex-33 { flex: 1 1 33.33%; max-width: 100%; max-height: 33.33%; box-sizing: border-box; } .layout-column > .flex-66, .layout-column > .flex-66 { flex: 1 1 66.66%; max-width: 100%; max-height: 66.66%; box-sizing: border-box; } .layout-row > .flex-45 { flex: 1 1 45%; max-width: 45%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-45 { flex: 1 1 45%; max-width: 100%; max-height: 45%; box-sizing: border-box; } .flex-50 { flex: 1 1 50%; max-width: 50%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-50 { flex: 1 1 50%; max-width: 50%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-50 { flex: 1 1 50%; max-width: 100%; max-height: 50%; box-sizing: border-box; } .layout-row > .flex-33, .layout-row > .flex-33 { flex: 1 1 33.33%; max-width: 33.33%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-66, .layout-row > .flex-66 { flex: 1 1 66.66%; max-width: 66.66%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-33, .layout-column > .flex-33 { flex: 1 1 33.33%; max-width: 100%; max-height: 33.33%; box-sizing: border-box; } .layout-column > .flex-66, .layout-column > .flex-66 { flex: 1 1 66.66%; max-width: 100%; max-height: 66.66%; box-sizing: border-box; } .layout-row > .flex-50 { flex: 1 1 50%; max-width: 50%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-50 { flex: 1 1 50%; max-width: 100%; max-height: 50%; box-sizing: border-box; } .flex-55 { flex: 1 1 55%; max-width: 55%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-55 { flex: 1 1 55%; max-width: 55%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-55 { flex: 1 1 55%; max-width: 100%; max-height: 55%; box-sizing: border-box; } .layout-row > .flex-33, .layout-row > .flex-33 { flex: 1 1 33.33%; max-width: 33.33%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-66, .layout-row > .flex-66 { flex: 1 1 66.66%; max-width: 66.66%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-33, .layout-column > .flex-33 { flex: 1 1 33.33%; max-width: 100%; max-height: 33.33%; box-sizing: border-box; } .layout-column > .flex-66, .layout-column > .flex-66 { flex: 1 1 66.66%; max-width: 100%; max-height: 66.66%; box-sizing: border-box; } .layout-row > .flex-55 { flex: 1 1 55%; max-width: 55%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-55 { flex: 1 1 55%; max-width: 100%; max-height: 55%; box-sizing: border-box; } .flex-60 { flex: 1 1 60%; max-width: 60%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-60 { flex: 1 1 60%; max-width: 60%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-60 { flex: 1 1 60%; max-width: 100%; max-height: 60%; box-sizing: border-box; } .layout-row > .flex-33, .layout-row > .flex-33 { flex: 1 1 33.33%; max-width: 33.33%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-66, .layout-row > .flex-66 { flex: 1 1 66.66%; max-width: 66.66%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-33, .layout-column > .flex-33 { flex: 1 1 33.33%; max-width: 100%; max-height: 33.33%; box-sizing: border-box; } .layout-column > .flex-66, .layout-column > .flex-66 { flex: 1 1 66.66%; max-width: 100%; max-height: 66.66%; box-sizing: border-box; } .layout-row > .flex-60 { flex: 1 1 60%; max-width: 60%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-60 { flex: 1 1 60%; max-width: 100%; max-height: 60%; box-sizing: border-box; } .flex-65 { flex: 1 1 65%; max-width: 65%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-65 { flex: 1 1 65%; max-width: 65%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-65 { flex: 1 1 65%; max-width: 100%; max-height: 65%; box-sizing: border-box; } .layout-row > .flex-33, .layout-row > .flex-33 { flex: 1 1 33.33%; max-width: 33.33%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-66, .layout-row > .flex-66 { flex: 1 1 66.66%; max-width: 66.66%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-33, .layout-column > .flex-33 { flex: 1 1 33.33%; max-width: 100%; max-height: 33.33%; box-sizing: border-box; } .layout-column > .flex-66, .layout-column > .flex-66 { flex: 1 1 66.66%; max-width: 100%; max-height: 66.66%; box-sizing: border-box; } .layout-row > .flex-65 { flex: 1 1 65%; max-width: 65%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-65 { flex: 1 1 65%; max-width: 100%; max-height: 65%; box-sizing: border-box; } .flex-70 { flex: 1 1 70%; max-width: 70%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-70 { flex: 1 1 70%; max-width: 70%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-70 { flex: 1 1 70%; max-width: 100%; max-height: 70%; box-sizing: border-box; } .layout-row > .flex-33, .layout-row > .flex-33 { flex: 1 1 33.33%; max-width: 33.33%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-66, .layout-row > .flex-66 { flex: 1 1 66.66%; max-width: 66.66%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-33, .layout-column > .flex-33 { flex: 1 1 33.33%; max-width: 100%; max-height: 33.33%; box-sizing: border-box; } .layout-column > .flex-66, .layout-column > .flex-66 { flex: 1 1 66.66%; max-width: 100%; max-height: 66.66%; box-sizing: border-box; } .layout-row > .flex-70 { flex: 1 1 70%; max-width: 70%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-70 { flex: 1 1 70%; max-width: 100%; max-height: 70%; box-sizing: border-box; } .flex-75 { flex: 1 1 75%; max-width: 75%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-75 { flex: 1 1 75%; max-width: 75%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-75 { flex: 1 1 75%; max-width: 100%; max-height: 75%; box-sizing: border-box; } .layout-row > .flex-33, .layout-row > .flex-33 { flex: 1 1 33.33%; max-width: 33.33%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-66, .layout-row > .flex-66 { flex: 1 1 66.66%; max-width: 66.66%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-33, .layout-column > .flex-33 { flex: 1 1 33.33%; max-width: 100%; max-height: 33.33%; box-sizing: border-box; } .layout-column > .flex-66, .layout-column > .flex-66 { flex: 1 1 66.66%; max-width: 100%; max-height: 66.66%; box-sizing: border-box; } .layout-row > .flex-75 { flex: 1 1 75%; max-width: 75%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-75 { flex: 1 1 75%; max-width: 100%; max-height: 75%; box-sizing: border-box; } .flex-80 { flex: 1 1 80%; max-width: 80%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-80 { flex: 1 1 80%; max-width: 80%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-80 { flex: 1 1 80%; max-width: 100%; max-height: 80%; box-sizing: border-box; } .layout-row > .flex-33, .layout-row > .flex-33 { flex: 1 1 33.33%; max-width: 33.33%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-66, .layout-row > .flex-66 { flex: 1 1 66.66%; max-width: 66.66%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-33, .layout-column > .flex-33 { flex: 1 1 33.33%; max-width: 100%; max-height: 33.33%; box-sizing: border-box; } .layout-column > .flex-66, .layout-column > .flex-66 { flex: 1 1 66.66%; max-width: 100%; max-height: 66.66%; box-sizing: border-box; } .layout-row > .flex-80 { flex: 1 1 80%; max-width: 80%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-80 { flex: 1 1 80%; max-width: 100%; max-height: 80%; box-sizing: border-box; } .flex-85 { flex: 1 1 85%; max-width: 85%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-85 { flex: 1 1 85%; max-width: 85%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-85 { flex: 1 1 85%; max-width: 100%; max-height: 85%; box-sizing: border-box; } .layout-row > .flex-33, .layout-row > .flex-33 { flex: 1 1 33.33%; max-width: 33.33%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-66, .layout-row > .flex-66 { flex: 1 1 66.66%; max-width: 66.66%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-33, .layout-column > .flex-33 { flex: 1 1 33.33%; max-width: 100%; max-height: 33.33%; box-sizing: border-box; } .layout-column > .flex-66, .layout-column > .flex-66 { flex: 1 1 66.66%; max-width: 100%; max-height: 66.66%; box-sizing: border-box; } .layout-row > .flex-85 { flex: 1 1 85%; max-width: 85%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-85 { flex: 1 1 85%; max-width: 100%; max-height: 85%; box-sizing: border-box; } .flex-90 { flex: 1 1 90%; max-width: 90%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-90 { flex: 1 1 90%; max-width: 90%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-90 { flex: 1 1 90%; max-width: 100%; max-height: 90%; box-sizing: border-box; } .layout-row > .flex-33, .layout-row > .flex-33 { flex: 1 1 33.33%; max-width: 33.33%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-66, .layout-row > .flex-66 { flex: 1 1 66.66%; max-width: 66.66%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-33, .layout-column > .flex-33 { flex: 1 1 33.33%; max-width: 100%; max-height: 33.33%; box-sizing: border-box; } .layout-column > .flex-66, .layout-column > .flex-66 { flex: 1 1 66.66%; max-width: 100%; max-height: 66.66%; box-sizing: border-box; } .layout-row > .flex-90 { flex: 1 1 90%; max-width: 90%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-90 { flex: 1 1 90%; max-width: 100%; max-height: 90%; box-sizing: border-box; } .flex-95 { flex: 1 1 95%; max-width: 95%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-95 { flex: 1 1 95%; max-width: 95%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-95 { flex: 1 1 95%; max-width: 100%; max-height: 95%; box-sizing: border-box; } .layout-row > .flex-33, .layout-row > .flex-33 { flex: 1 1 33.33%; max-width: 33.33%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-66, .layout-row > .flex-66 { flex: 1 1 66.66%; max-width: 66.66%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-33, .layout-column > .flex-33 { flex: 1 1 33.33%; max-width: 100%; max-height: 33.33%; box-sizing: border-box; } .layout-column > .flex-66, .layout-column > .flex-66 { flex: 1 1 66.66%; max-width: 100%; max-height: 66.66%; box-sizing: border-box; } .layout-row > .flex-95 { flex: 1 1 95%; max-width: 95%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-95 { flex: 1 1 95%; max-width: 100%; max-height: 95%; box-sizing: border-box; } .flex-100 { flex: 1 1 100%; max-width: 100%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-100 { flex: 1 1 100%; max-width: 100%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-100 { flex: 1 1 100%; max-width: 100%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-33, .layout-row > .flex-33 { flex: 1 1 33.33%; max-width: 33.33%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-66, .layout-row > .flex-66 { flex: 1 1 66.66%; max-width: 66.66%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-33, .layout-column > .flex-33 { flex: 1 1 33.33%; max-width: 100%; max-height: 33.33%; box-sizing: border-box; } .layout-column > .flex-66, .layout-column > .flex-66 { flex: 1 1 66.66%; max-width: 100%; max-height: 66.66%; box-sizing: border-box; } .layout-row > .flex-100 { flex: 1 1 100%; max-width: 100%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-100 { flex: 1 1 100%; max-width: 100%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-33, .layout-row > .flex-33 { flex: 1 1 33.33%; max-width: 33.33%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-66, .layout-row > .flex-66 { flex: 1 1 66.66%; max-width: 66.66%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex { min-width: 0; } .layout-column > .flex-33, .layout-column > .flex-33 { flex: 1 1 33.33%; max-width: 100%; max-height: 33.33%; box-sizing: border-box; } .layout-column > .flex-66, .layout-column > .flex-66 { flex: 1 1 66.66%; max-width: 100%; max-height: 66.66%; box-sizing: border-box; } .layout-column > .flex { min-height: 0; } .layout, .layout-column, .layout-row { box-sizing: border-box; display: -webkit-box; display: -webkit-flex; display: -moz-box; display: -ms-flexbox; display: flex; } .layout-column { flex-direction: column; } .layout-row { flex-direction: row; } .layout-padding-sm > *, .layout-padding > .flex-sm { padding: 4px; } .layout-padding, .layout-padding-gt-sm, .layout-padding-md, .layout-padding > *, .layout-padding-gt-sm > *, .layout-padding-md > *, .layout-padding > .flex, .layout-padding > .flex-gt-sm, .layout-padding > .flex-md { padding: 8px; } .layout-padding-gt-md > *, .layout-padding-lg > *, .layout-padding-gt-lg > *, .layout-padding > .flex-gt-md, .layout-padding > .flex-lg, .layout-padding > .flex-lg, .layout-padding > .flex-gt-lg { padding: 16px; } .layout-margin-sm > *, .layout-margin > .flex-sm { margin: 4px; } .layout-margin, .layout-margin-gt-sm, .layout-margin-md, .layout-margin > *, .layout-margin-gt-sm > *, .layout-margin-md > *, .layout-margin > .flex, .layout-margin > .flex-gt-sm, .layout-margin > .flex-md { margin: 8px; } .layout-margin-gt-md > *, .layout-margin-lg > *, .layout-margin-gt-lg > *, .layout-margin > .flex-gt-md, .layout-margin > .flex-lg, .layout-margin > .flex-gt-lg { margin: 16px; } .layout-wrap { flex-wrap: wrap; } .layout-nowrap { flex-wrap: nowrap; } .layout-fill { margin: 0; width: 100%; min-height: 100%; height: 100%; } /* Apply Mixins to create Layout/Flexbox styles */ .flex-order { order: 0; } .flex-order--20 { order: -20; } .flex-order--19 { order: -19; } .flex-order--18 { order: -18; } .flex-order--17 { order: -17; } .flex-order--16 { order: -16; } .flex-order--15 { order: -15; } .flex-order--14 { order: -14; } .flex-order--13 { order: -13; } .flex-order--12 { order: -12; } .flex-order--11 { order: -11; } .flex-order--10 { order: -10; } .flex-order--9 { order: -9; } .flex-order--8 { order: -8; } .flex-order--7 { order: -7; } .flex-order--6 { order: -6; } .flex-order--5 { order: -5; } .flex-order--4 { order: -4; } .flex-order--3 { order: -3; } .flex-order--2 { order: -2; } .flex-order--1 { order: -1; } .flex-order-0 { order: 0; } .flex-order-1 { order: 1; } .flex-order-2 { order: 2; } .flex-order-3 { order: 3; } .flex-order-4 { order: 4; } .flex-order-5 { order: 5; } .flex-order-6 { order: 6; } .flex-order-7 { order: 7; } .flex-order-8 { order: 8; } .flex-order-9 { order: 9; } .flex-order-10 { order: 10; } .flex-order-11 { order: 11; } .flex-order-12 { order: 12; } .flex-order-13 { order: 13; } .flex-order-14 { order: 14; } .flex-order-15 { order: 15; } .flex-order-16 { order: 16; } .flex-order-17 { order: 17; } .flex-order-18 { order: 18; } .flex-order-19 { order: 19; } .flex-order-20 { order: 20; } .offset-0, .flex-offset-0 { margin-left: 0; } [dir=rtl] .offset-0, [dir=rtl] .flex-offset-0 { margin-left: auto; margin-right: 0; } .offset-5, .flex-offset-5 { margin-left: 5%; } [dir=rtl] .offset-5, [dir=rtl] .flex-offset-5 { margin-left: auto; margin-right: 5%; } .offset-10, .flex-offset-10 { margin-left: 10%; } [dir=rtl] .offset-10, [dir=rtl] .flex-offset-10 { margin-left: auto; margin-right: 10%; } .offset-15, .flex-offset-15 { margin-left: 15%; } [dir=rtl] .offset-15, [dir=rtl] .flex-offset-15 { margin-left: auto; margin-right: 15%; } .offset-20, .flex-offset-20 { margin-left: 20%; } [dir=rtl] .offset-20, [dir=rtl] .flex-offset-20 { margin-left: auto; margin-right: 20%; } .offset-25, .flex-offset-25 { margin-left: 25%; } [dir=rtl] .offset-25, [dir=rtl] .flex-offset-25 { margin-left: auto; margin-right: 25%; } .offset-30, .flex-offset-30 { margin-left: 30%; } [dir=rtl] .offset-30, [dir=rtl] .flex-offset-30 { margin-left: auto; margin-right: 30%; } .offset-35, .flex-offset-35 { margin-left: 35%; } [dir=rtl] .offset-35, [dir=rtl] .flex-offset-35 { margin-left: auto; margin-right: 35%; } .offset-40, .flex-offset-40 { margin-left: 40%; } [dir=rtl] .offset-40, [dir=rtl] .flex-offset-40 { margin-left: auto; margin-right: 40%; } .offset-45, .flex-offset-45 { margin-left: 45%; } [dir=rtl] .offset-45, [dir=rtl] .flex-offset-45 { margin-left: auto; margin-right: 45%; } .offset-50, .flex-offset-50 { margin-left: 50%; } [dir=rtl] .offset-50, [dir=rtl] .flex-offset-50 { margin-left: auto; margin-right: 50%; } .offset-55, .flex-offset-55 { margin-left: 55%; } [dir=rtl] .offset-55, [dir=rtl] .flex-offset-55 { margin-left: auto; margin-right: 55%; } .offset-60, .flex-offset-60 { margin-left: 60%; } [dir=rtl] .offset-60, [dir=rtl] .flex-offset-60 { margin-left: auto; margin-right: 60%; } .offset-65, .flex-offset-65 { margin-left: 65%; } [dir=rtl] .offset-65, [dir=rtl] .flex-offset-65 { margin-left: auto; margin-right: 65%; } .offset-70, .flex-offset-70 { margin-left: 70%; } [dir=rtl] .offset-70, [dir=rtl] .flex-offset-70 { margin-left: auto; margin-right: 70%; } .offset-75, .flex-offset-75 { margin-left: 75%; } [dir=rtl] .offset-75, [dir=rtl] .flex-offset-75 { margin-left: auto; margin-right: 75%; } .offset-80, .flex-offset-80 { margin-left: 80%; } [dir=rtl] .offset-80, [dir=rtl] .flex-offset-80 { margin-left: auto; margin-right: 80%; } .offset-85, .flex-offset-85 { margin-left: 85%; } [dir=rtl] .offset-85, [dir=rtl] .flex-offset-85 { margin-left: auto; margin-right: 85%; } .offset-90, .flex-offset-90 { margin-left: 90%; } [dir=rtl] .offset-90, [dir=rtl] .flex-offset-90 { margin-left: auto; margin-right: 90%; } .offset-95, .flex-offset-95 { margin-left: 95%; } [dir=rtl] .offset-95, [dir=rtl] .flex-offset-95 { margin-left: auto; margin-right: 95%; } .offset-33, .flex-offset-33 { margin-left: calc(100% / 3); } .offset-66, .flex-offset-66 { margin-left: calc(200% / 3); } [dir=rtl] .offset-66, [dir=rtl] .flex-offset-66 { margin-left: auto; margin-right: calc(200% / 3); } .layout-align, .layout-align-start-stretch { justify-content: flex-start; align-content: stretch; align-items: stretch; } .layout-align-start, .layout-align-start-start, .layout-align-start-center, .layout-align-start-end, .layout-align-start-stretch { justify-content: flex-start; } .layout-align-center, .layout-align-center-start, .layout-align-center-center, .layout-align-center-end, .layout-align-center-stretch { justify-content: center; } .layout-align-end, .layout-align-end-start, .layout-align-end-center, .layout-align-end-end, .layout-align-end-stretch { justify-content: flex-end; } .layout-align-space-around, .layout-align-space-around-center, .layout-align-space-around-start, .layout-align-space-around-end, .layout-align-space-around-stretch { justify-content: space-around; } .layout-align-space-between, .layout-align-space-between-center, .layout-align-space-between-start, .layout-align-space-between-end, .layout-align-space-between-stretch { justify-content: space-between; } .layout-align-start-start, .layout-align-center-start, .layout-align-end-start, .layout-align-space-between-start, .layout-align-space-around-start { align-items: flex-start; align-content: flex-start; } .layout-align-start-center, .layout-align-center-center, .layout-align-end-center, .layout-align-space-between-center, .layout-align-space-around-center { align-items: center; align-content: center; max-width: 100%; } .layout-align-start-center > *, .layout-align-center-center > *, .layout-align-end-center > *, .layout-align-space-between-center > *, .layout-align-space-around-center > * { max-width: 100%; box-sizing: border-box; } .layout-align-start-end, .layout-align-center-end, .layout-align-end-end, .layout-align-space-between-end, .layout-align-space-around-end { align-items: flex-end; align-content: flex-end; } .layout-align-start-stretch, .layout-align-center-stretch, .layout-align-end-stretch, .layout-align-space-between-stretch, .layout-align-space-around-stretch { align-items: stretch; align-content: stretch; } .flex { flex: 1; box-sizing: border-box; } .flex-grow { flex: 1 1 100%; box-sizing: border-box; } .flex-initial { flex: 0 1 auto; box-sizing: border-box; } .flex-auto { flex: 1 1 auto; box-sizing: border-box; } .flex-none { flex: 0 0 auto; box-sizing: border-box; } .flex-noshrink { flex: 1 0 auto; box-sizing: border-box; } .flex-nogrow { flex: 0 1 auto; box-sizing: border-box; } .flex-0 { flex: 1 1 0%; max-width: 0%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-0 { flex: 1 1 0%; max-width: 0%; max-height: 100%; box-sizing: border-box; min-width: 0; } .layout-column > .flex-0 { flex: 1 1 0%; max-width: 100%; max-height: 0%; box-sizing: border-box; } .layout-row > .flex-33, .layout-row > .flex-33 { flex: 1 1 33.33%; max-width: 33.33%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-66, .layout-row > .flex-66 { flex: 1 1 66.66%; max-width: 66.66%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-33, .layout-column > .flex-33 { flex: 1 1 33.33%; max-width: 100%; max-height: 33.33%; box-sizing: border-box; } .layout-column > .flex-66, .layout-column > .flex-66 { flex: 1 1 66.66%; max-width: 100%; max-height: 66.66%; box-sizing: border-box; } .layout-row > .flex-0 { flex: 1 1 0%; max-width: 0%; max-height: 100%; box-sizing: border-box; min-width: 0; } .layout-column > .flex-0 { flex: 1 1 0%; max-width: 100%; max-height: 0%; box-sizing: border-box; min-height: 0; } .flex-5 { flex: 1 1 5%; max-width: 5%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-5 { flex: 1 1 5%; max-width: 5%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-5 { flex: 1 1 5%; max-width: 100%; max-height: 5%; box-sizing: border-box; } .layout-row > .flex-33, .layout-row > .flex-33 { flex: 1 1 33.33%; max-width: 33.33%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-66, .layout-row > .flex-66 { flex: 1 1 66.66%; max-width: 66.66%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-33, .layout-column > .flex-33 { flex: 1 1 33.33%; max-width: 100%; max-height: 33.33%; box-sizing: border-box; } .layout-column > .flex-66, .layout-column > .flex-66 { flex: 1 1 66.66%; max-width: 100%; max-height: 66.66%; box-sizing: border-box; } .layout-row > .flex-5 { flex: 1 1 5%; max-width: 5%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-5 { flex: 1 1 5%; max-width: 100%; max-height: 5%; box-sizing: border-box; } .flex-10 { flex: 1 1 10%; max-width: 10%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-10 { flex: 1 1 10%; max-width: 10%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-10 { flex: 1 1 10%; max-width: 100%; max-height: 10%; box-sizing: border-box; } .layout-row > .flex-33, .layout-row > .flex-33 { flex: 1 1 33.33%; max-width: 33.33%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-66, .layout-row > .flex-66 { flex: 1 1 66.66%; max-width: 66.66%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-33, .layout-column > .flex-33 { flex: 1 1 33.33%; max-width: 100%; max-height: 33.33%; box-sizing: border-box; } .layout-column > .flex-66, .layout-column > .flex-66 { flex: 1 1 66.66%; max-width: 100%; max-height: 66.66%; box-sizing: border-box; } .layout-row > .flex-10 { flex: 1 1 10%; max-width: 10%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-10 { flex: 1 1 10%; max-width: 100%; max-height: 10%; box-sizing: border-box; } .flex-15 { flex: 1 1 15%; max-width: 15%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-15 { flex: 1 1 15%; max-width: 15%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-15 { flex: 1 1 15%; max-width: 100%; max-height: 15%; box-sizing: border-box; } .layout-row > .flex-33, .layout-row > .flex-33 { flex: 1 1 33.33%; max-width: 33.33%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-66, .layout-row > .flex-66 { flex: 1 1 66.66%; max-width: 66.66%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-33, .layout-column > .flex-33 { flex: 1 1 33.33%; max-width: 100%; max-height: 33.33%; box-sizing: border-box; } .layout-column > .flex-66, .layout-column > .flex-66 { flex: 1 1 66.66%; max-width: 100%; max-height: 66.66%; box-sizing: border-box; } .layout-row > .flex-15 { flex: 1 1 15%; max-width: 15%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-15 { flex: 1 1 15%; max-width: 100%; max-height: 15%; box-sizing: border-box; } .flex-20 { flex: 1 1 20%; max-width: 20%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-20 { flex: 1 1 20%; max-width: 20%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-20 { flex: 1 1 20%; max-width: 100%; max-height: 20%; box-sizing: border-box; } .layout-row > .flex-33, .layout-row > .flex-33 { flex: 1 1 33.33%; max-width: 33.33%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-66, .layout-row > .flex-66 { flex: 1 1 66.66%; max-width: 66.66%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-33, .layout-column > .flex-33 { flex: 1 1 33.33%; max-width: 100%; max-height: 33.33%; box-sizing: border-box; } .layout-column > .flex-66, .layout-column > .flex-66 { flex: 1 1 66.66%; max-width: 100%; max-height: 66.66%; box-sizing: border-box; } .layout-row > .flex-20 { flex: 1 1 20%; max-width: 20%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-20 { flex: 1 1 20%; max-width: 100%; max-height: 20%; box-sizing: border-box; } .flex-25 { flex: 1 1 25%; max-width: 25%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-25 { flex: 1 1 25%; max-width: 25%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-25 { flex: 1 1 25%; max-width: 100%; max-height: 25%; box-sizing: border-box; } .layout-row > .flex-33, .layout-row > .flex-33 { flex: 1 1 33.33%; max-width: 33.33%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-66, .layout-row > .flex-66 { flex: 1 1 66.66%; max-width: 66.66%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-33, .layout-column > .flex-33 { flex: 1 1 33.33%; max-width: 100%; max-height: 33.33%; box-sizing: border-box; } .layout-column > .flex-66, .layout-column > .flex-66 { flex: 1 1 66.66%; max-width: 100%; max-height: 66.66%; box-sizing: border-box; } .layout-row > .flex-25 { flex: 1 1 25%; max-width: 25%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-25 { flex: 1 1 25%; max-width: 100%; max-height: 25%; box-sizing: border-box; } .flex-30 { flex: 1 1 30%; max-width: 30%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-30 { flex: 1 1 30%; max-width: 30%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-30 { flex: 1 1 30%; max-width: 100%; max-height: 30%; box-sizing: border-box; } .layout-row > .flex-33, .layout-row > .flex-33 { flex: 1 1 33.33%; max-width: 33.33%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-66, .layout-row > .flex-66 { flex: 1 1 66.66%; max-width: 66.66%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-33, .layout-column > .flex-33 { flex: 1 1 33.33%; max-width: 100%; max-height: 33.33%; box-sizing: border-box; } .layout-column > .flex-66, .layout-column > .flex-66 { flex: 1 1 66.66%; max-width: 100%; max-height: 66.66%; box-sizing: border-box; } .layout-row > .flex-30 { flex: 1 1 30%; max-width: 30%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-30 { flex: 1 1 30%; max-width: 100%; max-height: 30%; box-sizing: border-box; } .flex-35 { flex: 1 1 35%; max-width: 35%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-35 { flex: 1 1 35%; max-width: 35%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-35 { flex: 1 1 35%; max-width: 100%; max-height: 35%; box-sizing: border-box; } .layout-row > .flex-33, .layout-row > .flex-33 { flex: 1 1 33.33%; max-width: 33.33%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-66, .layout-row > .flex-66 { flex: 1 1 66.66%; max-width: 66.66%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-33, .layout-column > .flex-33 { flex: 1 1 33.33%; max-width: 100%; max-height: 33.33%; box-sizing: border-box; } .layout-column > .flex-66, .layout-column > .flex-66 { flex: 1 1 66.66%; max-width: 100%; max-height: 66.66%; box-sizing: border-box; } .layout-row > .flex-35 { flex: 1 1 35%; max-width: 35%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-35 { flex: 1 1 35%; max-width: 100%; max-height: 35%; box-sizing: border-box; } .flex-40 { flex: 1 1 40%; max-width: 40%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-40 { flex: 1 1 40%; max-width: 40%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-40 { flex: 1 1 40%; max-width: 100%; max-height: 40%; box-sizing: border-box; } .layout-row > .flex-33, .layout-row > .flex-33 { flex: 1 1 33.33%; max-width: 33.33%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-66, .layout-row > .flex-66 { flex: 1 1 66.66%; max-width: 66.66%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-33, .layout-column > .flex-33 { flex: 1 1 33.33%; max-width: 100%; max-height: 33.33%; box-sizing: border-box; } .layout-column > .flex-66, .layout-column > .flex-66 { flex: 1 1 66.66%; max-width: 100%; max-height: 66.66%; box-sizing: border-box; } .layout-row > .flex-40 { flex: 1 1 40%; max-width: 40%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-40 { flex: 1 1 40%; max-width: 100%; max-height: 40%; box-sizing: border-box; } .flex-45 { flex: 1 1 45%; max-width: 45%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-45 { flex: 1 1 45%; max-width: 45%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-45 { flex: 1 1 45%; max-width: 100%; max-height: 45%; box-sizing: border-box; } .layout-row > .flex-33, .layout-row > .flex-33 { flex: 1 1 33.33%; max-width: 33.33%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-66, .layout-row > .flex-66 { flex: 1 1 66.66%; max-width: 66.66%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-33, .layout-column > .flex-33 { flex: 1 1 33.33%; max-width: 100%; max-height: 33.33%; box-sizing: border-box; } .layout-column > .flex-66, .layout-column > .flex-66 { flex: 1 1 66.66%; max-width: 100%; max-height: 66.66%; box-sizing: border-box; } .layout-row > .flex-45 { flex: 1 1 45%; max-width: 45%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-45 { flex: 1 1 45%; max-width: 100%; max-height: 45%; box-sizing: border-box; } .flex-50 { flex: 1 1 50%; max-width: 50%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-50 { flex: 1 1 50%; max-width: 50%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-50 { flex: 1 1 50%; max-width: 100%; max-height: 50%; box-sizing: border-box; } .layout-row > .flex-33, .layout-row > .flex-33 { flex: 1 1 33.33%; max-width: 33.33%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-66, .layout-row > .flex-66 { flex: 1 1 66.66%; max-width: 66.66%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-33, .layout-column > .flex-33 { flex: 1 1 33.33%; max-width: 100%; max-height: 33.33%; box-sizing: border-box; } .layout-column > .flex-66, .layout-column > .flex-66 { flex: 1 1 66.66%; max-width: 100%; max-height: 66.66%; box-sizing: border-box; } .layout-row > .flex-50 { flex: 1 1 50%; max-width: 50%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-50 { flex: 1 1 50%; max-width: 100%; max-height: 50%; box-sizing: border-box; } .flex-55 { flex: 1 1 55%; max-width: 55%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-55 { flex: 1 1 55%; max-width: 55%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-55 { flex: 1 1 55%; max-width: 100%; max-height: 55%; box-sizing: border-box; } .layout-row > .flex-33, .layout-row > .flex-33 { flex: 1 1 33.33%; max-width: 33.33%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-66, .layout-row > .flex-66 { flex: 1 1 66.66%; max-width: 66.66%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-33, .layout-column > .flex-33 { flex: 1 1 33.33%; max-width: 100%; max-height: 33.33%; box-sizing: border-box; } .layout-column > .flex-66, .layout-column > .flex-66 { flex: 1 1 66.66%; max-width: 100%; max-height: 66.66%; box-sizing: border-box; } .layout-row > .flex-55 { flex: 1 1 55%; max-width: 55%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-55 { flex: 1 1 55%; max-width: 100%; max-height: 55%; box-sizing: border-box; } .flex-60 { flex: 1 1 60%; max-width: 60%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-60 { flex: 1 1 60%; max-width: 60%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-60 { flex: 1 1 60%; max-width: 100%; max-height: 60%; box-sizing: border-box; } .layout-row > .flex-33, .layout-row > .flex-33 { flex: 1 1 33.33%; max-width: 33.33%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-66, .layout-row > .flex-66 { flex: 1 1 66.66%; max-width: 66.66%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-33, .layout-column > .flex-33 { flex: 1 1 33.33%; max-width: 100%; max-height: 33.33%; box-sizing: border-box; } .layout-column > .flex-66, .layout-column > .flex-66 { flex: 1 1 66.66%; max-width: 100%; max-height: 66.66%; box-sizing: border-box; } .layout-row > .flex-60 { flex: 1 1 60%; max-width: 60%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-60 { flex: 1 1 60%; max-width: 100%; max-height: 60%; box-sizing: border-box; } .flex-65 { flex: 1 1 65%; max-width: 65%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-65 { flex: 1 1 65%; max-width: 65%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-65 { flex: 1 1 65%; max-width: 100%; max-height: 65%; box-sizing: border-box; } .layout-row > .flex-33, .layout-row > .flex-33 { flex: 1 1 33.33%; max-width: 33.33%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-66, .layout-row > .flex-66 { flex: 1 1 66.66%; max-width: 66.66%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-33, .layout-column > .flex-33 { flex: 1 1 33.33%; max-width: 100%; max-height: 33.33%; box-sizing: border-box; } .layout-column > .flex-66, .layout-column > .flex-66 { flex: 1 1 66.66%; max-width: 100%; max-height: 66.66%; box-sizing: border-box; } .layout-row > .flex-65 { flex: 1 1 65%; max-width: 65%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-65 { flex: 1 1 65%; max-width: 100%; max-height: 65%; box-sizing: border-box; } .flex-70 { flex: 1 1 70%; max-width: 70%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-70 { flex: 1 1 70%; max-width: 70%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-70 { flex: 1 1 70%; max-width: 100%; max-height: 70%; box-sizing: border-box; } .layout-row > .flex-33, .layout-row > .flex-33 { flex: 1 1 33.33%; max-width: 33.33%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-66, .layout-row > .flex-66 { flex: 1 1 66.66%; max-width: 66.66%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-33, .layout-column > .flex-33 { flex: 1 1 33.33%; max-width: 100%; max-height: 33.33%; box-sizing: border-box; } .layout-column > .flex-66, .layout-column > .flex-66 { flex: 1 1 66.66%; max-width: 100%; max-height: 66.66%; box-sizing: border-box; } .layout-row > .flex-70 { flex: 1 1 70%; max-width: 70%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-70 { flex: 1 1 70%; max-width: 100%; max-height: 70%; box-sizing: border-box; } .flex-75 { flex: 1 1 75%; max-width: 75%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-75 { flex: 1 1 75%; max-width: 75%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-75 { flex: 1 1 75%; max-width: 100%; max-height: 75%; box-sizing: border-box; } .layout-row > .flex-33, .layout-row > .flex-33 { flex: 1 1 33.33%; max-width: 33.33%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-66, .layout-row > .flex-66 { flex: 1 1 66.66%; max-width: 66.66%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-33, .layout-column > .flex-33 { flex: 1 1 33.33%; max-width: 100%; max-height: 33.33%; box-sizing: border-box; } .layout-column > .flex-66, .layout-column > .flex-66 { flex: 1 1 66.66%; max-width: 100%; max-height: 66.66%; box-sizing: border-box; } .layout-row > .flex-75 { flex: 1 1 75%; max-width: 75%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-75 { flex: 1 1 75%; max-width: 100%; max-height: 75%; box-sizing: border-box; } .flex-80 { flex: 1 1 80%; max-width: 80%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-80 { flex: 1 1 80%; max-width: 80%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-80 { flex: 1 1 80%; max-width: 100%; max-height: 80%; box-sizing: border-box; } .layout-row > .flex-33, .layout-row > .flex-33 { flex: 1 1 33.33%; max-width: 33.33%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-66, .layout-row > .flex-66 { flex: 1 1 66.66%; max-width: 66.66%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-33, .layout-column > .flex-33 { flex: 1 1 33.33%; max-width: 100%; max-height: 33.33%; box-sizing: border-box; } .layout-column > .flex-66, .layout-column > .flex-66 { flex: 1 1 66.66%; max-width: 100%; max-height: 66.66%; box-sizing: border-box; } .layout-row > .flex-80 { flex: 1 1 80%; max-width: 80%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-80 { flex: 1 1 80%; max-width: 100%; max-height: 80%; box-sizing: border-box; } .flex-85 { flex: 1 1 85%; max-width: 85%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-85 { flex: 1 1 85%; max-width: 85%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-85 { flex: 1 1 85%; max-width: 100%; max-height: 85%; box-sizing: border-box; } .layout-row > .flex-33, .layout-row > .flex-33 { flex: 1 1 33.33%; max-width: 33.33%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-66, .layout-row > .flex-66 { flex: 1 1 66.66%; max-width: 66.66%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-33, .layout-column > .flex-33 { flex: 1 1 33.33%; max-width: 100%; max-height: 33.33%; box-sizing: border-box; } .layout-column > .flex-66, .layout-column > .flex-66 { flex: 1 1 66.66%; max-width: 100%; max-height: 66.66%; box-sizing: border-box; } .layout-row > .flex-85 { flex: 1 1 85%; max-width: 85%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-85 { flex: 1 1 85%; max-width: 100%; max-height: 85%; box-sizing: border-box; } .flex-90 { flex: 1 1 90%; max-width: 90%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-90 { flex: 1 1 90%; max-width: 90%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-90 { flex: 1 1 90%; max-width: 100%; max-height: 90%; box-sizing: border-box; } .layout-row > .flex-33, .layout-row > .flex-33 { flex: 1 1 33.33%; max-width: 33.33%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-66, .layout-row > .flex-66 { flex: 1 1 66.66%; max-width: 66.66%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-33, .layout-column > .flex-33 { flex: 1 1 33.33%; max-width: 100%; max-height: 33.33%; box-sizing: border-box; } .layout-column > .flex-66, .layout-column > .flex-66 { flex: 1 1 66.66%; max-width: 100%; max-height: 66.66%; box-sizing: border-box; } .layout-row > .flex-90 { flex: 1 1 90%; max-width: 90%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-90 { flex: 1 1 90%; max-width: 100%; max-height: 90%; box-sizing: border-box; } .flex-95 { flex: 1 1 95%; max-width: 95%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-95 { flex: 1 1 95%; max-width: 95%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-95 { flex: 1 1 95%; max-width: 100%; max-height: 95%; box-sizing: border-box; } .layout-row > .flex-33, .layout-row > .flex-33 { flex: 1 1 33.33%; max-width: 33.33%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-66, .layout-row > .flex-66 { flex: 1 1 66.66%; max-width: 66.66%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-33, .layout-column > .flex-33 { flex: 1 1 33.33%; max-width: 100%; max-height: 33.33%; box-sizing: border-box; } .layout-column > .flex-66, .layout-column > .flex-66 { flex: 1 1 66.66%; max-width: 100%; max-height: 66.66%; box-sizing: border-box; } .layout-row > .flex-95 { flex: 1 1 95%; max-width: 95%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-95 { flex: 1 1 95%; max-width: 100%; max-height: 95%; box-sizing: border-box; } .flex-100 { flex: 1 1 100%; max-width: 100%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-100 { flex: 1 1 100%; max-width: 100%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-100 { flex: 1 1 100%; max-width: 100%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-33, .layout-row > .flex-33 { flex: 1 1 33.33%; max-width: 33.33%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-66, .layout-row > .flex-66 { flex: 1 1 66.66%; max-width: 66.66%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-33, .layout-column > .flex-33 { flex: 1 1 33.33%; max-width: 100%; max-height: 33.33%; box-sizing: border-box; } .layout-column > .flex-66, .layout-column > .flex-66 { flex: 1 1 66.66%; max-width: 100%; max-height: 66.66%; box-sizing: border-box; } .layout-row > .flex-100 { flex: 1 1 100%; max-width: 100%; max-height: 100%; box-sizing: border-box; } .layout-column > .flex-100 { flex: 1 1 100%; max-width: 100%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-33, .layout-row > .flex-33 { flex: 1 1 33.33%; max-width: 33.33%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex-66, .layout-row > .flex-66 { flex: 1 1 66.66%; max-width: 66.66%; max-height: 100%; box-sizing: border-box; } .layout-row > .flex { min-width: 0; } .layout-column > .flex-33, .layout-column > .flex-33 { flex: 1 1 33.33%; max-width: 100%; max-height: 33.33%; box-sizing: border-box; } .layout-column > .flex-66, .layout-column > .flex-66 { flex: 1 1 66.66%; max-width: 100%; max-height: 66.66%; box-sizing: border-box; } .layout-column > .flex { min-height: 0; } .layout, .layout-column, .layout-row { box-sizing: border-box; display: -webkit-box; display: -webkit-flex; display: -moz-box; display: -ms-flexbox; display: flex; } .layout-column { flex-direction: column; } .layout-row { flex-direction: row; } .layout-padding-sm > *, .layout-padding > .flex-sm { padding: 4px; } .layout-padding, .layout-padding-gt-sm, .layout-padding-md, .layout-padding > *, .layout-padding-gt-sm > *, .layout-padding-md > *, .layout-padding > .flex, .layout-padding > .flex-gt-sm, .layout-padding > .flex-md { padding: 8px; } .layout-padding-gt-md > *, .layout-padding-lg > *, .layout-padding-gt-lg > *, .layout-padding > .flex-gt-md, .layout-padding > .flex-lg, .layout-padding > .flex-lg, .layout-padding > .flex-gt-lg { padding: 16px; } .layout-margin-sm > *, .layout-margin > .flex-sm { margin: 4px; } .layout-margin, .layout-margin-gt-sm, .layout-margin-md, .layout-margin > *, .layout-margin-gt-sm > *, .layout-margin-md > *, .layout-margin > .flex, .layout-margin > .flex-gt-sm, .layout-margin > .flex-md { margin: 8px; } .layout-margin-gt-md > *, .layout-margin-lg > *, .layout-margin-gt-lg > *, .layout-margin > .flex-gt-md, .layout-margin > .flex-lg, .layout-margin > .flex-gt-lg { margin: 16px; } .layout-wrap { flex-wrap: wrap; } .layout-nowrap { flex-wrap: nowrap; } .layout-fill { margin: 0; width: 100%; min-height: 100%; height: 100%; } .q-grid tbody tr.q-grid-scroll-mark { height: 0; border: none; } .q-grid ::-webkit-scrollbar { width: 8px; height: 8px; } .q-grid ::-webkit-scrollbar-thumb { height: 15px; background-color: #c8c8c8; -webkit-box-shadow: inset 1px 1px 0 rgba(0, 0, 0, 0.1), inset 0 -1px 0 rgba(0, 0, 0, 0.07); } .q-grid ::-webkit-scrollbar-button { width: 0; height: 0; display: none; } .q-grid ::-webkit-scrollbar-corner { background-color: transparent; } .q-grid ::-webkit-scrollbar-track, .q-grid ::-webkit-scrollbar-track-piece { background-color: #f8f8f8; } .q-grid.q-grid-box { height: 100%; min-height: 100%; max-height: 100%; transform: translate3d(0, 0, 0); } .q-grid td, .q-grid th { vertical-align: middle; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; position: relative; box-sizing: border-box; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; } .q-grid td > *, .q-grid th > * { vertical-align: middle; } .q-grid td.q-grid-pivot, .q-grid th.q-grid-pivot { text-align: center; } .q-grid.q-grid-box:not(.q-grid-drag) td, .q-grid.q-grid-box:not(.q-grid-drag) th { transition: min-width 0.3s, width 0.3s, max-width 0.3s; } .q-grid td .q-grid-box td, .q-grid td .q-grid-box th { transition: none !important; } .q-grid td .q-grid-box:not(.q-grid-drag) td, .q-grid td .q-grid-box:not(.q-grid-drag) th { transition: min-width 0.3s, width 0.3s, max-width 0.3s !important; } .q-grid thead th > div { overflow: hidden; text-overflow: ellipsis; outline: none; } .q-grid thead td, .q-grid thead th, .q-grid tfoot td, .q-grid tfoot th, .q-grid tbody td, .q-grid tbody th { width: 150px; min-width: 150px; max-width: 150px; } .q-grid thead td.q-grid-pad, .q-grid thead th.q-grid-pad, .q-grid tfoot td.q-grid-pad, .q-grid tfoot th.q-grid-pad, .q-grid tbody td.q-grid-pad, .q-grid tbody th.q-grid-pad { width: 100%; min-width: 100%; max-width: 100%; padding: 0 0 0 1px !important; margin: 0 !important; } .q-grid thead td.q-grid-group, .q-grid thead th.q-grid-group, .q-grid tfoot td.q-grid-group, .q-grid tfoot th.q-grid-group, .q-grid tbody td.q-grid-group, .q-grid tbody th.q-grid-group { width: 200px; min-width: 200px; max-width: 200px; } .q-grid thead td.q-grid-pivot, .q-grid thead th.q-grid-pivot, .q-grid tfoot td.q-grid-pivot, .q-grid tfoot th.q-grid-pivot, .q-grid tbody td.q-grid-pivot, .q-grid tbody th.q-grid-pivot { width: 80px; min-width: 80px; max-width: 80px; } .q-grid thead td.q-grid-email, .q-grid thead th.q-grid-email, .q-grid tfoot td.q-grid-email, .q-grid tfoot th.q-grid-email, .q-grid tbody td.q-grid-email, .q-grid tbody th.q-grid-email { width: 200px; min-width: 200px; max-width: 200px; } .q-grid thead td.q-grid-password, .q-grid thead th.q-grid-password, .q-grid tfoot td.q-grid-password, .q-grid tfoot th.q-grid-password, .q-grid tbody td.q-grid-password, .q-grid tbody th.q-grid-password { width: 100px; min-width: 100px; max-width: 100px; } .q-grid thead td.q-grid-bool, .q-grid thead th.q-grid-bool, .q-grid tfoot td.q-grid-bool, .q-grid tfoot th.q-grid-bool, .q-grid tbody td.q-grid-bool, .q-grid tbody th.q-grid-bool { width: 80px; min-width: 80px; max-width: 80px; } .q-grid thead td.q-grid-date, .q-grid thead th.q-grid-date, .q-grid tfoot td.q-grid-date, .q-grid tfoot th.q-grid-date, .q-grid tbody td.q-grid-date, .q-grid tbody th.q-grid-date { width: 120px; min-width: 110px; max-width: 110px; } .q-grid thead td.q-grid-number, .q-grid thead td.q-grid-currency, .q-grid thead td.q-grid-id, .q-grid thead th.q-grid-number, .q-grid thead th.q-grid-currency, .q-grid thead th.q-grid-id, .q-grid tfoot td.q-grid-number, .q-grid tfoot td.q-grid-currency, .q-grid tfoot td.q-grid-id, .q-grid tfoot th.q-grid-number, .q-grid tfoot th.q-grid-currency, .q-grid tfoot th.q-grid-id, .q-grid tbody td.q-grid-number, .q-grid tbody td.q-grid-currency, .q-grid tbody td.q-grid-id, .q-grid tbody th.q-grid-number, .q-grid tbody th.q-grid-currency, .q-grid tbody th.q-grid-id { width: 100px; min-width: 100px; max-width: 100px; } .q-grid thead td.q-grid-array, .q-grid thead th.q-grid-array, .q-grid tfoot td.q-grid-array, .q-grid tfoot th.q-grid-array, .q-grid tbody td.q-grid-array, .q-grid tbody th.q-grid-array { width: 250px; min-width: 250px; max-width: 250px; } .q-grid thead td.q-grid-row-indicator, .q-grid thead th.q-grid-row-indicator, .q-grid tfoot td.q-grid-row-indicator, .q-grid tfoot th.q-grid-row-indicator, .q-grid tbody td.q-grid-row-indicator, .q-grid tbody th.q-grid-row-indicator { width: 24px; min-width: 24px; max-width: 24px; text-overflow: initial; } .q-grid thead td.q-grid-row-options, .q-grid thead th.q-grid-row-options, .q-grid tfoot td.q-grid-row-options, .q-grid tfoot th.q-grid-row-options, .q-grid tbody td.q-grid-row-options, .q-grid tbody th.q-grid-row-options { width: 48px; min-width: 48px; max-width: 48px; text-overflow: initial; } .q-grid thead td.q-grid-row-expand, .q-grid thead th.q-grid-row-expand, .q-grid tfoot td.q-grid-row-expand, .q-grid tfoot th.q-grid-row-expand, .q-grid tbody td.q-grid-row-expand, .q-grid tbody th.q-grid-row-expand { width: 48px; min-width: 48px; max-width: 48px; } .q-grid thead td.q-grid-row-number, .q-grid thead th.q-grid-row-number, .q-grid tfoot td.q-grid-row-number, .q-grid tfoot th.q-grid-row-number, .q-grid tbody td.q-grid-row-number, .q-grid tbody th.q-grid-row-number { width: 56px; min-width: 56px; max-width: 56px; } .q-grid thead td.q-grid-select, .q-grid thead th.q-grid-select, .q-grid tfoot td.q-grid-select, .q-grid tfoot th.q-grid-select, .q-grid tbody td.q-grid-select, .q-grid tbody th.q-grid-select { width: 56px; min-width: 56px; max-width: 56px; text-overflow: initial; } .q-grid thead td.q-grid-image, .q-grid thead th.q-grid-image, .q-grid tfoot td.q-grid-image, .q-grid tfoot th.q-grid-image, .q-grid tbody td.q-grid-image, .q-grid tbody th.q-grid-image { width: 80px; min-width: 80px; max-width: 80px; } .q-grid tbody td.q-grid-number, .q-grid tbody td.q-grid-currency, .q-grid tfoot td.q-grid-number, .q-grid tfoot td.q-grid-currency { text-align: right; } .q-grid tbody td.q-grid-id, .q-grid tfoot td.q-grid-id { text-align: left; } .q-grid tbody td.q-grid-bool, .q-grid tbody td.q-grid-password, .q-grid tbody td.q-grid-select, .q-grid tfoot td.q-grid-bool, .q-grid tfoot td.q-grid-password, .q-grid tfoot td.q-grid-select { text-align: center; } .q-grid tbody td.q-grid-dropdown select, .q-grid tfoot td.q-grid-dropdown select { width: 100%; } .q-grid tbody td.q-grid-row-options, .q-grid tfoot td.q-grid-row-options { cursor: pointer; } .q-grid-can-drag { -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; -khtml-user-drag: element; -webkit-user-drag: element; } .q-grid.q-grid-box .q-grid-row-indicator .q-grid-can-drag { cursor: move; opacity: 0.4; } .q-grid.q-grid-box .q-grid-row-indicator .q-grid-can-drag .q-grid-icon { width: 16px; min-width: 16px; min-height: 16px; height: 16px; font-size: 16px; vertical-align: middle; } .q-grid tr.q-grid-drag { opacity: 0.5; } .q-grid td.q-grid-drag, .q-grid th.q-grid-drag { opacity: 0.5; } .q-grid.q-grid-box:not(.q-grid-drag) td.q-grid-focused { outline: 2px solid rgba(63, 81, 181, 0.25); outline-offset: -2px; } .q-grid.q-grid-box:not(.q-grid-drag) td.q-grid-focused.q-grid-animate { outline: none; } .q-grid .q-grid-view:not(.q-grid-active) td.q-grid-focused { outline-color: rgba(63, 81, 181, 0.05); } .q-grid .q-grid-cell-handler { transition: all 0.15s; position: absolute; pointer-events: none; outline: 2px solid rgba(63, 81, 181, 0.25); outline-offset: -2px; display: none; } .q-grid .q-grid-cell-handler.q-grid-active { display: block; } .q-grid .q-grid-marker { display: block; position: absolute; width: 10px; height: 10px; bottom: 5px; right: 5px; font-size: 14px; color: #C8C8C8; cursor: move; } .q-grid .q-grid-view .q-grid-layer { position: absolute; width: 100%; height: 100%; } .q-grid .q-grid-view .q-grid-layer:empty { pointer-events: none; } .q-grid th > .q-grid-resize-handler { top: 20%; bottom: 20%; right: 0; height: 60%; width: 4px; z-index: 2; background: transparent; position: absolute; border-right: 1px solid #e0e0e0; cursor: col-resize; opacity: 0; } .q-grid th.q-grid-highlighted .q-grid-resize-handler, .q-grid th.q-grid-highlighted-prev .q-grid-resize-handler { opacity: 1; } .q-grid td > .q-grid-can-drag > .q-grid-resize-handler { height: 2px; width: 100%; bottom: 0; left: 0; width: 100vh; position: absolute; cursor: row-resize; z-index: 2; pointer-events: all; } .q-grid.q-grid-box.q-grid-drag th > .q-grid-resize-handler { opacity: 0; } .q-grid .q-grid-table tbody, .q-grid .q-grid-table thead, .q-grid .q-grid-table tfoot { border-collapse: collapse; border-spacing: 0; } .q-grid .q-grid-table table { border-spacing: 0; overflow: hidden; table-layout: fixed; display: flex; flex-flow: column; height: 100%; width: 100%; outline: none; } .q-grid .q-grid-table table thead, .q-grid .q-grid-table table tfoot { /* head takes the height it requires, and it's not scaled when table is resized */ flex: 0 0 auto; width: calc(100% - 8px); overflow: hidden; } .q-grid .q-grid-table table tbody { /* body takes all the remaining available space */ flex: 1 1 auto; display: block; overflow-y: scroll; overflow-x: scroll; outline: none; overflow-anchor: none; } .q-grid .q-grid-table table tbody.q-grid-body-top { flex: none; overflow-x: hidden; } .q-grid .q-grid-table table tbody.q-grid-body-bottom { flex: none; } .q-grid .q-grid-table table tbody tr { width: 100%; display: table-row; table-layout: fixed; } .q-grid .q-grid-table table tbody tr.q-grid-align { height: 0 !important; border: 0; } .q-grid .q-grid-table table tbody tr.q-grid-align:last-child { display: initial; } .q-grid .q-grid-table.q-grid-table-left thead, .q-grid .q-grid-table.q-grid-table-left tfoot { width: 100%; } .q-grid .q-grid-with-right-pin > .q-grid-view > .q-grid-table.q-grid-table-center > table > thead, .q-grid .q-grid-with-right-pin > .q-grid-view > .q-grid-table.q-grid-table-center > table > tfoot { width: 100%; } .q-grid .q-grid-toolbar-left, .q-grid .q-grid-toolbar-right { max-width: 250px; overflow: auto; } .q-grid .q-grid-view { position: relative; overflow: hidden; } .q-grid .q-grid-view.q-grid-select-range thead td, .q-grid .q-grid-view.q-grid-select-range thead th, .q-grid .q-grid-view.q-grid-select-range tfoot td, .q-grid .q-grid-view.q-grid-select-range tfoot th, .q-grid .q-grid-view.q-grid-select-range tbody td, .q-grid .q-grid-view.q-grid-select-range tbody th { -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; cursor: default; } .q-grid .q-grid-view > .q-grid-table-left > table > tbody { overflow-y: hidden; } .q-grid .q-grid-with-right-pin > .q-grid-view > .q-grid-table-center > table > tbody { overflow-y: hidden; } .q-grid .q-grid-with-bottom-pin > .q-grid-view > .q-grid-table-center > table > tbody:not(.q-grid-body-bottom) { overflow-x: hidden; } "],
template: "<ng-container *ngComponentOutlet=\"themeComponent\"></ng-container> <q-grid-box class=\"q-grid-box layout-column\" q-grid-markup=\"box\"> <q-grid-core-toolbar position=\"top\" class=\"q-grid-toolbar q-grid-toolbar-top flex-auto\" *ngIf=\"visibility.toolbar.top\"> </q-grid-core-toolbar> <div class=\"flex-100 layout-row\" [ngClass]=\"{ 'q-grid-with-left-pin': visibility.pin.left, 'q-grid-with-right-pin': visibility.pin.right, 'q-grid-with-top-pin': visibility.pin.top, 'q-grid-with-bottom-pin': visibility.pin.bottom }\"> <q-grid-core-toolbar position=\"left\" class=\"q-grid-toolbar q-grid-toolbar-left flex-auto\" *ngIf=\"visibility.toolbar.left\"> </q-grid-core-toolbar> <q-grid-core-view class=\"q-grid-view layout-row flex\" q-grid-markup=\"view\"> </q-grid-core-view> <q-grid-core-toolbar position=\"right\" class=\"q-grid-toolbar q-grid-toolbar-right flex-auto\" *ngIf=\"visibility.toolbar.right\"> </q-grid-core-toolbar> </div> <q-grid-core-toolbar position=\"bottom\" class=\"q-grid-toolbar q-grid-toolbar-bottom flex-auto\" *ngIf=\"visibility.toolbar.bottom\"> </q-grid-core-toolbar> </q-grid-box>",
encapsulation: ViewEncapsulation.None
}] }];
/** @nocollapse */
GridComponent.ctorParameters = function () {
return [{ type: RootService }, { type: ElementRef }, { type: NgZone }, { type: LayerService }, { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT] }] }, { type: ThemeService }];
};
GridComponent.propDecorators = {
model: [{ type: Input }],
actionItems: [{ type: Input, args: ['actions'] }],
gridTitle: [{ type: Input, args: ['header'] }],
gridCaption: [{ type: Input, args: ['caption'] }],
gridInteractionMode: [{ type: Input, args: ['interactionMode'] }],
gridId: [{ type: Input, args: ['id'] }],
dataColumns: [{ type: Input, args: ['columns'] }],
dataPipe: [{ type: Input, args: ['pipe'] }],
dataRows: [{ type: Input, args: ['rows'] }],
editCancel: [{ type: Input }],
editCommit: [{ type: Input }],
editEnter: [{ type: Input }],
editMethod: [{ type: Input }],
editMode: [{ type: Input }],
editReset: [{ type: Input }],
filterFetch: [{ type: Input }],
filterUnit: [{ type: Input }],
groupBy: [{ type: Input }],
groupMode: [{ type: Input }],
groupSummary: [{ type: Input }],
pivotBy: [{ type: Input }],
selectionItems: [{ type: Input, args: ['selection'] }],
selectionArea: [{ type: Input }],
selectionKey: [{ type: Input }],
selectionMode: [{ type: Input }],
selectionUnit: [{ type: Input }],
scrollMode: [{ type: Input }],
sortBy: [{ type: Input }],
sortMode: [{ type: Input }],
sortTrigger: [{ type: Input }],
styleCell: [{ type: Input }],
styleRow: [{ type: Input }],
selectionChanged: [{ type: Output }]
};
function GridComponent_tsickle_Closure_declarations() {
/** @type {?} */
GridComponent.prototype.model;
/** @type {?} */
GridComponent.prototype.actionItems;
/** @type {?} */
GridComponent.prototype.gridTitle;
/** @type {?} */
GridComponent.prototype.gridCaption;
/** @type {?} */
GridComponent.prototype.gridInteractionMode;
/** @type {?} */
GridComponent.prototype.gridId;
/** @type {?} */
GridComponent.prototype.dataColumns;
/** @type {?} */
GridComponent.prototype.dataPipe;
/** @type {?} */
GridComponent.prototype.dataRows;
/** @type {?} */
GridComponent.prototype.editCancel;
/** @type {?} */
GridComponent.prototype.editCommit;
/** @type {?} */
GridComponent.prototype.editEnter;
/** @type {?} */
GridComponent.prototype.editMethod;
/** @type {?} */
GridComponent.prototype.editMode;
/** @type {?} */
GridComponent.prototype.editReset;
/** @type {?} */
GridComponent.prototype.filterFetch;
/** @type {?} */
GridComponent.prototype.filterUnit;
/** @type {?} */
GridComponent.prototype.groupBy;
/** @type {?} */
GridComponent.prototype.groupMode;
/** @type {?} */
GridComponent.prototype.groupSummary;
/** @type {?} */
GridComponent.prototype.pivotBy;
/** @type {?} */
GridComponent.prototype.selectionItems;
/** @type {?} */
GridComponent.prototype.selectionArea;
/** @type {?} */
GridComponent.prototype.selectionKey;
/** @type {?} */
GridComponent.prototype.selectionMode;
/** @type {?} */
GridComponent.prototype.selectionUnit;
/** @type {?} */
GridComponent.prototype.scrollMode;
/** @type {?} */
GridComponent.prototype.sortBy;
/** @type {?} */
GridComponent.prototype.sortMode;
/** @type {?} */
GridComponent.prototype.sortTrigger;
/** @type {?} */
GridComponent.prototype.styleCell;
/** @type {?} */
GridComponent.prototype.styleRow;
/** @type {?} */
GridComponent.prototype.selectionChanged;
/** @type {?} */
GridComponent.prototype.themeComponent;
/** @type {?} */
GridComponent.prototype.root;
/** @type {?} */
GridComponent.prototype.element;
/** @type {?} */
GridComponent.prototype.zone;
/** @type {?} */
GridComponent.prototype.layerService;
/** @type {?} */
GridComponent.prototype.document;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var TemplateHostService = function TemplateHostService() {
classCallCheck(this, TemplateHostService);
this.key = identity$1;
};
TemplateHostService.decorators = [{ type: Injectable }];
function TemplateHostService_tsickle_Closure_declarations() {
/** @type {?} */
TemplateHostService.prototype.key;
}
var ColumnListCtrl = function () {
function ColumnListCtrl(model, canCopy, parseFactory$$1) {
classCallCheck(this, ColumnListCtrl);
this.model = model;
this.canCopy = canCopy;
this.parseFactory = parseFactory$$1;
}
createClass(ColumnListCtrl, [{
key: 'generateKey',
value: function generateKey(source) {
if (!isUndefined(source.editor)) {
return '$default.' + source.editor;
}
if (!isUndefined(source.type)) {
return '$default.' + source.type;
}
return '$default';
}
}, {
key: 'copy',
value: function copy(target, source) {
var canCopy = this.canCopy;
var parseFactory$$1 = this.parseFactory;
Object.keys(source).filter(function (key) {
return canCopy(key, source, target);
}).forEach(function (key) {
var sourceValue = source[key];
var accessor = compile(key);
var targetValue = accessor(target);
var targetType = getType(targetValue);
var sourceType = getType(sourceValue);
var value = sourceValue;
if (targetValue !== null && !isUndefined(targetValue)) {
var parse = parseFactory$$1(targetType);
var typedValue = parse(sourceValue, targetValue);
if (typedValue !== null) {
value = typedValue;
}
}
accessor(target, value);
});
}
}, {
key: 'add',
value: function add(column) {
var columnList = this.model.columnList;
var columns = columnList().columns.concat([column]);
columnList({ columns: columns }, {
source: 'column.list.ctrl',
behavior: 'core'
});
}
}, {
key: 'register',
value: function register(column) {
var columnList = this.model.columnList;
var reference = clone(columnList().reference);
reference[column.type || '$default'] = column;
columnList({ reference: reference }, {
source: 'column.list.ctrl',
behavior: 'core'
});
}
}, {
key: 'extract',
value: function extract(key, type) {
var model = this.model;
var createColumn = columnFactory(model);
var column = find$1(model.columnList().line, key);
if (column) {
createColumn(type, column);
} else {
column = createColumn(type || 'text').model;
column.key = key;
column.source = 'template';
}
return column;
}
}, {
key: 'delete',
value: function _delete(key) {
var _model = this.model,
data = _model.data,
columnList = _model.columnList;
var htmlColumns = columnList().columns;
var index = findIndex(htmlColumns, key);
if (index >= 0) {
var columns = Array.from(htmlColumns);
columns.splice(index, 1);
columnList({ columns: columns }, { source: 'column.list.ctrl', behavior: 'core' });
}
var dataColumns = Array.from(data().columns);
var line = findLine(dataColumns, key);
if (line) {
line.columns.splice(line.index, 1);
// trigger columns pipe unit
data({ columns: dataColumns }, { source: 'column.list.ctrl' });
}
}
}]);
return ColumnListCtrl;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var ColumnListService = function () {
/**
* @param {?} root
*/
function ColumnListService(root) {
classCallCheck(this, ColumnListService);
this.root = root;
}
/**
* @param {?} column
* @return {?}
*/
createClass(ColumnListService, [{
key: 'add',
value: function add(column) {
this.ctrl.add(column);
}
/**
* @param {?} target
* @param {?} source
* @return {?}
*/
}, {
key: 'copy',
value: function copy(target, source) {
this.ctrl.copy(target, source);
}
/**
* @param {?} source
* @return {?}
*/
}, {
key: 'generateKey',
value: function generateKey(source) {
return this.ctrl.generateKey(source);
}
/**
* @param {?} key
* @param {?} type
* @return {?}
*/
}, {
key: 'extract',
value: function extract(key, type) {
return this.ctrl.extract(key, type);
}
/**
* @param {?} column
* @return {?}
*/
}, {
key: 'register',
value: function register(column) {
this.ctrl.register(column);
}
/**
* @param {?} key
* @return {?}
*/
}, {
key: 'delete',
value: function _delete(key) {
this.ctrl.delete(key);
}
/**
* @return {?}
*/
}, {
key: 'ctrl',
get: function get$$1() {
if (this._ctrl) {
return this._ctrl;
}
var /** @type {?} */canCopy = function canCopy(key, source, target) {
return target.hasOwnProperty(key) && !isUndefined(source[key]);
};
this._ctrl = new ColumnListCtrl(this.root.model, canCopy, parseFactory);
return this._ctrl;
}
}]);
return ColumnListService;
}();
ColumnListService.decorators = [{ type: Injectable }];
/** @nocollapse */
ColumnListService.ctorParameters = function () {
return [{ type: RootService }];
};
function ColumnListService_tsickle_Closure_declarations() {
/** @type {?} */
ColumnListService.prototype._ctrl;
/** @type {?} */
ColumnListService.prototype.root;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var ColumnService = function ColumnService() {
classCallCheck(this, ColumnService);
};
ColumnService.decorators = [{ type: Injectable }];
function ColumnService_tsickle_Closure_declarations() {
/** @type {?} */
ColumnService.prototype.column;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var ColumnComponent = function () {
/**
* @param {?} columnList
* @param {?} templateHost
* @param {?} parent
* @param {?} service
* @param {?} element
*/
function ColumnComponent(columnList, templateHost, parent, service, element) {
classCallCheck(this, ColumnComponent);
this.columnList = columnList;
this.templateHost = templateHost;
this.parent = parent;
this.service = service;
this.element = element;
}
/**
* @return {?}
*/
createClass(ColumnComponent, [{
key: 'ngOnInit',
value: function ngOnInit() {
var _this = this;
var /** @type {?} */withKey = !isUndefined(this.key);
var /** @type {?} */withType = !isUndefined(this.type);
// We want to update model when ngOntInit is triggered and not in afterViewInit
// so we apply dirty hack to understand if column is cohort or not.
var /** @type {?} */element = /** @type {?} */this.element.nativeElement;
if (element.children.length && element.children.item(0).tagName === 'Q-GRID-COLUMN') {
this.type = 'cohort';
if (!withKey) {
this.key = '$cohort-' + (this.title || guid());
}
withKey = true;
withType = true;
}
if (!withKey) {
this.key = this.columnList.generateKey(this);
}
var /** @type {?} */column = this.columnList.extract(this.key, this.type);
this.columnList.copy(column, this);
this.templateHost.key = function (source) {
var /** @type {?} */parts = [source, 'cell'];
if (withType) {
parts.push(_this.type);
}
if (withKey) {
parts.push('the-' + _this.key);
}
return parts.join('-') + '.tpl.html';
};
if (withKey) {
if (this.parent) {
this.parent.column.children.push(column);
} else {
this.columnList.add(column);
}
this.service.column = column;
} else {
var /** @type {?} */settings = Object.keys(this).filter(function (key) {
return !isUndefined(_this[key]) && column.hasOwnProperty(key);
}).reduce(function (memo, key) {
memo[key] = column[key];
return memo;
}, {});
this.columnList.register(settings);
}
}
/**
* @return {?}
*/
}, {
key: 'ngOnDestroy',
value: function ngOnDestroy() {
var column = this.service.column;
if (column && column.source === 'template') {
this.columnList.delete(column.key);
}
}
}]);
return ColumnComponent;
}();
ColumnComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-column',
template: '<ng-content></ng-content>',
providers: [TemplateHostService, ColumnService],
changeDetection: ChangeDetectionStrategy.OnPush
}] }];
/** @nocollapse */
ColumnComponent.ctorParameters = function () {
return [{ type: ColumnListService }, { type: TemplateHostService }, { type: ColumnService, decorators: [{ type: SkipSelf }, { type: Optional }] }, { type: ColumnService }, { type: ElementRef }];
};
ColumnComponent.propDecorators = {
type: [{ type: Input }],
key: [{ type: Input }],
class: [{ type: Input }],
title: [{ type: Input }],
pin: [{ type: Input }],
aggregation: [{ type: Input }],
aggregationOptions: [{ type: Input }],
editor: [{ type: Input }],
editorOptions: [{ type: Input }],
format: [{ type: Input }],
symbol: [{ type: Input }],
code: [{ type: Input }],
width: [{ type: Input }],
widthMode: [{ type: Input }],
minWidth: [{ type: Input }],
maxWidth: [{ type: Input }],
viewWidth: [{ type: Input }],
offset: [{ type: Input }],
canEdit: [{ type: Input }],
canResize: [{ type: Input }],
canSort: [{ type: Input }],
canMove: [{ type: Input }],
canFilter: [{ type: Input }],
canHighlight: [{ type: Input }],
canFocus: [{ type: Input }],
isVisible: [{ type: Input }],
index: [{ type: Input }],
label: [{ type: Input }],
labelPath: [{ type: Input }],
itemLabel: [{ type: Input }],
itemFormat: [{ type: Input }],
itemType: [{ type: Input }],
value: [{ type: Input }],
path: [{ type: Input }],
compare: [{ type: Input }],
trueValue: [{ type: Input }],
falseValue: [{ type: Input }],
maxLength: [{ type: Input }]
};
function ColumnComponent_tsickle_Closure_declarations() {
/** @type {?} */
ColumnComponent.prototype.type;
/** @type {?} */
ColumnComponent.prototype.key;
/** @type {?} */
ColumnComponent.prototype.class;
/** @type {?} */
ColumnComponent.prototype.title;
/** @type {?} */
ColumnComponent.prototype.pin;
/** @type {?} */
ColumnComponent.prototype.aggregation;
/** @type {?} */
ColumnComponent.prototype.aggregationOptions;
/** @type {?} */
ColumnComponent.prototype.editor;
/** @type {?} */
ColumnComponent.prototype.editorOptions;
/** @type {?} */
ColumnComponent.prototype.format;
/** @type {?} */
ColumnComponent.prototype.symbol;
/** @type {?} */
ColumnComponent.prototype.code;
/** @type {?} */
ColumnComponent.prototype.width;
/** @type {?} */
ColumnComponent.prototype.widthMode;
/** @type {?} */
ColumnComponent.prototype.minWidth;
/** @type {?} */
ColumnComponent.prototype.maxWidth;
/** @type {?} */
ColumnComponent.prototype.viewWidth;
/** @type {?} */
ColumnComponent.prototype.offset;
/** @type {?} */
ColumnComponent.prototype.canEdit;
/** @type {?} */
ColumnComponent.prototype.canResize;
/** @type {?} */
ColumnComponent.prototype.canSort;
/** @type {?} */
ColumnComponent.prototype.canMove;
/** @type {?} */
ColumnComponent.prototype.canFilter;
/** @type {?} */
ColumnComponent.prototype.canHighlight;
/** @type {?} */
ColumnComponent.prototype.canFocus;
/** @type {?} */
ColumnComponent.prototype.isVisible;
/** @type {?} */
ColumnComponent.prototype.index;
/** @type {?} */
ColumnComponent.prototype.label;
/** @type {?} */
ColumnComponent.prototype.labelPath;
/** @type {?} */
ColumnComponent.prototype.itemLabel;
/** @type {?} */
ColumnComponent.prototype.itemFormat;
/** @type {?} */
ColumnComponent.prototype.itemType;
/** @type {?} */
ColumnComponent.prototype.value;
/** @type {?} */
ColumnComponent.prototype.path;
/** @type {?} */
ColumnComponent.prototype.compare;
/** @type {?} */
ColumnComponent.prototype.trueValue;
/** @type {?} */
ColumnComponent.prototype.falseValue;
/** @type {?} */
ColumnComponent.prototype.maxLength;
/** @type {?} */
ColumnComponent.prototype.columnList;
/** @type {?} */
ColumnComponent.prototype.templateHost;
/** @type {?} */
ColumnComponent.prototype.parent;
/** @type {?} */
ColumnComponent.prototype.service;
/** @type {?} */
ColumnComponent.prototype.element;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var ModelComponent = function (_NgComponent) {
inherits(ModelComponent, _NgComponent);
/**
* @param {?} root
*/
function ModelComponent(root) {
classCallCheck(this, ModelComponent);
var _this = possibleConstructorReturn(this, (ModelComponent.__proto__ || Object.getPrototypeOf(ModelComponent)).call(this));
_this.root = root;
_this.binder = new ModelBinder(_this);
_this.commit = noop$1;
_this.models = [];
return _this;
}
/**
* @return {?}
*/
createClass(ModelComponent, [{
key: 'setup',
value: function setup() {
return this.binder.bound(this.model, this.models, false);
}
/**
* @return {?}
*/
}, {
key: 'ngOnInit',
value: function ngOnInit() {
this.commit = this.setup();
this.commit();
}
/**
* @param {?} changes
* @return {?}
*/
}, {
key: 'ngOnChanges',
value: function ngOnChanges(changes) {
this.commit();
}
/**
* @return {?}
*/
}, {
key: 'ngOnDestroy',
value: function ngOnDestroy() {
get(ModelComponent.prototype.__proto__ || Object.getPrototypeOf(ModelComponent.prototype), 'ngOnDestroy', this).call(this);
this.binder.dispose();
}
/**
* @return {?}
*/
}, {
key: 'model',
get: function get$$1() {
return this.root.model;
}
}]);
return ModelComponent;
}(NgComponent);
function ModelComponent_tsickle_Closure_declarations() {
/** @type {?} */
ModelComponent.prototype.binder;
/** @type {?} */
ModelComponent.prototype.commit;
/** @type {?} */
ModelComponent.prototype.models;
/** @type {?} */
ModelComponent.prototype.root;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var ColumnListComponent = function (_ModelComponent) {
inherits(ColumnListComponent, _ModelComponent);
/**
* @param {?} root
*/
function ColumnListComponent(root) {
classCallCheck(this, ColumnListComponent);
var _this = possibleConstructorReturn(this, (ColumnListComponent.__proto__ || Object.getPrototypeOf(ColumnListComponent)).call(this, root));
_this.columnListGeneration = null;
_this.models = ['columnList'];
return _this;
}
return ColumnListComponent;
}(ModelComponent);
ColumnListComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-columns',
template: '<ng-content></ng-content>',
providers: [ColumnListService],
changeDetection: ChangeDetectionStrategy.OnPush
}] }];
/** @nocollapse */
ColumnListComponent.ctorParameters = function () {
return [{ type: RootService }];
};
ColumnListComponent.propDecorators = {
columnListGeneration: [{ type: Input, args: ['generation'] }]
};
function ColumnListComponent_tsickle_Closure_declarations() {
/** @type {?} */
ColumnListComponent.prototype.columnListGeneration;
}
var BoxCtrl = function BoxCtrl(model, element) {
classCallCheck(this, BoxCtrl);
element.classList.add(GRID_PREFIX);
model.dragChanged.watch(function (e) {
if (e.hasChanges('isActive')) {
if (model.drag().isActive) {
element.classList.add(GRID_PREFIX + '-drag');
} else {
element.classList.remove(GRID_PREFIX + '-drag');
}
}
});
};
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var BoxComponent = function (_NgComponent) {
inherits(BoxComponent, _NgComponent);
/**
* @param {?} root
* @param {?} element
* @param {?} theme
*/
function BoxComponent(root, element, theme) {
classCallCheck(this, BoxComponent);
var _this = possibleConstructorReturn(this, (BoxComponent.__proto__ || Object.getPrototypeOf(BoxComponent)).call(this));
_this.root = root;
_this.element = element;
_this.theme = theme;
_this.boxModel = null;
return _this;
}
/**
* @return {?}
*/
createClass(BoxComponent, [{
key: 'ngOnInit',
value: function ngOnInit() {
var /** @type {?} */ctrl = new BoxCtrl(this.model, this.element.nativeElement);
this.initTheme();
}
/**
* @return {?}
*/
}, {
key: 'initTheme',
value: function initTheme() {
var _this2 = this;
var /** @type {?} */element = this.element.nativeElement;
this.using(this.theme.changed.watch(function (e) {
if (e) {
element.classList.remove(GRID_PREFIX + '-theme-' + e.oldValue);
}
element.classList.add(GRID_PREFIX + '-theme-' + _this2.theme.name);
}));
}
/**
* @return {?}
*/
}, {
key: 'model',
get: function get$$1() {
var /** @type {?} */model = this.boxModel || this.root && this.root.model;
Guard.notNull(model, 'model');
return model;
}
}]);
return BoxComponent;
}(NgComponent);
BoxComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-box',
template: '<ng-content></ng-content>'
}] }];
/** @nocollapse */
BoxComponent.ctorParameters = function () {
return [{ type: RootService, decorators: [{ type: Optional }] }, { type: ElementRef }, { type: ThemeService }];
};
BoxComponent.propDecorators = {
boxModel: [{ type: Input, args: ['model'] }]
};
function BoxComponent_tsickle_Closure_declarations() {
/** @type {?} */
BoxComponent.prototype.boxModel;
/** @type {?} */
BoxComponent.prototype.root;
/** @type {?} */
BoxComponent.prototype.element;
/** @type {?} */
BoxComponent.prototype.theme;
}
var NO_BUTTON = 0;
var LEFT_BUTTON = 1;
var MIDDLE_BUTTON = 2;
var RIGHT_BUTTON = 3;
function checkButtonCode(event, code) {
return getButtonCode(event) === code;
}
function getButtonCode(event) {
return event.which;
}
var VERTICAL_SCROLL_CLASS = GRID_PREFIX + '-scroll-vertical';
var HORIZONTAL_SCROLL_CLASS = GRID_PREFIX + '-scroll-horizontal';
var BodyCtrl = function () {
function BodyCtrl(model, view, table, bag) {
classCallCheck(this, BodyCtrl);
this.model = model;
this.view = view;
this.bag = bag;
this.table = table;
this.rangeStartCell = null;
this.scrollingJob = jobLine(100);
}
createClass(BodyCtrl, [{
key: 'onScroll',
value: function onScroll(e) {
var scroll = this.model.scroll;
var oldValue = scroll();
var newValue = {};
var hasChanges = false;
if (oldValue.top !== e.scrollTop) {
this.table.view.addClass(VERTICAL_SCROLL_CLASS);
newValue.top = e.scrollTop;
hasChanges = true;
}
if (oldValue.left !== e.scrollLeft) {
this.table.view.addClass(HORIZONTAL_SCROLL_CLASS);
newValue.left = e.scrollLeft;
hasChanges = true;
}
if (hasChanges) {
scroll(newValue, {
source: 'body.core',
behavior: 'core'
});
}
this.scrollingJob(this.onScrollEnd.bind(this));
}
}, {
key: 'onScrollEnd',
value: function onScrollEnd() {
this.table.view.removeClass(VERTICAL_SCROLL_CLASS);
this.table.view.removeClass(HORIZONTAL_SCROLL_CLASS);
}
}, {
key: 'onWheel',
value: function onWheel(e) {
if (e.shiftKey) {
return;
}
var model = this.model,
table = this.table;
if (model.edit().state === 'view') {
var scroll = model.scroll;
var upper = 0;
Fastdom.measure(function () {
var lower = table.view.scrollHeight() - table.view.height();
var top = Math.min(lower, Math.max(upper, scroll().top + e.deltaY));
scroll({ top: top }, { source: 'body.core' });
});
}
}
}, {
key: 'onMouseDown',
value: function onMouseDown(e) {
if (checkButtonCode(e, LEFT_BUTTON)) {
var _selection = this.selection,
area = _selection.area,
mode = _selection.mode;
if (area !== 'body') {
return;
}
var pathFinder = new PathService(this.bag.body);
var cell = pathFinder.cell(eventPath(e));
if (mode === 'range') {
this.rangeStartCell = cell;
if (this.rangeStartCell) {
this.view.selection.selectRange(this.rangeStartCell, null, 'body');
}
}
}
}
}, {
key: 'onMouseMove',
value: function onMouseMove(e) {
var pathFinder = new PathService(this.bag.body);
var td = pathFinder.cell(eventPath(e));
if (td) {
var highlight = this.view.highlight;
var _model$highlight = this.model.highlight(),
rows = _model$highlight.rows,
cell = _model$highlight.cell;
if (cell) {
highlight.cell.execute(cell, false);
}
var newCell = {
rowIndex: td.rowIndex,
columnIndex: td.columnIndex
};
if (highlight.cell.canExecute(newCell)) {
highlight.cell.execute(newCell, true);
}
var tr = pathFinder.row(eventPath(e));
if (tr) {
var index = tr.index;
if (highlight.row.canExecute(index)) {
rows.filter(function (i) {
return i !== index;
}).forEach(function (i) {
return highlight.row.execute(i, false);
});
highlight.row.execute(index, true);
}
}
}
if (this.selection.mode === 'range') {
var startCell = this.rangeStartCell;
var endCell = td;
if (startCell && endCell) {
this.navigate(endCell);
this.view.selection.selectRange(startCell, endCell, 'body');
}
}
}
}, {
key: 'onMouseLeave',
value: function onMouseLeave() {
var highlight = this.view.highlight;
var _model$highlight2 = this.model.highlight(),
rows = _model$highlight2.rows,
cell = _model$highlight2.cell;
rows.forEach(function (rowIndex) {
return highlight.row.execute(rowIndex, false);
});
if (cell) {
highlight.cell.execute(null, false);
}
}
}, {
key: 'onMouseUp',
value: function onMouseUp(e) {
var mode = this.selection.mode;
var edit = this.model.edit;
if (checkButtonCode(e, LEFT_BUTTON)) {
var pathFinder = new PathService(this.bag.body);
var cell = pathFinder.cell(eventPath(e));
if (mode === 'range') {
this.rangeStartCell = null;
}
if (edit().state === 'startBatch') {
edit({ state: 'endBatch' }, { source: 'body.ctrl' });
return;
}
if (cell) {
this.select(cell);
this.navigate(cell);
if (this.view.edit.cell.enter.canExecute(cell)) {
if (this.selection.items.length > 1) {
return;
}
this.view.edit.cell.enter.execute(cell);
}
}
}
}
}, {
key: 'select',
value: function select(cell) {
var _selection2 = this.selection,
area = _selection2.area,
mode = _selection2.mode,
unit = _selection2.unit;
if (cell.column.type !== 'select' && (area !== 'body' || mode === 'range')) {
return;
}
var model = this.model;
var editMode = model.edit().mode;
switch (unit) {
case 'row':
{
if (cell.column.type === 'select' && cell.column.editorOptions.trigger === 'focus') {
var focusState = model.focus();
if (focusState.rowIndex !== cell.rowIndex || focusState.columnIndex !== cell.columnIndex) {
this.view.selection.toggleRow.execute(cell.row, 'body');
}
} else if (!editMode && cell.column.class !== 'control') {
this.view.selection.toggleRow.execute(cell.row, 'body');
}
break;
}
case 'column':
{
if (!editMode) {
this.view.selection.toggleColumn.execute(cell.column, 'body');
}
break;
}
case 'mix':
{
if (cell.column.type === 'row-indicator') {
this.view.selection.toggleCell.execute(cell, 'body');
}
}
}
}
}, {
key: 'navigate',
value: function navigate(cell) {
var focus = this.view.nav.focus;
if (focus.canExecute(cell)) {
focus.execute(cell);
}
}
}, {
key: 'selection',
get: function get$$1() {
return this.model.selection();
}
}]);
return BodyCtrl;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var TableCoreService = function TableCoreService() {
classCallCheck(this, TableCoreService);
};
TableCoreService.decorators = [{ type: Injectable }];
/** @nocollapse */
TableCoreService.ctorParameters = function () {
return [];
};
function TableCoreService_tsickle_Closure_declarations() {
/** @type {?} */
TableCoreService.prototype.pin;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var BodyCoreComponent = function (_NgComponent) {
inherits(BodyCoreComponent, _NgComponent);
/**
* @param {?} element
* @param {?} $view
* @param {?} $table
* @param {?} root
* @param {?} zone
* @param {?} cd
*/
function BodyCoreComponent(element, $view, $table, root, zone, cd) {
classCallCheck(this, BodyCoreComponent);
var _this = possibleConstructorReturn(this, (BodyCoreComponent.__proto__ || Object.getPrototypeOf(BodyCoreComponent)).call(this));
_this.element = element;
_this.$view = $view;
_this.$table = $table;
_this.root = root;
_this.zone = zone;
_this.cd = cd;
_this.pin = 'body';
return _this;
}
/**
* @return {?}
*/
createClass(BodyCoreComponent, [{
key: 'ngOnInit',
value: function ngOnInit() {
var _this2 = this;
var /** @type {?} */view = this.$view;
var /** @type {?} */element = /** @type {?} */this.element.nativeElement;
var model = this.root.model;
var /** @type {?} */table = this.$table;
var /** @type {?} */ctrl = new BodyCtrl(model, view, this.root.table, this.root.bag);
var /** @type {?} */listener = new EventListener(element, new EventManager(this));
this.zone.runOutsideAngular(function () {
listener.on('wheel', function (e) {
return ctrl.onWheel(e);
});
listener.on('scroll', function () {
return ctrl.onScroll({
scrollLeft: table.pin ? model.scroll().left : element.scrollLeft,
scrollTop: element.scrollTop
});
}, { passive: true });
listener.on('mousemove', ctrl.onMouseMove.bind(ctrl));
listener.on('mouseleave', ctrl.onMouseLeave.bind(ctrl));
});
listener.on('mousedown', ctrl.onMouseDown.bind(ctrl));
listener.on('mouseup', ctrl.onMouseUp.bind(ctrl));
var _model$data = model.data(),
id = _model$data.id;
this.rowId = id.row;
this.columnId = function (index, columnView) {
return id.column(index, columnView.model);
};
model.dataChanged.watch(function (e) {
if (e.hasChanges('id')) {
_this2.rowId = e.state.id.row;
var /** @type {?} */columnId = e.state.id.column;
_this2.columnId = function (index, columnView) {
return columnId(index, columnView.model);
};
}
});
model.sceneChanged.watch(function (e) {
if (model.grid().interactionMode === 'detached') {
if (e.hasChanges('status')) {
switch (e.state.status) {
case 'stop':
_this2.cd.detach();
break;
case 'start':
_this2.cd.reattach();
break;
}
}
}
});
}
/**
* @return {?}
*/
}, {
key: 'virtualRowId',
/**
* @param {?} index
* @return {?}
*/
value: function virtualRowId(index) {
return index;
}
}, {
key: 'selection',
get: function get$$1() {
return this.model.selection();
}
/**
* @return {?}
*/
}, {
key: 'model',
get: function get$$1() {
return this.root.model;
}
}]);
return BodyCoreComponent;
}(NgComponent);
BodyCoreComponent.decorators = [{ type: Component, args: [{
selector: 'tbody[q-grid-core-body]',
template: "<ng-container [ngSwitch]=\"$view.scroll.mode === 'virtual' && pin === 'body'\"> <ng-container *ngSwitchCase=\"true\"> <tr q-grid-vscroll-mark=\"top\" class=\"q-grid-scroll-mark\"> </tr> <tr class=\"q-grid-align\"> <td *ngFor=\"let $column of $view.body.columns($table.pin); trackBy: columnId\" [q-grid-core-td-align]=\"$column\"> </td> </tr> <tr *ngFor=\"let $row of $view.body.render.rows[pin] | qGridVscroll: $view.scroll.y; index as $vscrollIndex; viewIndex as $rowIndex; trackBy: virtualRowId\" [q-grid-core-tr]=\"$row\" [q-grid-core-index]=\"$vscrollIndex\" [q-grid-vscroll-row]=\"$vscrollIndex\" q-grid-core-source=\"body\"> <td *ngFor=\"let $column of $view.body.render.columns($row, $table.pin, $rowIndex); index as $columnIndex; trackBy: columnId\" [attr.rowspan]=\"$view.body.render.rowspan($row, $column, $rowIndex, $columnIndex)\" [attr.colspan]=\"$view.body.render.colspan($row, $column, $rowIndex, $columnIndex)\"> <ng-container [q-grid-core-td]=\"$column\"> </ng-container> </td> </tr> <tr q-grid-vscroll-mark=\"bottom\" class=\"q-grid-scroll-mark\"> </tr> </ng-container> <ng-container *ngSwitchDefault> <tr class=\"q-grid-align\"> <td *ngFor=\"let $column of $view.body.columns($table.pin); trackBy: columnId\" [q-grid-core-td-align]=\"$column\"> </td> </tr> <tr *ngFor=\"let $row of $view.body.render.rows[pin]; index as $rowIndex; trackBy: rowId\" [q-grid-core-tr]=\"$row\" [q-grid-core-index]=\"$rowIndex\" q-grid-core-source=\"body\"> <td *ngFor=\"let $column of $view.body.render.columns($row, $table.pin, $rowIndex); index as $columnIndex; trackBy: columnId\" [attr.rowspan]=\"$view.body.render.rowspan($row, $column, $rowIndex, $columnIndex)\" [attr.colspan]=\"$view.body.render.colspan($row, $column, $rowIndex, $columnIndex)\"> <ng-container [q-grid-core-td]=\"$column\"> </ng-container> </td> </tr> </ng-container> </ng-container>"
}] }];
/** @nocollapse */
BodyCoreComponent.ctorParameters = function () {
return [{ type: ElementRef }, { type: ViewCoreService }, { type: TableCoreService }, { type: RootService }, { type: NgZone }, { type: ChangeDetectorRef }];
};
BodyCoreComponent.propDecorators = {
pin: [{ type: Input }]
};
function BodyCoreComponent_tsickle_Closure_declarations() {
/** @type {?} */
BodyCoreComponent.prototype.pin;
/** @type {?} */
BodyCoreComponent.prototype.columnId;
/** @type {?} */
BodyCoreComponent.prototype.rowId;
/** @type {?} */
BodyCoreComponent.prototype.element;
/** @type {?} */
BodyCoreComponent.prototype.$view;
/** @type {?} */
BodyCoreComponent.prototype.$table;
/** @type {?} */
BodyCoreComponent.prototype.root;
/** @type {?} */
BodyCoreComponent.prototype.zone;
/** @type {?} */
BodyCoreComponent.prototype.cd;
}
var EditService = function () {
function EditService(model, table) {
classCallCheck(this, EditService);
this.model = model;
this.table = table;
}
createClass(EditService, [{
key: 'doBatch',
value: function doBatch(startCell) {
var table = this.table,
model = this.model;
var _model$view = model.view(),
rows = _model$view.rows,
columns = _model$view.columns;
var _model$selection = model.selection(),
items = _model$selection.items;
var shortcut = { register: function register() {
return {};
} };
var editView = new EditCellView(model, table, shortcut);
var startTd = this.table.body.cell(startCell.rowIndex, startCell.columnIndex).model();
var label = startTd.label;
var value = startTd.value;
var startColumnType = startTd.column.type;
for (var i = 0, length = items.length; i < length; i++) {
var _items$i = items[i],
row = _items$i.row,
column = _items$i.column;
var rowIndex = rows.indexOf(row);
var columnIndex = columns.indexOf(column);
var td = table.body.cell(rowIndex, columnIndex).model();
var type = td.column.type;
if (startColumnType === type) {
var editor = new CellEditor(td);
editor.label = label;
editor.value = value;
editView.editor = editor;
if (editView.push.canExecute()) {
editView.push.execute();
}
}
}
}
}]);
return EditService;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var CellHandlerComponent = function () {
/**
* @param {?} element
* @param {?} root
*/
function CellHandlerComponent(element, root) {
classCallCheck(this, CellHandlerComponent);
this.element = element;
this.root = root;
this.startCell = null;
this.initialSelectionMode = null;
this.initialEditState = null;
this.element.nativeElement.style.display = 'none';
}
/**
* @return {?}
*/
createClass(CellHandlerComponent, [{
key: 'ngOnInit',
value: function ngOnInit() {
var /** @type {?} */updateHandler = this.updateHandlerFactory();
var /** @type {?} */updateMarker = this.updateMarkerFactory();
this.root.model.navigationChanged.watch(function (e) {
updateHandler(e);
updateMarker(e);
});
}
/**
* @return {?}
*/
}, {
key: 'ngAfterViewInit',
value: function ngAfterViewInit() {
this.element.nativeElement.style.display = '';
}
/**
* @return {?}
*/
}, {
key: 'updateHandlerFactory',
value: function updateHandlerFactory() {
var _root = this.root,
model = _root.model,
table = _root.table;
var /** @type {?} */element = this.element.nativeElement;
var /** @type {?} */job = jobLine(150);
// When navigate first or when animation wasn't applied we need to omit
// next navigation event to make handler to correct position.
var /** @type {?} */isValid = false;
return function (e) {
if (e.hasChanges('cell')) {
var _e$state = e.state,
cell = _e$state.cell,
rowIndex = _e$state.rowIndex,
columnIndex = _e$state.columnIndex;
if (cell) {
var /** @type {?} */oldCell = e.changes["cell"].oldValue || {};
var /** @type {?} */newCell = e.changes["cell"].newValue || {};
var /** @type {?} */oldColumn = oldCell.column || {};
var /** @type {?} */newColumn = newCell.column || {};
// Do not apply animation for columns that have viewWidth assigned
// because it can be animated too.
var /** @type {?} */shouldAnimate = !model.drag().isActive && (oldColumn.key === newColumn.key || !(oldColumn.viewWidth || newColumn.viewWidth));
if (!shouldAnimate) {
isValid = false;
return;
}
// It can be that the cell object was changed but indices are not.
isValid = oldCell.rowIndex >= 0 && oldCell.columnIndex >= 0 && (newCell.rowIndex !== oldCell.rowIndex || newCell.columnIndex !== oldCell.columnIndex);
var /** @type {?} */domCell = table.body.cell(rowIndex, columnIndex);
if (isValid) {
domCell.addClass('q-grid-animate');
element.classList.add('q-grid-active');
job(function () {
element.classList.remove('q-grid-active');
domCell.removeClass('q-grid-animate');
}).catch(function () {
Fastdom.mutate(function () {
domCell.removeClass('q-grid-animate');
});
});
}
Fastdom.measure(function () {
var /** @type {?} */target = domCell.element;
var /** @type {?} */scrollState = model.scroll();
var /** @type {?} */top = target.offsetTop - scrollState.top + 'px';
var /** @type {?} */left = target.offsetLeft - (cell.column.pin ? 0 : scrollState.left) + 'px';
var /** @type {?} */width = target.offsetWidth + 'px';
var /** @type {?} */height = target.offsetHeight + 'px';
Fastdom.mutate(function () {
element.style.top = top;
element.style.left = left;
element.style.width = width;
element.style.height = height;
});
});
isValid = true;
}
}
};
}
/**
* @return {?}
*/
}, {
key: 'updateMarkerFactory',
value: function updateMarkerFactory() {
var _this = this;
var _root2 = this.root,
model = _root2.model,
table = _root2.table;
var /** @type {?} */editService = new EditService(model, table);
var /** @type {?} */job = jobLine(150);
var /** @type {?} */oldCell = null;
model.editChanged.on(function (e) {
if (e.hasChanges('state')) {
if (e.state.state === 'endBatch') {
model.edit({ state: _this.initialEditState });
editService.doBatch(_this.startCell);
model.selection({ mode: _this.initialSelectionMode });
_this.startCell = null;
}
}
});
return function (e) {
if (!_this.marker) {
return;
}
if (e.hasChanges('cell')) {
var _e$state2 = e.state,
rowIndex = _e$state2.rowIndex,
columnIndex = _e$state2.columnIndex;
var _model$edit = model.edit(),
method = _model$edit.method,
state = _model$edit.state;
var /** @type {?} */cell = table.body.cell(rowIndex, columnIndex).model();
if (method === 'batch') {
if (oldCell) {
Fastdom.mutate(function () {
return _this.marker.nativeElement.remove();
});
}
if (cell) {
job(function () {
return Fastdom.mutate(function () {
return cell.element.appendChild(_this.marker.nativeElement);
});
});
}
oldCell = cell;
}
if (state === 'startBatch' && !_this.startCell) {
_this.startCell = cell;
}
}
};
}
/**
* @param {?} e
* @return {?}
*/
}, {
key: 'startBatchEdit',
value: function startBatchEdit(e) {
var /** @type {?} */model = this.root.model;
this.startCell = model.navigation().cell;
if (this.startCell) {
this.initialEditState = model.edit().state;
this.initialSelectionMode = model.selection().mode;
model.selection({ mode: 'range' });
model.edit({ state: 'startBatch' });
}
}
/**
* @return {?}
*/
}, {
key: 'isMarkerVisible',
get: function get$$1() {
var /** @type {?} */model = this.root.model;
var _model$navigation = model.navigation(),
column = _model$navigation.column;
if (column) {
var /** @type {?} */type = column.type;
return model.edit().method === 'batch';
}
return false;
}
}]);
return CellHandlerComponent;
}();
CellHandlerComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-cell-handler',
template: "<ng-container *ngIf=\"isMarkerVisible\"> <i #marker class=\"material-icons q-grid-marker\" (mousedown)=\"startBatchEdit($event)\"> signal_cellular_4_bar </i> <i class=\"material-icons q-grid-marker\"> signal_cellular_4_bar </i> </ng-container>"
}] }];
/** @nocollapse */
CellHandlerComponent.ctorParameters = function () {
return [{ type: ElementRef }, { type: RootService }];
};
CellHandlerComponent.propDecorators = {
marker: [{ type: ViewChild, args: ['marker'] }]
};
function CellHandlerComponent_tsickle_Closure_declarations() {
/** @type {?} */
CellHandlerComponent.prototype.marker;
/** @type {?} */
CellHandlerComponent.prototype.startCell;
/** @type {?} */
CellHandlerComponent.prototype.initialSelectionMode;
/** @type {?} */
CellHandlerComponent.prototype.initialEditState;
/** @type {?} */
CellHandlerComponent.prototype.element;
/** @type {?} */
CellHandlerComponent.prototype.root;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var RaiseDirective = function () {
/**
* @param {?} element
*/
function RaiseDirective(element) {
classCallCheck(this, RaiseDirective);
this.element = element;
this.type = 'click';
}
/**
* @return {?}
*/
createClass(RaiseDirective, [{
key: 'ngAfterViewInit',
value: function ngAfterViewInit() {
var /** @type {?} */event = new Event(this.type);
var /** @type {?} */element = this.element.nativeElement;
var /** @type {?} */target = this.target ? element.querySelector(this.target) : element;
if (!target) {
throw new AppError('raise.directive', 'raise target is not found');
}
target.dispatchEvent(event);
}
}]);
return RaiseDirective;
}();
RaiseDirective.decorators = [{ type: Directive, args: [{
selector: '[q-grid-raise]'
}] }];
/** @nocollapse */
RaiseDirective.ctorParameters = function () {
return [{ type: ElementRef }];
};
RaiseDirective.propDecorators = {
type: [{ type: Input, args: ['q-grid-raise'] }],
target: [{ type: Input, args: ['q-grid-raise-target'] }]
};
function RaiseDirective_tsickle_Closure_declarations() {
/** @type {?} */
RaiseDirective.prototype.type;
/** @type {?} */
RaiseDirective.prototype.target;
/** @type {?} */
RaiseDirective.prototype.element;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var RaiseModule = function RaiseModule() {
classCallCheck(this, RaiseModule);
};
RaiseModule.decorators = [{ type: NgModule, args: [{
declarations: [RaiseDirective],
exports: [RaiseDirective]
}] }];
var DragService = function () {
function DragService() {
classCallCheck(this, DragService);
}
createClass(DragService, null, [{
key: 'decode',
value: function decode(source) {
return JSON.parse(source);
}
}, {
key: 'encode',
value: function encode(source) {
return JSON.stringify(source);
}
}, {
key: 'mimeType',
get: function get$$1() {
return 'application/x-' + GRID_PREFIX + '+json';
}
}]);
return DragService;
}();
DragService.element = null;
DragService.data = null;
DragService.area = null;
DragService.startPosition = null;
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var DragDirective = function () {
/**
* @param {?} root
* @param {?} elementRef
*/
function DragDirective(root, elementRef) {
classCallCheck(this, DragDirective);
this.root = root;
this.elementRef = elementRef;
var /** @type {?} */element = elementRef.nativeElement;
var /** @type {?} */listener = new EventListener(element, new EventManager(this));
element.classList.add(GRID_PREFIX + '-can-drag');
listener.on('dragstart', this.onStart);
listener.on('dragend', this.onEnd);
}
/**
* @param {?} e
* @return {?}
*/
createClass(DragDirective, [{
key: 'onStart',
value: function onStart(e) {
var /** @type {?} */transfer = e.dataTransfer;
var /** @type {?} */data = this.data;
var /** @type {?} */eventArg = { data: data };
if (this.drag.canExecute(eventArg) === false) {
e.preventDefault();
transfer.effectAllowed = 'none';
return false;
}
var /** @type {?} */result = this.drag.execute(eventArg);
DragService.element = result && isFunction(result.getBoundingClientRect) ? result : e.srcElement;
this.elementRef.nativeElement.classList.add(GRID_PREFIX + '-drag');
transfer.setData(DragService.mimeType, DragService.encode(data));
transfer.effectAllowed = this.effect || 'move';
DragService.data = data;
DragService.area = this.area;
var /** @type {?} */rect = DragService.element.getBoundingClientRect();
DragService.startPosition = {
x: e.clientX,
y: e.clientY,
rect: rect
};
if (this.root) {
var model = this.root.model;
model.drag({ isActive: true }, { source: 'drag.directive' });
}
}
/**
* @return {?}
*/
}, {
key: 'onEnd',
value: function onEnd() {
if (this.root) {
var model = this.root.model;
model.drag({ isActive: false }, { source: 'drag.directive' });
}
this.elementRef.nativeElement.classList.remove(GRID_PREFIX + '-drag');
DragService.data = null;
DragService.area = null;
DragService.element = null;
DragService.startPosition = null;
}
}]);
return DragDirective;
}();
DragDirective.decorators = [{ type: Directive, args: [{
selector: '[q-grid-drag]'
}] }];
/** @nocollapse */
DragDirective.ctorParameters = function () {
return [{ type: RootService, decorators: [{ type: Optional }] }, { type: ElementRef }];
};
DragDirective.propDecorators = {
data: [{ type: Input, args: ['q-grid-drag-data'] }],
effect: [{ type: Input, args: ['q-grid-drag-effect'] }],
drag: [{ type: Input, args: ['q-grid-drag'] }],
area: [{ type: Input, args: ['q-grid-drop-area'] }]
};
function DragDirective_tsickle_Closure_declarations() {
/** @type {?} */
DragDirective.prototype.data;
/** @type {?} */
DragDirective.prototype.effect;
/** @type {?} */
DragDirective.prototype.drag;
/** @type {?} */
DragDirective.prototype.area;
/** @type {?} */
DragDirective.prototype.root;
/** @type {?} */
DragDirective.prototype.elementRef;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @record
*/
function DropEventArg() {}
function DropEventArg_tsickle_Closure_declarations() {
/** @type {?} */
DropEventArg.prototype.path;
/** @type {?} */
DropEventArg.prototype.dragData;
/** @type {?} */
DropEventArg.prototype.dropData;
/** @type {?} */
DropEventArg.prototype.action;
/** @type {?} */
DropEventArg.prototype.inAreaY;
/** @type {?} */
DropEventArg.prototype.inAreaX;
}
var DropDirective = function (_NgComponent) {
inherits(DropDirective, _NgComponent);
/**
* @param {?} root
* @param {?} elementRef
* @param {?} zone
*/
function DropDirective(root, elementRef, zone) {
classCallCheck(this, DropDirective);
var _this = possibleConstructorReturn(this, (DropDirective.__proto__ || Object.getPrototypeOf(DropDirective)).call(this));
_this.root = root;
_this.elementRef = elementRef;
_this.zone = zone;
_this.dragDirection = 'y';
var /** @type {?} */element = elementRef.nativeElement;
var /** @type {?} */listener = new EventListener(element, new EventManager(_this));
element.classList.add(GRID_PREFIX + '-can-drop');
zone.runOutsideAngular(function () {
listener.on('dragenter', _this.onEnter);
listener.on('dragover', _this.onOver);
listener.on('dragleave', _this.onLeave);
});
listener.on('drop', _this.onDrop);
return _this;
}
/**
* @return {?}
*/
createClass(DropDirective, [{
key: 'ngOnInit',
value: function ngOnInit() {
var _this2 = this;
if (this.root) {
this.using(this.root.model.dragChanged.on(function (e) {
if (e.hasChanges('isActive')) {
if (!e.state.isActive) {
var /** @type {?} */eventArg = {
path: [],
dragData: DragService.data,
dropData: _this2.dropData,
action: 'end',
inAreaX: no,
inAreaY: no
};
if (_this2.drop.canExecute(eventArg)) {
_this2.drop.execute(eventArg);
}
}
}
}));
}
}
/**
* @param {?} e
* @return {?}
*/
}, {
key: 'onDrop',
value: function onDrop(e) {
e.stopPropagation();
this.elementRef.nativeElement.classList.remove(GRID_PREFIX + '-dragover');
var /** @type {?} */eventArg = {
path: /** @type {?} */e.path,
dragData: DragService.data,
dropData: this.dropData,
action: 'drop',
inAreaX: this.inAreaFactory(e, 'x'),
inAreaY: this.inAreaFactory(e, 'y')
};
if (this.drop.canExecute(eventArg)) {
this.drop.execute(eventArg);
}
return false;
}
/**
* @param {?} e
* @return {?}
*/
}, {
key: 'onEnter',
value: function onEnter(e) {
e.preventDefault();
this.elementRef.nativeElement.classList.add(GRID_PREFIX + '-dragover');
e.dataTransfer.dropEffect = 'move';
return false;
}
/**
* @param {?} e
* @return {?}
*/
}, {
key: 'onOver',
value: function onOver(e) {
e.preventDefault();
if (this.root && this.root.model.scene().status !== 'stop') {
return false;
}
if (this.area !== DragService.area) {
e.dataTransfer.dropEffect = 'none';
return false;
}
var /** @type {?} */pos = this.getPosition(e);
var /** @type {?} */path = this.getPath(pos);
if (path.indexOf(DragService.element) >= 0) {
return false;
}
var /** @type {?} */eventArg = {
path: path,
dragData: DragService.data,
dropData: this.dropData,
action: 'over',
inAreaX: this.inAreaFactory(e, 'x'),
inAreaY: this.inAreaFactory(e, 'y')
};
if (this.dragOver.canExecute(eventArg)) {
this.dragOver.execute(eventArg);
if (DragService.data !== eventArg.dragData) {
DragService.data = eventArg.dragData;
}
e.dataTransfer.dropEffect = 'move';
}
return false;
}
/**
* @return {?}
*/
}, {
key: 'onLeave',
value: function onLeave() {
this.elementRef.nativeElement.classList.remove(GRID_PREFIX + '-dragover');
}
/**
* @param {?} e
* @return {?}
*/
}, {
key: 'getPosition',
value: function getPosition(e) {
var /** @type {?} */start = DragService.startPosition;
var /** @type {?} */src = start.rect;
var /** @type {?} */offsetX = start.x - (src.left + src.width / 2);
var /** @type {?} */offsetY = start.y - (src.top + src.height / 2);
var clientX = e.clientX,
clientY = e.clientY;
var /** @type {?} */x = clientX - offsetX;
var /** @type {?} */y = clientY - offsetY;
return { x: x, y: y };
}
/**
* @param {?} __0
* @return {?}
*/
}, {
key: 'getPath',
value: function getPath(_ref) {
var x = _ref.x,
y = _ref.y;
// Document.elementsFromPoint is not working with tr?
// so we need to go through all parent.
var /** @type {?} */path = [];
var /** @type {?} */element = document.elementFromPoint(x, y);
while (element) {
path.push(element);
element = element.parentElement;
}
return path;
}
/**
* @param {?} e
* @param {?} direction
* @return {?}
*/
}, {
key: 'inAreaFactory',
value: function inAreaFactory(e, direction) {
var /** @type {?} */src = DragService.startPosition.rect;
var _getPosition = this.getPosition(e),
x = _getPosition.x,
y = _getPosition.y;
if (direction === 'y') {
return function (element) {
var /** @type {?} */trg = element.getBoundingClientRect();
// we are on the top of target
if (src.top < trg.top) {
return trg.bottom > y && y > trg.bottom - src.height;
}
// we are on the bottom of target
return trg.top < y && y < trg.top + src.height;
};
}
return function (element) {
var /** @type {?} */trg = element.getBoundingClientRect();
// we are on the left of target
if (src.left < trg.left) {
return trg.right > x && x > trg.right - src.width;
}
// we are on the right of target
return trg.left < x && x < trg.left + src.width;
};
}
}]);
return DropDirective;
}(NgComponent);
DropDirective.decorators = [{ type: Directive, args: [{
selector: '[q-grid-drop]'
}] }];
/** @nocollapse */
DropDirective.ctorParameters = function () {
return [{ type: RootService, decorators: [{ type: Optional }] }, { type: ElementRef }, { type: NgZone }];
};
DropDirective.propDecorators = {
area: [{ type: Input, args: ['q-grid-drop-area'] }],
dropData: [{ type: Input, args: ['q-grid-drop-data'] }],
drop: [{ type: Input, args: ['q-grid-drop'] }],
dragOver: [{ type: Input, args: ['q-grid-drag-over'] }],
dragDirection: [{ type: Input, args: ['q-grid-drag-direction'] }]
};
function DropDirective_tsickle_Closure_declarations() {
/** @type {?} */
DropDirective.prototype.area;
/** @type {?} */
DropDirective.prototype.dropData;
/** @type {?} */
DropDirective.prototype.drop;
/** @type {?} */
DropDirective.prototype.dragOver;
/** @type {?} */
DropDirective.prototype.dragDirection;
/** @type {?} */
DropDirective.prototype.root;
/** @type {?} */
DropDirective.prototype.elementRef;
/** @type {?} */
DropDirective.prototype.zone;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var DndModule = function DndModule() {
classCallCheck(this, DndModule);
};
DndModule.decorators = [{ type: NgModule, args: [{
declarations: [DragDirective, DropDirective],
exports: [DragDirective, DropDirective]
}] }];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var FocusDirective = function () {
/**
* @param {?} element
* @param {?} zone
*/
function FocusDirective(element, zone) {
classCallCheck(this, FocusDirective);
this.element = element;
this.zone = zone;
this.disabled = false;
}
/**
* @return {?}
*/
createClass(FocusDirective, [{
key: 'ngAfterViewInit',
value: function ngAfterViewInit() {
if (this.disabled) {
return;
}
var /** @type {?} */selector = this.selector;
var /** @type {?} */element = selector ? isString(selector) ? this.element.nativeElement.querySelector(selector) : selector : this.element.nativeElement;
if (!element) {
throw new AppError('focus.directive', 'Element ' + this.selector + ' is not found');
}
if (!isFunction(element.focus)) {
throw new AppError('focus.directive', 'Can\'t find focus method in ' + element);
}
// we need a small timeout to wait, for example, position directive
// in other case it will scroll to element before layout
this.zone.runOutsideAngular(function () {
return setTimeout(function () {
return element.focus();
}, 10);
});
}
}]);
return FocusDirective;
}();
FocusDirective.decorators = [{ type: Directive, args: [{
selector: '[q-grid-focus]'
}] }];
/** @nocollapse */
FocusDirective.ctorParameters = function () {
return [{ type: ElementRef }, { type: NgZone }];
};
FocusDirective.propDecorators = {
selector: [{ type: Input, args: ['q-grid-focus'] }],
disabled: [{ type: Input, args: ['q-grid-focus-disabled'] }]
};
function FocusDirective_tsickle_Closure_declarations() {
/** @type {?} */
FocusDirective.prototype.selector;
/** @type {?} */
FocusDirective.prototype.disabled;
/** @type {?} */
FocusDirective.prototype.element;
/** @type {?} */
FocusDirective.prototype.zone;
}
var AutofocusView = function (_Disposable) {
inherits(AutofocusView, _Disposable);
function AutofocusView(model, table, markup) {
classCallCheck(this, AutofocusView);
var _this = possibleConstructorReturn(this, (AutofocusView.__proto__ || Object.getPrototypeOf(AutofocusView)).call(this));
_this.using(model.sceneChanged.watch(function (e, off) {
if (e.hasChanges('status')) {
if (e.state.status === 'stop') {
var count = table.body.rowCount(0);
if (count) {
off();
var key = Object.keys(markup).find(function (p) {
return p.startsWith('body');
});
if (key) {
var element = markup[key];
if (element) {
element.focus();
}
}
var body = table.body;
var focus = model.focus;
var focusState = focus();
var cell = body.cell(focusState.rowIndex, focusState.columnIndex);
var cellModel = cell.model();
if (!cellModel || !cellModel.column.canFocus) {
var rowIndex = 0;
var rowCount = body.rowCount(0);
while (rowIndex < rowCount) {
var row = body.row(rowIndex);
var cells = row.cells();
var columnIndex = cells.findIndex(function (c) {
var m = c.model();
return m && m.column.canFocus;
});
if (columnIndex >= 0) {
focus({ rowIndex: rowIndex, columnIndex: columnIndex }, { source: 'autofocus.view' });
break;
}
rowIndex++;
}
}
}
}
}
}));
return _this;
}
return AutofocusView;
}(Disposable);
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var AutoFocusDirective = function () {
/**
* @param {?} root
*/
function AutoFocusDirective(root) {
classCallCheck(this, AutoFocusDirective);
this.root = root;
}
/**
* @return {?}
*/
createClass(AutoFocusDirective, [{
key: 'ngAfterViewInit',
value: function ngAfterViewInit() {
if (this.enabled !== false) {
var _root = this.root,
markup = _root.markup,
model = _root.model,
table = _root.table;
this.view = new AutofocusView(model, table, markup);
}
}
/**
* @return {?}
*/
}, {
key: 'ngOnDestroy',
value: function ngOnDestroy() {
if (this.view) {
this.view.dispose();
}
}
}]);
return AutoFocusDirective;
}();
AutoFocusDirective.decorators = [{ type: Directive, args: [{
selector: '[q-grid-autofocus]'
}] }];
/** @nocollapse */
AutoFocusDirective.ctorParameters = function () {
return [{ type: RootService }];
};
AutoFocusDirective.propDecorators = {
enabled: [{ type: Input, args: ['q-grid-autofocus'] }]
};
function AutoFocusDirective_tsickle_Closure_declarations() {
/** @type {?} */
AutoFocusDirective.prototype.view;
/** @type {?} */
AutoFocusDirective.prototype.enabled;
/** @type {?} */
AutoFocusDirective.prototype.root;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var BlurDirective = function () {
/**
* @param {?} renderer
* @param {?} elementRef
*/
function BlurDirective(renderer, elementRef) {
classCallCheck(this, BlurDirective);
this.renderer = renderer;
this.elementRef = elementRef;
this.onBlur = noop$1;
this.selector = 'input';
}
/**
* @return {?}
*/
createClass(BlurDirective, [{
key: 'ngOnInit',
value: function ngOnInit() {
var /** @type {?} */element = this.renderer.selectRootElement(this.selector);
this.renderer.listen(element, 'blur', this.onBlur);
}
}]);
return BlurDirective;
}();
BlurDirective.decorators = [{ type: Directive, args: [{
selector: '[q-grid-on-blur]'
}] }];
/** @nocollapse */
BlurDirective.ctorParameters = function () {
return [{ type: Renderer2 }, { type: ElementRef }];
};
BlurDirective.propDecorators = {
onBlur: [{ type: Input, args: ['q-grid-on-blur'] }],
selector: [{ type: Input, args: ['q-grid-on-blur-selector'] }]
};
function BlurDirective_tsickle_Closure_declarations() {
/** @type {?} */
BlurDirective.prototype.onBlur;
/** @type {?} */
BlurDirective.prototype.selector;
/** @type {?} */
BlurDirective.prototype.renderer;
/** @type {?} */
BlurDirective.prototype.elementRef;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var FocusModule = function FocusModule() {
classCallCheck(this, FocusModule);
};
FocusModule.decorators = [{ type: NgModule, args: [{
declarations: [FocusDirective, AutoFocusDirective, BlurDirective],
exports: [FocusDirective, AutoFocusDirective, BlurDirective]
}] }];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var ResizeDirective = function (_NgComponent) {
inherits(ResizeDirective, _NgComponent);
/**
* @param {?} root
* @param {?} elementRef
* @param {?} document
* @param {?} zone
*/
function ResizeDirective(root, elementRef, document, zone) {
classCallCheck(this, ResizeDirective);
var _this = possibleConstructorReturn(this, (ResizeDirective.__proto__ || Object.getPrototypeOf(ResizeDirective)).call(this));
_this.root = root;
_this.zone = zone;
_this.context = {
x: 0,
y: 0,
height: 0,
width: 0
};
_this.element = elementRef.nativeElement;
_this.divider = document.createElement('div');
_this.listener = {
divider: new EventListener(_this.divider, new EventManager(_this)),
document: new EventListener(document, new EventManager(_this))
};
return _this;
}
/**
* @return {?}
*/
createClass(ResizeDirective, [{
key: 'ngOnInit',
value: function ngOnInit() {
var _this2 = this;
var /** @type {?} */e = { data: this.key };
if (this.canResize(e)) {
this.zone.runOutsideAngular(function () {
_this2.listener.divider.on('mousedown', _this2.dragStart);
});
this.divider.classList.add(GRID_PREFIX + '-resize-handler');
this.element.appendChild(this.divider);
}
}
/**
* @return {?}
*/
}, {
key: 'ngOnDestroy',
value: function ngOnDestroy() {
get(ResizeDirective.prototype.__proto__ || Object.getPrototypeOf(ResizeDirective.prototype), 'ngOnDestroy', this).call(this);
this.listener.divider.off();
this.listener.document.off();
}
/**
* @param {?} e
* @return {?}
*/
}, {
key: 'dragStart',
value: function dragStart(e) {
var _this3 = this;
e.preventDefault();
var /** @type {?} */context = this.context;
context.width = this.element.clientWidth;
context.height = this.element.clientHeight;
context.x = e.screenX;
context.y = e.screenY;
this.zone.runOutsideAngular(function () {
_this3.listener.document.on('mousemove', _this3.drag);
_this3.listener.document.on('mouseup', _this3.dragEnd);
});
var /** @type {?} */model = this.model;
model.drag({ isActive: true });
}
/**
* @param {?} e
* @return {?}
*/
}, {
key: 'drag',
value: function drag(e) {
var layout = this.model.layout;
var /** @type {?} */context = this.context;
var /** @type {?} */state = clone(layout()[this.path]);
state.set(this.key, {
width: context.width + e.screenX - context.x,
height: context.height + e.screenY - context.y
});
layout(defineProperty({}, this.path, state));
}
/**
* @return {?}
*/
}, {
key: 'dragEnd',
value: function dragEnd() {
this.listener.document.off();
var /** @type {?} */model = this.model;
model.drag({ isActive: false });
}
/**
* @return {?}
*/
}, {
key: 'model',
get: function get$$1() {
return this.root.model;
}
}]);
return ResizeDirective;
}(NgComponent);
ResizeDirective.decorators = [{ type: Directive, args: [{
selector: '[q-grid-resize]'
}] }];
/** @nocollapse */
ResizeDirective.ctorParameters = function () {
return [{ type: RootService, decorators: [{ type: Optional }] }, { type: ElementRef }, { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT$1] }] }, { type: NgZone }];
};
ResizeDirective.propDecorators = {
key: [{ type: Input, args: ['q-grid-resize'] }],
path: [{ type: Input, args: ['q-grid-resize-path'] }],
canResize: [{ type: Input, args: ['q-grid-can-resize'] }]
};
function ResizeDirective_tsickle_Closure_declarations() {
/** @type {?} */
ResizeDirective.prototype.element;
/** @type {?} */
ResizeDirective.prototype.divider;
/** @type {?} */
ResizeDirective.prototype.listener;
/** @type {?} */
ResizeDirective.prototype.context;
/** @type {?} */
ResizeDirective.prototype.key;
/** @type {?} */
ResizeDirective.prototype.path;
/** @type {?} */
ResizeDirective.prototype.canResize;
/** @type {?} */
ResizeDirective.prototype.root;
/** @type {?} */
ResizeDirective.prototype.zone;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var AutosizeDirective = function () {
/**
* @param {?} element
*/
function AutosizeDirective(element) {
classCallCheck(this, AutosizeDirective);
this.emptyWidth = 75;
this.host = /** @type {?} */element.nativeElement;
}
/**
* @return {?}
*/
createClass(AutosizeDirective, [{
key: 'ngOnInit',
value: function ngOnInit() {
this.element = this.selector ? /** @type {?} */this.host.querySelector(this.selector) : /** @type {?} */this.host;
}
/**
* @param {?} text
* @return {?}
*/
}, {
key: 'autoWidth',
value: function autoWidth(text) {
var _this = this;
if (!text) {
this.actualText = text;
Fastdom.measure(function () {
Fastdom.mutate(function () {
_this.host.style.width = _this.emptyWidth + 'px';
});
});
return;
}
if (!this.element) {
return;
}
if (this.actualText === text) {
return;
}
this.actualText = text;
Fastdom.measure(function () {
var /** @type {?} */width = _this.calculateWidth(_this.element, text) + 'px';
Fastdom.mutate(function () {
return _this.host.style.width = width;
});
});
}
/**
* @param {?} value
* @return {?}
*/
}, {
key: 'calculateWidth',
/**
* @param {?} element
* @param {?} text
* @return {?}
*/
value: function calculateWidth(element, text) {
var /** @type {?} */width = 0;
if (text) {
var /** @type {?} */document = element.ownerDocument;
var /** @type {?} */body = document.body;
var /** @type {?} */test = document.createElement('span');
test.innerText = text;
test.style.whiteSpace = 'pre';
test.style.visibility = 'hidden';
test.style.font = element.style.font;
test.style.fontFamily = element.style.fontFamily;
test.style.lineHeight = element.style.lineHeight;
test.style.border = element.style.border;
// borderBox ?
body.appendChild(test);
width = test.offsetWidth;
test.remove();
}
return width;
}
}, {
key: 'value',
set: function set$$1(value) {
this.autoWidth(value);
}
}]);
return AutosizeDirective;
}();
AutosizeDirective.decorators = [{ type: Directive, args: [{
selector: '[q-grid-autosize]'
}] }];
/** @nocollapse */
AutosizeDirective.ctorParameters = function () {
return [{ type: ElementRef }];
};
AutosizeDirective.propDecorators = {
selector: [{ type: Input, args: ['q-grid-autosize'] }],
emptyWidth: [{ type: Input, args: ['q-grid-autosize-empty-width'] }],
value: [{ type: Input, args: ['q-grid-autisize-value'] }]
};
function AutosizeDirective_tsickle_Closure_declarations() {
/** @type {?} */
AutosizeDirective.prototype.selector;
/** @type {?} */
AutosizeDirective.prototype.emptyWidth;
/** @type {?} */
AutosizeDirective.prototype.actualText;
/** @type {?} */
AutosizeDirective.prototype.host;
/** @type {?} */
AutosizeDirective.prototype.element;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var ResizeModule = function ResizeModule() {
classCallCheck(this, ResizeModule);
};
ResizeModule.decorators = [{ type: NgModule, args: [{
declarations: [ResizeDirective, AutosizeDirective],
exports: [ResizeDirective, AutosizeDirective]
}] }];
var PositionView = function (_Disposable) {
inherits(PositionView, _Disposable);
function PositionView(context) {
classCallCheck(this, PositionView);
var _this = possibleConstructorReturn(this, (PositionView.__proto__ || Object.getPrototypeOf(PositionView)).call(this));
_this.element = context.element;
_this.targetName = context.targetName;
var windowListener = new EventListener(window, new EventManager(_this));
var job = jobLine(400);
_this.using(windowListener.on('resize', function () {
_this.invalidate();
// In case if after window resize there can different animated layout changes
job(function () {
return _this.invalidate();
});
}));
return _this;
}
createClass(PositionView, [{
key: 'invalidate',
value: function invalidate() {
var node = this.element.parentNode;
while (node) {
var targetName = (this.targetName || '').toLowerCase();
if (node.nodeName.toLowerCase() === targetName) {
this.layout(node, this.element);
this.element.style.opacity = 1;
return;
}
node = node.parentNode;
}
}
}, {
key: 'layout',
value: function layout(target, source) {
var _target$getBoundingCl = target.getBoundingClientRect(),
top = _target$getBoundingCl.top,
right = _target$getBoundingCl.right,
left = _target$getBoundingCl.left,
bottom = _target$getBoundingCl.bottom;
var _source$getBoundingCl = source.getBoundingClientRect(),
width = _source$getBoundingCl.width,
height = _source$getBoundingCl.height;
var br = this.boxRect();
var intersections = [];
intersections.push(this.intersection(br, {
top: top,
right: left + width,
bottom: top + height,
left: left
}));
intersections.push(this.intersection(br, {
top: top,
right: right,
bottom: top + height,
left: right - width
}));
intersections.push(this.intersection(br, {
top: bottom - height,
right: left + width,
bottom: bottom,
left: left
}));
intersections.push(this.intersection(br, {
top: bottom - height,
right: right,
bottom: bottom,
left: right - width
}));
var intersection = maxBy(intersections, function (i) {
return i.area;
});
var _intersection$b = intersection.b,
l = _intersection$b.left,
t = _intersection$b.top;
var pos = this.fix({ left: l - br.left, top: t - br.top, width: width, height: height });
source.style.left = pos.left + 'px';
source.style.top = pos.top + 'px';
}
}, {
key: 'intersection',
value: function intersection(a, b) {
var xo = Math.max(0, Math.min(a.right, b.right) - Math.max(a.left, b.left));
var yo = Math.max(0, Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top));
var area = xo * yo;
return { area: area, a: a, b: b };
}
}, {
key: 'fix',
value: function fix(rect) {
var wr = this.windowRect();
var br = this.boxRect();
var vw = wr.width,
vh = wr.height;
var vx = br.left - wr.left;
var vy = br.top - wr.top;
var rh = rect.height,
rw = rect.width;
var rx = rect.left + vx;
var ry = rect.top + vy;
var gtx1 = rx + rw > vw;
var ltx0 = rx < 0;
var gty1 = ry + rh > vh;
var lty0 = ry < 0;
var left = ltx0 || gtx1 ? (vw - rw) / 2 - vx : rect.left;
var top = lty0 || gty1 ? (vh - rh) / 2 - vy : rect.top;
return { left: left, top: top };
}
}, {
key: 'boxRect',
value: function boxRect() {
var view = this.element;
var marker = GRID_PREFIX + '-box';
while (view) {
if (view.classList && view.classList.contains(marker)) {
return view.getBoundingClientRect();
}
view = view.parentNode;
}
return this.windowRect();
}
}, {
key: 'windowRect',
value: function windowRect() {
var _window = window,
h = _window.innerHeight,
w = _window.innerWidth;
return {
top: 0,
left: 0,
bottom: h,
right: w,
height: h,
width: w
};
}
}]);
return PositionView;
}(Disposable);
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var PositionDirective = function () {
/**
* @param {?} element
*/
function PositionDirective(element) {
classCallCheck(this, PositionDirective);
this.element = element;
this.target = '';
}
/**
* @return {?}
*/
createClass(PositionDirective, [{
key: 'ngOnInit',
value: function ngOnInit() {
this.position = new PositionView({
element: this.element.nativeElement,
targetName: this.target
});
this.position.invalidate();
}
/**
* @return {?}
*/
}, {
key: 'ngOnDestroy',
value: function ngOnDestroy() {
this.position.dispose();
}
}]);
return PositionDirective;
}();
PositionDirective.decorators = [{ type: Directive, args: [{
selector: '[q-grid-position]'
}] }];
/** @nocollapse */
PositionDirective.ctorParameters = function () {
return [{ type: ElementRef }];
};
PositionDirective.propDecorators = {
target: [{ type: Input, args: ['q-grid-position'] }]
};
function PositionDirective_tsickle_Closure_declarations() {
/** @type {?} */
PositionDirective.prototype.target;
/** @type {?} */
PositionDirective.prototype.position;
/** @type {?} */
PositionDirective.prototype.element;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var StopPropagateDirective = function () {
/**
* @param {?} element
*/
function StopPropagateDirective(element) {
classCallCheck(this, StopPropagateDirective);
this.element = element;
this.key = '';
}
/**
* @return {?}
*/
createClass(StopPropagateDirective, [{
key: 'ngOnInit',
value: function ngOnInit() {
this.element.nativeElement.addEventListener(this.key, function (e) {
return e.stopPropagation();
});
}
}]);
return StopPropagateDirective;
}();
StopPropagateDirective.decorators = [{ type: Directive, args: [{
selector: '[q-grid-stop-propagate]'
}] }];
/** @nocollapse */
StopPropagateDirective.ctorParameters = function () {
return [{ type: ElementRef }];
};
StopPropagateDirective.propDecorators = {
key: [{ type: Input, args: ['q-grid-stop-propagate'] }]
};
function StopPropagateDirective_tsickle_Closure_declarations() {
/** @type {?} */
StopPropagateDirective.prototype.key;
/** @type {?} */
StopPropagateDirective.prototype.element;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var LayoutModule = function LayoutModule() {
classCallCheck(this, LayoutModule);
};
LayoutModule.decorators = [{ type: NgModule, args: [{
declarations: [PositionDirective, StopPropagateDirective],
exports: [PositionDirective, StopPropagateDirective]
}] }];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var BackdropService = function () {
function BackdropService() {
classCallCheck(this, BackdropService);
this.isActive = true;
}
/**
* @return {?}
*/
createClass(BackdropService, [{
key: 'hide',
value: function hide() {
Guard.notNull(this.element, 'element');
if (this.isActive) {
this.element.nativeElement.classList.add('q-grid-backdrop-inactive');
this.isActive = false;
}
}
/**
* @return {?}
*/
}, {
key: 'reveal',
value: function reveal() {
Guard.notNull(this.element, 'element');
if (!this.isActive) {
this.element.nativeElement.classList.remove('q-grid-backdrop-inactive');
this.isActive = true;
}
}
}]);
return BackdropService;
}();
BackdropService.decorators = [{ type: Injectable }];
function BackdropService_tsickle_Closure_declarations() {
/** @type {?} */
BackdropService.prototype.isActive;
/** @type {?} */
BackdropService.prototype.element;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var FileDirective = function (_NgComponent) {
inherits(FileDirective, _NgComponent);
/**
* @param {?} backdropService
* @param {?} elementRef
*/
function FileDirective(backdropService, elementRef) {
classCallCheck(this, FileDirective);
var _this = possibleConstructorReturn(this, (FileDirective.__proto__ || Object.getPrototypeOf(FileDirective)).call(this));
_this.backdropService = backdropService;
_this.reader = new FileReader();
_this.valueChange = new EventEmitter();
_this.labelChange = new EventEmitter();
_this.isValid = yes;
var /** @type {?} */listener = new EventListener(elementRef.nativeElement, new EventManager(_this));
_this.using(listener.on('change', _this.onUpload));
_this.using(listener.on('drop', _this.onUpload));
_this.using(listener.on('click', _this.hideBackdrop));
_this.using(listener.on('focus', _this.revealBackdrop));
_this.reader.onloadend = function (e) {
return _this.onLoadEnd(e);
};
return _this;
}
/**
* @return {?}
*/
createClass(FileDirective, [{
key: 'onUpload',
/**
* @param {?} e
* @return {?}
*/
value: function onUpload(e) {
var files = e.target.files;
var /** @type {?} */file = files[0];
if (file && this.isValid(file.name)) {
this.reader.readAsDataURL(file);
this.label = file.name;
}
}
/**
* @param {?} e
* @return {?}
*/
}, {
key: 'onLoadEnd',
value: function onLoadEnd(e) {
if (e.target.readyState === this.reader.DONE) {
this.value = e.target.result;
}
}
/**
* @return {?}
*/
}, {
key: 'hideBackdrop',
value: function hideBackdrop() {
if (this.backdropService) {
this.backdropService.hide();
}
}
/**
* @return {?}
*/
}, {
key: 'revealBackdrop',
value: function revealBackdrop() {
var _this2 = this;
if (this.backdropService) {
if (!this.backdropService.isActive) {
setTimeout(function () {
return _this2.backdropService.reveal();
}, 300);
}
}
}
}, {
key: 'value',
get: function get$$1() {
return this._value;
}
/**
* @param {?} value
* @return {?}
*/
,
set: function set$$1(value) {
if (value !== this._value) {
this._value = value;
this.valueChange.emit(value);
}
}
/**
* @return {?}
*/
}, {
key: 'label',
get: function get$$1() {
return this._label;
}
/**
* @param {?} value
* @return {?}
*/
,
set: function set$$1(value) {
if (value !== this._label) {
this._label = value;
this.labelChange.emit(value);
}
}
}]);
return FileDirective;
}(NgComponent);
FileDirective.decorators = [{ type: Directive, args: [{
selector: '[q-grid-file]'
}] }];
/** @nocollapse */
FileDirective.ctorParameters = function () {
return [{ type: BackdropService, decorators: [{ type: Optional }] }, { type: ElementRef }];
};
FileDirective.propDecorators = {
valueChange: [{ type: Output, args: ['q-grid-fileChange'] }],
labelChange: [{ type: Output, args: ['q-grid-file-labelChange'] }],
isValid: [{ type: Input, args: ['q-grid-file-is-valid'] }],
value: [{ type: Input, args: ['q-grid-file'] }],
label: [{ type: Input, args: ['q-grid-file-label'] }]
};
function FileDirective_tsickle_Closure_declarations() {
/** @type {?} */
FileDirective.prototype.reader;
/** @type {?} */
FileDirective.prototype._value;
/** @type {?} */
FileDirective.prototype._label;
/** @type {?} */
FileDirective.prototype.valueChange;
/** @type {?} */
FileDirective.prototype.labelChange;
/** @type {?} */
FileDirective.prototype.isValid;
/** @type {?} */
FileDirective.prototype.backdropService;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var FileModule = function FileModule() {
classCallCheck(this, FileModule);
};
FileModule.decorators = [{ type: NgModule, args: [{
declarations: [FileDirective],
exports: [FileDirective]
}] }];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var VscrollService = function () {
function VscrollService() {
classCallCheck(this, VscrollService);
}
createClass(VscrollService, [{
key: 'context',
/**
* @param {?=} settings
* @return {?}
*/
value: function context() {
var settings = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var /** @type {?} */context = new VscrollContext();
Object.assign(context.settings, settings);
context.container.update(0, true);
return context;
}
}]);
return VscrollService;
}();
VscrollService.decorators = [{ type: Injectable }];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @abstract
*/
var VscrollPort =
/**
* @param {?} view
* @param {?} element
*/
function VscrollPort(view, element) {
classCallCheck(this, VscrollPort);
this.view = view;
this.markup = {};
element.tabIndex = 0;
element.style.outline = 'none';
/** @type {?} */element.style.overflowAnchor = 'none';
};
function VscrollPort_tsickle_Closure_declarations() {
/** @type {?} */
VscrollPort.prototype.markup;
/** @type {?} */
VscrollPort.prototype.layout;
/** @type {?} */
VscrollPort.prototype.context;
/** @type {?} */
VscrollPort.prototype.view;
/**
* @abstract
* @return {?}
*/
VscrollPort.prototype.reset = function () {};
/**
* @abstract
* @param {?} newBox
* @param {?} oldBox
* @return {?}
*/
VscrollPort.prototype.hasChanges = function (newBox, oldBox) {};
/**
* @abstract
* @param {?} f
* @return {?}
*/
VscrollPort.prototype.emit = function (f) {};
/**
* @abstract
* @param {?} pad1
* @param {?} pad2
* @return {?}
*/
VscrollPort.prototype.move = function (pad1, pad2) {};
/**
* @abstract
* @param {?} items
* @return {?}
*/
VscrollPort.prototype.recycleFactory = function (items) {};
/**
* @abstract
* @param {?} offsets
* @param {?} box
* @param {?} arm
* @return {?}
*/
VscrollPort.prototype.getPositionUsingOffsets = function (offsets, box, arm) {};
/**
* @abstract
* @param {?} itemsSize
* @param {?} box
* @param {?} arm
* @return {?}
*/
VscrollPort.prototype.getPositionUsingItemSize = function (itemsSize, box, arm) {};
/**
* @abstract
* @return {?}
*/
VscrollPort.prototype.getItemSize = function () {};
/**
* @abstract
* @param {?} box
* @return {?}
*/
VscrollPort.prototype.getScrollSize = function (box) {};
/**
* @abstract
* @param {?} box
* @return {?}
*/
VscrollPort.prototype.getSize = function (box) {};
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @param {?} text
* @return {?}
*/
function capitalize(text) {
return text[0].toUpperCase() + text.slice(1);
}
/**
* @param {?} width
* @param {?} height
* @return {?}
*/
function placeholderBitmap(width, height) {
var /** @type {?} */minWidth = Math.max(width, 1);
var /** @type {?} */minHeight = Math.max(height, 1);
var /** @type {?} */canvas = document.createElement('canvas');
canvas.width = Math.max(width * 2, 1);
canvas.height = Math.max(height * 2, 1);
var /** @type {?} */ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0, 0, 0, 0.04)';
ctx.fillRect(0, 0, minWidth, minHeight);
ctx.fillStyle = 'rgba(0, 0, 0, 0.08)';
ctx.fillRect(width, height, minWidth, minHeight);
return canvas.toDataURL();
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @param {?} items
* @param {?} value
* @return {?}
*/
function findIndexAt(items, value) {
var /** @type {?} */length = items.length;
var /** @type {?} */min = 0;
var /** @type {?} */max = length - 1;
while (min <= max) {
var /** @type {?} */mid = min + max >> 1;
var /** @type {?} */k = items[mid];
if (k === value) {
return mid;
} else if (k < value) {
min = mid + 1;
} else {
max = mid - 1;
}
}
return min;
}
/**
* @record
*/
function IVscrollPosition() {}
function IVscrollPosition_tsickle_Closure_declarations() {
/** @type {?} */
IVscrollPosition.prototype.index;
/** @type {?} */
IVscrollPosition.prototype.offset;
/** @type {?} */
IVscrollPosition.prototype.lastOffset;
/** @type {?} */
IVscrollPosition.prototype.value;
/** @type {?} */
IVscrollPosition.prototype.pad;
}
/**
* @param {?} value
* @param {?} itemSize
* @return {?}
*/
function findPositionUsingItemSize(value, itemSize) {
var /** @type {?} */index = Math.max(0, Math.round(value / itemSize));
return {
index: index,
offset: itemSize * index,
lastOffset: 0,
value: value,
pad: 0
};
}
/**
* @param {?} value
* @param {?} offsets
* @return {?}
*/
function findPositionUsingOffsets(value, offsets) {
var /** @type {?} */index = findIndexAt(offsets, value);
var length = offsets.length;
if (index > 0) {
return {
index: index,
offset: offsets[index - 1],
lastOffset: offsets[length - 1],
value: value,
pad: 0
};
}
return {
index: 0,
offset: 0,
lastOffset: 0,
value: value,
pad: 0
};
}
/**
* @param {?} items
* @return {?}
*/
function recycleFactory(items) {
var /** @type {?} */offsets = new Array();
return function (index, count) {
var /** @type {?} */cursor = offsets.length;
var /** @type {?} */threshold = items.length;
var /** @type {?} */diff = Math.min(count, threshold + index) - cursor;
for (var /** @type {?} */i = threshold - diff; i < threshold; i++) {
var /** @type {?} */getSize = items[i];
var /** @type {?} */size = getSize();
if (cursor === 0) {
offsets[cursor] = size;
} else {
offsets[cursor] = offsets[cursor - 1] + size;
}
cursor++;
}
return offsets;
};
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var /** @type {?} */UNSET_ARM = Number.MAX_SAFE_INTEGER;
/**
* @return {?}
*/
function empty$2() {
return 0;
}
var VscrollLayout = function () {
/**
* @param {?} port
*/
function VscrollLayout(port) {
classCallCheck(this, VscrollLayout);
this.port = port;
this.items = [];
this.minArm = UNSET_ARM;
this.position = findPositionUsingOffsets(0, []);
this.getOffsets = recycleFactory(this.items);
}
/**
* @param {?} count
* @param {?} box
* @param {?} force
* @return {?}
*/
createClass(VscrollLayout, [{
key: 'recycle',
value: function recycle(count, box, force) {
var port = this.port;
var /** @type {?} */itemSize = port.getItemSize();
if (itemSize) {
return this.recycleItemSize(count, box, force, itemSize);
}
return this.recycleOffsets(count, box, force);
}
/**
* @param {?} position
* @return {?}
*/
}, {
key: 'invalidate',
value: function invalidate(position) {
var offset = position.offset;
var /** @type {?} */pad1 = Math.max(0, offset);
var /** @type {?} */pad2 = Math.max(0, position.pad - pad1);
this.port.move(pad1, pad2);
return position.index;
}
/**
* @return {?}
*/
}, {
key: 'reset',
value: function reset() {
this.minArm = UNSET_ARM;
this.getOffsets = this.port.recycleFactory(this.items);
this.position = findPositionUsingOffsets(0, []);
return this.invalidate(this.position);
}
/**
* @param {?} index
* @param {?} item
* @return {?}
*/
}, {
key: 'setItem',
value: function setItem(index, item) {
this.items[index] = item;
}
/**
* @param {?} index
* @return {?}
*/
}, {
key: 'removeItem',
value: function removeItem(index) {
var /** @type {?} */items = this.items;
var /** @type {?} */last = items.length - 1;
if (index === 0) {
items.shift();
} else if (index === last) {
items.pop();
while (last-- && items[last] === empty$2) {
items.pop();
}
} else {
// TODO: think how to avoid this
items[index] = empty$2;
}
}
/**
* @param {?} count
* @param {?} box
* @param {?} force
* @return {?}
*/
}, {
key: 'recycleOffsets',
value: function recycleOffsets(count, box, force) {
var position = this.position,
port = this.port;
var threshold = this.settings.threshold;
var /** @type {?} */offsets = this.getOffsets(position.index, count);
var /** @type {?} */arm = this.getArmUsingOffsets(offsets, box, position.index);
this.minArm = Math.min(this.minArm, arm);
var /** @type {?} */newPosition = port.getPositionUsingOffsets(offsets, box, this.minArm);
if (force || position.index !== newPosition.index) {
var /** @type {?} */last = Math.min(offsets.length - 1, newPosition.index + threshold - 1);
var /** @type {?} */first = newPosition.index - 1;
var /** @type {?} */viewSize = (offsets[last] || 0) - (offsets[first] || 0);
var /** @type {?} */scrollSize = offsets[offsets.length - 1] || 0;
var /** @type {?} */padSize = scrollSize - viewSize;
newPosition.pad = padSize;
return this.position = newPosition;
}
return null;
}
/**
* @param {?} count
* @param {?} box
* @param {?} force
* @param {?} itemSize
* @return {?}
*/
}, {
key: 'recycleItemSize',
value: function recycleItemSize(count, box, force, itemSize) {
var position = this.position,
port = this.port;
var /** @type {?} */arm = this.getArmUsingItemSize(itemSize, box);
var /** @type {?} */newPosition = port.getPositionUsingItemSize(itemSize, box, arm);
if (force || position.index !== newPosition.index) {
var threshold = this.settings.threshold;
var /** @type {?} */remain = Math.max(0, newPosition.index + threshold - this.container.count);
newPosition.pad = Math.max(0, itemSize * (count + remain - threshold));
return this.position = newPosition;
}
return null;
}
/**
* @param {?} itemSize
* @param {?} box
* @return {?}
*/
}, {
key: 'getArmUsingItemSize',
value: function getArmUsingItemSize(itemSize, box) {
var threshold = this.settings.threshold;
var /** @type {?} */portSize = this.port.getSize(box);
var /** @type {?} */viewSize = threshold * itemSize;
return Math.max(0, (viewSize - portSize) / 2);
}
/**
* @param {?} offsets
* @param {?} box
* @param {?} index
* @return {?}
*/
}, {
key: 'getArmUsingOffsets',
value: function getArmUsingOffsets(offsets, box, index) {
if (offsets.length) {
var threshold = this.settings.threshold;
var /** @type {?} */portSize = this.port.getSize(box);
var /** @type {?} */last = Math.min(offsets.length, index + threshold) - 1;
var /** @type {?} */first = last + 1 - threshold;
var /** @type {?} */viewSize = offsets[last] - offsets[first];
return Math.max(0, (viewSize - portSize) / 2);
}
return UNSET_ARM;
}
/**
* @return {?}
*/
}, {
key: 'container',
get: function get$$1() {
return this.port.context.container;
}
/**
* @return {?}
*/
}, {
key: 'settings',
get: function get$$1() {
return this.port.context.settings;
}
}]);
return VscrollLayout;
}();
function VscrollLayout_tsickle_Closure_declarations() {
/** @type {?} */
VscrollLayout.prototype.items;
/** @type {?} */
VscrollLayout.prototype.minArm;
/** @type {?} */
VscrollLayout.prototype.position;
/** @type {?} */
VscrollLayout.prototype.getOffsets;
/** @type {?} */
VscrollLayout.prototype.port;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var VscrollDirective = function () {
/**
* @param {?} elementRef
* @param {?} zone
* @param {?} renderer
*/
function VscrollDirective(elementRef, zone, renderer) {
var _this = this;
classCallCheck(this, VscrollDirective);
this.elementRef = elementRef;
this.scrollEvent = new EventEmitter();
this.resetEvent = new EventEmitter();
zone.runOutsideAngular(function () {
elementRef.nativeElement.addEventListener('scroll', function () {
return _this.onScroll();
}, { passive: true });
renderer.listen(window, 'resize', function () {
return _this.onResize();
});
});
}
/**
* @param {?} width
* @param {?} height
* @return {?}
*/
createClass(VscrollDirective, [{
key: 'drawPlaceholder',
value: function drawPlaceholder(width, height) {
var /** @type {?} */box = this.elementRef.nativeElement;
var /** @type {?} */style = box.style;
var /** @type {?} */placeholder = placeholderBitmap(width || box.clientWidth, height || box.clientHeight);
style.backgroundImage = 'url(' + placeholder + ')';
style.backgroundRepeat = 'repeat';
}
/**
* @return {?}
*/
}, {
key: 'resetX',
value: function resetX() {
this.elementRef.nativeElement.scrollLeft = 0;
}
/**
* @return {?}
*/
}, {
key: 'resetY',
value: function resetY() {
this.elementRef.nativeElement.scrollTop = 0;
}
/**
* @return {?}
*/
}, {
key: 'onScroll',
/**
* @return {?}
*/
value: function onScroll() {
this.scrollEvent.emit();
}
/**
* @return {?}
*/
}, {
key: 'onResize',
value: function onResize() {
var /** @type {?} */e = { handled: false, source: 'resize' };
this.resetEvent.emit(e);
}
}, {
key: 'element',
get: function get$$1() {
return this.elementRef.nativeElement;
}
}]);
return VscrollDirective;
}();
VscrollDirective.decorators = [{ type: Directive, args: [{
selector: '[q-grid-vscroll]'
}] }];
/** @nocollapse */
VscrollDirective.ctorParameters = function () {
return [{ type: ElementRef }, { type: NgZone }, { type: Renderer2 }];
};
function VscrollDirective_tsickle_Closure_declarations() {
/** @type {?} */
VscrollDirective.prototype.scrollEvent;
/** @type {?} */
VscrollDirective.prototype.resetEvent;
/** @type {?} */
VscrollDirective.prototype.elementRef;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var VscrollBox = function VscrollBox() {
classCallCheck(this, VscrollBox);
this.scrollWidth = 0;
this.scrollHeight = 0;
this.scrollTop = 0;
this.scrollLeft = 0;
this.portWidth = 0;
this.portHeight = 0;
};
function VscrollBox_tsickle_Closure_declarations() {
/** @type {?} */
VscrollBox.prototype.scrollWidth;
/** @type {?} */
VscrollBox.prototype.scrollHeight;
/** @type {?} */
VscrollBox.prototype.scrollTop;
/** @type {?} */
VscrollBox.prototype.scrollLeft;
/** @type {?} */
VscrollBox.prototype.portWidth;
/** @type {?} */
VscrollBox.prototype.portHeight;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var VscrollLink = function () {
/**
* @param {?} port
*/
function VscrollLink(port) {
var _this = this;
classCallCheck(this, VscrollLink);
this.port = port;
this.box = new VscrollBox();
this.ticking = false;
var view = port.view,
layout = port.layout;
var settings = this.settings,
container = this.container;
if (settings.placeholderHeight > 0 || settings.placeholderWidth > 0) {
var /** @type {?} */width = settings.placeholderWidth || isNumber(settings.columnWidth) && /** @type {?} */settings.columnWidth;
var /** @type {?} */height = settings.placeholderHeight || isNumber(settings.rowHeight) && /** @type {?} */settings.rowHeight;
view.drawPlaceholder(width, height);
}
view.scrollEvent.subscribe(function () {
return _this.update(false);
});
view.resetEvent.subscribe(function (e) {
if (e.handled) {
return;
}
e.handled = settings.resetTriggers.indexOf(e.source) < 0;
container.resetEvent.emit(e);
});
container.resetEvent.subscribe(function (e) {
if (e.handled) {
return;
}
container.cursor = layout.reset();
port.reset();
});
container.updateEvent.subscribe(function (e) {
if (e.force) {
_this.update(true);
}
});
}
/**
* @param {?} force
* @return {?}
*/
createClass(VscrollLink, [{
key: 'tick',
value: function tick(force) {
var _this2 = this;
this.ticking = false;
var /** @type {?} */port = this.port;
var /** @type {?} */count = this.container.count;
var /** @type {?} */position = port.layout.recycle(count, this.box, force);
if (position) {
this.container.apply(function () {
_this2.container.cursor = port.layout.invalidate(position);
_this2.container.drawEvent.emit({
position: _this2.container.cursor
});
}, function (f) {
return port.emit(f);
});
}
}
/**
* @param {?=} force
* @return {?}
*/
}, {
key: 'update',
value: function update() {
var _this3 = this;
var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
var /** @type {?} */view = this.port.view;
this.container.read(function () {
var /** @type {?} */element = view.element;
var /** @type {?} */newBox = {
scrollWidth: element.scrollWidth,
scrollHeight: element.scrollHeight,
scrollTop: element.scrollTop,
scrollLeft: element.scrollLeft,
portWidth: element.clientWidth,
portHeight: element.clientHeight
};
if (force || _this3.port.hasChanges(newBox, _this3.box)) {
_this3.box = newBox;
if (_this3.container.count && !_this3.ticking) {
_this3.ticking = true;
_this3.container.tick(function () {
return _this3.tick(force);
});
}
}
});
}
/**
* @return {?}
*/
}, {
key: 'settings',
get: function get$$1() {
return this.port.context.settings;
}
/**
* @return {?}
*/
}, {
key: 'container',
get: function get$$1() {
return this.port.context.container;
}
}]);
return VscrollLink;
}();
function VscrollLink_tsickle_Closure_declarations() {
/** @type {?} */
VscrollLink.prototype.box;
/** @type {?} */
VscrollLink.prototype.ticking;
/** @type {?} */
VscrollLink.prototype.port;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var VscrollPortYDirective = function (_VscrollPort) {
inherits(VscrollPortYDirective, _VscrollPort);
/**
* @param {?} zone
* @param {?} elementRef
* @param {?} view
*/
function VscrollPortYDirective(zone, elementRef, view) {
classCallCheck(this, VscrollPortYDirective);
var _this = possibleConstructorReturn(this, (VscrollPortYDirective.__proto__ || Object.getPrototypeOf(VscrollPortYDirective)).call(this, view, elementRef.nativeElement));
_this.zone = zone;
_this.elementRef = elementRef;
_this.markup = {};
return _this;
}
/**
* @return {?}
*/
createClass(VscrollPortYDirective, [{
key: 'ngOnInit',
value: function ngOnInit() {
Guard.notNull(this.context, 'context');
this.layout = new VscrollLayout(this);
return new VscrollLink(this);
}
/**
* @return {?}
*/
}, {
key: 'reset',
value: function reset() {
this.view.resetY();
}
/**
* @param {?} f
* @return {?}
*/
}, {
key: 'emit',
value: function emit(f) {
this.zone.run(f);
}
/**
* @param {?} itemSize
* @param {?} box
* @param {?} arm
* @return {?}
*/
}, {
key: 'getPositionUsingItemSize',
value: function getPositionUsingItemSize(itemSize, box, arm) {
var /** @type {?} */limitTop = box.scrollTop - arm;
var /** @type {?} */limitBottom = box.scrollHeight - (box.portHeight + arm);
var /** @type {?} */value = Math.min(limitBottom, Math.max(0, limitTop));
return findPositionUsingItemSize(value, itemSize);
}
/**
* @param {?} offsets
* @param {?} box
* @param {?} arm
* @return {?}
*/
}, {
key: 'getPositionUsingOffsets',
value: function getPositionUsingOffsets(offsets, box, arm) {
var /** @type {?} */limitTop = box.scrollTop - arm;
var /** @type {?} */limitBottom = box.scrollHeight - (box.portHeight + arm);
var /** @type {?} */value = Math.min(limitBottom, Math.max(0, limitTop));
return findPositionUsingOffsets(value, offsets);
}
/**
* @param {?} top
* @param {?} bottom
* @return {?}
*/
}, {
key: 'move',
value: function move(top, bottom) {
this.pad('top', top);
this.pad('bottom', bottom);
}
/**
* @return {?}
*/
}, {
key: 'getItemSize',
value: function getItemSize() {
var /** @type {?} */rowHeight = /** @type {?} */this.context.settings.rowHeight;
return isNumber(rowHeight) ? rowHeight : 0;
}
/**
* @param {?} box
* @return {?}
*/
}, {
key: 'getScrollSize',
value: function getScrollSize(box) {
return box.scrollHeight;
}
/**
* @param {?} box
* @return {?}
*/
}, {
key: 'getSize',
value: function getSize(box) {
return box.portHeight;
}
/**
* @param {?} items
* @return {?}
*/
}, {
key: 'recycleFactory',
value: function recycleFactory$$1(items) {
var _this2 = this;
var /** @type {?} */recycle = recycleFactory(items);
return function (index, count) {
var /** @type {?} */size = _this2.getItemSize();
if (size) {
return [];
}
return recycle(index, count);
};
}
/**
* @param {?} newBox
* @param {?} oldBox
* @return {?}
*/
}, {
key: 'hasChanges',
value: function hasChanges(newBox, oldBox) {
return !oldBox.portHeight || newBox.scrollTop !== oldBox.scrollTop;
}
/**
* @param {?} pos
* @param {?} value
* @return {?}
*/
}, {
key: 'pad',
value: function pad(pos, value) {
if (this.markup.hasOwnProperty(pos)) {
var /** @type {?} */mark = this.markup[pos];
mark.style.height = value + 'px';
} else {
this.elementRef.nativeElement.style['padding' + capitalize(pos)] = value + 'px';
}
}
}]);
return VscrollPortYDirective;
}(VscrollPort);
VscrollPortYDirective.decorators = [{ type: Directive, args: [{
selector: '[q-grid-vscroll-port-y]'
}] }];
/** @nocollapse */
VscrollPortYDirective.ctorParameters = function () {
return [{ type: NgZone }, { type: ElementRef }, { type: VscrollDirective }];
};
VscrollPortYDirective.propDecorators = {
context: [{ type: Input, args: ['q-grid-vscroll-port-y'] }]
};
function VscrollPortYDirective_tsickle_Closure_declarations() {
/** @type {?} */
VscrollPortYDirective.prototype.context;
/** @type {?} */
VscrollPortYDirective.prototype.markup;
/** @type {?} */
VscrollPortYDirective.prototype.layout;
/** @type {?} */
VscrollPortYDirective.prototype.zone;
/** @type {?} */
VscrollPortYDirective.prototype.elementRef;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var VscrollColumnDirective = function () {
/**
* @param {?} elementRef
* @param {?} port
*/
function VscrollColumnDirective(elementRef, port) {
classCallCheck(this, VscrollColumnDirective);
this.port = port;
this.column = elementRef.nativeElement;
}
/**
* @param {?} changes
* @return {?}
*/
createClass(VscrollColumnDirective, [{
key: 'ngOnChanges',
value: function ngOnChanges(changes) {
if (changes['index']) {
if (this.port.getItemSize()) {
this.ngOnChanges = null;
return;
}
var layout = this.layout,
settings = this.settings,
container = this.container,
column = this.column;
var rowHeight = settings.rowHeight;
this.ngOnChanges = function (e) {
if (e['index']) {
var /** @type {?} */change = e['index'];
var /** @type {?} */newIndex = change.currentValue;
var /** @type {?} */oldIndex = change.previousValue;
layout.removeItem(oldIndex);
var /** @type {?} */size = sizeFactory(rowHeight, container, column, newIndex);
layout.setItem(newIndex, size);
}
};
var /** @type {?} */firstChange = changes['index'];
var /** @type {?} */firstIndex = firstChange.currentValue;
var /** @type {?} */firstSize = sizeFactory(rowHeight, container, column, firstIndex);
layout.setItem(firstIndex, firstSize);
}
}
/**
* @return {?}
*/
}, {
key: 'ngOnDestroy',
value: function ngOnDestroy() {
this.port.layout.removeItem(this.index);
}
/**
* @return {?}
*/
}, {
key: 'layout',
get: function get$$1() {
return this.port.layout;
}
/**
* @return {?}
*/
}, {
key: 'settings',
get: function get$$1() {
return this.port.context.settings;
}
/**
* @return {?}
*/
}, {
key: 'container',
get: function get$$1() {
return this.port.context.container;
}
}]);
return VscrollColumnDirective;
}();
VscrollColumnDirective.decorators = [{ type: Directive, args: [{
selector: '[q-grid-vscroll-column]'
}] }];
/** @nocollapse */
VscrollColumnDirective.ctorParameters = function () {
return [{ type: ElementRef }, { type: VscrollPortYDirective }];
};
VscrollColumnDirective.propDecorators = {
index: [{ type: Input, args: ['q-grid-vscroll-column'] }]
};
function VscrollColumnDirective_tsickle_Closure_declarations() {
/** @type {?} */
VscrollColumnDirective.prototype.index;
/** @type {?} */
VscrollColumnDirective.prototype.column;
/** @type {?} */
VscrollColumnDirective.prototype.port;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var VscrollRowDirective = function () {
/**
* @param {?} elementRef
* @param {?} port
*/
function VscrollRowDirective(elementRef, port) {
classCallCheck(this, VscrollRowDirective);
this.port = port;
this.row = elementRef.nativeElement;
}
/**
* @param {?} changes
* @return {?}
*/
createClass(VscrollRowDirective, [{
key: 'ngOnChanges',
value: function ngOnChanges(changes) {
if (changes['index']) {
if (this.port.getItemSize()) {
this.ngOnChanges = null;
return;
}
var layout = this.layout,
settings = this.settings,
container = this.container,
row = this.row;
var rowHeight = settings.rowHeight;
this.ngOnChanges = function (e) {
if (e['index']) {
var /** @type {?} */change = e['index'];
var /** @type {?} */newIndex = change.currentValue;
var /** @type {?} */oldIndex = change.previousValue;
layout.removeItem(oldIndex);
var /** @type {?} */size = sizeFactory(rowHeight, container, row, newIndex);
layout.setItem(newIndex, size);
}
};
var /** @type {?} */firstChange = changes['index'];
var /** @type {?} */firstNewIndex = firstChange.currentValue;
var /** @type {?} */firstSize = sizeFactory(rowHeight, container, row, firstNewIndex);
layout.setItem(firstNewIndex, firstSize);
}
}
/**
* @return {?}
*/
}, {
key: 'ngOnDestroy',
value: function ngOnDestroy() {
this.port.layout.removeItem(this.index);
}
/**
* @return {?}
*/
}, {
key: 'layout',
get: function get$$1() {
return this.port.layout;
}
/**
* @return {?}
*/
}, {
key: 'settings',
get: function get$$1() {
return this.port.context.settings;
}
/**
* @return {?}
*/
}, {
key: 'container',
get: function get$$1() {
return this.port.context.container;
}
}]);
return VscrollRowDirective;
}();
VscrollRowDirective.decorators = [{ type: Directive, args: [{
selector: '[q-grid-vscroll-row]'
}] }];
/** @nocollapse */
VscrollRowDirective.ctorParameters = function () {
return [{ type: ElementRef }, { type: VscrollPortYDirective }];
};
VscrollRowDirective.propDecorators = {
index: [{ type: Input, args: ['q-grid-vscroll-row'] }]
};
function VscrollRowDirective_tsickle_Closure_declarations() {
/** @type {?} */
VscrollRowDirective.prototype.index;
/** @type {?} */
VscrollRowDirective.prototype.row;
/** @type {?} */
VscrollRowDirective.prototype.port;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var /** @type {?} */empty$3 = [];
var VscrollPipe = function () {
function VscrollPipe() {
classCallCheck(this, VscrollPipe);
}
createClass(VscrollPipe, [{
key: 'transform',
/**
* @param {?} data
* @param {?} context
* @return {?}
*/
value: function transform(data, context) {
Guard.notNull(context, 'context');
if (!data) {
return empty$3;
}
var /** @type {?} */count = data.length;
var container = context.container,
settings = context.settings;
container.update(count);
if (count) {
var items = container.items,
cursor = container.cursor;
var threshold = settings.threshold;
// We need to have a less number of virtual items on
// the bottom, as deferred loading is happen there should
// be a threshold place to draw several items below.
var /** @type {?} */first = cursor;
if (container.force || first !== container.position) {
var /** @type {?} */last = Math.min(cursor + threshold, count);
container.position = first;
items.length = last - first;
for (var /** @type {?} */i = first, /** @type {?} */j = 0; i < last; i++, j++) {
items[j] = data[i];
}
container.force = false;
}
return items;
}
return empty$3;
}
}]);
return VscrollPipe;
}();
VscrollPipe.decorators = [{ type: Pipe, args: [{
name: 'qGridVscroll',
pure: false
}] }];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var VscrollPortXDirective = function (_VscrollPort) {
inherits(VscrollPortXDirective, _VscrollPort);
/**
* @param {?} zone
* @param {?} elementRef
* @param {?} view
*/
function VscrollPortXDirective(zone, elementRef, view) {
classCallCheck(this, VscrollPortXDirective);
var _this = possibleConstructorReturn(this, (VscrollPortXDirective.__proto__ || Object.getPrototypeOf(VscrollPortXDirective)).call(this, view, elementRef.nativeElement));
_this.zone = zone;
_this.elementRef = elementRef;
_this.markup = {};
return _this;
}
/**
* @return {?}
*/
createClass(VscrollPortXDirective, [{
key: 'ngOnInit',
value: function ngOnInit() {
Guard.notNull(this.context, 'context');
this.layout = new VscrollLayout(this);
return new VscrollLink(this);
}
/**
* @return {?}
*/
}, {
key: 'reset',
value: function reset() {
this.view.resetX();
}
/**
* @param {?} f
* @return {?}
*/
}, {
key: 'emit',
value: function emit(f) {
this.zone.run(f);
}
/**
* @param {?} itemSize
* @param {?} box
* @param {?} arm
* @return {?}
*/
}, {
key: 'getPositionUsingItemSize',
value: function getPositionUsingItemSize(itemSize, box, arm) {
var /** @type {?} */limitTop = box.scrollLeft - arm;
var /** @type {?} */limitBottom = box.scrollWidth - (box.portWidth + arm);
var /** @type {?} */value = Math.min(limitBottom, Math.max(0, limitTop));
return findPositionUsingItemSize(value, itemSize);
}
/**
* @param {?} offsets
* @param {?} box
* @param {?} arm
* @return {?}
*/
}, {
key: 'getPositionUsingOffsets',
value: function getPositionUsingOffsets(offsets, box, arm) {
var /** @type {?} */limitTop = box.scrollLeft - arm;
var /** @type {?} */limitBottom = box.scrollHeight - (box.portWidth + arm);
var /** @type {?} */value = Math.min(limitBottom, Math.max(0, limitTop));
return findPositionUsingOffsets(value, offsets);
}
/**
* @param {?} left
* @param {?} right
* @return {?}
*/
}, {
key: 'move',
value: function move(left, right) {
this.pad('left', left);
this.pad('right', right);
}
/**
* @return {?}
*/
}, {
key: 'getItemSize',
value: function getItemSize() {
var /** @type {?} */columnWidth = /** @type {?} */this.context.settings.columnWidth;
return isNumber(columnWidth) ? columnWidth : 0;
}
/**
* @param {?} box
* @return {?}
*/
}, {
key: 'getScrollSize',
value: function getScrollSize(box) {
return box.scrollWidth;
}
/**
* @param {?} box
* @return {?}
*/
}, {
key: 'getSize',
value: function getSize(box) {
return box.portWidth;
}
/**
* @param {?} items
* @return {?}
*/
}, {
key: 'recycleFactory',
value: function recycleFactory$$1(items) {
var _this2 = this;
var /** @type {?} */recycle = recycleFactory(items);
return function (index, count) {
var /** @type {?} */size = _this2.getItemSize();
if (size) {
return [];
}
return recycle(index, count);
};
}
/**
* @param {?} newBox
* @param {?} oldBox
* @return {?}
*/
}, {
key: 'hasChanges',
value: function hasChanges(newBox, oldBox) {
return !oldBox.portWidth || newBox.scrollWidth !== oldBox.scrollWidth;
}
/**
* @param {?} pos
* @param {?} value
* @return {?}
*/
}, {
key: 'pad',
value: function pad(pos, value) {
if (this.markup.hasOwnProperty(pos)) {
var /** @type {?} */mark = this.markup[pos];
mark.style.width = value + 'px';
} else {
this.elementRef.nativeElement.style['padding' + capitalize(pos)] = value + 'px';
}
}
}]);
return VscrollPortXDirective;
}(VscrollPort);
VscrollPortXDirective.decorators = [{ type: Directive, args: [{
selector: '[q-grid-vscroll-port-x]'
}] }];
/** @nocollapse */
VscrollPortXDirective.ctorParameters = function () {
return [{ type: NgZone }, { type: ElementRef }, { type: VscrollDirective }];
};
VscrollPortXDirective.propDecorators = {
context: [{ type: Input, args: ['q-grid-vscroll-port-x'] }]
};
function VscrollPortXDirective_tsickle_Closure_declarations() {
/** @type {?} */
VscrollPortXDirective.prototype.context;
/** @type {?} */
VscrollPortXDirective.prototype.markup;
/** @type {?} */
VscrollPortXDirective.prototype.layout;
/** @type {?} */
VscrollPortXDirective.prototype.zone;
/** @type {?} */
VscrollPortXDirective.prototype.elementRef;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var VscrollMarkDirective = function () {
/**
* @param {?} elementRef
* @param {?} portX
* @param {?} portY
*/
function VscrollMarkDirective(elementRef, portX, portY) {
classCallCheck(this, VscrollMarkDirective);
this.elementRef = elementRef;
this.ports = [];
if (portX) {
this.ports.push(portX);
}
if (portY) {
this.ports.push(portY);
}
}
/**
* @return {?}
*/
createClass(VscrollMarkDirective, [{
key: 'ngOnInit',
value: function ngOnInit() {
var /** @type {?} */element = this.elementRef.nativeElement;
var /** @type {?} */key = this.key;
this.ports.forEach(function (port) {
return port.markup[key] = element;
});
}
/**
* @return {?}
*/
}, {
key: 'ngOnDestroy',
value: function ngOnDestroy() {
var /** @type {?} */key = this.key;
this.ports.forEach(function (port) {
return delete port.markup[key];
});
}
}]);
return VscrollMarkDirective;
}();
VscrollMarkDirective.decorators = [{ type: Directive, args: [{
selector: '[q-grid-vscroll-mark]'
}] }];
/** @nocollapse */
VscrollMarkDirective.ctorParameters = function () {
return [{ type: ElementRef }, { type: VscrollPortXDirective, decorators: [{ type: Optional }] }, { type: VscrollPortYDirective, decorators: [{ type: Optional }] }];
};
VscrollMarkDirective.propDecorators = {
key: [{ type: Input, args: ['q-grid-vscroll-mark'] }]
};
function VscrollMarkDirective_tsickle_Closure_declarations() {
/** @type {?} */
VscrollMarkDirective.prototype.key;
/** @type {?} */
VscrollMarkDirective.prototype.ports;
/** @type {?} */
VscrollMarkDirective.prototype.elementRef;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var VscrollModule = function VscrollModule() {
classCallCheck(this, VscrollModule);
};
VscrollModule.decorators = [{ type: NgModule, args: [{
declarations: [VscrollDirective, VscrollColumnDirective, VscrollRowDirective, VscrollMarkDirective, VscrollPortXDirective, VscrollPortYDirective, VscrollPipe],
exports: [VscrollDirective, VscrollColumnDirective, VscrollRowDirective, VscrollMarkDirective, VscrollPortXDirective, VscrollPortYDirective, VscrollPipe],
providers: [VscrollService]
}] }];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var InputModule = function InputModule() {
classCallCheck(this, InputModule);
};
InputModule.decorators = [{ type: NgModule, args: [{
declarations: [],
exports: []
}] }];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var TimeDirective = function () {
/**
* @param {?} templateRef
* @param {?} viewContainerRef
*/
function TimeDirective(templateRef, viewContainerRef) {
classCallCheck(this, TimeDirective);
viewContainerRef.createEmbeddedView(templateRef, this);
}
/**
* @param {?} previous
* @param {?} current
* @return {?}
*/
createClass(TimeDirective, [{
key: 'time',
value: function time(previous, current) {
var /** @type {?} */date = new Date(typeof current === 'string' ? Date.now() : previous);
var _current$split = current.split(':'),
_current$split2 = slicedToArray(_current$split, 3),
hours = _current$split2[0],
minutes = _current$split2[1],
seconds = _current$split2[2];
if (hours && minutes) {
date.setHours(+hours);
date.setMinutes(+minutes);
if (seconds) {
date.setSeconds(+seconds);
}
return date;
}
}
}]);
return TimeDirective;
}();
TimeDirective.decorators = [{ type: Directive, args: [{
selector: '[q-grid-time]'
}] }];
/** @nocollapse */
TimeDirective.ctorParameters = function () {
return [{ type: TemplateRef }, { type: ViewContainerRef }];
};
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var TimeModule = function TimeModule() {
classCallCheck(this, TimeModule);
};
TimeModule.decorators = [{ type: NgModule, args: [{
declarations: [TimeDirective],
exports: [TimeDirective]
}] }];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var /** @type {?} */DATEPATTERN_1 = /^\d{1,2}[\/|\-|\.|_]\d{1,2}[\/|\-|\.|_]\d{4}$/g; // Month/Day/Year Day/Month/Year
var /** @type {?} */DATEPATTERN_2 = /^\d{4}[\/|\-|\.|_]\d{1,2}[\/|\-|\.|_]\d{1,2}$/g;
var DateDirective = function () {
/**
* @param {?} templateRef
* @param {?} viewContainerRef
*/
function DateDirective(templateRef, viewContainerRef) {
classCallCheck(this, DateDirective);
viewContainerRef.createEmbeddedView(templateRef, this);
}
/**
* @param {?} text
* @return {?}
*/
createClass(DateDirective, [{
key: 'isValid',
value: function isValid(text) {
if (text.search(DATEPATTERN_1) === 0 || text.search(DATEPATTERN_2) === 0) {
return true;
}
return false;
}
}]);
return DateDirective;
}();
DateDirective.decorators = [{ type: Directive, args: [{
selector: '[q-grid-date]'
}] }];
/** @nocollapse */
DateDirective.ctorParameters = function () {
return [{ type: TemplateRef }, { type: ViewContainerRef }];
};
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var DateModule = function DateModule() {
classCallCheck(this, DateModule);
};
DateModule.decorators = [{ type: NgModule, args: [{
declarations: [DateDirective],
exports: [DateDirective]
}] }];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var CommandDirective = function () {
function CommandDirective() {
classCallCheck(this, CommandDirective);
this.shortcut = new Shortcut(new ShortcutDispatcher());
this.execute = new EventEmitter();
}
/**
* @return {?}
*/
createClass(CommandDirective, [{
key: 'ngOnInit',
value: function ngOnInit() {
var _this = this;
var /** @type {?} */command = this.command;
if (command && command.shortcut) {
var /** @type {?} */manager = new CommandManager(function (f) {
f();
_this.execute.emit();
}, this.commandContext);
this.shortcutOff = this.shortcut.register(manager, [command]);
}
}
/**
* @param {?} e
* @return {?}
*/
}, {
key: 'onKeyDown',
value: function onKeyDown(e) {
if (this.shortcutOff) {
this.shortcut.keyDown(e, 'command');
}
}
/**
* @return {?}
*/
}, {
key: 'ngOnDestroy',
value: function ngOnDestroy() {
if (this.shortcutOff) {
this.shortcutOff();
this.shortcutOff = null;
}
}
}]);
return CommandDirective;
}();
CommandDirective.decorators = [{ type: Directive, args: [{
selector: '[q-grid-command]'
}] }];
/** @nocollapse */
CommandDirective.ctorParameters = function () {
return [];
};
CommandDirective.propDecorators = {
command: [{ type: Input, args: ['q-grid-command'] }],
commandContext: [{ type: Input, args: ['q-grid-command-context'] }],
execute: [{ type: Output, args: ['q-grid-command-execute'] }],
onKeyDown: [{ type: HostListener, args: ['keydown', ['$event']] }]
};
function CommandDirective_tsickle_Closure_declarations() {
/** @type {?} */
CommandDirective.prototype.shortcut;
/** @type {?} */
CommandDirective.prototype.shortcutOff;
/** @type {?} */
CommandDirective.prototype.command;
/** @type {?} */
CommandDirective.prototype.commandContext;
/** @type {?} */
CommandDirective.prototype.execute;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var CommandModule = function CommandModule() {
classCallCheck(this, CommandModule);
};
CommandModule.decorators = [{ type: NgModule, args: [{
declarations: [CommandDirective],
exports: [CommandDirective]
}] }];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var CommonModule$1 = function CommonModule$$1() {
classCallCheck(this, CommonModule$$1);
};
CommonModule$1.decorators = [{ type: NgModule, args: [{
declarations: [],
exports: [DndModule, FocusModule, ResizeModule, LayoutModule, InputModule, RaiseModule, FileModule, VscrollModule, TimeModule, DateModule, CommandModule]
}] }];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var FootCoreComponent = function () {
/**
* @param {?} $view
* @param {?} $table
*/
function FootCoreComponent($view, $table) {
classCallCheck(this, FootCoreComponent);
this.$view = $view;
this.$table = $table;
}
/**
* @param {?} index
* @param {?} item
* @return {?}
*/
createClass(FootCoreComponent, [{
key: 'columnId',
value: function columnId(index, item) {
return item.model.key;
}
/**
* @param {?} index
* @return {?}
*/
}, {
key: 'rowId',
value: function rowId(index) {
return index;
}
}]);
return FootCoreComponent;
}();
FootCoreComponent.decorators = [{ type: Component, args: [{
selector: 'tfoot[q-grid-core-foot]',
template: "<tr *ngFor=\"let $row of $view.foot.rows; trackBy: rowId; index as $rowIndex\" [q-grid-core-trh]=\"$row\" [q-grid-core-index]=\"$rowIndex\" q-grid-core-source=\"foot\"> <td *ngFor=\"let $column of $view.foot.columns($row, $table.pin); trackBy: columnId; index as $columnIndex\" [attr.rowspan]=\"$column.rowspan\" [attr.colspan]=\"$column.colspan\"> <ng-container [q-grid-core-tf]=\"$column\"> </ng-container> </td> </tr>"
}] }];
/** @nocollapse */
FootCoreComponent.ctorParameters = function () {
return [{ type: ViewCoreService }, { type: TableCoreService }];
};
function FootCoreComponent_tsickle_Closure_declarations() {
/** @type {?} */
FootCoreComponent.prototype.$view;
/** @type {?} */
FootCoreComponent.prototype.$table;
}
var HeadCtrl = function () {
function HeadCtrl(model, view, bag) {
var _this = this;
classCallCheck(this, HeadCtrl);
this.model = model;
this.view = view;
this.bag = bag;
this.column = null;
this.pathFinder = new PathService(this.bag.head);
this.x = -1;
this.y = -1;
model.sceneChanged.watch(function (e) {
if (e.hasChanges('status')) {
var status = e.state.status;
switch (status) {
case 'start':
{
_this.highlight(null);
break;
}
case 'stop':
{
if (_this.x >= 0 && _this.y >= 0) {
var target = document.elementFromPoint(_this.x, _this.y);
if (target) {
var path = parents(target);
var cell = _this.pathFinder.cell(path);
if (cell) {
_this.highlight(cell.column);
return;
}
}
_this.highlight(null);
}
break;
}
}
}
});
}
createClass(HeadCtrl, [{
key: 'onMouseMove',
value: function onMouseMove(e) {
this.x = e.clientX;
this.y = e.clientY;
if (this.model.scene().status === 'stop') {
var cell = this.pathFinder.cell(eventPath(e));
if (cell) {
this.highlight(cell.column);
}
}
}
}, {
key: 'onMouseLeave',
value: function onMouseLeave() {
this.x = -1;
this.y = -1;
this.highlight(null);
}
}, {
key: 'highlight',
value: function highlight(column) {
var highlight = this.view.highlight;
if (!highlight.column.canExecute(column)) {
return;
}
if (this.column !== column) {
if (this.column) {
highlight.column.execute(this.column, false);
}
this.column = column;
if (column) {
highlight.column.execute(this.column, true);
}
}
}
}]);
return HeadCtrl;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var HeadCoreComponent = function (_NgComponent) {
inherits(HeadCoreComponent, _NgComponent);
/**
* @param {?} $view
* @param {?} $table
* @param {?} root
* @param {?} element
* @param {?} zone
*/
function HeadCoreComponent($view, $table, root, element, zone) {
classCallCheck(this, HeadCoreComponent);
var _this = possibleConstructorReturn(this, (HeadCoreComponent.__proto__ || Object.getPrototypeOf(HeadCoreComponent)).call(this));
_this.$view = $view;
_this.$table = $table;
_this.root = root;
_this.element = element;
_this.zone = zone;
return _this;
}
/**
* @return {?}
*/
createClass(HeadCoreComponent, [{
key: 'ngOnInit',
value: function ngOnInit() {
var /** @type {?} */element = this.element.nativeElement;
var /** @type {?} */ctrl = new HeadCtrl(this.root.model, this.$view, this.root.bag);
var /** @type {?} */listener = new EventListener(element, new EventManager(this));
this.zone.runOutsideAngular(function () {
listener.on('mousemove', function (e) {
return ctrl.onMouseMove(e);
});
listener.on('mouseleave', function (e) {
return ctrl.onMouseLeave(e);
});
});
}
/**
* @param {?} index
* @param {?} item
* @return {?}
*/
}, {
key: 'columnId',
value: function columnId(index, item) {
return item.model.key;
}
/**
* @param {?} index
* @return {?}
*/
}, {
key: 'rowId',
value: function rowId(index) {
return index;
}
}]);
return HeadCoreComponent;
}(NgComponent);
HeadCoreComponent.decorators = [{ type: Component, args: [{
selector: 'thead[q-grid-core-head]',
template: "<tr *ngFor=\"let $row of $view.head.rows; trackBy: rowId; index as $rowIndex\" [q-grid-core-trh]=\"$row\" [q-grid-core-index]=\"$rowIndex\" q-grid-core-source=\"head\"> <th *ngFor=\"let $column of $view.head.columns($row, $table.pin); trackBy: columnId; index as $columnIndex\" [attr.rowspan]=\"$column.rowspan\" [attr.colspan]=\"$column.colspan\" [q-grid-drag]=\"$view.head.drag\" [q-grid-drag-data]=\"$column.model.key\" q-grid-drop-area=\"head\" q-grid-resize-path=\"columns\" [q-grid-resize]=\"$column.model.key\" [q-grid-can-resize]=\"$view.head.resize.canExecute\"> <ng-container [q-grid-core-th]=\"$column\"> </ng-container> </th> </tr>"
}] }];
/** @nocollapse */
HeadCoreComponent.ctorParameters = function () {
return [{ type: ViewCoreService }, { type: TableCoreService }, { type: RootService }, { type: ElementRef }, { type: NgZone }];
};
function HeadCoreComponent_tsickle_Closure_declarations() {
/** @type {?} */
HeadCoreComponent.prototype.$view;
/** @type {?} */
HeadCoreComponent.prototype.$table;
/** @type {?} */
HeadCoreComponent.prototype.root;
/** @type {?} */
HeadCoreComponent.prototype.element;
/** @type {?} */
HeadCoreComponent.prototype.zone;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var LayerCoreComponent = function () {
/**
* @param {?} layerService
*/
function LayerCoreComponent(layerService) {
classCallCheck(this, LayerCoreComponent);
this.layerService = layerService;
}
/**
* @return {?}
*/
createClass(LayerCoreComponent, [{
key: 'isActive',
get: function get$$1() {
return this.layerService.count > 0;
}
}]);
return LayerCoreComponent;
}();
LayerCoreComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-core-layer',
template: "<div *ngIf=\"isActive\" class=\"q-grid-layer\"> <ng-container q-grid-core-layer></ng-container> </div>"
}] }];
/** @nocollapse */
LayerCoreComponent.ctorParameters = function () {
return [{ type: LayerService }];
};
function LayerCoreComponent_tsickle_Closure_declarations() {
/** @type {?} */
LayerCoreComponent.prototype.layerService;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var LayerCoreDirective =
/**
* @param {?} layerService
* @param {?} viewContainerRef
*/
function LayerCoreDirective(layerService, viewContainerRef) {
classCallCheck(this, LayerCoreDirective);
layerService.init(viewContainerRef);
};
LayerCoreDirective.decorators = [{ type: Directive, args: [{
selector: '[q-grid-core-layer]'
}] }];
/** @nocollapse */
LayerCoreDirective.ctorParameters = function () {
return [{ type: LayerService }, { type: ViewContainerRef }];
};
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var MarkupDirective = function () {
/**
* @param {?} root
* @param {?} element
* @param {?} table
*/
function MarkupDirective(root, element, table) {
classCallCheck(this, MarkupDirective);
this.root = root;
this.element = element;
this.table = table;
this.name = '';
}
/**
* @return {?}
*/
createClass(MarkupDirective, [{
key: 'ngOnInit',
value: function ngOnInit() {
this.root.markup[this.getName()] = this.element.nativeElement;
}
/**
* @return {?}
*/
}, {
key: 'ngOnDestroy',
value: function ngOnDestroy() {
delete this.root.markup[this.getName()];
}
/**
* @return {?}
*/
}, {
key: 'getName',
value: function getName() {
if (this.table && this.table.pin) {
return this.name + '-' + this.table.pin;
}
return this.name;
}
}]);
return MarkupDirective;
}();
MarkupDirective.decorators = [{ type: Directive, args: [{
selector: '[q-grid-markup]'
}] }];
/** @nocollapse */
MarkupDirective.ctorParameters = function () {
return [{ type: RootService }, { type: ElementRef }, { type: TableCoreService }];
};
MarkupDirective.propDecorators = {
name: [{ type: Input, args: ['q-grid-markup'] }]
};
function MarkupDirective_tsickle_Closure_declarations() {
/** @type {?} */
MarkupDirective.prototype.name;
/** @type {?} */
MarkupDirective.prototype.root;
/** @type {?} */
MarkupDirective.prototype.element;
/** @type {?} */
MarkupDirective.prototype.table;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var TableCoreComponent = function () {
/**
* @param {?} root
* @param {?} table
* @param {?} $view
*/
function TableCoreComponent(root, table, $view) {
classCallCheck(this, TableCoreComponent);
this.root = root;
this.table = table;
this.$view = $view;
this.pin = null;
}
/**
* @return {?}
*/
createClass(TableCoreComponent, [{
key: 'ngOnInit',
value: function ngOnInit() {
if (!this.pin) {
this.pin = null;
}
this.table.pin = this.pin;
}
/**
* @return {?}
*/
}, {
key: 'visibility',
get: function get$$1() {
return this.model.visibility();
}
/**
* @return {?}
*/
}, {
key: 'model',
get: function get$$1() {
return this.root.model;
}
}]);
return TableCoreComponent;
}();
TableCoreComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-core-table',
template: "<table q-grid-markup=\"table\"> <thead *ngIf=\"visibility.head\" q-grid-core-head q-grid-markup=\"head\" q-grid-animate=\"false\" q-grid-drop-area=\"head\" [q-grid-drop]=\"$view.head.drop\" q-grid-drag-direction=\"x\" [q-grid-drag-over]=\"$view.head.drop\"> </thead> <tbody *ngIf=\"visibility.pin.top\" class=\"q-grid-body-top\" pin=\"top\" q-grid-core-body q-grid-markup=\"body-top\" q-grid-animate=\"false\" tabindex=\"0\" q-grid-drop-area=\"body\" [q-grid-drop]=\"$view.row.drop\" q-grid-drag-direction=\"y\" [q-grid-drag-over]=\"$view.row.drop\"> </tbody> <tbody *ngIf=\"visibility.body\" q-grid-core-body q-grid-markup=\"body\" q-grid-animate=\"false\" tabindex=\"0\" q-grid-drop-area=\"body\" [q-grid-drop]=\"$view.row.drop\" q-grid-drag-direction=\"y\" q-grid-vscroll [q-grid-vscroll-port-y]=\"$view.scroll.y\" [q-grid-drag-over]=\"$view.row.drop\"> </tbody> <tbody *ngIf=\"visibility.pin.bottom\" class=\"q-grid-body-bottom\" pin=\"bottom\" q-grid-core-body q-grid-markup=\"body-bottom\" q-grid-animate=\"false\" tabindex=\"0\" q-grid-drop-area=\"body\" [q-grid-drop]=\"$view.row.drop\" q-grid-drag-direction=\"y\" [q-grid-drag-over]=\"$view.row.drop\"> </tbody> <tfoot *ngIf=\"visibility.foot\" q-grid-core-foot q-grid-markup=\"foot\" q-grid-animate=\"false\"> </tfoot> </table>",
providers: [TableCoreService]
}] }];
/** @nocollapse */
TableCoreComponent.ctorParameters = function () {
return [{ type: RootService }, { type: TableCoreService }, { type: ViewCoreService }];
};
TableCoreComponent.propDecorators = {
pin: [{ type: Input }]
};
function TableCoreComponent_tsickle_Closure_declarations() {
/** @type {?} */
TableCoreComponent.prototype.pin;
/** @type {?} */
TableCoreComponent.prototype.root;
/** @type {?} */
TableCoreComponent.prototype.table;
/** @type {?} */
TableCoreComponent.prototype.$view;
}
var toJson = JSON.stringify;
var toString$1 = Object.prototype.toString;
var hasCustomToString = function hasCustomToString(obj) {
return isFunction(obj.toString) && obj.toString !== toString$1;
};
var TdCtrl = function () {
function TdCtrl() {
classCallCheck(this, TdCtrl);
}
createClass(TdCtrl, null, [{
key: 'classify',
value: function classify(element, column) {
// @deprecated
element.classList.add(escapeAttr(GRID_PREFIX + '-' + column.key));
element.classList.add(escapeAttr(GRID_PREFIX + '-the-' + column.key));
element.classList.add(escapeAttr(GRID_PREFIX + '-' + column.type));
if (column.editor) {
element.classList.add(escapeAttr(GRID_PREFIX + '-' + column.editor));
}
}
}, {
key: 'viewMode',
value: function viewMode(element) {
element.classList.remove(GRID_PREFIX + '-edit');
}
}, {
key: 'editMode',
value: function editMode(element) {
element.classList.add(GRID_PREFIX + '-edit');
}
}, {
key: 'stringify',
value: function stringify(value) {
if (value == null) {
// null || undefined
return '';
}
switch (typeof value === 'undefined' ? 'undefined' : _typeof(value)) {
case 'string':
break;
case 'number':
value = '' + value;
break;
default:
if (hasCustomToString(value) && !isArray(value) && !isDate(value)) {
value = value.toString();
} else {
value = toJson(value);
}
}
return value;
}
}]);
return TdCtrl;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var /** @type {?} */classify = TdCtrl.classify;
var TdCoreAlignDirective = function () {
/**
* @param {?} element
*/
function TdCoreAlignDirective(element) {
classCallCheck(this, TdCoreAlignDirective);
this.element = element;
}
/**
* @return {?}
*/
createClass(TdCoreAlignDirective, [{
key: 'ngOnInit',
value: function ngOnInit() {
classify(this.element.nativeElement, this.columnView.model);
}
}]);
return TdCoreAlignDirective;
}();
TdCoreAlignDirective.decorators = [{ type: Directive, args: [{
selector: '[q-grid-core-td-align]'
}] }];
/** @nocollapse */
TdCoreAlignDirective.ctorParameters = function () {
return [{ type: ElementRef }];
};
TdCoreAlignDirective.propDecorators = {
columnView: [{ type: Input, args: ['q-grid-core-td-align'] }]
};
function TdCoreAlignDirective_tsickle_Closure_declarations() {
/** @type {?} */
TdCoreAlignDirective.prototype.columnView;
/** @type {?} */
TdCoreAlignDirective.prototype.element;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var TrCoreDirective = function () {
/**
* @param {?} $view
* @param {?} root
* @param {?} elementRef
*/
function TrCoreDirective($view, root, elementRef) {
classCallCheck(this, TrCoreDirective);
this.$view = $view;
this.root = root;
this.element = elementRef.nativeElement;
}
/**
* @return {?}
*/
createClass(TrCoreDirective, [{
key: 'ngOnInit',
/**
* @return {?}
*/
value: function ngOnInit() {
this.root.bag[this.source].addRow(this);
}
/**
* @return {?}
*/
}, {
key: 'ngOnDestroy',
value: function ngOnDestroy() {
this.root.bag[this.source].deleteRow(this);
}
}, {
key: 'index',
get: function get$$1() {
return this.$view.scroll.y.container.position + this.viewIndex;
}
}]);
return TrCoreDirective;
}();
TrCoreDirective.decorators = [{ type: Directive, args: [{
selector: '[q-grid-core-tr]'
}] }];
/** @nocollapse */
TrCoreDirective.ctorParameters = function () {
return [{ type: ViewCoreService }, { type: RootService }, { type: ElementRef }];
};
TrCoreDirective.propDecorators = {
viewIndex: [{ type: Input, args: ['q-grid-core-index'] }],
model: [{ type: Input, args: ['q-grid-core-tr'] }],
source: [{ type: Input, args: ['q-grid-core-source'] }]
};
function TrCoreDirective_tsickle_Closure_declarations() {
/** @type {?} */
TrCoreDirective.prototype.viewIndex;
/** @type {?} */
TrCoreDirective.prototype.model;
/** @type {?} */
TrCoreDirective.prototype.source;
/** @type {?} */
TrCoreDirective.prototype.element;
/** @type {?} */
TrCoreDirective.prototype.$view;
/** @type {?} */
TrCoreDirective.prototype.root;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @param {?} column
* @return {?}
*/
function canBuild(column) {
return column.type !== 'pad';
}
/**
* @param {?} source
* @param {?} column
* @param {?=} mode
* @return {?}
*/
function buildId(source, column) {
var mode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'view';
var key = /** @type {?} */column.key,
type = column.type,
itemType = column.itemType;
return source + '-' + mode + '-cell-' + type + '-of-' + itemType + '-the-' + key + '.tpl.html';
}
/**
* @param {?} source
* @param {?} column
* @param {?=} mode
* @return {?}
*/
function buildKeys(source, column) {
var mode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'view';
var key = /** @type {?} */column.key,
type = column.type,
itemType = column.itemType;
switch (mode) {
case 'view':
{
var /** @type {?} */result = [source + '-cell-' + type + '-the-' + key + '.tpl.html', source + '-cell-the-' + key + '.tpl.html', source + '-cell-' + type + '.tpl.html', source + '-cell.tpl.html', source + '-cell-text.tpl.html'];
if (itemType) {
result.splice.apply(result, [0, 0].concat([source + '-cell-' + type + '-of-' + itemType + '-the-' + key + '.tpl.html', source + '-cell-' + type + '-of-' + itemType + '.tpl.html']));
}
return result;
}
case 'edit':
{
type = column.editor || type;
var /** @type {?} */_result = [mode + '-cell-' + type + '-the-' + key + '.tpl.html', mode + '-cell-the-' + key + '.tpl.html', mode + '-cell-' + type + '.tpl.html', mode + '-cell.tpl.html', mode + '-cell-text.tpl.html'];
if (itemType) {
_result.splice.apply(_result, [0, 0].concat([mode + '-cell-' + type + '-of-' + itemType + '-the-' + key + '.tpl.html', mode + '-cell-' + type + '-of-' + itemType + '.tpl.html']));
}
return _result;
}
default:
throw new AppError('cell.service', 'Invalid mode \'' + mode + '\'');
}
}
var CellService = function () {
/**
* @param {?} templateService
*/
function CellService(templateService) {
classCallCheck(this, CellService);
this.templateService = templateService;
this.commits = new Map();
}
/**
* @param {?} source
* @param {?} column
* @param {?=} mode
* @return {?}
*/
createClass(CellService, [{
key: 'build',
value: function build(source, column) {
var mode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'view';
if (!canBuild(column)) {
return noop$1;
}
var /** @type {?} */id = buildId(source, column, mode);
var /** @type {?} */commits = this.commits;
var /** @type {?} */commit = commits.get(column.key);
if (commit) {
return commit;
}
var /** @type {?} */templateService = this.templateService;
var /** @type {?} */keys = buildKeys(source, column, mode);
var /** @type {?} */link = templateService.find(keys);
if (!link) {
throw new AppError('cell.service', 'Can\'t find template for ' + keys[0]);
}
commit = function commit(container, context) {
container.clear();
var /** @type {?} */createView = templateService.viewFactory(context);
createView(link, container);
};
commits.set(id, commit);
return commit;
}
}]);
return CellService;
}();
CellService.decorators = [{ type: Injectable }];
/** @nocollapse */
CellService.ctorParameters = function () {
return [{ type: TemplateService }];
};
function CellService_tsickle_Closure_declarations() {
/** @type {?} */
CellService.prototype.commits;
/** @type {?} */
CellService.prototype.templateService;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var /** @type {?} */classify$1 = TdCtrl.classify;
var TdCoreDirective = function () {
/**
* @param {?} $view
* @param {?} root
* @param {?} viewContainerRef
* @param {?} cellService
* @param {?} tr
* @param {?} element
*/
function TdCoreDirective($view, root, viewContainerRef, cellService, tr, element) {
classCallCheck(this, TdCoreDirective);
this.$view = $view;
this.root = root;
this.viewContainerRef = viewContainerRef;
this.cellService = cellService;
this.tr = tr;
this.$implicit = this;
this.element = null;
this.element = element.nativeElement.parentNode;
}
/**
* @return {?}
*/
createClass(TdCoreDirective, [{
key: 'ngOnInit',
value: function ngOnInit() {
this.root.bag.body.addCell(this);
classify$1(this.element, this.column);
this.mode('init');
}
/**
* @param {?} value
* @return {?}
*/
}, {
key: 'mode',
value: function mode(value) {
switch (value) {
case 'view':
case 'init':
{
var /** @type {?} */link = this.cellService.build('body', this.column, 'view');
link(this.viewContainerRef, this);
if (value !== 'init') {
this.element.classList.remove(GRID_PREFIX + '-edit');
}
break;
}
case 'edit':
{
var /** @type {?} */_link = this.cellService.build('body', this.column, 'edit');
_link(this.viewContainerRef, this);
this.element.classList.add(GRID_PREFIX + '-edit');
}
break;
default:
throw new AppError('td.core', 'Invalid mode ' + value);
}
}
/**
* @return {?}
*/
}, {
key: 'ngOnDestroy',
/**
* @return {?}
*/
value: function ngOnDestroy() {
this.root.bag.body.deleteCell(this);
}
}, {
key: 'value',
get: function get$$1() {
var column = this.column,
row = this.row,
rowIndex = this.rowIndex,
columnIndex = this.columnIndex;
return this.$view.body.render.getValue(row, column, rowIndex, columnIndex);
}
/**
* @param {?} value
* @return {?}
*/
,
set: function set$$1(value) {
var column = this.column,
row = this.row,
rowIndex = this.rowIndex,
columnIndex = this.columnIndex;
this.$view.body.render.setValue(row, column, value, rowIndex, columnIndex);
}
/**
* @return {?}
*/
}, {
key: 'label',
get: function get$$1() {
var column = this.column,
row = this.row,
rowIndex = this.rowIndex,
columnIndex = this.columnIndex;
return this.$view.body.render.getLabel(row, column, rowIndex, columnIndex);
}
/**
* @param {?} label
* @return {?}
*/
,
set: function set$$1(label) {
var column = this.column,
row = this.row,
rowIndex = this.rowIndex,
columnIndex = this.columnIndex;
this.$view.body.render.setLabel(row, column, label, rowIndex, columnIndex);
}
/**
* @return {?}
*/
}, {
key: 'column',
get: function get$$1() {
return this.columnView.model;
}
/**
* @return {?}
*/
}, {
key: 'columnIndex',
get: function get$$1() {
return this.columnView.columnIndex;
}
/**
* @return {?}
*/
}, {
key: 'row',
get: function get$$1() {
return this.tr.model;
}
/**
* @return {?}
*/
}, {
key: 'rowIndex',
get: function get$$1() {
return this.tr.index;
}
}]);
return TdCoreDirective;
}();
TdCoreDirective.decorators = [{ type: Directive, args: [{
selector: '[q-grid-core-td]'
}] }];
/** @nocollapse */
TdCoreDirective.ctorParameters = function () {
return [{ type: ViewCoreService }, { type: RootService }, { type: ViewContainerRef }, { type: CellService }, { type: TrCoreDirective }, { type: ElementRef }];
};
TdCoreDirective.propDecorators = {
columnView: [{ type: Input, args: ['q-grid-core-td'] }]
};
function TdCoreDirective_tsickle_Closure_declarations() {
/** @type {?} */
TdCoreDirective.prototype.$implicit;
/** @type {?} */
TdCoreDirective.prototype.columnView;
/** @type {?} */
TdCoreDirective.prototype.element;
/** @type {?} */
TdCoreDirective.prototype.$view;
/** @type {?} */
TdCoreDirective.prototype.root;
/** @type {?} */
TdCoreDirective.prototype.viewContainerRef;
/** @type {?} */
TdCoreDirective.prototype.cellService;
/** @type {?} */
TdCoreDirective.prototype.tr;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var TemplateDirective = function () {
/**
* @param {?} templateService
* @param {?} viewContainerRef
*/
function TemplateDirective(templateService, viewContainerRef) {
classCallCheck(this, TemplateDirective);
this.templateService = templateService;
this.viewContainerRef = viewContainerRef;
this.key = '';
this.context = null;
}
/**
* @return {?}
*/
createClass(TemplateDirective, [{
key: 'ngDoCheck',
value: function ngDoCheck() {
if (!this.viewRef) {
var /** @type {?} */link = this.templateService.find(this.key);
if (link) {
var /** @type {?} */createView = this.templateService.viewFactory(this.context);
this.viewRef = createView(link, this.viewContainerRef);
}
}
}
}]);
return TemplateDirective;
}();
TemplateDirective.decorators = [{ type: Directive, args: [{
selector: 'ng-container[key]'
}] }];
/** @nocollapse */
TemplateDirective.ctorParameters = function () {
return [{ type: TemplateService }, { type: ViewContainerRef }];
};
TemplateDirective.propDecorators = {
key: [{ type: Input }],
context: [{ type: Input }]
};
function TemplateDirective_tsickle_Closure_declarations() {
/** @type {?} */
TemplateDirective.prototype.viewRef;
/** @type {?} */
TemplateDirective.prototype.key;
/** @type {?} */
TemplateDirective.prototype.context;
/** @type {?} */
TemplateDirective.prototype.templateService;
/** @type {?} */
TemplateDirective.prototype.viewContainerRef;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var TemplateLink =
/**
* @param {?} template
* @param {?} context
*/
function TemplateLink(template, context) {
classCallCheck(this, TemplateLink);
this.template = template;
this.context = context;
};
function TemplateLink_tsickle_Closure_declarations() {
/** @type {?} */
TemplateLink.prototype.template;
/** @type {?} */
TemplateLink.prototype.context;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var TemplateLinkDirective = function () {
/**
* @param {?} templateLink
* @param {?} templateRef
*/
function TemplateLinkDirective(templateLink, templateRef) {
classCallCheck(this, TemplateLinkDirective);
this.templateLink = templateLink;
this.templateRef = templateRef;
this.key = '';
this.context = {};
}
/**
* @return {?}
*/
createClass(TemplateLinkDirective, [{
key: 'ngOnInit',
value: function ngOnInit() {
var /** @type {?} */link = new TemplateLink(this.templateRef, this.context);
this.templateLink.put(this.key, link);
}
}]);
return TemplateLinkDirective;
}();
TemplateLinkDirective.decorators = [{ type: Directive, args: [{
selector: 'ng-template[key]'
}] }];
/** @nocollapse */
TemplateLinkDirective.ctorParameters = function () {
return [{ type: TemplateLinkService }, { type: TemplateRef }];
};
TemplateLinkDirective.propDecorators = {
key: [{ type: Input }],
context: [{ type: Input }]
};
function TemplateLinkDirective_tsickle_Closure_declarations() {
/** @type {?} */
TemplateLinkDirective.prototype.key;
/** @type {?} */
TemplateLinkDirective.prototype.context;
/** @type {?} */
TemplateLinkDirective.prototype.templateLink;
/** @type {?} */
TemplateLinkDirective.prototype.templateRef;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var TemplateCacheDirective = function () {
/**
* @param {?} templateCache
* @param {?} templateRef
* @param {?} templateHost
*/
function TemplateCacheDirective(templateCache, templateRef, templateHost) {
classCallCheck(this, TemplateCacheDirective);
this.templateCache = templateCache;
this.templateRef = templateRef;
this.templateHost = templateHost;
this.key = '';
this.context = {};
}
/**
* @return {?}
*/
createClass(TemplateCacheDirective, [{
key: 'ngOnInit',
value: function ngOnInit() {
var /** @type {?} */link = new TemplateLink(this.templateRef, this.context);
if (this.templateHost) {
this.templateCache.put(this.templateHost.key(this.key), link);
} else {
this.templateCache.put(this.key, link);
}
}
}]);
return TemplateCacheDirective;
}();
TemplateCacheDirective.decorators = [{ type: Directive, args: [{
selector: 'ng-template[for]'
}] }];
/** @nocollapse */
TemplateCacheDirective.ctorParameters = function () {
return [{ type: TemplateCacheService }, { type: TemplateRef }, { type: TemplateHostService, decorators: [{ type: Optional }] }];
};
TemplateCacheDirective.propDecorators = {
key: [{ type: Input, args: ['for'] }],
context: [{ type: Input }]
};
function TemplateCacheDirective_tsickle_Closure_declarations() {
/** @type {?} */
TemplateCacheDirective.prototype.key;
/** @type {?} */
TemplateCacheDirective.prototype.context;
/** @type {?} */
TemplateCacheDirective.prototype.templateCache;
/** @type {?} */
TemplateCacheDirective.prototype.templateRef;
/** @type {?} */
TemplateCacheDirective.prototype.templateHost;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var TemplateModule = function TemplateModule() {
classCallCheck(this, TemplateModule);
};
TemplateModule.decorators = [{ type: NgModule, args: [{
declarations: [TemplateDirective, TemplateLinkDirective, TemplateCacheDirective],
exports: [TemplateDirective, TemplateLinkDirective, TemplateCacheDirective]
}] }];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var TrhCoreDirective = function () {
/**
* @param {?} $view
* @param {?} root
* @param {?} elementRef
*/
function TrhCoreDirective($view, root, elementRef) {
classCallCheck(this, TrhCoreDirective);
this.$view = $view;
this.root = root;
this.element = elementRef.nativeElement;
}
/**
* @return {?}
*/
createClass(TrhCoreDirective, [{
key: 'ngOnInit',
value: function ngOnInit() {
this.root.bag[this.source].addRow(this);
}
/**
* @return {?}
*/
}, {
key: 'ngOnDestroy',
value: function ngOnDestroy() {
this.root.bag[this.source].deleteRow(this);
}
}]);
return TrhCoreDirective;
}();
TrhCoreDirective.decorators = [{ type: Directive, args: [{
selector: '[q-grid-core-trh]'
}] }];
/** @nocollapse */
TrhCoreDirective.ctorParameters = function () {
return [{ type: ViewCoreService }, { type: RootService }, { type: ElementRef }];
};
TrhCoreDirective.propDecorators = {
index: [{ type: Input, args: ['q-grid-core-index'] }],
model: [{ type: Input, args: ['q-grid-core-trh'] }],
source: [{ type: Input, args: ['q-grid-core-source'] }]
};
function TrhCoreDirective_tsickle_Closure_declarations() {
/** @type {?} */
TrhCoreDirective.prototype.index;
/** @type {?} */
TrhCoreDirective.prototype.model;
/** @type {?} */
TrhCoreDirective.prototype.source;
/** @type {?} */
TrhCoreDirective.prototype.element;
/** @type {?} */
TrhCoreDirective.prototype.$view;
/** @type {?} */
TrhCoreDirective.prototype.root;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var /** @type {?} */classify$2 = TdCtrl.classify;
var TfCoreDirective = function () {
/**
* @param {?} $view
* @param {?} root
* @param {?} cellService
* @param {?} viewContainerRef
* @param {?} tr
* @param {?} element
*/
function TfCoreDirective($view, root, cellService, viewContainerRef, tr, element) {
classCallCheck(this, TfCoreDirective);
this.$view = $view;
this.root = root;
this.cellService = cellService;
this.viewContainerRef = viewContainerRef;
this.tr = tr;
this.element = null;
this.$implicit = this;
this.element = element.nativeElement.parentNode;
}
/**
* @return {?}
*/
createClass(TfCoreDirective, [{
key: 'ngOnInit',
value: function ngOnInit() {
var /** @type {?} */column = this.column;
var /** @type {?} */element = this.element;
this.root.bag.foot.addCell(this);
classify$2(element, column);
var /** @type {?} */link = this.cellService.build('foot', this.column);
link(this.viewContainerRef, this);
}
/**
* @return {?}
*/
}, {
key: 'mode',
/**
* @param {?} value
* @return {?}
*/
value: function mode(value) {
throw new AppError('tf-core.directive', value + ' mode is not supported');
}
/**
* @return {?}
*/
}, {
key: 'ngOnDestroy',
value: function ngOnDestroy() {
this.root.bag.foot.deleteCell(this);
}
}, {
key: 'value',
get: function get$$1() {
var /** @type {?} */column = this.column;
return this.$view.foot.value(column);
}
/**
* @return {?}
*/
}, {
key: 'label',
get: function get$$1() {
return this.label;
}
/**
* @return {?}
*/
}, {
key: 'column',
get: function get$$1() {
return this.columnView.model;
}
/**
* @return {?}
*/
}, {
key: 'columnIndex',
get: function get$$1() {
return this.columnView.columnIndex;
}
/**
* @return {?}
*/
}, {
key: 'row',
get: function get$$1() {
return this.tr.model;
}
/**
* @return {?}
*/
}, {
key: 'rowIndex',
get: function get$$1() {
return this.tr.index;
}
}]);
return TfCoreDirective;
}();
TfCoreDirective.decorators = [{ type: Directive, args: [{
selector: '[q-grid-core-tf]'
}] }];
/** @nocollapse */
TfCoreDirective.ctorParameters = function () {
return [{ type: ViewCoreService }, { type: RootService }, { type: CellService }, { type: ViewContainerRef }, { type: TrhCoreDirective }, { type: ElementRef }];
};
TfCoreDirective.propDecorators = {
columnView: [{ type: Input, args: ['q-grid-core-tf'] }]
};
function TfCoreDirective_tsickle_Closure_declarations() {
/** @type {?} */
TfCoreDirective.prototype.columnView;
/** @type {?} */
TfCoreDirective.prototype.element;
/** @type {?} */
TfCoreDirective.prototype.$implicit;
/** @type {?} */
TfCoreDirective.prototype.$view;
/** @type {?} */
TfCoreDirective.prototype.root;
/** @type {?} */
TfCoreDirective.prototype.cellService;
/** @type {?} */
TfCoreDirective.prototype.viewContainerRef;
/** @type {?} */
TfCoreDirective.prototype.tr;
}
var ThCtrl = function () {
function ThCtrl() {
classCallCheck(this, ThCtrl);
}
createClass(ThCtrl, null, [{
key: 'classify',
value: function classify(element, column) {
if (column.canEdit) {
element.classList.add(escapeAttr(GRID_PREFIX + '-can-edit'));
}
if (column.canResize) {
element.classList.add(escapeAttr(GRID_PREFIX + '-can-resize'));
}
if (column.canSort) {
element.classList.add(escapeAttr(GRID_PREFIX + '-can-sort'));
}
if (column.canMove) {
element.classList.add(escapeAttr(GRID_PREFIX + '-can-move'));
}
if (column.canFilter) {
element.classList.add(escapeAttr(GRID_PREFIX + '-can-filter'));
}
if (column.canHighlight) {
element.classList.add(escapeAttr(GRID_PREFIX + '-can-highlight'));
}
}
}]);
return ThCtrl;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var /** @type {?} */classifyTd = TdCtrl.classify;
var /** @type {?} */classifyTh = ThCtrl.classify;
var ThCoreDirective = function () {
/**
* @param {?} $view
* @param {?} root
* @param {?} viewContainerRef
* @param {?} cellService
* @param {?} tr
* @param {?} element
*/
function ThCoreDirective($view, root, viewContainerRef, cellService, tr, element) {
classCallCheck(this, ThCoreDirective);
this.$view = $view;
this.root = root;
this.viewContainerRef = viewContainerRef;
this.cellService = cellService;
this.tr = tr;
this.element = null;
this.$implicit = this;
this.element = element.nativeElement.parentNode;
}
/**
* @return {?}
*/
createClass(ThCoreDirective, [{
key: 'ngOnInit',
value: function ngOnInit() {
var /** @type {?} */column = this.column;
var /** @type {?} */element = this.element;
this.root.bag.head.addCell(this);
classifyTd(element, column);
classifyTh(element, column);
var /** @type {?} */target = column;
var /** @type {?} */source = 'head';
if (column.type === 'filter-row') {
var /** @type {?} */columnModel = /** @type {?} */column.model;
classifyTd(element, columnModel);
source = 'filter';
target = columnModel;
}
var /** @type {?} */link = this.cellService.build(source, target, 'view');
link(this.viewContainerRef, this);
}
/**
* @return {?}
*/
}, {
key: 'mode',
/**
* @param {?} value
* @return {?}
*/
value: function mode(value) {
throw new AppError('th-core.directive', value + ' mode is not supported');
}
/**
* @return {?}
*/
}, {
key: 'ngOnDestroy',
value: function ngOnDestroy() {
this.root.bag.head.deleteCell(this);
}
}, {
key: 'column',
get: function get$$1() {
return this.columnView.model;
}
/**
* @return {?}
*/
}, {
key: 'columnIndex',
get: function get$$1() {
return this.columnView.columnIndex;
}
/**
* @return {?}
*/
}, {
key: 'row',
get: function get$$1() {
return this.tr.model;
}
/**
* @return {?}
*/
}, {
key: 'rowIndex',
get: function get$$1() {
return this.tr.index;
}
}]);
return ThCoreDirective;
}();
ThCoreDirective.decorators = [{ type: Directive, args: [{
selector: '[q-grid-core-th]'
}] }];
/** @nocollapse */
ThCoreDirective.ctorParameters = function () {
return [{ type: ViewCoreService }, { type: RootService }, { type: ViewContainerRef }, { type: CellService }, { type: TrhCoreDirective }, { type: ElementRef }];
};
ThCoreDirective.propDecorators = {
columnView: [{ type: Input, args: ['q-grid-core-th'] }]
};
function ThCoreDirective_tsickle_Closure_declarations() {
/** @type {?} */
ThCoreDirective.prototype.columnView;
/** @type {?} */
ThCoreDirective.prototype.element;
/** @type {?} */
ThCoreDirective.prototype.value;
/** @type {?} */
ThCoreDirective.prototype.label;
/** @type {?} */
ThCoreDirective.prototype.$implicit;
/** @type {?} */
ThCoreDirective.prototype.$view;
/** @type {?} */
ThCoreDirective.prototype.root;
/** @type {?} */
ThCoreDirective.prototype.viewContainerRef;
/** @type {?} */
ThCoreDirective.prototype.cellService;
/** @type {?} */
ThCoreDirective.prototype.tr;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var ToolbarCoreComponent = function () {
function ToolbarCoreComponent() {
classCallCheck(this, ToolbarCoreComponent);
}
/**
* @return {?}
*/
createClass(ToolbarCoreComponent, [{
key: 'ngOnInit',
value: function ngOnInit() {}
}]);
return ToolbarCoreComponent;
}();
ToolbarCoreComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-core-toolbar',
template: "<ng-container key=\"toolbar-{{position}}.tpl.html\"></ng-container>"
}] }];
/** @nocollapse */
ToolbarCoreComponent.ctorParameters = function () {
return [];
};
ToolbarCoreComponent.propDecorators = {
position: [{ type: Input }]
};
function ToolbarCoreComponent_tsickle_Closure_declarations() {
/** @type {?} */
ToolbarCoreComponent.prototype.position;
}
var ViewCtrl = function () {
function ViewCtrl(model, view, gridService) {
classCallCheck(this, ViewCtrl);
this.model = model;
this.view = view;
this.watch(gridService);
this.ticking = false;
}
createClass(ViewCtrl, [{
key: 'invalidate',
value: function invalidate() {
var _this = this;
if (this.ticking) {
return;
}
var style = this.view.style;
if (style.needInvalidate()) {
this.ticking = true;
var rowMonitor = style.monitor.row;
var cellMonitor = style.monitor.cell;
Fastdom.mutate(function () {
// Apply mutate inside another mutate to ensure that style.invalidate is triggered last.
Fastdom.mutate(function () {
var domCell = cellMonitor.enter();
var domRow = rowMonitor.enter();
try {
style.invalidate(domCell, domRow);
} finally {
_this.ticking = false;
rowMonitor.exit();
cellMonitor.exit();
}
});
});
}
}
}, {
key: 'triggerLine',
value: function triggerLine(service, timeout) {
var job = jobLine(timeout);
var model = this.model;
var reduce = model.pipe().reduce;
var sessionUnits = [];
return function (source, changes, units) {
var _sessionUnits;
model.scene({ status: 'start' }, {
source: source
});
(_sessionUnits = sessionUnits).push.apply(_sessionUnits, toConsumableArray(units));
job(function () {
var jobUnits = reduce(sessionUnits, model);
sessionUnits = [];
jobUnits.forEach(function (pipe) {
return service.invalidate({
source: source,
changes: changes,
pipe: pipe,
why: pipe.why || 'refresh'
});
});
});
};
}
}, {
key: 'watch',
value: function watch(service) {
var triggerJob = this.triggerLine(service, 10);
var model = this.model;
var _model$pipe = model.pipe(),
triggers = _model$pipe.triggers;
var _model$data = model.data(),
pipe = _model$data.pipe;
if (pipe !== PipeUnit.default) {
triggerJob('grid', {}, [pipe]);
}
Object.keys(triggers).forEach(function (name) {
return model[name + 'Changed'].watch(function (e) {
if (e.tag.behavior === 'core') {
return;
}
var units = [];
var trigger = triggers[name];
for (var key in e.changes) {
var unit = trigger[key];
if (unit) {
units.push(unit);
}
}
if (units.length > 0) {
triggerJob(e.tag.source || name, e.changes, units);
}
});
});
}
}]);
return ViewCtrl;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var ViewCoreComponent = function (_NgComponent) {
inherits(ViewCoreComponent, _NgComponent);
/**
* @param {?} root
* @param {?} view
* @param {?} grid
* @param {?} zone
* @param {?} elementRef
* @param {?} cd
*/
function ViewCoreComponent(root, view, grid, zone, elementRef, cd) {
classCallCheck(this, ViewCoreComponent);
var _this = possibleConstructorReturn(this, (ViewCoreComponent.__proto__ || Object.getPrototypeOf(ViewCoreComponent)).call(this));
_this.root = root;
_this.view = view;
_this.grid = grid;
_this.zone = zone;
_this.elementRef = elementRef;
_this.cd = cd;
zone.onStable.subscribe(function () {
if (_this.root.isReady) {
var scene = _this.model.scene;
var _scene = scene(),
status = _scene.status;
if (status === 'push') {
scene({
status: 'stop'
}, {
source: 'grid.component',
behavior: 'core'
});
_this.ctrl.invalidate();
}
}
});
return _this;
}
/**
* @return {?}
*/
createClass(ViewCoreComponent, [{
key: 'ngDoCheck',
value: function ngDoCheck() {
var _model$scene = this.model.scene(),
status = _model$scene.status;
if (status === 'stop') {
this.ctrl.invalidate();
}
}
/**
* @return {?}
*/
}, {
key: 'ngOnInit',
value: function ngOnInit() {
var _this2 = this;
var model = this.model,
root = this.root,
view = this.view;
root.markup['view'] = this.elementRef.nativeElement;
// Views need to be init after `sceneChanged.watch` declaration
// to persist the right order of event sourcing.
view.init(model, root.table, root.commandManager);
var /** @type {?} */gridService = this.grid.service(model);
this.ctrl = new ViewCtrl(model, view, gridService);
model.sceneChanged.watch(function (e) {
if (e.hasChanges('status')) {
if (e.state.status === 'pull') {
_this2.cd.markForCheck();
// Run digest on the start of invalidate(e.g. for busy indicator)
// and on the ned of invalidate(e.g. to build the DOM)
_this2.zone.run(function () {
return model.scene({
status: 'push'
}, {
source: 'view-core.component',
behavior: 'core'
});
});
}
}
});
var /** @type {?} */virtualBody = /** @type {?} */this.root.table.body;
if (virtualBody.requestInvalidate) {
virtualBody.requestInvalidate.on(function () {
return _this2.ctrl.invalidate();
});
}
}
/**
* @return {?}
*/
}, {
key: 'model',
get: function get$$1() {
return this.root.model;
}
/**
* @return {?}
*/
}, {
key: 'visibility',
get: function get$$1() {
return this.model.visibility();
}
}]);
return ViewCoreComponent;
}(NgComponent);
ViewCoreComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-core-view',
template: "<q-grid-core-layer></q-grid-core-layer> <q-grid-core-table *ngIf=\"visibility.pin.left\" pin=\"left\" class=\"q-grid-table q-grid-table-left layout-column\"> </q-grid-core-table> <q-grid-core-table class=\"q-grid-table q-grid-table-center layout-column flex\"> </q-grid-core-table> <q-grid-core-table *ngIf=\"visibility.pin.right\" pin=\"right\" class=\"q-grid-table q-grid-table-right layout-column\"> </q-grid-core-table> <q-grid-cell-handler class=\"q-grid-cell-handler\"></q-grid-cell-handler>",
providers: [CellService]
}] }];
/** @nocollapse */
ViewCoreComponent.ctorParameters = function () {
return [{ type: RootService }, { type: ViewCoreService }, { type: GridService$1 }, { type: NgZone }, { type: ElementRef }, { type: ChangeDetectorRef }];
};
function ViewCoreComponent_tsickle_Closure_declarations() {
/** @type {?} */
ViewCoreComponent.prototype.ctrl;
/** @type {?} */
ViewCoreComponent.prototype.root;
/** @type {?} */
ViewCoreComponent.prototype.view;
/** @type {?} */
ViewCoreComponent.prototype.grid;
/** @type {?} */
ViewCoreComponent.prototype.zone;
/** @type {?} */
ViewCoreComponent.prototype.elementRef;
/** @type {?} */
ViewCoreComponent.prototype.cd;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var CoreModule = function CoreModule() {
classCallCheck(this, CoreModule);
};
CoreModule.decorators = [{ type: NgModule, args: [{
declarations: [BodyCoreComponent, CellHandlerComponent, FootCoreComponent, HeadCoreComponent, LayerCoreComponent, LayerCoreDirective, MarkupDirective, TableCoreComponent, TdCoreAlignDirective, TdCoreDirective, TfCoreDirective, ThCoreDirective, ToolbarCoreComponent, TrCoreDirective, TrhCoreDirective, ViewCoreComponent],
exports: [ViewCoreComponent, ToolbarCoreComponent],
imports: [TemplateModule, CommonModule, CommonModule$1],
providers: [VScrollService, TemplateCacheService, TemplateService]
}] }];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var ToolbarComponent =
/**
* @param {?} templateHost
*/
function ToolbarComponent(templateHost) {
classCallCheck(this, ToolbarComponent);
this.templateHost = templateHost;
templateHost.key = function (source) {
return 'toolbar-' + source + '.tpl.html';
};
};
ToolbarComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-toolbar',
template: '<ng-content></ng-content>',
providers: [TemplateHostService],
changeDetection: ChangeDetectionStrategy.OnPush
}] }];
/** @nocollapse */
ToolbarComponent.ctorParameters = function () {
return [{ type: TemplateHostService }];
};
function ToolbarComponent_tsickle_Closure_declarations() {
/** @type {?} */
ToolbarComponent.prototype.templateHost;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var RowComponent = function (_ModelComponent) {
inherits(RowComponent, _ModelComponent);
/**
* @param {?} root
* @param {?} templateHost
*/
function RowComponent(root, templateHost) {
classCallCheck(this, RowComponent);
var _this = possibleConstructorReturn(this, (RowComponent.__proto__ || Object.getPrototypeOf(RowComponent)).call(this, root));
_this.models = ['row'];
templateHost.key = function (source) {
return 'body-cell-row-' + source + '.tpl.html';
};
return _this;
}
return RowComponent;
}(ModelComponent);
RowComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-row',
template: '<ng-content></ng-content>',
providers: [TemplateHostService],
changeDetection: ChangeDetectionStrategy.OnPush
}] }];
/** @nocollapse */
RowComponent.ctorParameters = function () {
return [{ type: RootService }, { type: TemplateHostService }];
};
RowComponent.propDecorators = {
rowMode: [{ type: Input, args: ['mode'] }],
rowUnit: [{ type: Input, args: ['unit'] }],
rowCanMove: [{ type: Input, args: ['canMove'] }],
rowCanResize: [{ type: Input, args: ['canResize'] }],
rowHeight: [{ type: Input, args: ['height'] }]
};
function RowComponent_tsickle_Closure_declarations() {
/** @type {?} */
RowComponent.prototype.rowMode;
/** @type {?} */
RowComponent.prototype.rowUnit;
/** @type {?} */
RowComponent.prototype.rowCanMove;
/** @type {?} */
RowComponent.prototype.rowCanResize;
/** @type {?} */
RowComponent.prototype.rowHeight;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var LayerComponent =
/**
* @param {?} templateHost
*/
function LayerComponent(templateHost) {
classCallCheck(this, LayerComponent);
this.templateHost = templateHost;
templateHost.key = function (source) {
return 'layer-' + source + '.tpl.html';
};
};
LayerComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-layer',
template: '<ng-content></ng-content>',
providers: [TemplateHostService],
changeDetection: ChangeDetectionStrategy.OnPush
}] }];
/** @nocollapse */
LayerComponent.ctorParameters = function () {
return [{ type: TemplateHostService }];
};
function LayerComponent_tsickle_Closure_declarations() {
/** @type {?} */
LayerComponent.prototype.templateHost;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var MarkupDirective$1 = function () {
/**
* @param {?} root
* @param {?} element
*/
function MarkupDirective(root, element) {
classCallCheck(this, MarkupDirective);
this.root = root;
this.element = element;
this.name = '';
}
/**
* @return {?}
*/
createClass(MarkupDirective, [{
key: 'ngOnInit',
value: function ngOnInit() {
this.root.markup[this.name] = this.element.nativeElement;
}
/**
* @return {?}
*/
}, {
key: 'ngOnDestroy',
value: function ngOnDestroy() {
delete this.root.markup[this.name];
}
}]);
return MarkupDirective;
}();
MarkupDirective$1.decorators = [{ type: Directive, args: [{
selector: '[q-grid-markup]'
}] }];
/** @nocollapse */
MarkupDirective$1.ctorParameters = function () {
return [{ type: RootService }, { type: ElementRef }];
};
MarkupDirective$1.propDecorators = {
name: [{ type: Input, args: ['q-grid-markup'] }]
};
function MarkupDirective_tsickle_Closure_declarations$1() {
/** @type {?} */
MarkupDirective$1.prototype.name;
/** @type {?} */
MarkupDirective$1.prototype.root;
/** @type {?} */
MarkupDirective$1.prototype.element;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var MainModule = function MainModule() {
classCallCheck(this, MainModule);
};
MainModule.decorators = [{ type: NgModule, args: [{
declarations: [GridComponent, BoxComponent, ColumnListComponent, ColumnComponent, ToolbarComponent, RowComponent, LayerComponent, MarkupDirective$1],
exports: [GridComponent, ColumnListComponent, ColumnComponent, BoxComponent, ToolbarComponent, RowComponent, LayerComponent, CommonModule$1],
imports: [CoreModule, CommonModule, CommonModule$1],
providers: [GridService$1]
}] }];
/** @nocollapse */
MainModule.ctorParameters = function () {
return [];
};
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var ActionBarComponent = function () {
/**
* @param {?} plugin
*/
function ActionBarComponent(plugin) {
classCallCheck(this, ActionBarComponent);
this.plugin = plugin;
this.shortcutOff = null;
this.context = {
$implicit: this
};
}
/**
* @return {?}
*/
createClass(ActionBarComponent, [{
key: 'ngOnInit',
value: function ngOnInit() {
var _this = this;
var model = this.plugin.model;
model.actionChanged.watch(function (e) {
if (e.hasChanges('items')) {
if (_this.shortcutOff) {
_this.shortcutOff();
_this.shortcutOff = null;
}
var _model$action = model.action(),
shortcut = _model$action.shortcut,
manager = _model$action.manager;
_this.shortcutOff = shortcut.register(manager, e.state.items.map(function (act) {
return act.command;
}));
}
});
}
/**
* @return {?}
*/
}, {
key: 'ngOnDestroy',
/**
* @return {?}
*/
value: function ngOnDestroy() {
if (this.shortcutOff) {
this.shortcutOff();
this.shortcutOff = null;
}
}
}, {
key: 'actions',
get: function get$$1() {
return this.plugin.model.action().items;
}
}]);
return ActionBarComponent;
}();
ActionBarComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-action-bar',
template: "<ng-container key=\"plugin-action-bar.tpl.html\" [context]=\"context\"></ng-container> ",
providers: [PluginService]
}] }];
/** @nocollapse */
ActionBarComponent.ctorParameters = function () {
return [{ type: PluginService }];
};
function ActionBarComponent_tsickle_Closure_declarations() {
/** @type {?} */
ActionBarComponent.prototype.shortcutOff;
/** @type {?} */
ActionBarComponent.prototype.context;
/** @type {?} */
ActionBarComponent.prototype.plugin;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var ActionListComponent =
/**
* @param {?} plugin
*/
function ActionListComponent(plugin) {
classCallCheck(this, ActionListComponent);
this.plugin = plugin;
};
ActionListComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-actions',
template: '',
providers: [PluginService],
changeDetection: ChangeDetectionStrategy.OnPush
}] }];
/** @nocollapse */
ActionListComponent.ctorParameters = function () {
return [{ type: PluginService }];
};
function ActionListComponent_tsickle_Closure_declarations() {
/** @type {?} */
ActionListComponent.prototype.plugin;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var ActionCoreComponent = function () {
/**
* @param {?} plugin
*/
function ActionCoreComponent(plugin) {
classCallCheck(this, ActionCoreComponent);
this.plugin = plugin;
this.action = null;
this.context = {
$implicit: this
};
}
/**
* @return {?}
*/
createClass(ActionCoreComponent, [{
key: 'execute',
/**
* @return {?}
*/
value: function execute() {
var /** @type {?} */action = this.action;
if (!action) {
throw new AppError('action-core.component', 'Action shoud be setup');
}
return action.command.execute();
}
/**
* @return {?}
*/
}, {
key: 'canExecute',
value: function canExecute() {
var /** @type {?} */action = this.action;
if (!action) {
throw new AppError('action-core.component', 'Action should be setup');
}
return action.command.canExecute();
}
/**
* @return {?}
*/
}, {
key: 'model',
get: function get$$1() {
return this.plugin.model;
}
}, {
key: 'shortcut',
get: function get$$1() {
var /** @type {?} */action = this.action;
if (!action) {
throw new AppError('action-core.component', 'Action should be setup');
}
return action.command.shortcut;
}
/**
* @return {?}
*/
}, {
key: 'title',
get: function get$$1() {
var /** @type {?} */action = this.action;
if (!action) {
throw new AppError('action-core.component', 'Action should be setup');
}
var /** @type {?} */shortcut = this.shortcut;
return action.title + (shortcut ? ' (' + shortcut.toUpperCase() + ')' : '');
}
/**
* @return {?}
*/
}, {
key: 'icon',
get: function get$$1() {
var /** @type {?} */action = this.action;
if (!action) {
throw new AppError('action-core.component', 'Action shoud be setup');
}
return action.icon;
}
/**
* @return {?}
*/
}, {
key: 'templateUrl',
get: function get$$1() {
var /** @type {?} */action = this.action;
if (!action) {
throw new AppError('action-core.component', 'Action should be setup');
}
return action.templateUrl;
}
}]);
return ActionCoreComponent;
}();
ActionCoreComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-action-core',
template: "<ng-container key=\"plugin-action-core.tpl.html\" [context]=\"context\"></ng-container> ",
providers: [PluginService]
}] }];
/** @nocollapse */
ActionCoreComponent.ctorParameters = function () {
return [{ type: PluginService }];
};
ActionCoreComponent.propDecorators = {
action: [{ type: Input }]
};
function ActionCoreComponent_tsickle_Closure_declarations() {
/** @type {?} */
ActionCoreComponent.prototype.action;
/** @type {?} */
ActionCoreComponent.prototype.context;
/** @type {?} */
ActionCoreComponent.prototype.plugin;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var ActionComponent = function () {
/**
* @param {?} plugin
* @param {?} templateHost
*/
function ActionComponent(plugin, templateHost) {
var _this = this;
classCallCheck(this, ActionComponent);
this.plugin = plugin;
this.id = null;
this.title = null;
this.icon = null;
this.command = null;
templateHost.key = function (source) {
return 'action-' + source + '-' + _this.id + '.tpl.html';
};
}
/**
* @return {?}
*/
createClass(ActionComponent, [{
key: 'execute',
value: function execute() {
return this.command && this.command.execute();
}
/**
* @return {?}
*/
}, {
key: 'canExecute',
value: function canExecute() {
return this.command && this.command.canExecute();
}
/**
* @return {?}
*/
}, {
key: 'ngOnInit',
value: function ngOnInit() {
var /** @type {?} */model = this.model;
var /** @type {?} */hasCommand = !!this.command;
var /** @type {?} */command = hasCommand ? this.command : new Command();
var /** @type {?} */action = new Action(command, this.title, this.icon);
action.id = this.id;
var /** @type {?} */actions = Array.from(model.action().items);
actions.push(action);
model.action({ items: actions }, { source: 'action.component' });
if (!hasCommand) {
if (!this.id) {
throw new AppError('action.component', 'Command or id property is missed');
}
action.templateUrl = 'action-trigger-' + this.id + '.tpl.html';
}
}
/**
* @return {?}
*/
}, {
key: 'model',
get: function get$$1() {
return this.plugin.model;
}
}]);
return ActionComponent;
}();
ActionComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-action',
template: '',
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [TemplateHostService]
}] }];
/** @nocollapse */
ActionComponent.ctorParameters = function () {
return [{ type: PluginService }, { type: TemplateHostService }];
};
ActionComponent.propDecorators = {
id: [{ type: Input }],
title: [{ type: Input }],
icon: [{ type: Input }],
command: [{ type: Input }]
};
function ActionComponent_tsickle_Closure_declarations() {
/** @type {?} */
ActionComponent.prototype.id;
/** @type {?} */
ActionComponent.prototype.title;
/** @type {?} */
ActionComponent.prototype.icon;
/** @type {?} */
ActionComponent.prototype.command;
/** @type {?} */
ActionComponent.prototype.plugin;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var ActionBarModule = function ActionBarModule() {
classCallCheck(this, ActionBarModule);
};
ActionBarModule.decorators = [{ type: NgModule, args: [{
declarations: [ActionBarComponent, ActionListComponent, ActionComponent, ActionCoreComponent],
exports: [ActionBarComponent, ActionListComponent, ActionComponent, ActionCoreComponent],
imports: [TemplateModule]
}] }];
function predicateFactory(search) {
if (isObject(search)) {
// TODO: improve performance
var getters = Object.keys(search).map(function (key) {
var value = compileGet(key);
return { key: key, value: value };
});
var length = getters.length;
switch (length) {
case 0:
{
return yes;
}
case 1:
{
var get = getters[0];
var _pattern = search[get.key];
if (!_pattern) {
return yes;
}
var _expr = new RegExp(_pattern, 'gi');
return function (item) {
return _expr.test(get.value(item));
};
}
default:
{
return function (item) {
return getters.reduce(function (memo, get) {
return memo && new RegExp(search[get.key], 'gi').test(get.value(item)) || search[get.key] === '';
}, true);
};
}
}
}
var pattern = escapeRegexp(search);
var expr = new RegExp(pattern, 'gi');
return function (item) {
expr.lastIndex = 0;
return expr.test(item);
};
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var AutocompleteEditorComponent = function () {
/**
* @param {?} plugin
* @param {?} view
*/
function AutocompleteEditorComponent(plugin, view) {
classCallCheck(this, AutocompleteEditorComponent);
this.plugin = plugin;
this.view = view;
this.options = [];
this.context = {
$implicit: this
};
}
/**
* @param {?} search
* @return {?}
*/
createClass(AutocompleteEditorComponent, [{
key: 'filter',
value: function filter(search) {
var /** @type {?} */test = predicateFactory(search);
this.options = this.items.filter(function (item) {
return test(item);
});
}
/**
* @return {?}
*/
}, {
key: 'reset',
value: function reset() {
this.options = [];
}
/**
* @return {?}
*/
}, {
key: 'items',
get: function get$$1() {
return (/** @type {?} */this.cell.fetch.result
);
}
/**
* @return {?}
*/
}, {
key: 'title',
get: function get$$1() {
return this.cell.column.title;
}
/**
* @return {?}
*/
}, {
key: 'value',
get: function get$$1() {
return this.cell.value;
}
/**
* @param {?} value
* @return {?}
*/
,
set: function set$$1(value) {
this.cell.value = value;
}
/**
* @return {?}
*/
}, {
key: 'cell',
get: function get$$1() {
return this.view.edit.cell;
}
}]);
return AutocompleteEditorComponent;
}();
AutocompleteEditorComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-autocomplete-editor',
template: "<ng-container key=\"plugin-autocomplete-editor.tpl.html\" [context]=\"context\"></ng-container>",
providers: [PluginService]
}] }];
/** @nocollapse */
AutocompleteEditorComponent.ctorParameters = function () {
return [{ type: PluginService }, { type: ViewCoreService }];
};
function AutocompleteEditorComponent_tsickle_Closure_declarations() {
/** @type {?} */
AutocompleteEditorComponent.prototype.options;
/** @type {?} */
AutocompleteEditorComponent.prototype.context;
/** @type {?} */
AutocompleteEditorComponent.prototype.plugin;
/** @type {?} */
AutocompleteEditorComponent.prototype.view;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var AutocompleteEditorModule = function AutocompleteEditorModule() {
classCallCheck(this, AutocompleteEditorModule);
};
AutocompleteEditorModule.decorators = [{ type: NgModule, args: [{
declarations: [AutocompleteEditorComponent],
exports: [AutocompleteEditorComponent],
imports: [TemplateModule]
}] }];
var BackdropView = function BackdropView(context) {
var _this = this;
classCallCheck(this, BackdropView);
this.closeEvent = new Event$1();
var element = context.element;
var listener = new EventListener(element, new EventManager(this));
listener.on('mouseup', function (e) {
if (checkButtonCode(e, LEFT_BUTTON) || checkButtonCode(e, MIDDLE_BUTTON)) {
e.stopPropagation();
element.remove();
if (context.propagate !== false) {
var target = document.elementFromPoint(e.clientX, e.clientY);
var event = document.createEvent('MouseEvents');
event.initEvent('mouseup', true, true);
target.dispatchEvent(event);
}
_this.closeEvent.emit(e);
}
});
listener.on('keydown', function (e) {
return context.onKeyDown({ $event: e });
});
};
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var BackdropComponent = function () {
/**
* @param {?} backdropService
* @param {?} element
*/
function BackdropComponent(backdropService, element) {
var _this = this;
classCallCheck(this, BackdropComponent);
this.backdropService = backdropService;
this.closeEvent = new EventEmitter();
this.context = {
$implicit: this
};
backdropService.element = element;
var /** @type {?} */context = {
element: element.nativeElement,
onKeyDown: function onKeyDown() {},
propagate: false
};
var /** @type {?} */backdrop = new BackdropView(context);
backdrop.closeEvent.on(function () {
return _this.closeEvent.emit();
});
}
/**
* @return {?}
*/
createClass(BackdropComponent, [{
key: 'ngOnDestroy',
value: function ngOnDestroy() {
this.backdropService.element = null;
}
}]);
return BackdropComponent;
}();
BackdropComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-backdrop',
template: "<ng-container key=\"plugin-backdrop.tpl.html\" [context]=\"context\"></ng-container> ",
changeDetection: ChangeDetectionStrategy.OnPush
}] }];
/** @nocollapse */
BackdropComponent.ctorParameters = function () {
return [{ type: BackdropService }, { type: ElementRef }];
};
BackdropComponent.propDecorators = {
template: [{ type: ContentChild, args: [TemplateRef] }],
closeEvent: [{ type: Output, args: ['close'] }]
};
function BackdropComponent_tsickle_Closure_declarations() {
/** @type {?} */
BackdropComponent.prototype.template;
/** @type {?} */
BackdropComponent.prototype.closeEvent;
/** @type {?} */
BackdropComponent.prototype.context;
/** @type {?} */
BackdropComponent.prototype.backdropService;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var BackdropDirective = function () {
/**
* @param {?} zone
* @param {?} document
*/
function BackdropDirective(zone, document) {
classCallCheck(this, BackdropDirective);
this.zone = zone;
this.document = document;
this.selector = '';
this.close = new EventEmitter();
}
/**
* @param {?} value
* @return {?}
*/
createClass(BackdropDirective, [{
key: 'backdropHost',
set: function set$$1(value) {
var _this = this;
if (!value) {
if (this.backdrop) {
this.backdrop.remove();
this.backdrop = null;
}
return;
}
this.backdrop = this.document.createElement('div');
this.backdrop.classList.add('q-grid-backdrop');
this.backdrop.style.zIndex = '1000';
this.backdrop.addEventListener('click', function () {
_this.zone.runOutsideAngular(function () {
_this.close.emit();
_this.backdrop.remove();
_this.backdrop = null;
});
});
this.zone.runOutsideAngular(function () {
var /** @type {?} */element = /** @type {?} */document.querySelector(_this.selector);
element.style.zIndex = '1001';
element.parentElement.appendChild(_this.backdrop);
});
}
}]);
return BackdropDirective;
}();
BackdropDirective.decorators = [{ type: Directive, args: [{
selector: '[q-grid-backdrop]'
}] }];
/** @nocollapse */
BackdropDirective.ctorParameters = function () {
return [{ type: NgZone }, { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT$1] }] }];
};
BackdropDirective.propDecorators = {
selector: [{ type: Input, args: ['q-grid-backdrop-selector'] }],
close: [{ type: Output, args: ['q-grid-backdrop'] }],
backdropHost: [{ type: Input, args: ['q-grid-backdrop-active'] }]
};
function BackdropDirective_tsickle_Closure_declarations() {
/** @type {?} */
BackdropDirective.prototype.selector;
/** @type {?} */
BackdropDirective.prototype.close;
/** @type {?} */
BackdropDirective.prototype.backdrop;
/** @type {?} */
BackdropDirective.prototype.zone;
/** @type {?} */
BackdropDirective.prototype.document;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var BackdropModule = function BackdropModule() {
classCallCheck(this, BackdropModule);
};
BackdropModule.decorators = [{ type: NgModule, args: [{
declarations: [BackdropComponent, BackdropDirective],
exports: [BackdropComponent, BackdropDirective],
imports: [TemplateModule]
}] }];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var BoolEditorComponent = function () {
function BoolEditorComponent() {
classCallCheck(this, BoolEditorComponent);
this.autofocus = false;
this.valueChange = new EventEmitter();
this.context = {
$implicit: this
};
}
/**
* @return {?}
*/
createClass(BoolEditorComponent, [{
key: 'ngOnInit',
/**
* @return {?}
*/
value: function ngOnInit() {
var _this = this;
// entering edit mode means toggling boolean value
if (this.autofocus && this.column.editorOptions.trigger === 'click') {
Promise.resolve(null).then(function () {
return _this.value = _this.value === _this.trueValue ? _this.falseValue : _this.trueValue;
});
}
}
/**
* @return {?}
*/
}, {
key: 'isIndeterminate',
/**
* @return {?}
*/
value: function isIndeterminate() {
return this.column.isIndeterminate(this.value);
}
/**
* @return {?}
*/
}, {
key: 'value',
get: function get$$1() {
return this.state;
}
/**
* @param {?} value
* @return {?}
*/
,
set: function set$$1(value) {
if (value !== this.value) {
this.state = value;
this.valueChange.emit(value);
}
}
}, {
key: 'isChecked',
get: function get$$1() {
return this.column.isChecked(this.value);
}
/**
* @param {?} value
* @return {?}
*/
,
set: function set$$1(value) {
this.value = value ? this.trueValue : this.falseValue;
}
}, {
key: 'trueValue',
get: function get$$1() {
return this.column.trueValue;
}
/**
* @return {?}
*/
}, {
key: 'falseValue',
get: function get$$1() {
return this.column.falseValue;
}
}]);
return BoolEditorComponent;
}();
BoolEditorComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-bool-editor',
template: "<ng-container key=\"plugin-bool-editor.tpl.html\" [context]=\"context\"></ng-container> "
}] }];
/** @nocollapse */
BoolEditorComponent.ctorParameters = function () {
return [];
};
BoolEditorComponent.propDecorators = {
autofocus: [{ type: Input }],
column: [{ type: Input }],
label: [{ type: Input }],
valueChange: [{ type: Output }],
value: [{ type: Input }]
};
function BoolEditorComponent_tsickle_Closure_declarations() {
/** @type {?} */
BoolEditorComponent.prototype.state;
/** @type {?} */
BoolEditorComponent.prototype.autofocus;
/** @type {?} */
BoolEditorComponent.prototype.column;
/** @type {?} */
BoolEditorComponent.prototype.label;
/** @type {?} */
BoolEditorComponent.prototype.valueChange;
/** @type {?} */
BoolEditorComponent.prototype.context;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var BoolEditorModule = function BoolEditorModule() {
classCallCheck(this, BoolEditorModule);
};
BoolEditorModule.decorators = [{ type: NgModule, args: [{
declarations: [BoolEditorComponent],
exports: [BoolEditorComponent],
imports: [TemplateModule]
}] }];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var CaptionComponent = function () {
/**
* @param {?} plugin
*/
function CaptionComponent(plugin) {
classCallCheck(this, CaptionComponent);
this.plugin = plugin;
this.context = {
$implicit: this
};
}
/**
* @return {?}
*/
createClass(CaptionComponent, [{
key: 'value',
get: function get$$1() {
var _plugin$model$grid = this.plugin.model.grid(),
caption = _plugin$model$grid.caption,
title = _plugin$model$grid.title;
return caption || title;
}
}]);
return CaptionComponent;
}();
CaptionComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-caption',
template: "<ng-container key=\"plugin-caption.tpl.html\" [context]=\"context\"></ng-container> ",
providers: [PluginService]
}] }];
/** @nocollapse */
CaptionComponent.ctorParameters = function () {
return [{ type: PluginService }];
};
function CaptionComponent_tsickle_Closure_declarations() {
/** @type {?} */
CaptionComponent.prototype.context;
/** @type {?} */
CaptionComponent.prototype.plugin;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var CaptionModule = function CaptionModule() {
classCallCheck(this, CaptionModule);
};
CaptionModule.decorators = [{ type: NgModule, args: [{
declarations: [CaptionComponent],
exports: [CaptionComponent],
imports: [TemplateModule]
}] }];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var CellEditorComponent = function () {
function CellEditorComponent() {
classCallCheck(this, CellEditorComponent);
this.closeEvent = new EventEmitter();
this.context = {
$implicit: this
};
}
/**
* @return {?}
*/
createClass(CellEditorComponent, [{
key: 'close',
value: function close() {
this.closeEvent.emit();
}
}]);
return CellEditorComponent;
}();
CellEditorComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-cell-editor',
template: "<ng-container key=\"plugin-cell-editor.tpl.html\" [context]=\"context\"></ng-container> "
}] }];
CellEditorComponent.propDecorators = {
template: [{ type: ContentChild, args: [TemplateRef] }],
closeEvent: [{ type: Output, args: ['close'] }]
};
function CellEditorComponent_tsickle_Closure_declarations() {
/** @type {?} */
CellEditorComponent.prototype.template;
/** @type {?} */
CellEditorComponent.prototype.closeEvent;
/** @type {?} */
CellEditorComponent.prototype.context;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var CellEditorModule = function CellEditorModule() {
classCallCheck(this, CellEditorModule);
};
CellEditorModule.decorators = [{ type: NgModule, args: [{
declarations: [CellEditorComponent],
exports: [CellEditorComponent],
imports: [TemplateModule]
}] }];
var ColumnChooserModel = function ColumnChooserModel() {
classCallCheck(this, ColumnChooserModel);
this.resource = new Resource();
this.canAggregate = false;
this.canSort = true;
};
var ColumnChooserView = function () {
function ColumnChooserView(model, context) {
var _this = this;
classCallCheck(this, ColumnChooserView);
this.model = model;
this.context = context;
this.cancelEvent = new Event$1();
this.submitEvent = new Event$1();
this.dropEvent = new Event$1();
var setup = function setup() {
var _model$columnList = model.columnList(),
index = _model$columnList.index;
_this.tree = preOrderDFS([index], function (node, current, parent) {
var model = node.key.model;
var column = {
key: model.key,
title: model.title,
isVisible: model.isVisible,
canMove: model.canMove,
aggregation: model.aggregation
};
if (parent) {
var newNode = copy(node);
newNode.value = {
column: column,
isVisible: model.class === 'data' || model.class === 'cohort'
};
current.children.push(newNode);
return newNode;
}
current.value = { column: column, isVisible: true };
return current;
}, copy(index));
updateView();
};
var applyFilter = identity$1;
var updateView = function updateView() {
_this.listView = [];
_this.treeView = applyFilter(_this.tree);
preOrderDFS([_this.treeView], function (n) {
if (n.value.isVisible) {
_this.listView.push(n.value.column);
}
});
};
this.search = function (value) {
var search = ('' + value).toLowerCase();
applyFilter = search ? function (node) {
return filter(node, function (n) {
return n.value.column.title.toLowerCase().indexOf(search) >= 0;
});
} : identity$1;
updateView();
};
setup();
var toggle = function toggle(node, value) {
var children = node.children;
var column = node.value.column;
column.isVisible = value;
if (children.length) {
children.forEach(function (n) {
return toggle(n, value);
});
}
};
this.toggle = new Command({
source: 'column.chooser',
canExecute: function canExecute(node) {
return node.value.isVisible;
},
execute: function execute(node) {
return toggle(node, !_this.state(node));
}
});
this.toggleAll = new Command({
source: 'column.chooser',
execute: function execute() {
var state = !_this.stateAll();
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = _this.listView[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var column = _step.value;
column.isVisible = state;
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
}
});
this.defaults = new Command({
source: 'column.chooser',
execute: function execute() {
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = _this.listView[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var column = _step2.value;
column.isVisible = column.isDefault !== false;
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
}
});
this.toggleAggregation = new Command({ source: 'column.chooser' });
this.drop = new Command({
source: 'column.chooser',
canExecute: function canExecute(e) {
var node = e.dropData;
return node && node.value.column.canMove;
},
execute: function execute(e) {
switch (e.action) {
case 'over':
{
var src = e.dragData;
var trg = e.dropData;
if (src !== trg) {
var tree = _this.tree;
var oldPos = find(tree, function (node) {
return node === src;
});
var newPos = find(tree, function (node) {
return node === trg;
});
if (oldPos && newPos && newPos.path.indexOf(oldPos.node) < 0) {
var queue = oldPos.path.reverse();
var hostIndex = queue.findIndex(function (node) {
return node.children.length > 1;
});
if (hostIndex >= 0) {
var host = queue[hostIndex];
var target = queue[hostIndex - 1] || oldPos.node;
var index = host.children.indexOf(target);
host.children.splice(index, 1);
newPos.parent.children.splice(newPos.index, 0, target);
target.level = newPos.parent.level + 1;
preOrderDFS(target.children, function (node, root, parent) {
node.level = (root || parent).level + 1;
}, target);
_this.dropEvent.emit();
}
}
}
break;
}
}
}
});
this.drag = new Command({
source: 'column.chooser',
canExecute: function canExecute(e) {
var node = e.data;
return node && node.value.column.canMove;
}
});
this.submit = new Command({
source: 'column.chooser',
execute: function execute() {
var model = _this.model;
var index = preOrderDFS([_this.tree], function (node, current, parent) {
if (parent) {
var newNode = copy(node);
current.children.push(newNode);
var _node$value = node.value,
isVisible = _node$value.isVisible,
column = _node$value.column;
if (isVisible) {
var _model = newNode.key.model;
_model.isVisible = column.isVisible;
_model.aggregation = column.aggregation;
}
newNode.value = null;
return newNode;
}
current.value = null;
return current;
}, copy(_this.tree));
model.columnList({ index: index }, {
source: 'column.chooser.view'
});
_this.submitEvent.emit();
}
});
this.cancel = new Command({
source: 'column.chooser',
execute: function execute() {
return _this.cancelEvent.emit();
}
});
this.reset = new Command({
source: 'column.chooser',
execute: function execute() {
return setup();
}
});
this.aggregations = Object.getOwnPropertyNames(Aggregation).filter(function (key) {
return isFunction(Aggregation[key]);
});
model.dataChanged.on(function (e) {
if (e.tag.source === 'column.chooser') {
return;
}
if (e.hasChanges('columns')) {
setup();
}
});
model.columnListChanged.on(function (e) {
if (e.tag.source === 'column.chooser') {
return;
}
if (e.hasChanges('index')) {
setup();
}
});
}
createClass(ColumnChooserView, [{
key: 'state',
value: function state(node) {
var children = node.children;
var column = node.value.column;
if (children.length) {
return children.some(function (n) {
return n.value.column.isVisible;
});
}
return column.isVisible !== false;
}
}, {
key: 'stateAll',
value: function stateAll() {
return this.listView.every(function (c) {
return c.isVisible;
});
}
}, {
key: 'stateDefault',
value: function stateDefault() {
return this.listView.every(function (c) {
return c.isDefault !== false && c.isVisible !== false || c.isDefault === false && c.isVisible === false;
});
}
}, {
key: 'isIndeterminate',
value: function isIndeterminate() {
return !this.stateAll() && this.listView.some(function (c) {
return c.isVisible;
});
}
}, {
key: 'canAggregate',
get: function get$$1() {
return this.columnChooserCanAggregate;
}
}, {
key: 'resource',
get: function get$$1() {
return this.model.columnChooser().resource;
}
}]);
return ColumnChooserView;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var FocusAfterRender$1 = function () {
/**
* @param {?} plugin
* @param {?} root
*/
function FocusAfterRender$$1(plugin, root) {
classCallCheck(this, FocusAfterRender$$1);
var /** @type {?} */gridModel = plugin && plugin.model || root && root.model;
var /** @type {?} */domTable = plugin && plugin.table || root && root.table;
if (gridModel && domTable) {
this.focus = new FocusAfterRender(gridModel, domTable);
}
}
/**
* @return {?}
*/
createClass(FocusAfterRender$$1, [{
key: 'ngOnDestroy',
value: function ngOnDestroy() {
if (this.focus) {
this.focus.dispose();
this.focus = null;
}
}
}]);
return FocusAfterRender$$1;
}();
FocusAfterRender$1.decorators = [{ type: Injectable }];
/** @nocollapse */
FocusAfterRender$1.ctorParameters = function () {
return [{ type: PluginService, decorators: [{ type: Optional }] }, { type: RootService, decorators: [{ type: Optional }] }];
};
function FocusAfterRender_tsickle_Closure_declarations() {
/** @type {?} */
FocusAfterRender$1.prototype.focus;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var /** @type {?} */ColumnChooserName = 'qGridColumnChooser';
var RootContext = function () {
/**
* @param {?} ctrl
*/
function RootContext(ctrl) {
classCallCheck(this, RootContext);
this.ctrl = ctrl;
}
/**
* @return {?}
*/
createClass(RootContext, [{
key: 'node',
get: function get$$1() {
return this.ctrl.treeView;
}
}]);
return RootContext;
}();
function RootContext_tsickle_Closure_declarations() {
/** @type {?} */
RootContext.prototype.ctrl;
}
var ColumnChooserComponent = function () {
/**
* @param {?} plugin
* @param {?} zone
* @param {?} cd
* @param {?} focusAfterRender
*/
function ColumnChooserComponent(plugin, zone, cd, focusAfterRender) {
classCallCheck(this, ColumnChooserComponent);
this.plugin = plugin;
this.zone = zone;
this.cd = cd;
this.submitEvent = new EventEmitter();
this.cancelEvent = new EventEmitter();
}
/**
* @return {?}
*/
createClass(ColumnChooserComponent, [{
key: 'root',
value: function root() {
return { $implicit: new RootContext(this.context.$implicit) };
}
/**
* @param {?} changes
* @return {?}
*/
}, {
key: 'ngOnChanges',
value: function ngOnChanges(changes) {
this.plugin.keep(changes, ['columnChooser']);
}
/**
* @return {?}
*/
}, {
key: 'ngOnInit',
value: function ngOnInit() {
var _this = this;
var /** @type {?} */context = {
name: ColumnChooserName
};
var /** @type {?} */columnChooser = new ColumnChooserView(this.plugin.model, context);
columnChooser.submitEvent.on(function () {
return _this.submitEvent.emit();
});
columnChooser.cancelEvent.on(function () {
return _this.cancelEvent.emit();
});
columnChooser.dropEvent.on(function () {
_this.cd.markForCheck();
_this.zone.run(noop$1);
});
this.context = { $implicit: columnChooser, plugin: this };
}
}]);
return ColumnChooserComponent;
}();
ColumnChooserComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-column-chooser',
template: "<ng-container key=\"column-chooser.tpl.html\" [context]=\"context\"></ng-container> ",
providers: [FocusAfterRender$1, PluginService]
}] }];
/** @nocollapse */
ColumnChooserComponent.ctorParameters = function () {
return [{ type: PluginService }, { type: NgZone }, { type: ChangeDetectorRef }, { type: FocusAfterRender$1 }];
};
ColumnChooserComponent.propDecorators = {
columnChooserCanAggregate: [{ type: Input, args: ['canAggregate'] }],
submitEvent: [{ type: Output, args: ['submit'] }],
cancelEvent: [{ type: Output, args: ['cancel'] }]
};
function ColumnChooserComponent_tsickle_Closure_declarations() {
/** @type {?} */
ColumnChooserComponent.prototype.columnChooserCanAggregate;
/** @type {?} */
ColumnChooserComponent.prototype.submitEvent;
/** @type {?} */
ColumnChooserComponent.prototype.cancelEvent;
/** @type {?} */
ColumnChooserComponent.prototype.context;
/** @type {?} */
ColumnChooserComponent.prototype.plugin;
/** @type {?} */
ColumnChooserComponent.prototype.zone;
/** @type {?} */
ColumnChooserComponent.prototype.cd;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var ColumnChooserModule = function ColumnChooserModule() {
classCallCheck(this, ColumnChooserModule);
};
ColumnChooserModule.decorators = [{ type: NgModule, args: [{
imports: [FormsModule, TemplateModule],
exports: [ColumnChooserComponent],
declarations: [ColumnChooserComponent]
}] }];
var ColumnFilterModel = function ColumnFilterModel() {
classCallCheck(this, ColumnFilterModel);
this.threshold = 20;
this.source = 'data';
};
var ColumnFilterView = function () {
function ColumnFilterView(model, context) {
classCallCheck(this, ColumnFilterView);
this.model = model;
this.key = context.key;
this.cancelEvent = new Event$1();
this.submitEvent = new Event$1();
this.resetEvent = new Event$1();
var filterBy = this.model.filter().by[this.key];
this.by = new Set(filterBy && filterBy.items || []);
this.byBlanks = !!(filterBy && filterBy.blanks);
this.items = [];
Object.assign(this, this.commands);
this.column = find$1(this.model.columnList().line, this.key);
this.title = this.column.title;
this.getValue = getFactory$1(this.column);
}
createClass(ColumnFilterView, [{
key: 'state',
value: function state(item) {
return this.by.has(item);
}
}, {
key: 'stateAll',
value: function stateAll() {
return this.items.every(this.state.bind(this)) && (!this.hasBlanks || this.byBlanks);
}
}, {
key: 'isIndeterminate',
value: function isIndeterminate() {
return !this.stateAll() && (this.items.some(this.state.bind(this)) || this.byBlanks);
}
}, {
key: 'isEmpty',
value: function isEmpty() {
return !!this.by.size || this.byBlanks;
}
}, {
key: 'commands',
get: function get$$1() {
var _this = this;
return {
toggle: new Command({
source: 'column.filter.view',
execute: function execute(item) {
if (_this.by.has(item)) {
_this.by.delete(item);
} else {
_this.by.add(item);
}
}
}),
toggleAll: new Command({
source: 'column.filter.view',
execute: function execute(search) {
var state = !_this.stateAll();
if (state) {
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = _this.items[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var item = _step.value;
_this.by.add(item);
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
} else {
if (search) {
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = _this.by[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var _item = _step2.value;
if (_this.items.indexOf(_item) >= 0) {
_this.by.delete(_item);
}
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
} else {
_this.by.clear();
}
}
_this.byBlanks = _this.hasBlanks && state;
}
}),
submit: new Command({
source: 'column.filter.view',
execute: function execute() {
var model = _this.model;
var by = clone(model.filter().by);
var filter = by[_this.key] || {};
filter.items = Array.from(_this.by);
filter.blanks = _this.byBlanks;
if (filter.items.length || filter.blanks || filter.expression) {
by[_this.key] = filter;
} else {
delete by[_this.key];
}
model.filter({ by: by }, { source: 'column.filter.view' });
_this.submitEvent.emit();
}
}),
cancel: new Command({
source: 'column.filter.view',
execute: function execute() {
return _this.cancelEvent.emit();
}
}),
reset: new Command({
source: 'column.filter.view',
execute: function execute() {
_this.by = new Set();
_this.byBlanks = false;
_this.resetEvent.emit();
}
})
};
}
}]);
return ColumnFilterView;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var ColumnFilterComponent = function () {
/**
* @param {?} plugin
* @param {?} vscroll
* @param {?} qgrid
* @param {?} focusAfterRender
*/
function ColumnFilterComponent(plugin, vscroll, qgrid, focusAfterRender) {
classCallCheck(this, ColumnFilterComponent);
this.plugin = plugin;
this.vscroll = vscroll;
this.qgrid = qgrid;
this.search = '';
this.submitEvent = new EventEmitter();
this.cancelEvent = new EventEmitter();
}
/**
* @return {?}
*/
createClass(ColumnFilterComponent, [{
key: 'ngOnInit',
value: function ngOnInit() {
var _this = this;
var model = this.plugin.model;
var /** @type {?} */key = this.column.key;
var /** @type {?} */context = { key: key };
var /** @type {?} */columnFilter = new ColumnFilterView(model, context);
columnFilter.submitEvent.on(function () {
return _this.submitEvent.emit();
});
columnFilter.cancelEvent.on(function () {
return _this.cancelEvent.emit();
});
var /** @type {?} */vscrollContext = this.vscroll.context({
threshold: model.columnFilter().threshold,
fetch: function fetch(skip, take, d) {
var /** @type {?} */filterState = model.filter();
var /** @type {?} */service = _this.qgrid.service(model);
// We need to close items property for correct reset behavior
var /** @type {?} */items = columnFilter.items;
if (filterState.fetch !== _this.qgrid.noop) {
var /** @type {?} */cancelBusy = service.busy();
var /** @type {?} */select = filterState.fetch(key, {
skip: skip,
take: take,
value: columnFilter.getValue,
search: '' + _this.search,
// @deprecated
filter: '' + _this.search
});
var /** @type {?} */fetch = new Fetch(select);
fetch.run();
fetch.busy.then(function (page) {
items.push.apply(items, toConsumableArray(page));
d.resolve(items.length + (page.length === take ? take : 0));
cancelBusy();
}).catch(cancelBusy);
} else {
var /** @type {?} */_cancelBusy = service.busy();
var /** @type {?} */isBlank = model.filter().assertFactory().isNull;
try {
if (!items.length) {
var /** @type {?} */source = model[model.columnFilter().source];
var /** @type {?} */_items = source().rows.map(columnFilter.getValue);
if (columnFilter.column.type === 'array') {
_items = flatten(_items);
}
var /** @type {?} */uniqItems = uniq(_items);
var /** @type {?} */notBlankItems = uniqItems.filter(function (x) {
return !isBlank(x);
});
// TODO: improve search algo
var /** @type {?} */search = ('' + _this.search).toLowerCase();
var /** @type {?} */filteredItems = search ? notBlankItems.filter(function (x) {
return ('' + x).toLowerCase().indexOf(search) >= 0;
}) : notBlankItems;
filteredItems.sort(columnFilter.column.compare);
columnFilter.items = filteredItems;
columnFilter.hasBlanks = notBlankItems.length !== uniqItems.length && (!search || 'blanks'.indexOf(search.toLowerCase()) >= 0);
}
d.resolve(columnFilter.items.length);
} finally {
_cancelBusy();
}
}
}
});
this.vscrollContext = vscrollContext;
this.context = {
$implicit: columnFilter,
plugin: this,
vscroll: vscrollContext
};
}
/**
* @return {?}
*/
}, {
key: 'reset',
value: function reset() {
this.context.$implicit.items = [];
this.vscrollContext.container.reset();
}
/**
* @param {?} index
* @return {?}
*/
}, {
key: 'rowId',
value: function rowId(index) {
return index;
}
}]);
return ColumnFilterComponent;
}();
ColumnFilterComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-column-filter',
template: "<ng-container key=\"plugin-column-filter.tpl.html\" [context]=\"context\"></ng-container>",
providers: [FocusAfterRender$1, PluginService]
}] }];
/** @nocollapse */
ColumnFilterComponent.ctorParameters = function () {
return [{ type: PluginService }, { type: VscrollService }, { type: GridService$1 }, { type: FocusAfterRender$1 }];
};
ColumnFilterComponent.propDecorators = {
column: [{ type: Input }],
search: [{ type: Input }],
submitEvent: [{ type: Output, args: ['submit'] }],
cancelEvent: [{ type: Output, args: ['cancel'] }]
};
function ColumnFilterComponent_tsickle_Closure_declarations() {
/** @type {?} */
ColumnFilterComponent.prototype.column;
/** @type {?} */
ColumnFilterComponent.prototype.search;
/** @type {?} */
ColumnFilterComponent.prototype.submitEvent;
/** @type {?} */
ColumnFilterComponent.prototype.cancelEvent;
/** @type {?} */
ColumnFilterComponent.prototype.context;
/** @type {?} */
ColumnFilterComponent.prototype.vscrollContext;
/** @type {?} */
ColumnFilterComponent.prototype.plugin;
/** @type {?} */
ColumnFilterComponent.prototype.vscroll;
/** @type {?} */
ColumnFilterComponent.prototype.qgrid;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var ColumnFilterTriggerComponent = function () {
/**
* @param {?} plugin
* @param {?} view
* @param {?} element
*/
function ColumnFilterTriggerComponent(plugin, view, element) {
classCallCheck(this, ColumnFilterTriggerComponent);
this.plugin = plugin;
this.view = view;
this.element = element;
this.context = {
$implicit: this
};
}
/**
* @return {?}
*/
createClass(ColumnFilterTriggerComponent, [{
key: 'ngOnInit',
value: function ngOnInit() {
var _this = this;
this.plugin.model.filterChanged.watch(function (e) {
if (e.hasChanges('by')) {
if (_this.view.filter.has(_this.column)) {
_this.element.nativeElement.classList.add(GRID_PREFIX + '-active');
} else {
_this.element.nativeElement.classList.remove(GRID_PREFIX + '-active');
}
}
});
}
}]);
return ColumnFilterTriggerComponent;
}();
ColumnFilterTriggerComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-column-filter-trigger',
template: "<ng-container key=\"plugin-column-filter-trigger.tpl.html\" [context]=\"context\"></ng-container>",
providers: [PluginService]
}] }];
/** @nocollapse */
ColumnFilterTriggerComponent.ctorParameters = function () {
return [{ type: PluginService }, { type: ViewCoreService }, { type: ElementRef }];
};
ColumnFilterTriggerComponent.propDecorators = {
column: [{ type: Input }]
};
function ColumnFilterTriggerComponent_tsickle_Closure_declarations() {
/** @type {?} */
ColumnFilterTriggerComponent.prototype.column;
/** @type {?} */
ColumnFilterTriggerComponent.prototype.context;
/** @type {?} */
ColumnFilterTriggerComponent.prototype.plugin;
/** @type {?} */
ColumnFilterTriggerComponent.prototype.view;
/** @type {?} */
ColumnFilterTriggerComponent.prototype.element;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var ColumnFilterByComponent = function () {
function ColumnFilterByComponent() {
classCallCheck(this, ColumnFilterByComponent);
this.byBlanksChange = new EventEmitter();
this.context = {
$implicit: this
};
}
/**
* @return {?}
*/
createClass(ColumnFilterByComponent, [{
key: 'remove',
/**
* @param {?} item
* @return {?}
*/
value: function remove(item) {
this.by.delete(item);
}
/**
* @return {?}
*/
}, {
key: 'removeByBlanks',
value: function removeByBlanks() {
this.byBlanksChange.emit(false);
}
}, {
key: 'isBlanks',
get: function get$$1() {
return this.byBlanks;
}
}]);
return ColumnFilterByComponent;
}();
ColumnFilterByComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-column-filter-by',
template: "<ng-container key=\"plugin-column-filter-by.tpl.html\" [context]=\"context\"></ng-container> "
}] }];
/** @nocollapse */
ColumnFilterByComponent.ctorParameters = function () {
return [];
};
ColumnFilterByComponent.propDecorators = {
by: [{ type: Input }],
column: [{ type: Input }],
byBlanks: [{ type: Input }],
byBlanksChange: [{ type: Output }]
};
function ColumnFilterByComponent_tsickle_Closure_declarations() {
/** @type {?} */
ColumnFilterByComponent.prototype.by;
/** @type {?} */
ColumnFilterByComponent.prototype.column;
/** @type {?} */
ColumnFilterByComponent.prototype.byBlanks;
/** @type {?} */
ColumnFilterByComponent.prototype.byBlanksChange;
/** @type {?} */
ColumnFilterByComponent.prototype.context;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var ColumnFilterItemListDirective =
/**
* @param {?} cellService
*/
function ColumnFilterItemListDirective(cellService) {
classCallCheck(this, ColumnFilterItemListDirective);
this.cellService = cellService;
};
ColumnFilterItemListDirective.decorators = [{ type: Directive, args: [{
selector: '[q-grid-column-filter-item-list]',
providers: [CellService]
}] }];
/** @nocollapse */
ColumnFilterItemListDirective.ctorParameters = function () {
return [{ type: CellService }];
};
ColumnFilterItemListDirective.propDecorators = {
column: [{ type: Input, args: ['q-grid-column-filter-item-list'] }],
search: [{ type: Input, args: ['q-grid-column-filter-search'] }]
};
function ColumnFilterItemListDirective_tsickle_Closure_declarations() {
/** @type {?} */
ColumnFilterItemListDirective.prototype.column;
/** @type {?} */
ColumnFilterItemListDirective.prototype.search;
/** @type {?} */
ColumnFilterItemListDirective.prototype.cellService;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var ColumnFilterItemDirective = function () {
/**
* @param {?} viewContainerRef
* @param {?} itemList
*/
function ColumnFilterItemDirective(viewContainerRef, itemList) {
classCallCheck(this, ColumnFilterItemDirective);
this.viewContainerRef = viewContainerRef;
this.itemList = itemList;
this.$implicit = this;
}
/**
* @return {?}
*/
createClass(ColumnFilterItemDirective, [{
key: 'ngOnInit',
value: function ngOnInit() {
var /** @type {?} */itemList = this.itemList;
var /** @type {?} */link = itemList.cellService.build('column-filter', itemList.column);
link(this.viewContainerRef, this);
}
}]);
return ColumnFilterItemDirective;
}();
ColumnFilterItemDirective.decorators = [{ type: Directive, args: [{
selector: '[q-grid-column-filter-item]'
}] }];
/** @nocollapse */
ColumnFilterItemDirective.ctorParameters = function () {
return [{ type: ViewContainerRef }, { type: ColumnFilterItemListDirective }];
};
ColumnFilterItemDirective.propDecorators = {
value: [{ type: Input, args: ['q-grid-column-filter-item'] }]
};
function ColumnFilterItemDirective_tsickle_Closure_declarations() {
/** @type {?} */
ColumnFilterItemDirective.prototype.value;
/** @type {?} */
ColumnFilterItemDirective.prototype.$implicit;
/** @type {?} */
ColumnFilterItemDirective.prototype.viewContainerRef;
/** @type {?} */
ColumnFilterItemDirective.prototype.itemList;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var ColumnFilterModule = function ColumnFilterModule() {
classCallCheck(this, ColumnFilterModule);
};
ColumnFilterModule.decorators = [{ type: NgModule, args: [{
declarations: [ColumnFilterComponent, ColumnFilterTriggerComponent, ColumnFilterByComponent, ColumnFilterItemListDirective, ColumnFilterItemDirective],
exports: [ColumnFilterComponent, ColumnFilterTriggerComponent, ColumnFilterByComponent, ColumnFilterItemListDirective, ColumnFilterItemDirective],
imports: [TemplateModule]
}] }];
var GRID_ACTIVE_CLASS = GRID_PREFIX + '-active';
var GRID_HIDE_CLASS = GRID_PREFIX + '-hide';
var ColumnSortView = function () {
function ColumnSortView(model, context) {
classCallCheck(this, ColumnSortView);
this.model = model;
var column = context.column;
var view = context.view;
var element = this.element = context.element;
var iconDesc = context.iconDesc;
var iconAsc = context.iconAsc;
model.sortChanged.watch(function (e) {
if (e.hasChanges('by')) {
if (view.sort.order(column) < 0) {
Fastdom.mutate(function () {
element.classList.add(GRID_HIDE_CLASS);
element.classList.remove(GRID_ACTIVE_CLASS);
iconAsc.classList.remove(GRID_ACTIVE_CLASS);
iconDesc.classList.remove(GRID_ACTIVE_CLASS);
});
} else {
var direction = view.sort.direction(column);
var oldIcon = direction === 'asc' ? iconDesc : iconAsc;
var newIcon = direction === 'asc' ? iconAsc : iconDesc;
Fastdom.mutate(function () {
element.classList.add(GRID_ACTIVE_CLASS);
element.classList.remove(GRID_HIDE_CLASS);
oldIcon.classList.remove(GRID_ACTIVE_CLASS);
newIcon.classList.add(GRID_ACTIVE_CLASS);
});
}
}
});
this.toggle = new Command({
canExecute: function canExecute() {
return column.canSort;
},
execute: function execute() {
return view.sort.toggle.execute(column);
}
});
}
createClass(ColumnSortView, [{
key: 'onClick',
value: function onClick() {
if (this.toggle.canExecute()) {
this.toggle.execute();
return true;
}
return false;
}
}, {
key: 'onMouseLeave',
value: function onMouseLeave() {
var _this = this;
Fastdom.mutate(function () {
_this.element.classList.remove(GRID_HIDE_CLASS);
});
}
}]);
return ColumnSortView;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var ColumnSortComponent = function () {
/**
* @param {?} plugin
* @param {?} view
* @param {?} element
* @param {?} zone
*/
function ColumnSortComponent(plugin, view, element, zone) {
classCallCheck(this, ColumnSortComponent);
this.plugin = plugin;
this.view = view;
this.element = element;
this.zone = zone;
this.context = {
$implicit: this
};
}
/**
* @return {?}
*/
createClass(ColumnSortComponent, [{
key: 'ngAfterViewInit',
value: function ngAfterViewInit() {
var _this = this;
var nativeElement = this.element.nativeElement;
var /** @type {?} */iconAsc = nativeElement.querySelector('.q-grid-asc');
var /** @type {?} */iconDesc = nativeElement.querySelector('.q-grid-desc');
var /** @type {?} */ctrl = new ColumnSortView(this.plugin.model, {
element: nativeElement,
view: this.view,
column: this.column,
iconAsc: iconAsc,
iconDesc: iconDesc
});
var /** @type {?} */listener = new EventListener(nativeElement, new EventManager(this));
listener.on('click', function () {
if (ctrl.onClick()) {
var /** @type {?} */focus = new FocusAfterRender$1(_this.plugin, null);
}
});
this.zone.runOutsideAngular(function () {
return listener.on('mouseleave', function () {
return ctrl.onMouseLeave();
});
});
}
}]);
return ColumnSortComponent;
}();
ColumnSortComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-column-sort',
template: "<ng-container key=\"plugin-column-sort.tpl.html\" [context]=\"context\"></ng-container> ",
providers: [PluginService]
}] }];
/** @nocollapse */
ColumnSortComponent.ctorParameters = function () {
return [{ type: PluginService }, { type: ViewCoreService }, { type: ElementRef }, { type: NgZone }];
};
ColumnSortComponent.propDecorators = {
column: [{ type: Input }],
template: [{ type: ContentChild, args: [TemplateRef] }]
};
function ColumnSortComponent_tsickle_Closure_declarations() {
/** @type {?} */
ColumnSortComponent.prototype.column;
/** @type {?} */
ColumnSortComponent.prototype.template;
/** @type {?} */
ColumnSortComponent.prototype.context;
/** @type {?} */
ColumnSortComponent.prototype.plugin;
/** @type {?} */
ColumnSortComponent.prototype.view;
/** @type {?} */
ColumnSortComponent.prototype.element;
/** @type {?} */
ColumnSortComponent.prototype.zone;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var ColumnSortModule = function ColumnSortModule() {
classCallCheck(this, ColumnSortModule);
};
ColumnSortModule.decorators = [{ type: NgModule, args: [{
declarations: [ColumnSortComponent],
exports: [ColumnSortComponent],
imports: [TemplateModule]
}] }];
var DataManipulationModel = function DataManipulationModel() {
classCallCheck(this, DataManipulationModel);
this.resource = new Resource();
this.deleted = new Set();
this.added = new Set();
this.edited = new Map();
this.rowFactory = function (etalonRow) {
if (etalonRow) {
return cloneDeepWith(etalonRow, function (value) {
if (isArray(value)) {
return [];
}
if (!isObject(value) || isNumber(value) || isDate(value) || isBoolean(value) || isFunction(value)) {
return null;
}
});
}
};
};
var DataManipulationView = function () {
function DataManipulationView(model) {
var _this = this;
classCallCheck(this, DataManipulationView);
this.model = model;
this.commitCommand = new Command({
execute: function execute(e) {
if (e.column.class !== 'data') {
return;
}
var rowId = _this.rowId(e.rowIndex, e.row);
var columnId = _this.columnId(e.columnIndex, e.column);
var edited = _this.changes.edited;
var entries = edited.get(rowId);
if (!entries) {
entries = [];
edited.set(rowId, entries);
}
var entryIndex = entries.findIndex(function (entry) {
return entry.column === columnId;
});
var entry = entries[entryIndex];
if (!entry) {
entry = {
column: columnId,
oldValue: e.oldValue,
oldLabel: e.oldLabel
};
entryIndex = entries.length;
entries.push(entry);
}
entry.newValue = e.newValue;
entry.newLabel = e.newLabel;
// TODO: understand if we need to track label changes?
if (!_this.hasChanges(entry.newValue, entry.oldValue)) {
entries.splice(entryIndex, 1);
if (!entries.length) {
edited.delete(rowId);
}
}
}
});
this.actions = [new Action(new Command({
source: 'data.manipulation',
execute: function execute() {
var newRow = _this.rowFactory(_this.model.data().rows[0]);
if (isUndefined(newRow)) {
throw new AppError('data.manipulation', 'Setup rowFactory property to add new rows');
}
var rowId = _this.rowId(0, newRow);
var data = _this.model.data;
_this.changes.added.add(rowId);
data({
rows: [newRow].concat(data().rows)
}, {
source: 'data.manipulation'
});
},
shortcut: 'F7'
}), 'Add New Row', 'add')];
this.rowActions = [new Action(new Command({
source: 'data.manipulation',
canExecute: function canExecute(e) {
var rowId = _this.rowId(e.rowIndex, e.row);
return !_this.changes.deleted.has(rowId);
},
execute: function execute(e) {
var rowId = _this.rowId(e.rowIndex, e.row);
var changes = _this.changes;
if (changes.added.has(rowId)) {
changes.added.delete(rowId);
var data = _this.model.data;
var _rows = data().rows.filter(function (row, i) {
return _this.rowId(i, row) !== rowId;
});
data({ rows: _rows }, {
source: 'data.manipulation'
});
} else {
changes.deleted.add(rowId);
}
}
}), 'Delete Row', 'delete'), new Action(new Command({
source: 'data.manipulation',
execute: function execute(e) {
var rowId = _this.rowId(e.rowIndex, e.row);
if (_this.changes.deleted.has(rowId)) {
_this.changes.deleted.delete(rowId);
}
if (_this.changes.edited.has(rowId)) {
try {
var edits = _this.changes.edited.get(rowId);
var columnMap = map$1(_this.model.columnList().line);
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = edits[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var edit = _step.value;
var column = columnMap[edit.column];
if (!column) {
throw new AppError('data.manipulation', 'Column ' + edit.column + ' is not found');
}
set$1(e.row, column, edit.oldValue);
set$2(e.row, column, edit.oldLabel);
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
} finally {
_this.changes.edited.delete(rowId);
}
}
},
canExecute: function canExecute(e) {
var rowId = _this.rowId(e.rowIndex, e.row);
return _this.changes.deleted.has(rowId) || _this.changes.edited.has(rowId);
}
}), 'Revert Row', 'restore')];
this.rowId = model.data().id.row;
this.columnId = model.data().id.column;
this.rowFactory = model.dataManipulation().rowFactory;
var styleState = model.style();
var rows = Array.from(styleState.rows);
var cells = Array.from(styleState.cells);
rows.push(this.styleRow.bind(this));
cells.push(this.styleCell.bind(this));
model.edit({
mode: 'cell',
commit: Composite.command([this.commitCommand, model.edit().commit])
}).style({
rows: rows, cells: cells
}).action({
items: Composite.list([this.actions, model.action().items])
});
model.columnListChanged.watch(function (e, off) {
if (e.hasChanges('line')) {
var rowOptionsColumn = e.state.line.find(function (column) {
return column.type === 'row-options';
});
if (rowOptionsColumn) {
var _rowOptionsColumn$edi;
(_rowOptionsColumn$edi = rowOptionsColumn.editorOptions.actions).push.apply(_rowOptionsColumn$edi, toConsumableArray(_this.rowActions));
off();
}
}
});
}
createClass(DataManipulationView, [{
key: 'hasChanges',
value: function hasChanges(newValue, oldValue) {
// TODO: understand if we need to parse values (e.g. '12' vs 12)
return newValue !== oldValue;
}
}, {
key: 'styleRow',
value: function styleRow(row, context) {
var rowId = this.rowId(context.row, row);
if (this.changes.deleted.has(rowId)) {
context.class('deleted', { opacity: 0.3 });
}
}
}, {
key: 'styleCell',
value: function styleCell(row, column, context) {
var _this2 = this;
var rowId = this.rowId(context.row, row);
var changes = this.changes;
if (column.type === 'row-indicator') {
if (changes.deleted.has(rowId)) {
context.class('delete-indicator', { background: '#EF5350' });
} else if (changes.added.has(rowId)) {
context.class('add-indicator', { background: '#C8E6C9' });
} else if (changes.edited.has(rowId)) {
context.class('edit-indicator', { background: '#E3F2FD' });
}
return;
}
if (changes.edited.has(rowId)) {
var entries = changes.edited.get(rowId);
if (entries.findIndex(function (entry) {
return entry.column === _this2.columnId(context.column, column);
}) >= 0) {
context.class('edited', { background: '#E3F2FD' });
}
}
}
}, {
key: 'changes',
get: function get$$1() {
var model = this.model;
return model.dataManipulation();
}
}, {
key: 'resource',
get: function get$$1() {
return this.model.dataManipulation().resource;
}
}]);
return DataManipulationView;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var DataManipulationComponent = function () {
/**
* @param {?} plugin
*/
function DataManipulationComponent(plugin) {
classCallCheck(this, DataManipulationComponent);
this.plugin = plugin;
}
/**
* @param {?} changes
* @return {?}
*/
createClass(DataManipulationComponent, [{
key: 'ngOnChanges',
value: function ngOnChanges(changes) {
this.plugin.keep(changes, ['dataManipulation']);
}
/**
* @return {?}
*/
}, {
key: 'ngOnInit',
value: function ngOnInit() {
var /** @type {?} */dataManipulation = new DataManipulationView(this.plugin.model);
this.context = { $implicit: dataManipulation };
}
}]);
return DataManipulationComponent;
}();
DataManipulationComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-data-manipulation',
template: '',
providers: [PluginService]
}] }];
/** @nocollapse */
DataManipulationComponent.ctorParameters = function () {
return [{ type: PluginService }];
};
DataManipulationComponent.propDecorators = {
dataManipulationRowFactory: [{ type: Input, args: ['rowFactory'] }]
};
function DataManipulationComponent_tsickle_Closure_declarations() {
/** @type {?} */
DataManipulationComponent.prototype.dataManipulationRowFactory;
/** @type {?} */
DataManipulationComponent.prototype.context;
/** @type {?} */
DataManipulationComponent.prototype.plugin;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var DataManipulationModule = function DataManipulationModule() {
classCallCheck(this, DataManipulationModule);
};
DataManipulationModule.decorators = [{ type: NgModule, args: [{
declarations: [DataManipulationComponent],
exports: [DataManipulationComponent]
}] }];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var EditFormTriggerComponent = function EditFormTriggerComponent() {
classCallCheck(this, EditFormTriggerComponent);
this.context = {
$implicit: this
};
};
EditFormTriggerComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-edit-form-trigger',
template: "<ng-container key=\"plugin-edit-form-trigger.tpl.html\" [context]=\"context\"></ng-container> "
}] }];
EditFormTriggerComponent.propDecorators = {
caption: [{ type: Input }],
cell: [{ type: Input }]
};
function EditFormTriggerComponent_tsickle_Closure_declarations() {
/** @type {?} */
EditFormTriggerComponent.prototype.caption;
/** @type {?} */
EditFormTriggerComponent.prototype.cell;
/** @type {?} */
EditFormTriggerComponent.prototype.context;
}
var EditFormPanelView = function (_Disposable) {
inherits(EditFormPanelView, _Disposable);
function EditFormPanelView(model, context) {
classCallCheck(this, EditFormPanelView);
var _this = possibleConstructorReturn(this, (EditFormPanelView.__proto__ || Object.getPrototypeOf(EditFormPanelView)).call(this));
_this.model = model;
_this.editor = new RowEditor(context.row, model.columnList().line);
_this.caption = context.caption;
_this.submitEvent = new Event$1();
_this.cancelEvent = new Event$1();
_this.resetEvent = new Event$1();
_this.submit = _this.commands.submit;
_this.cancel = _this.commands.cancel;
_this.reset = _this.commands.reset;
if (!isUndefined(context.shortcut)) {
_this.using(context.shortcut.register(new Map(Object.entries(_this.commands))));
}
return _this;
}
createClass(EditFormPanelView, [{
key: 'shortcutFactory',
value: function shortcutFactory(type) {
var edit = this.model.edit;
return function () {
var shortcuts = edit()[type + 'Shortcuts'];
return shortcuts['reference'] || shortcuts['$default'];
};
}
}, {
key: 'editors',
get: function get$$1() {
return this.editor.editors;
}
}, {
key: 'commands',
get: function get$$1() {
var _this2 = this;
var commands = {
submit: new Command({
source: 'edit.form.panel',
shortcut: this.shortcutFactory('commit'),
execute: function execute() {
_this2.editor.commit();
_this2.submitEvent.emit();
}
}),
cancel: new Command({
source: 'edit.form.panel',
shortcut: this.shortcutFactory('cancel'),
execute: function execute() {
return _this2.cancelEvent.emit();
}
}),
reset: new Command({
source: 'edit.form.panel',
execute: function execute() {
_this2.editor.editors.forEach(function (e) {
return e.reset();
});
_this2.resetEvent.emit();
}
})
};
return commands;
}
}]);
return EditFormPanelView;
}(Disposable);
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var EditFormComponent = function () {
/**
* @param {?} plugin
*/
function EditFormComponent(plugin) {
classCallCheck(this, EditFormComponent);
this.plugin = plugin;
this.cancel = new EventEmitter();
this.reset = new EventEmitter();
this.submit = new EventEmitter();
}
/**
* @return {?}
*/
createClass(EditFormComponent, [{
key: 'ngOnInit',
value: function ngOnInit() {
var _this = this;
var /** @type {?} */view = new EditFormPanelView(this.plugin.model, { row: this.cell.row, caption: this.caption });
view.submitEvent.on(function () {
return _this.submit.emit();
});
view.cancelEvent.on(function () {
return _this.cancel.emit();
});
view.resetEvent.on(function () {
return _this.reset.emit();
});
this.context = { $implicit: view };
}
/**
* @return {?}
*/
}, {
key: 'ngOnDestroy',
value: function ngOnDestroy() {
this.context.$implicit.dispose();
}
}]);
return EditFormComponent;
}();
EditFormComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-edit-form',
template: "<ng-container key=\"plugin-edit-form.tpl.html\" [context]=\"context\"></ng-container> ",
providers: [PluginService]
}] }];
/** @nocollapse */
EditFormComponent.ctorParameters = function () {
return [{ type: PluginService }];
};
EditFormComponent.propDecorators = {
caption: [{ type: Input }],
cell: [{ type: Input }],
cancel: [{ type: Output }],
reset: [{ type: Output }],
submit: [{ type: Output }]
};
function EditFormComponent_tsickle_Closure_declarations() {
/** @type {?} */
EditFormComponent.prototype.caption;
/** @type {?} */
EditFormComponent.prototype.cell;
/** @type {?} */
EditFormComponent.prototype.cancel;
/** @type {?} */
EditFormComponent.prototype.reset;
/** @type {?} */
EditFormComponent.prototype.submit;
/** @type {?} */
EditFormComponent.prototype.context;
/** @type {?} */
EditFormComponent.prototype.plugin;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var EditFormControlComponent = function () {
function EditFormControlComponent() {
classCallCheck(this, EditFormControlComponent);
}
createClass(EditFormControlComponent, [{
key: 'key',
/**
* @return {?}
*/
get: function get$$1() {
if (this.editor) {
var column = this.editor.cell.column;
var /** @type {?} */type = column.editor || column.type;
return 'edit-form-' + type + '.tpl.html';
}
return 'edit-form-text.tpl.html';
}
}]);
return EditFormControlComponent;
}();
EditFormControlComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-edit-form-control',
template: "<ng-container key=\"{{key}}\" [context]=\"{$implicit: editor}\"> </ng-container>"
}] }];
EditFormControlComponent.propDecorators = {
editor: [{ type: Input }]
};
function EditFormControlComponent_tsickle_Closure_declarations() {
/** @type {?} */
EditFormControlComponent.prototype.editor;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var EditFormModule = function EditFormModule() {
classCallCheck(this, EditFormModule);
};
EditFormModule.decorators = [{ type: NgModule, args: [{
declarations: [EditFormTriggerComponent, EditFormComponent, EditFormControlComponent],
exports: [EditFormTriggerComponent, EditFormComponent, EditFormControlComponent],
imports: [CommonModule, TemplateModule]
}] }];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var Node$2 = function () {
/**
* @param {?} id
* @param {?} schema
* @param {?=} parent
*/
function Node(id, schema, parent) {
classCallCheck(this, Node);
this.id = id;
this.schema = schema;
this.parent = parent;
this.attributes = {};
this.children = [];
this.level = parent ? parent.level + 1 : 0;
}
/**
* @param {?} key
* @param {?=} value
* @return {?}
*/
createClass(Node, [{
key: 'attr',
value: function attr(key, value) {
if (arguments.length === 2) {
this.attributes[key] = value;
} else {
return this.attributes[key];
}
}
/**
* @return {?}
*/
}, {
key: 'classes',
value: function classes() {}
/**
* @param {?} child
* @param {?=} after
* @return {?}
*/
}, {
key: 'addChildAfter',
value: function addChildAfter(child, after) {
var /** @type {?} */index = after ? this.children.indexOf(after) : this.children.length - 1;
this.children.splice(index + 1, 0, child);
child.parent = this;
child.level = this.level + 1;
}
/**
* @param {?} child
* @param {?} before
* @return {?}
*/
}, {
key: 'addChildBefore',
value: function addChildBefore(child, before) {
var /** @type {?} */index = before ? this.children.indexOf(before) : 0;
this.children.splice(index, 0, child);
child.parent = this;
child.level = this.level + 1;
}
/**
* @param {?} child
* @return {?}
*/
}, {
key: 'addAfter',
value: function addAfter(child) {
if (!this.parent) {
throw new AppError('node', 'Can\'t add after root');
}
this.parent.addChildAfter(child, this);
}
/**
* @param {?} child
* @return {?}
*/
}, {
key: 'addBefore',
value: function addBefore(child) {
if (!this.parent) {
throw new AppError('node', 'Can\'t add after root');
}
this.parent.addChildBefore(child, this);
}
/**
* @return {?}
*/
}, {
key: 'clone',
value: function clone() {
return this.schema.apply(new Node(this.id, this.schema));
}
/**
* @return {?}
*/
}, {
key: 'remove',
value: function remove() {
if (!this.parent) {
throw new AppError('node', 'Root element can\'t be removed');
}
var /** @type {?} */index = this.parent.children.indexOf(this);
this.parent.children.splice(index, 1);
}
/**
* @return {?}
*/
}, {
key: 'clear',
value: function clear() {
this.children.forEach(function (child) {
return child.parent = null;
});
this.children = [];
}
/**
* @param {?=} indent
* @return {?}
*/
}, {
key: 'toString',
value: function toString() {
var indent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
return Array(indent).join('-') + ' ' + this.level + '\n' + this.children.map(function (child) {
return child.toString(indent + 1);
}).join('\n');
}
/**
* @return {?}
*/
}, {
key: 'toTraceString',
value: function toTraceString() {
if (null != this.parent) {
var /** @type {?} */parent = this.parent;
while (null !== parent.parent) {
parent = parent.parent;
}
return parent.toString();
}
return this.toString();
}
}]);
return Node;
}();
function Node_tsickle_Closure_declarations() {
/** @type {?} */
Node$2.prototype.attributes;
/** @type {?} */
Node$2.prototype.children;
/** @type {?} */
Node$2.prototype.level;
/** @type {?} */
Node$2.prototype.line;
/** @type {?} */
Node$2.prototype.id;
/** @type {?} */
Node$2.prototype.schema;
/** @type {?} */
Node$2.prototype.parent;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @param {?} array
* @param {?} predicate
* @return {?}
*/
function indexOf(array, predicate) {
for (var /** @type {?} */i = 0, /** @type {?} */length = array.length; i < length; i++) {
if (predicate(array[i], i)) {
return i;
}
}
return -1;
}
/**
* @template T
* @param {...?} args
* @return {?}
*/
function defaults$1() {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
var /** @type {?} */dst = args[0];
var /** @type {?} */result = /** @type {?} */clone(dst);
for (var /** @type {?} */i = 1, /** @type {?} */sourcesLength = args.length; i < sourcesLength; i++) {
var /** @type {?} */source = args[i];
if (!source) {
continue;
}
var /** @type {?} */keys = Object.keys(source);
for (var /** @type {?} */k = 0, /** @type {?} */keysLength = keys.length; k < keysLength; k++) {
var /** @type {?} */key = keys[k];
if (!result.hasOwnProperty(key)) {
result[key] = source[key];
}
}
}
return result;
}
/**
* @param {?} dst
* @param {?} src
* @return {?}
*/
function override(dst, src) {
var /** @type {?} */keys = Object.keys(src);
var /** @type {?} */length = keys.length;
for (var /** @type {?} */i = 0; i < length; i++) {
var /** @type {?} */key = keys[i];
dst[key] = src[key];
}
return dst;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var SerializationService = function () {
function SerializationService() {
classCallCheck(this, SerializationService);
}
createClass(SerializationService, [{
key: 'serialize',
/**
* @param {?} node
* @return {?}
*/
value: function serialize(node) {
return new Serializer(node).serialize();
}
/**
* @param {?} schema
* @param {?} data
* @return {?}
*/
}, {
key: 'deserialize',
value: function deserialize(schema, data) {
return new Deserializer(schema).deserialize(data);
}
}]);
return SerializationService;
}();
/**
* @param {?} node
* @param {?} map
* @return {?}
*/
function traverse(node, map) {
if (!map.hasOwnProperty(node.id)) {
map[node.id] = node;
}
for (var /** @type {?} */i = 0, /** @type {?} */length = node.children.length; i < length; i++) {
var /** @type {?} */child = node.children[0];
traverse(child, map);
}
}
var Serializer = function () {
/**
* @param {?} node
*/
function Serializer(node) {
classCallCheck(this, Serializer);
this.node = node;
}
/**
* @return {?}
*/
createClass(Serializer, [{
key: 'serialize',
value: function serialize() {
var _this = this;
var /** @type {?} */groups = this.node.line.expressions.map(function (expr) {
return _this.serializeGroup(expr);
});
return {
id: this.node.id,
attributes: this.serializeAttributes(this.node),
children: this.node.children.map(function (child) {
return new Serializer(child).serialize();
}),
line: groups.filter(function (group) {
return group.expressions.length;
})
};
}
/**
* @param {?} group
* @return {?}
*/
}, {
key: 'serializeGroup',
value: function serializeGroup(group) {
var _this2 = this;
return {
id: group.id,
expressions: group.expressions.filter(function (expr) {
return _this2.canSerialize(expr);
}).map(function (expr) {
return _this2.serializeExpression(expr);
})
};
}
/**
* @param {?} expression
* @return {?}
*/
}, {
key: 'serializeExpression',
value: function serializeExpression(expression) {
var /** @type {?} */result = /** @type {?} */{};
var /** @type {?} */serializeAttr = this.node.attr('serialize');
var /** @type {?} */serializableProps = serializeAttr[expression.id];
for (var /** @type {?} */i = 0, /** @type {?} */length = serializableProps.length; i < length; i++) {
var /** @type {?} */prop = serializableProps[i];
result[prop] = expression[prop];
}
result.id = expression.id;
result.type = expression.type;
result.method = expression.method;
return result;
}
/**
* @param {?} node
* @return {?}
*/
}, {
key: 'serializeAttributes',
value: function serializeAttributes(node) {
var _this3 = this;
var /** @type {?} */serializeAttr = this.node.attr('serialize');
if (serializeAttr && serializeAttr['@attr']) {
var /** @type {?} */props = serializeAttr['@attr'];
return props.reduce(function (memo, attr) {
memo[attr] = _this3.node.attr(attr);
return memo;
}, {});
}
return {};
}
/**
* @param {?} expression
* @return {?}
*/
}, {
key: 'canSerialize',
value: function canSerialize(expression) {
var /** @type {?} */serializeAttr = this.node.attr('serialize');
if (!serializeAttr) {
return false;
}
var /** @type {?} */props = serializeAttr[expression.id];
return !!(props && props.length);
}
}]);
return Serializer;
}();
function Serializer_tsickle_Closure_declarations() {
/** @type {?} */
Serializer.prototype.node;
}
var Deserializer = function () {
/**
* @param {?} schema
*/
function Deserializer(schema) {
classCallCheck(this, Deserializer);
this.schema = schema;
}
/**
* @param {?} data
* @param {?=} parent
* @param {?=} nodeMap
* @return {?}
*/
createClass(Deserializer, [{
key: 'deserialize',
value: function deserialize(data) {
var parent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
var nodeMap = arguments[2];
nodeMap = nodeMap || {};
var /** @type {?} */node = void 0;
if (!parent) {
node = new Node$2(data.id, this.schema);
this.schema.apply(node);
traverse(node, nodeMap);
node.clear();
} else {
node = nodeMap[data.id].clone();
parent.addChildAfter(node);
traverse(parent, nodeMap);
node.clear();
}
override(node.attributes, data.attributes);
this.deserializeLine(node, node.line, data.line);
var /** @type {?} */children = data.children;
var /** @type {?} */length = children.length;
for (var /** @type {?} */i = 0; i < length; i++) {
var /** @type {?} */child = children[i];
var /** @type {?} */childSchema = this.schema.schemaMap[child.id];
new Deserializer(childSchema).deserialize(child, node, nodeMap);
}
return node;
}
/**
* @param {?} node
* @param {?} line
* @param {?} dataGroups
* @return {?}
*/
}, {
key: 'deserializeLine',
value: function deserializeLine(node, line, dataGroups) {
for (var /** @type {?} */i = 0, /** @type {?} */length = dataGroups.length; i < length; i++) {
var /** @type {?} */dataGroup = dataGroups[i];
var /** @type {?} */exprGroup = /** @type {?} */line.get(dataGroup.id);
this.deserializeGroup(node, line, exprGroup, dataGroup);
}
}
/**
* @param {?} node
* @param {?} line
* @param {?} group
* @param {?} dataGroup
* @return {?}
*/
}, {
key: 'deserializeGroup',
value: function deserializeGroup(node, line, group, dataGroup) {
var /** @type {?} */dataExpressions = dataGroup.expressions;
var /** @type {?} */length = dataExpressions.length;
var /** @type {?} */index = void 0;
var _loop = function _loop(i) {
var /** @type {?} */dataExp = dataExpressions[i];
index = indexOf(group.expressions, function (expr) {
return expr.id === dataExp.id;
});
override(group.expressions[index], dataExp);
};
for (var /** @type {?} */i = 0; i < length; i++) {
_loop(i);
}
var _loop2 = function _loop2(i) {
var /** @type {?} */dataExpr = dataExpressions[i];
if (dataExpr.method) {
dataExpr.method.forEach(function (m) {
group.expressions[index][m](node, line);
group.expressions[index].method = dataExpressions[i].method;
});
}
};
for (var /** @type {?} */i = 0; i < length; i++) {
_loop2(i);
}
}
}]);
return Deserializer;
}();
function Deserializer_tsickle_Closure_declarations() {
/** @type {?} */
Deserializer.prototype.schema;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @record
* @template T
*/
function EbNodeServiceEventArg() {}
function EbNodeServiceEventArg_tsickle_Closure_declarations() {
/** @type {?} */
EbNodeServiceEventArg.prototype.newValue;
/** @type {?} */
EbNodeServiceEventArg.prototype.oldValue;
}
var EbNodeService = function () {
function EbNodeService() {
classCallCheck(this, EbNodeService);
this.node = null;
this.currentChange = new EventEmitter();
}
/**
* @return {?}
*/
createClass(EbNodeService, [{
key: 'current',
get: function get$$1() {
return this.node;
}
/**
* @param {?} value
* @return {?}
*/
,
set: function set$$1(value) {
var /** @type {?} */oldNode = this.node;
if (value !== oldNode) {
this.node = value;
this.currentChange.emit({
oldValue: oldNode,
newValue: value
});
}
}
}]);
return EbNodeService;
}();
EbNodeService.decorators = [{ type: Injectable }];
function EbNodeService_tsickle_Closure_declarations() {
/** @type {?} */
EbNodeService.prototype.node;
/** @type {?} */
EbNodeService.prototype.currentChange;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var EbNodeComponent = function () {
/**
* @param {?} service
*/
function EbNodeComponent(service) {
classCallCheck(this, EbNodeComponent);
this.service = service;
}
/**
* @param {?} e
* @return {?}
*/
createClass(EbNodeComponent, [{
key: 'select',
value: function select(e) {
e.stopPropagation();
if (this.model.parent) {
this.service.current = this.model;
}
}
}]);
return EbNodeComponent;
}();
EbNodeComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-eb-node',
template: "<ul class=\"q-grid-eb-node\" [q-grid-eb-class]=\"model.attr('class')\" [ngClass]=\"{'q-grid-eb-active': service.current === model}\" (click)=\"select($event)\"> <li class=\"q-grid-eb-line\"> <ul> <li *ngFor=\"let expr of model.line.expressions\" class=\"q-grid-eb-expression\"> <q-grid-eb-expression [model]=\"expr\" [node]=\"model\" [line]=\"model.line\"> </q-grid-eb-expression> </li> </ul> </li> <li class=\"q-grid-eb-children\"> <ul> <li *ngFor=\"let child of model.children\" class=\"q-grid-eb-child\"> <q-grid-eb-node [model]=\"child\"> </q-grid-eb-node> </li> </ul> </li> </ul> <ng-template key=\"eb-group.tpl.html\" let-$group let-$node=\"node\" let-$line=\"line\"> <ul class=\"q-grid-eb-group\"> <li *ngFor=\"let expr of $group.expressions\" class=\"q-grid-eb-expression\"> <q-grid-eb-expression [model]=\"expr\" [node]=\"$node\" [line]=\"$line\"> </q-grid-eb-expression> </li> </ul> </ng-template> "
}] }];
/** @nocollapse */
EbNodeComponent.ctorParameters = function () {
return [{ type: EbNodeService }];
};
EbNodeComponent.propDecorators = {
model: [{ type: Input }]
};
function EbNodeComponent_tsickle_Closure_declarations() {
/** @type {?} */
EbNodeComponent.prototype.model;
/** @type {?} */
EbNodeComponent.prototype.service;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @abstract
*/
var Expression = function Expression() {
classCallCheck(this, Expression);
this.templateUrl = '';
this.method = [];
};
function Expression_tsickle_Closure_declarations() {
/** @type {?} */
Expression.prototype.id;
/** @type {?} */
Expression.prototype.type;
/** @type {?} */
Expression.prototype.templateUrl;
/** @type {?} */
Expression.prototype.method;
}
var GroupExpression = function (_Expression) {
inherits(GroupExpression, _Expression);
function GroupExpression() {
classCallCheck(this, GroupExpression);
var _this = possibleConstructorReturn(this, (GroupExpression.__proto__ || Object.getPrototypeOf(GroupExpression)).call(this));
_this.expressions = [];
_this.type = 'group';
_this.templateUrl = 'eb-group.tpl.html';
return _this;
}
return GroupExpression;
}(Expression);
function GroupExpression_tsickle_Closure_declarations() {
/** @type {?} */
GroupExpression.prototype.expressions;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var Line = function () {
/**
* @param {?} GroupSchemaT
*/
function Line(GroupSchemaT) {
classCallCheck(this, Line);
this.GroupSchemaT = GroupSchemaT;
this.immutable = true;
this.expressions = [];
}
/**
* @param {?} id
* @return {?}
*/
createClass(Line, [{
key: 'getIndex',
value: function getIndex(id) {
var /** @type {?} */index = this.expressions.findIndex(function (item) {
return item.id === id;
});
if (index < 0) {
throw new AppError('line', 'Expression ' + id + ' not found');
}
return index;
}
/**
* @param {?} expressions
* @param {?} id
* @param {?=} parent
* @return {?}
*/
}, {
key: 'findById',
value: function findById(expressions, id) {
var parent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
for (var /** @type {?} */index = 0, /** @type {?} */length = expressions.length; index < length; index++) {
var /** @type {?} */expression = expressions[index];
if (expression.id === id) {
return { index: index, expression: expression, parent: parent };
}
if (expression instanceof GroupExpression) {
var /** @type {?} */group = /** @type {?} */expression;
var /** @type {?} */groupChild = this.findById(group.expressions, id, group);
if (groupChild) {
return groupChild;
}
}
}
return null;
}
/**
* @param {?} expression
* @return {?}
*/
}, {
key: 'add',
value: function add(expression) {
this.expressions.push(expression);
}
/**
* @param {?} id
* @return {?}
*/
}, {
key: 'clone',
value: function clone$$1(id) {
return (/** @type {?} */cloneDeepWith(this.get(id))
);
}
/**
* @param {?} id
* @return {?}
*/
}, {
key: 'get',
value: function get$$1(id) {
var /** @type {?} */expression = this.findById(this.expressions, id);
if (!expression) {
throw new AppError('line', 'Expression ' + id + ' not found');
}
return expression.expression;
}
/**
* @param {?} id
* @param {?} node
* @param {?} build
* @return {?}
*/
}, {
key: 'put',
value: function put(id, node, build) {
var /** @type {?} */index = this.getIndex(id);
var /** @type {?} */schema = new this.GroupSchemaT(node, this);
var /** @type {?} */group = new GroupExpression();
var /** @type {?} */item = this.findById(this.expressions, id);
if (item.expression instanceof GroupExpression) {
build(schema);
schema.apply(group);
group.id = id;
this.expressions.splice(index, 1, group);
this.immutable = false;
} else {
throw new AppError('line', 'Unsupported operation: put to expression, that is not a group');
}
}
/**
* @param {?} id
* @return {?}
*/
}, {
key: 'remove',
value: function remove(id) {
var /** @type {?} */item = this.findById(this.expressions, id);
var /** @type {?} */expressions = item.parent ? item.parent.expressions : this.expressions;
if (item.expression instanceof GroupExpression) {
item.expression.expressions = [];
} else {
throw new AppError('line', 'Unsupported operation: remove expression, that is not a group');
}
}
}]);
return Line;
}();
function Line_tsickle_Closure_declarations() {
/** @type {?} */
Line.prototype.immutable;
/** @type {?} */
Line.prototype.expressions;
/** @type {?} */
Line.prototype.GroupSchemaT;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @param {?} expression
* @param {?} args
* @return {?}
*/
function evaluateFactory(expression, args) {
return visit;
/**
* @param {?} value
* @return {?}
*/
function visit(value) {
if (isArray(value)) {
return visitArray(value);
} else if (isFunction(value)) {
return visitFunction(value);
} else if (isObject(value)) {
return visitObject(value);
}
return value;
}
/**
* @param {?} inst
* @return {?}
*/
function visitObject(inst) {
var /** @type {?} */keys = Object.keys(inst);
var /** @type {?} */length = keys.length;
var /** @type {?} */result = {};
for (var /** @type {?} */i = 0; i < length; i++) {
var /** @type {?} */key = keys[i];
result[key] = visit(inst[key]);
}
return result;
}
/**
* @param {?} list
* @return {?}
*/
function visitArray(list) {
var /** @type {?} */result = [];
for (var /** @type {?} */i = 0, /** @type {?} */length = list.length; i < length; i++) {
result[i] = visit(list[i]);
}
return result;
}
/**
* @param {?} delegate
* @return {?}
*/
function visitFunction(delegate) {
return delegate.apply(expression, args);
}
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var Watcher = function () {
/**
* @param {?} expression
* @param {?} key
* @param {?} handler
* @param {?=} args
*/
function Watcher(expression, key, handler) {
var args = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
classCallCheck(this, Watcher);
this.expression = expression;
this.key = key;
this.handler = handler;
this.args = args;
this.isFirstRun = true;
this.evaluate = evaluateFactory(expression, args);
this.oldValue = this.evaluate(expression[key]);
}
/**
* @return {?}
*/
createClass(Watcher, [{
key: 'detect',
value: function detect() {
var /** @type {?} */inst = this.expression[this.key];
var /** @type {?} */newValue = this.evaluate(inst);
if (this.isFirstRun || this.oldValue !== newValue) {
this.isFirstRun = false;
this.handler.apply(this.expression, [newValue, this.oldValue].concat(this.args));
this.oldValue = newValue;
}
}
}]);
return Watcher;
}();
function Watcher_tsickle_Closure_declarations() {
/** @type {?} */
Watcher.prototype.evaluate;
/** @type {?} */
Watcher.prototype.oldValue;
/** @type {?} */
Watcher.prototype.isFirstRun;
/** @type {?} */
Watcher.prototype.expression;
/** @type {?} */
Watcher.prototype.key;
/** @type {?} */
Watcher.prototype.handler;
/** @type {?} */
Watcher.prototype.args;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var EbExpressionComponent = function () {
function EbExpressionComponent() {
classCallCheck(this, EbExpressionComponent);
}
createClass(EbExpressionComponent, [{
key: 'ngOnInit',
/**
* @return {?}
*/
value: function ngOnInit() {
var _this = this;
this.context = { $implicit: this.model, node: this.node, line: this.line };
var /** @type {?} */$watch = this.model.$watch;
if ($watch) {
this.watchers = Object.keys($watch).map(function (key) {
return new Watcher(_this.model, key, $watch[key], [_this.node, _this.line]);
});
}
}
/**
* @return {?}
*/
}, {
key: 'ngDoCheck',
value: function ngDoCheck() {
var /** @type {?} */ws = this.watchers;
if (!ws) {
return;
}
for (var /** @type {?} */i = 0, /** @type {?} */length = ws.length; i < length; i++) {
ws[i].detect();
}
}
}]);
return EbExpressionComponent;
}();
EbExpressionComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-eb-expression',
template: "<ng-container [key]=\"model.templateUrl\" [context]=\"context\"> </ng-container> "
}] }];
EbExpressionComponent.propDecorators = {
node: [{ type: Input }],
line: [{ type: Input }],
model: [{ type: Input }]
};
function EbExpressionComponent_tsickle_Closure_declarations() {
/** @type {?} */
EbExpressionComponent.prototype.watchers;
/** @type {?} */
EbExpressionComponent.prototype.node;
/** @type {?} */
EbExpressionComponent.prototype.line;
/** @type {?} */
EbExpressionComponent.prototype.model;
/** @type {?} */
EbExpressionComponent.prototype.context;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var EbClassDirective = function () {
/**
* @param {?} element
* @param {?} node
*/
function EbClassDirective(element, node) {
classCallCheck(this, EbClassDirective);
this.element = element;
this.node = node;
this.oldClassList = [];
}
/**
* @return {?}
*/
createClass(EbClassDirective, [{
key: 'ngOnInit',
value: function ngOnInit() {
this.evaluate = evaluateFactory(this.model, [this.node ? this.node.model : null]);
}
/**
* @return {?}
*/
}, {
key: 'ngDoCheck',
value: function ngDoCheck() {
var /** @type {?} */result = this.evaluate(this.klass);
if (result) {
var /** @type {?} */classList = this.fetchClasses(result);
if (this.oldClassList.length !== classList.length || this.oldClassList.join(' ') !== classList.join(' ')) {
var _element$classList, _element$classList2;
var /** @type {?} */element = /** @type {?} */this.element.nativeElement;
(_element$classList = element.classList).remove.apply(_element$classList, toConsumableArray(this.oldClassList));
(_element$classList2 = element.classList).add.apply(_element$classList2, toConsumableArray(classList));
this.oldClassList = classList;
}
} else if (this.oldClassList.length) {
var _element$classList3;
var /** @type {?} */_element = /** @type {?} */this.element.nativeElement;
(_element$classList3 = _element.classList).remove.apply(_element$classList3, toConsumableArray(this.oldClassList));
this.oldClassList = [];
}
}
/**
* @param {?} meta
* @return {?}
*/
}, {
key: 'fetchClasses',
value: function fetchClasses(meta) {
if (isArray(meta)) {
return meta;
}
var /** @type {?} */keys = Object.keys(meta);
var /** @type {?} */classList = [];
for (var /** @type {?} */i = 0, /** @type {?} */length = keys.length; i < length; i++) {
var /** @type {?} */key = keys[i];
if (meta[key]) {
classList.push(key);
}
}
return classList;
}
}]);
return EbClassDirective;
}();
EbClassDirective.decorators = [{ type: Directive, args: [{
selector: '[q-grid-eb-class]'
}] }];
/** @nocollapse */
EbClassDirective.ctorParameters = function () {
return [{ type: ElementRef }, { type: EbNodeComponent, decorators: [{ type: Optional }] }];
};
EbClassDirective.propDecorators = {
klass: [{ type: Input, args: ['q-grid-eb-class'] }],
model: [{ type: Input, args: ['q-grid-eb-class-model'] }]
};
function EbClassDirective_tsickle_Closure_declarations() {
/** @type {?} */
EbClassDirective.prototype.klass;
/** @type {?} */
EbClassDirective.prototype.model;
/** @type {?} */
EbClassDirective.prototype.evaluate;
/** @type {?} */
EbClassDirective.prototype.oldClassList;
/** @type {?} */
EbClassDirective.prototype.element;
/** @type {?} */
EbClassDirective.prototype.node;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var EbModule = function EbModule() {
classCallCheck(this, EbModule);
};
EbModule.decorators = [{ type: NgModule, args: [{
imports: [CommonModule, TemplateModule],
exports: [EbNodeComponent, EbClassDirective],
declarations: [EbNodeComponent, EbExpressionComponent, EbClassDirective],
providers: [SerializationService, EbNodeService]
}] }];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var LegendComponent =
/**
* @param {?} templateHost
*/
function LegendComponent(templateHost) {
classCallCheck(this, LegendComponent);
this.context = {
$implicit: this
};
templateHost.key = function () {
return 'plugin-legend-core.tpl.html';
};
};
LegendComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-legend',
template: "<ng-container key=\"plugin-legend-core.tpl.html\" [context]=\"context\"></ng-container> ",
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [TemplateHostService]
}] }];
/** @nocollapse */
LegendComponent.ctorParameters = function () {
return [{ type: TemplateHostService }];
};
function LegendComponent_tsickle_Closure_declarations() {
/** @type {?} */
LegendComponent.prototype.context;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var LegendModule = function LegendModule() {
classCallCheck(this, LegendModule);
};
LegendModule.decorators = [{ type: NgModule, args: [{
declarations: [LegendComponent],
exports: [LegendComponent],
imports: [TemplateModule]
}] }];
var PagerView = function () {
function PagerView(model, table) {
classCallCheck(this, PagerView);
this.model = model;
this.table = table;
this.next = new Command({
source: 'pager',
execute: function execute() {
new FocusAfterRender(model, table);
model.pagination({ current: model.pagination().current + 1 }, { source: 'pager.view' });
},
canExecute: function canExecute() {
return (model.pagination().current + 1) * model.pagination().size < model.pagination().count;
}
});
this.prev = new Command({
source: 'pager',
execute: function execute() {
new FocusAfterRender(model, table);
model.pagination({ current: model.pagination().current - 1 }, { source: 'pager.view' });
},
canExecute: function canExecute() {
return model.pagination().current > 0;
}
});
}
createClass(PagerView, [{
key: 'theme',
get: function get$$1() {
return this.model.style().classList;
}
}, {
key: 'resource',
get: function get$$1() {
return this.model.pagination().resource;
}
}, {
key: 'size',
get: function get$$1() {
return this.model.pagination().size;
},
set: function set$$1(value) {
this.model.pagination({ size: value, current: 0 }, { source: 'pager.view' });
}
}, {
key: 'sizeList',
get: function get$$1() {
return this.model.pagination().sizeList;
}
}, {
key: 'current',
get: function get$$1() {
return this.model.pagination().current;
},
set: function set$$1(value) {
return this.model.pagination({ current: value }, { source: 'pager.view' });
}
}, {
key: 'from',
get: function get$$1() {
return Math.min(this.total, this.current * this.size + 1);
}
}, {
key: 'to',
get: function get$$1() {
return Math.min(this.total, (this.current + 1) * this.size);
}
}, {
key: 'total',
get: function get$$1() {
return this.model.pagination().count;
}
}, {
key: 'totalPages',
get: function get$$1() {
return this.size === 0 ? 0 : Math.max(1, Math.ceil(this.total / this.size));
}
}, {
key: 'scroll',
get: function get$$1() {
return this.model.scroll();
}
}]);
return PagerView;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var PagerComponent = function () {
/**
* @param {?} plugin
*/
function PagerComponent(plugin) {
classCallCheck(this, PagerComponent);
this.plugin = plugin;
}
/**
* @param {?} changes
* @return {?}
*/
createClass(PagerComponent, [{
key: 'ngOnChanges',
value: function ngOnChanges(changes) {
this.plugin.keep(changes, ['pagination']);
}
/**
* @return {?}
*/
}, {
key: 'ngOnInit',
value: function ngOnInit() {
var /** @type {?} */pager = new PagerView(this.plugin.model, this.plugin.table);
this.context = { $implicit: pager };
}
}]);
return PagerComponent;
}();
PagerComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-pager',
template: "<ng-container key=\"plugin-pager.tpl.html\" [context]=\"context\"></ng-container> ",
providers: [PluginService]
}] }];
/** @nocollapse */
PagerComponent.ctorParameters = function () {
return [{ type: PluginService }];
};
PagerComponent.propDecorators = {
paginationSize: [{ type: Input, args: ['size'] }],
paginationSizeList: [{ type: Input, args: ['sizeList'] }]
};
function PagerComponent_tsickle_Closure_declarations() {
/** @type {?} */
PagerComponent.prototype.paginationSize;
/** @type {?} */
PagerComponent.prototype.paginationSizeList;
/** @type {?} */
PagerComponent.prototype.context;
/** @type {?} */
PagerComponent.prototype.plugin;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var PagerTargetComponent = function () {
/**
* @param {?} plugin
*/
function PagerTargetComponent(plugin) {
classCallCheck(this, PagerTargetComponent);
this.plugin = plugin;
this.context = {
$implicit: this
};
}
/**
* @return {?}
*/
createClass(PagerTargetComponent, [{
key: 'ngOnInit',
value: function ngOnInit() {
this.value = this.current;
}
/**
* @param {?} e
* @return {?}
*/
}, {
key: 'keyDown',
value: function keyDown(e) {
var /** @type {?} */code = Shortcut.translate(e);
if (code.startsWith('numpad')) {
code = code.slice(6);
}
var /** @type {?} */value = this.value || 0;
switch (code) {
case 'enter':
{
if (value) {
this.plugin.model.pagination({ current: value - 1 }, { source: 'pager-target.component' });
}
break;
}
case 'up':
{
if (value < this.total) {
this.value = value + 1;
}
break;
}
case 'down':
{
if (value > 1) {
this.value = value - 1;
}
break;
}
case 'left':
case 'right':
case 'backspace':
{
break;
}
default:
{
var /** @type {?} */digit = Number.parseInt(code);
var /** @type {?} */page = Number.parseInt('' + value + digit);
var /** @type {?} */min = 1;
var /** @type {?} */max = this.total;
var /** @type {?} */isValid = page >= min && page <= max && !isNaN(digit);
if (!isValid) {
page > this.total ? this.value = max : this.value = min;
e.preventDefault();
}
}
}
}
/**
* @return {?}
*/
}, {
key: 'current',
get: function get$$1() {
return this.plugin.model.pagination().current + 1;
}
/**
* @return {?}
*/
}, {
key: 'total',
get: function get$$1() {
var /** @type {?} */pagination = this.plugin.model.pagination();
var /** @type {?} */count = pagination.count;
var /** @type {?} */size = pagination.size;
return size === 0 ? 0 : Math.max(1, Math.ceil(count / size));
}
}]);
return PagerTargetComponent;
}();
PagerTargetComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-pager-target',
template: "<ng-container key=\"plugin-pager-target.tpl.html\" [context]=\"context\"></ng-container> ",
providers: [PluginService]
}] }];
/** @nocollapse */
PagerTargetComponent.ctorParameters = function () {
return [{ type: PluginService }];
};
function PagerTargetComponent_tsickle_Closure_declarations() {
/** @type {?} */
PagerTargetComponent.prototype.value;
/** @type {?} */
PagerTargetComponent.prototype.context;
/** @type {?} */
PagerTargetComponent.prototype.plugin;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var PagerModule = function PagerModule() {
classCallCheck(this, PagerModule);
};
PagerModule.decorators = [{ type: NgModule, args: [{
declarations: [PagerComponent, PagerTargetComponent],
exports: [PagerComponent, PagerTargetComponent],
imports: [TemplateModule]
}] }];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var PersistenceComponent = function () {
/**
* @param {?} plugin
*/
function PersistenceComponent(plugin) {
classCallCheck(this, PersistenceComponent);
this.plugin = plugin;
}
/**
* @param {?} changes
* @return {?}
*/
createClass(PersistenceComponent, [{
key: 'ngOnChanges',
value: function ngOnChanges(changes) {
this.plugin.keep(changes, ['persistence']);
}
/**
* @return {?}
*/
}, {
key: 'ngOnInit',
value: function ngOnInit() {
var model = this.plugin.model;
var /** @type {?} */id = 'q-grid:' + model.grid().id + ':persistence-list';
model.persistence({ id: id });
model.persistence().storage.getItem(id).then(function (items) {
if (!items || items.length === 0) {
return;
}
var /** @type {?} */defaultItem = items.find(function (item) {
return item.isDefault;
});
if (defaultItem) {
var /** @type {?} */persistenceService = new PersistenceService(model);
persistenceService.load(defaultItem.model);
}
});
var /** @type {?} */action = new Action(new Command(), 'Save/Load', 'history');
action.templateUrl = 'plugin-persistence.tpl.html';
this.plugin.model.action({
items: Composite.list([[action], this.plugin.model.action().items])
}, {
source: 'persistence.component'
});
}
}]);
return PersistenceComponent;
}();
PersistenceComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-persistence',
template: '',
providers: [PluginService]
}] }];
/** @nocollapse */
PersistenceComponent.ctorParameters = function () {
return [{ type: PluginService }];
};
function PersistenceComponent_tsickle_Closure_declarations() {
/** @type {?} */
PersistenceComponent.prototype.plugin;
}
function stringifyFactory(property) {
switch (property) {
case 'filter':
return filter$2;
case 'sort':
return sort;
case 'group':
case 'pivot':
return transformBy(property);
default:
return function () {
return '';
};
}
}
function filter$2(model) {
var values = Object.values(model.by).map(function (column) {
return column.items;
});
if (values.length === 0) return '';
var by = flatten(values).join(', ');
return 'filter ' + by;
}
function sort(model) {
var keys = [];
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = model.by[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var item = _step.value;
for (var key in item) {
keys.push(key);
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
if (keys.length === 0) return '';
var by = keys.join(', ');
return 'sort ' + by;
}
function transformBy(property) {
return function (model) {
var keys = model.by;
if (keys.length === 0) return '';
var by = keys.join(', ');
return property + ' ' + by;
};
}
var PersistenceView = function () {
function PersistenceView(model) {
var _this = this;
classCallCheck(this, PersistenceView);
this.model = model;
this.service = new PersistenceService(model);
this.items = [];
this.state = {
editItem: null,
oldValue: null
};
this.closeEvent = new Event$1();
var persistence = model.persistence;
this.id = persistence().id;
this.title = this.stringify();
persistence().storage.getItem(this.id).then(function (items) {
_this.items = items || [];
_this.groups = _this.buildGroups(_this.items);
});
this.model.gridChanged.watch(function (e) {
if (e.hasChanges('status') && e.state.status === 'unbound') {
_this.closeEvent.emit();
}
});
this.create = new Command({
source: 'persistence.view',
execute: function execute() {
var item = {
title: _this.title,
modified: Date.now(),
model: _this.service.save(),
isDefault: false,
group: persistence().defaultGroup,
canEdit: true
};
if (persistence().create.execute(item) !== false) {
_this.items.push(item);
_this.persist();
_this.title = '';
return true;
}
return false;
},
canExecute: function canExecute() {
if (!!_this.title && _this.isUniqueTitle(_this.title)) {
var item = {
title: _this.title,
modified: Date.now(),
model: _this.service.save(),
isDefault: false,
group: persistence().defaultGroup,
canEdit: true
};
return persistence().create.canExecute(item);
}
return false;
}
});
this.edit = {
enter: new Command({
source: 'persistence.view',
execute: function execute(item) {
item = item || _this.items.find(_this.isActive);
if (!item) {
return false;
}
_this.state = {
editItem: item,
oldValue: clone(item)
};
return true;
},
canExecute: function canExecute(item) {
return _this.state.editItem === null && item.canEdit;
}
}),
commit: new Command({
source: 'persistence.view',
shortcut: 'enter',
execute: function execute(item) {
item = item || _this.state.editItem;
if (persistence().modify.execute(item) !== false) {
var title = item.title;
if (!title || !_this.isUniqueTitle(title)) {
_this.edit.cancel.execute();
return false;
}
item.modified = Date.now();
_this.persist();
_this.state.editItem = null;
return true;
}
return false;
},
canExecute: function canExecute() {
return _this.state.editItem !== null && persistence().modify.canExecute(_this.state.editItem);
}
}),
cancel: new Command({
source: 'persistence.view',
shortcut: 'escape',
execute: function execute() {
if (_this.state.editItem !== null) {
var index = _this.items.indexOf(_this.state.editItem);
_this.items.splice(index, 1, _this.state.oldValue);
_this.state.oldValue = null;
_this.state.editItem = null;
} else {
_this.closeEvent.emit();
}
return true;
}
})
};
this.load = new Command({
source: 'persistence.view',
canExecute: function canExecute(item) {
return persistence().load.canExecute(item);
},
execute: function execute(item) {
if (persistence().load.execute(item) !== false) {
_this.service.load(item.model);
return true;
}
return false;
}
});
this.reset = new Command({
source: 'persistence.view',
execute: function execute() {
if (persistence().reset.execute() !== false) {
_this.service.reset();
}
return false;
},
canExecute: function canExecute() {
return persistence().reset.canExecute();
}
});
this.remove = new Command({
source: 'persistence.view',
execute: function execute(item) {
var index = _this.items.indexOf(item);
if (index >= 0) {
if (persistence().remove.execute(item) !== false) {
_this.items.splice(index, 1);
_this.persist();
return true;
}
}
return false;
},
canExecute: function canExecute(item) {
return item.canEdit && persistence().remove.canExecute(item);
}
});
this.setDefault = new Command({
source: 'persistence.view',
canExecute: function canExecute(item) {
return persistence().setDefault.canExecute(item);
},
execute: function execute(item) {
if (persistence().setDefault.execute(item) !== false) {
var index = _this.items.indexOf(item);
if (index === -1) {
return false;
}
if (item.isDefault) {
item.isDefault = false;
} else {
_this.items.forEach(function (i) {
return i.isDefault = false;
});
item.isDefault = true;
}
_this.items.splice(index, 1, item);
_this.persist();
return true;
}
return false;
}
});
var commandManager = new CommandManager();
var shortcut = new Shortcut(new ShortcutDispatcher());
this.keyDown = function (e) {
return shortcut.keyDown(e);
};
shortcut.register(commandManager, [this.edit.enter, this.edit.commit, this.edit.cancel]);
}
createClass(PersistenceView, [{
key: 'buildGroups',
value: function buildGroups(items) {
return items.reduce(function (memo, item) {
var group = memo.find(function (m) {
return m.key === item.group;
});
if (group) {
group.items.push(item);
} else {
memo.push({
key: item.group,
items: [item]
});
}
return memo;
}, []);
}
}, {
key: 'isActive',
value: function isActive(item) {
return JSON.stringify(item.model) === JSON.stringify(this.service.save()); // eslint-disable-line angular/json-functions
}
}, {
key: 'persist',
value: function persist() {
this.model.persistence().storage.setItem(this.id, this.items.filter(function (item) {
return item.canEdit;
}));
this.groups = this.buildGroups(this.items);
}
}, {
key: 'stringify',
value: function stringify(item) {
var model = item ? item.model : this.service.save();
var targets = [];
var settings = this.model.persistence().settings;
for (var key in settings) {
if (!model[key]) {
continue;
}
var stringify = stringifyFactory(key);
var target = stringify(model[key]);
if (target !== '') {
targets.push(target);
}
}
return targets.join('; ') || 'No settings';
}
}, {
key: 'isUniqueTitle',
value: function isUniqueTitle(title) {
var _this2 = this;
return !this.items.some(function (item) {
return item !== _this2.state.editItem && item.title.toLowerCase() === title.trim().toLowerCase();
});
}
}, {
key: 'blank',
get: function get$$1() {
return {
title: 'Blank',
modified: Date.now(),
model: {},
isDefault: false,
group: 'blank',
canEdit: false
};
}
}, {
key: 'sortedItems',
get: function get$$1() {
return this.items.sort(function (a, b) {
return b.modified - a.modified;
});
}
}]);
return PersistenceView;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var PersistencePanelComponent = function () {
/**
* @param {?} plugin
*/
function PersistencePanelComponent(plugin) {
classCallCheck(this, PersistencePanelComponent);
this.plugin = plugin;
}
/**
* @return {?}
*/
createClass(PersistencePanelComponent, [{
key: 'ngOnInit',
value: function ngOnInit() {
var /** @type {?} */persistence = new PersistenceView(this.plugin.model);
this.context = { $implicit: persistence };
}
}]);
return PersistencePanelComponent;
}();
PersistencePanelComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-persistence-panel',
template: "<ng-container key=\"plugin-persistence-panel.tpl.html\" [context]=\"context\"></ng-container> ",
providers: [PluginService]
}] }];
/** @nocollapse */
PersistencePanelComponent.ctorParameters = function () {
return [{ type: PluginService }];
};
function PersistencePanelComponent_tsickle_Closure_declarations() {
/** @type {?} */
PersistencePanelComponent.prototype.context;
/** @type {?} */
PersistencePanelComponent.prototype.plugin;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var PersistenceModule = function PersistenceModule() {
classCallCheck(this, PersistenceModule);
};
PersistenceModule.decorators = [{ type: NgModule, args: [{
imports: [FormsModule, TemplateModule],
exports: [PersistenceComponent, PersistencePanelComponent],
declarations: [PersistenceComponent, PersistencePanelComponent],
entryComponents: [PersistencePanelComponent]
}] }];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var ProgressComponent = function () {
/**
* @param {?} plugin
* @param {?} cd
*/
function ProgressComponent(plugin, cd) {
classCallCheck(this, ProgressComponent);
this.plugin = plugin;
this.cd = cd;
this.context = {
$implicit: this
};
}
/**
* @param {?} changes
* @return {?}
*/
createClass(ProgressComponent, [{
key: 'ngOnChanges',
value: function ngOnChanges(changes) {
this.plugin.keep(changes, ['progress']);
}
/**
* @return {?}
*/
}, {
key: 'ngOnInit',
value: function ngOnInit() {
var _this = this;
this.plugin.model.progressChanged.watch(function () {
return _this.cd.detectChanges();
});
}
/**
* @return {?}
*/
}, {
key: 'isBusy',
get: function get$$1() {
var _plugin$model$progres = this.plugin.model.progress(),
isBusy = _plugin$model$progres.isBusy,
queue = _plugin$model$progres.queue;
return isBusy || queue.length;
}
}]);
return ProgressComponent;
}();
ProgressComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-progress',
template: "<ng-container key=\"plugin-progress.tpl.html\" [context]=\"context\"></ng-container> ",
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [PluginService]
}] }];
/** @nocollapse */
ProgressComponent.ctorParameters = function () {
return [{ type: PluginService }, { type: ChangeDetectorRef }];
};
function ProgressComponent_tsickle_Closure_declarations() {
/** @type {?} */
ProgressComponent.prototype.context;
/** @type {?} */
ProgressComponent.prototype.plugin;
/** @type {?} */
ProgressComponent.prototype.cd;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var ProgressModule = function ProgressModule() {
classCallCheck(this, ProgressModule);
};
ProgressModule.decorators = [{ type: NgModule, args: [{
declarations: [ProgressComponent],
exports: [ProgressComponent],
imports: [TemplateModule]
}] }];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var QueryBuilderModel = function QueryBuilderModel() {
classCallCheck(this, QueryBuilderModel);
this.node = null;
};
function QueryBuilderModel_tsickle_Closure_declarations() {
/** @type {?} */
QueryBuilderModel.prototype.node;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var QueryBuilderComponent = function () {
/**
* @param {?} plugin
*/
function QueryBuilderComponent(plugin) {
classCallCheck(this, QueryBuilderComponent);
this.plugin = plugin;
this.context = {
$implicit: this
};
}
/**
* @return {?}
*/
createClass(QueryBuilderComponent, [{
key: 'ngOnInit',
value: function ngOnInit() {
var /** @type {?} */action = new Action(new Command(), 'Query Builder', 'filter');
action.templateUrl = 'plugin-query-builder.tpl.html';
this.plugin.model.action({
items: Composite.list([[action], this.plugin.model.action().items])
}, {
source: 'query-builder.component'
});
}
}]);
return QueryBuilderComponent;
}();
QueryBuilderComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-query-builder',
template: "<ng-container key=\"plugin-query-builder.tpl.html\" [context]=\"context\"></ng-container>",
providers: [PluginService]
}] }];
/** @nocollapse */
QueryBuilderComponent.ctorParameters = function () {
return [{ type: PluginService }];
};
function QueryBuilderComponent_tsickle_Closure_declarations() {
/** @type {?} */
QueryBuilderComponent.prototype.context;
/** @type {?} */
QueryBuilderComponent.prototype.plugin;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @record
*/
function INodeSchema() {}
function INodeSchema_tsickle_Closure_declarations() {
/** @type {?} */
INodeSchema.prototype.schemaMap;
/** @type {?} */
INodeSchema.prototype.apply;
/** @type {?} */
INodeSchema.prototype.attr;
/** @type {?} */
INodeSchema.prototype.node;
/** @type {?} */
INodeSchema.prototype.group;
/** @type {?} */
INodeSchema.prototype.get;
/** @type {?} */
INodeSchema.prototype.materialize;
}
/**
* @param {?} GroupSchemaT
* @return {?}
*/
function nodeSchema(GroupSchemaT) {
return function () {
/**
* @param {?=} schemaMap
*/
function NodeSchema() {
var schemaMap = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
classCallCheck(this, NodeSchema);
this.schemaMap = schemaMap;
this.plan = [];
this.planMap = {};
}
/**
* @return {?}
*/
createClass(NodeSchema, [{
key: 'clone',
value: function clone() {
var /** @type {?} */schema = new NodeSchema(Object.assign({}, this.schemaMap));
schema.plan = [].concat(toConsumableArray(this.plan));
schema.planMap = Object.assign({}, this.planMap);
return schema;
}
/**
* @param {?} key
* @param {?} value
* @return {?}
*/
}, {
key: 'attr',
value: function attr(key, value) {
this.plan.push(function (node) {
return node.attr(key, value);
});
return this;
}
/**
* @param {?=} node
* @return {?}
*/
}, {
key: 'apply',
value: function apply(node) {
node = node || new Node$2('#root', this);
var /** @type {?} */line = new Line(GroupSchemaT);
node.line = line;
this.plan.forEach(function (p) {
return p(node, line);
});
return node;
}
/**
* @param {?} id
* @param {?} build
* @return {?}
*/
}, {
key: 'node',
value: function node(id, build) {
var _this = this;
if (!build) {
throw new AppError('node.schema', 'Build function is not defined');
}
this.plan.push(function (node, line) {
var /** @type {?} */schema = new NodeSchema(_this.schemaMap);
build(schema);
var /** @type {?} */newNode = new Node$2(id, schema, node);
schema.apply(newNode);
node.addChildAfter(newNode);
_this.schemaMap[id] = schema;
return node;
});
return this;
}
/**
* @param {?} id
* @param {?} build
* @return {?}
*/
}, {
key: 'group',
value: function group(id, build) {
if (!build) {
throw new AppError('node.schema', 'Build function is not defined');
}
var /** @type {?} */buildGroup = function buildGroup(node, line) {
var /** @type {?} */group = new GroupExpression();
group.id = id;
var /** @type {?} */schema = new GroupSchemaT(node, line);
build(schema);
schema.apply(group);
line.add(group);
return node;
};
this.plan.push(buildGroup);
this.planMap[id] = buildGroup;
return this;
}
/**
* @param {?} id
* @return {?}
*/
}, {
key: 'get',
value: function get$$1(id) {
var /** @type {?} */schema = this.schemaMap[id];
if (!schema) {
throw new AppError('node.schema', 'Schema ' + id + ' is not found');
}
return schema;
}
/**
* @param {?} id
* @return {?}
*/
}, {
key: 'materialize',
value: function materialize(id) {
var /** @type {?} */schema = this.get(id);
return schema.apply(new Node$2(id, schema));
}
}]);
return NodeSchema;
}();
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var GroupSchema = function () {
/**
* @param {?} node
* @param {?} line
*/
function GroupSchema(node, line) {
classCallCheck(this, GroupSchema);
this.node = node;
this.line = line;
this.plan = [];
}
/**
* @param {?} group
* @return {?}
*/
createClass(GroupSchema, [{
key: "apply",
value: function apply(group) {
var _this = this;
this.plan.forEach(function (p) {
return p(_this.node, _this.line, group);
});
}
}]);
return GroupSchema;
}();
function GroupSchema_tsickle_Closure_declarations() {
/** @type {?} */
GroupSchema.prototype.plan;
/** @type {?} */
GroupSchema.prototype.node;
/** @type {?} */
GroupSchema.prototype.line;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @param {?} inst
* @param {?} key
* @return {?}
*/
function method(inst, key) {
var /** @type {?} */sourceFn = inst[key];
return {
with: withFactory(inst, key, sourceFn)
};
}
/**
* @param {?} inst
* @return {?}
*/
function methodsOf(inst) {
var /** @type {?} */keys = Object.keys(inst);
var /** @type {?} */length = keys.length;
var /** @type {?} */patch = {};
for (var /** @type {?} */i = 0; i < length; i++) {
var /** @type {?} */key = keys[i];
if (isFunction(inst[key])) {
patch[key] = method(inst, key);
}
}
return {
with: function _with() {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
var /** @type {?} */keys = Object.keys(patch);
var /** @type {?} */length = keys.length;
for (var /** @type {?} */_i = 0; _i < length; _i++) {
var /** @type {?} */_key2 = keys[_i];
inst.action = _key2;
patch[_key2].with.apply(inst, args);
}
}
};
}
/**
* @param {?} inst
* @param {?} key
* @param {?} sourceFn
* @return {?}
*/
function withFactory(inst, key, sourceFn) {
var /** @type {?} */withFn = function withFn() {
for (var _len2 = arguments.length, withArgs = Array(_len2), _key3 = 0; _key3 < _len2; _key3++) {
withArgs[_key3] = arguments[_key3];
}
return inst[key] = function () {
for (var _len3 = arguments.length, keyArgs = Array(_len3), _key4 = 0; _key4 < _len3; _key4++) {
keyArgs[_key4] = arguments[_key4];
}
return sourceFn.apply(inst, withArgs.concat(keyArgs));
};
};
/** @type {?} */withFn.decorator = function () {
for (var _len4 = arguments.length, args = Array(_len4), _key5 = 0; _key5 < _len4; _key5++) {
args[_key5] = arguments[_key5];
}
var /** @type {?} */decorate = args[0];
args = args.slice(1);
inst[key] = function () {
return decorate.apply(inst, [sourceFn, inst, key].concat(args));
};
};
return withFn;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @record
*/
function IStatement() {}
function IStatement_tsickle_Closure_declarations() {
/** @type {?} */
IStatement.prototype.type;
/** @type {?} */
IStatement.prototype.templateKey;
/** @type {?|undefined} */
IStatement.prototype.defaults;
}
var EmptyStatement = function EmptyStatement() {
classCallCheck(this, EmptyStatement);
this.type = 'empty';
this.templateKey = 'eb-empty.tpl.html';
};
function EmptyStatement_tsickle_Closure_declarations() {
/** @type {?} */
EmptyStatement.prototype.type;
/** @type {?} */
EmptyStatement.prototype.templateKey;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var ExpressionBuilder = function () {
/**
* @param {?} settings
*/
function ExpressionBuilder(settings) {
classCallCheck(this, ExpressionBuilder);
this.settings = settings;
}
/**
* @template T
* @param {?} statements
* @return {?}
*/
createClass(ExpressionBuilder, [{
key: 'build',
value: function build(statements) {
var /** @type {?} */NodeSchemaT = nodeSchema(GroupSchema);
var /** @type {?} */settings = this.settings;
statements.concat([new EmptyStatement()]).forEach(function (statement) {
var /** @type {?} */factory = function factory() {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
var /** @type {?} */id = guid();
var /** @type {?} */sampleExpression = void 0;
if (args.length > 1) {
id = args[0];
sampleExpression = args[1];
} else if (args.length === 1) {
sampleExpression = args[0];
}
var /** @type {?} */build = function build(node, line) {
var /** @type {?} */expression = defaults$1(sampleExpression, statement.defaults, settings.defaults);
expression.id = id;
expression.type = statement.type;
expression.templateUrl = statement.templateKey;
var /** @type {?} */group = new GroupExpression();
group.id = id;
group.expressions.push(expression);
line.add(group);
methodsOf(expression).with(node, line);
var /** @type {?} */keys = Object.keys(expression);
keys.forEach(function (key) {
var /** @type {?} */sourceFunction = expression[key];
if (isFunction(sourceFunction)) {
expression[key] = function () {
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
var /** @type {?} */result = sourceFunction.apply(expression, args);
// TODO add decorator for muttable methods instead of trigger
if (!line.immutable) {
expression.method = expression.method || [];
if (expression.method.indexOf(key) < 0) {
expression.method.push(key);
}
line.immutable = true;
}
return result;
};
}
});
return node;
};
this.plan.push(build);
this.planMap[id] = build;
return this;
};
var /** @type {?} */groupFactory = function groupFactory() {
var /** @type {?} */id = guid();
var /** @type {?} */sampleExpression = void 0;
if (arguments.length > 1) {
id = arguments.length <= 0 ? undefined : arguments[0];
sampleExpression = arguments.length <= 1 ? undefined : arguments[1];
} else if (arguments.length === 1) {
sampleExpression = arguments.length <= 0 ? undefined : arguments[0];
}
var /** @type {?} */build = function build(node, line, expressionGroup) {
var /** @type {?} */expression = defaults$1(sampleExpression, statement.defaults, settings.defaults);
expression.id = id;
expression.type = statement.type;
expression.templateUrl = statement.templateKey;
expressionGroup.expressions.push(expression);
methodsOf(expression).with(node, line);
return node;
};
this.plan.push(build);
return this;
};
NodeSchemaT.prototype[statement.type] = factory;
GroupSchema.prototype[statement.type] = groupFactory;
});
// TODO: think how to avoid this
return (/** @type {?} */new NodeSchemaT()
);
}
}]);
return ExpressionBuilder;
}();
function ExpressionBuilder_tsickle_Closure_declarations() {
/** @type {?} */
ExpressionBuilder.prototype.settings;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @param {?} inst
* @return {?}
*/
function swap(inst) {
var /** @type {?} */result = {};
for (var /** @type {?} */prop in inst) {
if (inst.hasOwnProperty(prop)) {
result[inst[prop]] = prop;
}
}
return result;
}
var /** @type {?} */commonOperators = ['EQUALS', 'NOT EQUALS', 'IN', 'IS EMPTY', 'IS NOT EMPTY'];
var /** @type {?} */oneToOneCommonOperators = ['EQUALS', 'NOT EQUALS'];
var /** @type {?} */textOperators = ['LIKE', 'NOT LIKE', 'STARTS WITH', 'ENDS WITH'];
var /** @type {?} */numberOperators = ['BETWEEN', 'GREATER THAN', 'LESS THAN', 'GREATER OR EQ. TO', 'LESS OR EQ. TO'];
var /** @type {?} */oneToOneNumberOperators = ['GREATER THAN', 'LESS THAN', 'GREATER OR EQ. TO', 'LESS OR EQ. TO'];
var /** @type {?} */camelCaseMapping = {
'IS EMPTY': 'isNull',
'IS NOT EMPTY': 'isNotNull',
'EQUALS': 'equals',
'NOT EQUALS': 'notEquals',
'GREATER OR EQ. TO': 'greaterThanOrEquals',
'LESS OR EQ. TO': 'lessThanOrEquals',
'GREATER THAN': 'greaterThan',
'LESS THAN': 'lessThan',
'LIKE': 'like',
'NOT LIKE': 'notLike',
'STARTS WITH': 'startsWith',
'ENDS WITH': 'endsWith',
'IN': 'in',
'BETWEEN': 'between'
};
var /** @type {?} */typeMapping = {
bool: oneToOneCommonOperators,
id: commonOperators.concat(textOperators),
text: commonOperators.concat(textOperators),
email: commonOperators.concat(textOperators),
url: commonOperators.concat(textOperators),
password: commonOperators.concat(textOperators),
number: commonOperators.concat(numberOperators),
date: commonOperators.concat(numberOperators),
time: commonOperators.concat(numberOperators),
currency: commonOperators.concat(numberOperators)
};
var /** @type {?} */oneToOneMapping = {
bool: oneToOneCommonOperators,
id: oneToOneCommonOperators.concat(textOperators),
text: oneToOneCommonOperators.concat(textOperators),
email: oneToOneCommonOperators.concat(textOperators),
url: oneToOneCommonOperators.concat(textOperators),
password: oneToOneCommonOperators.concat(textOperators),
number: oneToOneCommonOperators.concat(oneToOneNumberOperators),
date: oneToOneCommonOperators.concat(oneToOneNumberOperators),
time: oneToOneCommonOperators.concat(oneToOneNumberOperators),
currency: oneToOneCommonOperators.concat(oneToOneNumberOperators)
};
var /** @type {?} */labelMapping = swap(camelCaseMapping);
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @record
*/
function IQueryBuilderSchema() {}
function IQueryBuilderSchema_tsickle_Closure_declarations() {
/** @type {?} */
IQueryBuilderSchema.prototype.apply;
/** @type {?} */
IQueryBuilderSchema.prototype.attr;
/** @type {?} */
IQueryBuilderSchema.prototype.node;
/** @type {?} */
IQueryBuilderSchema.prototype.group;
/** @type {?} */
IQueryBuilderSchema.prototype.get;
/** @type {?} */
IQueryBuilderSchema.prototype.materialize;
/** @type {?} */
IQueryBuilderSchema.prototype.autocomplete;
/** @type {?} */
IQueryBuilderSchema.prototype.button;
/** @type {?} */
IQueryBuilderSchema.prototype.input;
/** @type {?} */
IQueryBuilderSchema.prototype.iconButton;
/** @type {?} */
IQueryBuilderSchema.prototype.label;
/** @type {?} */
IQueryBuilderSchema.prototype.multiselect;
/** @type {?} */
IQueryBuilderSchema.prototype.select;
}
var QueryBuilderService = function () {
/**
* @param {?} model
*/
function QueryBuilderService(model) {
classCallCheck(this, QueryBuilderService);
this.model = model;
}
/**
* @return {?}
*/
createClass(QueryBuilderService, [{
key: 'columns',
value: function columns() {
var /** @type {?} */model = this.model;
return model.columnList().line.filter(function (column) {
return typeMapping.hasOwnProperty(column.type);
}).map(function (column) {
return {
key: column.key,
title: column.title,
type: column.type
};
});
}
/**
* @return {?}
*/
}, {
key: 'columnMap',
value: function columnMap() {
return this.columns().reduce(function (memo, column) {
memo[column.key] = column;
return memo;
}, {});
}
/**
* @param {?} expression
* @return {?}
*/
}, {
key: 'submit',
value: function submit(expression) {
var /** @type {?} */model = this.model;
model.filter({
by: expression
}, {
source: 'query-builder.service'
});
}
/**
* @param {?} key
* @param {?} skip
* @param {?} take
* @param {?} search
* @param {?=} selection
* @return {?}
*/
}, {
key: 'suggest',
value: function suggest(key, skip, take, search, selection) {
selection = (selection || []).map(function (item) {
return ('' + item).toLowerCase();
});
var /** @type {?} */model = this.model;
var /** @type {?} */columnMap = map$1(model.columnList().line);
var /** @type {?} */column = columnMap[key];
if (!column) {
throw new AppError('query-builder.service', 'Column ' + key + ' is not found');
}
var /** @type {?} */getValue = getFactory(column);
return new Promise(function (resolve) {
var /** @type {?} */view = model.data().rows.map(getValue).filter(function (item) {
return !isUndefined(item) && item !== '' && item !== null && selection.indexOf(('' + item).toLowerCase()) < 0;
});
var /** @type {?} */uniqueView = uniq(view);
var /** @type {?} */sortedView = uniqueView.sort();
var /** @type {?} */searchText = ('' + search).toLowerCase();
var /** @type {?} */filterView = searchText ? sortedView.filter(function (x) {
return ('' + x).toLowerCase().indexOf(searchText) >= 0;
}) : sortedView;
var /** @type {?} */toggleView = filterView.length ? filterView : sortedView;
var /** @type {?} */pageView = toggleView.slice(skip, take);
resolve(pageView);
});
}
/**
* @return {?}
*/
}, {
key: 'build',
value: function build() {
var /** @type {?} */statements = [{
type: 'label',
templateKey: 'plugin-eb-label.tpl.html'
}, {
type: 'input',
templateKey: 'plugin-eb-input.tpl.html'
}, {
type: 'select',
templateKey: 'plugin-eb-select.tpl.html'
}, {
type: 'button',
templateKey: 'plugin-eb-button.tpl.html'
}, {
type: 'iconButton',
templateKey: 'plugin-eb-icon-button.tpl.html'
}, {
type: 'autocomplete',
templateKey: 'plugin-eb-autocomplete.tpl.html'
}, {
type: 'multiselect',
templateKey: 'plugin-eb-multiselect.tpl.html'
}];
var /** @type {?} */settings = {
defaults: {
isValid: function isValid() {
return !this.validate || !(this.state = this.validate()).length;
}
}
};
return new ExpressionBuilder(settings).build(statements);
}
}]);
return QueryBuilderService;
}();
function QueryBuilderService_tsickle_Closure_declarations() {
/** @type {?} */
QueryBuilderService.prototype.model;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @param {?} service
* @param {?} name
* @return {?}
*/
function suggestFactory(service, name) {
return function (node, line) {
var /** @type {?} */search = this.value == null ? '' : ('' + this.value).toLowerCase();
var /** @type {?} */field = line.get(name).expressions[0].value;
return service.suggest(field, 0, 10, search);
};
}
/**
* @param {?} service
* @param {?} name
* @return {?}
*/
function suggestsFactory(service, name) {
return function (node, line) {
var /** @type {?} */search = this.search;
var /** @type {?} */field = line.get(name).expressions[0].value;
var /** @type {?} */selection = (this.values || []).map(function (item) {
return ('' + item).toLowerCase();
});
return new Promise(function (resolve, reject) {
return service.suggest(field, 0, 10, search, selection).then(function (items) {
var /** @type {?} */result = selection.length ? items.filter(function (item) {
return selection.indexOf(('' + item).toLowerCase()) < 0;
}) : items;
}).catch(function (ex) {
return reject(ex);
});
});
};
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var Validator$2 = function () {
/**
* @param {?} service
*/
function Validator(service) {
classCallCheck(this, Validator);
this.trueResult = [];
this.validators = {};
this.rules = {
'bool': ['required'],
'currency': ['required', 'decimal'],
'date': ['required', 'iso_date'],
'email': ['required'],
'file': ['required'],
'id': ['required'],
'image': ['required'],
'number': ['required', 'decimal'],
'password': ['required'],
'url': ['required'],
'reference': ['required'],
'text': ['required', 'string'],
'time': ['required']
};
this.columnMap = service.columnMap();
}
/**
* @param {?} key
* @return {?}
*/
createClass(Validator, [{
key: 'for',
value: function _for(key) {
var /** @type {?} */validators = this.validators;
if (validators.hasOwnProperty('key')) {
return validators[key];
}
var /** @type {?} */column = this.columnMap[key];
if (!column) {
throw new AppError('validator', 'Can\'t find column ' + key);
}
var /** @type {?} */trueResult = this.trueResult;
var /** @type {?} */id = column.type;
var /** @type {?} */rule = this.rules[id];
var /** @type {?} */validate = function validate(value) {
return trueResult;
};
if (rule) {
var /** @type {?} */schema = defineProperty({}, id, rule);
validate = function test(value) {
if (isArray(value)) {
var /** @type {?} */result = [];
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = value[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var item = _step.value;
result.push.apply(result, toConsumableArray(test(item)));
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
return result;
}
var /** @type {?} */target = defineProperty({}, id, value);
var /** @type {?} */validator = createValidator(schema);
var /** @type {?} */isValid = validator.validate(target);
if (isValid) {
return trueResult;
}
var /** @type {?} */error = validator.getErrors()[id];
return isArray(error) ? error : [error];
};
}
validators[key] = validate;
return validate;
}
}]);
return Validator;
}();
function Validator_tsickle_Closure_declarations() {
/** @type {?} */
Validator$2.prototype.columnMap;
/** @type {?} */
Validator$2.prototype.trueResult;
/** @type {?} */
Validator$2.prototype.validators;
/** @type {?} */
Validator$2.prototype.rules;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var /** @type {?} */getValue$3 = function getValue(line, id, props) {
var /** @type {?} */group = line.get(id);
if (group) {
if (group.expressions.length === 1) {
var /** @type {?} */expr = group.expressions[0];
var /** @type {?} */prop = props.filter(function (p) {
return expr.hasOwnProperty(p);
})[0];
if (prop) {
var /** @type {?} */value = expr[prop];
if (isArray(value) && value.length) {
return value[0];
}
return value;
}
}
}
return null;
};
var WhereSchema = function () {
/**
* @param {?} service
*/
function WhereSchema(service) {
classCallCheck(this, WhereSchema);
this.service = service;
}
/**
* @return {?}
*/
createClass(WhereSchema, [{
key: 'factory',
value: function factory() {
var /** @type {?} */service = this.service;
var /** @type {?} */suggest = suggestFactory(service, '#field');
var /** @type {?} */suggests = suggestsFactory(service, '#field');
var /** @type {?} */validator = new Validator$2(service);
return this.service.build().node('#logical', function (schema) {
schema.attr('serialize', {
'#logical-op': ['value']
}).attr('class', {
'qb-logical': true,
'qb-and': function qbAnd(node) {
var /** @type {?} */op = node.line.get('#logical-op');
return op.expressions[0].value === 'AND';
},
'qb-or': function qbOr(node) {
var /** @type {?} */op = node.line.get('#logical-op');
return op.expressions[0].value === 'OR';
}
}).select('#logical-op', {
classes: ['qb-operation'],
options: ['AND', 'OR'],
value: 'AND'
}).node('#condition', function (schema) {
schema.attr('serialize', {
'#field': ['value'],
'#operator': ['value'],
'#value': ['value'],
'#from': ['value'],
'#to': ['value'],
'#in-operand': ['values']
}).select('#field', {
classes: ['qb-field'],
options: service.columns().map(function (c) {
return c.key;
}),
value: service.columns().length ? service.columns()[0].key : '',
getLabel: function getLabel(node, line, key) {
var /** @type {?} */column = service.columns().filter(function (c) {
return c.key === key;
})[0];
return column && column.title || null;
},
getType: function getType(node, line, key) {
var /** @type {?} */column = service.columns().filter(function (c) {
return c.key === key;
})[0];
return column && column.type || null;
},
change: function change(node, line) {
var /** @type {?} */field = this.value;
var /** @type {?} */type = this.getType(field);
var /** @type {?} */ops = typeMapping[type] || [];
var /** @type {?} */op = line.get('#operator').expressions[0];
if (ops.indexOf(op.value) < 0) {
op.value = ops.length ? ops[0] : null;
op.change();
} else {
var /** @type {?} */operand = line.get('#operand').expressions[0];
if (operand.validate) {
var /** @type {?} */result = operand.validate();
if (result.length) {
operand.value = null;
}
} else {
operand.value = null;
}
}
}
}).select('#operator', {
classes: ['qb-operator'],
getOptions: function getOptions(node, line) {
var /** @type {?} */field = line.get('#field').expressions[0];
var /** @type {?} */name = field.value;
var /** @type {?} */type = field.getType(name);
return type ? typeMapping[type] : [];
},
value: 'EQUALS',
change: function change(node, line) {
switch (this.value.toLowerCase()) {
case 'equals':
case 'not equals':
case 'greater than':
case 'less than':
case 'greater or eq. to':
case 'less or eq. to':
case 'like':
case 'not like':
case 'starts with':
case 'ends with':
var /** @type {?} */value = getValue$3(line, '#operand', ['value', 'values']);
line.put('#operand', node, function (schema) {
schema.input('#value', {
classes: {
'qb-operand': true,
'qb-has-value': function qbHasValue() {
return !!this.value;
},
'qb-invalid': function qbInvalid(node) {
return !this.isValid(node);
}
},
value: value,
validate: function validate() {
var /** @type {?} */field = line.get('#field').expressions[0].value;
return validator.for(field)(this.value);
},
placeholderText: 'Select value',
suggest: suggest,
options: null,
refresh: function refresh(node, line) {
this.options = this.suggest(node, line);
}
});
});
break;
case 'between':
line.put('#operand', node, function (schema) {
schema.input('#from', {
classes: {
'qb-operand': true,
'qb-has-value': function qbHasValue() {
return !!this.value;
},
'qb-invalid': function qbInvalid(node) {
return !this.isValid(node);
}
},
validate: function validate() {
var /** @type {?} */field = line.get('#field').expressions[0].value;
return validator.for(field)(this.value);
},
options: suggest,
value: null,
placeholderText: 'Select value'
}).label('#and', {
classes: ['qb-operand', 'qb-operand-and-label'],
text: 'AND'
}).input('#to', {
classes: {
'qb-operand': true,
'qb-has-value': function qbHasValue() {
return !!this.value;
},
'qb-invalid': function qbInvalid(node) {
return !this.isValid(node);
}
},
value: null,
validate: function validate() {
var /** @type {?} */field = line.get('#field').expressions[0].value;
return validator.for(field)(this.value);
},
placeholderText: 'Select value',
suggest: suggest,
options: null,
refresh: function refresh(node, line) {
this.options = this.suggest(node, line);
}
});
});
break;
case 'in':
line.put('#operand', node, function (schema) {
schema.label('#in-open', {
text: '('
}).multiselect('#in-operand', {
classes: {
'qb-operand': true,
'qb-has-value': function qbHasValue() {
return !!this.values.length;
},
'qb-invalid': function qbInvalid(node) {
return !this.isValid(node);
}
},
validate: function validate() {
var /** @type {?} */field = line.get('#field').expressions[0].value;
return validator.for(field)(this.values);
},
values: [],
options: suggests,
placeholderText: 'Select value',
add: function add(node, line, value) {
if (value && this.values.indexOf(value) < 0) {
this.values.push(value);
}
}
}).label('#in-close', {
text: ')'
});
});
break;
case 'is empty':
case 'is not empty':
line.put('#operand', node, noop$1);
break;
}
}
}).group('#operand', function (schema) {
schema.autocomplete('#value', {
classes: {
'qb-operand': true,
'qb-has-value': function qbHasValue() {
return !!this.value;
},
'qb-invalid': function qbInvalid(node) {
return !this.isValid(node);
}
},
value: null,
validate: function validate(node, line) {
var /** @type {?} */field = line.get('#field').expressions[0].value;
return validator.for(field)(this.value);
},
placeholderText: 'Select value',
suggest: suggest,
options: null,
refresh: function refresh(node, line) {
this.options = this.suggest(node, line);
}
});
});
});
});
}
}]);
return WhereSchema;
}();
function WhereSchema_tsickle_Closure_declarations() {
/** @type {?} */
WhereSchema.prototype.service;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @param {?} item
* @return {?}
*/
function visit(item) {
switch (item.id) {
case '#root':
return visit(item.children[0]);
case '#logical':
var /** @type {?} */group = visitGroup(item);
if (group) {
if (!(group.left || group.right)) {
return null;
}
}
return group;
case '#condition':
return visitCondition(item);
default:
throw new AppError('converter', 'Invalid kind ' + item.kind);
}
}
/**
* @param {?} node
* @return {?}
*/
function visitGroup(node) {
var /** @type {?} */line = node.line;
var /** @type {?} */opExpr = find$2(line, '#logical-op', '#logical-op');
var /** @type {?} */children = node.children.filter(notPlaceholder).map(visit);
if (children.length === 0) {
return null;
}
if (children.length === 1) {
return {
kind: 'group',
op: opExpr.value.toLowerCase(),
left: children[0],
right: null
};
}
return children.slice(1).reduce(function (memo, item) {
return {
kind: 'group',
op: opExpr.value.toLowerCase(),
left: memo,
right: item
};
}, children[0]);
}
/**
* @param {?} node
* @return {?}
*/
function visitCondition(node) {
var /** @type {?} */line = node.line;
var /** @type {?} */opExpr = find$2(line, '#operator', '#operator');
var /** @type {?} */value = opExpr.value.toUpperCase();
var /** @type {?} */condition = void 0;
switch (value) {
case 'IS NOT EMPTY':
case 'IS EMPTY':
condition = visitUnary(line, opExpr.value);
break;
case 'EQUALS':
case 'NOT EQUALS':
case 'GREATER OR EQ. TO':
case 'GREATER THAN':
case 'LESS OR EQ. TO':
case 'LESS THAN':
case 'LIKE':
case 'NOT LIKE':
case 'STARTS WITH':
case 'ENDS WITH':
condition = visitBinary(line, opExpr.value);
break;
case 'BETWEEN':
condition = visitBetween(line);
break;
case 'IN':
condition = visitIn(line);
break;
default:
throw new AppError('converter', 'Invalid operation ' + value);
}
condition.kind = 'condition';
return condition;
}
/**
* @param {?} line
* @param {?} op
* @return {?}
*/
function visitUnary(line, op) {
var /** @type {?} */left = visitField(line);
return {
left: left.value,
op: camelCaseMapping[op.toUpperCase()]
};
}
/**
* @param {?} line
* @param {?} op
* @return {?}
*/
function visitBinary(line, op) {
var /** @type {?} */left = visitField(line);
var /** @type {?} */right = find$2(line, '#operand', '#value') || find$2(line, '#fieldRight');
return {
left: left.value,
op: camelCaseMapping[op.toUpperCase()],
right: right.value
};
}
/**
* @param {?} line
* @return {?}
*/
function visitIn(line) {
var /** @type {?} */left = visitField(line);
var /** @type {?} */right = find$2(line, '#operand', '#in-operand') || find$2(line, '#fieldRight');
return {
left: left.value,
op: 'in',
right: cloneDeepWith(right.values) || right.value
};
}
/**
* @param {?} line
* @return {?}
*/
function visitBetween(line) {
var /** @type {?} */left = visitField(line);
var /** @type {?} */from = find$2(line, '#operand', '#from') || find$2(line, '#fieldFrom');
var /** @type {?} */to = find$2(line, '#operand', '#to') || find$2(line, '#fieldTo');
return {
left: left.value,
op: 'between',
right: [from.value, to.value]
};
}
/**
* @param {?} line
* @return {?}
*/
function visitField(line) {
return find$2(line, '#field') || find$2(line, '#fieldLeft');
}
/**
* @param {?} node
* @return {?}
*/
function notPlaceholder(node) {
return !node.attributes.placeholder;
}
/**
* @param {?} line
* @param {?} groupId
* @param {?=} exprId
* @return {?}
*/
function find$2(line, groupId, exprId) {
var /** @type {?} */group = findById(line, groupId);
if (!group) {
return null;
}
return findById(group.expressions, exprId || groupId);
}
/**
* @param {?} items
* @param {?} id
* @return {?}
*/
function findById(items, id) {
var /** @type {?} */result = items.filter(function (item) {
return item.id === id;
});
var /** @type {?} */length = result.length;
if (length === 1) {
return result[0];
}
if (length > 1) {
throw new AppError('converter', 'Ambiguous id ' + id);
}
return null;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var TraverseService = function () {
function TraverseService() {
classCallCheck(this, TraverseService);
}
createClass(TraverseService, [{
key: "findUp",
/**
* @param {?} node
* @param {?} test
* @return {?}
*/
value: function findUp(node, test) {
while (node) {
if (test(node)) {
return node;
}
node = node.parent;
}
return null;
}
/**
* @param {?} node
* @return {?}
*/
}, {
key: "findUpSibling",
value: function findUpSibling(node) {
if (node.parent) {
var /** @type {?} */children = node.parent.children;
var /** @type {?} */index = children.indexOf(node);
if (index >= 0) {
if (index > 0) {
return children[index - 1];
}
return node.parent;
}
}
return null;
}
/**
* @param {?} root
* @return {?}
*/
}, {
key: "depth",
value: function depth(root) {
var _this = this;
return function (reduce, memo) {
memo = _this.visitLine(reduce, memo, root, root.line);
var /** @type {?} */children = root.children;
var /** @type {?} */length = children.length;
for (var /** @type {?} */i = 0; i < length; i++) {
memo = _this.depth(children[i])(reduce, memo);
}
return memo;
};
}
/**
* @param {?} reduce
* @param {?} memo
* @param {?} node
* @param {?} line
* @return {?}
*/
}, {
key: "visitLine",
value: function visitLine(reduce, memo, node, line) {
var /** @type {?} */groups = line.expressions;
var /** @type {?} */length = groups.length;
for (var /** @type {?} */i = 0; i < length; i++) {
memo = this.visitGroup(reduce, memo, node, line, groups[i]);
}
return memo;
}
/**
* @param {?} reduce
* @param {?} memo
* @param {?} node
* @param {?} line
* @param {?} group
* @return {?}
*/
}, {
key: "visitGroup",
value: function visitGroup(reduce, memo, node, line, group) {
var /** @type {?} */expressions = group.expressions;
var /** @type {?} */length = expressions.length;
for (var /** @type {?} */i = 0; i < length; i++) {
memo = reduce(memo, expressions[i], line, node);
}
return memo;
}
}]);
return TraverseService;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var QueryBuilderPanelComponent = function () {
/**
* @param {?} plugin
* @param {?} nodeService
* @param {?} focusAfterRender
*/
function QueryBuilderPanelComponent(plugin, nodeService, focusAfterRender) {
var _this = this;
classCallCheck(this, QueryBuilderPanelComponent);
this.plugin = plugin;
this.nodeService = nodeService;
this.close = new EventEmitter();
this.context = {
$implicit: this
};
this.traverse = new TraverseService();
this.addGroup = new Command({
execute: function execute() {
var /** @type {?} */current = _this.nodeService.current;
var /** @type {?} */parent = _this.findLogicalNode(current);
var /** @type {?} */group = parent.clone();
parent.addChildAfter(group, current.id === '#condition' && current);
if (current.id === '#condition') {
_this.nodeService.current = group;
}
},
canExecute: function canExecute() {
return !!_this.findLogicalNode(_this.nodeService.current);
}
});
this.addRule = new Command({
execute: function execute() {
var /** @type {?} */current = _this.nodeService.current;
var /** @type {?} */parent = _this.findLogicalNode(current);
var /** @type {?} */rule = _this.plan.materialize('#condition');
parent.addChildAfter(rule, current.id === '#condition' && current);
if (current.id === '#condition') {
_this.nodeService.current = rule;
}
},
canExecute: function canExecute() {
return !!_this.findLogicalNode(_this.nodeService.current);
}
});
this.remove = new Command({
execute: function execute() {
var /** @type {?} */current = _this.nodeService.current;
if (current.id === '#logical' && current.level === 1) {
current.clear();
} else {
var /** @type {?} */previous = _this.traverse.findUpSibling(current);
_this.nodeService.current = previous;
current.remove();
}
},
canExecute: function canExecute() {
var /** @type {?} */current = _this.nodeService.current;
return current && (current.id === '#condition' || current.level > 1 || current.children.length > 0);
}
});
this.submit = new Command({
source: 'query-builder.component',
execute: function execute() {
var /** @type {?} */serializer = new SerializationService();
var /** @type {?} */node = serializer.serialize(_this.node);
var /** @type {?} */by = clone(_this.plugin.model.filter().by);
by.$expression = visit(node);
_this.plugin.model.filter({ by: by });
_this.plugin.model.queryBuilder({ node: by.$expression ? node : null });
_this.close.emit();
},
canExecute: function canExecute() {
var /** @type {?} */depth = _this.traverse.depth(_this.node);
return depth(function (memo, expression, line, node) {
return node.attr('placeholder') ? memo : memo && expression.isValid();
}, true);
}
});
this.cancel = new Command({
source: 'query-builder.component',
execute: function execute() {
_this.close.emit();
}
});
this.reset = new Command({
source: 'query-builder.component',
execute: function execute() {
var /** @type {?} */schema = new WhereSchema(_this.queryService);
var /** @type {?} */plan = schema.factory();
_this.node = plan.apply();
var /** @type {?} */root = _this.node.children[0];
root.clear();
_this.nodeService.current = _this.node.children[0];
}
});
}
/**
* @return {?}
*/
createClass(QueryBuilderPanelComponent, [{
key: 'ngOnInit',
value: function ngOnInit() {
this.queryService = new QueryBuilderService(this.plugin.model);
var /** @type {?} */schema = new WhereSchema(this.queryService);
this.plan = /** @type {?} */schema.factory();
this.node = this.plan.apply();
var /** @type {?} */serializer = new SerializationService();
var _plugin$model$queryBu = this.plugin.model.queryBuilder(),
node = _plugin$model$queryBu.node;
if (node) {
this.node = serializer.deserialize(this.plan, node);
}
this.nodeService.current = this.node.children[0];
}
/**
* @param {?} node
* @return {?}
*/
}, {
key: 'findLogicalNode',
value: function findLogicalNode(node) {
return this.traverse.findUp(node, function (n) {
return n.id === '#logical';
});
}
}]);
return QueryBuilderPanelComponent;
}();
QueryBuilderPanelComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-query-builder-panel',
template: "<ng-container key=\"plugin-query-builder-panel.tpl.html\" [context]=\"context\"></ng-container>",
providers: [FocusAfterRender$1, PluginService]
}] }];
/** @nocollapse */
QueryBuilderPanelComponent.ctorParameters = function () {
return [{ type: PluginService }, { type: EbNodeService }, { type: FocusAfterRender$1 }];
};
QueryBuilderPanelComponent.propDecorators = {
close: [{ type: Output }]
};
function QueryBuilderPanelComponent_tsickle_Closure_declarations() {
/** @type {?} */
QueryBuilderPanelComponent.prototype.node;
/** @type {?} */
QueryBuilderPanelComponent.prototype.close;
/** @type {?} */
QueryBuilderPanelComponent.prototype.queryService;
/** @type {?} */
QueryBuilderPanelComponent.prototype.context;
/** @type {?} */
QueryBuilderPanelComponent.prototype.traverse;
/** @type {?} */
QueryBuilderPanelComponent.prototype.addGroup;
/** @type {?} */
QueryBuilderPanelComponent.prototype.addRule;
/** @type {?} */
QueryBuilderPanelComponent.prototype.remove;
/** @type {?} */
QueryBuilderPanelComponent.prototype.submit;
/** @type {?} */
QueryBuilderPanelComponent.prototype.cancel;
/** @type {?} */
QueryBuilderPanelComponent.prototype.reset;
/** @type {?} */
QueryBuilderPanelComponent.prototype.plan;
/** @type {?} */
QueryBuilderPanelComponent.prototype.plugin;
/** @type {?} */
QueryBuilderPanelComponent.prototype.nodeService;
}
function stringify(value, type, isValid) {
if (!isValid) {
return '<span class="q-grid-markup-condition-value-invalid"></span>';
}
switch (type) {
case 'text':
return stringifyText(value);
case 'number':
return stringifyNumber(value);
case 'date':
return stringifyDate(value);
default:
return '' + value;
}
}
function stringifyText(value) {
return '<span class="q-grid-markup-condition-quote">\'</span>\n <span class="q-grid-markup-condition-value q-grid-markup-condition-value-text">' + value + '</span>\n <span class="q-grid-markup-condition-quote">\'</span>';
}
function stringifyDate(value) {
var date = new Date(value);
if (date !== 'Invalid Date' && !isNaN(date)) {
return '<span class="q-grid-markup-condition-quote">\'</span>\n <span class="q-grid-markup-condition-value q-grid-markup-condition-value-date">' + value + '</span>\n <span class="q-grid-markup-condition-quote">\'</span>';
}
return '<span class="q-grid-markup-condition-quote">\'</span>\n <span class="q-grid-markup-condition-value q-grid-markup-condition-value-date q-grid-markup-condition-error">' + value + '</span>\n <span class="q-grid-markup-condition-quote">\'</span>';
}
function stringifyNumber(value) {
var number = parseFloat(value);
if (!isNaN(number) && isFinite(number)) {
return '<span class="q-grid-markup-condition-value q-grid-markup-condition-number">' + value + '</span>';
}
return '<span class="q-grid-markup-condition-value q-grid-markup-condition-number q-grid-markup-condition-error">' + value + '</span>';
}
function stringifyInteger(value) {
var number = parseInt(value);
if (!isNaN(number) && isFinite(number)) {
return '<span class="q-grid-markup-condition-value q-grid-markup-condition-number">' + value + '</span>';
}
return '<span class="q-grid-markup-condition-value q-grid-markup-condition-number q-grid-markup-condition-error">' + value + '</span>';
}
var MarkupVisitor = function (_Visitor) {
inherits(MarkupVisitor, _Visitor);
function MarkupVisitor(label, type, isValid) {
classCallCheck(this, MarkupVisitor);
var _this = possibleConstructorReturn(this, (MarkupVisitor.__proto__ || Object.getPrototypeOf(MarkupVisitor)).call(this));
_this.label = label;
_this.type = type;
_this.isValid = isValid;
return _this;
}
createClass(MarkupVisitor, [{
key: 'visitGroup',
value: function visitGroup(group, depth) {
if (group.right) {
var l = this.visit(group.left, depth);
var r = this.visit(group.right, depth);
var expr = '<div class="q-grid-markup-node-left">' + l + '</div><span class="q-grid-markup-group-op">' + group.op + '</span><div class="q-grid-markup-node-right">' + r + '</div>';
return '<div class="q-grid-markup-node">' + (depth > 1 ? '<span class="q-grid-markup-group-open">(</span>' + expr + '<span class="q-grid-markup-group-close">)</span>' : expr) + '</div>';
}
return '<div class="q-grid-markup-node">' + this.visit(group.left, depth) + '<div class="q-grid-markup-node">';
}
}, {
key: 'visitUnary',
value: function visitUnary(condition) {
switch (condition.op) {
case 'isNotNull':
return '<span class="q-grid-markup-condition-left">' + this.label(condition.left) + '</span><span class="q-grid-markup-condition-right q-grid-markup-condition-unary">is not empty</span>';
case 'isNull':
return '<span class="q-grid-markup-condition-left">' + this.label(condition.left) + '</span><span class="q-grid-markup-condition-right q-grid-markup-condition-unary">is empty</span>';
default:
throw new AppError('markup.visitor', 'Invalid operation ' + condition.op);
}
}
}, {
key: 'visitBinary',
value: function visitBinary(condition) {
var op = void 0;
switch (condition.op) {
case 'equals':
op = '=';
break;
case 'notEquals':
op = '<>';
break;
case 'greaterThanOrEquals':
op = '>=';
break;
case 'greaterThan':
op = '>';
break;
case 'lessThanOrEquals':
op = '<=';
break;
case 'lessThan':
op = '<';
break;
case 'like':
op = 'like';
break;
case 'notLike':
op = 'not like';
break;
case 'startsWith':
op = 'starts with';
break;
case 'endsWith':
op = 'ends with';
break;
default:
throw new AppError('markup.visitor', 'Invalid operation ' + condition.op);
}
var isValid = this.isValid(condition.left, condition.right);
return '<span class="q-grid-markup-condition-left">' + this.label(condition.left) + '</span>\n <span class="q-grid-markup-condition-op">' + op + '</span>\n <span class="q-grid-markup-condition-right">' + stringify(condition.right, this.type(condition.left), isValid) + '</span>';
}
}, {
key: 'visitBetween',
value: function visitBetween(condition) {
var isValid = this.isValid(condition.left, condition.right);
return '<span class="q-grid-markup-condition-left">' + this.label(condition.left) + '</span>\n <span class="q-grid-markup-condition-op">between</span>\n <span class="q-grid-markup-condition-right">' + stringify(condition.right[0], this.type(condition.left), isValid) + '</span>\n <span class="q-grid-markup-condition-op">and</span>\n <span class="q-grid-markup-condition-right">' + stringify(condition.right[1], this.type(condition.left), isValid) + '</span>';
}
}, {
key: 'visitIn',
value: function visitIn(condition) {
var _this2 = this;
var isValid = this.isValid(condition.left, condition.right);
return '<span class="q-grid-markup-condition-left">' + this.label(condition.left) + '</span>\n <span class="q-grid-markup-condition-op">in</span>\n <span class="q-grid-markup-condition-open">(</span>\n <span class="q-grid-markup-condition-right">' + condition.right.map(function (item) {
return stringify(item, _this2.type(condition.left), isValid);
}).join(', ') + '</span>\n <span class="q-grid-markup-condition-close">)</span>';
}
}]);
return MarkupVisitor;
}(Visitor);
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var QueryBuilderPipe = function () {
function QueryBuilderPipe() {
classCallCheck(this, QueryBuilderPipe);
}
createClass(QueryBuilderPipe, [{
key: 'transform',
/**
* @param {?} value
* @param {?} service
* @return {?}
*/
value: function transform(value, service) {
var /** @type {?} */node = /** @type {?} */value;
if (node) {
if (!this.visitor) {
var /** @type {?} */validator = new Validator$2(service);
var /** @type {?} */columnMap = service.columnMap();
this.visitor = new MarkupVisitor(function (key) {
return columnMap[key].title;
}, function (key) {
return columnMap[key].type;
}, function (key, value) {
return validator.for(key)(value).length === 0;
});
}
var /** @type {?} */serializer = new SerializationService();
var /** @type {?} */filter = serializer.serialize(node);
var /** @type {?} */expression = visit(filter);
if (expression) {
return this.visitor.visit(expression);
}
}
return 'Please, select a query';
}
}]);
return QueryBuilderPipe;
}();
QueryBuilderPipe.decorators = [{ type: Pipe, args: [{
name: 'qGridQueryBuilderMarkup',
pure: false
}] }];
function QueryBuilderPipe_tsickle_Closure_declarations() {
/** @type {?} */
QueryBuilderPipe.prototype.visitor;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var QueryBuilderModule = function QueryBuilderModule() {
classCallCheck(this, QueryBuilderModule);
};
QueryBuilderModule.decorators = [{ type: NgModule, args: [{
imports: [TemplateModule],
exports: [QueryBuilderComponent, QueryBuilderPanelComponent, QueryBuilderPipe],
declarations: [QueryBuilderComponent, QueryBuilderPanelComponent, QueryBuilderPipe]
}] }];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var ReferenceEditorComponent = function (_NgComponent) {
inherits(ReferenceEditorComponent, _NgComponent);
function ReferenceEditorComponent() {
classCallCheck(this, ReferenceEditorComponent);
var _this = possibleConstructorReturn(this, (ReferenceEditorComponent.__proto__ || Object.getPrototypeOf(ReferenceEditorComponent)).call(this));
_this.valueChange = new EventEmitter();
_this.afterSubmit = new EventEmitter();
_this.afterCancel = new EventEmitter();
_this.context = {
$implicit: _this
};
_this.submit = new Command();
_this.cancel = new Command();
return _this;
}
/**
* @return {?}
*/
createClass(ReferenceEditorComponent, [{
key: 'ngAfterViewInit',
/**
* @return {?}
*/
value: function ngAfterViewInit() {
var _this2 = this;
var model = this.model;
var _reference = this.reference,
commit = _reference.commit,
cancel = _reference.cancel;
var _model$edit = model.edit(),
commitShortcuts = _model$edit.commitShortcuts,
cancelShortcuts = _model$edit.cancelShortcuts;
var /** @type {?} */selectionService = new SelectionService(model);
// TODO: think how to get rid of this shit.
setTimeout(function () {
_this2.submit = new Command({
shortcut: commitShortcuts["form"],
canExecute: function canExecute() {
var _model$selection = model.selection(),
items = _model$selection.items;
var /** @type {?} */entries = selectionService.lookup(items);
var /** @type {?} */context = { items: items, entries: entries };
return commit.canExecute(context);
},
execute: function execute() {
var _model$selection2 = model.selection(),
items = _model$selection2.items;
var /** @type {?} */entries = selectionService.lookup(items);
var /** @type {?} */context = { items: items, entries: entries };
if (commit.execute(context) !== false) {
_this2.afterSubmit.emit();
} else {
_this2.afterCancel.emit();
}
return false;
}
});
_this2.cancel = new Command({
shortcut: cancelShortcuts["form"] || cancelShortcuts["$default"],
canExecute: function canExecute() {
return cancel.canExecute();
},
execute: function execute() {
if (cancel.execute() !== false) {
_this2.afterCancel.emit();
}
return false;
}
});
var _model$action = model.action(),
shortcut = _model$action.shortcut,
manager = _model$action.manager;
_this2.using(shortcut.register(manager, [_this2.submit, _this2.cancel]));
}, 0);
}
}, {
key: 'value',
get: function get$$1() {
return this.state;
}
/**
* @param {?} value
* @return {?}
*/
,
set: function set$$1(value) {
if (value !== this.state) {
this.state = value;
this.valueChange.emit(value);
}
}
}]);
return ReferenceEditorComponent;
}(NgComponent);
ReferenceEditorComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-reference-editor',
template: "<ng-container key=\"plugin-reference-editor.tpl.html\" [context]=\"context\"></ng-container> "
}] }];
/** @nocollapse */
ReferenceEditorComponent.ctorParameters = function () {
return [];
};
ReferenceEditorComponent.propDecorators = {
caption: [{ type: Input }],
cell: [{ type: Input }],
valueChange: [{ type: Output }],
afterSubmit: [{ type: Output }],
afterCancel: [{ type: Output }],
value: [{ type: Input }]
};
function ReferenceEditorComponent_tsickle_Closure_declarations() {
/** @type {?} */
ReferenceEditorComponent.prototype.state;
/** @type {?} */
ReferenceEditorComponent.prototype.caption;
/** @type {?} */
ReferenceEditorComponent.prototype.cell;
/** @type {?} */
ReferenceEditorComponent.prototype.valueChange;
/** @type {?} */
ReferenceEditorComponent.prototype.afterSubmit;
/** @type {?} */
ReferenceEditorComponent.prototype.afterCancel;
/** @type {?} */
ReferenceEditorComponent.prototype.reference;
/** @type {?} */
ReferenceEditorComponent.prototype.model;
/** @type {?} */
ReferenceEditorComponent.prototype.context;
/** @type {?} */
ReferenceEditorComponent.prototype.submit;
/** @type {?} */
ReferenceEditorComponent.prototype.cancel;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var ReferenceComponent = function (_NgComponent) {
inherits(ReferenceComponent, _NgComponent);
function ReferenceComponent() {
classCallCheck(this, ReferenceComponent);
var _this = possibleConstructorReturn(this, (ReferenceComponent.__proto__ || Object.getPrototypeOf(ReferenceComponent)).call(this));
_this.autofocus = false;
_this.valueChange = new EventEmitter();
_this.modelChange = new EventEmitter();
_this.referenceChange = new EventEmitter();
_this.context = {
$implicit: _this
};
return _this;
}
/**
* @return {?}
*/
createClass(ReferenceComponent, [{
key: 'ngOnInit',
/**
* @return {?}
*/
value: function ngOnInit() {
var _this2 = this;
this.reference = {
commit: new Command({ execute: function execute(e) {
return _this2.value = e.entries;
} }),
cancel: new Command(),
value: this.value
};
this.model = this.cell.column.editorOptions.modelFactory({
reference: this.reference,
row: this.cell.row,
column: this.cell.column,
getValue: getFactory(this.cell.column)
});
var /** @type {?} */selectionService = new SelectionService(this.model);
this.using(this.model.dataChanged.watch(function (e, off) {
if (e.hasChanges('rows') && e.state.rows.length > 0) {
off();
if (!_this2.model.selection().items.length) {
var value = _this2.reference.value;
if (!isUndefined(value)) {
var /** @type {?} */entries = isArray(value) ? value : [value];
var /** @type {?} */items = selectionService.map(entries);
_this2.model.selection({ items: items }, { source: 'reference.component' });
}
}
}
}));
this.using(this.model.selectionChanged.watch(function (e) {
if (e.tag.source === 'reference.component') {
return;
}
if (e.hasChanges('items')) {
var /** @type {?} */entries = selectionService.lookup(e.state.items);
_this2.value = entries;
}
}));
}
}, {
key: 'value',
get: function get$$1() {
return this._value;
}
/**
* @param {?} value
* @return {?}
*/
,
set: function set$$1(value) {
if (value !== this._value) {
this._value = value;
this.valueChange.emit(value);
}
}
/**
* @return {?}
*/
}, {
key: 'model',
get: function get$$1() {
return this._model;
}
/**
* @param {?} value
* @return {?}
*/
,
set: function set$$1(value) {
if (value !== this._model) {
this._model = value;
this.modelChange.emit(value);
}
}
/**
* @return {?}
*/
}, {
key: 'reference',
get: function get$$1() {
return this._reference;
}
/**
* @param {?} value
* @return {?}
*/
,
set: function set$$1(value) {
if (value !== this._reference) {
this._reference = value;
this.referenceChange.emit(value);
}
}
}]);
return ReferenceComponent;
}(NgComponent);
ReferenceComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-reference',
template: "<ng-container key=\"plugin-reference.tpl.html\" [context]=\"context\"></ng-container> "
}] }];
/** @nocollapse */
ReferenceComponent.ctorParameters = function () {
return [];
};
ReferenceComponent.propDecorators = {
autofocus: [{ type: Input }],
cell: [{ type: Input }],
valueChange: [{ type: Output }],
value: [{ type: Input }],
modelChange: [{ type: Output }],
model: [{ type: Input }],
referenceChange: [{ type: Output }],
reference: [{ type: Input }]
};
function ReferenceComponent_tsickle_Closure_declarations() {
/** @type {?} */
ReferenceComponent.prototype._value;
/** @type {?} */
ReferenceComponent.prototype._model;
/** @type {?} */
ReferenceComponent.prototype._reference;
/** @type {?} */
ReferenceComponent.prototype.autofocus;
/** @type {?} */
ReferenceComponent.prototype.cell;
/** @type {?} */
ReferenceComponent.prototype.valueChange;
/** @type {?} */
ReferenceComponent.prototype.modelChange;
/** @type {?} */
ReferenceComponent.prototype.referenceChange;
/** @type {?} */
ReferenceComponent.prototype.context;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var ReferenceEditorModule = function ReferenceEditorModule() {
classCallCheck(this, ReferenceEditorModule);
};
ReferenceEditorModule.decorators = [{ type: NgModule, args: [{
declarations: [ReferenceEditorComponent, ReferenceComponent],
exports: [ReferenceEditorComponent, ReferenceComponent],
imports: [TemplateModule]
}] }];
function serialize$1(model) {
var paginationState = model.pagination();
var sortState = model.sort();
var filterState = model.filter();
return {
filter: filterState.by,
order: sortState.by.map(function (s) {
var key = Object.keys(s)[0];
var value = s[key];
return (value === 'asc' ? '+' : '-') + key;
}),
skip: paginationState.current * paginationState.size,
take: paginationState.size
};
}
var RestView = function () {
function RestView(model, _ref) {
var get$$1 = _ref.get,
post = _ref.post;
classCallCheck(this, RestView);
this.model = model;
var _model$rest = this.model.rest(),
method = _model$rest.method,
url = _model$rest.url,
serialize$$1 = _model$rest.serialize;
if (!url) {
throw new AppError('rest', 'REST endpoint URL is required');
}
var fetch = this.fetchFactory(method, get$$1, post);
var doSerialize = this.serializeFactory(method, serialize$$1);
model.data({
pipe: [function (data, context, next) {
fetch(url, doSerialize(model)).then(function (data) {
return next(data);
});
}].concat(toConsumableArray(PipeUnit.view))
}, { source: 'rest.view' });
}
createClass(RestView, [{
key: 'fetchFactory',
value: function fetchFactory(method, get$$1, post) {
switch (method.toLowerCase()) {
case 'get':
return get$$1;
case 'post':
return post;
default:
throw new AppError('rest', '"' + method + '" is incorrect REST method');
}
}
}, {
key: 'serializeFactory',
value: function serializeFactory(method, serialize$$1) {
if (isFunction(serialize$$1)) {
return serialize$$1;
} else if (method === 'get') {
return serialize;
} else if (method === 'post') {
return serialize$1;
}
}
}]);
return RestView;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var RestComponent = function () {
/**
* @param {?} http
* @param {?} plugin
*/
function RestComponent(http, plugin) {
classCallCheck(this, RestComponent);
this.http = http;
this.plugin = plugin;
}
/**
* @param {?} changes
* @return {?}
*/
createClass(RestComponent, [{
key: 'ngOnChanges',
value: function ngOnChanges(changes) {
this.plugin.keep(changes, ['rest']);
}
/**
* @return {?}
*/
}, {
key: 'ngOnInit',
value: function ngOnInit() {
var _this = this;
var /** @type {?} */rest = new RestView(this.plugin.model, {
get: function get$$1(url, params) {
return _this.http.get(url, { params: params }).toPromise();
},
post: function post(url, data) {
return _this.http.post(url, { data: data }).toPromise();
}
});
this.context = { $implicit: rest };
}
}]);
return RestComponent;
}();
RestComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-rest',
template: '',
providers: [PluginService]
}] }];
/** @nocollapse */
RestComponent.ctorParameters = function () {
return [{ type: HttpClient }, { type: PluginService }];
};
RestComponent.propDecorators = {
restUrl: [{ type: Input, args: ['url'] }],
restMethod: [{ type: Input, args: ['method'] }],
restSerialize: [{ type: Input, args: ['serialize'] }]
};
function RestComponent_tsickle_Closure_declarations() {
/** @type {?} */
RestComponent.prototype.restUrl;
/** @type {?} */
RestComponent.prototype.restMethod;
/** @type {?} */
RestComponent.prototype.restSerialize;
/** @type {?} */
RestComponent.prototype.context;
/** @type {?} */
RestComponent.prototype.http;
/** @type {?} */
RestComponent.prototype.plugin;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var RestModule = function RestModule() {
classCallCheck(this, RestModule);
};
RestModule.decorators = [{ type: NgModule, args: [{
imports: [HttpClientModule],
declarations: [RestComponent],
exports: [RestComponent]
}] }];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var StatusBarComponent = function () {
/**
* @param {?} plugin
* @param {?} templateHost
*/
function StatusBarComponent(plugin, templateHost) {
classCallCheck(this, StatusBarComponent);
this.plugin = plugin;
this.context = {
$implicit: this
};
templateHost.key = function () {
return 'plugin-status-bar.tpl.html';
};
}
/**
* @return {?}
*/
createClass(StatusBarComponent, [{
key: 'rowIndex',
get: function get$$1() {
return this.plugin.model.focus().rowIndex;
}
/**
* @return {?}
*/
}, {
key: 'columnIndex',
get: function get$$1() {
return this.plugin.model.focus().columnIndex;
}
}]);
return StatusBarComponent;
}();
StatusBarComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-status-bar',
template: "<ng-container key=\"plugin-status-bar.tpl.html\" [context]=\"context\"></ng-container> ",
providers: [TemplateHostService, PluginService]
}] }];
/** @nocollapse */
StatusBarComponent.ctorParameters = function () {
return [{ type: PluginService }, { type: TemplateHostService }];
};
function StatusBarComponent_tsickle_Closure_declarations() {
/** @type {?} */
StatusBarComponent.prototype.context;
/** @type {?} */
StatusBarComponent.prototype.plugin;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var StatusBarModule = function StatusBarModule() {
classCallCheck(this, StatusBarModule);
};
StatusBarModule.decorators = [{ type: NgModule, args: [{
declarations: [StatusBarComponent],
exports: [StatusBarComponent],
imports: [TemplateModule]
}] }];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var TabTrapComponent = function () {
/**
* @param {?} plugin
* @param {?} element
*/
function TabTrapComponent(plugin, element) {
classCallCheck(this, TabTrapComponent);
this.plugin = plugin;
this.roundTrip = false;
this.context = {
$implicit: this
};
this.traps = new Map();
this.isActivating = false;
var /** @type {?} */listener = new EventListener(element.nativeElement, new EventManager(this));
listener.on('keydown', function (e) {
var /** @type {?} */code = Shortcut.translate(e);
if (code === 'tab' || code === 'shift+tab') {
e.stopPropagation();
}
});
}
/**
* @param {?} target
* @return {?}
*/
createClass(TabTrapComponent, [{
key: 'activate',
value: function activate(target) {
if (this.isActivating) {
return;
}
this.isActivating = true;
try {
if (this.roundTrip) {
this.goRound(target);
} else {
this.exit(target);
}
} finally {
this.isActivating = false;
}
}
/**
* @param {?} target
* @return {?}
*/
}, {
key: 'exit',
value: function exit(target) {
var /** @type {?} */e = {
key: 'Tab',
keyCode: 9,
shiftKey: target === 'start'
};
var model = this.plugin.model;
var /** @type {?} */shortcut = model.action().shortcut;
shortcut.keyDown(e, 'tab-trap');
}
/**
* @param {?} target
* @return {?}
*/
}, {
key: 'goRound',
value: function goRound(target) {
switch (target) {
case 'start':
{
var /** @type {?} */end = this.traps.get('end');
end.focus();
break;
}
case 'end':
{
var /** @type {?} */start = this.traps.get('start');
start.focus();
break;
}
default:
throw new AppError('tab.trap', 'Invalid target ' + target);
}
}
}]);
return TabTrapComponent;
}();
TabTrapComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-tab-trap',
template: "<ng-container key=\"plugin-tab-trap.tpl.html\" [context]=\"context\"></ng-container> ",
providers: [PluginService]
}] }];
/** @nocollapse */
TabTrapComponent.ctorParameters = function () {
return [{ type: PluginService }, { type: ElementRef }];
};
TabTrapComponent.propDecorators = {
template: [{ type: ContentChild, args: [TemplateRef] }],
roundTrip: [{ type: Input }]
};
function TabTrapComponent_tsickle_Closure_declarations() {
/** @type {?} */
TabTrapComponent.prototype.template;
/** @type {?} */
TabTrapComponent.prototype.roundTrip;
/** @type {?} */
TabTrapComponent.prototype.context;
/** @type {?} */
TabTrapComponent.prototype.traps;
/** @type {?} */
TabTrapComponent.prototype.isActivating;
/** @type {?} */
TabTrapComponent.prototype.plugin;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var TabtrapInDirective = function () {
/**
* @param {?} element
*/
function TabtrapInDirective(element) {
var _this = this;
classCallCheck(this, TabtrapInDirective);
this.element = element;
element.nativeElement.tabIndex = 0;
var /** @type {?} */listener = new EventListener(element.nativeElement, new EventManager(this));
listener.on('focus', function () {
return _this.host.activate(_this.target);
});
}
/**
* @return {?}
*/
createClass(TabtrapInDirective, [{
key: 'ngOnInit',
value: function ngOnInit() {
this.host.traps.set(this.target, this);
}
/**
* @return {?}
*/
}, {
key: 'focus',
value: function focus() {
this.element.nativeElement.focus();
}
}]);
return TabtrapInDirective;
}();
TabtrapInDirective.decorators = [{ type: Directive, args: [{
selector: '[q-grid-tab-trap-in]'
}] }];
/** @nocollapse */
TabtrapInDirective.ctorParameters = function () {
return [{ type: ElementRef }];
};
TabtrapInDirective.propDecorators = {
target: [{ type: Input, args: ['q-grid-tab-trap-in'] }],
host: [{ type: Input, args: ['q-grid-tab-trap-host'] }]
};
function TabtrapInDirective_tsickle_Closure_declarations() {
/** @type {?} */
TabtrapInDirective.prototype.target;
/** @type {?} */
TabtrapInDirective.prototype.host;
/** @type {?} */
TabtrapInDirective.prototype.element;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var TabTrapModule = function TabTrapModule() {
classCallCheck(this, TabTrapModule);
};
TabTrapModule.decorators = [{ type: NgModule, args: [{
declarations: [TabTrapComponent, TabtrapInDirective],
exports: [TabTrapComponent, TabtrapInDirective],
imports: [TemplateModule]
}] }];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var TitleComponent = function () {
/**
* @param {?} plugin
*/
function TitleComponent(plugin) {
classCallCheck(this, TitleComponent);
this.plugin = plugin;
this.context = {
$implicit: this
};
}
/**
* @return {?}
*/
createClass(TitleComponent, [{
key: 'value',
get: function get$$1() {
return this.plugin.model.grid().title;
}
}]);
return TitleComponent;
}();
TitleComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-title',
template: "<ng-container key=\"plugin-title.tpl.html\" [context]=\"context\"></ng-container> ",
providers: [PluginService]
}] }];
/** @nocollapse */
TitleComponent.ctorParameters = function () {
return [{ type: PluginService }];
};
function TitleComponent_tsickle_Closure_declarations() {
/** @type {?} */
TitleComponent.prototype.context;
/** @type {?} */
TitleComponent.prototype.plugin;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var TitleModule = function TitleModule() {
classCallCheck(this, TitleModule);
};
TitleModule.decorators = [{ type: NgModule, args: [{
declarations: [TitleComponent],
exports: [TitleComponent],
imports: [TemplateModule]
}] }];
var PluginService$1 = function () {
function PluginService(model) {
classCallCheck(this, PluginService);
this.model = model;
}
createClass(PluginService, [{
key: 'resolve',
value: function resolve(name) {
var lib = this.model.plugin().imports[name];
if (!lib) {
switch (name) {
case 'xlsx':
{
throw new AppError('plugin.service', 'To use export plugin for xlsx format please add http://github.com/SheetJS/js-xlsx library to your project');
}
case 'fileSaver':
{
throw new AppError('plugin.service', 'To use export plugin for file saving please add https://github.com/eligrey/FileSaver.js library to your project');
}
case 'pdf':
{
throw new AppError('plugin.service', 'To use export plugin for pdf format please add https://github.com/MrRio/jsPDF and https://github.com/simonbengtsson/jsPDF-AutoTable libraries to your project');
}
default:
{
throw new AppError('import library', 'Can\'t find ' + name + ' library in imports');
}
}
}
return lib;
}
}]);
return PluginService;
}();
function flatView$1(obj) {
var separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ', ';
var result = {};
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = Object.entries(obj)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var _step$value = slicedToArray(_step.value, 2),
prop = _step$value[0],
value = _step$value[1];
if (isArray(value)) {
var items = [];
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = value[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var item = _step2.value;
items.push(item);
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
result[prop] = items.join(separator);
} else if (isObject(value)) {
var flatObject = flatView$1(value, separator);
var _iteratorNormalCompletion3 = true;
var _didIteratorError3 = false;
var _iteratorError3 = undefined;
try {
for (var _iterator3 = Object.entries(flatObject)[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
var _step3$value = slicedToArray(_step3.value, 2),
flatProp = _step3$value[0],
flatValue = _step3$value[1];
result[prop + '.' + flatProp] = flatValue;
}
} catch (err) {
_didIteratorError3 = true;
_iteratorError3 = err;
} finally {
try {
if (!_iteratorNormalCompletion3 && _iterator3.return) {
_iterator3.return();
}
} finally {
if (_didIteratorError3) {
throw _iteratorError3;
}
}
}
} else {
result[prop] = value;
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
return result;
}
var Json = function () {
function Json() {
classCallCheck(this, Json);
}
createClass(Json, [{
key: 'write',
value: function write(rows, columns) {
var result = [];
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = rows[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var row = _step.value;
var flatRow = flatView$1(row);
var obj = {};
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = columns[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var column = _step2.value;
obj[column.title] = flatRow[column.key];
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
result.push(obj);
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
return JSON.stringify(result, '', 2);
}
}]);
return Json;
}();
var begin = '<?xml version="1.0" encoding="UTF-8"?><root>';
function escape$1(value) {
var result = '' + value;
var characters = [/</g, />/g, /&/g, /'/g, /"/g, /\s\s+/g, /\n/g];
var replacements = ['<', '>', '&', ''', '"', ' ', '
'];
for (var i = 0; i < characters.length; i++) {
result = result.replace(characters[i], replacements[i]);
}
return result;
}
function objToXml(obj) {
var result = '';
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = Object.entries(obj)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var _step$value = slicedToArray(_step.value, 2),
prop = _step$value[0],
value = _step$value[1];
if (obj.hasOwnProperty(prop)) {
if (isObject(value) && !isArray(value) && !isString(value)) {
result += '<' + prop + '>' + objToXml(value) + '</' + prop + '>';
} else if (isArray(value)) {
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = value[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var item = _step2.value;
if (isString(item)) {
result += '<' + prop + '>' + escape$1(item) + '</' + prop + '>';
} else {
result += '<' + prop + '>' + objToXml(item) + '</' + prop + '>';
}
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
} else if (isString(value)) {
result += '<' + prop + '>' + escape$1(value) + '</' + prop + '>';
}
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
return result;
}
var Xml = function () {
function Xml() {
classCallCheck(this, Xml);
}
createClass(Xml, [{
key: 'write',
value: function write(rows) {
var result = [begin];
var _iteratorNormalCompletion3 = true;
var _didIteratorError3 = false;
var _iteratorError3 = undefined;
try {
for (var _iterator3 = rows[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
var row = _step3.value;
result.push(objToXml({ row: row }));
}
} catch (err) {
_didIteratorError3 = true;
_iteratorError3 = err;
} finally {
try {
if (!_iteratorNormalCompletion3 && _iterator3.return) {
_iterator3.return();
}
} finally {
if (_didIteratorError3) {
throw _iteratorError3;
}
}
}
result.push('</root>');
return result.join('');
}
}]);
return Xml;
}();
var DELIMITER = ',';
function escape$2(value) {
var result = '' + value;
result = result.replace(/"/g, '""');
result = /[\n",]/.test(result) ? '"' + result + '"' : result;
return result;
}
var Csv = function () {
function Csv() {
classCallCheck(this, Csv);
}
createClass(Csv, [{
key: 'write',
value: function write(rows, columns) {
var result = [];
var values = [];
var head = [];
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = columns[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var column = _step.value;
if (column.class === 'data') {
values.push(getFactory(column));
head.push(escape$2(column.title));
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
result.push(head.join(DELIMITER));
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = rows[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var row = _step2.value;
var line = [];
var _iteratorNormalCompletion3 = true;
var _didIteratorError3 = false;
var _iteratorError3 = undefined;
try {
for (var _iterator3 = values[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
var getValue = _step3.value;
line.push(escape$2(getValue(row)));
}
} catch (err) {
_didIteratorError3 = true;
_iteratorError3 = err;
} finally {
try {
if (!_iteratorNormalCompletion3 && _iterator3.return) {
_iterator3.return();
}
} finally {
if (_didIteratorError3) {
throw _iteratorError3;
}
}
}
result.push(line.join(DELIMITER));
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
return result.join('\n');
}
}]);
return Csv;
}();
function downloadFactory(fileSaver) {
return function download(name, data, mimeType, extension) {
var blob = new Blob([data], { type: mimeType });
var type = extension ? extension : mimeType.split('/')[1];
var fileName = name + '.' + type;
fileSaver.saveAs(blob, fileName);
};
}
function sheet_to_workbook(sheet) {
var sheets = {};
sheets['Sheet1'] = sheet;
return { SheetNames: ['Sheet1'], Sheets: sheets };
}
function toArrayBuffer(excel) {
var buffer = new ArrayBuffer(excel.length);
var view = new Uint8Array(buffer);
for (var i = 0; i < excel.length; ++i) {
view[i] = excel.charCodeAt(i) & 0xFF;
}
return buffer;
}
var Xlsx = function () {
function Xlsx(xlsx) {
classCallCheck(this, Xlsx);
this.xlsx = xlsx;
}
createClass(Xlsx, [{
key: 'write',
value: function write(rows, columns) {
var result = [];
var headers = [];
var excelOptions = { bookType: 'xlsx', bookSST: true, cellDates: true, compression: true, type: 'binary' };
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = rows[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var row = _step.value;
result.push(flatView$1(row));
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = columns[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var column = _step2.value;
headers.push(column.title);
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
var worksheet = this.xlsx.utils.json_to_sheet(result);
var workbook = sheet_to_workbook(this.updateTitles(worksheet, headers));
var excel = this.xlsx.write(workbook, excelOptions);
return toArrayBuffer(excel);
}
}, {
key: 'updateTitles',
value: function updateTitles(worksheet, headers) {
var range = this.xlsx.utils.decode_range(worksheet['!ref']);
for (var i = range.s.r; i <= range.e.r; ++i) {
var address = this.xlsx.utils.encode_col(i) + '1';
if (!worksheet[address]) continue;
worksheet[address].v = headers[i];
}
return worksheet;
}
}]);
return Xlsx;
}();
var Pdf = function () {
function Pdf(jsPDF) {
classCallCheck(this, Pdf);
this.jsPDF = jsPDF;
}
createClass(Pdf, [{
key: 'write',
value: function write(rows, columns, name) {
var jsPDF = this.jsPDF;
var titles = [];
var values = [];
var doc = new jsPDF({ orientation: 'landscape', unit: 'in' });
var tableOptions = {
styles: {
overflow: 'linebreak',
fontSize: 8,
columnWidth: 'auto',
overflowColumns: true
},
headerStyles: {
overflow: 'ellipsize'
},
pageBreak: 'auto',
margin: 0
};
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = columns[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var column = _step.value;
titles.push({ title: column.title, dataKey: column.path });
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = rows[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var row = _step2.value;
values.push(flatView$1(row));
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
doc.autoTable(titles, values, tableOptions);
doc.save(name + '.pdf');
}
}]);
return Pdf;
}();
var ExportView = function () {
function ExportView(model, context) {
var _this = this;
classCallCheck(this, ExportView);
this.model = model;
this.type = context.type;
this.csv = new Command({
source: 'export',
canExecute: function canExecute() {
return _this.type === 'csv';
},
execute: function execute() {
var pluginService = new PluginService$1(_this.model);
var fileSaver = pluginService.resolve('fileSaver');
var csv = new Csv();
var data = csv.write(_this.rows, _this.columns);
var download = downloadFactory(fileSaver);
download(_this.id, data, 'text/' + _this.type);
}
});
this.json = new Command({
source: 'export',
canExecute: function canExecute() {
return _this.type === 'json';
},
execute: function execute() {
var pluginService = new PluginService$1(_this.model);
var fileSaver = pluginService.resolve('fileSaver');
var json = new Json();
var data = json.write(_this.rows, _this.columns);
var download = downloadFactory(fileSaver);
download(_this.id, data, 'text/' + _this.type);
}
});
this.xml = new Command({
source: 'export',
canExecute: function canExecute() {
return _this.type === 'xml';
},
execute: function execute() {
var pluginService = new PluginService$1(_this.model);
var fileSaver = pluginService.resolve('fileSaver');
var xml = new Xml();
var data = xml.write(_this.rows);
var download = downloadFactory(fileSaver);
download(_this.id, data, 'application/' + _this.type);
}
});
this.xlsx = new Command({
source: 'export',
canExecute: function canExecute() {
return _this.type === 'xlsx';
},
execute: function execute() {
var pluginService = new PluginService$1(_this.model);
var lib = pluginService.resolve('xlsx');
var fileSaver = pluginService.resolve('fileSaver');
var xlsx = new Xlsx(lib);
var data = xlsx.write(_this.rows, _this.columns);
var download = downloadFactory(fileSaver);
download(_this.id, data, 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'xlsx');
}
});
this.pdf = new Command({
source: 'export',
canExecute: function canExecute() {
return _this.type === 'pdf';
},
execute: function execute() {
var pluginService = new PluginService$1(_this.model);
var lib = pluginService.resolve('pdf');
var pdf = new Pdf(lib);
pdf.write(_this.rows, _this.columns, _this.id);
}
});
}
createClass(ExportView, [{
key: 'columns',
get: function get$$1() {
return this.model.columnList().line;
}
}, {
key: 'rows',
get: function get$$1() {
return this.model.data().rows;
}
}, {
key: 'id',
get: function get$$1() {
return this.model.grid().id;
}
}]);
return ExportView;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var ExportComponent = function () {
/**
* @param {?} plugin
* @param {?} templateHost
*/
function ExportComponent(plugin, templateHost) {
var _this = this;
classCallCheck(this, ExportComponent);
this.plugin = plugin;
this.templateHost = templateHost;
this.context = {
$implicit: this
};
this.templateHost.key = function () {
return 'export-' + _this.type;
};
}
/**
* @return {?}
*/
createClass(ExportComponent, [{
key: 'ngAfterViewInit',
value: function ngAfterViewInit() {
var _this2 = this;
var model = this.plugin.model;
var /** @type {?} */exportView = new ExportView(model, { type: this.type });
var /** @type {?} */action = new Action(new Command({ execute: function execute() {
return exportView[_this2.type].execute();
} }), 'Export to ' + this.type, 'file_download');
if (this.templateRef) {
action.templateUrl = this.templateHost.key('trigger');
}
model.action({
items: Composite.list([model.action().items, [action]])
}, {
source: 'export.component'
});
}
}]);
return ExportComponent;
}();
ExportComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-export',
template: '',
providers: [TemplateHostService, PluginService]
}] }];
/** @nocollapse */
ExportComponent.ctorParameters = function () {
return [{ type: PluginService }, { type: TemplateHostService }];
};
ExportComponent.propDecorators = {
type: [{ type: Input }],
templateRef: [{ type: ContentChild, args: [TemplateRef] }]
};
function ExportComponent_tsickle_Closure_declarations() {
/** @type {?} */
ExportComponent.prototype.type;
/** @type {?} */
ExportComponent.prototype.templateRef;
/** @type {?} */
ExportComponent.prototype.context;
/** @type {?} */
ExportComponent.prototype.plugin;
/** @type {?} */
ExportComponent.prototype.templateHost;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var ExportModule = function ExportModule() {
classCallCheck(this, ExportModule);
};
ExportModule.decorators = [{ type: NgModule, args: [{
declarations: [ExportComponent],
exports: [ExportComponent],
imports: [TemplateModule]
}] }];
function upload(element) {
var doc = element.ownerDocument;
var input = doc.createElement('input');
input.type = 'file';
input.style.display = 'none';
element.appendChild(input);
input.click();
}
function firstRowTitle(index, row) {
return row[index];
}
function numericTitle(index) {
return index;
}
function alphaTitle(index) {
var alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
if (index < alphabet.length) {
return alphabet[index];
} else {
var indexFirst = Math.floor(index / alphabet.length - 1);
var indexSecond = index % alphabet.length;
return '' + alphabet[indexFirst] + alphabet[indexSecond];
}
}
function rewriteObject(obj) {
var result = {};
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = Object.entries(obj)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var _step$value = slicedToArray(_step.value, 2),
key = _step$value[0],
value = _step$value[1];
result[key] = value;
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
return result;
}
var Xlsx$1 = function () {
function Xlsx(xlsx) {
classCallCheck(this, Xlsx);
this.xlsx = xlsx;
}
createClass(Xlsx, [{
key: 'read',
value: function read(data, options) {
var workbook = this.xlsx.read(data, { type: 'binary' });
return this.toJson(workbook, options);
}
}, {
key: 'toJson',
value: function toJson(workbook) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var wbOptions = {};
switch (options.head) {
case 'alpha':
{
wbOptions.header = 'A';
break;
}
case 'numeric':
{
wbOptions.header = 1;
break;
}
default:
{
break;
}
}
var result = [];
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = workbook.SheetNames[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var sheetName = _step2.value;
var partial = this.xlsx.utils.sheet_to_json(workbook.Sheets[sheetName], wbOptions);
result = partial.concat(result);
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
return result.map(rewriteObject);
}
}]);
return Xlsx;
}();
var NODE_TYPE = {
ELEMENT: 1,
ATTRIBUTE: 2,
TEXT: 3,
DOCUMENT: 9
};
var Xml$1 = function () {
function Xml() {
classCallCheck(this, Xml);
}
createClass(Xml, [{
key: 'read',
value: function read(text) {
if (!text) {
return [];
}
var parser = new DOMParser();
var root = parser.parseFromString(text, 'text/xml').documentElement;
var statistics = this.getStatistics(root);
var graph = this.build(root, statistics, 'root');
var key = Object.keys(graph)[0];
var result = graph[key];
if (isArray(result)) {
return result;
}
return [result];
}
}, {
key: 'arrayFromChildren',
value: function arrayFromChildren(node, statistics, path, tag) {
var result = [];
var children = Array.from(node.children).filter(function (child) {
return child.nodeName === tag;
});
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = children[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var child = _step.value;
result.push(this.buildNonArray(child, statistics, path));
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
return result;
}
}, {
key: 'build',
value: function build(node, statistics) {
var path = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'root';
var st = statistics.get(path);
if (st.isArray) {
return this.arrayFromChildren(node.parentNode, statistics, path, node.nodeName);
}
return this.buildNonArray(node, statistics, path);
}
}, {
key: 'buildNonArray',
value: function buildNonArray(node, statistics) {
var path = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'root';
var st = statistics.get(path);
if (st.isObject) {
var result = {};
var visited = new Set();
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = Array.from(node.attributes)[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var attr = _step2.value;
result[attr.name] = attr.value;
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
var _iteratorNormalCompletion3 = true;
var _didIteratorError3 = false;
var _iteratorError3 = undefined;
try {
for (var _iterator3 = Array.from(node.children)[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
var child = _step3.value;
var childPath = this.getPath(path, child.nodeName);
if (visited.has(childPath)) {
continue;
}
visited.add(childPath);
result[child.nodeName] = this.build(child, statistics, childPath);
}
} catch (err) {
_didIteratorError3 = true;
_iteratorError3 = err;
} finally {
try {
if (!_iteratorNormalCompletion3 && _iterator3.return) {
_iterator3.return();
}
} finally {
if (_didIteratorError3) {
throw _iteratorError3;
}
}
}
return result;
}
if (st.isText) {
return node.textContent;
}
return null;
}
}, {
key: 'info',
value: function info(node, lastInfo) {
if (!lastInfo) {
lastInfo = {
isArray: false,
isObject: false,
isText: false
};
}
return {
isArray: lastInfo.isArray || Array.from(node.parentNode.children).filter(function (child) {
return child.nodeName === node.nodeName;
}).length > 1,
isObject: lastInfo.isObject || node.children.length > 0 || node.attributes.length > 0,
isText: lastInfo.isText || this.isTextContainer(node)
};
}
}, {
key: 'getStatistics',
value: function getStatistics(node) {
var path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'root';
var statistics = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new Map();
statistics.set(path, this.info(node, statistics.get(path)));
var children = Array.from(node.children);
if (children.length > 0) {
var _iteratorNormalCompletion4 = true;
var _didIteratorError4 = false;
var _iteratorError4 = undefined;
try {
for (var _iterator4 = children[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
var child = _step4.value;
var childPath = this.getPath(path, child.nodeName);
this.getStatistics(child, childPath, statistics);
}
} catch (err) {
_didIteratorError4 = true;
_iteratorError4 = err;
} finally {
try {
if (!_iteratorNormalCompletion4 && _iterator4.return) {
_iterator4.return();
}
} finally {
if (_didIteratorError4) {
throw _iteratorError4;
}
}
}
}
return statistics;
}
}, {
key: 'isTextContainer',
value: function isTextContainer(node) {
return node.nodeType === NODE_TYPE.ELEMENT && !node.children.length && node.childNodes.length;
}
}, {
key: 'getPath',
value: function getPath() {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return args.join('/');
}
}]);
return Xml;
}();
var Json$1 = function () {
function Json() {
classCallCheck(this, Json);
}
createClass(Json, [{
key: 'read',
value: function read(data) {
var rows = JSON.parse(data);
if (isArray(rows)) {
return rows;
}
return [rows];
}
}]);
return Json;
}();
var CharReader = function () {
function CharReader(text) {
classCallCheck(this, CharReader);
this.text = text || '';
this.peeks = [];
this.position = 0;
this.length = this.text.length;
}
createClass(CharReader, [{
key: 'read',
value: function read() {
var peeks = this.peeks;
if (peeks.length > 0) {
return peeks.pop();
}
var nextPosition = this.position + 1;
if (nextPosition < this.length) {
var c = this.text[this.position];
this.position = nextPosition;
return c;
}
return CharReader.eof;
}
}, {
key: 'peek',
value: function peek() {
return this.peekCore(0);
}
}, {
key: 'peekPeek',
value: function peekPeek() {
return this.peekCore(1);
}
}, {
key: 'peekCore',
value: function peekCore(offset) {
var peeks = this.peeks;
if (offset < peeks.length) {
return peeks[offset];
}
var length = this.length;
for (var i = peeks.length; i <= offset; i++) {
var nextPosition = this.position + 1;
if (nextPosition >= length) {
return CharReader.eof;
}
var c = this.text[this.position];
this.position = nextPosition;
peeks.push(c);
}
return peeks[offset];
}
}, {
key: 'seek',
value: function seek(offset) {
var peeks = this.peeks;
var peekCount = peeks.length;
peeks.splice(0, Math.Min(offset, peekCount));
offset -= peekCount;
while (--offset >= 0) {
this.read();
}
return this.peek();
}
}], [{
key: 'eof',
get: function get$$1() {
return undefined;
}
}]);
return CharReader;
}();
var Csv$1 = function () {
function Csv() {
var delimiter = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ',';
classCallCheck(this, Csv);
this.delimiter = delimiter;
}
createClass(Csv, [{
key: 'read',
value: function read(text) {
var reader = new CharReader(text);
var delimiter = this.delimiter;
var result = [];
var line = [];
var term = '';
var condition = true;
do {
var c = reader.peek();
if (c === ' ') {
reader.read();
continue;
}
if (c === delimiter) {
reader.read();
line.push(term);
term = '';
continue;
}
if (c === '\n') {
reader.read();
if (line.length > 0 || term.length > 0) {
line.push(term);
term = '';
}
if (line.length > 0) {
result.push(line);
line = [];
}
continue;
}
if (c === '\r' && reader.peekPeek() === '\n') {
reader.read();
reader.read();
if (line.length > 0 || term.length > 0) {
line.push(term);
term = '';
}
if (line.length > 0) {
result.push(line);
line = [];
}
continue;
}
if (c === CharReader.eof) {
reader.read();
if (line.length > 0 || term.length > 0) {
line.push(term);
result.push(line);
}
break;
}
if (c === '"') {
term = this.readEscapedValue(reader, term);
} else {
term = this.readUnescapedValue(reader, term);
}
} while (condition);
return result.map(this.lineToObj);
}
}, {
key: 'readEscapedValue',
value: function readEscapedValue(reader, term) {
// Omit double quote
var c = reader.read();
while (c !== CharReader.eof) {
c = reader.read();
if (c === '"') {
if (reader.peek() === '"') {
term += reader.read();
continue;
}
break;
}
term += c;
}
return term;
}
}, {
key: 'readUnescapedValue',
value: function readUnescapedValue(reader, term) {
var delimiter = this.delimiter;
var c = reader.peek();
while (c !== CharReader.eof) {
if (c === delimiter || c === '\n' || c === '\r' && reader.peekPeek() === '\n') break;
term += reader.read();
c = reader.peek();
}
return term;
}
}, {
key: 'lineToObj',
value: function lineToObj(line) {
var result = {};
for (var i = 0, length = line.length; i < length; i++) {
result[i] = line[i];
}
return result;
}
}]);
return Csv;
}();
function getType$2(name) {
var dotDelimeter = /[.]/g.test(name);
if (dotDelimeter) {
var type = name.split('.');
return type[type.length - 1];
}
}
function readFile(e, file, model) {
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
var data = e.target.result;
var type = file.type === '' ? getType$2(file.name) : file.type;
var pluginService = new PluginService$1(model);
switch (type) {
case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet':
case 'xlsx':
{
var lib = pluginService.resolve('xlsx');
var xlsx = new Xlsx$1(lib);
var rows = xlsx.read(data, options);
var createColumn = columnFactory(model);
var columns = generate({
rows: rows,
columnFactory: function columnFactory$$1(type, body) {
return createColumn('text', body);
},
deep: false
});
model.data({
columns: columns,
rows: rows
}, { source: 'read' });
break;
}
case 'application/json':
case 'text/json':
case 'json':
{
var json = new Json$1();
var _rows = json.read(data);
if (_rows.length) {
var _createColumn = columnFactory(model);
var _columns = generate({
rows: _rows,
columnFactory: function columnFactory$$1(type, body) {
return _createColumn('text', body);
},
deep: true
});
model.data({
columns: _columns,
rows: _rows
}, { source: 'read' });
} else {
throw new AppError('import', 'JSON for input should be an array of objects');
}
break;
}
case 'application/xml':
case 'text/xml':
case 'xml':
{
var xml = new Xml$1();
var _rows2 = xml.read(data);
var _columns2 = generate({
rows: _rows2,
columnFactory: columnFactory(model),
deep: true
});
model.data({
columns: _columns2,
rows: _rows2
}, { source: 'read' });
break;
}
case 'application/vnd.ms-excel':
case 'text/csv':
case 'csv':
{
var csv = new Csv$1();
var _rows3 = csv.read(data);
var title = firstRowTitle;
if (options.head === 'alpha') {
title = alphaTitle;
} else if (options.head === 'numeric') {
title = numericTitle;
}
var _columns3 = generate({
rows: _rows3,
columnFactory: columnFactory(model),
deep: false,
title: title
});
if (title === firstRowTitle) {
_rows3.shift(0);
}
model.data({
columns: _columns3,
rows: _rows3
}, { source: 'read' });
break;
}
default:
{
throw new AppError('import', 'This is not valid file type ' + type);
}
}
}
var ImportView = function () {
function ImportView(model, context) {
classCallCheck(this, ImportView);
this.model = model;
var element = context.element,
options = context.options;
this.options = options;
this.upload = new Command({
source: 'import',
execute: function execute() {
return upload(element);
}
});
}
createClass(ImportView, [{
key: 'load',
value: function load(e) {
var _this = this;
var files = e.target.files;
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
var _loop = function _loop() {
var file = _step.value;
var reader = new FileReader();
reader.onload = function (e) {
readFile(e, file, _this.model, _this.options);
};
reader.readAsBinaryString(file);
};
for (var _iterator = files[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
_loop();
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
}
}]);
return ImportView;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var ImportComponent = function () {
/**
* @param {?} plugin
* @param {?} templateHost
* @param {?} hostElement
*/
function ImportComponent(plugin, templateHost, hostElement) {
classCallCheck(this, ImportComponent);
this.plugin = plugin;
this.templateHost = templateHost;
this.hostElement = hostElement;
this.context = {
$implicit: this
};
this.templateHost.key = function () {
return 'import';
};
}
/**
* @return {?}
*/
createClass(ImportComponent, [{
key: 'ngAfterViewInit',
value: function ngAfterViewInit() {
var /** @type {?} */element = this.hostElement.nativeElement;
var /** @type {?} */eventListener = new EventListener(element, new EventManager(this));
var model = this.plugin.model;
var /** @type {?} */context = { element: element, options: this.options };
var /** @type {?} */importView = new ImportView(model, context);
eventListener.on('change', function (e) {
return importView.load(e);
});
var /** @type {?} */action = new Action(new Command({ execute: function execute() {
return importView.upload.execute();
} }), 'Import data', 'file_upload');
if (this.templateRef) {
action.templateUrl = this.templateHost.key('trigger');
}
model.action({
items: Composite.list([model.action().items, [action]])
}, {
source: 'import.component'
});
}
/**
* @return {?}
*/
}, {
key: 'rows',
get: function get$$1() {
return this.plugin.model.data().rows;
}
/**
* @return {?}
*/
}, {
key: 'columns',
get: function get$$1() {
return this.plugin.model.columnList().line;
}
/**
* @return {?}
*/
}, {
key: 'id',
get: function get$$1() {
return this.plugin.model.grid().id;
}
}]);
return ImportComponent;
}();
ImportComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-import',
template: '',
providers: [TemplateHostService, PluginService]
}] }];
/** @nocollapse */
ImportComponent.ctorParameters = function () {
return [{ type: PluginService }, { type: TemplateHostService }, { type: ElementRef }];
};
ImportComponent.propDecorators = {
options: [{ type: Input }],
templateRef: [{ type: ContentChild, args: [TemplateRef] }]
};
function ImportComponent_tsickle_Closure_declarations() {
/** @type {?} */
ImportComponent.prototype.options;
/** @type {?} */
ImportComponent.prototype.templateRef;
/** @type {?} */
ImportComponent.prototype.context;
/** @type {?} */
ImportComponent.prototype.plugin;
/** @type {?} */
ImportComponent.prototype.templateHost;
/** @type {?} */
ImportComponent.prototype.hostElement;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var ImportModule = function ImportModule() {
classCallCheck(this, ImportModule);
};
ImportModule.decorators = [{ type: NgModule, args: [{
declarations: [ImportComponent],
exports: [ImportComponent],
imports: [TemplateModule]
}] }];
var ValidatorView = function () {
function ValidatorView(model, context) {
classCallCheck(this, ValidatorView);
this.model = model;
this.context = context;
this.oldErrors = [];
if (hasRules(this.rules, this.key)) {
this.validator = createValidator(this.rules, this.key);
}
}
createClass(ValidatorView, [{
key: 'errors',
get: function get$$1() {
if (this.validator) {
var target = defineProperty({}, this.key, this.value);
var isValid = this.validator.validate(target);
if (!isValid) {
var newError = this.validator.getErrors()[this.key];
var newErrors = isString(newError) ? [newError] : newError;
if (!isEqual(newErrors, this.oldErrors)) {
this.oldErrors = newErrors;
}
} else {
this.oldErrors.length = 0;
}
return this.oldErrors;
}
}
}, {
key: 'rules',
get: function get$$1() {
return this.model.validation().rules;
}
}, {
key: 'type',
get: function get$$1() {
return this.context.type;
}
}, {
key: 'value',
get: function get$$1() {
return this.context.value;
}
}, {
key: 'key',
get: function get$$1() {
return this.context.key;
}
}]);
return ValidatorView;
}();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var ValidatorComponent = function () {
/**
* @param {?} plugin
* @param {?} templateHost
*/
function ValidatorComponent(plugin, templateHost) {
classCallCheck(this, ValidatorComponent);
this.plugin = plugin;
this.templateHost = templateHost;
this.templateHost.key = function () {
return 'validator';
};
}
/**
* @return {?}
*/
createClass(ValidatorComponent, [{
key: 'ngOnInit',
value: function ngOnInit() {
var model = this.plugin.model;
var /** @type {?} */view = new ValidatorView(model, this);
this.context = { $implicit: view };
}
}]);
return ValidatorComponent;
}();
ValidatorComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-validator',
template: "<ng-container key=\"plugin-validator.tpl.html\" [context]=\"context\"></ng-container> ",
providers: [TemplateHostService, PluginService]
}] }];
/** @nocollapse */
ValidatorComponent.ctorParameters = function () {
return [{ type: PluginService }, { type: TemplateHostService }];
};
ValidatorComponent.propDecorators = {
value: [{ type: Input }],
key: [{ type: Input }],
type: [{ type: Input }]
};
function ValidatorComponent_tsickle_Closure_declarations() {
/** @type {?} */
ValidatorComponent.prototype.value;
/** @type {?} */
ValidatorComponent.prototype.key;
/** @type {?} */
ValidatorComponent.prototype.type;
/** @type {?} */
ValidatorComponent.prototype.context;
/** @type {?} */
ValidatorComponent.prototype.plugin;
/** @type {?} */
ValidatorComponent.prototype.templateHost;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var RuleComponent = function () {
/**
* @param {?} plugin
* @param {?} templateHost
*/
function RuleComponent(plugin, templateHost) {
classCallCheck(this, RuleComponent);
this.plugin = plugin;
this.templateHost = templateHost;
this.context = {
$implicit: this
};
this.templateHost.key = function () {
return 'rule';
};
}
/**
* @param {?} changes
* @return {?}
*/
createClass(RuleComponent, [{
key: 'ngOnChanges',
value: function ngOnChanges(changes) {
var _this = this;
var /** @type {?} */rule = {
for: this.for,
key: this.key
};
var model = this.plugin.model;
var /** @type {?} */validation = model.validation;
var /** @type {?} */rules = Array.from(validation().rules);
Object.keys(changes).forEach(function (key) {
if (!['for', 'key'].includes(key) && changes[key].firstChange) {
rule[key] = _this[key];
}
});
rules.push(rule);
validation({ rules: rules });
}
}]);
return RuleComponent;
}();
RuleComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-rule',
template: '',
providers: [TemplateHostService, PluginService]
}] }];
/** @nocollapse */
RuleComponent.ctorParameters = function () {
return [{ type: PluginService }, { type: TemplateHostService }];
};
RuleComponent.propDecorators = {
for: [{ type: Input }],
key: [{ type: Input }],
required: [{ type: Input }],
not_empty_list: [{ type: Input, args: ['notEmptyList'] }],
any_object: [{ type: Input, args: ['anyObject'] }],
eq: [{ type: Input, args: ['equal'] }],
string: [{ type: Input }],
length_between: [{ type: Input, args: ['lengthBetween'] }],
length_equal: [{ type: Input, args: ['lengthEqual'] }],
min_length: [{ type: Input, args: ['minLength'] }],
max_length: [{ type: Input, args: ['maxLength'] }],
one_of: [{ type: Input, args: ['oneOf'] }],
like: [{ type: Input, args: ['pattern'] }],
integer: [{ type: Input }],
positive_integer: [{ type: Input, args: ['positiveInteger'] }],
decimal: [{ type: Input }],
positive_decimal: [{ type: Input, args: ['positiveDecimal'] }],
max_number: [{ type: Input, args: ['maxNumber'] }],
min_number: [{ type: Input, args: ['minNumber'] }],
email: [{ type: Input }],
url: [{ type: Input }],
iso_date: [{ type: Input, args: ['isoDate'] }],
equal_to_field: [{ type: Input, args: ['equalToField'] }],
list_of: [{ type: Input, args: ['listOf'] }],
templateRef: [{ type: ContentChild, args: [TemplateRef] }]
};
function RuleComponent_tsickle_Closure_declarations() {
/** @type {?} */
RuleComponent.prototype.for;
/** @type {?} */
RuleComponent.prototype.key;
/** @type {?} */
RuleComponent.prototype.required;
/** @type {?} */
RuleComponent.prototype.not_empty_list;
/** @type {?} */
RuleComponent.prototype.any_object;
/** @type {?} */
RuleComponent.prototype.eq;
/** @type {?} */
RuleComponent.prototype.string;
/** @type {?} */
RuleComponent.prototype.length_between;
/** @type {?} */
RuleComponent.prototype.length_equal;
/** @type {?} */
RuleComponent.prototype.min_length;
/** @type {?} */
RuleComponent.prototype.max_length;
/** @type {?} */
RuleComponent.prototype.one_of;
/** @type {?} */
RuleComponent.prototype.like;
/** @type {?} */
RuleComponent.prototype.integer;
/** @type {?} */
RuleComponent.prototype.positive_integer;
/** @type {?} */
RuleComponent.prototype.decimal;
/** @type {?} */
RuleComponent.prototype.positive_decimal;
/** @type {?} */
RuleComponent.prototype.max_number;
/** @type {?} */
RuleComponent.prototype.min_number;
/** @type {?} */
RuleComponent.prototype.email;
/** @type {?} */
RuleComponent.prototype.url;
/** @type {?} */
RuleComponent.prototype.iso_date;
/** @type {?} */
RuleComponent.prototype.equal_to_field;
/** @type {?} */
RuleComponent.prototype.list_of;
/** @type {?} */
RuleComponent.prototype.templateRef;
/** @type {?} */
RuleComponent.prototype.context;
/** @type {?} */
RuleComponent.prototype.plugin;
/** @type {?} */
RuleComponent.prototype.templateHost;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var ValidationComponent =
/**
* @param {?} plugin
*/
function ValidationComponent(plugin) {
classCallCheck(this, ValidationComponent);
this.plugin = plugin;
};
ValidationComponent.decorators = [{ type: Component, args: [{
selector: 'q-grid-validation',
template: '',
providers: [PluginService]
}] }];
/** @nocollapse */
ValidationComponent.ctorParameters = function () {
return [{ type: PluginService }];
};
ValidationComponent.propDecorators = {
type: [{ type: Input }]
};
function ValidationComponent_tsickle_Closure_declarations() {
/** @type {?} */
ValidationComponent.prototype.type;
/** @type {?} */
ValidationComponent.prototype.plugin;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var ValidationModule = function ValidationModule() {
classCallCheck(this, ValidationModule);
};
ValidationModule.decorators = [{ type: NgModule, args: [{
declarations: [ValidationComponent, ValidatorComponent, RuleComponent],
exports: [ValidationComponent, ValidatorComponent, RuleComponent],
imports: [TemplateModule]
}] }];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
Model$1.register('columnChooser', ColumnChooserModel).register('columnFilter', ColumnFilterModel).register('dataManipulation', DataManipulationModel).register('queryBuilder', QueryBuilderModel);
var PluginModule = function PluginModule() {
classCallCheck(this, PluginModule);
};
PluginModule.decorators = [{ type: NgModule, args: [{
declarations: [],
exports: [ActionBarModule, AutocompleteEditorModule, BackdropModule, BoolEditorModule, CaptionModule, CellEditorModule, ColumnChooserModule, ColumnFilterModule, ColumnSortModule, DataManipulationModule, EbModule, EditFormModule, ExportModule, ImportModule, LegendModule, PagerModule, PersistenceModule, ProgressModule, QueryBuilderModule, ReferenceEditorModule, RestModule, StatusBarModule, TabTrapModule, TitleModule, ValidationModule]
}] }];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var GridModule =
/**
* @param {?} zone
* @param {?} datePipe
* @param {?} numberPipe
* @param {?} currencyPipe
*/
function GridModule(zone, datePipe, numberPipe, currencyPipe) {
classCallCheck(this, GridModule);
FormatService.date = function (x, format) {
return datePipe.transform(x, format);
};
FormatService.number = function (x, format) {
return numberPipe.transform(x, format);
};
FormatService.currency = function (x, format) {
return currencyPipe.transform(x, format);
};
Fastdom.invoke = function (task) {
return zone.runOutsideAngular(task);
};
setup(Model$1);
};
GridModule.decorators = [{ type: NgModule, args: [{
declarations: [],
exports: [GridComponent, ColumnListComponent, ColumnComponent, TemplateCacheDirective, PluginModule, MainModule, TemplateModule, FocusModule, RowComponent],
imports: [MainModule, TemplateModule],
providers: [DatePipe, DecimalPipe, CurrencyPipe, ThemeService, BackdropService]
}] }];
/** @nocollapse */
GridModule.ctorParameters = function () {
return [{ type: NgZone }, { type: DatePipe }, { type: DecimalPipe }, { type: CurrencyPipe }];
};
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var HighlightPipe = function () {
function HighlightPipe() {
classCallCheck(this, HighlightPipe);
}
createClass(HighlightPipe, [{
key: 'transform',
/**
* @param {?} text
* @param {?} search
* @return {?}
*/
value: function transform(text, search) {
if ((text || text === 0) && (search || search === 0)) {
text = text.toString();
search = search.toString();
var /** @type {?} */contains = new RegExp(escapeRegexp(search), 'gi');
if (contains.test(text)) {
return text.replace(contains, function (s) {
return '<span class="' + GRID_PREFIX + '-highlight-part">' + htmlEncode(s) + '</span>';
});
}
var /** @type {?} */contained = new RegExp(escapeRegexp(text), 'gi');
if (contained.test(search)) {
return '<span class="' + GRID_PREFIX + '-highlight-part">' + htmlEncode(text) + '</span>';
}
}
return htmlEncode( /** @type {?} */text);
}
}]);
return HighlightPipe;
}();
HighlightPipe.decorators = [{ type: Pipe, args: [{
name: 'qGridHighlight'
}] }];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var TimePipe = function (_DatePipe) {
inherits(TimePipe, _DatePipe);
function TimePipe() {
classCallCheck(this, TimePipe);
return possibleConstructorReturn(this, (TimePipe.__proto__ || Object.getPrototypeOf(TimePipe)).apply(this, arguments));
}
createClass(TimePipe, [{
key: 'transform',
/**
* @param {?} value
* @param {?=} format
* @return {?}
*/
value: function transform(value, format) {
var /** @type {?} */date = new Date(value);
if (date instanceof Date && !isNaN( /** @type {?} */date)) {
return get(TimePipe.prototype.__proto__ || Object.getPrototypeOf(TimePipe.prototype), 'transform', this).call(this, value, format);
} else {
return value;
}
}
}]);
return TimePipe;
}(DatePipe);
TimePipe.decorators = [{ type: Pipe, args: [{
name: 'qGridTime'
}] }];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var FilterPipe = function () {
function FilterPipe() {
classCallCheck(this, FilterPipe);
}
createClass(FilterPipe, [{
key: 'transform',
/**
* @param {?} items
* @param {?} __1
* @return {?}
*/
value: function transform(items, _ref) {
var _ref$search = _ref.search,
search = _ref$search === undefined ? null : _ref$search,
_ref$type = _ref.type,
type = _ref$type === undefined ? 'plain' : _ref$type;
if (search || search === 0 || search === false) {
var /** @type {?} */predicate = predicateFactory(search);
switch (type) {
case 'node':
{
var /** @type {?} */root = /** @type {?} */items;
return filter(root, predicate);
}
default:
{
return (/** @type {?} */items.filter(predicate)
);
}
}
}
return items;
}
}]);
return FilterPipe;
}();
FilterPipe.decorators = [{ type: Pipe, args: [{
name: 'qGridFilter'
}] }];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var PipeModule = function PipeModule() {
classCallCheck(this, PipeModule);
};
PipeModule.decorators = [{ type: NgModule, args: [{
declarations: [HighlightPipe, FilterPipe, TimePipe],
exports: [HighlightPipe, FilterPipe, TimePipe]
}] }];
/** @nocollapse */
PipeModule.ctorParameters = function () {
return [];
};
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
export { GridService, GridModule, GridComponent, GridService$1 as Grid, PluginService as GridPlugin, Model$1 as GridModel, Table as DomTable, HighlightPipe, TimePipe, FilterPipe, PipeModule, Action, Command, Pipe$1 as Pipe, PipeUnit, Node$1 as Node, RowDetailsStatus, Shortcut, ShortcutDispatcher, CommandManager, AppError as GridError, ArrayColumnModel as ArrayColumn, BoolColumnModel as BoolColumn, CohortColumnModel as CohortColumn, ColumnModel as Column, CurrencyColumnModel as CurrencyColumn, DataColumnModel as DataColumn, DateColumnModel as DateColumn, EmailColumnModel as EmailColumn, FileColumnModel as FileColumn, FilterRowColumnModel as FilterRowColumn, GroupColumnModel as GroupColumn, GroupSummaryColumnModel as GroupSummaryColumn, IdColumnModel as IdColumn, ImageColumnModel as ImageColumn, NumberColumnModel as NumberColumn, PadColumnModel as PadColumn, PasswordColumnModel as PasswordColumn, PivotColumnModel as PivotColumn, ReferenceColumnModel as ReferenceColumn, RowDetailsColumnModel as RowDetailsColumn, RowExpandColumnModel as RowExpandColumn, RowIndicatorColumnModel as RowIndicatorColumn, RowNumberColumnModel as RowNumberColumn, RowOptionsColumnModel as RowOptionsColumn, SelectColumnModel as SelectColumn, TextColumnModel as TextColumn, TimeColumnModel as TimeColumn, UrlColumnModel as UrlColumn, Box as DomBox, Cell as DomCell, Row as DomRow, Data as DomData, View as DomView, PluginModule, TemplateModule, TemplateService, ThemeService, CommonModule$1 as CommonModule, VscrollModule, ColumnView, CommandDirective as ɵfa, CommandModule as ɵez, DateDirective as ɵey, DateModule as ɵex, DndModule as ɵdv, DragDirective as ɵdw, DropDirective as ɵdx, FileDirective as ɵem, FileModule as ɵel, AutoFocusDirective as ɵea, BlurDirective as ɵeb, FocusDirective as ɵdz, FocusModule as ɵdy, FocusAfterRender$1 as ɵbk, InputModule as ɵei, LayoutModule as ɵef, PositionDirective as ɵeg, StopPropagateDirective as ɵeh, RaiseDirective as ɵek, RaiseModule as ɵej, AutosizeDirective as ɵee, ResizeDirective as ɵed, ResizeModule as ɵec, TimeDirective as ɵew, TimeModule as ɵev, VscrollColumnDirective as ɵeo, VscrollMarkDirective as ɵes, VscrollPortXDirective as ɵet, VscrollPortYDirective as ɵep, VscrollRowDirective as ɵer, VscrollDirective as ɵen, VscrollPipe as ɵeu, VscrollPort as ɵeq, VscrollService as ɵbn, ModelComponent as ɵj, NgComponent as ɵb, RootComponent as ɵa, RootService as ɵc, BoxComponent as ɵdq, ColumnListComponent as ɵi, ColumnListService as ɵk, ColumnComponent as ɵl, ColumnService as ɵn, BodyCoreComponent as ɵfc, TdCoreAlignDirective as ɵfl, TdCoreDirective as ɵfm, CellHandlerComponent as ɵfe, CellService as ɵbr, CoreModule as ɵfb, FootCoreComponent as ɵff, TfCoreDirective as ɵfo, HeadCoreComponent as ɵfg, ThCoreDirective as ɵfq, LayerCoreComponent as ɵfh, LayerCoreDirective as ɵfi, LayerComponent as ɵdt, LayerService as ɵh, MarkupDirective as ɵfj, RowComponent as ɵds, TrCoreDirective as ɵfn, TrhCoreDirective as ɵfp, VScrollService as ɵg, TableCoreComponent as ɵfk, TableCoreService as ɵfd, ToolbarCoreComponent as ɵfr, ViewCoreComponent as ɵfs, ViewCoreService as ɵf, MainModule as ɵdp, MarkupDirective$1 as ɵdu, ToolbarComponent as ɵdr, ActionBarComponent as ɵq, ActionBarModule as ɵp, ActionCoreComponent as ɵt, ActionListComponent as ɵr, ActionComponent as ɵs, AutocompleteEditorComponent as ɵx, AutocompleteEditorModule as ɵw, BackdropComponent as ɵz, BackdropDirective as ɵbb, BackdropModule as ɵy, BackdropService as ɵba, BoolEditorComponent as ɵbd, BoolEditorModule as ɵbc, CaptionComponent as ɵbf, CaptionModule as ɵbe, CellEditorComponent as ɵbh, CellEditorModule as ɵbg, ColumnChooserComponent as ɵbj, ColumnChooserModule as ɵbi, ColumnFilterByComponent as ɵbp, ColumnFilterItemListDirective as ɵbq, ColumnFilterItemDirective as ɵbs, ColumnFilterTriggerComponent as ɵbo, ColumnFilterComponent as ɵbm, ColumnFilterModule as ɵbl, ColumnSortComponent as ɵbu, ColumnSortModule as ɵbt, DataManipulationComponent as ɵbw, DataManipulationModule as ɵbv, EditFormControlComponent as ɵcg, EditFormTriggerComponent as ɵce, EditFormComponent as ɵcf, EditFormModule as ɵcd, ExportComponent as ɵci, ExportModule as ɵch, EbClassDirective as ɵca, EbExpressionComponent as ɵcb, EbNodeComponent as ɵby, EbNodeService as ɵbz, EbModule as ɵbx, SerializationService as ɵcc, ImportComponent as ɵck, ImportModule as ɵcj, LegendComponent as ɵcm, LegendModule as ɵcl, PagerTargetComponent as ɵcp, PagerComponent as ɵco, PagerModule as ɵcn, PersistencePanelComponent as ɵcs, PersistenceComponent as ɵcr, PersistenceModule as ɵcq, ProgressComponent as ɵcu, ProgressModule as ɵct, QueryBuilderPanelComponent as ɵcx, QueryBuilderComponent as ɵcw, QueryBuilderModule as ɵcv, QueryBuilderPipe as ɵcy, ReferenceEditorComponent as ɵda, ReferenceEditorModule as ɵcz, ReferenceComponent as ɵdb, RestComponent as ɵdd, RestModule as ɵdc, StatusBarComponent as ɵdf, StatusBarModule as ɵde, TabtrapInDirective as ɵdi, TabTrapComponent as ɵdh, TabTrapModule as ɵdg, TitleComponent as ɵdk, TitleModule as ɵdj, RuleComponent as ɵdo, ValidationComponent as ɵdm, ValidationModule as ɵdl, ValidatorComponent as ɵdn, TemplateCacheDirective as ɵo, TemplateCacheService as ɵd, TemplateHostService as ɵm, TemplateLinkDirective as ɵv, TemplateLinkService as ɵe, TemplateDirective as ɵu };
//# sourceMappingURL=ng2-qgrid.js.map