asksuite-citrus 0.8.3 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2022/lib/asksuite-citrus.module.mjs +7 -4
- package/esm2022/lib/components/autocomplete/autocomplete.component.mjs +12 -12
- package/esm2022/lib/components/toast/toast.component.mjs +68 -0
- package/esm2022/lib/services/toast/toast-ref.mjs +12 -0
- package/esm2022/lib/services/toast/toast.config.mjs +3 -0
- package/esm2022/lib/services/toast/toast.service.mjs +68 -0
- package/esm2022/public-api.mjs +5 -1
- package/fesm2022/asksuite-citrus.mjs +157 -16
- package/fesm2022/asksuite-citrus.mjs.map +1 -1
- package/lib/asksuite-citrus.module.d.ts +8 -7
- package/lib/components/autocomplete/autocomplete.component.d.ts +1 -0
- package/lib/components/toast/toast.component.d.ts +24 -0
- package/lib/services/toast/toast-ref.d.ts +7 -0
- package/lib/services/toast/toast.config.d.ts +11 -0
- package/lib/services/toast/toast.service.d.ts +23 -0
- package/package.json +1 -1
- package/public-api.d.ts +2 -0
@@ -1,5 +1,5 @@
|
|
1
1
|
import * as i0 from '@angular/core';
|
2
|
-
import { EventEmitter, Component, Input, Output, forwardRef, ViewChild, HostListener, Directive, ChangeDetectionStrategy, inject, DestroyRef, HostBinding, Inject, NgModule } from '@angular/core';
|
2
|
+
import { EventEmitter, Component, Input, Output, forwardRef, ViewChild, HostListener, Directive, ChangeDetectionStrategy, inject, DestroyRef, HostBinding, Inject, InjectionToken, NgModule, Injector, Injectable } from '@angular/core';
|
3
3
|
import * as i1 from '@angular/common';
|
4
4
|
import { DOCUMENT, CommonModule } from '@angular/common';
|
5
5
|
import * as i1$2 from '@angular/material/tooltip';
|
@@ -699,17 +699,21 @@ class AutocompleteComponent {
|
|
699
699
|
this.selectionForm = formBuilder.group({});
|
700
700
|
}
|
701
701
|
ngAfterViewInit() {
|
702
|
-
this.checkAllValue =
|
703
|
-
&& this.options.every(value => this.selectionForm.value[value[this.valueProp]]);
|
702
|
+
this.checkAllValue = this.isAllOptionsSelected();
|
704
703
|
this.handleInputChange();
|
705
704
|
this.listenSelectionChange();
|
706
705
|
}
|
706
|
+
isAllOptionsSelected() {
|
707
|
+
return Object.keys(this.selectionForm.value).length === this.options.length
|
708
|
+
&& this.options.every(value => this.selectionForm.value[value[this.valueProp]]);
|
709
|
+
}
|
707
710
|
ngOnChanges(changes) {
|
708
711
|
if (changes['options']) {
|
709
712
|
this._pageNumber = 1;
|
710
713
|
this._reachedEnd = false;
|
711
714
|
this.paginatedFilteredOptions = [];
|
712
715
|
this.filteredOptions = changes['options'].currentValue;
|
716
|
+
this.checkAllValue = this.selection.length === this.filteredOptions.length;
|
713
717
|
this.getMoreItems();
|
714
718
|
}
|
715
719
|
}
|
@@ -733,14 +737,14 @@ class AutocompleteComponent {
|
|
733
737
|
.valueChanges
|
734
738
|
.pipe(takeUntilDestroyed(this._destroy))
|
735
739
|
.subscribe((values) => {
|
736
|
-
this.
|
737
|
-
this.handleSelectionChange(values);
|
740
|
+
this.handleSelectionChange(this.options.filter(option => values[option[this.valueProp]]));
|
738
741
|
this.onChange(this.selection);
|
739
742
|
this.onTouched();
|
743
|
+
this.checkAllValue = this.selection.length === this.options.length;
|
740
744
|
});
|
741
745
|
}
|
742
746
|
handleSelectionChange(values) {
|
743
|
-
this.selection =
|
747
|
+
this.selection = values;
|
744
748
|
if (!this.chipsCollapsed) {
|
745
749
|
this.chipsCollapsed = this.selection.length < 2;
|
746
750
|
}
|
@@ -864,7 +868,6 @@ class AutocompleteComponent {
|
|
864
868
|
const nextPageItems = sortedFilteredOptions
|
865
869
|
.slice(this.ITEMS_PER_PAGE * (this._pageNumber - 1), this.ITEMS_PER_PAGE * this._pageNumber);
|
866
870
|
if (nextPageItems.length) {
|
867
|
-
this.updateFormControls(nextPageItems, this.selectionForm, this.formBuilder, this.valueProp, this.checkAllValue);
|
868
871
|
this.selectionForm.updateValueAndValidity();
|
869
872
|
this.paginatedFilteredOptions = [...this.paginatedFilteredOptions, ...nextPageItems];
|
870
873
|
this._pageNumber += 1;
|
@@ -910,10 +913,6 @@ class AutocompleteComponent {
|
|
910
913
|
// Control Value Accessor
|
911
914
|
writeValue(obj) {
|
912
915
|
this.selection = [];
|
913
|
-
if ((!obj || (Array.isArray(obj) && !obj.length)) && this.selectAll) {
|
914
|
-
this.selectAllOptions(this.selectAll);
|
915
|
-
return;
|
916
|
-
}
|
917
916
|
if (this.multiple && Array.isArray(obj)) {
|
918
917
|
this.selectionForm.reset({}, { emitEvent: false });
|
919
918
|
this.updateFormControls(obj, this.selectionForm, this.formBuilder, this.valueProp, true);
|
@@ -923,7 +922,8 @@ class AutocompleteComponent {
|
|
923
922
|
this.selectedOption = obj;
|
924
923
|
}
|
925
924
|
if (this.multiple && !this.selection.length) {
|
926
|
-
this.handleSelectionChange(
|
925
|
+
this.handleSelectionChange(obj);
|
926
|
+
this.checkAllValue = this.selection.length === this.options.length;
|
927
927
|
}
|
928
928
|
this.change.detectChanges();
|
929
929
|
}
|
@@ -1503,6 +1503,84 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.6", ngImpor
|
|
1503
1503
|
type: Input
|
1504
1504
|
}] } });
|
1505
1505
|
|
1506
|
+
const ASK_TOAST_CONFIG = new InjectionToken('Default toast options');
|
1507
|
+
|
1508
|
+
class ToastRef {
|
1509
|
+
constructor(overlay) {
|
1510
|
+
this.overlay = overlay;
|
1511
|
+
}
|
1512
|
+
close() {
|
1513
|
+
this.overlay.dispose();
|
1514
|
+
}
|
1515
|
+
getPosition() {
|
1516
|
+
return this.overlay.overlayElement.getBoundingClientRect();
|
1517
|
+
}
|
1518
|
+
}
|
1519
|
+
|
1520
|
+
class ToastComponent {
|
1521
|
+
constructor(data, ref) {
|
1522
|
+
this.data = data;
|
1523
|
+
this.ref = ref;
|
1524
|
+
this.message = '';
|
1525
|
+
this.icon = 'check_small';
|
1526
|
+
this.config = {
|
1527
|
+
timeout: 5000,
|
1528
|
+
};
|
1529
|
+
this.color = 'var(--success-green)';
|
1530
|
+
this.fontColor = 'var(--white)';
|
1531
|
+
this.isClosing = false;
|
1532
|
+
this.TYPES = {
|
1533
|
+
success: { color: 'var(--success-green)', icon: 'check_small', fontColor: 'var(--white)' },
|
1534
|
+
warning: { color: 'var(--warning-yellow)', icon: 'warning', fontColor: 'var(--grey-800)' },
|
1535
|
+
danger: { color: 'var(--error-red)', icon: 'error', fontColor: 'var(--white)' },
|
1536
|
+
info: { color: 'var(--facebook-blue)', icon: 'info', fontColor: 'var(--white)' },
|
1537
|
+
};
|
1538
|
+
this.message = data.message;
|
1539
|
+
this.type = data.type;
|
1540
|
+
this.config = {
|
1541
|
+
...this.config,
|
1542
|
+
...data.config
|
1543
|
+
};
|
1544
|
+
}
|
1545
|
+
set type(type) {
|
1546
|
+
this.icon = this.TYPES[type].icon;
|
1547
|
+
this.fontColor = this.TYPES[type].fontColor;
|
1548
|
+
this.color = this.TYPES[type].color;
|
1549
|
+
}
|
1550
|
+
ngOnInit() {
|
1551
|
+
if (this.config?.timeout) {
|
1552
|
+
this.timeoutRef = setTimeout(() => this.close(), this.config.timeout);
|
1553
|
+
}
|
1554
|
+
}
|
1555
|
+
ngOnDestroy() {
|
1556
|
+
clearTimeout(this.timeoutRef);
|
1557
|
+
}
|
1558
|
+
close() {
|
1559
|
+
this.isClosing = true;
|
1560
|
+
setTimeout(() => this.ref.close(), 250);
|
1561
|
+
}
|
1562
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.6", ngImport: i0, type: ToastComponent, deps: [{ token: ASK_TOAST_CONFIG }, { token: ToastRef }], target: i0.ɵɵFactoryTarget.Component }); }
|
1563
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.6", type: ToastComponent, selector: "ask-toast", inputs: { type: "type" }, host: { properties: { "style.background-color": "this.color", "style.color": "this.fontColor", "class.closing": "this.isClosing" } }, ngImport: i0, template: "<span class=\"material-icons icon\">\n {{ icon }}\n</span>\n\n<p class=\"message\">\n {{ message }}\n</p>\n\n<button type=\"button\" class=\"close-icon\" (click)=\"close()\">\n <span class=\"material-icons icon\" [style.color]=\"fontColor\">close</span>\n</button>\n", styles: [":root{--asksuite-orange: #FF5724;--white: #FFF;--grey-50: #F5F7FA;--grey-100: #E4E7EB;--grey-200: #CBD2D9;--grey-300: #9AA5B1;--grey-400: #7B8794;--grey-500: #616E7C;--grey-600: #52606D;--grey-700: #3E4C59;--grey-800: #2A3042;--grey-900: #1F2933;--yellow-50: #FFF8E2;--yellow-200: #FFECB3;--success-green: #4BAF50;--warning-yellow: #FFC107;--error-red: #E8453E;--shadow: rgba(42, 48, 66, .1607843137);--lightblue-tag: #CDF9F3;--lavender-tag: #D4DAF3;--green-tag: #CEEEAA;--pink-tag: #FBC5FF;--orange-tag: #FED5C9;--purple-tag: #DDBFE5;--yellow-tag: #FFE0B2;--blue-tag: #B2E5FD;--brown-tag: #EFC89C;--whatsapp-green: #68B35D;--facebook-blue: #0084FF;--instagram-pink: #D53E91;--google-blue: #345DC8;--telegram-blue: #34AADF;--telephone-yellow: #FECB00;--primary-background: #FFF;--secondary-background: #EFF3F8;--hover-background: #F5F7FA;--divider-background: #E4E7EB;--font-color-100: #2A3042;--font-color-200: #616E7C;--font-color-300: #9AA5B1}:root{--font-default: $font-default;--font-code: $font-code}:root{--font-xs: $font-xs;--font-sm: $font-sm;--font-md: $font-md;--font-lg: $font-lg;--font-xl: $font-xl;--font-xxl: $font-xxl}:root{--font-weight-regular: $font-weight-regular;--font-weight-medium: $font-weight-medium}:root{--radii-px: $radii-px;--radii-xs: $radii-xs;--radii-sm: $radii-sm;--radii-md: $radii-md;--radii-lg: $radii-lg;--radii-full: $radii-full}.ellipsis{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.scale-in-center{animation:scale-in-center .3s ease-in-out both}@keyframes scale-in-center{0%{transform:scale(0);opacity:1}to{transform:scale(1);opacity:1}}.scale-out-center{animation:scale-out-center .3s ease-in-out both}@keyframes scale-out-center{0%{transform:scale(1);opacity:1}to{transform:scale(0);opacity:1}}.ask-tooltip{background-color:#7b8794;color:#fff;padding:4px;border-radius:8px;position:relative}.ask-tooltip>div{text-align:center!important}.ask-tooltip:after{position:absolute;content:\"\";width:10px;height:10px;background-color:inherit}.ask-tooltip.-above{margin-bottom:4px}.ask-tooltip.-above:after{bottom:-5px;left:50%;transform:translate(-50%) rotate(45deg)}.ask-tooltip.-below{margin-top:4px}.ask-tooltip.-below:after{top:-5px;left:50%;transform:translate(-50%) rotate(45deg)}.ask-tooltip.-after,.ask-tooltip.-right{margin-left:4px}.ask-tooltip.-after:after,.ask-tooltip.-right:after{left:-5px;top:50%;transform:translateY(-50%) rotate(45deg)}.ask-tooltip.-before,.ask-tooltip.-left{margin-right:4px}.ask-tooltip.-before:after,.ask-tooltip.-left:after{right:-5px;top:50%;transform:translateY(-50%) rotate(45deg)}.material-icons{font-family:Material Icons;font-weight:400;font-style:normal;font-size:24px;line-height:1;letter-spacing:normal;text-transform:none;display:inline-block;white-space:nowrap;word-wrap:normal;direction:ltr;-webkit-font-feature-settings:\"liga\";-webkit-font-smoothing:antialiased}*{box-sizing:border-box}*,button,select,textarea{font-family:Inter,sans-serif;font-weight:400}input{font-size:1rem}.ask-badge{position:relative}.ask-badge>.badge{position:absolute;display:flex;justify-content:center;align-items:center;background-color:var(--bg-color);color:#fff;font-size:12px;text-overflow:ellipsis;white-space:nowrap;overflow:hidden;border-radius:50%;box-shadow:0 2px 6px -1px #00000080}.ask-badge>.badge.-primary{--bg-color: var(--asksuite-orange)}.ask-badge>.badge.-secondary{--bg-color: var(--grey-800)}.ask-badge>.badge.-top{top:-10px}.ask-badge>.badge.-bottom{bottom:-10px}.ask-badge>.badge.-left{left:-10px}.ask-badge>.badge.-right{right:-10px}.ask-badge>.badge.-small{width:18px;height:18px;font-size:10px}.ask-badge>.badge.-regular{width:22px;height:22px;font-size:11px}.ask-badge>.badge.-large{width:28px;height:28px;font-size:12px}.ask-dropdown-top-right{margin-left:8px}.ask-dropdown-top-left{margin-right:8px}.ask-dropdown-bottom-right,.ask-dropdown-bottom-left{margin-top:8px}:host{position:relative;display:flex;align-items:center;gap:8px;flex-direction:row;width:220px;padding:16px;border-radius:4px;box-shadow:0 0 6px #2a304229;animation:toastIn .2s ease-out 0s 1 normal forwards}@keyframes toastIn{0%{opacity:0;transform:translateY(-10px)}to{opacity:1;transform:translateY(0)}}@keyframes toastOut{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(-10px)}}:host.closing{animation:toastOut .2s ease-out 0s 1 normal forwards}:host>.icon{width:24px;height:24px;-webkit-user-select:none;user-select:none}:host>.message{font-size:1rem}.close-icon{position:absolute;display:flex;align-items:center;justify-content:center;width:14px;height:14px;border:none;outline:none;background:none;cursor:pointer;top:4px;right:4px}.close-icon>.icon{font-size:16px}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
1564
|
+
}
|
1565
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.6", ngImport: i0, type: ToastComponent, decorators: [{
|
1566
|
+
type: Component,
|
1567
|
+
args: [{ selector: 'ask-toast', changeDetection: ChangeDetectionStrategy.OnPush, template: "<span class=\"material-icons icon\">\n {{ icon }}\n</span>\n\n<p class=\"message\">\n {{ message }}\n</p>\n\n<button type=\"button\" class=\"close-icon\" (click)=\"close()\">\n <span class=\"material-icons icon\" [style.color]=\"fontColor\">close</span>\n</button>\n", styles: [":root{--asksuite-orange: #FF5724;--white: #FFF;--grey-50: #F5F7FA;--grey-100: #E4E7EB;--grey-200: #CBD2D9;--grey-300: #9AA5B1;--grey-400: #7B8794;--grey-500: #616E7C;--grey-600: #52606D;--grey-700: #3E4C59;--grey-800: #2A3042;--grey-900: #1F2933;--yellow-50: #FFF8E2;--yellow-200: #FFECB3;--success-green: #4BAF50;--warning-yellow: #FFC107;--error-red: #E8453E;--shadow: rgba(42, 48, 66, .1607843137);--lightblue-tag: #CDF9F3;--lavender-tag: #D4DAF3;--green-tag: #CEEEAA;--pink-tag: #FBC5FF;--orange-tag: #FED5C9;--purple-tag: #DDBFE5;--yellow-tag: #FFE0B2;--blue-tag: #B2E5FD;--brown-tag: #EFC89C;--whatsapp-green: #68B35D;--facebook-blue: #0084FF;--instagram-pink: #D53E91;--google-blue: #345DC8;--telegram-blue: #34AADF;--telephone-yellow: #FECB00;--primary-background: #FFF;--secondary-background: #EFF3F8;--hover-background: #F5F7FA;--divider-background: #E4E7EB;--font-color-100: #2A3042;--font-color-200: #616E7C;--font-color-300: #9AA5B1}:root{--font-default: $font-default;--font-code: $font-code}:root{--font-xs: $font-xs;--font-sm: $font-sm;--font-md: $font-md;--font-lg: $font-lg;--font-xl: $font-xl;--font-xxl: $font-xxl}:root{--font-weight-regular: $font-weight-regular;--font-weight-medium: $font-weight-medium}:root{--radii-px: $radii-px;--radii-xs: $radii-xs;--radii-sm: $radii-sm;--radii-md: $radii-md;--radii-lg: $radii-lg;--radii-full: $radii-full}.ellipsis{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.scale-in-center{animation:scale-in-center .3s ease-in-out both}@keyframes scale-in-center{0%{transform:scale(0);opacity:1}to{transform:scale(1);opacity:1}}.scale-out-center{animation:scale-out-center .3s ease-in-out both}@keyframes scale-out-center{0%{transform:scale(1);opacity:1}to{transform:scale(0);opacity:1}}.ask-tooltip{background-color:#7b8794;color:#fff;padding:4px;border-radius:8px;position:relative}.ask-tooltip>div{text-align:center!important}.ask-tooltip:after{position:absolute;content:\"\";width:10px;height:10px;background-color:inherit}.ask-tooltip.-above{margin-bottom:4px}.ask-tooltip.-above:after{bottom:-5px;left:50%;transform:translate(-50%) rotate(45deg)}.ask-tooltip.-below{margin-top:4px}.ask-tooltip.-below:after{top:-5px;left:50%;transform:translate(-50%) rotate(45deg)}.ask-tooltip.-after,.ask-tooltip.-right{margin-left:4px}.ask-tooltip.-after:after,.ask-tooltip.-right:after{left:-5px;top:50%;transform:translateY(-50%) rotate(45deg)}.ask-tooltip.-before,.ask-tooltip.-left{margin-right:4px}.ask-tooltip.-before:after,.ask-tooltip.-left:after{right:-5px;top:50%;transform:translateY(-50%) rotate(45deg)}.material-icons{font-family:Material Icons;font-weight:400;font-style:normal;font-size:24px;line-height:1;letter-spacing:normal;text-transform:none;display:inline-block;white-space:nowrap;word-wrap:normal;direction:ltr;-webkit-font-feature-settings:\"liga\";-webkit-font-smoothing:antialiased}*{box-sizing:border-box}*,button,select,textarea{font-family:Inter,sans-serif;font-weight:400}input{font-size:1rem}.ask-badge{position:relative}.ask-badge>.badge{position:absolute;display:flex;justify-content:center;align-items:center;background-color:var(--bg-color);color:#fff;font-size:12px;text-overflow:ellipsis;white-space:nowrap;overflow:hidden;border-radius:50%;box-shadow:0 2px 6px -1px #00000080}.ask-badge>.badge.-primary{--bg-color: var(--asksuite-orange)}.ask-badge>.badge.-secondary{--bg-color: var(--grey-800)}.ask-badge>.badge.-top{top:-10px}.ask-badge>.badge.-bottom{bottom:-10px}.ask-badge>.badge.-left{left:-10px}.ask-badge>.badge.-right{right:-10px}.ask-badge>.badge.-small{width:18px;height:18px;font-size:10px}.ask-badge>.badge.-regular{width:22px;height:22px;font-size:11px}.ask-badge>.badge.-large{width:28px;height:28px;font-size:12px}.ask-dropdown-top-right{margin-left:8px}.ask-dropdown-top-left{margin-right:8px}.ask-dropdown-bottom-right,.ask-dropdown-bottom-left{margin-top:8px}:host{position:relative;display:flex;align-items:center;gap:8px;flex-direction:row;width:220px;padding:16px;border-radius:4px;box-shadow:0 0 6px #2a304229;animation:toastIn .2s ease-out 0s 1 normal forwards}@keyframes toastIn{0%{opacity:0;transform:translateY(-10px)}to{opacity:1;transform:translateY(0)}}@keyframes toastOut{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(-10px)}}:host.closing{animation:toastOut .2s ease-out 0s 1 normal forwards}:host>.icon{width:24px;height:24px;-webkit-user-select:none;user-select:none}:host>.message{font-size:1rem}.close-icon{position:absolute;display:flex;align-items:center;justify-content:center;width:14px;height:14px;border:none;outline:none;background:none;cursor:pointer;top:4px;right:4px}.close-icon>.icon{font-size:16px}\n"] }]
|
1568
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
1569
|
+
type: Inject,
|
1570
|
+
args: [ASK_TOAST_CONFIG]
|
1571
|
+
}] }, { type: ToastRef }]; }, propDecorators: { color: [{
|
1572
|
+
type: HostBinding,
|
1573
|
+
args: ['style.background-color']
|
1574
|
+
}], fontColor: [{
|
1575
|
+
type: HostBinding,
|
1576
|
+
args: ['style.color']
|
1577
|
+
}], isClosing: [{
|
1578
|
+
type: HostBinding,
|
1579
|
+
args: ['class.closing']
|
1580
|
+
}], type: [{
|
1581
|
+
type: Input
|
1582
|
+
}] } });
|
1583
|
+
|
1506
1584
|
class AsksuiteCitrusModule {
|
1507
1585
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.6", ngImport: i0, type: AsksuiteCitrusModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
1508
1586
|
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.1.6", ngImport: i0, type: AsksuiteCitrusModule, declarations: [ButtonComponent,
|
@@ -1523,7 +1601,8 @@ class AsksuiteCitrusModule {
|
|
1523
1601
|
BadgeDirective,
|
1524
1602
|
AutofocusDirective,
|
1525
1603
|
ScrollDirective,
|
1526
|
-
AskTooltipDirective
|
1604
|
+
AskTooltipDirective,
|
1605
|
+
ToastComponent], imports: [CommonModule,
|
1527
1606
|
FormsModule,
|
1528
1607
|
ReactiveFormsModule,
|
1529
1608
|
CdkOverlayOrigin,
|
@@ -1577,7 +1656,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.6", ngImpor
|
|
1577
1656
|
BadgeDirective,
|
1578
1657
|
AutofocusDirective,
|
1579
1658
|
ScrollDirective,
|
1580
|
-
AskTooltipDirective
|
1659
|
+
AskTooltipDirective,
|
1660
|
+
ToastComponent,
|
1581
1661
|
],
|
1582
1662
|
imports: [
|
1583
1663
|
CommonModule,
|
@@ -1608,11 +1688,72 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.6", ngImpor
|
|
1608
1688
|
BadgeDirective,
|
1609
1689
|
AutofocusDirective,
|
1610
1690
|
ScrollDirective,
|
1611
|
-
AskTooltipDirective
|
1691
|
+
AskTooltipDirective,
|
1612
1692
|
],
|
1613
1693
|
}]
|
1614
1694
|
}] });
|
1615
1695
|
|
1696
|
+
class ToastService {
|
1697
|
+
constructor(overlay, injector) {
|
1698
|
+
this.overlay = overlay;
|
1699
|
+
this.injector = injector;
|
1700
|
+
this.TOP_MARGIN = 72;
|
1701
|
+
this.GAP = 8;
|
1702
|
+
}
|
1703
|
+
success(message, config) {
|
1704
|
+
this.pop('success', message, config);
|
1705
|
+
}
|
1706
|
+
info(message, config) {
|
1707
|
+
this.pop('info', message, config);
|
1708
|
+
}
|
1709
|
+
danger(message, config) {
|
1710
|
+
this.pop('danger', message, config);
|
1711
|
+
}
|
1712
|
+
warning(message, config) {
|
1713
|
+
this.pop('warning', message, config);
|
1714
|
+
}
|
1715
|
+
pop(type, message, config) {
|
1716
|
+
if (this.lastToast && !this.lastToast?.overlay.overlayElement) {
|
1717
|
+
this.lastToast = undefined;
|
1718
|
+
}
|
1719
|
+
const positionStrategy = this.getPositionStrategy();
|
1720
|
+
const overlayRef = this.overlay.create({
|
1721
|
+
positionStrategy,
|
1722
|
+
});
|
1723
|
+
const toastRef = new ToastRef(overlayRef);
|
1724
|
+
const injector = this.createInjector({ type, message, config }, toastRef);
|
1725
|
+
const toastPortal = new ComponentPortal(ToastComponent, null, injector);
|
1726
|
+
overlayRef.attach(toastPortal);
|
1727
|
+
this.lastToast = toastRef;
|
1728
|
+
}
|
1729
|
+
createInjector(data, toastRef) {
|
1730
|
+
return Injector.create({
|
1731
|
+
parent: this.injector,
|
1732
|
+
providers: [
|
1733
|
+
{ provide: ASK_TOAST_CONFIG, useValue: data },
|
1734
|
+
{ provide: ToastRef, useValue: toastRef },
|
1735
|
+
]
|
1736
|
+
});
|
1737
|
+
}
|
1738
|
+
getPositionStrategy() {
|
1739
|
+
return this.overlay.position().global().top(this.getTopOffset()).centerHorizontally();
|
1740
|
+
}
|
1741
|
+
getTopOffset() {
|
1742
|
+
const offset = this.lastToast ?
|
1743
|
+
this.lastToast.getPosition().bottom + this.GAP :
|
1744
|
+
this.TOP_MARGIN;
|
1745
|
+
return `${offset}px`;
|
1746
|
+
}
|
1747
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.6", ngImport: i0, type: ToastService, deps: [{ token: i1$3.Overlay }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
1748
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.6", ngImport: i0, type: ToastService, providedIn: 'root' }); }
|
1749
|
+
}
|
1750
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.6", ngImport: i0, type: ToastService, decorators: [{
|
1751
|
+
type: Injectable,
|
1752
|
+
args: [{
|
1753
|
+
providedIn: 'root'
|
1754
|
+
}]
|
1755
|
+
}], ctorParameters: function () { return [{ type: i1$3.Overlay }, { type: i0.Injector }]; } });
|
1756
|
+
|
1616
1757
|
/*
|
1617
1758
|
* Public API Surface of asksuite-citrus
|
1618
1759
|
*/
|
@@ -1621,5 +1762,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.6", ngImpor
|
|
1621
1762
|
* Generated bundle index. Do not edit.
|
1622
1763
|
*/
|
1623
1764
|
|
1624
|
-
export { AskDropdownDirective, AskTooltipDirective, AsksuiteCitrusModule, AutocompleteComponent, AutofocusDirective, AvatarComponent, AvatarStatus, BadgeDirective, BoxComponent, ButtonComponent, CheckboxComponent, ChipsComponent, DEFAULT_DATE_FORMAT, DatePickerCalendarComponent, DatePickerComponent, DropdownContainerComponent, InputComponent, PeriodLabel, ScrollDirective, SelectComponent, SkeletonComponent, SpinnerDirective, formatFrom, formatTo };
|
1765
|
+
export { ASK_TOAST_CONFIG, AskDropdownDirective, AskTooltipDirective, AsksuiteCitrusModule, AutocompleteComponent, AutofocusDirective, AvatarComponent, AvatarStatus, BadgeDirective, BoxComponent, ButtonComponent, CheckboxComponent, ChipsComponent, DEFAULT_DATE_FORMAT, DatePickerCalendarComponent, DatePickerComponent, DropdownContainerComponent, InputComponent, PeriodLabel, ScrollDirective, SelectComponent, SkeletonComponent, SpinnerDirective, ToastService, formatFrom, formatTo };
|
1625
1766
|
//# sourceMappingURL=asksuite-citrus.mjs.map
|