geminis-ng
Version:
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 8.2.14.
1,155 lines (1,127 loc) • 126 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('ng-zorro-antd/message'), require('ng-zorro-antd/notification'), require('@angular/router'), require('@angular/common/http'), require('@auth0/angular-jwt'), require('ng-zorro-antd/icon'), require('@angular/common/locales/zh'), require('@angular/common'), require('@angular/forms'), require('ng-zorro-antd/input-number'), require('ng-zorro-antd/switch'), require('ng-zorro-antd/date-picker'), require('ng-zorro-antd/slider'), require('ng-zorro-antd/checkbox'), require('ng-zorro-antd/form'), require('@angular/platform-browser'), require('geminis-ng-core'), require('ng-zorro-antd/modal'), require('ng-zorro-antd/input'), require('crypto-js/sha256'), require('crypto-js/enc-hex'), require('ng-zorro-antd/radio'), require('ng-zorro-antd/select'), require('ng-zorro-antd/spin'), require('ng-zorro-antd/table'), require('ng-zorro-antd/button'), require('ng-zorro-antd/breadcrumb'), require('ng-zorro-antd/layout'), require('ng-zorro-antd/menu'), require('ng-zorro-antd/tree'), require('rxjs')) :
typeof define === 'function' && define.amd ? define('geminis-ng', ['exports', '@angular/core', 'ng-zorro-antd/message', 'ng-zorro-antd/notification', '@angular/router', '@angular/common/http', '@auth0/angular-jwt', 'ng-zorro-antd/icon', '@angular/common/locales/zh', '@angular/common', '@angular/forms', 'ng-zorro-antd/input-number', 'ng-zorro-antd/switch', 'ng-zorro-antd/date-picker', 'ng-zorro-antd/slider', 'ng-zorro-antd/checkbox', 'ng-zorro-antd/form', '@angular/platform-browser', 'geminis-ng-core', 'ng-zorro-antd/modal', 'ng-zorro-antd/input', 'crypto-js/sha256', 'crypto-js/enc-hex', 'ng-zorro-antd/radio', 'ng-zorro-antd/select', 'ng-zorro-antd/spin', 'ng-zorro-antd/table', 'ng-zorro-antd/button', 'ng-zorro-antd/breadcrumb', 'ng-zorro-antd/layout', 'ng-zorro-antd/menu', 'ng-zorro-antd/tree', 'rxjs'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['geminis-ng'] = {}, global.ng.core, global.message, global.notification, global.ng.router, global.ng.common.http, global.angularJwt, global.icon, global.ng.common.locales.zh, global.ng.common, global.ng.forms, global.inputNumber, global._switch, global.datePicker, global.slider, global.checkbox, global.form, global.ng.platformBrowser, global.geminisNgCore, global.modal, global.input, global.SHA256, global.HEX, global.radio, global.select, global.spin, global.table, global.button, global.breadcrumb, global.layout, global.menu, global.tree, global.rxjs));
}(this, (function (exports, core, message, notification, router, http, angularJwt, icon, zh, common, forms, inputNumber, _switch, datePicker, slider, checkbox, form, platformBrowser, geminisNgCore, modal, input, SHA256, HEX, radio, select, spin, table, button, breadcrumb, layout, menu, tree, rxjs) { 'use strict';
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var zh__default = /*#__PURE__*/_interopDefaultLegacy(zh);
var SHA256__default = /*#__PURE__*/_interopDefaultLegacy(SHA256);
var HEX__default = /*#__PURE__*/_interopDefaultLegacy(HEX);
var GnMessageService = /** @class */ (function () {
function GnMessageService(messageService, notificationService) {
this.messageService = messageService;
this.notificationService = notificationService;
}
GnMessageService.prototype.success = function (content) {
this.messageService.success(content);
};
GnMessageService.prototype.error = function (content) {
this.notificationService.error('错误', content);
};
GnMessageService.prototype.warn = function (content) {
this.notificationService.warning('提示', content);
};
GnMessageService.prototype.clean = function () {
this.messageService.remove();
this.notificationService.remove();
};
return GnMessageService;
}());
GnMessageService.decorators = [
{ type: core.Injectable }
];
GnMessageService.ctorParameters = function () { return [
{ type: message.NzMessageService },
{ type: notification.NzNotificationService }
]; };
var GnMessageServiceModule = /** @class */ (function () {
function GnMessageServiceModule() {
}
return GnMessageServiceModule;
}());
GnMessageServiceModule.decorators = [
{ type: core.NgModule, args: [{
imports: [
message.NzMessageModule,
notification.NzNotificationModule
],
providers: [GnMessageService]
},] }
];
var GnLoginUser = /** @class */ (function () {
function GnLoginUser() {
}
return GnLoginUser;
}());
GnLoginUser.decorators = [
{ type: core.Injectable }
];
var GnSiteInfo = /** @class */ (function () {
function GnSiteInfo(loginUser) {
this.loginUser = loginUser;
this.showBreadcrumb = false;
this.siderMenuTheme = 'dark';
this.authSiderMenu = [];
this.siteAuthorities = [];
this.siderMenu = [];
}
GnSiteInfo.prototype.filterMenu = function () {
this.authSiderMenu = this.getAuthorityMenu(this.siderMenu, '');
};
GnSiteInfo.prototype.getAuthorityMenu = function (menus, parentPath) {
var _this = this;
if (this.loginUser.authorities && menus) {
return menus.map(function (menu) {
var _a;
var path = parentPath + (menu.router || '');
if (menu.authority) {
var authority = (_a = _this.siteAuthorities) === null || _a === void 0 ? void 0 : _a.find(function (item) { return item.url === path; });
if (!authority) {
_this.siteAuthorities.push({ url: path, authority: menu.authority });
}
}
return {
title: menu.title,
router: menu.router,
icon: menu.icon,
authority: menu.authority,
subMenu: _this.getAuthorityMenu(menu.subMenu, path)
};
}).filter(function (menu) { return _this.loginUser.authorities.includes(menu.authority)
|| ((!menu.subMenu || menu.subMenu.length === 0) && !menu.authority)
|| (menu.subMenu && menu.subMenu.length > 0); });
}
else {
return menus;
}
};
return GnSiteInfo;
}());
GnSiteInfo.decorators = [
{ type: core.Injectable }
];
GnSiteInfo.ctorParameters = function () { return [
{ type: GnLoginUser }
]; };
var GnRouteGuard = /** @class */ (function () {
function GnRouteGuard(user, siteInfo, router, messageService) {
this.user = user;
this.siteInfo = siteInfo;
this.router = router;
this.messageService = messageService;
}
GnRouteGuard.prototype.canActivate = function (route, state) {
var _a;
if (!this.user.isLogin) {
sessionStorage.setItem('blockUrl', state.url);
this.messageService.warn('请登录');
this.router.navigateByUrl(this.siteInfo.loginUrl);
return false;
}
else {
var authority = (_a = this.siteInfo.siteAuthorities) === null || _a === void 0 ? void 0 : _a.find(function (item) { return item.url === state.url; });
if (!authority || this.user.authorities.includes(authority.authority)) {
return true;
}
else {
sessionStorage.setItem('blockUrl', state.url);
this.messageService.warn('您的权限不足');
this.router.navigateByUrl(this.siteInfo.loginUrl);
return false;
}
}
};
return GnRouteGuard;
}());
GnRouteGuard.decorators = [
{ type: core.Injectable }
];
GnRouteGuard.ctorParameters = function () { return [
{ type: GnLoginUser },
{ type: GnSiteInfo },
{ type: router.Router },
{ type: GnMessageService }
]; };
var GnHttpInterceptorConfig = /** @class */ (function () {
function GnHttpInterceptorConfig() {
this.ignoreUrls = [];
}
return GnHttpInterceptorConfig;
}());
GnHttpInterceptorConfig.decorators = [
{ type: core.Injectable }
];
var GnOAuthUtils = /** @class */ (function () {
function GnOAuthUtils() {
this.helper = new angularJwt.JwtHelperService();
}
GnOAuthUtils.prototype.setToken = function (token) {
return sessionStorage.setItem('Authorization', token);
};
GnOAuthUtils.prototype.getToken = function () {
return sessionStorage.getItem('Authorization');
};
GnOAuthUtils.prototype.parseToken = function (token) {
return this.helper.decodeToken(token);
};
GnOAuthUtils.prototype.tokenExpired = function (token) {
return this.helper.isTokenExpired(token);
};
return GnOAuthUtils;
}());
var GnOAuthHttpInterceptor = /** @class */ (function () {
function GnOAuthHttpInterceptor(config, siteInfo, route) {
this.config = config;
this.siteInfo = siteInfo;
this.route = route;
this.oAuthUtils = new GnOAuthUtils();
}
GnOAuthHttpInterceptor.prototype.intercept = function (req, next) {
var headers = req.headers;
if (this.config.startWithUrl
&& req.url.startsWith(this.config.startWithUrl)
&& !this.config.ignoreUrls.includes(req.url)) {
var token = this.oAuthUtils.getToken();
if (this.oAuthUtils.tokenExpired(token)) {
if (this.siteInfo && this.siteInfo.loginUrl) {
this.route.navigateByUrl(this.siteInfo.loginUrl);
}
}
else {
headers = req.headers.set('Authorization', 'Bearer ' + token);
}
}
return next.handle(req.clone({
headers: headers
}));
};
return GnOAuthHttpInterceptor;
}());
GnOAuthHttpInterceptor.decorators = [
{ type: core.Injectable }
];
GnOAuthHttpInterceptor.ctorParameters = function () { return [
{ type: GnHttpInterceptorConfig },
{ type: GnSiteInfo },
{ type: router.Router }
]; };
common.registerLocaleData(zh__default['default']);
var GnAppConfigModule = /** @class */ (function () {
function GnAppConfigModule(httpClient, siteInfo, iconService, messageService) {
httpClient.get('assets/config/siteInfo.json')
.subscribe(function (value) {
siteInfo.title = value.title;
siteInfo.siderMenu = value.siderMenu;
siteInfo.siderMenuTheme = value.siderMenuTheme || 'dark';
siteInfo.showBreadcrumb = value.showBreadcrumb;
siteInfo.siteAuthorities = value.siteAuthorities;
siteInfo.iconFontUrl = value.iconFontUrl;
siteInfo.authSiderMenu = siteInfo.getAuthorityMenu(siteInfo.siderMenu, '');
iconService.fetchFromIconfont({
scriptUrl: siteInfo.iconFontUrl
});
}, function (error) {
messageService.error('获取系统信息错误');
throw error;
});
}
return GnAppConfigModule;
}());
GnAppConfigModule.decorators = [
{ type: core.NgModule, args: [{
declarations: [],
exports: [],
imports: [
http.HttpClientModule,
GnMessageServiceModule
],
providers: [
GnSiteInfo,
GnLoginUser,
GnRouteGuard,
GnHttpInterceptorConfig,
{ provide: http.HTTP_INTERCEPTORS, useClass: GnOAuthHttpInterceptor, multi: true }
]
},] }
];
GnAppConfigModule.ctorParameters = function () { return [
{ type: http.HttpClient },
{ type: GnSiteInfo },
{ type: icon.NzIconService },
{ type: GnMessageService }
]; };
var GnAppRootComponent = /** @class */ (function () {
function GnAppRootComponent() {
}
return GnAppRootComponent;
}());
GnAppRootComponent.decorators = [
{ type: core.Component, args: [{
selector: 'gn-app-root',
template: "\n <router-outlet></router-outlet>\n <div id=\"gn-app-root\"></div>\n "
},] }
];
var GnAppRootModule = /** @class */ (function () {
function GnAppRootModule() {
}
return GnAppRootModule;
}());
GnAppRootModule.decorators = [
{ type: core.NgModule, args: [{
declarations: [GnAppRootComponent],
exports: [
GnAppRootComponent
],
imports: [
router.RouterModule
]
},] }
];
/*! *****************************************************************************
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) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
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;
}
/** @deprecated */
function __spread() {
for (var ar = [], i = 0; i < arguments.length; i++)
ar = ar.concat(__read(arguments[i]));
return ar;
}
/** @deprecated */
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 __spreadArray(to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
to[j] = from[i];
return to;
}
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;
}
var formItemTypes = {
'input-number': inputNumber.NzInputNumberComponent,
date: datePicker.NzDatePickerComponent,
// 'date-range': NzRangePickerComponent,
// rate: NzRateComponent,
slider: slider.NzSliderComponent,
switch: _switch.NzSwitchComponent,
};
function GnFormItem(key) {
return function (target) {
formItemTypes[key] = target;
};
}
var GnCheckboxGroupComponent_1;
exports.GnCheckboxGroupComponent = GnCheckboxGroupComponent_1 = /** @class */ (function () {
function GnCheckboxGroupComponent() {
this.valueChanged = new core.EventEmitter();
this.valueChange = function (value) {
};
}
Object.defineProperty(GnCheckboxGroupComponent.prototype, "value", {
get: function () {
this.innerValue = this.items.filter(function (item) { return item.checked; }).map(function (item) { return item.value; });
return this.innerValue;
},
set: function (v) {
var _this = this;
if (this.innerValue !== v) {
this.innerValue = v;
this.items.forEach(function (item) {
item.checked = _this.innerValue.includes(item.value);
});
this.valueChange(this.innerValue);
}
},
enumerable: false,
configurable: true
});
GnCheckboxGroupComponent.prototype.registerOnChange = function (fn) {
this.valueChange = fn;
};
GnCheckboxGroupComponent.prototype.registerOnTouched = function (fn) {
};
GnCheckboxGroupComponent.prototype.writeValue = function (obj) {
this.value = obj;
};
return GnCheckboxGroupComponent;
}());
exports.GnCheckboxGroupComponent.decorators = [
{ type: core.Component, args: [{
selector: 'gn-checkbox-group',
template: "\n <nz-checkbox-group [(ngModel)]=\"items\" (ngModelChange)=\"valueChange(value);valueChanged.emit()\"></nz-checkbox-group>\n ",
providers: [{
provide: forms.NG_VALUE_ACCESSOR,
useExisting: core.forwardRef(function () { return GnCheckboxGroupComponent_1; }),
multi: true
}]
},] }
];
exports.GnCheckboxGroupComponent.propDecorators = {
value: [{ type: core.Input }],
valueChanged: [{ type: core.Output }]
};
exports.GnCheckboxGroupComponent = GnCheckboxGroupComponent_1 = __decorate([
GnFormItem('checkbox-group')
], exports.GnCheckboxGroupComponent);
var GnCheckboxGroupModule = /** @class */ (function () {
function GnCheckboxGroupModule() {
}
return GnCheckboxGroupModule;
}());
GnCheckboxGroupModule.decorators = [
{ type: core.NgModule, args: [{
declarations: [exports.GnCheckboxGroupComponent],
imports: [
common.CommonModule,
forms.FormsModule,
checkbox.NzCheckboxModule,
],
exports: [exports.GnCheckboxGroupComponent],
entryComponents: []
},] }
];
function controlContainerFactory() {
var formGroupDirective = new forms.FormGroupDirective([], []);
formGroupDirective.form = new forms.FormGroup({});
return formGroupDirective;
}
var GnFormDirective = /** @class */ (function () {
function GnFormDirective(controlContainer, elementRef, renderer, http, changeDetectorRef, modalRef) {
var _this = this;
this.controlContainer = controlContainer;
this.elementRef = elementRef;
this.renderer = renderer;
this.http = http;
this.changeDetectorRef = changeDetectorRef;
this.binded = false;
this.labelWidth = 6;
this.controlWidth = 18;
this.autoLoadData = true;
this.submitMethod = 'put';
this.loadMethod = 'post';
this.format = 'json';
this.formGroup = controlContainer.control;
this.formGroup.valueChanges.subscribe(function (newValue) {
if (modalRef) {
modalRef.updateConfig({ nzOkDisabled: _this.formGroup.invalid });
}
if (_this.innerBindValue && _this.binded) {
Object.assign(_this.innerBindValue, newValue);
}
});
}
Object.defineProperty(GnFormDirective.prototype, "cols", {
get: function () {
return this.colsValue;
},
set: function (value) {
this.colsValue = value;
if (!this.colsValue || this.colsValue < 1) {
return;
}
this.renderer.setStyle(this.elementRef.nativeElement, 'display', 'grid');
this.renderer.setStyle(this.elementRef.nativeElement, 'grid-template-columns', 'repeat(' + this.colsValue + ', 1fr)');
},
enumerable: false,
configurable: true
});
Object.defineProperty(GnFormDirective.prototype, "bindValue", {
set: function (value) {
this.binded = false;
this.innerBindValue = value;
this.formGroup.patchValue(value);
this.binded = true;
},
enumerable: false,
configurable: true
});
GnFormDirective.prototype.setValue = function (value) {
this.defaultValue = value;
this.formGroup.patchValue(value);
};
Object.defineProperty(GnFormDirective.prototype, "submitValue", {
get: function () {
var submitValue;
if (this.defaultValue) {
submitValue = Object.assign(geminisNgCore.GnObjectUtils.deepCopy(this.defaultValue), this.formGroup.value);
}
else {
submitValue = this.formGroup.value;
}
if (this.format === 'form') {
submitValue = geminisNgCore.GnJsonUtils.obj2FormData(submitValue);
}
return submitValue;
},
enumerable: false,
configurable: true
});
GnFormDirective.prototype.submit = function () {
if (!this.url) {
return Promise.resolve(this.submitValue);
}
else {
var options = Object.assign({ body: this.submitValue }, this.submitOptions);
return this.http.request(this.submitMethod, this.url, options).toPromise();
}
};
GnFormDirective.prototype.loadData = function () {
var _this = this;
if (!this.url || !this.dataId) {
if (this.defaultValue) {
this.formGroup.patchValue(this.defaultValue);
}
return Promise.resolve(null);
}
var queryParameter = {
pageSize: 1,
pageIndex: 0,
includes: this.dataIncludes,
filterGroup: {
type: 'and',
filters: [{ field: this.dataKey, compareType: '=', value: this.dataId }]
}
};
var options = Object.assign({ body: queryParameter }, this.loadOptions);
return this.http.request(this.loadMethod, this.url, options)
.toPromise()
.then(function (resp) {
if (resp.content.length === 0) {
throw new Error("\u672A\u627E\u5230\u6570\u636E[" + _this.dataId + "]");
}
_this.defaultValue = _this.defaultValue || {};
Object.assign(_this.defaultValue, resp.content[0]);
_this.formGroup.patchValue(_this.defaultValue);
return _this.defaultValue;
});
};
GnFormDirective.prototype.ngOnInit = function () {
if (this.autoLoadData) {
this.loadData();
}
};
GnFormDirective.prototype.ngAfterViewInit = function () {
this.changeDetectorRef.detectChanges();
};
return GnFormDirective;
}());
GnFormDirective.decorators = [
{ type: core.Directive, args: [{
selector: '[gn-form]',
providers: [
{ provide: forms.ControlContainer, useFactory: controlContainerFactory }
]
},] }
];
GnFormDirective.ctorParameters = function () { return [
{ type: forms.ControlContainer },
{ type: core.ElementRef },
{ type: core.Renderer2 },
{ type: http.HttpClient },
{ type: core.ChangeDetectorRef },
{ type: modal.NzModalRef, decorators: [{ type: core.Optional }] }
]; };
GnFormDirective.propDecorators = {
url: [{ type: core.Input }],
labelWidth: [{ type: core.Input }],
controlWidth: [{ type: core.Input }],
dataId: [{ type: core.Input }],
dataKey: [{ type: core.Input }],
dataIncludes: [{ type: core.Input }],
autoLoadData: [{ type: core.Input }],
submitMethod: [{ type: core.Input }],
loadMethod: [{ type: core.Input }],
format: [{ type: core.Input }],
submitOptions: [{ type: core.Input }],
loadOptions: [{ type: core.Input }],
defaultValue: [{ type: core.Input }],
cols: [{ type: core.Input }],
bindValue: [{ type: core.Input }]
};
var GnFormItemComponent = /** @class */ (function () {
function GnFormItemComponent(gnForm, nzForm, cdr, domSanitizer) {
this.gnForm = gnForm;
this.nzForm = nzForm;
this.cdr = cdr;
this.domSanitizer = domSanitizer;
this.controlVisible = true;
this.validators = [];
}
Object.defineProperty(GnFormItemComponent.prototype, "visible", {
get: function () {
return this.controlVisible;
},
set: function (value) {
this.controlVisible = value;
this.ensureFormControl();
},
enumerable: false,
configurable: true
});
Object.defineProperty(GnFormItemComponent.prototype, "colspan", {
get: function () {
return this.colspanValue;
},
set: function (value) {
this.colspanValue = value;
if (this.colspanValue > 1 && this.label) {
this.labelWidth = Math.ceil(this.gnForm.labelWidth / this.colspanValue);
this.controlWidth = Math.floor((this.gnForm.controlWidth + (this.colspanValue - 1) * 24) / this.colspanValue);
}
else if (!this.label) {
this.controlWidth = 24;
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(GnFormItemComponent.prototype, "hasRequired", {
get: function () {
return this.validators && this.validators.some(function (validator) { return validator.validator === 'required'; });
},
enumerable: false,
configurable: true
});
Object.defineProperty(GnFormItemComponent.prototype, "colSpan", {
get: function () {
return this.colspan ?
this.domSanitizer.bypassSecurityTrustStyle('auto / span ' + this.colspan) :
null;
},
enumerable: false,
configurable: true
});
Object.defineProperty(GnFormItemComponent.prototype, "rowSpan", {
get: function () {
return this.colspan ?
this.domSanitizer.bypassSecurityTrustStyle('auto / span ' + this.rowspan) :
null;
},
enumerable: false,
configurable: true
});
Object.defineProperty(GnFormItemComponent.prototype, "styleDisplay", {
get: function () {
return this.display === false ? 'none' : '';
},
enumerable: false,
configurable: true
});
GnFormItemComponent.prototype.ngOnInit = function () {
this.ensureFormControl();
};
GnFormItemComponent.prototype.ngAfterViewInit = function () {
// this.ensureFormControl();
if (this.nzFormControl) {
this.nzFormControl.nzValidateStatus = this.formControl;
}
if (this.defaultValue || this.defaultValue === false) {
if (typeof this.defaultValue === 'string' && this.defaultValue.startsWith('{') && this.defaultValue.endsWith('}')) {
// tslint:disable-next-line:no-eval
var calcValue = eval(this.defaultValue.substr(1, this.defaultValue.length - 2));
this.formControl.patchValue(calcValue);
}
else {
this.formControl.patchValue(this.defaultValue);
}
this.cdr.detectChanges();
}
};
GnFormItemComponent.prototype.ensureFormControl = function () {
if (this.field) {
if (this.controlVisible) {
this.formControl = geminisNgCore.GnFormUtils.ensureFormControl(this.gnForm.formGroup, this.field, this.validators);
}
else {
geminisNgCore.GnFormUtils.removeFormControl(this.gnForm.formGroup, this.field);
}
}
};
return GnFormItemComponent;
}());
GnFormItemComponent.decorators = [
{ type: core.Component, args: [{
selector: 'gn-form-item,[gn-form-item]',
template: "<nz-form-item *ngIf=\"controlVisible\">\n <nz-form-label *ngIf=\"label\" [nzRequired]=\"hasRequired\"\n [nzSpan]=\"nzForm.nzLayout === 'horizontal' ? (labelWidth || gnForm.labelWidth) : null\">{{label}}\n </nz-form-label>\n <nz-form-control [nzErrorTip]=\"errorTpl\"\n [nzSpan]=\"nzForm.nzLayout === 'horizontal' ? (controlWidth || gnForm.controlWidth) : null\">\n <ng-content></ng-content>\n <ng-template #errorTpl let-control>\n <ng-container *ngFor=\"let validator of validators\">\n <ng-container *ngIf=\"control.hasError(validator.validator)\">\n {{validator.message}}\n </ng-container>\n </ng-container>\n </ng-template>\n </nz-form-control>\n</nz-form-item>\n",
styles: [":host{padding:0 5px}"]
},] }
];
GnFormItemComponent.ctorParameters = function () { return [
{ type: GnFormDirective },
{ type: form.NzFormDirective },
{ type: core.ChangeDetectorRef },
{ type: platformBrowser.DomSanitizer }
]; };
GnFormItemComponent.propDecorators = {
nzFormControl: [{ type: core.ViewChild, args: [form.NzFormControlComponent,] }],
visible: [{ type: core.Input }],
label: [{ type: core.Input }],
field: [{ type: core.Input }],
colspan: [{ type: core.Input }],
rowspan: [{ type: core.Input }],
validators: [{ type: core.Input }],
defaultValue: [{ type: core.Input }],
display: [{ type: core.Input }],
colSpan: [{ type: core.HostBinding, args: ['style.grid-column',] }],
rowSpan: [{ type: core.HostBinding, args: ['style.grid-row',] }],
styleDisplay: [{ type: core.HostBinding, args: ['style.display',] }]
};
var GnFormModule = /** @class */ (function () {
function GnFormModule() {
}
return GnFormModule;
}());
GnFormModule.decorators = [
{ type: core.NgModule, args: [{
declarations: [GnFormDirective, GnFormItemComponent],
exports: [
GnFormDirective,
GnFormItemComponent
],
imports: [
common.CommonModule,
forms.FormsModule,
forms.ReactiveFormsModule,
form.NzFormModule
]
},] }
];
var GnHiddenComponent_1;
exports.GnHiddenComponent = GnHiddenComponent_1 = /** @class */ (function () {
function GnHiddenComponent(formItem) {
this.formItem = formItem;
this.valueChange = function (value) {
};
}
Object.defineProperty(GnHiddenComponent.prototype, "value", {
get: function () {
return this.innerValue;
},
set: function (v) {
if (this.innerValue !== v) {
this.innerValue = v;
this.valueChange(this.innerValue);
}
},
enumerable: false,
configurable: true
});
GnHiddenComponent.prototype.ngOnInit = function () {
if (this.formItem) {
this.formItem.display = false;
}
};
GnHiddenComponent.prototype.registerOnChange = function (fn) {
this.valueChange = fn;
};
GnHiddenComponent.prototype.registerOnTouched = function (fn) {
};
GnHiddenComponent.prototype.writeValue = function (obj) {
this.value = obj;
};
return GnHiddenComponent;
}());
exports.GnHiddenComponent.decorators = [
{ type: core.Component, args: [{
selector: 'gn-hidden',
template: "",
providers: [{
provide: forms.NG_VALUE_ACCESSOR,
useExisting: core.forwardRef(function () { return GnHiddenComponent_1; }),
multi: true
}]
},] }
];
exports.GnHiddenComponent.ctorParameters = function () { return [
{ type: GnFormItemComponent, decorators: [{ type: core.Optional }] }
]; };
exports.GnHiddenComponent.propDecorators = {
value: [{ type: core.Input }]
};
exports.GnHiddenComponent = GnHiddenComponent_1 = __decorate([
GnFormItem('hidden')
], exports.GnHiddenComponent);
var GnHiddenModule = /** @class */ (function () {
function GnHiddenModule() {
}
return GnHiddenModule;
}());
GnHiddenModule.decorators = [
{ type: core.NgModule, args: [{
declarations: [exports.GnHiddenComponent],
exports: [exports.GnHiddenComponent],
imports: [
common.CommonModule,
forms.FormsModule
],
entryComponents: []
},] }
];
var GnInputComponent_1;
exports.GnInputComponent = GnInputComponent_1 = /** @class */ (function () {
function GnInputComponent() {
this.placeholder = '';
this.valueChange = function (value) {
};
}
Object.defineProperty(GnInputComponent.prototype, "value", {
get: function () {
return this.innerValue;
},
set: function (v) {
if (this.innerValue !== v) {
this.innerValue = v;
this.valueChange(this.innerValue);
}
},
enumerable: false,
configurable: true
});
GnInputComponent.prototype.registerOnChange = function (fn) {
this.valueChange = fn;
};
GnInputComponent.prototype.registerOnTouched = function (fn) {
};
GnInputComponent.prototype.writeValue = function (obj) {
this.value = obj;
};
return GnInputComponent;
}());
exports.GnInputComponent.decorators = [
{ type: core.Component, args: [{
selector: 'gn-input',
template: "<input [(ngModel)]=\"value\" nz-input [placeholder]=\"placeholder\"/>\n",
providers: [{
provide: forms.NG_VALUE_ACCESSOR,
useExisting: core.forwardRef(function () { return GnInputComponent_1; }),
multi: true
}],
styles: [""]
},] }
];
exports.GnInputComponent.propDecorators = {
placeholder: [{ type: core.Input }],
value: [{ type: core.Input }]
};
exports.GnInputComponent = GnInputComponent_1 = __decorate([
GnFormItem('input')
], exports.GnInputComponent);
var GnInputModule = /** @class */ (function () {
function GnInputModule() {
}
return GnInputModule;
}());
GnInputModule.decorators = [
{ type: core.NgModule, args: [{
declarations: [exports.GnInputComponent],
exports: [exports.GnInputComponent],
imports: [
common.CommonModule,
input.NzInputModule,
forms.FormsModule
],
entryComponents: []
},] }
];
var modalContentTypes = {};
function GnModalContent(options) {
var option = typeof options === 'string' ? { key: options } : options;
return function (target) {
modalContentTypes[option.key] = Object.assign({ type: target }, option);
delete modalContentTypes[option.key].key;
};
}
var GnJsonFormComponent_1;
exports.GnJsonFormComponent = GnJsonFormComponent_1 = /** @class */ (function () {
function GnJsonFormComponent(http, messageService, changeDetectorRef) {
this.http = http;
this.messageService = messageService;
this.changeDetectorRef = changeDetectorRef;
this.config = { fields: [] };
this.configLoaded = new core.EventEmitte