@gnwebsoft/ui 3.0.0 → 3.0.2

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 (74) hide show
  1. package/README.md +688 -0
  2. package/dist/chunk-4H3AFH7A.js +505 -0
  3. package/dist/chunk-DE62KYFK.js +122 -0
  4. package/dist/chunk-DEPJRTVT.js +1 -0
  5. package/dist/chunk-EBRUE2WR.cjs +493 -0
  6. package/dist/chunk-FD57PCAC.cjs +1 -0
  7. package/dist/chunk-H3GQLELL.js +2025 -0
  8. package/dist/chunk-MVPLBJRK.cjs +1 -0
  9. package/dist/chunk-OJF67RNM.js +1 -0
  10. package/dist/chunk-OT7COE7R.cjs +2025 -0
  11. package/dist/chunk-R2YK4LTT.cjs +122 -0
  12. package/dist/chunk-U6SDYCWF.js +493 -0
  13. package/dist/chunk-ZC7FGYL2.cjs +505 -0
  14. package/dist/components/index.cjs +25 -0
  15. package/dist/components/index.d.cts +752 -0
  16. package/dist/components/index.d.ts +664 -15
  17. package/dist/components/index.js +25 -24
  18. package/dist/enhanced-z-I7EHVS.d.cts +134 -0
  19. package/dist/enhanced-z-I7EHVS.d.ts +134 -0
  20. package/dist/hooks/index.cjs +12 -0
  21. package/dist/hooks/index.d.cts +95 -0
  22. package/dist/hooks/index.d.ts +82 -4
  23. package/dist/hooks/index.js +12 -7
  24. package/dist/index.cjs +127 -0
  25. package/dist/index.d.cts +14 -0
  26. package/dist/index.d.ts +4 -8
  27. package/dist/index.js +127 -58
  28. package/dist/types/index.cjs +2 -0
  29. package/dist/types/index.d.cts +241 -0
  30. package/dist/types/index.d.ts +212 -15
  31. package/dist/types/index.js +2 -1
  32. package/dist/utils/index.cjs +45 -0
  33. package/dist/utils/index.d.cts +366 -0
  34. package/dist/utils/index.d.ts +317 -10
  35. package/dist/utils/index.js +45 -22
  36. package/dist/wrappers/index.cjs +54 -0
  37. package/dist/wrappers/index.d.cts +1684 -0
  38. package/dist/wrappers/index.d.ts +1601 -118
  39. package/dist/wrappers/index.js +54 -8
  40. package/package.json +139 -92
  41. package/dist/AsyncSelectPayload-Cz4bgak0.d.mts +0 -10
  42. package/dist/AsyncSelectPayload-Cz4bgak0.d.ts +0 -10
  43. package/dist/OptionItem-oN6XnOTJ.d.mts +0 -14
  44. package/dist/OptionItem-oN6XnOTJ.d.ts +0 -14
  45. package/dist/chunk-2JFL7TS5.mjs +0 -0
  46. package/dist/chunk-5HOGPCEO.mjs +0 -1427
  47. package/dist/chunk-6BGQA4BQ.js +0 -1
  48. package/dist/chunk-6JZ35VQJ.js +0 -19
  49. package/dist/chunk-6NOXJGU2.js +0 -1427
  50. package/dist/chunk-7M2VOCYN.js +0 -1
  51. package/dist/chunk-BWQUYXUW.mjs +0 -1634
  52. package/dist/chunk-D3J7MWAU.js +0 -1634
  53. package/dist/chunk-EVPUCTZA.mjs +0 -0
  54. package/dist/chunk-FSU3H777.mjs +0 -473
  55. package/dist/chunk-GFSTK7KN.mjs +0 -19
  56. package/dist/chunk-I7EIUZKK.js +0 -332
  57. package/dist/chunk-JKUOV3MN.js +0 -473
  58. package/dist/chunk-RQS44YC7.mjs +0 -332
  59. package/dist/components/index.d.mts +0 -103
  60. package/dist/components/index.mjs +0 -24
  61. package/dist/hooks/index.d.mts +0 -17
  62. package/dist/hooks/index.mjs +0 -7
  63. package/dist/index.d.mts +0 -18
  64. package/dist/index.mjs +0 -58
  65. package/dist/types/index.d.mts +0 -44
  66. package/dist/types/index.mjs +0 -1
  67. package/dist/utils/index.d.mts +0 -59
  68. package/dist/utils/index.mjs +0 -22
  69. package/dist/wrappers/index.d.mts +0 -201
  70. package/dist/wrappers/index.mjs +0 -8
  71. package/dist/wrappers2/index.d.mts +0 -247
  72. package/dist/wrappers2/index.d.ts +0 -247
  73. package/dist/wrappers2/index.js +0 -8
  74. package/dist/wrappers2/index.mjs +0 -8
