easy-mat-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.
Files changed (43) hide show
  1. package/ng-package.json +19 -0
  2. package/package.json +16 -18
  3. package/src/lib/easy-mat-ui.component.spec.ts +23 -0
  4. package/src/lib/easy-mat-ui.component.ts +16 -0
  5. package/src/lib/easy-mat-ui.service.spec.ts +16 -0
  6. package/src/lib/easy-mat-ui.service.ts +9 -0
  7. package/src/lib/easy-multi-select/easy-multi-select.css +102 -0
  8. package/src/lib/easy-multi-select/easy-multi-select.html +51 -0
  9. package/src/lib/easy-multi-select/easy-multi-select.spec.ts +23 -0
  10. package/src/lib/easy-multi-select/easy-multi-select.ts +181 -0
  11. package/src/lib/easy-table/easy-table.component.css +117 -0
  12. package/src/lib/easy-table/easy-table.component.html +221 -0
  13. package/src/lib/easy-table/easy-table.component.spec.ts +23 -0
  14. package/src/lib/easy-table/easy-table.component.ts +568 -0
  15. package/src/lib/model/dictionary.model.ts +4 -0
  16. package/src/lib/model/mat-column-typed.model.ts +41 -0
  17. package/src/lib/model/mat-column.model.ts +35 -0
  18. package/src/lib/model/tuple.model.ts +8 -0
  19. package/src/lib/shared/table-toolbar/table-toolbar.css +26 -0
  20. package/src/lib/shared/table-toolbar/table-toolbar.html +80 -0
  21. package/src/lib/shared/table-toolbar/table-toolbar.ts +130 -0
  22. package/src/lib/styles/_backgrounds.scss +39 -0
  23. package/src/lib/styles/_buttons.scss +90 -0
  24. package/src/lib/styles/_colors.scss +67 -0
  25. package/src/lib/styles/_effects.scss +44 -0
  26. package/src/lib/styles/_material-overrides.scss +87 -0
  27. package/src/lib/styles/_spacing.scss +68 -0
  28. package/src/lib/styles/_tables.scss +71 -0
  29. package/src/lib/styles/_typography.scss +105 -0
  30. package/src/lib/styles.scss +30 -0
  31. package/src/lib/utils/enums.ts +49 -0
  32. package/src/lib/utils/matTabCommon.ts +59 -0
  33. package/src/lib/utils/utils.ts +68 -0
  34. package/{public-api.d.ts → src/public-api.ts} +8 -3
  35. package/tsconfig.lib.json +18 -0
  36. package/tsconfig.lib.prod.json +11 -0
  37. package/tsconfig.spec.json +15 -0
  38. package/fesm2022/easy-mat-ui.mjs +0 -98
  39. package/fesm2022/easy-mat-ui.mjs.map +0 -1
  40. package/index.d.ts +0 -5
  41. package/lib/easy-mat-ui.component.d.ts +0 -5
  42. package/lib/easy-mat-ui.service.d.ts +0 -6
  43. package/lib/easy-table/easy-table.component.d.ts +0 -15
