UNPKG

@ohayojp.com/components

Version:

Common business components of ohayojp.

1,226 lines (1,219 loc) 165 kB
/** * @license ohayojp(cipchk@qq.com) v1.0.0 * (c) 2020 cipchk https://ohayojp.com/ * License: MIT */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/platform-browser'), require('@ohayojp.com/acl'), require('@ohayojp.com/theme'), require('@ohayojp.com/util'), require('@angular/common'), require('@angular/common/http'), require('rxjs'), require('rxjs/operators'), require('@ohayojp.com/components/xlsx'), require('@angular/router'), require('@angular/forms'), require('ng-zorro-antd/badge'), require('ng-zorro-antd/checkbox'), require('ng-zorro-antd/divider'), require('ng-zorro-antd/dropdown'), require('ng-zorro-antd/icon'), require('ng-zorro-antd/input'), require('ng-zorro-antd/menu'), require('ng-zorro-antd/popconfirm'), require('ng-zorro-antd/radio'), require('ng-zorro-antd/resizable'), require('ng-zorro-antd/table'), require('ng-zorro-antd/tag'), require('ng-zorro-antd/tooltip')) : typeof define === 'function' && define.amd ? define('@ohayojp.com/components/st', ['exports', '@angular/core', '@angular/platform-browser', '@ohayojp.com/acl', '@ohayojp.com/theme', '@ohayojp.com/util', '@angular/common', '@angular/common/http', 'rxjs', 'rxjs/operators', '@ohayojp.com/components/xlsx', '@angular/router', '@angular/forms', 'ng-zorro-antd/badge', 'ng-zorro-antd/checkbox', 'ng-zorro-antd/divider', 'ng-zorro-antd/dropdown', 'ng-zorro-antd/icon', 'ng-zorro-antd/input', 'ng-zorro-antd/menu', 'ng-zorro-antd/popconfirm', 'ng-zorro-antd/radio', 'ng-zorro-antd/resizable', 'ng-zorro-antd/table', 'ng-zorro-antd/tag', 'ng-zorro-antd/tooltip'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.ohayo = global.ohayo || {}, global.ohayo.components = global.ohayo.components || {}, global.ohayo.components.st = {}), global.ng.core, global.ng.platformBrowser, global.ohayo.acl, global.ohayo.theme, global.ohayo.util, global.ng.common, global.ng.common.http, global.rxjs, global.rxjs.operators, global.ohayo.components.xlsx, global.ng.router, global.ng.forms, global['ng-zorro-antd/badge'], global['ng-zorro-antd/checkbox'], global['ng-zorro-antd/divider'], global['ng-zorro-antd/dropdown'], global['ng-zorro-antd/icon'], global['ng-zorro-antd/input'], global['ng-zorro-antd/menu'], global['ng-zorro-antd/popconfirm'], global['ng-zorro-antd/radio'], global.resizable, global['ng-zorro-antd/table'], global['ng-zorro-antd/tag'], global['ng-zorro-antd/tooltip'])); }(this, (function (exports, i0, platformBrowser, acl, theme, util, common, http, rxjs, operators, xlsx, router, forms, badge, checkbox, divider, dropdown, icon, input, menu, popconfirm, radio, resizable, table, tag, tooltip) { 'use strict'; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ /* global Reflect, Promise */ var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; function __extends(d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); } var __assign = function () { __assign = Object.assign || function __assign(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; function __rest(s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; } function __decorate(decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; } function __param(paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); }; } function __metadata(metadataKey, metadataValue) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); } function __awaiter(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); } function __generator(thisArg, body) { var _ = { label: 0, sent: function () { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); while (_) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } } var __createBinding = Object.create ? (function (o, m, k, k2) { if (k2 === undefined) k2 = k; Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } }); }) : (function (o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; }); function __exportStar(m, o) { for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p); } function __values(o) { var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; if (m) return m.call(o); if (o && typeof o.length === "number") return { next: function () { if (o && i >= o.length) o = void 0; return { value: o && o[i++], done: !o }; } }; throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); } function __read(o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; } function __spread() { for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); return ar; } function __spreadArrays() { for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) r[k] = a[j]; return r; } ; function __await(v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } function __asyncGenerator(thisArg, _arguments, generator) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), i, q = []; return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } } function __asyncDelegator(o) { var i, p; return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } } function __asyncValues(o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var m = o[Symbol.asyncIterator], i; return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); } } function __makeTemplateObject(cooked, raw) { if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } return cooked; } ; var __setModuleDefault = Object.create ? (function (o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function (o, v) { o["default"] = v; }; function __importStar(mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; } function __importDefault(mod) { return (mod && mod.__esModule) ? mod : { default: mod }; } function __classPrivateFieldGet(receiver, privateMap) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return privateMap.get(receiver); } function __classPrivateFieldSet(receiver, privateMap, value) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to set private field on non-instance"); } privateMap.set(receiver, value); return value; } /** * @fileoverview added by tsickle * Generated from: st-row.directive.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var STRowSource = /** @class */ (function () { function STRowSource() { this.titles = {}; this.rows = {}; } /** * @param {?} type * @param {?} path * @param {?} ref * @return {?} */ STRowSource.prototype.add = function (type, path, ref) { this[type === 'title' ? 'titles' : 'rows'][path] = ref; }; /** * @param {?} path * @return {?} */ STRowSource.prototype.getTitle = function (path) { return this.titles[path]; }; /** * @param {?} path * @return {?} */ STRowSource.prototype.getRow = function (path) { return this.rows[path]; }; return STRowSource; }()); STRowSource.decorators = [ { type: i0.Injectable } ]; if (false) { /** * @type {?} * @private */ STRowSource.prototype.titles; /** * @type {?} * @private */ STRowSource.prototype.rows; } var STRowDirective = /** @class */ (function () { /** * @param {?} ref * @param {?} source */ function STRowDirective(ref, source) { this.ref = ref; this.source = source; } /** * @return {?} */ STRowDirective.prototype.ngOnInit = function () { this.source.add(this.type, this.id, this.ref); }; return STRowDirective; }()); STRowDirective.decorators = [ { type: i0.Directive, args: [{ selector: '[st-row]' },] } ]; /** @nocollapse */ STRowDirective.ctorParameters = function () { return [ { type: i0.TemplateRef }, { type: STRowSource, decorators: [{ type: i0.Host }] } ]; }; STRowDirective.propDecorators = { id: [{ type: i0.Input, args: ['st-row',] }], type: [{ type: i0.Input }] }; if (false) { /** @type {?} */ STRowDirective.prototype.id; /** @type {?} */ STRowDirective.prototype.type; /** * @type {?} * @private */ STRowDirective.prototype.ref; /** * @type {?} * @private */ STRowDirective.prototype.source; } /** * @fileoverview added by tsickle * Generated from: st-widget.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var STWidgetRegistry = /** @class */ (function () { function STWidgetRegistry() { this._widgets = {}; } Object.defineProperty(STWidgetRegistry.prototype, "widgets", { /** * @return {?} */ get: function () { return this._widgets; }, enumerable: false, configurable: true }); /** * @param {?} type * @param {?} widget * @return {?} */ STWidgetRegistry.prototype.register = function (type, widget) { this._widgets[type] = widget; }; /** * @param {?} type * @return {?} */ STWidgetRegistry.prototype.has = function (type) { return this._widgets.hasOwnProperty(type); }; /** * @param {?} type * @return {?} */ STWidgetRegistry.prototype.get = function (type) { return this._widgets[type]; }; return STWidgetRegistry; }()); STWidgetRegistry.decorators = [ { type: i0.Injectable, args: [{ providedIn: 'root' },] } ]; /** @nocollapse */ STWidgetRegistry.ɵprov = i0.ɵɵdefineInjectable({ factory: function STWidgetRegistry_Factory() { return new STWidgetRegistry(); }, token: STWidgetRegistry, providedIn: "root" }); if (false) { /** * @type {?} * @private */ STWidgetRegistry.prototype._widgets; } /** * @record */ function STColumnSourceProcessOptions() { } if (false) { /** @type {?} */ STColumnSourceProcessOptions.prototype.widthMode; /** @type {?} */ STColumnSourceProcessOptions.prototype.resizable; } var STColumnSource = /** @class */ (function () { /** * @param {?} dom * @param {?} rowSource * @param {?} acl * @param {?} i18nSrv * @param {?} stWidgetRegistry */ function STColumnSource(dom, rowSource, acl, i18nSrv, stWidgetRegistry) { this.dom = dom; this.rowSource = rowSource; this.acl = acl; this.i18nSrv = i18nSrv; this.stWidgetRegistry = stWidgetRegistry; } /** * @param {?} val * @return {?} */ STColumnSource.prototype.setCog = function (val) { this.cog = val; }; /** * @private * @param {?} i * @param {?} def * @return {?} */ STColumnSource.prototype.fixPop = function (i, def) { if (i.pop == null || i.pop === false) { i.pop = false; return; } /** @type {?} */ var pop = Object.assign({}, def); if (typeof i.pop === 'string') { pop.title = i.pop; } else if (typeof i.pop === 'object') { pop = Object.assign(Object.assign({}, pop), i.pop); } if (typeof pop.condition !== 'function') { pop.condition = ( /** * @return {?} */function () { return false; }); } i.pop = pop; }; /** * @private * @param {?} list * @return {?} */ STColumnSource.prototype.btnCoerce = function (list) { var e_1, _b; if (!list) return []; /** @type {?} */ var ret = []; var _c = this.cog, modal = _c.modal, drawer = _c.drawer, pop = _c.pop, btnIcon = _c.btnIcon; try { for (var list_1 = __values(list), list_1_1 = list_1.next(); !list_1_1.done; list_1_1 = list_1.next()) { var item = list_1_1.value; if (this.acl && item.acl && !this.acl.can(item.acl)) { continue; } if (item.type === 'modal' || item.type === 'static') { if (item.modal == null || item.modal.component == null) { console.warn("[st] Should specify modal parameter"); item.type = 'none'; } else { item.modal = Object.assign(Object.assign({ paramsName: 'record', size: 'lg' }, modal), item.modal); } } if (item.type === 'drawer') { if (item.drawer == null || item.drawer.component == null) { console.warn("[st] Should specify drawer parameter"); item.type = 'none'; } else { item.drawer = Object.assign(Object.assign({ paramsName: 'record', size: 'lg' }, drawer), item.drawer); } } if (item.type === 'del' && typeof item.pop === 'undefined') { item.pop = true; } // pop this.fixPop(item, ( /** @type {?} */(pop))); if (item.icon) { item.icon = Object.assign(Object.assign({}, btnIcon), (typeof item.icon === 'string' ? { type: item.icon } : item.icon)); } item.children = item.children && item.children.length > 0 ? this.btnCoerce(item.children) : []; // i18n if (item.i18n && this.i18nSrv) { item.text = this.i18nSrv.fanyi(item.i18n); } ret.push(item); } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (list_1_1 && !list_1_1.done && (_b = list_1.return)) _b.call(list_1); } finally { if (e_1) throw e_1.error; } } this.btnCoerceIf(ret); return ret; }; /** * @private * @param {?} list * @return {?} */ STColumnSource.prototype.btnCoerceIf = function (list) { var e_2, _b; try { for (var list_2 = __values(list), list_2_1 = list_2.next(); !list_2_1.done; list_2_1 = list_2.next()) { var item = list_2_1.value; if (!item.iif) item.iif = ( /** * @return {?} */function () { return true; }); item.iifBehavior = item.iifBehavior || this.cog.iifBehavior; if (item.children && item.children.length > 0) { this.btnCoerceIf(item.children); } else { item.children = []; } } } catch (e_2_1) { e_2 = { error: e_2_1 }; } finally { try { if (list_2_1 && !list_2_1.done && (_b = list_2.return)) _b.call(list_2); } finally { if (e_2) throw e_2.error; } } }; /** * @private * @param {?} list * @return {?} */ STColumnSource.prototype.fixedCoerce = function (list) { /** @type {?} */ var countReduce = ( /** * @param {?} a * @param {?} b * @return {?} */function (a, b) { return a + +( /** @type {?} */(b.width)).toString().replace('px', ''); }); // left width list .filter(( /** * @param {?} w * @return {?} */function (/** * @param {?} w * @return {?} */ w) { return w.fixed && w.fixed === 'left' && w.width; })) .forEach(( /** * @param {?} item * @param {?} idx * @return {?} */function (item, idx) { return (item._left = list.slice(0, idx).reduce(countReduce, 0) + 'px'); })); // right width list .filter(( /** * @param {?} w * @return {?} */function (/** * @param {?} w * @return {?} */ w) { return w.fixed && w.fixed === 'right' && w.width; })) .reverse() .forEach(( /** * @param {?} item * @param {?} idx * @return {?} */function (item, idx) { return (item._right = (idx > 0 ? list.slice(-idx).reduce(countReduce, 0) : 0) + 'px'); })); }; /** * @private * @param {?} item * @return {?} */ STColumnSource.prototype.sortCoerce = function (item) { /** @type {?} */ var res = this.fixSortCoerce(item); res.reName = Object.assign(Object.assign({}, this.cog.sortReName), res.reName); return res; }; /** * @private * @param {?} item * @return {?} */ STColumnSource.prototype.fixSortCoerce = function (item) { if (typeof item.sort === 'undefined') { return { enabled: false }; } /** @type {?} */ var res = {}; if (typeof item.sort === 'string') { res.key = item.sort; } else if (typeof item.sort !== 'boolean') { res = item.sort; } else if (typeof item.sort === 'boolean') { res.compare = ( /** * @param {?} a * @param {?} b * @return {?} */function (a, b) { return a[( /** @type {?} */(item.indexKey))] - b[( /** @type {?} */(item.indexKey))]; }); } if (!res.key) { res.key = item.indexKey; } res.enabled = true; return res; }; /** * @private * @param {?} item * @return {?} */ STColumnSource.prototype.filterCoerce = function (item) { var _this = this; if (item.filter == null) { return null; } /** @type {?} */ var res = item.filter; res.type = res.type || 'default'; /** @type {?} */ var icon = 'filter'; /** @type {?} */ var iconTheme = 'fill'; if (res.type === 'keyword') { if (res.menus == null || ( /** @type {?} */(res.menus)).length === 0) { res.menus = [{ value: '' }]; } icon = 'search'; iconTheme = 'outline'; } if (( /** @type {?} */(res.menus)).length === 0) { return null; } if (typeof res.multiple === 'undefined') { res.multiple = true; } res.confirmText = res.confirmText || this.cog.filterConfirmText; res.clearText = res.clearText || this.cog.filterClearText; res.key = res.key || item.indexKey; res.icon = res.icon || icon; /** @type {?} */ var baseIcon = ( /** @type {?} */({ type: icon, theme: iconTheme })); if (typeof res.icon === 'string') { res.icon = ( /** @type {?} */(Object.assign(Object.assign({}, baseIcon), { type: res.icon }))); } else { res.icon = Object.assign(Object.assign({}, baseIcon), res.icon); } this.updateDefault(res); if (this.acl) { res.menus = ( /** @type {?} */(res.menus)).filter(( /** * @param {?} w * @return {?} */function (/** * @param {?} w * @return {?} */ w) { return _this.acl.can(( /** @type {?} */(w.acl))); })); } if (( /** @type {?} */(res.menus)).length <= 0) { res = null; } return res; }; /** * @private * @param {?} item * @return {?} */ STColumnSource.prototype.restoreRender = function (item) { if (item.renderTitle) { item.__renderTitle = typeof item.renderTitle === 'string' ? this.rowSource.getTitle(item.renderTitle) : (( /** @type {?} */(item.renderTitle))); } if (item.render) { item.__render = typeof item.render === 'string' ? this.rowSource.getRow(item.render) : (( /** @type {?} */(item.render))); } }; /** * @private * @param {?} item * @return {?} */ STColumnSource.prototype.widgetCoerce = function (item) { var _a; if (item.type !== 'widget') return; if (item.widget == null || !this.stWidgetRegistry.has(item.widget.type)) { delete item.type; util.warn("st: No widget for type \"" + ((_a = item.widget) === null || _a === void 0 ? void 0 : _a.type) + "\""); } }; /** * @private * @param {?} rootColumns * @return {?} */ STColumnSource.prototype.genHeaders = function (rootColumns) { /** @type {?} */ var rows = []; /** @type {?} */ var widths = []; /** @type {?} */ var fillRowCells = ( /** * @param {?} columns * @param {?} colIndex * @param {?=} rowIndex * @return {?} */function (columns, colIndex, rowIndex) { if (rowIndex === void 0) { rowIndex = 0; } // Init rows rows[rowIndex] = rows[rowIndex] || []; /** @type {?} */ var currentColIndex = colIndex; /** @type {?} */ var colSpans = columns.map(( /** * @param {?} column * @return {?} */function (/** * @param {?} column * @return {?} */ column) { /** @type {?} */ var cell = { column: column, colStart: currentColIndex, hasSubColumns: false, }; /** @type {?} */ var colSpan = 1; /** @type {?} */ var subColumns = column.children; if (Array.isArray(subColumns) && subColumns.length > 0) { colSpan = fillRowCells(subColumns, currentColIndex, rowIndex + 1).reduce(( /** * @param {?} total * @param {?} count * @return {?} */function (total, count) { return total + count; }), 0); cell.hasSubColumns = true; } else { widths.push((( /** @type {?} */(cell.column.width))) || ''); } if ('colSpan' in column) { colSpan = ( /** @type {?} */(column.colSpan)); } if ('rowSpan' in column) { cell.rowSpan = column.rowSpan; } cell.colSpan = colSpan; cell.colEnd = cell.colStart + colSpan - 1; rows[rowIndex].push(( /** @type {?} */(cell))); currentColIndex += colSpan; return colSpan; })); return colSpans; }); fillRowCells(rootColumns, 0); // Handle `rowSpan` /** @type {?} */ var rowCount = rows.length; var _loop_1 = function (rowIndex) { rows[rowIndex].forEach(( /** * @param {?} cell * @return {?} */function (/** * @param {?} cell * @return {?} */ cell) { if (!('rowSpan' in cell) && !cell.hasSubColumns) { cell.rowSpan = rowCount - rowIndex; } })); }; for (var rowIndex = 0; rowIndex < rowCount; rowIndex += 1) { _loop_1(rowIndex); } return { headers: rows, headerWidths: rowCount > 1 ? widths : null }; }; /** * @private * @param {?} list * @return {?} */ STColumnSource.prototype.cleanCond = function (list) { var e_3, _b; /** @type {?} */ var res = []; /** @type {?} */ var copyList = util.deepCopy(list); try { for (var copyList_1 = __values(copyList), copyList_1_1 = copyList_1.next(); !copyList_1_1.done; copyList_1_1 = copyList_1.next()) { var item = copyList_1_1.value; if (item.iif && !item.iif(item)) { continue; } if (this.acl && item.acl && !this.acl.can(item.acl)) { continue; } res.push(item); } } catch (e_3_1) { e_3 = { error: e_3_1 }; } finally { try { if (copyList_1_1 && !copyList_1_1.done && (_b = copyList_1.return)) _b.call(copyList_1); } finally { if (e_3) throw e_3.error; } } return res; }; /** * @param {?} list * @param {?} options * @return {?} */ STColumnSource.prototype.process = function (list, options) { var _this = this; if (!list || list.length === 0) throw new Error("[st]: the columns property muse be define!"); var noIndex = this.cog.noIndex; /** @type {?} */ var checkboxCount = 0; /** @type {?} */ var radioCount = 0; /** @type {?} */ var point = 0; /** @type {?} */ var columns = []; /** @type {?} */ var processItem = ( /** * @param {?} item * @return {?} */function (item) { // index if (item.index) { if (!Array.isArray(item.index)) { item.index = item.index.split('.'); } item.indexKey = item.index.join('.'); } // #region title /** @type {?} */ var tit = (typeof item.title === 'string' ? { text: item.title } : item.title) || {}; if (tit.i18n && _this.i18nSrv) { tit.text = _this.i18nSrv.fanyi(tit.i18n); } if (tit.text) { tit._text = _this.dom.bypassSecurityTrustHtml(tit.text); } item.title = tit; // #endregion // no if (item.type === 'no') { item.noIndex = item.noIndex == null ? noIndex : item.noIndex; } // checkbox if (item.selections == null) { item.selections = []; } if (item.type === 'checkbox') { ++checkboxCount; if (!item.width) { item.width = (item.selections.length > 0 ? 62 : 50) + "px"; } } if (_this.acl) { item.selections = item.selections.filter(( /** * @param {?} w * @return {?} */function (/** * @param {?} w * @return {?} */ w) { return _this.acl.can(( /** @type {?} */(w.acl))); })); } // radio if (item.type === 'radio') { ++radioCount; item.selections = []; if (!item.width) { item.width = '50px'; } } // types if (item.type === 'yn') { item.yn = Object.assign({ truth: true }, item.yn); } if ((item.type === 'link' && typeof item.click !== 'function') || (item.type === 'badge' && item.badge == null) || (item.type === 'tag' && item.tag == null) || (item.type === 'enum' && item.enum == null)) { item.type = ''; } item._isTruncate = !!item.width && options.widthMode.strictBehavior === 'truncate' && item.type !== 'img'; // className if (!item.className) { item.className = (( /** @type {?} */({ number: 'text-right', currency: 'text-right', date: 'text-center', })))[( /** @type {?} */(item.type))]; } item._className = item.className || (item._isTruncate ? 'text-truncate' : null); // width if (typeof item.width === 'number') { item.width = item.width + "px"; } // sorter item._sort = _this.sortCoerce(item); // filter item.filter = ( /** @type {?} */(_this.filterCoerce(item))); // buttons item.buttons = _this.btnCoerce(( /** @type {?} */(item.buttons))); // widget _this.widgetCoerce(item); // restore custom row _this.restoreRender(item); // resizable item.resizable = Object.assign(Object.assign({ disabled: true, bounds: 'window', minWidth: 60, maxWidth: 360, preview: true }, options.resizable), (typeof item.resizable === 'boolean' ? (( /** @type {?} */({ disabled: !item.resizable }))) : item.resizable)); item.__point = point++; return item; }); /** @type {?} */ var processList = ( /** * @param {?} data * @return {?} */function (data) { var e_4, _b; try { for (var data_1 = __values(data), data_1_1 = data_1.next(); !data_1_1.done; data_1_1 = data_1.next()) { var item = data_1_1.value; columns.push(processItem(item)); if (Array.isArray(item.children)) { processList(item.children); } } } catch (e_4_1) { e_4 = { error: e_4_1 }; } finally { try { if (data_1_1 && !data_1_1.done && (_b = data_1.return)) _b.call(data_1); } finally { if (e_4) throw e_4.error; } } }); /** @type {?} */ var copyList = this.cleanCond(( /** @type {?} */(list))); processList(copyList); if (checkboxCount > 1) { throw new Error("[st]: just only one column checkbox"); } if (radioCount > 1) { throw new Error("[st]: just only one column radio"); } this.fixedCoerce(( /** @type {?} */(columns))); return Object.assign({ columns: columns.filter(( /** * @param {?} w * @return {?} */function (/** * @param {?} w * @return {?} */ w) { return !Array.isArray(w.children) || w.children.length === 0; })) }, this.genHeaders(copyList)); }; /** * @param {?} columns * @return {?} */ STColumnSource.prototype.restoreAllRender = function (columns) { var _this = this; columns.forEach(( /** * @param {?} i * @return {?} */function (/** * @param {?} i * @return {?} */ i) { return _this.restoreRender(i); })); }; /** * @template THIS * @this {THIS} * @param {?} filter * @return {THIS} */ STColumnSource.prototype.updateDefault = function (filter) { if (filter.type === 'default') { filter.default = ( /** @type {?} */(filter.menus)).findIndex(( /** * @param {?} w * @return {?} */function (/** * @param {?} w * @return {?} */ w) { return ( /** @type {?} */(w.checked)); })) !== -1; } else { filter.default = !!( /** @type {?} */(filter.menus))[0].value; } return ( /** @type {?} */(this)); }; /** * @template THIS * @this {THIS} * @param {?} col * @return {THIS} */ STColumnSource.prototype.cleanFilter = function (col) { /** @type {?} */ var f = ( /** @type {?} */(col.filter)); f.default = false; if (f.type === 'default') { ( /** @type {?} */(f.menus)).forEach(( /** * @param {?} i * @return {?} */function (/** * @param {?} i * @return {?} */ i) { return (i.checked = false); })); } else { ( /** @type {?} */(f.menus))[0].value = undefined; } return ( /** @type {?} */(this)); }; return STColumnSource; }()); STColumnSource.decorators = [ { type: i0.Injectable } ]; /** @nocollapse */ STColumnSource.ctorParameters = function () { return [ { type: platformBrowser.DomSanitizer }, { type: STRowSource, decorators: [{ type: i0.Host }] }, { type: acl.ACLService, decorators: [{ type: i0.Optional }] }, { type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [theme.OHAYO_I18N_TOKEN,] }] }, { type: STWidgetRegistry } ]; }; if (false) { /** * @type {?} * @private */ STColumnSource.prototype.cog; /** * @type {?} * @private */ STColumnSource.prototype.dom; /** * @type {?} * @private */ STColumnSource.prototype.rowSource; /** * @type {?} * @private */ STColumnSource.prototype.acl; /** * @type {?} * @private */ STColumnSource.prototype.i18nSrv; /** * @type {?} * @private */ STColumnSource.prototype.stWidgetRegistry; } /** * @record */ function STDataSourceOptions() { } if (false) { /** @type {?} */ STDataSourceOptions.prototype.pi; /** @type {?} */ STDataSourceOptions.prototype.ps; /** @type {?} */ STDataSourceOptions.prototype.paginator; /** @type {?} */ STDataSourceOptions.prototype.data; /** @type {?} */ STDataSourceOptions.prototype.total; /** @type {?} */ STDataSourceOptions.prototype.req; /** @type {?} */ STDataSourceOptions.prototype.res; /** @type {?} */ STDataSourceOptions.prototype.page; /** @type {?} */ STDataSourceOptions.prototype.columns; /** @type {?|undefined} */ STDataSourceOptions.prototype.singleSort; /** @type {?|undefined} */ STDataSourceOptions.prototype.multiSort; /** @type {?|undefined} */ STDataSourceOptions.prototype.rowClassName; } /** * @record */ function STDataSourceResult() { } if (false) { /** * 是否需要显示分页器 * @type {?} */ STDataSourceResult.prototype.pageShow; /** * 新 `pi`,若返回 `undefined` 表示用户受控 * @type {?} */ STDataSourceResult.protot