@picked/react 0.0.1-dev.1789541668638 → 0.0.1-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 (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 +0,0 @@
1
- import{isValidAdaptedComponent as e}from"../component.js";import{ExperienceProvider as t}from"../context.js";import{useStoreGlobal as n}from"../hooks/use-store-global.js";import r,{Suspense as i,useEffect as a,useMemo as o,useRef as s}from"react";import{isLazyLoader as c,supportsWindow as l}from"@picked/client";import{createExperienceInstance as u}from"@picked/client/server";import{jsx as d}from"react/jsx-runtime";function f(e){return typeof e==`function`&&!c(e)&&!(e instanceof Promise)}function p({experience:p,client:m}){let h=s(null);h.current??=u({client:m,experience:p});let g=h.current,_=n(g.componentAndFrameworkStore),v=n(m.readyStore);a(()=>{v&&l()&&p.prepareExperienceContentFx().catch(()=>void 0)},[v,p]);let y=_?.component.component,b=y&&e(y)?y.component:void 0,x=o(()=>c(b)?r.lazy(()=>b.load()):b instanceof Promise?r.lazy(()=>b):null,[b]);return f(b)?d(t,{value:g,children:d(b,{client:m,experience:g})}):x?d(t,{value:g,children:d(i,{fallback:null,children:d(x,{client:m,experience:g})})}):null}var m=r.memo(p);m.displayName=`ExperienceHost`;export{m as default};
@@ -1,35 +0,0 @@
1
- /**
2
- * @file Slot-based experience renderer. Renders every registered experience that targets the
3
- * named slot and whose condition is active, ordered by placement. Active is read synchronously
4
- * from the seeded condition-results store (sync on SSR / hydration first paint); on a cache miss
5
- * (standalone, no snapshot) the condition is evaluated asynchronously and the store update
6
- * re-renders reactively.
7
- */
8
- import React from 'react';
9
- interface ExperienceSlotProps {
10
- /**
11
- * Slot name. Maps to the `.picked-slot-<name>` selector that targeted experiences declare.
12
- * Named `name` rather than `slot` for parity with the Svelte component, where `slot` is a
13
- * reserved attribute.
14
- */
15
- readonly name: string;
16
- }
17
- /**
18
- * Renders the experiences that target the named slot and whose condition is active, ordered by
19
- * placement precedence (`replace → before → prepend → append → after`). An active `replace`
20
- * experience wins: the first one renders alone, replacing any other matches in the slot.
21
- *
22
- * Active is read from `conditionResults` via `peek`: a seeded snapshot makes it synchronous for
23
- * SSR and the hydration first paint, while a cache miss (standalone, no snapshot) triggers an
24
- * asynchronous evaluation in a browser effect whose store write re-renders this component.
25
- * Subscribing to `client.conditionResults.store` is what makes those late writes reactive.
26
- *
27
- * @param {ExperienceSlotProps} props - The component props.
28
- * @param {string} props.name - The slot name, mapped to the `.picked-slot-<name>` selector.
29
- * @returns {React.JSX.Element} The active experiences for the slot.
30
- * @example
31
- * <ExperienceSlot name="page" />
32
- */
33
- declare function ExperienceSlot({ name }: ExperienceSlotProps): React.JSX.Element;
34
- export default ExperienceSlot;
35
- //# sourceMappingURL=ExperienceSlot.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExperienceSlot.d.ts","sourceRoot":"","sources":["../../src/experience/ExperienceSlot.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAA6B,MAAM,OAAO,CAAA;AAQjD,UAAU,mBAAmB;IAC3B;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACtB;AAyFD;;;;;;;;;;;;;;;GAeG;AACH,iBAAS,cAAc,CAAC,EAAE,IAAI,EAAE,EAAE,mBAAmB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CA4DxE;eAEc,cAAc"}
@@ -1 +0,0 @@
1
- import{usePicked as e}from"../hooks/client.js";import{useStoreGlobal as t}from"../hooks/use-store-global.js";import"../hooks/index.js";import n from"./ExperienceHost.js";import{useEffect as r,useMemo as i}from"react";import{supportsWindow as a}from"@picked/client";import{evaluateConditionMemo as o,hashRule as s,ruleReferencesActionDeep as c}from"@picked/client/server";import{Fragment as l,jsx as u}from"react/jsx-runtime";var d=[`replace`,`before`,`prepend`,`append`,`after`];function f(e){let t=d.indexOf(e);return t===-1?d.length:t}function p(e,t,n){let r=e.configStore.getState(),i=r.targetSelectors.find(e=>e.selector===t);return!i||c(r.decisionLogic,n)?null:{experience:e,placement:i.placement,condition:r.decisionLogic,hash:s(r.decisionLogic)}}function m(){let{href:e,pathname:t,search:n,hostname:r,origin:i,protocol:a,port:o,host:s,hash:c}=globalThis.location;return{href:e,pathname:t,search:n,hostname:r,origin:i,protocol:a,port:o,host:s,hash:c}}function h({name:s}){let c=e(),d=`.picked-slot-${s}`,h=t(c.experiences.listStore);t(c.conditionResults.store);let g=t(c.conditions.listStore),_=i(()=>{let e={};for(let t of g)e[t.key]=t;return e},[g]),v=h.map(e=>p(e,d,_)).filter(e=>e!==null).sort((e,t)=>f(e.placement)-f(t.placement)),y=v.filter(e=>c.conditionResults.peek(e.hash)===!0),b=y.find(e=>e.placement===`replace`),x=b?[b]:y;return r(()=>{if(a())for(let e of v)c.conditionResults.peek(e.hash)===void 0&&o(c,e.condition,{context:{location:m()}})}),u(l,{children:x.map(e=>u(n,{experience:e.experience,client:c},e.experience.id))})}export{h as default};
@@ -1,33 +0,0 @@
1
- /** @file Renders a resolved html-asset field into a shadow root and re-executes its Picked-tagged scripts. */
2
- import React from 'react';
3
- interface HtmlRenderProps {
4
- /** The resolved html-asset field value (for example `content.body`). */
5
- readonly html: unknown;
6
- }
7
- /**
8
- * Renders a resolved html-asset field's HTML inside an open shadow root and rehydrates its
9
- * Picked-tagged scripts. The shadow boundary keeps the host page's CSS from bleeding into the
10
- * landing-page markup and lets shadow-scoped page scripts locate their own root during rehydration. On the server
11
- * the markup is emitted as a declarative shadow DOM template, a parser-only feature the browser
12
- * attaches as a real shadow root while parsing the response, so content is present from first paint.
13
- * On the client, the first commit adopts that parser-attached root and only rehydrates its scripts; a
14
- * client-only mount or a later content change attaches and writes the shadow root imperatively
15
- * instead. A non-matching value or a `null` content renders nothing.
16
- *
17
- * Inside a Picked live-preview session the update path changes: content arrives at typing speed, so
18
- * after the first render the shadow root is **morphed** rather than rewritten, and page scripts are
19
- * **frozen** — nothing re-executes. The two are one behaviour and must never be separated. Freezing
20
- * is what stops a customer's analytics and third-party pixels firing once per keystroke from the
21
- * dashboard; morphing is what keeps the page alive without them, since a wholesale rewrite would
22
- * detach every listener with nothing left to re-bind it. Markup inserted during a preview morph has
23
- * its scripts neutralised, so a newly-added section renders but has no behaviour until the next full
24
- * load — reported to the embedder so the editor can say so.
25
- *
26
- * @param {HtmlRenderProps} props - The component props.
27
- * @returns {React.JSX.Element} The shadow-root host element.
28
- * @example
29
- * <HtmlRender html={content.body} />
30
- */
31
- declare function HtmlRender({ html }: HtmlRenderProps): React.JSX.Element;
32
- export default HtmlRender;
33
- //# sourceMappingURL=HtmlRender.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HtmlRender.d.ts","sourceRoot":"","sources":["../../src/experience/HtmlRender.tsx"],"names":[],"mappings":"AAAA,8GAA8G;AAC9G,OAAO,KAA4B,MAAM,OAAO,CAAA;AAWhD,UAAU,eAAe;IACvB,wEAAwE;IACxE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;CACvB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,iBAAS,UAAU,CAAC,EAAE,IAAI,EAAE,EAAE,eAAe,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAuChE;eAEc,UAAU"}
@@ -1 +0,0 @@
1
- import{morphInto as e}from"./morph.js";import{useEffect as t,useRef as n}from"react";import{isHtmlAssetValue as r,isPreviewSession as i,rehydrateScripts as a,reportInertScriptSubtrees as o,supportsShadowRoot as s,supportsWindow as c}from"@picked/client";import{jsx as l}from"react/jsx-runtime";function u({html:u}){let d=(r(u)?u:null)?.content??``,f=n(null),p=n(!1);if(t(()=>{let t=f.current;if(!s()||!t)return;let n=t.shadowRoot,r=!p.current;if(p.current=!0,n&&r){d&&a(n);return}let c=n??t.attachShadow({mode:`open`});if(!r&&i()){let{inertScriptSubtrees:t}=e(c,d);o(t);return}c.innerHTML=d,d&&a(c)},[d]),!c()){let e=`<template shadowrootmode="open">${d}</template>`;return l(`div`,{ref:f,suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:e}})}return l(`div`,{ref:f,suppressHydrationWarning:!0})}export{u as default};
@@ -1,42 +0,0 @@
1
- /**
2
- * @file Provider that supplies a Picked client to descendant components — created from `options`
3
- * (hydrated from an optional SSR snapshot) or an existing client passed in — and, on the client
4
- * only, starts the interactive lifecycle.
5
- */
6
- import React from 'react';
7
- import type { CreateClientOptions, Picked } from '@picked/client';
8
- import { type PickedSnapshot } from '@picked/client/server';
9
- type PickedProviderProps = {
10
- readonly client: Picked;
11
- readonly snapshot?: PickedSnapshot;
12
- readonly children?: React.ReactNode;
13
- } | {
14
- readonly options: CreateClientOptions;
15
- readonly snapshot?: PickedSnapshot;
16
- readonly children?: React.ReactNode;
17
- };
18
- /**
19
- * Provides a Picked client to descendant components.
20
- *
21
- * Pass `options` to have the provider create the client and synchronously hydrate it from an
22
- * optional SSR snapshot, so `<ExperienceSlot>` and the hooks read a fully-populated client during SSR
23
- * and the hydration first paint; a `versionId` mismatch is tolerated (the client reconciles via
24
- * `start()`). Alternatively pass an existing `client` (such as the app's single global client) to
25
- * render experiences against it — supply `snapshot` alongside `client` to SSR-seed that shared
26
- * client rather than creating a second one. In the browser the provider calls `client.start()`
27
- * from an effect; `start()` is idempotent, so a client that was already started is left untouched.
28
- *
29
- * @param {PickedProviderProps} props - `{ client, snapshot? }` or `{ options, snapshot? }`, plus `children`.
30
- * @returns {React.JSX.Element} The provider wrapping its children.
31
- * @example
32
- * <PickedProvider options={options} snapshot={snapshot}>
33
- * <ExperienceSlot name="page" />
34
- * </PickedProvider>
35
- * @example
36
- * <PickedProvider client={globalClient} snapshot={snapshot}>
37
- * <ExperienceSlot name="page" />
38
- * </PickedProvider>
39
- */
40
- declare function PickedProvider(props: PickedProviderProps): React.JSX.Element;
41
- export default PickedProvider;
42
- //# sourceMappingURL=PickedProvider.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PickedProvider.d.ts","sourceRoot":"","sources":["../../src/experience/PickedProvider.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAA8B,MAAM,OAAO,CAAA;AAClD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAEjE,OAAO,EAAyB,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAGlF,KAAK,mBAAmB,GACpB;IACE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,QAAQ,CAAC,EAAE,cAAc,CAAA;IAClC,QAAQ,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CACpC,GACD;IACE,QAAQ,CAAC,OAAO,EAAE,mBAAmB,CAAA;IACrC,QAAQ,CAAC,QAAQ,CAAC,EAAE,cAAc,CAAA;IAClC,QAAQ,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CACpC,CAAA;AA8CL;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,iBAAS,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAwBrE;eAEc,cAAc"}
@@ -1 +0,0 @@
1
- import{ClientProvider as e}from"../context.js";import{useEffect as t,useState as n}from"react";import{createClient as r,supportsWindow as i}from"@picked/client";import{registerProjectConfig as a}from"@picked/client/server";import{jsx as o}from"react/jsx-runtime";function s(e,t){let n=e.session.store.getState().id;e.seededVersionId=t.versionId,a(e,t.projectConfig,{isPreview:!1,sessionId:n}),t.content.forEach(t=>e.registerContent(t)),e.conditionResults.seed(t.conditionResults)}function c(e,t){let n=r(e);return t&&s(n,t),n}function l(r){let[a]=n(()=>{let e;return`client`in r?(r.snapshot&&s(r.client,r.snapshot),e=r.client):e=c(r.options,r.snapshot),e});return t(()=>{i()&&a.start()},[a]),o(e,{value:a,children:r.children})}export{l as default};
@@ -1,26 +0,0 @@
1
- /** Outcome of a morph pass. Returned by {@link morphInto}. */
2
- interface MorphResult {
3
- /**
4
- * How many inserted subtrees contained at least one `<script>`. Those scripts are neutralised
5
- * before insertion, so the markup renders but has no behaviour until the next full load. The
6
- * dashboard surfaces this count so an author who adds a section understands why its carousel is
7
- * inert, instead of filing it as a bug.
8
- */
9
- inertScriptSubtrees: number;
10
- }
11
- /**
12
- * Morphs a root's children to match `markup`, preserving every node the new markup did not change.
13
- *
14
- * Scripts are never executed: existing ones are left untouched (mutating a script's text does not
15
- * re-run it) and inserted ones are neutralised before they reach the document. The returned count
16
- * reports how many inserted subtrees were affected, so the editor can say so.
17
- *
18
- * @param {ParentNode & Node} root - The live root — typically a shadow root — to update.
19
- * @param {string} markup - The desired markup.
20
- * @returns {MorphResult} How many inserted subtrees had their scripts neutralised.
21
- * @example
22
- * const { inertScriptSubtrees } = morphInto(shadowRoot, '<h1>Hello</h1>')
23
- */
24
- export declare function morphInto(root: ParentNode & Node, markup: string): MorphResult;
25
- export {};
26
- //# sourceMappingURL=morph.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"morph.d.ts","sourceRoot":"","sources":["../../src/experience/morph.ts"],"names":[],"mappings":"AAmBA,8DAA8D;AAC9D,UAAU,WAAW;IACnB;;;;;OAKG;IACH,mBAAmB,EAAE,MAAM,CAAA;CAC5B;AAuHD;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW,CAO9E"}
@@ -1 +0,0 @@
1
- import{PICKED_SCRIPT_TYPE as e}from"@picked/client";var t=`data-picked-hydrated`;function n(t){let n=t.querySelectorAll(`script`),r=t.tagName===`SCRIPT`;if(n.length===0&&!r)return!1;r&&t.setAttribute(`type`,e);for(let t of Array.from(n))t.setAttribute(`type`,e);return!0}function r(e,t,r){let i=t.importNode(e,!0);return i instanceof Element&&n(i)&&(r.inertScriptSubtrees+=1),i}function i(e,n){for(let t of Array.from(n.attributes))e.getAttribute(t.name)!==t.value&&e.setAttribute(t.name,t.value);for(let r of Array.from(e.attributes))r.name!==t&&(n.hasAttribute(r.name)||e.removeAttribute(r.name))}function a(e,t){return e.nodeType===t.nodeType&&e.nodeName===t.nodeName}function o(e,t,n,s){let c=Array.from(e.childNodes),l=Array.from(t.childNodes);for(let[t,u]of l.entries()){let l=c[t];if(!l){e.appendChild(r(u,n,s));continue}if(!a(l,u)){e.replaceChild(r(u,n,s),l);continue}if(l instanceof Element&&u instanceof Element){i(l,u),o(l,u,n,s);continue}l.nodeValue!==u.nodeValue&&(l.nodeValue=u.nodeValue)}for(let e of c.slice(l.length))e.remove()}function s(e,t){let n={inertScriptSubtrees:0},r=e.ownerDocument??globalThis.document,i=r.createElement(`template`);return i.innerHTML=t,o(e,i.content,r,n),n}export{s as morphInto};
@@ -1,45 +0,0 @@
1
- import type { ErrorCallback, FormCallbackOptions, SubmitCallback, SuccessCallback } from '@picked/client/form';
2
- export type { FormCallbackOptions } from '@picked/client/form';
3
- /**
4
- * The core's append-only registration functions, each returning an unsubscribe.
5
- *
6
- * Passed down from `useForm` so a hook that owns its own channel — `useStep` —
7
- * can register its single dispatcher directly against the core rather than
8
- * nesting inside another channel.
9
- *
10
- * @example useFormCallbacks(stepContext.formRegistrars)
11
- */
12
- export interface FormCallbackRegistrars {
13
- onBeforeSubmit: (callback: SubmitCallback) => () => void;
14
- onSuccess: (callback: SuccessCallback) => () => void;
15
- onError: (callback: ErrorCallback) => () => void;
16
- }
17
- /**
18
- * Lifecycle-safe registration surface handed to consumers.
19
- *
20
- * Nothing is returned because cleanup is automatic — the channel is torn down
21
- * with the hook instance that owns it. This mirrors the Svelte adapter, whose
22
- * registrations also return `void`.
23
- *
24
- * @example channel.onSuccess(({ data }) => track(data))
25
- */
26
- export interface FormCallbackChannel {
27
- onBeforeSubmit: (callback: SubmitCallback) => void;
28
- onSuccess: (callback: SuccessCallback) => void;
29
- onError: (callback: ErrorCallback) => void;
30
- }
31
- /**
32
- * Owns a form-callback channel for one hook instance.
33
- *
34
- * Registers a single dispatcher per event against the core registrars and routes
35
- * both the options slot and any imperative registrations through it, so consumer
36
- * callbacks can never accumulate in the core registry across renders.
37
- *
38
- * @param {FormCallbackRegistrars | undefined} registrars - Core registration functions; when undefined the channel no-ops, so callers can invoke this hook unconditionally.
39
- * @param {FormCallbackOptions} [options] - Latest-wins callback slots.
40
- * @returns {FormCallbackChannel} A registration surface whose cleanup is automatic.
41
- * @example const channel = useFormCallbacks(form.formRegistrars, { onSuccess })
42
- * @design-parity Mirrors the Svelte adapter's `$effect`-wrapped registration.
43
- */
44
- export declare function useFormCallbacks(registrars: FormCallbackRegistrars | undefined, options?: FormCallbackOptions): FormCallbackChannel;
45
- //# sourceMappingURL=use-form-callbacks.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-form-callbacks.d.ts","sourceRoot":"","sources":["../../src/form/use-form-callbacks.ts"],"names":[],"mappings":"AAkCA,OAAO,KAAK,EACV,aAAa,EACb,mBAAmB,EACnB,cAAc,EACd,eAAe,EAChB,MAAM,qBAAqB,CAAA;AAK5B,YAAY,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAK9D;;;;;;;;GAQG;AACH,MAAM,WAAW,sBAAsB;IACrC,cAAc,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,MAAM,IAAI,CAAA;IACxD,SAAS,EAAE,CAAC,QAAQ,EAAE,eAAe,KAAK,MAAM,IAAI,CAAA;IACpD,OAAO,EAAE,CAAC,QAAQ,EAAE,aAAa,KAAK,MAAM,IAAI,CAAA;CACjD;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,mBAAmB;IAClC,cAAc,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,IAAI,CAAA;IAClD,SAAS,EAAE,CAAC,QAAQ,EAAE,eAAe,KAAK,IAAI,CAAA;IAC9C,OAAO,EAAE,CAAC,QAAQ,EAAE,aAAa,KAAK,IAAI,CAAA;CAC3C;AAuFD;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,sBAAsB,GAAG,SAAS,EAC9C,OAAO,CAAC,EAAE,mBAAmB,GAC5B,mBAAmB,CAgGrB"}
@@ -1 +0,0 @@
1
- import{useCallback as e,useEffect as t,useMemo as n,useRef as r}from"react";function i(){return{pass:[],sealedAt:null,persistent:[]}}function a(e){e.sealedAt!==null&&(e.persistent=[...e.persistent,...e.pass.slice(e.sealedAt)]),e.pass=[],e.sealedAt=null}function o(e,t){let n={callback:t};return e.pass=[...e.pass,n],()=>{e.pass=e.pass.filter(e=>e!==n),e.persistent=e.persistent.filter(e=>e!==n)}}function s(e,t){let n=[...e.pass,...e.persistent].map(e=>e.callback);return t===void 0?n:[t,...n]}function c(c,l){let u=r(null);u.current??={beforeSubmit:i(),success:i(),error:i(),options:{}};let d=u.current;a(d.beforeSubmit),a(d.success),a(d.error),t(()=>{d.options=l??{},d.beforeSubmit.sealedAt=d.beforeSubmit.pass.length,d.success.sealedAt=d.success.pass.length,d.error.sealedAt=d.error.pass.length});let f=e(async e=>{let t=e;for(let e of s(d.beforeSubmit,d.options.onBeforeSubmit)){let n=await e(t);n!==void 0&&(t=n)}return t},[d]),p=e(async e=>{await Promise.all(s(d.success,d.options.onSuccess).map(t=>t(e)))},[d]),m=e(async e=>{await Promise.all(s(d.error,d.options.onError).map(t=>t(e)))},[d]);return t(()=>{if(!c)return;let e=[c.onBeforeSubmit(f),c.onSuccess(p),c.onError(m)];return()=>{e.forEach(e=>e())}},[c,f,p,m]),n(()=>({onBeforeSubmit:e=>o(d.beforeSubmit,e),onSuccess:e=>o(d.success,e),onError:e=>o(d.error,e)}),[d])}export{c as useFormCallbacks};
@@ -1,39 +0,0 @@
1
- /**
2
- * @file React hooks for consuming registered actions from the Picked client.
3
- */
4
- import type { Action, ActionKeys, ExperienceInstance } from '@picked/client';
5
- type ActionResult = string | string[] | boolean | void | undefined;
6
- /**
7
- * Returns the current evokable action function, reactive to store updates.
8
- * When `options.experience` is provided, the wrapped call passes that
9
- * experience as the action's context so manually-invoked handlers can
10
- * behave as if they were triggered by that experience — for example, to
11
- * call `context.experience.close()` after a submit.
12
- *
13
- * @param {ActionKeys} actionKey - Action key from the workspace schema.
14
- * @param {object} [options] - Optional invocation overrides.
15
- * @param {ExperienceInstance} options.experience - Experience to bind as the action's context.
16
- * @returns {() => ReturnType<Action>} The callable action function.
17
- * @example
18
- * const evoke = useAction('log-event')
19
- * const bound = useAction('submit-form', { experience: useExperience() })
20
- */
21
- export declare function useAction(actionKey: ActionKeys, options?: {
22
- experience: ExperienceInstance;
23
- }): () => ReturnType<Action>;
24
- /**
25
- * Returns the latest result of invoking the keyed action, reactive to store updates.
26
- * Re-evaluates whenever the underlying evokable store emits.
27
- *
28
- * @param {ActionKeys} actionKey - Action key from the workspace schema.
29
- * @param {object} [options] - Optional invocation overrides.
30
- * @param {ExperienceInstance} options.experience - Experience to bind as the action's context.
31
- * @returns {ActionResult} The latest action return value.
32
- * @example
33
- * const result = useActionResult('is-logged-in')
34
- */
35
- export declare function useActionResult(actionKey: ActionKeys, options?: {
36
- experience: ExperienceInstance;
37
- }): ActionResult;
38
- export {};
39
- //# sourceMappingURL=action.d.ts.map
@@ -1 +0,0 @@
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"}
@@ -1 +0,0 @@
1
- import{usePicked as e}from"./client.js";import{useStoreGlobal as t}from"./use-store-global.js";import{attach as n,createEffect as r,createEvent as i,createStore as a,sample as o}from"effector";function s(n,r){let i=e();return t(i.actions.getEvokableAction(n,r))}function c(s,c){let l=e().actions.getEvokableAction(s,c),u=a(void 0,{skipVoid:!1}),d=i(),f=n({source:l,mapParams:(e,t)=>t,effect:r(async e=>{if(e)return await e()})});return o({clock:d,target:f}),o({clock:f.doneData,target:u}),d(),o({clock:l,target:d}),t(u)}export{s as useAction,c as useActionResult};
@@ -1,24 +0,0 @@
1
- /**
2
- * @file React lookup hook for the Picked content registry. Mirrors the shape of
3
- * `useField(key)` — returns the registry store, leaving subscription to the consumer.
4
- */
5
- import type { Store } from 'effector';
6
- import { type TypedContent } from '@picked/client';
7
- /**
8
- * Returns the registry store for a content id. Resolves the Picked client via
9
- * `usePicked()` and returns `client.contents.getById(id)`. Consumers are
10
- * responsible for calling `useStoreGlobal` to subscribe.
11
- *
12
- * @template TData
13
- * @param {string} id - The content record id to look up.
14
- * @returns {Store<TypedContent<TData> | null>} The registry store; `null` until content is registered.
15
- * @example
16
- * ```tsx
17
- * const Banner = () => {
18
- * const content = useStoreGlobal(useContent<WelcomePage>('lc_banner'))
19
- * return <h1>{content?.data.title ?? ''}</h1>
20
- * }
21
- * ```
22
- */
23
- export declare function useContent<TData extends Record<string, unknown> = Record<string, unknown>>(id: string): Store<TypedContent<TData> | null>;
24
- //# sourceMappingURL=content.d.ts.map
@@ -1 +0,0 @@
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 +0,0 @@
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,45 +0,0 @@
1
- import type { FeatureKeys, FeatureResult, FeatureValueFor } from '@picked/client';
2
- type FeatureBucket = boolean | string | undefined;
3
- /**
4
- * Returns the current evokable feature function, reactive to store updates.
5
- *
6
- * @param {FeatureKeys} featureName - Feature key from the workspace schema.
7
- * @returns {() => Promise<FeatureBucket>} The evokable feature function.
8
- * @example
9
- * const evoke = useFeature('my-feature')
10
- */
11
- export declare function useFeature(featureName: FeatureKeys): () => Promise<FeatureBucket>;
12
- /**
13
- * Returns the feature's evaluated bucket result, reactive to store updates.
14
- *
15
- * The evaluation wiring belongs to the client, which builds it once per feature and
16
- * resolves it once — so a component that re-renders reads the same result rather than
17
- * rebuilding the graph behind it.
18
- *
19
- * The key type is inferred from the argument, so a workspace-known text feature narrows
20
- * its `bucket` to that feature's declared arms.
21
- *
22
- * @template K
23
- * @param {K} featureName - Feature key from the workspace schema.
24
- * @returns {FeatureResult<FeatureValueFor<K>> | undefined} The current feature evaluation result, reactive to store updates.
25
- * @example
26
- * const result = useFeatureResult('my-feature')
27
- */
28
- export declare function useFeatureResult<K extends FeatureKeys>(featureName: K): FeatureResult<FeatureValueFor<K>> | undefined;
29
- /**
30
- * Returns a feature's admin `enabled` flag, reactive to store updates.
31
- *
32
- * Unlike {@link useFeature}, this reads the static config flag directly and does not
33
- * trigger bucket resolution — so a disabled feature (`enabled: false`) can be told
34
- * apart from an enabled feature whose session simply was not allocated. Returns
35
- * `undefined` when the feature is unregistered or carries no `enabled` metadata
36
- * (for example, manually-registered features).
37
- *
38
- * @param {FeatureKeys} featureName - Feature key from the workspace schema.
39
- * @returns {boolean | undefined} The feature's `enabled` flag, or `undefined` when unknown.
40
- * @example
41
- * const enabled = useFeatureEnabled('winter-sale')
42
- */
43
- export declare function useFeatureEnabled(featureName: FeatureKeys): boolean | undefined;
44
- export {};
45
- //# sourceMappingURL=feature.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"feature.d.ts","sourceRoot":"","sources":["../../src/hooks/feature.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAIjF,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;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,WAAW,EACpD,WAAW,EAAE,CAAC,GACb,aAAa,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAI/C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,GAAG,SAAS,CAI/E"}
@@ -1 +0,0 @@
1
- import{usePicked as e}from"./client.js";import{useStoreGlobal as t}from"./use-store-global.js";function n(t){return e().features.getEvokableFeature(t)}function r(e){return t(n(e))}function i(n){let r=e();return t(r.features.getFeatureResult(n))}function a(n){let r=e();return t(r.features.getById(n))?.enabled}export{r as useFeature,a as useFeatureEnabled,i as useFeatureResult};
File without changes
@@ -1,56 +0,0 @@
1
- import type { Store } from 'effector';
2
- import { type ReferencedContent } from '@picked/client';
3
- /**
4
- * Resolves a single `reference` field value to the Content record it points at.
5
- *
6
- * The store is memoised on the field value, so re-rendering with the same
7
- * pointer keeps the same subscription. Consumers subscribe with `useStoreGlobal`.
8
- *
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
14
- * store keeps the lookup live when the field arrives after this call.
15
- * @returns {Store<ReferencedContent<TValue> | null>} The referenced record, or `null` when the field is unset or its target is not registered.
16
- * @throws {Error} When called outside a `ClientProvider`. The error is propagated unchanged from `usePicked()`.
17
- * @example
18
- * ```tsx
19
- * import { useReference, useStepContent, useStoreGlobal } from '@picked/react/hooks'
20
- *
21
- * const Byline = () => {
22
- * const content = useStepContent()
23
- * const author = useStoreGlobal(useReference(content?.author))
24
- * return <span>{String(author?.data.name ?? '')}</span>
25
- * }
26
- * ```
27
- */
28
- export declare function useReference<TValue>(value: TValue): Store<ReferencedContent<TValue> | null>;
29
- /**
30
- * Resolves a repeatable `reference` field to the Content records it points at,
31
- * in field order. A single (non-repeatable) value resolves to a one-element list.
32
- *
33
- * The list is dense: a pointer whose target did not resolve is skipped rather
34
- * than held as a hole, so the list can be rendered without a null check per item.
35
- *
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
41
- * store keeps the lookup live when the field arrives after this call.
42
- * @returns {Store<ReferencedContent<TValue>[]>} The referenced records that resolved.
43
- * @throws {Error} When called outside a `ClientProvider`. The error is propagated unchanged from `usePicked()`.
44
- * @example
45
- * ```tsx
46
- * import { useReferences, useStepContent, useStoreGlobal } from '@picked/react/hooks'
47
- *
48
- * const Authors = () => {
49
- * const content = useStepContent()
50
- * const authors = useStoreGlobal(useReferences(content?.authors))
51
- * return <ul>{authors.map((a) => <li key={a.id}>{String(a.data.name)}</li>)}</ul>
52
- * }
53
- * ```
54
- */
55
- export declare function useReferences<TValue>(value: TValue): Store<ReferencedContent<TValue>[]>;
56
- //# sourceMappingURL=reference.d.ts.map
@@ -1 +0,0 @@
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 +0,0 @@
1
- import{usePicked as e}from"./client.js";import{useMemo as t}from"react";import{deriveReference as n,deriveReferences as r}from"@picked/client";function i(r){let i=e();return t(()=>n(i.contents,r),[i,r])}function a(n){let i=e();return t(()=>r(i.contents,n),[i,n])}export{i as useReference,a as useReferences};
@@ -1 +0,0 @@
1
- import{describe as e,expectTypeOf 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(`narrows a text feature to its declared arms, including the boolean control`,()=>{t().toEqualTypeOf()}),n(`leaves a feature outside the value map resolving to the general value type`,()=>{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()})});
@@ -1 +0,0 @@
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().toEqualTypeOf(),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()})});
@@ -1,24 +0,0 @@
1
- import type { Store } from 'effector';
2
- /**
3
- * Reads an effector store's global value, independent of any effector scope a host app may have
4
- * installed via `effector-react`'s `<Provider>`.
5
- *
6
- * The Picked client is a global singleton (SSR isolation comes from per-request client instances,
7
- * not effector `fork()` scopes), so its stores must be read scope-agnostically. Reading them through
8
- * scope-aware `useUnit` inside a host `fork()` scope pins the value to the empty fork-time snapshot
9
- * and misses post-`start()` updates. This is the supported way for host apps to read any Picked
10
- * client store from React, including `useStep().fields`, whose form-evaluator store is created and
11
- * written in the global scope after a route-level fork is taken; a `useUnit(fields)` read in that
12
- * fork sees an empty array, while `useStoreGlobal(fields)` resolves the fields.
13
- *
14
- * @template T - The store's value type.
15
- * @param {Store<T>} store - The Picked client store to read globally.
16
- * @returns {T} The store's current global value, re-rendering on global updates.
17
- * @example
18
- * const experiences = useStoreGlobal(client.experiences.listStore)
19
- * @example
20
- * const { fields } = useStep()
21
- * const resolvedFields = useStoreGlobal(fields)
22
- */
23
- export declare function useStoreGlobal<T>(store: Store<T>): T;
24
- //# sourceMappingURL=use-store-global.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-store-global.d.ts","sourceRoot":"","sources":["../../src/hooks/use-store-global.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAgCrC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAMpD"}
@@ -1 +0,0 @@
1
- import{useSyncExternalStore as e}from"react";var t=new WeakMap;function n(e){let n=t.get(e);if(n)return n;let r=t=>{let n=e.watch(()=>t());return()=>n.unsubscribe()};return t.set(e,r),r}function r(t){return e(n(t),()=>t.getState(),()=>t.getState())}export{r as useStoreGlobal};
@@ -1 +0,0 @@
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()})});
@@ -1,25 +0,0 @@
1
- /** @file Step component that registers a step with the router and renders its content. */
2
- import type { ComponentType } from 'react';
3
- import React from 'react';
4
- interface StepProps {
5
- /** The step key used for registration and lookup. */
6
- readonly stepKey: string;
7
- readonly component?: ComponentType<Record<string, unknown>> | Promise<ComponentType<Record<string, unknown>>> | Promise<{
8
- default: ComponentType<Record<string, unknown>>;
9
- }>;
10
- readonly children?: React.ReactNode;
11
- }
12
- /**
13
- * Registers a step with the router and renders its component or children.
14
- *
15
- * @param {StepProps} props - The step props.
16
- * @param {string} props.stepKey - The step key used for registration and lookup.
17
- * @param {ComponentType | Promise<ComponentType> | Promise<{default: ComponentType}>} [props.component] - An optional component (sync or async) to render for this step.
18
- * @param {React.ReactNode} [props.children] - Optional children to render when no component is provided.
19
- * @returns {React.JSX.Element | null} The rendered step content wrapped in a step context provider.
20
- * @example
21
- * <Step stepKey="welcome" component={WelcomeStep} />
22
- */
23
- declare function Step({ stepKey, component, children }: StepProps): React.JSX.Element | null;
24
- export default Step;
25
- //# sourceMappingURL=Step.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Step.d.ts","sourceRoot":"","sources":["../../src/router/Step.tsx"],"names":[],"mappings":"AAAA,0FAA0F;AAC1F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAC1C,OAAO,KAAuC,MAAM,OAAO,CAAA;AAI3D,UAAU,SAAS;IACjB,qDAAqD;IACrD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,SAAS,CAAC,EACf,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACtC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,GAC/C,OAAO,CAAC;QAAE,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;KAAE,CAAC,CAAA;IAChE,QAAQ,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CACpC;AAED;;;;;;;;;;GAUG;AACH,iBAAS,IAAI,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,SAAS,4BAmDxD;eAEc,IAAI"}
@@ -1,17 +0,0 @@
1
- /** @file Root router component that manages step registration and active step detection. */
2
- import React from 'react';
3
- interface StepRouterProps {
4
- readonly children: React.ReactNode;
5
- }
6
- /**
7
- * Manages step registration and renders children within a step router context.
8
- *
9
- * @param {StepRouterProps} props - The router props.
10
- * @param {React.ReactNode} props.children - The steps to register and render.
11
- * @returns {React.JSX.Element | null} The step router context wrapping its children, or null until the current step is known.
12
- * @example
13
- * <StepRouter><Step key="welcome" /></StepRouter>
14
- */
15
- declare function StepRouter({ children }: StepRouterProps): React.JSX.Element | null;
16
- export default StepRouter;
17
- //# sourceMappingURL=StepRouter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"StepRouter.d.ts","sourceRoot":"","sources":["../../src/router/StepRouter.tsx"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,OAAO,KAAiD,MAAM,OAAO,CAAA;AAMrE,UAAU,eAAe;IACvB,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CACnC;AAED;;;;;;;;GAQG;AACH,iBAAS,UAAU,CAAC,EAAE,QAAQ,EAAE,EAAE,eAAe,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,GAAG,IAAI,CAiD3E;eAEc,UAAU"}
@@ -1,33 +0,0 @@
1
- /** @file Maps core FormField props to React-compatible camelCase event handlers. */
2
- import type { FormField } from '@picked/client/form';
3
- import type { ChangeEvent, FocusEvent, FormEvent } from 'react';
4
- type FieldElement = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
5
- export interface ReactFormFieldProps {
6
- id: string;
7
- name: string;
8
- key: string;
9
- value: FormField['props']['value'];
10
- type: FormField['props']['type'];
11
- required: boolean;
12
- placeholder: string | undefined;
13
- onInput: (e: FormEvent<FieldElement>) => void;
14
- onChange: (e: ChangeEvent<FieldElement>) => void;
15
- onBlur: (e: FocusEvent<FieldElement>) => void;
16
- }
17
- export type ReactFormField = Omit<FormField, 'props'> & {
18
- props: ReactFormFieldProps;
19
- };
20
- /**
21
- * Maps a core FormField to a React-compatible version with camelCase event handlers.
22
- *
23
- * Replaces lowercase DOM handlers (oninput, onchange, onblur) with React-style
24
- * camelCase handlers (onInput, onChange, onBlur) that bridge synthetic events to
25
- * the core SDK.
26
- *
27
- * @param {FormField} field - The core form field to map.
28
- * @returns {ReactFormField} A field with React-compatible props.
29
- * @example mapFieldToReact(coreField)
30
- */
31
- export declare function mapFieldToReact(field: FormField): ReactFormField;
32
- export {};
33
- //# sourceMappingURL=map-field-to-react.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"map-field-to-react.d.ts","sourceRoot":"","sources":["../../src/utils/map-field-to-react.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAkB,MAAM,OAAO,CAAA;AAG/E,KAAK,YAAY,GAAG,gBAAgB,GAAG,iBAAiB,GAAG,mBAAmB,CAAA;AAE9E,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAA;IAClC,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAA;IAChC,QAAQ,EAAE,OAAO,CAAA;IACjB,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,OAAO,EAAE,CAAC,CAAC,EAAE,SAAS,CAAC,YAAY,CAAC,KAAK,IAAI,CAAA;IAC7C,QAAQ,EAAE,CAAC,CAAC,EAAE,WAAW,CAAC,YAAY,CAAC,KAAK,IAAI,CAAA;IAChD,MAAM,EAAE,CAAC,CAAC,EAAE,UAAU,CAAC,YAAY,CAAC,KAAK,IAAI,CAAA;CAC9C;AAED,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,GAAG;IACtD,KAAK,EAAE,mBAAmB,CAAA;CAC3B,CAAA;AAwDD;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,GAAG,cAAc,CAYhE"}
@@ -1 +0,0 @@
1
- import{restoreCurrentTarget as e}from"./restore-current-target.js";function t(t){return n=>{e(n.nativeEvent,n.currentTarget),t(n.nativeEvent)}}function n(t,n){return r=>{e(r.nativeEvent,r.currentTarget),t.multiple&&r.currentTarget instanceof HTMLInputElement&&r.currentTarget.type===`checkbox`&&Object.defineProperty(r.nativeEvent,"type",{value:`change`,configurable:!0}),n(r.nativeEvent)}}function r(e){let{oninput:r,onchange:i,onblur:a,...o}=e.props;return{...e,props:{...o,onInput:t(r),onChange:n(e,i),onBlur:t(a)}}}export{r as mapFieldToReact};
@@ -1,17 +0,0 @@
1
- /** @file Type-safe bridge for React form events to the core SDK's SubmitEvent. */
2
- import type { SubmitEventWithCurrentTarget } from '@picked/client/form';
3
- /**
4
- * Narrows a native form submit event to SubmitEventWithCurrentTarget, restoring
5
- * currentTarget as a side effect so the core SDK can build FormData.
6
- *
7
- * Always runs unconditionally. Testing-library's `fireEvent.submit` dispatches
8
- * a plain Event (not SubmitEvent), and some legacy programmatic submits do the
9
- * same. The core consumer only reads currentTarget, so the narrowed type is a
10
- * TypeScript assertion, not a runtime gate.
11
- *
12
- * @param {Event} nativeEvent - Native DOM event from a React form submission.
13
- * @param {HTMLFormElement} currentTarget - Form element from React's synthetic event.
14
- * @example prepareNativeEvent(e.nativeEvent, e.currentTarget)
15
- */
16
- export declare function prepareNativeEvent(nativeEvent: Event, currentTarget: HTMLFormElement): asserts nativeEvent is SubmitEventWithCurrentTarget;
17
- //# sourceMappingURL=prepare-native-event.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"prepare-native-event.d.ts","sourceRoot":"","sources":["../../src/utils/prepare-native-event.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAA;AAGvE;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,KAAK,EAClB,aAAa,EAAE,eAAe,GAC7B,OAAO,CAAC,WAAW,IAAI,4BAA4B,CAErD"}
@@ -1 +0,0 @@
1
- import{restoreCurrentTarget as e}from"./restore-current-target.js";function t(t,n){e(t,n)}export{t as prepareNativeEvent};