@himanshu-sorathiya/react-kit 1.0.12 → 1.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -112,12 +112,27 @@ export interface FuzzySearchOptions {
112
112
  matchStrategy?: "any" | "all";
113
113
  exactPhraseBonus?: boolean;
114
114
  }
115
- export type UseFuzzySearchFields = [
116
- string,
117
- number
118
- ][];
115
+ export interface IndexedToken {
116
+ text: string;
117
+ weight: number;
118
+ }
119
+ export interface FlatIndexedItem<T> {
120
+ item: T;
121
+ index: number;
122
+ tokens: IndexedToken[];
123
+ combinedFlatText: string;
124
+ }
125
+ export interface ScoredItem<T> {
126
+ item: T;
127
+ score: number;
128
+ index: number;
129
+ }
130
+ export type UseFuzzySearchFields<T> = {
131
+ field: Extract<keyof T, string>;
132
+ weight: number;
133
+ }[];
119
134
  export type UseFuzzySearchReturn<T> = T[];
120
- export declare function useFuzzySearch<T>(data: T[], query: string, fields: UseFuzzySearchFields, options?: FuzzySearchOptions): UseFuzzySearchReturn<T>;
135
+ export declare function useFuzzySearch<T>(data: T[], query: string, fields: UseFuzzySearchFields<T>, options?: FuzzySearchOptions): UseFuzzySearchReturn<T>;
121
136
  declare const validKeyEventTypes: readonly [
122
137
  "keydown",
123
138
  "keyup",
package/dist/index.js CHANGED
@@ -276,7 +276,7 @@ function x(e, t, n = !1) {
276
276
  function S(e, t, n, r = {}) {
277
277
  let i = r.threshold ?? .01, o = r.caseSensitive ?? !1, s = r.matchStrategy ?? "any", c = r.exactPhraseBonus ?? !0, l = a(() => n.length === 0 || e.length === 0 ? [] : e.map((e, t) => {
278
278
  let r = [], i = [];
279
- for (let [t, a] of n) {
279
+ for (let { field: t, weight: a } of n) {
280
280
  let n = y(e, t);
281
281
  if (Array.isArray(n)) {
282
282
  for (let e of n) if (e != null && e !== "" && typeof e != "object") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@himanshu-sorathiya/react-kit",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "description": "An opinionated collection of react hooks, and reusable UI components.",
5
5
  "type": "module",
6
6
  "module": "./dist/index.js",