@picked/react 0.0.1-dev.1789541668638 → 0.0.1-next.2

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 (98) hide show
  1. package/dist/component.d.ts +5 -5
  2. package/dist/component.d.ts.map +1 -1
  3. package/dist/component.js +1 -1
  4. package/dist/context.d.ts +75 -5
  5. package/dist/context.d.ts.map +1 -1
  6. package/dist/context.js +1 -1
  7. package/dist/form/index.d.ts +13 -47
  8. package/dist/form/index.d.ts.map +1 -1
  9. package/dist/form/index.js +1 -1
  10. package/dist/hooks/client.d.ts +9 -9
  11. package/dist/hooks/client.d.ts.map +1 -1
  12. package/dist/hooks/client.js +1 -1
  13. package/dist/hooks/field.d.ts +5 -17
  14. package/dist/hooks/field.d.ts.map +1 -1
  15. package/dist/hooks/field.js +1 -1
  16. package/dist/hooks/index.d.ts +2 -14
  17. package/dist/hooks/index.d.ts.map +1 -1
  18. package/dist/hooks/index.js +1 -1
  19. package/dist/hooks/step.d.ts +21 -96
  20. package/dist/hooks/step.d.ts.map +1 -1
  21. package/dist/hooks/step.js +1 -1
  22. package/dist/hooks/storage.d.ts +1 -1
  23. package/dist/hooks/storage.js +1 -1
  24. package/dist/index.d.ts +0 -6
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +1 -1
  27. package/dist/plugins/framework/index.js +1 -1
  28. package/dist/plugins/framework/plugin.d.ts +4 -4
  29. package/dist/plugins/framework/plugin.d.ts.map +1 -1
  30. package/dist/plugins/framework/plugin.js +1 -1
  31. package/dist/render/browser.d.ts +2 -2
  32. package/dist/render/browser.d.ts.map +1 -1
  33. package/dist/render/browser.js +1 -1
  34. package/dist/render/server.d.ts +1 -1
  35. package/dist/render/server.d.ts.map +1 -1
  36. package/dist/render/server.js +1 -1
  37. package/dist/router/Step.js +1 -1
  38. package/dist/router/StepRouter.js +1 -1
  39. package/dist/router/context.d.ts +2 -2
  40. package/dist/router/context.d.ts.map +1 -1
  41. package/dist/router/context.js +1 -1
  42. package/dist/router/index.js +1 -1
  43. package/dist/server/index.d.ts +2 -2
  44. package/dist/server/index.js +1 -1
  45. package/dist/utils/array.d.ts.map +1 -1
  46. package/dist/utils/array.js +1 -1
  47. package/package.json +33 -92
  48. package/dist/.tsbuildinfo +0 -1
  49. package/dist/experience/ExperienceHost.d.ts +0 -34
  50. package/dist/experience/ExperienceHost.d.ts.map +0 -1
  51. package/dist/experience/ExperienceHost.js +0 -1
  52. package/dist/experience/ExperienceSlot.d.ts +0 -35
  53. package/dist/experience/ExperienceSlot.d.ts.map +0 -1
  54. package/dist/experience/ExperienceSlot.js +0 -1
  55. package/dist/experience/HtmlRender.d.ts +0 -33
  56. package/dist/experience/HtmlRender.d.ts.map +0 -1
  57. package/dist/experience/HtmlRender.js +0 -1
  58. package/dist/experience/PickedProvider.d.ts +0 -42
  59. package/dist/experience/PickedProvider.d.ts.map +0 -1
  60. package/dist/experience/PickedProvider.js +0 -1
  61. package/dist/experience/morph.d.ts +0 -26
  62. package/dist/experience/morph.d.ts.map +0 -1
  63. package/dist/experience/morph.js +0 -1
  64. package/dist/form/use-form-callbacks.d.ts +0 -45
  65. package/dist/form/use-form-callbacks.d.ts.map +0 -1
  66. package/dist/form/use-form-callbacks.js +0 -1
  67. package/dist/hooks/action.d.ts +0 -39
  68. package/dist/hooks/action.d.ts.map +0 -1
  69. package/dist/hooks/action.js +0 -1
  70. package/dist/hooks/content.d.ts +0 -24
  71. package/dist/hooks/content.d.ts.map +0 -1
  72. package/dist/hooks/content.js +0 -1
  73. package/dist/hooks/feature.d.ts +0 -45
  74. package/dist/hooks/feature.d.ts.map +0 -1
  75. package/dist/hooks/feature.js +0 -1
  76. package/dist/hooks/fixtures/augmented-registry.d.js +0 -0
  77. package/dist/hooks/reference.d.ts +0 -56
  78. package/dist/hooks/reference.d.ts.map +0 -1
  79. package/dist/hooks/reference.js +0 -1
  80. package/dist/hooks/typed-hooks-augmented.test-d.js +0 -1
  81. package/dist/hooks/typed-hooks.test-d.js +0 -1
  82. package/dist/hooks/use-store-global.d.ts +0 -24
  83. package/dist/hooks/use-store-global.d.ts.map +0 -1
  84. package/dist/hooks/use-store-global.js +0 -1
  85. package/dist/public-types.test-d.js +0 -1
  86. package/dist/router/Step.d.ts +0 -25
  87. package/dist/router/Step.d.ts.map +0 -1
  88. package/dist/router/StepRouter.d.ts +0 -17
  89. package/dist/router/StepRouter.d.ts.map +0 -1
  90. package/dist/utils/map-field-to-react.d.ts +0 -33
  91. package/dist/utils/map-field-to-react.d.ts.map +0 -1
  92. package/dist/utils/map-field-to-react.js +0 -1
  93. package/dist/utils/prepare-native-event.d.ts +0 -17
  94. package/dist/utils/prepare-native-event.d.ts.map +0 -1
  95. package/dist/utils/prepare-native-event.js +0 -1
  96. package/dist/utils/restore-current-target.d.ts +0 -17
  97. package/dist/utils/restore-current-target.d.ts.map +0 -1
  98. package/dist/utils/restore-current-target.js +0 -1
