@hitgrab/finder 0.1.18-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 (64) 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__/json.test.d.ts +0 -1
  12. package/dist/core/__tests__/pagination.test.d.ts +0 -1
  13. package/dist/core/__tests__/search.test.d.ts +0 -1
  14. package/dist/core/__tests__/sort-by.test.d.ts +0 -1
  15. package/dist/core/__tests__/test-constants.d.ts +0 -5
  16. package/dist/core/__tests__/test-types.d.ts +0 -6
  17. package/dist/core/__tests__/utils.test.d.ts +0 -1
  18. package/dist/core/core-constants.d.ts +0 -50
  19. package/dist/core/debounce-callback-registry.d.ts +0 -3
  20. package/dist/core/effect-book.d.ts +0 -12
  21. package/dist/core/event-emitter.d.ts +0 -12
  22. package/dist/core/filters.d.ts +0 -29
  23. package/dist/core/finder-core-implementation.d.ts +0 -45
  24. package/dist/core/finder-core.d.ts +0 -101
  25. package/dist/core/finder-error.d.ts +0 -3
  26. package/dist/core/group-by.d.ts +0 -25
  27. package/dist/core/pagination.d.ts +0 -19
  28. package/dist/core/rule-book/boolean-filter-handler.d.ts +0 -11
  29. package/dist/core/rule-book/filter-handler.d.ts +0 -29
  30. package/dist/core/rule-book/multiple-filter-handler.d.ts +0 -11
  31. package/dist/core/rule-book/rule-book.d.ts +0 -14
  32. package/dist/core/rule-book/single-filter-handler.d.ts +0 -11
  33. package/dist/core/search/calculate-character-match-indexes.d.ts +0 -1
  34. package/dist/core/search/calculate-string-match-segments.d.ts +0 -9
  35. package/dist/core/search/default-search-and-sort-algorithm.d.ts +0 -2
  36. package/dist/core/search/search-score.d.ts +0 -4
  37. package/dist/core/search/search-string-transform.d.ts +0 -8
  38. package/dist/core/search/string-match-haystack.d.ts +0 -15
  39. package/dist/core/search.d.ts +0 -18
  40. package/dist/core/sort-by.d.ts +0 -23
  41. package/dist/core/tester.d.ts +0 -8
  42. package/dist/core/types/core-types.d.ts +0 -90
  43. package/dist/core/types/effect-types.d.ts +0 -20
  44. package/dist/core/types/event-types.d.ts +0 -44
  45. package/dist/core/types/rule-types.d.ts +0 -89
  46. package/dist/core/types/string-match-types.d.ts +0 -10
  47. package/dist/core/utils/rule-type-enforcers.d.ts +0 -18
  48. package/dist/core/utils/rule-utils.d.ts +0 -14
  49. package/dist/index.d.ts +0 -13
  50. package/dist/index.js +0 -5133
  51. package/dist/index.umd.cjs +0 -27
  52. package/dist/react/components/finder-content-empty.d.ts +0 -7
  53. package/dist/react/components/finder-content-groups.d.ts +0 -7
  54. package/dist/react/components/finder-content-items.d.ts +0 -7
  55. package/dist/react/components/finder-content-loading.d.ts +0 -7
  56. package/dist/react/components/finder-content-no-matches.d.ts +0 -7
  57. package/dist/react/components/finder-content.d.ts +0 -25
  58. package/dist/react/components/finder-search-term-haystack.d.ts +0 -8
  59. package/dist/react/components/finder.d.ts +0 -9
  60. package/dist/react/components/string-match.d.ts +0 -12
  61. package/dist/react/hooks/use-finder-ref.d.ts +0 -2
  62. package/dist/react/hooks/use-finder.d.ts +0 -3
  63. package/dist/react/providers/finder-core-context.d.ts +0 -3
  64. package/dist/react/types/react-types.d.ts +0 -41
