@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.
- package/dist/component.d.ts +5 -5
- package/dist/component.d.ts.map +1 -1
- package/dist/component.js +1 -1
- package/dist/context.d.ts +75 -5
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +1 -1
- package/dist/form/index.d.ts +13 -47
- package/dist/form/index.d.ts.map +1 -1
- package/dist/form/index.js +1 -1
- package/dist/hooks/client.d.ts +9 -9
- package/dist/hooks/client.d.ts.map +1 -1
- package/dist/hooks/client.js +1 -1
- package/dist/hooks/field.d.ts +5 -17
- package/dist/hooks/field.d.ts.map +1 -1
- package/dist/hooks/field.js +1 -1
- package/dist/hooks/index.d.ts +2 -14
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/step.d.ts +21 -96
- package/dist/hooks/step.d.ts.map +1 -1
- package/dist/hooks/step.js +1 -1
- package/dist/hooks/storage.d.ts +1 -1
- package/dist/hooks/storage.js +1 -1
- package/dist/index.d.ts +0 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/plugins/framework/index.js +1 -1
- package/dist/plugins/framework/plugin.d.ts +4 -4
- package/dist/plugins/framework/plugin.d.ts.map +1 -1
- package/dist/plugins/framework/plugin.js +1 -1
- package/dist/render/browser.d.ts +2 -2
- package/dist/render/browser.d.ts.map +1 -1
- package/dist/render/browser.js +1 -1
- package/dist/render/server.d.ts +1 -1
- package/dist/render/server.d.ts.map +1 -1
- package/dist/render/server.js +1 -1
- package/dist/router/Step.js +1 -1
- package/dist/router/StepRouter.js +1 -1
- package/dist/router/context.d.ts +2 -2
- package/dist/router/context.d.ts.map +1 -1
- package/dist/router/context.js +1 -1
- package/dist/router/index.js +1 -1
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.js +1 -1
- package/dist/utils/array.d.ts.map +1 -1
- package/dist/utils/array.js +1 -1
- package/package.json +33 -92
- package/dist/.tsbuildinfo +0 -1
- package/dist/experience/ExperienceHost.d.ts +0 -34
- package/dist/experience/ExperienceHost.d.ts.map +0 -1
- package/dist/experience/ExperienceHost.js +0 -1
- package/dist/experience/ExperienceSlot.d.ts +0 -35
- package/dist/experience/ExperienceSlot.d.ts.map +0 -1
- package/dist/experience/ExperienceSlot.js +0 -1
- package/dist/experience/HtmlRender.d.ts +0 -33
- package/dist/experience/HtmlRender.d.ts.map +0 -1
- package/dist/experience/HtmlRender.js +0 -1
- package/dist/experience/PickedProvider.d.ts +0 -42
- package/dist/experience/PickedProvider.d.ts.map +0 -1
- package/dist/experience/PickedProvider.js +0 -1
- package/dist/experience/morph.d.ts +0 -26
- package/dist/experience/morph.d.ts.map +0 -1
- package/dist/experience/morph.js +0 -1
- package/dist/form/use-form-callbacks.d.ts +0 -45
- package/dist/form/use-form-callbacks.d.ts.map +0 -1
- package/dist/form/use-form-callbacks.js +0 -1
- package/dist/hooks/action.d.ts +0 -39
- package/dist/hooks/action.d.ts.map +0 -1
- package/dist/hooks/action.js +0 -1
- package/dist/hooks/content.d.ts +0 -24
- package/dist/hooks/content.d.ts.map +0 -1
- package/dist/hooks/content.js +0 -1
- package/dist/hooks/feature.d.ts +0 -45
- package/dist/hooks/feature.d.ts.map +0 -1
- package/dist/hooks/feature.js +0 -1
- package/dist/hooks/fixtures/augmented-registry.d.js +0 -0
- package/dist/hooks/reference.d.ts +0 -56
- package/dist/hooks/reference.d.ts.map +0 -1
- package/dist/hooks/reference.js +0 -1
- package/dist/hooks/typed-hooks-augmented.test-d.js +0 -1
- package/dist/hooks/typed-hooks.test-d.js +0 -1
- package/dist/hooks/use-store-global.d.ts +0 -24
- package/dist/hooks/use-store-global.d.ts.map +0 -1
- package/dist/hooks/use-store-global.js +0 -1
- package/dist/public-types.test-d.js +0 -1
- package/dist/router/Step.d.ts +0 -25
- package/dist/router/Step.d.ts.map +0 -1
- package/dist/router/StepRouter.d.ts +0 -17
- package/dist/router/StepRouter.d.ts.map +0 -1
- package/dist/utils/map-field-to-react.d.ts +0 -33
- package/dist/utils/map-field-to-react.d.ts.map +0 -1
- package/dist/utils/map-field-to-react.js +0 -1
- package/dist/utils/prepare-native-event.d.ts +0 -17
- package/dist/utils/prepare-native-event.d.ts.map +0 -1
- package/dist/utils/prepare-native-event.js +0 -1
- package/dist/utils/restore-current-target.d.ts +0 -17
- package/dist/utils/restore-current-target.d.ts.map +0 -1
- package/dist/utils/restore-current-target.js +0 -1
package/dist/component.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
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
|
-
}
|
|
6
|
+
}>, style?: AdaptedComponentStyle) => AdaptedComponent<"react", ComponentWithProps | Promise<{
|
|
7
7
|
default: ComponentWithProps;
|
|
8
|
-
}
|
|
9
|
-
export declare const isValidAdaptedComponent: (component: AdaptedComponent<string, unknown>) => component is AdaptedComponent<
|
|
8
|
+
}>>;
|
|
9
|
+
export declare const isValidAdaptedComponent: (component: AdaptedComponent<string, unknown>) => component is AdaptedComponent<"react", ComponentWithProps>;
|
|
10
10
|
//# sourceMappingURL=component.d.ts.map
|
package/dist/component.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../src/component.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,
|
|
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
|
-
|
|
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
|
|
2
|
-
export declare const ClientContext: import(
|
|
3
|
-
export declare const ClientProvider: import(
|
|
4
|
-
export declare const ExperienceContext: import(
|
|
5
|
-
|
|
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
|
package/dist/context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
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";
|
|
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};
|
package/dist/form/index.d.ts
CHANGED
|
@@ -1,50 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export
|
|
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
|
-
|
|
12
|
-
|
|
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
|
-
|
|
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
|
package/dist/form/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/form/index.ts"],"names":[],"mappings":"AAAA,
|
|
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"}
|
package/dist/form/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
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};
|
package/dist/hooks/client.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ExperienceInstance, Picked } from '@picked/client';
|
|
2
2
|
/**
|
|
3
|
-
* Retrieves the Picked Client for the Experience Instance
|
|
4
|
-
*
|
|
5
|
-
* @
|
|
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
|
-
*
|
|
12
|
-
* @
|
|
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":"
|
|
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"}
|
package/dist/hooks/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
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};
|
package/dist/hooks/field.d.ts
CHANGED
|
@@ -1,20 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
|
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"}
|
package/dist/hooks/field.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
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};
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,17 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
|
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"}
|
package/dist/hooks/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
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};
|
package/dist/hooks/step.d.ts
CHANGED
|
@@ -1,100 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
package/dist/hooks/step.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../src/hooks/step.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
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"}
|
package/dist/hooks/step.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
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};
|
package/dist/hooks/storage.d.ts
CHANGED
package/dist/hooks/storage.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
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
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
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
|
|
1
|
+
import{adaptReactComponent as a,isValidAdaptedComponent as e}from"./component.js";export{a as adaptReactComponent,e as isValidAdaptedComponent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{reactFrameworkPlugin as
|
|
1
|
+
import{reactFrameworkPlugin as o}from"./plugin.js";export{o as reactFrameworkPlugin};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
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,
|
|
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
|
|
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};
|
package/dist/render/browser.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
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
|
|
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":"
|
|
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"}
|
package/dist/render/browser.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isValidAdaptedComponent as
|
|
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};
|
package/dist/render/server.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
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;
|
|
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"}
|