@himanshu-sorathiya/react-kit 1.0.17 → 1.0.18

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.
@@ -0,0 +1,32 @@
1
+ // Generated by dts-bundle-generator v9.5.1
2
+
3
+ import { RefObject } from 'react';
4
+
5
+ declare const validKeyEventTypes: readonly [
6
+ "keydown",
7
+ "keyup",
8
+ "keypress"
9
+ ];
10
+ export type KeyEventType = (typeof validKeyEventTypes)[number];
11
+ export interface BaseKeyOptions {
12
+ enabled?: boolean;
13
+ target?: RefObject<HTMLElement | null> | Window;
14
+ preventDefault?: boolean;
15
+ stopPropagation?: boolean;
16
+ ignoreWhenFocusedInInputs?: boolean;
17
+ ctrlKey?: boolean;
18
+ shiftKey?: boolean;
19
+ altKey?: boolean;
20
+ metaKey?: boolean;
21
+ }
22
+ export type KeyOptions = BaseKeyOptions & ({
23
+ eventType?: "keydown" | "keypress";
24
+ preventRepeat?: boolean;
25
+ } | {
26
+ eventType: "keyup";
27
+ preventRepeat?: never;
28
+ });
29
+ export type UseKeyReturn = void;
30
+ export declare function useKey(key: string, handler: (e: KeyboardEvent) => void, { enabled, preventDefault, stopPropagation, eventType, preventRepeat, ignoreWhenFocusedInInputs, ctrlKey, shiftKey, altKey, metaKey, target, }?: KeyOptions): UseKeyReturn;
31
+
32
+ export {};
package/dist/events.js ADDED
@@ -0,0 +1,2 @@
1
+ import { t as e } from "./events2.js";
2
+ export { e as useKey };
@@ -0,0 +1,54 @@
1
+ import { useEffect as e, useLayoutEffect as t, useRef as n } from "react";
2
+ //#region src/events/useKey/constants.ts
3
+ var r = [
4
+ "keydown",
5
+ "keyup",
6
+ "keypress"
7
+ ];
8
+ //#endregion
9
+ //#region src/events/useKey/useKey.ts
10
+ function i(i, a, { enabled: o = !0, preventDefault: s = !0, stopPropagation: c = !0, eventType: l = "keydown", preventRepeat: u = !1, ignoreWhenFocusedInInputs: d = !0, ctrlKey: f = !1, shiftKey: p = !1, altKey: m = !1, metaKey: h = !1, target: g = window } = {}) {
11
+ let _ = n(a), v = n(o), y = n(!1);
12
+ t(() => {
13
+ _.current = a;
14
+ }, [a]), e(() => {
15
+ v.current = o;
16
+ }, [o]), e(() => {
17
+ let e = g && "current" in g ? g.current : g;
18
+ if (!e) return;
19
+ let t = i.toLowerCase(), n = r.includes(l) ? l : "keydown", a = u && n !== "keyup";
20
+ function o() {
21
+ y.current = !1;
22
+ }
23
+ function b(e) {
24
+ if (!(e instanceof KeyboardEvent)) return;
25
+ let n = e.key.toLowerCase();
26
+ (n === t || f && n === "control" || p && n === "shift" || m && n === "alt" || h && n === "meta") && (y.current = !1);
27
+ }
28
+ function x(e) {
29
+ if (!(e instanceof KeyboardEvent) || !v.current) return;
30
+ let n = e.target;
31
+ if (!(d && n instanceof HTMLElement && (n instanceof HTMLInputElement || n instanceof HTMLTextAreaElement || n instanceof HTMLSelectElement || n.isContentEditable)) && e.ctrlKey === f && e.shiftKey === p && e.altKey === m && e.metaKey === h && t === e.key.toLowerCase()) {
32
+ if (a && y.current) return;
33
+ y.current = !0, _.current(e), s && e.preventDefault(), c && e.stopPropagation();
34
+ }
35
+ }
36
+ return e.addEventListener(n, x), a && (e.addEventListener("keyup", b), window.addEventListener("blur", o)), () => {
37
+ e.removeEventListener(n, x), a && (e.removeEventListener("keyup", b), window.removeEventListener("blur", o));
38
+ };
39
+ }, [
40
+ i,
41
+ s,
42
+ c,
43
+ l,
44
+ u,
45
+ d,
46
+ f,
47
+ p,
48
+ m,
49
+ h,
50
+ g
51
+ ]);
52
+ }
53
+ //#endregion
54
+ export { i as t };
package/dist/index.d.ts CHANGED
@@ -3,22 +3,57 @@
3
3
  import React$1 from 'react';
4
4
  import { CSSProperties, RefObject } from 'react';
5
5
 
