@hitgrab/finder 0.1.0-alpha → 0.1.4-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 (46) hide show
  1. package/dist/core/__tests__/test-types.d.ts +2 -2
  2. package/dist/core/core-constants.d.ts +39 -0
  3. package/dist/core/effect-book.d.ts +12 -0
  4. package/dist/core/{events/event-emitter.d.ts → event-emitter.d.ts} +2 -2
  5. package/dist/core/filters.d.ts +28 -0
  6. package/dist/core/finder-core-implementation.d.ts +44 -0
  7. package/dist/core/finder-core.d.ts +56 -45
  8. package/dist/core/finder-error.d.ts +3 -0
  9. package/dist/core/{group-by/group-by.d.ts → group-by.d.ts} +6 -5
  10. package/dist/core/{pagination/pagination.d.ts → pagination.d.ts} +1 -1
  11. package/dist/core/{rule-book/rule-book.d.ts → rule-book.d.ts} +3 -3
  12. package/dist/core/search/calculate-character-match-indexes.d.ts +1 -0
  13. package/dist/core/search/{result-segments/search-result-segments.d.ts → calculate-string-match-segments.d.ts} +3 -3
  14. package/dist/core/search/{result-segments/result-segment-haystack.d.ts → string-match-haystack.d.ts} +3 -3
  15. package/dist/core/{search/search.d.ts → search.d.ts} +5 -5
  16. package/dist/core/{sort-by/sort-by.d.ts → sort-by.d.ts} +9 -5
  17. package/dist/core/{tester/tester.d.ts → tester.d.ts} +1 -1
  18. package/dist/core/types/core-types.d.ts +16 -15
  19. package/dist/core/types/effect-types.d.ts +0 -2
  20. package/dist/core/types/event-types.d.ts +5 -4
  21. package/dist/core/types/rule-types.d.ts +8 -12
  22. package/dist/core/types/string-match-types.d.ts +10 -0
  23. package/dist/core/utils/rule-type-enforcers.d.ts +5 -3
  24. package/dist/core/utils/rule-utils.d.ts +2 -4
  25. package/dist/index.d.ts +5 -3
  26. package/dist/index.js +3265 -3196
  27. package/dist/index.umd.cjs +19 -19
  28. package/dist/react/components/finder-search-term-haystack.d.ts +8 -0
  29. package/dist/react/components/finder.d.ts +2 -2
  30. package/dist/react/components/string-match.d.ts +12 -0
  31. package/dist/react/types/react-types.d.ts +8 -5
  32. package/package.json +11 -10
  33. package/dist/core/effect-book/effect-book.d.ts +0 -8
  34. package/dist/core/filters/filters-interface.d.ts +0 -31
  35. package/dist/core/filters/filters.d.ts +0 -28
  36. package/dist/core/group-by/group-by-interface.d.ts +0 -21
  37. package/dist/core/pagination/pagination-interface.d.ts +0 -23
  38. package/dist/core/search/algorithms/sequential-characters.d.ts +0 -1
  39. package/dist/core/search/algorithms/sequential-string.d.ts +0 -1
  40. package/dist/core/search/result-segments/result-segment-types.d.ts +0 -17
  41. package/dist/core/search/search-interface.d.ts +0 -15
  42. package/dist/core/sort-by/sort-by-interface.d.ts +0 -23
  43. package/dist/core/utils/finder-utils.d.ts +0 -3
  44. package/dist/react/components/finder-search-term.d.ts +0 -8
  45. package/dist/react/hooks/use-finder-constructor.d.ts +0 -7
  46. /package/dist/core/{debounce-callback-registry/debounce-callback-registry.d.ts → debounce-callback-registry.d.ts} +0 -0
@@ -0,0 +1,8 @@
1
+ import { FinderSearchTermProp } from "../types/react-types";
2
+ interface FinderSearchTermHaystackProps {
3
+ children: string;
4
+ Match?: FinderSearchTermProp;
5
+ Miss?: FinderSearchTermProp;
6
+ }
7
+ declare function FinderSearchTermHaystack({ Match, Miss, children: haystack }: FinderSearchTermHaystackProps): string | import("react/jsx-runtime").JSX.Element;
8
+ export { FinderSearchTermHaystack };
@@ -1,9 +1,9 @@
1
1
  import { FinderProps } from "../types/react-types";
