@picked/svelte 0.0.1-dev.1775623922816 → 0.0.1-dev.1775627395474

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 +1 @@
1
- import{getExperience as e,getPicked as t}from"../hooks/client.js";import{createForm as n}from"@picked/client/form";import*as r from"svelte/internal/client";function i(i,a,o){let s=n({client:t(),experienceInstance:e()},i,a,o);return{...s,form:{...s.form,onBeforeSubmit:e=>{r.user_effect(()=>s.form.onBeforeSubmit(e))},onSuccess:e=>{r.user_effect(()=>s.form.onSuccess(e))},onError:e=>{r.user_effect(()=>s.form.onError(e))}}}}export{i as createForm};
1
+ import{getExperience as e,getPicked as t}from"../hooks/client.js";import{createForm as n}from"@picked/client/form";import*as r from"svelte/internal/client";function i(i,a,o){let s=n({client:t(),experienceInstance:e()},i,a,o);return{...s,form:{...s.form,props:{...s.form.props,onsubmit:e=>s.form.props.onsubmit(e)},onBeforeSubmit:e=>{r.user_effect(()=>s.form.onBeforeSubmit(e))},onSuccess:e=>{r.user_effect(()=>s.form.onSuccess(e))},onError:e=>{r.user_effect(()=>s.form.onError(e))}}}}export{i as createForm};
@@ -1,12 +1,15 @@
1
1
  import { Store } from 'effector';
2
- import { FormInstance as CoreFormInstance, ErrorCallback, SubmitCallback, SuccessCallback } from '@picked/client/form';
2
+ import { FormInstance as CoreFormInstance, ErrorCallback, SubmitCallback, SubmitEventWithCurrentTarget, SuccessCallback } from '@picked/client/form';
3
3
  export type { FormField } from '@picked/client/form';
4
4
  /**
5
5
  * Svelte FormInstance — identical to core but callback registration returns void
6
6
  * (cleanup is handled automatically via $effect, not by the consumer).
7
7
  */
8
8
  export interface FormInstance<TFieldIds extends string = string> extends Omit<CoreFormInstance<TFieldIds>, 'form'> {
9
- form: Omit<CoreFormInstance<TFieldIds>['form'], 'onBeforeSubmit' | 'onSuccess' | 'onError'> & {
9
+ form: Omit<CoreFormInstance<TFieldIds>['form'], 'onBeforeSubmit' | 'onSuccess' | 'onError' | 'props'> & {
10
+ props: {
11
+ onsubmit: (e: SubmitEventWithCurrentTarget) => void;
12
+ };
10
13
  onBeforeSubmit: (callback: SubmitCallback<TFieldIds>) => void;
11
14
  onSuccess: (callback: SuccessCallback<TFieldIds>) => void;
12
15
  onError: (callback: ErrorCallback) => void;
@@ -15,10 +18,20 @@ export interface FormInstance<TFieldIds extends string = string> extends Omit<Co
15
18
  /**
16
19
  * Creates a form instance with Svelte lifecycle management.
17
20
  *
18
- * Wraps the framework-agnostic createForm from @picked/client/form:
19
- * - Injects client and experienceInstance from Svelte context
20
- * - Auto-wires callback cleanup via $effect so consumers don't need to manage lifecycle
21
+ * Wraps the framework-agnostic createForm from `@picked/client/form`:
22
+ * - Injects client and experienceInstance from Svelte context.
23
+ * - Wraps `form.props.onsubmit` as a plain function (not an Effector EventCallable).
24
+ * - Auto-wires callback cleanup via `$effect` so consumers don't need to manage lifecycle.
21
25
  *
22
26
  * Used internally by setStepContext — access via getStep() in components.
27
+ *
28
+ * @param {string} formId - Unique identifier for this form instance.
29
+ * @param {Store<string>} title - Reactive store holding the form/step title.
30
+ * @param {Store<string[]>} fieldIds - Reactive store of field IDs that belong to this form.
31
+ * @returns {FormInstance} A form instance with reactive field stores, submission handlers, and callback registration.
32
+ * @example
33
+ * ```ts
34
+ * const { form, fields } = createForm('lead-capture', $title, $fieldIds)
35
+ * ```
23
36
  */
24
37
  export declare function createForm(formId: string, title: Store<string>, fieldIds: Store<string[]>): FormInstance;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@picked/svelte",
3
- "version": "0.0.1-dev.1775623922816",
3
+ "version": "0.0.1-dev.1775627395474",
4
4
  "dependencies": {
5
5
  "d3": "^7.9.0"
6
6
  },
@@ -88,7 +88,7 @@
88
88
  },
89
89
  "module": "./dist/index.js",
90
90
  "peerDependencies": {
91
- "@picked/client": "0.0.1-dev.1775623922816",
91
+ "@picked/client": "0.0.1-dev.1775627395474",
92
92
  "effector": "^23.3.0",
93
93
  "svelte": "^5.46.4"
94
94
  },