@sd-angular/core 0.0.1040 → 0.0.1044
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/scss/quill-mention/quill-mention.css +55 -0
- package/assets/scss/sd-core.scss +1 -0
- package/bundles/sd-angular-core-chip.umd.js +41 -10
- package/bundles/sd-angular-core-chip.umd.js.map +1 -1
- package/bundles/sd-angular-core-chip.umd.min.js +2 -2
- package/bundles/sd-angular-core-chip.umd.min.js.map +1 -1
- package/bundles/sd-angular-core-comment.umd.js +16 -15
- package/bundles/sd-angular-core-comment.umd.js.map +1 -1
- package/bundles/sd-angular-core-comment.umd.min.js +2 -2
- package/bundles/sd-angular-core-comment.umd.min.js.map +1 -1
- package/bundles/sd-angular-core-editor.umd.js +73 -18
- package/bundles/sd-angular-core-editor.umd.js.map +1 -1
- package/bundles/sd-angular-core-editor.umd.min.js +2 -2
- package/bundles/sd-angular-core-editor.umd.min.js.map +1 -1
- package/bundles/sd-angular-core-filter.umd.js +703 -0
- package/bundles/sd-angular-core-filter.umd.js.map +1 -0
- package/bundles/sd-angular-core-filter.umd.min.js +2 -0
- package/bundles/sd-angular-core-filter.umd.min.js.map +1 -0
- package/bundles/sd-angular-core-form.umd.js +6 -4
- package/bundles/sd-angular-core-form.umd.js.map +1 -1
- package/bundles/sd-angular-core-form.umd.min.js +1 -1
- package/bundles/sd-angular-core-form.umd.min.js.map +1 -1
- package/bundles/sd-angular-core-grid-material.umd.js +87 -42
- package/bundles/sd-angular-core-grid-material.umd.js.map +1 -1
- package/bundles/sd-angular-core-grid-material.umd.min.js +1 -1
- package/bundles/sd-angular-core-grid-material.umd.min.js.map +1 -1
- package/bundles/sd-angular-core-modal-custom.umd.js +487 -0
- package/bundles/sd-angular-core-modal-custom.umd.js.map +1 -0
- package/bundles/sd-angular-core-modal-custom.umd.min.js +16 -0
- package/bundles/sd-angular-core-modal-custom.umd.min.js.map +1 -0
- package/bundles/sd-angular-core-modal-resizable.umd.js +487 -0
- package/bundles/sd-angular-core-modal-resizable.umd.js.map +1 -0
- package/bundles/sd-angular-core-modal-resizable.umd.min.js +16 -0
- package/bundles/sd-angular-core-modal-resizable.umd.min.js.map +1 -0
- package/bundles/sd-angular-core-setting.umd.js +176 -117
- package/bundles/sd-angular-core-setting.umd.js.map +1 -1
- package/bundles/sd-angular-core-setting.umd.min.js +1 -1
- package/bundles/sd-angular-core-setting.umd.min.js.map +1 -1
- package/bundles/sd-angular-core.umd.js +4 -4
- package/bundles/sd-angular-core.umd.min.js +1 -1
- package/bundles/sd-angular-core.umd.min.js.map +1 -1
- package/chip/sd-angular-core-chip.metadata.json +1 -1
- package/chip/src/lib/chip.component.d.ts +8 -1
- package/comment/sd-angular-core-comment.metadata.json +1 -1
- package/comment/src/lib/comment.model.d.ts +11 -0
- package/editor/sd-angular-core-editor.metadata.json +1 -1
- package/editor/src/lib/editor.component.d.ts +17 -3
- package/esm2015/chip/src/lib/chip.component.js +34 -4
- package/esm2015/chip/src/lib/chip.module.js +6 -3
- package/esm2015/comment/src/lib/comment.component.js +4 -4
- package/esm2015/comment/src/lib/comment.model.js +1 -1
- package/esm2015/comment/src/lib/comment.module.js +3 -1
- package/esm2015/editor/src/lib/editor.component.js +70 -14
- package/esm2015/editor/src/lib/editor.module.js +4 -2
- package/esm2015/filter/index.js +2 -0
- package/esm2015/filter/sd-angular-core-filter.js +8 -0
- package/esm2015/filter/src/lib/directives/sd-filter-def.directive.js +22 -0
- package/esm2015/filter/src/lib/filter.component.js +161 -0
- package/esm2015/filter/src/lib/filter.model.js +2 -0
- package/esm2015/filter/src/lib/filter.module.js +47 -0
- package/esm2015/filter/src/lib/filter.service.js +60 -0
- package/esm2015/filter/src/lib/pipes/values-local.pipe.js +19 -0
- package/esm2015/filter/src/lib/pipes/values-server.pipe.js +18 -0
- package/esm2015/filter/src/public-api.js +8 -0
- package/esm2015/form/src/lib/form.module.js +4 -1
- package/esm2015/grid-material/src/lib/components/quick-action/quick-action.component.js +1 -1
- package/esm2015/grid-material/src/lib/services/generated-column/generated-column.service.js +28 -12
- package/esm2015/grid-material/src/lib/services/grid-configuration.service.js +50 -21
- package/esm2015/modal-custom/index.js +2 -0
- package/esm2015/modal-custom/sd-angular-core-modal-custom.js +5 -0
- package/esm2015/modal-custom/src/lib/modal-custom/modal-custom.component.js +123 -0
- package/esm2015/modal-custom/src/lib/modal-custom.module.js +30 -0
- package/esm2015/modal-custom/src/public-api.js +6 -0
- package/esm2015/modal-resizable/index.js +2 -0
- package/esm2015/modal-resizable/sd-angular-core-modal-resizable.js +5 -0
- package/esm2015/modal-resizable/src/lib/modal-resizable/modal-resizable.component.js +123 -0
- package/esm2015/modal-resizable/src/lib/modal-resizable.module.js +30 -0
- package/esm2015/modal-resizable/src/public-api.js +6 -0
- package/esm2015/public-api.js +3 -1
- package/esm2015/setting/src/lib/setting.model.js +1 -1
- package/esm2015/setting/src/lib/setting.service.js +119 -58
- package/fesm2015/sd-angular-core-chip.js +37 -5
- package/fesm2015/sd-angular-core-chip.js.map +1 -1
- package/fesm2015/sd-angular-core-comment.js +5 -3
- package/fesm2015/sd-angular-core-comment.js.map +1 -1
- package/fesm2015/sd-angular-core-editor.js +72 -15
- package/fesm2015/sd-angular-core-editor.js.map +1 -1
- package/fesm2015/sd-angular-core-filter.js +323 -0
- package/fesm2015/sd-angular-core-filter.js.map +1 -0
- package/fesm2015/sd-angular-core-form.js +3 -0
- package/fesm2015/sd-angular-core-form.js.map +1 -1
- package/fesm2015/sd-angular-core-grid-material.js +77 -32
- package/fesm2015/sd-angular-core-grid-material.js.map +1 -1
- package/fesm2015/sd-angular-core-modal-custom.js +161 -0
- package/fesm2015/sd-angular-core-modal-custom.js.map +1 -0
- package/fesm2015/sd-angular-core-modal-resizable.js +161 -0
- package/fesm2015/sd-angular-core-modal-resizable.js.map +1 -0
- package/fesm2015/sd-angular-core-setting.js +119 -58
- package/fesm2015/sd-angular-core-setting.js.map +1 -1
- package/fesm2015/sd-angular-core.js +2 -0
- package/fesm2015/sd-angular-core.js.map +1 -1
- package/filter/index.d.ts +1 -0
- package/filter/package.json +12 -0
- package/filter/sd-angular-core-filter.d.ts +7 -0
- package/filter/sd-angular-core-filter.metadata.json +1 -0
- package/filter/src/lib/directives/sd-filter-def.directive.d.ts +8 -0
- package/filter/src/lib/filter.component.d.ts +31 -0
- package/filter/src/lib/filter.model.d.ts +105 -0
- package/filter/src/lib/filter.module.d.ts +2 -0
- package/filter/src/lib/filter.service.d.ts +9 -0
- package/filter/src/lib/pipes/values-local.pipe.d.ts +5 -0
- package/filter/src/lib/pipes/values-server.pipe.d.ts +5 -0
- package/filter/src/public-api.d.ts +4 -0
- package/form/sd-angular-core-form.metadata.json +1 -1
- package/grid-material/sd-angular-core-grid-material.metadata.json +1 -1
- package/grid-material/src/lib/services/generated-column/generated-column.service.d.ts +3 -2
- package/modal-custom/index.d.ts +1 -0
- package/modal-custom/package.json +12 -0
- package/modal-custom/sd-angular-core-modal-custom.d.ts +4 -0
- package/modal-custom/sd-angular-core-modal-custom.metadata.json +1 -0
- package/modal-custom/src/lib/modal-custom/modal-custom.component.d.ts +31 -0
- package/modal-custom/src/lib/modal-custom.module.d.ts +2 -0
- package/modal-custom/src/public-api.d.ts +2 -0
- package/modal-resizable/index.d.ts +1 -0
- package/modal-resizable/package.json +12 -0
- package/modal-resizable/sd-angular-core-modal-resizable.d.ts +4 -0
- package/modal-resizable/sd-angular-core-modal-resizable.metadata.json +1 -0
- package/modal-resizable/src/lib/modal-resizable/modal-resizable.component.d.ts +31 -0
- package/modal-resizable/src/lib/modal-resizable.module.d.ts +2 -0
- package/modal-resizable/src/public-api.d.ts +2 -0
- package/package.json +3 -2
- package/public-api.d.ts +2 -0
- package/{sd-angular-core-0.0.1040.tgz → sd-angular-core-0.0.1044.tgz} +0 -0
- package/setting/sd-angular-core-setting.metadata.json +1 -1
- package/setting/src/lib/setting.model.d.ts +20 -6
- package/setting/src/lib/setting.service.d.ts +2 -1
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { __classPrivateFieldGet, __classPrivateFieldSet } from 'tslib';
|
|
2
|
+
import { EventEmitter, Component, ChangeDetectionStrategy, ComponentFactoryResolver, ApplicationRef, Injector, ChangeDetectorRef, ViewChild, Input, Output, NgModule } from '@angular/core';
|
|
3
|
+
import { DomPortalOutlet, CdkPortal, PortalModule } from '@angular/cdk/portal';
|
|
4
|
+
import { v4 } from 'uuid';
|
|
5
|
+
import { SdLoadingService } from '@sd-angular/core/loading';
|
|
6
|
+
import $ from 'jquery';
|
|
7
|
+
import { CommonModule } from '@angular/common';
|
|
8
|
+
import { MatIconModule } from '@angular/material/icon';
|
|
9
|
+
import { MatDialogModule } from '@angular/material/dialog';
|
|
10
|
+
import { MatButtonModule } from '@angular/material/button';
|
|
11
|
+
import { SdButtonModule } from '@sd-angular/core/button';
|
|
12
|
+
|
|
13
|
+
var _embeddedViewRef, _drawMiniumBar;
|
|
14
|
+
class SdModalCustom {
|
|
15
|
+
constructor(cfr, ar, injector, ref, loadingService) {
|
|
16
|
+
this.cfr = cfr;
|
|
17
|
+
this.ar = ar;
|
|
18
|
+
this.injector = injector;
|
|
19
|
+
this.ref = ref;
|
|
20
|
+
this.loadingService = loadingService;
|
|
21
|
+
this.id = `I${v4()}`;
|
|
22
|
+
this.width = '480px';
|
|
23
|
+
this.editingChanged = new EventEmitter();
|
|
24
|
+
_embeddedViewRef.set(this, void 0);
|
|
25
|
+
this.isEditing = false;
|
|
26
|
+
this.isOpened = false;
|
|
27
|
+
this.isHover = false;
|
|
28
|
+
this.isLoading = false;
|
|
29
|
+
this.isMinium = false;
|
|
30
|
+
this.open = () => {
|
|
31
|
+
this.ref.markForCheck();
|
|
32
|
+
this.isOpened = true;
|
|
33
|
+
// console.log('OPEN isMinium' + this.id, this.isMinium);
|
|
34
|
+
// tinh toan width maxium lần đầu khi không ở trạng thái minium
|
|
35
|
+
if (!$('#' + this.id).hasClass('c-minium')) {
|
|
36
|
+
setTimeout(() => {
|
|
37
|
+
const maxiumWidth = $('#' + this.id).width();
|
|
38
|
+
if (maxiumWidth > 0) {
|
|
39
|
+
$('#' + this.id).attr('data-width', maxiumWidth);
|
|
40
|
+
}
|
|
41
|
+
$('#' + this.id).removeClass('c-closed');
|
|
42
|
+
}, 100);
|
|
43
|
+
}
|
|
44
|
+
this.maxium();
|
|
45
|
+
};
|
|
46
|
+
this.close = () => {
|
|
47
|
+
this.ref.markForCheck();
|
|
48
|
+
this.isOpened = false;
|
|
49
|
+
setTimeout(() => {
|
|
50
|
+
$('#' + this.id).css({ width: '0px', right: '0px' }).removeClass('c-minium').addClass('c-closed');
|
|
51
|
+
}, 100);
|
|
52
|
+
this.stopLoading();
|
|
53
|
+
__classPrivateFieldGet(this, _drawMiniumBar).call(this);
|
|
54
|
+
};
|
|
55
|
+
this.minium = () => {
|
|
56
|
+
this.ref.markForCheck();
|
|
57
|
+
this.isMinium = true;
|
|
58
|
+
// console.log('MINIUM isMinium' + this.id, this.isMinium);
|
|
59
|
+
__classPrivateFieldGet(this, _drawMiniumBar).call(this);
|
|
60
|
+
};
|
|
61
|
+
this.maxium = () => {
|
|
62
|
+
this.ref.markForCheck();
|
|
63
|
+
this.isMinium = false;
|
|
64
|
+
// console.log('MAXIUM isMinium' + this.id, this.isMinium);
|
|
65
|
+
__classPrivateFieldGet(this, _drawMiniumBar).call(this);
|
|
66
|
+
};
|
|
67
|
+
_drawMiniumBar.set(this, () => {
|
|
68
|
+
setTimeout(() => {
|
|
69
|
+
let totalRight = 8;
|
|
70
|
+
const miniumWidth = 300;
|
|
71
|
+
$('.modal-custom').each((index, item) => {
|
|
72
|
+
if ($(item).hasClass('c-minium')) {
|
|
73
|
+
$(item).css({ width: 300 + 'px', right: totalRight + 'px' });
|
|
74
|
+
totalRight += miniumWidth + 8;
|
|
75
|
+
}
|
|
76
|
+
else if (!$(item).hasClass('c-closed')) {
|
|
77
|
+
const maxiumWidth = parseInt($(item).attr('data-width'), 0);
|
|
78
|
+
if (maxiumWidth > 0) {
|
|
79
|
+
$(item).css({ width: maxiumWidth + 'px', right: totalRight + 'px' });
|
|
80
|
+
totalRight += maxiumWidth + 8;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}, 100);
|
|
85
|
+
});
|
|
86
|
+
this.startLoading = () => {
|
|
87
|
+
this.isLoading = true;
|
|
88
|
+
this.loadingService.stop();
|
|
89
|
+
this.loadingService.start(`#${this.id}`);
|
|
90
|
+
};
|
|
91
|
+
this.stopLoading = () => {
|
|
92
|
+
this.isLoading = false;
|
|
93
|
+
this.loadingService.stop();
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
ngAfterViewInit() {
|
|
97
|
+
__classPrivateFieldSet(this, _embeddedViewRef, new DomPortalOutlet(document.body, this.cfr, this.ar, this.injector).attachTemplatePortal(this.portal));
|
|
98
|
+
}
|
|
99
|
+
ngOnDestroy() {
|
|
100
|
+
__classPrivateFieldGet(this, _embeddedViewRef).destroy();
|
|
101
|
+
}
|
|
102
|
+
toggleEditable() {
|
|
103
|
+
this.isEditing = !this.isEditing;
|
|
104
|
+
this.editingChanged.emit(this.isEditing);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
_embeddedViewRef = new WeakMap(), _drawMiniumBar = new WeakMap();
|
|
108
|
+
SdModalCustom.decorators = [
|
|
109
|
+
{ type: Component, args: [{
|
|
110
|
+
selector: 'sd-modal-custom',
|
|
111
|
+
template: "<ng-template cdkPortal>\r\n <div [id]=\"id\" class=\"modal-custom\" [ngStyle]=\"{'width': width}\"\r\n [ngClass]=\"{'modal-custom--active': isOpened,'modal-custom--loading': isLoading, 'c-minium': isMinium}\"\r\n (mouseover)=\"isHover = true\" (mouseout)=\"isHover = false\">\r\n <ng-container *ngIf=\"isOpened\">\r\n <div class=\"modal-custom__header media align-items-center\">\r\n <div class=\"modal-custom__title media-body\">\r\n <ng-content select=\"[sdTitle]\"></ng-content>\r\n </div>\r\n <button type=\"button\" class=\"c-action--white c-min\" (click)=\"minium()\" *ngIf=\"!isMinium\" mat-icon-button\r\n title=\"Thu nh\u1ECF\">\r\n <mat-icon>remove</mat-icon>\r\n </button>\r\n <button type=\"button\" class=\"c-action--white c-max\" (click)=\"maxium()\" *ngIf=\"isMinium\" mat-icon-button\r\n title=\"Ph\u00F3ng to\">\r\n <mat-icon>remove</mat-icon>\r\n </button>\r\n <button type=\"button\" class=\"c-action--white\" (click)=\"close()\" mat-icon-button title=\"\u0110\u00F3ng\">\r\n <mat-icon>close</mat-icon>\r\n </button>\r\n </div>\r\n <div *ngIf=\"isOpened\" class=\"modal-custom__body\">\r\n <div class=\"modal-custom__content\">\r\n <ng-content select=\"[sdBody]\"></ng-content>\r\n </div>\r\n </div>\r\n <div class=\"modal-custom__footer\">\r\n <ng-content select=\"[sdFooter]\"></ng-content>\r\n </div>\r\n </ng-container>\r\n </div>\r\n</ng-template>",
|
|
112
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
113
|
+
styles: [".modal-custom{background-color:#fff;border-radius:4px 4px 0 0;bottom:0;box-shadow:0 .4px .8px rgba(0,0,0,.1),0 3px 6px rgba(0,0,0,.2);display:flex;flex-direction:column;opacity:0;pointer-events:none;position:fixed;right:12px;top:80px;transform:translate3d(0,100%,0);transition:all .3s ease-in-out;visibility:hidden;z-index:999}.modal-custom button.c-action--white:focus{outline:none!important}.modal-custom.c-minium-of-list{bottom:0;opacity:1;pointer-events:all;top:auto;transform:translateZ(0);visibility:visible}.modal-custom.c-minium{top:auto}.modal-custom.c-minium .modal-custom__body,.modal-custom.c-minium .modal-custom__footer{display:none}.c-action{color:#212121}.c-action:focus{outline:none}.c-action--white{color:#fff}.c-action--white.c-min{margin-bottom:-12px}.c-action--white.c-max{margin-top:-12px}.modal-custom__icon{background:transparent;border:0;color:#212121;outline:none;overflow:hidden}.modal-custom__icon .mat-icon{float:left}.modal-custom__header{background-color:#5d6165;border-radius:4px 4px 0 0;color:#fff;min-height:40px;padding:0 16px}.modal-custom__body{flex:1;position:relative}.modal-custom__content{bottom:0;left:0;overflow:auto;padding:8px 16px 16px;position:absolute;right:0;top:0}.modal-custom__footer{border-top:1px solid #dde0e5;padding:5px 0}.modal-custom-backdrop{background:none;border:0;bottom:0;height:100%;left:0;outline:none!important;position:fixed;right:0;top:0;transition:all .3s ease-in-out;width:100%;z-index:99}.modal-custom-backdrop--active{background-color:rgba(0,0,0,.4)}.modal-custom--active{opacity:1;pointer-events:all;transform:translateZ(0);visibility:visible}.modal-custom__title{font-size:14px;font-weight:500;line-height:20px}"]
|
|
114
|
+
},] }
|
|
115
|
+
];
|
|
116
|
+
SdModalCustom.ctorParameters = () => [
|
|
117
|
+
{ type: ComponentFactoryResolver },
|
|
118
|
+
{ type: ApplicationRef },
|
|
119
|
+
{ type: Injector },
|
|
120
|
+
{ type: ChangeDetectorRef },
|
|
121
|
+
{ type: SdLoadingService }
|
|
122
|
+
];
|
|
123
|
+
SdModalCustom.propDecorators = {
|
|
124
|
+
portal: [{ type: ViewChild, args: [CdkPortal,] }],
|
|
125
|
+
editable: [{ type: Input }],
|
|
126
|
+
width: [{ type: Input }],
|
|
127
|
+
editingChanged: [{ type: Output }]
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
class SdModalCustomModule {
|
|
131
|
+
}
|
|
132
|
+
SdModalCustomModule.decorators = [
|
|
133
|
+
{ type: NgModule, args: [{
|
|
134
|
+
imports: [
|
|
135
|
+
CommonModule,
|
|
136
|
+
MatIconModule,
|
|
137
|
+
MatDialogModule,
|
|
138
|
+
MatButtonModule,
|
|
139
|
+
SdButtonModule,
|
|
140
|
+
PortalModule
|
|
141
|
+
],
|
|
142
|
+
declarations: [
|
|
143
|
+
SdModalCustom
|
|
144
|
+
],
|
|
145
|
+
exports: [
|
|
146
|
+
SdModalCustom
|
|
147
|
+
],
|
|
148
|
+
providers: []
|
|
149
|
+
},] }
|
|
150
|
+
];
|
|
151
|
+
|
|
152
|
+
/*
|
|
153
|
+
* Public API Surface of superdev-angular-core
|
|
154
|
+
*/
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Generated bundle index. Do not edit.
|
|
158
|
+
*/
|
|
159
|
+
|
|
160
|
+
export { SdModalCustom, SdModalCustomModule };
|
|
161
|
+
//# sourceMappingURL=sd-angular-core-modal-custom.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sd-angular-core-modal-custom.js","sources":["../../../../projects/sd-core/modal-custom/src/lib/modal-custom/modal-custom.component.ts","../../../../projects/sd-core/modal-custom/src/lib/modal-custom.module.ts","../../../../projects/sd-core/modal-custom/src/public-api.ts","../../../../projects/sd-core/modal-custom/sd-angular-core-modal-custom.ts"],"sourcesContent":["import {\r\n Component,\r\n ViewChild,\r\n ComponentFactoryResolver,\r\n ApplicationRef,\r\n Injector,\r\n EmbeddedViewRef,\r\n AfterViewInit,\r\n OnDestroy,\r\n Input,\r\n Output,\r\n EventEmitter,\r\n ChangeDetectionStrategy,\r\n ChangeDetectorRef,\r\n} from '@angular/core';\r\nimport {CdkPortal, DomPortalOutlet} from '@angular/cdk/portal';\r\nimport * as uuid from 'uuid';\r\nimport {SdLoadingService} from '@sd-angular/core/loading';\r\nimport $ from 'jquery';\r\n\r\n@Component({\r\n selector: 'sd-modal-custom',\r\n templateUrl: './modal-custom.component.html',\r\n styleUrls: ['./modal-custom.component.scss'],\r\n changeDetection: ChangeDetectionStrategy.OnPush\r\n})\r\nexport class SdModalCustom implements AfterViewInit, OnDestroy {\r\n id = `I${uuid.v4()}`;\r\n @ViewChild(CdkPortal) portal: CdkPortal;\r\n @Input() editable: boolean;\r\n @Input() width = '480px';\r\n @Output() editingChanged = new EventEmitter<boolean>();\r\n #embeddedViewRef: EmbeddedViewRef<any>;\r\n isEditing = false;\r\n isOpened = false;\r\n isHover = false;\r\n isLoading = false;\r\n isMinium = false;\r\n\r\n constructor(\r\n private cfr: ComponentFactoryResolver,\r\n private ar: ApplicationRef,\r\n private injector: Injector,\r\n private ref: ChangeDetectorRef,\r\n private loadingService: SdLoadingService\r\n ) {\r\n }\r\n\r\n ngAfterViewInit() {\r\n this.#embeddedViewRef = new DomPortalOutlet(\r\n document.body,\r\n this.cfr,\r\n this.ar,\r\n this.injector\r\n ).attachTemplatePortal(this.portal);\r\n }\r\n\r\n open = () => {\r\n this.ref.markForCheck();\r\n this.isOpened = true;\r\n // console.log('OPEN isMinium' + this.id, this.isMinium);\r\n\r\n // tinh toan width maxium lần đầu khi không ở trạng thái minium\r\n if (!$('#' + this.id).hasClass('c-minium')) {\r\n setTimeout(() => {\r\n const maxiumWidth = $('#' + this.id).width();\r\n if (maxiumWidth > 0) {\r\n $('#' + this.id).attr('data-width', maxiumWidth);\r\n }\r\n $('#' + this.id).removeClass('c-closed');\r\n }, 100);\r\n }\r\n\r\n this.maxium();\r\n }\r\n\r\n close = () => {\r\n this.ref.markForCheck();\r\n this.isOpened = false;\r\n setTimeout(() => {\r\n $('#' + this.id).css({width: '0px', right: '0px'}).removeClass('c-minium').addClass('c-closed');\r\n }, 100);\r\n this.stopLoading();\r\n\r\n this.#drawMiniumBar();\r\n }\r\n\r\n minium = () => {\r\n this.ref.markForCheck();\r\n this.isMinium = true;\r\n // console.log('MINIUM isMinium' + this.id, this.isMinium);\r\n this.#drawMiniumBar();\r\n }\r\n\r\n maxium = () => {\r\n this.ref.markForCheck();\r\n this.isMinium = false;\r\n // console.log('MAXIUM isMinium' + this.id, this.isMinium);\r\n this.#drawMiniumBar();\r\n }\r\n\r\n #drawMiniumBar = () => {\r\n setTimeout(() => {\r\n let totalRight = 8;\r\n const miniumWidth = 300;\r\n $('.modal-custom').each((index, item) => {\r\n if ($(item).hasClass('c-minium')) {\r\n $(item).css({width: 300 + 'px', right: totalRight + 'px'});\r\n totalRight += miniumWidth + 8;\r\n } else if (!$(item).hasClass('c-closed')) {\r\n const maxiumWidth = parseInt($(item).attr('data-width'), 0);\r\n if (maxiumWidth > 0) {\r\n $(item).css({width: maxiumWidth + 'px', right: totalRight + 'px'});\r\n totalRight += maxiumWidth + 8;\r\n }\r\n }\r\n\r\n });\r\n }, 100);\r\n\r\n }\r\n\r\n startLoading = () => {\r\n this.isLoading = true;\r\n this.loadingService.stop();\r\n this.loadingService.start(`#${this.id}`);\r\n }\r\n\r\n stopLoading = () => {\r\n this.isLoading = false;\r\n this.loadingService.stop();\r\n }\r\n\r\n ngOnDestroy() {\r\n this.#embeddedViewRef.destroy();\r\n }\r\n\r\n toggleEditable() {\r\n this.isEditing = !this.isEditing;\r\n this.editingChanged.emit(this.isEditing);\r\n }\r\n}\r\n","import { NgModule } from '@angular/core';\r\nimport { CommonModule } from '@angular/common';\r\n\r\nimport { MatIconModule } from '@angular/material/icon';\r\nimport { MatDialogModule } from '@angular/material/dialog';\r\nimport { MatButtonModule } from '@angular/material/button';\r\nimport { SdButtonModule } from '@sd-angular/core/button';\r\nimport { SdModalCustom } from './modal-custom/modal-custom.component';\r\nimport { PortalModule } from '@angular/cdk/portal';\r\n\r\n@NgModule({\r\n imports: [\r\n CommonModule,\r\n MatIconModule,\r\n MatDialogModule,\r\n MatButtonModule,\r\n SdButtonModule,\r\n PortalModule\r\n ],\r\n declarations: [\r\n SdModalCustom\r\n ],\r\n exports: [\r\n SdModalCustom\r\n ],\r\n providers: [\r\n ]\r\n})\r\nexport class SdModalCustomModule {\r\n\r\n}\r\n","/*\r\n * Public API Surface of superdev-angular-core\r\n */\r\n\r\nexport * from './lib/modal-custom/modal-custom.component';\r\n\r\nexport * from './lib/modal-custom.module';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["uuid.v4"],"mappings":";;;;;;;;;;;;;MA0Ba,aAAa;IAaxB,YACU,GAA6B,EAC7B,EAAkB,EAClB,QAAkB,EAClB,GAAsB,EACtB,cAAgC;QAJhC,QAAG,GAAH,GAAG,CAA0B;QAC7B,OAAE,GAAF,EAAE,CAAgB;QAClB,aAAQ,GAAR,QAAQ,CAAU;QAClB,QAAG,GAAH,GAAG,CAAmB;QACtB,mBAAc,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AAE;oBACP,YAAY;oBACZ,aAAa;oBACb,eAAe;oBACf,eAAe;oBACf,cAAc;oBACd,YAAY;iBACb;gBACD,YAAY,EAAE;oBACZ,aAAa;iBACd;gBACD,OAAO,EAAE;oBACP,aAAa;iBACd;gBACD,SAAS,EAAE,EACV;aACF;;;AC3BD;;;;ACAA;;;;;;"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { __classPrivateFieldGet, __classPrivateFieldSet } from 'tslib';
|
|
2
|
+
import { EventEmitter, Component, ChangeDetectionStrategy, ComponentFactoryResolver, ApplicationRef, Injector, ChangeDetectorRef, ViewChild, Input, Output, NgModule } from '@angular/core';
|
|
3
|
+
import { DomPortalOutlet, CdkPortal, PortalModule } from '@angular/cdk/portal';
|
|
4
|
+
import { v4 } from 'uuid';
|
|
5
|
+
import { SdLoadingService } from '@sd-angular/core/loading';
|
|
6
|
+
import $ from 'jquery';
|
|
7
|
+
import { CommonModule } from '@angular/common';
|
|
8
|
+
import { MatIconModule } from '@angular/material/icon';
|
|
9
|
+
import { MatDialogModule } from '@angular/material/dialog';
|
|
10
|
+
import { MatButtonModule } from '@angular/material/button';
|
|
11
|
+
import { SdButtonModule } from '@sd-angular/core/button';
|
|
12
|
+
|
|
13
|
+
var _embeddedViewRef, _drawMiniumBar;
|
|
14
|
+
class SdModalResizable {
|
|
15
|
+
constructor(cfr, ar, injector, ref, loadingService) {
|
|
16
|
+
this.cfr = cfr;
|
|
17
|
+
this.ar = ar;
|
|
18
|
+
this.injector = injector;
|
|
19
|
+
this.ref = ref;
|
|
20
|
+
this.loadingService = loadingService;
|
|
21
|
+
this.id = `I${v4()}`;
|
|
22
|
+
this.width = '480px';
|
|
23
|
+
this.editingChanged = new EventEmitter();
|
|
24
|
+
_embeddedViewRef.set(this, void 0);
|
|
25
|
+
this.isEditing = false;
|
|
26
|
+
this.isOpened = false;
|
|
27
|
+
this.isHover = false;
|
|
28
|
+
this.isLoading = false;
|
|
29
|
+
this.isMinium = false;
|
|
30
|
+
this.open = () => {
|
|
31
|
+
this.ref.markForCheck();
|
|
32
|
+
this.isOpened = true;
|
|
33
|
+
// console.log('OPEN isMinium' + this.id, this.isMinium);
|
|
34
|
+
// tinh toan width maxium lần đầu khi không ở trạng thái minium
|
|
35
|
+
if (!$('#' + this.id).hasClass('c-minium')) {
|
|
36
|
+
setTimeout(() => {
|
|
37
|
+
const maxiumWidth = $('#' + this.id).width();
|
|
38
|
+
if (maxiumWidth > 0) {
|
|
39
|
+
$('#' + this.id).attr('data-width', maxiumWidth);
|
|
40
|
+
}
|
|
41
|
+
$('#' + this.id).removeClass('c-closed');
|
|
42
|
+
}, 100);
|
|
43
|
+
}
|
|
44
|
+
this.maxium();
|
|
45
|
+
};
|
|
46
|
+
this.close = () => {
|
|
47
|
+
this.ref.markForCheck();
|
|
48
|
+
this.isOpened = false;
|
|
49
|
+
setTimeout(() => {
|
|
50
|
+
$('#' + this.id).css({ width: '0px', right: '0px' }).removeClass('c-minium').addClass('c-closed');
|
|
51
|
+
}, 100);
|
|
52
|
+
this.stopLoading();
|
|
53
|
+
__classPrivateFieldGet(this, _drawMiniumBar).call(this);
|
|
54
|
+
};
|
|
55
|
+
this.minium = () => {
|
|
56
|
+
this.ref.markForCheck();
|
|
57
|
+
this.isMinium = true;
|
|
58
|
+
// console.log('MINIUM isMinium' + this.id, this.isMinium);
|
|
59
|
+
__classPrivateFieldGet(this, _drawMiniumBar).call(this);
|
|
60
|
+
};
|
|
61
|
+
this.maxium = () => {
|
|
62
|
+
this.ref.markForCheck();
|
|
63
|
+
this.isMinium = false;
|
|
64
|
+
// console.log('MAXIUM isMinium' + this.id, this.isMinium);
|
|
65
|
+
__classPrivateFieldGet(this, _drawMiniumBar).call(this);
|
|
66
|
+
};
|
|
67
|
+
_drawMiniumBar.set(this, () => {
|
|
68
|
+
setTimeout(() => {
|
|
69
|
+
let totalRight = 8;
|
|
70
|
+
const miniumWidth = 300;
|
|
71
|
+
$('.modal-custom').each((index, item) => {
|
|
72
|
+
if ($(item).hasClass('c-minium')) {
|
|
73
|
+
$(item).css({ width: 300 + 'px', right: totalRight + 'px' });
|
|
74
|
+
totalRight += miniumWidth + 8;
|
|
75
|
+
}
|
|
76
|
+
else if (!$(item).hasClass('c-closed')) {
|
|
77
|
+
const maxiumWidth = parseInt($(item).attr('data-width'), 0);
|
|
78
|
+
if (maxiumWidth > 0) {
|
|
79
|
+
$(item).css({ width: maxiumWidth + 'px', right: totalRight + 'px' });
|
|
80
|
+
totalRight += maxiumWidth + 8;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}, 100);
|
|
85
|
+
});
|
|
86
|
+
this.startLoading = () => {
|
|
87
|
+
this.isLoading = true;
|
|
88
|
+
this.loadingService.stop();
|
|
89
|
+
this.loadingService.start(`#${this.id}`);
|
|
90
|
+
};
|
|
91
|
+
this.stopLoading = () => {
|
|
92
|
+
this.isLoading = false;
|
|
93
|
+
this.loadingService.stop();
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
ngAfterViewInit() {
|
|
97
|
+
__classPrivateFieldSet(this, _embeddedViewRef, new DomPortalOutlet(document.body, this.cfr, this.ar, this.injector).attachTemplatePortal(this.portal));
|
|
98
|
+
}
|
|
99
|
+
ngOnDestroy() {
|
|
100
|
+
__classPrivateFieldGet(this, _embeddedViewRef).destroy();
|
|
101
|
+
}
|
|
102
|
+
toggleEditable() {
|
|
103
|
+
this.isEditing = !this.isEditing;
|
|
104
|
+
this.editingChanged.emit(this.isEditing);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
_embeddedViewRef = new WeakMap(), _drawMiniumBar = new WeakMap();
|
|
108
|
+
SdModalResizable.decorators = [
|
|
109
|
+
{ type: Component, args: [{
|
|
110
|
+
selector: 'sd-modal-resizable',
|
|
111
|
+
template: "<ng-template cdkPortal>\r\n <div [id]=\"id\" class=\"modal-custom\" [ngStyle]=\"{'width': width}\"\r\n [ngClass]=\"{'modal-custom--active': isOpened,'modal-custom--loading': isLoading, 'c-minium': isMinium}\"\r\n (mouseover)=\"isHover = true\" (mouseout)=\"isHover = false\">\r\n <ng-container *ngIf=\"isOpened\">\r\n <div class=\"modal-custom__header media align-items-center\">\r\n <div class=\"modal-custom__title media-body\">\r\n <ng-content select=\"[sdTitle]\"></ng-content>\r\n </div>\r\n <button type=\"button\" class=\"c-action--white c-min\" (click)=\"minium()\" *ngIf=\"!isMinium\" mat-icon-button\r\n title=\"Thu nh\u1ECF\">\r\n <mat-icon>remove</mat-icon>\r\n </button>\r\n <button type=\"button\" class=\"c-action--white c-max\" (click)=\"maxium()\" *ngIf=\"isMinium\" mat-icon-button\r\n title=\"Ph\u00F3ng to\">\r\n <mat-icon>remove</mat-icon>\r\n </button>\r\n <button type=\"button\" class=\"c-action--white\" (click)=\"close()\" mat-icon-button title=\"\u0110\u00F3ng\">\r\n <mat-icon>close</mat-icon>\r\n </button>\r\n </div>\r\n <div *ngIf=\"isOpened\" class=\"modal-custom__body\">\r\n <div class=\"modal-custom__content\">\r\n <ng-content select=\"[sdBody]\"></ng-content>\r\n </div>\r\n </div>\r\n <div class=\"modal-custom__footer\">\r\n <ng-content select=\"[sdFooter]\"></ng-content>\r\n </div>\r\n </ng-container>\r\n </div>\r\n</ng-template>",
|
|
112
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
113
|
+
styles: [".modal-custom{background-color:#fff;border-radius:4px 4px 0 0;bottom:0;box-shadow:0 .4px .8px rgba(0,0,0,.1),0 3px 6px rgba(0,0,0,.2);display:flex;flex-direction:column;opacity:0;pointer-events:none;position:fixed;right:12px;top:80px;transform:translate3d(0,100%,0);transition:all .3s ease-in-out;visibility:hidden;z-index:999}.modal-custom button.c-action--white:focus{outline:none!important}.modal-custom.c-minium-of-list{bottom:0;opacity:1;pointer-events:all;top:auto;transform:translateZ(0);visibility:visible}.modal-custom.c-minium{top:auto}.modal-custom.c-minium .modal-custom__body,.modal-custom.c-minium .modal-custom__footer{display:none}.c-action{color:#212121}.c-action:focus{outline:none}.c-action--white{color:#fff}.c-action--white.c-min{margin-bottom:-12px}.c-action--white.c-max{margin-top:-12px}.modal-custom__icon{background:transparent;border:0;color:#212121;outline:none;overflow:hidden}.modal-custom__icon .mat-icon{float:left}.modal-custom__header{background-color:#5d6165;border-radius:4px 4px 0 0;color:#fff;min-height:40px;padding:0 16px}.modal-custom__body{flex:1;position:relative}.modal-custom__content{bottom:0;left:0;overflow:auto;padding:8px 16px 16px;position:absolute;right:0;top:0}.modal-custom__footer{border-top:1px solid #dde0e5;padding:5px 0}.modal-custom-backdrop{background:none;border:0;bottom:0;height:100%;left:0;outline:none!important;position:fixed;right:0;top:0;transition:all .3s ease-in-out;width:100%;z-index:99}.modal-custom-backdrop--active{background-color:rgba(0,0,0,.4)}.modal-custom--active{opacity:1;pointer-events:all;transform:translateZ(0);visibility:visible}.modal-custom__title{font-size:14px;font-weight:500;line-height:20px}"]
|
|
114
|
+
},] }
|
|
115
|
+
];
|
|
116
|
+
SdModalResizable.ctorParameters = () => [
|
|
117
|
+
{ type: ComponentFactoryResolver },
|
|
118
|
+
{ type: ApplicationRef },
|
|
119
|
+
{ type: Injector },
|
|
120
|
+
{ type: ChangeDetectorRef },
|
|
121
|
+
{ type: SdLoadingService }
|
|
122
|
+
];
|
|
123
|
+
SdModalResizable.propDecorators = {
|
|
124
|
+
portal: [{ type: ViewChild, args: [CdkPortal,] }],
|
|
125
|
+
editable: [{ type: Input }],
|
|
126
|
+
width: [{ type: Input }],
|
|
127
|
+
editingChanged: [{ type: Output }]
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
class SdModalResizableModule {
|
|
131
|
+
}
|
|
132
|
+
SdModalResizableModule.decorators = [
|
|
133
|
+
{ type: NgModule, args: [{
|
|
134
|
+
imports: [
|
|
135
|
+
CommonModule,
|
|
136
|
+
MatIconModule,
|
|
137
|
+
MatDialogModule,
|
|
138
|
+
MatButtonModule,
|
|
139
|
+
SdButtonModule,
|
|
140
|
+
PortalModule
|
|
141
|
+
],
|
|
142
|
+
declarations: [
|
|
143
|
+
SdModalResizable
|
|
144
|
+
],
|
|
145
|
+
exports: [
|
|
146
|
+
SdModalResizable
|
|
147
|
+
],
|
|
148
|
+
providers: []
|
|
149
|
+
},] }
|
|
150
|
+
];
|
|
151
|
+
|
|
152
|
+
/*
|
|
153
|
+
* Public API Surface of superdev-angular-core
|
|
154
|
+
*/
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Generated bundle index. Do not edit.
|
|
158
|
+
*/
|
|
159
|
+
|
|
160
|
+
export { SdModalResizable, SdModalResizableModule };
|
|
161
|
+
//# sourceMappingURL=sd-angular-core-modal-resizable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sd-angular-core-modal-resizable.js","sources":["../../../../projects/sd-core/modal-resizable/src/lib/modal-resizable/modal-resizable.component.ts","../../../../projects/sd-core/modal-resizable/src/lib/modal-resizable.module.ts","../../../../projects/sd-core/modal-resizable/src/public-api.ts","../../../../projects/sd-core/modal-resizable/sd-angular-core-modal-resizable.ts"],"sourcesContent":["import {\r\n Component,\r\n ViewChild,\r\n ComponentFactoryResolver,\r\n ApplicationRef,\r\n Injector,\r\n EmbeddedViewRef,\r\n AfterViewInit,\r\n OnDestroy,\r\n Input,\r\n Output,\r\n EventEmitter,\r\n ChangeDetectionStrategy,\r\n ChangeDetectorRef,\r\n} from '@angular/core';\r\nimport {CdkPortal, DomPortalOutlet} from '@angular/cdk/portal';\r\nimport * as uuid from 'uuid';\r\nimport {SdLoadingService} from '@sd-angular/core/loading';\r\nimport $ from 'jquery';\r\n\r\n@Component({\r\n selector: 'sd-modal-resizable',\r\n templateUrl: './modal-resizable.component.html',\r\n styleUrls: ['./modal-resizable.component.scss'],\r\n changeDetection: ChangeDetectionStrategy.OnPush\r\n})\r\nexport class SdModalResizable implements AfterViewInit, OnDestroy {\r\n id = `I${uuid.v4()}`;\r\n @ViewChild(CdkPortal) portal: CdkPortal;\r\n @Input() editable: boolean;\r\n @Input() width = '480px';\r\n @Output() editingChanged = new EventEmitter<boolean>();\r\n #embeddedViewRef: EmbeddedViewRef<any>;\r\n isEditing = false;\r\n isOpened = false;\r\n isHover = false;\r\n isLoading = false;\r\n isMinium = false;\r\n\r\n constructor(\r\n private cfr: ComponentFactoryResolver,\r\n private ar: ApplicationRef,\r\n private injector: Injector,\r\n private ref: ChangeDetectorRef,\r\n private loadingService: SdLoadingService\r\n ) {\r\n }\r\n\r\n ngAfterViewInit() {\r\n this.#embeddedViewRef = new DomPortalOutlet(\r\n document.body,\r\n this.cfr,\r\n this.ar,\r\n this.injector\r\n ).attachTemplatePortal(this.portal);\r\n }\r\n\r\n open = () => {\r\n this.ref.markForCheck();\r\n this.isOpened = true;\r\n // console.log('OPEN isMinium' + this.id, this.isMinium);\r\n\r\n // tinh toan width maxium lần đầu khi không ở trạng thái minium\r\n if (!$('#' + this.id).hasClass('c-minium')) {\r\n setTimeout(() => {\r\n const maxiumWidth = $('#' + this.id).width();\r\n if (maxiumWidth > 0) {\r\n $('#' + this.id).attr('data-width', maxiumWidth);\r\n }\r\n $('#' + this.id).removeClass('c-closed');\r\n }, 100);\r\n }\r\n\r\n this.maxium();\r\n }\r\n\r\n close = () => {\r\n this.ref.markForCheck();\r\n this.isOpened = false;\r\n setTimeout(() => {\r\n $('#' + this.id).css({width: '0px', right: '0px'}).removeClass('c-minium').addClass('c-closed');\r\n }, 100);\r\n this.stopLoading();\r\n\r\n this.#drawMiniumBar();\r\n }\r\n\r\n minium = () => {\r\n this.ref.markForCheck();\r\n this.isMinium = true;\r\n // console.log('MINIUM isMinium' + this.id, this.isMinium);\r\n this.#drawMiniumBar();\r\n }\r\n\r\n maxium = () => {\r\n this.ref.markForCheck();\r\n this.isMinium = false;\r\n // console.log('MAXIUM isMinium' + this.id, this.isMinium);\r\n this.#drawMiniumBar();\r\n }\r\n\r\n #drawMiniumBar = () => {\r\n setTimeout(() => {\r\n let totalRight = 8;\r\n const miniumWidth = 300;\r\n $('.modal-custom').each((index, item) => {\r\n if ($(item).hasClass('c-minium')) {\r\n $(item).css({width: 300 + 'px', right: totalRight + 'px'});\r\n totalRight += miniumWidth + 8;\r\n } else if (!$(item).hasClass('c-closed')) {\r\n const maxiumWidth = parseInt($(item).attr('data-width'), 0);\r\n if (maxiumWidth > 0) {\r\n $(item).css({width: maxiumWidth + 'px', right: totalRight + 'px'});\r\n totalRight += maxiumWidth + 8;\r\n }\r\n }\r\n\r\n });\r\n }, 100);\r\n\r\n }\r\n\r\n startLoading = () => {\r\n this.isLoading = true;\r\n this.loadingService.stop();\r\n this.loadingService.start(`#${this.id}`);\r\n }\r\n\r\n stopLoading = () => {\r\n this.isLoading = false;\r\n this.loadingService.stop();\r\n }\r\n\r\n ngOnDestroy() {\r\n this.#embeddedViewRef.destroy();\r\n }\r\n\r\n toggleEditable() {\r\n this.isEditing = !this.isEditing;\r\n this.editingChanged.emit(this.isEditing);\r\n }\r\n}\r\n","import { NgModule } from '@angular/core';\r\nimport { CommonModule } from '@angular/common';\r\n\r\nimport { MatIconModule } from '@angular/material/icon';\r\nimport { MatDialogModule } from '@angular/material/dialog';\r\nimport { MatButtonModule } from '@angular/material/button';\r\nimport { SdButtonModule } from '@sd-angular/core/button';\r\nimport { SdModalResizable } from './modal-resizable/modal-resizable.component';\r\nimport { PortalModule } from '@angular/cdk/portal';\r\n\r\n@NgModule({\r\n imports: [\r\n CommonModule,\r\n MatIconModule,\r\n MatDialogModule,\r\n MatButtonModule,\r\n SdButtonModule,\r\n PortalModule\r\n ],\r\n declarations: [\r\n SdModalResizable\r\n ],\r\n exports: [\r\n SdModalResizable\r\n ],\r\n providers: [\r\n ]\r\n})\r\nexport class SdModalResizableModule {\r\n\r\n}\r\n","/*\r\n * Public API Surface of superdev-angular-core\r\n */\r\n\r\nexport * from './lib/modal-resizable/modal-resizable.component';\r\n\r\nexport * from './lib/modal-resizable.module';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["uu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oB;gBAC9B,+hDAA+C;gBAE/C,eAAe,EAAE,uBAAuB,CAAC,MAAM;;aAChD;;;YAtBC,wBAAwB;YACxB,cAAc;YACd,QAAQ;YAQR,iBAAiB;YAIX,gBAAgB;;;qBAWrB,SAAS,SAAC,SAAS;uBACnB,KAAK;oBACL,KAAK;6BACL,MAAM;;;MCHI,sBAAsB;;;YAlBlC,QAAQ,SAAC;gBACR,OAAO,EAAE;oBACP,YAAY;oBACZ,aAAa;oBACb,eAAe;oBACf,eAAe;oBACf,cAAc;oBACd,YAAY;iBACb;gBACD,YAAY,EAAE;oBACZ,gBAAgB;iBACjB;gBACD,OAAO,EAAE;oBACP,gBAAgB;iBACjB;gBACD,SAAS,EAAE,EACV;aACF;;;AC3BD;;;;ACAA;;;;;;"}
|
|
@@ -1,34 +1,25 @@
|
|
|
1
1
|
import { InjectionToken, ɵɵdefineInjectable, ɵɵinject, Injectable, Inject, Optional } from '@angular/core';
|
|
2
|
-
import {
|
|
2
|
+
import { __classPrivateFieldGet, __awaiter } from 'tslib';
|
|
3
3
|
import hash from 'object-hash';
|
|
4
|
-
import {
|
|
4
|
+
import { BehaviorSubject } from 'rxjs';
|
|
5
5
|
import { startWith, switchMap } from 'rxjs/operators';
|
|
6
6
|
|
|
7
7
|
const SETTING_CONFIG = new InjectionToken('setting.configuration');
|
|
8
8
|
|
|
9
|
-
var _cache, _subject, _get, _set, _has, _remove;
|
|
9
|
+
var _cache, _subject, _get, _getServer, _set, _setServer, _has, _hasServer, _remove, _removeServer;
|
|
10
10
|
class SdSettingService {
|
|
11
11
|
constructor(configuration) {
|
|
12
12
|
this.configuration = configuration;
|
|
13
13
|
_cache.set(this, {});
|
|
14
14
|
_subject.set(this, {});
|
|
15
15
|
_get.set(this, (key, option) => {
|
|
16
|
-
return () =>
|
|
17
|
-
var _a;
|
|
16
|
+
return () => {
|
|
18
17
|
let cache = __classPrivateFieldGet(this, _cache)[key];
|
|
19
18
|
if ((option === null || option === void 0 ? void 0 : option.type) === 'session') {
|
|
20
19
|
try {
|
|
21
20
|
cache = JSON.parse(sessionStorage.getItem(key));
|
|
22
21
|
}
|
|
23
|
-
catch (
|
|
24
|
-
cache = undefined;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
else if ((option === null || option === void 0 ? void 0 : option.type) === 'server') {
|
|
28
|
-
try {
|
|
29
|
-
cache = yield ((_a = this.configuration) === null || _a === void 0 ? void 0 : _a.get(key, option));
|
|
30
|
-
}
|
|
31
|
-
catch (_c) {
|
|
22
|
+
catch (_a) {
|
|
32
23
|
cache = undefined;
|
|
33
24
|
}
|
|
34
25
|
}
|
|
@@ -36,7 +27,7 @@ class SdSettingService {
|
|
|
36
27
|
try {
|
|
37
28
|
cache = JSON.parse(localStorage.getItem(key));
|
|
38
29
|
}
|
|
39
|
-
catch (
|
|
30
|
+
catch (_b) {
|
|
40
31
|
cache = undefined;
|
|
41
32
|
}
|
|
42
33
|
}
|
|
@@ -44,11 +35,26 @@ class SdSettingService {
|
|
|
44
35
|
return option === null || option === void 0 ? void 0 : option.default;
|
|
45
36
|
}
|
|
46
37
|
return JSON.parse(JSON.stringify(cache.data));
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
_getServer.set(this, (key, option) => {
|
|
41
|
+
return () => __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
var _a;
|
|
43
|
+
let cache = __classPrivateFieldGet(this, _cache)[key];
|
|
44
|
+
try {
|
|
45
|
+
cache = yield ((_a = this.configuration) === null || _a === void 0 ? void 0 : _a.get(key, option));
|
|
46
|
+
}
|
|
47
|
+
catch (_b) {
|
|
48
|
+
cache = undefined;
|
|
49
|
+
}
|
|
50
|
+
if (!cache) {
|
|
51
|
+
return option === null || option === void 0 ? void 0 : option.default;
|
|
52
|
+
}
|
|
53
|
+
return JSON.parse(JSON.stringify(cache.data));
|
|
47
54
|
});
|
|
48
55
|
});
|
|
49
56
|
_set.set(this, (key, option) => {
|
|
50
|
-
return (data) =>
|
|
51
|
-
var _a;
|
|
57
|
+
return (data) => {
|
|
52
58
|
__classPrivateFieldGet(this, _cache)[key] = {
|
|
53
59
|
data: JSON.parse(JSON.stringify(data)),
|
|
54
60
|
createdOn: new Date()
|
|
@@ -62,15 +68,6 @@ class SdSettingService {
|
|
|
62
68
|
console.error(err);
|
|
63
69
|
}
|
|
64
70
|
}
|
|
65
|
-
else if ((option === null || option === void 0 ? void 0 : option.type) === 'server') {
|
|
66
|
-
try {
|
|
67
|
-
yield ((_a = this.configuration) === null || _a === void 0 ? void 0 : _a.set(key, __classPrivateFieldGet(this, _cache)[key]));
|
|
68
|
-
__classPrivateFieldGet(this, _subject)[key].next(__classPrivateFieldGet(this, _cache)[key].data);
|
|
69
|
-
}
|
|
70
|
-
catch (err) {
|
|
71
|
-
console.error(err);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
71
|
else {
|
|
75
72
|
try {
|
|
76
73
|
localStorage.setItem(key, JSON.stringify(__classPrivateFieldGet(this, _cache)[key]));
|
|
@@ -80,25 +77,32 @@ class SdSettingService {
|
|
|
80
77
|
console.error(err);
|
|
81
78
|
}
|
|
82
79
|
}
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
_setServer.set(this, (key, option) => {
|
|
83
|
+
return (data) => __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
var _a;
|
|
85
|
+
__classPrivateFieldGet(this, _cache)[key] = {
|
|
86
|
+
data: JSON.parse(JSON.stringify(data)),
|
|
87
|
+
createdOn: new Date()
|
|
88
|
+
};
|
|
89
|
+
try {
|
|
90
|
+
yield ((_a = this.configuration) === null || _a === void 0 ? void 0 : _a.set(key, __classPrivateFieldGet(this, _cache)[key]));
|
|
91
|
+
__classPrivateFieldGet(this, _subject)[key].next(__classPrivateFieldGet(this, _cache)[key].data);
|
|
92
|
+
}
|
|
93
|
+
catch (err) {
|
|
94
|
+
console.error(err);
|
|
95
|
+
}
|
|
83
96
|
});
|
|
84
97
|
});
|
|
85
98
|
_has.set(this, (key, option) => {
|
|
86
|
-
return () =>
|
|
87
|
-
var _a;
|
|
99
|
+
return () => {
|
|
88
100
|
let cache = __classPrivateFieldGet(this, _cache)[key];
|
|
89
101
|
if ((option === null || option === void 0 ? void 0 : option.type) === 'session') {
|
|
90
102
|
try {
|
|
91
103
|
cache = JSON.parse(sessionStorage.getItem(key));
|
|
92
104
|
}
|
|
93
|
-
catch (
|
|
94
|
-
cache = undefined;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
else if ((option === null || option === void 0 ? void 0 : option.type) === 'server') {
|
|
98
|
-
try {
|
|
99
|
-
cache = yield ((_a = this.configuration) === null || _a === void 0 ? void 0 : _a.get(key, option));
|
|
100
|
-
}
|
|
101
|
-
catch (_c) {
|
|
105
|
+
catch (_a) {
|
|
102
106
|
cache = undefined;
|
|
103
107
|
}
|
|
104
108
|
}
|
|
@@ -106,7 +110,7 @@ class SdSettingService {
|
|
|
106
110
|
try {
|
|
107
111
|
cache = JSON.parse(localStorage.getItem(key));
|
|
108
112
|
}
|
|
109
|
-
catch (
|
|
113
|
+
catch (_b) {
|
|
110
114
|
cache = undefined;
|
|
111
115
|
}
|
|
112
116
|
}
|
|
@@ -114,18 +118,30 @@ class SdSettingService {
|
|
|
114
118
|
return false;
|
|
115
119
|
}
|
|
116
120
|
return true;
|
|
121
|
+
};
|
|
122
|
+
});
|
|
123
|
+
_hasServer.set(this, (key, option) => {
|
|
124
|
+
return () => __awaiter(this, void 0, void 0, function* () {
|
|
125
|
+
var _a;
|
|
126
|
+
let cache = __classPrivateFieldGet(this, _cache)[key];
|
|
127
|
+
try {
|
|
128
|
+
cache = yield ((_a = this.configuration) === null || _a === void 0 ? void 0 : _a.get(key, option));
|
|
129
|
+
}
|
|
130
|
+
catch (_b) {
|
|
131
|
+
cache = undefined;
|
|
132
|
+
}
|
|
133
|
+
if (!cache) {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
return true;
|
|
117
137
|
});
|
|
118
138
|
});
|
|
119
139
|
_remove.set(this, (key, option) => {
|
|
120
140
|
return () => __awaiter(this, void 0, void 0, function* () {
|
|
121
|
-
var _a;
|
|
122
141
|
try {
|
|
123
142
|
if ((option === null || option === void 0 ? void 0 : option.type) === 'session') {
|
|
124
143
|
sessionStorage.removeItem(key);
|
|
125
144
|
}
|
|
126
|
-
else if ((option === null || option === void 0 ? void 0 : option.type) === 'server') {
|
|
127
|
-
yield ((_a = this.configuration) === null || _a === void 0 ? void 0 : _a.remove(key, option));
|
|
128
|
-
}
|
|
129
145
|
else {
|
|
130
146
|
localStorage.removeItem(key);
|
|
131
147
|
}
|
|
@@ -137,8 +153,55 @@ class SdSettingService {
|
|
|
137
153
|
}
|
|
138
154
|
});
|
|
139
155
|
});
|
|
156
|
+
_removeServer.set(this, (key, option) => {
|
|
157
|
+
return () => __awaiter(this, void 0, void 0, function* () {
|
|
158
|
+
var _a;
|
|
159
|
+
try {
|
|
160
|
+
yield ((_a = this.configuration) === null || _a === void 0 ? void 0 : _a.remove(key, option));
|
|
161
|
+
__classPrivateFieldGet(this, _cache)[key] = undefined;
|
|
162
|
+
__classPrivateFieldGet(this, _subject)[key].next(undefined);
|
|
163
|
+
}
|
|
164
|
+
catch (err) {
|
|
165
|
+
console.error(err);
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
});
|
|
140
169
|
}
|
|
141
170
|
create(key, option) {
|
|
171
|
+
var _a;
|
|
172
|
+
if (!key) {
|
|
173
|
+
throw new Error('Key is required');
|
|
174
|
+
}
|
|
175
|
+
let hashKey = null;
|
|
176
|
+
if (typeof (key) === 'string') {
|
|
177
|
+
hashKey = key;
|
|
178
|
+
}
|
|
179
|
+
else if (typeof (key) === 'object') {
|
|
180
|
+
hashKey = hash(key);
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
throw new Error('Invalid key');
|
|
184
|
+
}
|
|
185
|
+
if ((_a = this.configuration) === null || _a === void 0 ? void 0 : _a.convertKey) {
|
|
186
|
+
hashKey = this.configuration.convertKey(hashKey);
|
|
187
|
+
}
|
|
188
|
+
const get = __classPrivateFieldGet(this, _get).call(this, hashKey, option);
|
|
189
|
+
const set = __classPrivateFieldGet(this, _set).call(this, hashKey, option);
|
|
190
|
+
const has = __classPrivateFieldGet(this, _has).call(this, hashKey, option);
|
|
191
|
+
const remove = __classPrivateFieldGet(this, _remove).call(this, hashKey, option);
|
|
192
|
+
if (!__classPrivateFieldGet(this, _subject)[hashKey]) {
|
|
193
|
+
__classPrivateFieldGet(this, _subject)[hashKey] = new BehaviorSubject(get());
|
|
194
|
+
}
|
|
195
|
+
return {
|
|
196
|
+
get,
|
|
197
|
+
set,
|
|
198
|
+
has,
|
|
199
|
+
remove,
|
|
200
|
+
subject: __classPrivateFieldGet(this, _subject)[hashKey],
|
|
201
|
+
observer: __classPrivateFieldGet(this, _subject)[hashKey].pipe(startWith(__classPrivateFieldGet(this, _subject)[hashKey].getValue()))
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
createServer(key, option) {
|
|
142
205
|
var _a, _b, _c, _d;
|
|
143
206
|
if (!key) {
|
|
144
207
|
throw new Error('Key is required');
|
|
@@ -156,23 +219,21 @@ class SdSettingService {
|
|
|
156
219
|
if ((_a = this.configuration) === null || _a === void 0 ? void 0 : _a.convertKey) {
|
|
157
220
|
hashKey = this.configuration.convertKey(hashKey);
|
|
158
221
|
}
|
|
159
|
-
if ((
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
throw new Error('Please init setting configuration method remove for type server');
|
|
168
|
-
}
|
|
222
|
+
if (!((_b = this.configuration) === null || _b === void 0 ? void 0 : _b.get)) {
|
|
223
|
+
throw new Error('Please init setting configuration method get for type server');
|
|
224
|
+
}
|
|
225
|
+
if (!((_c = this.configuration) === null || _c === void 0 ? void 0 : _c.set)) {
|
|
226
|
+
throw new Error('Please init setting configuration method set for type server');
|
|
227
|
+
}
|
|
228
|
+
if (!((_d = this.configuration) === null || _d === void 0 ? void 0 : _d.remove)) {
|
|
229
|
+
throw new Error('Please init setting configuration method remove for type server');
|
|
169
230
|
}
|
|
170
231
|
if (!__classPrivateFieldGet(this, _subject)[hashKey]) {
|
|
171
|
-
__classPrivateFieldGet(this, _subject)[hashKey] = new
|
|
232
|
+
__classPrivateFieldGet(this, _subject)[hashKey] = new BehaviorSubject(option === null || option === void 0 ? void 0 : option.default);
|
|
172
233
|
}
|
|
173
|
-
const get = __classPrivateFieldGet(this,
|
|
174
|
-
const set = __classPrivateFieldGet(this,
|
|
175
|
-
const has = __classPrivateFieldGet(this,
|
|
234
|
+
const get = __classPrivateFieldGet(this, _getServer).call(this, hashKey, option);
|
|
235
|
+
const set = __classPrivateFieldGet(this, _setServer).call(this, hashKey, option);
|
|
236
|
+
const has = __classPrivateFieldGet(this, _hasServer).call(this, hashKey, option);
|
|
176
237
|
const remove = __classPrivateFieldGet(this, _remove).call(this, hashKey, option);
|
|
177
238
|
return {
|
|
178
239
|
get,
|
|
@@ -180,11 +241,11 @@ class SdSettingService {
|
|
|
180
241
|
has,
|
|
181
242
|
remove,
|
|
182
243
|
subject: __classPrivateFieldGet(this, _subject)[hashKey],
|
|
183
|
-
observer: __classPrivateFieldGet(this, _subject)[hashKey].pipe(startWith(
|
|
244
|
+
observer: __classPrivateFieldGet(this, _subject)[hashKey].pipe(startWith(__classPrivateFieldGet(this, _subject)[hashKey].getValue()), switchMap(get))
|
|
184
245
|
};
|
|
185
246
|
}
|
|
186
247
|
}
|
|
187
|
-
_cache = new WeakMap(), _subject = new WeakMap(), _get = new WeakMap(), _set = new WeakMap(), _has = new WeakMap(), _remove = new WeakMap();
|
|
248
|
+
_cache = new WeakMap(), _subject = new WeakMap(), _get = new WeakMap(), _getServer = new WeakMap(), _set = new WeakMap(), _setServer = new WeakMap(), _has = new WeakMap(), _hasServer = new WeakMap(), _remove = new WeakMap(), _removeServer = new WeakMap();
|
|
188
249
|
SdSettingService.ɵprov = ɵɵdefineInjectable({ factory: function SdSettingService_Factory() { return new SdSettingService(ɵɵinject(SETTING_CONFIG, 8)); }, token: SdSettingService, providedIn: "root" });
|
|
189
250
|
SdSettingService.decorators = [
|
|
190
251
|
{ type: Injectable, args: [{
|