@forgedevstack/bear 1.0.7 → 1.0.8

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 (169) hide show
  1. package/dist/components/Alert/Alert.cjs +1 -1
  2. package/dist/components/Alert/Alert.const.cjs +1 -1
  3. package/dist/components/Alert/Alert.const.d.ts +4 -0
  4. package/dist/components/Alert/Alert.const.js +9 -15
  5. package/dist/components/Alert/Alert.js +43 -38
  6. package/dist/components/AppBar/AppBar.cjs +1 -1
  7. package/dist/components/AppBar/AppBar.js +20 -16
  8. package/dist/components/BackTop/BackTop.cjs +1 -0
  9. package/dist/components/BackTop/BackTop.const.cjs +1 -0
  10. package/dist/components/BackTop/BackTop.const.d.ts +34 -0
  11. package/dist/components/BackTop/BackTop.const.js +29 -0
  12. package/dist/components/BackTop/BackTop.d.ts +21 -0
  13. package/dist/components/BackTop/BackTop.js +87 -0
  14. package/dist/components/BackTop/BackTop.types.d.ts +28 -0
  15. package/dist/components/BackTop/index.d.ts +3 -0
  16. package/dist/components/Badge/Badge.constants.d.ts +4 -4
  17. package/dist/components/Badge/Badge.types.d.ts +3 -3
  18. package/dist/components/BottomSheet/BottomSheet.cjs +1 -1
  19. package/dist/components/BottomSheet/BottomSheet.js +39 -38
  20. package/dist/components/Button/Button.cjs +1 -1
  21. package/dist/components/Button/Button.constants.cjs +38 -48
  22. package/dist/components/Button/Button.constants.d.ts +22 -3
  23. package/dist/components/Button/Button.constants.js +51 -50
  24. package/dist/components/Button/Button.d.ts +14 -7
  25. package/dist/components/Button/Button.js +123 -45
  26. package/dist/components/Button/Button.types.d.ts +22 -4
  27. package/dist/components/Calendar/Calendar.cjs +1 -1
  28. package/dist/components/Calendar/Calendar.js +3 -2
  29. package/dist/components/Card/Card.const.d.ts +2 -2
  30. package/dist/components/Card/Card.types.d.ts +2 -2
  31. package/dist/components/Chat/Chat.cjs +1 -0
  32. package/dist/components/Chat/Chat.const.cjs +1 -0
  33. package/dist/components/Chat/Chat.const.d.ts +26 -0
  34. package/dist/components/Chat/Chat.const.js +29 -0
  35. package/dist/components/Chat/Chat.d.ts +21 -0
  36. package/dist/components/Chat/Chat.js +179 -0
  37. package/dist/components/Chat/Chat.types.d.ts +55 -0
  38. package/dist/components/Chat/index.d.ts +2 -0
  39. package/dist/components/Confetti/Confetti.cjs +1 -0
  40. package/dist/components/Confetti/Confetti.const.cjs +1 -0
  41. package/dist/components/Confetti/Confetti.const.d.ts +16 -0
  42. package/dist/components/Confetti/Confetti.const.js +36 -0
  43. package/dist/components/Confetti/Confetti.d.ts +23 -0
  44. package/dist/components/Confetti/Confetti.js +94 -0
  45. package/dist/components/Confetti/Confetti.types.d.ts +50 -0
  46. package/dist/components/Confetti/index.d.ts +4 -0
  47. package/dist/components/Confetti/useConfetti.cjs +1 -0
  48. package/dist/components/Confetti/useConfetti.d.ts +13 -0
  49. package/dist/components/Confetti/useConfetti.js +12 -0
  50. package/dist/components/DatePicker/DatePicker.cjs +1 -1
  51. package/dist/components/DatePicker/DatePicker.js +3 -2
  52. package/dist/components/DiffViewer/DiffViewer.cjs +1 -0
  53. package/dist/components/DiffViewer/DiffViewer.const.cjs +1 -0
  54. package/dist/components/DiffViewer/DiffViewer.const.d.ts +18 -0
  55. package/dist/components/DiffViewer/DiffViewer.const.js +21 -0
  56. package/dist/components/DiffViewer/DiffViewer.d.ts +18 -0
  57. package/dist/components/DiffViewer/DiffViewer.js +127 -0
  58. package/dist/components/DiffViewer/DiffViewer.types.d.ts +40 -0
  59. package/dist/components/DiffViewer/DiffViewer.utils.cjs +3 -0
  60. package/dist/components/DiffViewer/DiffViewer.utils.d.ts +9 -0
  61. package/dist/components/DiffViewer/DiffViewer.utils.js +39 -0
  62. package/dist/components/DiffViewer/index.d.ts +2 -0
  63. package/dist/components/Drawer/Drawer.cjs +1 -1
  64. package/dist/components/Drawer/Drawer.js +35 -35
  65. package/dist/components/FloatingChat/FloatingChat.cjs +1 -0
  66. package/dist/components/FloatingChat/FloatingChat.const.cjs +1 -0
  67. package/dist/components/FloatingChat/FloatingChat.const.d.ts +12 -0
  68. package/dist/components/FloatingChat/FloatingChat.const.js +15 -0
  69. package/dist/components/FloatingChat/FloatingChat.d.ts +19 -0
  70. package/dist/components/FloatingChat/FloatingChat.js +144 -0
  71. package/dist/components/FloatingChat/FloatingChat.types.d.ts +44 -0
  72. package/dist/components/FloatingChat/index.d.ts +2 -0
  73. package/dist/components/JsonViewer/JsonViewer.cjs +1 -0
  74. package/dist/components/JsonViewer/JsonViewer.const.cjs +1 -0
  75. package/dist/components/JsonViewer/JsonViewer.const.d.ts +4 -0
  76. package/dist/components/JsonViewer/JsonViewer.const.js +24 -0
  77. package/dist/components/JsonViewer/JsonViewer.d.ts +17 -0
  78. package/dist/components/JsonViewer/JsonViewer.js +195 -0
  79. package/dist/components/JsonViewer/JsonViewer.types.d.ts +54 -0
  80. package/dist/components/JsonViewer/index.d.ts +2 -0
  81. package/dist/components/Kanban/Kanban.cjs +1 -1
  82. package/dist/components/Kanban/Kanban.js +18 -17
  83. package/dist/components/QRCode/QRCode.cjs +1 -0
  84. package/dist/components/QRCode/QRCode.const.cjs +1 -0
  85. package/dist/components/QRCode/QRCode.const.d.ts +21 -0
  86. package/dist/components/QRCode/QRCode.const.js +11 -0
  87. package/dist/components/QRCode/QRCode.d.ts +29 -0
  88. package/dist/components/QRCode/QRCode.js +68 -0
  89. package/dist/components/QRCode/QRCode.types.d.ts +32 -0
  90. package/dist/components/QRCode/QRCode.utils.cjs +1 -0
  91. package/dist/components/QRCode/QRCode.utils.d.ts +12 -0
  92. package/dist/components/QRCode/QRCode.utils.js +74 -0
  93. package/dist/components/QRCode/index.d.ts +3 -0
  94. package/dist/components/Spinner/Spinner.types.d.ts +2 -2
  95. package/dist/components/Terminal/Terminal.cjs +1 -0
  96. package/dist/components/Terminal/Terminal.const.cjs +1 -0
  97. package/dist/components/Terminal/Terminal.const.d.ts +32 -0
  98. package/dist/components/Terminal/Terminal.const.js +42 -0
  99. package/dist/components/Terminal/Terminal.d.ts +27 -0
  100. package/dist/components/Terminal/Terminal.js +155 -0
  101. package/dist/components/Terminal/Terminal.types.d.ts +49 -0
  102. package/dist/components/Terminal/index.d.ts +2 -0
  103. package/dist/components/Tour/Tour.cjs +1 -0
  104. package/dist/components/Tour/Tour.const.cjs +1 -0
  105. package/dist/components/Tour/Tour.const.d.ts +25 -0
  106. package/dist/components/Tour/Tour.const.js +38 -0
  107. package/dist/components/Tour/Tour.d.ts +17 -0
  108. package/dist/components/Tour/Tour.js +179 -0
  109. package/dist/components/Tour/Tour.types.d.ts +80 -0
  110. package/dist/components/Tour/index.d.ts +4 -0
  111. package/dist/components/Tour/useTour.cjs +1 -0
  112. package/dist/components/Tour/useTour.d.ts +14 -0
  113. package/dist/components/Tour/useTour.js +27 -0
  114. package/dist/components/Typography/Typography.cjs +1 -1
  115. package/dist/components/Typography/Typography.d.ts +5 -1
  116. package/dist/components/Typography/Typography.js +93 -57
  117. package/dist/components/Typography/Typography.types.d.ts +29 -2
  118. package/dist/components/index.cjs +1 -1
  119. package/dist/components/index.d.ts +19 -1
  120. package/dist/components/index.js +242 -218
  121. package/dist/context/BearProvider.cjs +1 -1
  122. package/dist/context/BearProvider.d.ts +110 -5
  123. package/dist/context/BearProvider.js +198 -53
  124. package/dist/context/defaultTheme.cjs +1 -1
  125. package/dist/context/defaultTheme.js +11 -11
  126. package/dist/hooks/index.cjs +1 -1
  127. package/dist/hooks/index.d.ts +14 -0
  128. package/dist/hooks/index.js +56 -39
  129. package/dist/hooks/useBearComponent/index.d.ts +2 -0
  130. package/dist/hooks/useBearComponent/useBearComponent.cjs +1 -0
  131. package/dist/hooks/useBearComponent/useBearComponent.d.ts +71 -0
  132. package/dist/hooks/useBearComponent/useBearComponent.js +54 -0
  133. package/dist/hooks/useBearComponent/useBearComponent.types.d.ts +40 -0
  134. package/dist/hooks/useIdle/index.d.ts +2 -0
  135. package/dist/hooks/useIdle/useIdle.cjs +1 -0
  136. package/dist/hooks/useIdle/useIdle.d.ts +22 -0
  137. package/dist/hooks/useIdle/useIdle.js +66 -0
  138. package/dist/hooks/useIdle/useIdle.types.d.ts +29 -0
  139. package/dist/hooks/useLongPress/index.d.ts +2 -0
  140. package/dist/hooks/useLongPress/useLongPress.cjs +1 -0
  141. package/dist/hooks/useLongPress/useLongPress.d.ts +17 -0
  142. package/dist/hooks/useLongPress/useLongPress.js +44 -0
  143. package/dist/hooks/useLongPress/useLongPress.types.d.ts +26 -0
  144. package/dist/hooks/useOnline/index.d.ts +2 -0
  145. package/dist/hooks/useOnline/useOnline.cjs +1 -0
  146. package/dist/hooks/useOnline/useOnline.d.ts +16 -0
  147. package/dist/hooks/useOnline/useOnline.js +25 -0
  148. package/dist/hooks/useOnline/useOnline.types.d.ts +15 -0
  149. package/dist/hooks/usePageVisibility/index.d.ts +2 -0
  150. package/dist/hooks/usePageVisibility/usePageVisibility.cjs +1 -0
  151. package/dist/hooks/usePageVisibility/usePageVisibility.d.ts +19 -0
  152. package/dist/hooks/usePageVisibility/usePageVisibility.js +26 -0
  153. package/dist/hooks/usePageVisibility/usePageVisibility.types.d.ts +15 -0
  154. package/dist/hooks/useSpotlight/index.d.ts +2 -0
  155. package/dist/hooks/useSpotlight/useSpotlight.cjs +1 -0
  156. package/dist/hooks/useSpotlight/useSpotlight.d.ts +24 -0
  157. package/dist/hooks/useSpotlight/useSpotlight.js +49 -0
  158. package/dist/hooks/useSpotlight/useSpotlight.types.d.ts +23 -0
  159. package/dist/hooks/useWebSocket/index.d.ts +2 -0
  160. package/dist/hooks/useWebSocket/useWebSocket.cjs +1 -0
  161. package/dist/hooks/useWebSocket/useWebSocket.d.ts +22 -0
  162. package/dist/hooks/useWebSocket/useWebSocket.js +75 -0
  163. package/dist/hooks/useWebSocket/useWebSocket.types.d.ts +44 -0
  164. package/dist/index.cjs +1 -1
  165. package/dist/index.js +324 -283
  166. package/dist/styles.css +1 -1
  167. package/dist/types/component.types.d.ts +125 -42
  168. package/dist/types/theme.types.d.ts +82 -0
  169. package/package.json +1 -1
