@picked/react 0.0.56 → 0.0.57-next.1
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.
- package/dist/form/index.d.ts +31 -22
- package/dist/form/index.d.ts.map +1 -1
- package/dist/form/index.js +1 -1
- package/dist/form/index.test.d.ts +2 -0
- package/dist/form/index.test.d.ts.map +1 -0
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/step.d.ts +13 -23
- package/dist/hooks/step.d.ts.map +1 -1
- package/dist/hooks/step.js +1 -1
- package/dist/hooks/step.test.d.ts +2 -0
- package/dist/hooks/step.test.d.ts.map +1 -0
- package/dist/router/StepRouter.js +1 -1
- package/dist/utils/map-field-to-react.d.ts +32 -0
- package/dist/utils/map-field-to-react.d.ts.map +1 -0
- package/dist/utils/map-field-to-react.js +1 -0
- package/dist/utils/map-field-to-react.test.d.ts +2 -0
- package/dist/utils/map-field-to-react.test.d.ts.map +1 -0
- package/dist/utils/prepare-native-event.d.ts +16 -0
- package/dist/utils/prepare-native-event.d.ts.map +1 -0
- package/dist/utils/prepare-native-event.js +1 -0
- package/dist/utils/restore-current-target.d.ts +17 -0
- package/dist/utils/restore-current-target.d.ts.map +1 -0
- package/dist/utils/restore-current-target.js +1 -0
- package/package.json +2 -2
package/dist/form/index.d.ts
CHANGED
|
@@ -1,28 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
|
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
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
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(
|
|
27
|
-
export {};
|
|
36
|
+
export declare function useForm(formId: string, title: Store<string>, fieldKeys: Store<string[]>): FormInstance;
|
|
28
37
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/form/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/form/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/form/index.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,OAAO,EAAE,KAAK,SAAS,EAAW,MAAM,OAAO,CAAA;AAC/C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,YAAY,IAAI,gBAAgB,EACrC,KAAK,cAAc,EACnB,KAAK,eAAe,EACrB,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAAmB,KAAK,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAGlF,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE;QACJ,KAAK,EAAE;YACL,QAAQ,EAAE,CAAC,CAAC,EAAE,SAAS,CAAC,eAAe,CAAC,KAAK,IAAI,CAAA;SAClD,CAAA;QACD,MAAM,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAA;QAC1C,UAAU,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAA;QAClD,cAAc,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,MAAM,IAAI,CAAA;QACxD,SAAS,EAAE,CAAC,QAAQ,EAAE,eAAe,KAAK,MAAM,IAAI,CAAA;QACpD,OAAO,EAAE,CAAC,QAAQ,EAAE,aAAa,KAAK,MAAM,IAAI,CAAA;KACjD,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"}
|
package/dist/form/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useExperience as e,usePicked as t}from"../hooks/client.js";import"../
|
|
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 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../src/form/index.test.tsx"],"names":[],"mappings":""}
|
package/dist/hooks/index.js
CHANGED
|
@@ -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{
|
|
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};
|
package/dist/hooks/step.d.ts
CHANGED
|
@@ -1,29 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ExperienceStep
|
|
3
|
-
import {
|
|
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
|
|
7
|
-
fields: Store<
|
|
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
|
-
*
|
|
40
|
-
*
|
|
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;
|
package/dist/hooks/step.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../src/hooks/step.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../src/hooks/step.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAW,KAAK,YAAY,EAAE,MAAM,SAAS,CAAA;AAEpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAGjE,MAAM,WAAW,WAAW;IAC1B,IAAI,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"}
|
package/dist/hooks/step.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useExperience as e
|
|
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 @@
|
|
|
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{
|
|
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 @@
|
|
|
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.
|
|
3
|
+
"version": "0.0.57-next.1",
|
|
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.
|
|
88
|
+
"@picked/client": "0.0.57-next.1",
|
|
89
89
|
"effector": "^23.3.0",
|
|
90
90
|
"effector-react": "^23.3.0",
|
|
91
91
|
"react": "19.2.2",
|