@noxickon/onyx 0.0.4-dev.8 → 1.0.0

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 (67) hide show
  1. package/dist/chunks/hooks-DiKvsNs-.js +48 -0
  2. package/dist/chunks/hooks-bJFfbTks.js +8624 -0
  3. package/dist/chunks/query-BhvXa-m6.js +10 -0
  4. package/dist/chunks/query-iDn3qBGF.js +14 -0
  5. package/dist/chunks/ui-ChsTPgui.js +41 -0
  6. package/dist/chunks/ui-DxsSYHCv.js +20634 -0
  7. package/dist/chunks/useAuth-BFgXzu6Q.js +12 -0
  8. package/dist/chunks/useAuth-DxoDe3YA.js +1 -0
  9. package/dist/contexts/contexts.cjs.js +5 -0
  10. package/dist/contexts/contexts.es.js +156 -0
  11. package/dist/contexts.d.ts +117 -0
  12. package/dist/hooks/hooks.cjs.js +1 -6
  13. package/dist/hooks/hooks.es.js +11 -1916
  14. package/dist/hooks.d.ts +84 -22
  15. package/dist/index.d.ts +1782 -268
  16. package/dist/layouts/layouts.cjs.js +1 -0
  17. package/dist/layouts/layouts.es.js +688 -0
  18. package/dist/layouts.d.ts +430 -0
  19. package/dist/onyx.cjs.js +1 -1
  20. package/dist/onyx.es.js +53 -1395
  21. package/dist/pages/pages.cjs.js +2 -2
  22. package/dist/pages/pages.es.js +72 -70
  23. package/dist/pages.d.ts +4 -4
  24. package/dist/routes/routes.cjs.js +1 -0
  25. package/dist/routes/routes.es.js +31 -0
  26. package/dist/routes.d.ts +28 -0
  27. package/dist/shared.css +77 -48
  28. package/dist/ui.css +1 -0
  29. package/dist/utils/utils.cjs.js +1 -1
  30. package/dist/utils/utils.es.js +20 -6
  31. package/dist/utils.d.ts +109 -5
  32. package/package.json +39 -28
  33. package/dist/chunks/AuthContext-CaZKJMxQ.js +0 -2149
  34. package/dist/chunks/AuthContext-uU1aP9gj.js +0 -31
  35. package/dist/chunks/Button-D-v4l8ZE.js +0 -20
  36. package/dist/chunks/Button-bARrxYyo.js +0 -11053
  37. package/dist/chunks/Input-CLi1H63d.js +0 -1
  38. package/dist/chunks/Input-dfvmdIHi.js +0 -138
  39. package/dist/chunks/_commonjsHelpers-C6fGbg64.js +0 -6
  40. package/dist/chunks/_commonjsHelpers-DwGv2jUC.js +0 -1
  41. package/dist/chunks/constants-B1_n9ezb.js +0 -1
  42. package/dist/chunks/constants-CDXq37n6.js +0 -4
  43. package/dist/chunks/errorHelper--G-SWQzN.js +0 -18
  44. package/dist/chunks/errorHelper-DaP_XxEx.js +0 -1
  45. package/dist/chunks/formatTimestamp-CMxOnPo1.js +0 -12
  46. package/dist/chunks/formatTimestamp-TTsNcy7u.js +0 -1
  47. package/dist/chunks/index-CPwC_oqh.js +0 -561
  48. package/dist/chunks/index-DY808_YF.js +0 -2
  49. package/dist/chunks/isObject-BDHKUJKN.js +0 -1
  50. package/dist/chunks/isObject-vmP43YLW.js +0 -6
  51. package/dist/chunks/jsx-runtime--oOP9f8K.js +0 -284
  52. package/dist/chunks/jsx-runtime-CITbqOLs.js +0 -22
  53. package/dist/chunks/tslib.es6-ci7D5hcx.js +0 -44
  54. package/dist/chunks/tslib.es6-nRfFZWHa.js +0 -1
  55. package/dist/chunks/useAuth-BsWbsZD5.js +0 -1
  56. package/dist/chunks/useAuth-CkaMowHd.js +0 -11
  57. package/dist/chunks/useForm-DfmfCtGn.js +0 -3070
  58. package/dist/chunks/useForm-OVVxm4qZ.js +0 -18
  59. package/dist/chunks/useQuery-Dh3SZN5S.js +0 -1482
  60. package/dist/chunks/useQuery-y4De9xeL.js +0 -2
  61. package/dist/context/context.cjs.js +0 -1
  62. package/dist/context/context.es.js +0 -39
  63. package/dist/context.d.ts +0 -47
  64. package/dist/index.css +0 -1
  65. package/dist/layout/layout.cjs.js +0 -1
  66. package/dist/layout/layout.es.js +0 -265
  67. package/dist/layout.d.ts +0 -90
package/dist/hooks.d.ts CHANGED
@@ -1,10 +1,9 @@
1
- import { ApolloQueryResult } from '@apollo/client';
2
1
  import { AxiosProgressEvent } from 'axios';
3
2
  import { AxiosResponse } from 'axios';
4
3
  import { DocumentNode } from 'graphql';