@@ -1,44 +1,241 @@
1
1
  import { GridSortModel } from '@mui/x-data-grid';
2
- export { a as AsyncSelectMultiPayload, A as AsyncSelectPayload } from '../AsyncSelectPayload-Cz4bgak0.js';
3
- export { A as AsyncMultiSelectPayload, O as OptionItem, a as OptionItem2 } from '../OptionItem-oN6XnOTJ.js';
4
2
 
5
- type ValidationErrors = {
3
+ /**
4
+ * Type definition for server validation errors structure.
5
+ *
6
+ * This type represents the format of validation errors returned from server APIs.
7
+ * It supports multiple error formats for each field, allowing flexibility in how
8
+ * validation errors are communicated and processed.
9
+ *
10
+ * @example
11
+ * String error messages:
12
+ * ```tsx
13
+ * const errors: ValidationErrors = {
14
+ * email: 'Email is required',
15
+ * username: 'Username must be unique'
16
+ * };
17
+ * ```
18
+ *
19
+ * @example
20
+ * Array of error messages:
21
+ * ```tsx
22
+ * const errors: ValidationErrors = {
23
+ * password: [
24
+ * 'Password must be at least 8 characters',
25
+ * 'Password must contain at least one number',
26
+ * 'Password must contain at least one special character'
27
+ * ]
28
+ * };
29
+ * ```
30
+ *
31
+ * @example
32
+ * Boolean flags for validation state:
33
+ * ```tsx
34
+ * const errors: ValidationErrors = {
35
+ * termsAccepted: false, // Field is invalid
36
+ * emailVerified: true // Field has an error
37
+ * };
38
+ * ```
39
+ *
40
+ * @example
41
+ * Structured error objects:
42
+ * ```tsx
43
+ * const errors: ValidationErrors = {
44
+ * dateOfBirth: {
45
+ * key: 'DATE_INVALID',
46
+ * message: 'Date of birth must be in the past'
47
+ * }
48
+ * };
49
+ * ```
50
+ *
51
+ * @public
52
+ */
53
+ interface ValidationErrors {
6
54
  [field: string]: string | string[] | boolean | {
7
55
  key: string;
8
56
  message: string;
9
57
  };
10
- };
58
+ }
11
59
 
12
- type ApiResponse<TModel> = {
60
+ /**
61
+ * Standardized API response structure for server communications.
62
+ *
63
+ * This type defines the common structure for API responses throughout the application,
64
+ * providing a consistent interface for handling server responses, errors, and data.
65
+ * It follows a standard error response format with optional success data.
66
+ *
67
+ * @template TModel - The type of data contained in the apiData field
68
+ *
69
+ * @example
70
+ * Success response with data:
71
+ * ```tsx
72
+ * const userResponse: ApiResponse<User> = {
73
+ * status: 200,
74
+ * apiData: {
75
+ * id: 1,
76
+ * name: 'John Doe',
77
+ * email: 'john@example.com'
78
+ * }
79
+ * };
80
+ * ```
81
+ *
82
+ * @example
83
+ * Error response with validation errors:
84
+ * ```tsx
85
+ * const errorResponse: ApiResponse<null> = {
86
+ * type: 'validation_error',
87
+ * title: 'Validation failed',
88
+ * status: 400,
89
+ * traceId: 'abc123',
90
+ * errors: {
91
+ * email: 'Email is required',
92
+ * password: ['Too short', 'Must contain numbers']
93
+ * },
94
+ * modelErrors: true
95
+ * };
96
+ * ```
97
+ *
98
+ * @public
99
+ */
100
+ interface ApiResponse<TModel> {
101
+ /**
102
+ * The type or category of the response/error
103
+ * @example "validation_error" | "server_error" | "success"
104
+ */
13
105
  type?: string;
106
+ /**
107
+ * Human-readable title or summary of the response
108
+ * @example "Validation Failed" | "User Created Successfully"
109
+ */
14
110
  title?: string;
111
+ /**
112
+ * HTTP status code of the response
113
+ * @example 200 | 400 | 500
114
+ */
15
115
  status?: number;
116
+ /**
117
+ * Unique identifier for tracing/debugging the request
118
+ * @example "abc123-def456-ghi789"
119
+ */
16
120
  traceId?: string;
121
+ /**
122
+ * Field-specific validation errors
123
+ */
17
124
  errors?: ValidationErrors;
125
+ /**
126
+ * Flag indicating if there are model validation errors
127
+ */
18
128
  modelErrors?: boolean;
129
+ /**
130
+ * The actual response data/payload
131
+ */
19
132
  apiData?: TModel;
20
- };
133
+ }
21
134
 
