quang 19.0.19-2
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/README.md +25 -0
- package/auth/README.md +160 -0
- package/auth/auth-providers.d.ts +39 -0
- package/auth/auth.service.d.ts +52 -0
- package/auth/directives/has-at-least-one-role.directive.d.ts +26 -0
- package/auth/directives/has-every-role.directive.d.ts +26 -0
- package/auth/directives/is-authenticated.directive.d.ts +14 -0
- package/auth/directives/is-not-authenticated.directive.d.ts +14 -0
- package/auth/guards/index.d.ts +2 -0
- package/auth/guards/is-allowed.guard.d.ts +2 -0
- package/auth/guards/is-authenticated.guard.d.ts +2 -0
- package/auth/index.d.ts +9 -0
- package/auth/logout-on-error.interceptor.d.ts +9 -0
- package/auth/mobile/index.d.ts +1 -0
- package/auth/mobile/mobile-auth-feature.d.ts +2 -0
- package/auth/token-storage/index.d.ts +3 -0
- package/auth/token-storage/local-storage-feature.d.ts +2 -0
- package/auth/token-storage/memory-storage-feature.d.ts +12 -0
- package/auth/token-storage/session-storage-feature.d.ts +2 -0
- package/components/autocomplete/autocomplete.component.d.ts +43 -0
- package/components/autocomplete/index.d.ts +1 -0
- package/components/checkbox/checkbox.component.d.ts +11 -0
- package/components/checkbox/index.d.ts +1 -0
- package/components/date/date.component.d.ts +85 -0
- package/components/date/global-date.component.scss +1 -0
- package/components/date/index.d.ts +1 -0
- package/components/input/index.d.ts +1 -0
- package/components/input/input.component.d.ts +15 -0
- package/components/paginator/index.d.ts +5 -0
- package/components/paginator/paginator-language.service.d.ts +10 -0
- package/components/paginator/paginator.component.d.ts +30 -0
- package/components/paginator/paginator.module.d.ts +7 -0
- package/components/paginator/paginator.service.d.ts +6 -0
- package/components/paginator/paginatorIntl.d.ts +12 -0
- package/components/select/index.d.ts +1 -0
- package/components/select/select.component.d.ts +29 -0
- package/components/shared/ErrorData.d.ts +4 -0
- package/components/shared/index.d.ts +4 -0
- package/components/shared/makeId.d.ts +1 -0
- package/components/shared/option-list/option-list.component.d.ts +50 -0
- package/components/shared/quang-base-component.directive.d.ts +50 -0
- package/components/table/index.d.ts +1 -0
- package/components/table/table.component.d.ts +66 -0
- package/components/wysiwyg/global-wysiswyg.component.scss +1 -0
- package/components/wysiwyg/index.d.ts +1 -0
- package/components/wysiwyg/wysiwyg.component.d.ts +46 -0
- package/device/index.d.ts +1 -0
- package/device/resize-observable.service.d.ts +11 -0
- package/fesm2022/quang-auth-mobile.mjs +48 -0
- package/fesm2022/quang-auth-mobile.mjs.map +1 -0
- package/fesm2022/quang-auth.mjs +473 -0
- package/fesm2022/quang-auth.mjs.map +1 -0
- package/fesm2022/quang-components-autocomplete.mjs +196 -0
- package/fesm2022/quang-components-autocomplete.mjs.map +1 -0
- package/fesm2022/quang-components-checkbox.mjs +53 -0
- package/fesm2022/quang-components-checkbox.mjs.map +1 -0
- package/fesm2022/quang-components-date.mjs +392 -0
- package/fesm2022/quang-components-date.mjs.map +1 -0
- package/fesm2022/quang-components-input.mjs +54 -0
- package/fesm2022/quang-components-input.mjs.map +1 -0
- package/fesm2022/quang-components-paginator.mjs +157 -0
- package/fesm2022/quang-components-paginator.mjs.map +1 -0
- package/fesm2022/quang-components-select.mjs +123 -0
- package/fesm2022/quang-components-select.mjs.map +1 -0
- package/fesm2022/quang-components-shared.mjs +386 -0
- package/fesm2022/quang-components-shared.mjs.map +1 -0
- package/fesm2022/quang-components-table.mjs +162 -0
- package/fesm2022/quang-components-table.mjs.map +1 -0
- package/fesm2022/quang-components-wysiwyg.mjs +230 -0
- package/fesm2022/quang-components-wysiwyg.mjs.map +1 -0
- package/fesm2022/quang-device.mjs +42 -0
- package/fesm2022/quang-device.mjs.map +1 -0
- package/fesm2022/quang-forms.mjs +188 -0
- package/fesm2022/quang-forms.mjs.map +1 -0
- package/fesm2022/quang-loader.mjs +116 -0
- package/fesm2022/quang-loader.mjs.map +1 -0
- package/fesm2022/quang-overlay-modal.mjs +118 -0
- package/fesm2022/quang-overlay-modal.mjs.map +1 -0
- package/fesm2022/quang-overlay-popover.mjs +70 -0
- package/fesm2022/quang-overlay-popover.mjs.map +1 -0
- package/fesm2022/quang-overlay-shared.mjs +359 -0
- package/fesm2022/quang-overlay-shared.mjs.map +1 -0
- package/fesm2022/quang-overlay-toast.mjs +105 -0
- package/fesm2022/quang-overlay-toast.mjs.map +1 -0
- package/fesm2022/quang-overlay-tooltip.mjs +56 -0
- package/fesm2022/quang-overlay-tooltip.mjs.map +1 -0
- package/fesm2022/quang-shared.mjs +29 -0
- package/fesm2022/quang-shared.mjs.map +1 -0
- package/fesm2022/quang-translation.mjs +119 -0
- package/fesm2022/quang-translation.mjs.map +1 -0
- package/fesm2022/quang.mjs +23 -0
- package/fesm2022/quang.mjs.map +1 -0
- package/forms/README.md +6 -0
- package/forms/form-group-model.d.ts +18 -0
- package/forms/index.d.ts +2 -0
- package/forms/validators.d.ts +43 -0
- package/index.d.ts +30 -0
- package/loader/README.md +14 -0
- package/loader/index.d.ts +4 -0
- package/loader/loader-providers.d.ts +23 -0
- package/loader/loader.component.d.ts +23 -0
- package/loader/loader.interceptor.d.ts +10 -0
- package/loader/loader.service.d.ts +9 -0
- package/overlay/modal/index.d.ts +1 -0
- package/overlay/modal/modal.component.d.ts +29 -0
- package/overlay/popover/index.d.ts +1 -0
- package/overlay/popover/popover.component.d.ts +13 -0
- package/overlay/popover/popover.directive.d.ts +11 -0
- package/overlay/shared/CustomViewportRuler.d.ts +63 -0
- package/overlay/shared/index.d.ts +3 -0
- package/overlay/shared/quang-base-overlay.component.d.ts +9 -0
- package/overlay/shared/quang-base-overlay.directive.d.ts +44 -0
- package/overlay/toast/index.d.ts +2 -0
- package/overlay/toast/toast.component.d.ts +13 -0
- package/overlay/toast/toast.service.d.ts +27 -0
- package/overlay/tooltip/index.d.ts +2 -0
- package/overlay/tooltip/tooltip.component.d.ts +11 -0
- package/overlay/tooltip/tooltip.directive.d.ts +11 -0
- package/package.json +146 -0
- package/shared/index.d.ts +1 -0
- package/shared/intercept-utils.d.ts +13 -0
- package/translation/README.md +21 -0
- package/translation/index.d.ts +4 -0
- package/translation/translation-loader.service.d.ts +10 -0
- package/translation/translation-providers.d.ts +28 -0
- package/translation/translation.service.d.ts +15 -0
- package/translation/translations.tokens.d.ts +5 -0
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { NgIf, NgClass, NgTemplateOutlet, NgFor } from '@angular/common';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
import { input, output, inject, DestroyRef, viewChild, effect, signal, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
4
|
+
import { toObservable, takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
5
|
+
import { TranslocoPipe } from '@jsverse/transloco';
|
|
6
|
+
import { ResizeObservableService } from 'quang/device';
|
|
7
|
+
|
|
8
|
+
var SortTable;
|
|
9
|
+
(function (SortTable) {
|
|
10
|
+
SortTable["DEFAULT"] = "DEFAULT";
|
|
11
|
+
SortTable["ASC"] = "ASC";
|
|
12
|
+
SortTable["DESC"] = "DESC";
|
|
13
|
+
})(SortTable || (SortTable = {}));
|
|
14
|
+
/**
|
|
15
|
+
* Table component for displaying data in a tabular format.
|
|
16
|
+
*
|
|
17
|
+
* It supports customizable column cells template and sorting rows by column headers.
|
|
18
|
+
*
|
|
19
|
+
* @usageNotes
|
|
20
|
+
* The component must be configured using the {@link TableConfiguration} object
|
|
21
|
+
*/
|
|
22
|
+
class QuangTableComponent {
|
|
23
|
+
constructor() {
|
|
24
|
+
this.clickableRow = input(false);
|
|
25
|
+
this.selectedRows = input();
|
|
26
|
+
this.stickyTable = input(true);
|
|
27
|
+
this.selectedRow = output();
|
|
28
|
+
this.sortChanged = output();
|
|
29
|
+
this.SortTable = SortTable;
|
|
30
|
+
this.destroyRef = inject(DestroyRef);
|
|
31
|
+
this._resizeObservableService = inject(ResizeObservableService);
|
|
32
|
+
this._tableHeader = viewChild('tableHeader');
|
|
33
|
+
this._tableHeaderElement = viewChild('tableHeader');
|
|
34
|
+
this.noResultsText = input('quangTable.noResults');
|
|
35
|
+
this._tableHeaderEffect = effect(() => {
|
|
36
|
+
if (this._tableHeader()) {
|
|
37
|
+
this.fixTableHeaderWidth();
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
this._tableHeaderElementEffect = effect(() => {
|
|
41
|
+
if (this._tableHeaderElement()) {
|
|
42
|
+
this.fixTableHeaderWidth();
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
this._fakeTableHeader = viewChild('fakeTableHeader');
|
|
46
|
+
this._fakeTableHeaderEffect = effect(() => {
|
|
47
|
+
if (this._fakeTableHeader()) {
|
|
48
|
+
this.fixTableHeaderWidth();
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
this.tableConfigurations = input.required();
|
|
52
|
+
this._tableConfigurations = signal({
|
|
53
|
+
headers: [],
|
|
54
|
+
rows: [],
|
|
55
|
+
});
|
|
56
|
+
this.tableConfigurations$ = toObservable(this.tableConfigurations)
|
|
57
|
+
.pipe(takeUntilDestroyed())
|
|
58
|
+
.subscribe((data) => {
|
|
59
|
+
const headers = [];
|
|
60
|
+
const rows = [];
|
|
61
|
+
for (const header of data.headers) {
|
|
62
|
+
headers.push({ ...header });
|
|
63
|
+
}
|
|
64
|
+
for (const row of data.rows) {
|
|
65
|
+
rows.push({ ...row });
|
|
66
|
+
}
|
|
67
|
+
this._tableConfigurations.set({
|
|
68
|
+
headers,
|
|
69
|
+
rows,
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
this.effectTableConfigurations = effect(() => {
|
|
73
|
+
if (this._tableConfigurations()) {
|
|
74
|
+
this.fixTableHeaderWidth();
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
this.hiddenColumnsObservable = undefined;
|
|
78
|
+
this.lastWidth = -1;
|
|
79
|
+
}
|
|
80
|
+
onClickRow(row) {
|
|
81
|
+
if (this.clickableRow()) {
|
|
82
|
+
this.selectedRow.emit(row);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
isSelected(rowId) {
|
|
86
|
+
return !!this.selectedRows()?.some((x) => x === rowId);
|
|
87
|
+
}
|
|
88
|
+
fixTableHeaderWidth() {
|
|
89
|
+
setTimeout(() => {
|
|
90
|
+
const stickyColumns = this._tableHeader()?.nativeElement?.querySelectorAll('th');
|
|
91
|
+
// Copy the column widths from our hidden Primary table header to our Sticky Table header.
|
|
92
|
+
const hiddenColumns = this._fakeTableHeader()?.nativeElement?.querySelectorAll('th');
|
|
93
|
+
if (stickyColumns?.length > 0 && hiddenColumns?.length > 0) {
|
|
94
|
+
if (this.hiddenColumnsObservable) {
|
|
95
|
+
this.hiddenColumnsObservable.unsubscribe();
|
|
96
|
+
}
|
|
97
|
+
this.hiddenColumnsObservable = this._resizeObservableService
|
|
98
|
+
.widthResizeObservable(hiddenColumns[0])
|
|
99
|
+
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
100
|
+
.subscribe((data) => {
|
|
101
|
+
if (data !== this.lastWidth) {
|
|
102
|
+
this.lastWidth = data;
|
|
103
|
+
this.fixTableHeaderWidth();
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
for (let i = 0; i < hiddenColumns?.length; i++) {
|
|
107
|
+
const th = hiddenColumns[i];
|
|
108
|
+
// Since the Sticky Table header is expected to be an exact copy of the Primary Table, we know their indices will be the same.
|
|
109
|
+
stickyColumns[i].style.minWidth = `${th.offsetWidth}px`;
|
|
110
|
+
stickyColumns[i].style.maxWidth = `${th.offsetWidth}px`;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
onSortColumn(sort) {
|
|
116
|
+
const tableHeaders = [];
|
|
117
|
+
for (const header of this._tableConfigurations().headers) {
|
|
118
|
+
tableHeaders.push({
|
|
119
|
+
...header,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
tableHeaders.forEach((header) => {
|
|
123
|
+
if (!header.sort?.key)
|
|
124
|
+
return;
|
|
125
|
+
if (header.sort?.key === sort.key) {
|
|
126
|
+
switch (sort.sort) {
|
|
127
|
+
case SortTable.ASC:
|
|
128
|
+
header.sort.sort = SortTable.DESC;
|
|
129
|
+
break;
|
|
130
|
+
case SortTable.DESC:
|
|
131
|
+
header.sort.sort = SortTable.DEFAULT;
|
|
132
|
+
break;
|
|
133
|
+
case SortTable.DEFAULT:
|
|
134
|
+
default:
|
|
135
|
+
header.sort.sort = SortTable.ASC;
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
header.sort = {
|
|
141
|
+
...header.sort,
|
|
142
|
+
sort: SortTable.DEFAULT,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
this._tableConfigurations.set({ ...this._tableConfigurations(), headers: tableHeaders });
|
|
147
|
+
this.sortChanged.emit([sort]); // it's an array to handle multisort in the future
|
|
148
|
+
}
|
|
149
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.5", ngImport: i0, type: QuangTableComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
150
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "19.2.5", type: QuangTableComponent, isStandalone: true, selector: "quang-table", inputs: { clickableRow: { classPropertyName: "clickableRow", publicName: "clickableRow", isSignal: true, isRequired: false, transformFunction: null }, selectedRows: { classPropertyName: "selectedRows", publicName: "selectedRows", isSignal: true, isRequired: false, transformFunction: null }, stickyTable: { classPropertyName: "stickyTable", publicName: "stickyTable", isSignal: true, isRequired: false, transformFunction: null }, noResultsText: { classPropertyName: "noResultsText", publicName: "noResultsText", isSignal: true, isRequired: false, transformFunction: null }, tableConfigurations: { classPropertyName: "tableConfigurations", publicName: "tableConfigurations", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { selectedRow: "selectedRow", sortChanged: "sortChanged" }, viewQueries: [{ propertyName: "_tableHeader", first: true, predicate: ["tableHeader"], descendants: true, isSignal: true }, { propertyName: "_tableHeaderElement", first: true, predicate: ["tableHeader"], descendants: true, isSignal: true }, { propertyName: "_fakeTableHeader", first: true, predicate: ["fakeTableHeader"], descendants: true, isSignal: true }], ngImport: i0, template: "<div\n [class.sticky-table]=\"stickyTable()\"\n class=\"table-responsive\"\n>\n <ng-container *ngIf=\"_tableConfigurations().rows?.length\">\n <div\n (scroll)=\"tableContainer.scrollLeft = tableHeaderContainer.scrollLeft\"\n #tableHeaderContainer\n class=\"table-header-container\"\n id=\"tableHeaderContainer\"\n >\n <table\n #tableHeader\n id=\"tableHeader\"\n >\n <thead>\n <tr>\n <ng-container *ngFor=\"let header of _tableConfigurations().headers; let i = index\">\n <th\n [class.sort-btn]=\"header?.sort\"\n (click)=\"header?.sort ? onSortColumn(header.sort!) : null\"\n class=\"align-bottom\"\n >\n <div\n [ngClass]=\"header?.css\"\n class=\"align-self-end d-flex gap-1\"\n >\n {{ !header.renderer ? (header.text | transloco) : null }}\n <ng-container\n [ngTemplateOutlet]=\"header?.renderer ?? null\"\n [ngTemplateOutletContext]=\"{\n $implicit: header.payload,\n }\"\n ></ng-container>\n <div\n *ngIf=\"header.sort?.key\"\n class=\"d-flex justify-content-between\"\n >\n <ng-container\n [ngTemplateOutlet]=\"orderBtns\"\n [ngTemplateOutletContext]=\"{ $implicit: header.sort }\"\n ></ng-container>\n </div>\n </div>\n </th>\n </ng-container>\n </tr>\n </thead>\n </table>\n </div>\n <div\n (scroll)=\"tableHeaderContainer.scrollLeft = tableContainer.scrollLeft\"\n #tableContainer\n class=\"table-container\"\n >\n <table\n class=\"table\"\n id=\"table-content\"\n >\n <thead\n #fakeTableHeader\n class=\"fake-table-header\"\n id=\"fakeTableHeader\"\n >\n <tr>\n <ng-container *ngFor=\"let header of _tableConfigurations().headers; let i = index\">\n <th\n [class.sort-btn]=\"header?.sort\"\n (click)=\"header?.sort ? onSortColumn(header.sort!) : null\"\n class=\"align-bottom\"\n >\n <div\n [ngClass]=\"header?.css\"\n class=\"align-self-end d-flex gap-1\"\n >\n {{ !header.renderer ? (header.text | transloco) : null }}\n <ng-container\n [ngTemplateOutlet]=\"header?.renderer ?? null\"\n [ngTemplateOutletContext]=\"{\n $implicit: header.payload,\n }\"\n ></ng-container>\n <div\n *ngIf=\"header.sort?.key\"\n class=\"d-flex justify-content-between\"\n >\n <ng-container\n [ngTemplateOutlet]=\"orderBtns\"\n [ngTemplateOutletContext]=\"{ $implicit: header.sort }\"\n ></ng-container>\n </div>\n </div>\n </th>\n </ng-container>\n </tr>\n </thead>\n <tbody>\n <tr\n [class.hover-table]=\"clickableRow()\"\n [class.selectedRow]=\"row?.rowId ? isSelected(row.rowId!) : null\"\n [ngClass]=\"row.css\"\n (click)=\"clickableRow() ? onClickRow(row) : null\"\n *ngFor=\"let row of _tableConfigurations().rows\"\n >\n <td\n [attr.colspan]=\"cell?.fullWidth ? _tableConfigurations().headers.length : undefined\"\n [ngClass]=\"cell.css!\"\n *ngFor=\"let cell of row.cellData\"\n >\n {{ !cell.renderer ? cell.text : null }}\n <ng-container\n [ngTemplateOutlet]=\"cell?.renderer ?? null\"\n [ngTemplateOutletContext]=\"{\n $implicit: cell.payload,\n }\"\n ></ng-container>\n </td>\n </tr>\n </tbody>\n </table>\n </div>\n </ng-container>\n <h6\n *ngIf=\"!_tableConfigurations().rows?.length\"\n class=\"text-center mt-3\"\n >\n {{ noResultsText() | transloco }}\n </h6>\n</div>\n\n<ng-template\n #orderBtns\n let-order\n>\n <div\n [class.sort-asc]=\"order.sort === SortTable.ASC\"\n [class.sort-default]=\"order.sort === SortTable.DEFAULT\"\n [class.sort-desc]=\"order.sort === SortTable.DESC\"\n class=\"sort-arrows\"\n >\n <svg\n class=\"arrow-up\"\n fill=\"currentColor\"\n height=\"10\"\n stroke=\"currentColor\"\n viewBox=\"279.5 -600.5 401 201\"\n width=\"10\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"m280-400 200-200 200 200H280Z\"\n fill=\"currentColor\"\n stroke=\"currentColor\"\n ></path>\n </svg>\n <svg\n class=\"arrow-down\"\n fill=\"currentColor\"\n height=\"10\"\n stroke=\"currentColor\"\n viewBox=\"279.5 -560.5 401 201\"\n width=\"10\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M480-360 280-560h400L480-360Z\"\n fill=\"currentColor\"\n stroke=\"currentColor\"\n ></path>\n </svg>\n </div>\n</ng-template>\n", styles: [":host{display:block;--table-header-container-top: 0;--table-header-bg: var(--bs-body-bg);--table-header-border-color: var(--bs-border-color);--table-header-border-width: 4px;--table-row-hover-brightness: 90%;--table-row-selected-brightness: 95%}.table-responsive{overflow:initial}.table-responsive .fake-table-header{height:0;overflow:hidden;line-height:0;visibility:collapse}.table-responsive .fake-table-header th{padding-top:0!important;padding-bottom:0!important;margin-top:0!important;margin-bottom:0!important;background-color:var(--table-header-bg);border:unset}.table-responsive .table-header-container{overflow-x:hidden;z-index:1}.table-responsive .table-container{overflow-x:auto}.table-responsive table{width:100%;font-size:16px;overflow-y:auto;margin-bottom:unset}.table-responsive table thead{text-transform:uppercase}.table-responsive table thead th{padding:1rem .5rem;z-index:999;background-color:var(--table-header-bg);box-shadow:inset 0 calc(var(--table-header-border-width) * -1) 0 0 var(--table-header-border-color)}.table-responsive table tbody tr:first-child td{border-top:0}.table-responsive table tbody tr.hover-table:hover{cursor:pointer;filter:brightness(var(--table-row-hover-brightness))}.table-responsive table tbody tr.selectedRow{filter:brightness(var(--table-row-selected-brightness))}.table-responsive table tbody tr td{padding:1rem .5rem;font-weight:300;vertical-align:middle}.table-responsive table tbody tr:last-child{border-bottom:transparent}.table-responsive.sticky-table{position:relative}.table-responsive.sticky-table .table-header-container{position:sticky;top:var(--table-header-container-top, 0)}.sort-arrows{display:flex;flex-direction:column;justify-content:center}.sort-default{opacity:30%}.sort-asc .arrow-up{opacity:100%}.sort-asc .arrow-down,.sort-desc .arrow-up{display:none}.sort-desc .arrow-down{opacity:100%}.sort-btn:hover{cursor:pointer}\n"], dependencies: [{ kind: "pipe", type: TranslocoPipe, name: "transloco" }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: NgFor, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
151
|
+
}
|
|
152
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.5", ngImport: i0, type: QuangTableComponent, decorators: [{
|
|
153
|
+
type: Component,
|
|
154
|
+
args: [{ selector: 'quang-table', imports: [TranslocoPipe, NgIf, NgClass, NgTemplateOutlet, NgFor], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div\n [class.sticky-table]=\"stickyTable()\"\n class=\"table-responsive\"\n>\n <ng-container *ngIf=\"_tableConfigurations().rows?.length\">\n <div\n (scroll)=\"tableContainer.scrollLeft = tableHeaderContainer.scrollLeft\"\n #tableHeaderContainer\n class=\"table-header-container\"\n id=\"tableHeaderContainer\"\n >\n <table\n #tableHeader\n id=\"tableHeader\"\n >\n <thead>\n <tr>\n <ng-container *ngFor=\"let header of _tableConfigurations().headers; let i = index\">\n <th\n [class.sort-btn]=\"header?.sort\"\n (click)=\"header?.sort ? onSortColumn(header.sort!) : null\"\n class=\"align-bottom\"\n >\n <div\n [ngClass]=\"header?.css\"\n class=\"align-self-end d-flex gap-1\"\n >\n {{ !header.renderer ? (header.text | transloco) : null }}\n <ng-container\n [ngTemplateOutlet]=\"header?.renderer ?? null\"\n [ngTemplateOutletContext]=\"{\n $implicit: header.payload,\n }\"\n ></ng-container>\n <div\n *ngIf=\"header.sort?.key\"\n class=\"d-flex justify-content-between\"\n >\n <ng-container\n [ngTemplateOutlet]=\"orderBtns\"\n [ngTemplateOutletContext]=\"{ $implicit: header.sort }\"\n ></ng-container>\n </div>\n </div>\n </th>\n </ng-container>\n </tr>\n </thead>\n </table>\n </div>\n <div\n (scroll)=\"tableHeaderContainer.scrollLeft = tableContainer.scrollLeft\"\n #tableContainer\n class=\"table-container\"\n >\n <table\n class=\"table\"\n id=\"table-content\"\n >\n <thead\n #fakeTableHeader\n class=\"fake-table-header\"\n id=\"fakeTableHeader\"\n >\n <tr>\n <ng-container *ngFor=\"let header of _tableConfigurations().headers; let i = index\">\n <th\n [class.sort-btn]=\"header?.sort\"\n (click)=\"header?.sort ? onSortColumn(header.sort!) : null\"\n class=\"align-bottom\"\n >\n <div\n [ngClass]=\"header?.css\"\n class=\"align-self-end d-flex gap-1\"\n >\n {{ !header.renderer ? (header.text | transloco) : null }}\n <ng-container\n [ngTemplateOutlet]=\"header?.renderer ?? null\"\n [ngTemplateOutletContext]=\"{\n $implicit: header.payload,\n }\"\n ></ng-container>\n <div\n *ngIf=\"header.sort?.key\"\n class=\"d-flex justify-content-between\"\n >\n <ng-container\n [ngTemplateOutlet]=\"orderBtns\"\n [ngTemplateOutletContext]=\"{ $implicit: header.sort }\"\n ></ng-container>\n </div>\n </div>\n </th>\n </ng-container>\n </tr>\n </thead>\n <tbody>\n <tr\n [class.hover-table]=\"clickableRow()\"\n [class.selectedRow]=\"row?.rowId ? isSelected(row.rowId!) : null\"\n [ngClass]=\"row.css\"\n (click)=\"clickableRow() ? onClickRow(row) : null\"\n *ngFor=\"let row of _tableConfigurations().rows\"\n >\n <td\n [attr.colspan]=\"cell?.fullWidth ? _tableConfigurations().headers.length : undefined\"\n [ngClass]=\"cell.css!\"\n *ngFor=\"let cell of row.cellData\"\n >\n {{ !cell.renderer ? cell.text : null }}\n <ng-container\n [ngTemplateOutlet]=\"cell?.renderer ?? null\"\n [ngTemplateOutletContext]=\"{\n $implicit: cell.payload,\n }\"\n ></ng-container>\n </td>\n </tr>\n </tbody>\n </table>\n </div>\n </ng-container>\n <h6\n *ngIf=\"!_tableConfigurations().rows?.length\"\n class=\"text-center mt-3\"\n >\n {{ noResultsText() | transloco }}\n </h6>\n</div>\n\n<ng-template\n #orderBtns\n let-order\n>\n <div\n [class.sort-asc]=\"order.sort === SortTable.ASC\"\n [class.sort-default]=\"order.sort === SortTable.DEFAULT\"\n [class.sort-desc]=\"order.sort === SortTable.DESC\"\n class=\"sort-arrows\"\n >\n <svg\n class=\"arrow-up\"\n fill=\"currentColor\"\n height=\"10\"\n stroke=\"currentColor\"\n viewBox=\"279.5 -600.5 401 201\"\n width=\"10\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"m280-400 200-200 200 200H280Z\"\n fill=\"currentColor\"\n stroke=\"currentColor\"\n ></path>\n </svg>\n <svg\n class=\"arrow-down\"\n fill=\"currentColor\"\n height=\"10\"\n stroke=\"currentColor\"\n viewBox=\"279.5 -560.5 401 201\"\n width=\"10\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M480-360 280-560h400L480-360Z\"\n fill=\"currentColor\"\n stroke=\"currentColor\"\n ></path>\n </svg>\n </div>\n</ng-template>\n", styles: [":host{display:block;--table-header-container-top: 0;--table-header-bg: var(--bs-body-bg);--table-header-border-color: var(--bs-border-color);--table-header-border-width: 4px;--table-row-hover-brightness: 90%;--table-row-selected-brightness: 95%}.table-responsive{overflow:initial}.table-responsive .fake-table-header{height:0;overflow:hidden;line-height:0;visibility:collapse}.table-responsive .fake-table-header th{padding-top:0!important;padding-bottom:0!important;margin-top:0!important;margin-bottom:0!important;background-color:var(--table-header-bg);border:unset}.table-responsive .table-header-container{overflow-x:hidden;z-index:1}.table-responsive .table-container{overflow-x:auto}.table-responsive table{width:100%;font-size:16px;overflow-y:auto;margin-bottom:unset}.table-responsive table thead{text-transform:uppercase}.table-responsive table thead th{padding:1rem .5rem;z-index:999;background-color:var(--table-header-bg);box-shadow:inset 0 calc(var(--table-header-border-width) * -1) 0 0 var(--table-header-border-color)}.table-responsive table tbody tr:first-child td{border-top:0}.table-responsive table tbody tr.hover-table:hover{cursor:pointer;filter:brightness(var(--table-row-hover-brightness))}.table-responsive table tbody tr.selectedRow{filter:brightness(var(--table-row-selected-brightness))}.table-responsive table tbody tr td{padding:1rem .5rem;font-weight:300;vertical-align:middle}.table-responsive table tbody tr:last-child{border-bottom:transparent}.table-responsive.sticky-table{position:relative}.table-responsive.sticky-table .table-header-container{position:sticky;top:var(--table-header-container-top, 0)}.sort-arrows{display:flex;flex-direction:column;justify-content:center}.sort-default{opacity:30%}.sort-asc .arrow-up{opacity:100%}.sort-asc .arrow-down,.sort-desc .arrow-up{display:none}.sort-desc .arrow-down{opacity:100%}.sort-btn:hover{cursor:pointer}\n"] }]
|
|
155
|
+
}] });
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Generated bundle index. Do not edit.
|
|
159
|
+
*/
|
|
160
|
+
|
|
161
|
+
export { QuangTableComponent, SortTable };
|
|
162
|
+
//# sourceMappingURL=quang-components-table.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quang-components-table.mjs","sources":["../../../projects/quang/components/table/table.component.ts","../../../projects/quang/components/table/table.component.html","../../../projects/quang/components/table/quang-components-table.ts"],"sourcesContent":["import { NgClass, NgFor, NgIf, NgTemplateOutlet } from '@angular/common'\nimport {\n ChangeDetectionStrategy,\n Component,\n DestroyRef,\n ElementRef,\n TemplateRef,\n effect,\n inject,\n input,\n output,\n signal,\n viewChild,\n} from '@angular/core'\nimport { takeUntilDestroyed, toObservable } from '@angular/core/rxjs-interop'\n\nimport { TranslocoPipe } from '@jsverse/transloco'\nimport { ResizeObservableService } from 'quang/device'\nimport { Subscription } from 'rxjs'\n\nexport interface TableHeader {\n text?: string\n sort?: SortCol\n css?: string[]\n renderer?: TemplateRef<any>\n payload?: any\n}\n\nexport interface TableConfiguration<T> {\n headers: TableHeader[]\n rows: TableRow<T>[]\n}\n\nexport interface TableCell {\n renderer?: TemplateRef<any>\n payload?: any\n text?: string\n css?: string[]\n fullWidth?: boolean\n}\n\nexport interface TableRow<T> {\n payload?: T\n rowId?: string | number\n css?: string[]\n cellData: TableCell[]\n}\n\nexport enum SortTable {\n DEFAULT = 'DEFAULT',\n ASC = 'ASC',\n DESC = 'DESC',\n}\n\nexport interface SortCol {\n key: string\n sort: SortTable\n}\n\n@Component({\n selector: 'quang-table',\n templateUrl: './table.component.html',\n styleUrl: './table.component.scss',\n imports: [TranslocoPipe, NgIf, NgClass, NgTemplateOutlet, NgFor],\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\n/**\n * Table component for displaying data in a tabular format.\n *\n * It supports customizable column cells template and sorting rows by column headers.\n *\n * @usageNotes\n * The component must be configured using the {@link TableConfiguration} object\n */\nexport class QuangTableComponent<T> {\n clickableRow = input<boolean>(false)\n\n selectedRows = input<string[] | number[]>()\n\n stickyTable = input<boolean>(true)\n\n selectedRow = output<TableRow<T>>()\n\n sortChanged = output<SortCol[]>()\n\n public SortTable = SortTable\n\n destroyRef = inject(DestroyRef)\n\n _resizeObservableService = inject(ResizeObservableService)\n\n _tableHeader = viewChild<ElementRef>('tableHeader')\n\n _tableHeaderElement = viewChild<Element>('tableHeader')\n\n noResultsText = input<string>('quangTable.noResults')\n\n _tableHeaderEffect = effect(() => {\n if (this._tableHeader()) {\n this.fixTableHeaderWidth()\n }\n })\n\n _tableHeaderElementEffect = effect(() => {\n if (this._tableHeaderElement()) {\n this.fixTableHeaderWidth()\n }\n })\n\n _fakeTableHeader = viewChild<ElementRef>('fakeTableHeader')\n\n _fakeTableHeaderEffect = effect(() => {\n if (this._fakeTableHeader()) {\n this.fixTableHeaderWidth()\n }\n })\n\n tableConfigurations = input.required<TableConfiguration<T>>()\n\n _tableConfigurations = signal<TableConfiguration<T>>({\n headers: [],\n rows: [],\n })\n\n tableConfigurations$ = toObservable(this.tableConfigurations)\n .pipe(takeUntilDestroyed())\n .subscribe((data) => {\n const headers: TableHeader[] = []\n const rows: TableRow<T>[] = []\n for (const header of data.headers) {\n headers.push({ ...header })\n }\n for (const row of data.rows) {\n rows.push({ ...row })\n }\n this._tableConfigurations.set({\n headers,\n rows,\n })\n })\n\n effectTableConfigurations = effect(() => {\n if (this._tableConfigurations()) {\n this.fixTableHeaderWidth()\n }\n })\n\n hiddenColumnsObservable?: Subscription = undefined\n\n onClickRow(row: TableRow<T>): void {\n if (this.clickableRow()) {\n this.selectedRow.emit(row)\n }\n }\n\n isSelected(rowId: string | number): boolean {\n return !!this.selectedRows()?.some((x) => x === rowId)\n }\n\n lastWidth = -1\n\n fixTableHeaderWidth() {\n setTimeout(() => {\n const stickyColumns = this._tableHeader()?.nativeElement?.querySelectorAll('th')\n\n // Copy the column widths from our hidden Primary table header to our Sticky Table header.\n const hiddenColumns = this._fakeTableHeader()?.nativeElement?.querySelectorAll('th')\n\n if (stickyColumns?.length > 0 && hiddenColumns?.length > 0) {\n if (this.hiddenColumnsObservable) {\n this.hiddenColumnsObservable.unsubscribe()\n }\n this.hiddenColumnsObservable = this._resizeObservableService\n .widthResizeObservable(hiddenColumns[0])\n .pipe(takeUntilDestroyed(this.destroyRef))\n .subscribe((data) => {\n if (data !== this.lastWidth) {\n this.lastWidth = data\n this.fixTableHeaderWidth()\n }\n })\n for (let i = 0; i < hiddenColumns?.length; i++) {\n const th = hiddenColumns[i]\n // Since the Sticky Table header is expected to be an exact copy of the Primary Table, we know their indices will be the same.\n stickyColumns[i].style.minWidth = `${th.offsetWidth}px`\n stickyColumns[i].style.maxWidth = `${th.offsetWidth}px`\n }\n }\n })\n }\n\n onSortColumn(sort: SortCol): void {\n const tableHeaders: TableHeader[] = []\n for (const header of this._tableConfigurations().headers) {\n tableHeaders.push({\n ...header,\n })\n }\n tableHeaders.forEach((header) => {\n if (!header.sort?.key) return\n\n if (header.sort?.key === sort.key) {\n switch (sort.sort) {\n case SortTable.ASC:\n header.sort.sort = SortTable.DESC\n break\n case SortTable.DESC:\n header.sort.sort = SortTable.DEFAULT\n break\n case SortTable.DEFAULT:\n default:\n header.sort.sort = SortTable.ASC\n break\n }\n } else {\n header.sort = {\n ...header.sort,\n sort: SortTable.DEFAULT,\n }\n }\n })\n this._tableConfigurations.set({ ...this._tableConfigurations(), headers: tableHeaders })\n this.sortChanged.emit([sort]) // it's an array to handle multisort in the future\n }\n}\n","<div\n [class.sticky-table]=\"stickyTable()\"\n class=\"table-responsive\"\n>\n <ng-container *ngIf=\"_tableConfigurations().rows?.length\">\n <div\n (scroll)=\"tableContainer.scrollLeft = tableHeaderContainer.scrollLeft\"\n #tableHeaderContainer\n class=\"table-header-container\"\n id=\"tableHeaderContainer\"\n >\n <table\n #tableHeader\n id=\"tableHeader\"\n >\n <thead>\n <tr>\n <ng-container *ngFor=\"let header of _tableConfigurations().headers; let i = index\">\n <th\n [class.sort-btn]=\"header?.sort\"\n (click)=\"header?.sort ? onSortColumn(header.sort!) : null\"\n class=\"align-bottom\"\n >\n <div\n [ngClass]=\"header?.css\"\n class=\"align-self-end d-flex gap-1\"\n >\n {{ !header.renderer ? (header.text | transloco) : null }}\n <ng-container\n [ngTemplateOutlet]=\"header?.renderer ?? null\"\n [ngTemplateOutletContext]=\"{\n $implicit: header.payload,\n }\"\n ></ng-container>\n <div\n *ngIf=\"header.sort?.key\"\n class=\"d-flex justify-content-between\"\n >\n <ng-container\n [ngTemplateOutlet]=\"orderBtns\"\n [ngTemplateOutletContext]=\"{ $implicit: header.sort }\"\n ></ng-container>\n </div>\n </div>\n </th>\n </ng-container>\n </tr>\n </thead>\n </table>\n </div>\n <div\n (scroll)=\"tableHeaderContainer.scrollLeft = tableContainer.scrollLeft\"\n #tableContainer\n class=\"table-container\"\n >\n <table\n class=\"table\"\n id=\"table-content\"\n >\n <thead\n #fakeTableHeader\n class=\"fake-table-header\"\n id=\"fakeTableHeader\"\n >\n <tr>\n <ng-container *ngFor=\"let header of _tableConfigurations().headers; let i = index\">\n <th\n [class.sort-btn]=\"header?.sort\"\n (click)=\"header?.sort ? onSortColumn(header.sort!) : null\"\n class=\"align-bottom\"\n >\n <div\n [ngClass]=\"header?.css\"\n class=\"align-self-end d-flex gap-1\"\n >\n {{ !header.renderer ? (header.text | transloco) : null }}\n <ng-container\n [ngTemplateOutlet]=\"header?.renderer ?? null\"\n [ngTemplateOutletContext]=\"{\n $implicit: header.payload,\n }\"\n ></ng-container>\n <div\n *ngIf=\"header.sort?.key\"\n class=\"d-flex justify-content-between\"\n >\n <ng-container\n [ngTemplateOutlet]=\"orderBtns\"\n [ngTemplateOutletContext]=\"{ $implicit: header.sort }\"\n ></ng-container>\n </div>\n </div>\n </th>\n </ng-container>\n </tr>\n </thead>\n <tbody>\n <tr\n [class.hover-table]=\"clickableRow()\"\n [class.selectedRow]=\"row?.rowId ? isSelected(row.rowId!) : null\"\n [ngClass]=\"row.css\"\n (click)=\"clickableRow() ? onClickRow(row) : null\"\n *ngFor=\"let row of _tableConfigurations().rows\"\n >\n <td\n [attr.colspan]=\"cell?.fullWidth ? _tableConfigurations().headers.length : undefined\"\n [ngClass]=\"cell.css!\"\n *ngFor=\"let cell of row.cellData\"\n >\n {{ !cell.renderer ? cell.text : null }}\n <ng-container\n [ngTemplateOutlet]=\"cell?.renderer ?? null\"\n [ngTemplateOutletContext]=\"{\n $implicit: cell.payload,\n }\"\n ></ng-container>\n </td>\n </tr>\n </tbody>\n </table>\n </div>\n </ng-container>\n <h6\n *ngIf=\"!_tableConfigurations().rows?.length\"\n class=\"text-center mt-3\"\n >\n {{ noResultsText() | transloco }}\n </h6>\n</div>\n\n<ng-template\n #orderBtns\n let-order\n>\n <div\n [class.sort-asc]=\"order.sort === SortTable.ASC\"\n [class.sort-default]=\"order.sort === SortTable.DEFAULT\"\n [class.sort-desc]=\"order.sort === SortTable.DESC\"\n class=\"sort-arrows\"\n >\n <svg\n class=\"arrow-up\"\n fill=\"currentColor\"\n height=\"10\"\n stroke=\"currentColor\"\n viewBox=\"279.5 -600.5 401 201\"\n width=\"10\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"m280-400 200-200 200 200H280Z\"\n fill=\"currentColor\"\n stroke=\"currentColor\"\n ></path>\n </svg>\n <svg\n class=\"arrow-down\"\n fill=\"currentColor\"\n height=\"10\"\n stroke=\"currentColor\"\n viewBox=\"279.5 -560.5 401 201\"\n width=\"10\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M480-360 280-560h400L480-360Z\"\n fill=\"currentColor\"\n stroke=\"currentColor\"\n ></path>\n </svg>\n </div>\n</ng-template>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;IAgDY;AAAZ,CAAA,UAAY,SAAS,EAAA;AACnB,IAAA,SAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;AACnB,IAAA,SAAA,CAAA,KAAA,CAAA,GAAA,KAAW;AACX,IAAA,SAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACf,CAAC,EAJW,SAAS,KAAT,SAAS,GAIpB,EAAA,CAAA,CAAA;AAcD;;;;;;;AAOG;MACU,mBAAmB,CAAA;AAfhC,IAAA,WAAA,GAAA;AAgBE,QAAA,IAAA,CAAA,YAAY,GAAG,KAAK,CAAU,KAAK,CAAC;QAEpC,IAAY,CAAA,YAAA,GAAG,KAAK,EAAuB;AAE3C,QAAA,IAAA,CAAA,WAAW,GAAG,KAAK,CAAU,IAAI,CAAC;QAElC,IAAW,CAAA,WAAA,GAAG,MAAM,EAAe;QAEnC,IAAW,CAAA,WAAA,GAAG,MAAM,EAAa;QAE1B,IAAS,CAAA,SAAA,GAAG,SAAS;AAE5B,QAAA,IAAA,CAAA,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;AAE/B,QAAA,IAAA,CAAA,wBAAwB,GAAG,MAAM,CAAC,uBAAuB,CAAC;AAE1D,QAAA,IAAA,CAAA,YAAY,GAAG,SAAS,CAAa,aAAa,CAAC;AAEnD,QAAA,IAAA,CAAA,mBAA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AAA,EAAA,SAAA,CAAA,EAAA,EAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EAAE,gBAAgB,EAAA,QAAA,EAAA,oBAAA,EAAA,MAAA,EAAA,CAAA,yBAAA,EAAA,kBAAA,EAAA,0BAAA,CAAA,EAAA,EAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EAAE,KAAK,EAAA,QAAA,EAAA,kBAAA,EAAA,MAAA,EAAA,CAAA,SAAA,EAAA,cAAA,EAAA,eAAA,CAAA,EAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA,CAAA;;2FAWpD,mBAAmB,EAAA,UAAA,EAAA,CAAA;kBAf/B,SAAS;AACE,YAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,aAAa,EAGd,OAAA,EAAA,CAAC,aAAa,EAAE,IAAI,EAAE,OAAO,EAAE,gBAAgB,EAAE,KAAK,CAAC,EAC/C,eAAA,EAAA,uBAAuB,CAAC,MAAM,EAAA,QAAA,EAAA,g9KAAA,EAAA,MAAA,EAAA,CAAA,y2DAAA,CAAA,EAAA;;;AEhEjD;;AAEG;;;;"}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { NgIf, NgClass } from '@angular/common';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
import { viewChild, input, signal, inject, ChangeDetectorRef, effect, forwardRef, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
4
|
+
import { toObservable, takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
5
|
+
import { Validators, NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
6
|
+
import { TranslocoPipe } from '@jsverse/transloco';
|
|
7
|
+
import { filter, take } from 'rxjs';
|
|
8
|
+
import sunEditor from 'suneditor';
|
|
9
|
+
import plugins from 'suneditor/src/plugins';
|
|
10
|
+
import { QuangBaseComponent } from 'quang/components/shared';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* WYSIWYG (What You See Is What You Get) component based on {@link https://github.com/JiHong88/SunEditor}.
|
|
14
|
+
*
|
|
15
|
+
* This component provides a rich text editor for users to create and edit HTML content.
|
|
16
|
+
* It supports a wide range of formatting options.
|
|
17
|
+
*
|
|
18
|
+
* @usageNotes
|
|
19
|
+
* The component allows you to show or hide buttons from the WYSIWYG editor.
|
|
20
|
+
* By default, all the available buttons are shown in the editor bar.
|
|
21
|
+
*
|
|
22
|
+
* The height of the editor can be customized by setting the `minHeight` property. By default, it is `200px`.
|
|
23
|
+
*/
|
|
24
|
+
class QuangWysiwygComponent extends QuangBaseComponent {
|
|
25
|
+
constructor() {
|
|
26
|
+
super(...arguments);
|
|
27
|
+
this._inputForWysiwyg = viewChild('inputForWysiwyg');
|
|
28
|
+
this.minHeight = input('200px');
|
|
29
|
+
this.font = input(true);
|
|
30
|
+
this.fontSize = input(true);
|
|
31
|
+
this.formatBlock = input(true);
|
|
32
|
+
this.paragraphStyle = input(true);
|
|
33
|
+
this.blockquote = input(true);
|
|
34
|
+
this.bold = input(true);
|
|
35
|
+
this.underline = input(true);
|
|
36
|
+
this.italic = input(true);
|
|
37
|
+
this.strike = input(true);
|
|
38
|
+
this.fontColor = input(true);
|
|
39
|
+
this.highlightColor = input(true);
|
|
40
|
+
this.textStyle = input(true);
|
|
41
|
+
this.removeFormat = input(true);
|
|
42
|
+
this.align = input(true);
|
|
43
|
+
this.list = input(true);
|
|
44
|
+
this.table = input(true);
|
|
45
|
+
this.link = input(true);
|
|
46
|
+
this.image = input(true);
|
|
47
|
+
this.fullScreen = input(true);
|
|
48
|
+
this.showBlocks = input(true);
|
|
49
|
+
this.onImageUploadError = input();
|
|
50
|
+
this.onFileDrop = input();
|
|
51
|
+
this.wysiwygOptions = input(undefined);
|
|
52
|
+
this._sunEditorWysiwygInstance = signal(undefined);
|
|
53
|
+
this._sunEditorWysiwygInstance$ = toObservable(this._sunEditorWysiwygInstance);
|
|
54
|
+
this.changeDetectorRef = signal(inject(ChangeDetectorRef));
|
|
55
|
+
this._generateSunEditorWysiwygEffect = effect(() => {
|
|
56
|
+
try {
|
|
57
|
+
const inputForWysiwyg = this._inputForWysiwyg()?.nativeElement;
|
|
58
|
+
if (inputForWysiwyg) {
|
|
59
|
+
const sunEditorOptions = {
|
|
60
|
+
plugins,
|
|
61
|
+
defaultTag: 'div',
|
|
62
|
+
buttonList: this._ngControl()?.control?.enabled && !this.isReadonly() ? [this.getButtonList()] : [],
|
|
63
|
+
minHeight: this.minHeight(),
|
|
64
|
+
width: '100%',
|
|
65
|
+
...(this.wysiwygOptions() ?? {}),
|
|
66
|
+
};
|
|
67
|
+
let sunEditorWysiwygInstance = this._sunEditorWysiwygInstance();
|
|
68
|
+
const ngControl = this._ngControl();
|
|
69
|
+
if (sunEditorWysiwygInstance) {
|
|
70
|
+
if (ngControl?.control?.enabled) {
|
|
71
|
+
sunEditorWysiwygInstance.enable();
|
|
72
|
+
}
|
|
73
|
+
sunEditorWysiwygInstance.setOptions(sunEditorOptions);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
sunEditorWysiwygInstance = sunEditor.create(inputForWysiwyg, sunEditorOptions);
|
|
77
|
+
this._sunEditorWysiwygInstance.set(sunEditorWysiwygInstance);
|
|
78
|
+
}
|
|
79
|
+
const imageUploadError = this.onImageUploadError();
|
|
80
|
+
const onFileDrop = this.onFileDrop();
|
|
81
|
+
if (imageUploadError && sunEditorWysiwygInstance) {
|
|
82
|
+
sunEditorWysiwygInstance.onImageUploadError = imageUploadError;
|
|
83
|
+
}
|
|
84
|
+
if (onFileDrop && sunEditorWysiwygInstance) {
|
|
85
|
+
sunEditorWysiwygInstance.onDrop = onFileDrop;
|
|
86
|
+
}
|
|
87
|
+
this.registerEvents();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
catch (_) {
|
|
91
|
+
// we usually end up here when we are in a modal and then it starts in the right way
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
this.STRIP_HTML_REGEX = /<[^>]*>/g;
|
|
95
|
+
}
|
|
96
|
+
registerEvents() {
|
|
97
|
+
const sunEditorInstance = this._sunEditorWysiwygInstance();
|
|
98
|
+
if (sunEditorInstance) {
|
|
99
|
+
sunEditorInstance.onChange = (contents) => {
|
|
100
|
+
this.onChangedHandler(contents);
|
|
101
|
+
this.changeDetectorRef().markForCheck();
|
|
102
|
+
};
|
|
103
|
+
sunEditorInstance.onBlur = () => {
|
|
104
|
+
this.onBlurHandler();
|
|
105
|
+
};
|
|
106
|
+
if (this._isDisabled()) {
|
|
107
|
+
sunEditorInstance.disable();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
writeValue(val) {
|
|
112
|
+
super.writeValue(val);
|
|
113
|
+
this._sunEditorWysiwygInstance$
|
|
114
|
+
.pipe(takeUntilDestroyed(this.destroyRef), filter((x) => !!x), take(1))
|
|
115
|
+
.subscribe((sunEditorWysiwygInstance) => {
|
|
116
|
+
console.log('ciao sunEditorWysiwygInstance', sunEditorWysiwygInstance);
|
|
117
|
+
if (sunEditorWysiwygInstance) {
|
|
118
|
+
try {
|
|
119
|
+
sunEditorWysiwygInstance.setContents(val);
|
|
120
|
+
}
|
|
121
|
+
catch (_) {
|
|
122
|
+
// we usually end up here when we are in a modal and then it starts in the right way
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
validate(control) {
|
|
128
|
+
if (control.hasValidator(Validators.required) && control.value?.replace(this.STRIP_HTML_REGEX, '') === '') {
|
|
129
|
+
return { required: true };
|
|
130
|
+
}
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
onChangedHandler(value) {
|
|
134
|
+
super.onChangedHandler(value);
|
|
135
|
+
const control = this._ngControl();
|
|
136
|
+
if (control?.control) {
|
|
137
|
+
if (this.validate(control.control))
|
|
138
|
+
control.control.setErrors(this.validate(control.control));
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
getButtonList() {
|
|
142
|
+
const buttonList = [];
|
|
143
|
+
if (this.font()) {
|
|
144
|
+
buttonList.push('font');
|
|
145
|
+
}
|
|
146
|
+
if (this.fontSize()) {
|
|
147
|
+
buttonList.push('fontSize');
|
|
148
|
+
}
|
|
149
|
+
if (this.formatBlock()) {
|
|
150
|
+
buttonList.push('formatBlock');
|
|
151
|
+
}
|
|
152
|
+
if (this.paragraphStyle()) {
|
|
153
|
+
buttonList.push('paragraphStyle');
|
|
154
|
+
}
|
|
155
|
+
if (this.blockquote()) {
|
|
156
|
+
buttonList.push('blockquote');
|
|
157
|
+
}
|
|
158
|
+
if (this.bold()) {
|
|
159
|
+
buttonList.push('bold');
|
|
160
|
+
}
|
|
161
|
+
if (this.underline()) {
|
|
162
|
+
buttonList.push('underline');
|
|
163
|
+
}
|
|
164
|
+
if (this.italic()) {
|
|
165
|
+
buttonList.push('italic');
|
|
166
|
+
}
|
|
167
|
+
if (this.strike()) {
|
|
168
|
+
buttonList.push('strike');
|
|
169
|
+
}
|
|
170
|
+
if (this.fontColor()) {
|
|
171
|
+
buttonList.push('fontColor');
|
|
172
|
+
}
|
|
173
|
+
if (this.highlightColor()) {
|
|
174
|
+
buttonList.push('hiliteColor');
|
|
175
|
+
}
|
|
176
|
+
if (this.textStyle()) {
|
|
177
|
+
buttonList.push('textStyle');
|
|
178
|
+
}
|
|
179
|
+
if (this.removeFormat()) {
|
|
180
|
+
buttonList.push('removeFormat');
|
|
181
|
+
}
|
|
182
|
+
if (this.align()) {
|
|
183
|
+
buttonList.push('align');
|
|
184
|
+
}
|
|
185
|
+
if (this.list()) {
|
|
186
|
+
buttonList.push('list');
|
|
187
|
+
}
|
|
188
|
+
if (this.table()) {
|
|
189
|
+
buttonList.push('table');
|
|
190
|
+
}
|
|
191
|
+
if (this.link()) {
|
|
192
|
+
buttonList.push('link');
|
|
193
|
+
}
|
|
194
|
+
if (this.image()) {
|
|
195
|
+
buttonList.push('image');
|
|
196
|
+
}
|
|
197
|
+
if (this.fullScreen()) {
|
|
198
|
+
buttonList.push('fullScreen');
|
|
199
|
+
}
|
|
200
|
+
if (this.showBlocks()) {
|
|
201
|
+
buttonList.push('showBlocks');
|
|
202
|
+
}
|
|
203
|
+
return buttonList;
|
|
204
|
+
}
|
|
205
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.5", ngImport: i0, type: QuangWysiwygComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
206
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "19.2.5", type: QuangWysiwygComponent, isStandalone: true, selector: "quang-wysiwyg", inputs: { minHeight: { classPropertyName: "minHeight", publicName: "minHeight", isSignal: true, isRequired: false, transformFunction: null }, font: { classPropertyName: "font", publicName: "font", isSignal: true, isRequired: false, transformFunction: null }, fontSize: { classPropertyName: "fontSize", publicName: "fontSize", isSignal: true, isRequired: false, transformFunction: null }, formatBlock: { classPropertyName: "formatBlock", publicName: "formatBlock", isSignal: true, isRequired: false, transformFunction: null }, paragraphStyle: { classPropertyName: "paragraphStyle", publicName: "paragraphStyle", isSignal: true, isRequired: false, transformFunction: null }, blockquote: { classPropertyName: "blockquote", publicName: "blockquote", isSignal: true, isRequired: false, transformFunction: null }, bold: { classPropertyName: "bold", publicName: "bold", isSignal: true, isRequired: false, transformFunction: null }, underline: { classPropertyName: "underline", publicName: "underline", isSignal: true, isRequired: false, transformFunction: null }, italic: { classPropertyName: "italic", publicName: "italic", isSignal: true, isRequired: false, transformFunction: null }, strike: { classPropertyName: "strike", publicName: "strike", isSignal: true, isRequired: false, transformFunction: null }, fontColor: { classPropertyName: "fontColor", publicName: "fontColor", isSignal: true, isRequired: false, transformFunction: null }, highlightColor: { classPropertyName: "highlightColor", publicName: "highlightColor", isSignal: true, isRequired: false, transformFunction: null }, textStyle: { classPropertyName: "textStyle", publicName: "textStyle", isSignal: true, isRequired: false, transformFunction: null }, removeFormat: { classPropertyName: "removeFormat", publicName: "removeFormat", isSignal: true, isRequired: false, transformFunction: null }, align: { classPropertyName: "align", publicName: "align", isSignal: true, isRequired: false, transformFunction: null }, list: { classPropertyName: "list", publicName: "list", isSignal: true, isRequired: false, transformFunction: null }, table: { classPropertyName: "table", publicName: "table", isSignal: true, isRequired: false, transformFunction: null }, link: { classPropertyName: "link", publicName: "link", isSignal: true, isRequired: false, transformFunction: null }, image: { classPropertyName: "image", publicName: "image", isSignal: true, isRequired: false, transformFunction: null }, fullScreen: { classPropertyName: "fullScreen", publicName: "fullScreen", isSignal: true, isRequired: false, transformFunction: null }, showBlocks: { classPropertyName: "showBlocks", publicName: "showBlocks", isSignal: true, isRequired: false, transformFunction: null }, onImageUploadError: { classPropertyName: "onImageUploadError", publicName: "onImageUploadError", isSignal: true, isRequired: false, transformFunction: null }, onFileDrop: { classPropertyName: "onFileDrop", publicName: "onFileDrop", isSignal: true, isRequired: false, transformFunction: null }, wysiwygOptions: { classPropertyName: "wysiwygOptions", publicName: "wysiwygOptions", isSignal: true, isRequired: false, transformFunction: null } }, providers: [
|
|
207
|
+
{
|
|
208
|
+
provide: NG_VALUE_ACCESSOR,
|
|
209
|
+
useExisting: forwardRef(() => QuangWysiwygComponent),
|
|
210
|
+
multi: true,
|
|
211
|
+
},
|
|
212
|
+
], viewQueries: [{ propertyName: "_inputForWysiwyg", first: true, predicate: ["inputForWysiwyg"], descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0, template: "<div class=\"mb-3\">\n <label\n [htmlFor]=\"componentId()\"\n *ngIf=\"componentLabel()\"\n class=\"form-label\"\n >\n {{ componentLabel() | transloco }}\n <span [hidden]=\"!_isRequired()\">*</span>\n </label>\n <div\n [class.is-invalid]=\"_showErrors()\"\n [class.is-valid]=\"_showSuccess()\"\n class=\"input-wysiwyg-container is-invalid\"\n >\n <textarea\n [disabled]=\"_isDisabled()\"\n [id]=\"componentId()\"\n [ngClass]=\"componentClass()\"\n [placeholder]=\"componentPlaceholder() | transloco\"\n [readOnly]=\"isReadonly()\"\n [tabIndex]=\"componentTabIndex()\"\n [value]=\"_value()\"\n #inputForWysiwyg\n class=\"form-control\"\n ></textarea>\n </div>\n <div class=\"valid-feedback\">\n {{ successMessage() | transloco }}\n </div>\n <div class=\"invalid-feedback\">\n {{ _currentErrorMessage() | transloco: _currentErrorMessageExtraData() }}\n </div>\n <small\n [hidden]=\"_showSuccess() || _showErrors()\"\n *ngIf=\"helpMessage()\"\n aria-live=\"assertive\"\n class=\"form-text text-muted\"\n >\n {{ helpMessage() | transloco }}\n </small>\n</div>\n", styles: [":host{display:block}::ng-deep .se-toolbar{color:var(--bs-body-color)!important;background-color:var(--bs-body-bg)!important;z-index:unset!important}::ng-deep .se-wrapper-inner{color:var(--bs-body-color)!important;background-color:var(--bs-body-bg)!important}::ng-deep .se-btn{color:var(--bs-body-color)!important}::ng-deep .se-btn:enabled.active{color:var(--bs-primary)!important}::ng-deep .se-btn:hover{background-color:var(--bs-secondary-bg)!important}::ng-deep .se-resizing-bar{color:var(--bs-body-color)!important;background-color:var(--bs-body-bg)!important}::ng-deep .se-navigation{color:var(--bs-body-color)!important;background-color:var(--bs-body-bg)!important}::ng-deep .sun-editor input{display:none}::ng-deep .sun-editor .se-container{border-radius:var(--bs-border-radius)}::ng-deep .se-wrapper{z-index:unset!important}::ng-deep .se-wrapper textarea:disabled+.se-wrapper-wysiwyg{background-color:var(--bs-secondary-bg)}::ng-deep .se-wrapper .se-wrapper-inner{border-top:1px solid var(--bs-border-color)}::ng-deep .is-invalid .sun-editor .se-container .se-toolbar{border-bottom:1px solid var(--bs-danger)}::ng-deep .is-invalid .sun-editor .se-container .se-wrapper .se-wrapper-inner{--bs-form-bg-icon: url(\"data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc3545'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23dc3545' stroke='none'/%3e%3c/svg%3e\");border:1px solid var(--bs-danger);padding-right:3rem;background-position:right .75rem center,center right 2.25rem;background-size:1.5rem,calc(.75em + .375rem) calc(.75em + .375rem);background-image:var(--bs-form-bg-icon);background-repeat:no-repeat}::ng-deep .is-valid .sun-editor .se-container .se-toolbar{border-bottom:1px solid var(--bs-success)}::ng-deep .is-valid .sun-editor .se-container .se-wrapper .se-wrapper-inner{--bs-form-bg-icon: url(\"data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%23198754' d='M2.3 6.73.6 4.53c-.4-1.04.46-1.4 1.1-.8l1.1 1.4 3.4-3.8c.6-.63 1.6-.27 1.2.7l-4 4.6c-.43.5-.8.4-1.1.1z'/%3e%3c/svg%3e\");border:1px solid var(--bs-success);padding-right:3rem;background-position:right .75rem center,center right 2.25rem;background-size:1.5rem,calc(.75em + .375rem) calc(.75em + .375rem);background-image:var(--bs-form-bg-icon);background-repeat:no-repeat}\n"], dependencies: [{ kind: "pipe", type: TranslocoPipe, name: "transloco" }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
213
|
+
}
|
|
214
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.5", ngImport: i0, type: QuangWysiwygComponent, decorators: [{
|
|
215
|
+
type: Component,
|
|
216
|
+
args: [{ selector: 'quang-wysiwyg', providers: [
|
|
217
|
+
{
|
|
218
|
+
provide: NG_VALUE_ACCESSOR,
|
|
219
|
+
useExisting: forwardRef(() => QuangWysiwygComponent),
|
|
220
|
+
multi: true,
|
|
221
|
+
},
|
|
222
|
+
], imports: [TranslocoPipe, NgIf, NgClass], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"mb-3\">\n <label\n [htmlFor]=\"componentId()\"\n *ngIf=\"componentLabel()\"\n class=\"form-label\"\n >\n {{ componentLabel() | transloco }}\n <span [hidden]=\"!_isRequired()\">*</span>\n </label>\n <div\n [class.is-invalid]=\"_showErrors()\"\n [class.is-valid]=\"_showSuccess()\"\n class=\"input-wysiwyg-container is-invalid\"\n >\n <textarea\n [disabled]=\"_isDisabled()\"\n [id]=\"componentId()\"\n [ngClass]=\"componentClass()\"\n [placeholder]=\"componentPlaceholder() | transloco\"\n [readOnly]=\"isReadonly()\"\n [tabIndex]=\"componentTabIndex()\"\n [value]=\"_value()\"\n #inputForWysiwyg\n class=\"form-control\"\n ></textarea>\n </div>\n <div class=\"valid-feedback\">\n {{ successMessage() | transloco }}\n </div>\n <div class=\"invalid-feedback\">\n {{ _currentErrorMessage() | transloco: _currentErrorMessageExtraData() }}\n </div>\n <small\n [hidden]=\"_showSuccess() || _showErrors()\"\n *ngIf=\"helpMessage()\"\n aria-live=\"assertive\"\n class=\"form-text text-muted\"\n >\n {{ helpMessage() | transloco }}\n </small>\n</div>\n", styles: [":host{display:block}::ng-deep .se-toolbar{color:var(--bs-body-color)!important;background-color:var(--bs-body-bg)!important;z-index:unset!important}::ng-deep .se-wrapper-inner{color:var(--bs-body-color)!important;background-color:var(--bs-body-bg)!important}::ng-deep .se-btn{color:var(--bs-body-color)!important}::ng-deep .se-btn:enabled.active{color:var(--bs-primary)!important}::ng-deep .se-btn:hover{background-color:var(--bs-secondary-bg)!important}::ng-deep .se-resizing-bar{color:var(--bs-body-color)!important;background-color:var(--bs-body-bg)!important}::ng-deep .se-navigation{color:var(--bs-body-color)!important;background-color:var(--bs-body-bg)!important}::ng-deep .sun-editor input{display:none}::ng-deep .sun-editor .se-container{border-radius:var(--bs-border-radius)}::ng-deep .se-wrapper{z-index:unset!important}::ng-deep .se-wrapper textarea:disabled+.se-wrapper-wysiwyg{background-color:var(--bs-secondary-bg)}::ng-deep .se-wrapper .se-wrapper-inner{border-top:1px solid var(--bs-border-color)}::ng-deep .is-invalid .sun-editor .se-container .se-toolbar{border-bottom:1px solid var(--bs-danger)}::ng-deep .is-invalid .sun-editor .se-container .se-wrapper .se-wrapper-inner{--bs-form-bg-icon: url(\"data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc3545'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23dc3545' stroke='none'/%3e%3c/svg%3e\");border:1px solid var(--bs-danger);padding-right:3rem;background-position:right .75rem center,center right 2.25rem;background-size:1.5rem,calc(.75em + .375rem) calc(.75em + .375rem);background-image:var(--bs-form-bg-icon);background-repeat:no-repeat}::ng-deep .is-valid .sun-editor .se-container .se-toolbar{border-bottom:1px solid var(--bs-success)}::ng-deep .is-valid .sun-editor .se-container .se-wrapper .se-wrapper-inner{--bs-form-bg-icon: url(\"data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%23198754' d='M2.3 6.73.6 4.53c-.4-1.04.46-1.4 1.1-.8l1.1 1.4 3.4-3.8c.6-.63 1.6-.27 1.2.7l-4 4.6c-.43.5-.8.4-1.1.1z'/%3e%3c/svg%3e\");border:1px solid var(--bs-success);padding-right:3rem;background-position:right .75rem center,center right 2.25rem;background-size:1.5rem,calc(.75em + .375rem) calc(.75em + .375rem);background-image:var(--bs-form-bg-icon);background-repeat:no-repeat}\n"] }]
|
|
223
|
+
}] });
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Generated bundle index. Do not edit.
|
|
227
|
+
*/
|
|
228
|
+
|
|
229
|
+
export { QuangWysiwygComponent };
|
|
230
|
+
//# sourceMappingURL=quang-components-wysiwyg.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quang-components-wysiwyg.mjs","sources":["../../../projects/quang/components/wysiwyg/wysiwyg.component.ts","../../../projects/quang/components/wysiwyg/wysiwyg.component.html","../../../projects/quang/components/wysiwyg/quang-components-wysiwyg.ts"],"sourcesContent":["import { NgClass, NgIf } from '@angular/common'\nimport {\n AfterViewInit,\n ChangeDetectionStrategy,\n ChangeDetectorRef,\n Component,\n ElementRef,\n effect,\n forwardRef,\n inject,\n input,\n signal,\n viewChild,\n} from '@angular/core'\nimport { takeUntilDestroyed, toObservable } from '@angular/core/rxjs-interop'\nimport { AbstractControl, NG_VALUE_ACCESSOR, ValidationErrors, Validators } from '@angular/forms'\n\nimport { TranslocoPipe } from '@jsverse/transloco'\nimport { filter, take } from 'rxjs'\nimport sunEditor from 'suneditor'\nimport SunEditorCore from 'suneditor/src/lib/core'\nimport { SunEditorOptions } from 'suneditor/src/options'\nimport plugins from 'suneditor/src/plugins'\n\nimport { QuangBaseComponent } from 'quang/components/shared'\n\nexport type QuangWysiwygOptions = SunEditorOptions\n\n@Component({\n selector: 'quang-wysiwyg',\n templateUrl: './wysiwyg.component.html',\n styleUrl: './wysiwyg.component.scss',\n providers: [\n {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => QuangWysiwygComponent),\n multi: true,\n },\n ],\n imports: [TranslocoPipe, NgIf, NgClass],\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\n/**\n * WYSIWYG (What You See Is What You Get) component based on {@link https://github.com/JiHong88/SunEditor}.\n *\n * This component provides a rich text editor for users to create and edit HTML content.\n * It supports a wide range of formatting options.\n *\n * @usageNotes\n * The component allows you to show or hide buttons from the WYSIWYG editor.\n * By default, all the available buttons are shown in the editor bar.\n *\n * The height of the editor can be customized by setting the `minHeight` property. By default, it is `200px`.\n */\nexport class QuangWysiwygComponent extends QuangBaseComponent<string> implements AfterViewInit {\n _inputForWysiwyg = viewChild<ElementRef>('inputForWysiwyg')\n\n minHeight = input<string | undefined>('200px')\n\n font = input<boolean>(true)\n\n fontSize = input<boolean>(true)\n\n formatBlock = input<boolean>(true)\n\n paragraphStyle = input<boolean>(true)\n\n blockquote = input<boolean>(true)\n\n bold = input<boolean>(true)\n\n underline = input<boolean>(true)\n\n italic = input<boolean>(true)\n\n strike = input<boolean>(true)\n\n fontColor = input<boolean>(true)\n\n highlightColor = input<boolean>(true)\n\n textStyle = input<boolean>(true)\n\n removeFormat = input<boolean>(true)\n\n align = input<boolean>(true)\n\n list = input<boolean>(true)\n\n table = input<boolean>(true)\n\n link = input<boolean>(true)\n\n image = input<boolean>(true)\n\n fullScreen = input<boolean>(true)\n\n showBlocks = input<boolean>(true)\n\n onImageUploadError = input<(errorMessage: any, result: any, core: any) => boolean>()\n onFileDrop = input<(e: any, cleanData: any, maxCharCount: any, core: any) => boolean>()\n\n wysiwygOptions = input<QuangWysiwygOptions | undefined>(undefined)\n\n _sunEditorWysiwygInstance = signal<SunEditorCore | undefined>(undefined)\n _sunEditorWysiwygInstance$ = toObservable(this._sunEditorWysiwygInstance)\n\n changeDetectorRef = signal(inject(ChangeDetectorRef))\n\n _generateSunEditorWysiwygEffect = effect(() => {\n try {\n const inputForWysiwyg = this._inputForWysiwyg()?.nativeElement\n if (inputForWysiwyg) {\n const sunEditorOptions: SunEditorOptions = {\n plugins,\n defaultTag: 'div',\n buttonList: this._ngControl()?.control?.enabled && !this.isReadonly() ? [this.getButtonList()] : [],\n minHeight: this.minHeight(),\n width: '100%',\n ...(this.wysiwygOptions() ?? {}),\n }\n\n let sunEditorWysiwygInstance = this._sunEditorWysiwygInstance()\n const ngControl = this._ngControl()\n\n if (sunEditorWysiwygInstance) {\n if (ngControl?.control?.enabled) {\n sunEditorWysiwygInstance.enable()\n }\n sunEditorWysiwygInstance.setOptions(sunEditorOptions)\n } else {\n sunEditorWysiwygInstance = sunEditor.create(inputForWysiwyg, sunEditorOptions)\n this._sunEditorWysiwygInstance.set(sunEditorWysiwygInstance)\n }\n\n const imageUploadError = this.onImageUploadError()\n const onFileDrop = this.onFileDrop()\n\n if (imageUploadError && sunEditorWysiwygInstance) {\n sunEditorWysiwygInstance.onImageUploadError = imageUploadError\n }\n if (onFileDrop && sunEditorWysiwygInstance) {\n sunEditorWysiwygInstance.onDrop = onFileDrop\n }\n\n this.registerEvents()\n }\n } catch (_) {\n // we usually end up here when we are in a modal and then it starts in the right way\n }\n })\n\n STRIP_HTML_REGEX = /<[^>]*>/g\n\n registerEvents(): void {\n const sunEditorInstance = this._sunEditorWysiwygInstance()\n if (sunEditorInstance) {\n sunEditorInstance.onChange = (contents) => {\n this.onChangedHandler(contents)\n this.changeDetectorRef().markForCheck()\n }\n sunEditorInstance.onBlur = () => {\n this.onBlurHandler()\n }\n if (this._isDisabled()) {\n sunEditorInstance.disable()\n }\n }\n }\n\n override writeValue(val: string): void {\n super.writeValue(val)\n this._sunEditorWysiwygInstance$\n .pipe(\n takeUntilDestroyed(this.destroyRef),\n filter((x) => !!x),\n take(1)\n )\n .subscribe((sunEditorWysiwygInstance) => {\n console.log('ciao sunEditorWysiwygInstance', sunEditorWysiwygInstance)\n if (sunEditorWysiwygInstance) {\n try {\n sunEditorWysiwygInstance.setContents(val)\n } catch (_) {\n // we usually end up here when we are in a modal and then it starts in the right way\n }\n }\n })\n }\n\n validate(control: AbstractControl): ValidationErrors | null {\n if (control.hasValidator(Validators.required) && control.value?.replace(this.STRIP_HTML_REGEX, '') === '') {\n return { required: true }\n }\n return null\n }\n\n override onChangedHandler(value: string): void {\n super.onChangedHandler(value)\n const control = this._ngControl()\n if (control?.control) {\n if (this.validate(control.control)) control.control.setErrors(this.validate(control.control))\n }\n }\n\n getButtonList(): string[] {\n const buttonList: string[] = []\n if (this.font()) {\n buttonList.push('font')\n }\n if (this.fontSize()) {\n buttonList.push('fontSize')\n }\n if (this.formatBlock()) {\n buttonList.push('formatBlock')\n }\n if (this.paragraphStyle()) {\n buttonList.push('paragraphStyle')\n }\n if (this.blockquote()) {\n buttonList.push('blockquote')\n }\n if (this.bold()) {\n buttonList.push('bold')\n }\n if (this.underline()) {\n buttonList.push('underline')\n }\n if (this.italic()) {\n buttonList.push('italic')\n }\n if (this.strike()) {\n buttonList.push('strike')\n }\n if (this.fontColor()) {\n buttonList.push('fontColor')\n }\n if (this.highlightColor()) {\n buttonList.push('hiliteColor')\n }\n if (this.textStyle()) {\n buttonList.push('textStyle')\n }\n if (this.removeFormat()) {\n buttonList.push('removeFormat')\n }\n if (this.align()) {\n buttonList.push('align')\n }\n if (this.list()) {\n buttonList.push('list')\n }\n if (this.table()) {\n buttonList.push('table')\n }\n if (this.link()) {\n buttonList.push('link')\n }\n if (this.image()) {\n buttonList.push('image')\n }\n if (this.fullScreen()) {\n buttonList.push('fullScreen')\n }\n if (this.showBlocks()) {\n buttonList.push('showBlocks')\n }\n return buttonList\n }\n}\n","<div class=\"mb-3\">\n <label\n [htmlFor]=\"componentId()\"\n *ngIf=\"componentLabel()\"\n class=\"form-label\"\n >\n {{ componentLabel() | transloco }}\n <span [hidden]=\"!_isRequired()\">*</span>\n </label>\n <div\n [class.is-invalid]=\"_showErrors()\"\n [class.is-valid]=\"_showSuccess()\"\n class=\"input-wysiwyg-container is-invalid\"\n >\n <textarea\n [disabled]=\"_isDisabled()\"\n [id]=\"componentId()\"\n [ngClass]=\"componentClass()\"\n [placeholder]=\"componentPlaceholder() | transloco\"\n [readOnly]=\"isReadonly()\"\n [tabIndex]=\"componentTabIndex()\"\n [value]=\"_value()\"\n #inputForWysiwyg\n class=\"form-control\"\n ></textarea>\n </div>\n <div class=\"valid-feedback\">\n {{ successMessage() | transloco }}\n </div>\n <div class=\"invalid-feedback\">\n {{ _currentErrorMessage() | transloco: _currentErrorMessageExtraData() }}\n </div>\n <small\n [hidden]=\"_showSuccess() || _showErrors()\"\n *ngIf=\"helpMessage()\"\n aria-live=\"assertive\"\n class=\"form-text text-muted\"\n >\n {{ helpMessage() | transloco }}\n </small>\n</div>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;AA0CA;;;;;;;;;;;AAWG;A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A,eAAA,EAAA,IAAA,EAAA,QAAA,EAAA,EAAA,EAAA,QAAA,ECtCH,+oCAyCA,EDFY,MAAA,EAAA,CAAA,g6EAAA,CAAA,EAAA,YAAA,EAAA,CAAA,EAAA,IAAA,EAAA,MAAA,EAAA,IAAA,EAAA,aAAa,EAAE,IAAA,EAAA,WAAA,EAAA,EAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EAAA,IAAI,6FAAE,OAAO,EAAA,QAAA,EAAA,WAAA,EAAA,MAAA,EAAA,CAAA,OAAA,EAAA,SAAA,CAAA,EAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA,CAAA;;2FAe3B,qBAAqB,EAAA,UAAA,EAAA,CAAA;kBA1BjC,SAAS;AACE,YAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,eAAe,EAGd,SAAA,EAAA;AACT,wBAAA;AACE,4BAAA,OAAO,EAAE,iBAAiB;AAC1B,4BAAA,WAAW,EAAE,UAAU,CAAC,2BAA2B,CAAC;AACpD,4BAAA,KAAK,EAAE,IAAI;AACZ,yBAAA;qBACF,EACQ,OAAA,EAAA,CAAC,aAAa,EAAE,IAAI,EAAE,OAAO,CAAC,EAAA,eAAA,EACtB,uBAAuB,CAAC,MAAM,EAAA,QAAA,EAAA,+oCAAA,EAAA,MAAA,EAAA,CAAA,g6EAAA,CAAA,EAAA;;;AExCjD;;AAEG;;;;"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Injectable } from '@angular/core';
|
|
3
|
+
import { Observable, map, filter, throttleTime } from 'rxjs';
|
|
4
|
+
|
|
5
|
+
class ResizeObservableService {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.notifiers = [];
|
|
8
|
+
this.resizeObserver = new ResizeObserver((entries) => {
|
|
9
|
+
this.notifiers.forEach((obs) => obs.next(entries));
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
resizeObservable(elem) {
|
|
13
|
+
this.resizeObserver.observe(elem);
|
|
14
|
+
const newObserverCandidate = new Observable((subscriber) => {
|
|
15
|
+
this.notifiers.push(subscriber);
|
|
16
|
+
return () => {
|
|
17
|
+
const idx = this.notifiers.findIndex((val) => val === subscriber);
|
|
18
|
+
this.notifiers.splice(idx, 1);
|
|
19
|
+
this.resizeObserver.unobserve(elem);
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
return newObserverCandidate.pipe(map((entries) => entries.find((entry) => entry.target === elem)), filter(Boolean), throttleTime(30));
|
|
23
|
+
}
|
|
24
|
+
widthResizeObservable(elem) {
|
|
25
|
+
return this.resizeObservable(elem).pipe(map((entry) => entry.borderBoxSize[0].inlineSize), filter(Boolean));
|
|
26
|
+
}
|
|
27
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.5", ngImport: i0, type: ResizeObservableService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
28
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.5", ngImport: i0, type: ResizeObservableService, providedIn: 'root' }); }
|
|
29
|
+
}
|
|
30
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.5", ngImport: i0, type: ResizeObservableService, decorators: [{
|
|
31
|
+
type: Injectable,
|
|
32
|
+
args: [{
|
|
33
|
+
providedIn: 'root',
|
|
34
|
+
}]
|
|
35
|
+
}], ctorParameters: () => [] });
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Generated bundle index. Do not edit.
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
export { ResizeObservableService };
|
|
42
|
+
//# sourceMappingURL=quang-device.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quang-device.mjs","sources":["../../../projects/quang/device/resize-observable.service.ts","../../../projects/quang/device/quang-device.ts"],"sourcesContent":["import { Injectable } from '@angular/core'\n\nimport { NextObserver, Observable, Subscriber, filter, map, throttleTime } from 'rxjs'\n\n@Injectable({\n providedIn: 'root',\n})\nexport class ResizeObservableService {\n private resizeObserver: ResizeObserver\n\n private notifiers: NextObserver<ResizeObserverEntry[]>[] = []\n\n constructor() {\n this.resizeObserver = new ResizeObserver((entries: ResizeObserverEntry[]) => {\n this.notifiers.forEach((obs) => obs.next(entries))\n })\n }\n\n resizeObservable(elem: Element): Observable<ResizeObserverEntry> {\n this.resizeObserver.observe(elem)\n const newObserverCandidate = new Observable<ResizeObserverEntry[]>(\n (subscriber: Subscriber<ResizeObserverEntry[]>) => {\n this.notifiers.push(subscriber)\n\n return () => {\n const idx = this.notifiers.findIndex((val) => val === subscriber)\n this.notifiers.splice(idx, 1)\n this.resizeObserver.unobserve(elem)\n }\n }\n )\n\n return newObserverCandidate.pipe(\n map((entries) => entries.find((entry) => entry.target === elem)),\n filter(Boolean),\n throttleTime(30)\n )\n }\n\n widthResizeObservable(elem: Element): Observable<number> {\n return this.resizeObservable(elem).pipe(\n map((entry) => entry.borderBoxSize[0].inlineSize),\n filter(Boolean)\n )\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;MAOa,uBAAuB,CAAA;AAKlC,IAAA,WAAA,GAAA;QAFQ,IAAS,CAAA,SAAA,GAA0C,EAAE;QAG3D,IAAI,CAAC,cAAc,GAAG,IAAI,cAAc,CAAC,CAAC,OAA8B,KAAI;AAC1E,YAAA,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACpD,SAAC,CAAC;;AAGJ,IAAA,gBAAgB,CAAC,IAAa,EAAA;AAC5B,QAAA,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI,CAAC;QACjC,MAAM,oBAAoB,GAAG,IAAI,UAAU,CACzC,CAAC,UAA6C,KAAI;AAChD,YAAA,IA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