@hitgrab/finder 0.0.26-alpha → 0.1.0-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 (67) hide show
  1. package/README.md +7 -1106
  2. package/dist/core/effect-book/effect-book.d.ts +8 -0
  3. package/dist/core/events/event-emitter.d.ts +2 -1
  4. package/dist/core/filters/filters-interface.d.ts +13 -14
  5. package/dist/core/filters/filters.d.ts +15 -16
  6. package/dist/core/finder-core.d.ts +29 -51
  7. package/dist/core/group-by/group-by-interface.d.ts +7 -7
  8. package/dist/core/group-by/group-by.d.ts +12 -10
  9. package/dist/core/pagination/pagination.d.ts +5 -4
  10. package/dist/core/rule-book/rule-book.d.ts +14 -0
  11. package/dist/core/search/algorithms/sequential-characters.d.ts +1 -2
  12. package/dist/core/search/algorithms/sequential-string.d.ts +1 -2
  13. package/dist/core/search/{haystack.d.ts → result-segments/result-segment-haystack.d.ts} +1 -1
  14. package/dist/core/search/result-segments/result-segment-types.d.ts +2 -3
  15. package/dist/core/search/result-segments/search-result-segments.d.ts +3 -11
  16. package/dist/core/search/search-interface.d.ts +3 -2
  17. package/dist/core/search/search-score.d.ts +4 -0
  18. package/dist/core/search/search-string-transform.d.ts +8 -0
  19. package/dist/core/search/search.d.ts +7 -5
  20. package/dist/core/sort-by/sort-by-interface.d.ts +5 -5
  21. package/dist/core/sort-by/sort-by.d.ts +6 -5
  22. package/dist/core/tester/tester.d.ts +8 -0
  23. package/dist/core/types/core-types.d.ts +92 -0
  24. package/dist/core/types/effect-types.d.ts +22 -0
  25. package/dist/core/types/event-types.d.ts +43 -0
  26. package/dist/core/types/rule-types.d.ts +108 -0
  27. package/dist/core/utils/rule-type-enforcers.d.ts +9 -5
  28. package/dist/core/utils/rule-utils.d.ts +5 -8
  29. package/dist/index.d.ts +6 -14
  30. package/dist/index.js +3204 -3547
  31. package/dist/index.umd.cjs +30 -30
  32. package/dist/react/components/finder-content-empty.d.ts +6 -0
  33. package/dist/react/components/finder-content-groups.d.ts +7 -0
  34. package/dist/react/components/finder-content-items.d.ts +7 -0
  35. package/dist/react/components/finder-content-loading.d.ts +6 -0
  36. package/dist/react/components/finder-content-no-matches.d.ts +6 -0
  37. package/dist/react/components/finder-content.d.ts +20 -8
  38. package/dist/react/components/finder-search-term.d.ts +2 -1
  39. package/dist/react/components/finder.d.ts +7 -1
  40. package/dist/react/hooks/use-finder-constructor.d.ts +7 -0
  41. package/dist/react/hooks/use-finder-ref.d.ts +1 -1
  42. package/dist/react/hooks/use-finder.d.ts +1 -5
  43. package/dist/react/providers/finder-core-context.d.ts +3 -0
  44. package/dist/react/types/react-types.d.ts +9 -13
  45. package/package.json +4 -1
  46. package/dist/core/__tests__/selected-items.test.d.ts +0 -1
  47. package/dist/core/layout/layout-interface.d.ts +0 -19
  48. package/dist/core/layout/layout.d.ts +0 -21
  49. package/dist/core/meta/meta-interface.d.ts +0 -18
  50. package/dist/core/meta/meta.d.ts +0 -16
  51. package/dist/core/plugins/plugin-mediator.d.ts +0 -14
  52. package/dist/core/plugins/plugin-super-class.d.ts +0 -8
  53. package/dist/core/search/algorithms/unordered-characters.d.ts +0 -2
  54. package/dist/core/selected-items/selected-items-interface.d.ts +0 -22
  55. package/dist/core/selected-items/selected-items.d.ts +0 -23
  56. package/dist/core/types/internal-types.d.ts +0 -15
  57. package/dist/core/utils/string-compare-utils.d.ts +0 -13
  58. package/dist/react/components/finder-empty.d.ts +0 -6
  59. package/dist/react/components/finder-groups.d.ts +0 -7
  60. package/dist/react/components/finder-items.d.ts +0 -7
  61. package/dist/react/components/finder-loading.d.ts +0 -6
  62. package/dist/react/components/finder-no-matches.d.ts +0 -6
  63. package/dist/react/hooks/use-finder-context.d.ts +0 -2
  64. package/dist/react/providers/finder-context.d.ts +0 -3
  65. package/dist/types.d.ts +0 -221
  66. /package/dist/core/__tests__/{layout.test.d.ts → effects.test.d.ts} +0 -0
  67. /package/dist/core/__tests__/{plugins.test.d.ts → events.test.d.ts} +0 -0
