@himanshu-sorathiya/react-kit 1.0.14 → 1.0.17

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 (3) hide show
  1. package/dist/index.d.ts +163 -76
  2. package/dist/index.js +579 -324
  3. package/package.json +2 -2
package/dist/index.d.ts CHANGED
@@ -1,35 +1,24 @@
1
1
  // Generated by dts-bundle-generator v9.5.1
2
2
 
3
+ import React$1 from 'react';
3
4
  import { CSSProperties, RefObject } from 'react';
4
5
 
6
+ export interface FuzzyHighlighterProps {
7
+ text: string;
8
+ query: string;
9
+ className?: string;
10
+ caseSensitive?: boolean;
11
+ }
12
+ export declare function FuzzyHighlighter({ text, query, className, caseSensitive, }: FuzzyHighlighterProps): React$1.JSX.Element;
5
13
  export interface ModalLayoutProps {
6
14
  modalId: string;
7
- children: React.ReactNode;
15
+ children: React$1.ReactNode;
8
16
  wrapperClassName?: string;
9
- wrapperStyle?: CSSProperties;
17
+ wrapperStyle?: React$1.CSSProperties;
10
18
  containerClassName?: string;
11
- containerStyle?: CSSProperties;
19
+ containerStyle?: React$1.CSSProperties;
12
20
  }
13
21
  export declare function ModalLayout({ modalId, children, wrapperClassName, wrapperStyle, containerClassName, containerStyle, }: ModalLayoutProps): import("react").ReactPortal | null;
14
- export interface DebounceOptions {
15
- maxWait?: number;
16
- leading?: boolean;
17
- trailing?: boolean;
18
- }
19
- export interface UseDebounceReturn<Args extends any[]> {
20
- debouncedFunc: (...args: Args) => void;
21
- cancel: () => void;
22
- flush: () => void;
23
- isPending: boolean;
24
- }
25
- export declare function useDebounce<Args extends any[]>(func: (...args: Args) => void, delay: number, options?: DebounceOptions): UseDebounceReturn<Args>;
26
- export interface DebouncedValueOptions {
27
- maxWait?: number;
28
- leading?: boolean;
29
- trailing?: boolean;
30
- }
31
- export type UseDebouncedValueReturn<T> = T;
32
- export declare function useDebouncedValue<T>(value: T, delay: number, options?: DebouncedValueOptions): UseDebouncedValueReturn<T>;
33
22
  export type FilterType = "text" | "number" | "boolean" | "date" | "select" | "multiselect" | "custom";
34
23
  export type TextOperator = "contains" | "equals" | "startsWith" | "endsWith" | "notContains";
35
24
  export type NumberOperator = "equals" | "greaterThan" | "lessThan" | "greaterThanOrEqual" | "lessThanOrEqual" | "between";
@@ -133,69 +122,49 @@ export type UseFuzzySearchFields<T> = {
133
122
  }[];
134
123
  export type UseFuzzySearchReturn<T> = T[];
135
124
  export declare function useFuzzySearch<T>(data: T[], query: string, fields: UseFuzzySearchFields<T>, options?: FuzzySearchOptions): UseFuzzySearchReturn<T>;
