@hitgrab/finder 0.1.17-alpha → 0.1.19-alpha

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 (63) hide show
  1. package/dist/index.cjs +1 -0
  2. package/dist/index.d.cts +538 -0
  3. package/dist/index.d.mts +538 -0
  4. package/dist/index.mjs +1 -0
  5. package/package.json +9 -16
  6. package/dist/core/__tests__/core.test.d.ts +0 -1
  7. package/dist/core/__tests__/effects.test.d.ts +0 -1
  8. package/dist/core/__tests__/events.test.d.ts +0 -1
  9. package/dist/core/__tests__/filter.test.d.ts +0 -1
  10. package/dist/core/__tests__/group-by.test.d.ts +0 -1
  11. package/dist/core/__tests__/pagination.test.d.ts +0 -1
  12. package/dist/core/__tests__/search.test.d.ts +0 -1
  13. package/dist/core/__tests__/sort-by.test.d.ts +0 -1
  14. package/dist/core/__tests__/test-constants.d.ts +0 -5
  15. package/dist/core/__tests__/test-types.d.ts +0 -6
  16. package/dist/core/__tests__/utils.test.d.ts +0 -1
  17. package/dist/core/core-constants.d.ts +0 -46
  18. package/dist/core/debounce-callback-registry.d.ts +0 -3
  19. package/dist/core/effect-book.d.ts +0 -12
  20. package/dist/core/event-emitter.d.ts +0 -12
  21. package/dist/core/filter-utils/boolean-filter.d.ts +0 -10
  22. package/dist/core/filter-utils/filter-factory.d.ts +0 -18
  23. package/dist/core/filter-utils/multiple-filter.d.ts +0 -10
  24. package/dist/core/filter-utils/single-filter.d.ts +0 -10
  25. package/dist/core/filters.d.ts +0 -28
  26. package/dist/core/finder-core-implementation.d.ts +0 -44
  27. package/dist/core/finder-core.d.ts +0 -99
  28. package/dist/core/finder-error.d.ts +0 -3
  29. package/dist/core/group-by.d.ts +0 -23
  30. package/dist/core/pagination.d.ts +0 -19
  31. package/dist/core/rule-book.d.ts +0 -14
  32. package/dist/core/search/calculate-character-match-indexes.d.ts +0 -1
  33. package/dist/core/search/calculate-string-match-segments.d.ts +0 -9
  34. package/dist/core/search/default-search-and-sort-algorithm.d.ts +0 -2
  35. package/dist/core/search/search-score.d.ts +0 -4
  36. package/dist/core/search/search-string-transform.d.ts +0 -8
  37. package/dist/core/search/string-match-haystack.d.ts +0 -15
  38. package/dist/core/search.d.ts +0 -18
  39. package/dist/core/sort-by.d.ts +0 -23
  40. package/dist/core/tester.d.ts +0 -8
  41. package/dist/core/types/core-types.d.ts +0 -93
  42. package/dist/core/types/effect-types.d.ts +0 -20
  43. package/dist/core/types/event-types.d.ts +0 -44
  44. package/dist/core/types/rule-types.d.ts +0 -93
  45. package/dist/core/types/string-match-types.d.ts +0 -10
  46. package/dist/core/utils/rule-type-enforcers.d.ts +0 -15
  47. package/dist/core/utils/rule-utils.d.ts +0 -9
  48. package/dist/index.d.ts +0 -13
  49. package/dist/index.js +0 -5041
  50. package/dist/index.umd.cjs +0 -27
  51. package/dist/react/components/finder-content-empty.d.ts +0 -7
  52. package/dist/react/components/finder-content-groups.d.ts +0 -7
  53. package/dist/react/components/finder-content-items.d.ts +0 -7
  54. package/dist/react/components/finder-content-loading.d.ts +0 -7
  55. package/dist/react/components/finder-content-no-matches.d.ts +0 -7
  56. package/dist/react/components/finder-content.d.ts +0 -25
  57. package/dist/react/components/finder-search-term-haystack.d.ts +0 -8
  58. package/dist/react/components/finder.d.ts +0 -9
  59. package/dist/react/components/string-match.d.ts +0 -12
  60. package/dist/react/hooks/use-finder-ref.d.ts +0 -2
  61. package/dist/react/hooks/use-finder.d.ts +0 -3
  62. package/dist/react/providers/finder-core-context.d.ts +0 -3
  63. package/dist/react/types/react-types.d.ts +0 -41
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,5 +0,0 @@
1
- import { MockObjectItem } from "./test-types";
2
- export declare const apple: MockObjectItem;
3
- export declare const orange: MockObjectItem;
4
- export declare const banana: MockObjectItem;
5
- export declare const objectItems: MockObjectItem[];
@@ -1,6 +0,0 @@
1
- export interface MockObjectItem {
2
- type: string;
3
- name: string;
4
- price: number;
5
- daysUntilExpiryDate: string;
6
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,46 +0,0 @@
1
- export declare const EVENTS: {
2
- readonly INIT: "init";
3
- readonly FIRST_USER_INTERACTION: "firstUserInteraction";
4
- readonly READY: "ready";
5
- readonly CHANGE: "change";
6
- readonly SET_ITEMS: "setItems";
7
- readonly SET_IS_LOADING: "setIsLoading";
8
- readonly SET_IS_DISABLED: "setIsDisabled";
9
- readonly SET_CONTEXT: "setContext";
10
- readonly SET_SEARCH_TERM: "setSearchTerm";
11
- readonly RESET_SEARCH_TERM: "resetSearchTerm";
12
- readonly SET_FILTER: "setFilter";
13
- readonly SET_SORT_BY: "setSortBy";
14
- readonly SET_SORT_BY_DIRECTION: "setSortDirection";
15
- readonly SET_GROUP_BY: "setGroupBy";
16
- readonly SET_GROUP_SORT_BY_DIRECTION: "setGroupBySortDirection";
17
- readonly SET_PAGE: "setPage";
18
- readonly SET_NUM_ITEMS_PER_PAGE: "setNumItemsPerPage";
19
- readonly SYNC_UPDATED_AT: "syncUpdatedAt";
20
- };
21
- export declare const EVENT_SOURCE: {
22
- readonly CORE: "core";
23
- readonly SEARCH: "search";
24
- readonly FILTERS: "filters";
25
- readonly GROUP_BY: "groupBy";
26
- readonly SORT_BY: "sortBy";
27
- readonly PAGINATION: "pagination";
28
- };
29
- export declare const ERRORS: {
30
- RULE_NOT_FOUND: string;
31
- WRONG_RULE_TYPE_FOR_MIXIN: string;
32
- NO_SEARCH_RULE_SET: string;
33
- SETTING_MULTIPLE_FILTER_WITHOUT_ARRAY: string;
34
- ADDING_OPTION_TO_MULTIPLE_FILTER_WITHOUT_OPTION_VALUE: string;
35
- DELETING_OPTION_VALUE_FROM_NON_MULTIPLE_FILTER: string;
36
- SETTING_BOOLEAN_FILTER_WITHOUT_BOOLEAN_VALUE: string;
37
- ADDING_OPTION_VALUE_TO_NON_MULTIPLE_FILTER: string;
38
- TOGGLING_OPTION_ON_RULE_WITH_NO_OPTIONS: string;
39
- TOGGLING_OPTION_ON_RULE_WITH_SINGLE_VALUE: string;
40
- TOGGLING_OPTION_THAT_DOES_NOT_EXIST: string;
41
- TOGGLING_OPTION_WITHOUT_PASSING_OPTION: string;
42
- TESTING_OPTIONS_ON_RULE_WITH_NO_OPTIONS: string;
43
- INVALID_RULE_WITHOUT_ID: string;
44
- INVALID_RULE_SHAPE: string;
45
- INVALID_RULE_DUPLICATE: string;
46
- };
@@ -1,3 +0,0 @@
1
- import { FinderRule } from "./types/rule-types";
2
- declare function DebounceCallbackRegistry(): (rule: FinderRule, callback: () => void) => any;
3
- export { DebounceCallbackRegistry };
@@ -1,12 +0,0 @@
1
- import { FinderCore } from "./finder-core";
2
- import { HydratedRuleEffect, HydratedSearchEffect, RuleEffect, SearchEffect } from "./types/effect-types";
3
- import { FinderRule } from "./types/rule-types";
4
- export declare class EffectBook<FItem, FContext> {
5
- #private;
6
- searchEffects: HydratedSearchEffect[];
7
- ruleEffects: HydratedRuleEffect[];
8
- constructor(effects: (RuleEffect | SearchEffect)[], items: FItem[], context: FContext);
9
- hydrateDefinitions(items: FItem[], context: FContext): void;
10
- processRule(rule: FinderRule, instance: FinderCore): void;
11
- processSearchTerm(searchTerm: string, instance: FinderCore): void;
12
- }
@@ -1,12 +0,0 @@
1
- import { EventCallback } from "./types/core-types";
2
- /**
3
- * A barebones event emitter
4
- */
5
- export declare class EventEmitter<EventNames extends string> {
6
- #private;
7
- on(event: EventNames, callback: EventCallback): void;
8
- off(event: EventNames, callback?: EventCallback): void;
9
- emit(event: EventNames, payload?: any): void;
10
- silently(callback: CallableFunction): void;
11
- isSilent(): boolean;
12
- }
@@ -1,10 +0,0 @@
1
- import { HydratedFilterRule } from "../types/rule-types";
2
- export declare function BooleanFilter(rule: HydratedFilterRule): {
3
- validate(value: unknown): boolean;
4
- parse(value: unknown): any;
5
- has(value: unknown): any;
6
- toggle(value: unknown, optionValue?: any): boolean;
7
- add(value: unknown, optionValue: any): never;
8
- delete(value: unknown, optionValue?: any): undefined;
9
- isActive(value: unknown): boolean;
10
- };
@@ -1,18 +0,0 @@
1
- import { HydratedFilterRule } from "../types/rule-types";
2
- export declare function makeFilter(rule: HydratedFilterRule): {
3
- validate(value: unknown): boolean;
4
- parse(value: unknown): any;
5
- has(value: unknown): any;
6
- toggle(value: unknown, optionValue?: any): boolean;
7
- add(value: unknown, optionValue: any): never;
8
- delete(value: unknown, optionValue?: any): undefined;
9
- isActive(value: unknown): boolean;
10
- } | {
11
- validate(value: unknown): boolean;
12
- parse(value: unknown): any[];
13
- has(value: unknown, optionValue?: any): boolean;
14
- toggle(value: unknown, optionValue?: any): any[];
15
- add(value: unknown, optionValue: any): any[];
16
- delete(value: unknown, optionValue?: any): any[] | undefined;
17
- isActive(value: unknown): boolean;
18
- };
@@ -1,10 +0,0 @@
1
- import { HydratedFilterRule } from "../types/rule-types";
2
- export declare function MultipleFilter(rule: HydratedFilterRule): {
3
- validate(value: unknown): boolean;
4
- parse(value: unknown): any[];
5
- has(value: unknown, optionValue?: any): boolean;
6
- toggle(value: unknown, optionValue?: any): any[];
7
- add(value: unknown, optionValue: any): any[];
8
- delete(value: unknown, optionValue?: any): any[] | undefined;
9
- isActive(value: unknown): boolean;
10
- };
@@ -1,10 +0,0 @@
1
- import { HydratedFilterRule } from "../types/rule-types";
2
- export declare function SingleFilter(rule: HydratedFilterRule): {
3
- validate(): boolean;
4
- parse(value: unknown): any;
5
- has(value: unknown): value is {} | null;
6
- toggle(value: unknown, optionValue?: any): never;
7
- add(value: unknown, optionValue: any): never;
8
- delete(value: unknown, optionValue?: any): undefined;
9
- isActive(value: unknown): boolean;
10
- };
@@ -1,28 +0,0 @@
1
- import { FilterRuleUnion, FilterTestOptions, FilterTestRuleOptions, HydratedFilterRule } from "./types/rule-types";
2
- import { MixinInjectedDependencies, SerializedFiltersMixin } from "./types/core-types";
3
- interface InitialValues {
4
- initialFilters: Record<string, any> | undefined;
5
- }
6
- type FilterRuleIdentifier = string | FilterRuleUnion | HydratedFilterRule;
7
- declare class FiltersMixin {
8
- #private;
9
- constructor({ initialFilters }: InitialValues, deps: MixinInjectedDependencies);
10
- set<FValue>(identifier: FilterRuleIdentifier, value: FValue | FValue[]): void;
11
- get rules(): HydratedFilterRule<unknown, any, any>[];
12
- get activeRules(): HydratedFilterRule<unknown, any, any>[];
13
- get(identifier: FilterRuleIdentifier): any;
14
- has(identifier: FilterRuleIdentifier, optionValue?: any): boolean;
15
- getRule(identifier: FilterRuleIdentifier): HydratedFilterRule<any, any, any>;
16
- add(identifier: FilterRuleIdentifier, optionValue: any): void;
17
- delete(identifier: FilterRuleIdentifier, optionValue?: any): void;
18
- isRuleActive(identifier: FilterRuleIdentifier): boolean;
19
- toggle(identifier: FilterRuleIdentifier, optionValue?: any): void;
20
- test(options: FilterTestOptions): any[];
21
- testRule({ rule: identifier, value, ...options }: FilterTestRuleOptions): any[];
22
- testRuleOptions(identifier: FilterRuleIdentifier, isAdditive?: boolean): Map<any, any>;
23
- get values(): Record<string, any>;
24
- get raw(): Record<string, any>;
25
- serialize(): SerializedFiltersMixin;
26
- static process<FItem>(options: SerializedFiltersMixin, items: FItem[], context: any): FItem[];
27
- }
28
- export { FiltersMixin };
@@ -1,44 +0,0 @@
1
- import { SearchMixin } from "./search";
2
- import { FiltersMixin } from "./filters";
3
- import { SortByMixin } from "./sort-by";
4
- import { GroupByMixin } from "./group-by";
5
- import { PaginationMixin } from "./pagination";
6
- import { FinderCore } from "./finder-core";
7
- import { FinderConstructorOptions, SnapshotSerializedMixins, EventCallback } from "./types/core-types";
8
- import { FinderEventName } from "./types/event-types";
9
- import { FinderRule } from "./types/rule-types";
10
- declare class FinderCoreImplementation<FItem, FContext = any> {
11
- #private;
12
- isReady: boolean;
13
- isLoading: boolean;
14
- disabled: boolean;
15
- updatedAt: number;
16
- search: SearchMixin<FItem>;
17
- filters: FiltersMixin;
18
- sortBy: SortByMixin<FItem>;
19
- groupBy: GroupByMixin<FItem, FContext>;
20
- pagination: PaginationMixin<FItem>;
21
- context: FContext;
22
- getInstanceFn: () => FinderCore;
23
- constructor(items: FItem[] | null | undefined, { rules, effects, initialSearchTerm, initialSortBy, initialSortDirection, initialGroupBy, initialFilters, context, page, numItemsPerPage, isLoading, disabled, requireGroup, ignoreSortByRulesWhileSearchRuleIsActive, onInit, onReady, onFirstUserInteraction, onChange, }: FinderConstructorOptions<FItem, FContext>, getInstanceFn: () => FinderCore);
24
- emitFirstUserInteraction(): void;
25
- get items(): FItem[];
26
- get matches(): import("./types/core-types").ResultSnapshot<FItem>;
27
- test(mixins: SnapshotSerializedMixins, isAdditive?: boolean): FItem[];
28
- get isEmpty(): boolean;
29
- get hasMatches(): boolean;
30
- get events(): {
31
- on: (event: FinderEventName, callback: EventCallback) => void;
32
- off: (event: FinderEventName, callback: EventCallback) => void;
33
- silently: (callback: EventCallback) => void;
34
- isSilent: () => boolean;
35
- };
36
- getRule(identifier: string | FinderRule<FItem>): FinderRule<FItem>;
37
- get state(): "loading" | "empty" | "groups" | "items" | "noMatches";
38
- setItems(items: FItem[] | null | undefined): void;
39
- setIsLoading(value?: boolean): void;
40
- setIsDisabled(value?: boolean): void;
41
- setRules(definitions: FinderRule<FItem, FContext>[]): void;
42
- setContext(context: FContext): void;
43
- }
44
- export { FinderCoreImplementation };
@@ -1,99 +0,0 @@
1
- import { FinderConstructorOptions, SnapshotSerializedMixins } from "./types/core-types";
2
- import { FinderRule } from "./types/rule-types";
3
- /**
4
- * This thin wrapper around FinderCoreImplementation defines the mixin interfaces and hides private methods.
5
- */
6
- declare class FinderCore<FItem = any, FContext = any> {
7
- #private;
8
- constructor(items: FItem[] | null | undefined, options: FinderConstructorOptions<FItem, FContext>);
9
- get items(): FItem[];
10
- get context(): FContext;
11
- get isReady(): boolean;
12
- get isEmpty(): boolean;
13
- get hasMatches(): boolean;
14
- get isLoading(): boolean;
15
- get disabled(): boolean;
16
- get state(): "loading" | "empty" | "groups" | "items" | "noMatches";
17
- get updatedAt(): number;
18
- get events(): {
19
- on: (event: import("./types/event-types").FinderEventName, callback: import("./types/core-types").EventCallback) => void;
20
- off: (event: import("./types/event-types").FinderEventName, callback: import("./types/core-types").EventCallback) => void;
21
- silently: (callback: import("./types/core-types").EventCallback) => void;
22
- isSilent: () => boolean;
23
- };
24
- /**
25
- * Mixin interfaces
26
- */
27
- get matches(): import("./types/core-types").ResultSnapshot<FItem>;
28
- get search(): {
29
- rule: import("..").SearchRule<unknown, any> | undefined;
30
- searchTerm: string;
31
- hasSearchTerm: boolean;
32
- hasSearchRule: boolean;
33
- setSearchTerm: (value: string) => void;
34
- reset: () => void;
35
- test: (searchTerm: string, isAdditive?: boolean) => FItem[];
36
- };
37
- get filters(): {
38
- values: Record<string, any>;
39
- raw: Record<string, any>;
40
- activeRules: import("..").HydratedFilterRule<unknown, any, any>[];
41
- rules: import("..").HydratedFilterRule<unknown, any, any>[];
42
- isActive: (identifier: string | import("..").FilterRuleUnion | import("..").HydratedFilterRule<any, any, any>) => boolean;
43
- get: (identifier: string | import("..").FilterRuleUnion | import("..").HydratedFilterRule<any, any, any>) => any;
44
- add: (identifier: string | import("..").FilterRuleUnion | import("..").HydratedFilterRule<any, any, any>, optionValue: any) => void;
45
- has: (identifier: string | import("..").FilterRuleUnion | import("..").HydratedFilterRule<any, any, any>, optionValue?: any) => boolean;
46
- getRule: (identifier: string | import("..").FilterRuleUnion | import("..").HydratedFilterRule<any, any, any>) => import("..").HydratedFilterRule<any, any, any>;
47
- toggle: (identifier: string | import("..").FilterRuleUnion | import("..").HydratedFilterRule<any, any, any>, optionValue?: any) => void;
48
- set: <FValue>(identifier: string | import("..").FilterRuleUnion | import("..").HydratedFilterRule<any, any, any>, value: FValue | FValue[]) => void;
49
- delete: (identifier: string | import("..").FilterRuleUnion | import("..").HydratedFilterRule<any, any, any>, optionValue?: any) => void;
50
- test: (options: import("./types/rule-types").FilterTestOptions) => any[];
51
- testRule: ({ rule: identifier, value, ...options }: import("./types/rule-types").FilterTestRuleOptions) => any[];
52
- testRuleOptions: (identifier: string | import("..").FilterRuleUnion | import("..").HydratedFilterRule<any, any, any>, isAdditive?: boolean) => Map<any, any>;
53
- };
54
- get sortBy(): {
55
- activeRule: import("..").SortByRule<unknown, any> | undefined;
56
- sortDirection: import("..").SortDirection;
57
- userHasSetSortDirection: boolean;
58
- rules: import("..").SortByRule<unknown, any>[];
59
- set: (identifier?: string | import("..").SortByRule, incomingSortDirection?: import("..").SortDirection) => void;
60
- setSortDirection: (incomingSortDirection?: import("..").SortDirection) => void;
61
- cycleSortDirection: () => void;
62
- toggleSortDirection: () => void;
63
- reset: () => void;
64
- };
65
- get groupBy(): {
66
- activeRule: import("..").GroupByRule<unknown, any> | undefined;
67
- requireGroup: boolean;
68
- rules: import("..").GroupByRule<unknown, any>[];
69
- groupSortDirection: import("..").SortDirection | undefined;
70
- set: (identifier?: string | import("..").GroupByRule) => void;
71
- toggle: (identifier: import("..").GroupByRule | string) => void;
72
- setGroupSortDirection: (direction?: import("..").SortDirection) => void;
73
- reset: () => void;
74
- };
75
- get pagination(): {
76
- page: number;
77
- offset: number;
78
- numItemsPerPage: number | undefined;
79
- numTotalItems: number;
80
- lastPage: number | undefined;
81
- isPaginated: boolean;
82
- setPage: (value: number) => void;
83
- setNumItemsPerPage: (value?: number) => void;
84
- };
85
- /**
86
- * Mutators
87
- */
88
- setItems(items: FItem[] | null | undefined): void;
89
- setIsLoading(value?: boolean): void;
90
- setIsDisabled(value?: boolean): void;
91
- setRules(definitions: FinderRule<FItem>[]): void;
92
- setContext(context: FContext): void;
93
- /**
94
- * Utils
95
- */
96
- test(mixins: SnapshotSerializedMixins, isAdditive?: boolean): FItem[];
97
- getRule(identifier: string | FinderRule<FItem>): FinderRule<FItem>;
98
- }
99
- export { FinderCore };
@@ -1,3 +0,0 @@
1
- export declare class FinderError extends Error {
2
- constructor(message: string, options?: any);
3
- }
@@ -1,23 +0,0 @@
1
- import { GroupByRule } from "./types/rule-types";
2
- import { FinderResultGroup, MixinInjectedDependencies, SerializedGroupByMixin, SortDirection } from "./types/core-types";
3
- interface InitialValues {
4
- initialGroupBy: string | undefined;
5
- requireGroup: boolean;
6
- }
7
- declare class GroupByMixin<FItem, FContext> {
8
- #private;
9
- requireGroup: boolean;
10
- constructor({ initialGroupBy, requireGroup }: InitialValues, deps: MixinInjectedDependencies<FItem, FContext>);
11
- getRule(identifier: string | GroupByRule): GroupByRule<unknown, any>;
12
- get rules(): GroupByRule<unknown, any>[];
13
- get activeRule(): GroupByRule<unknown, any> | undefined;
14
- get hasGroupByRule(): boolean;
15
- get groupSortDirection(): SortDirection | undefined;
16
- set(identifier?: string | GroupByRule): void;
17
- setGroupSortDirection(direction?: SortDirection): void;
18
- toggle(identifier: GroupByRule | string): void;
19
- reset(): void;
20
- serialize(): SerializedGroupByMixin;
21
- static process<FItem>(options: SerializedGroupByMixin, items: FItem[], context: unknown): FinderResultGroup<FItem>[];
22
- }
23
- export { GroupByMixin };
@@ -1,19 +0,0 @@
1
- import { MixinInjectedDependencies, SerializedPaginationMixin } from "./types/core-types";
2
- interface InitialValues {
3
- page: number | undefined;
4
- numItemsPerPage: number | undefined;
5
- }
6
- declare class PaginationMixin<FItem> {
7
- #private;
8
- numItemsPerPage?: number;
9
- constructor({ page, numItemsPerPage }: InitialValues, handlers: MixinInjectedDependencies<FItem>);
10
- setPage(value: number): void;
11
- setNumItemsPerPage(value?: number): void;
12
- get lastPage(): number | undefined;
13
- get numTotalItems(): number;
14
- get page(): number;
15
- get offset(): number;
16
- serialize(): SerializedPaginationMixin;
17
- static process<FItem>(options: SerializedPaginationMixin, items: FItem[]): FItem[];
18
- }
19
- export { PaginationMixin };
@@ -1,14 +0,0 @@
1
- import { FinderRule } from "./types/rule-types";
2
- /**
3
- * Stores rule definitions and hydrated rules
4
- */
5
- export declare class RuleBook<FItem, FContext> {
6
- #private;
7
- rules: FinderRule<FItem>[];
8
- constructor(definitions: FinderRule<FItem>[], items: FItem[], context: FContext);
9
- hydrateDefinitions(items: FItem[], context: FContext): void;
10
- getRule(identifier: string | FinderRule): FinderRule<FItem>;
11
- getDefinitions(): FinderRule<FItem>[];
12
- setRules(definitions: FinderRule<FItem>[]): void;
13
- static validateDefinitions(definitions: FinderRule[]): boolean;
14
- }
@@ -1 +0,0 @@
1
- export declare function calculateCharacterMatchIndexes(haystack: string, needle: string): number[] | undefined;
@@ -1,9 +0,0 @@
1
- import { StringMatchSegment } from "../types/string-match-types";
2
- /**
3
- * Helper function to determine which specfic characters are matched inside a string.
4
- */
5
- export declare function calculateStringMatchSegments(haystack: string | string[], needle: string): StringMatchSegment[] | undefined;
6
- /**
7
- * Determine if a characterIndexFn would return a result for a haystack.
8
- */
9
- export declare function hasCharacterIndexMatches(haystack: string | string[], needle: string): boolean;
@@ -1,2 +0,0 @@
1
- import { SerializedSearchMixin } from "../types/core-types";
2
- export declare function defaultSearchAndSortAlgorithm<FItem>(options: SerializedSearchMixin, items: FItem[], context: unknown): FItem[];
@@ -1,4 +0,0 @@
1
- export declare function calculateSearchScore(indexes: number[], haystack: string): {
2
- percentOfHaystackMatched: number;
3
- longestSequentialSequence: number;
4
- };
@@ -1,8 +0,0 @@
1
- /**
2
- * Ensure haystacks and needles are formatted consistently.
3
- *
4
- * Transforming includes:
5
- * 1. Convert to lowercase.
6
- * 2. Strip all non-word and non-digit characters.
7
- */
8
- export declare function transformStringForComparison(value: string): string;
@@ -1,15 +0,0 @@
1
- export declare class StringMatchHaystack {
2
- #private;
3
- source: string;
4
- transformed: string;
5
- constructor(haystack: string);
6
- getSourceCharacterIndex(transformedCharacterIndex: number): number;
7
- /**
8
- * We need to preserve the relationship between the source and the transformed results.
9
- */
10
- static composeTransformedHaystackSegments(haystack: string): {
11
- value: string;
12
- index: number;
13
- length: number;
14
- }[];
15
- }
@@ -1,18 +0,0 @@
1
- import { MixinInjectedDependencies, SerializedSearchMixin } from "./types/core-types";
2
- interface InitialValues {
3
- initialSearchTerm: string | undefined;
4
- }
5
- declare class SearchMixin<FItem> {
6
- #private;
7
- searchTerm: string;
8
- constructor({ initialSearchTerm }: InitialValues, deps: MixinInjectedDependencies<FItem>);
9
- get rule(): import("..").SearchRule<unknown, any> | undefined;
10
- get hasSearchRule(): boolean;
11
- get hasSearchTerm(): boolean;
12
- setSearchTerm(value: string): void;
13
- reset(): void;
14
- serialize(): SerializedSearchMixin;
15
- test(searchTerm: string, isAdditive?: boolean): FItem[];
16
- static process<FItem>(options: SerializedSearchMixin, items: FItem[], context: unknown): FItem[];
17
- }
18
- export { SearchMixin };
@@ -1,23 +0,0 @@
1
- import { SortByRule } from "./types/rule-types";
2
- import { MixinInjectedDependencies, SerializedSortByMixin, SortDirection } from "./types/core-types";
3
- interface InitialValues {
4
- initialSortBy: string | undefined;
5
- initialSortDirection?: SortDirection;
6
- }
7
- declare class SortByMixin<FItem> {
8
- #private;
9
- constructor({ initialSortBy, initialSortDirection }: InitialValues, deps: MixinInjectedDependencies<FItem>);
10
- getRule(identifier: string | SortByRule): SortByRule<unknown, any>;
11
- get rules(): SortByRule<unknown, any>[];
12
- get activeRule(): SortByRule<unknown, any> | undefined;
13
- get sortDirection(): SortDirection;
14
- get userHasSetSortDirection(): boolean;
15
- setSortDirection(incomingSortDirection?: SortDirection): void;
16
- cycleSortDirection(): void;
17
- toggleSortDirection(): void;
18
- set(identifier?: string | SortByRule, incomingSortDirection?: SortDirection): void;
19
- reset(): void;
20
- serialize(): SerializedSortByMixin;
21
- static process<FItem>(options: SerializedSortByMixin, items: FItem[], context: unknown): FItem[];
22
- }
23
- export { SortByMixin };
@@ -1,8 +0,0 @@
1
- import { ResultSnapshot, SnapshotOptions } from "./types/core-types";
2
- export declare class Tester<FItem, FContext> {
3
- snapshot: ResultSnapshot<FItem>;
4
- isStale: boolean;
5
- setIsStale(value: boolean): void;
6
- takeSnapshot({ items, context, mixins }: SnapshotOptions<FItem, FContext>): void;
7
- static test<FItem, FContext>({ mixins, items, context }: SnapshotOptions<FItem, FContext>): FItem[];
8
- }
@@ -1,93 +0,0 @@
1
- import { DebounceCallbackRegistry } from "../debounce-callback-registry";
2
- import { RuleBook } from "../rule-book";
3
- import { RuleEffect, SearchEffect } from "./effect-types";
4
- import { FinderOnChangeCallback, FinderOnFirstUserInteractCallback, FinderOnInitCallback, FinderOnReadyCallback, FinderTouchCallback } from "./event-types";
5
- import { FinderRule, GroupByRule, HydratedFilterRule, SearchRule, SortByRule } from "./rule-types";
6
- export interface FinderConstructorOptions<FItem, FContext = any> {
7
- rules: FinderRule<FItem>[];
8
- effects?: (RuleEffect | SearchEffect)[];
9
- context?: FContext;
10
- isLoading?: boolean;
11
- disabled?: boolean;
12
- initialSearchTerm?: string;
13
- initialSortBy?: string;
14
- initialSortDirection?: SortDirection;
15
- initialGroupBy?: string;
16
- initialFilters?: Record<string, any>;
17
- ignoreSortByRulesWhileSearchRuleIsActive?: boolean;
18
- requireGroup?: boolean;
19
- page?: number;
20
- numItemsPerPage?: number;
21
- onInit?: FinderOnInitCallback;
22
- onReady?: FinderOnReadyCallback;
23
- onFirstUserInteraction?: FinderOnFirstUserInteractCallback;
24
- onChange?: FinderOnChangeCallback;
25
- }
26
- export interface FinderResultGroup<FItem> {
27
- id: string;
28
- items: FItem[];
29
- }
30
- export type SortDirection = "asc" | "desc" | ("asc" | "desc")[];
31
- export interface ResultSnapshot<FItem> {
32
- items?: FItem[];
33
- groups?: FinderResultGroup<FItem>[];
34
- numMatchedItems: number;
35
- numTotalItems: number;
36
- hasGroupByRule: boolean;
37
- }
38
- export interface MixinInjectedDependencies<FItem = any, FContext = any> {
39
- isLoading: () => boolean;
40
- isDisabled: () => boolean;
41
- getRuleBook: () => RuleBook<FItem, FContext>;
42
- touch: FinderTouchCallback;
43
- getItems: () => FItem[];
44
- test: (serializedMixins: SnapshotSerializedMixins, isAdditive?: boolean) => FItem[];
45
- debouncer: ReturnType<typeof DebounceCallbackRegistry>;
46
- }
47
- export type EventCallback = (payload?: any) => void;
48
- export interface SnapshotOptions<FItem, FContext> {
49
- items: FItem[];
50
- context: FContext;
51
- mixins: SnapshotSerializedMixins;
52
- }
53
- export interface SnapshotSerializedMixins {
54
- search?: SerializedSearchMixin;
55
- filters?: SerializedFiltersMixin;
56
- sortBy?: SerializedSortByMixin;
57
- pagination?: SerializedPaginationMixin;
58
- groupBy?: SerializedGroupByMixin;
59
- }
60
- export interface SerializedSearchMixin {
61
- searchTerm: string;
62
- rule?: SearchRule;
63
- }
64
- export interface SerializedFiltersMixin {
65
- rules: HydratedFilterRule[];
66
- values: Record<string, any>;
67
- }
68
- export interface SerializedSortByMixin {
69
- rule?: SortByRule;
70
- sortDirection?: SortDirection;
71
- }
72
- export interface SerializedPaginationMixin {
73
- page: number;
74
- numItemsPerPage?: number;
75
- }
76
- export interface SerializedGroupByMixin {
77
- rule?: GroupByRule;
78
- sortDirection?: SortDirection;
79
- }
80
- export interface SearchScore {
81
- percentOfHaystackMatched: number;
82
- longestSequentialSequence: number;
83
- }
84
- export interface PaginationMixinInterface {
85
- page: number;
86
- offset: number;
87
- numItemsPerPage: number | undefined;
88
- numTotalItems: number;
89
- lastPage: number | undefined;
90
- isPaginated: boolean;
91
- setPage: (value: number) => void;
92
- setNumItemsPerPage: (value: number) => void;
93
- }
@@ -1,20 +0,0 @@
1
- import { FinderCore } from "../finder-core";
2
- import { FinderRule } from "./rule-types";
3
- export interface RuleEffect<FItem = any, FContext = any> {
4
- rules: string | FinderRule<FItem> | (string | FinderRule<FItem>)[] | ((items: FItem[], context: FContext) => string | FinderRule<FItem> | (string | FinderRule<FItem>)[]);
5
- onChange: (instance: FinderCore<FItem, FContext>, rule: FinderRule<FItem>) => void;
6
- }
7
- export interface HydratedRuleEffect<FItem = any, FContext = any> {
8
- rules: (string | FinderRule<FItem>)[];
9
- onChange: (instance: FinderCore<FItem, FContext>, rule: FinderRule<FItem>) => void;
10
- _isHydrated: true;
11
- }
12
- export interface SearchEffect<FItem = any, FContext = any> {
13
- haystack: string | string[] | ((items: FItem[], context: FContext) => string | string[]);
14
- onChange: (instance: FinderCore<FItem, FContext>, searchTerm: string) => void;
15
- }
16
- export interface HydratedSearchEffect<FItem = any, FContext = any> {
17
- haystack: string[];
18
- onChange: (instance: FinderCore<FItem, FContext>, searchTerm: string) => void;
19
- _isHydrated: true;
20
- }