@picked/react 0.0.1-dev.1780458499348 → 0.0.1-dev.1780464669265

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":"Experience.d.ts","sourceRoot":"","sources":["../../src/experience/Experience.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAoB,MAAM,OAAO,CAAA;AAQxC,UAAU,eAAe;IACvB;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACtB;AAoED;;;;;;;;;;;;;;GAcG;AACH,iBAAS,UAAU,CAAC,EAAE,IAAI,EAAE,EAAE,eAAe,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CA2ChE;AAED,eAAe,UAAU,CAAA"}
1
+ {"version":3,"file":"Experience.d.ts","sourceRoot":"","sources":["../../src/experience/Experience.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAoB,MAAM,OAAO,CAAA;AAQxC,UAAU,eAAe;IACvB;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACtB;AAmFD;;;;;;;;;;;;;;GAcG;AACH,iBAAS,UAAU,CAAC,EAAE,IAAI,EAAE,EAAE,eAAe,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CA2ChE;AAED,eAAe,UAAU,CAAA"}
@@ -1 +1 @@
1
- import{usePicked as e}from"../hooks/client.js";import{useStoreGlobal as t}from"../hooks/use-store-global.js";import"../hooks/index.js";import n from"./ExperienceHost.js";import{useEffect as r}from"react";import{supportsWindow as i}from"@picked/client";import{evaluateConditionMemo as a,hashRule as o}from"@picked/client/server";import{Fragment as s,jsx as c}from"react/jsx-runtime";var l=[`before`,`prepend`,`append`,`after`];function u(e){let t=l.indexOf(e);return t===-1?l.length:t}function d(e,t){let n=e.configStore.getState(),r=n.targetSelectors.find(e=>e.selector===t);return r?{experience:e,placement:r.placement,condition:n.decisionLogic,hash:o(n.decisionLogic)}:null}function f(){let{href:e,pathname:t,search:n,hostname:r,origin:i,protocol:a,port:o,host:s,hash:c}=globalThis.location;return{href:e,pathname:t,search:n,hostname:r,origin:i,protocol:a,port:o,host:s,hash:c}}function p({name:o}){let l=e(),p=`.picked-slot-${o}`,m=t(l.experiences.listStore);t(l.conditionResults.store);let h=m.map(e=>d(e,p)).filter(e=>e!==null).sort((e,t)=>u(e.placement)-u(t.placement)),g=h.filter(e=>l.conditionResults.peek(e.hash)===!0);return r(()=>{if(i())for(let e of h)l.conditionResults.peek(e.hash)===void 0&&a(l,e.condition,{context:{location:f()}})}),c(s,{children:g.map(e=>c(n,{experience:e.experience,client:l},e.experience.id))})}export{p as default};
1
+ import{usePicked as e}from"../hooks/client.js";import{useStoreGlobal as t}from"../hooks/use-store-global.js";import"../hooks/index.js";import n from"./ExperienceHost.js";import{useEffect as r}from"react";import{supportsWindow as i}from"@picked/client";import{evaluateConditionMemo as a,hashRule as o,ruleReferencesAction as s}from"@picked/client/server";import{Fragment as c,jsx as l}from"react/jsx-runtime";var u=[`before`,`prepend`,`append`,`after`];function d(e){let t=u.indexOf(e);return t===-1?u.length:t}function f(e,t){let n=e.configStore.getState(),r=n.targetSelectors.find(e=>e.selector===t);return!r||r.placement===`replace`||s(n.decisionLogic)?null:{experience:e,placement:r.placement,condition:n.decisionLogic,hash:o(n.decisionLogic)}}function p(){let{href:e,pathname:t,search:n,hostname:r,origin:i,protocol:a,port:o,host:s,hash:c}=globalThis.location;return{href:e,pathname:t,search:n,hostname:r,origin:i,protocol:a,port:o,host:s,hash:c}}function m({name:o}){let s=e(),u=`.picked-slot-${o}`,m=t(s.experiences.listStore);t(s.conditionResults.store);let h=m.map(e=>f(e,u)).filter(e=>e!==null).sort((e,t)=>d(e.placement)-d(t.placement)),g=h.filter(e=>s.conditionResults.peek(e.hash)===!0);return r(()=>{if(i())for(let e of h)s.conditionResults.peek(e.hash)===void 0&&a(s,e.condition,{context:{location:p()}})}),l(c,{children:g.map(e=>l(n,{experience:e.experience,client:s},e.experience.id))})}export{m as default};
@@ -1 +1 @@
1
- {"version":3,"file":"ExperienceHost.d.ts","sourceRoot":"","sources":["../../src/experience/ExperienceHost.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAA+C,MAAM,OAAO,CAAA;AAEnE,OAAO,KAAK,EAAsB,eAAe,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAOjF,UAAU,mBAAmB;IAC3B,QAAQ,CAAC,UAAU,EAAE,eAAe,CAAA;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CACxB;AAiBD;;;;;;;;;;;;;;;GAeG;AACH,iBAAS,cAAc,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,mBAAmB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,GAAG,IAAI,CAsD7F;AAED,eAAe,cAAc,CAAA"}
1
+ {"version":3,"file":"ExperienceHost.d.ts","sourceRoot":"","sources":["../../src/experience/ExperienceHost.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAA+C,MAAM,OAAO,CAAA;AAEnE,OAAO,KAAK,EAAsB,eAAe,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAOjF,UAAU,mBAAmB;IAC3B,QAAQ,CAAC,UAAU,EAAE,eAAe,CAAA;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CACxB;AAiBD;;;;;;;;;;;;;;;GAeG;AACH,iBAAS,cAAc,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,mBAAmB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,GAAG,IAAI,CAyD7F;AAED,eAAe,cAAc,CAAA"}
@@ -1 +1 @@
1
- import{isValidAdaptedComponent as e}from"../component.js";import{ExperienceProvider as t}from"../context.js";import{useStoreGlobal as n}from"../hooks/use-store-global.js";import r,{Suspense as i,useEffect as a,useMemo as o,useRef as s}from"react";import{isLazyLoader as c,supportsWindow as l}from"@picked/client";import{createExperienceInstance as u}from"@picked/client/server";import{jsx as d}from"react/jsx-runtime";function f(e){return typeof e==`function`&&!c(e)&&!(e instanceof Promise)}function p({experience:p,client:m}){let h=s(null);h.current??=u({client:m,experience:p});let g=h.current,_=n(g.componentAndFrameworkStore),v=n(m.readyStore);a(()=>{v&&l()&&p.prepareExperienceContentFx()},[v,p]);let y=_?.component.component,b=y&&e(y)?y.component:void 0,x=o(()=>c(b)?r.lazy(()=>b.load()):b instanceof Promise?r.lazy(()=>b):null,[b]);return f(b)?d(t,{value:g,children:d(b,{client:m,experience:g})}):x?d(t,{value:g,children:d(i,{fallback:null,children:d(x,{client:m,experience:g})})}):null}export{p as default};
1
+ import{isValidAdaptedComponent as e}from"../component.js";import{ExperienceProvider as t}from"../context.js";import{useStoreGlobal as n}from"../hooks/use-store-global.js";import r,{Suspense as i,useEffect as a,useMemo as o,useRef as s}from"react";import{isLazyLoader as c,supportsWindow as l}from"@picked/client";import{createExperienceInstance as u}from"@picked/client/server";import{jsx as d}from"react/jsx-runtime";function f(e){return typeof e==`function`&&!c(e)&&!(e instanceof Promise)}function p({experience:p,client:m}){let h=s(null);h.current??=u({client:m,experience:p});let g=h.current,_=n(g.componentAndFrameworkStore),v=n(m.readyStore);a(()=>{v&&l()&&p.prepareExperienceContentFx().catch(()=>void 0)},[v,p]);let y=_?.component.component,b=y&&e(y)?y.component:void 0,x=o(()=>c(b)?r.lazy(()=>b.load()):b instanceof Promise?r.lazy(()=>b):null,[b]);return f(b)?d(t,{value:g,children:d(b,{client:m,experience:g})}):x?d(t,{value:g,children:d(i,{fallback:null,children:d(x,{client:m,experience:g})})}):null}export{p as default};
@@ -39,17 +39,16 @@ export declare function useStep(): StepContext;
39
39
  */
40
40
  export declare function useSetStepContext(stepKey: string): StepContext;
41
41
  /**
42
- * Returns the current step's resolved CMS content data, or `null` when no content is
43
- * registered for the step's `layoutContentId`. Subscribes to `useStep().layoutContentStore`
44
- * via Effector's `useUnit`, so the component re-renders on content updates.
42
+ * Returns the current step's resolved CMS content data, or `null` when no content is registered.
43
+ *
44
+ * Reads `StepContextProvider` when present (the `StepRouter`/`Step` path); when absent (the slot
45
+ * render path, where only an `ExperienceProvider` is mounted) it falls back to resolving the
46
+ * experience's layout content, so slot-rendered components read content without crashing.
47
+ * Subscribes via `useStoreGlobal`, so the component re-renders on content updates.
45
48
  *
46
49
  * @returns {Record<string, unknown> | null} The Content record's `data`, or `null`.
47
- * @throws {Error} When called outside `StepContextProvider`.
48
50
  * @example
49
- * ```tsx
50
51
  * const content = useStepContent()
51
- * return <Layout headline={content?.headline as string ?? ''} />
52
- * ```
53
52
  */
54
53
  export declare function useStepContent(): Record<string, unknown> | null;
55
54
  //# sourceMappingURL=step.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../src/hooks/step.ts"],"names":[],"mappings":"AAEA,OAAO,EAAW,KAAK,KAAK,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC7D,OAAO,EAAW,KAAK,YAAY,EAAE,MAAM,SAAS,CAAA;AAEpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAIjE,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,KAAK,CAAC,cAAc,CAAC,CAAA;IAC3B,kFAAkF;IAClF,MAAM,EAAE,KAAK,CAAC,cAAc,EAAE,CAAC,CAAA;IAC/B;;;;;OAKG;IACH,kBAAkB,EAAE,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,CAAA;IACzC,QAAQ,EAAE,OAAO,CAAA;IACjB,0CAA0C;IAC1C,YAAY,EAAE,OAAO,CAAA;IACrB,IAAI,EAAE,YAAY,CAAC,MAAM,CAAC,CAAA;CAC3B;AAED,eAAO,MAAM,mBAAmB,6CAA0C,CAAA;AAE1E;;;;;GAKG;AACH,wBAAgB,OAAO,IAAI,WAAW,CAOrC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,CA6D9D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAI/D"}
1
+ {"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../src/hooks/step.ts"],"names":[],"mappings":"AAEA,OAAO,EAAW,KAAK,KAAK,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC7D,OAAO,EAAW,KAAK,YAAY,EAAE,MAAM,SAAS,CAAA;AAEpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAIjE,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,KAAK,CAAC,cAAc,CAAC,CAAA;IAC3B,kFAAkF;IAClF,MAAM,EAAE,KAAK,CAAC,cAAc,EAAE,CAAC,CAAA;IAC/B;;;;;OAKG;IACH,kBAAkB,EAAE,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,CAAA;IACzC,QAAQ,EAAE,OAAO,CAAA;IACjB,0CAA0C;IAC1C,YAAY,EAAE,OAAO,CAAA;IACrB,IAAI,EAAE,YAAY,CAAC,MAAM,CAAC,CAAA;CAC3B;AAED,eAAO,MAAM,mBAAmB,6CAA0C,CAAA;AAE1E;;;;;GAKG;AACH,wBAAgB,OAAO,IAAI,WAAW,CAOrC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,CA6D9D;AAgCD;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAM/D"}
@@ -1 +1 @@
1
- import{useExperience as e,usePicked as t}from"./client.js";import{useForm as n}from"../form/index.js";import{useStepRouter as r}from"../router/context.js";import{useStoreGlobal as i}from"./use-store-global.js";import{createContext as a,useContext as o,useMemo as s}from"react";import{combine as c}from"effector";var l=a(null);function u(){let e=o(l);if(!e)throw Error(`useStep must be used within a StepContextProvider`);return e}function d(i){let a=e(),o=t(),{activeStep:l}=r(),u=s(()=>l?.key===i,[l?.key,i]),d=s(()=>a.treeStore.map(e=>e.steps.find(e=>e.key===i)??{id:i,key:i,name:``,fieldKeys:[]},{skipVoid:!1}),[a,i]),{form:f,fields:p}=n(i,s(()=>d.map(e=>e.name,{skipVoid:!1}),[d]),s(()=>d.map(e=>e.fieldKeys,{skipVoid:!1}),[d]));return{step:d,fields:p,layoutContentStore:s(()=>c(d,o.contents.indexStore,(e,t)=>e.layoutContentId?t[e.layoutContentId]??null:null,{skipVoid:!1}),[d,o]),isActive:u,isActiveStep:u,form:f}}function f(){let{layoutContentStore:e}=u();return i(e)?.data??null}export{l as StepContextProvider,d as useSetStepContext,u as useStep,f as useStepContent};
1
+ import{useExperience as e,usePicked as t}from"./client.js";import{useForm as n}from"../form/index.js";import{useStepRouter as r}from"../router/context.js";import{useStoreGlobal as i}from"./use-store-global.js";import{createContext as a,useContext as o,useMemo as s}from"react";import{combine as c}from"effector";var l=a(null);function u(){let e=o(l);if(!e)throw Error(`useStep must be used within a StepContextProvider`);return e}function d(i){let a=e(),o=t(),{activeStep:l}=r(),u=s(()=>l?.key===i,[l?.key,i]),d=s(()=>a.treeStore.map(e=>e.steps.find(e=>e.key===i)??{id:i,key:i,name:``,fieldKeys:[]},{skipVoid:!1}),[a,i]),{form:f,fields:p}=n(i,s(()=>d.map(e=>e.name,{skipVoid:!1}),[d]),s(()=>d.map(e=>e.fieldKeys,{skipVoid:!1}),[d]));return{step:d,fields:p,layoutContentStore:s(()=>c(d,o.contents.indexStore,(e,t)=>e.layoutContentId?t[e.layoutContentId]??null:null,{skipVoid:!1}),[d,o]),isActive:u,isActiveStep:u,form:f}}function f(){let n=e(),r=t();return s(()=>c(n.treeStore,r.contents.indexStore,(e,t)=>{let n=e.steps.find(e=>e.layoutContentId);return n?.layoutContentId?t[n.layoutContentId]??null:null}),[n,r])}function p(){let e=o(l),t=f();return i(e?.layoutContentStore??t)?.data??null}export{l as StepContextProvider,d as useSetStepContext,u as useStep,p as useStepContent};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@picked/react",
3
- "version": "0.0.1-dev.1780458499348",
3
+ "version": "0.0.1-dev.1780464669265",
4
4
  "devDependencies": {
5
5
  "@picked/client": "workspace:*",
6
6
  "@repo/eslint-config": "workspace:*",
@@ -85,7 +85,7 @@
85
85
  },
86
86
  "module": "./dist/index.js",
87
87
  "peerDependencies": {
88
- "@picked/client": "0.0.1-dev.1780458499348",
88
+ "@picked/client": "0.0.1-dev.1780464669265",
89
89
  "effector": "^23.3.0",
90
90
  "react": "19.2.2",
91
91
  "react-dom": "19.2.2"