@ts-core/angular 13.0.49 → 13.0.52

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.
@@ -3336,8 +3336,8 @@ class WindowFactory {
3336
3336
  // Constructor
3337
3337
  //
3338
3338
  // --------------------------------------------------------------------------
3339
- constructor(classType) {
3340
- this.classType = classType;
3339
+ constructor(defaultType) {
3340
+ this.defaultType = defaultType;
3341
3341
  }
3342
3342
  // --------------------------------------------------------------------------
3343
3343
  //
@@ -3345,887 +3345,413 @@ class WindowFactory {
3345
3345
  //
3346
3346
  // --------------------------------------------------------------------------
3347
3347
  create(properties) {
3348
- return new this.classType(properties);
3348
+ let item = null;
3349
+ if (!_.isNil(this.createFunction)) {
3350
+ item = this.createFunction(properties);
3351
+ }
3352
+ if (_.isNil(item)) {
3353
+ item = new this.defaultType(properties);
3354
+ }
3355
+ return item;
3349
3356
  }
3350
3357
  }
3351
3358
 
3352
- class WindowBase extends DestroyableContainer {
3359
+ class IWindowContent extends DestroyableContainer {
3353
3360
  // --------------------------------------------------------------------------
3354
3361
  //
3355
- // Constructor
3362
+ // Constructor
3356
3363
  //
3357
3364
  // --------------------------------------------------------------------------
3358
- constructor() {
3365
+ constructor(container) {
3359
3366
  super();
3360
- // --------------------------------------------------------------------------
3361
- //
3362
- // Properties
3363
- //
3364
- // --------------------------------------------------------------------------
3365
- this._x = NaN;
3366
- this._width = NaN;
3367
- this._y = NaN;
3368
- this._height = NaN;
3369
- this.updatePosition = () => this.setPosition();
3367
+ this.container = container;
3370
3368
  }
3371
- setProperties() {
3372
- let config = this.getConfig();
3373
- if (!_.isNaN(config.defaultWidth)) {
3374
- this.width = config.defaultWidth;
3375
- }
3376
- if (!_.isNaN(config.defaultHeight)) {
3377
- this.height = config.defaultHeight;
3378
- }
3369
+ // --------------------------------------------------------------------------
3370
+ //
3371
+ // Private Methods
3372
+ //
3373
+ // --------------------------------------------------------------------------
3374
+ commitWindowProperties() {
3375
+ this.commitConfigProperties();
3379
3376
  }
3380
- setPosition() {
3381
- let config = this.getConfig();
3382
- switch (config.horizontalAlign) {
3383
- case WindowAlign.START:
3384
- this.x = !_.isNaN(this.paddingLeft) ? this.paddingLeft : 0;
3385
- break;
3386
- case WindowAlign.END:
3387
- let value = ViewUtil.getStageWidth() - this.calculateWidth();
3388
- if (!_.isNaN(this.paddingRight)) {
3389
- value -= this.paddingRight;
3390
- }
3391
- this.x = value;
3392
- break;
3393
- default:
3394
- this.x = (ViewUtil.getStageWidth() - this.calculateWidth()) / 2;
3395
- break;
3377
+ commitConfigProperties() { }
3378
+ // --------------------------------------------------------------------------
3379
+ //
3380
+ // Public Methods
3381
+ //
3382
+ // --------------------------------------------------------------------------
3383
+ ngAfterViewInit() {
3384
+ this.emit(WindowEvent.CONTENT_READY);
3385
+ }
3386
+ ngOnDestroy() {
3387
+ // do nothing, window will destroy content after closing
3388
+ }
3389
+ blink() {
3390
+ if (!_.isNil(this.window)) {
3391
+ this.window.blink();
3396
3392
  }
3397
- switch (config.verticalAlign) {
3398
- case WindowAlign.START:
3399
- this.y = !_.isNaN(this.paddingTop) ? this.paddingTop : 0;
3400
- break;
3401
- case WindowAlign.END:
3402
- let value = ViewUtil.getStageHeight() - this.calculateHeight();
3403
- if (!_.isNaN(this.paddingBottom)) {
3404
- value -= this.paddingBottom;
3405
- }
3406
- this.y = value;
3407
- break;
3408
- default:
3409
- this.y = (ViewUtil.getStageHeight() - this.calculateHeight()) / 2;
3410
- break;
3393
+ }
3394
+ shake() {
3395
+ if (!_.isNil(this.window)) {
3396
+ this.window.shake();
3411
3397
  }
3412
3398
  }
3413
- clearSize() {
3414
- this._x = NaN;
3415
- this._y = NaN;
3416
- this._width = NaN;
3417
- this._height = NaN;
3399
+ emit(event) {
3400
+ if (!_.isNil(this.window)) {
3401
+ this.window.emit(event);
3402
+ }
3418
3403
  }
3419
- commitSizeProperties() {
3420
- let width = !_.isNaN(this.width) ? this.width + 'px' : 'auto';
3421
- let height = !_.isNaN(this.height) ? this.height + 'px' : 'auto';
3422
- this.getReference().updateSize(width, height);
3404
+ close() {
3405
+ if (!_.isNil(this.window)) {
3406
+ this.window.close();
3407
+ }
3423
3408
  }
3424
- commitPositionProperties() {
3425
- if (_.isNaN(this._x) && _.isNaN(this._y)) {
3409
+ destroy() {
3410
+ if (this.isDestroyed) {
3426
3411
  return;
3427
3412
  }
3428
- let position = {};
3429
- if (!_.isNaN(this._y)) {
3430
- position.top = this._y + 'px';
3431
- }
3432
- if (!_.isNaN(this._x)) {
3433
- position.left = this._x + 'px';
3434
- }
3435
- this.getReference().updatePosition(position);
3413
+ super.destroy();
3414
+ this.window = null;
3415
+ this.container = null;
3436
3416
  }
3437
3417
  // --------------------------------------------------------------------------
3438
3418
  //
3439
- // Public Methods
3419
+ // Proxy Public Properties
3440
3420
  //
3441
3421
  // --------------------------------------------------------------------------
3442
- calculateWidth() {
3443
- return !_.isNaN(this.width) ? this.width : ViewUtil.getWidth(this.getContainer());
3422
+ get data() {
3423
+ return !_.isNil(this.config) ? this.config.data : null;
3444
3424
  }
3445
- calculateHeight() {
3446
- return !_.isNaN(this.height) ? this.height : ViewUtil.getHeight(this.getContainer());
3425
+ get isOnTop() {
3426
+ return !_.isNil(this.window) ? this.window.isOnTop : false;
3447
3427
  }
3448
- // --------------------------------------------------------------------------
3449
- //
3450
- // Private Properties
3451
- //
3452
- // --------------------------------------------------------------------------
3453
- get width() {
3454
- return this._width;
3428
+ get isMinimized() {
3429
+ return !_.isNil(this.window) ? this.window.isMinimized : false;
3455
3430
  }
3456
- set width(value) {
3457
- value = this.getConfig().parseWidth(value);
3458
- if (value === this._width) {
3459
- return;
3460
- }
3461
- this._width = value;
3462
- this.commitSizeProperties();
3431
+ get events() {
3432
+ return !_.isNil(this.window) ? this.window.events : null;
3463
3433
  }
3464
- get height() {
3465
- return this._height;
3434
+ get isDisabled() {
3435
+ return !_.isNil(this.window) ? this.window.isDisabled : false;
3466
3436
  }
3467
- set height(value) {
3468
- value = this.getConfig().parseHeight(value);
3469
- if (value === this._height) {
3470
- return;
3437
+ set isDisabled(value) {
3438
+ if (!_.isNil(this.window)) {
3439
+ this.window.isDisabled = value;
3471
3440
  }
3472
- this._height = value;
3473
- this.commitSizeProperties();
3474
3441
  }
3475
3442
  // --------------------------------------------------------------------------
3476
3443
  //
3477
- // Public Properties
3444
+ // Public Properties
3478
3445
  //
3479
3446
  // --------------------------------------------------------------------------
3480
- get x() {
3481
- return this._x;
3482
- }
3483
- set x(value) {
3484
- value = this.getConfig().parseX(value);
3485
- if (value === this._x) {
3486
- return;
3447
+ get element() {
3448
+ if (_.isNil(this.container)) {
3449
+ return null;
3487
3450
  }
3488
- this._x = value;
3489
- this.commitPositionProperties();
3451
+ return this.container instanceof ViewContainerRef ? this.container.element : this.container;
3490
3452
  }
3491
- get y() {
3492
- return this._y;
3453
+ get config() {
3454
+ return !_.isNil(this.window) ? this.window.config : null;
3493
3455
  }
3494
- set y(value) {
3495
- value = this.getConfig().parseY(value);
3496
- if (value === this._y) {
3456
+ get window() {
3457
+ return this._window;
3458
+ }
3459
+ set window(value) {
3460
+ if (value === this._window) {
3497
3461
  return;
3498
3462
  }
3499
- this._y = value;
3500
- this.commitPositionProperties();
3501
- }
3502
- get paddingTop() {
3503
- return this.getConfig().paddingTop;
3504
- }
3505
- get paddingLeft() {
3506
- return this.getConfig().paddingLeft;
3507
- }
3508
- get paddingRight() {
3509
- return this.getConfig().paddingRight;
3463
+ this._window = value;
3464
+ if (!_.isNil(value)) {
3465
+ this.commitWindowProperties();
3466
+ }
3510
3467
  }
3511
- get paddingBottom() {
3512
- return this.getConfig().paddingBottom;
3468
+ }
3469
+ IWindowContent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: IWindowContent, deps: [{ token: WINDOW_CONTENT_CONTAINER, optional: true }], target: i0.ɵɵFactoryTarget.Component });
3470
+ IWindowContent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: IWindowContent, selector: "ng-component", inputs: { isDisabled: "isDisabled", window: "window" }, usesInheritance: true, ngImport: i0, template: '', isInline: true });
3471
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: IWindowContent, decorators: [{
3472
+ type: Component,
3473
+ args: [{ template: '' }]
3474
+ }], ctorParameters: function () {
3475
+ return [{ type: undefined, decorators: [{
3476
+ type: Optional
3477
+ }, {
3478
+ type: Inject,
3479
+ args: [WINDOW_CONTENT_CONTAINER]
3480
+ }] }];
3481
+ }, propDecorators: { isDisabled: [{
3482
+ type: Input
3483
+ }], window: [{
3484
+ type: Input
3485
+ }] } });
3486
+ const WINDOW_CONTENT_CONTAINER = new InjectionToken('WINDOW_CONTENT_CONTAINER');
3487
+
3488
+ class WindowQuestionBaseComponent extends IWindowContent {
3489
+ // --------------------------------------------------------------------------
3490
+ //
3491
+ // Protected Methods
3492
+ //
3493
+ // --------------------------------------------------------------------------
3494
+ commitConfigProperties() {
3495
+ super.commitConfigProperties();
3496
+ this.data.closePromise.then(() => {
3497
+ if (!this.isDestroyed) {
3498
+ this.close();
3499
+ }
3500
+ });
3513
3501
  }
3514
3502
  }
3515
3503
 
3516
- class WindowImpl extends WindowBase {
3504
+ class WindowQuestionComponent extends WindowQuestionBaseComponent {
3517
3505
  // --------------------------------------------------------------------------
3518
3506
  //
3519
- // Constructor
3507
+ // Constructor
3520
3508
  //
3521
3509
  // --------------------------------------------------------------------------
3522
- constructor(properties) {
3523
- super();
3524
- // --------------------------------------------------------------------------
3525
- //
3526
- // Properties
3527
- //
3528
- // --------------------------------------------------------------------------
3529
- this._isBlink = false;
3530
- this._isShaking = false;
3531
- this._isOnTop = false;
3532
- this._isDisabled = false;
3533
- this._isMinimized = false;
3534
- this.isOpened = false;
3535
- this.isWasOnTop = false;
3536
- // --------------------------------------------------------------------------
3537
- //
3538
- // Protected Methods
3539
- //
3540
- // --------------------------------------------------------------------------
3541
- this.setClosed = () => {
3542
- this.isOpened = false;
3543
- this.emit(WindowEvent.CLOSED);
3544
- this.destroy();
3545
- };
3546
- this.setOpened = () => {
3547
- this.isOpened = true;
3548
- this.emit(WindowEvent.OPENED);
3549
- };
3550
- this.blinkToggle = () => {
3551
- this.isBlink = !this.isBlink;
3552
- };
3553
- this.stopShaking = () => {
3554
- this.isShaking = false;
3555
- };
3556
- this.emitResize = () => {
3557
- this.emit(WindowEvent.RESIZED);
3558
- };
3559
- this.resizeHandler = () => {
3560
- if (!this.isOpened) {
3561
- return;
3562
- }
3563
- clearTimeout(this.resizeTimer);
3564
- this.resizeTimer = setTimeout(this.emitResize, WindowImpl.RESIZE_DELAY);
3565
- };
3566
- this.mouseDownHandlerProxy = (event) => {
3567
- this.mouseDownHandler(event);
3568
- };
3569
- this.mouseClickHandlerProxy = (event) => {
3570
- this.mouseClickHandler(event);
3571
- };
3572
- this.observer = new Subject();
3573
- this.elements = new Array();
3574
- this.properties = properties;
3575
- this.content.window = this;
3576
- // Have to save for unsubscribe on destroy
3577
- this._wrapper = this.properties.overlay.hostElement;
3578
- this._backdrop = this.properties.overlay.backdropElement;
3579
- this._container = this.properties.overlay.overlayElement;
3580
- this.setProperties();
3581
- this.getReference().afterOpened().pipe(takeUntil$1(this.destroyed)).subscribe(this.setOpened);
3582
- this.getReference().afterClosed().pipe(takeUntil$1(this.destroyed)).subscribe(this.setClosed);
3583
- this.events
3584
- .pipe(filter$1(event => event === WindowEvent.CONTENT_READY), takeUntil$1(this.destroyed))
3585
- .subscribe(this.updatePosition);
3510
+ constructor(container, language) {
3511
+ super(container);
3512
+ this.language = language;
3513
+ ViewUtil.addClasses(container.element, 'd-block');
3586
3514
  }
3587
3515
  // --------------------------------------------------------------------------
3588
3516
  //
3589
- // Elements Methods
3517
+ // Public Methods
3590
3518
  //
3591
3519
  // --------------------------------------------------------------------------
3592
- elementsCreate() {
3593
- this.elements = new Array();
3594
- }
3595
- elementsDestroy() {
3596
- this.elements.forEach(item => this.elementDestroy(item));
3597
- this.elements = null;
3598
- }
3599
- elementAdd(item) {
3600
- this.elements.push(item);
3601
- item.instance.window = this;
3602
- return item;
3603
- }
3604
- elementRemove(item) {
3605
- ArrayUtil.remove(this.elements, item);
3606
- this.elementDestroy(item);
3607
- return item;
3608
- }
3609
- elementDestroy(item) {
3610
- item.instance.window = null;
3611
- item.destroy();
3612
- return item;
3613
- }
3614
- setProperties() {
3615
- super.setProperties();
3616
- ViewUtil.addClass(this.container, 'vi-window');
3617
- ViewUtil.toggleClass(this.container, 'vi-modal', this.config.isModal);
3618
- this.container.addEventListener('click', this.mouseClickHandlerProxy, true);
3619
- if (!this.config.isModal) {
3620
- this.container.addEventListener('mousedown', this.mouseDownHandlerProxy);
3520
+ commitConfigProperties() {
3521
+ super.commitConfigProperties();
3522
+ if (!_.isNil(this.data.text)) {
3523
+ this.text = this.data.text.replace(/(?:\r\n|\r|\n)/g, `<br/>`);
3621
3524
  }
3622
- /*
3623
- if (!this.config.isModal) {
3624
- this.container.addEventListener('click', this.mouseClickHandlerProxy, true);
3625
- this.container.addEventListener('mousedown', this.mouseDownHandlerProxy);
3525
+ if (this.language.isHasTranslation(this.data.options.yesTextId)) {
3526
+ this.data.yesText = this.language.translate(this.data.options.yesTextId);
3626
3527
  }
3627
- */
3628
- this.elementsCreate();
3629
- }
3630
- commitIsBlinkProperties() { }
3631
- commitIsShakingProperties() { }
3632
- commitIsDisabledProperties() { }
3633
- commitIsMinimizedProperties() { }
3634
- getConfig() {
3635
- return this.properties.config;
3636
- }
3637
- getContainer() {
3638
- return this.container;
3639
- }
3640
- getReference() {
3641
- return this.properties.reference;
3642
- }
3643
- isNeedClickStopPropagation(event) {
3644
- // return !this.isWasOnTop;
3645
- if (this.isWasOnTop) {
3646
- return false;
3528
+ if (this.language.isHasTranslation(this.data.options.notTextId)) {
3529
+ this.data.notText = this.language.translate(this.data.options.notTextId);
3647
3530
  }
3648
- let element = _.find(this.elements, item => item.location.nativeElement === event.target);
3649
- if (_.isNil(element)) {
3650
- return false;
3531
+ if (this.language.isHasTranslation(this.data.options.checkTextId)) {
3532
+ this.data.checkText = this.language.translate(this.data.options.checkTextId);
3651
3533
  }
3652
- element.instance.clickHandler(event);
3653
- return true;
3654
- }
3655
- stopBlinkIfNeed() {
3656
- this.isBlink = false;
3657
- if (!this.blinkTimer) {
3658
- return;
3534
+ if (this.language.isHasTranslation(this.data.options.closeTextId)) {
3535
+ this.data.closeText = this.language.translate(this.data.options.closeTextId);
3659
3536
  }
3660
- clearInterval(this.blinkTimer);
3661
- this.blinkTimer = null;
3662
3537
  }
3663
- mouseDownHandler(event) {
3664
- this.setOnTop();
3538
+ }
3539
+ WindowQuestionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: WindowQuestionComponent, deps: [{ token: i0.ViewContainerRef }, { token: i1$1.LanguageService }], target: i0.ɵɵFactoryTarget.Component });
3540
+ WindowQuestionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: WindowQuestionComponent, selector: "ng-component", usesInheritance: true, ngImport: i0, template: "<p class=\"text m-4 text-center mouse-inactive text-word-wrap-break-word\" [innerHTML]=\"text\"></p>\n\n<div class=\"text-center border-sm-top p-3\">\n\n <button (click)=\"data?.closeClickHandler()\" mat-stroked-button *ngIf=\"data?.isInfo\">\n <span [innerHTML]=\"data?.closeText\"></span>\n </button>\n\n <button class=\"mr-3 me-3\" (click)=\"data?.yesClickHandler()\" color=\"primary\" mat-stroked-button *ngIf=\"data?.isQuestion\">\n <span [innerHTML]=\"data?.yesText\"></span>\n </button>\n\n <button (click)=\"data?.notClickHandler()\" mat-stroked-button *ngIf=\"data?.isQuestion\">\n <span [innerHTML]=\"data?.notText\"></span>\n </button>\n\n</div>", components: [{ type: i2.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }], directives: [{ type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
3541
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: WindowQuestionComponent, decorators: [{
3542
+ type: Component,
3543
+ args: [{ template: "<p class=\"text m-4 text-center mouse-inactive text-word-wrap-break-word\" [innerHTML]=\"text\"></p>\n\n<div class=\"text-center border-sm-top p-3\">\n\n <button (click)=\"data?.closeClickHandler()\" mat-stroked-button *ngIf=\"data?.isInfo\">\n <span [innerHTML]=\"data?.closeText\"></span>\n </button>\n\n <button class=\"mr-3 me-3\" (click)=\"data?.yesClickHandler()\" color=\"primary\" mat-stroked-button *ngIf=\"data?.isQuestion\">\n <span [innerHTML]=\"data?.yesText\"></span>\n </button>\n\n <button (click)=\"data?.notClickHandler()\" mat-stroked-button *ngIf=\"data?.isQuestion\">\n <span [innerHTML]=\"data?.notText\"></span>\n </button>\n\n</div>" }]
3544
+ }], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i1$1.LanguageService }]; } });
3545
+
3546
+ class WindowElement extends DestroyableContainer {
3547
+ // --------------------------------------------------------------------------
3548
+ //
3549
+ // Constructor
3550
+ //
3551
+ // --------------------------------------------------------------------------
3552
+ constructor(element) {
3553
+ super();
3554
+ this.element = element;
3665
3555
  }
3666
- mouseClickHandler(event) {
3667
- if (this.isNeedClickStopPropagation(event)) {
3668
- event.stopPropagation();
3556
+ // --------------------------------------------------------------------------
3557
+ //
3558
+ // Private Methods
3559
+ //
3560
+ // --------------------------------------------------------------------------
3561
+ checkWindowParent() {
3562
+ let container = this.getContainer();
3563
+ if (!_.isNil(container)) {
3564
+ ViewUtil.appendChild(container, this.element.nativeElement);
3669
3565
  }
3670
- if (!this.isWasOnTop) {
3671
- this.isWasOnTop = true;
3566
+ }
3567
+ getContainer() {
3568
+ let item = ViewUtil.parseElement(this.element.nativeElement);
3569
+ while (!_.isNil(item) && item.nodeName.toLowerCase() !== 'mat-dialog-container') {
3570
+ item = item.parentElement;
3672
3571
  }
3572
+ return item;
3673
3573
  }
3574
+ createChildren() { }
3575
+ destroyChildren() { }
3576
+ commitWindowProperties() { }
3674
3577
  // --------------------------------------------------------------------------
3675
3578
  //
3676
- // Public Methods
3579
+ // Public Methods
3677
3580
  //
3678
3581
  // --------------------------------------------------------------------------
3679
- emit(event) {
3680
- this.observer.next(event);
3681
- }
3682
- close() {
3683
- this.getReference().close();
3582
+ ngAfterViewInit() {
3583
+ this.createChildren();
3584
+ this.checkWindowParent();
3684
3585
  }
3685
3586
  destroy() {
3686
3587
  if (this.isDestroyed) {
3687
3588
  return;
3688
3589
  }
3689
3590
  super.destroy();
3690
- this.elementsDestroy();
3691
- this._container.removeEventListener('click', this.mouseClickHandlerProxy, true);
3692
- this._container.removeEventListener('mousedown', this.mouseDownHandlerProxy);
3693
- if (!_.isNil(this.content)) {
3694
- this.content.destroy();
3695
- }
3696
- if (!_.isNil(this.observer)) {
3697
- this.observer.complete();
3698
- this.observer = null;
3699
- }
3700
- this.properties = null;
3701
- this._wrapper = null;
3702
- this._backdrop = null;
3703
- this._container = null;
3704
- clearInterval(this.blinkTimer);
3705
- this.blinkTimer = null;
3706
- clearInterval(this.shakeTimer);
3707
- this.shakeTimer = null;
3708
- clearTimeout(this.resizeTimer);
3709
- this.resizeTimer = null;
3710
- }
3711
- blink() {
3712
- clearInterval(this.blinkTimer);
3713
- this.blinkTimer = setInterval(this.blinkToggle, WindowImpl.BLINK_DELAY);
3714
- }
3715
- shake() {
3716
- if (this.isShaking) {
3717
- return;
3718
- }
3719
- this.isShaking = true;
3720
- clearInterval(this.shakeTimer);
3721
- this.shakeTimer = setInterval(this.stopShaking, WindowImpl.SHAKE_DELAY);
3722
- }
3723
- setOnTop() {
3724
- this.isWasOnTop = this.isOnTop;
3725
- this.emit(WindowEvent.SET_ON_TOP);
3591
+ this.destroyChildren();
3592
+ this.element = null;
3593
+ this.window = null;
3726
3594
  }
3727
3595
  // --------------------------------------------------------------------------
3728
3596
  //
3729
- // Size Methods
3597
+ // Event Handlers
3730
3598
  //
3731
3599
  // --------------------------------------------------------------------------
3732
- getWidth() {
3733
- return this.width;
3734
- }
3735
- getHeight() {
3736
- return this.height;
3737
- }
3738
- setWidth(value, isNeedNotify = true) {
3739
- this.width = value;
3740
- if (isNeedNotify) {
3741
- this.resizeHandler();
3742
- }
3743
- }
3744
- setHeight(value, isNeedNotify = true) {
3745
- this.height = value;
3746
- if (isNeedNotify) {
3747
- this.resizeHandler();
3748
- }
3749
- }
3750
- setSize(width, height) {
3751
- this.setWidth(width, false);
3752
- this.setHeight(height, false);
3753
- this.resizeHandler();
3600
+ clickHandler(event) {
3601
+ event.stopPropagation();
3754
3602
  }
3755
3603
  // --------------------------------------------------------------------------
3756
3604
  //
3757
- // Move Methods
3605
+ // Protected Properties
3758
3606
  //
3759
3607
  // --------------------------------------------------------------------------
3760
- getX() {
3761
- return this.x;
3762
- }
3763
- setX(value, isNeedNotify = true) {
3764
- this.x = value;
3765
- if (isNeedNotify) {
3766
- this.emit(WindowEvent.MOVED);
3767
- }
3768
- }
3769
- getY() {
3770
- return this.y;
3771
- }
3772
- setY(value, isNeedNotify = true) {
3773
- this.y = value;
3774
- if (isNeedNotify) {
3775
- this.emit(WindowEvent.MOVED);
3776
- }
3777
- }
3778
- move(x, y) {
3779
- this.setX(x, false);
3780
- this.setY(y, false);
3781
- this.emit(WindowEvent.MOVED);
3608
+ get nativeElement() {
3609
+ return this.element ? this.element.nativeElement : null;
3782
3610
  }
3783
3611
  // --------------------------------------------------------------------------
3784
3612
  //
3785
- // Private Properties
3613
+ // Public Properties
3786
3614
  //
3787
3615
  // --------------------------------------------------------------------------
3788
- get isBlink() {
3789
- return this._isBlink;
3616
+ get window() {
3617
+ return this._window;
3790
3618
  }
3791
- set isBlink(value) {
3792
- if (value === this._isBlink) {
3619
+ set window(value) {
3620
+ if (value === this._window) {
3793
3621
  return;
3794
3622
  }
3795
- this._isBlink = value;
3796
- this.commitIsBlinkProperties();
3797
- }
3798
- get isShaking() {
3799
- return this._isShaking;
3800
- }
3801
- set isShaking(value) {
3802
- if (value === this._isShaking) {
3803
- return;
3623
+ this._window = value;
3624
+ if (this.window) {
3625
+ this.commitWindowProperties();
3804
3626
  }
3805
- this._isShaking = value;
3806
- this.commitIsShakingProperties();
3807
3627
  }
3628
+ }
3629
+ WindowElement.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: WindowElement, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
3630
+ WindowElement.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: WindowElement, selector: "ng-component", usesInheritance: true, ngImport: i0, template: '', isInline: true });
3631
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: WindowElement, decorators: [{
3632
+ type: Component,
3633
+ args: [{ template: '' }]
3634
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }]; } });
3635
+
3636
+ class WindowCloseElementComponent extends WindowElement {
3808
3637
  // --------------------------------------------------------------------------
3809
3638
  //
3810
- // Public Properties
3639
+ // Constructor
3811
3640
  //
3812
3641
  // --------------------------------------------------------------------------
3813
- get events() {
3814
- return this.observer.asObservable();
3815
- }
3816
- get config() {
3817
- return this.properties.config;
3818
- }
3819
- get content() {
3820
- return this.properties.reference ? this.properties.reference.componentInstance : null;
3821
- }
3822
- get container() {
3823
- return this._container;
3824
- }
3825
- get wrapper() {
3826
- return this._wrapper;
3827
- }
3828
- get backdrop() {
3829
- return this._backdrop;
3830
- }
3831
- get isOnTop() {
3832
- return this._isOnTop;
3642
+ constructor(element) {
3643
+ super(element);
3833
3644
  }
3834
- set isOnTop(value) {
3835
- if (value === this._isOnTop) {
3836
- return;
3645
+ // --------------------------------------------------------------------------
3646
+ //
3647
+ // Private Methods
3648
+ //
3649
+ // --------------------------------------------------------------------------
3650
+ createChildren() {
3651
+ super.createChildren();
3652
+ if (!_.isNil(WindowCloseElementComponent.ICON_VALUE)) {
3653
+ ViewUtil.setProperty(this.nativeElement, 'innerHTML', WindowCloseElementComponent.ICON_VALUE);
3837
3654
  }
3838
- this._isOnTop = value;
3839
- clearInterval(this.blinkTimer);
3840
- this.isBlink = false;
3841
- }
3842
- get isMinimized() {
3843
- return this._isMinimized;
3844
- }
3845
- set isMinimized(value) {
3846
- if (value === this._isMinimized) {
3847
- return;
3655
+ if (!_.isNil(WindowCloseElementComponent.ICON_CLASS)) {
3656
+ ViewUtil.addClasses(this.nativeElement, WindowCloseElementComponent.ICON_CLASS);
3848
3657
  }
3849
- this._isMinimized = value;
3850
- this.commitIsMinimizedProperties();
3851
- this.emit(WindowEvent.MINIMIZED_CHANGED);
3852
- this.stopBlinkIfNeed();
3853
- }
3854
- get isDisabled() {
3855
- return this._isDisabled;
3658
+ ViewUtil.addClass(this.nativeElement, 'mouse-active');
3856
3659
  }
3857
- set isDisabled(value) {
3858
- if (value === this._isDisabled) {
3859
- return;
3660
+ // --------------------------------------------------------------------------
3661
+ //
3662
+ // Event Handlers
3663
+ //
3664
+ // --------------------------------------------------------------------------
3665
+ clickHandler(event) {
3666
+ super.clickHandler(event);
3667
+ if (!_.isNil(this.window)) {
3668
+ this.window.close();
3860
3669
  }
3861
- this._isDisabled = value;
3862
- this.commitIsDisabledProperties();
3863
- this.emit(WindowEvent.DISABLED_CHANGED);
3864
3670
  }
3865
3671
  }
3866
3672
  // --------------------------------------------------------------------------
3867
3673
  //
3868
- // Constants
3674
+ // Constants
3869
3675
  //
3870
3676
  // --------------------------------------------------------------------------
3871
- WindowImpl.BLINK_DELAY = 500;
3872
- WindowImpl.SHAKE_DELAY = 500;
3873
- WindowImpl.RESIZE_DELAY = 200;
3677
+ WindowCloseElementComponent.ICON_CLASS = 'fas fa-times';
3678
+ WindowCloseElementComponent.ICON_VALUE = null;
3679
+ WindowCloseElementComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: WindowCloseElementComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
3680
+ WindowCloseElementComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: WindowCloseElementComponent, selector: "vi-window-close-element", usesInheritance: true, ngImport: i0, template: '', isInline: true, styles: [":host{display:block;position:absolute;color:#fff;background-color:#0006;border-radius:50%;padding:8px;font-size:14px;font-weight:700;text-align:center}:host:hover{background-color:#0009}:host.small{font-size:10px;padding:4px}\n"] });
3681
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: WindowCloseElementComponent, decorators: [{
3682
+ type: Component,
3683
+ args: [{ selector: 'vi-window-close-element', template: '', styles: [":host{display:block;position:absolute;color:#fff;background-color:#0006;border-radius:50%;padding:8px;font-size:14px;font-weight:700;text-align:center}:host:hover{background-color:#0009}:host.small{font-size:10px;padding:4px}\n"] }]
3684
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }]; } });
3874
3685
 
3875
- class BottomSheetImpl extends DestroyableContainer {
3686
+ class WindowMinimizeElementComponent extends WindowElement {
3876
3687
  // --------------------------------------------------------------------------
3877
3688
  //
3878
- // Constructor
3689
+ // Constructor
3879
3690
  //
3880
3691
  // --------------------------------------------------------------------------
3881
- constructor(properties) {
3882
- super();
3883
- // --------------------------------------------------------------------------
3884
- //
3885
- // Properties
3886
- //
3887
- // --------------------------------------------------------------------------
3888
- this._isBlink = false;
3889
- this._isDisabled = false;
3692
+ constructor(element) {
3693
+ super(element);
3890
3694
  // --------------------------------------------------------------------------
3891
3695
  //
3892
- // Protected Methods
3696
+ // Private Methods
3893
3697
  //
3894
3698
  // --------------------------------------------------------------------------
3895
- this.setClosed = () => {
3896
- this.emit(WindowEvent.CLOSED);
3897
- this.destroy();
3898
- };
3899
- this.setOpened = () => {
3900
- this.emit(WindowEvent.OPENED);
3901
- };
3902
- this.blinkToggle = () => {
3903
- this.isBlink = !this.isBlink;
3904
- };
3905
- this.mouseDownHandlerProxy = (event) => {
3906
- this.mouseDownHandler(event);
3907
- };
3908
- this.mouseClickHandlerProxy = (event) => {
3909
- this.mouseClickHandler(event);
3699
+ this.commitIconProperties = () => {
3700
+ let icon = this.window.isMinimized ? WindowMinimizeElementComponent.ICON_MAXIMIZE_VALUE : WindowMinimizeElementComponent.ICON_MINIMIZE_VALUE;
3701
+ ViewUtil.setProperty(this.nativeElement, 'innerHTML', icon);
3910
3702
  };
3911
- this.observer = new Subject();
3912
- this.properties = properties;
3913
- this.content.window = this;
3914
- // Have to save for unsubscribe on destroy
3915
- this._wrapper = this.properties.overlay.hostElement;
3916
- this._backdrop = this.properties.overlay.backdropElement;
3917
- this._container = this.properties.overlay.overlayElement;
3918
- this.setProperties();
3919
- this.elementsCreate();
3920
- this.getReference().afterOpened().pipe(takeUntil$1(this.destroyed)).subscribe(this.setOpened);
3921
- this.getReference().afterDismissed().pipe(takeUntil$1(this.destroyed)).subscribe(this.setClosed);
3922
3703
  }
3923
3704
  // --------------------------------------------------------------------------
3924
3705
  //
3925
- // Elements Methods
3706
+ // Protected Methods
3926
3707
  //
3927
3708
  // --------------------------------------------------------------------------
3928
- elementsCreate() {
3929
- this.elements = new Array();
3930
- }
3931
- elementsDestroy() {
3932
- this.elements.forEach(item => this.elementDestroy(item));
3933
- this.elements = null;
3934
- }
3935
- elementAdd(item) {
3936
- this.elements.push(item);
3937
- item.instance.window = this;
3938
- return item;
3939
- }
3940
- elementRemove(item) {
3941
- ArrayUtil.remove(this.elements, item);
3942
- this.elementDestroy(item);
3943
- return item;
3944
- }
3945
- elementDestroy(item) {
3946
- item.instance.window = null;
3947
- item.destroy();
3948
- return item;
3949
- }
3950
- setProperties() {
3951
- ViewUtil.addClass(this.container, 'vi-bottom-sheet');
3952
- ViewUtil.toggleClass(this.container, 'vi-modal', this.config.isModal);
3953
- if (!this.config.isModal) {
3954
- this.container.addEventListener('click', this.mouseClickHandlerProxy, true);
3955
- this.container.addEventListener('mousedown', this.mouseDownHandlerProxy);
3956
- }
3957
- }
3958
- commitIsBlinkProperties() { }
3959
- commitIsDisabledProperties() { }
3960
- getConfig() {
3961
- return this.properties.config;
3962
- }
3963
- getContainer() {
3964
- return this.container;
3965
- }
3966
- getReference() {
3967
- return this.properties.reference;
3709
+ commitWindowProperties() {
3710
+ super.commitWindowProperties();
3711
+ this.window.events.pipe(takeUntil(this.destroyed)).subscribe(event => {
3712
+ if (event === WindowEvent.MINIMIZED_CHANGED) {
3713
+ this.commitIconProperties();
3714
+ }
3715
+ });
3968
3716
  }
3969
- isNeedClickStopPropagation(event) {
3970
- let element = _.find(this.elements, item => item.location.nativeElement === event.target);
3971
- if (_.isNil(element)) {
3972
- return false;
3717
+ createChildren() {
3718
+ super.createChildren();
3719
+ if (!_.isNil(WindowMinimizeElementComponent.ICON_MINIMIZE_VALUE)) {
3720
+ ViewUtil.setProperty(this.nativeElement, 'innerHTML', WindowMinimizeElementComponent.ICON_MINIMIZE_VALUE);
3973
3721
  }
3974
- element.instance.clickHandler(event);
3975
- return true;
3976
- }
3977
- stopBlinkIfNeed() {
3978
- this.isBlink = false;
3979
- if (!this.blinkTimer) {
3980
- return;
3722
+ if (!_.isNil(WindowMinimizeElementComponent.ICON_CLASS)) {
3723
+ ViewUtil.addClasses(this.nativeElement, WindowMinimizeElementComponent.ICON_CLASS);
3981
3724
  }
3982
- clearInterval(this.blinkTimer);
3983
- this.blinkTimer = null;
3725
+ ViewUtil.addClass(this.nativeElement, 'mouse-active');
3984
3726
  }
3985
3727
  // --------------------------------------------------------------------------
3986
3728
  //
3987
- // Event Handlers
3729
+ // Event Handlers
3988
3730
  //
3989
3731
  // --------------------------------------------------------------------------
3990
- mouseDownHandler(event) {
3991
- this.setOnTop();
3992
- }
3993
- mouseClickHandler(event) {
3994
- if (this.isNeedClickStopPropagation(event)) {
3995
- event.stopPropagation();
3996
- }
3997
- }
3998
- // --------------------------------------------------------------------------
3999
- //
4000
- // Public Methods
4001
- //
4002
- // --------------------------------------------------------------------------
4003
- emit(event) {
4004
- this.observer.next(event);
4005
- }
4006
- close() {
4007
- this.getReference().dismiss();
4008
- }
4009
- destroy() {
4010
- if (this.isDestroyed) {
4011
- return;
4012
- }
4013
- super.destroy();
4014
- this.elementsDestroy();
4015
- this._container.removeEventListener('click', this.mouseClickHandlerProxy, true);
4016
- this._container.removeEventListener('mousedown', this.mouseDownHandlerProxy);
4017
- if (!_.isNil(this.content)) {
4018
- this.content.destroy();
4019
- }
4020
- if (!_.isNil(this.observer)) {
4021
- this.observer.complete();
4022
- this.observer = null;
4023
- }
4024
- this.properties = null;
4025
- this._wrapper = null;
4026
- this._backdrop = null;
4027
- this._container = null;
4028
- clearInterval(this.blinkTimer);
4029
- this.blinkTimer = null;
4030
- }
4031
- blink() {
4032
- clearInterval(this.blinkTimer);
4033
- this.blinkTimer = setInterval(this.blinkToggle, WindowImpl.BLINK_DELAY);
4034
- }
4035
- shake() { }
4036
- setOnTop() { }
4037
- // --------------------------------------------------------------------------
4038
- //
4039
- // Size Methods
4040
- //
4041
- // --------------------------------------------------------------------------
4042
- getWidth() {
4043
- return NaN;
4044
- }
4045
- getHeight() {
4046
- return NaN;
4047
- }
4048
- setWidth(value, isNeedNotify = true) { }
4049
- setHeight(value, isNeedNotify = true) { }
4050
- setSize(width, height) { }
4051
- // --------------------------------------------------------------------------
4052
- //
4053
- // Move Methods
4054
- //
4055
- // --------------------------------------------------------------------------
4056
- getX() {
4057
- return NaN;
4058
- }
4059
- setX(value, isNeedNotify = true) { }
4060
- getY() {
4061
- return NaN;
4062
- }
4063
- setY(value, isNeedNotify = true) { }
4064
- move(x, y) { }
4065
- // --------------------------------------------------------------------------
4066
- //
4067
- // Private Properties
4068
- //
4069
- // --------------------------------------------------------------------------
4070
- get reference() {
4071
- return this.properties.reference;
4072
- }
4073
- get isBlink() {
4074
- return this._isBlink;
4075
- }
4076
- set isBlink(value) {
4077
- if (value === this._isBlink) {
4078
- return;
4079
- }
4080
- this._isBlink = value;
4081
- this.commitIsBlinkProperties();
4082
- }
4083
- get isShaking() {
4084
- return false;
4085
- }
4086
- set isShaking(value) { }
4087
- // --------------------------------------------------------------------------
4088
- //
4089
- // Public Properties
4090
- //
4091
- // --------------------------------------------------------------------------
4092
- get events() {
4093
- return this.observer.asObservable();
4094
- }
4095
- get config() {
4096
- return this.properties.config;
4097
- }
4098
- get content() {
4099
- return !_.isNil(this.reference) ? this.reference.instance : null;
4100
- }
4101
- get container() {
4102
- return this._container;
4103
- }
4104
- get wrapper() {
4105
- return this._wrapper;
4106
- }
4107
- get backdrop() {
4108
- return this._backdrop;
4109
- }
4110
- get isOnTop() {
4111
- return false;
4112
- }
4113
- set isOnTop(value) { }
4114
- get isMinimized() {
4115
- return false;
4116
- }
4117
- set isMinimized(value) { }
4118
- get isDisabled() {
4119
- return this._isDisabled;
4120
- }
4121
- set isDisabled(value) {
4122
- if (value === this._isDisabled) {
4123
- return;
3732
+ clickHandler(event) {
3733
+ super.clickHandler(event);
3734
+ if (!_.isNil(this.window)) {
3735
+ this.window.isMinimized = !this.window.isMinimized;
4124
3736
  }
4125
- this._isDisabled = value;
4126
- this.commitIsDisabledProperties();
4127
- this.emit(WindowEvent.DISABLED_CHANGED);
4128
3737
  }
4129
3738
  }
4130
3739
  // --------------------------------------------------------------------------
4131
3740
  //
4132
- // Constants
3741
+ // Constants
4133
3742
  //
4134
3743
  // --------------------------------------------------------------------------
4135
- BottomSheetImpl.BLINK_DELAY = 500;
4136
- BottomSheetImpl.SHAKE_DELAY = 500;
4137
-
4138
- class WindowElement extends DestroyableContainer {
4139
- // --------------------------------------------------------------------------
4140
- //
4141
- // Constructor
4142
- //
4143
- // --------------------------------------------------------------------------
4144
- constructor(element) {
4145
- super();
4146
- this.element = element;
4147
- }
4148
- // --------------------------------------------------------------------------
4149
- //
4150
- // Private Methods
4151
- //
4152
- // --------------------------------------------------------------------------
4153
- checkWindowParent() {
4154
- let container = this.getContainer();
4155
- if (!_.isNil(container)) {
4156
- ViewUtil.appendChild(container, this.element.nativeElement);
4157
- }
4158
- }
4159
- getContainer() {
4160
- let item = ViewUtil.parseElement(this.element.nativeElement);
4161
- while (!_.isNil(item) && item.nodeName.toLowerCase() !== 'mat-dialog-container') {
4162
- item = item.parentElement;
4163
- }
4164
- return item;
4165
- }
4166
- createChildren() { }
4167
- destroyChildren() { }
4168
- commitWindowProperties() { }
4169
- // --------------------------------------------------------------------------
4170
- //
4171
- // Public Methods
4172
- //
4173
- // --------------------------------------------------------------------------
4174
- ngAfterViewInit() {
4175
- this.createChildren();
4176
- this.checkWindowParent();
4177
- }
4178
- destroy() {
4179
- if (this.isDestroyed) {
4180
- return;
4181
- }
4182
- super.destroy();
4183
- this.destroyChildren();
4184
- this.element = null;
4185
- this.window = null;
4186
- }
4187
- // --------------------------------------------------------------------------
4188
- //
4189
- // Event Handlers
4190
- //
4191
- // --------------------------------------------------------------------------
4192
- clickHandler(event) {
4193
- event.stopPropagation();
4194
- }
4195
- // --------------------------------------------------------------------------
4196
- //
4197
- // Protected Properties
4198
- //
4199
- // --------------------------------------------------------------------------
4200
- get nativeElement() {
4201
- return this.element ? this.element.nativeElement : null;
4202
- }
4203
- // --------------------------------------------------------------------------
4204
- //
4205
- // Public Properties
4206
- //
4207
- // --------------------------------------------------------------------------
4208
- get window() {
4209
- return this._window;
4210
- }
4211
- set window(value) {
4212
- if (value === this._window) {
4213
- return;
4214
- }
4215
- this._window = value;
4216
- if (this.window) {
4217
- this.commitWindowProperties();
4218
- }
4219
- }
4220
- }
4221
- WindowElement.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: WindowElement, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
4222
- WindowElement.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: WindowElement, selector: "ng-component", usesInheritance: true, ngImport: i0, template: '', isInline: true });
4223
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: WindowElement, decorators: [{
3744
+ WindowMinimizeElementComponent.ICON_CLASS = null;
3745
+ WindowMinimizeElementComponent.ICON_MINIMIZE_VALUE = null;
3746
+ WindowMinimizeElementComponent.ICON_MAXIMIZE_VALUE = null;
3747
+ WindowMinimizeElementComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: WindowMinimizeElementComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
3748
+ WindowMinimizeElementComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: WindowMinimizeElementComponent, selector: "vi-window-minimize-element", usesInheritance: true, ngImport: i0, template: '', isInline: true, styles: [":host{display:block;position:absolute;color:#fff;background-color:#0006;border-radius:50%;padding:8px;font-size:14px;font-weight:700;text-align:center}:host:hover{background-color:#0009}:host.small{font-size:10px;padding:4px}\n"] });
3749
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: WindowMinimizeElementComponent, decorators: [{
4224
3750
  type: Component,
4225
- args: [{ template: '' }]
3751
+ args: [{ selector: 'vi-window-minimize-element', template: '', styles: [":host{display:block;position:absolute;color:#fff;background-color:#0006;border-radius:50%;padding:8px;font-size:14px;font-weight:700;text-align:center}:host:hover{background-color:#0009}:host.small{font-size:10px;padding:4px}\n"] }]
4226
3752
  }], ctorParameters: function () { return [{ type: i0.ElementRef }]; } });
4227
3753
 
4228
- class BottomSheetCloseElementComponent extends WindowElement {
3754
+ class WindowResizeElementComponent extends WindowElement {
4229
3755
  // --------------------------------------------------------------------------
4230
3756
  //
4231
3757
  // Constructor
@@ -4241,13 +3767,13 @@ class BottomSheetCloseElementComponent extends WindowElement {
4241
3767
  // --------------------------------------------------------------------------
4242
3768
  createChildren() {
4243
3769
  super.createChildren();
4244
- if (!_.isNil(BottomSheetCloseElementComponent.ICON_VALUE)) {
4245
- ViewUtil.setProperty(this.nativeElement, 'innerHTML', BottomSheetCloseElementComponent.ICON_VALUE);
3770
+ if (!_.isNil(WindowResizeElementComponent.ICON_VALUE)) {
3771
+ ViewUtil.setProperty(this.nativeElement, 'innerHTML', WindowResizeElementComponent.ICON_VALUE);
4246
3772
  }
4247
- if (!_.isNil(BottomSheetCloseElementComponent.ICON_CLASS)) {
4248
- ViewUtil.addClasses(this.nativeElement, BottomSheetCloseElementComponent.ICON_CLASS);
3773
+ if (!_.isNil(WindowResizeElementComponent.ICON_CLASS)) {
3774
+ ViewUtil.addClasses(this.nativeElement, WindowResizeElementComponent.ICON_CLASS);
4249
3775
  }
4250
- ViewUtil.addClass(this.nativeElement, 'mouse-active');
3776
+ ViewUtil.setStyle(this.nativeElement, 'cursor', 'pointer');
4251
3777
  }
4252
3778
  // --------------------------------------------------------------------------
4253
3779
  //
@@ -4257,7 +3783,6 @@ class BottomSheetCloseElementComponent extends WindowElement {
4257
3783
  clickHandler(event) {
4258
3784
  super.clickHandler(event);
4259
3785
  if (!_.isNil(this.window)) {
4260
- this.window.close();
4261
3786
  }
4262
3787
  }
4263
3788
  }
@@ -4266,419 +3791,531 @@ class BottomSheetCloseElementComponent extends WindowElement {
4266
3791
  // Constants
4267
3792
  //
4268
3793
  // --------------------------------------------------------------------------
4269
- BottomSheetCloseElementComponent.ICON_CLASS = 'fas fa-times';
4270
- BottomSheetCloseElementComponent.ICON_VALUE = null;
4271
- BottomSheetCloseElementComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: BottomSheetCloseElementComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
4272
- BottomSheetCloseElementComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: BottomSheetCloseElementComponent, selector: "vi-bottom-sheet-close-element", usesInheritance: true, ngImport: i0, template: '', isInline: true, styles: [":host{display:block;position:absolute;color:#fff;background-color:#0006;border-radius:50%;padding:8px;font-size:14px;font-weight:700;text-align:center}:host:hover{background-color:#0009}:host.small{font-size:10px;padding:4px}\n"] });
4273
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: BottomSheetCloseElementComponent, decorators: [{
3794
+ WindowResizeElementComponent.ICON_CLASS = 'fas fa-arrows-alt';
3795
+ WindowResizeElementComponent.ICON_VALUE = null;
3796
+ WindowResizeElementComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: WindowResizeElementComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
3797
+ WindowResizeElementComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: WindowResizeElementComponent, selector: "vi-window-resize-element", usesInheritance: true, ngImport: i0, template: '', isInline: true, styles: [":host{display:block;position:absolute;color:#fff;background-color:#0006;border-radius:50%;padding:8px;font-size:14px;font-weight:700;text-align:center}:host:hover{background-color:#0009}:host.small{font-size:10px;padding:4px}\n"] });
3798
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: WindowResizeElementComponent, decorators: [{
4274
3799
  type: Component,
4275
- args: [{ selector: 'vi-bottom-sheet-close-element', template: '', styles: [":host{display:block;position:absolute;color:#fff;background-color:#0006;border-radius:50%;padding:8px;font-size:14px;font-weight:700;text-align:center}:host:hover{background-color:#0009}:host.small{font-size:10px;padding:4px}\n"] }]
3800
+ args: [{ selector: 'vi-window-resize-element', template: '', styles: [":host{display:block;position:absolute;color:#fff;background-color:#0006;border-radius:50%;padding:8px;font-size:14px;font-weight:700;text-align:center}:host:hover{background-color:#0009}:host.small{font-size:10px;padding:4px}\n"] }]
4276
3801
  }], ctorParameters: function () { return [{ type: i0.ElementRef }]; } });
4277
3802
 
4278
- class BottomSheetBaseComponent extends BottomSheetImpl {
3803
+ class WindowBase extends DestroyableContainer {
4279
3804
  // --------------------------------------------------------------------------
4280
3805
  //
4281
- // Protected Methods
3806
+ // Constructor
4282
3807
  //
4283
3808
  // --------------------------------------------------------------------------
4284
- elementsCreate() {
4285
- super.elementsCreate();
4286
- if (!(this.content.container instanceof ViewContainerRef)) {
4287
- return;
3809
+ constructor() {
3810
+ super();
3811
+ // --------------------------------------------------------------------------
3812
+ //
3813
+ // Properties
3814
+ //
3815
+ // --------------------------------------------------------------------------
3816
+ this._x = NaN;
3817
+ this._width = NaN;
3818
+ this._y = NaN;
3819
+ this._height = NaN;
3820
+ this.updatePosition = () => this.setPosition();
3821
+ }
3822
+ setProperties() {
3823
+ let config = this.getConfig();
3824
+ if (!_.isNaN(config.defaultWidth)) {
3825
+ this.width = config.defaultWidth;
4288
3826
  }
4289
- if (!this.config.disableClose) {
4290
- this.elementAdd(this.content.container.createComponent(BottomSheetBaseComponent.CLOSE_COMPONENT));
3827
+ if (!_.isNaN(config.defaultHeight)) {
3828
+ this.height = config.defaultHeight;
4291
3829
  }
4292
3830
  }
4293
- commitIsBlinkProperties() {
4294
- ViewUtil.toggleClass(this.container, this.blinkClass, this.isBlink);
4295
- }
4296
- commitIsDisabledProperties() {
4297
- ViewUtil.toggleClass(this.container, this.disabledClass, this.isDisabled);
4298
- ViewUtil.toggleClass(this.content.element, this.disabledClass, this.isDisabled);
4299
- ViewUtil.toggleClass(this.content.element.nativeElement.parentElement, this.disabledClass, this.isDisabled);
4300
- }
4301
- commitIsShakingProperties() {
4302
- ViewUtil.toggleClass(this.container, this.shakingClass, this.isShaking);
4303
- }
4304
- // --------------------------------------------------------------------------
4305
- //
4306
- // Protected Properties
4307
- //
4308
- // --------------------------------------------------------------------------
4309
- get blinkClass() {
4310
- return 'vi-blink';
3831
+ setPosition() {
3832
+ let config = this.getConfig();
3833
+ switch (config.horizontalAlign) {
3834
+ case WindowAlign.START:
3835
+ this.x = !_.isNaN(this.paddingLeft) ? this.paddingLeft : 0;
3836
+ break;
3837
+ case WindowAlign.END:
3838
+ let value = ViewUtil.getStageWidth() - this.calculateWidth();
3839
+ if (!_.isNaN(this.paddingRight)) {
3840
+ value -= this.paddingRight;
3841
+ }
3842
+ this.x = value;
3843
+ break;
3844
+ default:
3845
+ this.x = (ViewUtil.getStageWidth() - this.calculateWidth()) / 2;
3846
+ break;
3847
+ }
3848
+ switch (config.verticalAlign) {
3849
+ case WindowAlign.START:
3850
+ this.y = !_.isNaN(this.paddingTop) ? this.paddingTop : 0;
3851
+ break;
3852
+ case WindowAlign.END:
3853
+ let value = ViewUtil.getStageHeight() - this.calculateHeight();
3854
+ if (!_.isNaN(this.paddingBottom)) {
3855
+ value -= this.paddingBottom;
3856
+ }
3857
+ this.y = value;
3858
+ break;
3859
+ default:
3860
+ this.y = (ViewUtil.getStageHeight() - this.calculateHeight()) / 2;
3861
+ break;
3862
+ }
4311
3863
  }
4312
- get disabledClass() {
4313
- return 'vi-disabled';
3864
+ clearSize() {
3865
+ this._x = NaN;
3866
+ this._y = NaN;
3867
+ this._width = NaN;
3868
+ this._height = NaN;
4314
3869
  }
4315
- get minimizedClass() {
4316
- return 'vi-minimized';
3870
+ commitSizeProperties() {
3871
+ let width = !_.isNaN(this.width) ? this.width + 'px' : 'auto';
3872
+ let height = !_.isNaN(this.height) ? this.height + 'px' : 'auto';
3873
+ this.getReference().updateSize(width, height);
4317
3874
  }
4318
- get shakingClass() {
4319
- return 'shake-constant shake-horizontal';
3875
+ commitPositionProperties() {
3876
+ if (_.isNaN(this._x) && _.isNaN(this._y)) {
3877
+ return;
3878
+ }
3879
+ let position = {};
3880
+ if (!_.isNaN(this._y)) {
3881
+ position.top = this._y + 'px';
3882
+ }
3883
+ if (!_.isNaN(this._x)) {
3884
+ position.left = this._x + 'px';
3885
+ }
3886
+ this.getReference().updatePosition(position);
4320
3887
  }
4321
- }
4322
- // --------------------------------------------------------------------------
4323
- //
4324
- // Static Properties
4325
- //
4326
- // --------------------------------------------------------------------------
4327
- BottomSheetBaseComponent.CLOSE_COMPONENT = BottomSheetCloseElementComponent;
4328
-
4329
- class IWindowContent extends DestroyableContainer {
4330
3888
  // --------------------------------------------------------------------------
4331
3889
  //
4332
- // Constructor
3890
+ // Public Methods
4333
3891
  //
4334
3892
  // --------------------------------------------------------------------------
4335
- constructor(container) {
4336
- super();
4337
- this.container = container;
3893
+ calculateWidth() {
3894
+ return !_.isNaN(this.width) ? this.width : ViewUtil.getWidth(this.getContainer());
4338
3895
  }
4339
- // --------------------------------------------------------------------------
4340
- //
4341
- // Private Methods
4342
- //
4343
- // --------------------------------------------------------------------------
4344
- commitWindowProperties() {
4345
- this.commitConfigProperties();
3896
+ calculateHeight() {
3897
+ return !_.isNaN(this.height) ? this.height : ViewUtil.getHeight(this.getContainer());
4346
3898
  }
4347
- commitConfigProperties() { }
4348
3899
  // --------------------------------------------------------------------------
4349
3900
  //
4350
- // Public Methods
3901
+ // Private Properties
4351
3902
  //
4352
3903
  // --------------------------------------------------------------------------
4353
- ngAfterViewInit() {
4354
- this.emit(WindowEvent.CONTENT_READY);
4355
- }
4356
- ngOnDestroy() {
4357
- // do nothing, window will destroy content after closing
4358
- }
4359
- blink() {
4360
- if (!_.isNil(this.window)) {
4361
- this.window.blink();
4362
- }
4363
- }
4364
- shake() {
4365
- if (!_.isNil(this.window)) {
4366
- this.window.shake();
4367
- }
3904
+ get width() {
3905
+ return this._width;
4368
3906
  }
4369
- emit(event) {
4370
- if (!_.isNil(this.window)) {
4371
- this.window.emit(event);
3907
+ set width(value) {
3908
+ value = this.getConfig().parseWidth(value);
3909
+ if (value === this._width) {
3910
+ return;
4372
3911
  }
3912
+ this._width = value;
3913
+ this.commitSizeProperties();
4373
3914
  }
4374
- close() {
4375
- if (!_.isNil(this.window)) {
4376
- this.window.close();
4377
- }
3915
+ get height() {
3916
+ return this._height;
4378
3917
  }
4379
- destroy() {
4380
- if (this.isDestroyed) {
3918
+ set height(value) {
3919
+ value = this.getConfig().parseHeight(value);
3920
+ if (value === this._height) {
4381
3921
  return;
4382
3922
  }
4383
- super.destroy();
4384
- this.window = null;
4385
- this.container = null;
3923
+ this._height = value;
3924
+ this.commitSizeProperties();
4386
3925
  }
4387
3926
  // --------------------------------------------------------------------------
4388
3927
  //
4389
- // Proxy Public Properties
3928
+ // Public Properties
4390
3929
  //
4391
3930
  // --------------------------------------------------------------------------
4392
- get data() {
4393
- return !_.isNil(this.config) ? this.config.data : null;
4394
- }
4395
- get isOnTop() {
4396
- return !_.isNil(this.window) ? this.window.isOnTop : false;
4397
- }
4398
- get isMinimized() {
4399
- return !_.isNil(this.window) ? this.window.isMinimized : false;
3931
+ get x() {
3932
+ return this._x;
4400
3933
  }
4401
- get events() {
4402
- return !_.isNil(this.window) ? this.window.events : null;
3934
+ set x(value) {
3935
+ value = this.getConfig().parseX(value);
3936
+ if (value === this._x) {
3937
+ return;
3938
+ }
3939
+ this._x = value;
3940
+ this.commitPositionProperties();
4403
3941
  }
4404
- get isDisabled() {
4405
- return !_.isNil(this.window) ? this.window.isDisabled : false;
3942
+ get y() {
3943
+ return this._y;
4406
3944
  }
4407
- set isDisabled(value) {
4408
- if (!_.isNil(this.window)) {
4409
- this.window.isDisabled = value;
3945
+ set y(value) {
3946
+ value = this.getConfig().parseY(value);
3947
+ if (value === this._y) {
3948
+ return;
4410
3949
  }
3950
+ this._y = value;
3951
+ this.commitPositionProperties();
4411
3952
  }
4412
- // --------------------------------------------------------------------------
4413
- //
4414
- // Public Properties
4415
- //
4416
- // --------------------------------------------------------------------------
4417
- get element() {
4418
- if (_.isNil(this.container)) {
4419
- return null;
4420
- }
4421
- return this.container instanceof ViewContainerRef ? this.container.element : this.container;
3953
+ get paddingTop() {
3954
+ return this.getConfig().paddingTop;
4422
3955
  }
4423
- get config() {
4424
- return !_.isNil(this.window) ? this.window.config : null;
3956
+ get paddingLeft() {
3957
+ return this.getConfig().paddingLeft;
4425
3958
  }
4426
- get window() {
4427
- return this._window;
3959
+ get paddingRight() {
3960
+ return this.getConfig().paddingRight;
4428
3961
  }
4429
- set window(value) {
4430
- if (value === this._window) {
4431
- return;
4432
- }
4433
- this._window = value;
4434
- if (!_.isNil(value)) {
4435
- this.commitWindowProperties();
4436
- }
3962
+ get paddingBottom() {
3963
+ return this.getConfig().paddingBottom;
4437
3964
  }
4438
3965
  }
4439
- IWindowContent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: IWindowContent, deps: [{ token: WINDOW_CONTENT_CONTAINER, optional: true }], target: i0.ɵɵFactoryTarget.Component });
4440
- IWindowContent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: IWindowContent, selector: "ng-component", inputs: { isDisabled: "isDisabled", window: "window" }, usesInheritance: true, ngImport: i0, template: '', isInline: true });
4441
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: IWindowContent, decorators: [{
4442
- type: Component,
4443
- args: [{ template: '' }]
4444
- }], ctorParameters: function () {
4445
- return [{ type: undefined, decorators: [{
4446
- type: Optional
4447
- }, {
4448
- type: Inject,
4449
- args: [WINDOW_CONTENT_CONTAINER]
4450
- }] }];
4451
- }, propDecorators: { isDisabled: [{
4452
- type: Input
4453
- }], window: [{
4454
- type: Input
4455
- }] } });
4456
- const WINDOW_CONTENT_CONTAINER = new InjectionToken('WINDOW_CONTENT_CONTAINER');
4457
3966
 
4458
- class WindowQuestionBaseComponent extends IWindowContent {
3967
+ class WindowImpl extends WindowBase {
4459
3968
  // --------------------------------------------------------------------------
4460
3969
  //
4461
- // Protected Methods
3970
+ // Constructor
4462
3971
  //
4463
3972
  // --------------------------------------------------------------------------
4464
- commitConfigProperties() {
4465
- super.commitConfigProperties();
4466
- this.data.closePromise.then(() => {
4467
- if (!this.isDestroyed) {
4468
- this.close();
3973
+ constructor(properties) {
3974
+ super();
3975
+ // --------------------------------------------------------------------------
3976
+ //
3977
+ // Properties
3978
+ //
3979
+ // --------------------------------------------------------------------------
3980
+ this._isBlink = false;
3981
+ this._isShaking = false;
3982
+ this._isOnTop = false;
3983
+ this._isDisabled = false;
3984
+ this._isMinimized = false;
3985
+ this.isOpened = false;
3986
+ this.isWasOnTop = false;
3987
+ // --------------------------------------------------------------------------
3988
+ //
3989
+ // Protected Methods
3990
+ //
3991
+ // --------------------------------------------------------------------------
3992
+ this.setClosed = () => {
3993
+ this.isOpened = false;
3994
+ this.emit(WindowEvent.CLOSED);
3995
+ this.destroy();
3996
+ };
3997
+ this.setOpened = () => {
3998
+ this.isOpened = true;
3999
+ this.emit(WindowEvent.OPENED);
4000
+ };
4001
+ this.blinkToggle = () => {
4002
+ this.isBlink = !this.isBlink;
4003
+ };
4004
+ this.stopShaking = () => {
4005
+ this.isShaking = false;
4006
+ };
4007
+ this.emitResize = () => {
4008
+ this.emit(WindowEvent.RESIZED);
4009
+ };
4010
+ this.resizeHandler = () => {
4011
+ if (!this.isOpened) {
4012
+ return;
4469
4013
  }
4470
- });
4014
+ clearTimeout(this.resizeTimer);
4015
+ this.resizeTimer = setTimeout(this.emitResize, WindowImpl.RESIZE_DELAY);
4016
+ };
4017
+ this.mouseDownHandlerProxy = (event) => {
4018
+ this.mouseDownHandler(event);
4019
+ };
4020
+ this.mouseClickHandlerProxy = (event) => {
4021
+ this.mouseClickHandler(event);
4022
+ };
4023
+ this.observer = new Subject();
4024
+ this.elements = new Array();
4025
+ this.properties = properties;
4026
+ this.content.window = this;
4027
+ // Have to save for unsubscribe on destroy
4028
+ this._wrapper = this.properties.overlay.hostElement;
4029
+ this._backdrop = this.properties.overlay.backdropElement;
4030
+ this._container = this.properties.overlay.overlayElement;
4031
+ this.setProperties();
4032
+ this.getReference().afterOpened().pipe(takeUntil$1(this.destroyed)).subscribe(this.setOpened);
4033
+ this.getReference().afterClosed().pipe(takeUntil$1(this.destroyed)).subscribe(this.setClosed);
4034
+ this.events
4035
+ .pipe(filter$1(event => event === WindowEvent.CONTENT_READY), takeUntil$1(this.destroyed))
4036
+ .subscribe(this.updatePosition);
4471
4037
  }
4472
- }
4473
-
4474
- class WindowQuestionComponent extends WindowQuestionBaseComponent {
4475
4038
  // --------------------------------------------------------------------------
4476
4039
  //
4477
- // Constructor
4040
+ // Elements Methods
4478
4041
  //
4479
4042
  // --------------------------------------------------------------------------
4480
- constructor(container, language) {
4481
- super(container);
4482
- this.language = language;
4483
- ViewUtil.addClasses(container.element, 'd-block');
4043
+ elementsCreate() {
4044
+ this.elements = new Array();
4045
+ }
4046
+ elementsDestroy() {
4047
+ this.elements.forEach(item => this.elementDestroy(item));
4048
+ this.elements = null;
4049
+ }
4050
+ elementAdd(item) {
4051
+ this.elements.push(item);
4052
+ item.instance.window = this;
4053
+ return item;
4054
+ }
4055
+ elementRemove(item) {
4056
+ ArrayUtil.remove(this.elements, item);
4057
+ this.elementDestroy(item);
4058
+ return item;
4059
+ }
4060
+ elementDestroy(item) {
4061
+ item.instance.window = null;
4062
+ item.destroy();
4063
+ return item;
4064
+ }
4065
+ setProperties() {
4066
+ super.setProperties();
4067
+ ViewUtil.addClass(this.container, 'vi-window');
4068
+ ViewUtil.toggleClass(this.container, 'vi-modal', this.config.isModal);
4069
+ this.container.addEventListener('click', this.mouseClickHandlerProxy, true);
4070
+ if (!this.config.isModal) {
4071
+ this.container.addEventListener('mousedown', this.mouseDownHandlerProxy);
4072
+ }
4073
+ this.elementsCreate();
4074
+ }
4075
+ commitIsBlinkProperties() { }
4076
+ commitIsShakingProperties() { }
4077
+ commitIsDisabledProperties() { }
4078
+ commitIsMinimizedProperties() { }
4079
+ getConfig() {
4080
+ return this.properties.config;
4081
+ }
4082
+ getContainer() {
4083
+ return this.container;
4084
+ }
4085
+ getReference() {
4086
+ return this.properties.reference;
4087
+ }
4088
+ isNeedClickStopPropagation(event) {
4089
+ // return !this.isWasOnTop;
4090
+ if (this.isWasOnTop) {
4091
+ return false;
4092
+ }
4093
+ let element = _.find(this.elements, item => item.location.nativeElement === event.target);
4094
+ if (_.isNil(element)) {
4095
+ return false;
4096
+ }
4097
+ element.instance.clickHandler(event);
4098
+ return true;
4099
+ }
4100
+ stopBlinkIfNeed() {
4101
+ this.isBlink = false;
4102
+ if (!this.blinkTimer) {
4103
+ return;
4104
+ }
4105
+ clearInterval(this.blinkTimer);
4106
+ this.blinkTimer = null;
4107
+ }
4108
+ mouseDownHandler(event) {
4109
+ this.setOnTop();
4110
+ }
4111
+ mouseClickHandler(event) {
4112
+ if (this.isNeedClickStopPropagation(event)) {
4113
+ event.stopPropagation();
4114
+ }
4115
+ if (!this.isWasOnTop) {
4116
+ this.isWasOnTop = true;
4117
+ }
4484
4118
  }
4485
4119
  // --------------------------------------------------------------------------
4486
4120
  //
4487
- // Public Methods
4121
+ // Public Methods
4488
4122
  //
4489
4123
  // --------------------------------------------------------------------------
4490
- commitConfigProperties() {
4491
- super.commitConfigProperties();
4492
- if (!_.isNil(this.data.text)) {
4493
- this.text = this.data.text.replace(/(?:\r\n|\r|\n)/g, `<br/>`);
4494
- }
4495
- if (this.language.isHasTranslation(this.data.options.yesTextId)) {
4496
- this.data.yesText = this.language.translate(this.data.options.yesTextId);
4124
+ emit(event) {
4125
+ this.observer.next(event);
4126
+ }
4127
+ close() {
4128
+ this.getReference().close();
4129
+ }
4130
+ destroy() {
4131
+ if (this.isDestroyed) {
4132
+ return;
4497
4133
  }
4498
- if (this.language.isHasTranslation(this.data.options.notTextId)) {
4499
- this.data.notText = this.language.translate(this.data.options.notTextId);
4134
+ super.destroy();
4135
+ this.elementsDestroy();
4136
+ this._container.removeEventListener('click', this.mouseClickHandlerProxy, true);
4137
+ this._container.removeEventListener('mousedown', this.mouseDownHandlerProxy);
4138
+ if (!_.isNil(this.content)) {
4139
+ this.content.destroy();
4500
4140
  }
4501
- if (this.language.isHasTranslation(this.data.options.checkTextId)) {
4502
- this.data.checkText = this.language.translate(this.data.options.checkTextId);
4141
+ if (!_.isNil(this.observer)) {
4142
+ this.observer.complete();
4143
+ this.observer = null;
4503
4144
  }
4504
- if (this.language.isHasTranslation(this.data.options.closeTextId)) {
4505
- this.data.closeText = this.language.translate(this.data.options.closeTextId);
4145
+ this.properties = null;
4146
+ this._wrapper = null;
4147
+ this._backdrop = null;
4148
+ this._container = null;
4149
+ clearInterval(this.blinkTimer);
4150
+ this.blinkTimer = null;
4151
+ clearInterval(this.shakeTimer);
4152
+ this.shakeTimer = null;
4153
+ clearTimeout(this.resizeTimer);
4154
+ this.resizeTimer = null;
4155
+ }
4156
+ blink() {
4157
+ clearInterval(this.blinkTimer);
4158
+ this.blinkTimer = setInterval(this.blinkToggle, WindowImpl.BLINK_DELAY);
4159
+ }
4160
+ shake() {
4161
+ if (this.isShaking) {
4162
+ return;
4506
4163
  }
4164
+ this.isShaking = true;
4165
+ clearInterval(this.shakeTimer);
4166
+ this.shakeTimer = setInterval(this.stopShaking, WindowImpl.SHAKE_DELAY);
4507
4167
  }
4508
- }
4509
- WindowQuestionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: WindowQuestionComponent, deps: [{ token: i0.ViewContainerRef }, { token: i1$1.LanguageService }], target: i0.ɵɵFactoryTarget.Component });
4510
- WindowQuestionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: WindowQuestionComponent, selector: "ng-component", usesInheritance: true, ngImport: i0, template: "<p class=\"text m-4 text-center mouse-inactive text-word-wrap-break-word\" [innerHTML]=\"text\"></p>\n\n<div class=\"text-center border-sm-top p-3\">\n\n <button (click)=\"data?.closeClickHandler()\" mat-stroked-button *ngIf=\"data?.isInfo\">\n <span [innerHTML]=\"data?.closeText\"></span>\n </button>\n\n <button class=\"mr-3 me-3\" (click)=\"data?.yesClickHandler()\" color=\"primary\" mat-stroked-button *ngIf=\"data?.isQuestion\">\n <span [innerHTML]=\"data?.yesText\"></span>\n </button>\n\n <button (click)=\"data?.notClickHandler()\" mat-stroked-button *ngIf=\"data?.isQuestion\">\n <span [innerHTML]=\"data?.notText\"></span>\n </button>\n\n</div>", components: [{ type: i2.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }], directives: [{ type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
4511
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: WindowQuestionComponent, decorators: [{
4512
- type: Component,
4513
- args: [{ template: "<p class=\"text m-4 text-center mouse-inactive text-word-wrap-break-word\" [innerHTML]=\"text\"></p>\n\n<div class=\"text-center border-sm-top p-3\">\n\n <button (click)=\"data?.closeClickHandler()\" mat-stroked-button *ngIf=\"data?.isInfo\">\n <span [innerHTML]=\"data?.closeText\"></span>\n </button>\n\n <button class=\"mr-3 me-3\" (click)=\"data?.yesClickHandler()\" color=\"primary\" mat-stroked-button *ngIf=\"data?.isQuestion\">\n <span [innerHTML]=\"data?.yesText\"></span>\n </button>\n\n <button (click)=\"data?.notClickHandler()\" mat-stroked-button *ngIf=\"data?.isQuestion\">\n <span [innerHTML]=\"data?.notText\"></span>\n </button>\n\n</div>" }]
4514
- }], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i1$1.LanguageService }]; } });
4515
-
4516
- class WindowCloseElementComponent extends WindowElement {
4517
- // --------------------------------------------------------------------------
4518
- //
4519
- // Constructor
4520
- //
4521
- // --------------------------------------------------------------------------
4522
- constructor(element) {
4523
- super(element);
4168
+ setOnTop() {
4169
+ this.isWasOnTop = this.isOnTop;
4170
+ this.emit(WindowEvent.SET_ON_TOP);
4524
4171
  }
4525
4172
  // --------------------------------------------------------------------------
4526
4173
  //
4527
- // Private Methods
4174
+ // Size Methods
4528
4175
  //
4529
4176
  // --------------------------------------------------------------------------
4530
- createChildren() {
4531
- super.createChildren();
4532
- if (!_.isNil(WindowCloseElementComponent.ICON_VALUE)) {
4533
- ViewUtil.setProperty(this.nativeElement, 'innerHTML', WindowCloseElementComponent.ICON_VALUE);
4534
- }
4535
- if (!_.isNil(WindowCloseElementComponent.ICON_CLASS)) {
4536
- ViewUtil.addClasses(this.nativeElement, WindowCloseElementComponent.ICON_CLASS);
4177
+ getWidth() {
4178
+ return this.width;
4179
+ }
4180
+ getHeight() {
4181
+ return this.height;
4182
+ }
4183
+ setWidth(value, isNeedNotify = true) {
4184
+ this.width = value;
4185
+ if (isNeedNotify) {
4186
+ this.resizeHandler();
4537
4187
  }
4538
- ViewUtil.addClass(this.nativeElement, 'mouse-active');
4539
4188
  }
4540
- // --------------------------------------------------------------------------
4541
- //
4542
- // Event Handlers
4543
- //
4544
- // --------------------------------------------------------------------------
4545
- clickHandler(event) {
4546
- super.clickHandler(event);
4547
- if (!_.isNil(this.window)) {
4548
- this.window.close();
4189
+ setHeight(value, isNeedNotify = true) {
4190
+ this.height = value;
4191
+ if (isNeedNotify) {
4192
+ this.resizeHandler();
4549
4193
  }
4550
4194
  }
4551
- }
4552
- // --------------------------------------------------------------------------
4553
- //
4554
- // Constants
4555
- //
4556
- // --------------------------------------------------------------------------
4557
- WindowCloseElementComponent.ICON_CLASS = 'fas fa-times';
4558
- WindowCloseElementComponent.ICON_VALUE = null;
4559
- WindowCloseElementComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: WindowCloseElementComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
4560
- WindowCloseElementComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: WindowCloseElementComponent, selector: "vi-window-close-element", usesInheritance: true, ngImport: i0, template: '', isInline: true, styles: [":host{display:block;position:absolute;color:#fff;background-color:#0006;border-radius:50%;padding:8px;font-size:14px;font-weight:700;text-align:center}:host:hover{background-color:#0009}:host.small{font-size:10px;padding:4px}\n"] });
4561
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: WindowCloseElementComponent, decorators: [{
4562
- type: Component,
4563
- args: [{ selector: 'vi-window-close-element', template: '', styles: [":host{display:block;position:absolute;color:#fff;background-color:#0006;border-radius:50%;padding:8px;font-size:14px;font-weight:700;text-align:center}:host:hover{background-color:#0009}:host.small{font-size:10px;padding:4px}\n"] }]
4564
- }], ctorParameters: function () { return [{ type: i0.ElementRef }]; } });
4565
-
4566
- class WindowMinimizeElementComponent extends WindowElement {
4567
- // --------------------------------------------------------------------------
4568
- //
4569
- // Constructor
4570
- //
4571
- // --------------------------------------------------------------------------
4572
- constructor(element) {
4573
- super(element);
4574
- // --------------------------------------------------------------------------
4575
- //
4576
- // Private Methods
4577
- //
4578
- // --------------------------------------------------------------------------
4579
- this.commitIconProperties = () => {
4580
- let icon = this.window.isMinimized ? WindowMinimizeElementComponent.ICON_MAXIMIZE_VALUE : WindowMinimizeElementComponent.ICON_MINIMIZE_VALUE;
4581
- ViewUtil.setProperty(this.nativeElement, 'innerHTML', icon);
4582
- };
4195
+ setSize(width, height) {
4196
+ this.setWidth(width, false);
4197
+ this.setHeight(height, false);
4198
+ this.resizeHandler();
4583
4199
  }
4584
4200
  // --------------------------------------------------------------------------
4585
4201
  //
4586
- // Protected Methods
4202
+ // Move Methods
4587
4203
  //
4588
4204
  // --------------------------------------------------------------------------
4589
- commitWindowProperties() {
4590
- super.commitWindowProperties();
4591
- this.window.events.pipe(takeUntil(this.destroyed)).subscribe(event => {
4592
- if (event === WindowEvent.MINIMIZED_CHANGED) {
4593
- this.commitIconProperties();
4594
- }
4595
- });
4205
+ getX() {
4206
+ return this.x;
4596
4207
  }
4597
- createChildren() {
4598
- super.createChildren();
4599
- if (!_.isNil(WindowMinimizeElementComponent.ICON_MINIMIZE_VALUE)) {
4600
- ViewUtil.setProperty(this.nativeElement, 'innerHTML', WindowMinimizeElementComponent.ICON_MINIMIZE_VALUE);
4208
+ setX(value, isNeedNotify = true) {
4209
+ this.x = value;
4210
+ if (isNeedNotify) {
4211
+ this.emit(WindowEvent.MOVED);
4601
4212
  }
4602
- if (!_.isNil(WindowMinimizeElementComponent.ICON_CLASS)) {
4603
- ViewUtil.addClasses(this.nativeElement, WindowMinimizeElementComponent.ICON_CLASS);
4213
+ }
4214
+ getY() {
4215
+ return this.y;
4216
+ }
4217
+ setY(value, isNeedNotify = true) {
4218
+ this.y = value;
4219
+ if (isNeedNotify) {
4220
+ this.emit(WindowEvent.MOVED);
4604
4221
  }
4605
- ViewUtil.addClass(this.nativeElement, 'mouse-active');
4222
+ }
4223
+ move(x, y) {
4224
+ this.setX(x, false);
4225
+ this.setY(y, false);
4226
+ this.emit(WindowEvent.MOVED);
4606
4227
  }
4607
4228
  // --------------------------------------------------------------------------
4608
4229
  //
4609
- // Event Handlers
4230
+ // Private Properties
4610
4231
  //
4611
4232
  // --------------------------------------------------------------------------
4612
- clickHandler(event) {
4613
- super.clickHandler(event);
4614
- if (!_.isNil(this.window)) {
4615
- this.window.isMinimized = !this.window.isMinimized;
4233
+ get isBlink() {
4234
+ return this._isBlink;
4235
+ }
4236
+ set isBlink(value) {
4237
+ if (value === this._isBlink) {
4238
+ return;
4616
4239
  }
4240
+ this._isBlink = value;
4241
+ this.commitIsBlinkProperties();
4617
4242
  }
4618
- }
4619
- // --------------------------------------------------------------------------
4620
- //
4621
- // Constants
4622
- //
4623
- // --------------------------------------------------------------------------
4624
- WindowMinimizeElementComponent.ICON_CLASS = null;
4625
- WindowMinimizeElementComponent.ICON_MINIMIZE_VALUE = null;
4626
- WindowMinimizeElementComponent.ICON_MAXIMIZE_VALUE = null;
4627
- WindowMinimizeElementComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: WindowMinimizeElementComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
4628
- WindowMinimizeElementComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: WindowMinimizeElementComponent, selector: "vi-window-minimize-element", usesInheritance: true, ngImport: i0, template: '', isInline: true, styles: [":host{display:block;position:absolute;color:#fff;background-color:#0006;border-radius:50%;padding:8px;font-size:14px;font-weight:700;text-align:center}:host:hover{background-color:#0009}:host.small{font-size:10px;padding:4px}\n"] });
4629
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: WindowMinimizeElementComponent, decorators: [{
4630
- type: Component,
4631
- args: [{ selector: 'vi-window-minimize-element', template: '', styles: [":host{display:block;position:absolute;color:#fff;background-color:#0006;border-radius:50%;padding:8px;font-size:14px;font-weight:700;text-align:center}:host:hover{background-color:#0009}:host.small{font-size:10px;padding:4px}\n"] }]
4632
- }], ctorParameters: function () { return [{ type: i0.ElementRef }]; } });
4633
-
4634
- class WindowResizeElementComponent extends WindowElement {
4635
- // --------------------------------------------------------------------------
4636
- //
4637
- // Constructor
4638
- //
4639
- // --------------------------------------------------------------------------
4640
- constructor(element) {
4641
- super(element);
4243
+ get isShaking() {
4244
+ return this._isShaking;
4245
+ }
4246
+ set isShaking(value) {
4247
+ if (value === this._isShaking) {
4248
+ return;
4249
+ }
4250
+ this._isShaking = value;
4251
+ this.commitIsShakingProperties();
4642
4252
  }
4643
4253
  // --------------------------------------------------------------------------
4644
4254
  //
4645
- // Private Methods
4255
+ // Public Properties
4646
4256
  //
4647
4257
  // --------------------------------------------------------------------------
4648
- createChildren() {
4649
- super.createChildren();
4650
- if (!_.isNil(WindowResizeElementComponent.ICON_VALUE)) {
4651
- ViewUtil.setProperty(this.nativeElement, 'innerHTML', WindowResizeElementComponent.ICON_VALUE);
4258
+ get events() {
4259
+ return this.observer.asObservable();
4260
+ }
4261
+ get config() {
4262
+ return this.properties.config;
4263
+ }
4264
+ get content() {
4265
+ return this.properties.reference ? this.properties.reference.componentInstance : null;
4266
+ }
4267
+ get container() {
4268
+ return this._container;
4269
+ }
4270
+ get wrapper() {
4271
+ return this._wrapper;
4272
+ }
4273
+ get backdrop() {
4274
+ return this._backdrop;
4275
+ }
4276
+ get isOnTop() {
4277
+ return this._isOnTop;
4278
+ }
4279
+ set isOnTop(value) {
4280
+ if (value === this._isOnTop) {
4281
+ return;
4652
4282
  }
4653
- if (!_.isNil(WindowResizeElementComponent.ICON_CLASS)) {
4654
- ViewUtil.addClasses(this.nativeElement, WindowResizeElementComponent.ICON_CLASS);
4283
+ this._isOnTop = value;
4284
+ clearInterval(this.blinkTimer);
4285
+ this.isBlink = false;
4286
+ }
4287
+ get isMinimized() {
4288
+ return this._isMinimized;
4289
+ }
4290
+ set isMinimized(value) {
4291
+ if (value === this._isMinimized) {
4292
+ return;
4655
4293
  }
4656
- ViewUtil.setStyle(this.nativeElement, 'cursor', 'pointer');
4294
+ this._isMinimized = value;
4295
+ this.commitIsMinimizedProperties();
4296
+ this.emit(WindowEvent.MINIMIZED_CHANGED);
4297
+ this.stopBlinkIfNeed();
4657
4298
  }
4658
- // --------------------------------------------------------------------------
4659
- //
4660
- // Event Handlers
4661
- //
4662
- // --------------------------------------------------------------------------
4663
- clickHandler(event) {
4664
- super.clickHandler(event);
4665
- if (!_.isNil(this.window)) {
4299
+ get isDisabled() {
4300
+ return this._isDisabled;
4301
+ }
4302
+ set isDisabled(value) {
4303
+ if (value === this._isDisabled) {
4304
+ return;
4666
4305
  }
4306
+ this._isDisabled = value;
4307
+ this.commitIsDisabledProperties();
4308
+ this.emit(WindowEvent.DISABLED_CHANGED);
4667
4309
  }
4668
4310
  }
4669
4311
  // --------------------------------------------------------------------------
4670
4312
  //
4671
- // Constants
4313
+ // Constants
4672
4314
  //
4673
4315
  // --------------------------------------------------------------------------
4674
- WindowResizeElementComponent.ICON_CLASS = 'fas fa-arrows-alt';
4675
- WindowResizeElementComponent.ICON_VALUE = null;
4676
- WindowResizeElementComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: WindowResizeElementComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
4677
- WindowResizeElementComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: WindowResizeElementComponent, selector: "vi-window-resize-element", usesInheritance: true, ngImport: i0, template: '', isInline: true, styles: [":host{display:block;position:absolute;color:#fff;background-color:#0006;border-radius:50%;padding:8px;font-size:14px;font-weight:700;text-align:center}:host:hover{background-color:#0009}:host.small{font-size:10px;padding:4px}\n"] });
4678
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: WindowResizeElementComponent, decorators: [{
4679
- type: Component,
4680
- args: [{ selector: 'vi-window-resize-element', template: '', styles: [":host{display:block;position:absolute;color:#fff;background-color:#0006;border-radius:50%;padding:8px;font-size:14px;font-weight:700;text-align:center}:host:hover{background-color:#0009}:host.small{font-size:10px;padding:4px}\n"] }]
4681
- }], ctorParameters: function () { return [{ type: i0.ElementRef }]; } });
4316
+ WindowImpl.BLINK_DELAY = 500;
4317
+ WindowImpl.SHAKE_DELAY = 500;
4318
+ WindowImpl.RESIZE_DELAY = 200;
4682
4319
 
4683
4320
  class WindowResizeable extends WindowImpl {
4684
4321
  // --------------------------------------------------------------------------
@@ -4917,18 +4554,10 @@ class WindowService extends Destroyable {
4917
4554
  this._windows = new Map();
4918
4555
  this.dialog = dialog;
4919
4556
  this.language = language;
4920
- this.observer = new Subject();
4921
- this.properties = new PropertiesManager(cookies);
4922
- this.defaultFactory = new WindowFactory(WindowBaseComponent);
4923
- this.questionComponent = WindowQuestionComponent;
4924
- }
4925
- // --------------------------------------------------------------------------
4926
- //
4927
- // Protected Methods
4928
- //
4929
- // --------------------------------------------------------------------------
4930
- getFactory(component, config) {
4931
- return this.defaultFactory;
4557
+ this.observer = new Subject();
4558
+ this.properties = new PropertiesManager(cookies);
4559
+ this.factory = new WindowFactory(WindowBaseComponent);
4560
+ this.questionComponent = WindowQuestionComponent;
4932
4561
  }
4933
4562
  // --------------------------------------------------------------------------
4934
4563
  //
@@ -5059,7 +4688,7 @@ class WindowService extends Destroyable {
5059
4688
  // let dialog = this.dialog as any;
5060
4689
  // dialog._getOverlayState = config.isModal ? dialog.getOverlayStateModal : dialog.getOverlayStateNonModal;
5061
4690
  let reference = this.dialog.open(component, config);
5062
- window = this.getFactory(component, config).create({ config, reference, overlay: reference._overlayRef });
4691
+ window = this.factory.create({ config, reference, overlay: reference._overlayRef });
5063
4692
  this.observer.next(new ObservableData(WindowServiceEvent.OPEN_STARTED, window));
5064
4693
  let subscription = window.events.subscribe(event => {
5065
4694
  switch (event) {
@@ -5122,114 +4751,428 @@ class WindowService extends Destroyable {
5122
4751
  if (this.isDestroyed) {
5123
4752
  return;
5124
4753
  }
5125
- super.destroy();
5126
- this.removeAll();
4754
+ super.destroy();
4755
+ this.removeAll();
4756
+ if (!_.isNil(this.observer)) {
4757
+ this.observer.complete();
4758
+ this.observer = null;
4759
+ }
4760
+ if (!_.isNil(this.properties)) {
4761
+ this.properties.destroy();
4762
+ this.properties = null;
4763
+ }
4764
+ this.factory = null;
4765
+ this.questionComponent = null;
4766
+ this.dialog = null;
4767
+ this.language = null;
4768
+ this._windows = null;
4769
+ }
4770
+ // --------------------------------------------------------------------------
4771
+ //
4772
+ // Additional Methods
4773
+ //
4774
+ // --------------------------------------------------------------------------
4775
+ info(translationId, translation, questionOptions, configOptions) {
4776
+ let text = this.language.translate(translationId, translation);
4777
+ let config = _.assign(new WindowConfig(true, false, 450), configOptions);
4778
+ config.data = new QuestionManager(_.assign(questionOptions, { mode: QuestionMode.INFO, text }));
4779
+ return this.open(this.questionComponent, config).config.data;
4780
+ }
4781
+ question(translationId, translation, questionOptions, configOptions) {
4782
+ let text = this.language.translate(translationId, translation);
4783
+ let config = _.assign(new WindowConfig(true, false, 450), configOptions);
4784
+ config.data = new QuestionManager(_.assign(questionOptions, { mode: QuestionMode.QUESTION, text }));
4785
+ return this.open(this.questionComponent, config).config.data;
4786
+ }
4787
+ // --------------------------------------------------------------------------
4788
+ //
4789
+ // Private Properties
4790
+ //
4791
+ // --------------------------------------------------------------------------
4792
+ get windowsArray() {
4793
+ return Array.from(this.windows.values()).map(item => item.window);
4794
+ }
4795
+ // --------------------------------------------------------------------------
4796
+ //
4797
+ // Public Properties
4798
+ //
4799
+ // --------------------------------------------------------------------------
4800
+ get events() {
4801
+ return this.observer.asObservable();
4802
+ }
4803
+ get windows() {
4804
+ return this._windows;
4805
+ }
4806
+ }
4807
+ WindowService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: WindowService, deps: [{ token: i1.MatDialog }, { token: i1$1.LanguageService }, { token: CookieService }], target: i0.ɵɵFactoryTarget.Injectable });
4808
+ WindowService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: WindowService, providedIn: 'root' });
4809
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: WindowService, decorators: [{
4810
+ type: Injectable,
4811
+ args: [{ providedIn: 'root' }]
4812
+ }], ctorParameters: function () { return [{ type: i1.MatDialog }, { type: i1$1.LanguageService }, { type: CookieService }]; } });
4813
+ class PropertiesManager extends Destroyable {
4814
+ // --------------------------------------------------------------------------
4815
+ //
4816
+ // Constructor
4817
+ //
4818
+ // --------------------------------------------------------------------------
4819
+ constructor(cookies) {
4820
+ super();
4821
+ this.cookies = cookies;
4822
+ }
4823
+ // --------------------------------------------------------------------------
4824
+ //
4825
+ // Public Methods
4826
+ //
4827
+ // --------------------------------------------------------------------------
4828
+ load(name, config) {
4829
+ let item = this.cookies.getObject(name + 'Window');
4830
+ if (!item) {
4831
+ return;
4832
+ }
4833
+ if (item.hasOwnProperty('width')) {
4834
+ config.defaultWidth = item.width;
4835
+ }
4836
+ if (item.hasOwnProperty('height')) {
4837
+ config.defaultHeight = item.height;
4838
+ }
4839
+ }
4840
+ save(name, window) {
4841
+ this.cookies.putObject(name + 'Window', {
4842
+ width: window.getWidth(),
4843
+ height: window.getHeight()
4844
+ });
4845
+ }
4846
+ destroy() {
4847
+ if (this.isDestroyed) {
4848
+ return;
4849
+ }
4850
+ super.destroy();
4851
+ this.cookies = null;
4852
+ }
4853
+ }
4854
+ var WindowServiceEvent;
4855
+ (function (WindowServiceEvent) {
4856
+ WindowServiceEvent["OPEN_STARTED"] = "OPEN_STARTED";
4857
+ WindowServiceEvent["OPENED"] = "OPENED";
4858
+ WindowServiceEvent["OPEN_FINISHED"] = "OPEN_FINISHED";
4859
+ WindowServiceEvent["CLOSED"] = "CLOSED";
4860
+ WindowServiceEvent["SETTED_ON_TOP"] = "SETTED_ON_TOP";
4861
+ })(WindowServiceEvent || (WindowServiceEvent = {}));
4862
+
4863
+ class BottomSheetImpl extends DestroyableContainer {
4864
+ // --------------------------------------------------------------------------
4865
+ //
4866
+ // Constructor
4867
+ //
4868
+ // --------------------------------------------------------------------------
4869
+ constructor(properties) {
4870
+ super();
4871
+ // --------------------------------------------------------------------------
4872
+ //
4873
+ // Properties
4874
+ //
4875
+ // --------------------------------------------------------------------------
4876
+ this._isBlink = false;
4877
+ this._isDisabled = false;
4878
+ // --------------------------------------------------------------------------
4879
+ //
4880
+ // Protected Methods
4881
+ //
4882
+ // --------------------------------------------------------------------------
4883
+ this.setClosed = () => {
4884
+ this.emit(WindowEvent.CLOSED);
4885
+ this.destroy();
4886
+ };
4887
+ this.setOpened = () => {
4888
+ this.emit(WindowEvent.OPENED);
4889
+ };
4890
+ this.blinkToggle = () => {
4891
+ this.isBlink = !this.isBlink;
4892
+ };
4893
+ this.mouseDownHandlerProxy = (event) => {
4894
+ this.mouseDownHandler(event);
4895
+ };
4896
+ this.mouseClickHandlerProxy = (event) => {
4897
+ this.mouseClickHandler(event);
4898
+ };
4899
+ this.observer = new Subject();
4900
+ this.properties = properties;
4901
+ this.content.window = this;
4902
+ // Have to save for unsubscribe on destroy
4903
+ this._wrapper = this.properties.overlay.hostElement;
4904
+ this._backdrop = this.properties.overlay.backdropElement;
4905
+ this._container = this.properties.overlay.overlayElement;
4906
+ this.setProperties();
4907
+ this.elementsCreate();
4908
+ this.getReference().afterOpened().pipe(takeUntil$1(this.destroyed)).subscribe(this.setOpened);
4909
+ this.getReference().afterDismissed().pipe(takeUntil$1(this.destroyed)).subscribe(this.setClosed);
4910
+ }
4911
+ // --------------------------------------------------------------------------
4912
+ //
4913
+ // Elements Methods
4914
+ //
4915
+ // --------------------------------------------------------------------------
4916
+ elementsCreate() {
4917
+ this.elements = new Array();
4918
+ }
4919
+ elementsDestroy() {
4920
+ this.elements.forEach(item => this.elementDestroy(item));
4921
+ this.elements = null;
4922
+ }
4923
+ elementAdd(item) {
4924
+ this.elements.push(item);
4925
+ item.instance.window = this;
4926
+ return item;
4927
+ }
4928
+ elementRemove(item) {
4929
+ ArrayUtil.remove(this.elements, item);
4930
+ this.elementDestroy(item);
4931
+ return item;
4932
+ }
4933
+ elementDestroy(item) {
4934
+ item.instance.window = null;
4935
+ item.destroy();
4936
+ return item;
4937
+ }
4938
+ setProperties() {
4939
+ ViewUtil.addClass(this.container, 'vi-bottom-sheet');
4940
+ ViewUtil.toggleClass(this.container, 'vi-modal', this.config.isModal);
4941
+ this.container.addEventListener('click', this.mouseClickHandlerProxy, true);
4942
+ if (!this.config.isModal) {
4943
+ this.container.addEventListener('mousedown', this.mouseDownHandlerProxy);
4944
+ }
4945
+ }
4946
+ commitIsBlinkProperties() { }
4947
+ commitIsDisabledProperties() { }
4948
+ getConfig() {
4949
+ return this.properties.config;
4950
+ }
4951
+ getContainer() {
4952
+ return this.container;
4953
+ }
4954
+ getReference() {
4955
+ return this.properties.reference;
4956
+ }
4957
+ isNeedClickStopPropagation(event) {
4958
+ let element = _.find(this.elements, item => item.location.nativeElement === event.target);
4959
+ if (_.isNil(element)) {
4960
+ return false;
4961
+ }
4962
+ element.instance.clickHandler(event);
4963
+ return true;
4964
+ }
4965
+ stopBlinkIfNeed() {
4966
+ this.isBlink = false;
4967
+ if (!this.blinkTimer) {
4968
+ return;
4969
+ }
4970
+ clearInterval(this.blinkTimer);
4971
+ this.blinkTimer = null;
4972
+ }
4973
+ // --------------------------------------------------------------------------
4974
+ //
4975
+ // Event Handlers
4976
+ //
4977
+ // --------------------------------------------------------------------------
4978
+ mouseDownHandler(event) {
4979
+ this.setOnTop();
4980
+ }
4981
+ mouseClickHandler(event) {
4982
+ if (this.isNeedClickStopPropagation(event)) {
4983
+ event.stopPropagation();
4984
+ }
4985
+ }
4986
+ // --------------------------------------------------------------------------
4987
+ //
4988
+ // Public Methods
4989
+ //
4990
+ // --------------------------------------------------------------------------
4991
+ emit(event) {
4992
+ this.observer.next(event);
4993
+ }
4994
+ close() {
4995
+ this.getReference().dismiss();
4996
+ }
4997
+ destroy() {
4998
+ if (this.isDestroyed) {
4999
+ return;
5000
+ }
5001
+ super.destroy();
5002
+ this.elementsDestroy();
5003
+ this._container.removeEventListener('click', this.mouseClickHandlerProxy, true);
5004
+ this._container.removeEventListener('mousedown', this.mouseDownHandlerProxy);
5005
+ if (!_.isNil(this.content)) {
5006
+ this.content.destroy();
5007
+ }
5127
5008
  if (!_.isNil(this.observer)) {
5128
5009
  this.observer.complete();
5129
5010
  this.observer = null;
5130
5011
  }
5131
- if (!_.isNil(this.properties)) {
5132
- this.properties.destroy();
5133
- this.properties = null;
5134
- }
5135
- this.defaultFactory = null;
5136
- this.questionComponent = null;
5137
- this.dialog = null;
5138
- this.language = null;
5139
- this._windows = null;
5012
+ this.properties = null;
5013
+ this._wrapper = null;
5014
+ this._backdrop = null;
5015
+ this._container = null;
5016
+ clearInterval(this.blinkTimer);
5017
+ this.blinkTimer = null;
5140
5018
  }
5019
+ blink() {
5020
+ clearInterval(this.blinkTimer);
5021
+ this.blinkTimer = setInterval(this.blinkToggle, WindowImpl.BLINK_DELAY);
5022
+ }
5023
+ shake() { }
5024
+ setOnTop() { }
5141
5025
  // --------------------------------------------------------------------------
5142
5026
  //
5143
- // Additional Methods
5027
+ // Size Methods
5144
5028
  //
5145
5029
  // --------------------------------------------------------------------------
5146
- info(translationId, translation, questionOptions, configOptions) {
5147
- let text = this.language.translate(translationId, translation);
5148
- let config = _.assign(new WindowConfig(true, false, 450), configOptions);
5149
- config.data = new QuestionManager(_.assign(questionOptions, { mode: QuestionMode.INFO, text }));
5150
- return this.open(this.questionComponent, config).config.data;
5030
+ getWidth() {
5031
+ return NaN;
5151
5032
  }
5152
- question(translationId, translation, questionOptions, configOptions) {
5153
- let text = this.language.translate(translationId, translation);
5154
- let config = _.assign(new WindowConfig(true, false, 450), configOptions);
5155
- config.data = new QuestionManager(_.assign(questionOptions, { mode: QuestionMode.QUESTION, text }));
5156
- return this.open(this.questionComponent, config).config.data;
5033
+ getHeight() {
5034
+ return NaN;
5157
5035
  }
5036
+ setWidth(value, isNeedNotify = true) { }
5037
+ setHeight(value, isNeedNotify = true) { }
5038
+ setSize(width, height) { }
5158
5039
  // --------------------------------------------------------------------------
5159
5040
  //
5160
- // Private Properties
5041
+ // Move Methods
5161
5042
  //
5162
5043
  // --------------------------------------------------------------------------
5163
- get windowsArray() {
5164
- return Array.from(this.windows.values()).map(item => item.window);
5044
+ getX() {
5045
+ return NaN;
5046
+ }
5047
+ setX(value, isNeedNotify = true) { }
5048
+ getY() {
5049
+ return NaN;
5165
5050
  }
5051
+ setY(value, isNeedNotify = true) { }
5052
+ move(x, y) { }
5166
5053
  // --------------------------------------------------------------------------
5167
5054
  //
5168
- // Public Properties
5055
+ // Private Properties
5169
5056
  //
5170
5057
  // --------------------------------------------------------------------------
5171
- get events() {
5172
- return this.observer.asObservable();
5058
+ get reference() {
5059
+ return this.properties.reference;
5173
5060
  }
5174
- get windows() {
5175
- return this._windows;
5061
+ get isBlink() {
5062
+ return this._isBlink;
5176
5063
  }
5177
- }
5178
- WindowService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: WindowService, deps: [{ token: i1.MatDialog }, { token: i1$1.LanguageService }, { token: CookieService }], target: i0.ɵɵFactoryTarget.Injectable });
5179
- WindowService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: WindowService, providedIn: 'root' });
5180
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: WindowService, decorators: [{
5181
- type: Injectable,
5182
- args: [{ providedIn: 'root' }]
5183
- }], ctorParameters: function () { return [{ type: i1.MatDialog }, { type: i1$1.LanguageService }, { type: CookieService }]; } });
5184
- class PropertiesManager extends Destroyable {
5064
+ set isBlink(value) {
5065
+ if (value === this._isBlink) {
5066
+ return;
5067
+ }
5068
+ this._isBlink = value;
5069
+ this.commitIsBlinkProperties();
5070
+ }
5071
+ get isShaking() {
5072
+ return false;
5073
+ }
5074
+ set isShaking(value) { }
5185
5075
  // --------------------------------------------------------------------------
5186
5076
  //
5187
- // Constructor
5077
+ // Public Properties
5188
5078
  //
5189
5079
  // --------------------------------------------------------------------------
5190
- constructor(cookies) {
5191
- super();
5192
- this.cookies = cookies;
5080
+ get events() {
5081
+ return this.observer.asObservable();
5082
+ }
5083
+ get config() {
5084
+ return this.properties.config;
5085
+ }
5086
+ get content() {
5087
+ return !_.isNil(this.reference) ? this.reference.instance : null;
5088
+ }
5089
+ get container() {
5090
+ return this._container;
5091
+ }
5092
+ get wrapper() {
5093
+ return this._wrapper;
5094
+ }
5095
+ get backdrop() {
5096
+ return this._backdrop;
5097
+ }
5098
+ get isOnTop() {
5099
+ return false;
5100
+ }
5101
+ set isOnTop(value) { }
5102
+ get isMinimized() {
5103
+ return false;
5104
+ }
5105
+ set isMinimized(value) { }
5106
+ get isDisabled() {
5107
+ return this._isDisabled;
5108
+ }
5109
+ set isDisabled(value) {
5110
+ if (value === this._isDisabled) {
5111
+ return;
5112
+ }
5113
+ this._isDisabled = value;
5114
+ this.commitIsDisabledProperties();
5115
+ this.emit(WindowEvent.DISABLED_CHANGED);
5193
5116
  }
5117
+ }
5118
+ // --------------------------------------------------------------------------
5119
+ //
5120
+ // Constants
5121
+ //
5122
+ // --------------------------------------------------------------------------
5123
+ BottomSheetImpl.BLINK_DELAY = 500;
5124
+ BottomSheetImpl.SHAKE_DELAY = 500;
5125
+
5126
+ class BottomSheetBaseComponent extends BottomSheetImpl {
5194
5127
  // --------------------------------------------------------------------------
5195
5128
  //
5196
- // Public Methods
5129
+ // Protected Methods
5197
5130
  //
5198
5131
  // --------------------------------------------------------------------------
5199
- load(name, config) {
5200
- let item = this.cookies.getObject(name + 'Window');
5201
- if (!item) {
5132
+ elementsCreate() {
5133
+ super.elementsCreate();
5134
+ if (!(this.content.container instanceof ViewContainerRef)) {
5202
5135
  return;
5203
5136
  }
5204
- if (item.hasOwnProperty('width')) {
5205
- config.defaultWidth = item.width;
5206
- }
5207
- if (item.hasOwnProperty('height')) {
5208
- config.defaultHeight = item.height;
5137
+ if (!this.config.disableClose) {
5138
+ this.elementAdd(this.content.container.createComponent(BottomSheetBaseComponent.CLOSE_COMPONENT));
5209
5139
  }
5210
5140
  }
5211
- save(name, window) {
5212
- this.cookies.putObject(name + 'Window', {
5213
- width: window.getWidth(),
5214
- height: window.getHeight()
5215
- });
5141
+ commitIsBlinkProperties() {
5142
+ ViewUtil.toggleClass(this.container, this.blinkClass, this.isBlink);
5216
5143
  }
5217
- destroy() {
5218
- if (this.isDestroyed) {
5219
- return;
5220
- }
5221
- super.destroy();
5222
- this.cookies = null;
5144
+ commitIsDisabledProperties() {
5145
+ ViewUtil.toggleClass(this.container, this.disabledClass, this.isDisabled);
5146
+ ViewUtil.toggleClass(this.content.element, this.disabledClass, this.isDisabled);
5147
+ ViewUtil.toggleClass(this.content.element.nativeElement.parentElement, this.disabledClass, this.isDisabled);
5148
+ }
5149
+ commitIsShakingProperties() {
5150
+ ViewUtil.toggleClass(this.container, this.shakingClass, this.isShaking);
5151
+ }
5152
+ // --------------------------------------------------------------------------
5153
+ //
5154
+ // Protected Properties
5155
+ //
5156
+ // --------------------------------------------------------------------------
5157
+ get blinkClass() {
5158
+ return 'vi-blink';
5159
+ }
5160
+ get disabledClass() {
5161
+ return 'vi-disabled';
5162
+ }
5163
+ get minimizedClass() {
5164
+ return 'vi-minimized';
5165
+ }
5166
+ get shakingClass() {
5167
+ return 'shake-constant shake-horizontal';
5223
5168
  }
5224
5169
  }
5225
- var WindowServiceEvent;
5226
- (function (WindowServiceEvent) {
5227
- WindowServiceEvent["OPEN_STARTED"] = "OPEN_STARTED";
5228
- WindowServiceEvent["OPENED"] = "OPENED";
5229
- WindowServiceEvent["OPEN_FINISHED"] = "OPEN_FINISHED";
5230
- WindowServiceEvent["CLOSED"] = "CLOSED";
5231
- WindowServiceEvent["SETTED_ON_TOP"] = "SETTED_ON_TOP";
5232
- })(WindowServiceEvent || (WindowServiceEvent = {}));
5170
+ // --------------------------------------------------------------------------
5171
+ //
5172
+ // Static Properties
5173
+ //
5174
+ // --------------------------------------------------------------------------
5175
+ BottomSheetBaseComponent.CLOSE_COMPONENT = WindowBaseComponent.CLOSE_COMPONENT;
5233
5176
 
5234
5177
  class BottomSheetService extends Destroyable {
5235
5178
  // --------------------------------------------------------------------------
@@ -5242,25 +5185,17 @@ class BottomSheetService extends Destroyable {
5242
5185
  this.dialog = dialog;
5243
5186
  this.language = language;
5244
5187
  this.observer = new Subject();
5245
- this.defaultFactory = new WindowFactory(BottomSheetBaseComponent);
5188
+ this.factory = new WindowFactory(BottomSheetBaseComponent);
5246
5189
  this.questionComponent = WindowQuestionComponent;
5247
5190
  }
5248
5191
  // --------------------------------------------------------------------------
5249
5192
  //
5250
- // Protected Methods
5251
- //
5252
- // --------------------------------------------------------------------------
5253
- getFactory(component, config) {
5254
- return this.defaultFactory;
5255
- }
5256
- // --------------------------------------------------------------------------
5257
- //
5258
5193
  // Public Methods
5259
5194
  //
5260
5195
  // --------------------------------------------------------------------------
5261
5196
  open(component, config) {
5262
5197
  let reference = this.dialog.open(component, config);
5263
- let window = this.getFactory(component, config).create({ config, reference: reference, overlay: reference._overlayRef });
5198
+ let window = this.factory.create({ config, reference: reference, overlay: reference._overlayRef });
5264
5199
  this.observer.next(new ObservableData(WindowServiceEvent.OPEN_STARTED, window));
5265
5200
  let subscription = window.events.subscribe(event => {
5266
5201
  switch (event) {
@@ -5287,7 +5222,7 @@ class BottomSheetService extends Destroyable {
5287
5222
  this.observer.complete();
5288
5223
  this.observer = null;
5289
5224
  }
5290
- this.defaultFactory = null;
5225
+ this.factory = null;
5291
5226
  this.questionComponent = null;
5292
5227
  this.dialog = null;
5293
5228
  this.language = null;
@@ -5325,6 +5260,56 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
5325
5260
  args: [{ providedIn: 'root' }]
5326
5261
  }], ctorParameters: function () { return [{ type: i1$2.MatBottomSheet }, { type: i1$1.LanguageService }]; } });
5327
5262
 
5263
+ class BottomSheetCloseElementComponent extends WindowElement {
5264
+ // --------------------------------------------------------------------------
5265
+ //
5266
+ // Constructor
5267
+ //
5268
+ // --------------------------------------------------------------------------
5269
+ constructor(element) {
5270
+ super(element);
5271
+ }
5272
+ // --------------------------------------------------------------------------
5273
+ //
5274
+ // Private Methods
5275
+ //
5276
+ // --------------------------------------------------------------------------
5277
+ createChildren() {
5278
+ super.createChildren();
5279
+ if (!_.isNil(BottomSheetCloseElementComponent.ICON_VALUE)) {
5280
+ ViewUtil.setProperty(this.nativeElement, 'innerHTML', BottomSheetCloseElementComponent.ICON_VALUE);
5281
+ }
5282
+ if (!_.isNil(BottomSheetCloseElementComponent.ICON_CLASS)) {
5283
+ ViewUtil.addClasses(this.nativeElement, BottomSheetCloseElementComponent.ICON_CLASS);
5284
+ }
5285
+ ViewUtil.addClass(this.nativeElement, 'mouse-active');
5286
+ }
5287
+ // --------------------------------------------------------------------------
5288
+ //
5289
+ // Event Handlers
5290
+ //
5291
+ // --------------------------------------------------------------------------
5292
+ clickHandler(event) {
5293
+ super.clickHandler(event);
5294
+ if (!_.isNil(this.window)) {
5295
+ this.window.close();
5296
+ }
5297
+ }
5298
+ }
5299
+ // --------------------------------------------------------------------------
5300
+ //
5301
+ // Constants
5302
+ //
5303
+ // --------------------------------------------------------------------------
5304
+ BottomSheetCloseElementComponent.ICON_CLASS = 'fas fa-times';
5305
+ BottomSheetCloseElementComponent.ICON_VALUE = null;
5306
+ BottomSheetCloseElementComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: BottomSheetCloseElementComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
5307
+ BottomSheetCloseElementComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: BottomSheetCloseElementComponent, selector: "sheet-close-element", usesInheritance: true, ngImport: i0, template: '', isInline: true, styles: [":host{display:block;position:absolute;color:#fff;background-color:#0006;border-radius:50%;padding:8px;font-size:14px;font-weight:700;text-align:center}:host:hover{background-color:#0009}:host.small{font-size:10px;padding:4px}\n"] });
5308
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: BottomSheetCloseElementComponent, decorators: [{
5309
+ type: Component,
5310
+ args: [{ selector: 'sheet-close-element', template: '', styles: [":host{display:block;position:absolute;color:#fff;background-color:#0006;border-radius:50%;padding:8px;font-size:14px;font-weight:700;text-align:center}:host:hover{background-color:#0009}:host.small{font-size:10px;padding:4px}\n"] }]
5311
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }]; } });
5312
+
5328
5313
  const IMPORTS$4 = [CommonModule, FormsModule, MatBottomSheetModule, MatButtonModule, LanguageModule];
5329
5314
  const ENTRY_COMPONENTS$3 = [BottomSheetCloseElementComponent];
5330
5315
  const DECLARATIONS$4 = [...ENTRY_COMPONENTS$3];
@@ -6914,15 +6899,6 @@ class WindowModule {
6914
6899
  return {
6915
6900
  ngModule: WindowModule,
6916
6901
  providers: [WindowService]
6917
- /*
6918
- providers: [
6919
- {
6920
- provide: WindowService,
6921
- deps: [MatDialog, LanguageService, CookieService],
6922
- useFactory: windowServiceFactory
6923
- }
6924
- ]
6925
- */
6926
6902
  };
6927
6903
  }
6928
6904
  }