@picked/react 0.0.56 → 0.0.57

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,28 +1,37 @@
1
- import { FormInstance as CoreFormInstance, ErrorCallback, SubmitCallback, SuccessCallback } from '@picked/client/form';
2
- interface UseFormOptions {
3
- formId: string;
4
- title: string;
5
- fieldKeys: string[];
6
- }
7
- /**
8
- * React FormInstance — identical to core but callback registration returns void
9
- * (cleanup is handled automatically via useEffect, not by the consumer).
10
- */
11
- interface FormInstance<TFieldKeys extends string = string> extends Omit<CoreFormInstance<TFieldKeys>, 'form'> {
12
- form: Omit<CoreFormInstance<TFieldKeys>['form'], 'onBeforeSubmit' | 'onSuccess' | 'onError'> & {
13
- onBeforeSubmit: (callback: SubmitCallback<TFieldKeys>) => void;
14
- onSuccess: (callback: SuccessCallback<TFieldKeys>) => void;
15
- onError: (callback: ErrorCallback) => void;
1
+ import { FormEvent } from 'react';
2
+ import { Store } from 'effector';
3
+ import { ErrorCallback, FormInstance as CoreFormInstance, SubmitCallback, SuccessCallback } from '@picked/client/form';
4
+ import { ReactFormField } from '../utils/map-field-to-react';
5
+ export interface FormInstance {
6
+ form: {
7
+ props: {
8
+ onSubmit: (e: FormEvent<HTMLFormElement>) => void;
9
+ };
10
+ errors: CoreFormInstance['form']['errors'];
11
+ submitting: CoreFormInstance['form']['submitting'];
12
+ onBeforeSubmit: (callback: SubmitCallback) => () => void;
13
+ onSuccess: (callback: SuccessCallback) => () => void;
14
+ onError: (callback: ErrorCallback) => () => void;
16
15
  };
16
+ fields: Store<ReactFormField[]>;
17
17
  }
18
18
  /**
19
- * React hook wrapping the framework-agnostic createForm from @picked/client/form.
19
+ * React hook mirroring Svelte's `createForm`: accepts reactive stores for
20
+ * `title` and `fieldKeys` and returns a React-adapted form instance.
21
+ *
22
+ * The form is a stateful object (typed values, errors, subscribers) whose
23
+ * lifetime is the hook instance, not the render — so `title` and `fieldKeys`
24
+ * are stores (reactive access over time) rather than values (snapshots).
25
+ *
26
+ * `onBeforeSubmit` / `onSuccess` / `onError` return the core unsubscribe so
27
+ * callers can register inside `useEffect` with standard React cleanup:
28
+ * `useEffect(() => form.onBeforeSubmit(handler), [form, handler])`.
20
29
  *
21
- * - Injects client and experienceInstance from React context
22
- * - Collects unsubscribe functions from callback registration and cleans them
23
- * up on unmount via a single useEffect
24
- * - Consumer DX: `form.onSuccess(cb)` — no hooks or lifecycle awareness needed
30
+ * @param {string} formId - Stable identifier for the form.
31
+ * @param {Store<string>} title - Store holding the form/step title.
32
+ * @param {Store<string[]>} fieldKeys - Store of field keys belonging to this form.
33
+ * @returns {FormInstance} React form with submit handler, mapped fields, and subscribable callbacks.
34
+ * @example const { form, fields } = useForm(stepKey, nameStore, fieldKeysStore)
25
35
  */
26
- export declare function useForm({ formId, title, fieldKeys }: UseFormOptions): FormInstance;
27
- export {};
36
+ export declare function useForm(formId: string, title: Store<string>, fieldKeys: Store<string[]>): FormInstance;
28
37
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/form/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,YAAY,IAAI,gBAAgB,EACrC,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,eAAe,EACrB,MAAM,qBAAqB,CAAA;AAG5B,UAAU,cAAc;IACtB,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,MAAM,EAAE,CAAA;CACpB;AAED;;;GAGG;AACH,UAAU,YAAY,CAAC,UAAU,SAAS,MAAM,GAAG,MAAM,CAAE,SAAQ,IAAI,CACrE,gBAAgB,CAAC,UAAU,CAAC,EAC5B,MAAM,CACP;IACC,IAAI,EAAE,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,EAAE,gBAAgB,GAAG,WAAW,GAAG,SAAS,CAAC,GAAG;QAC7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,CAAA;IACD,MAAM,EAAE,KAAK,CAAC,cAAc,EAAE,CAAC,CAAA;CAChC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,OAAO,CACrB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,EACpB,SAAS,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,GACzB,YAAY,CAgCd"}
@@ -1 +1 @@
1
- import{useExperience as e,usePicked as t}from"../hooks/client.js";import"../hooks/index.js";import{useEffect as n,useMemo as r,useRef as i}from"react";import{createStore as a}from"effector";import{createForm as o}from"@picked/client/form";function s({formId:s,title:c,fieldKeys:l}){let u=t(),d=e(),f=r(()=>a(c),[c]),p=r(()=>a(l),[l]),m=r(()=>o({client:u,experienceInstance:d},s,f,p),[u,d,s,f,p]),h=i([]);return n(()=>()=>{h.current.forEach(e=>e()),h.current=[]},[]),{form:r(()=>({...m.form,onBeforeSubmit:e=>{h.current.push(m.form.onBeforeSubmit(e))},onSuccess:e=>{h.current.push(m.form.onSuccess(e))},onError:e=>{h.current.push(m.form.onError(e))}}),[m]),fields:m.fields}}export{s as useForm};
1
+ import{useExperience as e,usePicked as t}from"../hooks/client.js";import{mapFieldToReact as n}from"../utils/map-field-to-react.js";import{prepareNativeEvent as r}from"../utils/prepare-native-event.js";import{useMemo as i}from"react";import{createForm as a}from"@picked/client/form";function o(o,s,c){let l=t(),u=e(),d=i(()=>a({client:l,experienceInstance:u},o,s,c),[l,u,o,s,c]),f=i(()=>d.fields.map(e=>e.map(n)),[d]);return{form:i(()=>({errors:d.form.errors,submitting:d.form.submitting,props:{onSubmit:e=>{e.preventDefault(),r(e.nativeEvent,e.currentTarget),d.form.props.onsubmit(e.nativeEvent)}},onBeforeSubmit:e=>d.form.onBeforeSubmit(e),onSuccess:e=>d.form.onSuccess(e),onError:e=>d.form.onError(e)}),[d]),fields:f}}export{o as useForm};
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../src/form/index.test.tsx"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- import{ClientContext as e,ClientProvider as t,ExperienceContext as n,ExperienceProvider as r}from"../context.js";import{useExperience as i,usePicked as a}from"./client.js";import{useSetStepContext as o,useStep as s}from"./step.js";import{useLocalStorage as c,useSessionStorage as l}from"./storage.js";import{getField as u}from"./field.js";import{useFeature as d,useFeatureResult as f}from"./feature.js";export{e as ClientContext,t as ClientProvider,n as ExperienceContext,r as ExperienceProvider,u as getField,i as useExperience,d as useFeature,f as useFeatureResult,c as useLocalStorage,a as usePicked,l as useSessionStorage,o as useSetStepContext,s as useStep};
1
+ import{ClientContext as e,ClientProvider as t,ExperienceContext as n,ExperienceProvider as r}from"../context.js";import{useExperience as i,usePicked as a}from"./client.js";import{useFeature as o,useFeatureResult as s}from"./feature.js";import{getField as c}from"./field.js";import{useSetStepContext as l,useStep as u}from"./step.js";import{useLocalStorage as d,useSessionStorage as f}from"./storage.js";export{e as ClientContext,t as ClientProvider,n as ExperienceContext,r as ExperienceProvider,c as getField,i as useExperience,o as useFeature,s as useFeatureResult,d as useLocalStorage,a as usePicked,f as useSessionStorage,l as useSetStepContext,u as useStep};
@@ -1,29 +1,15 @@
1
- import { EventCallable, Store } from 'effector';
2
- import { ExperienceStep, ValidationError } from '@picked/client';
3
- import { FormField, ErrorCallback, SubmitCallback, SubmitEventWithCurrentTarget, SuccessCallback } from '@picked/client/form';
1
+ import { Store } from 'effector';
2
+ import { ExperienceStep } from '@picked/client';
3
+ import { FormInstance } from '../form';
4
+ import { ReactFormField } from '../utils/map-field-to-react';
4
5
  export interface StepContext {
5
6
  step: Store<ExperienceStep>;
6
- /** Reactive store of fields with current values, errors, touched state, and event handlers. */
7
- fields: Store<FormField[]>;
7
+ /** Reactive store of fields with React-style event handlers and current state. */
8
+ fields: Store<ReactFormField[]>;
8
9
  isActive: boolean;
9
10
  /** @deprecated Use `isActive` instead. */
10
11
  isActiveStep: boolean;
11
- form: {
12
- /** HTML-safe attributes to spread onto a form element. */
13
- props: {
14
- onsubmit: EventCallable<SubmitEventWithCurrentTarget>;
15
- };
16
- /** Flat list of all current validation errors. */
17
- errors: Store<ValidationError[]>;
18
- /** Whether the form is currently submitting. */
19
- submitting: Store<boolean>;
20
- /** Register a callback to transform data before submission. Cleanup is automatic. */
21
- onBeforeSubmit: (callback: SubmitCallback) => void;
22
- /** Register a callback to run on successful submission. Cleanup is automatic. */
23
- onSuccess: (callback: SuccessCallback) => void;
24
- /** Register a callback to run on validation errors. Cleanup is automatic. */
25
- onError: (callback: ErrorCallback) => void;
26
- };
12
+ form: FormInstance['form'];
27
13
  }
28
14
  export declare const StepContextProvider: import('react').Context<StepContext | null>;
29
15
  /**
@@ -36,8 +22,12 @@ export declare function useStep(): StepContext;
36
22
  /**
37
23
  * Creates and provides step context for the given step key.
38
24
  *
39
- * @param {string} stepKey - The step key.
40
- * @returns {StepContext} The step context with form, fields, and active state.
25
+ * If the step key is not (yet) present in the experience tree, the returned
26
+ * `step` store resolves to an empty placeholder and updates reactively once the
27
+ * step is registered — matching the Svelte SDK's behaviour.
28
+ *
29
+ * @param {string} stepKey - The step key to look up in the experience tree.
30
+ * @returns {StepContext} Step context with form, fields, and active state.
41
31
  * @example useSetStepContext('step-1')
42
32
  */
43
33
  export declare function useSetStepContext(stepKey: string): StepContext;
@@ -1 +1 @@
1
- {"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../src/hooks/step.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACrE,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,4BAA4B,EACjC,KAAK,eAAe,EACrB,MAAM,qBAAqB,CAA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,EAAE,KAAK,CAAC,cAAc,CAAC,CAAA;IAC3B,kFAAkF;IAClF,MAAM,EAAE,KAAK,CAAC,cAAc,EAAE,CAAC,CAAA;IAC/B,QAAQ,EAAE,OAAO,CAAA;IACjB,0CAA0C;IAC1C,YAAY,EAAE,OAAO,CAAA;IACrB,IAAI,EAAE,YAAY,CAAC,MAAM,CAAC,CAAA;CAC3B;AAED,eAAO,MAAM,mBAAmB,6CAA0C,CAAA;AAE1E;;;;;GAKG;AACH,wBAAgB,OAAO,IAAI,WAAW,CAOrC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,CAyC9D"}
@@ -1 +1 @@
1
- import{useExperience as e,usePicked as t}from"./client.js";import{useStepRouter as n}from"../router/context.js";import{createContext as r,useContext as i,useEffect as a,useMemo as o,useRef as s}from"react";import{createForm as c}from"@picked/client/form";var l=r(null);function u(){let e=i(l);if(!e)throw Error(`useStep must be used within a StepContextProvider`);return e}function d(r){let i=e(),l=t(),{activeStep:u}=n(),d=o(()=>u?.key===r,[u?.key,r]),f=o(()=>i.treeStore.map(e=>{let t=e.steps.find(e=>e.key===r);if(!t)throw Error(`Step with key "${r}" not found in the experience tree.`);return t}),[i,r]),p=o(()=>f.map(e=>e.name),[f]),m=o(()=>f.map(e=>e.fieldKeys),[f]),h=o(()=>c({client:l,experienceInstance:i},r,p,m),[l,i,r,p,m]),g=s([]);a(()=>()=>{g.current.forEach(e=>e()),g.current=[]},[]);let _=o(()=>({...h.form,onBeforeSubmit:e=>{g.current.push(h.form.onBeforeSubmit(e))},onSuccess:e=>{g.current.push(h.form.onSuccess(e))},onError:e=>{g.current.push(h.form.onError(e))}}),[h]);return{step:f,fields:h.fields,isActive:d,isActiveStep:d,form:_}}export{l as StepContextProvider,d as useSetStepContext,u as useStep};
1
+ import{useExperience as e}from"./client.js";import{useForm as t}from"../form/index.js";import{useStepRouter as n}from"../router/context.js";import{createContext as r,useContext as i,useMemo as a}from"react";var o=r(null);function s(){let e=i(o);if(!e)throw Error(`useStep must be used within a StepContextProvider`);return e}function c(r){let i=e(),{activeStep:o}=n(),s=a(()=>o?.key===r,[o?.key,r]),c=a(()=>i.treeStore.map(e=>e.steps.find(e=>e.key===r)??{id:r,key:r,name:``,fieldKeys:[]},{skipVoid:!1}),[i,r]),{form:l,fields:u}=t(r,a(()=>c.map(e=>e.name,{skipVoid:!1}),[c]),a(()=>c.map(e=>e.fieldKeys,{skipVoid:!1}),[c]));return{step:c,fields:u,isActive:s,isActiveStep:s,form:l}}export{o as StepContextProvider,c as useSetStepContext,s as useStep};
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=step.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"step.test.d.ts","sourceRoot":"","sources":["../../src/hooks/step.test.tsx"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- import{useExperience as e}from"../hooks/client.js";import{StepRouterProvider as t}from"./context.js";import"../hooks/index.js";import{useCallback as n,useMemo as r,useRef as i,useState as a}from"react";import{supportsWindow as o}from"@picked/client";import{useUnit as s}from"effector-react";import{jsx as c}from"react/jsx-runtime";function l({children:l}){let{currentStepStore:u}=e(),d=s(u),f=i(!1),[p,m]=a([]),[h,g]=a(null),_=n(e=>{if(o())m(t=>[...t,e]);else{if(f.current)return;e.key===d?.key&&(g(e),f.current=!0)}},[d?.key]),v=n(e=>{m(t=>t.filter(t=>t!==e))},[]),y=r(()=>h??p.find(e=>e.key===d?.key)??null,[h,p,d?.key]),b=r(()=>({activeStep:y,registerStep:_,unregisterStep:v}),[y,_,v]);return d?.key?c(t,{value:b,children:l}):null}export{l as default};
1
+ import{useExperience as e}from"../hooks/client.js";import{StepRouterProvider as t}from"./context.js";import"../hooks/index.js";import{useCallback as n,useMemo as r,useRef as i,useState as a}from"react";import{useUnit as o}from"effector-react";import{supportsWindow as s}from"@picked/client";import{jsx as c}from"react/jsx-runtime";function l({children:l}){let{currentStepStore:u}=e(),d=o(u),f=i(!1),[p,m]=a([]),[h,g]=a(null),_=n(e=>{if(s())m(t=>[...t,e]);else{if(f.current)return;e.key===d?.key&&(g(e),f.current=!0)}},[d?.key]),v=n(e=>{m(t=>t.filter(t=>t!==e))},[]),y=r(()=>h??p.find(e=>e.key===d?.key)??null,[h,p,d?.key]),b=r(()=>({activeStep:y,registerStep:_,unregisterStep:v}),[y,_,v]);return d?.key?c(t,{value:b,children:l}):null}export{l as default};
@@ -0,0 +1,32 @@
1
+ import { FormField } from '@picked/client/form';
2
+ import { ChangeEvent, FocusEvent, FormEvent } from 'react';
3
+ type FieldElement = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
4
+ export interface ReactFormFieldProps {
5
+ id: string;
6
+ name: string;
7
+ key: string;
8
+ value: FormField['props']['value'];
9
+ type: FormField['props']['type'];
10
+ required: boolean;
11
+ placeholder: string | undefined;
12
+ onInput: (e: FormEvent<FieldElement>) => void;
13
+ onChange: (e: ChangeEvent<FieldElement>) => void;
14
+ onBlur: (e: FocusEvent<FieldElement>) => void;
15
+ }
16
+ export type ReactFormField = Omit<FormField, 'props'> & {
17
+ props: ReactFormFieldProps;
18
+ };
19
+ /**
20
+ * Maps a core FormField to a React-compatible version with camelCase event handlers.
21
+ *
22
+ * Replaces lowercase DOM handlers (oninput, onchange, onblur) with React-style
23
+ * camelCase handlers (onInput, onChange, onBlur) that bridge synthetic events to
24
+ * the core SDK.
25
+ *
26
+ * @param {FormField} field - The core form field to map.
27
+ * @returns {ReactFormField} A field with React-compatible props.
28
+ * @example mapFieldToReact(coreField)
29
+ */
30
+ export declare function mapFieldToReact(field: FormField): ReactFormField;
31
+ export {};
32
+ //# sourceMappingURL=map-field-to-react.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"map-field-to-react.d.ts","sourceRoot":"","sources":["../../src/utils/map-field-to-react.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAkB,MAAM,OAAO,CAAA;AAG/E,KAAK,YAAY,GAAG,gBAAgB,GAAG,iBAAiB,GAAG,mBAAmB,CAAA;AAE9E,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAA;IAClC,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAA;IAChC,QAAQ,EAAE,OAAO,CAAA;IACjB,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,OAAO,EAAE,CAAC,CAAC,EAAE,SAAS,CAAC,YAAY,CAAC,KAAK,IAAI,CAAA;IAC7C,QAAQ,EAAE,CAAC,CAAC,EAAE,WAAW,CAAC,YAAY,CAAC,KAAK,IAAI,CAAA;IAChD,MAAM,EAAE,CAAC,CAAC,EAAE,UAAU,CAAC,YAAY,CAAC,KAAK,IAAI,CAAA;CAC9C;AAED,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,GAAG;IACtD,KAAK,EAAE,mBAAmB,CAAA;CAC3B,CAAA;AAiBD;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,GAAG,cAAc,CAYhE"}
@@ -0,0 +1 @@
1
+ import{restoreCurrentTarget as e}from"./restore-current-target.js";function t(t){return n=>{e(n.nativeEvent,n.currentTarget),t(n.nativeEvent)}}function n(e){let{oninput:n,onchange:r,onblur:i,...a}=e.props;return{...e,props:{...a,onInput:t(n),onChange:t(r),onBlur:t(i)}}}export{n as mapFieldToReact};
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=map-field-to-react.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"map-field-to-react.test.d.ts","sourceRoot":"","sources":["../../src/utils/map-field-to-react.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,16 @@
1
+ import { SubmitEventWithCurrentTarget } from '@picked/client/form';
2
+ /**
3
+ * Narrows a native form submit event to SubmitEventWithCurrentTarget, restoring
4
+ * currentTarget as a side effect so the core SDK can build FormData.
5
+ *
6
+ * Always runs unconditionally. Testing-library's `fireEvent.submit` dispatches
7
+ * a plain Event (not SubmitEvent), and some legacy programmatic submits do the
8
+ * same. The core consumer only reads currentTarget, so the narrowed type is a
9
+ * TypeScript assertion, not a runtime gate.
10
+ *
11
+ * @param {Event} nativeEvent - Native DOM event from a React form submission.
12
+ * @param {HTMLFormElement} currentTarget - Form element from React's synthetic event.
13
+ * @example prepareNativeEvent(e.nativeEvent, e.currentTarget)
14
+ */
15
+ export declare function prepareNativeEvent(nativeEvent: Event, currentTarget: HTMLFormElement): asserts nativeEvent is SubmitEventWithCurrentTarget;
16
+ //# sourceMappingURL=prepare-native-event.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prepare-native-event.d.ts","sourceRoot":"","sources":["../../src/utils/prepare-native-event.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAA;AAGvE;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,KAAK,EAClB,aAAa,EAAE,eAAe,GAC7B,OAAO,CAAC,WAAW,IAAI,4BAA4B,CAErD"}
@@ -0,0 +1 @@
1
+ import{restoreCurrentTarget as e}from"./restore-current-target.js";function t(t,n){e(t,n)}export{t as prepareNativeEvent};
@@ -0,0 +1,17 @@
1
+ /** @file Writes currentTarget onto a native event to bridge React's synthetic events to DOM handlers. */
2
+ /**
3
+ * Writes currentTarget onto a native DOM event.
4
+ *
5
+ * React delegates events at the root and preserves currentTarget only on its
6
+ * synthetic wrapper — the underlying native event has currentTarget set to the
7
+ * delegation root during dispatch and reset to null afterwards. The core SDK's
8
+ * handlers read currentTarget directly, so this restores the element that React
9
+ * routed the event to. `writable: true` lets the property be reassigned if the
10
+ * same event bubbles through multiple bridged handlers.
11
+ *
12
+ * @param {Event} event - The native DOM event from a React synthetic event.
13
+ * @param {EventTarget} currentTarget - The element from React's synthetic event.
14
+ * @example restoreCurrentTarget(e.nativeEvent, e.currentTarget)
15
+ */
16
+ export declare function restoreCurrentTarget(event: Event, currentTarget: EventTarget): void;
17
+ //# sourceMappingURL=restore-current-target.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"restore-current-target.d.ts","sourceRoot":"","sources":["../../src/utils/restore-current-target.ts"],"names":[],"mappings":"AAAA,yGAAyG;AAEzG;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,WAAW,GAAG,IAAI,CAMnF"}
@@ -0,0 +1 @@
1
+ function e(e,t){Object.defineProperty(e,`currentTarget`,{value:t,configurable:!0,writable:!0})}export{e as restoreCurrentTarget};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@picked/react",
3
- "version": "0.0.56",
3
+ "version": "0.0.57",
4
4
  "devDependencies": {
5
5
  "@picked/client": "workspace:*",
6
6
  "@repo/eslint-config": "workspace:*",
@@ -85,7 +85,7 @@
85
85
  },
86
86
  "module": "./dist/index.js",
87
87
  "peerDependencies": {
88
- "@picked/client": "0.0.56",
88
+ "@picked/client": "0.0.57",
89
89
  "effector": "^23.3.0",
90
90
  "effector-react": "^23.3.0",
91
91
  "react": "19.2.2",