@hmcts/opal-frontend-common 0.0.20 → 0.0.21
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/components/abstract/abstract-sortable-table/index.d.ts +33 -2
- package/components/abstract/abstract-sortable-table-pagination/index.d.ts +16 -1
- package/components/abstract/abstract-table-filter/README.md +76 -0
- package/components/abstract/abstract-table-filter/index.d.ts +116 -0
- package/components/abstract/abstract-table-filter/interfaces/index.d.ts +17 -0
- package/components/abstract/abstract-table-filter/types/index.d.ts +3 -0
- package/components/moj/moj-filter/index.d.ts +16 -0
- package/components/moj/moj-filter/moj-filter-panel/index.d.ts +8 -0
- package/components/moj/moj-filter/moj-filter-panel/moj-filter-panel-header/README.md +43 -0
- package/components/moj/moj-filter/moj-filter-panel/moj-filter-panel-header/index.d.ts +9 -0
- package/components/moj/moj-filter/moj-filter-panel/moj-filter-panel-option/README.md +81 -0
- package/components/moj/moj-filter/moj-filter-panel/moj-filter-panel-option/index.d.ts +18 -0
- package/components/moj/moj-filter/moj-filter-panel/moj-filter-panel-option/moj-filter-panel-option-form-group-item/README.md +53 -0
- package/components/moj/moj-filter/moj-filter-panel/moj-filter-panel-option/moj-filter-panel-option-form-group-item/index.d.ts +30 -0
- package/components/moj/moj-filter/moj-filter-panel/moj-filter-panel-option/moj-filter-panel-option-form-group-keyword/README.md +59 -0
- package/components/moj/moj-filter/moj-filter-panel/moj-filter-panel-option/moj-filter-panel-option-form-group-keyword/index.d.ts +22 -0
- package/components/moj/moj-filter/moj-filter-panel/moj-filter-panel-selected/README.md +55 -0
- package/components/moj/moj-filter/moj-filter-panel/moj-filter-panel-selected/index.d.ts +21 -0
- package/components/moj/moj-filter/moj-filter-panel/moj-filter-panel-selected/moj-filter-panel-selected-tag/README.md +52 -0
- package/components/moj/moj-filter/moj-filter-panel/moj-filter-panel-selected/moj-filter-panel-selected-tag/index.d.ts +24 -0
- package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-sortable-table-pagination.mjs +23 -7
- package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-sortable-table-pagination.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-sortable-table.mjs +69 -9
- package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-sortable-table.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-table-filter-interfaces.mjs +4 -0
- package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-table-filter-interfaces.mjs.map +1 -0
- package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-table-filter-types.mjs +4 -0
- package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-table-filter-types.mjs.map +1 -0
- package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-table-filter.mjs +184 -0
- package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-table-filter.mjs.map +1 -0
- package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-filter-moj-filter-panel-moj-filter-panel-header.mjs +22 -0
- package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-filter-moj-filter-panel-moj-filter-panel-header.mjs.map +1 -0
- package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-filter-moj-filter-panel-moj-filter-panel-option-moj-filter-panel-option-form-group-item.mjs +44 -0
- package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-filter-moj-filter-panel-moj-filter-panel-option-moj-filter-panel-option-form-group-item.mjs.map +1 -0
- package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-filter-moj-filter-panel-moj-filter-panel-option-moj-filter-panel-option-form-group-keyword.mjs +48 -0
- package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-filter-moj-filter-panel-moj-filter-panel-option-moj-filter-panel-option-form-group-keyword.mjs.map +1 -0
- package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-filter-moj-filter-panel-moj-filter-panel-option.mjs +34 -0
- package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-filter-moj-filter-panel-moj-filter-panel-option.mjs.map +1 -0
- package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-filter-moj-filter-panel-moj-filter-panel-selected-moj-filter-panel-selected-tag.mjs +41 -0
- package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-filter-moj-filter-panel-moj-filter-panel-selected-moj-filter-panel-selected-tag.mjs.map +1 -0
- package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-filter-moj-filter-panel-moj-filter-panel-selected.mjs +43 -0
- package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-filter-moj-filter-panel-moj-filter-panel-selected.mjs.map +1 -0
- package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-filter-moj-filter-panel.mjs +18 -0
- package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-filter-moj-filter-panel.mjs.map +1 -0
- package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-filter.mjs +31 -0
- package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-filter.mjs.map +1 -0
- package/package.json +56 -1
|
@@ -2,10 +2,13 @@ import * as _angular_core from '@angular/core';
|
|
|
2
2
|
import { OnInit, EventEmitter } from '@angular/core';
|
|
3
3
|
import { IAbstractTableData, IAbstractSortState } from '@hmcts/opal-frontend-common/components/abstract/abstract-sortable-table/interfaces';
|
|
4
4
|
import { SortableValuesType, SortDirectionType } from '@hmcts/opal-frontend-common/components/abstract/abstract-sortable-table/types';
|
|
5
|
+
import { AbstractTableFilterComponent } from '@hmcts/opal-frontend-common/components/abstract/abstract-table-filter';
|
|
5
6
|
|
|
6
|
-
declare abstract class AbstractSortableTableComponent implements OnInit {
|
|
7
|
+
declare abstract class AbstractSortableTableComponent extends AbstractTableFilterComponent implements OnInit {
|
|
7
8
|
private readonly sortService;
|
|
8
|
-
|
|
9
|
+
displayTableDataSignal: _angular_core.WritableSignal<IAbstractTableData<SortableValuesType>[]>;
|
|
10
|
+
filteredTableDataSignal: _angular_core.WritableSignal<IAbstractTableData<SortableValuesType>[]>;
|
|
11
|
+
sortedTableDataSignal: _angular_core.WritableSignal<IAbstractTableData<SortableValuesType>[]>;
|
|
9
12
|
abstractExistingSortState: IAbstractSortState | null;
|
|
10
13
|
sortStateSignal: _angular_core.WritableSignal<IAbstractSortState>;
|
|
11
14
|
sortedColumnTitleSignal: _angular_core.WritableSignal<string>;
|
|
@@ -71,10 +74,38 @@ declare abstract class AbstractSortableTableComponent implements OnInit {
|
|
|
71
74
|
key: string;
|
|
72
75
|
sortType: 'ascending' | 'descending';
|
|
73
76
|
}): void;
|
|
77
|
+
/**
|
|
78
|
+
* Synchronizes the sorted table data with the current filter and sort state.
|
|
79
|
+
*
|
|
80
|
+
* This effect observes changes to the filtered table data and the sort state signals.
|
|
81
|
+
* If no active sort key is found (i.e., no sorting is applied), it sets the sorted table data
|
|
82
|
+
* to a shallow copy of the filtered data. Otherwise, sorting logic should be applied elsewhere.
|
|
83
|
+
*
|
|
84
|
+
* @protected
|
|
85
|
+
*/
|
|
86
|
+
protected syncSortedDataEffect: _angular_core.EffectRef;
|
|
74
87
|
/**
|
|
75
88
|
* Lifecycle hook to initialise the sort state.
|
|
76
89
|
*/
|
|
77
90
|
ngOnInit(): void;
|
|
91
|
+
/**
|
|
92
|
+
* Applies the current filters to the table data and updates the sorted data accordingly.
|
|
93
|
+
*
|
|
94
|
+
* This method overrides the parent implementation to additionally handle sorting.
|
|
95
|
+
* If there is an active sort key, it applies the corresponding sort to the filtered data.
|
|
96
|
+
* If no sort key is active, it simply updates the sorted data to match the filtered data.
|
|
97
|
+
*
|
|
98
|
+
* @override
|
|
99
|
+
*/
|
|
100
|
+
onApplyFilters(): void;
|
|
101
|
+
/**
|
|
102
|
+
* Clears all filters applied to the table and restores the data to its unfiltered state.
|
|
103
|
+
* If a sort is currently active, re-applies the sort after clearing filters.
|
|
104
|
+
* Otherwise, resets the sorted table data to match the filtered data.
|
|
105
|
+
*
|
|
106
|
+
* @override
|
|
107
|
+
*/
|
|
108
|
+
clearAllFilters(): void;
|
|
78
109
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<AbstractSortableTableComponent, never>;
|
|
79
110
|
static ɵcmp: _angular_core.ɵɵComponentDeclaration<AbstractSortableTableComponent, "ng-component", never, {}, { "abstractSortState": "abstractSortState"; }, never, never, true, never>;
|
|
80
111
|
}
|
|
@@ -7,6 +7,12 @@ declare abstract class AbstractSortableTablePaginationComponent extends Abstract
|
|
|
7
7
|
currentPageSignal: _angular_core.WritableSignal<number>;
|
|
8
8
|
itemsPerPageSignal: _angular_core.WritableSignal<number>;
|
|
9
9
|
startIndexComputed: _angular_core.Signal<number>;
|
|
10
|
+
/**
|
|
11
|
+
* Computes the end index for the current page of the sorted table data.
|
|
12
|
+
* Ensures the end index does not exceed the total number of items.
|
|
13
|
+
*
|
|
14
|
+
* @returns The zero-based index of the last item to display on the current page.
|
|
15
|
+
*/
|
|
10
16
|
endIndexComputed: _angular_core.Signal<number>;
|
|
11
17
|
paginatedTableDataComputed: _angular_core.Signal<_hmcts_opal_frontend_common_components_abstract_abstract_sortable_table_interfaces.IAbstractTableData<_hmcts_opal_frontend_common_components_abstract_abstract_sortable_table_types.SortableValuesType>[]>;
|
|
12
18
|
/**
|
|
@@ -16,12 +22,21 @@ declare abstract class AbstractSortableTablePaginationComponent extends Abstract
|
|
|
16
22
|
* - `key`: The column key to sort by.
|
|
17
23
|
* - `sortType`: The sorting order, either 'ascending' or 'descending'.
|
|
18
24
|
*
|
|
19
|
-
* Resets `currentPageSignal` to 1 and triggers re-sorting of `
|
|
25
|
+
* Resets `currentPageSignal` to 1 and triggers re-sorting of `displayTableDataSignal`.
|
|
20
26
|
*/
|
|
21
27
|
onSortChange(event: {
|
|
22
28
|
key: string;
|
|
23
29
|
sortType: 'ascending' | 'descending';
|
|
24
30
|
}): void;
|
|
31
|
+
/**
|
|
32
|
+
* Applies the current filters to the table data.
|
|
33
|
+
*
|
|
34
|
+
* Overrides the base implementation to additionally reset the pagination to the first page
|
|
35
|
+
* after filters are applied.
|
|
36
|
+
*
|
|
37
|
+
* @override
|
|
38
|
+
*/
|
|
39
|
+
onApplyFilters(): void;
|
|
25
40
|
/**
|
|
26
41
|
* Handles the event when the page is changed.
|
|
27
42
|
*
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# AbstractTableFilterComponent
|
|
2
|
+
|
|
3
|
+
The `AbstractTableFilterComponent` is an abstract base class designed for building reactive, filterable table components in Angular. It provides a fully signal-based filtering model using Angular 19's reactivity system, and supports filtering via keyword input and grouped filter tags.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Reactive filtering of table data using Angular signals
|
|
8
|
+
- Supports both keyword and tag-based filtering
|
|
9
|
+
- Exposes computed filtered data for consumption
|
|
10
|
+
- Clean override points for matching logic
|
|
11
|
+
- Stateless, testable, and reusable foundation for filterable tables
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
Extend this class in your table wrapper component:
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
@Component({ ... })
|
|
19
|
+
export class MyFilterableTableComponent extends AbstractTableFilterComponent {
|
|
20
|
+
override matchItemWithFilterOption(item: any, categoryName: string, option: IAbstractTableFilterOption): boolean {
|
|
21
|
+
// Optional: customise matching logic per field
|
|
22
|
+
return item?.[categoryName] === option.value;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
override matchItemWithKeyword(item: any, keyword: string): boolean {
|
|
26
|
+
return Object.values(item).some(value =>
|
|
27
|
+
value?.toString().toLowerCase().includes(keyword.toLowerCase())
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Set filter and table data like so:
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
this.setTableData(tableData);
|
|
37
|
+
this.filterTags.set(filterCategories);
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Signals
|
|
41
|
+
|
|
42
|
+
| Signal | Type | Description |
|
|
43
|
+
| ------------------------- | -------------------------------------- | --------------------------------------------------------- |
|
|
44
|
+
| `displayTableDataSignal` | Signal<IAbstractTableData[]> | The full, unfiltered dataset |
|
|
45
|
+
| `filterTags` | Signal<IAbstractTableFilterCategory[]> | Grouped tag filters with selection state |
|
|
46
|
+
| `keyword` | Signal<string> | Keyword used for text-based filtering |
|
|
47
|
+
| `abstractSelectedTags` | Signal<IAbstractTableFilterCategory[]> | Computed from `filterTags`; not used in applied filtering |
|
|
48
|
+
| `filteredTableDataSignal` | Signal<IAbstractTableData[]> | Computed signal of filtered results |
|
|
49
|
+
|
|
50
|
+
## Public Methods
|
|
51
|
+
|
|
52
|
+
| Method | Description |
|
|
53
|
+
| ----------------------------------------------------- | ----------------------------------------------- |
|
|
54
|
+
| `onKeywordChange(keyword)` | Updates the keyword for filtering |
|
|
55
|
+
| `onCategoryCheckboxChange(category, value, selected)` | Toggles a specific tag option |
|
|
56
|
+
| `removeTag(category, value)` | Deselects a tag based on category and value |
|
|
57
|
+
| `clearAllFilters()` | Clears all tag selections and the keyword input |
|
|
58
|
+
| `setTableData(data)` | Sets the full table data to be filtered |
|
|
59
|
+
| `resetFiltersTo(tags, keyword?)` | Resets filter tags and optionally the keyword |
|
|
60
|
+
|
|
61
|
+
## Protected Methods (Override Points)
|
|
62
|
+
|
|
63
|
+
| Method | Description |
|
|
64
|
+
| ---------------------------------- | --------------------------------------------------------------------- |
|
|
65
|
+
| `matchItemWithFilterOption()` | Allows overriding how tag filters match table data |
|
|
66
|
+
| `matchItemWithKeyword()` | Allows overriding how keyword filters apply |
|
|
67
|
+
| `getSelectedOptionsFromTags(tags)` | Utility method to extract selected tag options from a tag group array |
|
|
68
|
+
|
|
69
|
+
## Testing
|
|
70
|
+
|
|
71
|
+
Unit tests should verify:
|
|
72
|
+
|
|
73
|
+
- Data passed to `displayTableDataSignal` is filtered as expected
|
|
74
|
+
- `filterTags` updates trigger recomputation of `filteredTableDataSignal`
|
|
75
|
+
- Override methods correctly influence filtering behaviour
|
|
76
|
+
- Events like `onKeywordChange()` and `clearAllFilters()` produce expected state
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import * as _angular_core from '@angular/core';
|
|
2
|
+
import { Signal } from '@angular/core';
|
|
3
|
+
import { IAbstractTableData, IAbstractTableFilterCategory, IAbstractTableFilterOption } from '@hmcts/opal-frontend-common/components/abstract/abstract-table-filter/interfaces';
|
|
4
|
+
import { SortableValuesType } from '@hmcts/opal-frontend-common/components/abstract/abstract-table-filter/types';
|
|
5
|
+
|
|
6
|
+
declare abstract class AbstractTableFilterComponent {
|
|
7
|
+
displayTableDataSignal: _angular_core.WritableSignal<IAbstractTableData<SortableValuesType>[]>;
|
|
8
|
+
filteredTableDataSignal: _angular_core.WritableSignal<IAbstractTableData<SortableValuesType>[]>;
|
|
9
|
+
filterTags: _angular_core.WritableSignal<IAbstractTableFilterCategory[]>;
|
|
10
|
+
keyword: _angular_core.WritableSignal<string>;
|
|
11
|
+
appliedFilterTags: _angular_core.WritableSignal<IAbstractTableFilterCategory[]>;
|
|
12
|
+
appliedKeyword: _angular_core.WritableSignal<string>;
|
|
13
|
+
/**
|
|
14
|
+
* Determines whether a given item matches a specific filter option within a category.
|
|
15
|
+
* @param item The data item to test.
|
|
16
|
+
* @param categoryName The category name to check within the item.
|
|
17
|
+
* @param option The filter option to match against.
|
|
18
|
+
* @returns True if the item's value for the category matches the option's value; otherwise false.
|
|
19
|
+
*/
|
|
20
|
+
protected matchItemWithFilterOption(item: IAbstractTableData<SortableValuesType>, categoryName: string, option: IAbstractTableFilterOption): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Determines whether a given item matches the keyword filter.
|
|
23
|
+
* Checks if any value in the item contains the keyword (case-insensitive).
|
|
24
|
+
* @param item The data item to test.
|
|
25
|
+
* @param keyword The keyword to match against.
|
|
26
|
+
* @returns True if any value in the item contains the keyword; otherwise false.
|
|
27
|
+
*/
|
|
28
|
+
protected matchItemWithKeyword(item: IAbstractTableData<SortableValuesType>, keyword: string): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Extracts and returns categories from the provided tags that have at least one selected option.
|
|
31
|
+
*
|
|
32
|
+
* For each category in the input array, this method filters its options to include only those marked as selected.
|
|
33
|
+
* Only categories with at least one selected option are included in the returned array.
|
|
34
|
+
*
|
|
35
|
+
* @param tags - An array of category objects, each containing a list of options.
|
|
36
|
+
* @returns An array of category objects, each with only the selected options, and only categories with at least one selected option.
|
|
37
|
+
*/
|
|
38
|
+
protected getSelectedOptionsFromTags(tags: IAbstractTableFilterCategory[]): IAbstractTableFilterCategory[];
|
|
39
|
+
/**
|
|
40
|
+
* A computed signal that returns the currently selected filter tags.
|
|
41
|
+
* It filters the filterTags signal to include only those options that are selected,
|
|
42
|
+
* grouped by their category name.
|
|
43
|
+
*
|
|
44
|
+
* @returns An array of filter categories each containing only the selected options.
|
|
45
|
+
*/
|
|
46
|
+
abstractSelectedTags: Signal<IAbstractTableFilterCategory[]>;
|
|
47
|
+
/**
|
|
48
|
+
* Updates the keyword used to filter the table data.
|
|
49
|
+
* @param newKeyword The new keyword string to filter by.
|
|
50
|
+
*/
|
|
51
|
+
onKeywordChange(newKeyword: string): void;
|
|
52
|
+
/**
|
|
53
|
+
* Updates the selection state of a filter option within a category.
|
|
54
|
+
* @param categoryName The name of the filter category.
|
|
55
|
+
* @param optionValue The value of the filter option to update.
|
|
56
|
+
* @param selected Whether the option is selected (true) or deselected (false).
|
|
57
|
+
*/
|
|
58
|
+
onCategoryCheckboxChange(categoryName: string, optionValue: string | number, selected: boolean): void;
|
|
59
|
+
/**
|
|
60
|
+
* Removes a selected filter tag by deselecting the corresponding filter option.
|
|
61
|
+
* @param categoryName The name of the filter category.
|
|
62
|
+
* @param optionValue The value of the filter option to remove.
|
|
63
|
+
*/
|
|
64
|
+
removeTag(categoryName: string, optionValue: string | number): void;
|
|
65
|
+
/**
|
|
66
|
+
* Clears all applied filters and resets the filter state.
|
|
67
|
+
*
|
|
68
|
+
* This method performs the following actions:
|
|
69
|
+
* - Resets the keyword and applied keyword to empty strings.
|
|
70
|
+
* - Iterates through all filter tag groups and sets each option's `selected` property to `false`.
|
|
71
|
+
* - Updates both the current and applied filter tags with the cleared state.
|
|
72
|
+
* - Applies the updated filter state.
|
|
73
|
+
*/
|
|
74
|
+
clearAllFilters(): void;
|
|
75
|
+
/**
|
|
76
|
+
* Initializes and updates the filtered table data based on the currently applied keyword and filter tags.
|
|
77
|
+
*
|
|
78
|
+
* This method performs the following steps:
|
|
79
|
+
* 1. Retrieves the current table data, applied keyword, and filter tags.
|
|
80
|
+
* 2. If filter tags are present, filters the data to include only items that match all selected filter options.
|
|
81
|
+
* 3. If a keyword is present, further filters the data to include only items that match the keyword.
|
|
82
|
+
* 4. Updates the filtered table data signal with the resulting filtered data.
|
|
83
|
+
*
|
|
84
|
+
* @remarks
|
|
85
|
+
* - Filtering by tags requires each item to match every group of filter tags.
|
|
86
|
+
* - Filtering by keyword is case-insensitive and trims whitespace.
|
|
87
|
+
*/
|
|
88
|
+
applyFilterState(): void;
|
|
89
|
+
/**
|
|
90
|
+
* Applies the current filter tags and keyword to the table data.
|
|
91
|
+
*
|
|
92
|
+
* This method updates the `appliedFilterTags` and `appliedKeyword` properties
|
|
93
|
+
* with the current filter values, then re-initialises the filtered data set
|
|
94
|
+
* by invoking `applyFilterState()`.
|
|
95
|
+
*
|
|
96
|
+
* Typically called when the user confirms or applies filter changes in the UI.
|
|
97
|
+
*/
|
|
98
|
+
onApplyFilters(): void;
|
|
99
|
+
/**
|
|
100
|
+
* Sets the data to be displayed in the table.
|
|
101
|
+
*
|
|
102
|
+
* @param data - An array of table data objects conforming to the `IAbstractTableData<SortableValuesType>` interface.
|
|
103
|
+
*/
|
|
104
|
+
setTableData(data: IAbstractTableData<SortableValuesType>[]): void;
|
|
105
|
+
/**
|
|
106
|
+
* Resets the filter and keyword state to the provided values and reapplies them.
|
|
107
|
+
*
|
|
108
|
+
* @param tags - The filter tag state to apply (including selected values).
|
|
109
|
+
* @param keyword - The keyword string to apply (optional, defaults to empty).
|
|
110
|
+
*/
|
|
111
|
+
resetFiltersTo(tags: IAbstractTableFilterCategory[], keyword?: string): void;
|
|
112
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<AbstractTableFilterComponent, never>;
|
|
113
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<AbstractTableFilterComponent, "ng-component", never, {}, {}, never, never, true, never>;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export { AbstractTableFilterComponent };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SortableValuesType } from '@hmcts/opal-frontend-common/components/abstract/abstract-table-filter/types';
|
|
2
|
+
|
|
3
|
+
interface IAbstractTableFilterOption {
|
|
4
|
+
label: string;
|
|
5
|
+
value: string | number;
|
|
6
|
+
count?: number;
|
|
7
|
+
selected: boolean;
|
|
8
|
+
}
|
|
9
|
+
interface IAbstractTableFilterCategory {
|
|
10
|
+
categoryName: string;
|
|
11
|
+
options: IAbstractTableFilterOption[];
|
|
12
|
+
}
|
|
13
|
+
interface IAbstractTableData<T extends SortableValuesType> {
|
|
14
|
+
[key: string]: T | T[];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type { IAbstractTableData, IAbstractTableFilterCategory, IAbstractTableFilterOption };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
|
|
3
|
+
declare class MojFilterComponent {
|
|
4
|
+
showFilter: boolean;
|
|
5
|
+
/**
|
|
6
|
+
* Toggles the visibility of the filter panel.
|
|
7
|
+
*
|
|
8
|
+
* This method inverts the current value of `showFilter`, effectively
|
|
9
|
+
* showing the filter panel if it is hidden, or hiding it if it is visible.
|
|
10
|
+
*/
|
|
11
|
+
toggleFilter(): void;
|
|
12
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MojFilterComponent, never>;
|
|
13
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<MojFilterComponent, "opal-lib-moj-filter", never, { "showFilter": { "alias": "showFilter"; "required": false; }; }, {}, never, ["[mojFilterPanel]", "[mojFilterContent]"], true, never>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { MojFilterComponent };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
|
|
3
|
+
declare class MojFilterPanelComponent {
|
|
4
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MojFilterPanelComponent, never>;
|
|
5
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<MojFilterPanelComponent, "opal-lib-moj-filter-panel", never, {}, {}, never, ["[mojFilterPanelHeader]", "[mojFilterPanelSelected]", "[mojFilterPanelOption]"], true, never>;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export { MojFilterPanelComponent };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# MojFilterPanelHeaderComponent
|
|
2
|
+
|
|
3
|
+
The `MojFilterPanelHeaderComponent` is a structural header component used within the `MojFilterComponent`. It is designed to render a heading using the [MOJ Design System](https://design-patterns.service.justice.gov.uk/components/filter/) conventions.
|
|
4
|
+
|
|
5
|
+
This component is intended to be used inside the `[mojFilterPanelHeader]` slot of the `MojFilterComponent`.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- Renders a section header using MoJ-styled classes.
|
|
10
|
+
- Accepts a `title` input with a default value of `"Filter"`.
|
|
11
|
+
- Compatible with content projection (if needed).
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
### Import
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { MojFilterPanelHeaderComponent } from '@hmcts/opal-frontend-common/components/moj/moj-filter';
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### In Template
|
|
22
|
+
|
|
23
|
+
```html
|
|
24
|
+
<opal-lib-moj-filter-panel-header [title]="'Filter offences'"></opal-lib-moj-filter-panel-header>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Inputs
|
|
28
|
+
|
|
29
|
+
| Input | Type | Default | Description |
|
|
30
|
+
| ----- | ------ | -------- | ---------------------------------- |
|
|
31
|
+
| title | string | 'Filter' | The title to display in the header |
|
|
32
|
+
|
|
33
|
+
## Accessibility
|
|
34
|
+
|
|
35
|
+
- Uses an `<h2>` element with the `govuk-heading-m` class for screen-reader-friendly headings.
|
|
36
|
+
- You can override the title text using the `title` input to ensure headings remain meaningful and contextual.
|
|
37
|
+
|
|
38
|
+
## Testing
|
|
39
|
+
|
|
40
|
+
Unit tests should verify:
|
|
41
|
+
|
|
42
|
+
- The default title renders as `"Filter"`.
|
|
43
|
+
- The custom title input renders correctly.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
|
|
3
|
+
declare class MojFilterPanelHeaderComponent {
|
|
4
|
+
title: string;
|
|
5
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MojFilterPanelHeaderComponent, never>;
|
|
6
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<MojFilterPanelHeaderComponent, "opal-lib-moj-filter-panel-header", never, { "title": { "alias": "title"; "required": false; }; }, {}, never, never, true, never>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export { MojFilterPanelHeaderComponent };
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# MojFilterPanelOptionComponent
|
|
2
|
+
|
|
3
|
+
The `MojFilterPanelOptionComponent` is a structural subcomponent of `MojFilterComponent` used to wrap and layout filter controls and the "Apply filters" button using MoJ styling conventions.
|
|
4
|
+
|
|
5
|
+
This component provides a submit button and two content projection slots:
|
|
6
|
+
|
|
7
|
+
- `[mojFilterPanelKeyword]` — typically used to project a keyword input component
|
|
8
|
+
- `[mojFilterPanelItems]` — typically used to project checkbox groups per filter category
|
|
9
|
+
|
|
10
|
+
## Features
|
|
11
|
+
|
|
12
|
+
- GOV.UK-styled apply button
|
|
13
|
+
- Emits a `applyFilters` event when clicked
|
|
14
|
+
- Allows keyword and category controls to be projected via slots
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
### Import
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { MojFilterPanelOptionComponent } from '@hmcts/opal-frontend-common/components/moj/moj-filter';
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### In Template
|
|
25
|
+
|
|
26
|
+
```html
|
|
27
|
+
<opal-lib-moj-filter-panel-option (applyFilters)="onApplyFilters()">
|
|
28
|
+
<ng-container mojFilterPanelKeyword>
|
|
29
|
+
<opal-lib-moj-filter-panel-option-form-group-keyword
|
|
30
|
+
(keywordChange)="onKeywordChange($event)"
|
|
31
|
+
></opal-lib-moj-filter-panel-option-form-group-keyword>
|
|
32
|
+
</ng-container>
|
|
33
|
+
<ng-container mojFilterPanelItems>
|
|
34
|
+
@for (item of filterTags(); track item.categoryName) {
|
|
35
|
+
<opal-lib-moj-filter-panel-option-form-group-item
|
|
36
|
+
[options]="item"
|
|
37
|
+
(changed)="onCategoryCheckboxChange($event)"
|
|
38
|
+
></opal-lib-moj-filter-panel-option-form-group-item>
|
|
39
|
+
}
|
|
40
|
+
</ng-container>
|
|
41
|
+
</opal-lib-moj-filter-panel-option>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Inputs
|
|
45
|
+
|
|
46
|
+
| Input | Type | Default | Description |
|
|
47
|
+
| ------------ | -------- | ----------------- | -------------------------------------- |
|
|
48
|
+
| `buttonText` | `string` | `'Apply filters'` | The text displayed on the apply button |
|
|
49
|
+
|
|
50
|
+
## Outputs
|
|
51
|
+
|
|
52
|
+
| Output | Type | Description |
|
|
53
|
+
| -------------- | ------ | ---------------------------------------- |
|
|
54
|
+
| `applyFilters` | `void` | Emitted when the apply button is clicked |
|
|
55
|
+
|
|
56
|
+
## Content Projection Slots
|
|
57
|
+
|
|
58
|
+
| Slot | Description |
|
|
59
|
+
| ------------------------- | --------------------------------------------- |
|
|
60
|
+
| `[mojFilterPanelKeyword]` | Slot for projecting a keyword input component |
|
|
61
|
+
| `[mojFilterPanelItems]` | Slot for projecting category checkbox groups |
|
|
62
|
+
|
|
63
|
+
## Accessibility
|
|
64
|
+
|
|
65
|
+
- Uses a GOV.UK button with `data-module="govuk-button"` and `type="button"`.
|
|
66
|
+
- Consumers should ensure appropriate ARIA labelling for projected input fields.
|
|
67
|
+
|
|
68
|
+
## Testing
|
|
69
|
+
|
|
70
|
+
Unit tests should verify:
|
|
71
|
+
|
|
72
|
+
- The apply button renders with custom `buttonText`
|
|
73
|
+
- The `applyFilters` output emits on click
|
|
74
|
+
- Projected content is rendered in the appropriate slot
|
|
75
|
+
|
|
76
|
+
## Related Subcomponents
|
|
77
|
+
|
|
78
|
+
The following components are typically projected into this component via the documented slots:
|
|
79
|
+
|
|
80
|
+
- [`MojFilterPanelOptionFormGroupKeywordComponent`](../moj-filter-panel-option-form-group-keyword) – renders a GOV.UK text input for keyword filtering
|
|
81
|
+
- [`MojFilterPanelOptionFormGroupItemComponent`](../moj-filter-panel-option-form-group-item) – renders checkbox groups per filter category
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { EventEmitter } from '@angular/core';
|
|
3
|
+
|
|
4
|
+
declare class MojFilterPanelOptionComponent {
|
|
5
|
+
buttonText: string;
|
|
6
|
+
applyFilters: EventEmitter<void>;
|
|
7
|
+
/**
|
|
8
|
+
* Emits the applyFilters event.
|
|
9
|
+
*
|
|
10
|
+
* This method triggers the emission of the applyFilters event to notify
|
|
11
|
+
* any subscribers that the filter criteria have been applied.
|
|
12
|
+
*/
|
|
13
|
+
onApplyFilters(): void;
|
|
14
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MojFilterPanelOptionComponent, never>;
|
|
15
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<MojFilterPanelOptionComponent, "opal-lib-moj-filter-panel-option", never, { "buttonText": { "alias": "buttonText"; "required": false; }; }, { "applyFilters": "applyFilters"; }, never, ["[mojFilterPanelKeyword]"], true, never>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { MojFilterPanelOptionComponent };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# MojFilterPanelOptionFormGroupItemComponent
|
|
2
|
+
|
|
3
|
+
The `MojFilterPanelOptionFormGroupItemComponent` is a reusable form group subcomponent of the `MojFilterOptionComponent`. It renders a group of GOV.UK checkboxes for a specific filter category.
|
|
4
|
+
|
|
5
|
+
This component is typically used inside the `[mojFilterPanelItems]` content projection slot of the `MojFilterOptionComponent`.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- Renders checkboxes in a `<fieldset>` for a given filter category
|
|
10
|
+
- Outputs the changed option and category context
|
|
11
|
+
- Styled using GOV.UK checkbox and fieldset classes
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
### Import
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { MojFilterPanelOptionFormGroupItemComponent } from '@hmcts/opal-frontend-common/components/moj/moj-filter/moj-filter-panel/moj-filter-panel-option/moj-filter-panel-option-form-group-item';
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### In Template
|
|
22
|
+
|
|
23
|
+
```html
|
|
24
|
+
<opal-lib-moj-filter-panel-option-form-group-item
|
|
25
|
+
[options]="{ categoryName: 'Status', options: statusOptions }"
|
|
26
|
+
(changed)="onCategoryCheckboxChange($event)"
|
|
27
|
+
></opal-lib-moj-filter-panel-option-form-group-item>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Inputs
|
|
31
|
+
|
|
32
|
+
| Input | Type | Description |
|
|
33
|
+
| ------- | ----------------------------------------------------------------- | ----------------------------------------------- |
|
|
34
|
+
| options | `{ categoryName: string, options: IAbstractTableFilterOption[] }` | Filter category name and checkbox options array |
|
|
35
|
+
|
|
36
|
+
## Outputs
|
|
37
|
+
|
|
38
|
+
| Output | Type | Description |
|
|
39
|
+
| ------- | ------------------------------------------------------------ | -------------------------------------------- |
|
|
40
|
+
| changed | `{ categoryName: string, item: IAbstractTableFilterOption }` | Emitted when a checkbox selection is toggled |
|
|
41
|
+
|
|
42
|
+
## Accessibility
|
|
43
|
+
|
|
44
|
+
- Uses `<fieldset>` and `<legend>` for grouping related inputs.
|
|
45
|
+
- Each checkbox input is labelled with a `<label>` and includes unique `id`/`name` attributes to support screen readers.
|
|
46
|
+
|
|
47
|
+
## Testing
|
|
48
|
+
|
|
49
|
+
Unit tests should verify:
|
|
50
|
+
|
|
51
|
+
- The correct number of checkboxes renders for the given options
|
|
52
|
+
- The checkbox is checked based on the `selected` flag
|
|
53
|
+
- The `changed` output emits with the expected payload
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { EventEmitter } from '@angular/core';
|
|
3
|
+
import { IAbstractTableFilterOption } from '@hmcts/opal-frontend-common/components/abstract/abstract-table-filter/interfaces';
|
|
4
|
+
|
|
5
|
+
declare class MojFilterPanelOptionFormGroupItemComponent {
|
|
6
|
+
hostClass: string;
|
|
7
|
+
options: {
|
|
8
|
+
categoryName: string;
|
|
9
|
+
options: IAbstractTableFilterOption[];
|
|
10
|
+
};
|
|
11
|
+
changed: EventEmitter<{
|
|
12
|
+
categoryName: string;
|
|
13
|
+
item: IAbstractTableFilterOption;
|
|
14
|
+
}>;
|
|
15
|
+
/**
|
|
16
|
+
* Handles a change in the checkbox state.
|
|
17
|
+
*
|
|
18
|
+
* This method updates the selected property of the given filter option based on the
|
|
19
|
+
* current state of the checkbox element derived from the event. It then emits the
|
|
20
|
+
* changed filter option to notify listeners of the update.
|
|
21
|
+
*
|
|
22
|
+
* @param event - The event object triggered by the checkbox change.
|
|
23
|
+
* @param item - The filter option item whose selected state needs to be updated.
|
|
24
|
+
*/
|
|
25
|
+
onCheckboxChange(event: Event, item: IAbstractTableFilterOption): void;
|
|
26
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MojFilterPanelOptionFormGroupItemComponent, never>;
|
|
27
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<MojFilterPanelOptionFormGroupItemComponent, "opal-lib-moj-filter-panel-options-form-group-item, [opal-lib-moj-filter-panel-options-form-group-item]", never, { "options": { "alias": "options"; "required": false; }; }, { "changed": "changed"; }, never, never, true, never>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { MojFilterPanelOptionFormGroupItemComponent };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# MojFilterPanelOptionFormGroupKeywordComponent
|
|
2
|
+
|
|
3
|
+
The `MojFilterPanelOptionFormGroupKeywordComponent` is a simple, reusable keyword input subcomponent used within the `MojFilterPanelOptionComponent`.
|
|
4
|
+
|
|
5
|
+
It renders a GOV.UK-styled input field with a label and emits the entered keyword string via `keywordChange`.
|
|
6
|
+
|
|
7
|
+
This component is projected into `[mojFilterPanelKeyword]`.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- GOV.UK-styled input field and label
|
|
12
|
+
- Emits user input as a keyword string
|
|
13
|
+
- Accepts configurable input ID, name, and label
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
### Import
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { MojFilterPanelOptionFormGroupKeywordComponent } from '@hmcts/opal-frontend-common/components/moj/moj-filter';
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### In Template
|
|
24
|
+
|
|
25
|
+
```html
|
|
26
|
+
<opal-lib-moj-filter-panel-option-form-group-keyword
|
|
27
|
+
[inputId]="'keywords'"
|
|
28
|
+
[inputName]="'keywords'"
|
|
29
|
+
[labelValue]="'Search by keyword'"
|
|
30
|
+
(keywordChange)="onKeywordChange($event)"
|
|
31
|
+
></opal-lib-moj-filter-panel-option-form-group-keyword>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Inputs
|
|
35
|
+
|
|
36
|
+
| Input | Type | Default | Description |
|
|
37
|
+
| ------------ | ------ | ---------- | -------------------------------------- |
|
|
38
|
+
| `inputId` | string | 'keywords' | The HTML ID applied to the input field |
|
|
39
|
+
| `inputName` | string | 'keywords' | The name attribute for the input field |
|
|
40
|
+
| `labelValue` | string | 'Keywords' | The visible label for the input |
|
|
41
|
+
|
|
42
|
+
## Outputs
|
|
43
|
+
|
|
44
|
+
| Output | Type | Description |
|
|
45
|
+
| --------------- | -------- | ----------------------------------- |
|
|
46
|
+
| `keywordChange` | `string` | Emits the keyword string when typed |
|
|
47
|
+
|
|
48
|
+
## Accessibility
|
|
49
|
+
|
|
50
|
+
- Label is properly linked to the input using `for`/`id`.
|
|
51
|
+
- Uses `govuk-label--m` and `govuk-input` to ensure visual and accessibility compliance with GOV.UK design system.
|
|
52
|
+
|
|
53
|
+
## Testing
|
|
54
|
+
|
|
55
|
+
Unit tests should verify:
|
|
56
|
+
|
|
57
|
+
- The label renders correctly using `labelValue`
|
|
58
|
+
- The input emits `keywordChange` with the expected string
|
|
59
|
+
- Custom `inputId` and `inputName` values are respected
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { EventEmitter } from '@angular/core';
|
|
3
|
+
|
|
4
|
+
declare class MojFilterPanelOptionFormGroupKeywordComponent {
|
|
5
|
+
inputId: string;
|
|
6
|
+
inputName: string;
|
|
7
|
+
labelValue: string;
|
|
8
|
+
keywordChange: EventEmitter<string>;
|
|
9
|
+
/**
|
|
10
|
+
* Handles the keyword change event from an input element.
|
|
11
|
+
*
|
|
12
|
+
* This function extracts the keyword from the event target (an HTML input element) and emits the new value
|
|
13
|
+
* using the `keywordChange` event emitter.
|
|
14
|
+
*
|
|
15
|
+
* @param event - The DOM event triggered by a change in the input element.
|
|
16
|
+
*/
|
|
17
|
+
onKeywordChange(event?: Event): void;
|
|
18
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MojFilterPanelOptionFormGroupKeywordComponent, never>;
|
|
19
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<MojFilterPanelOptionFormGroupKeywordComponent, "opal-lib-moj-filter-panel-option-form-group-keyword", never, { "inputId": { "alias": "inputId"; "required": false; }; "inputName": { "alias": "inputName"; "required": false; }; "labelValue": { "alias": "labelValue"; "required": false; }; }, { "keywordChange": "keywordChange"; }, never, ["[mojFilterPanelItems]"], true, never>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { MojFilterPanelOptionFormGroupKeywordComponent };
|