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