5
- import { FetchResult } from '@apollo/client';
6
- import { MutationHookOptions } from '@apollo/client';
7
- import { QueryHookOptions } from '@apollo/client';
4
+ import { RefObject } from 'react';
5
+ import { useLazyQuery } from '@apollo/client/react';
6
+ import { useMutation } from '@apollo/client/react';
8
7
  import * as z from 'zod/v4';
9
8
 
10
9
  export declare type BuiltInRule = 'nullable' | 'required' | 'string' | 'email' | 'url' | 'number' | 'integer' | 'positive' | 'negative' | 'ipv4' | 'boolean' | 'date' | 'array' | 'object' | `min:${number}` | `max:${number}` | `minLength:${number}` | `maxLength:${number}` | `pattern:${string}` | 'file' | `fileSize:${string}` | `fileType:${string}` | `arrayMinLength:${number}` | `arrayMaxLength:${number}` | 'arrayEach:string' | 'arrayEach:number' | 'arrayEach:email' | 'arrayEach:url' | 'arrayEach:file' | `arrayEach:fileSize:${string}` | `arrayEach:fileType:${string}`;
@@ -14,23 +13,27 @@ export declare interface CustomValidatorWithMessage {
14
13
  message: string;
15
14
  }
16
15
 
17
- declare type GetNestedValue<T, P extends string> = P extends keyof T ? T[P] : P extends `${infer K}.${infer Rest}` ? K extends keyof T ? GetNestedValue<T[K], Rest> : never : never;
16
+ declare type FormDataWithoutRoot<T> = T & {
17
+ root?: never;
18
+ };
19
+
20
+ export declare type GetNestedValue<T, P extends string> = P extends keyof T ? T[P] : P extends `${infer K}.${infer Rest}` ? K extends keyof T ? GetNestedValue<T[K], Rest> : never : never;
18
21
 
19
22
  export declare const handleRules: (rules: ValidationRule[]) => z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
20
23
 