@@ -1,10 +1,10 @@
1
- import type { AdaptedComponent, AdaptedComponentStyle, LazyComponentLoader } from '@picked/client';
2
- import type { ComponentType } from 'react';
1
+ import { AdaptedComponent, AdaptedComponentStyle } from '@picked/client';
2
+ import { ComponentType } from 'react';
3
3
  export type ComponentWithProps = ComponentType<any>;
4
4
  export declare const adaptReactComponent: (component: ComponentWithProps | Promise<{
5
5
  default: ComponentWithProps;
6
- }> | LazyComponentLoader<ComponentWithProps>, style?: AdaptedComponentStyle) => AdaptedComponent<'react', ComponentWithProps | Promise<{
6
+ }>, style?: AdaptedComponentStyle) => AdaptedComponent<"react", ComponentWithProps | Promise<{
7
7
  default: ComponentWithProps;
8
- }> | LazyComponentLoader<ComponentWithProps>>;
9
- export declare const isValidAdaptedComponent: (component: AdaptedComponent<string, unknown>) => component is AdaptedComponent<'react', ComponentWithProps>;
8
+ }>>;
9
+ export declare const isValidAdaptedComponent: (component: AdaptedComponent<string, unknown>) => component is AdaptedComponent<"react", ComponentWithProps>;
10
10
  //# sourceMappingURL=component.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../src/component.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AAClG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAE1C,MAAM,MAAM,kBAAkB,GAAG,aAAa,CAAC,GAAG,CAAC,CAAA;AAKnD,eAAO,MAAM,mBAAmB,cAE1B,kBAAkB,GAClB,OAAO,CAAC;IAAE,OAAO,EAAE,kBAAkB,CAAA;CAAE,CAAC,GACxC,mBAAmB,CAAC,kBAAkB,CAAC,UACnC,qBAAqB,KAC5B,gBAAgB,CACjB,OAAO,EACL,kBAAkB,GAClB,OAAO,CAAC;IAAE,OAAO,EAAE,kBAAkB,CAAA;CAAE,CAAC,GACxC,mBAAmB,CAAC,kBAAkB,CAAC,CAO1C,CAAA;AAED,eAAO,MAAM,uBAAuB,cACvB,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,KAC3C,SAAS,IAAI,gBAAgB,CAAC,OAAO,EAAE,kBAAkB,CAE3D,CAAA"}