6
- export interface FuzzyHighlighterProps {
7
- text: string;
8
- query: string;
9
- className?: string;
10
- caseSensitive?: boolean;
6
+ declare const validKeyEventTypes: readonly [
7
+ "keydown",
8
+ "keyup",
9
+ "keypress"
10
+ ];
11
+ export type KeyEventType = (typeof validKeyEventTypes)[number];
12
+ export interface BaseKeyOptions {
13
+ enabled?: boolean;
14
+ target?: React$1.RefObject<HTMLElement | null> | Window;
15
+ preventDefault?: boolean;
16
+ stopPropagation?: boolean;
17
+ ignoreWhenFocusedInInputs?: boolean;
18
+ ctrlKey?: boolean;
19
+ shiftKey?: boolean;
20
+ altKey?: boolean;
21
+ metaKey?: boolean;
11
22
  }
12
- export declare function FuzzyHighlighter({ text, query, className, caseSensitive, }: FuzzyHighlighterProps): React$1.JSX.Element;
13
- export interface ModalLayoutProps {
14
- modalId: string;
15
- children: React$1.ReactNode;
16
- wrapperClassName?: string;
17
- wrapperStyle?: React$1.CSSProperties;
18
- containerClassName?: string;
19
- containerStyle?: React$1.CSSProperties;
23
+ export type KeyOptions = BaseKeyOptions & ({
24
+ eventType?: "keydown" | "keypress";
25
+ preventRepeat?: boolean;
26
+ } | {
27
+ eventType: "keyup";
28
+ preventRepeat?: never;
29
+ });
30
+ export type UseKeyReturn = void;
31
+ export declare function useKey(key: string, handler: (e: KeyboardEvent) => void, { enabled, preventDefault, stopPropagation, eventType, preventRepeat, ignoreWhenFocusedInInputs, ctrlKey, shiftKey, altKey, metaKey, target, }?: KeyOptions): UseKeyReturn;
32
+ export interface DebounceOptions {
33
+ maxWait?: number;
34
+ leading?: boolean;
35
+ trailing?: boolean;
20
36
  }
21
- export declare function ModalLayout({ modalId, children, wrapperClassName, wrapperStyle, containerClassName, containerStyle, }: ModalLayoutProps): import("react").ReactPortal | null;
37
+ export interface UseDebounceReturn<Args extends any[]> {
38
+ debouncedFunc: (...args: Args) => void;
39
+ cancel: () => void;
40
+ flush: () => void;
41
+ isPending: boolean;
42
+ }
43
+ export declare function useDebounce<Args extends any[]>(func: (...args: Args) => void, delay: number, options?: DebounceOptions): UseDebounceReturn<Args>;
44
+ export type UseDebouncedValueReturn<T> = T;
45
+ export declare function useDebouncedValue<T>(value: T, delay: number, options?: DebounceOptions): UseDebouncedValueReturn<T>;
46
+ export interface ThrottleOptions {
47
+ leading?: boolean;
48
+ trailing?: boolean;
49
+ }
50
+ export interface UseThrottleReturn<Args extends any[]> {
51
+ throttledFunc: (...args: Args) => void;
52
+ cancel: () => void;
53
+ flush: () => void;
54
+ isPending: boolean;
55
+ }
56
+ export declare function useThrottle<Args extends any[]>(func: (...args: Args) => void, delay: number, options?: ThrottleOptions): UseThrottleReturn<Args>;
22
57
  export type FilterType = "text" | "number" | "boolean" | "date" | "select" | "multiselect" | "custom";
23
58
  export type TextOperator = "contains" | "equals" | "startsWith" | "endsWith" | "notContains";
24
59
  export type NumberOperator = "equals" | "greaterThan" | "lessThan" | "greaterThanOrEqual" | "lessThanOrEqual" | "between";
@@ -250,6 +285,22 @@ export interface UseSortReturn<T> {
250
285
  getSortIndex: (id: string) => number | undefined;
251
286
  }
252
287
  export declare function useSort<T>(data: T[], initialSorts?: SortState): UseSortReturn<T>;
288
+ export interface FuzzyHighlighterProps {
289
+ text: string;
290
+ query: string;
291
+ className?: string;
292
+ caseSensitive?: boolean;
293
+ }
294
+ export declare function FuzzyHighlighter({ text, query, className, caseSensitive, }: FuzzyHighlighterProps): React$1.JSX.Element;
295
+ export interface ModalLayoutProps {
296
+ modalId: string;
297
+ children: React$1.ReactNode;
298
+ wrapperClassName?: string;
299
+ wrapperStyle?: React$1.CSSProperties;
300
+ containerClassName?: string;
301
+ containerStyle?: React$1.CSSProperties;
302
+ }
303
+ export declare function ModalLayout({ modalId, children, wrapperClassName, wrapperStyle, containerClassName, containerStyle, }: ModalLayoutProps): import("react").ReactPortal | null;
253
304
  export type ExpansionId = string | number;
254
305
  export interface UseExpansionReturn<T> {
255
306
  expandedIds: ExpansionId[];
@@ -320,63 +371,12 @@ export interface UseVisibilityReturn<T> {
320
371
  showAll: (itemsArray?: VisibilityId[] | T[]) => void;
321
372
  hideAll: (itemsArray?: VisibilityId[] | T[]) => void;
322
373
  resetVisibility: () => void;
323
- replaceVisibility: (newItems: VisibilityId[] | T[]) => void;
374
+ replaceVisibility: (newVisibleItems: VisibilityId[] | T[]) => void;
324
375
  }
325
376
  export declare function useVisibility<T = unknown>({ items, field, initialVisibleIds, }: {
326
377
  items: T[];
327
378
  field?: string;
328
379
  initialVisibleIds?: VisibilityId[];
329
380
  }): 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>;
344
- export interface ThrottleOptions {
345
- leading?: boolean;
346
- trailing?: boolean;
347
- }
348
- export interface UseThrottleReturn<Args extends any[]> {
349
- throttledFunc: (...args: Args) => void;
350
- cancel: () => void;
351
- flush: () => void;
352
- isPending: boolean;
353
- }
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;
381
381
 
382
382
  export {};