@picked/react 0.0.73 → 0.0.74-next.1

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.
Files changed (55) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/form/index.d.ts +4 -3
  3. package/dist/form/index.d.ts.map +1 -1
  4. package/dist/hooks/action.d.ts +5 -5
  5. package/dist/hooks/action.d.ts.map +1 -1
  6. package/dist/hooks/content.d.ts +7 -13
  7. package/dist/hooks/content.d.ts.map +1 -1
  8. package/dist/hooks/content.js +1 -1
  9. package/dist/hooks/feature.d.ts +7 -7
  10. package/dist/hooks/feature.d.ts.map +1 -1
  11. package/dist/hooks/field.d.ts +10 -5
  12. package/dist/hooks/field.d.ts.map +1 -1
  13. package/dist/hooks/fixtures/augmented-registry.d.js +0 -0
  14. package/dist/hooks/index.d.ts +1 -0
  15. package/dist/hooks/index.d.ts.map +1 -1
  16. package/dist/hooks/reference.d.ts +20 -14
  17. package/dist/hooks/reference.d.ts.map +1 -1
  18. package/dist/hooks/step.d.ts +37 -15
  19. package/dist/hooks/step.d.ts.map +1 -1
  20. package/dist/hooks/typed-hooks-augmented.test-d.js +1 -0
  21. package/dist/hooks/typed-hooks.test-d.js +1 -0
  22. package/dist/public-types.test-d.js +1 -0
  23. package/package.json +6 -4
  24. package/dist/experience/HtmlRender.preview.test.d.ts +0 -2
  25. package/dist/experience/HtmlRender.preview.test.d.ts.map +0 -1
  26. package/dist/experience/HtmlRender.server.test.d.ts +0 -2
  27. package/dist/experience/HtmlRender.server.test.d.ts.map +0 -1
  28. package/dist/experience/HtmlRender.test.d.ts +0 -2
  29. package/dist/experience/HtmlRender.test.d.ts.map +0 -1
  30. package/dist/experience/__fixtures__/TestExperience.d.ts +0 -17
  31. package/dist/experience/__fixtures__/TestExperience.d.ts.map +0 -1
  32. package/dist/experience/__fixtures__/project-config.d.ts +0 -50
  33. package/dist/experience/__fixtures__/project-config.d.ts.map +0 -1
  34. package/dist/experience/experience.server.test.d.ts +0 -2
  35. package/dist/experience/experience.server.test.d.ts.map +0 -1
  36. package/dist/experience/experience.test.d.ts +0 -2
  37. package/dist/experience/experience.test.d.ts.map +0 -1
  38. package/dist/form/index.test.d.ts +0 -2
  39. package/dist/form/index.test.d.ts.map +0 -1
  40. package/dist/form/use-form-callbacks.test.d.ts +0 -2
  41. package/dist/form/use-form-callbacks.test.d.ts.map +0 -1
  42. package/dist/hooks/reference.test.d.ts +0 -2
  43. package/dist/hooks/reference.test.d.ts.map +0 -1
  44. package/dist/hooks/step.test.d.ts +0 -2
  45. package/dist/hooks/step.test.d.ts.map +0 -1
  46. package/dist/hooks/use-store-global.test.d.ts +0 -2
  47. package/dist/hooks/use-store-global.test.d.ts.map +0 -1
  48. package/dist/peer-floor.server.test.d.ts +0 -2
  49. package/dist/peer-floor.server.test.d.ts.map +0 -1
  50. package/dist/peer-floor.test.d.ts +0 -2
  51. package/dist/peer-floor.test.d.ts.map +0 -1
  52. package/dist/router/StepRouter.test.d.ts +0 -2
  53. package/dist/router/StepRouter.test.d.ts.map +0 -1
  54. package/dist/utils/map-field-to-react.test.d.ts +0 -2
  55. package/dist/utils/map-field-to-react.test.d.ts.map +0 -1