@@ -0,0 +1,19 @@
1
+ {
2
+ "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3
+ "dest": "../../dist/easy-mat-ui",
4
+ "lib": {
5
+ "entryFile": "src/public-api.ts",
6
+ "styleIncludePaths": [
7
+ "../../node_modules",
8
+ "src/lib/styles"
9
+ ]
10
+ },
11
+ "assets": [
12
+ "src/lib/styles/theme.scss",
13
+ "node_modules/@angular/material/prebuilt-themes/indigo-pink.css"
14
+ ],
15
+ "allowedNonPeerDependencies": [
16
+ "bootstrap",
17
+ "file-saver"
18
+ ]
19
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "easy-mat-ui",
3
- "version": "0.0.2",
4
- "description": "A customizable Angular Material Table component with Bootstrap styling and i18n support",
3
+ "version": "0.0.4",
4
+ "description": "A customizable Angular Material",
5
5
  "keywords": [
6
6
  "angular",
7
7
  "material",
@@ -14,27 +14,25 @@
14
14
  "author": "Red One <ton.email@example.com>",
15
15
  "license": "MIT",
16
16
  "peerDependencies": {
17
- "@angular/common": "^19.0.0",
18
- "@angular/core": "^19.0.0",
19
- "@angular/material": "^19.0.0",
20
- "@angular/cdk": "^19.0.0",
17
+ "@angular/common": "^20.0.5",
18
+ "@angular/core": "^20.0.5",
19
+ "@angular/material": "^20.0.5",
20
+ "@angular/cdk": "^20.0.5",
21
21
  "@ngx-translate/core": "^16.0.0",
22
22
  "@ngx-translate/http-loader": "^16.0.0",
23
- "bootstrap": "^5.3.0"
23
+ "bootstrap": "^5.3.0",
24
+ "@angular/forms": "^20.0.5",
25
+ "@angular/platform-browser": "^20.0.5",
26
+ "@angular/platform-browser-dynamic": "^20.0.5",
27
+ "@angular/animations": "^20.0.5"
24
28
  },
25
29
  "dependencies": {
26
30
  "tslib": "^2.3.0"
27
31
  },
28
32
  "module": "fesm2022/easy-mat-ui.mjs",
29
33
  "typings": "index.d.ts",
30
- "exports": {
31
- ".": {
32
- "default": "./fesm2022/easy-mat-ui.mjs",
33
- "types": "./index.d.ts"
34
- },
35
- "./package.json": {
36
- "default": "./package.json"
37
- }
38
- },
39
- "sideEffects": false
40
- }
34
+ "sideEffects": false,
35
+ "publishConfig": {
36
+ "access": "public"
37
+ }
38
+ }
@@ -0,0 +1,23 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { EasyMatUiComponent } from './easy-mat-ui.component';
4
+
5
+ describe('EasyMatUiComponent', () => {
6
+ let component: EasyMatUiComponent;
7
+ let fixture: ComponentFixture<EasyMatUiComponent>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ imports: [EasyMatUiComponent]
12
+ })
13
+ .compileComponents();
14
+
15
+ fixture = TestBed.createComponent(EasyMatUiComponent);
16
+ component = fixture.componentInstance;
17
+ fixture.detectChanges();
18
+ });
19
+
20
+ it('should create', () => {
21
+ expect(component).toBeTruthy();
22
+ });
23
+ });
@@ -0,0 +1,16 @@
1
+ import { Component } from '@angular/core';
2
+
3
+ @Component({
4
+ selector: 'lib-easy-mat-ui',
5
+ imports: [],
6
+ template: `
7
+ <p>
8
+ easy-mat-ui works!
9
+ </p>
10
+ `,
11
+ standalone: true,
12
+ styles: ``
13
+ })
14
+ export class EasyMatUiComponent {
15
+
16
+ }
@@ -0,0 +1,16 @@
1
+ import { TestBed } from '@angular/core/testing';
2
+
3
+ import { EasyMatUiService } from './easy-mat-ui.service';
4
+
5
+ describe('EasyMatUiService', () => {
6
+ let service: EasyMatUiService;
7
+
8
+ beforeEach(() => {
9
+ TestBed.configureTestingModule({});
10
+ service = TestBed.inject(EasyMatUiService);
11
+ });
12
+
13
+ it('should be created', () => {
14
+ expect(service).toBeTruthy();
15
+ });
16
+ });
@@ -0,0 +1,9 @@
1
+ import { Injectable } from '@angular/core';
2
+
3
+ @Injectable({
4
+ providedIn: 'root'
5
+ })
6
+ export class EasyMatUiService {
7
+
8
+ constructor() { }
9
+ }
@@ -0,0 +1,102 @@
1
+ .full-width {
2
+ width: 100%;
3
+ }
4
+
5
+ .select-header {
6
+ display: flex;
7
+ align-items: center;
8
+ padding: 10px;
9
+ gap: 8px;
10
+ flex-wrap: nowrap;
11
+ overflow: hidden;
12
+ }
13
+
14
+ .search-field {
15
+ flex: 1;
16
+ min-width: 0;
17
+ }
18
+
19
+ mat-form-field.search-field {
20
+ margin: 0;
21
+ }
22
+
23
+ .options {
24
+ max-height: 200px;
25
+ overflow-y: auto;
26
+ overflow-x: hidden;
27
+ }
28
+
29
+ .no-data {
30
+ padding: 12px;
31
+ color: gray;
32
+ font-style: italic;
33
+ }
34
+
35
+ .select-color {
36
+ white-space: nowrap;
37
+ }
38
+
39
+ ::ng-deep .checkbox-container{
40
+ display: flex !important;
41
+ align-items: center !important;
42
+ }
43
+
44
+ ::ng-deep div.mat-mdc-select-panel{
45
+ max-height: unset !important;
46
+ }
47
+
48
+
49
+
50
+
51
+
52
+
53
+ .pd-l-10 {
54
+ padding-left: 10px;
55
+ }
56
+
57
+ .pd-r-10 {
58
+ padding-right: 10px;
59
+ }
60
+
61
+ .pd-t-10 {
62
+ padding-top: 10px;
63
+ }
64
+
65
+ .select-color {
66
+ color: #5a0023 !important;
67
+ font-weight: 500;
68
+ }
69
+
70
+ .d-contents {
71
+ display: contents;
72
+ }
73
+
74
+ .no-data {
75
+ color: red;
76
+ font-weight: bold;
77
+ text-align: center;
78
+ }
79
+
80
+ ::ng-deep .mat-checkbox-layout {
81
+ margin-top: 15px;
82
+ }
83
+
84
+ ::ng-deep .mat-select-panel {
85
+ min-width: 100% !important;
86
+ }
87
+
88
+ ::ng-deep .cdk-overlay-pane {
89
+ transform: none !important;
90
+ }
91
+
92
+ .mat-icon {
93
+ color: red !important;
94
+ }
95
+
96
+ .hover {
97
+ cursor: pointer;
98
+ }
99
+
100
+ ::ng-deep .mat-mdc-form-field-subscript-wrapper.mat-mdc-form-field-bottom-align {
101
+ display: none !important;
102
+ }
@@ -0,0 +1,51 @@
1
+ <mat-form-field class="w-100 underline-style flex-grow-1" [ngClass]="padding" floatLabel="always">
2
+ @if (!noPlaceholderNoHint && !hidePlaceholder) {
3
+ <mat-label>
4
+ {{ title | translate }}
5
+ </mat-label>
6
+ }
7
+ <mat-select [formControl]="multiSelectControl" multiple #opts [panelClass]="uniqueId"
8
+ (openedChange)="searchCtrl.setValue('')">
9
+ <div class="checkbox-container container-fluid pd-l-10 pd-t-10 w-100 flex-grow-1">
10
+ <mat-checkbox
11
+ color="primary"
12
+ [checked]="selected(opts) === 'all'"
13
+ [indeterminate]="selected(opts) === 'some'"
14
+ (change)="toggleSelection(opts)"
15
+ matTooltip="{{getTooltips(opts) | translate }}"
16
+ matTooltipPosition="above">
17
+ </mat-checkbox>
18
+ <mat-form-field class="w-100 flex-grow-1">
19
+ <input matInput #input placeholder="Search" class="w-100 flex-grow-1"
20
+ [formControl]="searchCtrl"
21
+ (keydown)="onKeydown($event, input)"/>
22
+ <mat-icon class="hover" matSuffix (click)="clear()" title="{{'CLEAR' | translate}}">cleaning_services</mat-icon>
23
+ </mat-form-field>
24
+
25
+ <mat-icon class="hover" matSuffix (click)="opts.close()"
26
+ title="{{ 'CLOSE' | translate }}">close
27
+ </mat-icon>
28
+ </div>
29
+ <mat-divider></mat-divider>
30
+ <div class="options">
31
+ @if (searchCtrl.value && !opts.options?.length) {
32
+ <div class="no-data">
33
+ {{ 'NO_RESULTS_FOUND' | translate }} "{{ searchCtrl.value }}"
34
+ </div>
35
+ }
36
+ <mat-option class="select-color"
37
+ *ngFor="let item of filteredMultiSelect | async "
38
+ [value]="item[valueField]"
39
+ (onSelectionChange)="onSelectionChange($event)"
40
+ >{{ item[displayField] }}
41
+ </mat-option
42
+ >
43
+ </div>
44
+ </mat-select>
45
+ </mat-form-field>
46
+ @if (!noPlaceholderNoHint && data.length === 0) {
47
+ <div>
48
+ {{ 'NO_OPTIONS' | translate }}
49
+ </div>
50
+ }
51
+
@@ -0,0 +1,23 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { EasyMultiSelect } from './easy-multi-select';
4
+
5
+ describe('EasyMultiSelect', () => {
6
+ let component: EasyMultiSelect;
7
+ let fixture: ComponentFixture<EasyMultiSelect>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ imports: [EasyMultiSelect]
12
+ })
13
+ .compileComponents();
14
+
15
+ fixture = TestBed.createComponent(EasyMultiSelect);
16
+ component = fixture.componentInstance;
17
+ fixture.detectChanges();
18
+ });
19
+
20
+ it('should create', () => {
21
+ expect(component).toBeTruthy();
22
+ });
23
+ });
@@ -0,0 +1,181 @@
1
+ import {
2
+ AfterViewInit,
3
+ ChangeDetectionStrategy,
4
+ ChangeDetectorRef,
5
+ Component,
6
+ EventEmitter,
7
+ Input,
8
+ OnInit,
9
+ Output
10
+ } from '@angular/core';
11
+ import {FormControl, ReactiveFormsModule} from '@angular/forms';
12
+ import {MatSelect, MatSelectModule} from '@angular/material/select';
13
+ import {CommonModule} from '@angular/common';
14
+ import {MatFormFieldAppearance, MatFormFieldModule} from '@angular/material/form-field';
15
+ import {MatCheckboxModule} from '@angular/material/checkbox';
16
+ import {MatIconModule} from '@angular/material/icon';
17
+ import {MatDividerModule} from '@angular/material/divider';
18
+ import {MatTooltipModule} from '@angular/material/tooltip';
19
+ import {TranslateModule} from '@ngx-translate/core';
20
+ import {MatInput, MatInputModule} from "@angular/material/input";
21
+ import {MatButtonModule, MatIconButton} from '@angular/material/button';
22
+ import {Dictionary} from '../model/dictionary.model';
23
+ import {map, Observable, startWith} from 'rxjs';
24
+ import {MatOption, MatOptionSelectionChange} from '@angular/material/core';
25
+ import {Utils} from '../utils/utils';
26
+
27
+ @Component({
28
+ selector: 'lib-easy-multi-select',
29
+ host: { '[attr.data-component-id]': "'easy-multi-select-' + componentId" },
30
+ standalone: true,
31
+ imports: [
32
+ CommonModule,
33
+ ReactiveFormsModule,
34
+ MatFormFieldModule,
35
+ MatSelectModule,
36
+ MatCheckboxModule,
37
+ MatIconModule,
38
+ MatDividerModule,
39
+ MatTooltipModule,
40
+ TranslateModule,
41
+ MatInputModule,
42
+ MatButtonModule
43
+ ],
44
+ templateUrl: './easy-multi-select.html',
45
+ styleUrls: ['./easy-multi-select.css', '../styles.scss'],
46
+ changeDetection: ChangeDetectionStrategy.OnPush,
47
+ })
48
+ export class EasyMultiSelect implements OnInit, AfterViewInit {
49
+ componentId = Math.random().toString(36).substring(2);
50
+ @Input() data: Dictionary[] = [];
51
+ @Input() title = 'multi select';
52
+ @Input() valueField!: keyof Dictionary;
53
+ @Input() displayField!: keyof Dictionary;
54
+ @Input() selectedData: Dictionary[] = [];
55
+ @Input() readOnly = false;
56
+ @Input() noPlaceholderNoHint = false;
57
+ @Input() padding = 'pd-0';
58
+ @Input() appearance: MatFormFieldAppearance = 'fill';
59
+
60
+ @Output() change = new EventEmitter<string[]>();
61
+ multiSelectControl = new FormControl<string[]>([]);
62
+ searchCtrl = new FormControl<string>('');
63
+ filteredMultiSelect: Observable<Dictionary[]> = new Observable<Dictionary[]>();
64
+
65
+ @Input() idPrefix = 'multi-select';
66
+ uniqueId = `${this.idPrefix}-${Math.random().toString(36).substring(2, 9)}`;
67
+
68
+
69
+ constructor(private cdref: ChangeDetectorRef) {
70
+ }
71
+
72
+ ngOnInit(): void {
73
+ this.data = (Utils.getUnique(this.data, this.valueField as string) as Dictionary[]).sort((a, b) =>
74
+ Utils.safeCompare(a[this.displayField], b[this.displayField])
75
+ );
76
+ this.initFilterGroup();
77
+
78
+ if (this.selectedData.length > 0) {
79
+ const selectedValues = this.selectedData.map((x) => x[this.valueField] as string);
80
+ this.setMultiSelectControl(selectedValues);
81
+ }
82
+
83
+ if (this.readOnly) {
84
+ this.multiSelectControl.disable();
85
+ }
86
+ }
87
+
88
+ initFilterGroup(): void {
89
+ this.filteredMultiSelect = this.searchCtrl.valueChanges.pipe(
90
+ startWith(''),
91
+ map((value) => this._filter(value ?? '', this.data.slice()))
92
+ );
93
+ }
94
+
95
+ setMultiSelectControl(values: string[] | null): void {
96
+ this.multiSelectControl.setValue(values);
97
+ }
98
+
99
+ private _filter(value: string, options: Dictionary[]): Dictionary[] {
100
+ const filterValue = value.toLowerCase();
101
+ return options.filter((option) => {
102
+ const fieldValue = option[this.displayField];
103
+ const fieldStr = (fieldValue !== null && fieldValue !== undefined) ? String(fieldValue).toLowerCase() : '';
104
+ return fieldStr.includes(filterValue);
105
+ });
106
+ }
107
+
108
+
109
+ selected(select: MatSelect): 'some' | 'all' | undefined {
110
+ const options = select?.options;
111
+ if (!options) return undefined;
112
+
113
+ const total = options.length;
114
+ const selectedCount = options.filter(opt => opt.selected).length;
115
+
116
+ if (selectedCount === total) return 'all';
117
+ if (selectedCount > 0) return 'some';
118
+ return undefined;
119
+ }
120
+
121
+ toggleSelection(select: MatSelect): void {
122
+ let values = this.multiSelectControl.value ?? [];
123
+ const selection = this.selected(select);
124
+
125
+ select.options.forEach((item: MatOption) => {
126
+ if (selection !== 'all' && !values.includes(item.value)) {
127
+ values.push(item.value);
128
+ } else if (selection === 'all' && values.includes(item.value)) {
129
+ values = values.filter((value) => value !== item.value);
130
+ }
131
+ });
132
+
133
+ this.setMultiSelectControl(values);
134
+ this.change.emit(values);
135
+ }
136
+
137
+ onSelectionChange(event: MatOptionSelectionChange): void {
138
+ let values = this.multiSelectControl.value ?? [];
139
+ if (event.isUserInput) {
140
+ if (event.source.selected && !values.includes(event.source.value)) {
141
+ values.push(event.source.value);
142
+ } else if (!event.source.selected && values.includes(event.source.value)) {
143
+ values = values.filter((value) => value !== event.source.value);
144
+ }
145
+ this.setMultiSelectControl(values);
146
+ this.change.emit(values);
147
+ }
148
+ }
149
+
150
+ getTooltips(select: MatSelect): string {
151
+ return this.selected(select) === 'all' ? 'UNSELECT_ALL' : 'SELECT_ALL';
152
+ }
153
+
154
+ resetSelection(): void {
155
+ console.log(' *** resetSelection* ***');
156
+ this.multiSelectControl.setValue([]);
157
+ this.searchCtrl.setValue('');
158
+ this.change.emit([]);
159
+ }
160
+
161
+ ngAfterViewInit(): void {
162
+ this.cdref.detectChanges();
163
+ }
164
+
165
+ onKeydown(e: KeyboardEvent, i: HTMLInputElement): void {
166
+ i.onkeydown?.(e);
167
+ e.stopPropagation();
168
+ }
169
+
170
+ clear(): void {
171
+ console.log('************** clear -----------------')
172
+ this.searchCtrl.patchValue('');
173
+ this.setMultiSelectControl(null);
174
+ }
175
+
176
+ get hidePlaceholder(): boolean {
177
+ const value = this.multiSelectControl.value;
178
+ return Array.isArray(value) && value.length > 0;
179
+ }
180
+
181
+ }
@@ -0,0 +1,117 @@
1
+ /*
2
+ .custom-th-cell {
3
+ display: flex;
4
+ flex-direction: column;
5
+ justify-content: space-between;
6
+ height: 100%;
7
+ padding: 4px;
8
+ }
9
+
10
+ .header-label {
11
+ font-weight: 500;
12
+ text-align: left;
13
+ width: 100%;
14
+ }
15
+
16
+ .header-filter {
17
+ margin-top: 4px;
18
+ width: 100%;
19
+ }
20
+ */
21
+
22
+ .visibility-hidden {
23
+ visibility: hidden !important;
24
+ }
25
+
26
+ .password-cell {
27
+ display: flex;
28
+ align-items: center;
29
+ justify-content: space-between;
30
+ min-width: 100px;
31
+ }
32
+
33
+ .masked-text {
34
+ font-family: sans-serif;
35
+ letter-spacing: 2px;
36
+ user-select: none;
37
+ }
38
+
39
+ .toggle-btn {
40
+ background: none;
41
+ border: none;
42
+ cursor: pointer;
43
+ padding: 0;
44
+ margin-left: 8px;
45
+ color: #666;
46
+ }
47
+
48
+ .toggle-btn:hover {
49
+ color: #000;
50
+ }
51
+
52
+
53
+ .active-item {
54
+ background-color: #4caf50 !important;
55
+ color: white;
56
+ margin: 4px;
57
+ border-radius: 4px;
58
+ }
59
+
60
+ .inactive-item {
61
+ background: transparent;
62
+ color: #5a0023;
63
+ margin: 4px;
64
+ border-radius: 4px;
65
+ }
66
+
67
+ .group1 {
68
+ background-color: white !important;
69
+ }
70
+
71
+ .group1 {
72
+ background-color: #e5f1ee !important;
73
+ }
74
+
75
+ .group2 {
76
+ background-color: #d1e0e0 !important;
77
+ }
78
+
79
+ .group3 {
80
+ background-color: #c9d3ed !important;
81
+ }
82
+
83
+ .group4 {
84
+ background-color: #c9d0db !important;
85
+ }
86
+
87
+ .group5 {
88
+ background-color: #fdf3e9 !important;
89
+ }
90
+
91
+ .group6 {
92
+ background-color: #ddb5b5 !important;
93
+ }
94
+
95
+
96
+ .group-header-row {
97
+ background: #f6f6f6;
98
+ }
99
+
100
+ .collapse-controls {
101
+ text-align: center !important;
102
+ }
103
+
104
+ .group-header-cell {
105
+ font-weight: bold;
106
+ text-align: left;
107
+ padding: 8px;
108
+
109
+ button {
110
+ all: unset;
111
+ cursor: pointer;
112
+ display: flex;
113
+ align-items: center;
114
+ gap: 8px;
115
+ }
116
+ }
117
+