@kris701/ez-ui 0.0.2 → 0.0.4

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,178 +1,178 @@
1
- import { CommonModule } from "@angular/common";
2
- import { Component, Input, signal } from "@angular/core";
3
- import { FormsModule } from "@angular/forms";
4
- import { TuiButton, TuiDataList, TuiDropdown, TuiInput } from "@taiga-ui/core";
5
- import { TuiBadgeNotification, TuiBadgedContent, TuiButtonSelect, TuiDataListWrapper, TuiMultiSelect, TuiStringifyContentPipe } from "@taiga-ui/kit";
6
- import { FloatTable } from "../floattable";
7
- import { FloatTableFilter } from "../models/FloatTableFilter";
8
-
9
- @Component({
10
- selector: 'tuiThSelectFilter',
11
- imports: [CommonModule, FormsModule, TuiDropdown, TuiDataListWrapper, TuiButton, TuiButtonSelect, TuiStringifyContentPipe, TuiBadgeNotification, TuiBadgedContent, TuiInput, TuiMultiSelect, TuiDataList],
12
- template: `
13
- @if(tuiThSelectFilter){
14
- <tui-badged-content>
15
- @if(filterApplied()){
16
- <tui-badge-notification
17
- size="s"
18
- tuiSlot="top"
19
- >
20
- 1
21
- </tui-badge-notification>
22
- }
23
- <button
24
- tuiButton size="s"
25
- iconStart="funnel"
26
- appearance="flat-grayscale"
27
- style="opacity:0.72"
28
- [tuiDropdown]="filterPop"
29
- [(tuiDropdownOpen)]="filterVisible"
30
- (click)="filterVisible.set(true)"
31
- ></button>
32
- </tui-badged-content>
33
-
34
- <ng-template #filterPop>
35
- <div class="flex flex-col gap-2 p-4" style="min-width:20rem">
36
- <button
37
- appearance="outline-grayscale"
38
- size="s"
39
- tuiButton
40
- tuiButtonSelect
41
- [(ngModel)]="filterType"
42
- >
43
- {{ filterType.label }}
44
- <tui-data-list-wrapper
45
- *tuiDropdown
46
- [itemContent]="stringify | tuiStringifyContent"
47
- [items]="filterTypes"
48
- />
49
- </button>
50
-
51
- <button
52
- appearance="secondary-grayscale"
53
- size="s"
54
- tuiButton
55
- tuiButtonSelect
56
- [(ngModel)]="selected"
57
- >
58
- {{selected.length === 1 ? selected[0] : 'Selected ' + selected.length}}
59
-
60
- <tui-data-list *tuiDropdown>
61
- <tui-opt-group
62
- label="Options"
63
- tuiMultiSelectGroup
64
- >
65
- @for (option of options; track option) {
66
- <button
67
- tuiOption
68
- type="button"
69
- [value]="option"
70
- >
71
- {{ option }}
72
- </button>
73
- }
74
- </tui-opt-group>
75
- </tui-data-list>
76
- </button>
77
-
78
- <button
79
- tuiButton size="s"
80
- iconStart="funnel"
81
- tuiButton
82
- (click)="applyFilter(filterType.expression)"
83
- >
84
- Apply
85
- </button>
86
-
87
- @if(filterApplied()){
88
- <button
89
- tuiButton size="s"
90
- iconStart="circle-x"
91
- tuiButton
92
- (click)="clearFilter()"
93
- >
94
- Clear
95
- </button>
96
- }
97
- </div>
98
- </ng-template>
99
- }
100
- `
101
- })
102
- export class TableSelectFilter {
103
- @Input() tuiThSelectFilter!: string;
104
-
105
- filterApplied = signal<boolean>(false);
106
- filterVisible = signal<boolean>(false);
107
-
108
- table : FloatTable;
109
-
110
- @Input() options : string[] = [];
111
- selected : string[] = [];
112
- filterType : any;
113
- filterTypes : any[];
114
-
115
- protected readonly stringify = (item: any): string => `${item.label}`;
116
-
117
- constructor(table : FloatTable){
118
- this.table = table;
119
-
120
- this.filterTypes = [
121
- {
122
- label: 'Contains',
123
- expression: 'sel;con'
124
- },
125
- {
126
- label: 'Not Contains',
127
- expression: 'sel;ncon'
128
- }
129
- ];
130
- this.filterType = this.filterTypes[0];
131
-
132
- this.table.onPresetChange.subscribe(x => {
133
- if (!x)
134
- {
135
- this.filterType = this.filterTypes[0];
136
- this.selected = [];
137
- this.filterApplied.set(false);
138
- return;
139
- }
140
- var filter = x.filters.find(x => x.column == this.tuiThSelectFilter);
141
- if (!filter)
142
- {
143
- this.filterType = this.filterTypes[0];
144
- this.selected = [];
145
- this.filterApplied.set(false);
146
- return;
147
- }
148
- var type = this.filterTypes.find(x => x.expression == filter!.expression);
149
- if (!type)
150
- {
151
- this.filterType = this.filterTypes[0];
152
- this.selected = [];
153
- this.filterApplied.set(false);
154
- return;
155
- }
156
-
157
- this.filterType = type;
158
- this.selected = filter.value;
159
- this.filterApplied.set(true);
160
- })
161
- }
162
-
163
- applyFilter(expression : string){
164
- this.table.setFilter({
165
- column: this.tuiThSelectFilter,
166
- value: this.selected,
167
- expression: expression,
168
- } as FloatTableFilter);
169
- this.filterVisible.set(false);
170
- this.filterApplied.set(true);
171
- }
172
-
173
- clearFilter(){
174
- this.table.clearFilter(this.tuiThSelectFilter);
175
- this.filterVisible.set(false);
176
- this.filterApplied.set(false);
177
- }
178
- }
1
+ import { CommonModule } from "@angular/common";
2
+ import { Component, Input, signal } from "@angular/core";
3
+ import { FormsModule } from "@angular/forms";
4
+ import { TuiButton, TuiDataList, TuiDropdown, TuiInput } from "@taiga-ui/core";
5
+ import { TuiBadgeNotification, TuiBadgedContent, TuiButtonSelect, TuiDataListWrapper, TuiMultiSelect, TuiStringifyContentPipe } from "@taiga-ui/kit";
6
+ import { FloatTable } from "../floattable";
7
+ import { FloatTableFilter } from "../models/FloatTableFilter";
8
+
9
+ @Component({
10
+ selector: 'tuiThSelectFilter',
11
+ imports: [CommonModule, FormsModule, TuiDropdown, TuiDataListWrapper, TuiButton, TuiButtonSelect, TuiStringifyContentPipe, TuiBadgeNotification, TuiBadgedContent, TuiInput, TuiMultiSelect, TuiDataList],
12
+ template: `
13
+ @if(tuiThSelectFilter){
14
+ <tui-badged-content>
15
+ @if(filterApplied()){
16
+ <tui-badge-notification
17
+ size="s"
18
+ tuiSlot="top"
19
+ >
20
+ 1
21
+ </tui-badge-notification>
22
+ }
23
+ <button
24
+ tuiButton size="s"
25
+ iconStart="funnel"
26
+ appearance="flat-grayscale"
27
+ style="opacity:0.72"
28
+ [tuiDropdown]="filterPop"
29
+ [(tuiDropdownOpen)]="filterVisible"
30
+ (click)="filterVisible.set(true)"
31
+ ></button>
32
+ </tui-badged-content>
33
+
34
+ <ng-template #filterPop>
35
+ <div class="flex flex-col gap-2 p-4" style="min-width:20rem">
36
+ <button
37
+ appearance="outline-grayscale"
38
+ size="s"
39
+ tuiButton
40
+ tuiButtonSelect
41
+ [(ngModel)]="filterType"
42
+ >
43
+ {{ filterType.label }}
44
+ <tui-data-list-wrapper
45
+ *tuiDropdown
46
+ [itemContent]="stringify | tuiStringifyContent"
47
+ [items]="filterTypes"
48
+ />
49
+ </button>
50
+
51
+ <button
52
+ appearance="secondary-grayscale"
53
+ size="s"
54
+ tuiButton
55
+ tuiButtonSelect
56
+ [(ngModel)]="selected"
57
+ >
58
+ {{selected.length === 1 ? selected[0] : 'Selected ' + selected.length}}
59
+
60
+ <tui-data-list *tuiDropdown>
61
+ <tui-opt-group
62
+ label="Options"
63
+ tuiMultiSelectGroup
64
+ >
65
+ @for (option of options; track option) {
66
+ <button
67
+ tuiOption
68
+ type="button"
69
+ [value]="option"
70
+ >
71
+ {{ option }}
72
+ </button>
73
+ }
74
+ </tui-opt-group>
75
+ </tui-data-list>
76
+ </button>
77
+
78
+ <button
79
+ tuiButton size="s"
80
+ iconStart="funnel"
81
+ tuiButton
82
+ (click)="applyFilter(filterType.expression)"
83
+ >
84
+ Apply
85
+ </button>
86
+
87
+ @if(filterApplied()){
88
+ <button
89
+ tuiButton size="s"
90
+ iconStart="circle-x"
91
+ tuiButton
92
+ (click)="clearFilter()"
93
+ >
94
+ Clear
95
+ </button>
96
+ }
97
+ </div>
98
+ </ng-template>
99
+ }
100
+ `
101
+ })
102
+ export class TableSelectFilter {
103
+ @Input() tuiThSelectFilter!: string;
104
+
105
+ filterApplied = signal<boolean>(false);
106
+ filterVisible = signal<boolean>(false);
107
+
108
+ table : FloatTable;
109
+
110
+ @Input() options : string[] = [];
111
+ selected : string[] = [];
112
+ filterType : any;
113
+ filterTypes : any[];
114
+
115
+ protected readonly stringify = (item: any): string => `${item.label}`;
116
+
117
+ constructor(table : FloatTable){
118
+ this.table = table;
119
+
120
+ this.filterTypes = [
121
+ {
122
+ label: 'Contains',
123
+ expression: 'sel;con'
124
+ },
125
+ {
126
+ label: 'Not Contains',
127
+ expression: 'sel;ncon'
128
+ }
129
+ ];
130
+ this.filterType = this.filterTypes[0];
131
+
132
+ this.table.onPresetChange.subscribe(x => {
133
+ if (!x)
134
+ {
135
+ this.filterType = this.filterTypes[0];
136
+ this.selected = [];
137
+ this.filterApplied.set(false);
138
+ return;
139
+ }
140
+ var filter = x.filters.find(x => x.column == this.tuiThSelectFilter);
141
+ if (!filter)
142
+ {
143
+ this.filterType = this.filterTypes[0];
144
+ this.selected = [];
145
+ this.filterApplied.set(false);
146
+ return;
147
+ }
148
+ var type = this.filterTypes.find(x => x.expression == filter!.expression);
149
+ if (!type)
150
+ {
151
+ this.filterType = this.filterTypes[0];
152
+ this.selected = [];
153
+ this.filterApplied.set(false);
154
+ return;
155
+ }
156
+
157
+ this.filterType = type;
158
+ this.selected = filter.value;
159
+ this.filterApplied.set(true);
160
+ })
161
+ }
162
+
163
+ applyFilter(expression : string){
164
+ this.table.setFilter({
165
+ column: this.tuiThSelectFilter,
166
+ value: this.selected,
167
+ expression: expression,
168
+ } as FloatTableFilter);
169
+ this.filterVisible.set(false);
170
+ this.filterApplied.set(true);
171
+ }
172
+
173
+ clearFilter(){
174
+ this.table.clearFilter(this.tuiThSelectFilter);
175
+ this.filterVisible.set(false);
176
+ this.filterApplied.set(false);
177
+ }
178
+ }
@@ -1,161 +1,161 @@
1
- import { CommonModule } from "@angular/common";
2
- import { Component, Input, signal } from "@angular/core";
3
- import { FormsModule } from "@angular/forms";
4
- import { TuiButton, TuiDropdown, TuiInput } from "@taiga-ui/core";
5
- import { TuiBadgeNotification, TuiBadgedContent, TuiButtonSelect, TuiDataListWrapper, TuiStringifyContentPipe } from "@taiga-ui/kit";
6
- import { FloatTable } from "../floattable";
7
- import { FloatTableFilter } from "../models/FloatTableFilter";
8
-
9
- @Component({
10
- selector: 'tuiThTextFilter',
11
- imports: [CommonModule, FormsModule, TuiDropdown, TuiDataListWrapper, TuiButton, TuiButtonSelect, TuiStringifyContentPipe, TuiBadgeNotification, TuiBadgedContent, TuiInput],
12
- template: `
13
- @if(tuiThTextFilter){
14
- <tui-badged-content>
15
- @if(filterApplied()){
16
- <tui-badge-notification
17
- size="s"
18
- tuiSlot="top"
19
- >
20
- 1
21
- </tui-badge-notification>
22
- }
23
- <button
24
- tuiButton size="s"
25
- iconStart="funnel"
26
- appearance="flat-grayscale"
27
- style="opacity:0.72"
28
- [tuiDropdown]="filterPop"
29
- [(tuiDropdownOpen)]="filterVisible"
30
- (click)="filterVisible.set(true)"
31
- ></button>
32
- </tui-badged-content>
33
-
34
- <ng-template #filterPop>
35
- <div class="flex flex-col gap-2 p-4" style="min-width:20rem">
36
- <button
37
- appearance="outline-grayscale"
38
- size="s"
39
- tuiButton
40
- tuiButtonSelect
41
- [(ngModel)]="filterType"
42
- >
43
- {{ filterType.label }}
44
- <tui-data-list-wrapper
45
- *tuiDropdown
46
- [itemContent]="stringify | tuiStringifyContent"
47
- [items]="filterTypes"
48
- />
49
- </button>
50
-
51
- <tui-textfield tuiTextfieldSize="s" (keydown.enter)="applyFilter(filterType.expression)">
52
- <input tuiInput [(ngModel)]="value"/>
53
- </tui-textfield>
54
- <button
55
- tuiButton size="s"
56
- iconStart="funnel"
57
- tuiButton
58
- (click)="applyFilter(filterType.expression)"
59
- >
60
- Apply
61
- </button>
62
-
63
- @if(filterApplied()){
64
- <button
65
- tuiButton size="s"
66
- iconStart="circle-x"
67
- tuiButton
68
- (click)="clearFilter()"
69
- >
70
- Clear
71
- </button>
72
- }
73
- </div>
74
- </ng-template>
75
- }
76
- `
77
- })
78
- export class TableTextFilter {
79
- @Input() tuiThTextFilter!: string;
80
-
81
- filterApplied = signal<boolean>(false);
82
- filterVisible = signal<boolean>(false);
83
-
84
- table : FloatTable;
85
-
86
- value : string = '';
87
- filterType : any;
88
- filterTypes : any[];
89
-
90
- protected readonly stringify = (item: any): string => `${item.label}`;
91
-
92
- constructor(table : FloatTable){
93
- this.table = table;
94
-
95
- this.filterTypes = [
96
- {
97
- label: 'Contains',
98
- expression: 'str;con'
99
- },
100
- {
101
- label: 'Not Contains',
102
- expression: 'str;ncon'
103
- },
104
- {
105
- label: 'Starts With',
106
- expression: 'str;sta'
107
- },
108
- {
109
- label: 'Ends With',
110
- expression: 'str;end'
111
- }
112
- ];
113
- this.filterType = this.filterTypes[0];
114
-
115
- this.table.onPresetChange.subscribe(x => {
116
- if (!x)
117
- {
118
- this.filterType = this.filterTypes[0];
119
- this.value = "";
120
- this.filterApplied.set(false);
121
- return;
122
- }
123
- var filter = x.filters.find(x => x.column == this.tuiThTextFilter);
124
- if (!filter)
125
- {
126
- this.filterType = this.filterTypes[0];
127
- this.value = "";
128
- this.filterApplied.set(false);
129
- return;
130
- }
131
- var type = this.filterTypes.find(x => x.expression == filter!.expression);
132
- if (!type)
133
- {
134
- this.filterType = this.filterTypes[0];
135
- this.value = "";
136
- this.filterApplied.set(false);
137
- return;
138
- }
139
-
140
- this.filterType = type;
141
- this.value = filter.value;
142
- this.filterApplied.set(true);
143
- })
144
- }
145
-
146
- applyFilter(expression : string){
147
- this.table.setFilter({
148
- column: this.tuiThTextFilter,
149
- value: this.value,
150
- expression: expression,
151
- } as FloatTableFilter);
152
- this.filterVisible.set(false);
153
- this.filterApplied.set(true);
154
- }
155
-
156
- clearFilter(){
157
- this.table.clearFilter(this.tuiThTextFilter);
158
- this.filterVisible.set(false);
159
- this.filterApplied.set(false);
160
- }
161
- }
1
+ import { CommonModule } from "@angular/common";
2
+ import { Component, Input, signal } from "@angular/core";
3
+ import { FormsModule } from "@angular/forms";
4
+ import { TuiButton, TuiDropdown, TuiInput } from "@taiga-ui/core";
5
+ import { TuiBadgeNotification, TuiBadgedContent, TuiButtonSelect, TuiDataListWrapper, TuiStringifyContentPipe } from "@taiga-ui/kit";
6
+ import { FloatTable } from "../floattable";
7
+ import { FloatTableFilter } from "../models/FloatTableFilter";
8
+
9
+ @Component({
10
+ selector: 'tuiThTextFilter',
11
+ imports: [CommonModule, FormsModule, TuiDropdown, TuiDataListWrapper, TuiButton, TuiButtonSelect, TuiStringifyContentPipe, TuiBadgeNotification, TuiBadgedContent, TuiInput],
12
+ template: `
13
+ @if(tuiThTextFilter){
14
+ <tui-badged-content>
15
+ @if(filterApplied()){
16
+ <tui-badge-notification
17
+ size="s"
18
+ tuiSlot="top"
19
+ >
20
+ 1
21
+ </tui-badge-notification>
22
+ }
23
+ <button
24
+ tuiButton size="s"
25
+ iconStart="funnel"
26
+ appearance="flat-grayscale"
27
+ style="opacity:0.72"
28
+ [tuiDropdown]="filterPop"
29
+ [(tuiDropdownOpen)]="filterVisible"
30
+ (click)="filterVisible.set(true)"
31
+ ></button>
32
+ </tui-badged-content>
33
+
34
+ <ng-template #filterPop>
35
+ <div class="flex flex-col gap-2 p-4" style="min-width:20rem">
36
+ <button
37
+ appearance="outline-grayscale"
38
+ size="s"
39
+ tuiButton
40
+ tuiButtonSelect
41
+ [(ngModel)]="filterType"
42
+ >
43
+ {{ filterType.label }}
44
+ <tui-data-list-wrapper
45
+ *tuiDropdown
46
+ [itemContent]="stringify | tuiStringifyContent"
47
+ [items]="filterTypes"
48
+ />
49
+ </button>
50
+
51
+ <tui-textfield tuiTextfieldSize="s" (keydown.enter)="applyFilter(filterType.expression)">
52
+ <input tuiInput [(ngModel)]="value"/>
53
+ </tui-textfield>
54
+ <button
55
+ tuiButton size="s"
56
+ iconStart="funnel"
57
+ tuiButton
58
+ (click)="applyFilter(filterType.expression)"
59
+ >
60
+ Apply
61
+ </button>
62
+
63
+ @if(filterApplied()){
64
+ <button
65
+ tuiButton size="s"
66
+ iconStart="circle-x"
67
+ tuiButton
68
+ (click)="clearFilter()"
69
+ >
70
+ Clear
71
+ </button>
72
+ }
73
+ </div>
74
+ </ng-template>
75
+ }
76
+ `
77
+ })
78
+ export class TableTextFilter {
79
+ @Input() tuiThTextFilter!: string;
80
+
81
+ filterApplied = signal<boolean>(false);
82
+ filterVisible = signal<boolean>(false);
83
+
84
+ table : FloatTable;
85
+
86
+ value : string = '';
87
+ filterType : any;
88
+ filterTypes : any[];
89
+
90
+ protected readonly stringify = (item: any): string => `${item.label}`;
91
+
92
+ constructor(table : FloatTable){
93
+ this.table = table;
94
+
95
+ this.filterTypes = [
96
+ {
97
+ label: 'Contains',
98
+ expression: 'str;con'
99
+ },
100
+ {
101
+ label: 'Not Contains',
102
+ expression: 'str;ncon'
103
+ },
104
+ {
105
+ label: 'Starts With',
106
+ expression: 'str;sta'
107
+ },
108
+ {
109
+ label: 'Ends With',
110
+ expression: 'str;end'
111
+ }
112
+ ];
113
+ this.filterType = this.filterTypes[0];
114
+
115
+ this.table.onPresetChange.subscribe(x => {
116
+ if (!x)
117
+ {
118
+ this.filterType = this.filterTypes[0];
119
+ this.value = "";
120
+ this.filterApplied.set(false);
121
+ return;
122
+ }
123
+ var filter = x.filters.find(x => x.column == this.tuiThTextFilter);
124
+ if (!filter)
125
+ {
126
+ this.filterType = this.filterTypes[0];
127
+ this.value = "";
128
+ this.filterApplied.set(false);
129
+ return;
130
+ }
131
+ var type = this.filterTypes.find(x => x.expression == filter!.expression);
132
+ if (!type)
133
+ {
134
+ this.filterType = this.filterTypes[0];
135
+ this.value = "";
136
+ this.filterApplied.set(false);
137
+ return;
138
+ }
139
+
140
+ this.filterType = type;
141
+ this.value = filter.value;
142
+ this.filterApplied.set(true);
143
+ })
144
+ }
145
+
146
+ applyFilter(expression : string){
147
+ this.table.setFilter({
148
+ column: this.tuiThTextFilter,
149
+ value: this.value,
150
+ expression: expression,
151
+ } as FloatTableFilter);
152
+ this.filterVisible.set(false);
153
+ this.filterApplied.set(true);
154
+ }
155
+
156
+ clearFilter(){
157
+ this.table.clearFilter(this.tuiThTextFilter);
158
+ this.filterVisible.set(false);
159
+ this.filterApplied.set(false);
160
+ }
161
+ }