@@ -5,15 +5,16 @@ import { type ErrorCallback, type FormInstance as CoreFormInstance, type SubmitC
5
5
  import { type ReactFormField } from '../utils/map-field-to-react';
6
6
  import { type FormCallbackOptions, type FormCallbackRegistrars } from './use-form-callbacks';
7
7
  export type { FormCallbackOptions, FormCallbackRegistrars, FormCallbackChannel, } from './use-form-callbacks';
8
- export interface FormInstance {
8
+ export type { ReactFormField, ReactFormFieldProps } from '../utils/map-field-to-react';
9
+ export interface FormInstance<TFieldKeys extends string = string> {
9
10
  form: {
10
11
  props: {
11
12
  onSubmit: (e: FormEvent<HTMLFormElement>) => void;
12
13
  };
13
14
  errors: CoreFormInstance['form']['errors'];
14
15
  submitting: CoreFormInstance['form']['submitting'];
15
- onBeforeSubmit: (callback: SubmitCallback) => void;
16
- onSuccess: (callback: SuccessCallback) => void;
16
+ onBeforeSubmit: (callback: SubmitCallback<TFieldKeys>) => void;
17
+ onSuccess: (callback: SuccessCallback<TFieldKeys>) => void;
17
18
  onError: (callback: ErrorCallback) => void;
18
19
  };
19
20
  fields: Store<ReactFormField[]>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/form/index.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,OAAO,EAAE,KAAK,SAAS,EAAW,MAAM,OAAO,CAAA;AAC/C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,YAAY,IAAI,gBAAgB,EACrC,KAAK,cAAc,EACnB,KAAK,eAAe,EACrB,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAAmB,KAAK,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAElF,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC5B,MAAM,sBAAsB,CAAA;AAE7B,YAAY,EACV,mBAAmB,EACnB,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,sBAAsB,CAAA;AAE7B,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE;QACJ,KAAK,EAAE;YACL,QAAQ,EAAE,CAAC,CAAC,EAAE,SAAS,CAAC,eAAe,CAAC,KAAK,IAAI,CAAA;SAClD,CAAA;QACD,MAAM,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAA;QAC1C,UAAU,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAA;QAClD,cAAc,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,IAAI,CAAA;QAClD,SAAS,EAAE,CAAC,QAAQ,EAAE,eAAe,KAAK,IAAI,CAAA;QAC9C,OAAO,EAAE,CAAC,QAAQ,EAAE,aAAa,KAAK,IAAI,CAAA;KAC3C,CAAA;IACD,MAAM,E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AC,YAAY,CAAC,CAAA;QAClD,cAAc,EAAE,CAAC,QAAQ,EAAE,cAAc,CAAC,UAAU,CAAC,KAAK,IAAI,CAAA;QAC9D,SAAS,EAAE,CAAC,QAAQ,EAAE,eAAe,CAAC,UAAU,CAAC,KAAK,IAAI,CAAA;QAC1D,OAAO,EAAE,CAAC,QAAQ,EAAE,aAAa,KAAK,IAAI,CAAA;KAC3C,CAAA;IACD,MAAM,EAAE,KAAK,CAAC,cAAc,EAAE,CAAC,CAAA;IAC/B;;;;OAIG;IACH,cAAc,EAAE,sBAAsB,CAAA;CACvC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,OAAO,CACrB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,EACpB,SAAS,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,EAC1B,OAAO,CAAC,EAAE,mBAAmB,GAC5B,YAAY,CA2Cd"}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @file React hooks for consuming registered actions from the Picked client.
3
3
  */
4
- import type { Action, ExperienceInstance } from '@picked/client';
4
+ import type { Action, ActionKeys, ExperienceInstance } from '@picked/client';
5
5
  type ActionResult = string | string[] | boolean | void | undefined;
6
6
  /**
7
7
  * Returns the current evokable action function, reactive to store updates.
@@ -10,7 +10,7 @@ type ActionResult = string | string[] | boolean | void | undefined;
10
10
  * behave as if they were triggered by that experience — for example, to
11
11
  * call `context.experience.close()` after a submit.
12
12
  *
13
- * @param {string} actionKey - The registered action key.
13
+ * @param {ActionKeys} actionKey - Action key from the workspace schema.
14
14
  * @param {object} [options] - Optional invocation overrides.
15
15
  * @param {ExperienceInstance} options.experience - Experience to bind as the action's context.
16
16
  * @returns {() => ReturnType<Action>} The callable action function.
@@ -18,21 +18,21 @@ type ActionResult = string | string[] | boolean | void | undefined;
18
18
  * const evoke = useAction('log-event')
19
19
  * const bound = useAction('submit-form', { experience: useExperience() })
20
20
  */
21
- export declare function useAction(actionKey: string, options?: {
21
+ export declare function useAction(actionKey: ActionKeys, options?: {
22
22
  experience: ExperienceInstance;
23
23
  }): () => ReturnType<Action>;
24
24
  /**
25
25
  * Returns the latest result of invoking the keyed action, reactive to store updates.
26
26
  * Re-evaluates whenever the underlying evokable store emits.
27
27
  *
28
- * @param {string} actionKey - The registered action key.
28
+ * @param {ActionKeys} actionKey - Action key from the workspace schema.
29
29
  * @param {object} [options] - Optional invocation overrides.
30
30
  * @param {ExperienceInstance} options.experience - Experience to bind as the action's context.
31
31
  * @returns {ActionResult} The latest action return value.
32
32
  * @example
33
33
  * const result = useActionResult('is-logged-in')
34
34
  */
35
- export declare function useActionResult(actionKey: string, options?: {
35
+ export declare function useActionResult(actionKey: ActionKeys, options?: {
36
36
  experience: ExperienceInstance;
37
37
  }): ActionResult;
38
38
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../src/hooks/action.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAKhE,KAAK,YAAY,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAA;AAElE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,SAAS,CACvB,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE;IAAE,UAAU,EAAE,kBAAkB,CAAA;CAAE,GAC3C,MAAM,UAAU,CAAC,MAAM,CAAC,CAG1B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE;IAAE,UAAU,EAAE,kBAAkB,CAAA;CAAE,GAC3C,YAAY,CAmCd"}
1
+ {"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../src/hooks/action.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAK5E,KAAK,YAAY,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAA;AAElE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,SAAS,CACvB,SAAS,EAAE,UAAU,EACrB,OAAO,CAAC,EAAE;IAAE,UAAU,EAAE,kBAAkB,CAAA;CAAE,GAC3C,MAAM,UAAU,CAAC,MAAM,CAAC,CAG1B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,UAAU,EACrB,OAAO,CAAC,EAAE;IAAE,UAAU,EAAE,kBAAkB,CAAA;CAAE,GAC3C,YAAY,CAmCd"}
@@ -3,28 +3,22 @@
3
3
  * `useField(key)` — returns the registry store, leaving subscription to the consumer.
4
4
  */
5
5
  import type { Store } from 'effector';
6
- import type { Content } from '@picked/client';
6
+ import { type TypedContent } from '@picked/client';
7
7
  /**
8
8
  * Returns the registry store for a content id. Resolves the Picked client via
9
9
  * `usePicked()` and returns `client.contents.getById(id)`. Consumers are
10
- * responsible for calling `useUnit` to subscribe.
11
- *
12
- * Named with the `use` prefix so it satisfies React's rules-of-hooks (it
13
- * indirectly calls `usePicked()`, which is itself a hook).
10
+ * responsible for calling `useStoreGlobal` to subscribe.
14
11
  *
12
+ * @template TData
15
13
  * @param {string} id - The content record id to look up.
16
- * @returns {Store<Content | null>} The registry store; `null` until content is registered.
17
- * @throws {Error} When called outside a `ClientProvider`. The error is propagated unchanged from `usePicked()`.
14
+ * @returns {Store<TypedContent<TData> | null>} The registry store; `null` until content is registered.
18
15
  * @example
19
16
  * ```tsx
20
- * import { useUnit } from 'effector-react'
21
- * import { useContent } from '@picked/react'
22
- *
23
17
  * const Banner = () => {
24
- * const content = useUnit(useContent('lc_banner'))
25
- * return <h1>{(content?.data?.headline as string) ?? ''}</h1>
18
+ * const content = useStoreGlobal(useContent<WelcomePage>('lc_banner'))
19
+ * return <h1>{content?.data.title ?? ''}</h1>
26
20
  * }
27
21
  * ```
28
22
  */
29
- export declare function useContent(id: string): Store<Content | null>;
23
+ export declare function useContent<TData extends Record<string, unknown> = Record<string, unknown>>(id: string): Store<TypedContent<TData> | null>;
30
24
  //# sourceMappingURL=content.d.ts.map
@@ -1 +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"}
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,EAAuB,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAGvE;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,UAAU,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACxF,EAAE,EAAE,MAAM,GACT,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAGnC"}
@@ -1 +1 @@
1
- import{usePicked as e}from"./client.js";function t(t){return e().contents.getById(t)}export{t as useContent};
1
+ import{usePicked as e}from"./client.js";import{toTypedContentStore as t}from"@picked/client";function n(n){let r=e();return t(r.contents.getById(n))}export{n as useContent};
@@ -1,14 +1,14 @@
1
- import type { FeatureResult } from '@picked/client';
1
+ import type { FeatureKeys, FeatureResult } from '@picked/client';
2
2
  type FeatureBucket = boolean | string | undefined;
3
3
  /**
4
4
  * Returns the current evokable feature function, reactive to store updates.
5
5
  *
6
- * @param {string} featureName - The name of the feature to retrieve.
6
+ * @param {FeatureKeys} featureName - Feature key from the workspace schema.
7
7
  * @returns {() => Promise<FeatureBucket>} The evokable feature function.
8
8
  * @example
9
9
  * const evoke = useFeature('my-feature')
10
10
  */
11
- export declare function useFeature(featureName: string): () => Promise<FeatureBucket>;
11
+ export declare function useFeature(featureName: FeatureKeys): () => Promise<FeatureBucket>;
12
12
  /**
13
13
  * Returns the feature's evaluated bucket result, reactive to store updates.
14
14
  *
@@ -16,12 +16,12 @@ export declare function useFeature(featureName: string): () => Promise<FeatureBu
16
16
  * resolves it once — so a component that re-renders reads the same result rather than
17
17
  * rebuilding the graph behind it.
18
18
  *
19
- * @param {string} featureName - The name of the feature to evaluate.
19
+ * @param {FeatureKeys} featureName - Feature key from the workspace schema.
20
20
  * @returns {FeatureResult | undefined} The current feature evaluation result, reactive to store updates.
21
21
  * @example
22
22
  * const result = useFeatureResult('my-feature')
23
23
  */
24
- export declare function useFeatureResult(featureName: string): FeatureResult | undefined;
24
+ export declare function useFeatureResult(featureName: FeatureKeys): FeatureResult | undefined;
25
25
  /**
26
26
  * Returns a feature's admin `enabled` flag, reactive to store updates.
27
27
  *
@@ -31,11 +31,11 @@ export declare function useFeatureResult(featureName: string): FeatureResult | u
31
31
  * `undefined` when the feature is unregistered or carries no `enabled` metadata
32
32
  * (for example, manually-registered features).
33
33
  *
34
- * @param {string} featureName - The feature id to look up.
34
+ * @param {FeatureKeys} featureName - Feature key from the workspace schema.
35
35
  * @returns {boolean | undefined} The feature's `enabled` flag, or `undefined` when unknown.
36
36
  * @example
37
37
  * const enabled = useFeatureEnabled('winter-sale')
38
38
  */
39
- export declare function useFeatureEnabled(featureName: string): boolean | undefined;
39
+ export declare function useFeatureEnabled(featureName: FeatureKeys): boolean | undefined;
40
40
  export {};
41
41
  //# sourceMappingURL=feature.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"feature.d.ts","sourceRoot":"","sources":["../../src/hooks/feature.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAInD,KAAK,aAAa,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAA;AAgBjD;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,OAAO,CAAC,aAAa,CAAC,CAE5E;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAI/E;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAI1E"}
1
+ {"version":3,"file":"feature.d.ts","sourceRoot":"","sources":["../../src/hooks/feature.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAIhE,KAAK,aAAa,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAA;AAgBjD;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,OAAO,CAAC,aAAa,CAAC,CAEjF;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,WAAW,GAAG,aAAa,GAAG,SAAS,CAIpF;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,GAAG,SAAS,CAI/E"}
@@ -1,15 +1,20 @@
1
1
  /**
2
2
  * @file React hook for accessing individual field data and response values from the Picked client.
3
3
  */
4
- import type { Field, FieldValue } from '@picked/client';
4
+ import type { Field, FieldKeys, FieldValueFor } from '@picked/client';
5
5
  import type { Store } from 'effector';
6
- export interface GetFieldResponse {
7
- value: Store<FieldValue>;
6
+ export interface GetFieldResponse<K extends FieldKeys = FieldKeys> {
7
+ value: Store<FieldValueFor<K>>;
8
8
  field: Store<Field | null>;
9
9
  }
10
10
  /**
11
+ * Returns reactive stores for a field definition and its current response value.
11
12
  *
12
- * @param key string
13
+ * @template K
14
+ * @param {K} key - Field key from the workspace schema.
15
+ * @returns {GetFieldResponse<K>} Field metadata and value stores.
16
+ * @example
17
+ * const { value } = getField('email')
13
18
  */
14
- export declare function getField(key: string): GetFieldResponse;
19
+ export declare function getField<K extends FieldKeys>(key: K): GetFieldResponse<K>;
15
20
  //# sourceMappingURL=field.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../../src/hooks/field.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AACvD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAGrC,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,CAAA;IACxB,KAAK,EAAE,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,CAAA;CAC3B;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAQtD"}
1
+ {"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../../src/hooks/field.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AACrE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAGrC,MAAM,WAAW,gBAAgB,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS;IAC/D,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAA;IAC9B,KAAK,EAAE,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,CAAA;CAC3B;AAED;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,SAAS,EAAE,GAAG,EAAE,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAQzE"}
File without changes
@@ -6,6 +6,7 @@ export { usePicked, useExperience } from './client';
6
6
  export { useStoreGlobal } from './use-store-global';
7
7
  export { useStep, useSetStepContext, useStepContent } from './step';
8
8
  export type { StepContext } from './step';
9
+ export type { ReactFormField, ReactFormFieldProps } from '../utils/map-field-to-react';
9
10
  export { useSessionStorage, useLocalStorage } from './storage';
10
11
  export type { UseStorageOptions } from './storage';
11
12
  export * from './field';
@@ -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,cAAc,EAAE,MAAM,oBAAoB,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,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAC3E,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACtC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,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,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAA;AACnE,YAAY,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AACzC,YAAY,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AACtF,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,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAC3E,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACtC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA"}
@@ -1,28 +1,31 @@
1
1
  import type { Store } from 'effector';
2
- import { type Content } from '@picked/client';
2
+ import { type ReferencedContent } from '@picked/client';
3
3
  /**
4
4
  * Resolves a single `reference` field value to the Content record it points at.
5
5
  *
6
6
  * The store is memoised on the field value, so re-rendering with the same
7
- * pointer keeps the same subscription. Consumers subscribe with `useUnit`.
7
+ * pointer keeps the same subscription. Consumers subscribe with `useStoreGlobal`.
8
8
  *
9
- * @param {unknown} value - The raw `reference` value, or an Effector store carrying one. A
9
+ * When the workspace schema has been generated, the record narrows to the Content Model the
10
+ * field targets; otherwise it stays the untyped `Content`.
11
+ *
12
+ * @template TValue
13
+ * @param {TValue} value - The raw `reference` value, or an Effector store carrying one. A
10
14
  * store keeps the lookup live when the field arrives after this call.
11
- * @returns {Store<Content | null>} The referenced record, or `null` when the field is unset or its target is not registered.
15
+ * @returns {Store<ReferencedContent<TValue> | null>} The referenced record, or `null` when the field is unset or its target is not registered.
12
16
  * @throws {Error} When called outside a `ClientProvider`. The error is propagated unchanged from `usePicked()`.
13
17
  * @example
14
18
  * ```tsx
15
- * import { useUnit } from 'effector-react'
16
- * import { useReference, useStepContent } from '@picked/react/hooks'
19
+ * import { useReference, useStepContent, useStoreGlobal } from '@picked/react/hooks'
17
20
  *
18
21
  * const Byline = () => {
19
22
  * const content = useStepContent()
20
- * const author = useUnit(useReference(content?.author))
23
+ * const author = useStoreGlobal(useReference(content?.author))
21
24
  * return <span>{String(author?.data.name ?? '')}</span>
22
25
  * }
23
26
  * ```
24
27
  */
25
- export declare function useReference(value: unknown): Store<Content | null>;
28
+ export declare function useReference<TValue>(value: TValue): Store<ReferencedContent<TValue> | null>;
26
29
  /**
27
30
  * Resolves a repeatable `reference` field to the Content records it points at,
28
31
  * in field order. A single (non-repeatable) value resolves to a one-element list.
@@ -30,21 +33,24 @@ export declare function useReference(value: unknown): Store<Content | null>;
30
33
  * The list is dense: a pointer whose target did not resolve is skipped rather
31
34
  * than held as a hole, so the list can be rendered without a null check per item.
32
35
  *
33
- * @param {unknown} value - The raw `reference` value, or an Effector store carrying one. A
36
+ * When the workspace schema has been generated, each record narrows to the Content Model the
37
+ * field targets; otherwise they stay the untyped `Content`.
38
+ *
39
+ * @template TValue
40
+ * @param {TValue} value - The raw `reference` value, or an Effector store carrying one. A
34
41
  * store keeps the lookup live when the field arrives after this call.
35
- * @returns {Store<Content[]>} The referenced records that resolved.
42
+ * @returns {Store<ReferencedContent<TValue>[]>} The referenced records that resolved.
36
43
  * @throws {Error} When called outside a `ClientProvider`. The error is propagated unchanged from `usePicked()`.
37
44
  * @example
38
45
  * ```tsx
39
- * import { useUnit } from 'effector-react'
40
- * import { useReferences, useStepContent } from '@picked/react/hooks'
46
+ * import { useReferences, useStepContent, useStoreGlobal } from '@picked/react/hooks'
41
47
  *
42
48
  * const Authors = () => {
43
49
  * const content = useStepContent()
44
- * const authors = useUnit(useReferences(content?.authors))
50
+ * const authors = useStoreGlobal(useReferences(content?.authors))
45
51
  * return <ul>{authors.map((a) => <li key={a.id}>{String(a.data.name)}</li>)}</ul>
46
52
  * }
47
53
  * ```
48
54
  */
49
- export declare function useReferences(value: unknown): Store<Content[]>;
55
+ export declare function useReferences<TValue>(value: TValue): Store<ReferencedContent<TValue>[]>;
50
56
  //# sourceMappingURL=reference.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"reference.d.ts","sourceRoot":"","sources":["../../src/hooks/reference.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,EAAqC,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAGhF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,CAGlE;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC,CAG9D"}
1
+ {"version":3,"file":"reference.d.ts","sourceRoot":"","sources":["../../src/hooks/reference.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,gBAAgB,CAAA;AAGvB;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC,iBAAiB,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAA;AAM5F;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC,iBAAiB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA"}
@@ -1,9 +1,9 @@
1
1
  import { type Store } from 'effector';
2
- import type { Content, ExperienceStep } from '@picked/client';
2
+ import type { Content, ContentForStep, ExperienceStep, FieldKeysForStep, StepContentModelsMap, StepKeys, StepLayoutContent } from '@picked/client';
3
3
  import { type FormInstance } from '../form';
4
4
  import { type FormCallbackOptions } from '../form/use-form-callbacks';
5
5
  import type { ReactFormField } from '../utils/map-field-to-react';
6
- export interface StepContext {
6
+ export interface StepContext<TFieldKeys extends string = string> {
7
7
  step: Store<ExperienceStep>;
8
8
  /** Reactive store of fields with React-style event handlers and current state. */
9
9
  fields: Store<ReactFormField[]>;
@@ -21,19 +21,19 @@ export interface StepContext {
21
21
  * `useStepContent()` yields, exposed here so a step can read everything it needs from a
22
22
  * single `useStep()` call.
23
23
  */
24
- content: Store<Record<string, unknown> | null>;
24
+ content: Store<StepLayoutContent | null>;
25
25
  isActive: boolean;
26
26
  /** @deprecated Use `isActive` instead. */
27
27
  isActiveStep: boolean;
28
- form: FormInstance['form'];
28
+ form: FormInstance<TFieldKeys>['form'];
29
29
  /**
30
30
  * Raw core registrars, used by `useStep` to own a callback channel scoped to the
31
31
  * consuming component rather than to `Step`. Internal: not part of the
32
32
  * supported surface.
33
33
  */
34
- formRegistrars: FormInstance['formRegistrars'];
34
+ formRegistrars: FormInstance<TFieldKeys>['formRegistrars'];
35
35
  }
36
- export declare const StepContextProvider: import("react").Context<StepContext | null>;
36
+ export declare const StepContextProvider: import("react").Context<StepContext<string> | null>;
37
37
  /**
38
38
  * Retrieves the step context from the nearest provider.
39
39
  *
@@ -45,10 +45,25 @@ export declare const StepContextProvider: import("react").Context<StepContext |
45
45
  * component unmounts, independently of sibling consumers.
46
46
  *
47
47
  * @param {FormCallbackOptions} [options] - Latest-wins submit callback slots; the recommended way to attach callbacks.
48
- * @returns {StepContext} The current step context.
48
+ * @returns {StepContext} The current step context, loosely typed.
49
49
  * @example const { form, fields } = useStep({ onSuccess: ({ data }) => track(data) })
50
50
  */
51
51
  export declare function useStep(options?: FormCallbackOptions): StepContext;
52
+ /**
53
+ * Retrieves the step context narrowed by an asserted step key.
54
+ *
55
+ * The `K` type argument is compile-time narrowing only. It asserts which step the caller
56
+ * renders, so `content` resolves to that step's content model and the `form`/field callbacks
57
+ * type against that step's field keys. Runtime data always comes from the current provider.
58
+ *
59
+ * @template K
60
+ * @param {FormCallbackOptions} [options] - Latest-wins submit callback slots, typed to that step's field keys.
61
+ * @returns {StepContext} The current step context with `content` narrowed to `ContentForStep<K>`.
62
+ * @example useStep<'lead-capture-form'>({ onSuccess: ({ data }) => track(data) })
63
+ */
64
+ export declare function useStep<K extends StepKeys>(options?: FormCallbackOptions<FieldKeysForStep<K>>): Omit<StepContext<FieldKeysForStep<K>>, 'content'> & {
65
+ content: Store<ContentForStep<K> | null>;
66
+ };
52
67
  /**
53
68
  * Creates and provides step context for the given step key.
54
69
  *
@@ -56,23 +71,30 @@ export declare function useStep(options?: FormCallbackOptions): StepContext;
56
71
  * `step` store resolves to an empty placeholder and updates reactively once the
57
72
  * step is registered — matching the Svelte SDK's behaviour.
58
73
  *
59
- * @param {string} stepKey - The step key to look up in the experience tree.
74
+ * @param {StepKeys} stepKey - Step key from the workspace schema, looked up in the experience tree.
60
75
  * @param {FormCallbackOptions} [options] - Latest-wins submit callback slots for the step's own form.
61
76
  * @returns {StepContext} Step context with form, fields, and active state.
62
77
  * @example useSetStepContext('step-1', { onSuccess: ({ data }) => track(data) })
63
78
  */
64
- export declare function useSetStepContext(stepKey: string, options?: FormCallbackOptions): StepContext;
79
+ export declare function useSetStepContext(stepKey: StepKeys, options?: FormCallbackOptions): StepContext;
65
80
  /**
66
81
  * Returns the current step's resolved CMS content data, or `null` when no content is registered.
67
82
  *
68
- * Reads `StepContextProvider` when present (the `StepRouter`/`Step` path); when absent (the slot
69
- * render path, where only an `ExperienceProvider` is mounted) it falls back to resolving the
70
- * experience's layout content, so slot-rendered components read content without crashing.
71
- * Subscribes via `useStoreGlobal`, so the component re-renders on content updates.
83
+ * The optional `K` type argument is compile-time narrowing only. It asserts which step the
84
+ * caller renders; runtime data always comes from the current step context.
72
85
  *
73
- * @returns {Record<string, unknown> | null} The Content record's `data`, or `null`.
86
+ * @returns {StepLayoutContent | null} The Content record's `data`, or `null`.
74
87
  * @example
75
88
  * const content = useStepContent()
76
89
  */
77
- export declare function useStepContent(): Record<string, unknown> | null;
90
+ export declare function useStepContent(): StepLayoutContent | null;
91
+ /**
92
+ * Returns the current step's CMS content narrowed by an asserted step key.
93
+ *
94
+ * @template K
95
+ * @returns {ContentForStep<K> | null} Narrowed content data, or `null`.
96
+ * @example
97
+ * const content = useStepContent<'main'>()
98
+ */
99
+ export declare function useStepContent<K extends keyof StepContentModelsMap>(): ContentForStep<K> | null;
78
100
  //# 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;AACpD,OAAO,EAAoB,KAAK,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAEvF,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;;;;;;OAMG;IACH,OAA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f as t,it as n}from"vitest";e(`typed hooks (augmented registry)`,()=>{n(`narrows content and field value types from the registry`,()=>{t().toEqualTypeOf(),t().toEqualTypeOf(),t().toEqualTypeOf()}),n(`reports exactly the keys the workspace declares`,()=>{t().toEqualTypeOf(),t().toEqualTypeOf(),t().toEqualTypeOf(),t().toEqualTypeOf(),t().toEqualTypeOf()}),n(`accepts a key defined in the application rather than the workspace`,()=>{t(`a-feature-from-createClient`).toExtend(),t(`a-locally-registered-step`).toExtend(),t(`a-locally-registered-experience`).toExtend(),t(`an-action-the-app-registers`).toExtend(),t(`a-locally-registered-field`).toExtend()}),n(`keeps the workspace keys inside the open unions, so an editor still suggests them`,()=>{t().toExtend(),t().toExtend(),t().toExtend()}),n(`narrows form callback data values to the field schema type`,()=>{t().toEqualTypeOf(),t().toEqualTypeOf()}),n(`type-checks known response keys while leaving unknown keys permissive`,()=>{t().toEqualTypeOf(),t().toEqualTypeOf()})});
@@ -0,0 +1 @@
1
+ import{useContent as e}from"./content.js";import{describe as t,expectTypeOf as n,it as r}from"vitest";t(`typed hooks (unaugmented registry)`,()=>{r(`falls back to loose types when the registry is empty`,()=>{n().toExtend(),n().toExtend(),n().toExtend(),n().toExtend(),n().toExtend(),n().toExtend(),n().toEqualTypeOf(),n().toExtend(),n().toEqualTypeOf(),n().toEqualTypeOf()}),r(`accepts a generated-style type alias for the content escape hatch`,()=>{n(e(`lc_x`)).toEqualTypeOf()})});
@@ -0,0 +1 @@
1
+ import{describe as e,expectTypeOf as t,it as n}from"vitest";e(`public form types`,()=>{n(`exports ReactFormField from the hooks entry`,()=>{t().toEqualTypeOf()}),n(`exports the same ReactFormField from the form entry`,()=>{t().toEqualTypeOf()}),n(`keeps the field props reachable for renderers`,()=>{t().toEqualTypeOf()})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@picked/react",
3
- "version": "0.0.73",
3
+ "version": "0.0.74-next.1",
4
4
  "devDependencies": {
5
5
  "@picked/client": "workspace:*",
6
6
  "@repo/eslint-config": "workspace:*",
@@ -69,7 +69,9 @@
69
69
  "src/plugins/framework/index.ts"
70
70
  ],
71
71
  "ignore": [
72
- "eslint.config.js"
72
+ "eslint.config.js",
73
+ "**/*.test-d.ts",
74
+ "src/hooks/fixtures/**"
73
75
  ],
74
76
  "ignoreBinaries": [
75
77
  "attw",
@@ -86,7 +88,7 @@
86
88
  },
87
89
  "module": "./dist/index.js",
88
90
  "peerDependencies": {
89
- "@picked/client": "0.0.73",
91
+ "@picked/client": "0.0.74-next.1",
90
92
  "effector": "^23.4.4",
91
93
  "react": "^18.3.0 || ^19.0.0",
92
94
  "react-dom": "^18.3.0 || ^19.0.0"
@@ -108,7 +110,7 @@
108
110
  "test:coverage": "../../scripts/vitest-coverage.sh",
109
111
  "test:packaged-types": "attw --pack",
110
112
  "test:watch": "vitest",
111
- "type-check": "tsgo -p . --noEmit && tsgo -p tsconfig.react18.json --noEmit"
113
+ "type-check": "tsgo -p . --noEmit && tsgo -p tsconfig.react18.json --noEmit && tsgo -p tsconfig.test-d.json --noEmit"
112
114
  },
113
115
  "size-limit": [
114
116
  {
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=HtmlRender.preview.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HtmlRender.preview.test.d.ts","sourceRoot":"","sources":["../../src/experience/HtmlRender.preview.test.tsx"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=HtmlRender.server.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HtmlRender.server.test.d.ts","sourceRoot":"","sources":["../../src/experience/HtmlRender.server.test.tsx"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=HtmlRender.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HtmlRender.test.d.ts","sourceRoot":"","sources":["../../src/experience/HtmlRender.test.tsx"],"names":[],"mappings":""}
@@ -1,17 +0,0 @@
1
- /** @file Test fixture: a trivial experience component that renders its instance id. */
2
- import type { ExperienceInstance } from '@picked/client';
3
- interface TestExperienceProps {
4
- readonly experience: ExperienceInstance;
5
- }
6
- /**
7
- * Renders the experience instance id so tests can assert which experiences mounted.
8
- *
9
- * @param {TestExperienceProps} props - The component props.
10
- * @param {ExperienceInstance} props.experience - The experience instance whose id is rendered.
11
- * @returns {React.JSX.Element} A node containing the experience id.
12
- * @example
13
- * <TestExperience experience={instance} />
14
- */
15
- declare function TestExperience({ experience }: TestExperienceProps): React.JSX.Element;
16
- export default TestExperience;
17
- //# sourceMappingURL=TestExperience.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TestExperience.d.ts","sourceRoot":"","sources":["../../../src/experience/__fixtures__/TestExperience.tsx"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAExD,UAAU,mBAAmB;IAC3B,QAAQ,CAAC,UAAU,EAAE,kBAAkB,CAAA;CACxC;AAED;;;;;;;;GAQG;AACH,iBAAS,cAAc,CAAC,EAAE,UAAU,EAAE,EAAE,mBAAmB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAE9E;eAEc,cAAc"}
@@ -1,50 +0,0 @@
1
- /** @file Test fixtures: minimal project configs and snapshots for the SSR component tests. */
2
- import { type PickedSnapshot, type ProjectConfig, type ProjectConfigExperience } from '@picked/client/server';
3
- import type { ExperienceTarget } from '@picked/client';
4
- type ConditionRule = ProjectConfigExperience['condition'];
5
- /** A JSON-logic rule that always evaluates truthy, used as a stand-in experience condition. */
6
- export declare const PASSING_RULE: ConditionRule;
7
- /**
8
- * Builds a minimal `ProjectConfigExperience` targeting the page slot with the given placement.
9
- *
10
- * @param {object} overrides - Experience overrides.
11
- * @param {string} overrides.id - The experience id.
12
- * @param {string} overrides.key - The experience key.
13
- * @param {ExperienceTarget['placement']} overrides.placement - The slot placement.
14
- * @param {ConditionRule} [overrides.condition] - The experience's decision logic.
15
- * @param {string} [overrides.selector] - The target selector (defaults to the page slot).
16
- * @returns {ProjectConfigExperience} A minimal experience config.
17
- * @example
18
- * buildExperience({ id: 'exp-1', key: 'hero', placement: 'append', condition: PASSING_RULE })
19
- */
20
- export declare function buildExperience(overrides: {
21
- id: string;
22
- key: string;
23
- placement: ExperienceTarget['placement'];
24
- condition?: ConditionRule;
25
- selector?: string;
26
- }): ProjectConfigExperience;
27
- /**
28
- * Builds a minimal `ProjectConfig` containing the given experiences and (optionally) named
29
- * conditions referenced by composition.
30
- *
31
- * @param {ProjectConfigExperience[]} experiences - The experiences to include.
32
- * @param {ProjectConfig['conditions']} [conditions] - Named conditions registered for composition.
33
- * @returns {ProjectConfig} A minimal project config.
34
- * @example
35
- * buildProjectConfig([buildExperience({ id: 'exp-1', key: 'hero', placement: 'append' })])
36
- */
37
- export declare function buildProjectConfig(experiences: ProjectConfigExperience[], conditions?: ProjectConfig['conditions']): ProjectConfig;
38
- /**
39
- * Builds a plain-JSON SSR snapshot whose `conditionResults` seed marks each experience's
40
- * condition active or inactive by rule hash.
41
- *
42
- * @param {ProjectConfig} projectConfig - The project config to snapshot.
43
- * @param {Record<string, boolean>} resultsByExperienceId - Active flags keyed by experience id.
44
- * @returns {PickedSnapshot} A snapshot with seeded condition results.
45
- * @example
46
- * buildSnapshot(config, { 'exp-1': true })
47
- */
48
- export declare function buildSnapshot(projectConfig: ProjectConfig, resultsByExperienceId: Record<string, boolean>): PickedSnapshot;
49
- export {};
50
- //# sourceMappingURL=project-config.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"project-config.d.ts","sourceRoot":"","sources":["../../../src/experience/__fixtures__/project-config.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,uBAAuB,EAC7B,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAEtD,KAAK,aAAa,GAAG,uBAAuB,CAAC,WAAW,CAAC,CAAA;AAEzD,+FAA+F;AAC/F,eAAO,MAAM,YAAY,EAAE,aAAgC,CAAA;AAK3D;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE;IACzC,EAAE,EAAE,MAAM,CAAA;IACV,GAAG,EAAE,MAAM,CAAA;IACX,SAAS,EAAE,gBAAgB,CAAC,WAAW,CAAC,CAAA;IACxC,SAAS,CAAC,EAAE,aAAa,CAAA;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,GAAG,uBAAuB,CAY1B;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,uBAAuB,EAAE,EACtC,UAAU,GAAE,aAAa,CAAC,YAAY,CAAM,GAC3C,aAAa,CAcf;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAC3B,aAAa,EAAE,aAAa,EAC5B,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7C,cAAc,CAehB"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=experience.server.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"experience.server.test.d.ts","sourceRoot":"","sources":["../../src/experience/experience.server.test.tsx"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=experience.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"experience.test.d.ts","sourceRoot":"","sources":["../../src/experience/experience.test.tsx"],"names":[],"mappings":""}
@@ -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=use-form-callbacks.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-form-callbacks.test.d.ts","sourceRoot":"","sources":["../../src/form/use-form-callbacks.test.tsx"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=reference.test.d.ts.map