@timeax/form-palette 0.0.3 → 0.0.5

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 (120) hide show
  1. package/{src/schema/adapter.ts → dist/adapters.d.mts} +118 -43
  2. package/dist/adapters.d.ts +292 -0
  3. package/dist/adapters.js +13283 -0
  4. package/dist/adapters.js.map +1 -0
  5. package/dist/adapters.mjs +13269 -0
  6. package/dist/adapters.mjs.map +1 -0
  7. package/dist/index.d.mts +3744 -0
  8. package/dist/index.d.ts +3744 -0
  9. package/dist/index.js +43014 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/index.mjs +42965 -0
  12. package/dist/index.mjs.map +1 -0
  13. package/package.json +22 -7
  14. package/.scaffold-cache.json +0 -537
  15. package/src/.scaffold-cache.json +0 -544
  16. package/src/adapters/axios.ts +0 -117
  17. package/src/adapters/index.ts +0 -91
  18. package/src/adapters/inertia.ts +0 -187
  19. package/src/core/adapter-registry.ts +0 -87
  20. package/src/core/bound/bind-host.ts +0 -14
  21. package/src/core/bound/observe-bound-field.ts +0 -172
  22. package/src/core/bound/wait-for-bound-field.ts +0 -57
  23. package/src/core/context.ts +0 -23
  24. package/src/core/core-provider.tsx +0 -818
  25. package/src/core/core-root.tsx +0 -72
  26. package/src/core/core-shell.tsx +0 -44
  27. package/src/core/errors/error-strip.tsx +0 -71
  28. package/src/core/errors/index.ts +0 -2
  29. package/src/core/errors/map-error-bag.ts +0 -51
  30. package/src/core/errors/map-zod.ts +0 -39
  31. package/src/core/hooks/use-button.ts +0 -220
  32. package/src/core/hooks/use-core-context.ts +0 -20
  33. package/src/core/hooks/use-core-utility.ts +0 -0
  34. package/src/core/hooks/use-core.ts +0 -13
  35. package/src/core/hooks/use-field.ts +0 -497
  36. package/src/core/hooks/use-optional-field.ts +0 -28
  37. package/src/core/index.ts +0 -0
  38. package/src/core/registry/binder-registry.ts +0 -82
  39. package/src/core/registry/field-registry.ts +0 -187
  40. package/src/core/test.tsx +0 -17
  41. package/src/global.d.ts +0 -14
  42. package/src/index.ts +0 -68
  43. package/src/input/index.ts +0 -4
  44. package/src/input/input-field.tsx +0 -854
  45. package/src/input/input-layout-graph.ts +0 -230
  46. package/src/input/input-props.ts +0 -190
  47. package/src/lib/get-global-countries.ts +0 -87
  48. package/src/lib/utils.ts +0 -6
  49. package/src/presets/index.ts +0 -0
  50. package/src/presets/shadcn-preset.ts +0 -0
  51. package/src/presets/shadcn-variants/checkbox.tsx +0 -849
  52. package/src/presets/shadcn-variants/chips.tsx +0 -756
  53. package/src/presets/shadcn-variants/color.tsx +0 -284
  54. package/src/presets/shadcn-variants/custom.tsx +0 -227
  55. package/src/presets/shadcn-variants/date.tsx +0 -796
  56. package/src/presets/shadcn-variants/file.tsx +0 -764
  57. package/src/presets/shadcn-variants/keyvalue.tsx +0 -556
  58. package/src/presets/shadcn-variants/multiselect.tsx +0 -1132
  59. package/src/presets/shadcn-variants/number.tsx +0 -176
  60. package/src/presets/shadcn-variants/password.tsx +0 -737
  61. package/src/presets/shadcn-variants/phone.tsx +0 -628
  62. package/src/presets/shadcn-variants/radio.tsx +0 -578
  63. package/src/presets/shadcn-variants/select.tsx +0 -956
  64. package/src/presets/shadcn-variants/slider.tsx +0 -622
  65. package/src/presets/shadcn-variants/text.tsx +0 -343
  66. package/src/presets/shadcn-variants/textarea.tsx +0 -66
  67. package/src/presets/shadcn-variants/toggle.tsx +0 -218
  68. package/src/presets/shadcn-variants/treeselect.tsx +0 -784
  69. package/src/presets/ui/badge.tsx +0 -46
  70. package/src/presets/ui/button.tsx +0 -60
  71. package/src/presets/ui/calendar.tsx +0 -214
  72. package/src/presets/ui/checkbox.tsx +0 -115
  73. package/src/presets/ui/custom.tsx +0 -0
  74. package/src/presets/ui/dialog.tsx +0 -141
  75. package/src/presets/ui/field.tsx +0 -246
  76. package/src/presets/ui/input-mask.tsx +0 -739
  77. package/src/presets/ui/input-otp.tsx +0 -77
  78. package/src/presets/ui/input.tsx +0 -1011
  79. package/src/presets/ui/label.tsx +0 -22
  80. package/src/presets/ui/number.tsx +0 -1370
  81. package/src/presets/ui/popover.tsx +0 -46
  82. package/src/presets/ui/radio-group.tsx +0 -43
  83. package/src/presets/ui/scroll-area.tsx +0 -56
  84. package/src/presets/ui/select.tsx +0 -190
  85. package/src/presets/ui/separator.tsx +0 -28
  86. package/src/presets/ui/slider.tsx +0 -61
  87. package/src/presets/ui/switch.tsx +0 -32
  88. package/src/presets/ui/textarea.tsx +0 -634
  89. package/src/presets/ui/time-dropdowns.tsx +0 -350
  90. package/src/schema/core.ts +0 -429
  91. package/src/schema/field-map.ts +0 -0
  92. package/src/schema/field.ts +0 -224
  93. package/src/schema/index.ts +0 -0
  94. package/src/schema/input-field.ts +0 -260
  95. package/src/schema/presets.ts +0 -0
  96. package/src/schema/variant.ts +0 -216
  97. package/src/variants/core/checkbox.tsx +0 -54
  98. package/src/variants/core/chips.tsx +0 -22
  99. package/src/variants/core/color.tsx +0 -16
  100. package/src/variants/core/custom.tsx +0 -18
  101. package/src/variants/core/date.tsx +0 -25
  102. package/src/variants/core/file.tsx +0 -9
  103. package/src/variants/core/keyvalue.tsx +0 -12
  104. package/src/variants/core/multiselect.tsx +0 -28
  105. package/src/variants/core/number.tsx +0 -115
  106. package/src/variants/core/password.tsx +0 -35
  107. package/src/variants/core/phone.tsx +0 -16
  108. package/src/variants/core/radio.tsx +0 -38
  109. package/src/variants/core/select.tsx +0 -15
  110. package/src/variants/core/slider.tsx +0 -55
  111. package/src/variants/core/text.tsx +0 -114
  112. package/src/variants/core/textarea.tsx +0 -22
  113. package/src/variants/core/toggle.tsx +0 -50
  114. package/src/variants/core/treeselect.tsx +0 -11
  115. package/src/variants/helpers/selection-summary.tsx +0 -236
  116. package/src/variants/index.ts +0 -75
  117. package/src/variants/registry.ts +0 -38
  118. package/src/variants/select-shared.ts +0 -0
  119. package/src/variants/shared.ts +0 -126
  120. package/tsconfig.json +0 -14