@@ -1,20 +0,0 @@
1
- import { FinderCore } from "../finder-core";
2
- import { RuleDefinition } from "./rule-types";
3
- export interface RuleEffect<FItem = any, FContext = any> {
4
- rules: string | RuleDefinition<FItem> | (string | RuleDefinition<FItem>)[] | ((items: FItem[], context: FContext) => string | RuleDefinition<FItem> | (string | RuleDefinition<FItem>)[]);
5
- onChange: (instance: FinderCore<FItem, FContext>, rule: RuleDefinition<FItem>) => void;
6
- }
7
- export interface HydratedRuleEffect<FItem = any, FContext = any> {
8
- rules: (string | RuleDefinition<FItem>)[];
9
- onChange: (instance: FinderCore<FItem, FContext>, rule: RuleDefinition<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
- }
@@ -1,44 +0,0 @@
1
- import { EVENT_SOURCE, EVENTS } from "../core-constants";
2
- import { FinderCore } from "../finder-core";
3
- import { RuleDefinition } from "./rule-types";
4
- export type FinderTouchSource = (typeof EVENT_SOURCE)[keyof typeof EVENT_SOURCE];
5
- interface FinderSharedEventProps {
6
- source: string;
7
- event: FinderEventName;
8
- timestamp: number;
9
- instance: FinderCore;
10
- }
11
- export interface FinderInitEvent extends FinderSharedEventProps {
12
- source: "core";
13
- event: "init";
14
- }
15
- export interface FinderFirstUserInteractionEvent extends FinderSharedEventProps {
16
- source: "core";
17
- event: "firstUserInteraction";
18
- }
19
- export interface FinderReadyEvent extends FinderSharedEventProps {
20
- source: "core";
21
- event: "ready";
22
- }
23
- export type FinderEvent = FinderInitEvent | FinderFirstUserInteractionEvent | FinderReadyEvent | FinderChangeEvent;
24
- export type FinderOnInitCallback = (event: FinderInitEvent) => void;
25
- export type FinderOnReadyCallback = (event: FinderReadyEvent) => void;
26
- export type FinderOnFirstUserInteractCallback = (event: FinderFirstUserInteractionEvent) => void;
27
- export type FinderOnChangeCallback = (event: FinderChangeEvent) => void;
28
- export type FinderTouchCallback = (event: FinderTouchEvent) => void;
29
- /**
30
- * Internal communication between mixins and core
31
- */
32
- export interface FinderTouchEvent {
33
- source: FinderTouchSource;
34
- event: FinderEventName;
35
- current: any;
36
- initial: any;
37
- rule?: RuleDefinition;
38
- }
39
- /**
40
- * External type that consumers will receive
41
- */
42
- export type FinderChangeEvent = FinderTouchEvent & FinderSharedEventProps;
43
- export type FinderEventName = (typeof EVENTS)[keyof typeof EVENTS];
44
- export {};
@@ -1,89 +0,0 @@
1
- import { FinderResultGroup, SortDirection } from "./core-types";
2
- /**
3
- * Select a property from the item to sort by.
4
- */
5
- export type FinderPropertySelector<FItem, FContext = any> = (item: FItem, context: FContext) => string | number;
6
- interface Rule {
7
- id: string;
8
- debounceMilliseconds?: number;
9
- label?: string;
10
- hidden?: boolean;
11
- }
12
- export type RuleDefinition<FItem = any, FContext = any> = SearchRuleDefinition<FItem, FContext> | FilterRuleDefinition<FItem, FContext> | SortByRuleDefinition<FItem, FContext> | GroupByRuleDefinition<FItem, FContext>;
13
- export interface SearchRuleDefinition<FItem = any, FContext = any> extends Omit<Rule, "id"> {
14
- id?: string;
15
- searchFn?: (item: FItem, context: FContext) => string | string[];
16
- }
17
- /**
18
- * Describes the display of a filter or sort option.
19
- */
20
- export interface FilterOption<FValue = any> {
21
- label?: string;
22
- value: FValue;
23
- disabled?: boolean;
24
- }
25
- export interface FilterRuleDefinition<FItem = any, FValue = any, FContext = any> extends Rule {
26
- filterFn: (item: FItem, value: FValue, context: FContext) => boolean;
27
- required?: boolean;
28
- strictOptions?: boolean;
29
- multiple?: boolean;
30
- boolean?: boolean;
31
- options?: FilterOption<FValue>[] | ((options: {
32
- items: FItem[];
33
- context: FContext;
34
- }) => FilterOption<FValue>[]);
35
- }
36
- export type AnyFilterRuleDefinition<FItem = any, FValue = any> = Omit<FilterRuleDefinition<FItem, FValue>, "options">;
37
- export interface FilterRuleWithBooleanValue<FItem = any, FValue = boolean, FContext = any> extends FilterRuleDefinition<FItem, FValue, FContext> {
38
- multiple?: false;
39
- boolean: true;
40
- defaultValue?: boolean;
41
- options?: never;
42
- }
43
- export interface FilterRuleWithSingleValue<FItem = any, FValue = any, FContext = any> extends FilterRuleDefinition<FItem, FValue, FContext> {
44
- multiple?: false;
45
- boolean?: false;
46
- defaultValue?: FValue;
47
- }
48
- export interface FilterRuleWithMultipleValues<FItem = any, FValue = any, FContext = any> extends FilterRuleDefinition<FItem, FValue, FContext> {
49
- multiple: true;
50
- boolean?: false;
51
- defaultValue?: FValue[];
52
- }
53
- /**
54
- * A hydrated filter has rendered any option generator functions, and narrowed ambiguous properties from FilterRule.
55
- */
56
- export interface HydratedFilterRuleDefinition<FItem = any, FValue = any, FContext = any> extends FilterRuleDefinition<FItem, FValue, FContext> {
57
- options?: FilterOption<FValue>[];
58
- multiple: boolean;
59
- boolean: boolean;
60
- _isHydrated: true;
61
- }
62
- export interface SortByRuleDefinition<FItem = any, FContext = any> extends Rule {
63
- sortFn: FinderPropertySelector<FItem, FContext> | FinderPropertySelector<FItem, FContext>[];
64
- defaultSortDirection?: SortDirection;
65
- }
66
- export interface GroupByRuleDefinition<FItem = any, FContext = any> extends Rule {
67
- groupFn: FinderPropertySelector<FItem, FContext>;
68
- sortGroupFn?: FinderPropertySelector<FinderResultGroup<FItem>, FContext>;
69
- defaultGroupSortDirection?: SortDirection;
70
- sticky?: {
71
- header?: string | string[];
72
- footer?: string | string[];
73
- };
74
- }
75
- export interface SearchTestOptions {
76
- rule: SearchRuleDefinition[];
77
- searchTerm: string;
78
- }
79
- export interface FilterTestOptions {
80
- rules: HydratedFilterRuleDefinition[];
81
- values?: Record<string, any>;
82
- isAdditive?: boolean;
83
- }
84
- export interface FilterTestRuleOptions {
85
- rule: string | AnyFilterRuleDefinition;
86
- value: any;
87
- isAdditive?: boolean;
88
- }
89
- export {};
@@ -1,10 +0,0 @@
1
- /**
2
- * These values all point to the transformed haystack.
3
- */
4
- export interface StringMatchSegment {
5
- index: number;
6
- length: number;
7
- is_match: boolean;
8
- value: string;
9
- }
10
- export type SearchCharacterIndexFn = (haystack: string, needle: string) => number[] | undefined;
@@ -1,18 +0,0 @@
1
- import { FinderCore } from "../finder-core";
2
- import { RuleEffect, SearchEffect } from "../types/effect-types";
3
- import { FilterRuleWithBooleanValue, FilterRuleWithMultipleValues, FilterRuleWithSingleValue, RuleDefinition, GroupByRuleDefinition, SearchRuleDefinition, SortByRuleDefinition, AnyFilterRuleDefinition } from "../types/rule-types";
4
- /**
5
- * Enforce structure for an array of rule of mixed types.
6
- */
7
- export declare function finderRuleset<FItem, FContext = any>(rules: RuleDefinition<FItem, FContext>[]): RuleDefinition<FItem, FContext>[];
8
- export declare function searchRule<FItem, FContext = any>(rule: SearchRuleDefinition<FItem, FContext>): SearchRuleDefinition<FItem, FContext>;
9
- export declare function filterRule<FItem, FValue = any, FContext = any, T = FilterRuleWithMultipleValues<FItem, FValue, FContext>>(rule: T): FilterRuleWithMultipleValues<FItem, FValue>;
10
- export declare function filterRule<FItem, FValue = boolean, FContext = any, T = FilterRuleWithBooleanValue<FItem, FValue, FContext>>(rule: T): FilterRuleWithBooleanValue<FItem, FValue>;
11
- export declare function filterRule<FItem, FValue = any, FContext = any, T = FilterRuleWithSingleValue<FItem, FValue, FContext>>(rule: T): FilterRuleWithSingleValue<FItem, FValue>;
12
- export declare function sortByRule<FItem, FContext = any>(rule: SortByRuleDefinition<FItem, FContext>): SortByRuleDefinition<FItem, FContext>;
13
- export declare function groupByRule<FItem, FContext = any>(rule: GroupByRuleDefinition<FItem, FContext>): GroupByRuleDefinition<FItem, FContext>;
14
- export declare function ruleEffect<FItem, FContext = any>(rules: string | RuleDefinition<FItem> | (string | RuleDefinition<FItem>)[] | ((items: FItem[], context: FContext) => string | RuleDefinition<FItem> | (string | RuleDefinition<FItem>)[]), onChange: (instance: FinderCore<FItem, FContext>, rule: RuleDefinition) => void): RuleEffect<FItem, FContext>;
15
- export declare function searchEffect<FItem, FContext = any>(haystack: string | string[] | ((items: FItem[], context: FContext) => string | string[]), onChange: (instance: FinderCore<FItem, FContext>, searchTerm: string) => void): SearchEffect<FItem, FContext>;
16
- export declare function transformFilterToSingleValue<FItem, FValue, FContext = any>(filter: AnyFilterRuleDefinition<FItem, FValue>): FilterRuleWithMultipleValues<FItem, FValue, FContext>;
17
- export declare function transformFilterToBoolean<FItem, FValue, FContext = any>(filter: AnyFilterRuleDefinition<FItem, FValue>): FilterRuleWithBooleanValue<FItem, boolean, FContext>;
18
- export declare function transformFilterToMultiple<FItem, FValue, FContext = any>(filter: AnyFilterRuleDefinition<FItem, FValue>): FilterRuleWithMultipleValues<FItem, FValue, FContext>;
@@ -1,14 +0,0 @@
1
- import { RuleEffect, SearchEffect } from "../types/effect-types";
2
- import { FilterRuleWithBooleanValue, FilterRuleWithMultipleValues, FilterRuleWithSingleValue, GroupByRuleDefinition, HydratedFilterRuleDefinition, SearchRuleDefinition, SortByRuleDefinition } from "../types/rule-types";
3
- type FilterRuleUnion<FItem> = FilterRuleWithSingleValue<FItem> | FilterRuleWithMultipleValues<FItem> | FilterRuleWithBooleanValue<FItem>;
4
- export declare function isSortByRuleDefinition<FItem>(rule: unknown): rule is SortByRuleDefinition<FItem>;
5
- export declare function isSearchRuleDefinition<FItem>(rule: unknown): rule is SearchRuleDefinition<FItem>;
6
- export declare function isFilterRuleDefinition<FItem>(rule: unknown): rule is FilterRuleUnion<FItem>;
7
- export declare function isFilterRuleDefinitionWithHydratedOptions(rule: unknown): rule is HydratedFilterRuleDefinition;
8
- export declare function isGroupByRuleDefinition<FItem>(rule: unknown): rule is GroupByRuleDefinition<FItem>;
9
- export declare function isRuleEffectDefinition<FItem>(data: unknown): data is RuleEffect<FItem>;
10
- export declare function isSearchEffectDefinition<FItem>(data: unknown): data is SearchEffect<FItem>;
11
- export declare function isBooleanFilterRuleDefinition<FItem>(rule: unknown): rule is FilterRuleWithBooleanValue<FItem>;
12
- export declare function isMultipleValueFilterRuleDefinition<FItem>(rule: unknown): rule is FilterRuleWithMultipleValues<FItem>;
13
- export declare function isSingleValueFilterRuleDefinition<FItem>(rule: unknown): rule is FilterRuleWithSingleValue<FItem>;
14
- export {};
package/dist/index.d.ts DELETED
@@ -1,13 +0,0 @@
1
- export type { FinderConstructorOptions, FinderResultGroup, SortDirection } from "./core/types/core-types";
2
- export { finderRuleset, searchRule, filterRule, sortByRule, groupByRule, ruleEffect, searchEffect, transformFilterToSingleValue, transformFilterToMultiple, transformFilterToBoolean, } from "./core/utils/rule-type-enforcers";
3
- export type { SearchRuleDefinition, SortByRuleDefinition, GroupByRuleDefinition, FilterRuleDefinition, FilterOption, AnyFilterRuleDefinition, } from "./core/types/rule-types";
4
- export type { RuleEffect, SearchEffect } from "./core/types/effect-types";
5
- export type { FinderEvent, FinderInitEvent, FinderReadyEvent, FinderFirstUserInteractionEvent, FinderChangeEvent } from "./core/types/event-types";
6
- /**
7
- * React hooks and components
8
- */
9
- export { useFinder } from "./react/hooks/use-finder";
10
- export { Finder } from "./react/components/finder";
11
- export { useFinderRef } from "./react/hooks/use-finder-ref";
12
- export { StringMatch } from "./react/components/string-match";
13
- export type { FinderProps, FinderContentProps, StringMatchSegmentProps } from "./react/types/react-types";