1
+ {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../src/component.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAA;AAC7E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAE1C,MAAM,MAAM,kBAAkB,GAAG,aAAa,CAAC,GAAG,CAAC,CAAA;AAKnD,eAAO,MAAM,mBAAmB,GAC9B,WAAW,kBAAkB,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,kBAAkB,CAAA;CAAE,CAAC,EACxE,QAAQ,qBAAqB,KAC5B,gBAAgB,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,kBAAkB,CAAA;CAAE,CAAC,CAMzF,CAAA;AAED,eAAO,MAAM,uBAAuB,GAClC,WAAW,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,KAC3C,SAAS,IAAI,gBAAgB,CAAC,OAAO,EAAE,kBAAkB,CAE3D,CAAA"}
package/dist/component.js CHANGED
@@ -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};
1
+ const a=(e,t)=>({frameworkName:"react",component:e,style:t}),r=e=>e.frameworkName==="react";export{a as adaptReactComponent,r as isValidAdaptedComponent};
package/dist/context.d.ts CHANGED
@@ -1,6 +1,76 @@
1
- import type { ExperienceInstance, Picked } from '@picked/client';
2
- export declare const ClientContext: import("react").Context<Picked | null>;
3
- export declare const ClientProvider: import("react").Provider<Picked | null>;
4
- export declare const ExperienceContext: import("react").Context<ExperienceInstance | null>;
5
- export declare const ExperienceProvider: import("react").Provider<ExperienceInstance | null>;
1
+ import { Picked } from '@picked/client';
2
+ export declare const ClientContext: import('react').Context<Picked | null>;
3
+ export declare const ClientProvider: import('react').Provider<Picked | null>;
4
+ export declare const ExperienceContext: import('react').Context<{
5
+ experienceId: string;
6
+ configStore: import('effector').Store<{
7
+ type: string;
8
+ name: string;
9
+ decisionLogic: import('node_modules/@picked/client/dist/types/logic-engine').LogicRule | undefined;
10
+ targetSelectors: import('@picked/client').ExperienceTarget[];
11
+ }>;
12
+ target: HTMLElement | undefined;
13
+ componentStore: import('effector').Store<{
14
+ name: string;
15
+ component: import('@picked/client').AdaptedComponent<string, unknown>;
16
+ frameworkStore: import('effector').Store<import('@picked/client').Framework | undefined>;
17
+ } | undefined>;
18
+ stateStore: import('effector').StoreWritable<"transitioning" | "ready">;
19
+ isOpenStore: import('effector').StoreWritable<boolean>;
20
+ open: import('effector').EventCallable<void>;
21
+ close: import('effector').EventCallable<void>;
22
+ toggleOpen: import('effector').EventCallable<void>;
23
+ setOpen: import('effector').EventCallable<boolean>;
24
+ treeStore: import('effector').Store<{
25
+ steps: import('@picked/client').ExperienceStep[];
26
+ nodes: import('@picked/client').ExperienceNode[];
27
+ edges: import('@picked/client').ExperienceEdge[];
28
+ conditionals: import('@picked/client').ExperienceConditional[];
29
+ }>;
30
+ currentNodeStore: import('effector').Store<import('@picked/client').ExperienceNode | null>;
31
+ currentStepStore: import('effector').Store<import('@picked/client').ExperienceStep | null>;
32
+ nextReachableStepNodesStore: import('effector').Store<import('@picked/client').ExperienceNode[]>;
33
+ stepsToOriginStore: import('effector').Store<number[]>;
34
+ stepsToLeafStore: import('effector').Store<number[]>;
35
+ goToNextStep: import('effector').EventCallable<void>;
36
+ goToPreviousStep: import('effector').EventCallable<void>;
37
+ goToStepById: import('effector').EventCallable<string>;
38
+ stepsHistoryStore: import('effector').Store<import('@picked/client').HistoryEntry[]>;
39
+ } | null>;
40
+ export declare const ExperienceProvider: import('react').Provider<{
41
+ experienceId: string;
42
+ configStore: import('effector').Store<{
43
+ type: string;
44
+ name: string;
45
+ decisionLogic: import('node_modules/@picked/client/dist/types/logic-engine').LogicRule | undefined;
46
+ targetSelectors: import('@picked/client').ExperienceTarget[];
47
+ }>;
48
+ target: HTMLElement | undefined;
49
+ componentStore: import('effector').Store<{
50
+ name: string;
51
+ component: import('@picked/client').AdaptedComponent<string, unknown>;
52
+ frameworkStore: import('effector').Store<import('@picked/client').Framework | undefined>;
53
+ } | undefined>;
54
+ stateStore: import('effector').StoreWritable<"transitioning" | "ready">;
55
+ isOpenStore: import('effector').StoreWritable<boolean>;
56
+ open: import('effector').EventCallable<void>;
57
+ close: import('effector').EventCallable<void>;
58
+ toggleOpen: import('effector').EventCallable<void>;
59
+ setOpen: import('effector').EventCallable<boolean>;
60
+ treeStore: import('effector').Store<{
61
+ steps: import('@picked/client').ExperienceStep[];
62
+ nodes: import('@picked/client').ExperienceNode[];
63
+ edges: import('@picked/client').ExperienceEdge[];
64
+ conditionals: import('@picked/client').ExperienceConditional[];
65
+ }>;
66
+ currentNodeStore: import('effector').Store<import('@picked/client').ExperienceNode | null>;
67
+ currentStepStore: import('effector').Store<import('@picked/client').ExperienceStep | null>;
68
+ nextReachableStepNodesStore: import('effector').Store<import('@picked/client').ExperienceNode[]>;
69
+ stepsToOriginStore: import('effector').Store<number[]>;
70
+ stepsToLeafStore: import('effector').Store<number[]>;
71
+ goToNextStep: import('effector').EventCallable<void>;
72
+ goToPreviousStep: import('effector').EventCallable<void>;
73
+ goToStepById: import('effector').EventCallable<string>;
74
+ stepsHistoryStore: import('effector').Store<import('@picked/client').HistoryEntry[]>;
75
+ } | null>;
6
76
  //# sourceMappingURL=context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAEhE,eAAO,MAAM,aAAa,wCAAqC,CAAA;AAC/D,eAAO,MAAM,cAAc,yCAAyB,CAAA;AAEpD,eAAO,MAAM,iBAAiB,oDAAiD,CAAA;AAC/E,eAAO,MAAM,kBAAkB,qDAA6B,CAAA"}
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAsB,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAEhE,eAAO,MAAM,aAAa,wCAAqC,CAAA;AAC/D,eAAO,MAAM,cAAc,yCAAyB,CAAA;AAEpD,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAAiD,CAAA;AAC/E,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAA6B,CAAA"}
package/dist/context.js CHANGED
@@ -1 +1 @@
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};
1
+ import{createContext as e}from"react";const t=e(null),n=t.Provider,o=e(null),i=o.Provider;export{t as ClientContext,n as ClientProvider,o as ExperienceContext,i as ExperienceProvider};
@@ -1,50 +1,16 @@
1
- /** @file React `useForm` hook — thin adapter over createForm from `@picked/client/form`. */
2
- import { type FormEvent } from 'react';
3
- import type { Store } from 'effector';
4
- import { type ErrorCallback, type FormInstance as CoreFormInstance, type SubmitCallback, type SuccessCallback } from '@picked/client/form';
5
- import { type ReactFormField } from '../utils/map-field-to-react';
6
- import { type FormCallbackOptions, type FormCallbackRegistrars } from './use-form-callbacks';
7
- export type { FormCallbackOptions, FormCallbackRegistrars, FormCallbackChannel, } from './use-form-callbacks';
8
- export type { ReactFormField, ReactFormFieldProps } from '../utils/map-field-to-react';
9
- export interface FormInstance<TFieldKeys extends string = string> {
1
+ import { ValidationError } from '@picked/client';
2
+ interface GetFormOptions {
3
+ id: string;
4
+ title: string;
5
+ onSuccess?: () => void | Promise<void>;
6
+ onError?: (errors: ValidationError[]) => void | Promise<void>;
7
+ }
8
+ export declare function useForm(options: GetFormOptions): {
10
9
  form: {
11
- props: {
12
- onSubmit: (e: FormEvent<HTMLFormElement>) => void;
13
- };
14
- errors: CoreFormInstance['form']['errors'];
15
- submitting: CoreFormInstance['form']['submitting'];
16
- onBeforeSubmit: (callback: SubmitCallback<TFieldKeys>) => void;
17
- onSuccess: (callback: SuccessCallback<TFieldKeys>) => void;
18
- onError: (callback: ErrorCallback) => void;
10
+ onsubmit: (event: SubmitEvent & {
11
+ currentTarget: EventTarget & HTMLFormElement;
12
+ }) => Promise<void>;
19
13
  };
20
- fields: Store<ReactFormField[]>;
21
- /**
22
- * Raw core registrars, so a hook that owns its own callback channel (`useStep`)
23
- * can register its dispatcher directly against the core rather than nesting
24
- * inside this hook's channel. Internal: not part of the supported surface.
25
- */
26
- formRegistrars: FormCallbackRegistrars;
27
- }
28
- /**
29
- * React hook mirroring Svelte's `createForm`: accepts reactive stores for
30
- * `title` and `fieldKeys` and returns a React-adapted form instance.
31
- *
32
- * The form is a stateful object (typed values, errors, subscribers) whose
33
- * lifetime is the hook instance, not the render — so `title` and `fieldKeys`
34
- * are stores (reactive access over time) rather than values (snapshots).
35
- *
36
- * Callback lifetime is the hook instance, not the render: `onBeforeSubmit` /
37
- * `onSuccess` / `onError` are safe to call from a render body and return `void`,
38
- * because cleanup happens automatically when the hook unmounts. Prefer the
39
- * `options` argument — it is latest-wins and has no registration side effect at
40
- * all. See `use-form-callbacks.ts` for how this is achieved.
41
- *
42
- * @param {string} formId - Stable identifier for the form.
43
- * @param {Store<string>} title - Store holding the form/step title.
44
- * @param {Store<string[]>} fieldKeys - Store of field keys belonging to this form.
45
- * @param {FormCallbackOptions} [options] - Latest-wins submit callback slots.
46
- * @returns {FormInstance} React form with submit handler, mapped fields, and subscribable callbacks.
47
- * @example const { form, fields } = useForm(stepKey, nameStore, fieldKeysStore, { onSuccess })
48
- */
49
- export declare function useForm(formId: string, title: Store<string>, fieldKeys: Store<string[]>, options?: FormCallbackOptions): FormInstance;
14
+ };
15
+ export {};
50
16
  //# sourceMappingURL=index.d.ts.map