@@ -1,38 +1,35 @@
1
- // src/schema/adapter.ts
1
+ import { AxiosResponse } from 'axios';
2
+ import { Page } from './../../../../node_modules/@inertiajs/core/types/types.d';
2
3
 
3
4
  /**
4
5
  * HTTP methods supported by the core adapter layer.
5
6
  *
6
7
  * This matches the legacy Method union from the old types.ts.
7
8
  */
8
- export type Method = 'post' | 'get' | 'delete' | 'put' | 'patch';
9
-
9
+ type Method = 'post' | 'get' | 'delete' | 'put' | 'patch';
10
10
  /**
11
11
  * Lifecycle callbacks used by adapters to report events back to the core.
12
12
  *
13
13
  * @template Ok Type of the "successful" response payload (e.g. AxiosResponse).
14
14
  * @template Err Type of the "error" payload (e.g. AxiosError, unknown).
15
15
  */
16
- export interface AdapterCallbacks<Ok = unknown, Err = unknown> {
16
+ interface AdapterCallbacks<Ok = unknown, Err = unknown> {
17
17
  /**
18
18
  * Called when the underlying request completes successfully.
19
19
  * The adapter decides what "success" means (HTTP 2xx, no exception, etc.).
20
20
  */
21
21
  onSuccess?(response: Ok): void;
22
-
23
22
  /**
24
23
  * Called when the underlying request fails.
25
24
  * Adapters should pass the most informative error shape they have.
26
25
  */
27
26
  onError?(error: Err): void;
28
-
29
27
  /**
30
28
  * Called at the end of the adapter lifecycle, whether success or error.
31
29
  * Useful for clearing loading states, unlocking buttons, etc.
32
30
  */
33
31
  onFinish?(): void;
34
32
  }
35
-
36
33
  /**
37
34
  * Result interface returned by an adapter.
38
35
  *
@@ -51,7 +48,7 @@ export interface AdapterCallbacks<Ok = unknown, Err = unknown> {
51
48
  *
52
49
  * @template Ok Type of the "successful" response payload.
53
50
  */
54
- export interface AdapterResult<Ok = unknown> {
51
+ interface AdapterResult<Ok = unknown> {
55
52
  /**
56
53
  * Fire-and-forget trigger.
57
54
  *
@@ -61,7 +58,6 @@ export interface AdapterResult<Ok = unknown> {
61
58
  * @param options Optional adapter-specific options.
62
59
  */
63
60
  submit(options?: unknown): void;
64
-
65
61
  /**
66
62
  * Promise-based trigger.
67
63
  *
@@ -71,7 +67,6 @@ export interface AdapterResult<Ok = unknown> {
71
67
  * @param options Optional adapter-specific options.
72
68
  */
73
69
  send(options?: unknown): Promise<Ok>;
74
-
75
70
  /**
76
71
  * Convenience trigger.
77
72
  *
@@ -86,7 +81,6 @@ export interface AdapterResult<Ok = unknown> {
86
81
  */
87
82
  run(options?: unknown): void | Promise<Ok>;
88
83
  }
89
-
90
84
  /**
91
85
  * Configuration passed from the core runtime to a concrete adapter factory.
92
86
  *
@@ -94,12 +88,11 @@ export interface AdapterResult<Ok = unknown> {
94
88
  * @template Ok Type of the "successful" response payload.
95
89
  * @template Err Type of the "error" payload.
96
90
  */
97
- export interface AdapterConfig<Body = unknown, Ok = unknown, Err = unknown> {
91
+ interface AdapterConfig<Body = unknown, Ok = unknown, Err = unknown> {
98
92
  /**
99
93
  * HTTP method / intent used by the adapter.
100
94
  */
101
95
  method: Method;
102
-
103
96
  /**
104
97
  * Fully-resolved URL or route string.
105
98
  *
@@ -107,7 +100,6 @@ export interface AdapterConfig<Body = unknown, Ok = unknown, Err = unknown> {
107
100
  * before handing control to the adapter.
108
101
  */
109
102
  url: string;
110
-
111
103
  /**
112
104
  * Request body payload built by the core.
113
105
  *
@@ -116,7 +108,6 @@ export interface AdapterConfig<Body = unknown, Ok = unknown, Err = unknown> {
116
108
  * { ...formValues, ...extra }
117
109
  */
118
110
  data: Body;
119
-
120
111
  /**
121
112
  * Lifecycle callbacks provided by the core.
122
113
  *
@@ -125,7 +116,6 @@ export interface AdapterConfig<Body = unknown, Ok = unknown, Err = unknown> {
125
116
  */
126
117
  callbacks?: AdapterCallbacks<Ok, Err>;
127
118
  }
128
-
129
119
  /**
130
120
  * Factory function type for creating an adapter instance.
131
121
  *
@@ -137,12 +127,7 @@ export interface AdapterConfig<Body = unknown, Ok = unknown, Err = unknown> {
137
127
  * @template Ok Type of the "successful" response payload.
138
128
  * @template Err Type of the "error" payload.
139
129
  */
140
- export type AdapterFactory<
141
- Body = unknown,
142
- Ok = unknown,
143
- Err = unknown,
144
- > = (config: AdapterConfig<Body, Ok, Err>) => AdapterResult<Ok>;
145
-
130
+ type AdapterFactory<Body = unknown, Ok = unknown, Err = unknown> = (config: AdapterConfig<Body, Ok, Err>) => AdapterResult<Ok>;
146
131
  /**
147
132
  * Registry of adapter flavours.
148
133
  *
@@ -154,45 +139,41 @@ export type AdapterFactory<
154
139
  * Hosts can extend this interface via module augmentation to add
155
140
  * their own adapter flavours (e.g. 'axios', 'inertia', ...).
156
141
  */
157
- export interface Adapters {
142
+ interface Adapters {
158
143
  local: {
159
144
  /**
160
145
  * Type of the value produced by adapter.send() for this adapter flavour.
161
146
  */
162
- ok: { data: unknown };
163
-
147
+ ok: {
148
+ data: unknown;
149
+ };
164
150
  /**
165
151
  * Type of the error value passed into callbacks.onError for this adapter.
166
152
  */
167
153
  err: unknown;
168
154
  };
169
155
  }
170
-
171
156
  /**
172
157
  * Union of all adapter keys known to the core.
173
158
  *
174
159
  * Hosts can extend this union by augmenting the Adapters interface.
175
160
  */
176
- export type AdapterKey = keyof Adapters;
177
-
161
+ type AdapterKey = keyof Adapters;
178
162
  /**
179
163
  * Helper: given an adapter key K, get its "ok" payload type.
180
164
  */
181
- export type AdapterOk<K extends AdapterKey> = Adapters[K]['ok'];
182
-
165
+ type AdapterOk<K extends AdapterKey> = Adapters[K]['ok'];
183
166
  /**
184
167
  * Helper: given an adapter key K, get its "error" payload type.
185
168
  */
186
- export type AdapterError<K extends AdapterKey> = Adapters[K]['err'];
187
-
169
+ type AdapterError<K extends AdapterKey> = Adapters[K]['err'];
188
170
  /**
189
171
  * Helper: what CoreProps.onSubmitted receives for adapter K.
190
172
  *
191
173
  * For now, this is the same as AdapterOk<K>. If a host wants a different
192
174
  * shape, they can wrap/transform in their own components.
193
175
  */
194
- export type AdapterSubmit<K extends AdapterKey> = AdapterOk<K>;
195
-
176
+ type AdapterSubmit<K extends AdapterKey> = AdapterOk<K>;
196
177
  /**
197
178
  * AdapterConfig specialised for a named adapter key K, using the
198
179
  * registry's ok/err types for that key.
@@ -200,18 +181,112 @@ export type AdapterSubmit<K extends AdapterKey> = AdapterOk<K>;
200
181
  * @template K Adapter key.
201
182
  * @template Body Outbound payload type.
202
183
  */
203
- export type NamedAdapterConfig<
204
- K extends AdapterKey,
205
- Body = unknown,
206
- > = AdapterConfig<Body, AdapterOk<K>, AdapterError<K>>;
207
-
184
+ type NamedAdapterConfig<K extends AdapterKey, Body = unknown> = AdapterConfig<Body, AdapterOk<K>, AdapterError<K>>;
208
185
  /**
209
186
  * AdapterFactory specialised for a named adapter key K.
210
187
  *
211
188
  * @template K Adapter key.
212
189
  * @template Body Outbound payload type.
213
190
  */
214
- export type NamedAdapterFactory<
215
- K extends AdapterKey,
216
- Body = unknown,
217
- > = (config: NamedAdapterConfig<K, Body>) => AdapterResult<AdapterOk<K>>;
191
+ type NamedAdapterFactory<K extends AdapterKey, Body = unknown> = (config: NamedAdapterConfig<K, Body>) => AdapterResult<AdapterOk<K>>;
192
+
193
+ /**
194
+ * Built-in 'local' adapter.
195
+ *
196
+ * Semantics:
197
+ * - send(options?) resolves to `{ data: Body }`
198
+ * - submit/run do nothing by default (no side effects)
199
+ *
200
+ * The core will typically call onSubmitted with the result of send().
201
+ */
202
+ declare const localAdapter: NamedAdapterFactory<"local", any>;
203
+ /**
204
+ * Register or override an adapter factory for a given key.
205
+ *
206
+ * Hosts can call this at bootstrap time, e.g.:
207
+ *
208
+ * registerAdapter<'axios'>('axios', axiosAdapter);
209
+ */
210
+ declare function registerAdapter<K extends AdapterKey, Body = any>(key: K, factory: NamedAdapterFactory<K, Body>): void;
211
+ /**
212
+ * Lookup an adapter factory by key.
213
+ *
214
+ * If no adapter is found for the given key, this returns undefined.
215
+ */
216
+ declare function getAdapter<K extends AdapterKey>(key: K): NamedAdapterFactory<K, any> | undefined;
217
+ /**
218
+ * Check whether an adapter is registered for the given key.
219
+ */
220
+ declare function hasAdapter(key: AdapterKey): boolean;
221
+
222
+ declare const createAxiosAdapter: NamedAdapterFactory<"axios">;
223
+ declare module "@/schema/adapter" {
224
+ interface Adapters {
225
+ axios: {
226
+ /**
227
+ * What adapter.send() resolves with for Axios.
228
+ */
229
+ ok: AxiosResponse<unknown>;
230
+ /**
231
+ * What callbacks.onError receives for Axios.
232
+ *
233
+ * We pass the *payload* (e.g. response.data), not the raw AxiosError,
234
+ * so Form Palette's autoErr branch can see `.errors`.
235
+ */
236
+ err: unknown;
237
+ };
238
+ }
239
+ }
240
+
241
+ declare const createInertiaAdapter: NamedAdapterFactory<"inertia">;
242
+ declare module "@/schema/adapter" {
243
+ interface Adapters {
244
+ inertia: {
245
+ /**
246
+ * What adapter.send() resolves with for Inertia.
247
+ * This is the Page object passed to onSuccess.
248
+ */
249
+ ok: Page<any>;
250
+ /**
251
+ * What callbacks.onError receives for Inertia.
252
+ *
253
+ * We shape this as `{ errors: ErrorBag }` so Form Palette's
254
+ * autoErr branch can see `.errors`.
255
+ */
256
+ err: {
257
+ errors: Record<string, string | string[]>;
258
+ } | unknown;
259
+ };
260
+ }
261
+ }
262
+
263
+ /**
264
+ * Register the Axios adapter under the "axios" key.
265
+ *
266
+ * This performs a basic runtime check to make sure Axios is present.
267
+ * If Axios isn't available or doesn't look like a proper Axios instance,
268
+ * an error is thrown.
269
+ */
270
+ declare function registerAxiosAdapter(): void;
271
+ /**
272
+ * Register the Inertia adapter under the "inertia" key.
273
+ *
274
+ * This explicitly tests that '@inertiajs/react' can be imported and that
275
+ * it exposes a router with a .visit() method. If not, an error is thrown.
276
+ *
277
+ * Note:
278
+ * - This function is async because it uses dynamic import.
279
+ * - Call it at bootstrap time and await it:
280
+ *
281
+ * await registerInertiaAdapter();
282
+ */
283
+ declare function registerInertiaAdapter(): Promise<void>;
284
+ /**
285
+ * Optional helper: convenience registration for known adapter keys.
286
+ *
287
+ * This is purely ergonomic; you can also call registerAxiosAdapter /
288
+ * registerInertiaAdapter directly.
289
+ */
290
+ declare function registerKnownAdapter(key: AdapterKey): Promise<void>;
291
+
292
+ export { type AdapterCallbacks, type AdapterConfig, type AdapterError, type AdapterFactory, type AdapterKey, type AdapterOk, type AdapterResult, type AdapterSubmit, type Adapters, type Method, type NamedAdapterConfig, type NamedAdapterFactory, createAxiosAdapter, createInertiaAdapter, getAdapter, hasAdapter, localAdapter, registerAdapter, registerAxiosAdapter, registerInertiaAdapter, registerKnownAdapter };
@@ -0,0 +1,292 @@
1
+ import { AxiosResponse } from 'axios';
2
+ import { Page } from './../../../../node_modules/@inertiajs/core/types/types.d';
3
+
4
+ /**
5
+ * HTTP methods supported by the core adapter layer.
6
+ *
7
+ * This matches the legacy Method union from the old types.ts.
8
+ */
9
+ type Method = 'post' | 'get' | 'delete' | 'put' | 'patch';
10
+ /**
11
+ * Lifecycle callbacks used by adapters to report events back to the core.
12
+ *
13
+ * @template Ok Type of the "successful" response payload (e.g. AxiosResponse).
14
+ * @template Err Type of the "error" payload (e.g. AxiosError, unknown).
15
+ */
16
+ interface AdapterCallbacks<Ok = unknown, Err = unknown> {
17
+ /**
18
+ * Called when the underlying request completes successfully.
19
+ * The adapter decides what "success" means (HTTP 2xx, no exception, etc.).
20
+ */
21
+ onSuccess?(response: Ok): void;
22
+ /**
23
+ * Called when the underlying request fails.
24
+ * Adapters should pass the most informative error shape they have.
25
+ */
26
+ onError?(error: Err): void;
27
+ /**
28
+ * Called at the end of the adapter lifecycle, whether success or error.
29
+ * Useful for clearing loading states, unlocking buttons, etc.
30
+ */
31
+ onFinish?(): void;
32
+ }
33
+ /**
34
+ * Result interface returned by an adapter.
35
+ *
36
+ * Generic evolution of the legacy AdapterResult:
37
+ *
38
+ * type AdapterResult = {
39
+ * submit(options?: unknown): void;
40
+ * send<T = unknown>(): Promise<AxiosResponse<T>>;
41
+ * run(options?: unknown): void;
42
+ * };
43
+ *
44
+ * Differences:
45
+ * - The success payload is generic (Ok) instead of hard-coded to AxiosResponse.
46
+ * - send() always returns Promise<Ok>.
47
+ * - run() may return either void or Promise<Ok>, depending on adapter.
48
+ *
49
+ * @template Ok Type of the "successful" response payload.
50
+ */
51
+ interface AdapterResult<Ok = unknown> {
52
+ /**
53
+ * Fire-and-forget trigger.
54
+ *
55
+ * Intended for flows where the caller does not care about the response
56
+ * object itself (e.g. SPA navigation).
57
+ *
58
+ * @param options Optional adapter-specific options.
59
+ */
60
+ submit(options?: unknown): void;
61
+ /**
62
+ * Promise-based trigger.
63
+ *
64
+ * Intended for flows where the caller wants to await the response object.
65
+ * Adapters should reject the promise when an error occurs.
66
+ *
67
+ * @param options Optional adapter-specific options.
68
+ */
69
+ send(options?: unknown): Promise<Ok>;
70
+ /**
71
+ * Convenience trigger.
72
+ *
73
+ * Adapters are free to implement this as:
74
+ * - submit(options) (returning void), or
75
+ * - send(options) (returning Promise<Ok>).
76
+ *
77
+ * Callers that need strict typing can prefer send();
78
+ * callers that just need "do the thing" can use run().
79
+ *
80
+ * @param options Optional adapter-specific options.
81
+ */
82
+ run(options?: unknown): void | Promise<Ok>;
83
+ }
84
+ /**
85
+ * Configuration passed from the core runtime to a concrete adapter factory.
86
+ *
87
+ * @template Body Type of the outbound payload (form values + extra data).
88
+ * @template Ok Type of the "successful" response payload.
89
+ * @template Err Type of the "error" payload.
90
+ */
91
+ interface AdapterConfig<Body = unknown, Ok = unknown, Err = unknown> {
92
+ /**
93
+ * HTTP method / intent used by the adapter.
94
+ */
95
+ method: Method;
96
+ /**
97
+ * Fully-resolved URL or route string.
98
+ *
99
+ * The core is responsible for resolving named routes, base URLs, etc.,
100
+ * before handing control to the adapter.
101
+ */
102
+ url: string;
103
+ /**
104
+ * Request body payload built by the core.
105
+ *
106
+ * Typically something like:
107
+ *
108
+ * { ...formValues, ...extra }
109
+ */
110
+ data: Body;
111
+ /**
112
+ * Lifecycle callbacks provided by the core.
113
+ *
114
+ * The adapter should invoke these at the appropriate times; it must not
115
+ * swallow errors without calling onError (when provided).
116
+ */
117
+ callbacks?: AdapterCallbacks<Ok, Err>;
118
+ }
119
+ /**
120
+ * Factory function type for creating an adapter instance.
121
+ *
122
+ * Concrete implementations (Axios, Inertia, fetch, custom) can conform
123
+ * to this signature. The core runtime only knows about this type and does
124
+ * not depend on any adapter-specific details.
125
+ *
126
+ * @template Body Type of the outbound payload (form values + extra data).
127
+ * @template Ok Type of the "successful" response payload.
128
+ * @template Err Type of the "error" payload.
129
+ */
130
+ type AdapterFactory<Body = unknown, Ok = unknown, Err = unknown> = (config: AdapterConfig<Body, Ok, Err>) => AdapterResult<Ok>;
131
+ /**
132
+ * Registry of adapter flavours.
133
+ *
134
+ * The library hard-codes a single built-in adapter flavour:
135
+ *
136
+ * - 'local' → host-handled, no transport semantics.
137
+ * .send() resolves to `{ data: Body }`.
138
+ *
139
+ * Hosts can extend this interface via module augmentation to add
140
+ * their own adapter flavours (e.g. 'axios', 'inertia', ...).
141
+ */
142
+ interface Adapters {
143
+ local: {
144
+ /**
145
+ * Type of the value produced by adapter.send() for this adapter flavour.
146
+ */
147
+ ok: {
148
+ data: unknown;
149
+ };
150
+ /**
151
+ * Type of the error value passed into callbacks.onError for this adapter.
152
+ */
153
+ err: unknown;
154
+ };
155
+ }
156
+ /**
157
+ * Union of all adapter keys known to the core.
158
+ *
159
+ * Hosts can extend this union by augmenting the Adapters interface.
160
+ */
161
+ type AdapterKey = keyof Adapters;
162
+ /**
163
+ * Helper: given an adapter key K, get its "ok" payload type.
164
+ */
165
+ type AdapterOk<K extends AdapterKey> = Adapters[K]['ok'];
166
+ /**
167
+ * Helper: given an adapter key K, get its "error" payload type.
168
+ */
169
+ type AdapterError<K extends AdapterKey> = Adapters[K]['err'];
170
+ /**
171
+ * Helper: what CoreProps.onSubmitted receives for adapter K.
172
+ *
173
+ * For now, this is the same as AdapterOk<K>. If a host wants a different
174
+ * shape, they can wrap/transform in their own components.
175
+ */
176
+ type AdapterSubmit<K extends AdapterKey> = AdapterOk<K>;
177
+ /**
178
+ * AdapterConfig specialised for a named adapter key K, using the
179
+ * registry's ok/err types for that key.
180
+ *
181
+ * @template K Adapter key.
182
+ * @template Body Outbound payload type.
183
+ */
184
+ type NamedAdapterConfig<K extends AdapterKey, Body = unknown> = AdapterConfig<Body, AdapterOk<K>, AdapterError<K>>;
185
+ /**
186
+ * AdapterFactory specialised for a named adapter key K.
187
+ *
188
+ * @template K Adapter key.
189
+ * @template Body Outbound payload type.
190
+ */
191
+ type NamedAdapterFactory<K extends AdapterKey, Body = unknown> = (config: NamedAdapterConfig<K, Body>) => AdapterResult<AdapterOk<K>>;
192
+
193
+ /**
194
+ * Built-in 'local' adapter.
195
+ *
196
+ * Semantics:
197
+ * - send(options?) resolves to `{ data: Body }`
198
+ * - submit/run do nothing by default (no side effects)
199
+ *
200
+ * The core will typically call onSubmitted with the result of send().
201
+ */
202
+ declare const localAdapter: NamedAdapterFactory<"local", any>;
203
+ /**
204
+ * Register or override an adapter factory for a given key.
205
+ *
206
+ * Hosts can call this at bootstrap time, e.g.:
207
+ *
208
+ * registerAdapter<'axios'>('axios', axiosAdapter);
209
+ */
210
+ declare function registerAdapter<K extends AdapterKey, Body = any>(key: K, factory: NamedAdapterFactory<K, Body>): void;
211
+ /**
212
+ * Lookup an adapter factory by key.
213
+ *
214
+ * If no adapter is found for the given key, this returns undefined.
215
+ */
216
+ declare function getAdapter<K extends AdapterKey>(key: K): NamedAdapterFactory<K, any> | undefined;
217
+ /**
218
+ * Check whether an adapter is registered for the given key.
219
+ */
220
+ declare function hasAdapter(key: AdapterKey): boolean;
221
+
222
+ declare const createAxiosAdapter: NamedAdapterFactory<"axios">;
223
+ declare module "@/schema/adapter" {
224
+ interface Adapters {
225
+ axios: {
226
+ /**
227
+ * What adapter.send() resolves with for Axios.
228
+ */
229
+ ok: AxiosResponse<unknown>;
230
+ /**
231
+ * What callbacks.onError receives for Axios.
232
+ *
233
+ * We pass the *payload* (e.g. response.data), not the raw AxiosError,
234
+ * so Form Palette's autoErr branch can see `.errors`.
235
+ */
236
+ err: unknown;
237
+ };
238
+ }
239
+ }
240
+
241
+ declare const createInertiaAdapter: NamedAdapterFactory<"inertia">;
242
+ declare module "@/schema/adapter" {
243
+ interface Adapters {
244
+ inertia: {
245
+ /**
246
+ * What adapter.send() resolves with for Inertia.
247
+ * This is the Page object passed to onSuccess.
248
+ */
249
+ ok: Page<any>;
250
+ /**
251
+ * What callbacks.onError receives for Inertia.
252
+ *
253
+ * We shape this as `{ errors: ErrorBag }` so Form Palette's
254
+ * autoErr branch can see `.errors`.
255
+ */
256
+ err: {
257
+ errors: Record<string, string | string[]>;
258
+ } | unknown;
259
+ };
260
+ }
261
+ }
262
+
263
+ /**
264
+ * Register the Axios adapter under the "axios" key.
265
+ *
266
+ * This performs a basic runtime check to make sure Axios is present.
267
+ * If Axios isn't available or doesn't look like a proper Axios instance,
268
+ * an error is thrown.
269
+ */
270
+ declare function registerAxiosAdapter(): void;
271
+ /**
272
+ * Register the Inertia adapter under the "inertia" key.
273
+ *
274
+ * This explicitly tests that '@inertiajs/react' can be imported and that
275
+ * it exposes a router with a .visit() method. If not, an error is thrown.
276
+ *
277
+ * Note:
278
+ * - This function is async because it uses dynamic import.
279
+ * - Call it at bootstrap time and await it:
280
+ *
281
+ * await registerInertiaAdapter();
282
+ */
283
+ declare function registerInertiaAdapter(): Promise<void>;
284
+ /**
285
+ * Optional helper: convenience registration for known adapter keys.
286
+ *
287
+ * This is purely ergonomic; you can also call registerAxiosAdapter /
288
+ * registerInertiaAdapter directly.
289
+ */
290
+ declare function registerKnownAdapter(key: AdapterKey): Promise<void>;
291
+
292
+ export { type AdapterCallbacks, type AdapterConfig, type AdapterError, type AdapterFactory, type AdapterKey, type AdapterOk, type AdapterResult, type AdapterSubmit, type Adapters, type Method, type NamedAdapterConfig, type NamedAdapterFactory, createAxiosAdapter, createInertiaAdapter, getAdapter, hasAdapter, localAdapter, registerAdapter, registerAxiosAdapter, registerInertiaAdapter, registerKnownAdapter };