@picked/react 0.0.30 → 0.0.31
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/hooks/step.d.ts +3 -3
- package/dist/hooks/step.d.ts.map +1 -1
- package/dist/hooks/step.js +1 -1
- package/dist/router/Step.js +1 -1
- package/package.json +10 -3
package/dist/hooks/step.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Store } from 'effector';
|
|
2
1
|
import { Field, Response } from '@picked/client';
|
|
3
2
|
type FieldWithValue = Field & {
|
|
4
3
|
value: Response | undefined;
|
|
@@ -8,10 +7,11 @@ type StepWithLabel = {
|
|
|
8
7
|
label: string;
|
|
9
8
|
};
|
|
10
9
|
export interface StepContext {
|
|
11
|
-
step:
|
|
12
|
-
fields:
|
|
10
|
+
step: StepWithLabel;
|
|
11
|
+
fields: FieldWithValue[];
|
|
13
12
|
isActiveStep?: boolean;
|
|
14
13
|
}
|
|
14
|
+
export declare const StepContextProvider: import('react').Context<StepContext | null>;
|
|
15
15
|
export declare function useStep(): {
|
|
16
16
|
step: StepWithLabel;
|
|
17
17
|
fields: FieldWithValue[];
|
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":"
|
|
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"}
|
package/dist/hooks/step.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createContext as
|
|
1
|
+
import{createContext as b,useContext as E,useMemo as m}from"react";import{attach as F,createEffect as R,combine as A,createStore as P,sample as g}from"effector";import{evaluateRuleLogic as k}from"@picked/client";import{useUnit as y}from"effector-react";import{useStepRouter as D}from"../router/context.js";import{useExperience as L,usePicked as M}from"./client.js";const U=b(null);function G(){const e=E(U);if(!e)throw new Error("useStep must be used within a StepContextProvider");return{step:e.step,fields:e.fields,isActiveStep:e.isActiveStep??!1}}function H(e){const d=L(),s=M(),{activeStep:o}=D(),x=m(()=>(o==null?void 0:o.id)===e,[o==null?void 0:o.id,e]),{stepContext:S}=m(()=>{const n=F({source:A({steps:d.treeStore.map(r=>r.steps),fields:s.fields.listStore,responses:s.responses.listStore}),effect:R(async({steps:r,fields:l,responses:C})=>{const c=r.find(t=>t.id===e);if(!c)throw new Error(`Step with id "${e}" not found in the experience tree.`);const h=l.filter(t=>c.fieldIds.includes(t.id)),p=[];for(const t of h)t.condition?await k(s,t.condition)&&p.push(t):p.push(t);const w=p.map(t=>{var a;const u=(a=C.find(v=>v.fieldId===t.id))==null?void 0:a.value;return{...t,value:u}});return{step:{id:c.id,label:c.label},fields:w}})}),f=P({step:{id:e,label:""},fields:[]});return f.on(n.doneData,(r,l)=>l),g({clock:[s.fields.listStore,s.responses.listStore],target:n}),n(),{stepContextFx:n,stepContext:f}},[e,s,d]),i=y(S);return{step:i==null?void 0:i.step,fields:(i==null?void 0:i.fields)||[],isActiveStep:x}}export{U as StepContextProvider,H as useSetStepContext,G as useStep};
|
package/dist/router/Step.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as f}from"react/jsx-runtime";import{useState as c,useEffect as n}from"react";import{useSetStepContext as d,StepContextProvider as p}from"../hooks/step.js";import{useStepRouter as v}from"./context.js";const g=({id:i,component:e,children:S})=>{const r={id:i},{registerStep:s,unregisterStep:o}=v(),[l,u]=c(null),a=d(i);return n(()=>(s(r),()=>o(r)),[s,o,r]),n(()=>{e&&typeof e!="function"?Promise.resolve(e).then(t=>{typeof t=="object"&&"default"in t?u(()=>t.default):u(()=>t)}):typeof e=="function"&&u(()=>e)},[e]),e?l?f(p.Provider,{value:a,children:f(l,{})}):null:f(p.Provider,{value:a,children:S})};export{g as default};
|
package/package.json
CHANGED
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@picked/react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.31",
|
|
4
4
|
"devDependencies": {
|
|
5
5
|
"@picked/client": "workspace:*",
|
|
6
6
|
"@repo/eslint-config": "workspace:*",
|
|
7
7
|
"@repo/typescript-config": "workspace:*",
|
|
8
|
+
"@testing-library/react": "^16.3.0",
|
|
8
9
|
"@types/node": "^22",
|
|
9
10
|
"@types/react": "19.2.4",
|
|
10
11
|
"@types/react-dom": "19.2.3",
|
|
11
12
|
"@vitejs/plugin-react": "^4.5.2",
|
|
13
|
+
"@vitest/coverage-v8": "^3.2.4",
|
|
12
14
|
"effector": "^23.3.0",
|
|
13
15
|
"effector-react": "^23.3.0",
|
|
14
16
|
"fast-glob": "^3.3.3",
|
|
17
|
+
"jsdom": "^26.1.0",
|
|
15
18
|
"typedoc": "^0.28.5",
|
|
16
19
|
"typedoc-plugin-markdown": "^4.6.3",
|
|
17
20
|
"vite": "^6.4.1",
|
|
18
|
-
"vite-plugin-dts": "^4.5.4"
|
|
21
|
+
"vite-plugin-dts": "^4.5.4",
|
|
22
|
+
"vitest": "^3.2.4"
|
|
19
23
|
},
|
|
20
24
|
"exports": {
|
|
21
25
|
".": {
|
|
@@ -54,7 +58,7 @@
|
|
|
54
58
|
],
|
|
55
59
|
"module": "./dist/index.js",
|
|
56
60
|
"peerDependencies": {
|
|
57
|
-
"@picked/client": "0.0.
|
|
61
|
+
"@picked/client": "0.0.31",
|
|
58
62
|
"effector": "^23.3.0",
|
|
59
63
|
"effector-react": "^23.3.0",
|
|
60
64
|
"react": "19.2.2",
|
|
@@ -69,7 +73,10 @@
|
|
|
69
73
|
"lint-files": "eslint",
|
|
70
74
|
"lint:format": "eslint . --fix",
|
|
71
75
|
"lint:report": "eslint . -o './.reports/eslint.json' -f json || [ -f './.reports/eslint.json' ]",
|
|
76
|
+
"test": "vitest run",
|
|
77
|
+
"test:coverage": "vitest run --coverage",
|
|
72
78
|
"test:packaged-types": "attw --pack",
|
|
79
|
+
"test:watch": "vitest",
|
|
73
80
|
"type-check": "tsc -p . --noEmit"
|
|
74
81
|
},
|
|
75
82
|
"type": "module",
|