22
- type OperationResponse = {
135
+ interface AsyncSelectPayload {
136
+ query: string | null;
137
+ initialValue?: string | number | null;
138
+ }
139
+ interface AsyncSelectMultiPayload {
140
+ query: string | null;
141
+ initialValues?: string[] | number[] | null;
142
+ }
143
+
144
+ /**
145
+ * Standard option item structure for select components.
146
+ *
147
+ * This type defines the expected structure for option items used in
148
+ * select components throughout the application. It provides a consistent
149
+ * interface with string labels and values.
150
+ *
151
+ * @example
152
+ * Basic usage:
153
+ * ```tsx
154
+ * const categories: OptionItem[] = [
155
+ * { Label: 'Technology', Value: 'tech' },
156
+ * { Label: 'Finance', Value: 'finance' },
157
+ * { Label: 'Healthcare', Value: 'health' }
158
+ * ];
159
+ * ```
160
+ *
161
+ * @public
162
+ */
163
+ interface OptionItem {
164
+ /** Display text shown to the user */
165
+ Label: string;
166
+ /** Internal value used for form submission and identification */
167
+ Value: string;
168
+ }
169
+ /**
170
+ * Payload structure for async multi-select operations.
171
+ *
172
+ * This type defines the data structure used when performing asynchronous
173
+ * multi-select operations, typically for server-side filtering and loading
174
+ * of options with pre-selected values.
175
+ *
176
+ * @example
177
+ * Search with initial values:
178
+ * ```tsx
179
+ * const payload: AsyncMultiSelectPayload = {
180
+ * query: 'john',
181
+ * initialValues: ['user1', 'user2', 'user3']
182
+ * };
183
+ * ```
184
+ *
185
+ * @public
186
+ */
187
+ interface AsyncMultiSelectPayload {
188
+ /** Search query string for filtering options */
189
+ query: string | null;
190
+ /** Pre-selected values to be included in the selection */
191
+ initialValues?: string[] | number[] | null;
192
+ }
193
+ /**
194
+ * Extended option item structure supporting both string and number values.
195
+ *
196
+ * This type extends the basic OptionItem to support numeric values,
197
+ * providing flexibility for different data types while maintaining
198
+ * the same label-value structure.
199
+ *
200
+ * @example
201
+ * Mixed value types:
202
+ * ```tsx
203
+ * const options: OptionItem2[] = [
204
+ * { Label: 'First Option', Value: 1 },
205
+ * { Label: 'Second Option', Value: 'second' },
206
+ * { Label: 'Third Option', Value: 3 }
207
+ * ];
208
+ * ```
209
+ *
210
+ * @public
211
+ */
212
+ interface OptionItem2 {
213
+ /** Display text shown to the user */
214
+ Label: string;
215
+ /** Internal value that can be either a number or string */
216
+ Value: number | string;
217
+ }
218
+
219
+ interface OperationResponse {
23
220
  id?: number;
24
221
  rowsAffected: number;
25
- };
222
+ }
26
223
 
27
- type PostModel<TFilterModel> = {
224
+ interface PostModel<TFilterModel> {
28
225
  filterModel?: TFilterModel;
29
226
  pageOffset: number;
30
227
  pageSize: number;
31
228
  sortField: string | null;
32
229
  sortOrder: "asc" | "desc" | null | undefined;
33
230
  sortModel?: GridSortModel;
34
- };
35
- type ListResponse<TGridModel> = {
231
+ }
232
+ interface ListResponse<TGridModel> {
36
233
  Data: TGridModel[];
37
234
  Total: number;
38
- };
39
- type ValueLabel = {
235
+ }
236
+ interface ValueLabel {
40
237
  Value: number | string;
41
238
  Label: string;
42
- };
239
+ }
43
240
 