@@ -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,YAAY,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AAEtF,MAAM,WAAW,YAAY,CAAC,UAAU,SAAS,MAAM,GAAG,MAAM;IAC9D,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,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
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/form/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAqB,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAQxE,UAAU,cAAc;IACtB,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACtC,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,EAAE,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAC9D;AAED,wBAAgB,OAAO,CAAC,OAAO,EAAE,cAAc;;0BAKd,WAAW,GAAG;YAAE,aAAa,EAAE,WAAW,GAAG,eAAe,CAAA;SAAE;;EAyG9F"}
@@ -1 +1 @@
1
- import{useExperience as e,usePicked as t}from"../hooks/client.js";import{mapFieldToReact as n}from"../utils/map-field-to-react.js";import{prepareNativeEvent as r}from"../utils/prepare-native-event.js";import{useFormCallbacks as i}from"./use-form-callbacks.js";import{useMemo as a}from"react";import{createForm as o}from"@picked/client/form";function s(s,c,l,u){let d=t(),f=e(),p=a(()=>o({client:d,experienceInstance:f},s,c,l),[d,f,s,c,l]),m=a(()=>p.fields.map(e=>e.map(n)),[p]),h=a(()=>({onBeforeSubmit:e=>p.form.onBeforeSubmit(e),onSuccess:e=>p.form.onSuccess(e),onError:e=>p.form.onError(e)}),[p]),g=i(h,u);return{form:a(()=>({errors:p.form.errors,submitting:p.form.submitting,props:{onSubmit:e=>{e.preventDefault(),r(e.nativeEvent,e.currentTarget),p.form.props.onsubmit(e.nativeEvent)}},onBeforeSubmit:g.onBeforeSubmit,onSuccess:g.onSuccess,onError:g.onError}),[p,g]),fields:m,formRegistrars:h}}export{s as useForm};
1
+ import{usePicked as v,useExperience as y}from"../hooks/client.js";import"../hooks/step.js";import"react";import"@picked/client";function _(a){const s=v();y();const{id:n,title:o}=a;async function d(c){var f,m;c.preventDefault(),s.eventBus({type:"form_submit",form:{id:n,title:o}});const p=new FormData(c.currentTarget),i={data:{},push(t){const r=t.questionId,e=this.data[r];e?Array.isArray(e)&&Array.isArray(t.value)?Array.isArray(e)&&Array.isArray(t.value)&&(typeof e[0]=="string"?this.data[r]=[...e,...t.value].map(String):typeof e[0]=="number"?this.data[r]=[...e,...t.value].map(Number):typeof e[0]=="boolean"?this.data[r]=[...e,...t.value].map(u=>!!u):this.data[r]=t.value):this.data[r]=t.value:this.data[r]=t.value}};for(const[t,r]of p.entries()){const e=s.fields.getById(t).getState();if(!e)continue;const u=e.id;switch(e.type){case"text":i.push({questionId:u,value:e.multiple?[String(r)]:String(r)});break;case"number":i.push({questionId:u,value:e.multiple?[Number(r)]:Number(r)});break;case"boolean":i.push({questionId:u,value:e.multiple?[r==="true"]:r==="true"});break}}const{errors:l}=await s.responses.commit(i.data);if(l.length>0){s.eventBus({type:"form_submit_error",form:{id:n,title:o},exception:"Form validation error"}),l.forEach(t=>{s.eventBus({type:"field_validation_error",exception:t})}),await((f=a.onError)==null?void 0:f.call(a,l));return}s.eventBus({type:"form_submit_success",form:{id:n,title:o}}),await((m=a.onSuccess)==null?void 0:m.call(a))}return{form:{onsubmit:d}}}export{_ as useForm};
@@ -1,16 +1,16 @@
1
- import type { ExperienceInstance, Picked } from '@picked/client';
1
+ import { ExperienceInstance, Picked } from '@picked/client';
2
2
  /**
3
- * Retrieves the Picked Client for the Experience Instance.
4
- * @returns The Picked client instance that provides access to experiences, steps, and other Picked functionality.
5
- * @example
6
- * const client = usePicked()
3
+ * Retrieves the Picked Client for the Experience Instance
4
+ *
5
+ * @returns The Picked client instance that provides access to experiences, steps, and other Picked functionality
7
6
  */
8
7
  export declare function usePicked(): Picked;
9
8
  /**
10
- * Retrieves the Experience Store for the current Experience Instance.
11
- * @returns The Experience store instance that provides access to experience configuration and state.
12
- * @example
13
- * const experience = useExperience()
9
+ * Retrieves the Experience Store for the current Experience Instance
10
+ *
11
+ * @returns The Experience store instance that provides access to experience configuration and state
14
12
  */
15
13
  export declare function useExperience(): ExperienceInstance;