@@ -0,0 +1,71 @@
1
+ import { ReactNode } from 'react';
2
+ import { BearComponentOverrides, ButtonVariantsConfig } from '../../types/component.types';
3
+ import { UseBearComponentReturn, BearComponentContextValue } from './useBearComponent.types';
4
+ interface BearComponentProviderProps {
5
+ children: ReactNode;
6
+ /** Initial component overrides */
7
+ components?: BearComponentOverrides;
8
+ /** Initial variant configurations */
9
+ variants?: {
10
+ Button?: ButtonVariantsConfig;
11
+ };
12
+ }
13
+ /**
14
+ * Provider for global component customization
15
+ *
16
+ * @example
17
+ * ```tsx
18
+ * <BearComponentProvider
19
+ * components={{
20
+ * Button: {
21
+ * root: { borderRadius: '9999px' }
22
+ * }
23
+ * }}
24
+ * variants={{
25
+ * Button: {
26
+ * primary: {
27
+ * bg: '#ec4899',
28
+ * bgHover: '#db2777',
29
+ * text: '#ffffff'
30
+ * }
31
+ * }
32
+ * }}
33
+ * >
34
+ * <App />
35
+ * </BearComponentProvider>
36
+ * ```
37
+ */
38
+ export declare const BearComponentProvider: ({ children, components: initialComponents, variants: initialVariants, }: BearComponentProviderProps) => import("react/jsx-runtime").JSX.Element;
39
+ /**
40
+ * Access the component customization context
41
+ */
42
+ export declare const useBearComponentContext: () => BearComponentContextValue | null;
43
+ /**
44
+ * Hook to get and apply component style overrides
45
+ *
46
+ * @param componentKey - The component key (e.g., 'Button', 'Input')
47
+ * @param defaultStyles - Optional default styles to merge with
48
+ *
49
+ * @example
50
+ * ```tsx
51
+ * // Inside a component
52
+ * const { getStyles, mergeStyles, hasOverrides } = useBearComponent('Button');
53
+ *
54
+ * return (
55
+ * <button style={mergeStyles('root', { padding: '8px' })}>
56
+ * <span style={getStyles('text')}>Click me</span>
57
+ * </button>
58
+ * );
59
+ * ```
60
+ */
61
+ export declare const useBearComponent: <K extends keyof BearComponentOverrides>(componentKey: K, defaultStyles?: BearComponentOverrides[K]) => UseBearComponentReturn;
62
+ /**
63
+ * Shorthand alias for useBearComponent
64
+ *
65
+ * @example
66
+ * ```tsx
67
+ * const { getStyles } = useBC('Button');
68
+ * ```
69
+ */
70
+ export declare const useBC: <K extends keyof BearComponentOverrides>(componentKey: K, defaultStyles?: BearComponentOverrides[K]) => UseBearComponentReturn;
71
+ export {};
@@ -0,0 +1,54 @@
1
+ import { jsx as b } from "react/jsx-runtime";
2
+ import { createContext as O, useState as d, useCallback as r, useMemo as y, useContext as x } from "react";
3
+ const v = O(null), h = ({
4
+ children: p,
5
+ components: m = {},
6
+ variants: u = {}
7
+ }) => {
8
+ const [t, c] = d(m), [a, l] = d(u), o = r((e, S) => {
9
+ c((i) => ({
10
+ ...i,
11
+ [e]: {
12
+ ...i[e] || {},
13
+ ...S
14
+ }
15
+ }));
16
+ }, []), n = r((e, S) => {
17
+ l((i) => ({
18
+ ...i,
19
+ [e]: {
20
+ ...i[e] || {},
21
+ ...S
22
+ }
23
+ }));
24
+ }, []), s = r((e) => t[e], [t]), C = r((e) => a[e], [a]), g = r(() => {
25
+ c({}), l({});
26
+ }, []), B = y(() => ({
27
+ components: t,
28
+ variants: a,
29
+ registerComponent: o,
30
+ registerVariant: n,
31
+ getComponentStyles: s,
32
+ getVariantConfig: C,
33
+ clearOverrides: g
34
+ }), [t, a, o, n, s, C, g]);
35
+ return /* @__PURE__ */ b(v.Provider, { value: B, children: p });
36
+ }, j = () => x(v), P = (p, m) => {
37
+ const u = x(v), t = u == null ? void 0 : u.components[p], c = r((o = "root") => {
38
+ const n = t, s = m, C = n == null ? void 0 : n[o];
39
+ return {
40
+ ...(s == null ? void 0 : s[o]) || {},
41
+ ...C || {}
42
+ };
43
+ }, [t, m]), a = r((o = "root", n) => ({
44
+ ...c(o),
45
+ ...n || {}
46
+ }), [c]), l = y(() => t !== void 0 && Object.keys(t).length > 0, [t]);
47
+ return { getStyles: c, mergeStyles: a, hasOverrides: l };
48
+ }, k = P;
49
+ export {
50
+ h as BearComponentProvider,
51
+ k as useBC,
52
+ P as useBearComponent,
53
+ j as useBearComponentContext
54
+ };
@@ -0,0 +1,40 @@
1
+ import { CSSProperties } from 'react';
2
+ import { BearComponentOverrides, ButtonVariantsConfig } from '../../types/component.types';
3
+ /**
4
+ * Component part style definition
5
+ */
6
+ export interface ComponentPartStyles {
7
+ [part: string]: CSSProperties;
8
+ }
9
+ /**
10
+ * Return type for useBearComponent hook
11
+ */
12
+ export interface UseBearComponentReturn {
13
+ /** Get styles for a specific component part */
14
+ getStyles: (part?: string) => CSSProperties;
15
+ /** Merge with additional styles */
16
+ mergeStyles: (part: string | undefined, additionalStyles?: CSSProperties) => CSSProperties;
17
+ /** Check if component has overrides */
18
+ hasOverrides: boolean;
19
+ }
20
+ /**
21
+ * Context value for component customization
22
+ */
23
+ export interface BearComponentContextValue {
24
+ /** Component style overrides */
25
+ components: BearComponentOverrides;
26
+ /** Variant configurations */
27
+ variants: {
28
+ Button?: ButtonVariantsConfig;
29
+ };
30
+ /** Register component overrides */
31
+ registerComponent: <K extends keyof BearComponentOverrides>(componentKey: K, styles: BearComponentOverrides[K]) => void;
32
+ /** Register variant overrides */
33
+ registerVariant: <K extends 'Button'>(componentKey: K, variantConfig: ButtonVariantsConfig) => void;
34
+ /** Get component styles */
35
+ getComponentStyles: <K extends keyof BearComponentOverrides>(componentKey: K) => BearComponentOverrides[K] | undefined;
36
+ /** Get variant config */
37
+ getVariantConfig: <K extends 'Button'>(componentKey: K) => ButtonVariantsConfig | undefined;
38
+ /** Clear all overrides */
39
+ clearOverrides: () => void;
40
+ }
@@ -0,0 +1,2 @@
1
+ export { useIdle } from './useIdle';
2
+ export type { UseIdleOptions, UseIdleReturn } from './useIdle.types';
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),y=["mousemove","mousedown","keydown","touchstart","scroll","wheel"],A=6e4;function L(S={}){const{timeout:a=A,events:f=y,initialState:k=!1,onIdle:d,onActive:m}=S,[w,v]=e.useState(k),[D,I]=e.useState(Date.now()),[h,T]=e.useState(a),[c,b]=e.useState(!1),o=e.useRef(null),r=e.useRef(null),l=e.useRef(d),i=e.useRef(m);e.useEffect(()=>{l.current=d,i.current=m},[d,m]);const u=e.useCallback(()=>{o.current&&(clearTimeout(o.current),o.current=null),r.current&&(clearInterval(r.current),r.current=null)},[]),t=e.useCallback(()=>{if(c)return;u();const s=Date.now();T(a),r.current=setInterval(()=>{const n=Date.now()-s;T(Math.max(0,a-n))},1e3),o.current=setTimeout(()=>{var n;v(!0),(n=l.current)==null||n.call(l),r.current&&clearInterval(r.current)},a)},[a,c,u]),E=e.useCallback(()=>{var n;if(c)return;const s=w;v(!1),I(Date.now()),t(),s&&((n=i.current)==null||n.call(i))},[c,w,t]),C=e.useCallback(()=>{v(!1),I(Date.now()),t()},[t]),R=e.useCallback(()=>{b(!0),u()},[u]),p=e.useCallback(()=>{b(!1),t()},[t]);return e.useEffect(()=>{if(!(typeof window>"u"))return t(),f.forEach(s=>{window.addEventListener(s,E,{passive:!0})}),()=>{u(),f.forEach(s=>{window.removeEventListener(s,E)})}},[f,E,t,u]),{isIdle:w,remaining:h,lastActive:D,reset:C,pause:R,resume:p}}exports.useIdle=L;
@@ -0,0 +1,22 @@
1
+ import { UseIdleOptions, UseIdleReturn } from './useIdle.types';
2
+ /**
3
+ * useIdle - Detect user inactivity
4
+ *
5
+ * @example
6
+ * ```tsx
7
+ * const { isIdle, remaining, reset } = useIdle({
8
+ * timeout: 30000, // 30 seconds
9
+ * onIdle: () => console.log('User is idle'),
10
+ * onActive: () => console.log('User is active'),
11
+ * });
12
+ *
13
+ * return (
14
+ * <div>
15
+ * {isIdle ? 'User is idle' : `Active (${remaining}ms until idle)`}
16
+ * <button onClick={reset}>Reset</button>
17
+ * </div>
18
+ * );
19
+ * ```
20
+ */
21
+ export declare function useIdle(options?: UseIdleOptions): UseIdleReturn;
22
+ export default useIdle;
@@ -0,0 +1,66 @@
1
+ import { useState as f, useRef as d, useEffect as A, useCallback as c } from "react";
2
+ const F = [
3
+ "mousemove",
4
+ "mousedown",
5
+ "keydown",
6
+ "touchstart",
7
+ "scroll",
8
+ "wheel"
9
+ ], M = 6e4;
10
+ function R(L = {}) {
11
+ const {
12
+ timeout: o = M,
13
+ events: m = F,
14
+ initialState: y = !1,
15
+ onIdle: w,
16
+ onActive: v
17
+ } = L, [E, I] = f(y), [S, D] = f(Date.now()), [U, h] = f(o), [u, p] = f(!1), a = d(null), r = d(null), i = d(w), l = d(v);
18
+ A(() => {
19
+ i.current = w, l.current = v;
20
+ }, [w, v]);
21
+ const s = c(() => {
22
+ a.current && (clearTimeout(a.current), a.current = null), r.current && (clearInterval(r.current), r.current = null);
23
+ }, []), e = c(() => {
24
+ if (u) return;
25
+ s();
26
+ const t = Date.now();
27
+ h(o), r.current = setInterval(() => {
28
+ const n = Date.now() - t;
29
+ h(Math.max(0, o - n));
30
+ }, 1e3), a.current = setTimeout(() => {
31
+ var n;
32
+ I(!0), (n = i.current) == null || n.call(i), r.current && clearInterval(r.current);
33
+ }, o);
34
+ }, [o, u, s]), T = c(() => {
35
+ var n;
36
+ if (u) return;
37
+ const t = E;
38
+ I(!1), D(Date.now()), e(), t && ((n = l.current) == null || n.call(l));
39
+ }, [u, E, e]), g = c(() => {
40
+ I(!1), D(Date.now()), e();
41
+ }, [e]), k = c(() => {
42
+ p(!0), s();
43
+ }, [s]), x = c(() => {
44
+ p(!1), e();
45
+ }, [e]);
46
+ return A(() => {
47
+ if (!(typeof window > "u"))
48
+ return e(), m.forEach((t) => {
49
+ window.addEventListener(t, T, { passive: !0 });
50
+ }), () => {
51
+ s(), m.forEach((t) => {
52
+ window.removeEventListener(t, T);
53
+ });
54
+ };
55
+ }, [m, T, e, s]), {
56
+ isIdle: E,
57
+ remaining: U,
58
+ lastActive: S,
59
+ reset: g,
60
+ pause: k,
61
+ resume: x
62
+ };
63
+ }
64
+ export {
65
+ R as useIdle
66
+ };
@@ -0,0 +1,29 @@
1
+ /**
2
+ * useIdle hook types
3
+ */
4
+ export interface UseIdleOptions {
5
+ /** Timeout in milliseconds before user is considered idle (default: 60000 = 1 min) */
6
+ timeout?: number;
7
+ /** Events to listen for as activity (default: mouse, keyboard, touch, scroll) */
8
+ events?: (keyof WindowEventMap)[];
9
+ /** Initial idle state */
10
+ initialState?: boolean;
11
+ /** Callback when user becomes idle */
12
+ onIdle?: () => void;
13
+ /** Callback when user becomes active */
14
+ onActive?: () => void;
15
+ }
16
+ export interface UseIdleReturn {
17
+ /** Whether the user is currently idle */
18
+ isIdle: boolean;
19
+ /** Time remaining until idle (ms) */
20
+ remaining: number;
21
+ /** Last activity timestamp */
22
+ lastActive: number;
23
+ /** Reset the idle timer */
24
+ reset: () => void;
25
+ /** Pause idle detection */
26
+ pause: () => void;
27
+ /** Resume idle detection */
28
+ resume: () => void;
29
+ }
@@ -0,0 +1,2 @@
1
+ export { useLongPress } from './useLongPress';
2
+ export type { UseLongPressOptions, UseLongPressReturn } from './useLongPress.types';
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),p=400;function D(d={}){const{threshold:R=p,onLongPress:s,onClick:i,onStart:u,onFinish:c,onCancel:n,filterEvents:b,disabled:C=!1}=d,l=t.useRef(null),k=t.useRef(!1),r=t.useRef(!1),E=t.useRef(null),o=t.useCallback(()=>{l.current&&(clearTimeout(l.current),l.current=null)},[]),a=t.useCallback(e=>{C||b&&!b(e)||(r.current=!0,k.current=!1,E.current=e,u==null||u(e),l.current=setTimeout(()=>{k.current=!0,s==null||s(e)},R))},[C,b,u,s,R]),T=t.useCallback(e=>{r.current&&(o(),r.current=!1,n==null||n(e))},[o,n]),f=t.useCallback(e=>{r.current&&(o(),r.current=!1,!k.current&&i&&i(e),c==null||c(e))},[o,i,c]),L=t.useCallback(e=>{e.button===0&&a(e)},[a]),g=t.useCallback(e=>{f(e)},[f]),m=t.useCallback(e=>{T(e)},[T]),M=t.useCallback(e=>{a(e)},[a]),h=t.useCallback(e=>{f(e)},[f]);return{onMouseDown:L,onMouseUp:g,onMouseLeave:m,onTouchStart:M,onTouchEnd:h}}exports.useLongPress=D;
@@ -0,0 +1,17 @@
1
+ import { UseLongPressOptions, UseLongPressReturn } from './useLongPress.types';
2
+ /**
3
+ * useLongPress - Detect long press gestures
4
+ *
5
+ * @example
6
+ * ```tsx
7
+ * const longPressProps = useLongPress({
8
+ * threshold: 500,
9
+ * onLongPress: () => console.log('Long pressed!'),
10
+ * onClick: () => console.log('Clicked!'),
11
+ * });
12
+ *
13
+ * return <button {...longPressProps}>Hold me</button>;
14
+ * ```
15
+ */
16
+ export declare function useLongPress(options?: UseLongPressOptions): UseLongPressReturn;
17
+ export default useLongPress;
@@ -0,0 +1,44 @@
1
+ import { useRef as a, useCallback as t } from "react";
2
+ const H = 400;
3
+ function g(L = {}) {
4
+ const {
5
+ threshold: E = H,
6
+ onLongPress: n,
7
+ onClick: R,
8
+ onStart: c,
9
+ onFinish: s,
10
+ onCancel: u,
11
+ filterEvents: T,
12
+ disabled: d = !1
13
+ } = L, o = a(null), m = a(!1), e = a(!1), b = a(null), f = t(() => {
14
+ o.current && (clearTimeout(o.current), o.current = null);
15
+ }, []), l = t((r) => {
16
+ d || T && !T(r) || (e.current = !0, m.current = !1, b.current = r, c == null || c(r), o.current = setTimeout(() => {
17
+ m.current = !0, n == null || n(r);
18
+ }, E));
19
+ }, [d, T, c, n, E]), p = t((r) => {
20
+ e.current && (f(), e.current = !1, u == null || u(r));
21
+ }, [f, u]), i = t((r) => {
22
+ e.current && (f(), e.current = !1, !m.current && R && R(r), s == null || s(r));
23
+ }, [f, R, s]), h = t((r) => {
24
+ r.button === 0 && l(r);
25
+ }, [l]), D = t((r) => {
26
+ i(r);
27
+ }, [i]), M = t((r) => {
28
+ p(r);
29
+ }, [p]), k = t((r) => {
30
+ l(r);
31
+ }, [l]), A = t((r) => {
32
+ i(r);
33
+ }, [i]);
34
+ return {
35
+ onMouseDown: h,
36
+ onMouseUp: D,
37
+ onMouseLeave: M,
38
+ onTouchStart: k,
39
+ onTouchEnd: A
40
+ };
41
+ }
42
+ export {
43
+ g as useLongPress
44
+ };
@@ -0,0 +1,26 @@
1
+ import { MouseEvent, TouchEvent } from 'react';
2
+ export interface UseLongPressOptions {
3
+ /** Duration in ms to trigger long press (default: 400) */
4
+ threshold?: number;
5
+ /** Callback for long press */
6
+ onLongPress?: (event: MouseEvent | TouchEvent) => void;
7
+ /** Callback for regular click (if released before threshold) */
8
+ onClick?: (event: MouseEvent | TouchEvent) => void;
9
+ /** Callback when press starts */
10
+ onStart?: (event: MouseEvent | TouchEvent) => void;
11
+ /** Callback when press ends (regardless of long press) */
12
+ onFinish?: (event: MouseEvent | TouchEvent) => void;
13
+ /** Callback when press is cancelled (e.g., mouse leaves) */
14
+ onCancel?: (event: MouseEvent | TouchEvent) => void;
15
+ /** Filter function to determine if event should trigger */
16
+ filterEvents?: (event: MouseEvent | TouchEvent) => boolean;
17
+ /** Disable the long press */
18
+ disabled?: boolean;
19
+ }
20
+ export interface UseLongPressReturn {
21
+ onMouseDown: (event: MouseEvent) => void;
22
+ onMouseUp: (event: MouseEvent) => void;
23
+ onMouseLeave: (event: MouseEvent) => void;
24
+ onTouchStart: (event: TouchEvent) => void;
25
+ onTouchEnd: (event: TouchEvent) => void;
26
+ }
@@ -0,0 +1,2 @@
1
+ export { useOnline } from './useOnline';
2
+ export type { UseOnlineOptions, UseOnlineReturn } from './useOnline.types';
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react");function w(a={}){const{onOnline:o,onOffline:r}=a,[f,c]=e.useState(()=>typeof navigator<"u"?navigator.onLine:!0),[d,l]=e.useState(null),t=e.useRef(o),i=e.useRef(r);e.useEffect(()=>{t.current=o,i.current=r},[o,r]);const s=e.useCallback(()=>{var n;c(!0),l(Date.now()),(n=t.current)==null||n.call(t)},[]),u=e.useCallback(()=>{var n;c(!1),l(Date.now()),(n=i.current)==null||n.call(i)},[]);return e.useEffect(()=>{if(!(typeof window>"u"))return window.addEventListener("online",s),window.addEventListener("offline",u),()=>{window.removeEventListener("online",s),window.removeEventListener("offline",u)}},[s,u]),{isOnline:f,since:d}}exports.useOnline=w;
@@ -0,0 +1,16 @@
1
+ import { UseOnlineOptions, UseOnlineReturn } from './useOnline.types';
2
+ /**
3
+ * useOnline - Detect online/offline network status
4
+ *
5
+ * @example
6
+ * ```tsx
7
+ * const { isOnline, since } = useOnline({
8
+ * onOnline: () => console.log('Back online!'),
9
+ * onOffline: () => console.log('Gone offline!'),
10
+ * });
11
+ *
12
+ * return <div>{isOnline ? '🟢 Online' : '🔴 Offline'}</div>;
13
+ * ```
14
+ */
15
+ export declare function useOnline(options?: UseOnlineOptions): UseOnlineReturn;
16
+ export default useOnline;
@@ -0,0 +1,25 @@
1
+ import { useState as l, useRef as d, useEffect as f, useCallback as a } from "react";
2
+ function O(w = {}) {
3
+ const { onOnline: i, onOffline: o } = w, [v, u] = l(
4
+ () => typeof navigator < "u" ? navigator.onLine : !0
5
+ ), [E, c] = l(null), e = d(i), t = d(o);
6
+ f(() => {
7
+ e.current = i, t.current = o;
8
+ }, [i, o]);
9
+ const r = a(() => {
10
+ var n;
11
+ u(!0), c(Date.now()), (n = e.current) == null || n.call(e);
12
+ }, []), s = a(() => {
13
+ var n;
14
+ u(!1), c(Date.now()), (n = t.current) == null || n.call(t);
15
+ }, []);
16
+ return f(() => {
17
+ if (!(typeof window > "u"))
18
+ return window.addEventListener("online", r), window.addEventListener("offline", s), () => {
19
+ window.removeEventListener("online", r), window.removeEventListener("offline", s);
20
+ };
21
+ }, [r, s]), { isOnline: v, since: E };
22
+ }
23
+ export {
24
+ O as useOnline
25
+ };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * useOnline hook types
3
+ */
4
+ export interface UseOnlineOptions {
5
+ /** Callback when going online */
6
+ onOnline?: () => void;
7
+ /** Callback when going offline */
8
+ onOffline?: () => void;
9
+ }
10
+ export interface UseOnlineReturn {
11
+ /** Whether the browser is currently online */
12
+ isOnline: boolean;
13
+ /** Time since last status change (ms) */
14
+ since: number | null;
15
+ }
@@ -0,0 +1,2 @@
1
+ export { usePageVisibility } from './usePageVisibility';
2
+ export type { UsePageVisibilityOptions, UsePageVisibilityReturn } from './usePageVisibility.types';
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react");function b(a={}){const{onVisible:n,onHidden:s}=a,[r,d]=e.useState(()=>typeof document<"u"?document.visibilityState:"visible"),i=e.useRef(n),t=e.useRef(s);e.useEffect(()=>{i.current=n,t.current=s},[n,s]);const u=e.useCallback(()=>{var o,l;const c=document.visibilityState;d(c),c==="visible"?(o=i.current)==null||o.call(i):c==="hidden"&&((l=t.current)==null||l.call(t))},[]);return e.useEffect(()=>{if(!(typeof document>"u"))return document.addEventListener("visibilitychange",u),()=>{document.removeEventListener("visibilitychange",u)}},[u]),{isVisible:r==="visible",visibilityState:r}}exports.usePageVisibility=b;
@@ -0,0 +1,19 @@
1
+ import { UsePageVisibilityOptions, UsePageVisibilityReturn } from './usePageVisibility.types';
2
+ /**
3
+ * usePageVisibility - Detect when page/tab is visible or hidden
4
+ *
5
+ * @example
6
+ * ```tsx
7
+ * const { isVisible, visibilityState } = usePageVisibility({
8
+ * onVisible: () => console.log('Tab is visible'),
9
+ * onHidden: () => console.log('Tab is hidden'),
10
+ * });
11
+ *
12
+ * // Pause video when tab is hidden
13
+ * useEffect(() => {
14
+ * if (!isVisible) videoRef.current?.pause();
15
+ * }, [isVisible]);
16
+ * ```
17
+ */
18
+ export declare function usePageVisibility(options?: UsePageVisibilityOptions): UsePageVisibilityReturn;
19
+ export default usePageVisibility;
@@ -0,0 +1,26 @@
1
+ import { useState as v, useRef as l, useEffect as d, useCallback as f } from "react";
2
+ function m(a = {}) {
3
+ const { onVisible: t, onHidden: n } = a, [u, b] = v(
4
+ () => typeof document < "u" ? document.visibilityState : "visible"
5
+ ), e = l(t), i = l(n);
6
+ d(() => {
7
+ e.current = t, i.current = n;
8
+ }, [t, n]);
9
+ const s = f(() => {
10
+ var r, o;
11
+ const c = document.visibilityState;
12
+ b(c), c === "visible" ? (r = e.current) == null || r.call(e) : c === "hidden" && ((o = i.current) == null || o.call(i));
13
+ }, []);
14
+ return d(() => {
15
+ if (!(typeof document > "u"))
16
+ return document.addEventListener("visibilitychange", s), () => {
17
+ document.removeEventListener("visibilitychange", s);
18
+ };
19
+ }, [s]), {
20
+ isVisible: u === "visible",
21
+ visibilityState: u
22
+ };
23
+ }
24
+ export {
25
+ m as usePageVisibility
26
+ };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * usePageVisibility hook types
3
+ */
4
+ export interface UsePageVisibilityOptions {
5
+ /** Callback when page becomes visible */
6
+ onVisible?: () => void;
7
+ /** Callback when page becomes hidden */
8
+ onHidden?: () => void;
9
+ }
10
+ export interface UsePageVisibilityReturn {
11
+ /** Whether the page is currently visible */
12
+ isVisible: boolean;
13
+ /** Document visibility state */
14
+ visibilityState: DocumentVisibilityState;
15
+ }
@@ -0,0 +1,2 @@
1
+ export { useSpotlight } from './useSpotlight';
2
+ export type { UseSpotlightOptions, UseSpotlightReturn } from './useSpotlight.types';
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),h=(b={})=>{const{size:o=120,color:r="rgba(255, 255, 255, 0.15)",enabled:t=!0}=b,s=e.useRef(null),[n,g]=e.useState({x:0,y:0}),[i,a]=e.useState(!1),c=e.useCallback(p=>{if(!t||!s.current)return;const d=s.current.getBoundingClientRect();g({x:p.clientX-d.left,y:p.clientY-d.top})},[t]),u=e.useCallback(()=>{t&&a(!0)},[t]),l=e.useCallback(()=>{a(!1)},[]),y=e.useMemo(()=>!t||!i?{position:"absolute",pointerEvents:"none",opacity:0,transition:"opacity 0.2s ease"}:{position:"absolute",pointerEvents:"none",left:n.x-o/2,top:n.y-o/2,width:o,height:o,borderRadius:"50%",background:`radial-gradient(circle, ${r} 0%, transparent 70%)`,opacity:1,transition:"opacity 0.2s ease",zIndex:0},[t,i,n.x,n.y,o,r]),f=e.useMemo(()=>({onMouseMove:c,onMouseEnter:u,onMouseLeave:l}),[c,u,l]);return{ref:s,spotlightStyle:y,isHovered:i,handlers:f}};exports.useSpotlight=h;
@@ -0,0 +1,24 @@
1
+ import { UseSpotlightOptions, UseSpotlightReturn } from './useSpotlight.types';
2
+ /**
3
+ * Hook for mouse-follow spotlight/hover effect
4
+ *
5
+ * @example
6
+ * ```tsx
7
+ * const { ref, spotlightStyle, handlers } = useSpotlight({
8
+ * size: 100,
9
+ * color: 'rgba(255, 255, 255, 0.15)'
10
+ * });
11
+ *
12
+ * return (
13
+ * <button
14
+ * ref={ref}
15
+ * {...handlers}
16
+ * style={{ position: 'relative', overflow: 'hidden' }}
17
+ * >
18
+ * <span style={spotlightStyle} />
19
+ * Click me
20
+ * </button>
21
+ * );
22
+ * ```
23
+ */
24
+ export declare const useSpotlight: (options?: UseSpotlightOptions) => UseSpotlightReturn;
@@ -0,0 +1,49 @@
1
+ import { useRef as x, useState as f, useCallback as r, useMemo as y } from "react";
2
+ const m = (g = {}) => {
3
+ const {
4
+ size: e = 120,
5
+ color: i = "rgba(255, 255, 255, 0.15)",
6
+ enabled: t = !0
7
+ } = g, n = x(null), [o, b] = f({ x: 0, y: 0 }), [s, a] = f(!1), c = r((p) => {
8
+ if (!t || !n.current) return;
9
+ const d = n.current.getBoundingClientRect();
10
+ b({
11
+ x: p.clientX - d.left,
12
+ y: p.clientY - d.top
13
+ });
14
+ }, [t]), u = r(() => {
15
+ t && a(!0);
16
+ }, [t]), l = r(() => {
17
+ a(!1);
18
+ }, []), h = y(() => !t || !s ? {
19
+ position: "absolute",
20
+ pointerEvents: "none",
21
+ opacity: 0,
22
+ transition: "opacity 0.2s ease"
23
+ } : {
24
+ position: "absolute",
25
+ pointerEvents: "none",
26
+ left: o.x - e / 2,
27
+ top: o.y - e / 2,
28
+ width: e,
29
+ height: e,
30
+ borderRadius: "50%",
31
+ background: `radial-gradient(circle, ${i} 0%, transparent 70%)`,
32
+ opacity: 1,
33
+ transition: "opacity 0.2s ease",
34
+ zIndex: 0
35
+ }, [t, s, o.x, o.y, e, i]), v = y(() => ({
36
+ onMouseMove: c,
37
+ onMouseEnter: u,
38
+ onMouseLeave: l
39
+ }), [c, u, l]);
40
+ return {
41
+ ref: n,
42
+ spotlightStyle: h,
43
+ isHovered: s,
44
+ handlers: v
45
+ };
46
+ };
47
+ export {
48
+ m as useSpotlight
49
+ };
@@ -0,0 +1,23 @@
1
+ import { RefObject, CSSProperties } from 'react';
2
+ export interface UseSpotlightOptions {
3
+ /** Size of the spotlight in pixels */
4
+ size?: number;
5
+ /** Color of the spotlight (with alpha) */
6
+ color?: string;
7
+ /** Whether spotlight is enabled */
8
+ enabled?: boolean;
9
+ }
10
+ export interface UseSpotlightReturn {
11
+ /** Ref to attach to the element */
12
+ ref: RefObject<HTMLElement | null>;
13
+ /** Style object for the spotlight overlay */
14
+ spotlightStyle: CSSProperties;
15
+ /** Whether mouse is currently over the element */
16
+ isHovered: boolean;
17
+ /** Event handlers to attach */
18
+ handlers: {
19
+ onMouseMove: (e: React.MouseEvent) => void;
20
+ onMouseEnter: () => void;
21
+ onMouseLeave: () => void;
22
+ };
23
+ }
@@ -0,0 +1,2 @@
1
+ export { useWebSocket } from './useWebSocket';
2
+ export type { UseWebSocketOptions, UseWebSocketReturn, WebSocketStatus } from './useWebSocket.types';
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react");function L(E,M={}){const{autoConnect:O=!0,autoReconnect:T=!0,reconnectAttempts:a=5,reconnectInterval:W=3e3,protocols:N,onOpen:R,onClose:g,onError:C,onMessage:m}=M,[w,o]=e.useState("closed"),[P,J]=e.useState(null),[h,p]=e.useState(null),r=e.useRef(null),l=e.useRef(0),f=e.useRef(null),u=e.useRef(!1),i=e.useRef(R),d=e.useRef(g),S=e.useRef(C),b=e.useRef(m);e.useEffect(()=>{i.current=R,d.current=g,S.current=C,b.current=m},[R,g,C,m]);const s=e.useCallback(()=>{f.current&&(clearTimeout(f.current),f.current=null)},[]),k=e.useCallback(()=>{var c;if(!(typeof window>"u")&&((c=r.current)==null?void 0:c.readyState)!==WebSocket.OPEN){s(),o("connecting"),p(null);try{r.current=new WebSocket(E,N),r.current.onopen=t=>{var n;u.current||(o("open"),l.current=0,(n=i.current)==null||n.call(i,t))},r.current.onclose=t=>{var n;u.current||(o("closed"),(n=d.current)==null||n.call(d,t),T&&l.current<a&&!u.current&&(l.current+=1,f.current=setTimeout(()=>{k()},W)))},r.current.onerror=t=>{var n;u.current||(p(t),(n=S.current)==null||n.call(S,t))},r.current.onmessage=t=>{var n;if(!u.current){try{const I=JSON.parse(t.data);J(I)}catch{J(t.data)}(n=b.current)==null||n.call(b,t)}}}catch(t){o("closed"),p(t)}}},[E,N,T,a,W,s]),j=e.useCallback((c,t)=>{s(),l.current=a,r.current&&(o("closing"),r.current.close(c,t),r.current=null)},[s,a]),y=e.useCallback(c=>{var t;((t=r.current)==null?void 0:t.readyState)===WebSocket.OPEN&&r.current.send(c)},[]),q=e.useCallback(c=>{y(JSON.stringify(c))},[y]),A=e.useCallback(()=>r.current,[]);return e.useEffect(()=>(u.current=!1,O&&k(),()=>{u.current=!0,s(),r.current&&(r.current.close(),r.current=null)}),[O,k,s]),{status:w,isConnected:w==="open",lastMessage:P,error:h,send:y,sendJson:q,connect:k,disconnect:j,getSocket:A}}exports.useWebSocket=L;