21
- export declare interface QueryOptions {
24
+ export declare interface QueryOptions<TResponse = unknown> {
22
25
  onBefore?: () => void;
23
26
  onError?: (error: unknown) => void;
24
27
  onFinish?: () => void;
25
- onSuccess?: (response: ApolloQueryResult<unknown>) => void;
28
+ onSuccess?: (response: Awaited<ReturnType<ReturnType<typeof useLazyQuery<TResponse>>[0]>>) => void;
26
29
  skipValidation?: boolean;
27
30
  }
28
31
 
29
- export declare interface SubmitOptions {
32
+ export declare interface SubmitOptions<TResponse = unknown> {
30
33
  onBefore?: () => void;
31
34
  onError?: (error: unknown) => void;
32
35
  onFinish?: () => void;
33
- onSuccess?: (response: FetchResult) => void;
36
+ onSuccess?: (response: Awaited<ReturnType<ReturnType<typeof useMutation<TResponse>>[0]>>) => void;
34
37
  skipValidation?: boolean;
35
38
  }
36
39
 
@@ -44,6 +47,20 @@ export declare interface UploadOptions {
44
47
  skipValidation?: boolean;
45
48
  }
46
49
 
50
+ export declare function useControllableState<T>({ defaultValue, name, onChange, value: controlledValue, }: UseControllableStateParams<T>): UseControllableStateReturn<T>;
51
+
52
+ export declare interface UseControllableStateParams<T> {
53
+ defaultValue?: T;
54
+ name?: string;
55
+ onChange?: (value: T | undefined) => void;
56
+ value?: T;
57
+ }
58
+
59
+ export declare type UseControllableStateReturn<T> = [
60
+ T | undefined,
61
+ (value: T | undefined | ((prev: T | undefined) => T | undefined)) => void
62
+ ];
63
+
47
64
  export declare const useFileUpload: <T extends Record<string, unknown>>({ endpoint, headers, initialData, validationRules, }: UseFileUploadOptions<T>) => UseFileUploadReturn<T>;
48
65
 
49
66
  export declare interface UseFileUploadOptions<T extends Record<string, unknown>> extends UseFormStateOptions<T> {
@@ -57,42 +74,63 @@ export declare interface UseFileUploadReturn<T extends Record<string, unknown>>
57
74
  upload: (options?: UploadOptions) => void;
58
75
  }
59
76
 
60
- export declare const useFilter: <T extends Record<string, unknown>>({ headers, initialData, options, query: queryDocument, validationRules, }: UseFilterOptions<T>) => UseFilterReturn<T>;
77
+ export declare const useFilter: <T extends Record<string, any>, TResponse = unknown>({ headers, initialData, options, query: queryDocument, validationRules, }: UseFilterOptions<T, TResponse>) => UseFilterReturn<T, TResponse>;
61
78
 
62
- export declare interface UseFilterOptions<T extends Record<string, unknown>> extends UseFormStateOptions<T> {
79
+ export declare interface UseFilterOptions<T extends Record<string, any>, TResponse = unknown> extends UseFormStateOptions<T> {
63
80
  headers?: Record<string, string>;
64
- options?: QueryHookOptions;
81
+ options?: Parameters<typeof useLazyQuery<TResponse>>[1];
65
82
  query: DocumentNode;
66
83
  }
67
84
 
68
- export declare interface UseFilterReturn<T extends Record<string, unknown>> extends Omit<UseFormStateReturn<T>, 'data' | 'setData'> {
69
- data: unknown;
85
+ export declare interface UseFilterReturn<T extends Record<string, any>, TResponse = unknown> extends Omit<UseFormStateReturn<T>, 'data' | 'setData'> {
86
+ data: TResponse | undefined;
70
87
  error: unknown;
71
88
  filter: T;
72
89
  isLoading: boolean;
73
- query: (options?: QueryOptions) => void;
90
+ query: (options?: QueryOptions<TResponse>) => void;
74
91
  refetch: () => void;
75
92
  setFilter: UseFormStateReturn<T>['setData'];
76
93
  }
77
94
 
78
- export declare const useForm: <T extends Record<string, unknown>>({ headers, initialData, operation, options, validationRules, }: UseFormOptions<T>) => UseFormReturn<T>;
95
+ export declare const useFocus: ({ containerRef, options }: UseFocusParams) => UseFocusReturn;
79
96
 
80
- export declare interface UseFormOptions<T extends Record<string, unknown>> extends UseFormStateOptions<T> {
97
+ export declare interface UseFocusOptions {
98
+ autoFocus?: boolean;
99
+ enabled?: boolean;
100
+ restoreFocus?: boolean;
101
+ trapFocus?: boolean;
102
+ }
103
+
104
+ export declare interface UseFocusParams {
105
+ containerRef: RefObject<HTMLElement | null>;
106
+ options?: UseFocusOptions;
107
+ }
108
+
109
+ export declare interface UseFocusReturn {
110
+ focusFirst: () => void;
111
+ focusLast: () => void;
112
+ getCurrentFocus: () => HTMLElement | null;
113
+ getFocusableElements: () => HTMLElement[];
114
+ }
115
+
116
+ export declare const useForm: <T extends Record<string, any>, TResponse = unknown>({ headers, initialData, operation, options, validationRules, }: UseFormOptions<T, TResponse>) => UseFormReturn<T, TResponse>;
117
+
118
+ export declare interface UseFormOptions<T extends Record<string, any>, TResponse = unknown> extends UseFormStateOptions<T> {
81
119
  headers?: Record<string, string>;
82
120
  operation: DocumentNode;
83
- options?: MutationHookOptions;
121
+ options?: Parameters<typeof useMutation<TResponse>>[1];
84
122
  }
85
123
 
86
- export declare interface UseFormReturn<T extends Record<string, unknown>> extends UseFormStateReturn<T> {
124
+ export declare interface UseFormReturn<T extends Record<string, any>, TResponse = unknown> extends UseFormStateReturn<T> {
87
125
  isLoading: boolean;
88
- submit: (options?: SubmitOptions) => void;
89
- transform: (transformFn: (data: T) => unknown) => Omit<UseFormReturn<T>, 'transform'>;
126
+ submit: (options?: SubmitOptions<TResponse>) => void;
127
+ transform: (transformFn: (data: T) => unknown) => Omit<UseFormReturn<T, TResponse>, 'transform'>;
90
128
  }
91
129
 
92
130
  export declare const useFormState: <T extends Record<string, unknown>>({ initialData, validationRules, }: UseFormStateOptions<T>) => UseFormStateReturn<T>;
93
131
 
94
132
  export declare interface UseFormStateOptions<T extends Record<string, unknown> = Record<string, unknown>> {
95
- initialData: T;
133
+ initialData: FormDataWithoutRoot<T>;
96
134
  validationRules?: ValidatorConfig;
97
135
  }
98
136
 
@@ -113,6 +151,30 @@ export declare interface UseFormStateReturn<T = Record<string, unknown>> {
113
151
  validate: () => boolean;
114
152
  }
115
153
 
154
+ export declare const useKeyboard: ({ allowRepeat, enabled, onArrowDown, onArrowUp, onEnter, onEscape, onTab, }: UseKeyboardOptions) => void;
155
+
156
+ export declare interface UseKeyboardOptions {
157
+ allowRepeat?: boolean;
158
+ enabled?: boolean;
159
+ onArrowDown?: () => void;
160
+ onArrowUp?: () => void;
161
+ onEnter?: () => void;
162
+ onEscape?: () => void;
163
+ onTab?: () => void;
164
+ }
165
+
166
+ export declare const useOverflowDetection: ({ selector, }?: UseOverflowDetectionOptions) => UseOverflowDetectionReturn;
167
+
168
+ export declare interface UseOverflowDetectionOptions {
169
+ selector?: string;
170
+ }
171
+
172
+ export declare interface UseOverflowDetectionReturn {
173
+ checkOverflow: () => void;
174
+ handleResize: (node: HTMLDivElement | null) => () => void;
175
+ overflowAmount: number;
176
+ }
177
+
116
178
  export declare type ValidationError = string | string[];
117
179
 
118
180
  export declare type ValidationErrors = Record<string, ValidationError>;