@timeax/form-palette 0.0.6 → 0.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.
@@ -1,4 +1,4 @@
1
- import { AxiosResponse } from 'axios';
1
+ import { AxiosResponse, AxiosRequestConfig } from 'axios';
2
2
  import { Page } from './../../../../node_modules/@inertiajs/core/types/types.d';
3
3
 
4
4
  /**
@@ -6,7 +6,7 @@ import { Page } from './../../../../node_modules/@inertiajs/core/types/types.d';
6
6
  *
7
7
  * This matches the legacy Method union from the old types.ts.
8
8
  */
9
- type Method = 'post' | 'get' | 'delete' | 'put' | 'patch';
9
+ type Method$1 = 'post' | 'get' | 'delete' | 'put' | 'patch';
10
10
  /**
11
11
  * Lifecycle callbacks used by adapters to report events back to the core.
12
12
  *
@@ -89,17 +89,6 @@ interface AdapterResult<Ok = unknown> {
89
89
  * @template Err Type of the "error" payload.
90
90
  */
91
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
92
  /**
104
93
  * Request body payload built by the core.
105
94
  *
@@ -153,6 +142,9 @@ interface Adapters {
153
142
  err: unknown;
154
143
  };
155
144
  }
145
+ type AdapterProps<K extends AdapterKey> = Adapters[K] extends {
146
+ props: infer P;
147
+ } ? P : {};
156
148
  /**
157
149
  * Union of all adapter keys known to the core.
158
150
  *
@@ -181,7 +173,7 @@ type AdapterSubmit<K extends AdapterKey> = AdapterOk<K>;
181
173
  * @template K Adapter key.
182
174
  * @template Body Outbound payload type.
183
175
  */
184
- type NamedAdapterConfig<K extends AdapterKey, Body = unknown> = AdapterConfig<Body, AdapterOk<K>, AdapterError<K>>;
176
+ type NamedAdapterConfig<K extends AdapterKey, Body = unknown> = AdapterConfig<Body, AdapterOk<K>, AdapterError<K>> & AdapterProps<K>;
185
177
  /**
186
178
  * AdapterFactory specialised for a named adapter key K.
187
179
  *
@@ -234,6 +226,31 @@ declare module "@/schema/adapter" {
234
226
  * so Form Palette's autoErr branch can see `.errors`.
235
227
  */
236
228
  err: unknown;
229
+ /**
230
+ * Extra public props exposed on CoreProps when adapter="axios".
231
+ *
232
+ * These are set on the Core shell and then used by createAxiosAdapter.
233
+ */
234
+ props: {
235
+ /**
236
+ * Request URL for this form.
237
+ * Required when using the axios adapter.
238
+ */
239
+ url: string;
240
+ /**
241
+ * HTTP method to use for this form.
242
+ * Optional: the adapter/Core can still default to "post".
243
+ */
244
+ method?: Method;
245
+ /**
246
+ * Base Axios request config merged into every request.
247
+ *
248
+ * Useful for baseURL, headers, withCredentials, params,
249
+ * timeout, etc. Per-call overrides still go through the
250
+ * `options` parameter of submit/send/run.
251
+ */
252
+ config?: AxiosRequestConfig<any>;
253
+ };
237
254
  };
238
255
  }
239
256
  }
@@ -256,6 +273,19 @@ declare module "@/schema/adapter" {
256
273
  err: {
257
274
  errors: Record<string, string | string[]>;
258
275
  } | unknown;
276
+ /**
277
+ * Extra public props exposed on CoreProps when adapter="inertia".
278
+ */
279
+ props: {
280
+ /**
281
+ * Target URL / route for the Inertia visit.
282
+ */
283
+ url: string;
284
+ /**
285
+ * HTTP method to use for the visit.
286
+ */
287
+ method?: Method;
288
+ };
259
289
  };
260
290
  }
261
291
  }
@@ -289,4 +319,4 @@ declare function registerInertiaAdapter(): Promise<void>;
289
319
  */
290
320
  declare function registerKnownAdapter(key: AdapterKey): Promise<void>;
291
321
 
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 };
322
+ export { type AdapterCallbacks, type AdapterConfig, type AdapterError, type AdapterFactory, type AdapterKey, type AdapterOk, type AdapterProps, type AdapterResult, type AdapterSubmit, type Adapters, type Method$1 as Method, type NamedAdapterConfig, type NamedAdapterFactory, createAxiosAdapter, createInertiaAdapter, getAdapter, hasAdapter, localAdapter, registerAdapter, registerAxiosAdapter, registerInertiaAdapter, registerKnownAdapter };
@@ -1,4 +1,4 @@
1
- import { AxiosResponse } from 'axios';
1
+ import { AxiosResponse, AxiosRequestConfig } from 'axios';
2
2
  import { Page } from './../../../../node_modules/@inertiajs/core/types/types.d';
