@stackflow/react
Advanced tools
Comparing version 0.4.0 to 0.5.0
export declare const useCoreActions: () => { | ||
dispatchEvent: import("@stackflow/core").DispatchEvent; | ||
getStack: () => import("@stackflow/core").AggregateOutput; | ||
push: ({ activityId, activityName, params, }: { | ||
push: ({ activityId, activityName, params, skipEnterActiveState, }: { | ||
activityId: string; | ||
@@ -10,4 +10,5 @@ activityName: string; | ||
}; | ||
skipEnterActiveState?: boolean | undefined; | ||
}) => void; | ||
replace: ({ activityId, activityName, params, }: { | ||
replace: ({ activityId, activityName, params, skipEnterActiveState, }: { | ||
activityId: string; | ||
@@ -18,4 +19,7 @@ activityName: string; | ||
}; | ||
skipEnterActiveState?: boolean | undefined; | ||
}) => void; | ||
pop: () => void; | ||
pop: (params?: { | ||
skipExitActiveState?: boolean | undefined; | ||
} | undefined) => void; | ||
}; |
@@ -1,2 +0,2 @@ | ||
var Dt=Object.create;var O=Object.defineProperty,Ot=Object.defineProperties,bt=Object.getOwnPropertyDescriptor,It=Object.getOwnPropertyDescriptors,Nt=Object.getOwnPropertyNames,$=Object.getOwnPropertySymbols,Mt=Object.getPrototypeOf,Q=Object.prototype.hasOwnProperty,Vt=Object.prototype.propertyIsEnumerable;var K=(t,e,o)=>e in t?O(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,f=(t,e)=>{for(var o in e||(e={}))Q.call(e,o)&&K(t,o,e[o]);if($)for(var o of $(e))Vt.call(e,o)&&K(t,o,e[o]);return t},E=(t,e)=>Ot(t,It(e));var Bt=(t,e)=>{for(var o in e)O(t,o,{get:e[o],enumerable:!0})},X=(t,e,o,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Nt(e))!Q.call(t,s)&&s!==o&&O(t,s,{get:()=>e[s],enumerable:!(i=bt(e,s))||i.enumerable});return t};var P=(t,e,o)=>(o=t!=null?Dt(Mt(t)):{},X(e||!t||!t.__esModule?O(o,"default",{value:t,enumerable:!0}):o,t)),Ut=t=>X(O({},"__esModule",{value:!0}),t);var zt={};Bt(zt,{stackflow:()=>Jt,useActions:()=>_,useActivity:()=>Ft,useActivityParams:()=>Ht,useStack:()=>qt});module.exports=Ut(zt);var Z=require("react");var Y=require("react"),T=(0,Y.createContext)(null);var Ft=()=>(0,Z.useContext)(T);var tt=require("react");function Ht(){return(0,tt.useContext)(T).params}var ot=require("react");var et=require("react"),I=(0,et.createContext)(null);var qt=()=>(0,ot.useContext)(I);var S=P(require("react"));var rt=require("react"),N=(0,rt.createContext)({});var it=P(require("react"));var nt=({children:t,value:e})=>it.default.createElement(N.Provider,{value:e},t);var at=P(require("react"));function M(){return at.default.useContext(N)}var A=require("@stackflow/core"),u=P(require("react")),Pt=P(require("react-fast-compare"));var ct=P(require("react"));var V=require("react"),st=P(require("react-fast-compare"));function B(t){let e=(0,V.useRef)(t),o=e.current,i=(0,st.default)(o,t);return(0,V.useEffect)(()=>{i||(e.current=t)}),i?o:t}var mt=({children:t,value:e})=>ct.default.createElement(T.Provider,{value:B(e)},t);var pt=require("@stackflow/core");function b(){return(0,pt.id)()}var ft=require("react"),U=(0,ft.createContext)(null);var ut=P(require("react"));var vt=({children:t,value:e})=>ut.default.createElement(U.Provider,{value:e},t);var dt=require("react");function y(){return(0,dt.useContext)(U)}var xt=require("react"),F=(0,xt.createContext)(null);var lt=require("react"),H=(0,lt.createContext)(null);var Gt=1e3,Lt=Gt/60,Ct=({transitionDuration:t,initialActivity:e,activities:o,children:i})=>{let s=y(),m=M(),n=(0,u.useMemo)(()=>{let p=new Date().getTime()-t,C=s.reduce((L,W)=>{var J,z;return(z=(J=W.initialPushedEvent)==null?void 0:J.call(W))!=null?z:L},null),l=e?(0,A.makeEvent)("Pushed",{activityId:b(),activityName:e({context:m}),params:{},eventDate:p}):null;C&&l&&console.warn(`Stackflow - Some plugin overrides an "initialActivity" option. The "initialActivity" option you set to "${l.activityName}" in the "stackflow" is ignored.`);let k=C!=null?C:l;k||console.warn("Stackflow - There is no initial activity. If you want to set the initial activity, add the `initialActivity` option of the `stackflow()` function or add a plugin that sets the initial activity. (e.g. `@stackflow/plugin-history-sync`)");let wt=Object.keys(o).map(L=>(0,A.makeEvent)("ActivityRegistered",{activityName:L,eventDate:p})),j=[(0,A.makeEvent)("Initialized",{transitionDuration:t,eventDate:p}),...wt];return k&&j.push(k),j},[]),c=(0,u.useMemo)(()=>(0,A.aggregate)(n,new Date().getTime()),[]),[r,a]=(0,u.useState)(()=>c),v=(0,u.useRef)(n),d=(0,u.useRef)(c),x=(0,u.useCallback)(()=>d.current,[d]),R=(0,u.useCallback)((p,C)=>{let l=(0,A.makeEvent)(p,C),k=[...v.current,l];v.current=k,a((0,A.aggregate)(k,new Date().getTime()))},[v,a]);return(0,u.useEffect)(()=>{let p=setInterval(()=>{let C=v.current,l=(0,A.aggregate)(C,new Date().getTime());(0,Pt.default)(r,l)||(a(l),d.current=l),l.globalTransitionState==="idle"&&clearInterval(p)},Lt);return()=>{clearInterval(p)}},[v,r,a]),u.default.createElement(H.Provider,{value:r},u.default.createElement(F.Provider,{value:(0,u.useMemo)(()=>({getStack:x,dispatchEvent:R}),[x,R])},i))};var g=P(require("react"));var yt=t=>JSON.parse(JSON.stringify(t)),q=()=>{let t=y(),e=M(),{dispatchEvent:o,getStack:i}=g.default.useContext(F),s=(0,g.useCallback)((r,a)=>{let v=!1,d=yt(a),x=()=>{v=!0},R=p=>{d=yt(p)};return t.forEach(p=>{var C,l,k;switch(r){case"PUSHED":(C=p.onBeforePush)==null||C.call(p,{actionParams:d,actions:{dispatchEvent:o,getStack:i,preventDefault:x,overrideActionParams:R}});break;case"REPLACED":(l=p.onBeforeReplace)==null||l.call(p,{actionParams:d,actions:{dispatchEvent:o,getStack:i,preventDefault:x,overrideActionParams:R}});break;case"POPPED":(k=p.onBeforePop)==null||k.call(p,{actionParams:d,actions:{dispatchEvent:o,getStack:i,preventDefault:x,overrideActionParams:R}});break;default:break}}),{isPrevented:v,params:d}},[t,o,i,e]),m=(0,g.useCallback)(({activityId:r,activityName:a,params:v})=>{let{isPrevented:d,params:x}=s("PUSHED",{activityId:r,activityName:a,params:v});d||o("Pushed",f({},x))},[o]),n=(0,g.useCallback)(({activityId:r,activityName:a,params:v})=>{let{isPrevented:d,params:x}=s("REPLACED",{activityId:r,activityName:a,params:v});d||o("Replaced",f({},x))},[o]),c=(0,g.useCallback)(()=>{let{isPrevented:r,params:a}=s("POPPED",{});r||o("Popped",a)},[o]);return(0,g.useMemo)(()=>({dispatchEvent:o,getStack:i,push:m,replace:n,pop:c}),[o,i,m,n,c])};var kt=P(require("react"));var w=()=>kt.default.useContext(H);var At=require("@stackflow/core"),h=require("react");var Wt=()=>{let t=y(),e=w(),o=q(),i=(0,h.useCallback)(n=>{t.forEach(c=>{var r;(r=c.onInit)==null||r.call(c,n)})},[]),s=(0,h.useCallback)(({actions:n,effect:c})=>{switch(c._TAG){case"PUSHED":{t.forEach(r=>{var a;return(a=r.onPushed)==null?void 0:a.call(r,{actions:n,effect:c})});break}case"POPPED":{t.forEach(r=>{var a;return(a=r.onPopped)==null?void 0:a.call(r,{actions:n,effect:c})});break}case"REPLACED":{t.forEach(r=>{var a;return(a=r.onReplaced)==null?void 0:a.call(r,{actions:n,effect:c})});break}case"%SOMETHING_CHANGED%":{t.forEach(r=>{var a;return(a=r.onChanged)==null?void 0:a.call(r,{actions:n,effect:c})});break}default:break}},[]);(0,h.useEffect)(()=>{i==null||i({actions:{dispatchEvent:o.dispatchEvent,getStack:o.getStack}})},[]);let m=(0,h.useRef)(e);return(0,h.useEffect)(()=>{let n=m.current;(n?(0,At.produceEffects)(n,e):[]).forEach(r=>{s({actions:{dispatchEvent:o.dispatchEvent,getStack:o.getStack},effect:r})}),m.current=f({},e)},[e]),null},gt=Wt;var D=P(require("react"));var G=P(require("react"));var St=P(require("react"));var Et=({children:t,value:e})=>St.default.createElement(I.Provider,{value:B(e)},t);var _t=({activities:t,plugin:e})=>{let o=w(),i=y();return e.render({stack:E(f({},o),{render(s){let m=f(f({},o),s);return{activities:m.activities.map(n=>E(f({},n),{key:n.id,render(c){let r=t[n.name],a=G.default.createElement(r,f({},n.params));return i.forEach(v=>{var d,x;a=(x=(d=v.wrapActivity)==null?void 0:d.call(v,{activity:E(f({},n),{render:()=>a})}))!=null?x:a}),G.default.createElement(Et,{value:m},G.default.createElement(mt,{key:n.id,value:f(f({},n),c)},a))}}))}}})})},ht=_t;var jt=({activities:t})=>{let e=w(),o=y(),i=o.filter(m=>!!m.render);(0,D.useEffect)(()=>{i.length===0&&console.warn(`Stackflow - There is no rendering plugin, so "<Stack />" doesn't render anything. If you want to render some UI, use "@stackflow/plugin-renderer-basic" or add another rendering plugin.`)},[i]);let s=D.default.createElement(D.default.Fragment,null,i.map(m=>D.default.createElement(ht,{activities:t,key:m.key,plugin:m})));return o.forEach(m=>{var n,c;s=(c=(n=m.wrapStack)==null?void 0:n.call(m,{stack:E(f({},e),{render(){return s}})}))!=null?c:s}),s},Rt=jt;var Tt=require("react");function _(){let t=q();return(0,Tt.useMemo)(()=>({push(e,o,i){t.push({activityId:b(),activityName:e,params:o})},replace(e,o,i){t.replace({activityId:b(),activityName:e,params:o})},pop(e){t.pop()}}),[t.push,t.replace,t.pop])}function Jt(t){let e=Object.entries(t.activities).reduce((o,[i,s])=>E(f({},o),{[i]:S.default.memo(s)}),{});return{Stack(o){var s;let i=(0,S.useMemo)(()=>{var m;return((m=t.plugins)!=null?m:[]).reduce((n,c)=>[...n,...Array.isArray(c)?c:[c]],[]).map(n=>n({context:o.context}))},[]);return S.default.createElement(nt,{value:(s=o.context)!=null?s:{}},S.default.createElement(vt,{value:i},S.default.createElement(Ct,{activities:e,initialActivity:t.initialActivity,transitionDuration:t.transitionDuration},S.default.createElement(Rt,{activities:e}),S.default.createElement(gt,null))))},useFlow:_}} | ||
var Ot=Object.create;var O=Object.defineProperty,bt=Object.defineProperties,Nt=Object.getOwnPropertyDescriptor,It=Object.getOwnPropertyDescriptors,Mt=Object.getOwnPropertyNames,K=Object.getOwnPropertySymbols,Vt=Object.getPrototypeOf,X=Object.prototype.hasOwnProperty,Bt=Object.prototype.propertyIsEnumerable;var Q=(t,e,o)=>e in t?O(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,f=(t,e)=>{for(var o in e||(e={}))X.call(e,o)&&Q(t,o,e[o]);if(K)for(var o of K(e))Bt.call(e,o)&&Q(t,o,e[o]);return t},h=(t,e)=>bt(t,It(e));var Ut=(t,e)=>{for(var o in e)O(t,o,{get:e[o],enumerable:!0})},Y=(t,e,o,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Mt(e))!X.call(t,s)&&s!==o&&O(t,s,{get:()=>e[s],enumerable:!(i=Nt(e,s))||i.enumerable});return t};var P=(t,e,o)=>(o=t!=null?Ot(Vt(t)):{},Y(e||!t||!t.__esModule?O(o,"default",{value:t,enumerable:!0}):o,t)),Ft=t=>Y(O({},"__esModule",{value:!0}),t);var $t={};Ut($t,{stackflow:()=>zt,useActions:()=>j,useActivity:()=>Ht,useActivityParams:()=>qt,useStack:()=>Gt});module.exports=Ft($t);var tt=require("react");var Z=require("react"),T=(0,Z.createContext)(null);var Ht=()=>(0,tt.useContext)(T);var et=require("react");function qt(){return(0,et.useContext)(T).params}var rt=require("react");var ot=require("react"),N=(0,ot.createContext)(null);var Gt=()=>(0,rt.useContext)(N);var E=P(require("react"));var it=require("react"),I=(0,it.createContext)({});var nt=P(require("react"));var at=({children:t,value:e})=>nt.default.createElement(I.Provider,{value:e},t);var st=P(require("react"));function M(){return st.default.useContext(I)}var S=require("@stackflow/core"),l=P(require("react")),Ct=P(require("react-fast-compare"));var mt=P(require("react"));var V=require("react"),ct=P(require("react-fast-compare"));function B(t){let e=(0,V.useRef)(t),o=e.current,i=(0,ct.default)(o,t);return(0,V.useEffect)(()=>{i||(e.current=t)}),i?o:t}var pt=({children:t,value:e})=>mt.default.createElement(T.Provider,{value:B(e)},t);var ft=require("@stackflow/core");function b(){return(0,ft.id)()}var ut=require("react"),U=(0,ut.createContext)(null);var vt=P(require("react"));var lt=({children:t,value:e})=>vt.default.createElement(U.Provider,{value:e},t);var dt=require("react");function y(){return(0,dt.useContext)(U)}var xt=require("react"),F=(0,xt.createContext)(null);var Pt=require("react"),H=(0,Pt.createContext)(null);var Lt=1e3,Wt=Lt/60,kt=({transitionDuration:t,initialActivity:e,activities:o,children:i})=>{let s=y(),m=M(),n=(0,l.useMemo)(()=>{let p=new Date().getTime()-t,C=s.reduce((L,W)=>{var z,$;return($=(z=W.initialPushedEvent)==null?void 0:z.call(W))!=null?$:L},null),x=e?(0,S.makeEvent)("Pushed",{activityId:b(),activityName:e({context:m}),params:{},eventDate:p,skipEnterActiveState:!1}):null;C&&x&&console.warn(`Stackflow - Some plugin overrides an "initialActivity" option. The "initialActivity" option you set to "${x.activityName}" in the "stackflow" is ignored.`);let A=C!=null?C:x;A||console.warn("Stackflow - There is no initial activity. If you want to set the initial activity, add the `initialActivity` option of the `stackflow()` function or add a plugin that sets the initial activity. (e.g. `@stackflow/plugin-history-sync`)");let Dt=Object.keys(o).map(L=>(0,S.makeEvent)("ActivityRegistered",{activityName:L,eventDate:p})),J=[(0,S.makeEvent)("Initialized",{transitionDuration:t,eventDate:p}),...Dt];return A&&J.push(A),J},[]),c=(0,l.useMemo)(()=>(0,S.aggregate)(n,new Date().getTime()),[]),[r,a]=(0,l.useState)(()=>c),u=(0,l.useRef)(n),v=(0,l.useRef)(c),d=(0,l.useCallback)(()=>v.current,[v]),k=(0,l.useCallback)((p,C)=>{let x=(0,S.makeEvent)(p,C),A=[...u.current,x];u.current=A,a((0,S.aggregate)(A,new Date().getTime()))},[u,a]);return(0,l.useEffect)(()=>{let p=setInterval(()=>{let C=u.current,x=(0,S.aggregate)(C,new Date().getTime());(0,Ct.default)(r,x)||(a(x),v.current=x),x.globalTransitionState==="idle"&&clearInterval(p)},Wt);return()=>{clearInterval(p)}},[u,r,a]),l.default.createElement(H.Provider,{value:r},l.default.createElement(F.Provider,{value:(0,l.useMemo)(()=>({getStack:d,dispatchEvent:k}),[d,k])},i))};var g=P(require("react"));var yt=t=>JSON.parse(JSON.stringify(t)),q=()=>{let t=y(),e=M(),{dispatchEvent:o,getStack:i}=g.default.useContext(F),s=(0,g.useCallback)((r,a)=>{let u=!1,v=yt(a),d=()=>{u=!0},k=p=>{v=yt(p)};return t.forEach(p=>{var C,x,A;switch(r){case"PUSHED":(C=p.onBeforePush)==null||C.call(p,{actionParams:v,actions:{dispatchEvent:o,getStack:i,preventDefault:d,overrideActionParams:k}});break;case"REPLACED":(x=p.onBeforeReplace)==null||x.call(p,{actionParams:v,actions:{dispatchEvent:o,getStack:i,preventDefault:d,overrideActionParams:k}});break;case"POPPED":(A=p.onBeforePop)==null||A.call(p,{actionParams:v,actions:{dispatchEvent:o,getStack:i,preventDefault:d,overrideActionParams:k}});break;default:break}}),{isPrevented:u,params:v}},[t,o,i,e]),m=(0,g.useCallback)(({activityId:r,activityName:a,params:u,skipEnterActiveState:v})=>{let{isPrevented:d,params:k}=s("PUSHED",{activityId:r,activityName:a,params:u,skipEnterActiveState:v});d||o("Pushed",f({},k))},[o]),n=(0,g.useCallback)(({activityId:r,activityName:a,params:u,skipEnterActiveState:v})=>{let{isPrevented:d,params:k}=s("REPLACED",{activityId:r,activityName:a,params:u,skipEnterActiveState:v});d||o("Replaced",f({},k))},[o]),c=(0,g.useCallback)(r=>{let a=r!=null?r:{},{isPrevented:u,params:v}=s("POPPED",a);u||o("Popped",f({},v))},[o]);return(0,g.useMemo)(()=>({dispatchEvent:o,getStack:i,push:m,replace:n,pop:c}),[o,i,m,n,c])};var At=P(require("react"));var w=()=>At.default.useContext(H);var St=require("@stackflow/core"),R=require("react");var _t=()=>{let t=y(),e=w(),o=q(),i=(0,R.useCallback)(n=>{t.forEach(c=>{var r;(r=c.onInit)==null||r.call(c,n)})},[]),s=(0,R.useCallback)(({actions:n,effect:c})=>{switch(c._TAG){case"PUSHED":{t.forEach(r=>{var a;return(a=r.onPushed)==null?void 0:a.call(r,{actions:n,effect:c})});break}case"POPPED":{t.forEach(r=>{var a;return(a=r.onPopped)==null?void 0:a.call(r,{actions:n,effect:c})});break}case"REPLACED":{t.forEach(r=>{var a;return(a=r.onReplaced)==null?void 0:a.call(r,{actions:n,effect:c})});break}case"%SOMETHING_CHANGED%":{t.forEach(r=>{var a;return(a=r.onChanged)==null?void 0:a.call(r,{actions:n,effect:c})});break}default:break}},[]);(0,R.useEffect)(()=>{i==null||i({actions:{dispatchEvent:o.dispatchEvent,getStack:o.getStack}})},[]);let m=(0,R.useRef)(e);return(0,R.useEffect)(()=>{let n=m.current;(n?(0,St.produceEffects)(n,e):[]).forEach(r=>{s({actions:{dispatchEvent:o.dispatchEvent,getStack:o.getStack},effect:r})}),m.current=f({},e)},[e]),null},gt=_t;var D=P(require("react"));var G=P(require("react"));var Et=P(require("react"));var ht=({children:t,value:e})=>Et.default.createElement(N.Provider,{value:B(e)},t);var jt=({activities:t,plugin:e})=>{let o=w(),i=y();return e.render({stack:h(f({},o),{render(s){let m=f(f({},o),s);return{activities:m.activities.map(n=>h(f({},n),{key:n.id,render(c){let r=t[n.name],a=G.default.createElement(r,f({},n.params));return i.forEach(u=>{var v,d;a=(d=(v=u.wrapActivity)==null?void 0:v.call(u,{activity:h(f({},n),{render:()=>a})}))!=null?d:a}),G.default.createElement(ht,{value:m},G.default.createElement(pt,{key:n.id,value:f(f({},n),c)},a))}}))}}})})},Rt=jt;var Jt=({activities:t})=>{let e=w(),o=y(),i=o.filter(m=>!!m.render);(0,D.useEffect)(()=>{i.length===0&&console.warn(`Stackflow - There is no rendering plugin, so "<Stack />" doesn't render anything. If you want to render some UI, use "@stackflow/plugin-renderer-basic" or add another rendering plugin.`)},[i]);let s=D.default.createElement(D.default.Fragment,null,i.map(m=>D.default.createElement(Rt,{activities:t,key:m.key,plugin:m})));return o.forEach(m=>{var n,c;s=(c=(n=m.wrapStack)==null?void 0:n.call(m,{stack:h(f({},e),{render(){return s}})}))!=null?c:s}),s},Tt=Jt;var wt=require("react");function _(t){return t?t.animate===void 0||t.animate==null?{skipActiveState:!1}:{skipActiveState:!t.animate}:{skipActiveState:!1}}function j(){let t=q();return(0,wt.useMemo)(()=>({push(e,o,i){t.push({activityId:b(),activityName:e,params:o,skipEnterActiveState:_(i).skipActiveState})},replace(e,o,i){t.replace({activityId:b(),activityName:e,params:o,skipEnterActiveState:_(i).skipActiveState})},pop(e){t.pop({skipExitActiveState:_(e).skipActiveState})}}),[t.push,t.replace,t.pop])}function zt(t){let e=Object.entries(t.activities).reduce((o,[i,s])=>h(f({},o),{[i]:E.default.memo(s)}),{});return{Stack(o){var s;let i=(0,E.useMemo)(()=>{var m;return((m=t.plugins)!=null?m:[]).reduce((n,c)=>[...n,...Array.isArray(c)?c:[c]],[]).map(n=>n({context:o.context}))},[]);return E.default.createElement(at,{value:(s=o.context)!=null?s:{}},E.default.createElement(lt,{value:i},E.default.createElement(kt,{activities:e,initialActivity:t.initialActivity,transitionDuration:t.transitionDuration},E.default.createElement(Tt,{activities:e}),E.default.createElement(gt,null))))},useFlow:j}} | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@stackflow/react", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"license": "Apache-2.0", | ||
@@ -29,3 +29,3 @@ "exports": { | ||
"devDependencies": { | ||
"@stackflow/core": "^0.3.0", | ||
"@stackflow/core": "^0.4.0", | ||
"@types/react": "^18.0.9", | ||
@@ -49,3 +49,3 @@ "react": "^18.1.0", | ||
}, | ||
"gitHead": "30236087e383905696ded8e2c5e1a2ecb088bf1a" | ||
"gitHead": "fd15108ea159510977b2932a50f78f3ff9fefcd3" | ||
} |
@@ -81,2 +81,3 @@ import { Effect } from "@stackflow/core"; | ||
params, | ||
skipEnterActiveState, | ||
}: { | ||
@@ -86,2 +87,3 @@ activityId: string; | ||
params: { [key: string]: string }; | ||
skipEnterActiveState?: boolean; | ||
}) => { | ||
@@ -94,2 +96,3 @@ const { isPrevented, params: eventParams } = triggerPreEffectHook( | ||
params, | ||
skipEnterActiveState, | ||
}, | ||
@@ -112,2 +115,3 @@ ); | ||
params, | ||
skipEnterActiveState, | ||
}: { | ||
@@ -117,2 +121,3 @@ activityId: string; | ||
params: { [key: string]: string }; | ||
skipEnterActiveState?: boolean; | ||
}) => { | ||
@@ -125,2 +130,3 @@ const { isPrevented, params: eventParams } = triggerPreEffectHook( | ||
params, | ||
skipEnterActiveState, | ||
}, | ||
@@ -138,12 +144,16 @@ ); | ||
const pop = useCallback(() => { | ||
const { isPrevented, params: eventParams } = triggerPreEffectHook( | ||
"POPPED", | ||
{}, | ||
); | ||
const pop = useCallback( | ||
(params?: { skipExitActiveState?: boolean }) => { | ||
const initialParams = params ?? {}; | ||
const { isPrevented, params: eventParams } = triggerPreEffectHook( | ||
"POPPED", | ||
initialParams, | ||
); | ||
if (!isPrevented) { | ||
dispatchEvent("Popped", eventParams); | ||
} | ||
}, [dispatchEvent]); | ||
if (!isPrevented) { | ||
dispatchEvent("Popped", { ...eventParams }); | ||
} | ||
}, | ||
[dispatchEvent], | ||
); | ||
@@ -150,0 +160,0 @@ return useMemo( |
@@ -7,2 +7,16 @@ import { useMemo } from "react"; | ||
function parseActionOptions(options?: { animate?: boolean }) { | ||
if (!options) { | ||
return { skipActiveState: false }; | ||
} | ||
const isNullableAnimateOption = | ||
options.animate === undefined || options.animate == null; | ||
if (isNullableAnimateOption) { | ||
return { skipActiveState: false }; | ||
} | ||
return { skipActiveState: !options.animate }; | ||
} | ||
export type UseActionsOutputType<T extends BaseActivities> = { | ||
@@ -49,2 +63,3 @@ /** | ||
params, | ||
skipEnterActiveState: parseActionOptions(options).skipActiveState, | ||
}); | ||
@@ -57,6 +72,9 @@ }, | ||
params, | ||
skipEnterActiveState: parseActionOptions(options).skipActiveState, | ||
}); | ||
}, | ||
pop(options) { | ||
coreActions.pop(); | ||
coreActions.pop({ | ||
skipExitActiveState: parseActionOptions(options).skipActiveState, | ||
}); | ||
}, | ||
@@ -63,0 +81,0 @@ }), |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
127730
1175