44
- export type { ApiResponse, ListResponse, OperationResponse, PostModel, ValidationErrors, ValueLabel };
241
+ export type { ApiResponse, AsyncMultiSelectPayload, AsyncSelectMultiPayload, AsyncSelectPayload, ListResponse, OperationResponse, OptionItem, OptionItem2, PostModel, ValidationErrors, ValueLabel };
@@ -1 +1,2 @@
1
- "use strict";require('../chunk-6BGQA4BQ.js');
1
+ import "../chunk-DEPJRTVT.js";
2
+ //# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFtdLAogICJzb3VyY2VzQ29udGVudCI6IFtdLAogICJtYXBwaW5ncyI6ICIiLAogICJuYW1lcyI6IFtdCn0K
@@ -0,0 +1,45 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+ var _chunkZC7FGYL2cjs = require('../chunk-ZC7FGYL2.cjs');
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+ exports.api = _chunkZC7FGYL2cjs.api; exports.api2 = _chunkZC7FGYL2cjs.api2; exports.flattenObjectKeys = _chunkZC7FGYL2cjs.flattenObjectKeys; exports.getTimezone = _chunkZC7FGYL2cjs.getTimezone; exports.handleServerErrors = _chunkZC7FGYL2cjs.handleServerErrors; exports.propertyExists = _chunkZC7FGYL2cjs.propertyExists; exports.readValueAsDate = _chunkZC7FGYL2cjs.readValueAsDate; exports.removeLeadingTrailingSlashes = _chunkZC7FGYL2cjs.removeLeadingTrailingSlashes; exports.schemaTools = _chunkZC7FGYL2cjs.schemaTools; exports.typedWatch = _chunkZC7FGYL2cjs.typedWatch; exports.useWatchBatch = _chunkZC7FGYL2cjs.useWatchBatch; exports.useWatchBoolean = _chunkZC7FGYL2cjs.useWatchBoolean; exports.useWatchConditional = _chunkZC7FGYL2cjs.useWatchConditional; exports.useWatchDebounced = _chunkZC7FGYL2cjs.useWatchDebounced; exports.useWatchDefault = _chunkZC7FGYL2cjs.useWatchDefault; exports.useWatchField = _chunkZC7FGYL2cjs.useWatchField; exports.useWatchFields = _chunkZC7FGYL2cjs.useWatchFields; exports.useWatchForm = _chunkZC7FGYL2cjs.useWatchForm; exports.useWatchSelector = _chunkZC7FGYL2cjs.useWatchSelector; exports.useWatchTransform = _chunkZC7FGYL2cjs.useWatchTransform;
45
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImQ6XFxQcm9qZWN0c1xcZ253ZWItbW9ub3JlcG9cXHBhY2thZ2VzXFx1aVxcZGlzdFxcdXRpbHNcXGluZGV4LmNqcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTtBQUNFO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDRix5REFBOEI7QUFDOUI7QUFDRTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0YsK3BDQUFDIiwiZmlsZSI6IkQ6XFxQcm9qZWN0c1xcZ253ZWItbW9ub3JlcG9cXHBhY2thZ2VzXFx1aVxcZGlzdFxcdXRpbHNcXGluZGV4LmNqcyJ9
@@ -0,0 +1,366 @@
1
+ import { PostModel, ApiResponse, ListResponse, ValidationErrors } from '../types/index.cjs';
2
+ import { PickerValidDate } from '@mui/x-date-pickers';
3
+ import { useLocalizationContext } from '@mui/x-date-pickers/internals';
4
+ import * as react_hook_form from 'react-hook-form';
5
+ import { FieldValues, UseFormSetError, Control, DeepPartialSkipArrayKey, Path, PathValue } from 'react-hook-form';
6
+ import { z } from 'zod';
7
+ import '@mui/x-data-grid';
8
+
9
+ declare class api {
10
+ static filter<T, TFilter>(url: string, postModel: PostModel<TFilter>): Promise<ApiResponse<ListResponse<T>>>;
11
+ static post<T>(url: string, body?: any): Promise<ApiResponse<T>>;
12
+ static get<T>(url: string): Promise<ApiResponse<T>>;
13
+ static delete<T>(url: string): Promise<ApiResponse<T>>;
14
+ static put<T>(url: string, body?: any): Promise<ApiResponse<T>>;
15
+ static fetch(url: string, options?: any): Promise<Response>;
16
+ static tempFetch<T>(url: string, options?: any): Promise<ApiResponse<T>>;
17
+ static upload<T>(url: string, formData: FormData): Promise<ApiResponse<T>>;
18
+ }
19
+
20
+ declare class api2 {
21
+ static filter<T, TFilter>(url: string, postModel: PostModel<TFilter>): Promise<ApiResponse<ListResponse<T>>>;
22
+ static post<T>(url: string, body?: any): Promise<ApiResponse<T>>;
23
+ static get<T>(url: string): Promise<ApiResponse<T>>;
24
+ static delete<T>(url: string): Promise<ApiResponse<T>>;
25
+ static put<T>(url: string, body?: any): Promise<ApiResponse<T>>;
26
+ static fetch(url: string, options?: any): Promise<Response>;
27
+ static tempFetch<T>(url: string, options?: any): Promise<ApiResponse<T>>;
28
+ static upload<T>(url: string, formData: FormData): Promise<ApiResponse<T>>;
29
+ }
30
+
31
+ /**
32
+ * Recursively flattens an object into a flat structure with dot-notation keys.
33
+ *
34
+ * This utility function takes a nested object and converts it into a flat object
35
+ * where nested properties are represented using dot notation. It handles both
36
+ * nested objects and arrays, preserving all levels of the original structure
37
+ * as separate keys in the result.
38
+ *
39
+ * @example
40
+ * Basic object flattening:
41
+ * ```tsx
42
+ * const nested = {
43
+ * user: {
44
+ * name: 'John',
45
+ * address: {
46
+ * city: 'New York',
47
+ * zip: '10001'
48
+ * }
49
+ * }
50
+ * };
51
+ *
52
+ * const flattened = flattenObjectKeys(nested);
53
+ * // Result:
54
+ * // {
55
+ * // 'user': { name: 'John', address: { city: 'New York', zip: '10001' } },
56
+ * // 'user.name': 'John',
57
+ * // 'user.address': { city: 'New York', zip: '10001' },
58
+ * // 'user.address.city': 'New York',
59
+ * // 'user.address.zip': '10001'
60
+ * // }
61
+ * ```
62
+ *
63
+ * @example
64
+ * Array handling:
65
+ * ```tsx
66
+ * const withArrays = {
67
+ * items: [
68
+ * { id: 1, name: 'Item 1' },
69
+ * { id: 2, name: 'Item 2' }
70
+ * ]
71
+ * };
72
+ *
73
+ * const flattened = flattenObjectKeys(withArrays);
74
+ * // Result includes:
75
+ * // {
76
+ * // 'items': [...],
77
+ * // 'items.0': { id: 1, name: 'Item 1' },
78
+ * // 'items.0.id': 1,
79
+ * // 'items.0.name': 'Item 1',
80
+ * // 'items.1': { id: 2, name: 'Item 2' },
81
+ * // 'items.1.id': 2,
82
+ * // 'items.1.name': 'Item 2'
83
+ * // }
84
+ * ```
85
+ *
86
+ * @param obj - The object to flatten
87
+ * @param prefix - Internal parameter for building key paths (used in recursion)
88
+ * @returns A flat object with dot-notation keys representing the original structure
89
+ *
90
+ * @public
91
+ */
92
+ declare const flattenObjectKeys: (obj: any, prefix?: string) => {
93
+ [x: string]: any;
94
+ };
95
+
96
+ declare function getTimezone<TDate extends PickerValidDate>(adapter: ReturnType<typeof useLocalizationContext>, value: TDate): string | null;
97
+
98
+ /**
99
+ * Configuration options for the handleServerErrors function.
100
+ *
101
+ * @template TFieldValues - The form values type
102
+ *
103
+ * @public
104
+ */
105
+ interface HandleServerErrorsType<TFieldValues extends FieldValues = FieldValues> {
106
+ /**
107
+ * Server validation errors object containing field-specific error messages
108
+ * @example { email: 'Email is already taken', password: ['Too short', 'Must contain numbers'] }
109
+ */
110
+ errors?: ValidationErrors;
111
+ /**
112
+ * The setError function from react-hook-form for setting field errors
113
+ */
114
+ setError: UseFormSetError<TFieldValues>;
115
+ }
116
+ /**
117
+ * Processes server validation errors and applies them to react-hook-form fields.
118
+ *
119
+ * This utility function takes validation errors from a server response and automatically
120
+ * applies them to the corresponding form fields using react-hook-form's setError function.
121
+ * It supports various error formats including strings, arrays of strings, and boolean flags.
122
+ *
123
+ * The function uses object flattening to handle nested error structures and ensures
124
+ * that only valid field paths are processed.
125
+ *
126
+ * @example
127
+ * Basic usage with server response:
128
+ * ```tsx
129
+ * const { setError } = useForm();
130
+ *
131
+ * try {
132
+ * await submitForm(data);
133
+ * } catch (error) {
134
+ * handleServerErrors({
135
+ * errors: error.response.data.errors,
136
+ * setError
137
+ * });
138
+ * }
139
+ * ```
140
+ *
141
+ * @example
142
+ * With different error formats:
143
+ * ```tsx
144
+ * const serverErrors = {
145
+ * email: 'Email is already taken',
146
+ * password: ['Too short', 'Must contain numbers'],
147
+ * terms: true // Boolean flag indicating invalid
148
+ * };
149
+ *
150
+ * handleServerErrors({ errors: serverErrors, setError });
151
+ * // Results in:
152
+ * // - email field shows: "Email is already taken"
153
+ * // - password field shows: "Too short Must contain numbers"
154
+ * // - terms field shows: "Field is not valid."
155
+ * ```
156
+ *
157
+ * @template TFieldValues - The form values type
158
+ *
159
+ * @param args - Configuration object containing errors and setError function
160
+ *
161
+ * @public
162
+ */
163
+ declare const handleServerErrors: <TFieldValues extends FieldValues = FieldValues>(args: HandleServerErrorsType<TFieldValues>) => void;
164
+
165
+ /**
166
+ * Type-safe property existence checker that acts as a type guard.
167
+ *
168
+ * Checks if a given property exists on an object and narrows the TypeScript type
169
+ * to include that property. This is useful for safely accessing properties on
170
+ * objects of unknown structure while maintaining type safety.
171
+ *
172
+ * @template X - The type of the object being checked
173
+ * @template Y - The type of the property key (extends PropertyKey)
174
+ *
175
+ * @param obj - The object to check for the property
176
+ * @param prop - The property key to check for existence
177
+ *
178
+ * @returns A type predicate indicating whether the property exists on the object.
179
+ * If true, the object type is narrowed to include the specified property.
180
+ *
181
+ * @example
182
+ * ```typescript
183
+ * const data: unknown = { name: "John", age: 30 };
184
+ *
185
+ * if (propertyExists(data, "name")) {
186
+ * // TypeScript now knows data has a 'name' property
187
+ * console.log(data.name); // Type-safe access
188
+ * }
189
+ *
190
+ * // Check for nested property existence
191
+ * if (propertyExists(obj, "user") && propertyExists(obj.user, "id")) {
192
+ * console.log(obj.user.id); // Safe nested access
193
+ * }
194
+ * ```
195
+ *
196
+ * @since 2.18.45
197
+ */
198
+ declare function propertyExists<X, Y extends PropertyKey>(obj: X, prop: Y): obj is X & Record<Y, unknown>;
199
+
200
+ declare function readValueAsDate<TDate extends PickerValidDate>(adapter: ReturnType<typeof useLocalizationContext>, value: string | null | TDate): TDate | null;
201
+
202
+ declare const removeLeadingTrailingSlashes: (route: string) => string;
203
+
204
+ declare const schemaTools: {
205
+ date: ({ message }?: {
206
+ message?: string;
207
+ }) => z.ZodPipe<z.ZodCoercedString<unknown>, z.ZodTransform<string | null, string>>;
208
+ nullableDate: ({ message }?: {
209
+ message?: string;
210
+ }) => z.ZodPipe<z.ZodPipe<z.ZodCoercedString<unknown>, z.ZodTransform<string | null, string>>, z.ZodTransform<string | null, string | null>>;
211
+ dateRange: ({ message }?: {
212
+ message?: string;
213
+ }) => z.ZodObject<{
214
+ start: z.ZodCoercedDate<unknown>;
215
+ end: z.ZodCoercedDate<unknown>;
216
+ }, z.core.$strip>;
217
+ requiredString: ({ message, min, max }?: {
218
+ message?: string;
219
+ min?: number;
220
+ max?: number;
221
+ }) => z.ZodString;
222
+ email: ({ message }?: {
223
+ message?: string;
224
+ }) => z.ZodString;
225
+ url: ({ message }?: {
226
+ message?: string;
227
+ }) => z.ZodString;
228
+ phone: ({ message }?: {
229
+ message?: string;
230
+ }) => z.ZodString;
231
+ alphanumeric: ({ message }?: {
232
+ message?: string;
233
+ }) => z.ZodString;
234
+ slug: ({ message }?: {
235
+ message?: string;
236
+ }) => z.ZodString;
237
+ positiveNumber: ({ message, min, max }?: {
238
+ message?: string;
239
+ min?: number;
240
+ max?: number;
241
+ }) => z.ZodNumber;
242
+ nonNegativeNumber: ({ message, max }?: {
243
+ message?: string;
244
+ max?: number;
245
+ }) => z.ZodNumber;
246
+ integer: ({ message, min, max }?: {
247
+ message?: string;
248
+ min?: number;
249
+ max?: number;
250
+ }) => z.ZodNumber;
251
+ percentage: ({ message }?: {
252
+ message?: string;
253
+ }) => z.ZodNumber;
254
+ nonEmptyArray: <T>(schema: z.ZodSchema<T>, { message }?: {
255
+ message?: string;
256
+ }) => z.ZodArray<z.ZodType<T, unknown, z.core.$ZodTypeInternals<T, unknown>>>;
257
+ uniqueArray: <T>(schema: z.ZodSchema<T>, { message }?: {
258
+ message?: string;
259
+ }) => z.ZodArray<z.ZodType<T, unknown, z.core.$ZodTypeInternals<T, unknown>>>;
260
+ requiredBoolean: ({ message }?: {
261
+ message?: string;
262
+ }) => z.ZodBoolean;
263
+ nonEmptyObject: <T extends Record<string, unknown>>(schema: z.ZodSchema<T>, { message }?: {
264
+ message?: string;
265
+ }) => z.ZodType<T, unknown, z.core.$ZodTypeInternals<T, unknown>>;
266
+ fileSize: ({ maxSize, message }: {
267
+ maxSize: number;
268
+ message?: string;
269
+ }) => z.ZodCustom<File, File>;
270
+ fileType: ({ allowedTypes, message }: {
271
+ allowedTypes: string[];
272
+ message?: string;
273
+ }) => z.ZodCustom<File, File>;
274
+ conditional: <T, U>(condition: (data: T) => boolean, trueSchema: z.ZodSchema<U>, falseSchema: z.ZodSchema<U>) => z.ZodUnion<readonly [z.ZodType<U, unknown, z.core.$ZodTypeInternals<U, unknown>>, z.ZodType<U, unknown, z.core.$ZodTypeInternals<U, unknown>>]>;
275
+ transform: {
276
+ toLowerCase: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
277
+ toUpperCase: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
278
+ trim: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
279
+ toNumber: z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>;
280
+ toBoolean: z.ZodPipe<z.ZodString, z.ZodTransform<boolean, string>>;
281
+ parseJson: <T>(schema: z.ZodSchema<T>) => z.ZodPipe<z.ZodString, z.ZodTransform<Awaited<T>, string>>;
282
+ };
283
+ };
284
+
285
+ /**
286
+ * Core watch functions for React Hook Form
287
+ * These are the primary building blocks for form watching
288
+ */
289
+ /**
290
+ * Utility type to ensure array elements are all Path<T>
291
+ */
292
+ type PathArray<T extends FieldValues> = ReadonlyArray<Path<T>>;
293
+ /**
294
+ * Hook to watch entire form - returns all form values
295
+ */
296
+ declare const useWatchForm: <TFieldValues extends FieldValues>(control: Control<TFieldValues>) => DeepPartialSkipArrayKey<TFieldValues>;
297
+ /**
298
+ * Hook to watch single field by path - supports any nested path
299
+ */
300
+ declare const useWatchField: <TFieldValues extends FieldValues, TName extends Path<TFieldValues>>(control: Control<TFieldValues>, name: TName) => PathValue<TFieldValues, TName>;
301
+ /**
302
+ * Hook to watch multiple fields by paths - returns array of values
303
+ */
304
+ declare const useWatchFields: <TFieldValues extends FieldValues, TNames extends ReadonlyArray<Path<TFieldValues>>>(control: Control<TFieldValues>, names: TNames) => Array<PathValue<TFieldValues, TNames[number]>>;
305
+
306
+ /**
307
+ * Utility watch functions for React Hook Form
308
+ * Enhanced functionality for specific use cases
309
+ */
310
+ /**
311
+ * Watch field with transformation/selector
312
+ */
313
+ declare const useWatchTransform: <TFieldValues extends FieldValues, TName extends Path<TFieldValues>, TOutput>(control: Control<TFieldValues>, name: TName, transform: (value: PathValue<TFieldValues, TName>) => TOutput) => TOutput;
314
+ /**
315
+ * Watch field with default fallback value
316
+ */
317
+ declare const useWatchDefault: <TFieldValues extends FieldValues, TName extends Path<TFieldValues>>(control: Control<TFieldValues>, name: TName, defaultValue: PathValue<TFieldValues, TName>) => PathValue<TFieldValues, TName>;
318
+ /**
319
+ * Watch field as boolean with guaranteed boolean return
320
+ */
321
+ declare const useWatchBoolean: <TFieldValues extends FieldValues, TName extends Path<TFieldValues>>(control: Control<TFieldValues>, name: TName, defaultValue?: boolean) => boolean;
322
+ /**
323
+ * Watch multiple fields and return an object with field paths as keys
324
+ */
325
+ declare const useWatchBatch: <TFieldValues extends FieldValues, TFields extends ReadonlyArray<Path<TFieldValues>>>(control: Control<TFieldValues>, fields: TFields) => { [K in TFields[number]]: PathValue<TFieldValues, K>; };
326
+ /**
327
+ * Watch field conditionally based on boolean flag
328
+ */
329
+ declare const useWatchConditional: <TFieldValues extends FieldValues, TName extends Path<TFieldValues>>(control: Control<TFieldValues>, name: TName, shouldWatch: boolean, fallback?: PathValue<TFieldValues, TName>) => PathValue<TFieldValues, TName> | undefined;
330
+ /**
331
+ * Watch field with debounced updates
332
+ */
333
+ declare const useWatchDebounced: <TFieldValues extends FieldValues, TName extends Path<TFieldValues>>(control: Control<TFieldValues>, name: TName, delay?: number) => PathValue<TFieldValues, TName>;
334
+ /**
335
+ * Watch field with memoized selector function
336
+ */
337
+ declare const useWatchSelector: <TFieldValues extends FieldValues, TName extends Path<TFieldValues>, TOutput>(control: Control<TFieldValues>, name: TName, selector: (value: PathValue<TFieldValues, TName>) => TOutput, deps?: React.DependencyList) => TOutput;
338
+
339
+ /**
340
+ * Organized utilities by use case
341
+ * Provides a convenient object-based API for all watch functions
342
+ */
343
+ declare const typedWatch: {
344
+ /** Watch entire form */
345
+ readonly form: <TFieldValues extends react_hook_form.FieldValues>(control: react_hook_form.Control<TFieldValues>) => react_hook_form.DeepPartialSkipArrayKey<TFieldValues>;
346
+ /** Watch single field */
347
+ readonly field: <TFieldValues extends react_hook_form.FieldValues, TName extends react_hook_form.Path<TFieldValues>>(control: react_hook_form.Control<TFieldValues>, name: TName) => react_hook_form.PathValue<TFieldValues, TName>;
348
+ /** Watch multiple fields */
349
+ readonly fields: <TFieldValues extends react_hook_form.FieldValues, TNames extends ReadonlyArray<react_hook_form.Path<TFieldValues>>>(control: react_hook_form.Control<TFieldValues>, names: TNames) => Array<react_hook_form.PathValue<TFieldValues, TNames[number]>>;
350
+ /** Watch with transformation */
351
+ readonly transform: <TFieldValues extends react_hook_form.FieldValues, TName extends react_hook_form.Path<TFieldValues>, TOutput>(control: react_hook_form.Control<TFieldValues>, name: TName, transform: (value: react_hook_form.PathValue<TFieldValues, TName>) => TOutput) => TOutput;
352
+ /** Watch with default value */
353
+ readonly withDefault: <TFieldValues extends react_hook_form.FieldValues, TName extends react_hook_form.Path<TFieldValues>>(control: react_hook_form.Control<TFieldValues>, name: TName, defaultValue: react_hook_form.PathValue<TFieldValues, TName>) => react_hook_form.PathValue<TFieldValues, TName>;
354
+ /** Watch as boolean */
355
+ readonly boolean: <TFieldValues extends react_hook_form.FieldValues, TName extends react_hook_form.Path<TFieldValues>>(control: react_hook_form.Control<TFieldValues>, name: TName, defaultValue?: boolean) => boolean;
356
+ /** Watch multiple with custom keys */
357
+ readonly batch: <TFieldValues extends react_hook_form.FieldValues, TFields extends ReadonlyArray<react_hook_form.Path<TFieldValues>>>(control: react_hook_form.Control<TFieldValues>, fields: TFields) => { [K in TFields[number]]: react_hook_form.PathValue<TFieldValues, K>; };
358
+ /** Watch conditionally */
359
+ readonly conditional: <TFieldValues extends react_hook_form.FieldValues, TName extends react_hook_form.Path<TFieldValues>>(control: react_hook_form.Control<TFieldValues>, name: TName, shouldWatch: boolean, fallback?: react_hook_form.PathValue<TFieldValues, TName>) => react_hook_form.PathValue<TFieldValues, TName> | undefined;
360
+ /** Watch with debouncing */
361
+ readonly debounced: <TFieldValues extends react_hook_form.FieldValues, TName extends react_hook_form.Path<TFieldValues>>(control: react_hook_form.Control<TFieldValues>, name: TName, delay?: number) => react_hook_form.PathValue<TFieldValues, TName>;
362
+ /** Watch with selector */
363
+ readonly selector: <TFieldValues extends react_hook_form.FieldValues, TName extends react_hook_form.Path<TFieldValues>, TOutput>(control: react_hook_form.Control<TFieldValues>, name: TName, selector: (value: react_hook_form.PathValue<TFieldValues, TName>) => TOutput, deps?: React.DependencyList) => TOutput;
364
+ };
365
+
366
+ export { type PathArray, api, api2, flattenObjectKeys, getTimezone, handleServerErrors, propertyExists, readValueAsDate, removeLeadingTrailingSlashes, schemaTools, typedWatch, useWatchBatch, useWatchBoolean, useWatchConditional, useWatchDebounced, useWatchDefault, useWatchField, useWatchFields, useWatchForm, useWatchSelector, useWatchTransform };