@picked/react 0.0.1-dev.1773729274420 → 0.0.1-dev.1773804563218
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/hooks/client.d.ts +8 -8
- package/dist/hooks/client.d.ts.map +1 -1
- package/dist/hooks/client.js +1 -1
- package/dist/hooks/field.d.ts +1 -1
- package/dist/hooks/field.d.ts.map +1 -1
- package/dist/hooks/field.js +1 -1
- package/dist/hooks/index.d.ts +6 -1
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/step.d.ts +17 -2
- package/dist/hooks/step.d.ts.map +1 -1
- package/dist/hooks/step.js +1 -1
- package/package.json +19 -2
package/dist/hooks/client.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { ExperienceInstance, Picked } from '@picked/client';
|
|
2
2
|
/**
|
|
3
|
-
* Retrieves the Picked Client for the Experience Instance
|
|
4
|
-
*
|
|
5
|
-
* @
|
|
3
|
+
* Retrieves the Picked Client for the Experience Instance.
|
|
4
|
+
* @returns The Picked client instance that provides access to experiences, steps, and other Picked functionality.
|
|
5
|
+
* @example
|
|
6
|
+
* const client = usePicked()
|
|
6
7
|
*/
|
|
7
8
|
export declare function usePicked(): Picked;
|
|
8
9
|
/**
|
|
9
|
-
* Retrieves the Experience Store for the current Experience Instance
|
|
10
|
-
*
|
|
11
|
-
* @
|
|
10
|
+
* Retrieves the Experience Store for the current Experience Instance.
|
|
11
|
+
* @returns The Experience store instance that provides access to experience configuration and state.
|
|
12
|
+
* @example
|
|
13
|
+
* const experience = useExperience()
|
|
12
14
|
*/
|
|
13
15
|
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":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAGhE;;;;;GAKG;AACH,wBAAgB,SAAS,IAAI,MAAM,CAOlC;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,IAAI,kBAAkB,CAOlD"}
|
package/dist/hooks/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useContext as t}from"react";import{ExperienceContext as
|
|
1
|
+
import{useContext as t}from"react";import{ExperienceContext as r,ClientContext as n}from"../context.js";function u(){const e=t(n);if(!e)throw new Error("usePicked must be used within a ClientProvider");return e}function c(){const e=t(r);if(!e)throw new Error("useExperience must be used within an ExperienceProvider");return e}export{c as useExperience,u as usePicked};
|
package/dist/hooks/field.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
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,
|
|
1
|
+
{"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../../src/hooks/field.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AACvD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAGrC,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,CAAA;IACxB,KAAK,EAAE,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,CAAA;CAC3B;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAQtD"}
|
package/dist/hooks/field.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{usePicked as o}from"./client.js";function r(e){const t=o(),s=t.fields.getByKey(e),n=t.responses.getByFieldKey(e);return{field:s,value:n}}export{r as getField};
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @file Public re-exports for the hooks entry point.
|
|
3
|
+
*/
|
|
4
|
+
export { usePicked, useExperience } from './client';
|
|
2
5
|
export { useStep, useSetStepContext } from './step';
|
|
6
|
+
export type { StepContext } from './step';
|
|
3
7
|
export { useSessionStorage, useLocalStorage } from './storage';
|
|
8
|
+
export type { UseStorageOptions } from './storage';
|
|
4
9
|
export * from './field';
|
|
5
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAA;AACnD,YAAY,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AACzC,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAC9D,YAAY,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAClD,cAAc,SAAS,CAAA"}
|
package/dist/hooks/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{useExperience as t,usePicked as r}from"./client.js";import{useSetStepContext as p,useStep as u}from"./step.js";import{useLocalStorage as S,useSessionStorage as f}from"./storage.js";import{getField as m}from"./field.js";export{m as getField,t as useExperience,S as useLocalStorage,r as usePicked,f as useSessionStorage,p as useSetStepContext,u as useStep};
|
package/dist/hooks/step.d.ts
CHANGED
|
@@ -2,21 +2,36 @@ import { Field, Response } from '@picked/client';
|
|
|
2
2
|
type FieldWithValue = Field & {
|
|
3
3
|
value: Response | undefined;
|
|
4
4
|
};
|
|
5
|
-
|
|
5
|
+
interface StepWithLabel {
|
|
6
6
|
id: string;
|
|
7
7
|
label: string;
|
|
8
|
-
}
|
|
8
|
+
}
|
|
9
9
|
export interface StepContext {
|
|
10
10
|
step: StepWithLabel;
|
|
11
11
|
fields: FieldWithValue[];
|
|
12
12
|
isActiveStep?: boolean;
|
|
13
13
|
}
|
|
14
14
|
export declare const StepContextProvider: import('react').Context<StepContext | null>;
|
|
15
|
+
/**
|
|
16
|
+
* Returns the current step context, including step metadata and evaluated fields.
|
|
17
|
+
* Must be used within a component wrapped by `StepContextProvider`.
|
|
18
|
+
* @returns The step, its evaluated fields, and whether this is the active step.
|
|
19
|
+
* @example
|
|
20
|
+
* const { step, fields, isActiveStep } = useStep()
|
|
21
|
+
*/
|
|
15
22
|
export declare function useStep(): {
|
|
16
23
|
step: StepWithLabel;
|
|
17
24
|
fields: FieldWithValue[];
|
|
18
25
|
isActiveStep: boolean;
|
|
19
26
|
};
|
|
27
|
+
/**
|
|
28
|
+
* Creates and returns step context stores for the given step ID.
|
|
29
|
+
* Evaluates field conditions reactively whenever fields or responses change.
|
|
30
|
+
* @param stepId - The ID of the step to set context for.
|
|
31
|
+
* @returns The step metadata, evaluated fields, and active step indicator.
|
|
32
|
+
* @example
|
|
33
|
+
* const { step, fields, isActiveStep } = useSetStepContext('step-123')
|
|
34
|
+
*/
|
|
20
35
|
export declare function useSetStepContext(stepId: string): {
|
|
21
36
|
step: StepWithLabel;
|
|
22
37
|
fields: FieldWithValue[];
|
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":"
|
|
1
|
+
{"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../src/hooks/step.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAoC,MAAM,gBAAgB,CAAA;AAMvF,KAAK,cAAc,GAAG,KAAK,GAAG;IAAE,KAAK,EAAE,QAAQ,GAAG,SAAS,CAAA;CAAE,CAAA;AAC7D,UAAU,aAAa;IACrB,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;CACd;AAOD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,aAAa,CAAA;IACnB,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB;AAED,eAAO,MAAM,mBAAmB,6CAA0C,CAAA;AAE1E;;;;;;GAMG;AACH,wBAAgB,OAAO;;;;EAWtB;AAeD;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM;;;;EA8G/C"}
|
package/dist/hooks/step.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createContext as
|
|
1
|
+
import{createContext as y,useMemo as m,useContext as E}from"react";import{combine as S,attach as F,createEffect as P,createStore as R,sample as k}from"effector";import{evaluateRuleLogic as A}from"@picked/client";import{useUnit as g}from"effector-react";import{useStepRouter as K}from"../router/context.js";import{useExperience as _,usePicked as B}from"./client.js";const D=y(null);function G(){const t=E(D);if(!t)throw new Error("useStep must be used within a StepContextProvider");return{step:t.step,fields:t.fields,isActiveStep:t.isActiveStep??!1}}function H(t){const l=_(),s=B(),{activeStep:f}=K(),x=m(()=>f?.id===t,[f?.id,t]),{stepContext:v}=m(()=>{const C=l.treeStore.map(o=>o.steps),h=S(C,s.steps.listStore,(o,i)=>i.filter(c=>o.includes(c.id))),r=F({source:S({steps:h,fields:s.fields.listStore,responses:s.responses.listStore}),mapParams:(o,i)=>i,effect:P(async({steps:o,fields:i,responses:c})=>{const n=o.find(e=>e.id===t);if(!n)throw new Error(`Step with id "${t}" not found in the experience tree.`);const w=i.filter(e=>(n.fieldIds??[]).includes(e.id)),p=[];for(const e of w)e.condition?await A(s,e.condition)&&p.push(e):p.push(e);const a={};for(const e of c)a[e.fieldKey]=e;const b=p.map(e=>({...e,value:a[e.key]?.value}));return{step:{id:n.id,label:n.name??n.label},fields:b}})}),u=R({step:{id:t,label:""},fields:[]});return u.on(r.doneData,(o,i)=>i),k({clock:[s.fields.listStore,s.responses.listStore],target:r}),r(),{stepContextFx:r,stepContext:u}},[t,s,l]),d=g(v);return{step:d.step,fields:d.fields,isActiveStep:x}}export{D as StepContextProvider,H as useSetStepContext,G as useStep};
|
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.1773804563218",
|
|
4
4
|
"devDependencies": {
|
|
5
5
|
"@picked/client": "workspace:*",
|
|
6
6
|
"@repo/eslint-config": "workspace:*",
|
|
@@ -59,16 +59,33 @@
|
|
|
59
59
|
"dist"
|
|
60
60
|
],
|
|
61
61
|
"knip": {
|
|
62
|
+
"entry": [
|
|
63
|
+
"src/index.ts",
|
|
64
|
+
"src/server/index.ts",
|
|
65
|
+
"src/router/index.ts",
|
|
66
|
+
"src/form/index.ts",
|
|
67
|
+
"src/hooks/index.ts",
|
|
68
|
+
"src/plugins/framework/index.ts"
|
|
69
|
+
],
|
|
70
|
+
"ignore": [
|
|
71
|
+
"eslint.config.js"
|
|
72
|
+
],
|
|
62
73
|
"ignoreBinaries": [
|
|
74
|
+
"attw",
|
|
63
75
|
"knip",
|
|
64
76
|
"jscpd",
|
|
65
77
|
"eslint",
|
|
66
78
|
"tsc"
|
|
79
|
+
],
|
|
80
|
+
"ignoreDependencies": [
|
|
81
|
+
"@picked/client",
|
|
82
|
+
"@repo/eslint-config",
|
|
83
|
+
"@repo/typescript-config"
|
|
67
84
|
]
|
|
68
85
|
},
|
|
69
86
|
"module": "./dist/index.js",
|
|
70
87
|
"peerDependencies": {
|
|
71
|
-
"@picked/client": "0.0.1-dev.
|
|
88
|
+
"@picked/client": "0.0.1-dev.1773804563218",
|
|
72
89
|
"effector": "^23.3.0",
|
|
73
90
|
"effector-react": "^23.3.0",
|
|
74
91
|
"react": "19.2.2",
|