@@ -0,0 +1,8 @@
1
+ import { HydratedRuleEffect, HydratedSearchEffect, RuleEffect, SearchEffect } from "../types/effect-types";
2
+ export declare class EffectBook<FItem, FContext> {
3
+ #private;
4
+ searchEffects: HydratedSearchEffect[];
5
+ ruleEffects: HydratedRuleEffect[];
6
+ constructor(effects: (RuleEffect | SearchEffect)[], items: FItem[], context: FContext);
7
+ hydrateDefinitions<FItem, FContext>(items: FItem[], context: FContext): void;
8
+ }
@@ -1,4 +1,4 @@
1
- import { EventCallback } from "../types/internal-types";
1
+ import { EventCallback } from "../types/core-types";
2
2
  /**
3
3
  * A barebones event emitter
4
4
  */
@@ -8,4 +8,5 @@ export declare class EventEmitter<EventNames extends string> {
8
8
  off(event: EventNames, callback: EventCallback): void;
9
9
  emit(event: EventNames, payload?: any): void;
10
10
  silently(callback: CallableFunction): void;
11
+ isSilent(): boolean;
11
12
  }
@@ -3,30 +3,29 @@ import { FiltersMixin } from "./filters";
3
3
  * Public surface for the Filters mixin
4
4
  */
5
5
  declare function readonlyFiltersInterface(mixin: FiltersMixin): {
6
- filters: Record<string, any>;
6
+ values: Record<string, any>;
7
7
  raw: Record<string, any>;
8
- activeRules: import("../..").HydratedFilterRule<any, any>[];
9
- rules: import("../..").HydratedFilterRule<any, any>[];
8
+ activeRules: import("../..").HydratedFilterRule<unknown, any, any>[];
9
+ rules: import("../..").HydratedFilterRule<unknown, any, any>[];
10
10
  isActive: (identifier: string | import("../..").FilterRuleUnion | import("../..").HydratedFilterRule) => boolean;
11
11
  get: (identifier: string | import("../..").FilterRuleUnion | import("../..").HydratedFilterRule) => any;
12
12
  has: (identifier: string | import("../..").FilterRuleUnion | import("../..").HydratedFilterRule, optionValue?: import("../..").FilterOption | any) => any;
13
- getRule: <FItem = any, FValue = any>(identifier: string | import("../..").FilterRuleUnion<FItem, FValue> | import("../..").HydratedFilterRule<FItem, FValue>) => import("../..").HydratedFilterRule<FItem, FValue>;
13
+ getRule: (identifier: string | import("../..").FilterRuleUnion | import("../..").HydratedFilterRule) => import("../..").HydratedFilterRule<any, any, any> | undefined;
14
14
  };
15
15
  declare function filtersInterface(mixin: FiltersMixin): {
16
- toggle: (identifier: string | import("../..").FilterRuleUnion | import("../..").HydratedFilterRule) => void;
17
- toggleOption: (identifier: string | import("../..").FilterRuleUnion | import("../..").HydratedFilterRule, optionValue: import("../..").FilterOption | any) => void;
18
- set: <FItem, FValue>(identifier: string | import("../..").FilterRuleUnion<FItem, FValue> | import("../..").HydratedFilterRule<FItem, FValue>, incomingFilterValue: FValue | FValue[]) => void;
16
+ toggle: (identifier: string | import("../..").FilterRuleUnion | import("../..").HydratedFilterRule, optionValue?: import("../..").FilterOption | any) => void;
17
+ set: <FItem, FValue>(identifier: string | import("../..").FilterRuleUnion<FItem, FValue> | import("../..").HydratedFilterRule<FItem, FValue, any>, incomingFilterValue: FValue | FValue[]) => void;
19
18
  delete: (identifier: string | import("../..").FilterRuleUnion | import("../..").HydratedFilterRule) => void;
20
- test: (options: import("../../types").FilterTestOptions) => any[];
21
- testRule: ({ rule: identifier, value, ...options }: import("../../types").FilterTestRuleOptions) => any[];
22
- testRuleOptions: ({ rule: identifier, ...options }: import("../../types").FilterTestRuleOptionsOptions) => Map<any, any>;
23
- filters: Record<string, any>;
19
+ test: (options: import("../types/rule-types").FilterTestOptions) => any[];
20
+ testRule: ({ rule: identifier, value, ...options }: import("../types/rule-types").FilterTestRuleOptions) => any[];
21
+ testRuleOptions: ({ rule: identifier, ...options }: import("../types/rule-types").FilterTestRuleOptionsOptions) => Map<any, any>;
22
+ values: Record<string, any>;
24
23
  raw: Record<string, any>;
25
- activeRules: import("../..").HydratedFilterRule<any, any>[];
26
- rules: import("../..").HydratedFilterRule<any, any>[];
24
+ activeRules: import("../..").HydratedFilterRule<unknown, any, any>[];
25
+ rules: import("../..").HydratedFilterRule<unknown, any, any>[];
27
26
  isActive: (identifier: string | import("../..").FilterRuleUnion | import("../..").HydratedFilterRule) => boolean;
28
27
  get: (identifier: string | import("../..").FilterRuleUnion | import("../..").HydratedFilterRule) => any;
29
28
  has: (identifier: string | import("../..").FilterRuleUnion | import("../..").HydratedFilterRule, optionValue?: import("../..").FilterOption | any) => any;
30
- getRule: <FItem = any, FValue = any>(identifier: string | import("../..").FilterRuleUnion<FItem, FValue> | import("../..").HydratedFilterRule<FItem, FValue>) => import("../..").HydratedFilterRule<FItem, FValue>;
29
+ getRule: (identifier: string | import("../..").FilterRuleUnion | import("../..").HydratedFilterRule) => import("../..").HydratedFilterRule<any, any, any> | undefined;
31
30
  };