136
- declare const validKeyEventTypes: readonly [
137
- "keydown",
138
- "keyup",
139
- "keypress"
140
- ];
141
- export type KeyEventType = (typeof validKeyEventTypes)[number];
142
- export interface BaseKeyOptions {
143
- enabled?: boolean;
144
- target?: RefObject<HTMLElement | null> | Window;
145
- preventDefault?: boolean;
146
- stopPropagation?: boolean;
147
- ignoreWhenFocusedInInputs?: boolean;
148
- ctrlKey?: boolean;
149
- shiftKey?: boolean;
150
- altKey?: boolean;
151
- metaKey?: boolean;
152
- }
153
- export type KeyOptions = BaseKeyOptions & ({
154
- eventType?: "keydown" | "keypress";
155
- preventRepeat?: boolean;
156
- } | {
157
- eventType: "keyup";
158
- preventRepeat?: never;
159
- });
160
- export type UseKeyReturn = void;
161
- export declare function useKey(key: string, handler: (e: KeyboardEvent) => void, { enabled, preventDefault, stopPropagation, eventType, preventRepeat, ignoreWhenFocusedInInputs, ctrlKey, shiftKey, altKey, metaKey, target, }?: KeyOptions): UseKeyReturn;
162
- export interface UseModalStateReturn<TData> {
163
- isOpen: boolean;
164
- id: string | null;
165
- data: TData | undefined;
125
+ export interface Group<T> {
126
+ key: string;
127
+ items: T[];
166
128
  }
167
- export interface UseModalActionsReturn {
168
- openModal: <T = unknown>(id: string, data?: T) => void;
169
- closeModal: () => void;
170
- clearModal: () => void;
129
+ export interface UseGroupingReturn<T> {
130
+ groupedRecord: Record<string, T[]>;
131
+ groupedArray: Group<T>[];
132
+ groupKeys: string[];
133
+ totalGroups: number;
134
+ activeGroupBy: string | undefined;
135
+ changeGroupBy: (newField: string) => void;
136
+ clearGrouping: () => void;
137
+ resetGrouping: () => void;
138
+ getGroupItems: (groupKey: string) => T[];
171
139
  }
172
- export type UseModalReturn<TData> = UseModalStateReturn<TData> & UseModalActionsReturn;
173
- export declare function useModalState<TData = unknown>(): UseModalStateReturn<TData>;
174
- export declare function useModalActions(): UseModalActionsReturn;
175
- export declare function useModal<TData = unknown>(): UseModalReturn<TData>;
140
+ export declare function useGrouping<T = unknown>({ items, initialGroupBy, }: {
141
+ items: T[];
142
+ initialGroupBy?: string;
143
+ }): UseGroupingReturn<T>;
144
+ export type SelectionId = string | number;
176
145
  export interface UseMultipleSelectionReturn<T> {
177
- selectedIds: (string | number)[];
146
+ selectedIds: SelectionId[];
178
147
  selectedCount: number;
179
148
  selectedItems: T[];
180
149
  isEmpty: boolean;
181
- select: (item: string | number | T) => void;
182
- deselect: (item: string | number | T) => void;
183
- toggle: (item: string | number | T) => void;
184
- isSelected: (item: string | number | T) => boolean;
185
- replaceSelection: (newSelectedItems: (string | number)[] | T[]) => void;
150
+ select: (item: SelectionId | T) => void;
151
+ deselect: (item: SelectionId | T) => void;
152
+ toggle: (item: SelectionId | T) => void;
153
+ isSelected: (item: SelectionId | T) => boolean;
186
154
  resetSelection: () => void;
155
+ replaceSelection: (newSelectedItems: SelectionId[] | T[]) => void;
187
156
  selectAll: () => void;
188
157
  deselectAll: () => void;
189
158
  toggleAll: () => void;
190
159
  invertSelection: () => void;
191
- selectMultiple: (newItems: (string | number)[] | T[]) => void;
192
- deselectMultiple: (itemsToRemove: (string | number)[] | T[]) => void;
193
- retainOnly: (itemsToRetain: (string | number)[] | T[]) => void;
160
+ selectMultiple: (newItems: SelectionId[] | T[]) => void;
161
+ deselectMultiple: (itemsToRemove: SelectionId[] | T[]) => void;
162
+ retainOnly: (itemsToRetain: SelectionId[] | T[]) => void;
194
163
  }
195
164
  export declare function useMultipleSelection<T = unknown>({ items, field, initialSelectedIds, }: {
196
165
  items: T[];
197
166
  field?: string;
198
- initialSelectedIds?: (number | string)[];
167
+ initialSelectedIds?: SelectionId[];
199
168
  }): UseMultipleSelectionReturn<T>;
200
169
  export interface UseOrderReturn<T> {
201
170
  orderedItems: T[];
@@ -207,8 +176,8 @@ export interface UseOrderReturn<T> {
207
176
  moveToBottom: (index: number) => void;
208
177
  move: (fromIndex: number, toIndex: number) => void;
209
178
  swap: (indexA: number, indexB: number) => void;
210
- replaceOrder: (newOrderedItems: T[]) => void;
211
179
  resetOrder: () => void;
180
+ replaceOrder: (newOrderedItems: T[]) => void;
212
181
  }
213
182
  export declare function useOrder<T>(initialItems: T[]): UseOrderReturn<T>;
214
183
  export interface UsePaginationReturn<T> {
@@ -229,16 +198,17 @@ export interface UsePaginationReturn<T> {
229
198
  resetPagination: () => void;
230
199
  }
231
200
  export declare function usePagination<T>(data: T[], initialPageSize: number, initialPageIndex?: number): UsePaginationReturn<T>;
201
+ type SelectionId$1 = string | number;
232
202
  export interface UseSingleSelectionReturn {
233
- selectedId: string | number | undefined;
203
+ selectedId: SelectionId$1 | undefined;
234
204
  hasSelection: boolean;
235
- select: (id: string | number) => void;
205
+ select: (id: SelectionId$1) => void;
236
206
  deselect: () => void;
237
- toggle: (id: string | number) => void;
238
- isSelected: (id: string | number) => boolean;
207
+ toggle: (id: SelectionId$1) => void;
208
+ isSelected: (id: SelectionId$1) => boolean;
239
209
  resetSelection: () => void;
240
210
  }
241
- export declare function useSingleSelection(initialSelectedId?: number | string): UseSingleSelectionReturn;
211
+ export declare function useSingleSelection(initialSelectedId?: SelectionId$1): UseSingleSelectionReturn;
242
212
  export type SortType = "numeric" | "alphabetical" | "alphanumeric" | "boolean" | "date" | "basic" | "custom";
243
213
  export interface BaseSortOptions {
244
214
  desc?: boolean;
@@ -280,6 +250,97 @@ export interface UseSortReturn<T> {
280
250
  getSortIndex: (id: string) => number | undefined;
281
251
  }
282
252
  export declare function useSort<T>(data: T[], initialSorts?: SortState): UseSortReturn<T>;
253
+ export type ExpansionId = string | number;
254
+ export interface UseExpansionReturn<T> {
255
+ expandedIds: ExpansionId[];
256
+ expandedItems: T[];
257
+ isExpanded: (itemOrId: ExpansionId | T) => boolean;
258
+ expand: (itemOrId: ExpansionId | T) => void;
259
+ collapse: (itemOrId: ExpansionId | T) => void;
260
+ toggle: (itemOrId: ExpansionId | T) => void;
261
+ expandAll: () => void;
262
+ collapseAll: () => void;
263
+ resetExpansion: () => void;
264
+ replaceExpansion: (newExpandedItems: ExpansionId[] | T[]) => void;
265
+ }
266
+ export declare function useExpansion<T = unknown>({ items, field, initialExpandedIds, multiple, }?: {
267
+ items?: T[];
268
+ field?: string;
269
+ initialExpandedIds?: ExpansionId[];
270
+ multiple?: boolean;
271
+ }): UseExpansionReturn<T>;
272
+ export interface UseModalStateReturn<TData> {
273
+ isOpen: boolean;
274
+ id: string | null;
275
+ data: TData | undefined;
276
+ }
277
+ export interface UseModalActionsReturn {
278
+ openModal: <T = unknown>(id: string, data?: T) => void;
279
+ closeModal: () => void;
280
+ clearModal: () => void;
281
+ }
282
+ export type UseModalReturn<TData> = UseModalStateReturn<TData> & UseModalActionsReturn;
283
+ export declare function useModalState<TData = unknown>(): UseModalStateReturn<TData>;
284
+ export declare function useModalActions(): UseModalActionsReturn;
285
+ export declare function useModal<TData = unknown>(): UseModalReturn<TData>;
286
+ export type PinId = string | number;
287
+ export interface UsePinReturn<T> {
288
+ pinnedIds: PinId[];
289
+ pinnedItems: T[];
290
+ unpinnedItems: T[];
291
+ pinnedCount: number;
292
+ hasPins: boolean;
293
+ isAtMaxLimit: boolean;
294
+ pin: (itemOrId: PinId | T) => void;
295
+ unpin: (itemOrId: PinId | T) => void;
296
+ togglePin: (itemOrId: PinId | T) => void;
297
+ isPinned: (itemOrId: PinId | T) => boolean;
298
+ clearPins: () => void;
299
+ resetPins: () => void;
300
+ replacePins: (newPinnedItems: PinId[] | T[]) => void;
301
+ pinMultiple: (newItems: PinId[] | T[]) => void;
302
+ unpinMultiple: (itemsToRemove: PinId[] | T[]) => void;
303
+ }
304
+ export declare function usePin<T = unknown>({ items, field, initialPinnedIds, maxPins, }: {
305
+ items: T[];
306
+ field?: string;
307
+ initialPinnedIds?: PinId[];
308
+ maxPins?: number;
309
+ }): UsePinReturn<T>;
310
+ export type VisibilityId = number | string;
311
+ export interface UseVisibilityReturn<T> {
312
+ visibleIds: VisibilityId[];
313
+ visibleItems: T[];
314
+ hiddenItems: T[];
315
+ visibleCount: number;
316
+ isVisible: (itemOrId: VisibilityId | T) => boolean;
317
+ show: (itemOrId: VisibilityId | T) => void;
318
+ hide: (itemOrId: VisibilityId | T) => void;
319
+ toggleVisibility: (itemOrId: VisibilityId | T) => void;
320
+ showAll: (itemsArray?: VisibilityId[] | T[]) => void;
321
+ hideAll: (itemsArray?: VisibilityId[] | T[]) => void;
322
+ resetVisibility: () => void;
323
+ replaceVisibility: (newItems: VisibilityId[] | T[]) => void;
324
+ }
325
+ export declare function useVisibility<T = unknown>({ items, field, initialVisibleIds, }: {
326
+ items: T[];
327
+ field?: string;
328
+ initialVisibleIds?: VisibilityId[];
329
+ }): UseVisibilityReturn<T>;
330
+ export interface DebounceOptions {
331
+ maxWait?: number;
332
+ leading?: boolean;
333
+ trailing?: boolean;
334
+ }
335
+ export interface UseDebounceReturn<Args extends any[]> {
336
+ debouncedFunc: (...args: Args) => void;
337
+ cancel: () => void;
338
+ flush: () => void;
339
+ isPending: boolean;
340
+ }
341
+ export declare function useDebounce<Args extends any[]>(func: (...args: Args) => void, delay: number, options?: DebounceOptions): UseDebounceReturn<Args>;
342
+ export type UseDebouncedValueReturn<T> = T;
343
+ export declare function useDebouncedValue<T>(value: T, delay: number, options?: DebounceOptions): UseDebouncedValueReturn<T>;
283
344
  export interface ThrottleOptions {
284
345
  leading?: boolean;
285
346
  trailing?: boolean;
@@ -291,5 +352,31 @@ export interface UseThrottleReturn<Args extends any[]> {
291
352
  isPending: boolean;
292
353
  }
293
354
  export declare function useThrottle<Args extends any[]>(func: (...args: Args) => void, delay: number, options?: ThrottleOptions): UseThrottleReturn<Args>;
355
+ declare const validKeyEventTypes: readonly [
356
+ "keydown",
357
+ "keyup",
358
+ "keypress"
359
+ ];
360
+ export type KeyEventType = (typeof validKeyEventTypes)[number];
361
+ export interface BaseKeyOptions {
362
+ enabled?: boolean;
363
+ target?: React$1.RefObject<HTMLElement | null> | Window;
364
+ preventDefault?: boolean;
365
+ stopPropagation?: boolean;
366
+ ignoreWhenFocusedInInputs?: boolean;
367
+ ctrlKey?: boolean;
368
+ shiftKey?: boolean;
369
+ altKey?: boolean;
370
+ metaKey?: boolean;
371
+ }
372
+ export type KeyOptions = BaseKeyOptions & ({
373
+ eventType?: "keydown" | "keypress";
374
+ preventRepeat?: boolean;
375
+ } | {
376
+ eventType: "keyup";
377
+ preventRepeat?: never;
378
+ });
379
+ export type UseKeyReturn = void;
380
+ export declare function useKey(key: string, handler: (e: KeyboardEvent) => void, { enabled, preventDefault, stopPropagation, eventType, preventRepeat, ignoreWhenFocusedInInputs, ctrlKey, shiftKey, altKey, metaKey, target, }?: KeyOptions): UseKeyReturn;
294
381
 
295
382
  export {};