@picked/svelte 0.0.62-next.5 → 0.0.62-next.6

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,18 @@
1
+ import { Store } from 'effector';
2
+ import { Content } from '@picked/client';
3
+ /**
4
+ * Returns the registry store for a content id, mirroring `getField(key)`. Resolves
5
+ * the Picked client via `getPicked()` and returns `client.contents.getById(id)`.
6
+ *
7
+ * @param {string} id - The content record id to look up.
8
+ * @returns {Store<Content | null>} The registry store; `null` until content is registered.
9
+ * @example
10
+ * ```svelte
11
+ * <script>
12
+ * import { getContent } from '@picked/svelte'
13
+ * const banner = getContent('lc_banner')
14
+ * </script>
15
+ * <h1>{$banner?.data?.headline ?? ''}</h1>
16
+ * ```
17
+ */
18
+ export declare function getContent(id: string): Store<Content | null>;
@@ -0,0 +1 @@
1
+ import{getPicked as e}from"./client.js";function t(t){return e().contents.getById(t)}export{t as getContent};
@@ -3,7 +3,8 @@ export { getPicked, getExperience } from './client';
3
3
  export { getPredicate, getPredicateResult } from './predicate';
4
4
  export { getFeature, getFeatureResult } from './feature';
5
5
  export { getAction, getActionResult } from './action';
6
- export { getStep, setStepContext } from './step';
6
+ export { getStep, setStepContext, getStepContent } from './step';
7
+ export { getContent } from './content';
7
8
  export { useUnit, getContextScope, setContextScope } from './stores';
8
9
  export { createSessionStorageStore, createLocalStorageStore } from './storage.js';
9
10
  export { getTrackRecommendationPresentEvent } from './events';
@@ -1 +1 @@
1
- import{getExperience as e,getPicked as t}from"./client.js";import{getPredicate as n,getPredicateResult as r}from"./predicate.js";import{getFeature as i,getFeatureResult as a}from"./feature.js";import{getAction as o,getActionResult as s}from"./action.js";import{getStep as c,setStepContext as l}from"./step.js";import{getContextScope as u,setContextScope as d,useUnit as f}from"./stores.js";import{createLocalStorageStore as p,createSessionStorageStore as m}from"./storage.js";import{getTrackRecommendationPresentEvent as h}from"./events.js";import{createQuery as g,queryCache as _,queryPresets as v}from"./create-query/index.js";export{p as createLocalStorageStore,g as createQuery,m as createSessionStorageStore,o as getAction,s as getActionResult,u as getContextScope,e as getExperience,i as getFeature,a as getFeatureResult,t as getPicked,n as getPredicate,r as getPredicateResult,c as getStep,h as getTrackRecommendationPresentEvent,_ as queryCache,v as queryPresets,d as setContextScope,l as setStepContext,f as useUnit};
1
+ import{getExperience as e,getPicked as t}from"./client.js";import{getPredicate as n,getPredicateResult as r}from"./predicate.js";import{getFeature as i,getFeatureResult as a}from"./feature.js";import{getAction as o,getActionResult as s}from"./action.js";import{getStep as c,getStepContent as l,setStepContext as u}from"./step.js";import{getContent as d}from"./content.js";import{getContextScope as f,setContextScope as p,useUnit as m}from"./stores.js";import{createLocalStorageStore as h,createSessionStorageStore as g}from"./storage.js";import{getTrackRecommendationPresentEvent as _}from"./events.js";import{createQuery as v,queryCache as y,queryPresets as b}from"./create-query/index.js";export{h as createLocalStorageStore,v as createQuery,g as createSessionStorageStore,o as getAction,s as getActionResult,d as getContent,f as getContextScope,e as getExperience,i as getFeature,a as getFeatureResult,t as getPicked,n as getPredicate,r as getPredicateResult,c as getStep,l as getStepContent,_ as getTrackRecommendationPresentEvent,y as queryCache,b as queryPresets,p as setContextScope,u as setStepContext,m as useUnit};
@@ -1,10 +1,15 @@
1
1
  import { Store } from 'effector';
2
- import { ExperienceStep } from '@picked/client';
2
+ import { Content, ExperienceStep } from '@picked/client';
3
3
  import { FormInstance, FormField } from '../form/create-form.svelte';
