@picked/react 0.0.1-dev.1776839789244 → 0.0.1-dev.1777506629683
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.
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Action, ExperienceInstance } from '@picked/client';
|
|
2
|
+
type ActionResult = string | string[] | boolean | void | undefined;
|
|
3
|
+
/**
|
|
4
|
+
* Returns the current evokable action function, reactive to store updates.
|
|
5
|
+
* When `options.experience` is provided, the wrapped call passes that
|
|
6
|
+
* experience as the action's context so manually-invoked handlers can
|
|
7
|
+
* behave as if they were triggered by that experience — for example, to
|
|
8
|
+
* call `context.experience.close()` after a submit.
|
|
9
|
+
*
|
|
10
|
+
* @param {string} actionKey - The registered action key.
|
|
11
|
+
* @param {object} [options] - Optional invocation overrides.
|
|
12
|
+
* @param {ExperienceInstance} options.experience - Experience to bind as the action's context.
|
|
13
|
+
* @returns {() => ReturnType<Action>} The callable action function.
|
|
14
|
+
* @example
|
|
15
|
+
* const evoke = useAction('log-event')
|
|
16
|
+
* const bound = useAction('submit-form', { experience: useExperience() })
|
|
17
|
+
*/
|
|
18
|
+
export declare function useAction(actionKey: string, options?: {
|
|
19
|
+
experience: ExperienceInstance;
|
|
20
|
+
}): () => ReturnType<Action>;
|
|
21
|
+
/**
|
|
22
|
+
* Returns the latest result of invoking the keyed action, reactive to store updates.
|
|
23
|
+
* Re-evaluates whenever the underlying evokable store emits.
|
|
24
|
+
*
|
|
25
|
+
* @param {string} actionKey - The registered action key.
|
|
26
|
+
* @param {object} [options] - Optional invocation overrides.
|
|
27
|
+
* @param {ExperienceInstance} options.experience - Experience to bind as the action's context.
|
|
28
|
+
* @returns {ActionResult} The latest action return value.
|
|
29
|
+
* @example
|
|
30
|
+
* const result = useActionResult('is-logged-in')
|
|
31
|
+
*/
|
|
32
|
+
export declare function useActionResult(actionKey: string, options?: {
|
|
33
|
+
experience: ExperienceInstance;
|
|
34
|
+
}): ActionResult;
|
|
35
|
+
export {};
|
|
36
|
+
//# sourceMappingURL=action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../src/hooks/action.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAKhE,KAAK,YAAY,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAA;AAElE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,SAAS,CACvB,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE;IAAE,UAAU,EAAE,kBAAkB,CAAA;CAAE,GAC3C,MAAM,UAAU,CAAC,MAAM,CAAC,CAG1B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE;IAAE,UAAU,EAAE,kBAAkB,CAAA;CAAE,GAC3C,YAAY,CAmCd"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{usePicked as e}from"./client.js";import{attach as t,createEffect as n,createEvent as r,createStore as i,sample as a}from"effector";import{useUnit as o}from"effector-react";function s(t,n){return o(e().actions.getEvokableAction(t,n))}function c(s,c){let l=e().actions.getEvokableAction(s,c),u=i(void 0,{skipVoid:!1}),d=r(),f=t({source:l,mapParams:(e,t)=>t,effect:n(async e=>{if(e)return await e()})});return a({clock:d,target:f}),a({clock:f.doneData,target:u}),d(),a({clock:l,target:d}),o(u)}export{s as useAction,c as useActionResult};
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -9,4 +9,5 @@ export { useSessionStorage, useLocalStorage } from './storage';
|
|
|
9
9
|
export type { UseStorageOptions } from './storage';
|
|
10
10
|
export * from './field';
|
|
11
11
|
export { useFeature, useFeatureResult } from './feature';
|
|
12
|
+
export { useAction, useActionResult } from './action';
|
|
12
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AACjG,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EAAE,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;AACvB,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AACjG,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EAAE,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;AACvB,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AACxD,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA"}
|
package/dist/hooks/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ClientContext as e,ClientProvider as t,ExperienceContext as n,ExperienceProvider as r}from"../context.js";import{useExperience as i,usePicked as a}from"./client.js";import{
|
|
1
|
+
import{ClientContext as e,ClientProvider as t,ExperienceContext as n,ExperienceProvider as r}from"../context.js";import{useExperience as i,usePicked as a}from"./client.js";import{useAction as o,useActionResult as s}from"./action.js";import{useFeature as c,useFeatureResult as l}from"./feature.js";import{getField as u}from"./field.js";import{useSetStepContext as d,useStep as f}from"./step.js";import{useLocalStorage as p,useSessionStorage as m}from"./storage.js";export{e as ClientContext,t as ClientProvider,n as ExperienceContext,r as ExperienceProvider,u as getField,o as useAction,s as useActionResult,i as useExperience,c as useFeature,l as useFeatureResult,p as useLocalStorage,a as usePicked,m as useSessionStorage,d as useSetStepContext,f 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.1777506629683",
|
|
4
4
|
"devDependencies": {
|
|
5
5
|
"@picked/client": "workspace:*",
|
|
6
6
|
"@repo/eslint-config": "workspace:*",
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
},
|
|
86
86
|
"module": "./dist/index.js",
|
|
87
87
|
"peerDependencies": {
|
|
88
|
-
"@picked/client": "0.0.1-dev.
|
|
88
|
+
"@picked/client": "0.0.1-dev.1777506629683",
|
|
89
89
|
"effector": "^23.3.0",
|
|
90
90
|
"effector-react": "^23.3.0",
|
|
91
91
|
"react": "19.2.2",
|