2
2
  import { FinderContent } from "./finder-content";
3
- import { FinderSearchTerm } from "./finder-search-term";
3
+ import { FinderSearchTermHaystack } from "./finder-search-term-haystack";
4
4
  declare function Finder<FItem = any, FContext = any>({ items, rules, effects, initialSearchTerm, initialSortBy, initialSortDirection, initialGroupBy, initialFilters, context, isLoading, disabled, page, numItemsPerPage, requireGroup, ignoreSortByRulesWhileSearchRuleIsActive, onInit, onReady, onFirstUserInteraction, onChange, controllerRef, children, }: FinderProps<FItem, FContext>): import("react/jsx-runtime").JSX.Element;
5
5
  declare namespace Finder {
6
6
  var Content: typeof FinderContent;
7
- var SearchTerm: typeof FinderSearchTerm;
7
+ var SearchTermHaystack: typeof FinderSearchTermHaystack;
8
8
  }
9
9
  export { Finder };
@@ -0,0 +1,12 @@
1
+ import { FinderSearchTermProp } from "../types/react-types";
2
+ interface StringMatchProps {
3
+ needle: string;
4
+ haystack: string;
5
+ Match?: FinderSearchTermProp;
6
+ Miss?: FinderSearchTermProp;
7
+ }
8
+ /**
9
+ * Split a string into result segment components .
10
+ */
11
+ declare function StringMatch({ needle, haystack, Match, Miss }: StringMatchProps): string | (string | import("react/jsx-runtime").JSX.Element)[];
12
+ export { StringMatch };
@@ -2,16 +2,15 @@
2
2
  * React-specific types for creating consumer components.
3
3
  */
4
4
  import { ElementType, PropsWithChildren, ReactElement, ReactNode, RefObject } from "react";
5
- import { paginationInterface } from "../../core/pagination/pagination-interface";
5
+ import { FinderConstructorOptions, FinderResultGroup, PaginationMixinInterface } from "../../core/types/core-types";
6
+ import { StringMatchSegment } from "../../core/types/string-match-types";
6
7
  import { FinderCore } from "../../core/finder-core";
7
- import { GroupByRule } from "../../core/types/rule-types";
8
- import { FinderConstructorOptions, FinderResultGroup } from "../../core/types/core-types";
9
8
  export interface FinderProps<FItem, FContext> extends FinderConstructorOptions<FItem, FContext>, PropsWithChildren {
10
9
  items: FItem[] | undefined | null;
11
10
  controllerRef?: RefObject<FinderCore<FItem, FContext> | null>;
12
11
  }
13
12
  export interface FinderContentProps<FContext = any> {
14
- pagination: ReturnType<typeof paginationInterface>;
13
+ pagination: PaginationMixinInterface;
15
14
  context?: FContext;
16
15
  }
17
16
  export interface FinderContentItemProps<FItem, FContext = any> extends FinderContentProps<FContext> {
@@ -19,6 +18,10 @@ export interface FinderContentItemProps<FItem, FContext = any> extends FinderCon
19
18
  }
20
19
  export interface FinderContentGroupProps<FItem, FContext = any> extends FinderContentProps<FContext> {
21
20
  groups: FinderResultGroup<FItem>[];
22
- rule: GroupByRule;
23
21
  }
24
22
  export type FinderContentRenderProp = ElementType<FinderContentProps> | ReactElement<FinderContentProps> | Iterable<ReactNode>;
23
+ export interface StringMatchSegmentProps {
24
+ segment: StringMatchSegment;
25
+ segmentIndex: number;
26
+ }
27
+ export type FinderSearchTermProp = keyof HTMLElementTagNameMap | ElementType | ElementType<StringMatchSegmentProps>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hitgrab/finder",
3
- "version": "0.1.0-alpha",
3
+ "version": "0.1.4-alpha",
4
4
  "description": "Headless datatables for things that aren't tables.",
5
5
  "type": "module",
