@kris701/ez-ui 0.0.9 → 0.0.10

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.
Files changed (34) hide show
  1. package/fesm2022/kris701-ez-ui.mjs +1074 -0
  2. package/fesm2022/kris701-ez-ui.mjs.map +1 -0
  3. package/package.json +19 -7
  4. package/types/kris701-ez-ui.d.ts +171 -0
  5. package/index.ts +0 -2
  6. package/ng-package.json +0 -15
  7. package/public-api.ts +0 -15
  8. package/src/components/dateinput.ts +0 -58
  9. package/src/components/floatfileupload.ts +0 -52
  10. package/src/components/floattable/filters/tuiThDateFilter.ts +0 -159
  11. package/src/components/floattable/filters/tuiThSelectFilter.ts +0 -178
  12. package/src/components/floattable/filters/tuiThTextFilter.ts +0 -161
  13. package/src/components/floattable/floattable.presets.ts +0 -197
  14. package/src/components/floattable/floattable.ts +0 -309
  15. package/src/components/floattable/helpers/floattable.filterhelpers.ts +0 -23
  16. package/src/components/floattable/models/FloatTableFilter.ts +0 -5
  17. package/src/components/floattable/models/FloatTableFilterMethod.ts +0 -5
  18. package/src/components/floattable/models/FloatTableSort.ts +0 -4
  19. package/src/components/floattable/models/FloatTableSortFilterPreset.ts +0 -10
  20. package/src/components/floattable/models/FloatTableSortFilterPresetSave.ts +0 -6
  21. package/src/components/floattable/models/FloatTableSortMethod.ts +0 -4
  22. package/src/components/floattable/services/floattable.filterservice.ts +0 -110
  23. package/src/components/floattable/sorts/tuiThSortable.ts +0 -75
  24. package/src/components/markdowneditor.ts +0 -340
  25. package/src/components/menubar.ts +0 -144
  26. package/src/components/multiselect.ts +0 -77
  27. package/src/components/numberinput.ts +0 -45
  28. package/src/components/passwordinput.ts +0 -44
  29. package/src/components/textinput.ts +0 -40
  30. package/src/helpers/compressImage.ts +0 -20
  31. package/src/interfaces/baseCRUDInterface.ts +0 -181
  32. package/src/interfaces/baseListService.ts +0 -62
  33. package/tsconfig.lib.json +0 -12
  34. package/tsconfig.lib.prod.json +0 -11
