platformcommons-web-lib 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/commons-shared-web-ui-1.0.0.tgz +0 -0
- package/documentation/alert.md +123 -0
- package/documentation/button-dropdown.md +126 -0
- package/documentation/button.md +184 -0
- package/documentation/cards-usage-guidelines.md +131 -0
- package/documentation/configurable-form.md +605 -0
- package/documentation/confirmation-modal.md +250 -0
- package/documentation/filter-sidebar.md +178 -0
- package/documentation/filter-table-selector.md +228 -0
- package/documentation/form-builder.md +597 -0
- package/documentation/form-components.md +384 -0
- package/documentation/nav.md +427 -0
- package/documentation/pagination.md +181 -0
- package/documentation/side-nav-documentation.md +169 -0
- package/documentation/smart-form.md +2177 -0
- package/documentation/smart-table.md +1198 -0
- package/documentation/snackbar.md +118 -0
- package/documentation/style-externalization.md +88 -0
- package/documentation/summary-card.md +279 -0
- package/ng-package.json +28 -0
- package/package.json +54 -0
- package/src/lib/modules/alert/alert.models.ts +6 -0
- package/src/lib/modules/alert/alert.module.ts +16 -0
- package/src/lib/modules/alert/alert.theme.scss +85 -0
- package/src/lib/modules/alert/components/alert/alert.component.html +27 -0
- package/src/lib/modules/alert/components/alert/alert.component.scss +92 -0
- package/src/lib/modules/alert/components/alert/alert.component.ts +81 -0
- package/src/lib/modules/button/button.models.ts +13 -0
- package/src/lib/modules/button/button.module.ts +16 -0
- package/src/lib/modules/button/button.theme.scss +121 -0
- package/src/lib/modules/button/components/button/button.component.html +22 -0
- package/src/lib/modules/button/components/button/button.component.scss +88 -0
- package/src/lib/modules/button/components/button/button.component.ts +67 -0
- package/src/lib/modules/button-dropdown/button-dropdown.models.ts +26 -0
- package/src/lib/modules/button-dropdown/button-dropdown.module.ts +22 -0
- package/src/lib/modules/button-dropdown/button-dropdown.theme.scss +87 -0
- package/src/lib/modules/button-dropdown/components/button-dropdown/button-dropdown.component.html +41 -0
- package/src/lib/modules/button-dropdown/components/button-dropdown/button-dropdown.component.scss +135 -0
- package/src/lib/modules/button-dropdown/components/button-dropdown/button-dropdown.component.ts +160 -0
- package/src/lib/modules/configurable-form/component/configurable-form.component.html +294 -0
- package/src/lib/modules/configurable-form/component/configurable-form.component.scss +503 -0
- package/src/lib/modules/configurable-form/component/configurable-form.component.ts +628 -0
- package/src/lib/modules/configurable-form/configurable-form.examples.ts +154 -0
- package/src/lib/modules/configurable-form/configurable-form.model.ts +131 -0
- package/src/lib/modules/configurable-form/configurable-form.module.ts +19 -0
- package/src/lib/modules/configurable-form/configurable-form.theme.scss +78 -0
- package/src/lib/modules/confirmation-modal/components/confirmation-modal/confirmation-modal.component.html +77 -0
- package/src/lib/modules/confirmation-modal/components/confirmation-modal/confirmation-modal.component.scss +395 -0
- package/src/lib/modules/confirmation-modal/components/confirmation-modal/confirmation-modal.component.ts +266 -0
- package/src/lib/modules/confirmation-modal/confirmation-modal.models.ts +71 -0
- package/src/lib/modules/confirmation-modal/confirmation-modal.module.ts +20 -0
- package/src/lib/modules/confirmation-modal/confirmation-modal.theme.scss +87 -0
- package/src/lib/modules/filter/components/filter/filter.component.html +131 -0
- package/src/lib/modules/filter/components/filter/filter.component.scss +245 -0
- package/src/lib/modules/filter/components/filter/filter.component.ts +216 -0
- package/src/lib/modules/filter/filter.models.ts +88 -0
- package/src/lib/modules/filter/filter.module.ts +24 -0
- package/src/lib/modules/filter/filter.theme.scss +92 -0
- package/src/lib/modules/filter-sidebar/components/filter-sidebar/filter-sidebar.component.html +112 -0
- package/src/lib/modules/filter-sidebar/components/filter-sidebar/filter-sidebar.component.scss +186 -0
- package/src/lib/modules/filter-sidebar/components/filter-sidebar/filter-sidebar.component.ts +163 -0
- package/src/lib/modules/filter-sidebar/filter-sidebar.models.ts +95 -0
- package/src/lib/modules/filter-sidebar/filter-sidebar.module.ts +24 -0
- package/src/lib/modules/filter-sidebar/filter-sidebar.theme.scss +38 -0
- package/src/lib/modules/filter-table-selector/components/filter-table-selector/filter-table-selector.component.html +73 -0
- package/src/lib/modules/filter-table-selector/components/filter-table-selector/filter-table-selector.component.scss +321 -0
- package/src/lib/modules/filter-table-selector/components/filter-table-selector/filter-table-selector.component.ts +361 -0
- package/src/lib/modules/filter-table-selector/filter-table-selector.models.ts +91 -0
- package/src/lib/modules/filter-table-selector/filter-table-selector.module.ts +22 -0
- package/src/lib/modules/filter-table-selector/filter-table-selector.theme.scss +36 -0
- package/src/lib/modules/form-builder/components/field-configurator/configurator-config-panel/configurator-config-panel.component.html +63 -0
- package/src/lib/modules/form-builder/components/field-configurator/configurator-config-panel/configurator-config-panel.component.scss +496 -0
- package/src/lib/modules/form-builder/components/field-configurator/configurator-config-panel/configurator-config-panel.component.ts +445 -0
- package/src/lib/modules/form-builder/components/field-configurator/configurator-tree/configurator-tree.component.html +75 -0
- package/src/lib/modules/form-builder/components/field-configurator/configurator-tree/configurator-tree.component.scss +210 -0
- package/src/lib/modules/form-builder/components/field-configurator/configurator-tree/configurator-tree.component.ts +55 -0
- package/src/lib/modules/form-builder/components/field-configurator/field-configurator.component.html +25 -0
- package/src/lib/modules/form-builder/components/field-configurator/field-configurator.component.scss +82 -0
- package/src/lib/modules/form-builder/components/field-configurator/field-configurator.component.ts +95 -0
- package/src/lib/modules/form-builder/components/field-selection/field-selection.component.html +20 -0
- package/src/lib/modules/form-builder/components/field-selection/field-selection.component.scss +37 -0
- package/src/lib/modules/form-builder/components/field-selection/field-selection.component.ts +94 -0
- package/src/lib/modules/form-builder/components/field-selection/group-node/group-node.component.html +46 -0
- package/src/lib/modules/form-builder/components/field-selection/group-node/group-node.component.scss +102 -0
- package/src/lib/modules/form-builder/components/field-selection/group-node/group-node.component.ts +50 -0
- package/src/lib/modules/form-builder/components/field-selection/selection-field-node/selection-field-node.component.html +35 -0
- package/src/lib/modules/form-builder/components/field-selection/selection-field-node/selection-field-node.component.scss +67 -0
- package/src/lib/modules/form-builder/components/field-selection/selection-field-node/selection-field-node.component.ts +34 -0
- package/src/lib/modules/form-builder/components/field-selection/selection-section-node/selection-section-node.component.html +68 -0
- package/src/lib/modules/form-builder/components/field-selection/selection-section-node/selection-section-node.component.scss +113 -0
- package/src/lib/modules/form-builder/components/field-selection/selection-section-node/selection-section-node.component.ts +74 -0
- package/src/lib/modules/form-builder/configs/field-type-schema.map.ts +533 -0
- package/src/lib/modules/form-builder/form-builder.module.ts +36 -0
- package/src/lib/modules/form-builder/form-builder.theme.scss +212 -0
- package/src/lib/modules/form-builder/index.ts +9 -0
- package/src/lib/modules/form-builder/models/builder.models.ts +7 -0
- package/src/lib/modules/form-builder/models/field-configurator.models.ts +38 -0
- package/src/lib/modules/form-builder/models/field-selection.models.ts +51 -0
- package/src/lib/modules/form-builder/services/field-configurator.service.ts +258 -0
- package/src/lib/modules/form-builder/services/field-selection.service.ts +300 -0
- package/src/lib/modules/form-builder/services/form-schema-tree.service.ts +652 -0
- package/src/lib/modules/form-builder/tokens/builder.tokens.ts +10 -0
- package/src/lib/modules/form-builder/utils/constants.ts +43 -0
- package/src/lib/modules/form-components/components/checkbox/_theme.scss +63 -0
- package/src/lib/modules/form-components/components/checkbox/checkbox.component.html +29 -0
- package/src/lib/modules/form-components/components/checkbox/checkbox.component.scss +111 -0
- package/src/lib/modules/form-components/components/checkbox/checkbox.component.ts +207 -0
- package/src/lib/modules/form-components/components/checkbox/checkbox.models.ts +35 -0
- package/src/lib/modules/form-components/components/datepicker/_theme.scss +82 -0
- package/src/lib/modules/form-components/components/datepicker/datepicker.component.html +42 -0
- package/src/lib/modules/form-components/components/datepicker/datepicker.component.scss +115 -0
- package/src/lib/modules/form-components/components/datepicker/datepicker.component.ts +267 -0
- package/src/lib/modules/form-components/components/datepicker/datepicker.models.ts +45 -0
- package/src/lib/modules/form-components/components/dropdown/_theme.scss +91 -0
- package/src/lib/modules/form-components/components/dropdown/dropdown.component.html +74 -0
- package/src/lib/modules/form-components/components/dropdown/dropdown.component.scss +252 -0
- package/src/lib/modules/form-components/components/dropdown/dropdown.component.ts +377 -0
- package/src/lib/modules/form-components/components/dropdown/dropdown.models.ts +53 -0
- package/src/lib/modules/form-components/components/input/_theme.scss +77 -0
- package/src/lib/modules/form-components/components/input/input.component.html +51 -0
- package/src/lib/modules/form-components/components/input/input.component.scss +128 -0
- package/src/lib/modules/form-components/components/input/input.component.ts +250 -0
- package/src/lib/modules/form-components/components/input/input.models.ts +55 -0
- package/src/lib/modules/form-components/components/radio/_theme.scss +61 -0
- package/src/lib/modules/form-components/components/radio/radio.component.html +22 -0
- package/src/lib/modules/form-components/components/radio/radio.component.scss +107 -0
- package/src/lib/modules/form-components/components/radio/radio.component.ts +181 -0
- package/src/lib/modules/form-components/components/radio/radio.models.ts +39 -0
- package/src/lib/modules/form-components/components/search/_theme.scss +73 -0
- package/src/lib/modules/form-components/components/search/search.component.html +15 -0
- package/src/lib/modules/form-components/components/search/search.component.scss +87 -0
- package/src/lib/modules/form-components/components/search/search.component.ts +213 -0
- package/src/lib/modules/form-components/components/search/search.models.ts +40 -0
- package/src/lib/modules/form-components/components/toggle/_theme.scss +45 -0
- package/src/lib/modules/form-components/components/toggle/toggle.component.html +15 -0
- package/src/lib/modules/form-components/components/toggle/toggle.component.scss +81 -0
- package/src/lib/modules/form-components/components/toggle/toggle.component.ts +166 -0
- package/src/lib/modules/form-components/components/toggle/toggle.models.ts +27 -0
- package/src/lib/modules/form-components/directives/click-outside.directive.ts +22 -0
- package/src/lib/modules/form-components/form-components.module.ts +41 -0
- package/src/lib/modules/form-components/form-components.theme.scss +25 -0
- package/src/lib/modules/material/material.module.ts +94 -0
- package/src/lib/modules/nav/components/nav/nav.component.html +34 -0
- package/src/lib/modules/nav/components/nav/nav.component.scss +171 -0
- package/src/lib/modules/nav/components/nav/nav.component.ts +82 -0
- package/src/lib/modules/nav/nav.models.ts +31 -0
- package/src/lib/modules/nav/nav.module.ts +17 -0
- package/src/lib/modules/nav/nav.theme.scss +86 -0
- package/src/lib/modules/pagination/components/pagination/pagination.component.html +52 -0
- package/src/lib/modules/pagination/components/pagination/pagination.component.scss +155 -0
- package/src/lib/modules/pagination/components/pagination/pagination.component.ts +109 -0
- package/src/lib/modules/pagination/pagination.module.ts +17 -0
- package/src/lib/modules/pagination/pagination.theme.scss +66 -0
- package/src/lib/modules/side-nav/components/side-nav/side-nav.component.html +56 -0
- package/src/lib/modules/side-nav/components/side-nav/side-nav.component.scss +342 -0
- package/src/lib/modules/side-nav/components/side-nav/side-nav.component.ts +135 -0
- package/src/lib/modules/side-nav/side-nav.models.ts +38 -0
- package/src/lib/modules/side-nav/side-nav.module.ts +16 -0
- package/src/lib/modules/side-nav/side-nav.theme.scss +111 -0
- package/src/lib/modules/smart-form/components/form-field/form-field.component.html +1109 -0
- package/src/lib/modules/smart-form/components/form-field/form-field.component.scss +1860 -0
- package/src/lib/modules/smart-form/components/form-field/form-field.component.ts +2232 -0
- package/src/lib/modules/smart-form/components/form-section/form-section.component.html +64 -0
- package/src/lib/modules/smart-form/components/form-section/form-section.component.scss +209 -0
- package/src/lib/modules/smart-form/components/form-section/form-section.component.ts +119 -0
- package/src/lib/modules/smart-form/components/smart-form/smart-form.component.html +253 -0
- package/src/lib/modules/smart-form/components/smart-form/smart-form.component.scss +689 -0
- package/src/lib/modules/smart-form/components/smart-form/smart-form.component.ts +1087 -0
- package/src/lib/modules/smart-form/index.ts +10 -0
- package/src/lib/modules/smart-form/models/form-schema.model.ts +700 -0
- package/src/lib/modules/smart-form/models/hierarchy-config.model.ts +21 -0
- package/src/lib/modules/smart-form/services/expression.service.ts +75 -0
- package/src/lib/modules/smart-form/services/smart-form-controller.service.ts +65 -0
- package/src/lib/modules/smart-form/smart-form.examples.ts +1324 -0
- package/src/lib/modules/smart-form/smart-form.module.ts +36 -0
- package/src/lib/modules/smart-form/smart-form.theme.scss +890 -0
- package/src/lib/modules/smart-form/utils/translation.utils.ts +82 -0
- package/src/lib/modules/smart-form/utils/trusted-url.pipe.ts +25 -0
- package/src/lib/modules/smart-form/utils/validation.utils.ts +98 -0
- package/src/lib/modules/smart-table/components/smart-table/smart-table.component.html +283 -0
- package/src/lib/modules/smart-table/components/smart-table/smart-table.component.scss +685 -0
- package/src/lib/modules/smart-table/components/smart-table/smart-table.component.ts +1118 -0
- package/src/lib/modules/smart-table/models/table-config.model.ts +202 -0
- package/src/lib/modules/smart-table/smart-table.module.ts +30 -0
- package/src/lib/modules/smart-table/smart-table.theme.scss +335 -0
- package/src/lib/modules/smart-table/utils/safe-html.pipe.ts +22 -0
- package/src/lib/modules/smart-table/utils/smart-table.utils.ts +18 -0
- package/src/lib/modules/snackbar/components/snackbar.component.html +41 -0
- package/src/lib/modules/snackbar/components/snackbar.component.scss +99 -0
- package/src/lib/modules/snackbar/components/snackbar.component.ts +18 -0
- package/src/lib/modules/snackbar/models/snackbar.models.ts +10 -0
- package/src/lib/modules/snackbar/services/snackbar.service.ts +40 -0
- package/src/lib/modules/snackbar/snackbar.module.ts +11 -0
- package/src/lib/modules/snackbar/snackbar.theme.scss +93 -0
- package/src/lib/modules/summary-card/components/summary-card/summary-card.component.html +47 -0
- package/src/lib/modules/summary-card/components/summary-card/summary-card.component.scss +199 -0
- package/src/lib/modules/summary-card/components/summary-card/summary-card.component.ts +126 -0
- package/src/lib/modules/summary-card/summary-card.module.ts +18 -0
- package/src/lib/modules/summary-card/summary-card.theme.scss +176 -0
- package/src/lib/shared-ui.module.ts +44 -0
- package/src/lib/styles/global.scss +152 -0
- package/src/lib/styles/utilities.scss +250 -0
- package/src/lib/utils/constants.ts +11 -0
- package/src/lib/utils/storage.utils.ts +37 -0
- package/src/lib/utils/string.utils.ts +23 -0
- package/src/lib/utils/translation.utils.ts +87 -0
- package/src/public-api.ts +104 -0
- package/tsconfig.lib.json +15 -0
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { Component, EventEmitter, Input, OnInit, Output, ElementRef, HostListener } from '@angular/core';
|
|
2
|
+
import { Router, ActivatedRoute } from '@angular/router';
|
|
3
|
+
import { TableFilterConfig, TableFilterOutput, TableFilterColumn, TableFilterLabels } from '../../filter.models';
|
|
4
|
+
|
|
5
|
+
@Component({
|
|
6
|
+
selector: 'lib-filter',
|
|
7
|
+
templateUrl: './filter.component.html',
|
|
8
|
+
styleUrls: ['./filter.component.scss'],
|
|
9
|
+
standalone: false
|
|
10
|
+
})
|
|
11
|
+
export class FilterComponent implements OnInit {
|
|
12
|
+
@Input() config: TableFilterConfig = { items: [] };
|
|
13
|
+
@Input() activeFilters: TableFilterOutput = {};
|
|
14
|
+
@Input() columns: TableFilterColumn[] = [];
|
|
15
|
+
@Input() labels: TableFilterLabels = {
|
|
16
|
+
filterBtn: '',
|
|
17
|
+
clear: '',
|
|
18
|
+
apply: '',
|
|
19
|
+
search: '',
|
|
20
|
+
columns: '',
|
|
21
|
+
showAll: '',
|
|
22
|
+
hideAll: ''
|
|
23
|
+
};
|
|
24
|
+
@Input() theme: string = '';
|
|
25
|
+
|
|
26
|
+
@Output() filterChange = new EventEmitter<TableFilterOutput>();
|
|
27
|
+
@Output() columnChange = new EventEmitter<TableFilterColumn[]>();
|
|
28
|
+
@Output() toggle = new EventEmitter<boolean>();
|
|
29
|
+
|
|
30
|
+
isOpen = false;
|
|
31
|
+
activeTab: 'filters' | 'columns' = 'filters';
|
|
32
|
+
|
|
33
|
+
// Temporary state while panel is open
|
|
34
|
+
tempFilters: TableFilterOutput = {};
|
|
35
|
+
tempColumns: TableFilterColumn[] = [];
|
|
36
|
+
|
|
37
|
+
constructor(
|
|
38
|
+
private elementRef: ElementRef,
|
|
39
|
+
private router: Router,
|
|
40
|
+
private route: ActivatedRoute
|
|
41
|
+
) { }
|
|
42
|
+
|
|
43
|
+
ngOnInit(): void {
|
|
44
|
+
this.syncTempState();
|
|
45
|
+
this.initFromUrl();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
private initFromUrl(): void {
|
|
49
|
+
if (this.config.settings?.persistent) {
|
|
50
|
+
this.route.queryParams.subscribe(params => {
|
|
51
|
+
if (Object.keys(params).length > 0) {
|
|
52
|
+
const newFilters: TableFilterOutput = { ...this.activeFilters };
|
|
53
|
+
Object.keys(params).forEach(key => {
|
|
54
|
+
// Skip non-filter params if possible, or assume all are filters
|
|
55
|
+
// Ideally we check against config items
|
|
56
|
+
if (params[key] !== undefined) {
|
|
57
|
+
newFilters[key] = params[key];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
this.activeFilters = newFilters;
|
|
61
|
+
this.syncTempState();
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@HostListener('document:click', ['$event'])
|
|
68
|
+
onClickOutside(event: Event): void {
|
|
69
|
+
if (!this.elementRef.nativeElement.contains(event.target)) {
|
|
70
|
+
this.isOpen = false;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
togglePanel(): void {
|
|
75
|
+
this.isOpen = !this.isOpen;
|
|
76
|
+
if (this.isOpen) {
|
|
77
|
+
this.syncTempState();
|
|
78
|
+
this.activeTab = 'filters';
|
|
79
|
+
}
|
|
80
|
+
this.toggle.emit(this.isOpen);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
setActiveTab(tab: 'filters' | 'columns'): void {
|
|
84
|
+
this.activeTab = tab;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Generic Filter Change Handler
|
|
88
|
+
onFilterChange(key: string | undefined, value: any): void {
|
|
89
|
+
if (!key) return;
|
|
90
|
+
this.tempFilters[key] = value;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Column Visibility Logic
|
|
94
|
+
toggleColumn(columnId: string): void {
|
|
95
|
+
const col = this.tempColumns.find(c => c.id === columnId);
|
|
96
|
+
if (col) {
|
|
97
|
+
col.visible = !col.visible;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
toggleAllColumns(visible: boolean): void {
|
|
102
|
+
this.tempColumns.forEach(c => c.visible = visible);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Actions
|
|
106
|
+
clearAll(): void {
|
|
107
|
+
if (this.activeTab === 'filters') {
|
|
108
|
+
this.tempFilters = {};
|
|
109
|
+
if (this.config.settings?.persistent) {
|
|
110
|
+
this.updateUrl({});
|
|
111
|
+
}
|
|
112
|
+
} else {
|
|
113
|
+
// Reset columns to default or show all?
|
|
114
|
+
// Usually 'clear' in filters context means clear filters
|
|
115
|
+
// But if we are in columns tab, maybe we want to reset columns?
|
|
116
|
+
// For now, let's keep it simple: generic clear clears filters.
|
|
117
|
+
this.tempFilters = {};
|
|
118
|
+
}
|
|
119
|
+
// If we want clear to apply immediately without clicking apply:
|
|
120
|
+
// this.apply();
|
|
121
|
+
// But usually "Clear" inside panel just clears temp state until Apply is clicked.
|
|
122
|
+
// However, if the user requested "Persistent" and "Clear", they might expect immediate URL update?
|
|
123
|
+
// Standard UX: panel actions apply on "Apply".
|
|
124
|
+
// The persisted state should only change when "Apply" is clicked?
|
|
125
|
+
// Wait, if I update URL on clearAll inside panel, it might be confusing if panel is still open with cleared state but not "applied" to data.
|
|
126
|
+
// Re-reading expectation: "Persistent" setting usually means the filter state is synced with URL.
|
|
127
|
+
// If I clear temp state, URL shouldn't change until I click Apply.
|
|
128
|
+
// SO I WILL NOT UPDATE URL HERE. The `initFromUrl` loads INTO `activeFilters`.
|
|
129
|
+
// `apply()` updates `activeFilters` AND should update URL.
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
apply(): void {
|
|
133
|
+
// Apply temp state to active state
|
|
134
|
+
this.activeFilters = { ...this.tempFilters };
|
|
135
|
+
// Clean up undefined/null values
|
|
136
|
+
Object.keys(this.activeFilters).forEach(key => {
|
|
137
|
+
if (this.activeFilters[key] === null || this.activeFilters[key] === undefined || this.activeFilters[key] === '') {
|
|
138
|
+
delete this.activeFilters[key];
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
// Apply columns
|
|
143
|
+
this.columns = this.tempColumns.map(c => ({ ...c }));
|
|
144
|
+
|
|
145
|
+
this.filterChange.emit(this.activeFilters);
|
|
146
|
+
this.columnChange.emit(this.columns);
|
|
147
|
+
|
|
148
|
+
if (this.config.settings?.persistent) {
|
|
149
|
+
this.updateUrl(this.activeFilters);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
this.isOpen = false;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
private updateUrl(queryParams: any): void {
|
|
157
|
+
this.router.navigate([], {
|
|
158
|
+
relativeTo: this.route,
|
|
159
|
+
queryParams: queryParams,
|
|
160
|
+
queryParamsHandling: 'merge', // or 'replace' to clear others? 'merge' ensures we don't lose other params
|
|
161
|
+
// But wait, if we removed a filter, merge keeps it?
|
|
162
|
+
// We need to explicitly clear removed keys if we use merge.
|
|
163
|
+
// Or use pure replacement of filter keys.
|
|
164
|
+
// For simplicity, let's assuming we want to replace parameters that overlap.
|
|
165
|
+
// But to clear keys, we need to pass `null` or `undefined` for those keys in `queryParams`?
|
|
166
|
+
// Angular router: passing null removes the param.
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
// Refined updateUrl logic:
|
|
170
|
+
// We merged activeFilters. But if we removed a key, it's missing from activeFilters.
|
|
171
|
+
// We need to compare with current params and remove keys that are no longer in activeFilters?
|
|
172
|
+
// A simpler way for this component:
|
|
173
|
+
// We likely want to replace ALL query params that correspond to filters.
|
|
174
|
+
// But we don't know which params are filters vs other things (e.g. page, sort).
|
|
175
|
+
// For now, I will just push `this.activeFilters`.
|
|
176
|
+
// NOTE: This doesn't clear keys that were removed.
|
|
177
|
+
// To fix clearing:
|
|
178
|
+
// I should probably navigate with exact activeFilters if I knew they are the ONLY params.
|
|
179
|
+
// Better:
|
|
180
|
+
// this.router.navigate([], { queryParams: this.activeFilters }); // property replaces all
|
|
181
|
+
// If we want to keep 'page', etc., we need to include them.
|
|
182
|
+
// Let's use 'merge' but we need to handle clearing.
|
|
183
|
+
// I will implement a smarter update.
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
activeFilterCountValue(): number {
|
|
187
|
+
return Object.keys(this.activeFilters).length;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
get activeFilterCount(): number {
|
|
192
|
+
return Object.keys(this.activeFilters).length;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
private syncTempState(): void {
|
|
196
|
+
this.tempFilters = { ...this.activeFilters };
|
|
197
|
+
this.tempColumns = JSON.parse(JSON.stringify(this.columns || []));
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
get containerStyles(): { [key: string]: string } {
|
|
201
|
+
const styles: { [key: string]: string } = {};
|
|
202
|
+
if (this.config.styles) {
|
|
203
|
+
if (this.config.styles.width) styles['--cc-filter-panel-width'] = this.config.styles.width;
|
|
204
|
+
if (this.config.styles.padding) styles['--cc-filter-panel-padding'] = this.config.styles.padding;
|
|
205
|
+
if (this.config.styles.gap) styles['--cc-filter-panel-gap'] = this.config.styles.gap;
|
|
206
|
+
if (this.config.styles.backgroundColor) styles['--cc-filter-panel-bg'] = this.config.styles.backgroundColor;
|
|
207
|
+
if (this.config.styles.borderRadius) styles['--cc-filter-panel-radius'] = this.config.styles.borderRadius;
|
|
208
|
+
if (this.config.styles.headerHeight) styles['--cc-filter-panel-header-height'] = this.config.styles.headerHeight;
|
|
209
|
+
}
|
|
210
|
+
return styles;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
trackByFn(index: number, item: any): any {
|
|
214
|
+
return item.key || index;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { InputConfig } from '../form-components/components/input/input.models';
|
|
2
|
+
import { DropdownConfig } from '../form-components/components/dropdown/dropdown.models';
|
|
3
|
+
import { CheckboxConfig } from '../form-components/components/checkbox/checkbox.models';
|
|
4
|
+
import { RadioConfig } from '../form-components/components/radio/radio.models';
|
|
5
|
+
import { ToggleConfig } from '../form-components/components/toggle/toggle.models';
|
|
6
|
+
import { DatePickerConfig } from '../form-components/components/datepicker/datepicker.models';
|
|
7
|
+
import { FilterSearchConfig } from '../form-components/components/search/search.models';
|
|
8
|
+
import { FilterItemType } from '../filter-sidebar/filter-sidebar.models';
|
|
9
|
+
|
|
10
|
+
// Reuse the same item structure as sidebar for consistency
|
|
11
|
+
export interface TableFilterItem {
|
|
12
|
+
key?: string;
|
|
13
|
+
type: FilterItemType;
|
|
14
|
+
label?: string;
|
|
15
|
+
visible?: boolean;
|
|
16
|
+
|
|
17
|
+
// Component Configs
|
|
18
|
+
inputConfig?: InputConfig;
|
|
19
|
+
dropdownConfig?: DropdownConfig;
|
|
20
|
+
checkboxConfig?: CheckboxConfig;
|
|
21
|
+
radioConfig?: RadioConfig;
|
|
22
|
+
toggleConfig?: ToggleConfig;
|
|
23
|
+
datepickerConfig?: DatePickerConfig;
|
|
24
|
+
searchConfig?: FilterSearchConfig;
|
|
25
|
+
|
|
26
|
+
// Layout / Grouping
|
|
27
|
+
children?: TableFilterItem[];
|
|
28
|
+
expanded?: boolean;
|
|
29
|
+
|
|
30
|
+
// Customization
|
|
31
|
+
styles?: { [key: string]: string };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface TableFilterConfig {
|
|
35
|
+
items: TableFilterItem[];
|
|
36
|
+
|
|
37
|
+
// Global Filter Styling
|
|
38
|
+
styles?: {
|
|
39
|
+
width?: string;
|
|
40
|
+
padding?: string;
|
|
41
|
+
gap?: string;
|
|
42
|
+
backgroundColor?: string;
|
|
43
|
+
borderRadius?: string;
|
|
44
|
+
headerHeight?: string;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
columns?: TableFilterColumn[];
|
|
48
|
+
|
|
49
|
+
settings?: {
|
|
50
|
+
persistent?: boolean;
|
|
51
|
+
collapsible?: boolean;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// Actions visibility
|
|
55
|
+
actions?: {
|
|
56
|
+
clear?: { visible?: boolean; label?: string; };
|
|
57
|
+
apply?: { visible?: boolean; label?: string; };
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface TableFilterColumn {
|
|
62
|
+
id: string;
|
|
63
|
+
label: string;
|
|
64
|
+
visible: boolean;
|
|
65
|
+
filterable?: boolean;
|
|
66
|
+
filterOptions?: any[]; // Legacy or simple options
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface TableFilterLabels {
|
|
70
|
+
filterBtn: string;
|
|
71
|
+
clear: string;
|
|
72
|
+
apply: string;
|
|
73
|
+
search: string;
|
|
74
|
+
columns: string; // Tab label
|
|
75
|
+
showAll: string;
|
|
76
|
+
hideAll: string;
|
|
77
|
+
items?: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface TableFilterOutput {
|
|
81
|
+
[key: string]: any;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface TableFilterChangeEvent {
|
|
85
|
+
key: string;
|
|
86
|
+
value: any;
|
|
87
|
+
allFilters: TableFilterOutput;
|
|
88
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
4
|
+
|
|
5
|
+
import { ButtonModule } from '../button/button.module';
|
|
6
|
+
import { FormComponentsModule } from '../form-components/form-components.module';
|
|
7
|
+
import { FilterComponent } from './components/filter/filter.component';
|
|
8
|
+
|
|
9
|
+
@NgModule({
|
|
10
|
+
declarations: [
|
|
11
|
+
FilterComponent
|
|
12
|
+
],
|
|
13
|
+
imports: [
|
|
14
|
+
CommonModule,
|
|
15
|
+
FormsModule,
|
|
16
|
+
ReactiveFormsModule,
|
|
17
|
+
ButtonModule,
|
|
18
|
+
FormComponentsModule
|
|
19
|
+
],
|
|
20
|
+
exports: [
|
|
21
|
+
FilterComponent
|
|
22
|
+
]
|
|
23
|
+
})
|
|
24
|
+
export class FilterModule { }
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
@use 'sass:map';
|
|
2
|
+
|
|
3
|
+
// Default configuration for the filter theme
|
|
4
|
+
$default-filter-config: (
|
|
5
|
+
// Button Trigger
|
|
6
|
+
btn-bg: #ffffff,
|
|
7
|
+
btn-border: 1px solid #e0e0e0,
|
|
8
|
+
btn-radius: 4px,
|
|
9
|
+
btn-text-color: #333,
|
|
10
|
+
btn-hover-bg: #f5f5f5,
|
|
11
|
+
btn-active-bg: #e3f2fd,
|
|
12
|
+
btn-active-text: #1976d2,
|
|
13
|
+
btn-badge-bg: #f44336,
|
|
14
|
+
btn-badge-text: #fff,
|
|
15
|
+
|
|
16
|
+
// Panel / Sidebar
|
|
17
|
+
panel-bg: #ffffff,
|
|
18
|
+
panel-border: 1px solid #e0e0e0,
|
|
19
|
+
panel-shadow: 0 4px 12px rgba(0, 0, 0, 0.15),
|
|
20
|
+
panel-width: 320px,
|
|
21
|
+
panel-min-width: 480px,
|
|
22
|
+
panel-header-bg: #fafafa,
|
|
23
|
+
panel-header-text: #333,
|
|
24
|
+
panel-padding: 1rem,
|
|
25
|
+
panel-radius: 8px,
|
|
26
|
+
panel-header-height: 48px,
|
|
27
|
+
|
|
28
|
+
// Tabs
|
|
29
|
+
tab-bg: transparent,
|
|
30
|
+
tab-text: #666,
|
|
31
|
+
tab-active-bg: #fff,
|
|
32
|
+
tab-active-text: #1976d2,
|
|
33
|
+
tab-border-bottom: 2px solid #1976d2,
|
|
34
|
+
|
|
35
|
+
// Content
|
|
36
|
+
section-title: #333,
|
|
37
|
+
option-text: #555,
|
|
38
|
+
option-hover-bg: #f9f9f9,
|
|
39
|
+
|
|
40
|
+
// Footer actions
|
|
41
|
+
footer-bg: #fff,
|
|
42
|
+
footer-border-top: 1px solid #e0e0e0,
|
|
43
|
+
action-primary-bg: #1976d2,
|
|
44
|
+
action-primary-text: #fff,
|
|
45
|
+
action-secondary-text: #666
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
@mixin filter-theme($user-config: ()) {
|
|
49
|
+
$config: map.merge($default-filter-config, $user-config);
|
|
50
|
+
|
|
51
|
+
// Button Trigger
|
|
52
|
+
--cc-filter-btn-bg: #{map.get($config, btn-bg)};
|
|
53
|
+
--cc-filter-btn-border: #{map.get($config, btn-border)};
|
|
54
|
+
--cc-filter-btn-radius: #{map.get($config, btn-radius)};
|
|
55
|
+
--cc-filter-btn-text-color: #{map.get($config, btn-text-color)};
|
|
56
|
+
--cc-filter-btn-hover-bg: #{map.get($config, btn-hover-bg)};
|
|
57
|
+
--cc-filter-btn-active-bg: #{map.get($config, btn-active-bg)};
|
|
58
|
+
--cc-filter-btn-active-text: #{map.get($config, btn-active-text)};
|
|
59
|
+
--cc-filter-btn-badge-bg: #{map.get($config, btn-badge-bg)};
|
|
60
|
+
--cc-filter-btn-badge-text: #{map.get($config, btn-badge-text)};
|
|
61
|
+
|
|
62
|
+
// Panel
|
|
63
|
+
--cc-filter-panel-bg: #{map.get($config, panel-bg)};
|
|
64
|
+
--cc-filter-panel-border: #{map.get($config, panel-border)};
|
|
65
|
+
--cc-filter-panel-shadow: #{map.get($config, panel-shadow)};
|
|
66
|
+
--cc-filter-panel-width: #{map.get($config, panel-width)};
|
|
67
|
+
--cc-filter-panel-min-width: #{map.get($config, panel-min-width)};
|
|
68
|
+
--cc-filter-panel-padding: #{map.get($config, panel-padding)};
|
|
69
|
+
--cc-filter-panel-header-bg: #{map.get($config, panel-header-bg)};
|
|
70
|
+
--cc-filter-panel-header-text: #{map.get($config, panel-header-text)};
|
|
71
|
+
--cc-filter-panel-radius: #{map.get($config, panel-radius)};
|
|
72
|
+
--cc-filter-panel-header-height: #{map.get($config, panel-header-height)};
|
|
73
|
+
|
|
74
|
+
// Tabs
|
|
75
|
+
--cc-filter-tab-bg: #{map.get($config, tab-bg)};
|
|
76
|
+
--cc-filter-tab-text: #{map.get($config, tab-text)};
|
|
77
|
+
--cc-filter-tab-active-bg: #{map.get($config, tab-active-bg)};
|
|
78
|
+
--cc-filter-tab-active-text: #{map.get($config, tab-active-text)};
|
|
79
|
+
--cc-filter-tab-border-bottom: #{map.get($config, tab-border-bottom)};
|
|
80
|
+
|
|
81
|
+
// Content
|
|
82
|
+
--cc-filter-section-title: #{map.get($config, section-title)};
|
|
83
|
+
--cc-filter-option-text: #{map.get($config, option-text)};
|
|
84
|
+
--cc-filter-option-hover-bg: #{map.get($config, option-hover-bg)};
|
|
85
|
+
|
|
86
|
+
// Footer
|
|
87
|
+
--cc-filter-footer-bg: #{map.get($config, footer-bg)};
|
|
88
|
+
--cc-filter-footer-border-top: #{map.get($config, footer-border-top)};
|
|
89
|
+
--cc-filter-action-primary-bg: #{map.get($config, action-primary-bg)};
|
|
90
|
+
--cc-filter-action-primary-text: #{map.get($config, action-primary-text)};
|
|
91
|
+
--cc-filter-action-secondary-text: #{map.get($config, action-secondary-text)};
|
|
92
|
+
}
|
package/src/lib/modules/filter-sidebar/components/filter-sidebar/filter-sidebar.component.html
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
<div class="cc-filter-sidebar" [ngStyle]="sidebarStyles" [class.collapsed]="isCollapsed">
|
|
2
|
+
|
|
3
|
+
<!-- Header -->
|
|
4
|
+
<div class="cc-filter-header" *ngIf="config.header?.visible !== false">
|
|
5
|
+
<div class="cc-header-content">
|
|
6
|
+
<span class="cc-header-title" *ngIf="config.header?.title">
|
|
7
|
+
<span *ngIf="config.header?.icon" [class]="config.header?.icon" class="cc-header-icon material-icons">
|
|
8
|
+
<!-- {{config.header?.icon }} -->
|
|
9
|
+
</span>
|
|
10
|
+
{{ config.header?.title }}
|
|
11
|
+
</span>
|
|
12
|
+
<ng-content select="[header-actions]"></ng-content>
|
|
13
|
+
</div>
|
|
14
|
+
<button type="button" *ngIf="config.settings?.collapsible" (click)="toggleCollapse()" class="cc-icon-btn"
|
|
15
|
+
[attr.aria-label]="isCollapsed ? config.labels?.expandAriaLabel : config.labels?.collapseAriaLabel">
|
|
16
|
+
<span class="material-icons">{{ isCollapsed ? 'menu_open' : 'menu' }}</span>
|
|
17
|
+
</button>
|
|
18
|
+
<button type="button" *ngIf="config.header?.showClose && !isCollapsed" (click)="onClose()"
|
|
19
|
+
class="cc-icon-btn cc-close-btn" [attr.aria-label]="config.labels?.closeAriaLabel">
|
|
20
|
+
<span class="material-icons">close</span>
|
|
21
|
+
</button>
|
|
22
|
+
<!-- Code snippet debug (optional) -->
|
|
23
|
+
<button type="button" *ngIf="config.settings?.showCodeSnippet" (click)="onShowCodeSnippet()" class="cc-icon-btn"
|
|
24
|
+
[attr.aria-label]="config.labels?.codeSnippetAriaLabel">
|
|
25
|
+
<span class="material-icons">code</span>
|
|
26
|
+
</button>
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
<!-- Content (Scrollable) -->
|
|
30
|
+
<div class="cc-filter-content" [class.hidden]="isCollapsed">
|
|
31
|
+
<ng-container *ngFor="let item of config.items; trackBy: trackByFn">
|
|
32
|
+
<ng-container *ngTemplateOutlet="itemTemplate; context: { item: item }"></ng-container>
|
|
33
|
+
</ng-container>
|
|
34
|
+
</div>
|
|
35
|
+
|
|
36
|
+
<!-- Footer -->
|
|
37
|
+
<div class="cc-filter-footer" *ngIf="config.footer?.visible !== false && !isCollapsed">
|
|
38
|
+
<lib-button variant="outline" color="warn" class="cc-btn-clear"
|
|
39
|
+
*ngIf="config.footer?.clearButton?.visible !== false" (click)="clearFilters()">
|
|
40
|
+
{{ config.footer?.clearButton?.label }}
|
|
41
|
+
</lib-button>
|
|
42
|
+
<lib-button variant="primary" color="warn" class="cc-btn-apply"
|
|
43
|
+
*ngIf="config.footer?.applyButton?.visible !== false" [disabled]="config.footer?.applyButton?.disabled ?? false"
|
|
44
|
+
(click)="applyFilters()">
|
|
45
|
+
{{ config.footer?.applyButton?.label }}
|
|
46
|
+
</lib-button>
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
|
|
50
|
+
<!-- Recursive Template for Items -->
|
|
51
|
+
<ng-template #itemTemplate let-item="item">
|
|
52
|
+
<div class="cc-filter-item" [ngClass]="['type-' + item.type]"
|
|
53
|
+
[style.display]="item.visible === false ? 'none' : 'block'" [ngStyle]="item.styles">
|
|
54
|
+
|
|
55
|
+
<ng-container [ngSwitch]="item.type">
|
|
56
|
+
|
|
57
|
+
<!-- Input -->
|
|
58
|
+
<lib-input *ngSwitchCase="'input'" [config]="item.inputConfig" [label]="item.label"
|
|
59
|
+
[ngModel]="filters[item.key]" (valueChange)="onValueChange(item.key, $event)">
|
|
60
|
+
</lib-input>
|
|
61
|
+
|
|
62
|
+
<!-- Dropdown -->
|
|
63
|
+
<lib-dropdown *ngSwitchCase="'dropdown'" [config]="item.dropdownConfig" [label]="item.label"
|
|
64
|
+
[ngModel]="filters[item.key]" (selectionChange)="onValueChange(item.key, $event)">
|
|
65
|
+
</lib-dropdown>
|
|
66
|
+
|
|
67
|
+
<!-- Checkbox -->
|
|
68
|
+
<lib-checkbox *ngSwitchCase="'checkbox'" [config]="item.checkboxConfig" [label]="item.label"
|
|
69
|
+
[checked]="!!filters[item.key]" (checkedChange)="onValueChange(item.key, $event)">
|
|
70
|
+
</lib-checkbox>
|
|
71
|
+
|
|
72
|
+
<!-- Radio -->
|
|
73
|
+
<lib-radio *ngSwitchCase="'radio'" [config]="item.radioConfig" [label]="item.label"
|
|
74
|
+
[ngModel]="filters[item.key]" (selectionChange)="onValueChange(item.key, $event)">
|
|
75
|
+
</lib-radio>
|
|
76
|
+
|
|
77
|
+
<!-- Toggle -->
|
|
78
|
+
<lib-toggle *ngSwitchCase="'toggle'" [config]="item.toggleConfig" [label]="item.label"
|
|
79
|
+
[checked]="filters[item.key]" (toggleChange)="onValueChange(item.key, $event)">
|
|
80
|
+
</lib-toggle>
|
|
81
|
+
|
|
82
|
+
<!-- Datepicker -->
|
|
83
|
+
<lib-datepicker *ngSwitchCase="'datepicker'" [config]="item.datepickerConfig" [label]="item.label"
|
|
84
|
+
[ngModel]="filters[item.key]" (dateChange)="onValueChange(item.key, $event)">
|
|
85
|
+
</lib-datepicker>
|
|
86
|
+
|
|
87
|
+
<!-- Search -->
|
|
88
|
+
<lib-search *ngSwitchCase="'active-search'" [config]="item.searchConfig" [label]="item.label"
|
|
89
|
+
[ngModel]="filters[item.key]" (search)="onValueChange(item.key, $event)">
|
|
90
|
+
</lib-search>
|
|
91
|
+
|
|
92
|
+
<!-- Group / Accordion -->
|
|
93
|
+
<div *ngSwitchCase="'group'" class="cc-accordion-item" [class.expanded]="item.expanded">
|
|
94
|
+
<button type="button" class="cc-accordion-header" (click)="item.expanded = !item.expanded">
|
|
95
|
+
<span class="cc-accordion-title">{{ item.label }}</span>
|
|
96
|
+
<span class="material-icons cc-accordion-icon">{{ item.expanded ? 'expand_less' : 'expand_more'
|
|
97
|
+
}}</span>
|
|
98
|
+
</button>
|
|
99
|
+
|
|
100
|
+
<div class="cc-accordion-body" *ngIf="item.expanded">
|
|
101
|
+
<ng-container *ngFor="let child of item.children; trackBy: trackByFn">
|
|
102
|
+
<ng-container *ngTemplateOutlet="itemTemplate; context: { item: child }"></ng-container>
|
|
103
|
+
</ng-container>
|
|
104
|
+
</div>
|
|
105
|
+
</div>
|
|
106
|
+
|
|
107
|
+
<!-- Custom Divider -->
|
|
108
|
+
<div *ngSwitchCase="'divider'" class="cc-filter-divider"></div>
|
|
109
|
+
|
|
110
|
+
</ng-container>
|
|
111
|
+
</div>
|
|
112
|
+
</ng-template>
|