@picked/react 0.0.1-dev.1774231221701 → 0.0.1-dev.1774912386475

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.
@@ -9,8 +9,8 @@ interface UseFormOptions {
9
9
  * (cleanup is handled automatically via useEffect, not by the consumer).
10
10
  */
11
11
  interface FormInstance<TFieldIds extends string = string> extends Omit<CoreFormInstance<TFieldIds>, 'form'> {
12
- form: Omit<CoreFormInstance<TFieldIds>['form'], 'onSubmit' | 'onSuccess' | 'onError'> & {
13
- onSubmit: (callback: SubmitCallback<TFieldIds>) => void;
12
+ form: Omit<CoreFormInstance<TFieldIds>['form'], 'onBeforeSubmit' | 'onSuccess' | 'onError'> & {
13
+ onBeforeSubmit: (callback: SubmitCallback<TFieldIds>) => void;
14
14
  onSuccess: (callback: SuccessCallback<TFieldIds>) => void;
15
15
  onError: (callback: ErrorCallback) => void;
16
16
  };
@@ -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,QAAQ,EAAE,MAAM,EAAE,CAAA;CACnB;AAED;;;GAGG;AACH,UAAU,YAAY,CAAC,SAAS,SAAS,MAAM,GAAG,MAAM,CACtD,SAAQ,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IACjD,IAAI,EAAE,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,WAAW,GAAG,SAAS,CAAC,GAAG;QACtF,QAAQ,EAAE,CAAC,QAAQ,EAAE,cAAc,CAAC,SAAS,CAAC,KAAK,IAAI,CAAA;QACvD,SAAS,EAAE,CAAC,QAAQ,EAAE,eAAe,CAAC,SAAS,CAAC,KAAK,IAAI,CAAA;QACzD,OAAO,EAAE,CAAC,QAAQ,EAAE,aAAa,KAAK,IAAI,CAAA;KAC3C,CAAA;CACF;AAED;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,cAAc,GAAG,YAAY,CAyCjF"}
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,QAAQ,EAAE,MAAM,EAAE,CAAA;CACnB;AAED;;;GAGG;AACH,UAAU,YAAY,CAAC,SAAS,SAAS,MAAM,GAAG,MAAM,CAAE,SAAQ,IAAI,CACpE,gBAAgB,CAAC,SAAS,CAAC,EAC3B,MAAM,CACP;IACC,IAAI,EAAE,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,EAAE,gBAAgB,GAAG,WAAW,GAAG,SAAS,CAAC,GAAG;QAC5F,cAAc,EAAE,CAAC,QAAQ,EAAE,cAAc,CAAC,SAAS,CAAC,KAAK,IAAI,CAAA;QAC7D,SAAS,EAAE,CAAC,QAAQ,EAAE,eAAe,CAAC,SAAS,CAAC,KAAK,IAAI,CAAA;QACzD,OAAO,EAAE,CAAC,QAAQ,EAAE,aAAa,KAAK,IAAI,CAAA;KAC3C,CAAA;CACF;AAED;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,cAAc,GAAG,YAAY,CAwCjF"}
@@ -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,fieldIds: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,onSubmit:e=>{h.current.push(m.form.onSubmit(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"../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,fieldIds: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,16 +1,16 @@
1
1
  import { ExperienceInstance, Picked } from '@picked/client';
2
2
  /**
3
- * Retrieves the Picked Client for the Experience Instance
4
- *
5
- * @returns The Picked client instance that provides access to experiences, steps, and other Picked functionality
3
+ * Retrieves the Picked Client for the Experience Instance.
4
+ * @returns The Picked client instance that provides access to experiences, steps, and other Picked functionality.
5
+ * @example
6
+ * const client = usePicked()
6
7
  */
7
8
  export declare function usePicked(): Picked;
8
9
  /**
9
- * Retrieves the Experience Store for the current Experience Instance
10
- *
11
- * @returns The Experience store instance that provides access to experience configuration and state
10
+ * Retrieves the Experience Store for the current Experience Instance.
11
+ * @returns The Experience store instance that provides access to experience configuration and state.
12
+ * @example
13
+ * const experience = useExperience()
12
14
  */
13
15
  export declare function useExperience(): ExperienceInstance;
14
- export declare const getPicked: typeof usePicked;
15
- export declare const getExperience: typeof useExperience;
16
16
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/hooks/client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAGhE;;;;GAIG;AACH,wBAAgB,SAAS,IAAI,MAAM,CAOlC;AAED;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,kBAAkB,CAOlD;AAGD,eAAO,MAAM,SAAS,kBAAY,CAAA;AAClC,eAAO,MAAM,aAAa,sBAAgB,CAAA"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/hooks/client.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAGhE;;;;;GAKG;AACH,wBAAgB,SAAS,IAAI,MAAM,CAOlC;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,IAAI,kBAAkB,CAOlD"}
@@ -1 +1 @@
1
- import{ClientContext as e,ExperienceContext as t}from"../context.js";import{useContext as n}from"react";function r(){let t=n(e);if(!t)throw Error(`usePicked must be used within a ClientProvider`);return t}function i(){let e=n(t);if(!e)throw Error(`useExperience must be used within an ExperienceProvider`);return e}var a=r,o=i;export{o as getExperience,a as getPicked,i as useExperience,r as usePicked};
1
+ import{ClientContext as e,ExperienceContext as t}from"../context.js";import{useContext as n}from"react";function r(){let t=n(e);if(!t)throw Error(`usePicked must be used within a ClientProvider`);return t}function i(){let e=n(t);if(!e)throw Error(`useExperience must be used within an ExperienceProvider`);return e}export{i as useExperience,r as usePicked};
@@ -4,5 +4,5 @@ export interface GetFieldResponse {
4
4
  value: Store<FieldValue>;
5
5
  field: Store<Field | null>;
6
6
  }
7
- export declare function getField(id: string): GetFieldResponse;
7
+ export declare function getField(key: string): GetFieldResponse;
8
8
  //# sourceMappingURL=field.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../../src/hooks/field.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AACvD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAGrC,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,CAAA;IACxB,KAAK,EAAE,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,CAAA;CAC3B;AAED,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,gBAAgB,CAQrD"}
1
+ {"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../../src/hooks/field.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AACvD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAGrC,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,CAAA;IACxB,KAAK,EAAE,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,CAAA;CAC3B;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAQtD"}
@@ -1 +1 @@
1
- import{getPicked as e}from"./client.js";function t(t){let n=e();return{field:n.fields.getById(t),value:n.responses.getByFieldId(t)}}export{t as getField};
1
+ import{usePicked as e}from"./client.js";function t(t){let n=e();return{field:n.fields.getByKey(t),value:n.responses.getByFieldKey(t)}}export{t as getField};
@@ -1,5 +1,10 @@
1
- export { usePicked, useExperience, getPicked, getExperience } from './client';
1
+ /**
2
+ * @file Public re-exports for the hooks entry point.
3
+ */
4
+ export { usePicked, useExperience } from './client';
2
5
  export { useStep, useSetStepContext } from './step';
6
+ export type { StepContext } from './step';
3
7
  export { useSessionStorage, useLocalStorage } from './storage';
8
+ export type { UseStorageOptions } from './storage';
4
9
  export * from './field';
5
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAC7E,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAA;AACnD,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAC9D,cAAc,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAA;AACnD,YAAY,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AACzC,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAC9D,YAAY,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAClD,cAAc,SAAS,CAAA"}
@@ -1 +1 @@
1
- import{getExperience as e,getPicked as t,useExperience as n,usePicked as r}from"./client.js";import{useSetStepContext as i,useStep as a}from"./step.js";import{useLocalStorage as o,useSessionStorage as s}from"./storage.js";import{getField as c}from"./field.js";export{e as getExperience,c as getField,t as getPicked,n as useExperience,o as useLocalStorage,r as usePicked,s as useSessionStorage,i as useSetStepContext,a as useStep};
1
+ import{useExperience as e,usePicked as t}from"./client.js";import{useSetStepContext as n,useStep as r}from"./step.js";import{useLocalStorage as i,useSessionStorage as a}from"./storage.js";import{getField as o}from"./field.js";export{o as getField,e as useExperience,i as useLocalStorage,t as usePicked,a as useSessionStorage,n as useSetStepContext,r as useStep};
@@ -1,26 +1,44 @@
1
- import { Field, Response } from '@picked/client';
2
- type FieldWithValue = Field & {
3
- value: Response | undefined;
4
- };
5
- type StepWithLabel = {
6
- id: string;
7
- label: string;
8
- };
1
+ import { EventCallable, Store } from 'effector';
2
+ import { ExperienceStep, ValidationError } from '@picked/client';
3
+ import { FormField, ErrorCallback, SubmitCallback, SubmitEventWithCurrentTarget, SuccessCallback } from '@picked/client/form';
9
4
  export interface StepContext {
10
- step: StepWithLabel;
11
- fields: FieldWithValue[];
12
- isActiveStep?: boolean;
5
+ step: Store<ExperienceStep>;
6
+ /** Reactive store of fields with current values, errors, touched state, and event handlers. */
7
+ fields: Store<FormField[]>;
8
+ isActive: boolean;
9
+ /** @deprecated Use `isActive` instead. */
10
+ 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
+ };
13
27
  }
14
28
  export declare const StepContextProvider: import('react').Context<StepContext | null>;
15
- export declare function useStep(): {
16
- step: StepWithLabel;
17
- fields: FieldWithValue[];
18
- isActiveStep: boolean;
19
- };
20
- export declare function useSetStepContext(stepId: string): {
21
- step: StepWithLabel;
22
- fields: FieldWithValue[];
23
- isActiveStep: boolean;
24
- };
25
- export {};
29
+ /**
30
+ * Retrieves the step context from the nearest provider.
31
+ *
32
+ * @returns {StepContext} The current step context.
33
+ * @example useStep()
34
+ */
35
+ export declare function useStep(): StepContext;
36
+ /**
37
+ * Creates and provides step context for the given step ID.
38
+ *
39
+ * @param {string} stepId - The step identifier.
40
+ * @returns {StepContext} The step context with form, fields, and active state.
41
+ * @example useSetStepContext('step-1')
42
+ */
43
+ export declare function useSetStepContext(stepId: string): StepContext;
26
44
  //# sourceMappingURL=step.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../src/hooks/step.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAoC,MAAM,gBAAgB,CAAA;AAMvF,KAAK,cAAc,GAAG,KAAK,GAAG;IAAE,KAAK,EAAE,QAAQ,GAAG,SAAS,CAAA;CAAE,CAAA;AAC7D,KAAK,aAAa,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAA;AAOlD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,aAAa,CAAA;IACnB,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB;AAED,eAAO,MAAM,mBAAmB,6CAA0C,CAAA;AAE1E,wBAAgB,OAAO;;;;EAWtB;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM;;;;EA+F/C"}
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,CAAA;AAI5B,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,KAAK,CAAC,cAAc,CAAC,CAAA;IAC3B,+FAA+F;IAC/F,MAAM,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAAA;IAC1B,QAAQ,EAAE,OAAO,CAAA;IACjB,0CAA0C;IAC1C,YAAY,EAAE,OAAO,CAAA;IACrB,IAAI,EAAE;QACJ,0DAA0D;QAC1D,KAAK,EAAE;YACL,QAAQ,EAAE,aAAa,CAAC,4BAA4B,CAAC,CAAA;SACtD,CAAA;QACD,kDAAkD;QAClD,MAAM,EAAE,KAAK,CAAC,eAAe,EAAE,CAAC,CAAA;QAChC,gDAAgD;QAChD,UAAU,EAAE,KAAK,CAAC,OAAO,CAAC,CAAA;QAC1B,qFAAqF;QACrF,cAAc,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,IAAI,CAAA;QAClD,iFAAiF;QACjF,SAAS,EAAE,CAAC,QAAQ,EAAE,eAAe,KAAK,IAAI,CAAA;QAC9C,6EAA6E;QAC7E,OAAO,EAAE,CAAC,QAAQ,EAAE,aAAa,KAAK,IAAI,CAAA;KAC3C,CAAA;CACF;AAED,eAAO,MAAM,mBAAmB,6CAA0C,CAAA;AAE1E;;;;;GAKG;AACH,wBAAgB,OAAO,IAAI,WAAW,CAOrC;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,CAkE7D"}
@@ -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,useMemo as a}from"react";import{attach as o,combine as s,createEffect as c,createStore as l,sample as u}from"effector";import{evaluateRuleLogic as d}from"@picked/client";import{useUnit as f}from"effector-react";var p=r(null);function m(){let e=i(p);if(!e)throw Error(`useStep must be used within a StepContextProvider`);return{step:e.step,fields:e.fields,isActiveStep:e.isActiveStep??!1}}function h(r){let i=e(),p=t(),{activeStep:m}=n(),h=a(()=>m?.id===r,[m?.id,r]),{stepContext:g}=a(()=>{let e=o({source:s({steps:i.treeStore.map(e=>e.steps),fields:p.fields.listStore,responses:p.responses.listStore}),effect:c(async({steps:e,fields:t,responses:n})=>{let i=e.find(e=>e.id===r);if(!i)throw Error(`Step with id "${r}" not found in the experience tree.`);let a=t.filter(e=>i.fieldIds.includes(e.id)),o=[];for(let e of a)e.condition?await d(p,e.condition)&&o.push(e):o.push(e);let s=o.map(e=>{let t=n.find(t=>t.fieldId===e.id)?.value;return{...e,value:t}});return{step:{id:i.id,label:i.label},fields:s}})}),t=l({step:{id:r,label:``},fields:[]});return t.on(e.doneData,(e,t)=>t),u({clock:[p.fields.listStore,p.responses.listStore],target:e}),e(),{stepContextFx:e,stepContext:t}},[r,p,i]),_=f(g);return{step:_?.step,fields:_?.fields||[],isActiveStep:h}}export{p as StepContextProvider,h as useSetStepContext,m as useStep};
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.id===r);if(!t)throw Error(`Step with id "${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.fieldIds),[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 +1 @@
1
- import{useStepRouter as e}from"./context.js";import{StepContextProvider as t,useSetStepContext as n}from"../hooks/step.js";import{useEffect as r,useState as i}from"react";import{jsx as a}from"react/jsx-runtime";var o=({id:o,component:s,children:c})=>{let l={id:o},{registerStep:u,unregisterStep:d}=e(),[f,p]=i(null),m=n(o);return r(()=>(u(l),()=>d(l)),[u,d,l]),r(()=>{s&&typeof s!=`function`?Promise.resolve(s).then(e=>{typeof e==`object`&&`default`in e?p(()=>e.default):p(()=>e)}):typeof s==`function`&&p(()=>s)},[s]),s?f?a(t.Provider,{value:m,children:a(f,{})}):null:a(t.Provider,{value:m,children:c})};export{o as default};
1
+ import{useStepRouter as e}from"./context.js";import{StepContextProvider as t,useSetStepContext as n}from"../hooks/step.js";import{useEffect as r,useMemo as i,useState as a}from"react";import{jsx as o}from"react/jsx-runtime";function s({stepKey:s,id:c,component:l,children:u}){let d=s??c??``,f=i(()=>({id:d,key:d}),[d]),{registerStep:p,unregisterStep:m}=e(),h=i(()=>typeof l==`function`?l:null,[l]),[g,_]=a(null),v=n(d);r(()=>(p(f),()=>m(f)),[p,m,f]),r(()=>{l&&typeof l!=`function`&&Promise.resolve(l).then(e=>{typeof e==`object`&&`default`in e?_(()=>e.default):typeof e==`function`&&_(()=>e)})},[l]);let y=h??g;return l?y?o(t.Provider,{value:v,children:o(y,{})}):null:o(t.Provider,{value:v,children:u})}export{s as default};
@@ -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,useEffect 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";var l=({children:l})=>{let{currentStepStore:u}=e(),d=s(u),[f,p]=a(null),m=i(!1),[h,g]=a([]),_=n(e=>{if(o())g(t=>[...t,e]);else{if(m.current)return;e.id===d?.id&&(p(e),m.current=!0)}},[d?.id]),v=n(e=>{g(t=>t.filter(t=>t!==e))},[]);r(()=>{p(h.find(e=>e.id===d?.id)||null)},[h,d?.id]);let y={activeStep:f,registerStep:_,unregisterStep:v};return d?.id?c(t,{value:y,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{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,5 +1,6 @@
1
1
  export interface Step {
2
2
  id: string;
3
+ key: string;
3
4
  }
4
5
  interface ContextOptions {
5
6
  activeStep?: Step | null;
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/router/context.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAA;CACX;AAED,UAAU,cAAc;IACtB,UAAU,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;IACxB,cAAc,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAA;IACpC,YAAY,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAA;CACnC;AAID,eAAO,MAAM,kBAAkB,iDAA6B,CAAA;AAE5D,eAAO,MAAM,aAAa,sBAOzB,CAAA"}
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/router/context.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAA;IACV,GAAG,EAAE,MAAM,CAAA;CACZ;AAED,UAAU,cAAc;IACtB,UAAU,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;IACxB,cAAc,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAA;IACpC,YAAY,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAA;CACnC;AAID,eAAO,MAAM,kBAAkB,iDAA6B,CAAA;AAE5D,eAAO,MAAM,aAAa,sBAOzB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@picked/react",
3
- "version": "0.0.1-dev.1774231221701",
3
+ "version": "0.0.1-dev.1774912386475",
4
4
  "devDependencies": {
5
5
  "@picked/client": "workspace:*",
6
6
  "@repo/eslint-config": "workspace:*",
@@ -59,16 +59,33 @@
59
59
  "dist"
60
60
  ],
61
61
  "knip": {
62
+ "entry": [
63
+ "src/index.ts",
64
+ "src/server/index.ts",
65
+ "src/router/index.ts",
66
+ "src/form/index.ts",
67
+ "src/hooks/index.ts",
68
+ "src/plugins/framework/index.ts"
69
+ ],
70
+ "ignore": [
71
+ "eslint.config.js"
72
+ ],
62
73
  "ignoreBinaries": [
74
+ "attw",
63
75
  "knip",
64
76
  "jscpd",
65
77
  "eslint",
66
78
  "tsgo"
79
+ ],
80
+ "ignoreDependencies": [
81
+ "@picked/client",
82
+ "@repo/eslint-config",
83
+ "@repo/typescript-config"
67
84
  ]
68
85
  },
69
86
  "module": "./dist/index.js",
70
87
  "peerDependencies": {
71
- "@picked/client": "0.0.1-dev.1774231221701",
88
+ "@picked/client": "0.0.1-dev.1774912386475",
72
89
  "effector": "^23.3.0",
73
90
  "effector-react": "^23.3.0",
74
91
  "react": "19.2.2",
@@ -88,7 +105,7 @@
88
105
  "lint:report": "eslint . -o './.reports/eslint.json' -f json || [ -f './.reports/eslint.json' ]",
89
106
  "size": "size-limit",
90
107
  "test": "vitest run",
91
- "test:coverage": "vitest run --coverage",
108
+ "test:coverage": "../../scripts/vitest-coverage.sh",
92
109
  "test:packaged-types": "attw --pack",
93
110
  "test:watch": "vitest",
94
111
  "type-check": "tsgo -p . --noEmit"