@@ -1,309 +0,0 @@
1
- import { CommonModule } from '@angular/common';
2
- import { Component, ContentChild, EventEmitter, Input, OnChanges, Output, signal, SimpleChanges, TemplateRef, ViewChild } from '@angular/core';
3
- import { FormsModule } from '@angular/forms';
4
- import { TuiTable, TuiTablePagination } from '@taiga-ui/addon-table';
5
- import { TuiButton, TuiDropdown, TuiHint, TuiIcon, TuiInput, TuiLoader, TuiScrollbar } from "@taiga-ui/core";
6
- import { TuiChevron, TuiDataListWrapper } from '@taiga-ui/kit';
7
- import { TuiBlockStatus } from '@taiga-ui/layout';
8
- import { FloatTablePresets } from './floattable.presets';
9
- import { FloatTableFilter } from './models/FloatTableFilter';
10
- import { FloatTableSort } from './models/FloatTableSort';
11
- import { FloatTableSortFilterPreset } from './models/FloatTableSortFilterPreset';
12
- import { FloatTableFilterService } from './services/floattable.filterservice';
13
-
14
- @Component({
15
- selector: 'app-floattable',
16
- imports: [FormsModule, CommonModule, TuiTable, TuiScrollbar, TuiButton, TuiChevron, TuiDropdown, TuiDataListWrapper, TuiTablePagination, TuiLoader, TuiBlockStatus, TuiIcon, TuiInput, FloatTablePresets, TuiHint],
17
- template: `
18
- <div class="app-floattable">
19
- <tui-loader [inheritColor]="true" [overlay]="true" size="xxl" [loading]="isLoading()">
20
- @if(values.length == 0){
21
- <tui-block-status>
22
- <tui-icon tuiSlot="top" icon="grid-2x2-x" />
23
-
24
- <h3>No Data</h3>
25
-
26
- No data to display.
27
- </tui-block-status>
28
- }
29
- @else {
30
- @if(showAdd || showRefresh || showClearFilters){
31
- <div class="flex flex-row gap-2 p-2" style="padding-bottom:0px">
32
- @if(showRefresh){
33
- <button tuiButton iconStart="rotate-cw" size="s" appearance="info" (click)="onLoadItems.emit()" tuiHint="Refresh the table"></button>
34
- }
35
- @if(showAdd){
36
- <button tuiButton iconStart="plus" size="s" appearance="info" (click)="onAddItem.emit()" tuiHint="Add new item"></button>
37
- }
38
- @if(showClearFilters){
39
- <button tuiButton iconStart="funnel-x" size="s" appearance="info" (click)="clearFilters()" tuiHint="Clear filters"></button>
40
- }
41
- </div>
42
- }
43
- @if(allowPresets){
44
- <app-floattable-presets #presetHeader [storageKey]="storageKey" (onPresetChange)="onPresetChange.emit($event)">
45
- </app-floattable-presets>
46
- }
47
- <tui-scrollbar class="w-full h-full">
48
- <table tuiTable class="w-full h-full">
49
- <thead>
50
- <tr>
51
- @if(expandable){
52
- <th tuiTh></th>
53
- }
54
- <ng-container [ngTemplateOutlet]="tableHeader"></ng-container>
55
- </tr>
56
- </thead>
57
- @for (item of displayValues(); track page() * pageSize() + i; let i = $index){
58
- @let fullIndex = page() * pageSize() + i;
59
- <tbody tuiTbody>
60
- <tr>
61
- @if(expandable){
62
- <td tuiTd class="app-floattable-expander">
63
- <button
64
- appearance="flat-grayscale"
65
- size="xs"
66
- tuiIconButton
67
- type="button"
68
- [tuiChevron]="state[fullIndex] ?? false"
69
- (click)="state[fullIndex] = !state[fullIndex];onRowExpanded.emit(item)"
70
- >
71
- Toggle
72
- </button>
73
- </td>
74
- }
75
- <ng-container [ngTemplateOutlet]="tableRows" [ngTemplateOutletContext]="{ $implicit: item }"></ng-container>
76
- </tr>
77
- </tbody>
78
-
79
- <tbody tuiTableExpand [expanded]="state[fullIndex] ?? false">
80
- @if(state[fullIndex] ?? false){
81
- <tr>
82
- <ng-container [ngTemplateOutlet]="tableExpandedrow" [ngTemplateOutletContext]="{ $implicit: item }"></ng-container>
83
- </tr>
84
- }
85
- </tbody>
86
- }
87
- </table>
88
- </tui-scrollbar>
89
- <div class="app-floattable-footer">
90
- <tui-table-pagination
91
- [(size)]="pageSize"
92
- [(page)]="page"
93
- [total]="internalValues.length"
94
- [items]="pageSizes"
95
- (pageChange)="processPage()"
96
- (sizeChange)="processPage()"
97
- />
98
- </div>
99
- }
100
- </tui-loader>
101
- </div>
102
- `,
103
- host: {
104
- class:'w-full h-full'
105
- },
106
- styles: `
107
- .app-floattable {
108
- border: 2px solid var(--tui-border-normal);
109
- border-radius: var(--tui-radius-l);
110
- display:flex;
111
- height:100%;
112
- width:100%;
113
- overflow:hidden;
114
-
115
- ::ng-deep tui-loader {
116
- display:flex;
117
- height:100%;
118
- width:100%;
119
- flex-direction: column;
120
-
121
- > .t-content {
122
- display:flex;
123
- height:100%;
124
- width:100%;
125
- flex-direction: column;
126
- gap:0.5rem;
127
- overflow-x:auto;
128
- }
129
-
130
- > .t-loader {
131
- position:absolute;
132
- width:100%;
133
- height:100%;
134
- }
135
- }
136
-
137
- ::ng-deep tui-scrollbar {
138
- > .t-content {
139
- display:flex;
140
- gap:10px;
141
- width:0px;
142
- }
143
- }
144
-
145
- .app-floattable-footer {
146
- display:flex;
147
- margin-bottom:0.5rem;
148
- padding-left:2rem;
149
- padding-right:2rem;
150
-
151
- tui-table-pagination {
152
- flex: 1
153
- }
154
- }
155
-
156
- ::ng-deep table {
157
- border-radius: var(--tui-radius-l);
158
- }
159
-
160
- ::ng-deep th {
161
- background-color: var(--tui-background-base-alt) !important;
162
- }
163
-
164
- ::ng-deep .app-floattable-expander {
165
- padding:0px;
166
-
167
- button {
168
- width:100%;
169
- height:100%;
170
- border-radius: 0px;
171
- }
172
- }
173
-
174
- th[tuiTh] {
175
- align-items:center;
176
- }
177
- }
178
- `
179
- })
180
- export class FloatTable implements OnChanges {
181
- @ContentChild('tableHeader', { static: false }) tableHeader: TemplateRef<any> | undefined;
182
- @ContentChild('tableRows', { static: false }) tableRows: TemplateRef<any> | undefined;
183
- @ContentChild('tableExpandedrow', { static: false }) tableExpandedrow: TemplateRef<any> | undefined;
184
-
185
- @ViewChild('presetHeader', { static: false }) presetHeader: FloatTablePresets | undefined;
186
-
187
- @Input() disabled: boolean = false;
188
- @Input() isLoading = signal<boolean>(false);
189
-
190
- @Input() showAdd: boolean = false;
191
- @Input() showRefresh: boolean = false;
192
- @Input() showClearFilters: boolean = false;
193
-
194
- @Input() expandable: boolean = false;
195
-
196
- @Input() values: any[] = [];
197
- internalValues: any[] = [];
198
- displayValues = signal<any[]>([]);
199
-
200
- sorts = signal<FloatTableSort[]>([]);
201
- filters = signal<FloatTableFilter[]>([]);
202
-
203
- @Input() storageKey: string | null = null;
204
- @Input() allowPresets: boolean = false;
205
-
206
- constructor(private filterService : FloatTableFilterService){
207
-
208
- }
209
-
210
- async ngOnChanges(changes: SimpleChanges) {
211
- if (changes['values'] && changes['values'].previousValue != changes['values'].currentValue) {
212
- this.values = changes['values'].currentValue;
213
- this.applyFilter();
214
- }
215
- }
216
-
217
- @Output() onAddItem: EventEmitter<any> = new EventEmitter();
218
- @Output() onLoadItems: EventEmitter<any> = new EventEmitter();
219
- @Output() onRowExpanded: EventEmitter<any> = new EventEmitter();
220
- @Output() onPresetChange: EventEmitter<FloatTableSortFilterPreset | null> = new EventEmitter<FloatTableSortFilterPreset | null>();
221
-
222
- @Input() pageSize = signal<number>(25);
223
- page = signal<number>(0);
224
- pages = signal<number>(0);
225
- readonly pageSizes = [10, 25, 50, 100, 1000];
226
- processPage(){
227
- var fromIndex = this.pageSize() * this.page();
228
- var toIndex = fromIndex + this.pageSize();
229
- this.displayValues.set(this.internalValues.slice(fromIndex, toIndex));
230
- }
231
-
232
- applySorts(){
233
- var sorted = [...this.internalValues]
234
- for(var sort of this.sorts())
235
- sorted = this.filterService.sort(sorted, sort);
236
- this.internalValues = sorted;
237
- }
238
-
239
- applyFilter(){
240
- var filtered = [...this.values]
241
- for(var filter of this.filters())
242
- filtered = this.filterService.filter(filtered, filter);
243
- this.internalValues = filtered;
244
- this.applySorts();
245
- this.state = [];
246
- this.page.set(0);
247
- this.pages.set(Math.floor(this.internalValues.length / this.pageSize()) + 1)
248
- this.processPage();
249
-
250
- this.presetHeader?.saveCurrentPreset();
251
- }
252
-
253
- state: Record<number, boolean> = {};
254
-
255
- setSort(sort : FloatTableSort){
256
- var sorts = this.sorts();
257
- var target = sorts.findIndex(x => x.column == sort.column);
258
- if (target != -1)
259
- sorts[target] = sort;
260
- else
261
- sorts.push(sort);
262
- this.sorts.set(sorts);
263
-
264
- this.applyFilter();
265
- }
266
-
267
- clearSort(column : string){
268
- var sorts = this.sorts();
269
- var target = sorts.findIndex(x => x.column == column);
270
- if (target != -1)
271
- sorts.splice(target, 1)
272
- this.sorts.set(sorts);
273
-
274
- this.applyFilter();
275
- }
276
-
277
- setFilter(filter : FloatTableFilter){
278
- var filters = this.filters();
279
- var target = filters.findIndex(x => x.column == filter.column);
280
- if (target != -1){
281
- filters[target] = filter;
282
- }
283
- else
284
- filters.push(filter);
285
- this.filters.set(filters);
286
-
287
- this.applyFilter();
288
- }
289
-
290
- clearFilter(column : string){
291
- var filters = this.filters();
292
- var target = filters.findIndex(x => x.column == column);
293
- if (target != -1)
294
- filters.splice(target, 1)
295
- this.filters.set(filters);
296
-
297
- this.applyFilter();
298
- }
299
-
300
- clearFilters(){
301
- this.presetHeader?.currentPreset.set(null);
302
- this.onPresetChange.emit(null);
303
- this.sorts.set([])
304
- this.filters.set([])
305
- this.presetHeader?.savePresets();
306
- this.applyFilter();
307
- }
308
- }
309
-
@@ -1,23 +0,0 @@
1
- export class FilterHelpers {
2
- public static textFilter(values: any[], fn : (i : string) => boolean, column : string) : any[]{
3
- var filtered = []
4
- for(let value of values)
5
- {
6
- var asStr : string = value[column];
7
- if (fn(asStr))
8
- filtered.push(value);
9
- }
10
- return filtered;
11
- }
12
-
13
- public static dateFilter(values: any[], fn : (i : Date) => boolean, column : string) : any[]{
14
- var filtered = []
15
- for(let value of values)
16
- {
17
- var asDate : Date = new Date(value[column]);
18
- if (fn(asDate))
19
- filtered.push(value);
20
- }
21
- return filtered;
22
- }
23
- }
@@ -1,5 +0,0 @@
1
- export interface FloatTableFilter {
2
- column : string;
3
- value : any;
4
- expression : string;
5
- }
@@ -1,5 +0,0 @@
1
- export interface FloatTableFilterMethod {
2
- key : string;
3
- action : string;
4
- filter(values : any[], column : string, value : any) : any[];
5
- }
@@ -1,4 +0,0 @@
1
- export interface FloatTableSort {
2
- column : string;
3
- state : 'asc' | 'desc' | 'none';
4
- }
@@ -1,10 +0,0 @@
1
- import { FloatTableFilter } from "./FloatTableFilter";
2
- import { FloatTableSort } from "./FloatTableSort";
3
-
4
- export interface FloatTableSortFilterPreset {
5
- id : string;
6
- name : string;
7
- sorts : FloatTableSort[];
8
- filters : FloatTableFilter[];
9
- edit: boolean;
10
- }
@@ -1,6 +0,0 @@
1
- import { FloatTableSortFilterPreset } from "./FloatTableSortFilterPreset";
2
-
3
- export interface FloatTableSortFilterPresetSave {
4
- current : string | null;
5
- presets : FloatTableSortFilterPreset[];
6
- }
@@ -1,4 +0,0 @@
1
- export interface FloatTableSortMethod {
2
- state : 'asc' | 'desc' | 'none';
3
- sort(a : any, b : any, column : string) : number;
4
- }
@@ -1,110 +0,0 @@
1
- import { FilterHelpers } from "../helpers/floattable.filterhelpers";
2
- import { FloatTableFilter } from "../models/FloatTableFilter";
3
- import { FloatTableFilterMethod } from "../models/FloatTableFilterMethod";
4
- import { FloatTableSort } from "../models/FloatTableSort";
5
- import { FloatTableSortMethod } from "../models/FloatTableSortMethod";
6
-
7
- export class FloatTableFilterService {
8
- public sortMethods : FloatTableSortMethod[] = [
9
- {
10
- state: 'asc',
11
- sort: (a: any, b: any, column : string) => {
12
- if (a[column] < b[column])
13
- return 1;
14
- if (a[column] > b[column])
15
- return -1;
16
- return 0;
17
- }
18
- } as FloatTableSortMethod,
19
- {
20
- state: 'desc',
21
- sort: (a: any, b: any, column : string) => {
22
- if (a[column] < b[column])
23
- return -1;
24
- if (a[column] > b[column])
25
- return 1;
26
- return 0;
27
- }
28
- } as FloatTableSortMethod
29
- ]
30
-
31
- public filterMethods : FloatTableFilterMethod[] = [
32
- // Text filters
33
- {
34
- key: 'str',
35
- action: 'con',
36
- filter: (values : any[], column : string, value : any) => FilterHelpers.textFilter(values, (i : string) => i.includes(value), column)
37
- },
38
- {
39
- key: 'str',
40
- action: 'ncon',
41
- filter: (values : any[], column : string, value : any) => FilterHelpers.textFilter(values, (i : string) => !i.includes(value), column)
42
- },
43
- {
44
- key: 'str',
45
- action: 'sta',
46
- filter: (values : any[], column : string, value : any) => FilterHelpers.textFilter(values, (i : string) => i.startsWith(value), column)
47
- },
48
- {
49
- key: 'str',
50
- action: 'end',
51
- filter: (values : any[], column : string, value : any) => FilterHelpers.textFilter(values, (i : string) => i.endsWith(value), column)
52
- },
53
-
54
- // Select filters
55
- {
56
- key: 'sel',
57
- action: 'con',
58
- filter: (values : any[], column : string, value : any) => FilterHelpers.textFilter(values, (i : string) => value.includes(i), column)
59
- },
60
- {
61
- key: 'sel',
62
- action: 'ncon',
63
- filter: (values : any[], column : string, value : any) => FilterHelpers.textFilter(values, (i : string) => !value.includes(i), column)
64
- },
65
-
66
- // Date filters
67
- {
68
- key: 'dat',
69
- action: 'bef',
70
- filter: (values : any[], column : string, value : any) =>
71
- FilterHelpers.dateFilter(
72
- values,
73
- (i : Date) => {
74
- var normal = value[0].toLocalNativeDate()
75
- normal.setMilliseconds(value[1].toAbsoluteMilliseconds());
76
- return i.getTime() < normal.getTime()
77
- },
78
- column)
79
- },
80
- {
81
- key: 'dat',
82
- action: 'aft',
83
- filter: (values : any[], column : string, value : any) =>
84
- FilterHelpers.dateFilter(
85
- values,
86
- (i : Date) => {
87
- var normal = value[0].toLocalNativeDate()
88
- normal.setMilliseconds(value[1].toAbsoluteMilliseconds());
89
- return i.getTime() > normal.getTime()
90
- },
91
- column)
92
- },
93
- ]
94
-
95
- public sort(values : any[], sort : FloatTableSort) : any[]{
96
- var target = this.sortMethods.find(x => x.state == sort.state);
97
- if (target)
98
- return values.sort((a : any, b: any) => target!.sort(a,b,sort.column));
99
- return values;
100
- }
101
-
102
- public filter(values : any[], filter : FloatTableFilter) : any[]{
103
- var split = filter.expression.split(';');
104
- var target = this.filterMethods.find(x => split[0] == x.key && split[1] == x.action);
105
- if (target)
106
- return target!.filter(values, filter.column, filter.value);
107
- return values;
108
- }
109
- }
110
-
@@ -1,75 +0,0 @@
1
- import { CommonModule } from "@angular/common";
2
- import { Component, Input, signal } from "@angular/core";
3
- import { TuiButton } from "@taiga-ui/core";
4
- import { FloatTable } from "../floattable";
5
- import { FloatTableSort } from "../models/FloatTableSort";
6
-
7
- @Component({
8
- selector: 'tuiThSortable',
9
- imports: [CommonModule, TuiButton],
10
- template: `
11
- @if(tuiThSortable){
12
- <button tuiButton style="opacity:0.72" [iconStart]="icon()" size="s" appearance="flat-grayscale" (click)="sort()"></button>
13
- }
14
- `
15
- })
16
- export class TableSortableColumn {
17
- @Input() tuiThSortable!: string;
18
-
19
- table : FloatTable;
20
- state : 'asc' | 'desc' | 'none' = 'none';
21
- icon = signal<string | null | undefined>("text-align-justify");
22
-
23
- constructor(table : FloatTable){
24
- this.table = table;
25
-
26
- this.table.onPresetChange.subscribe(x => {
27
- if (!x)
28
- {
29
- this.state = 'none'
30
- this.icon.set('text-align-justify');
31
- return;
32
- }
33
- var sort = x.sorts.find(x => x.column == this.tuiThSortable);
34
- if (!sort)
35
- {
36
- this.state = 'none'
37
- this.icon.set('text-align-justify');
38
- return;
39
- }
40
- this.state = sort.state;
41
-
42
- switch(sort.state){
43
- case 'none':
44
- this.icon.set('text-align-justify');
45
- break;
46
- case 'asc':
47
- this.icon.set('arrow-up-wide-narrow');
48
- break;
49
- case 'desc':
50
- this.icon.set('arrow-down-wide-narrow');
51
- break;
52
- }
53
- })
54
- }
55
-
56
- sort(){
57
- switch(this.state){
58
- case 'none':
59
- this.state = 'asc';
60
- this.table.setSort({ column: this.tuiThSortable, state: this.state } as FloatTableSort)
61
- this.icon.set('arrow-up-wide-narrow');
62
- break;
63
- case 'asc':
64
- this.state = 'desc';
65
- this.table.setSort({ column: this.tuiThSortable, state: this.state } as FloatTableSort)
66
- this.icon.set('arrow-down-wide-narrow');
67
- break;
68
- case 'desc':
69
- this.state = 'none';
70
- this.table.clearSort(this.tuiThSortable);
71
- this.icon.set('text-align-justify');
72
- break;
73
- }
74
- }
75
- }