6
6
  "files": [
@@ -25,9 +25,9 @@
25
25
  "scripts": {
26
26
  "dev": "vite",
27
27
  "build": "vite build && tsc --project tsconfig.production.json",
28
- "build:docs": "npm --prefix docusaurus run build && rm -r docs && cp -r ./docusaurus/docs ./docs && mkdir ./docs/examples",
29
- "build:armory": "npm --prefix examples/react-armory run build && cp -r ./examples/react-armory/dist ./docs/examples/armory",
30
- "build:shoes": "npm --prefix examples/react-shoes run build && cp -r ./examples/react-shoes/dist ./docs/examples/shoes",
28
+ "build:docs": "npm --prefix docusaurus run build && rm -r docs && cp -r ./docusaurus/build ./docs && mkdir ./docs/examples",
29
+ "build:armory": "npm --prefix examples/react-armory run build && rm -r ./docs/examples/armory && cp -r ./examples/react-armory/dist ./docs/examples/armory",
30
+ "build:shoes": "npm --prefix examples/react-shoes run build && rm -r ./docs/examples/shoes && cp -r ./examples/react-shoes/dist ./docs/examples/shoes",
31
31
  "test": "vitest"
32
32
  },
33
33
  "repository": {
@@ -58,13 +58,14 @@
58
58
  "@types/react": "^19.1.3",
59
59
  "@types/react-dom": "^19.1.3",
60
60
  "@vitejs/plugin-react": "^4.3.2",
61
- "eslint": "^8.57.1",
62
- "eslint-config-airbnb": "^19.0.4",
63
- "eslint-config-airbnb-base": "^15.0.0",
64
- "eslint-config-airbnb-typescript": "^17.0.0",
65
- "eslint-plugin-import": "^2.27.5",
61
+ "@eslint/js": "^9.36.0",
62
+ "eslint": "^9.36.0",
63
+ "eslint-plugin-jsx-a11y": "^6.10.2",
64
+ "eslint-plugin-react": "^7.37.5",
65
+ "eslint-plugin-react-hooks": "^5.2.0",
66
+ "typescript-eslint": "^8.45.0",
66
67
  "prettier": "^3.5.3",
67
- "typescript": "^5.8.2",
68
+ "typescript": "^5.9.2",
68
69
  "vite": "^6.3.5",
69
70
  "vite-plugin-checker": "^0.9.0",
70
71
  "vitest": "^3.1.3"
@@ -1,8 +0,0 @@
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,31 +0,0 @@
1
- import { FiltersMixin } from "./filters";
2
- /**
3
- * Public surface for the Filters mixin
4
- */
5
- declare function readonlyFiltersInterface(mixin: FiltersMixin): {
6
- values: Record<string, any>;
7
- raw: Record<string, any>;
8
- activeRules: import("../..").HydratedFilterRule<unknown, any, any>[];
9
- rules: import("../..").HydratedFilterRule<unknown, any, any>[];
10
- isActive: (identifier: string | import("../..").FilterRuleUnion | import("../..").HydratedFilterRule) => boolean;
11
- get: (identifier: string | import("../..").FilterRuleUnion | import("../..").HydratedFilterRule) => any;
12
- has: (identifier: string | import("../..").FilterRuleUnion | import("../..").HydratedFilterRule, optionValue?: import("../..").FilterOption | any) => any;
13
- getRule: (identifier: string | import("../..").FilterRuleUnion | import("../..").HydratedFilterRule) => import("../..").HydratedFilterRule<any, any, any> | undefined;
14
- };
15
- declare function filtersInterface(mixin: FiltersMixin): {
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;
18
- delete: (identifier: string | import("../..").FilterRuleUnion | import("../..").HydratedFilterRule) => void;
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>;
23
- raw: Record<string, any>;
24
- activeRules: import("../..").HydratedFilterRule<unknown, any, any>[];
25
- rules: import("../..").HydratedFilterRule<unknown, any, any>[];
26
- isActive: (identifier: string | import("../..").FilterRuleUnion | import("../..").HydratedFilterRule) => boolean;
27
- get: (identifier: string | import("../..").FilterRuleUnion | import("../..").HydratedFilterRule) => any;
28
- has: (identifier: string | import("../..").FilterRuleUnion | import("../..").HydratedFilterRule, optionValue?: import("../..").FilterOption | any) => any;
29
- getRule: (identifier: string | import("../..").FilterRuleUnion | import("../..").HydratedFilterRule) => import("../..").HydratedFilterRule<any, any, any> | undefined;
30
- };
31
- export { readonlyFiltersInterface, filtersInterface };
@@ -1,28 +0,0 @@
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
- initialFilters: Record<string, any> | undefined;
5
- }
6
- declare class FiltersMixin {
7
- #private;
8
- constructor({ initialFilters }: InitialValues, deps: MixinInjectedDependencies);
9
- set<FItem, FValue>(identifier: FilterRuleUnion<FItem, FValue> | HydratedFilterRule<FItem, FValue> | string, incomingFilterValue: FValue | FValue[]): void;
10
- get rules(): HydratedFilterRule<unknown, any, any>[];
11
- get activeRules(): HydratedFilterRule<unknown, any, any>[];
12
- get(identifier: string | FilterRuleUnion | HydratedFilterRule): any;
13
- has(identifier: string | FilterRuleUnion | HydratedFilterRule, optionValue?: FilterOption | any): any;
14
- getRule(identifier: string | FilterRuleUnion | HydratedFilterRule): HydratedFilterRule<any, any, any> | undefined;
15
- delete(identifier: string | FilterRuleUnion | HydratedFilterRule): void;
16
- isRuleActive(identifier: string | FilterRuleUnion | HydratedFilterRule): boolean;
17
- toggle(identifier: string | FilterRuleUnion | HydratedFilterRule, optionValue?: FilterOption | any): void;
18
- test(options: FilterTestOptions): any[];
19
- testRule({ rule: identifier, value, ...options }: FilterTestRuleOptions): any[];
20
- testRuleOptions({ rule: identifier, ...options }: FilterTestRuleOptionsOptions): Map<any, any>;
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;
27
- }
28
- export { FiltersMixin };
@@ -1,21 +0,0 @@
1
- import { GroupByMixin } from "./group-by";
2
- /**
3
- * Public surface for the Group By mixin
4
- */
5
- declare function readonlyGroupByInterface<FItem, FContext>(mixin: GroupByMixin<FItem, FContext>): {
6
- activeRule: import("../..").GroupByRule<unknown, any> | undefined;
7
- requireGroup: boolean;
8
- rules: import("../..").GroupByRule<unknown, any>[];
9
- groupIdSortDirection: import("../..").SortDirection | undefined;
10
- };
11
- declare function groupByInterface<FItem, FContext>(mixin: GroupByMixin<FItem, FContext>): {
12
- set: (identifier?: string | import("../..").GroupByRule) => void;
13
- toggle: (identifier: import("../..").GroupByRule | string) => void;
14
- setGroupIdSortDirection: (direction?: import("../..").SortDirection) => void;
15
- reset: () => void;
16
- activeRule: import("../..").GroupByRule<unknown, any> | undefined;
17
- requireGroup: boolean;
18
- rules: import("../..").GroupByRule<unknown, any>[];
19
- groupIdSortDirection: import("../..").SortDirection | undefined;
20
- };
21
- export { readonlyGroupByInterface, groupByInterface };
@@ -1,23 +0,0 @@
1
- import { PaginationMixin } from "./pagination";
2
- /**
3
- * Public surface for the pagination mixin
4
- */
5
- declare function readonlyPaginationInterface<FItem>(mixin: PaginationMixin<FItem>): {
6
- page: number;
7
- offset: number;
8
- numItemsPerPage: number | undefined;
9
- numTotalItems: number;
10
- lastPage: number | undefined;
11
- isPaginated: boolean;
12
- };
13
- declare function paginationInterface<FItem>(mixin: PaginationMixin<FItem>): {
14
- setPage: (value: number) => void;
15
- setNumItemsPerPage: (value?: number) => void;
16
- page: number;
17
- offset: number;
18
- numItemsPerPage: number | undefined;
19
- numTotalItems: number;
20
- lastPage: number | undefined;
21
- isPaginated: boolean;
22
- };
23
- export { readonlyPaginationInterface, paginationInterface };
@@ -1 +0,0 @@
1
- export declare function calculateSequentialCharacterIndexes(haystack: string, needle: string): number[] | undefined;
@@ -1 +0,0 @@
1
- export declare function calculateSequentialStringCharacterIndexes(haystack: string, needle: string): number[] | undefined;
@@ -1,17 +0,0 @@
1
- /**
2
- * Internal type used to prepare the result segment. These values all point to the transformed haystack.
3
- */
4
- export interface ResultSegmentInternal {
5
- start: number;
6
- end: number;
7
- length: number;
8
- is_match: boolean;
9
- value: string;
10
- _internal: true;
11
- }
12
- /**
13
- * Consumable type ready for use. All values are mapped to the haystack source.
14
- */
15
- export interface ResultSegment extends Omit<ResultSegmentInternal, "_internal"> {
16
- }
17
- export type SearchCharacterIndexFn = (haystack: string, needle: string) => number[] | undefined;
@@ -1,15 +0,0 @@
1
- import { SearchMixin } from "./search";
2
- declare function readonlySearchInterface<FItem>(mixin: SearchMixin<FItem>): {
3
- searchTerm: string;
4
- hasSearchTerm: boolean;
5
- hasSearchRule: boolean;
6
- };
7
- declare function searchInterface<FItem>(mixin: SearchMixin<FItem>): {
8
- setSearchTerm: (incomingSearchTerm: string) => void;
9
- reset: () => void;
10
- test: (searchTerm: string, isAdditive?: boolean) => FItem[];
11
- searchTerm: string;
12
- hasSearchTerm: boolean;
13
- hasSearchRule: boolean;
14
- };
15
- export { readonlySearchInterface, searchInterface };
@@ -1,23 +0,0 @@
1
- import { SortDirection } from "../types/core-types";
2
- import { SortByMixin } from "./sort-by";
3
- /**
4
- * Public surface for the SortBy mixin
5
- */
6
- declare function readonlySortByInterface<FItem>(mixin: SortByMixin<FItem>): {
7
- activeRule: import("../..").SortByRule<unknown, any> | undefined;
8
- sortDirection: SortDirection;
9
- userHasSetSortDirection: boolean;
10
- rules: import("../..").SortByRule<unknown, any>[];
11
- };
12
- declare function sortByInterface<FItem>(mixin: SortByMixin<FItem>): {
13
- set: (identifier?: string | import("../..").SortByRule, incomingSortDirection?: SortDirection) => void;
14
- setSortDirection: (incomingSortDirection?: SortDirection) => void;
15
- cycleSortDirection: () => void;
16
- toggleSortDirection: () => void;
17
- reset(): void;
18
- activeRule: import("../..").SortByRule<unknown, any> | undefined;
19
- sortDirection: SortDirection;
20
- userHasSetSortDirection: boolean;
21
- rules: import("../..").SortByRule<unknown, any>[];
22
- };
23
- export { readonlySortByInterface, sortByInterface };
@@ -1,3 +0,0 @@
1
- export declare function clamp(value: number, min: number, max: number): number;
2
- export declare function simpleUniqBy<T>(data: T[], key: string): T[];
3
- export declare function range(start: number, end: number): number[];
@@ -1,8 +0,0 @@
1
- import { ElementType } from "react";
2
- interface FinderSearchTermProps {
3
- children: string;
4
- Component?: ElementType;
5
- searchTerm?: string;
6
- }
7
- declare function FinderSearchTerm({ Component, searchTerm, children }: FinderSearchTermProps): string | (string | import("react/jsx-runtime").JSX.Element)[];
8
- export { FinderSearchTerm };
@@ -1,7 +0,0 @@
1
- import { FinderCore } from "../../core/finder-core";
2
- import { FinderConstructorOptions } from "../../core/types/core-types";
3
- /**
4
- * Create a finder instance with contained state and controllers.
5
- */
6
- declare function useFinderConstructor<FItem>(items: FItem[] | null | undefined, { rules, initialSearchTerm, initialSortBy, initialSortDirection, initialGroupBy, initialFilters, context, page, numItemsPerPage, isLoading, disabled, requireGroup, onInit, onReady, onFirstUserInteraction, onChange, }: FinderConstructorOptions<FItem>): FinderCore<FItem>;
7
- export { useFinderConstructor };