@picked/react 0.0.1-dev.1772412203098 → 0.0.1-dev.1773363643396

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;;EA+G9F"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/form/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAQjE,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;;EAmG9F"}
@@ -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(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};
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(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(s=>!!s):this.data[r]=t.value):this.data[r]=t.value:this.data[r]=t.value}};for(const[t,r]of m.entries()){const e=a.fields.getById(t).getState();if(!e)continue;const s=e.key??e.id??t;switch(e.type){case"text":i.push({questionId:s,value:e.multiple?[String(r)]:String(r)});break;case"number":i.push({questionId:s,value:e.multiple?[Number(r)]:Number(r)});break;case"boolean":i.push({questionId:s,value:e.multiple?[r==="true"]:r==="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(t=>{a.eventBus({type:"field_validation_error",exception:{reason:[t]},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};
@@ -2,10 +2,10 @@ import { Field, Response } from '@picked/client';
2
2
  type FieldWithValue = Field & {
3
3
  value: Response | undefined;
4
4
  };
5
- type StepWithLabel = {
5
+ interface StepWithLabel {
6
6
  id: string;
7
- label: string;
8
- };
7
+ name: string;
8
+ }
9
9
  export interface StepContext {
10
10
  step: StepWithLabel;
11
11
  fields: FieldWithValue[];
@@ -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,KAAK,EAAE,QAAQ,EAAoC,MAAM,gBAAgB,CAAA;AAMvF,KAAK,cAAc,GAAG,KAAK,GAAG;IAAE,KAAK,EAAE,QAAQ,GAAG,SAAS,CAAA;CAAE,CAAA;AAC7D,UAAU,aAAa;IAAG,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE;AAOpD,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;;;;EAgG/C"}
@@ -1 +1 @@
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};
1
+ import{createContext as h,useMemo as u,useContext as w}from"react";import{attach as F,createEffect as E,combine as R,createStore as g,sample as k}from"effector";import{evaluateRuleLogic as y}from"@picked/client";import{useUnit as A}from"effector-react";import{useStepRouter as P}from"../router/context.js";import{useExperience as b,usePicked as M}from"./client.js";const B=h(null);function z(){const t=w(B);if(!t)throw new Error("useStep must be used within a StepContextProvider");return{step:t.step,fields:t.fields,isActiveStep:t.isActiveStep??!1}}function G(t){const p=b(),o=M(),{activeStep:d}=P(),a=u(()=>d?.id===t,[d?.id,t]),{stepContext:m}=u(()=>{const s=F({source:R({steps:p.treeStore.map(i=>i.steps),fields:o.fields.listStore,responses:o.responses.listStore}),effect:E(async({steps:i,fields:r,responses:S})=>{const n=i.find(e=>e.id===t);if(!n)throw new Error(`Step with id "${t}" not found in the experience tree.`);const x=r.filter(e=>n.fieldIds.includes(e.key??"")),c=[];for(const e of x)e.condition?await y(o,e.condition)&&c.push(e):c.push(e);const v=new Map(S.map(e=>[e.fieldId,e.value])),C=c.map(e=>({...e,value:e.id!=null?v.get(e.id):void 0}));return{step:{id:n.id,name:n.name},fields:C}})}),f=g({step:{id:t,name:""},fields:[]});return f.on(s.doneData,(i,r)=>r),k({clock:[o.fields.listStore,o.responses.listStore],target:s}),s(),{stepContextFx:s,stepContext:f}},[t,o,p]),l=A(m);return{step:l.step,fields:l.fields,isActiveStep:a}}export{B as StepContextProvider,G as useSetStepContext,z as useStep};
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@picked/react",
3
- "version": "0.0.1-dev.1772412203098",
3
+ "version": "0.0.1-dev.1773363643396",
4
4
  "devDependencies": {
5
5
  "@picked/client": "workspace:*",
6
6
  "@repo/eslint-config": "workspace:*",
7
7
  "@repo/typescript-config": "workspace:*",
8
+ "@size-limit/preset-small-lib": "^12.0.0",
8
9
  "@testing-library/react": "^16.3.0",
9
10
  "@types/node": "^22",
10
11
  "@types/react": "19.2.4",
@@ -15,6 +16,7 @@
15
16
  "effector-react": "^23.3.0",
16
17
  "fast-glob": "^3.3.3",
17
18
  "jsdom": "^26.1.0",
19
+ "size-limit": "^12.0.0",
18
20
  "typedoc": "^0.28.5",
19
21
  "typedoc-plugin-markdown": "^4.6.3",
20
22
  "vite": "^7.3.1",
@@ -61,12 +63,31 @@
61
63
  "knip",
62
64
  "jscpd",
63
65
  "eslint",
64
- "tsc"
65
- ]
66
+ "tsc",
67
+ "attw"
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
87
  },
67
88
  "module": "./dist/index.js",
68
89
  "peerDependencies": {
69
- "@picked/client": "0.0.1-dev.1772412203098",
90
+ "@picked/client": "0.0.1-dev.1773363643396",
70
91
  "effector": "^23.3.0",
71
92
  "effector-react": "^23.3.0",
72
93
  "react": "19.2.2",
@@ -80,16 +101,43 @@
80
101
  "dev": "vite build --watch",
81
102
  "jscpd": "jscpd src",
82
103
  "knip": "knip",
83
- "lint": "eslint .",
104
+ "lint": "if [ \"$AGENT\" = \"true\" ]; then echo \"[AGENT HINT] Prefer running lint on specific files from the repo root: node scripts/lint-files.js <files>\"; fi && eslint .",
84
105
  "lint-files": "eslint",
85
106
  "lint:format": "eslint . --fix",
86
107
  "lint:report": "eslint . -o './.reports/eslint.json' -f json || [ -f './.reports/eslint.json' ]",
108
+ "size": "size-limit",
87
109
  "test": "vitest run",
88
110
  "test:coverage": "vitest run --coverage",
89
111
  "test:packaged-types": "attw --pack",
90
112
  "test:watch": "vitest",
91
113
  "type-check": "tsc -p . --noEmit"
92
114
  },
115
+ "size-limit": [
116
+ {
117
+ "path": "dist/index.js",
118
+ "limit": "10 kB"
119
+ },
120
+ {
121
+ "path": "dist/server/index.js",
122
+ "limit": "10 kB"
123
+ },
124
+ {
125
+ "path": "dist/router/index.js",
126
+ "limit": "5 kB"
127
+ },
128
+ {
129
+ "path": "dist/form/index.js",
130
+ "limit": "5 kB"
131
+ },
132
+ {
133
+ "path": "dist/hooks/index.js",
134
+ "limit": "5 kB"
135
+ },
136
+ {
137
+ "path": "dist/plugins/framework/index.js",
138
+ "limit": "5 kB"
139
+ }
140
+ ],
93
141
  "type": "module",
94
142
  "types": "./dist/index.d.ts"
95
143
  }