@tetacom/ng-components 1.5.6 → 1.6.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.
@@ -1,19 +1,21 @@
1
- import { OnInit } from '@angular/core';
2
1
  import { CurrentModal } from '../model/current-modal';
3
- import { DynamicData } from '../../../common/contract/dynamic-data';
2
+ import { DialogButtonType } from '../model/dialog-data';
4
3
  import * as i0 from "@angular/core";
5
- export declare class DialogComponent implements OnInit {
4
+ export declare class DialogComponent {
6
5
  modal: CurrentModal;
7
- private data;
8
- message: string;
9
- buttonText: string;
10
- buttonIcon: string;
11
- buttonPalette: string;
12
- showCancelButton: boolean;
13
- constructor(modal: CurrentModal, data: DynamicData);
6
+ title: string;
7
+ private _text;
8
+ get text(): string;
9
+ set text(value: string);
10
+ private _confirm;
11
+ get confirm(): DialogButtonType;
12
+ set confirm(value: DialogButtonType);
13
+ private _decline;
14
+ get decline(): null | DialogButtonType;
15
+ set decline(value: null | DialogButtonType);
16
+ constructor(modal: CurrentModal);
14
17
  cancel(): void;
15
18
  ok(): void;
16
- ngOnInit(): void;
17
19
  static ɵfac: i0.ɵɵFactoryDeclaration<DialogComponent, never>;
18
- static ɵcmp: i0.ɵɵComponentDeclaration<DialogComponent, "teta-dialog", never, { "message": { "alias": "message"; "required": false; }; "buttonText": { "alias": "buttonText"; "required": false; }; "buttonIcon": { "alias": "buttonIcon"; "required": false; }; "buttonPalette": { "alias": "buttonPalette"; "required": false; }; "showCancelButton": { "alias": "showCancelButton"; "required": false; }; }, {}, never, never, true, never>;
20
+ static ɵcmp: i0.ɵɵComponentDeclaration<DialogComponent, "teta-dialog", never, { "title": { "alias": "title"; "required": true; }; "text": { "alias": "text"; "required": false; }; "confirm": { "alias": "confirm"; "required": false; }; "decline": { "alias": "decline"; "required": false; }; }, {}, never, never, true, never>;
19
21
  }
@@ -1,11 +1,12 @@
1
1
  import { ModalService } from './modal.service';
2
2
  import { Observable } from 'rxjs';
3
+ import { DialogDataType } from './model/dialog-data';
3
4
  import * as i0 from "@angular/core";
4
5
  export declare class DialogService {
5
6
  private _modal;
6
7
  constructor(_modal: ModalService);
7
- alert(message: string): void;
8
- confirm(message: string, buttonText?: string, buttonIcon?: string, buttonPalette?: string): Observable<boolean>;
8
+ alert(title: string): void;
9
+ confirm(confirmDialogData: DialogDataType): Observable<boolean>;
9
10
  private createDialog;
10
11
  static ɵfac: i0.ɵɵFactoryDeclaration<DialogService, never>;
11
12
  static ɵprov: i0.ɵɵInjectableDeclaration<DialogService>;
@@ -0,0 +1,11 @@
1
+ export interface DialogButtonType {
2
+ text: string;
3
+ palette?: string;
4
+ icon?: string;
5
+ }
6
+ export interface DialogDataType {
7
+ title: string;
8
+ text?: string;
9
+ confirm?: DialogButtonType;
10
+ decline?: DialogButtonType;
11
+ }
@@ -5094,9 +5094,26 @@ class CurrentModal {
5094
5094
  }
5095
5095
 
5096
5096
  class DialogComponent {
5097
- constructor(modal, data) {
5097
+ get text() {
5098
+ return this._text;
5099
+ }
5100
+ set text(value) {
5101
+ this._text = value || '';
5102
+ }
5103
+ get confirm() {
5104
+ return this._confirm;
5105
+ }
5106
+ set confirm(value) {
5107
+ this._confirm = value || { text: 'common.ok', palette: 'primary' };
5108
+ }
5109
+ get decline() {
5110
+ return this._decline;
5111
+ }
5112
+ set decline(value) {
5113
+ this._decline = value !== undefined ? value : { text: 'common.cancel', palette: 'text' };
5114
+ }
5115
+ constructor(modal) {
5098
5116
  this.modal = modal;
5099
- this.data = data;
5100
5117
  }
5101
5118
  cancel() {
5102
5119
  this.modal.close({
@@ -5108,22 +5125,20 @@ class DialogComponent {
5108
5125
  reason: ModalCloseReason.resolve,
5109
5126
  });
5110
5127
  }
5111
- ngOnInit() { }
5112
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: DialogComponent, deps: [{ token: CurrentModal }, { token: DynamicData }], target: i0.ɵɵFactoryTarget.Component }); }
5113
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.5", type: DialogComponent, isStandalone: true, selector: "teta-dialog", inputs: { message: "message", buttonText: "buttonText", buttonIcon: "buttonIcon", buttonPalette: "buttonPalette", showCancelButton: "showCancelButton" }, ngImport: i0, template: "<div class=\"padding-2 font-body-2\">\n {{ message | transloco }}\n</div>\n<teta-toolbar class=\"justify-content-end\">\n @if (showCancelButton) {\n <button teta-button (click)=\"cancel()\" [palette]=\"'text'\" [view]=\"'ghost'\">\n {{ 'common.cancel' | transloco }}\n </button>\n }\n\n <button teta-button (click)=\"ok()\" [square]=\"!buttonText?.length\" [palette]=\"buttonPalette\">\n @if (buttonIcon) {\n <teta-icon [name]=\"buttonIcon\"></teta-icon>\n }\n @if (buttonText?.length > 0) {\n {{ buttonText | transloco }}\n }\n </button>\n</teta-toolbar>\n", styles: [":host{display:flex;flex-direction:column;width:300px}\n"], dependencies: [{ kind: "component", type: ToolbarComponent, selector: "teta-toolbar", inputs: ["palette", "class"] }, { kind: "component", type: ButtonComponent, selector: "button[teta-button], teta-button", inputs: ["palette", "class", "view", "square", "viewType", "size"] }, { kind: "component", type: IconComponent, selector: "teta-icon", inputs: ["name", "size", "palette", "class"] }, { kind: "ngmodule", type: TranslocoModule }, { kind: "pipe", type: i1$2.TranslocoPipe, name: "transloco" }] }); }
5128
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: DialogComponent, deps: [{ token: CurrentModal }], target: i0.ɵɵFactoryTarget.Component }); }
5129
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.5", type: DialogComponent, isStandalone: true, selector: "teta-dialog", inputs: { title: "title", text: "text", confirm: "confirm", decline: "decline" }, ngImport: i0, template: "<h3 class=\"padding-2 font-title-2\">\n {{ title | transloco }}\n</h3>\n\n@if (text) {\n <p class=\"padding-2 font-body-3\">\n {{ text | transloco }}\n </p>\n}\n\n<teta-toolbar class=\"justify-content-end\">\n @if (decline) {\n <button teta-button (click)=\"cancel()\" [palette]=\"decline?.palette || 'text'\" [view]=\"'ghost'\">\n @if (decline?.icon) {\n <teta-icon [name]=\"decline.icon\"></teta-icon>\n }\n @if (decline.text) {\n {{ decline.text | transloco }}\n }\n </button>\n }\n\n <button teta-button (click)=\"ok()\" [palette]=\"confirm?.palette || 'primary'\">\n @if (confirm?.icon) {\n <teta-icon [name]=\"confirm.icon\"></teta-icon>\n }\n @if (confirm.text) {\n {{ confirm.text | transloco }}\n }\n </button>\n</teta-toolbar>\n", styles: [":host{display:flex;flex-direction:column;width:300px}\n"], dependencies: [{ kind: "component", type: ToolbarComponent, selector: "teta-toolbar", inputs: ["palette", "class"] }, { kind: "component", type: ButtonComponent, selector: "button[teta-button], teta-button", inputs: ["palette", "class", "view", "square", "viewType", "size"] }, { kind: "component", type: IconComponent, selector: "teta-icon", inputs: ["name", "size", "palette", "class"] }, { kind: "ngmodule", type: TranslocoModule }, { kind: "pipe", type: i1$2.TranslocoPipe, name: "transloco" }] }); }
5114
5130
  }