32
31
  export { readonlyFiltersInterface, filtersInterface };
@@ -1,29 +1,28 @@
1
- import { HydratedFilterRule, FilterOption, FilterTestOptions, FilterTestRuleOptions, FilterTestRuleOptionsOptions, MetaInterface, FilterRuleUnion } from "../../types";
2
- import { MixinInjectedDependencies } from "../types/internal-types";
3
- type InitialValues = {
1
+ import { FilterOption, FilterRule, FilterRuleUnion, FilterTestOptions, FilterTestRuleOptions, FilterTestRuleOptionsOptions, HydratedFilterRule } from "../types/rule-types";
2
+ import { MixinInjectedDependencies, SerializedFiltersMixin } from "../types/core-types";
3
+ interface InitialValues {
4
4
  initialFilters: Record<string, any> | undefined;
5
- };
5
+ }
6
6
  declare class FiltersMixin {
7
7
  #private;
8
- filters: Record<string, any>;
9
8
  constructor({ initialFilters }: InitialValues, deps: MixinInjectedDependencies);
10
9
  set<FItem, FValue>(identifier: FilterRuleUnion<FItem, FValue> | HydratedFilterRule<FItem, FValue> | string, incomingFilterValue: FValue | FValue[]): void;
11
- get rules(): HydratedFilterRule<any, any>[];
12
- clearHydratedRules(): void;
13
- getRule<FItem = any, FValue = any>(identifier: FilterRuleUnion<FItem, FValue> | HydratedFilterRule<FItem, FValue> | string): HydratedFilterRule<FItem, FValue>;
14
- get activeRules(): HydratedFilterRule<any, any>[];
10
+ get rules(): HydratedFilterRule<unknown, any, any>[];
11
+ get activeRules(): HydratedFilterRule<unknown, any, any>[];
15
12
  get(identifier: string | FilterRuleUnion | HydratedFilterRule): any;
16
13
  has(identifier: string | FilterRuleUnion | HydratedFilterRule, optionValue?: FilterOption | any): any;
14
+ getRule(identifier: string | FilterRuleUnion | HydratedFilterRule): HydratedFilterRule<any, any, any> | undefined;
17
15
  delete(identifier: string | FilterRuleUnion | HydratedFilterRule): void;
18
- isActive(identifier: string | FilterRuleUnion | HydratedFilterRule): boolean;
19
- toggle(identifier: string | FilterRuleUnion | HydratedFilterRule): void;
20
- toggleOption(identifier: string | FilterRuleUnion | HydratedFilterRule, optionValue: FilterOption | any): void;
16
+ isRuleActive(identifier: string | FilterRuleUnion | HydratedFilterRule): boolean;
17
+ toggle(identifier: string | FilterRuleUnion | HydratedFilterRule, optionValue?: FilterOption | any): void;
21
18
  test(options: FilterTestOptions): any[];
22
19
  testRule({ rule: identifier, value, ...options }: FilterTestRuleOptions): any[];
23
20
  testRuleOptions({ rule: identifier, ...options }: FilterTestRuleOptionsOptions): Map<any, any>;
24
- getFilters(): Record<string, any>;
25
- process(items: any[], meta: MetaInterface): any[];
26
- static process<FItem>(items: FItem[], rules: HydratedFilterRule[], values: Record<string, any>, meta: MetaInterface): FItem[];
27
- static isActive(rule: FilterRuleUnion | HydratedFilterRule, value: any): boolean;
21
+ getValues(): Record<string, any>;
22
+ getRawValues(): Record<string, any>;
23
+ serialize(): SerializedFiltersMixin;
24
+ static process<FItem>(options: SerializedFiltersMixin, items: FItem[], context?: any): FItem[];
25
+ static isRuleActive(rule: FilterRuleUnion | HydratedFilterRule, value: any): boolean;
26
+ static hydrateRule<FItem = any, FContext = any>(rule: FilterRule, items: FItem[], context: FContext): HydratedFilterRule;
28
27
  }
29
28
  export { FiltersMixin };