4
4
  export interface StepContext extends FormInstance {
5
5
  step: Store<ExperienceStep>;
6
6
  /** Directly accessible fields with current response values — usable without a form. */
7
7
  fields: Store<FormField[]>;
8
+ /**
9
+ * Reactive store of the current step's CMS layout content. Resolves the step's
10
+ * `layoutContentId` against `client.contents` and stays reactive.
11
+ */
12
+ layoutContentStore: Store<Content | null>;
8
13
  isActive: Store<boolean>;
9
14
  /** @deprecated Use `isActive` instead. */
10
15
  isActiveStep: Store<boolean>;
@@ -12,13 +17,31 @@ export interface StepContext extends FormInstance {
12
17
  /**
13
18
  * Creates and sets step context in the Svelte context tree.
14
19
  *
15
- * @param stepKey - The step key.
20
+ * @param {string} stepKey - The step key.
21
+ * @returns {StepContext} The created step context.
16
22
  * @example setStepContext('step-1')
17
23
  */
18
24
  export declare function setStepContext(stepKey: string): StepContext;
19
25
  /**
20
26
  * Retrieves the step context from the Svelte context tree.
21
27
  *
28
+ * @returns {StepContext} The current step context.
22
29
  * @example getStep()
23
30
  */
24
31
  export declare function getStep(): StepContext;
32
+ /**
33
+ * Returns a Svelte/Effector store that yields the current step's resolved CMS content
34
+ * data, or `null` when no content is registered for the step's `layoutContentId`.
35
+ * Subscribers automatically receive updates when content is registered or replaced.
36
+ *
37
+ * @returns {Store<Record<string, unknown> | null>} A store of the Content record's `data`.
38
+ * @example
39
+ * ```svelte
40
+ * <script>
41
+ * import { getStepContent } from '@picked/svelte'
42
+ * const content = getStepContent()
43
+ * </script>
44
+ * <h1>{$content?.headline ?? ''}</h1>
45
+ * ```
46
+ */
47
+ export declare function getStepContent(): Store<Record<string, unknown> | null>;
@@ -1 +1 @@
1
- import{STEP_CONTEXT_KEY as e}from"../context.js";import{getPicked as t}from"./client.js";import{getStepRouter as n}from"../router/context.js";import{getContext as r,setContext as i}from"svelte";import{createForm as a}from"../form/create-form.svelte";function o(r){let o=t(),{activeStep:s}=n(),c=s.map(e=>e?.key===r),l=o.steps.listStore.map(e=>e.find(e=>e.key===r)??{id:r,key:r,name:``,fieldKeys:[]});return i(e,{step:l,isActive:c,isActiveStep:c,...a(r,l.map(e=>e.name),l.map(e=>e.fieldKeys))})}function s(){return r(e)}export{s as getStep,o as setStepContext};
1
+ import{STEP_CONTEXT_KEY as e}from"../context.js";import{getPicked as t}from"./client.js";import{getStepRouter as n}from"../router/context.js";import{combine as r}from"effector";import{getContext as i,setContext as a}from"svelte";import{createForm as o}from"../form/create-form.svelte";function s(i){let s=t(),{activeStep:c}=n(),l=c.map(e=>e?.key===i),u=s.steps.listStore.map(e=>e.find(e=>e.key===i)??{id:i,key:i,name:``,fieldKeys:[]}),d=o(i,u.map(e=>e.name),u.map(e=>e.fieldKeys));return a(e,{step:u,layoutContentStore:r(u,s.contents.indexStore,(e,t)=>e.layoutContentId?t[e.layoutContentId]??null:null,{skipVoid:!1}),isActive:l,isActiveStep:l,...d})}function c(){return i(e)}function l(){let{layoutContentStore:e}=c();return e.map(e=>e?.data??null,{skipVoid:!1})}export{c as getStep,l as getStepContent,s as setStepContext};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@picked/svelte",
3
- "version": "0.0.62-next.5",
3
+ "version": "0.0.62-next.6",
4
4
  "dependencies": {
5
5
  "d3": "^7.9.0"
6
6
  },
@@ -88,7 +88,7 @@
88
88
  },
89
89
  "module": "./dist/index.js",
90
90
  "peerDependencies": {
91
- "@picked/client": "0.0.62-next.5",
91
+ "@picked/client": "0.0.62-next.6",
92
92
  "effector": "^23.3.0",
93
93
  "svelte": "^5.46.4"
94
94
  },