5115
5131
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: DialogComponent, decorators: [{
5116
5132
  type: Component,
5117
- args: [{ selector: 'teta-dialog', imports: [ToolbarComponent, ButtonComponent, IconComponent, TranslocoModule], template: "<div class=\"padding-2 font-body-2\">\n {{ message | transloco }}\n</div>\n<teta-toolbar class=\"justify-content-end\">\n @if (showCancelButton) {\n <button teta-button (click)=\"cancel()\" [palette]=\"'text'\" [view]=\"'ghost'\">\n {{ 'common.cancel' | transloco }}\n </button>\n }\n\n <button teta-button (click)=\"ok()\" [square]=\"!buttonText?.length\" [palette]=\"buttonPalette\">\n @if (buttonIcon) {\n <teta-icon [name]=\"buttonIcon\"></teta-icon>\n }\n @if (buttonText?.length > 0) {\n {{ buttonText | transloco }}\n }\n </button>\n</teta-toolbar>\n", styles: [":host{display:flex;flex-direction:column;width:300px}\n"] }]
5118
- }], ctorParameters: () => [{ type: CurrentModal }, { type: DynamicData }], propDecorators: { message: [{
5119
- type: Input
5120
- }], buttonText: [{
5121
- type: Input
5122
- }], buttonIcon: [{
5133
+ args: [{ selector: 'teta-dialog', imports: [ToolbarComponent, ButtonComponent, IconComponent, TranslocoModule], template: "<h3 class=\"padding-2 font-title-2\">\n {{ title | transloco }}\n</h3>\n\n@if (text) {\n <p class=\"padding-2 font-body-3\">\n {{ text | transloco }}\n </p>\n}\n\n<teta-toolbar class=\"justify-content-end\">\n @if (decline) {\n <button teta-button (click)=\"cancel()\" [palette]=\"decline?.palette || 'text'\" [view]=\"'ghost'\">\n @if (decline?.icon) {\n <teta-icon [name]=\"decline.icon\"></teta-icon>\n }\n @if (decline.text) {\n {{ decline.text | transloco }}\n }\n </button>\n }\n\n <button teta-button (click)=\"ok()\" [palette]=\"confirm?.palette || 'primary'\">\n @if (confirm?.icon) {\n <teta-icon [name]=\"confirm.icon\"></teta-icon>\n }\n @if (confirm.text) {\n {{ confirm.text | transloco }}\n }\n </button>\n</teta-toolbar>\n", styles: [":host{display:flex;flex-direction:column;width:300px}\n"] }]
5134
+ }], ctorParameters: () => [{ type: CurrentModal }], propDecorators: { title: [{
5135
+ type: Input,
5136
+ args: [{ required: true }]
5137
+ }], text: [{
5123
5138
  type: Input
5124
- }], buttonPalette: [{
5139
+ }], confirm: [{
5125
5140
  type: Input
5126
- }], showCancelButton: [{
5141
+ }], decline: [{
5127
5142
  type: Input
5128
5143
  }] } });
