advanced-filter-system 1.5.0 → 1.5.2
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/README.md +64 -47
- package/dist/afs.legacy.js +1 -1
- package/dist/afs.legacy.js.map +1 -1
- package/dist/afs.modern.js +1 -1
- package/dist/afs.modern.js.map +1 -1
- package/package.json +8 -2
- package/src/types/core.d.ts +65 -0
- package/src/types/date-filter.ts +18 -0
- package/src/types/features.d.ts +148 -0
- package/src/types/filter.ts +17 -0
- package/src/types/index.d.ts +442 -0
- package/src/types/input-range-filter.ts +19 -0
- package/src/types/pagination.ts +37 -0
- package/src/types/range-filter.ts +8 -0
- package/src/types/search.ts +5 -0
- package/src/types/sort.ts +9 -0
- package/src/types/url-manager.ts +11 -0
- package/src/types/utils.d.ts +128 -0
package/package.json
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "advanced-filter-system",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.2",
|
|
4
4
|
"description": "Advanced filtering system for DOM elements with multiple features",
|
|
5
5
|
"main": "dist/afs.legacy.js",
|
|
6
6
|
"module": "dist/afs.modern.js",
|
|
7
7
|
"browser": "dist/afs.legacy.min.js",
|
|
8
8
|
"private": false,
|
|
9
9
|
"type": "module",
|
|
10
|
+
"types": "./src/types/index.d.ts",
|
|
11
|
+
"typings": "./src/types/index.d.ts",
|
|
10
12
|
"exports": {
|
|
11
13
|
".": {
|
|
14
|
+
"types": "./src/types/index.d.ts",
|
|
12
15
|
"import": "./dist/afs.modern.js",
|
|
13
16
|
"require": "./dist/afs.legacy.js",
|
|
14
17
|
"browser": "./dist/afs.legacy.min.js"
|
|
@@ -35,6 +38,7 @@
|
|
|
35
38
|
},
|
|
36
39
|
"files": [
|
|
37
40
|
"dist",
|
|
41
|
+
"src/types",
|
|
38
42
|
"LICENSE",
|
|
39
43
|
"README.md"
|
|
40
44
|
],
|
|
@@ -49,7 +53,9 @@
|
|
|
49
53
|
"browser",
|
|
50
54
|
"manipulation",
|
|
51
55
|
"element-filter",
|
|
52
|
-
"web"
|
|
56
|
+
"web",
|
|
57
|
+
"typescript",
|
|
58
|
+
"types"
|
|
53
59
|
],
|
|
54
60
|
"author": "misits",
|
|
55
61
|
"license": "MIT",
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core Types for Advanced Filter System
|
|
3
|
+
* @fileoverview TypeScript definitions for core classes
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { AFSOptions, AFSEventData, EventCallback, FilterMode, FilterCategoryMode } from './index';
|
|
7
|
+
|
|
8
|
+
// Options Class
|
|
9
|
+
export declare class Options {
|
|
10
|
+
static readonly defaults: AFSOptions;
|
|
11
|
+
readonly options: AFSOptions;
|
|
12
|
+
|
|
13
|
+
constructor(userOptions?: Partial<AFSOptions>);
|
|
14
|
+
|
|
15
|
+
get(path: string): any;
|
|
16
|
+
set(path: string, value: any): void;
|
|
17
|
+
update(updates: Partial<AFSOptions>): void;
|
|
18
|
+
reset(): void;
|
|
19
|
+
export(): AFSOptions;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// State Class
|
|
23
|
+
export declare class State {
|
|
24
|
+
constructor();
|
|
25
|
+
|
|
26
|
+
getState(): any;
|
|
27
|
+
setState(path: string, value: any): void;
|
|
28
|
+
resetState(): void;
|
|
29
|
+
export(): any;
|
|
30
|
+
import(state: any): void;
|
|
31
|
+
reset(): void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Logger Class
|
|
35
|
+
export declare class Logger {
|
|
36
|
+
constructor(debug?: boolean, logLevel?: string);
|
|
37
|
+
|
|
38
|
+
debug(...args: any[]): void;
|
|
39
|
+
info(...args: any[]): void;
|
|
40
|
+
warn(...args: any[]): void;
|
|
41
|
+
error(...args: any[]): void;
|
|
42
|
+
log(level: string, ...args: any[]): void;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// EventEmitter Class
|
|
46
|
+
export declare class EventEmitter {
|
|
47
|
+
constructor();
|
|
48
|
+
|
|
49
|
+
on(event: string, callback: EventCallback): void;
|
|
50
|
+
off(event: string, callback?: EventCallback): void;
|
|
51
|
+
emit(event: string, data?: AFSEventData): void;
|
|
52
|
+
once(event: string, callback: EventCallback): void;
|
|
53
|
+
removeAllListeners(event?: string): void;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// StyleManager Class
|
|
57
|
+
export declare class StyleManager {
|
|
58
|
+
constructor(options: Options);
|
|
59
|
+
|
|
60
|
+
applyStyles(): void;
|
|
61
|
+
removeStyles(): void;
|
|
62
|
+
updateStyles(newOptions: Partial<AFSOptions>): void;
|
|
63
|
+
injectCSS(css: string, id?: string): void;
|
|
64
|
+
removeCSS(id: string): void;
|
|
65
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface DateRangeOptions {
|
|
2
|
+
key: string;
|
|
3
|
+
container: HTMLElement;
|
|
4
|
+
format?: string;
|
|
5
|
+
minDate?: Date;
|
|
6
|
+
maxDate?: Date;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface DateRange {
|
|
10
|
+
startDate: Date;
|
|
11
|
+
endDate: Date;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface DateFilterEvent {
|
|
15
|
+
key: string;
|
|
16
|
+
startDate: Date;
|
|
17
|
+
endDate: Date;
|
|
18
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Feature Types for Advanced Filter System
|
|
3
|
+
* @fileoverview TypeScript definitions for feature classes
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
SortDirection,
|
|
8
|
+
SortCriteria,
|
|
9
|
+
FilterMode,
|
|
10
|
+
FilterTypeConfig,
|
|
11
|
+
RangeSliderOptions,
|
|
12
|
+
DateFilterOptions,
|
|
13
|
+
PageInfo,
|
|
14
|
+
AFSEventData
|
|
15
|
+
} from './index';
|
|
16
|
+
import { AFS } from './index';
|
|
17
|
+
|
|
18
|
+
// Filter Feature
|
|
19
|
+
export declare class Filter {
|
|
20
|
+
constructor(afs: AFS);
|
|
21
|
+
|
|
22
|
+
addFilter(filter: string): void;
|
|
23
|
+
removeFilter(filter: string): void;
|
|
24
|
+
toggleFilter(filter: string): void;
|
|
25
|
+
toggleFilterExclusive(filter: string): void;
|
|
26
|
+
clearAllFilters(): void;
|
|
27
|
+
clearFilterCategory(category: string): void;
|
|
28
|
+
getActiveFilters(): Set<string>;
|
|
29
|
+
setFilterTypeLogic(type: string, logic: FilterMode | FilterTypeConfig): void;
|
|
30
|
+
applyFilters(): void;
|
|
31
|
+
getFilteredItems(): Set<HTMLElement>;
|
|
32
|
+
isFilterActive(filter: string): boolean;
|
|
33
|
+
getFiltersByType(type: string): Set<string>;
|
|
34
|
+
destroy(): void;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Search Feature
|
|
38
|
+
export declare class Search {
|
|
39
|
+
constructor(afs: AFS);
|
|
40
|
+
|
|
41
|
+
search(query: string): void;
|
|
42
|
+
clearSearch(): void;
|
|
43
|
+
setValue(value: string): void;
|
|
44
|
+
getValue(): string;
|
|
45
|
+
getMatches(): HTMLElement[];
|
|
46
|
+
highlightMatches(enable?: boolean): void;
|
|
47
|
+
configure(options: {
|
|
48
|
+
keys?: string[];
|
|
49
|
+
debounce?: number;
|
|
50
|
+
minLength?: number;
|
|
51
|
+
caseSensitive?: boolean;
|
|
52
|
+
}): void;
|
|
53
|
+
destroy(): void;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Sort Feature
|
|
57
|
+
export declare class Sort {
|
|
58
|
+
constructor(afs: AFS);
|
|
59
|
+
|
|
60
|
+
sort(key: string, direction?: SortDirection): void;
|
|
61
|
+
sortMultiple(criteria: SortCriteria[]): void;
|
|
62
|
+
sortWithComparator(key: string, comparator: (a: any, b: any) => number): void;
|
|
63
|
+
shuffle(): void;
|
|
64
|
+
reset(): void;
|
|
65
|
+
getCurrentSort(): SortCriteria | null;
|
|
66
|
+
getSortValue(element: HTMLElement, key: string): any;
|
|
67
|
+
addCustomComparator(name: string, comparator: (a: any, b: any) => number): void;
|
|
68
|
+
destroy(): void;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Pagination Feature
|
|
72
|
+
export declare class Pagination {
|
|
73
|
+
constructor(afs: AFS);
|
|
74
|
+
|
|
75
|
+
goToPage(page: number): void;
|
|
76
|
+
nextPage(): void;
|
|
77
|
+
previousPage(): void;
|
|
78
|
+
firstPage(): void;
|
|
79
|
+
lastPage(): void;
|
|
80
|
+
setPaginationMode(enabled: boolean): void;
|
|
81
|
+
setItemsPerPage(count: number): void;
|
|
82
|
+
getPageInfo(): PageInfo;
|
|
83
|
+
getCurrentPage(): number;
|
|
84
|
+
getTotalPages(): number;
|
|
85
|
+
getItemsPerPage(): number;
|
|
86
|
+
update(): void;
|
|
87
|
+
render(): void;
|
|
88
|
+
destroy(): void;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Range Filter Feature
|
|
92
|
+
export declare class RangeFilter {
|
|
93
|
+
constructor(afs: AFS);
|
|
94
|
+
|
|
95
|
+
addRangeSlider(options: RangeSliderOptions): void;
|
|
96
|
+
removeRangeSlider(key: string): void;
|
|
97
|
+
getRangeValue(key: string): { min: number; max: number } | null;
|
|
98
|
+
setRangeValue(key: string, min: number, max: number): void;
|
|
99
|
+
resetRange(key: string): void;
|
|
100
|
+
getRangeSliders(): Map<string, any>;
|
|
101
|
+
updateHistogram(key: string): void;
|
|
102
|
+
destroy(): void;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Date Filter Feature
|
|
106
|
+
export declare class DateFilter {
|
|
107
|
+
constructor(afs: AFS);
|
|
108
|
+
|
|
109
|
+
addDateRange(options: DateFilterOptions): void;
|
|
110
|
+
removeDateRange(key: string): void;
|
|
111
|
+
getDateRange(key: string): { start: Date; end: Date } | null;
|
|
112
|
+
setDateRange(key: string, start: Date, end: Date): void;
|
|
113
|
+
resetDateRange(key: string): void;
|
|
114
|
+
getDateFilters(): Map<string, any>;
|
|
115
|
+
parseDate(dateString: string, format?: string): Date;
|
|
116
|
+
formatDate(date: Date, format?: string): string;
|
|
117
|
+
destroy(): void;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// URL Manager Feature
|
|
121
|
+
export declare class URLManager {
|
|
122
|
+
constructor(afs: AFS);
|
|
123
|
+
|
|
124
|
+
initialize(): void;
|
|
125
|
+
updateURL(): void;
|
|
126
|
+
loadFromURL(): void;
|
|
127
|
+
clearURL(): void;
|
|
128
|
+
getURLParams(): URLSearchParams;
|
|
129
|
+
hasParams(): boolean;
|
|
130
|
+
getParam(param: string): string | null;
|
|
131
|
+
setParam(param: string, value: string): void;
|
|
132
|
+
removeParam(param: string): void;
|
|
133
|
+
serializeState(): string;
|
|
134
|
+
deserializeState(serialized: string): any;
|
|
135
|
+
destroy(): void;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Input Range Filter Feature
|
|
139
|
+
export declare class InputRangeFilter {
|
|
140
|
+
constructor(afs: AFS);
|
|
141
|
+
|
|
142
|
+
addInput(selector: string, key: string): void;
|
|
143
|
+
removeInput(key: string): void;
|
|
144
|
+
getValue(key: string): string | null;
|
|
145
|
+
setValue(key: string, value: string): void;
|
|
146
|
+
getInputs(): Map<string, HTMLInputElement>;
|
|
147
|
+
destroy(): void;
|
|
148
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface FilterOptions {
|
|
2
|
+
mode: 'AND' | 'OR';
|
|
3
|
+
activeClass: string;
|
|
4
|
+
hiddenClass: string;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface FilterGroupOptions {
|
|
8
|
+
filters: string[];
|
|
9
|
+
operator: 'AND' | 'OR';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface FilterEvent {
|
|
13
|
+
filter: string;
|
|
14
|
+
activeFilters: string[];
|
|
15
|
+
visibleItems: number;
|
|
16
|
+
hiddenItems: number;
|
|
17
|
+
}
|