@picked/react 0.0.50-next.3 → 0.0.50-next.4
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/component.js +1 -1
- package/dist/context.js +1 -1
- package/dist/form/index.js +1 -1
- package/dist/hooks/client.js +1 -1
- package/dist/hooks/field.js +1 -1
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/step.js +1 -1
- package/dist/hooks/storage.js +1 -1
- package/dist/index.js +1 -1
- package/dist/plugins/framework/index.js +1 -1
- package/dist/plugins/framework/plugin.js +1 -1
- package/dist/render/browser.js +1 -1
- package/dist/render/server.js +1 -1
- package/dist/router/Step.js +1 -1
- package/dist/router/StepRouter.js +1 -1
- package/dist/router/context.js +1 -1
- package/dist/router/index.js +1 -1
- package/dist/server/index.js +1 -1
- package/dist/utils/array.js +1 -1
- package/package.json +6 -6
package/dist/component.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
var e=(e,t)=>({frameworkName:`react`,component:e,style:t}),t=e=>e.frameworkName===`react`;export{e as adaptReactComponent,t as isValidAdaptedComponent};
|
package/dist/context.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createContext as e}from"react";
|
|
1
|
+
import{createContext as e}from"react";var t=e(null),n=t.Provider,r=e(null),i=r.Provider;export{t as ClientContext,n as ClientProvider,r as ExperienceContext,i as ExperienceProvider};
|
package/dist/form/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{useExperience as e,usePicked as t}from"../hooks/client.js";import"../hooks/index.js";function n(n){let r=t(),i=e(),{id:a,title:o}=n;async function s(e){e.preventDefault(),r.eventBus({type:`form_submit`,form:{id:a,title:o},experience:i});let t=new FormData(e.currentTarget),s={data:{},push(e){let t=e.questionId,n=this.data[t];n&&Array.isArray(n)&&Array.isArray(e.value)?Array.isArray(n)&&Array.isArray(e.value)&&(typeof n[0]==`string`?this.data[t]=[...n,...e.value].map(String):typeof n[0]==`number`?this.data[t]=[...n,...e.value].map(Number):typeof n[0]==`boolean`?this.data[t]=[...n,...e.value].map(e=>!!e):this.data[t]=e.value):this.data[t]=e.value}};for(let[e,n]of t.entries()){let t=r.fields.getById(e).getState();if(!t)continue;let i=t.id;switch(t.type){case`text`:s.push({questionId:i,value:t.multiple?[String(n)]:String(n)});break;case`number`:s.push({questionId:i,value:t.multiple?[Number(n)]:Number(n)});break;case`boolean`:s.push({questionId:i,value:t.multiple?[n===`true`]:n===`true`});break}}let{errors:c}=await r.responses.commit(s.data);if(c.length>0){r.eventBus({type:`form_submit_error`,form:{id:a,title:o},exception:{reason:c},experience:i}),c.forEach(e=>{r.eventBus({type:`field_validation_error`,exception:{reason:[e]},experience:i})}),await n.onError?.(c);return}r.eventBus({type:`form_submit_success`,form:{id:a,title:o},experience:i}),await n.onSuccess?.()}return{form:{onsubmit:s}}}export{n as useForm};
|
package/dist/hooks/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
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};
|
package/dist/hooks/field.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getPicked as
|
|
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};
|
package/dist/hooks/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getExperience as
|
|
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};
|
package/dist/hooks/step.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
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};
|
package/dist/hooks/storage.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{useExperience as e}from"./client.js";import{useCallback as t,useEffect as n,useState as r}from"react";import{createStorageKey as i,localStore as a,sessionStore as o,supportsLocalStorage as s,supportsSessionStorage as c}from"@picked/client";var l={fallback:null,scope:`global`};function u(u,d,f){let{fallback:p,scope:m}={...l,...f},h=e(),g=u===`session`?o:a,_=u===`session`?c:s,[v,y]=r(p??null),b=i(d,m,h);return n(()=>{if(_()){let e=g.get(b).text();e!==null&&y(e)}},[g,b,_]),n(()=>{if(!_())return;let e=g.subscribe(b,e=>{y(e.text())});return()=>{e()}},[g,b,_]),[v,t(e=>{y(e),_()&&(e?g.set(b,e):g.remove(b))},[g,b,_])]}function d(e,t){return u(`session`,e,t)}function f(e,t){return u(`local`,e,t)}export{f as useLocalStorage,d as useSessionStorage};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{adaptReactComponent as
|
|
1
|
+
import{adaptReactComponent as e,isValidAdaptedComponent as t}from"./component.js";export{e as adaptReactComponent,t as isValidAdaptedComponent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{reactFrameworkPlugin as
|
|
1
|
+
import{reactFrameworkPlugin as e}from"./plugin.js";export{e as reactFrameworkPlugin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{adaptReactComponent as
|
|
1
|
+
import{adaptReactComponent as e}from"../../component.js";import{renderReactComponent as t}from"../../render/browser.js";var n=n=>({name:`react-framework`,setup:r=>{r.registerFramework({name:`react`,render(...e){return t(...e,{stylesheets:n.stylesheets,css:n.css})}});let i=n.components.experience;i&&r.registerComponent(`experience`,e(i.component,i.style))}});export{n as reactFrameworkPlugin};
|
package/dist/render/browser.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{isValidAdaptedComponent as e}from"../component.js";import{ClientProvider as t,ExperienceProvider as n}from"../context.js";import{mergeArrays as r}from"../utils/array.js";import i from"react";import{isLazyLoader as a}from"@picked/client";import{createRoot as o}from"react-dom/client";var s=new WeakMap,c=async(c,l,u,d,f)=>{if(!e(l))throw Error(`The component is invalid.`);let p=r(l.style?.sheets,f.stylesheets),m=r(l.style?.css,f.css);p.length&&p.forEach(e=>{let t=document.createElement(`link`);t.setAttribute(`rel`,`stylesheet`),t.setAttribute(`href`,e),t.setAttribute(`type`,`text/css`),t.setAttribute(`picked-injected`,`true`),c.appendChild(t)}),m.length&&m.forEach(e=>{let t=document.createElement(`style`);t.textContent=e,t.setAttribute(`type`,`text/css`),t.setAttribute(`picked-injected`,`true`),c.appendChild(t)});let h=document.createElement(`div`);c.appendChild(h);let g=o(h);s.set(c,g);let _;_=a(l.component)?(await l.component.load()).default:l.component instanceof Promise?(await l.component).default:l.component,g.render(i.createElement(t,{value:u},i.createElement(n,{value:d},i.createElement(_,{client:u,experience:d}))))},l=e=>{let t=s.get(e);t&&(t.unmount(),s.delete(e))};export{c as renderReactComponent,l as unRenderReactComponent};
|
package/dist/render/server.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{isValidAdaptedComponent as e}from"../component.js";import{ClientProvider as t,ExperienceProvider as n}from"../context.js";import{mergeArrays as r}from"../utils/array.js";import i from"react";import{isLazyLoader as a}from"@picked/client";import{renderToString as o}from"react-dom/server";var s=async(s,c,l,u)=>{if(!e(s))throw Error(`The component is invalid.`);let d=r(s.style?.sheets,u.stylesheets),f=r(s.style?.css,u.css),p;return p=a(s.component)?(await s.component.load()).default:s.component instanceof Promise?(await s.component).default:s.component,{stylesheets:d,css:f,body:o(i.createElement(t,{value:c},i.createElement(n,{value:l},i.createElement(p,{client:c,experience:l})))),head:``}};export{s as staticRenderReactComponent};
|
package/dist/router/Step.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
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 +1 @@
|
|
|
1
|
-
import{
|
|
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};
|
package/dist/router/context.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createContext as
|
|
1
|
+
import{createContext as e,useContext as t}from"react";var n=e(null),r=n.Provider,i=()=>{let e=t(n);if(!e)throw Error(`useStepRouter must be used within a StepRouterProvider`);return e};export{r as StepRouterProvider,i as useStepRouter};
|
package/dist/router/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{StepRouterProvider as e,useStepRouter as t}from"./context.js";import n from"./StepRouter.js";import r from"./Step.js";export{r as Step,n as StepRouter,e as StepRouterProvider,t as useStepRouter};
|
package/dist/server/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isValidAdaptedComponent as
|
|
1
|
+
import{isValidAdaptedComponent as e}from"../component.js";import{staticRenderReactComponent as t}from"../render/server.js";var n={isValidComponent:e,render:async(e,n,r)=>{let i=await t(e,n,r,{});return{head:i.head,body:i.body}}};export{n as renderer};
|
package/dist/utils/array.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
var e=(e,t)=>[...e||[],...t||[]];export{e as mergeArrays};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@picked/react",
|
|
3
|
-
"version": "0.0.50-next.
|
|
3
|
+
"version": "0.0.50-next.4",
|
|
4
4
|
"devDependencies": {
|
|
5
5
|
"@picked/client": "workspace:*",
|
|
6
6
|
"@repo/eslint-config": "workspace:*",
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"@types/node": "^22",
|
|
11
11
|
"@types/react": "19.2.4",
|
|
12
12
|
"@types/react-dom": "19.2.3",
|
|
13
|
-
"@vitejs/plugin-react": "^
|
|
14
|
-
"@vitest/coverage-v8": "^4.0
|
|
13
|
+
"@vitejs/plugin-react": "^6.0.1",
|
|
14
|
+
"@vitest/coverage-v8": "^4.1.0",
|
|
15
15
|
"effector": "^23.3.0",
|
|
16
16
|
"effector-react": "^23.3.0",
|
|
17
17
|
"fast-glob": "^3.3.3",
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"size-limit": "^12.0.0",
|
|
20
20
|
"typedoc": "^0.28.5",
|
|
21
21
|
"typedoc-plugin-markdown": "^4.6.3",
|
|
22
|
-
"vite": "^
|
|
22
|
+
"vite": "^8.0.1",
|
|
23
23
|
"vite-plugin-dts": "^4.5.4",
|
|
24
|
-
"vitest": "^4.0
|
|
24
|
+
"vitest": "^4.1.0"
|
|
25
25
|
},
|
|
26
26
|
"exports": {
|
|
27
27
|
".": {
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
},
|
|
69
69
|
"module": "./dist/index.js",
|
|
70
70
|
"peerDependencies": {
|
|
71
|
-
"@picked/client": "0.0.50-next.
|
|
71
|
+
"@picked/client": "0.0.50-next.4",
|
|
72
72
|
"effector": "^23.3.0",
|
|
73
73
|
"effector-react": "^23.3.0",
|
|
74
74
|
"react": "19.2.2",
|