5129
5144
 
@@ -5301,19 +5316,19 @@ class DialogService {
5301
5316
  constructor(_modal) {
5302
5317
  this._modal = _modal;
5303
5318
  }
5304
- alert(message) {
5305
- this.createDialog(message, 'common.ok', null, 'primary', false);
5319
+ alert(title) {
5320
+ this.createDialog({ title, decline: null });
5306
5321
  }
5307
- confirm(message, buttonText = 'common.ok', buttonIcon = null, buttonPalette = 'primary') {
5308
- return this.createDialog(message, buttonText, buttonIcon, buttonPalette, true).pipe(map((result) => result.reason === ModalCloseReason.resolve));
5322
+ confirm(confirmDialogData) {
5323
+ return this.createDialog(confirmDialogData).pipe(map((result) => result.reason === ModalCloseReason.resolve));
5309
5324
  }
5310
- createDialog(message, buttonText = 'common.ok', buttonIcon = null, buttonPalette = 'primary', showCancelButton = true) {
5325
+ createDialog(dialogData) {
5326
+ const { title, text, confirm, decline } = dialogData;
5311
5327
  const dialog = this._modal.create(DialogComponent, {
5312
- message,
5313
- buttonText,
5314
- buttonIcon,
5315
- buttonPalette,
5316
- showCancelButton,
5328
+ title,
5329
+ text,
5330
+ confirm,
5331
+ decline,
5317
5332
  }, {
5318
5333
  esc: true,
5319
5334
  backdrop: true,