14
+ export declare const getPicked: typeof usePicked;
15
+ export declare const getExperience: typeof useExperience;
16
16
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/hooks/client.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAGhE;;;;;GAKG;AACH,wBAAgB,SAAS,IAAI,MAAM,CAOlC;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,IAAI,kBAAkB,CAOlD"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/hooks/client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAGhE;;;;GAIG;AACH,wBAAgB,SAAS,IAAI,MAAM,CAOlC;AAED;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,kBAAkB,CAOlD;AAGD,eAAO,MAAM,SAAS,kBAAY,CAAA;AAClC,eAAO,MAAM,aAAa,sBAAgB,CAAA"}
@@ -1 +1 @@
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}export{i as useExperience,r as usePicked};
1
+ import{useContext as t}from"react";import{ClientContext as n,ExperienceContext as r}from"../context.js";function i(){const e=t(n);if(!e)throw new Error("usePicked must be used within a ClientProvider");return e}function o(){const e=t(r);if(!e)throw new Error("useExperience must be used within an ExperienceProvider");return e}const u=i,x=o;export{x as getExperience,u as getPicked,o as useExperience,i as usePicked};
@@ -1,20 +1,8 @@
1
- /**
2
- * @file React hook for accessing individual field data and response values from the Picked client.
3
- */
4
- import type { Field, FieldKeys, FieldValueFor } from '@picked/client';
5
- import type { Store } from 'effector';
6
- export interface GetFieldResponse<K extends FieldKeys = FieldKeys> {
7
- value: Store<FieldValueFor<K>>;
1
+ import { Field, FieldValue } from '@picked/client';
2
+ import { Store } from 'effector';
3
+ export interface GetFieldResponse {
4
+ value: Store<FieldValue>;
8
5
  field: Store<Field | null>;
9
6
  }
10
- /**
11
- * Returns reactive stores for a field definition and its current response value.
12
- *
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')
18
- */
19
- export declare function getField<K extends FieldKeys>(key: K): GetFieldResponse<K>;
7
+ export declare function getField(id: string): GetFieldResponse;
20
8
  //# 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,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"}
1
+ {"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../../src/hooks/field.ts"],"names":[],"mappings":"AAAA,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,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,gBAAgB,CAQrD"}
@@ -1 +1 @@
1
- import{usePicked as e}from"./client.js";function t(t){let n=e();return{field:n.fields.getByKey(t),value:n.responses.getByFieldKey(t)}}export{t as getField};
1
+ import{getPicked as s}from"./client.js";function r(e){const t=s(),n=t.fields.getById(e),o=t.responses.getByFieldId(e);return{field:n,value:o}}export{r as getField};
@@ -1,17 +1,5 @@
1
- /**
2
- * @file Public re-exports for the hooks entry point.
3
- */
4
- export { ClientContext, ClientProvider, ExperienceContext, ExperienceProvider } from '../context';
5
- export { usePicked, useExperience } from './client';
6
- export { useStoreGlobal } from './use-store-global';
7
- export { useStep, useSetStepContext, useStepContent } from './step';
8
- export type { StepContext } from './step';
9
- export type { ReactFormField, ReactFormFieldProps } from '../utils/map-field-to-react';
1
+ export { usePicked, useExperience, getPicked, getExperience } from './client';
2
+ export { useStep, useSetStepContext } from './step';
10
3
  export { useSessionStorage, useLocalStorage } from './storage';
11
- export type { UseStorageOptions } from './storage';
12
4
  export * from './field';
