@picked/react 0.0.12-next.4 → 0.0.12-next.5

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 +1 @@
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;;EA0G9F"}
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"}
@@ -1 +1 @@
1
- import{usePicked as y,useExperience as v}from"../hooks/client.js";import"../hooks/step.js";import"react";import"@picked/client";function _(a){const s=y();v();const{id:o,title:l}=a;async function d(c){var f,m;c.preventDefault(),s.eventBus({type:"form_submit",form:{id:o,title:l}});const p=new FormData(c.currentTarget),i={data:{},push(t){const r=t.questionId,e=this.data[r];e?Array.isArray(e)&&Array.isArray(t.value)?Array.isArray(e)&&Array.isArray(t.value)&&(typeof e[0]=="string"?this.data[r]=[...e,...t.value].map(String):typeof e[0]=="number"?this.data[r]=[...e,...t.value].map(Number):typeof e[0]=="boolean"?this.data[r]=[...e,...t.value].map(u=>!!u):this.data[r]=t.value):this.data[r]=t.value:this.data[r]=t.value}};for(const[t,r]of p.entries()){const e=s.fields.getById(t).getState();if(!e)continue;const u=e.id;switch(e.type){case"text":i.push({questionId:u,value:e.multiple?[String(r)]:String(r)});break;case"number":i.push({questionId:u,value:e.multiple?[Number(r)]:Number(r)});break;case"boolean":i.push({questionId:u,value:e.multiple?[r==="true"]:r==="true"});break}}const{errors:n}=await s.responses.commit(i.data);if(n.length>0){s.eventBus({type:"form_submit_error",form:{id:o,title:l},exception:{reason:n}}),n.forEach(t=>{s.eventBus({type:"field_validation_error",exception:{reason:[t]}})}),await((f=a.onError)==null?void 0:f.call(a,n));return}s.eventBus({type:"form_submit_success",form:{id:o,title:l}}),await((m=a.onSuccess)==null?void 0:m.call(a))}return{form:{onsubmit:d}}}export{_ as useForm};
1
+ import{usePicked as v,useExperience as b}from"../hooks/client.js";import"../hooks/step.js";import"react";import"@picked/client";function _(a){const s=v(),i=b(),{id:l,title:c}=a;async function p(f){var m,d;f.preventDefault(),s.eventBus({type:"form_submit",form:{id:l,title:c},experience:i});const y=new FormData(f.currentTarget),n={data:{},push(t){const r=t.questionId,e=this.data[r];e?Array.isArray(e)&&Array.isArray(t.value)?Array.isArray(e)&&Array.isArray(t.value)&&(typeof e[0]=="string"?this.data[r]=[...e,...t.value].map(String):typeof e[0]=="number"?this.data[r]=[...e,...t.value].map(Number):typeof e[0]=="boolean"?this.data[r]=[...e,...t.value].map(u=>!!u):this.data[r]=t.value):this.data[r]=t.value:this.data[r]=t.value}};for(const[t,r]of y.entries()){const e=s.fields.getById(t).getState();if(!e)continue;const u=e.id;switch(e.type){case"text":n.push({questionId:u,value:e.multiple?[String(r)]:String(r)});break;case"number":n.push({questionId:u,value:e.multiple?[Number(r)]:Number(r)});break;case"boolean":n.push({questionId:u,value:e.multiple?[r==="true"]:r==="true"});break}}const{errors:o}=await s.responses.commit(n.data);if(o.length>0){s.eventBus({type:"form_submit_error",form:{id:l,title:c},exception:{reason:o},experience:i}),o.forEach(t=>{s.eventBus({type:"field_validation_error",exception:{reason:[t]},experience:i})}),await((m=a.onError)==null?void 0:m.call(a,o));return}s.eventBus({type:"form_submit_success",form:{id:l,title:c},experience:i}),await((d=a.onSuccess)==null?void 0:d.call(a))}return{form:{onsubmit:p}}}export{_ as useForm};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@picked/react",
3
- "version": "0.0.12-next.4",
3
+ "version": "0.0.12-next.5",
4
4
  "devDependencies": {
5
5
  "@picked/client": "workspace:*",
6
6
  "@repo/eslint-config": "workspace:*",
@@ -54,7 +54,7 @@
54
54
  ],
55
55
  "module": "./dist/index.js",
56
56
  "peerDependencies": {
57
- "@picked/client": "0.0.12-next.4",
57
+ "@picked/client": "0.0.12-next.5",
58
58
  "effector": "^23.3.0",
59
59
  "effector-react": "^23.3.0",
60
60
  "react": "^19.1.0",