3
3
 
4
4
  /**
@@ -6,7 +6,7 @@ import { Page } from './../../../../node_modules/@inertiajs/core/types/types.d';
6
6
  *
7
7
  * This matches the legacy Method union from the old types.ts.
8
8
  */
9
- type Method = 'post' | 'get' | 'delete' | 'put' | 'patch';
9
+ type Method$1 = 'post' | 'get' | 'delete' | 'put' | 'patch';
10
10
  /**
11
11
  * Lifecycle callbacks used by adapters to report events back to the core.
12
12
  *
@@ -89,17 +89,6 @@ interface AdapterResult<Ok = unknown> {
89
89
  * @template Err Type of the "error" payload.
90
90
  */
91
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
92
  /**
104
93
  * Request body payload built by the core.
105
94
  *
@@ -153,6 +142,9 @@ interface Adapters {
153
142
  err: unknown;
154
143
  };
155
144
  }
145
+ type AdapterProps<K extends AdapterKey> = Adapters[K] extends {
146
+ props: infer P;
147
+ } ? P : {};
156
148
  /**
157
149
  * Union of all adapter keys known to the core.
158
150
  *
@@ -181,7 +173,7 @@ type AdapterSubmit<K extends AdapterKey> = AdapterOk<K>;
181
173
  * @template K Adapter key.
182
174
  * @template Body Outbound payload type.
183
175
  */
184
- type NamedAdapterConfig<K extends AdapterKey, Body = unknown> = AdapterConfig<Body, AdapterOk<K>, AdapterError<K>>;
176
+ type NamedAdapterConfig<K extends AdapterKey, Body = unknown> = AdapterConfig<Body, AdapterOk<K>, AdapterError<K>> & AdapterProps<K>;
185
177
  /**
186
178
  * AdapterFactory specialised for a named adapter key K.
187
179
  *
@@ -234,6 +226,31 @@ declare module "@/schema/adapter" {
234
226
  * so Form Palette's autoErr branch can see `.errors`.
235
227
  */
236
228
  err: unknown;
229
+ /**
230
+ * Extra public props exposed on CoreProps when adapter="axios".
231
+ *
232
+ * These are set on the Core shell and then used by createAxiosAdapter.
233
+ */
234
+ props: {
235
+ /**
236
+ * Request URL for this form.
237
+ * Required when using the axios adapter.
238
+ */
239
+ url: string;
240
+ /**
241
+ * HTTP method to use for this form.
242
+ * Optional: the adapter/Core can still default to "post".
243
+ */
244
+ method?: Method;
245
+ /**
246
+ * Base Axios request config merged into every request.
247
+ *
248
+ * Useful for baseURL, headers, withCredentials, params,
249
+ * timeout, etc. Per-call overrides still go through the
250
+ * `options` parameter of submit/send/run.
251
+ */
252
+ config?: AxiosRequestConfig<any>;
253
+ };
237
254
  };
238
255
  }
239
256
  }
@@ -256,6 +273,19 @@ declare module "@/schema/adapter" {
256
273
  err: {
257
274
  errors: Record<string, string | string[]>;
258
275
  } | unknown;
276
+ /**
277
+ * Extra public props exposed on CoreProps when adapter="inertia".
278
+ */
279
+ props: {
280
+ /**
281
+ * Target URL / route for the Inertia visit.
282
+ */
283
+ url: string;
284
+ /**
285
+ * HTTP method to use for the visit.
286
+ */
287
+ method?: Method;
288
+ };
259
289
  };
260
290
  }
261
291
  }
@@ -289,4 +319,4 @@ declare function registerInertiaAdapter(): Promise<void>;
289
319
  */
290
320
  declare function registerKnownAdapter(key: AdapterKey): Promise<void>;
291
321
 
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 };
322
+ export { type AdapterCallbacks, type AdapterConfig, type AdapterError, type AdapterFactory, type AdapterKey, type AdapterOk, type AdapterProps, type AdapterResult, type AdapterSubmit, type Adapters, type Method$1 as Method, type NamedAdapterConfig, type NamedAdapterFactory, createAxiosAdapter, createInertiaAdapter, getAdapter, hasAdapter, localAdapter, registerAdapter, registerAxiosAdapter, registerInertiaAdapter, registerKnownAdapter };
package/dist/adapters.js CHANGED
@@ -13125,7 +13125,7 @@ function normalizeInertiaError(raw) {
13125
13125
  return raw;
13126
13126
  }
13127
13127
  var createInertiaAdapter = (config3) => {
13128
- const { method, url, data, callbacks } = config3;
13128
+ const { method = "post", url, data, callbacks } = config3;
13129
13129
  const upperMethod = method.toUpperCase();
13130
13130
  function buildOptions(resolve, reject, extraOptions) {
13131
13131
  const merged = {