13
- export { useFeature, useFeatureResult, useFeatureEnabled } from './feature';
14
- export { useAction, useActionResult } from './action';
15
- export { useContent } from './content';
16
- export { useReference, useReferences } from './reference';
17
5
  //# 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,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
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAC7E,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAA;AACnD,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAC9D,cAAc,SAAS,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{useStoreGlobal as o}from"./use-store-global.js";import{useSetStepContext as s,useStep as c,useStepContent as l}from"./step.js";import{useLocalStorage as u,useSessionStorage as d}from"./storage.js";import{getField as f}from"./field.js";import{useFeature as p,useFeatureEnabled as m,useFeatureResult as h}from"./feature.js";import{useAction as g,useActionResult as _}from"./action.js";import{useContent as v}from"./content.js";import{useReference as y,useReferences as b}from"./reference.js";export{e as ClientContext,t as ClientProvider,n as ExperienceContext,r as ExperienceProvider,f as getField,g as useAction,_ as useActionResult,v as useContent,i as useExperience,p as useFeature,m as useFeatureEnabled,h as useFeatureResult,u as useLocalStorage,a as usePicked,y as useReference,b as useReferences,d as useSessionStorage,s as useSetStepContext,c as useStep,l as useStepContent,o as useStoreGlobal};
1
+ import{getExperience as o,getPicked as r,useExperience as p,usePicked as s}from"./client.js";import{useSetStepContext as i,useStep as u}from"./step.js";import{useLocalStorage as c,useSessionStorage as g}from"./storage.js";import{getField as m}from"./field.js";export{o as getExperience,m as getField,r as getPicked,p as useExperience,c as useLocalStorage,s as usePicked,g as useSessionStorage,i as useSetStepContext,u as useStep};
@@ -1,100 +1,25 @@
1
- import { type Store } from 'effector';
2
- import type { Content, ContentForStep, ExperienceStep, FieldKeysForStep, StepContentModelsMap, StepKeys, StepLayoutContent } from '@picked/client';
3
- import { type FormInstance } from '../form';
4
- import { type FormCallbackOptions } from '../form/use-form-callbacks';
5
- import type { ReactFormField } from '../utils/map-field-to-react';
6
- export interface StepContext<TFieldKeys extends string = string> {
7
- step: Store<ExperienceStep>;
8
- /** Reactive store of fields with React-style event handlers and current state. */
9
- fields: Store<ReactFormField[]>;
10
- /**
11
- * Reactive store of the current step's CMS layout content. Resolves the step's
12
- * `layoutContentId` against `client.contents` and stays reactive — when content is
13
- * registered or updated, subscribers re-render. Yields `null` when the step has no
14
- * `layoutContentId` or the referenced content has not been registered yet.
15
- */
16
- layoutContentStore: Store<Content | null>;
17
- /**
18
- * Reactive store of the current step's CMS content `data`, or `null` when the step has
19
- * no `layoutContentId` or the referenced content is not yet registered. Derived from
20
- * `layoutContentStore`; subscribe with `useStoreGlobal(content)`. This is the value
21
- * `useStepContent()` yields, exposed here so a step can read everything it needs from a
22
- * single `useStep()` call.
23
- */
24
- content: Store<StepLayoutContent | null>;
25
- isActive: boolean;
26
- /** @deprecated Use `isActive` instead. */
1
+ import { Field, Response } from '@picked/client';
2
+ export interface StepContextValue {
3
+ step: {
4
+ id: string;
5
+ label: string;
6
+ };
7
+ fields: {
8
+ field: Field | undefined;
9
+ value: Response | undefined;
10
+ }[];
27
11
  isActiveStep: boolean;
28
- form: FormInstance<TFieldKeys>['form'];
29
- /**
30
- * Raw core registrars, used by `useStep` to own a callback channel scoped to the
31
- * consuming component rather than to `Step`. Internal: not part of the
32
- * supported surface.
33
- */
34
- formRegistrars: FormInstance<TFieldKeys>['formRegistrars'];
35
12
  }
36
- export declare const StepContextProvider: import("react").Context<StepContext<string> | null>;
37
- /**
38
- * Retrieves the step context from the nearest provider.
39
- *
40
- * The returned `form`'s callback registration is scoped to **this** hook
41
- * instance, not to the enclosing `Step`. That distinction is load-bearing: a
42
- * component subscribed to field state re-renders on every keystroke while `Step`
43
- * does not, so a channel anchored at `Step` would still accumulate one
44
- * registration per consumer render. Callbacks are torn down when the consuming
45
- * component unmounts, independently of sibling consumers.
46
- *
47
- * @param {FormCallbackOptions} [options] - Latest-wins submit callback slots; the recommended way to attach callbacks.
48
- * @returns {StepContext} The current step context, loosely typed.
49
- * @example const { form, fields } = useStep({ onSuccess: ({ data }) => track(data) })
50
- */
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>;
13
+ export declare function useStep(): StepContextValue;
14
+ export declare function useSetStepContext(stepId: string): {
15
+ step: {
16
+ id: string;
17
+ label: string;
18
+ };
19
+ fields: {
20
+ field: Field | undefined;
21
+ value: import('@picked/client').FieldValue | undefined;
22
+ }[];
23
+ isActiveStep: boolean;
66
24
  };
67
- /**
68
- * Creates and provides step context for the given step key.
69
- *
70
- * If the step key is not (yet) present in the experience tree, the returned
71
- * `step` store resolves to an empty placeholder and updates reactively once the
72
- * step is registered — matching the Svelte SDK's behaviour.
73
- *
74
- * @param {StepKeys} stepKey - Step key from the workspace schema, looked up in the experience tree.
75
- * @param {FormCallbackOptions} [options] - Latest-wins submit callback slots for the step's own form.
76
- * @returns {StepContext} Step context with form, fields, and active state.
77
- * @example useSetStepContext('step-1', { onSuccess: ({ data }) => track(data) })
78
- */
79
- export declare function useSetStepContext(stepKey: StepKeys, options?: FormCallbackOptions): StepContext;
80
- /**
81
- * Returns the current step's resolved CMS content data, or `null` when no content is registered.
82
- *
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.
85
- *
86
- * @returns {StepLayoutContent | null} The Content record's `data`, or `null`.
87
- * @example
88
- * const content = useStepContent()
89
- */
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;
100
25
  //# 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,EACV,OAAO,EACP,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,QAAQ,EACR,iBAAiB,EAClB,MAAM,gBAAgB,CAAA;AACvB,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,CAAC,UAAU,SAAS,MAAM,GAAG,MAAM;IAC7D,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,OAAO,EAAE,KAAK,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAA;IACxC,QAAQ,EAAE,OAAO,CAAA;IACjB,0CAA0C;IAC1C,YAAY,EAAE,OAAO,CAAA;IACrB,IAAI,EAAE,YAAY,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAA;IACtC;;;;OAIG;IACH,cAAc,EAAE,YAAY,CAAC,UAAU,CAAC,CAAC,gBAAgB,CAAC,CAAA;CAC3D;AAED,eAAO,MAAM,mBAAmB,qDAA0C,CAAA;AAE1E;;;;;;;;;;;;;GAaG;AACH,wBAAgB,OAAO,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,WAAW,CAAA;AACnE;;;;;;;;;;;GAWG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,QAAQ,EACxC,OAAO,CAAC,EAAE,mBAAmB,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,GACjD,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG;IACrD,OAAO,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAA;CACzC,CAAA;AA0BD;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,WAAW,CAoE/F;AAgCD;;;;;;;;;GASG;AACH,wBAAgB,cAAc,IAAI,iBAAiB,GAAG,IAAI,CAAA;AAC1D;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,oBAAoB,KAAK,cAAc,CAAC,CAAC,CAAC,GAAG,IAAI,CAAA"}
1
+ {"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../src/hooks/step.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAKrD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE;QACJ,EAAE,EAAE,MAAM,CAAA;QACV,KAAK,EAAE,MAAM,CAAA;KACd,CAAA;IACD,MAAM,EAAE;QAAE,KAAK,EAAE,KAAK,GAAG,SAAS,CAAC;QAAC,KAAK,EAAE,QAAQ,GAAG,SAAS,CAAA;KAAE,EAAE,CAAA;IACnE,YAAY,EAAE,OAAO,CAAA;CACtB;AAID,wBAAgB,OAAO,qBAOtB;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM;;;;;;;;;;EA4C/C"}
@@ -1 +1 @@
1
- import{useExperience as e,usePicked as t}from"./client.js";import{useStoreGlobal as n}from"./use-store-global.js";import{useFormCallbacks as r}from"../form/use-form-callbacks.js";import{useForm as i}from"../form/index.js";import{useStepRouter as a}from"../router/context.js";import{createContext as o,useContext as s,useMemo as c}from"react";import{combine as l}from"effector";var u=o(null);function d(e){let t=s(u),n=r(t?.formRegistrars,e),i=c(()=>t?{...t,form:{...t.form,...n}}:null,[t,n]);if(!i)throw Error(`useStep must be used within a StepContextProvider`);return i}function f(n,r){let o=e(),s=t(),{activeStep:u}=a(),d=c(()=>u?.key===n,[u?.key,n]),f=c(()=>o.treeStore.map(e=>e.steps.find(e=>e.key===n)??{id:n,key:n,name:``,fieldKeys:[]},{skipVoid:!1}),[o,n]),p=c(()=>f.map(e=>e.name,{skipVoid:!1}),[f]),m=c(()=>f.map(e=>e.fieldKeys,{skipVoid:!1}),[f]),{form:h,fields:g,formRegistrars:_}=i(n,p,m,r),v=c(()=>l(f,s.contents.indexStore,(e,t)=>e.layoutContentId?t[e.layoutContentId]??null:null,{skipVoid:!1}),[f,s]);return{step:f,fields:g,layoutContentStore:v,content:c(()=>v.map(e=>e?.data??null,{skipVoid:!1}),[v]),isActive:d,isActiveStep:d,form:h,formRegistrars:_}}function p(){let n=e(),r=t();return c(()=>l(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 m(){let e=s(u),t=p(),r=e?.layoutContentStore??t;return n(r)?.data??null}export{u as StepContextProvider,f as useSetStepContext,d as useStep,m as useStepContent};
1
+ import{createContext as a,useContext as w,useMemo as h}from"react";import{combine as C}from"effector";import{useUnit as b}from"effector-react";import{useStepRouter as E}from"../router/context.js";import{useExperience as P,usePicked as k}from"./client.js";const v=a(null);function $(){const e=w(v);if(!e)throw new Error("useStep must be used within a StepContextProvider");return e}function g(e){const d=P(),s=k(),{activeStep:t}=E(),p=h(()=>(t==null?void 0:t.id)===e,[t==null?void 0:t.id,e]),i=b(C({tree:d.treeStore,fields:s.fields.listStore,responses:s.responses.listStore},({tree:c,fields:f,responses:l})=>{const n=c.steps.find(o=>o.id===e);if(!n)throw new Error(`Step with id "${e}" not found in the experience tree.`);const m=n.fieldIds.map(o=>{var u;const x=f.find(r=>r.id===o),S=(u=l.find(r=>r.fieldId===o))==null?void 0:u.value;return{field:x,value:S}});return{step:{id:n.id,label:n.label},fields:m}}));return{step:i.step,fields:i.fields,isActiveStep:p}}export{g as useSetStepContext,$ as useStep};
@@ -1,4 +1,4 @@
1
- import type { StorageScope } from '@picked/client';
1
+ import { StorageScope } from '@picked/client';
2
2
  export interface UseStorageOptions {
3
3
  fallback: string | undefined | null;
4
4
  scope: StorageScope;
@@ -1 +1 @@
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};
1
+ import{useState as x,useEffect as a,useCallback as d}from"react";import{createStorageKey as k,supportsSessionStorage as v,supportsLocalStorage as E,sessionStore as K,localStore as L}from"@picked/client";import{useExperience as h}from"./client.js";const y={fallback:null,scope:"global"};function u(o,n,l){const{fallback:i,scope:f}={...y,...l},p=h(),s=o==="session"?K:L,r=o==="session"?v:E,[S,c]=x(i??null),t=k(n,f,p);a(()=>{if(r()){const e=s.get(t).text();e!==null&&c(e)}},[s,t,r]),a(()=>{if(!r())return;const e=m=>{c(m.text())},b=s.subscribe(t,e);return()=>{b()}},[s,t,r]);const g=d(e=>{c(e),r()&&(e?s.set(t,e):s.remove(t))},[s,t,r]);return[S,g]}function j(o,n){return u("session",o,n)}function q(o,n){return u("local",o,n)}export{q as useLocalStorage,j as useSessionStorage};
package/dist/index.d.ts CHANGED
@@ -1,9 +1,3 @@
1
- /**
2
- * @file Public re-exports for the main `@picked/react` entry point.
3
- */
4
1
  export { adaptReactComponent, isValidAdaptedComponent } from './component';
5
2
  export type * from './component';
6
- export { default as PickedProvider } from './experience/PickedProvider';
7
- export { default as ExperienceSlot } from './experience/ExperienceSlot';
8
- export { default as HtmlRender } from './experience/HtmlRender';
9
3
  //# 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;AAChC,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,6BAA6B,CAAA;AACvE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,6BAA6B,CAAA;AACvE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,yBAAyB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAC1E,mBAAmB,aAAa,CAAA"}
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{adaptReactComponent as e,isValidAdaptedComponent as t}from"./component.js";import n from"./experience/PickedProvider.js";import r from"./experience/ExperienceSlot.js";import i from"./experience/HtmlRender.js";export{r as ExperienceSlot,i as HtmlRender,n as PickedProvider,e as adaptReactComponent,t as isValidAdaptedComponent};
1
+ import{adaptReactComponent as a,isValidAdaptedComponent as e}from"./component.js";export{a as adaptReactComponent,e as isValidAdaptedComponent};
@@ -1 +1 @@
1
- import{reactFrameworkPlugin as e}from"./plugin.js";export{e as reactFrameworkPlugin};
1
+ import{reactFrameworkPlugin as o}from"./plugin.js";export{o as reactFrameworkPlugin};
@@ -1,6 +1,5 @@
1
- /** @file React framework plugin that registers the React renderer and unmounter with the Picked client. */
2
- import type { AdaptableComponents, AdaptedComponentStyle, Plugin } from '@picked/client';
3
- import { type ComponentWithProps } from '../../component';
1
+ import { AdaptableComponents, AdaptedComponentStyle, Plugin } from '@picked/client';
2
+ import { ComponentWithProps } from '../../component';
4
3
  export type AdapterComponents = Partial<Record<keyof AdaptableComponents, {
5
4
  component: ComponentWithProps;
6
5
  style?: AdaptedComponentStyle;
@@ -15,8 +14,9 @@ export interface ReactFrameworkPluginOptions {
15
14
  * This plugin registers the React framework and allows rendering React components
16
15
  * with the client's experience data.
17
16
  *
18
- * @param {ReactFrameworkPluginOptions} options - Configuration options for the React plugin.
17
+ * @param {ReactFrameworkPluginOptions} options - Configuration options for the React plugin
19
18
  * @returns {Plugin} The plugin.
19
+ *
20
20
  * @example
21
21
  * ```typescript
22
22
  * createClient({
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/framework/plugin.ts"],"names":[],"mappings":"AAAA,2GAA2G;AAC3G,OAAO,KAAK,EAAE,mBAAmB,EAAE,qBAAqB,EAAU,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAChG,OAAO,EAAuB,KAAK,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAG9E,MAAM,MAAM,iBAAiB,GAAG,OAAO,CACrC,MAAM,CACJ,MAAM,mBAAmB,EACzB;IAAE,SAAS,EAAE,kBAAkB,CAAC;IAAC,KAAK,CAAC,EAAE,qBAAqB,CAAA;CAAE,CACjE,CACF,CAAA;AAED,MAAM,WAAW,2BAA2B;IAC1C,UAAU,EAAE,iBAAiB,CAAA;IAC7B,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;IACtB,GAAG,CAAC,EAAE,MAAM,EAAE,CAAA;CACf;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,oBAAoB,YAAa,2BAA2B,KAAG,MAwB3E,CAAA"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/framework/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,qBAAqB,EAAU,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAChG,OAAO,EAAuB,KAAK,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAG9E,MAAM,MAAM,iBAAiB,GAAG,OAAO,CACrC,MAAM,CACJ,MAAM,mBAAmB,EACzB;IAAE,SAAS,EAAE,kBAAkB,CAAC;IAAC,KAAK,CAAC,EAAE,qBAAqB,CAAA;CAAE,CACjE,CACF,CAAA;AAED,MAAM,WAAW,2BAA2B;IAC1C,UAAU,EAAE,iBAAiB,CAAA;IAC7B,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;IACtB,GAAG,CAAC,EAAE,MAAM,EAAE,CAAA;CACf;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,oBAAoB,GAAI,SAAS,2BAA2B,KAAG,MAuB3E,CAAA"}
@@ -1 +1 @@
1
- import{adaptReactComponent as e}from"../../component.js";import{renderReactComponent as t,unRenderReactComponent as n}from"../../render/browser.js";var r=r=>({name:`react-framework`,setup:i=>{i.registerFramework({name:`react`,render(...e){return t(...e,{stylesheets:r.stylesheets,css:r.css})},unmount:e=>n(e)});let a=r.components.experience;a&&i.registerComponent(`experience`,e(a.component,a.style))}});export{r as reactFrameworkPlugin};
1
+ import{adaptReactComponent as o}from"../../component.js";import{renderReactComponent as m}from"../../render/browser.js";const a=e=>({name:"react-framework",setup:t=>{t.registerFramework({name:"react",render(...n){return m(...n,{stylesheets:e.stylesheets,css:e.css})}});const r=e.components.experience;r&&t.registerComponent("experience",o(r.component,r.style))}});export{a as reactFrameworkPlugin};
@@ -1,7 +1,7 @@
1
- import type { AdaptedComponent, ExperienceInstance, Picked } from '@picked/client';
1
+ import { AdaptedComponent, ExperienceInstance, Picked } from '@picked/client';
2
2
  export declare const renderReactComponent: (shadowRoot: ShadowRoot, component: AdaptedComponent<string, unknown>, client: Picked, experience: ExperienceInstance, options: {
3
3
  stylesheets?: string[];
4
4
  css?: string[];
5
5
  }) => Promise<void>;
6
- export declare const unRenderReactComponent: (target: Element | ShadowRoot) => void;
6
+ export declare const unRenderReactComponent: (target: Element) => void;
7
7
  //# sourceMappingURL=browser.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/render/browser.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AASlF,eAAO,MAAM,oBAAoB,eACnB,UAAU,aACX,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,UACpC,MAAM,cACF,kBAAkB,WACrB;IACP,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;IACtB,GAAG,CAAC,EAAE,MAAM,EAAE,CAAA;CACf,kBA0DF,CAAA;AAED,eAAO,MAAM,sBAAsB,WAAY,OAAO,GAAG,UAAU,SAMlE,CAAA"}
1
+ {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/render/browser.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAQlF,eAAO,MAAM,oBAAoB,GAC/B,YAAY,UAAU,EACtB,WAAW,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5C,QAAQ,MAAM,EACd,YAAY,kBAAkB,EAC9B,SAAS;IACP,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;IACtB,GAAG,CAAC,EAAE,MAAM,EAAE,CAAA;CACf,kBAoEF,CAAA;AAED,eAAO,MAAM,sBAAsB,GAAI,QAAQ,OAAO,SAMrD,CAAA"}
@@ -1 +1 @@
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};
1
+ import n from"react";import{createRoot as v}from"react-dom/client";import{isValidAdaptedComponent as A}from"../component.js";import{ClientProvider as E,ExperienceProvider as h}from"../context.js";import{mergeArrays as y}from"../utils/array.js";const l=new WeakMap,x=async(r,t,o,c,a)=>{var p,f;if(!A(t))throw new Error("The component is invalid.");const m=y((p=t.style)==null?void 0:p.sheets,a.stylesheets),d=y((f=t.style)==null?void 0:f.css,a.css);m.length&&m.forEach(s=>{const e=document.createElement("link");e.setAttribute("rel","stylesheet"),e.setAttribute("href",s),e.setAttribute("type","text/css"),e.setAttribute("picked-injected","true"),r.appendChild(e)}),d.length&&d.forEach(s=>{const e=document.createElement("style");e.textContent=s,e.setAttribute("type","text/css"),e.setAttribute("picked-injected","true"),r.appendChild(e)});const u=document.createElement("div");r.appendChild(u);const i=v(u);if(l.set(r,i),t.component instanceof Promise){const{default:s}=await t.component;i.render(n.createElement(E,{value:o},n.createElement(h,{value:c},n.createElement(s,{client:o,experience:c}))));return}const C=t.component;i.render(n.createElement(E,{value:o},n.createElement(h,{value:c},n.createElement(C,{client:o,experience:c}))))},R=r=>{const t=l.get(r);t&&(t.unmount(),l.delete(r))};export{x as renderReactComponent,R as unRenderReactComponent};
@@ -1,4 +1,4 @@
1
- import type { AdaptedComponent, ExperienceInstance, Picked } from '@picked/client';
1
+ import { AdaptedComponent, ExperienceInstance, Picked } from '@picked/client';
2
2
  export declare const staticRenderReactComponent: (component: AdaptedComponent<string, unknown>, client: Picked, experience: ExperienceInstance, options: {
3
3
  stylesheets?: string[];
4
4
  css?: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/render/server.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAMlF,eAAO,MAAM,0BAA0B,cAC1B,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,UACpC,MAAM,cACF,kBAAkB,WACrB;IACP,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;IACtB,GAAG,CAAC,EAAE,MAAM,EAAE,CAAA;CACf;;;;;EAuCF,CAAA"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/render/server.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAKlF,eAAO,MAAM,0BAA0B,GACrC,WAAW,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5C,QAAQ,MAAM,EACd,YAAY,kBAAkB,EAC9B,SAAS;IACP,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;IACtB,GAAG,CAAC,EAAE,MAAM,EAAE,CAAA;CACf;;;;;EAgDF,CAAA"}