@picked/react 0.0.1-dev.1778561735098 → 0.0.1-dev.1780446300503

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.
@@ -0,0 +1,27 @@
1
+ import { default as React } from 'react';
2
+ interface ExperienceProps {
3
+ /**
4
+ * Slot name. Maps to the `.picked-slot-<name>` selector that targeted experiences declare.
5
+ * Named `name` rather than `slot` for parity with the Svelte component, where `slot` is a
6
+ * reserved attribute.
7
+ */
8
+ readonly name: string;
9
+ }
10
+ /**
11
+ * Renders the experiences that target the named slot and whose condition is active, ordered by
12
+ * placement precedence (`before → prepend → append → after`).
13
+ *
14
+ * Active is read from `conditionResults` via `peek`: a seeded snapshot makes it synchronous for
15
+ * SSR and the hydration first paint, while a cache miss (standalone, no snapshot) triggers an
16
+ * asynchronous evaluation in a browser effect whose store write re-renders this component.
17
+ * Subscribing to `client.conditionResults.store` is what makes those late writes reactive.
18
+ *
19
+ * @param {ExperienceProps} props - The component props.
20
+ * @param {string} props.name - The slot name, mapped to the `.picked-slot-<name>` selector.
21
+ * @returns {React.JSX.Element} The active experiences for the slot.
22
+ * @example
23
+ * <Experience name="page" />
24
+ */
25
+ declare function Experience({ name }: ExperienceProps): React.JSX.Element;
26
+ export default Experience;
27
+ //# sourceMappingURL=Experience.d.ts.map
@@ -0,0 +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;AAmED;;;;;;;;;;;;;;GAcG;AACH,iBAAS,UAAU,CAAC,EAAE,IAAI,EAAE,EAAE,eAAe,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CA2ChE;AAED,eAAe,UAAU,CAAA"}
@@ -0,0 +1 @@
1
+ import{usePicked as e}from"../hooks/client.js";import"../hooks/index.js";import t from"./ExperienceHost.js";import{useEffect as n}from"react";import{supportsWindow as r}from"@picked/client";import{evaluateConditionMemo as i,hashRule as a}from"@picked/client/server";import{Fragment as o,jsx as s}from"react/jsx-runtime";import{useUnit as c}from"effector-react";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:a(n.decisionLogic)}:null}function f(){let{href:e,pathname:t,search:n,hostname:r,origin:i,protocol:a,port:o,host:s,hash:c}=window.location;return{href:e,pathname:t,search:n,hostname:r,origin:i,protocol:a,port:o,host:s,hash:c}}function p({name:a}){let l=e(),p=`.picked-slot-${a}`,m=c(l.experiences.listStore);c(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 n(()=>{if(r())for(let e of h)l.conditionResults.peek(e.hash)===void 0&&i(l,e.condition,{context:{location:f()}})}),s(o,{children:g.map(e=>s(t,{experience:e.experience,client:l},e.experience.id))})}export{p as default};
@@ -0,0 +1,25 @@
1
+ import { default as React } from 'react';
2
+ import { ExperienceStore, Picked } from '@picked/client';
3
+ interface ExperienceHostProps {
4
+ readonly experience: ExperienceStore;
5
+ readonly client: Picked;
6
+ }
7
+ /**
8
+ * Instantiates a single experience and renders its resolved React component.
9
+ *
10
+ * The experience instance is created once per mount (a ref initializer), exposed via
11
+ * `ExperienceProvider` so the component's hooks (`useExperience`, `useStep`) resolve, and the
12
+ * component is passed the same `{ client, experience }` props the browser/server renderers use.
13
+ * Direct components render synchronously; lazy loaders and promise-wrapped components render
14
+ * through `React.lazy` + `Suspense` (fallback `null`) and swap in once resolved.
15
+ *
16
+ * @param {ExperienceHostProps} props - The host props.
17
+ * @param {ExperienceStore} props.experience - The experience to instantiate.
18
+ * @param {Picked} props.client - The Picked client.
19
+ * @returns {React.JSX.Element | null} The rendered component, or null when none resolves.
20
+ * @example
21
+ * <ExperienceHost experience={experienceStore} client={client} />
22
+ */
23
+ declare function ExperienceHost({ experience, client }: ExperienceHostProps): React.JSX.Element | null;
24
+ export default ExperienceHost;
25
+ //# sourceMappingURL=ExperienceHost.d.ts.map
@@ -0,0 +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;AAGnE,OAAO,KAAK,EAAsB,eAAe,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAMjF,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"}
@@ -0,0 +1 @@
1
+ import{isValidAdaptedComponent as e}from"../component.js";import{ExperienceProvider as t}from"../context.js";import n,{Suspense as r,useEffect as i,useMemo as a,useRef as o}from"react";import{isLazyLoader as s,supportsWindow as c}from"@picked/client";import{createExperienceInstance as l}from"@picked/client/server";import{jsx as u}from"react/jsx-runtime";import{useUnit as d}from"effector-react";function f(e){return typeof e==`function`&&!s(e)&&!(e instanceof Promise)}function p({experience:p,client:m}){let h=o(null);h.current??=l({client:m,experience:p});let g=h.current,_=d(g.componentAndFrameworkStore),v=d(m.readyStore);i(()=>{v&&c()&&p.prepareExperienceContentFx()},[v,p]);let y=_?.component.component,b=y&&e(y)?y.component:void 0,x=a(()=>s(b)?n.lazy(()=>b.load()):b instanceof Promise?n.lazy(()=>b):null,[b]);return f(b)?u(t,{value:g,children:u(b,{client:m,experience:g})}):x?u(t,{value:g,children:u(r,{fallback:null,children:u(x,{client:m,experience:g})})}):null}export{p as default};
@@ -0,0 +1,35 @@
1
+ import { default as React } from 'react';
2
+ import { CreateClientOptions, Picked } from '@picked/client';
3
+ import { PickedSnapshot } from '@picked/client/server';
4
+ type PickedProviderProps = {
5
+ readonly client: Picked;
6
+ readonly children?: React.ReactNode;
7
+ } | {
8
+ readonly options: CreateClientOptions;
9
+ readonly snapshot?: PickedSnapshot;
10
+ readonly children?: React.ReactNode;
11
+ };
12
+ /**
13
+ * Provides a Picked client to descendant components.
14
+ *
15
+ * Pass `options` to have the provider create the client and synchronously hydrate it from an
16
+ * optional SSR snapshot, so `<Experience>` and the hooks read a fully-populated client during SSR
17
+ * and the hydration first paint; a `versionId` mismatch is tolerated (the client reconciles via
18
+ * `start()`). Alternatively pass an existing `client` (such as the app's already-running global
19
+ * client) to render experiences against it. In the browser the provider calls `client.start()`
20
+ * from an effect; `start()` is idempotent, so a client that was already started is left untouched.
21
+ *
22
+ * @param {PickedProviderProps} props - Either `{ client }` or `{ options, snapshot? }`, plus `children`.
23
+ * @returns {React.JSX.Element} The provider wrapping its children.
24
+ * @example
25
+ * <PickedProvider options={options} snapshot={snapshot}>
26
+ * <Experience name="page" />
27
+ * </PickedProvider>
28
+ * @example
29
+ * <PickedProvider client={globalClient}>
30
+ * <Experience name="hero-widget" />
31
+ * </PickedProvider>
32
+ */
33
+ declare function PickedProvider(props: PickedProviderProps): React.JSX.Element;
34
+ export default PickedProvider;
35
+ //# sourceMappingURL=PickedProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PickedProvider.d.ts","sourceRoot":"","sources":["../../src/experience/PickedProvider.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAA4B,MAAM,OAAO,CAAA;AAChD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAEjE,OAAO,EAAyB,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAGlF,KAAK,mBAAmB,GACpB;IACE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CACpC,GACD;IACE,QAAQ,CAAC,OAAO,EAAE,mBAAmB,CAAA;IACrC,QAAQ,CAAC,QAAQ,CAAC,EAAE,cAAc,CAAA;IAClC,QAAQ,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CACpC,CAAA;AA+BL;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,iBAAS,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAarE;AAED,eAAe,cAAc,CAAA"}
@@ -0,0 +1 @@
1
+ import{ClientProvider as e}from"../context.js";import{useEffect as t,useRef as n}from"react";import{createClient as r,supportsWindow as i}from"@picked/client";import{registerProjectConfig as a}from"@picked/client/server";import{jsx as o}from"react/jsx-runtime";function s(e,t){let n=r(e);if(t){let e=n.session.store.getState().id;a(n,t.projectConfig,{isPreview:!1,sessionId:e}),t.content.forEach(e=>n.registerContent(e)),n.conditionResults.seed(t.conditionResults)}return n}function c(r){let a=n(null);a.current??=`client`in r?r.client:s(r.options,r.snapshot);let c=a.current;return t(()=>{i()&&c.start()},[c]),o(e,{value:c,children:r.children})}export{c as default};
@@ -1 +1 @@
1
- import{usePicked as e}from"./client.js";import{attach as t,createEffect as n,createEvent as r,createStore as i,sample as a}from"effector";import{useUnit as o}from"effector-react";function s(t,n){return o(e().actions.getEvokableAction(t,n))}function c(s,c){let l=e().actions.getEvokableAction(s,c),u=i(void 0,{skipVoid:!1}),d=r(),f=t({source:l,mapParams:(e,t)=>t,effect:n(async e=>{if(e)return await e()})});return a({clock:d,target:f}),a({clock:f.doneData,target:u}),d(),a({clock:l,target:d}),o(u)}export{s as useAction,c as useActionResult};
1
+ import{usePicked as e}from"./client.js";import{useUnit as t}from"effector-react";import{attach as n,createEffect as r,createEvent as i,createStore as a,sample as o}from"effector";function s(n,r){return t(e().actions.getEvokableAction(n,r))}function c(s,c){let l=e().actions.getEvokableAction(s,c),u=a(void 0,{skipVoid:!1}),d=i(),f=n({source:l,mapParams:(e,t)=>t,effect:r(async e=>{if(e)return await e()})});return o({clock:d,target:f}),o({clock:f.doneData,target:u}),d(),o({clock:l,target:d}),t(u)}export{s as useAction,c as useActionResult};
@@ -0,0 +1,26 @@
1
+ import { Store } from 'effector';
2
+ import { Content } from '@picked/client';
3
+ /**
4
+ * Returns the registry store for a content id. Resolves the Picked client via
5
+ * `usePicked()` and returns `client.contents.getById(id)`. Consumers are
6
+ * responsible for calling `useUnit` to subscribe.
7
+ *
8
+ * Named with the `use` prefix so it satisfies React's rules-of-hooks (it
9
+ * indirectly calls `usePicked()`, which is itself a hook).
10
+ *
11
+ * @param {string} id - The content record id to look up.
12
+ * @returns {Store<Content | null>} The registry store; `null` until content is registered.
13
+ * @throws {Error} When called outside a `ClientProvider`. The error is propagated unchanged from `usePicked()`.
14
+ * @example
15
+ * ```tsx
16
+ * import { useUnit } from 'effector-react'
17
+ * import { useContent } from '@picked/react'
18
+ *
19
+ * const Banner = () => {
20
+ * const content = useUnit(useContent('lc_banner'))
21
+ * return <h1>{(content?.data?.headline as string) ?? ''}</h1>
22
+ * }
23
+ * ```
24
+ */
25
+ export declare function useContent(id: string): Store<Content | null>;
26
+ //# sourceMappingURL=content.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../src/hooks/content.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAG7C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,CAG5D"}
@@ -0,0 +1 @@
1
+ import{usePicked as e}from"./client.js";function t(t){return e().contents.getById(t)}export{t as useContent};
@@ -1 +1 @@
1
- import{usePicked as e}from"./client.js";import{attach as t,createEffect as n,createEvent as r,createStore as i,sample as a}from"effector";import{useUnit as o}from"effector-react";function s(t){return e().features.getEvokableFeature(t)}function c(e){return o(s(e))}function l(e){let c=s(e),l=i(void 0,{skipVoid:!1}),u=r(),d=t({source:c,mapParams:(e,t)=>t,effect:n(async e=>await e())});return a({clock:u,target:d}),a({clock:d.doneData,fn:t=>{if(t!==void 0)return{id:e,bucket:t}},target:l}),u(),a({clock:c,target:u}),o(l)}export{c as useFeature,l as useFeatureResult};
1
+ import{usePicked as e}from"./client.js";import{useUnit as t}from"effector-react";import{attach as n,createEffect as r,createEvent as i,createStore as a,sample as o}from"effector";function s(t){return e().features.getEvokableFeature(t)}function c(e){return t(s(e))}function l(e){let c=s(e),l=a(void 0,{skipVoid:!1}),u=i(),d=n({source:c,mapParams:(e,t)=>t,effect:r(async e=>await e())});return o({clock:u,target:d}),o({clock:d.doneData,fn:t=>{if(t!==void 0)return{id:e,bucket:t}},target:l}),u(),o({clock:c,target:u}),t(l)}export{c as useFeature,l as useFeatureResult};
@@ -3,11 +3,12 @@
3
3
  */
4
4
  export { ClientContext, ClientProvider, ExperienceContext, ExperienceProvider } from '../context';
5
5
  export { usePicked, useExperience } from './client';
6
- export { useStep, useSetStepContext } from './step';
6
+ export { useStep, useSetStepContext, useStepContent } from './step';
7
7
  export type { StepContext } from './step';
8
8
  export { useSessionStorage, useLocalStorage } from './storage';
9
9
  export type { UseStorageOptions } from './storage';
10
10
  export * from './field';
11
11
  export { useFeature, useFeatureResult } from './feature';
12
12
  export { useAction, useActionResult } from './action';
13
+ export { useContent } from './content';
13
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AACjG,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAA;AACnD,YAAY,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AACzC,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAC9D,YAAY,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAClD,cAAc,SAAS,CAAA;AACvB,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AACxD,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AACjG,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAA;AACnE,YAAY,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AACzC,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAC9D,YAAY,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAClD,cAAc,SAAS,CAAA;AACvB,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AACxD,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA"}
@@ -1 +1 @@
1
- import{ClientContext as e,ClientProvider as t,ExperienceContext as n,ExperienceProvider as r}from"../context.js";import{useExperience as i,usePicked as a}from"./client.js";import{useAction as o,useActionResult as s}from"./action.js";import{useFeature as c,useFeatureResult as l}from"./feature.js";import{getField as u}from"./field.js";import{useSetStepContext as d,useStep as f}from"./step.js";import{useLocalStorage as p,useSessionStorage as m}from"./storage.js";export{e as ClientContext,t as ClientProvider,n as ExperienceContext,r as ExperienceProvider,u as getField,o as useAction,s as useActionResult,i as useExperience,c as useFeature,l as useFeatureResult,p as useLocalStorage,a as usePicked,m as useSessionStorage,d as useSetStepContext,f as useStep};
1
+ import{ClientContext as e,ClientProvider as t,ExperienceContext as n,ExperienceProvider as r}from"../context.js";import{useExperience as i,usePicked as a}from"./client.js";import{useSetStepContext as o,useStep as s,useStepContent as c}from"./step.js";import{useLocalStorage as l,useSessionStorage as u}from"./storage.js";import{getField as d}from"./field.js";import{useFeature as f,useFeatureResult as p}from"./feature.js";import{useAction as m,useActionResult as h}from"./action.js";import{useContent as g}from"./content.js";export{e as ClientContext,t as ClientProvider,n as ExperienceContext,r as ExperienceProvider,d as getField,m as useAction,h as useActionResult,g as useContent,i as useExperience,f as useFeature,p as useFeatureResult,l as useLocalStorage,a as usePicked,u as useSessionStorage,o as useSetStepContext,s as useStep,c as useStepContent};
@@ -1,11 +1,18 @@
1
1
  import { Store } from 'effector';
2
- import { ExperienceStep } from '@picked/client';
2
+ import { Content, ExperienceStep } from '@picked/client';
3
3
  import { FormInstance } from '../form';
4
4
  import { ReactFormField } from '../utils/map-field-to-react';
5
5
  export interface StepContext {
6
6
  step: Store<ExperienceStep>;
7
7
  /** Reactive store of fields with React-style event handlers and current state. */
8
8
  fields: Store<ReactFormField[]>;
9
+ /**
10
+ * Reactive store of the current step's CMS layout content. Resolves the step's
11
+ * `layoutContentId` against `client.contents` and stays reactive — when content is
12
+ * registered or updated, subscribers re-render. Yields `null` when the step has no
13
+ * `layoutContentId` or the referenced content has not been registered yet.
14
+ */
15
+ layoutContentStore: Store<Content | null>;
9
16
  isActive: boolean;
10
17
  /** @deprecated Use `isActive` instead. */
11
18
  isActiveStep: boolean;
@@ -31,4 +38,18 @@ export declare function useStep(): StepContext;
31
38
  * @example useSetStepContext('step-1')
32
39
  */
33
40
  export declare function useSetStepContext(stepKey: string): StepContext;
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.
45
+ *
46
+ * @returns {Record<string, unknown> | null} The Content record's `data`, or `null`.
47
+ * @throws {Error} When called outside `StepContextProvider`.
48
+ * @example
49
+ * ```tsx
50
+ * const content = useStepContent()
51
+ * return <Layout headline={content?.headline as string ?? ''} />
52
+ * ```
53
+ */
54
+ export declare function useStepContent(): Record<string, unknown> | null;
34
55
  //# sourceMappingURL=step.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../src/hooks/step.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAW,KAAK,YAAY,EAAE,MAAM,SAAS,CAAA;AAEpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAGjE,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,KAAK,CAAC,cAAc,CAAC,CAAA;IAC3B,kFAAkF;IAClF,MAAM,EAAE,KAAK,CAAC,cAAc,EAAE,CAAC,CAAA;IAC/B,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,CAyC9D"}
1
+ {"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../src/hooks/step.ts"],"names":[],"mappings":"AAEA,OAAO,EAAW,KAAK,KAAK,EAAE,MAAM,UAAU,CAAA;AAE9C,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;AAGjE,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 +1 @@
1
- import{useExperience as e}from"./client.js";import{useForm as t}from"../form/index.js";import{useStepRouter as n}from"../router/context.js";import{createContext as r,useContext as i,useMemo as a}from"react";var o=r(null);function s(){let e=i(o);if(!e)throw Error(`useStep must be used within a StepContextProvider`);return e}function c(r){let i=e(),{activeStep:o}=n(),s=a(()=>o?.key===r,[o?.key,r]),c=a(()=>i.treeStore.map(e=>e.steps.find(e=>e.key===r)??{id:r,key:r,name:``,fieldKeys:[]},{skipVoid:!1}),[i,r]),{form:l,fields:u}=t(r,a(()=>c.map(e=>e.name,{skipVoid:!1}),[c]),a(()=>c.map(e=>e.fieldKeys,{skipVoid:!1}),[c]));return{step:c,fields:u,isActive:s,isActiveStep:s,form:l}}export{o as StepContextProvider,c as useSetStepContext,s as useStep};
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{createContext as i,useContext as a,useMemo as o}from"react";import{useUnit as s}from"effector-react";import{combine as c}from"effector";var l=i(null);function u(){let e=a(l);if(!e)throw Error(`useStep must be used within a StepContextProvider`);return e}function d(i){let a=e(),s=t(),{activeStep:l}=r(),u=o(()=>l?.key===i,[l?.key,i]),d=o(()=>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,o(()=>d.map(e=>e.name,{skipVoid:!1}),[d]),o(()=>d.map(e=>e.fieldKeys,{skipVoid:!1}),[d]));return{step:d,fields:p,layoutContentStore:o(()=>c(d,s.contents.indexStore,(e,t)=>e.layoutContentId?t[e.layoutContentId]??null:null,{skipVoid:!1}),[d,s]),isActive:u,isActiveStep:u,form:f}}function f(){let{layoutContentStore:e}=u();return s(e)?.data??null}export{l as StepContextProvider,d as useSetStepContext,u as useStep,f as useStepContent};
package/dist/index.d.ts CHANGED
@@ -3,4 +3,6 @@
3
3
  */
4
4
  export { adaptReactComponent, isValidAdaptedComponent } from './component';
5
5
  export type * from './component';
6
+ export { default as PickedProvider } from './experience/PickedProvider';
7
+ export { default as Experience } from './experience/Experience';
6
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAC1E,mBAAmB,aAAa,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAC1E,mBAAmB,aAAa,CAAA;AAChC,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,6BAA6B,CAAA;AACvE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,yBAAyB,CAAA"}
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{adaptReactComponent as e,isValidAdaptedComponent as t}from"./component.js";export{e as adaptReactComponent,t as isValidAdaptedComponent};
1
+ import{adaptReactComponent as e,isValidAdaptedComponent as t}from"./component.js";import n from"./experience/PickedProvider.js";import r from"./experience/Experience.js";export{r as Experience,n as PickedProvider,e as adaptReactComponent,t as isValidAdaptedComponent};
@@ -1 +1 @@
1
- import{useExperience as e}from"../hooks/client.js";import{StepRouterProvider as t}from"./context.js";import"../hooks/index.js";import{useCallback as n,useMemo as r,useRef as i,useState as a}from"react";import{useUnit as o}from"effector-react";import{supportsWindow as s}from"@picked/client";import{jsx as c}from"react/jsx-runtime";function l({children:l}){let{currentStepStore:u}=e(),d=o(u),f=i(!1),[p,m]=a([]),[h,g]=a(null),_=n(e=>{if(s())m(t=>[...t,e]);else{if(f.current)return;e.key===d?.key&&(g(e),f.current=!0)}},[d?.key]),v=n(e=>{m(t=>t.filter(t=>t!==e))},[]),y=r(()=>h??p.find(e=>e.key===d?.key)??null,[h,p,d?.key]),b=r(()=>({activeStep:y,registerStep:_,unregisterStep:v}),[y,_,v]);return d?.key?c(t,{value:b,children:l}):null}export{l as default};
1
+ import{useExperience as e}from"../hooks/client.js";import{StepRouterProvider as t}from"./context.js";import"../hooks/index.js";import{useCallback as n,useMemo as r,useRef as i,useState as a}from"react";import{supportsWindow as o}from"@picked/client";import{jsx as s}from"react/jsx-runtime";import{useUnit as c}from"effector-react";function l({children:l}){let{currentStepStore:u}=e(),d=c(u),f=i(!1),[p,m]=a([]),[h,g]=a(null),_=n(e=>{if(o())m(t=>[...t,e]);else{if(f.current)return;e.key===d?.key&&(g(e),f.current=!0)}},[d?.key]),v=n(e=>{m(t=>t.filter(t=>t!==e))},[]),y=r(()=>h??p.find(e=>e.key===d?.key)??null,[h,p,d?.key]),b=r(()=>({activeStep:y,registerStep:_,unregisterStep:v}),[y,_,v]);return d?.key?s(t,{value:b,children:l}):null}export{l as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@picked/react",
3
- "version": "0.0.1-dev.1778561735098",
3
+ "version": "0.0.1-dev.1780446300503",
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.1778561735098",
88
+ "@picked/client": "0.0.1-dev.1780446300503",
89
89
  "effector": "^23.3.0",
90
90
  "effector-react": "^23.3.0",
91
91
  "react": "19.2.2",
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=index.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../src/form/index.test.tsx"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=step.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"step.test.d.ts","sourceRoot":"","sources":["../../src/hooks/step.test.tsx"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=StepRouter.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"StepRouter.test.d.ts","sourceRoot":"","sources":["../../src/router/StepRouter.test.tsx"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=map-field-to-react.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"map-field-to-react.test.d.ts","sourceRoot":"","sources":["../../src/utils/map-field-to-react.test.tsx"],"names":[],"mappings":""}