@picked/react 0.0.1-dev.1773371977114 → 0.0.1-dev.1773719715758
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.map +1 -1
- package/dist/form/index.js +1 -1
- 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/package.json +4 -23
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":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/form/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAqB,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAQxE,UAAU,cAAc;IACtB,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACtC,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,EAAE,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAC9D;AAED,wBAAgB,OAAO,CAAC,OAAO,EAAE,cAAc;;0BAKd,WAAW,GAAG;YAAE,aAAa,EAAE,WAAW,GAAG,eAAe,CAAA;SAAE;;EA+G9F"}
|
package/dist/form/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{usePicked as d,useExperience as y}from"../hooks/client.js";import"../hooks/step.js";import"react";import"@picked/client";function A(u){const a=d(),o=y(),{id:l,title:c}=u;async function p(f){f.preventDefault(),a.eventBus({type:"form_submit",form:{id:l,title:c},experience:o});const m=new FormData(f.currentTarget),i={data:{},push(
|
|
1
|
+
import{usePicked as d,useExperience as y}from"../hooks/client.js";import"../hooks/step.js";import"react";import"@picked/client";function A(u){const a=d(),o=y(),{id:l,title:c}=u;async function p(f){f.preventDefault(),a.eventBus({type:"form_submit",form:{id:l,title:c},experience:o});const m=new FormData(f.currentTarget),i={data:{},push(r){const t=r.questionId,e=this.data[t];e?Array.isArray(e)&&Array.isArray(r.value)?Array.isArray(e)&&Array.isArray(r.value)&&(typeof e[0]=="string"?this.data[t]=[...e,...r.value].map(String):typeof e[0]=="number"?this.data[t]=[...e,...r.value].map(Number):typeof e[0]=="boolean"?this.data[t]=[...e,...r.value].map(s=>!!s):this.data[t]=r.value):this.data[t]=r.value:this.data[t]=r.value}};for(const[r,t]of m.entries()){const e=a.fields.getById(r).getState();if(!e)continue;const s=e.id;switch(e.type){case"text":i.push({questionId:s,value:e.multiple?[String(t)]:String(t)});break;case"number":i.push({questionId:s,value:e.multiple?[Number(t)]:Number(t)});break;case"boolean":i.push({questionId:s,value:e.multiple?[t==="true"]:t==="true"});break}}const{errors:n}=await a.responses.commit(i.data);if(n.length>0){a.eventBus({type:"form_submit_error",form:{id:l,title:c},exception:{reason:n},experience:o}),n.forEach(r=>{a.eventBus({type:"field_validation_error",exception:{reason:[r]},experience:o})}),await u.onError?.(n);return}a.eventBus({type:"form_submit_success",form:{id:l,title:c},experience:o}),await u.onSuccess?.()}return{form:{onsubmit:p}}}export{A as useForm};
|
package/dist/hooks/step.d.ts
CHANGED
|
@@ -2,10 +2,10 @@ import { Field, Response } from '@picked/client';
|
|
|
2
2
|
type FieldWithValue = Field & {
|
|
3
3
|
value: Response | undefined;
|
|
4
4
|
};
|
|
5
|
-
|
|
5
|
+
type StepWithLabel = {
|
|
6
6
|
id: string;
|
|
7
|
-
|
|
8
|
-
}
|
|
7
|
+
label: string;
|
|
8
|
+
};
|
|
9
9
|
export interface StepContext {
|
|
10
10
|
step: StepWithLabel;
|
|
11
11
|
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":"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,
|
|
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 w,useMemo as a,useContext as b}from"react";import{attach as E,createEffect as F,combine as R,createStore as A,sample as P}from"effector";import{evaluateRuleLogic as g}from"@picked/client";import{useUnit as k}from"effector-react";import{useStepRouter as y}from"../router/context.js";import{useExperience as D,usePicked as L}from"./client.js";const M=w(null);function B(){const e=b(M);if(!e)throw new Error("useStep must be used within a StepContextProvider");return{step:e.step,fields:e.fields,isActiveStep:e.isActiveStep??!1}}function G(e){const l=D(),s=L(),{activeStep:p}=y(),m=a(()=>p?.id===e,[p?.id,e]),{stepContext:S}=a(()=>{const o=E({source:R({steps:l.treeStore.map(i=>i.steps),fields:s.fields.listStore,responses:s.responses.listStore}),effect:F(async({steps:i,fields:r,responses:x})=>{const n=i.find(t=>t.id===e);if(!n)throw new Error(`Step with id "${e}" not found in the experience tree.`);const v=r.filter(t=>n.fieldIds.includes(t.id)),c=[];for(const t of v)t.condition?await g(s,t.condition)&&c.push(t):c.push(t);const C=c.map(t=>{const u=x.find(h=>h.fieldId===t.id)?.value;return{...t,value:u}});return{step:{id:n.id,label:n.label},fields:C}})}),f=A({step:{id:e,label:""},fields:[]});return f.on(o.doneData,(i,r)=>r),P({clock:[s.fields.listStore,s.responses.listStore],target:o}),o(),{stepContextFx:o,stepContext:f}},[e,s,l]),d=k(S);return{step:d?.step,fields:d?.fields||[],isActiveStep:m}}export{M as StepContextProvider,G as useSetStepContext,B as useStep};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@picked/react",
|
|
3
|
-
"version": "0.0.1-dev.
|
|
3
|
+
"version": "0.0.1-dev.1773719715758",
|
|
4
4
|
"devDependencies": {
|
|
5
5
|
"@picked/client": "workspace:*",
|
|
6
6
|
"@repo/eslint-config": "workspace:*",
|
|
@@ -63,31 +63,12 @@
|
|
|
63
63
|
"knip",
|
|
64
64
|
"jscpd",
|
|
65
65
|
"eslint",
|
|
66
|
-
"tsc"
|
|
67
|
-
|
|
68
|
-
],
|
|
69
|
-
"ignoreFiles": [
|
|
70
|
-
"eslint.config.js",
|
|
71
|
-
"src/plugins/framework/index.ts",
|
|
72
|
-
"src/router/index.ts",
|
|
73
|
-
"src/router/Step.tsx"
|
|
74
|
-
],
|
|
75
|
-
"ignoreDependencies": [
|
|
76
|
-
"@picked/client",
|
|
77
|
-
"@repo/eslint-config",
|
|
78
|
-
"@repo/typescript-config"
|
|
79
|
-
],
|
|
80
|
-
"ignoreIssues": {
|
|
81
|
-
"src/**": [
|
|
82
|
-
"exports",
|
|
83
|
-
"types",
|
|
84
|
-
"duplicates"
|
|
85
|
-
]
|
|
86
|
-
}
|
|
66
|
+
"tsc"
|
|
67
|
+
]
|
|
87
68
|
},
|
|
88
69
|
"module": "./dist/index.js",
|
|
89
70
|
"peerDependencies": {
|
|
90
|
-
"@picked/client": "0.0.1-dev.
|
|
71
|
+
"@picked/client": "0.0.1-dev.1773719715758",
|
|
91
72
|
"effector": "^23.3.0",
|
|
92
73
|
"effector-react": "^23.3.0",
|
|
93
74
|
"react": "19.2.2",
|