@picked/react 0.0.1-dev.1770178792114 → 0.0.1-dev.1770256874555
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/context.d.ts +3 -77
- package/dist/context.d.ts.map +1 -1
- package/dist/hooks/client.js +1 -1
- package/dist/hooks/step.js +1 -1
- package/dist/hooks/storage.js +1 -1
- package/package.json +2 -2
package/dist/context.d.ts
CHANGED
|
@@ -1,80 +1,6 @@
|
|
|
1
|
-
import { Picked } from '@picked/client';
|
|
1
|
+
import { ExperienceInstance, Picked } from '@picked/client';
|
|
2
2
|
export declare const ClientContext: import('react').Context<Picked | null>;
|
|
3
3
|
export declare const ClientProvider: import('react').Provider<Picked | null>;
|
|
4
|
-
export declare const ExperienceContext: import('react').Context<
|
|
5
|
-
|
|
6
|
-
experienceId: string;
|
|
7
|
-
configStore: import('effector').Store<{
|
|
8
|
-
name: string;
|
|
9
|
-
decisionLogic: import('node_modules/@picked/client/dist/types/logic-engine').LogicRule | undefined;
|
|
10
|
-
targetSelectors: import('@picked/client').ExperienceTarget[];
|
|
11
|
-
initializeOpenLogic: import('node_modules/@picked/client/dist/types/logic-engine').LogicValue | import('node_modules/@picked/client/dist/types/logic-engine').LogicRule;
|
|
12
|
-
}>;
|
|
13
|
-
target: HTMLElement | undefined;
|
|
14
|
-
componentStore: import('effector').Store<{
|
|
15
|
-
name: string;
|
|
16
|
-
component: import('@picked/client').AdaptedComponent<string, unknown>;
|
|
17
|
-
frameworkStore: import('effector').Store<import('@picked/client').Framework | undefined>;
|
|
18
|
-
} | undefined>;
|
|
19
|
-
stateStore: import('effector').StoreWritable<"transitioning" | "ready">;
|
|
20
|
-
isOpenStore: import('effector').StoreWritable<boolean>;
|
|
21
|
-
open: import('effector').EventCallable<void>;
|
|
22
|
-
close: import('effector').EventCallable<void>;
|
|
23
|
-
toggleOpen: import('effector').EventCallable<void>;
|
|
24
|
-
setOpen: import('effector').EventCallable<boolean>;
|
|
25
|
-
treeStore: import('effector').Store<{
|
|
26
|
-
steps: import('@picked/client').ExperienceStep[];
|
|
27
|
-
nodes: import('@picked/client').ExperienceNode[];
|
|
28
|
-
edges: import('@picked/client').ExperienceEdge[];
|
|
29
|
-
conditionals: import('@picked/client').ExperienceConditional[];
|
|
30
|
-
}>;
|
|
31
|
-
fieldsStore: import('effector').Store<import('@picked/client').Field[]>;
|
|
32
|
-
currentNodeStore: import('effector').Store<import('@picked/client').ExperienceNode | null>;
|
|
33
|
-
currentStepStore: import('effector').Store<import('@picked/client').ExperienceStep | null>;
|
|
34
|
-
nextReachableStepNodesStore: import('effector').Store<import('@picked/client').ExperienceNode[]>;
|
|
35
|
-
stepsToOriginStore: import('effector').Store<number[]>;
|
|
36
|
-
stepsToLeafStore: import('effector').Store<number[]>;
|
|
37
|
-
goToNextStep: import('effector').EventCallable<void>;
|
|
38
|
-
goToPreviousStep: import('effector').EventCallable<void>;
|
|
39
|
-
goToStepById: import('effector').EventCallable<string>;
|
|
40
|
-
stepsHistoryStore: import('effector').Store<import('@picked/client').HistoryEntry[]>;
|
|
41
|
-
} | null>;
|
|
42
|
-
export declare const ExperienceProvider: import('react').Provider<{
|
|
43
|
-
id: string;
|
|
44
|
-
experienceId: string;
|
|
45
|
-
configStore: import('effector').Store<{
|
|
46
|
-
name: string;
|
|
47
|
-
decisionLogic: import('node_modules/@picked/client/dist/types/logic-engine').LogicRule | undefined;
|
|
48
|
-
targetSelectors: import('@picked/client').ExperienceTarget[];
|
|
49
|
-
initializeOpenLogic: import('node_modules/@picked/client/dist/types/logic-engine').LogicValue | import('node_modules/@picked/client/dist/types/logic-engine').LogicRule;
|
|
50
|
-
}>;
|
|
51
|
-
target: HTMLElement | undefined;
|
|
52
|
-
componentStore: import('effector').Store<{
|
|
53
|
-
name: string;
|
|
54
|
-
component: import('@picked/client').AdaptedComponent<string, unknown>;
|
|
55
|
-
frameworkStore: import('effector').Store<import('@picked/client').Framework | undefined>;
|
|
56
|
-
} | undefined>;
|
|
57
|
-
stateStore: import('effector').StoreWritable<"transitioning" | "ready">;
|
|
58
|
-
isOpenStore: import('effector').StoreWritable<boolean>;
|
|
59
|
-
open: import('effector').EventCallable<void>;
|
|
60
|
-
close: import('effector').EventCallable<void>;
|
|
61
|
-
toggleOpen: import('effector').EventCallable<void>;
|
|
62
|
-
setOpen: import('effector').EventCallable<boolean>;
|
|
63
|
-
treeStore: import('effector').Store<{
|
|
64
|
-
steps: import('@picked/client').ExperienceStep[];
|
|
65
|
-
nodes: import('@picked/client').ExperienceNode[];
|
|
66
|
-
edges: import('@picked/client').ExperienceEdge[];
|
|
67
|
-
conditionals: import('@picked/client').ExperienceConditional[];
|
|
68
|
-
}>;
|
|
69
|
-
fieldsStore: import('effector').Store<import('@picked/client').Field[]>;
|
|
70
|
-
currentNodeStore: import('effector').Store<import('@picked/client').ExperienceNode | null>;
|
|
71
|
-
currentStepStore: import('effector').Store<import('@picked/client').ExperienceStep | null>;
|
|
72
|
-
nextReachableStepNodesStore: import('effector').Store<import('@picked/client').ExperienceNode[]>;
|
|
73
|
-
stepsToOriginStore: import('effector').Store<number[]>;
|
|
74
|
-
stepsToLeafStore: import('effector').Store<number[]>;
|
|
75
|
-
goToNextStep: import('effector').EventCallable<void>;
|
|
76
|
-
goToPreviousStep: import('effector').EventCallable<void>;
|
|
77
|
-
goToStepById: import('effector').EventCallable<string>;
|
|
78
|
-
stepsHistoryStore: import('effector').Store<import('@picked/client').HistoryEntry[]>;
|
|
79
|
-
} | null>;
|
|
4
|
+
export declare const ExperienceContext: import('react').Context<ExperienceInstance | null>;
|
|
5
|
+
export declare const ExperienceProvider: import('react').Provider<ExperienceInstance | null>;
|
|
80
6
|
//# 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,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"}
|
package/dist/hooks/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useContext as t}from"react";import{
|
|
1
|
+
import{useContext as t}from"react";import{ExperienceContext as n,ClientContext as r}from"../context.js";function i(){const e=t(r);if(!e)throw new Error("usePicked must be used within a ClientProvider");return e}function o(){const e=t(n);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/step.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createContext as w,
|
|
1
|
+
import{createContext as w,useMemo as a,useContext as b}from"react";import{attach as E,createEffect as F,combine as R,createStore as A,sample as P}from"effector";import{evaluateRuleLogic as g}from"@picked/client";import{useUnit as k}from"effector-react";import{useStepRouter as y}from"../router/context.js";import{useExperience as D,usePicked as L}from"./client.js";const M=w(null);function B(){const e=b(M);if(!e)throw new Error("useStep must be used within a StepContextProvider");return{step:e.step,fields:e.fields,isActiveStep:e.isActiveStep??!1}}function G(e){const l=D(),s=L(),{activeStep:p}=y(),m=a(()=>p?.id===e,[p?.id,e]),{stepContext:S}=a(()=>{const o=E({source:R({steps:l.treeStore.map(i=>i.steps),fields:s.fields.listStore,responses:s.responses.listStore}),effect:F(async({steps:i,fields:r,responses:x})=>{const n=i.find(t=>t.id===e);if(!n)throw new Error(`Step with id "${e}" not found in the experience tree.`);const v=r.filter(t=>n.fieldIds.includes(t.id)),c=[];for(const t of v)t.condition?await g(s,t.condition)&&c.push(t):c.push(t);const C=c.map(t=>{const u=x.find(h=>h.fieldId===t.id)?.value;return{...t,value:u}});return{step:{id:n.id,label:n.label},fields:C}})}),f=A({step:{id:e,label:""},fields:[]});return f.on(o.doneData,(i,r)=>r),P({clock:[s.fields.listStore,s.responses.listStore],target:o}),o(),{stepContextFx:o,stepContext:f}},[e,s,l]),d=k(S);return{step:d?.step,fields:d?.fields||[],isActiveStep:m}}export{M as StepContextProvider,G as useSetStepContext,B as useStep};
|
package/dist/hooks/storage.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useState as x,useEffect as a,useCallback as d}from"react";import{createStorageKey as k,
|
|
1
|
+
import{useState as x,useEffect as a,useCallback as d}from"react";import{createStorageKey as k,sessionStore as v,localStore as E,supportsSessionStorage as K,supportsLocalStorage 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"?v:E,r=o==="session"?K:L,[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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@picked/react",
|
|
3
|
-
"version": "0.0.1-dev.
|
|
3
|
+
"version": "0.0.1-dev.1770256874555",
|
|
4
4
|
"devDependencies": {
|
|
5
5
|
"@picked/client": "workspace:*",
|
|
6
6
|
"@repo/eslint-config": "workspace:*",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
],
|
|
59
59
|
"module": "./dist/index.js",
|
|
60
60
|
"peerDependencies": {
|
|
61
|
-
"@picked/client": "0.0.1-dev.
|
|
61
|
+
"@picked/client": "0.0.1-dev.1770256874555",
|
|
62
62
|
"effector": "^23.3.0",
|
|
63
63
|
"effector-react": "^23.3.0",
|
|
64
64
|
"react": "19.2.2",
|