@@ -1,41 +1,42 @@
1
- import { MatchesSnapshot, FinderConstructorOptions, FinderEventName } from "../types";
2
- import { PluginMediator } from "./plugins/plugin-mediator";
3
- import { EventCallback } from "./types/internal-types";
4
- declare class FinderCore<FItem> {
1
+ import { FinderEventName } from "./types/event-types";
2
+ import { FinderRule } from "./types/rule-types";
3
+ import { EventCallback, FinderConstructorOptions, SnapshotSerializedMixins } from "./types/core-types";
4
+ declare class FinderCore<FItem, FContext = any> {
5
5
  #private;
6
6
  isReady: boolean;
7
7
  isLoading: boolean;
8
8
  disabled: boolean;
9
9
  updatedAt?: number;
10
- plugins: PluginMediator<FItem>;
11
- constructor(items: FItem[] | null | undefined, { rules, initialSearchTerm, initialSortBy, initialSortDirection, initialGroupBy, initialFilters, initialSelectedItems, initialMeta, page, numItemsPerPage, isLoading, disabled, requireGroup, maxSelectedItems, layoutVariants, initialLayout, plugins, onInit, onReady, onFirstUserInteraction, onChange, }: FinderConstructorOptions<FItem>);
10
+ context: FContext;
11
+ 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>);
12
12
  emitFirstUserInteraction(): void;
13
13
  get items(): FItem[];
14
- get matches(): MatchesSnapshot<FItem>;
14
+ get matches(): import("./types/core-types").ResultSnapshot<FItem>;
15
+ test(mixins: SnapshotSerializedMixins, isAdditive?: boolean): FItem[];
15
16
  get isEmpty(): boolean;
16
17
  get search(): {
17
18
  setSearchTerm: (incomingSearchTerm: string) => void;
18
19
  reset: () => void;
20
+ test: (searchTerm: string, isAdditive?: boolean) => FItem[];
19
21
  searchTerm: string;
20
- activeRule: import("..").SearchRule<unknown> | undefined;
21
22
  hasSearchTerm: boolean;
23
+ hasSearchRule: boolean;
22
24
  };
23
25
  get filters(): {
24
- toggle: (identifier: string | import("..").FilterRuleUnion | import("..").HydratedFilterRule) => void;
25
- toggleOption: (identifier: string | import("..").FilterRuleUnion | import("..").HydratedFilterRule, optionValue: import("..").FilterOption | any) => void;
26
- set: <FItem_1, FValue>(identifier: string | import("..").FilterRuleUnion<FItem_1, FValue> | import("..").HydratedFilterRule<FItem_1, FValue>, incomingFilterValue: FValue | FValue[]) => void;
26
+ toggle: (identifier: string | import("..").FilterRuleUnion | import("..").HydratedFilterRule, optionValue?: import("..").FilterOption | any) => void;
27
+ set: <FItem_1, FValue>(identifier: string | import("..").FilterRuleUnion<FItem_1, FValue> | import("..").HydratedFilterRule<FItem_1, FValue, any>, incomingFilterValue: FValue | FValue[]) => void;
27
28
  delete: (identifier: string | import("..").FilterRuleUnion | import("..").HydratedFilterRule) => void;
28
- test: (options: import("../types").FilterTestOptions) => any[];
29
- testRule: ({ rule: identifier, value, ...options }: import("../types").FilterTestRuleOptions) => any[];
30
- testRuleOptions: ({ rule: identifier, ...options }: import("../types").FilterTestRuleOptionsOptions) => Map<any, any>;
31
- filters: Record<string, any>;
29
+ test: (options: import("./types/rule-types").FilterTestOptions) => any[];
30
+ testRule: ({ rule: identifier, value, ...options }: import("./types/rule-types").FilterTestRuleOptions) => any[];
31
+ testRuleOptions: ({ rule: identifier, ...options }: import("./types/rule-types").FilterTestRuleOptionsOptions) => Map<any, any>;
32
+ values: Record<string, any>;
32
33
  raw: Record<string, any>;
33
- activeRules: import("..").HydratedFilterRule<any, any>[];
34
- rules: import("..").HydratedFilterRule<any, any>[];
34
+ activeRules: import("..").HydratedFilterRule<unknown, any, any>[];
35
+ rules: import("..").HydratedFilterRule<unknown, any, any>[];
35
36
  isActive: (identifier: string | import("..").FilterRuleUnion | import("..").HydratedFilterRule) => boolean;
36
37
  get: (identifier: string | import("..").FilterRuleUnion | import("..").HydratedFilterRule) => any;
37
38
  has: (identifier: string | import("..").FilterRuleUnion | import("..").HydratedFilterRule, optionValue?: import("..").FilterOption | any) => any;
38
- getRule: <FItem_1 = any, FValue = any>(identifier: string | import("..").FilterRuleUnion<FItem_1, FValue> | import("..").HydratedFilterRule<FItem_1, FValue>) => import("..").HydratedFilterRule<FItem_1, FValue>;
39
+ getRule: (identifier: string | import("..").FilterRuleUnion | import("..").HydratedFilterRule) => import("..").HydratedFilterRule<any, any, any> | undefined;
39
40
  };
40
41
  get sortBy(): {
41
42
  set: (identifier?: string | import("..").SortByRule, incomingSortDirection?: import("..").SortDirection) => void;
@@ -43,29 +44,21 @@ declare class FinderCore<FItem> {
43
44
  cycleSortDirection: () => void;
44
45
  toggleSortDirection: () => void;
45
46
  reset(): void;
46
- activeRule: import("..").SortByRule<unknown> | undefined;
47
+ activeRule: import("..").SortByRule<unknown, any> | undefined;
47
48
  sortDirection: import("..").SortDirection;
48
49
  userHasSetSortDirection: boolean;
49
- rules: import("..").SortByRule<unknown>[];
50
+ rules: import("..").SortByRule<unknown, any>[];
50
51
  };
51
52
  get groupBy(): {
52
- set: (identifier?: import("..").GroupByRule | string) => void;
53
+ set: (identifier?: string | import("..").GroupByRule) => void;
53
54
  toggle: (identifier: import("..").GroupByRule | string) => void;
54
55
  setGroupIdSortDirection: (direction?: import("..").SortDirection) => void;
55
56
  reset: () => void;
56
- activeRule: import("..").GroupByRule<unknown> | undefined;
57
+ activeRule: import("..").GroupByRule<unknown, any> | undefined;
57
58
  requireGroup: boolean;
58
- rules: import("..").GroupByRule<unknown>[];
59
+ rules: import("..").GroupByRule<unknown, any>[];
59
60
  groupIdSortDirection: import("..").SortDirection | undefined;
60
61
  };
61
- get meta(): {
62
- set: (metaIdentifier: any, value: any) => void;
63
- delete: (metaIdentifier: any) => void;
64
- reset: () => void;
65
- value: Record<string, any>;
66
- get: (metaIdentifier: any) => any;
67
- has: (metaIdentifier: any) => boolean;
68
- };
69
62
  get pagination(): {
70
63
  setPage: (value: number) => void;
71
64
  setNumItemsPerPage: (value?: number) => void;
@@ -76,33 +69,18 @@ declare class FinderCore<FItem> {
76
69
  lastPage: number | undefined;
77
70
  isPaginated: boolean;
78
71
  };
79
- get selectedItems(): {
80
- setMaxSelectedItems: (value?: number) => void;
81
- select: (item: FItem) => void;
82
- selectOnly: (item: FItem) => void;
83
- delete: (item: FItem) => void;
84
- toggle: (item: FItem) => void;
85
- toggleOnly: (item: FItem) => void;
86
- reset: () => void;
87
- items: FItem[];
88
- maxSelectedItems: number | undefined;
89
- isSelected: (item: FItem) => boolean;
90
- };
91
- get layout(): {
92
- set: (identifier: string | import("..").LayoutVariant | undefined) => void;
93
- reset: () => void;
94
- variants: import("..").LayoutVariant[];
95
- activeLayout: import("..").LayoutVariant | undefined;
96
- raw: import("..").LayoutVariant | undefined;
97
- is: (identifier: string | import("..").LayoutVariant | undefined) => boolean;
98
- };
99
72
  get events(): {
100
73
  on: (event: FinderEventName, callback: EventCallback) => void;
101
74
  off: (event: FinderEventName, callback: EventCallback) => void;
75
+ silently: (callback: EventCallback) => void;
76
+ isSilent: () => boolean;
102
77
  };
78
+ getRule<Rule>(identifier: string | FinderRule<FItem>): Rule;
103
79
  get state(): "loading" | "empty" | "groups" | "items" | "noMatches";
104
80
  setItems(items: FItem[] | null | undefined): void;
105
81
  setIsLoading(value?: boolean): void;
106
82
  setIsDisabled(value?: boolean): void;
83
+ setRules(definitions: FinderRule<FItem, FContext>[]): void;
84
+ setContext(context: FContext): void;
107
85
  }
108
86
  export { FinderCore };
@@ -2,20 +2,20 @@ import { GroupByMixin } from "./group-by";
2
2
  /**
3
3
  * Public surface for the Group By mixin
4
4
  */
5
- declare function readonlyGroupByInterface<FItem>(mixin: GroupByMixin<FItem>): {
6
- activeRule: import("../..").GroupByRule<unknown> | undefined;
5
+ declare function readonlyGroupByInterface<FItem, FContext>(mixin: GroupByMixin<FItem, FContext>): {
6
+ activeRule: import("../..").GroupByRule<unknown, any> | undefined;
7
7
  requireGroup: boolean;
8
- rules: import("../..").GroupByRule<unknown>[];
8
+ rules: import("../..").GroupByRule<unknown, any>[];
9
9
  groupIdSortDirection: import("../..").SortDirection | undefined;
10
10
  };
11
- declare function groupByInterface<FItem>(mixin: GroupByMixin<FItem>): {
12
- set: (identifier?: import("../..").GroupByRule | string) => void;
11
+ declare function groupByInterface<FItem, FContext>(mixin: GroupByMixin<FItem, FContext>): {
12
+ set: (identifier?: string | import("../..").GroupByRule) => void;
13
13
  toggle: (identifier: import("../..").GroupByRule | string) => void;
14
14
  setGroupIdSortDirection: (direction?: import("../..").SortDirection) => void;
15
15
  reset: () => void;
16
- activeRule: import("../..").GroupByRule<unknown> | undefined;
16
+ activeRule: import("../..").GroupByRule<unknown, any> | undefined;
17
17
  requireGroup: boolean;
18
- rules: import("../..").GroupByRule<unknown>[];
18
+ rules: import("../..").GroupByRule<unknown, any>[];
19
19
  groupIdSortDirection: import("../..").SortDirection | undefined;
20
20
  };
21
21
  export { readonlyGroupByInterface, groupByInterface };
@@ -1,20 +1,22 @@
1
- import { GroupByRule, FinderResultGroup, SortDirection, MetaInterface } from "../../types";
2
- import { MixinInjectedDependencies } from "../types/internal-types";
3
- type InitialValues = {
1
+ import { GroupByRule } from "../types/rule-types";
2
+ import { FinderResultGroup, MixinInjectedDependencies, SerializedGroupByMixin, SortDirection } from "../types/core-types";
3
+ interface InitialValues {
4
4
  initialGroupBy: string | undefined;
5
5
  requireGroup: boolean;
6
- };
7
- declare class GroupByMixin<FItem> {
6
+ }
7
+ declare class GroupByMixin<FItem, FContext> {
8
8
  #private;
9
9
  requireGroup: boolean;
10
10
  groupIdSortDirection?: SortDirection;
11
- constructor({ initialGroupBy, requireGroup }: InitialValues, deps: MixinInjectedDependencies<FItem>);
12
- get rules(): GroupByRule<unknown>[];
13
- get activeRule(): GroupByRule<unknown> | undefined;
14
- set(identifier?: GroupByRule | string): void;
11
+ constructor({ initialGroupBy, requireGroup }: InitialValues, deps: MixinInjectedDependencies<FItem, FContext>);
12
+ get rules(): GroupByRule<unknown, any>[];
13
+ get activeRule(): GroupByRule<unknown, any> | undefined;
14
+ get hasGroupByRule(): boolean;
15
+ set(identifier?: string | GroupByRule): void;
15
16
  setGroupIdSortDirection(direction?: SortDirection): void;
16
17
  toggle(identifier: GroupByRule | string): void;
17
18
  reset(): void;
18
- process(items: FItem[], meta: MetaInterface): FinderResultGroup<FItem>[];
19
+ serialize(): SerializedGroupByMixin;
20
+ static process<FItem, FContext>(options: SerializedGroupByMixin, items: FItem[], context?: FContext): FinderResultGroup<FItem>[];
19
21
  }
20
22
  export { GroupByMixin };
@@ -1,8 +1,8 @@
1
- import { MixinInjectedDependencies } from "../types/internal-types";
2
- type InitialValues = {
1
+ import { MixinInjectedDependencies, SerializedPaginationMixin } from "../types/core-types";
2
+ interface InitialValues {
3
3
  page: number | undefined;
4
4
  numItemsPerPage: number | undefined;
5
- };
5
+ }
6
6
  declare class PaginationMixin<FItem> {
7
7
  #private;
8
8
  numItemsPerPage?: number;
@@ -13,6 +13,7 @@ declare class PaginationMixin<FItem> {
13
13
  get numTotalItems(): number;
14
14
  get page(): number;
15
15
  get offset(): number;
16
- process(items: FItem[]): FItem[];
16
+ serialize(): SerializedPaginationMixin;
17
+ static process<FItem>(options: SerializedPaginationMixin, items: FItem[]): FItem[];
17
18
  }
18
19
  export { PaginationMixin };
@@ -0,0 +1,14 @@
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<FItem, FContext>(items: FItem[], context: FContext): void;
10
+ getRule<Rule>(identifier: string | FinderRule): Rule | undefined;
11
+ getDefinitions(): FinderRule<FItem>[];
12
+ setRules(definitions: FinderRule<FItem>[]): void;
13
+ static validateDefinitions(definitions: FinderRule[]): boolean;
14
+ }
@@ -1,2 +1 @@
1
- import { Haystack } from "../haystack";
2
- export declare function calculateSequentialCharacterIndexes(haystack: Haystack, needle: string): number[] | undefined;
1
+ export declare function calculateSequentialCharacterIndexes(haystack: string, needle: string): number[] | undefined;
@@ -1,2 +1 @@
1
- import { Haystack } from "../haystack";
2
- export declare function calculateSequentialStringCharacterIndexes(haystack: Haystack, needle: string): number[] | undefined;
1
+ export declare function calculateSequentialStringCharacterIndexes(haystack: string, needle: string): number[] | undefined;
@@ -1,4 +1,4 @@
1
- export declare class Haystack {
1
+ export declare class ResultSegmentHaystack {
2
2
  #private;
3
3
  source: string;
4
4
  transformed: string;
@@ -1,4 +1,3 @@
1
- import { Haystack } from "../haystack";
2
1
  /**
3
2
  * Internal type used to prepare the result segment. These values all point to the transformed haystack.
4
3
  */
@@ -11,8 +10,8 @@ export interface ResultSegmentInternal {
11
10
  _internal: true;
12
11
  }
13
12
  /**
14
- * Consumabel type ready for use. All values are mapped to the haystack source.
13
+ * Consumable type ready for use. All values are mapped to the haystack source.
15
14
  */
16
15
  export interface ResultSegment extends Omit<ResultSegmentInternal, "_internal"> {
17
16
  }
18
- export type SearchCharacterIndexFn = (haystack: Haystack, needle: string) => number[] | undefined;
17
+ export type SearchCharacterIndexFn = (haystack: string, needle: string) => number[] | undefined;
@@ -1,17 +1,9 @@
1
- import { ResultSegment, SearchCharacterIndexFn } from "./result-segment-types";
1
+ import { ResultSegment } from "./result-segment-types";
2
2
  /**
3
3
  * Helper function to determine which specfic characters are matched inside a string.
4
4
  */
5
- export declare function getSearchResultSegments(characterIndexFn: SearchCharacterIndexFn, haystack: string, needle: string, aliases?: string[] | null): ResultSegment[] | undefined;
5
+ export declare function getSearchResultSegments(haystack: string | string[], needle: string): ResultSegment[] | undefined;
6
6
  /**
7
7
  * Determine if a characterIndexFn would return a result for a haystack.
8
8
  */
9
- export declare function hasCharacterIndexMatches(characterIndexFn: SearchCharacterIndexFn, haystack: string, needle: string, aliases?: string[] | null): boolean;
10
- /**
11
- * Ensure haystacks and needles are formatted consistently.
12
- *
13
- * Transforming includes:
14
- * 1. Convert to lowercase.
15
- * 2. Strip all non-word and non-digit characters.
16
- */
17
- export declare function transformStringForComparison(value: string): string;
9
+ export declare function hasCharacterIndexMatches(haystack: string | string[], needle: string, exact?: boolean): boolean;
@@ -1,14 +1,15 @@
1
1
  import { SearchMixin } from "./search";
2
2
  declare function readonlySearchInterface<FItem>(mixin: SearchMixin<FItem>): {
3
3
  searchTerm: string;
4
- activeRule: import("../..").SearchRule<unknown> | undefined;
5
4
  hasSearchTerm: boolean;
5
+ hasSearchRule: boolean;
6
6
  };
7
7
  declare function searchInterface<FItem>(mixin: SearchMixin<FItem>): {
8
8
  setSearchTerm: (incomingSearchTerm: string) => void;
9
9
  reset: () => void;
10
+ test: (searchTerm: string, isAdditive?: boolean) => FItem[];
10
11
  searchTerm: string;
11
- activeRule: import("../..").SearchRule<unknown> | undefined;
12
12
  hasSearchTerm: boolean;
13
+ hasSearchRule: boolean;
13
14
  };
14
15
  export { readonlySearchInterface, searchInterface };
@@ -0,0 +1,4 @@
1
+ export declare function calculateSearchScore(indexes: number[], haystack: string): {
2
+ percentOfHaystackMatched: number;
3
+ longestSequentialSequence: number;
4
+ };
@@ -0,0 +1,8 @@
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,16 +1,18 @@
1
- import { MetaInterface } from "../../types";
2
- import { MixinInjectedDependencies } from "../types/internal-types";
1
+ import { MixinInjectedDependencies, SerializedSearchMixin } from "../types/core-types";
3
2
  type InitialValues = {
4
3
  initialSearchTerm: string | undefined;
5
4
  };
6
5
  declare class SearchMixin<FItem> {
7
6
  #private;
7
+ searchTerm: string;
8
8
  constructor({ initialSearchTerm }: InitialValues, deps: MixinInjectedDependencies<FItem>);
9
- get searchTerm(): string;
10
- get rule(): import("../..").SearchRule<unknown> | undefined;
9
+ get rule(): import("../..").SearchRule<unknown, any> | undefined;
11
10
  get hasSearchRule(): boolean;
11
+ get hasSearchTerm(): boolean;
12
12
  setSearchTerm(incomingSearchTerm: string): void;
13
13
  reset(): void;
14
- process(items: FItem[], meta: MetaInterface): FItem[];
14
+ serialize(): SerializedSearchMixin;
15
+ test(searchTerm: string, isAdditive?: boolean): FItem[];
16
+ static process<FItem, FContext>(options: SerializedSearchMixin, items: FItem[], context?: FContext): FItem[];
15
17
  }
16
18
  export { SearchMixin };
@@ -1,13 +1,13 @@
1
- import { SortDirection } from "../../types";
1
+ import { SortDirection } from "../types/core-types";
2
2
  import { SortByMixin } from "./sort-by";
3
3
  /**
4
4
  * Public surface for the SortBy mixin
5
5
  */
6
6
  declare function readonlySortByInterface<FItem>(mixin: SortByMixin<FItem>): {
7
- activeRule: import("../..").SortByRule<unknown> | undefined;
7
+ activeRule: import("../..").SortByRule<unknown, any> | undefined;
8
8
  sortDirection: SortDirection;
9
9
  userHasSetSortDirection: boolean;
10
- rules: import("../..").SortByRule<unknown>[];
10
+ rules: import("../..").SortByRule<unknown, any>[];
11
11
  };
12
12
  declare function sortByInterface<FItem>(mixin: SortByMixin<FItem>): {
13
13
  set: (identifier?: string | import("../..").SortByRule, incomingSortDirection?: SortDirection) => void;
@@ -15,9 +15,9 @@ declare function sortByInterface<FItem>(mixin: SortByMixin<FItem>): {
15
15
  cycleSortDirection: () => void;
16
16
  toggleSortDirection: () => void;
17
17
  reset(): void;
18
- activeRule: import("../..").SortByRule<unknown> | undefined;
18
+ activeRule: import("../..").SortByRule<unknown, any> | undefined;
19
19
  sortDirection: SortDirection;
20
20
  userHasSetSortDirection: boolean;
21
- rules: import("../..").SortByRule<unknown>[];
21
+ rules: import("../..").SortByRule<unknown, any>[];
22
22
  };
23
23
  export { readonlySortByInterface, sortByInterface };
@@ -1,5 +1,5 @@
1
- import { SortByRule, SortDirection } from "../../types";
2
- import { MixinInjectedDependencies } from "../types/internal-types";
1
+ import { SortByRule } from "../types/rule-types";
2
+ import { MixinInjectedDependencies, SerializedSortByMixin, SortDirection } from "../types/core-types";
3
3
  type InitialValues = {
4
4
  initialSortBy: string | undefined;
5
5
  initialSortDirection?: SortDirection;
@@ -7,12 +7,13 @@ type InitialValues = {
7
7
  declare class SortByMixin<FItem> {
8
8
  #private;
9
9
  constructor({ initialSortBy, initialSortDirection }: InitialValues, deps: MixinInjectedDependencies<FItem>);
10
- get rules(): SortByRule<unknown>[];
11
- get activeRule(): SortByRule<unknown> | undefined;
10
+ get rules(): SortByRule<unknown, any>[];
11
+ get activeRule(): SortByRule<unknown, any> | undefined;
12
12
  get sortDirection(): SortDirection;
13
13
  get userHasSetSortDirection(): boolean;
14
14
  setSortDirection(incomingSortDirection?: SortDirection): void;
15
15
  set(identifier?: string | SortByRule, incomingSortDirection?: SortDirection): void;
16
- process(items: FItem[]): FItem[];
16
+ serialize(): SerializedSortByMixin;
17
+ static process<FItem, FContext>(options: SerializedSortByMixin, items: FItem[], context: FContext): FItem[];
17
18
  }
18
19
  export { SortByMixin };
@@ -0,0 +1,8 @@
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
+ }
@@ -0,0 +1,92 @@
1
+ import { DebounceCallbackRegistry } from "../debounce-callback-registry/debounce-callback-registry";
2
+ import { readonlyFiltersInterface } from "../filters/filters-interface";
3
+ import { readonlyGroupByInterface } from "../group-by/group-by-interface";
4
+ import { RuleBook } from "../rule-book/rule-book";
5
+ import { readonlySearchInterface } from "../search/search-interface";
6
+ import { readonlySortByInterface } from "../sort-by/sort-by-interface";
7
+ import { RuleEffect, SearchEffect } from "./effect-types";
8
+ import { FinderOnChangeCallback, FinderOnFirstUserInteractCallback, FinderOnInitCallback, FinderOnReadyCallback, FinderTouchCallback } from "./event-types";
9
+ import { FinderRule, GroupByRule, HydratedFilterRule, SearchRule, SortByRule } from "./rule-types";
10
+ export interface FinderConstructorOptions<FItem, FContext = any> {
11
+ rules: FinderRule<FItem>[];
12
+ effects?: (RuleEffect | SearchEffect)[];
13
+ context?: FContext;
14
+ isLoading?: boolean;
15
+ disabled?: boolean;
16
+ initialSearchTerm?: string;
17
+ initialSortBy?: string;
18
+ initialSortDirection?: SortDirection;
19
+ initialGroupBy?: string;
20
+ initialFilters?: Record<string, any>;
21
+ ignoreSortByRulesWhileSearchRuleIsActive?: boolean;
22
+ requireGroup?: boolean;
23
+ page?: number;
24
+ numItemsPerPage?: number;
25
+ onInit?: FinderOnInitCallback;
26
+ onReady?: FinderOnReadyCallback;
27
+ onFirstUserInteraction?: FinderOnFirstUserInteractCallback;
28
+ onChange?: FinderOnChangeCallback;
29
+ }
30
+ export interface FinderResultGroup<FItem> {
31
+ id: string;
32
+ items: FItem[];
33
+ }
34
+ export type SortDirection = "asc" | "desc" | ("asc" | "desc")[];
35
+ export interface ResultSnapshot<FItem> {
36
+ items?: FItem[];
37
+ groups?: FinderResultGroup<FItem>[];
38
+ numMatchedItems: number;
39
+ numTotalItems: number;
40
+ hasGroupByRule: boolean;
41
+ }
42
+ export interface FinderSnapshot<FItem, FContext = any> {
43
+ search: ReturnType<typeof readonlySearchInterface<FItem>>;
44
+ filters: ReturnType<typeof readonlyFiltersInterface>;
45
+ sortBy: ReturnType<typeof readonlySortByInterface<FItem>>;
46
+ groupBy: ReturnType<typeof readonlyGroupByInterface<FItem, FContext>>;
47
+ context?: FContext;
48
+ updatedAt?: number;
49
+ }
50
+ export interface MixinInjectedDependencies<FItem = any, FContext = any> {
51
+ isLoading: () => boolean;
52
+ isDisabled: () => boolean;
53
+ getRuleBook: () => RuleBook<FItem, FContext>;
54
+ touch: FinderTouchCallback;
55
+ getContext: () => any;
56
+ getItems: () => FItem[];
57
+ test: (serializedMixins: SnapshotSerializedMixins, isAdditive?: boolean) => FItem[];
58
+ debouncer: DebounceCallbackRegistry;
59
+ }
60
+ export type EventCallback = (payload?: any) => void;
61
+ export interface SnapshotOptions<FItem, FContext> {
62
+ items: FItem[];
63
+ context: FContext;
64
+ mixins: SnapshotSerializedMixins;
65
+ }
66
+ export interface SnapshotSerializedMixins {
67
+ search?: SerializedSearchMixin;
68
+ filters?: SerializedFiltersMixin;
69
+ sortBy?: SerializedSortByMixin;
70
+ pagination?: SerializedPaginationMixin;
71
+ groupBy?: SerializedGroupByMixin;
72
+ }
73
+ export interface SerializedSearchMixin {
74
+ searchTerm: string;
75
+ rule?: SearchRule;
76
+ }
77
+ export interface SerializedFiltersMixin {
78
+ rules: HydratedFilterRule[];
79
+ values: Record<string, any>;
80
+ }
81
+ export interface SerializedSortByMixin {
82
+ rule?: SortByRule;
83
+ sortDirection?: SortDirection;
84
+ }
85
+ export interface SerializedPaginationMixin {
86
+ page: number;
87
+ numItemsPerPage?: number;
88
+ }
89
+ export interface SerializedGroupByMixin {
90
+ rule?: GroupByRule;
91
+ sortDirection?: SortDirection;
92
+ }