react-modal-navigation 1.1.6 → 1.1.8
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/CHANGELOG.md +16 -0
- package/README.md +53 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.js +593 -554
- package/dist/style.css +17 -0
- package/docs/API.md +11 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
## 1.1.6 — stronger page transitions
|
|
2
|
+
- Increase default page slide from 22px/240ms to 96px/360ms.
|
|
3
|
+
- Add configurable `pageAnimationDistance` with matching CSS and Web Animations behavior.
|
|
4
|
+
|
|
1
5
|
## 1.1.6 — Architecture maintenance
|
|
2
6
|
|
|
3
7
|
- Extracted Loading and Toast controllers from ModalNavigator.
|
|
@@ -76,3 +80,15 @@
|
|
|
76
80
|
- Added a real React 19 `ModalProvider` / `ModalNavigator` profiler integration suite.
|
|
77
81
|
- Added `npm run test:react` and explicit React testing dependencies.
|
|
78
82
|
- No Context API redesign in this change; performance refactors await measured results.
|
|
83
|
+
|
|
84
|
+
- Fix: Default Header back button now follows the current render stack depth; per-screen `showBackButton` is respected.
|
|
85
|
+
|
|
86
|
+
### Page navigation animation (1.1.6 compatibility update)
|
|
87
|
+
- Added opt-out internal route slide/fade transitions, reverse direction on back navigation.
|
|
88
|
+
- Added `pageAnimation` and `pageAnimationDuration` modal options.
|
|
89
|
+
- Respects reduced-motion preferences and avoids retriggering on unrelated updates.
|
|
90
|
+
|
|
91
|
+
### 双页面过渡动画(兼容 v1.1.6)
|
|
92
|
+
- `navigate`/`goBack` 时增加旧页退出 + 新页进入的同步动画。
|
|
93
|
+
- 旧页使用 inert DOM 快照,兼容返回时页面卸载、KeepAlive 缓存和快速连续导航;完成后清理。
|
|
94
|
+
- 尊重 `prefers-reduced-motion`;沿用 `pageAnimationDuration`、`pageAnimationDistance` 配置。
|
package/README.md
CHANGED
|
@@ -710,3 +710,56 @@ function LoadingIndicator() {
|
|
|
710
710
|
声明式 Footer 的按钮配置现在使用逐属性比较,避免 JSON 序列化丢失函数属性或遗漏新增配置字段。异步操作仍需要在业务层使用 `try/finally` 管理自身资源。
|
|
711
711
|
|
|
712
712
|
类型增强:可通过 `TypedModalNavigation<Routes>` 为项目提供路由名及参数的静态检查。
|
|
713
|
+
|
|
714
|
+
### 返回按钮显示规则(1.1.6 修复)
|
|
715
|
+
|
|
716
|
+
默认 Header 在导航栈超过一页时自动显示返回按钮。使用 `navigation.navigate('Detail')` 推入页面;`replace` / `reset` 不增加可返回的历史。可通过 `showBackButton: false` 隐藏,页面 `setOptions({ showBackButton: true })` 可覆盖默认设置。如果使用 `renderHeader` 自定义整个 Header,需要自行渲染返回按钮。
|
|
717
|
+
|
|
718
|
+
## 页面跳转动画
|
|
719
|
+
|
|
720
|
+
`navigation.navigate()` 进入新页面时默认从右侧轻滑入,`navigation.goBack()` 返回时从左侧轻滑入,动画时长默认为 **240ms**。仅页面路由发生变化时触发,修改参数、Toast 或 Footer 不会重复触发。系统启用减少动态效果时会自动关闭动画。
|
|
721
|
+
|
|
722
|
+
```jsx
|
|
723
|
+
const registry = {
|
|
724
|
+
device: {
|
|
725
|
+
initialRoute: 'List',
|
|
726
|
+
modalOptions: { pageAnimation: true, pageAnimationDuration: 260 },
|
|
727
|
+
screens: { List: { component: List }, Detail: { component: Detail } },
|
|
728
|
+
},
|
|
729
|
+
};
|
|
730
|
+
|
|
731
|
+
// 页面内
|
|
732
|
+
navigation.navigate('Detail', { id: 1 });
|
|
733
|
+
navigation.goBack();
|
|
734
|
+
```
|
|
735
|
+
|
|
736
|
+
不需要动画时传入 `pageAnimation: false`。`animation: false` 同时禁用弹窗和页面动画。
|
|
737
|
+
|
|
738
|
+
|
|
739
|
+
### 更明显的页面滑动效果
|
|
740
|
+
|
|
741
|
+
默认页面滑动距离由 22px 提高到 96px,动画时长由 240ms 提高到 360ms,并增加淡入和轻微缩放。可通过以下选项调整:
|
|
742
|
+
|
|
743
|
+
```jsx
|
|
744
|
+
modalOptions: {
|
|
745
|
+
pageAnimation: true,
|
|
746
|
+
pageAnimationDuration: 420,
|
|
747
|
+
pageAnimationDistance: 140,
|
|
748
|
+
}
|
|
749
|
+
```
|
|
750
|
+
|
|
751
|
+
`pageAnimationDistance` 范围为 0–300px;`pageAnimationDuration` 范围为 0–1000ms。系统启用减少动态效果时仍尊重该设置。
|
|
752
|
+
|
|
753
|
+
## 双页面同步切换动画
|
|
754
|
+
|
|
755
|
+
默认在 `navigation.navigate()` 和 `navigation.goBack()` 时,同时播放**旧页面退出**与**新页面进入**动画。向前导航时旧页向左退出、新页从右进入;返回时方向相反。
|
|
756
|
+
|
|
757
|
+
```jsx
|
|
758
|
+
modalOptions: {
|
|
759
|
+
pageAnimation: true,
|
|
760
|
+
pageAnimationDuration: 380,
|
|
761
|
+
pageAnimationDistance: 140,
|
|
762
|
+
}
|
|
763
|
+
```
|
|
764
|
+
|
|
765
|
+
退出页使用仅用于展示的不可交互 DOM 快照;原页面仍按原有 KeepAlive 策略保留或卸载。动画期间旧页面不会再次响应点击,完成后自动移除快照;系统启用 `prefers-reduced-motion` 时跳过动画。自定义 Header、Footer 不参与滑动。
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),e=require("react"),rt=require("react-dom"),We=e.createContext(null),ot=e.createContext(null),Me=e.createContext(null),je=e.createContext(null),Ye=e.createContext(null),_e=e.createContext(null),Fe=e.createContext(null),Oe=e.createContext(null),De=e.createContext(null),at=e.createContext(null),st=e.createContext(null),Ve=e.createContext(null);function ct(t){let n=t;const o=new Set;return{getSnapshot:()=>n,subscribe:r=>(o.add(r),()=>o.delete(r)),publish(r){if(n!==r){n=r;for(const i of[...o])i()}},listenerCount:()=>o.size}}function Pe(t){let n=t;const o=new Set;return{getSnapshot:()=>n,subscribe:r=>(o.add(r),()=>o.delete(r)),publish(r){if(!Object.is(n,r)){n=r;for(const i of[...o])i()}},listenerCount:()=>o.size}}let it=0;const qe=(t,n)=>({key:`modal-route-${++it}`,name:t,params:n??{}}),Qe=(t,n)=>[qe(t,n)];function Ee(t,n){switch(n.type){case"RESET":return Qe(n.name,n.params);case"NAVIGATE":{const o=t.findIndex(r=>r.name===n.name);return o<0?[...t,qe(n.name,n.params)]:t.slice(0,o+1).map((r,i)=>i===o?{...r,params:n.params??{}}:r)}case"SET_OPTIONS":return t.map((o,r)=>r===t.length-1?{...o,options:{...o.options??{},...n.options??{}}}:o);case"SET_PARAMS":return t.map((o,r)=>r===t.length-1?{...o,params:{...o.params??{},...n.params??{}}}:o);case"BACK":return t.length>1?t.slice(0,-1):t;case"REPLACE":return t.length?[...t.slice(0,-1),qe(n.name,n.params)]:t;default:return t}}function ut(t,n,o=1/0){const r=o===1/0?1/0:Math.max(0,Math.floor(Number(o)||0)),i=t.slice(0,-1).filter(l=>n[l.name]?.keepAlive!==!1),g=new Set((r===0?[]:i.slice(-r)).map(l=>l.key));return t.filter((l,f)=>f===t.length-1||g.has(l.key))}const Ke=()=>{if(typeof document>"u")return"light";const t=document.documentElement,n=document.body;return t.classList.contains("dark")||n.classList.contains("dark")||t.dataset.theme==="dark"||n.dataset.theme==="dark"?"dark":t.classList.contains("light")||n.classList.contains("light")||t.dataset.theme==="light"||n.dataset.theme==="light"?"light":window.matchMedia?.("(prefers-color-scheme: dark)").matches?"dark":"light"};let ve=0;const ue=[];let Be=null;function lt(){if(ve++,ve===1){const n=document.documentElement,o=document.body,r={html:n.style.overflow,body:o.style.overflow,padding:o.style.paddingRight,width:o.style.getPropertyValue("--modal-scrollbar-width")},i=Math.max(0,window.innerWidth-n.clientWidth),g=parseFloat(getComputedStyle(o).paddingRight)||0;i&&(o.style.paddingRight=`${g+i}px`),o.style.setProperty("--modal-scrollbar-width",`${i}px`),n.style.overflow="hidden",o.style.overflow="hidden",Be=()=>{n.style.overflow=r.html,o.style.overflow=r.body,o.style.paddingRight=r.padding,r.width?o.style.setProperty("--modal-scrollbar-width",r.width):o.style.removeProperty("--modal-scrollbar-width")}}let t=!1;return()=>{t||(t=!0,ve=Math.max(0,ve-1),ve||(Be?.(),Be=null))}}const dt='a[href],button:not([disabled]),input:not([disabled]),textarea:not([disabled]),select:not([disabled]),[tabindex]:not([tabindex="-1"])',mt=t=>!t.closest('[inert], [hidden], [aria-hidden="true"]')&&t.getClientRects().length>0&&getComputedStyle(t).visibility!=="hidden"&&getComputedStyle(t).display!=="none";function ft({dialogRef:t,options:n,requestClose:o,children:r,exiting:i=!1}){const g=e.useRef(null),l=e.useRef(null),f=e.useRef(o);f.current=o;const d=e.useRef(n.closeOnEsc);d.current=n.closeOnEsc;const[x,R]=e.useState(Ke),v=n.theme==="light"||n.theme==="dark"?n.theme:x;e.useEffect(()=>{if(n.theme==="light"||n.theme==="dark")return;const b=()=>R(Ke()),M=new MutationObserver(b);for(const F of[document.documentElement,document.body])M.observe(F,{attributes:!0,attributeFilter:["class","data-theme"]});const q=window.matchMedia?.("(prefers-color-scheme: dark)");return q?.addEventListener?.("change",b),b(),()=>{M.disconnect(),q?.removeEventListener?.("change",b)}},[n.theme]),e.useEffect(()=>{l.current=document.activeElement;const b=lt(),M=g.current;ue.push(M),t.current?.focus({preventScroll:!0});const q=j=>{const W=t.current;if(!W||ue.at(-1)!==M)return;if(j.key==="Escape"&&d.current!==!1){j.preventDefault(),f.current("escape");return}if(j.key!=="Tab")return;const N=[...W.querySelectorAll(dt)].filter(mt);if(!N.length){j.preventDefault(),W.focus();return}const Q=N[0],J=N.at(-1);W.contains(document.activeElement)?j.shiftKey&&(document.activeElement===Q||document.activeElement===W)?(j.preventDefault(),J.focus()):!j.shiftKey&&(document.activeElement===J||document.activeElement===W)&&(j.preventDefault(),Q.focus()):(j.preventDefault(),(j.shiftKey?J:Q).focus())},F=j=>{ue.at(-1)===M&&t.current&&!t.current.contains(j.target)&&t.current.focus({preventScroll:!0})};return document.addEventListener("keydown",q),document.addEventListener("focusin",F),()=>{document.removeEventListener("keydown",q),document.removeEventListener("focusin",F);const j=ue.at(-1)===M,W=ue.indexOf(M);if(W!==-1&&ue.splice(W,1),b(),j){const N=l.current;N?.isConnected&&!N.closest("[inert], [hidden]")?N.focus?.({preventScroll:!0}):ue.at(-1)?.querySelector("[role=dialog]")?.focus?.({preventScroll:!0})}}},[t]);const h=n.backgroundColor??n.backgroudColor,m=typeof h=="string"?h:h?.[v],c=typeof m=="string"&&/^(#|rgb\(|rgba\(|hsl\(|hsla\(|oklch\(|color\(|var\()/.test(m.trim())?m:null,L={sm:400,md:560,lg:720,xl:960,full:"100%"},E=["center","left","right","top","bottom"].includes(n.placement)?n.placement:"right",P=b=>typeof b=="number"?`${b}px`:b,B=P(n.width??L[n.size]??460),I=P(n.height),k=P(n.maxHeight),$=P(n.maxWidth),K=Number(n.viewportGap??5),G=Number.isFinite(K)?Math.max(0,K):5,S=typeof n.borderRadius=="number"?`${n.borderRadius}px`:n.borderRadius??"12px";return rt.createPortal(u.jsx("div",{ref:g,className:`pmn-overlay ${i?"pmn-exiting":"pmn-entering"} ${n.animation===!1?"pmn-no-animation":""} pmn-place-${E} ${n.mobileFullscreen?"pmn-mobile-fullscreen":""}`,style:{padding:G,"--pmn-animation-duration":`${Math.min(1e3,Math.max(0,Number(n.animationDuration??220)||0))}ms`},onMouseDown:b=>{b.target===b.currentTarget&&n.closeOnOverlay===!0&&f.current("overlay")},children:u.jsx("section",{ref:t,tabIndex:-1,role:"dialog","aria-modal":"true","aria-label":n.ariaLabel??"Dialog","data-modal-theme":v,className:`pmn-dialog ${v==="dark"?"dark":""} ${!c&&m?m:""} ${n.className??""}`,style:{"--pmn-width":B,"--pmn-gap":`${G}px`,...I!==void 0?{"--pmn-height":I}:{},...k!==void 0?{"--pmn-max-height":k}:{},...$!==void 0?{"--pmn-max-width":$}:{},borderRadius:S,...c?{backgroundColor:c}:{}},children:r})}),document.body)}function Ge({back:t}){return u.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",width:"20",height:"20",fill:"none",stroke:"currentColor",strokeWidth:"2",children:t?u.jsx("path",{d:"m15 18-6-6 6-6"}):u.jsx("path",{d:"M18 6 6 18M6 6l12 12"})})}function pt({options:t,screen:n,route:o,navigation:r,requestClose:i,translate:g}){if(t.showHeader===!1)return null;const l=g??(h=>h),f=n.showTitle??t.showTitle??!0,d=typeof n.title=="function"?n.title({t:l,route:o,navigation:r}):n.title??o.name,x={route:o,navigation:r,close:i,canGoBack:r.canGoBack,title:d,t:l},R=n.renderHeader??t.renderHeader;if(R)return R(x);const v=n.renderHeaderRight??t.renderHeaderRight;return u.jsxs("header",{className:`pmn-header ${n.showHeaderBorder??t.showHeaderBorder?"pmn-border-bottom":""} ${t.headerClassName??""}`,children:[t.showBackButton!==!1&&r.canGoBack&&u.jsx("button",{type:"button",className:"pmn-icon-button","aria-label":l("modal.back"),onClick:()=>r.goBack(),children:u.jsx(Ge,{back:!0})}),f?u.jsx("h2",{children:d}):u.jsx("div",{className:"pmn-header-spacer"}),v?.(x),t.showCloseButton!==!1&&u.jsx("button",{type:"button",className:"pmn-icon-button","aria-label":l("modal.close"),onClick:()=>i("header"),children:u.jsx(Ge,{})})]})}function gt({screen:t,options:n,override:o,route:r,navigation:i,requestClose:g,translate:l,onError:f,loadingApi:d}){const[x,R]=e.useState(null),v=e.useRef(new Set),h=e.useRef(!0);e.useEffect(()=>(h.current=!0,()=>{h.current=!1}),[]);const m=l??(b=>b),c={...n,...t,...o},{showFooter:L,renderFooter:E,done:P,cancel:B,cancle:I}=c,k=B??I,$={route:r,navigation:i,close:g,t:m};if(L===!1)return null;const K=`pmn-footer ${c.showFooterBorder?"pmn-border-top":""} ${c.footerClassName??""}`;if(typeof E=="function")return u.jsx("footer",{className:K,children:E({...$,pending:v.current.size>0})});const G=Array.isArray(c.actions)?c.actions:null;if(!G&&typeof P!="function"&&typeof k!="function")return null;const S=async(b,M,q)=>{if(v.current.has(b)||typeof M!="function")return;v.current.add(b),R(b);const F=d?.begin(r.key,q??c.loadingText??m("modal.processing"));try{await M($)}catch(j){f?.(j,{phase:"footer",action:b,route:r})}finally{d?.end(r.key,F),v.current.delete(b),h.current&&R(j=>j===b?null:j)}};return G?u.jsx("footer",{className:K,children:G.filter(b=>!b.hidden).map(b=>{const M=v.current.has(b.key)||b.loading===!0;return u.jsx("button",{type:"button",disabled:b.disabled===!0||M,className:`pmn-button ${b.variant==="primary"||b.variant==="danger"?"pmn-button-primary":"pmn-button-secondary"} ${b.variant==="danger"?"pmn-button-danger":""}`,onClick:()=>S(b.key,b.onClick,b.loadingText),children:M?b.loadingText??c.loadingText??m("modal.processing"):b.label},b.key)})}):u.jsxs("footer",{className:K,children:[typeof k=="function"&&u.jsx("button",{type:"button",disabled:x!==null,onClick:()=>S("cancel",k),className:"pmn-button pmn-button-secondary",children:c.cancelText??m("modal.cancel")}),typeof P=="function"&&u.jsx("button",{type:"button",disabled:x!==null||c.doneDisabled===!0,onClick:()=>S("done",P),className:"pmn-button pmn-button-primary",children:x==="done"?c.loadingText??m("modal.processing"):c.doneText??m("modal.done")})]})}function ht({loading:t,translate:n}){if(!t.visible)return null;const r=(n??(g=>g))("modal.loading"),i=t.text??(r==="modal.loading"?"加载中...":r);return u.jsx("div",{className:"pmn-loading-overlay",role:"status","aria-live":"polite","aria-busy":"true",children:u.jsxs("div",{className:"pmn-loading-content",children:[u.jsx("span",{className:"pmn-spinner","aria-hidden":"true"}),i&&u.jsx("span",{className:"pmn-loading-text",children:i})]})})}class bt extends e.Component{state={error:null};static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n,o){this.props.onError?.(n,{phase:"render",route:this.props.route,componentStack:o.componentStack})}componentDidUpdate(n){n.route?.key!==this.props.route?.key&&this.state.error&&this.setState({error:null})}render(){return this.state.error?u.jsxs("div",{role:"alert",className:"pmn-error-screen",children:[u.jsx("strong",{children:"页面加载失败"}),u.jsx("p",{children:this.state.error.message}),u.jsx("button",{type:"button",className:"pmn-button pmn-button-secondary",onClick:()=>this.setState({error:null}),children:"重试"})]}):this.props.children}}const xt={success:"✓",error:"×",warning:"!",info:"i"};function yt({items:t,dismiss:n}){return t.length?u.jsx("div",{className:"pmn-toast-region","aria-label":"Notifications",children:t.map(o=>u.jsxs("div",{className:`pmn-toast pmn-toast-${o.type}`,role:o.type==="error"||o.type==="warning"?"alert":"status",children:[u.jsx("span",{className:"pmn-toast-symbol","aria-hidden":"true",children:xt[o.type]}),u.jsx("span",{className:"pmn-toast-message",children:o.message}),o.dismissible&&u.jsx("button",{type:"button",className:"pmn-toast-close","aria-label":"Dismiss notification",onClick:()=>n(o.id),children:"×"})]},o.id))}):null}function vt(t,n){const o=e.useRef(0),r=e.useRef(new Map),i=e.useCallback(f=>{clearTimeout(r.current.get(f)),r.current.delete(f),n.current&&t.current.publish(t.current.getSnapshot().filter(d=>d.id!==f))},[]),g=e.useCallback((f,d={})=>{if(typeof f!="string"||!f.trim())throw new TypeError("[react-modal-navigation] toast message must be a non-empty string");const x=typeof d=="string"?{type:d}:d??{},R=["success","error","warning","info"].includes(x.type)?x.type:"info",v=++o.current,h=Number.isFinite(x.duration)?Math.max(0,x.duration):3e3;if(!n.current)return null;const m=t.current.getSnapshot(),c=m.slice(0,Math.max(0,m.length-4));for(const L of c)clearTimeout(r.current.get(L.id)),r.current.delete(L.id);return t.current.publish([...m.slice(-4),{id:v,message:f,type:R,dismissible:x.dismissible!==!1}]),h>0&&r.current.set(v,setTimeout(()=>i(v),h)),v},[i]),l=e.useMemo(()=>{const f=(d,x)=>g(d,x);for(const d of["success","error","warning","info"])f[d]=(x,R={})=>g(x,{...R,type:d});return f.promise=async(d,x,R={})=>{const v=g(x.loading,{...R,type:"info",duration:0});try{const h=await(typeof d=="function"?d():d);v!=null&&i(v);const m=typeof x.success=="function"?x.success(h):x.success;return m&&g(m,{...R,type:"success"}),h}catch(h){v!=null&&i(v);const m=typeof x.error=="function"?x.error(h):x.error;throw m&&g(m,{...R,type:"error"}),h}},f.dismiss=i,f.clear=()=>{for(const d of r.current.values())clearTimeout(d);r.current.clear(),t.current.publish([])},f},[g,i]);return e.useEffect(()=>()=>{for(const f of r.current.values())clearTimeout(f);r.current.clear()},[]),{toast:l,dismissToast:i}}function wt(t,n,o){const r=e.useRef(new Map),i=e.useRef(0),g=e.useCallback(()=>{if(!n.current)return;const h=[...r.current.values()],m={visible:h.length>0,text:h.at(-1)?.text??null,count:h.length},c=t.current.getSnapshot();(c.visible!==m.visible||c.text!==m.text||c.count!==m.count)&&t.current.publish(m)},[]),l=e.useCallback((h,m)=>{if(!n.current||h!=="global"&&o.current!==h)return null;const c=++i.current;return r.current.set(c,{owner:h,text:m}),g(),c},[g]),f=e.useCallback((h,m)=>{if(m!=null)r.current.get(m)?.owner===h&&r.current.delete(m);else for(const[c,L]of r.current)L.owner===h&&r.current.delete(c);g()},[g]),d=e.useCallback((h,m)=>{h?(f("global"),l("global",m)):f("global")},[l,f]),x=e.useCallback((h,m,c)=>{m?(f(h),l(h,c)):f(h)},[l,f]);return{loadingApi:e.useMemo(()=>({setLoading:d,setScreenLoading:x,begin:l,end:f}),[d,x,l,f]),refreshLoading:g,loadingTasks:r,setLoading:d}}const kt=e.memo(function({store:n,translate:o}){const r=e.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getSnapshot);return u.jsx(ht,{loading:r,translate:o})}),Ct=e.memo(function({store:n,dismiss:o}){const r=e.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getSnapshot);return u.jsx(yt,{items:r,dismiss:o})}),Rt=e.memo(function({store:n,routeKey:o,...r}){const i=e.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getSnapshot);return u.jsx(gt,{...r,override:i[o]})}),Et=e.memo(function({route:n,screen:o,navigation:r,focused:i,resultEvent:g,setFooter:l,loadingApi:f,loadingStore:d,bodyClassName:x,notifyError:R,registerDirtyGuard:v}){const h=o.component,m=e.useMemo(()=>({isFocused:i,resultEvent:g,routeKey:n.key,setFooter:l}),[i,g,n.key,l]),c=e.useMemo(()=>({setLoading:(E,P)=>f.setScreenLoading(n.key,E,P),showLoading:E=>f.begin(n.key,E),hideLoading:E=>f.end(n.key,E)}),[f,n.key]),L=e.useMemo(()=>({routeKey:n.key,registerDirtyGuard:v}),[n.key,v]);return u.jsx(Ve.Provider,{value:n,children:u.jsx(Ye.Provider,{value:L,children:u.jsx(Me.Provider,{value:m,children:u.jsx(je.Provider,{value:c,children:u.jsx(De.Provider,{value:d,children:u.jsx("div",{hidden:!i,inert:!i,"data-modal-route-key":n.key,tabIndex:-1,className:`pmn-body ${x??""}`,children:u.jsx(bt,{route:n,onError:R,children:u.jsx(h,{route:n,navigation:r})})})})})})})})});function Je({config:t,initialScreen:n,params:o,options:r,translate:i,onRequestClose:g,onOpened:l,registerLoading:f,notifyError:d,error:x,clearError:R,registerDirtyGuard:v,canNavigate:h,exiting:m=!1}){const[c,L]=e.useReducer(Ee,null,()=>Qe(n??t.initialRoute,o)),E=e.useRef(null);E.current||(E.current=ct({canGoBack:c.length>1,stack:c,currentRoute:c.at(-1)}));const P=e.useRef(null),B=e.useRef(null),I=e.useRef(null);P.current||(P.current=Pe({visible:!1,text:null,count:0})),B.current||(B.current=Pe({})),I.current||(I.current=Pe([]));const k=e.useRef(!0),$=e.useRef(0),{toast:K,dismissToast:G}=vt(I,k);e.useEffect(()=>(k.current=!0,()=>{k.current=!1,$.current++}),[]);const[S,b]=e.useState({}),M=e.useRef(new Map),q=e.useRef(null),F=e.useRef(null),j=e.useRef(!1),W=e.useRef(!1),N=e.useRef(new Map),Q=e.useRef(0),J=e.useCallback((a,y,T)=>{for(const[D,ne]of N.current)a.includes(ne.key)&&(N.current.delete(D),ne.resolve({status:y,...y==="returned"?{value:T}:{}}))},[]),A=e.useRef(c);A.current=c;const re=e.useRef(h);re.current=h;const X=e.useRef(!1),ge=e.useRef(0),z=c.at(-1),O=z.key,oe=e.useRef(O);oe.current=O;const{loadingApi:he,refreshLoading:be,loadingTasks:le,setLoading:se}=wt(P,k,oe),Z=t.screens,we=P,de=e.useRef(f);de.current=f,e.useEffect(()=>(de.current?.({setLoading:se}),()=>de.current?.(null)),[se]);const ke=e.useCallback((a,y)=>{if(!k.current)return;const T=B.current.getSnapshot();if(y===null){if(!(a in T))return;const D={...T};delete D[a],B.current.publish(D);return}T[a]!==y&&B.current.publish({...T,[a]:y})},[]),xe=e.useCallback(()=>{if(typeof document>"u")return;const a=document.activeElement;if(!(a instanceof HTMLElement)||!q.current?.contains(a))return;const y=a.closest("[data-modal-route-key]");y&&M.current.set(y.dataset.modalRouteKey,a),q.current.focus({preventScroll:!0})},[]),ye=e.useCallback(a=>{if(!Object.prototype.hasOwnProperty.call(Z,a))throw new Error(`[react-modal-navigation] Unknown modal screen: ${a}`)},[Z]),ae=e.useCallback((a,y)=>{try{Promise.resolve(r[a]?.(y)).catch(T=>d(T,{phase:a}))}catch(T){d(T,{phase:a})}},[r,d]),V=e.useCallback(async(a,y,T,D)=>{if(!k.current||W.current)return!1;const ne=$.current,_=A.current,Te=_.at(-1);if(a!=="BACK"&&ye(y),a==="BACK"&&_.length<=1)return!1;const ze=a==="NAVIGATE"?_.findIndex(pe=>pe.name===y):-1,Ne=a==="RESET"?_:a==="BACK"||a==="REPLACE"?[Te]:ze>=0?_.slice(ze+1):[];W.current=!0;try{if(Ne.length&&re.current&&!await re.current(Ne.map(Le=>Le.key),{reason:"navigation",action:a,from:Te,to:a==="BACK"?_.at(-2)?.name:y})||!k.current||ne!==$.current||A.current.at(-1)?.key!==Te.key)return!1;if(a==="BACK"&&D!==void 0){const Re=_.at(-2);b(Le=>({...Le,[Re.key]:{id:++ge.current,data:D}}))}a==="RESET"&&b({}),J(Ne.map(Re=>Re.key),a==="BACK"?"returned":"removed",D),xe();const pe={type:a,name:y,params:T};return A.current=Ee(A.current,pe),L(pe),!0}catch(pe){return k.current&&d(pe,{phase:"navigationGuard",action:a}),!1}finally{W.current=!1}},[ye,xe,d,J]),s=e.useCallback((a,y)=>V("NAVIGATE",a,y),[V]),p=e.useCallback(async(a,y)=>{if(!k.current)return{status:"cancelled"};if(A.current,!await V("NAVIGATE",a,y)||!k.current)return{status:"cancelled"};const D=A.current.at(-1);return!D||D.name!==a?{status:"cancelled"}:new Promise(ne=>{const _=++Q.current;N.current.set(_,{key:D.key,resolve:ne})})},[V]),C=e.useCallback((a,y)=>V("REPLACE",a,y),[V]),w=e.useCallback((a,y)=>V("RESET",a,y),[V]),H=e.useCallback(a=>{if(!a||typeof a!="object"||Array.isArray(a))throw new TypeError("[react-modal-navigation] setParams expects an object");if(!k.current)return;const y={type:"SET_PARAMS",params:a};A.current=Ee(A.current,y),L(y)},[]),U=e.useCallback(a=>{if(!a||typeof a!="object"||Array.isArray(a))throw new TypeError("[react-modal-navigation] setOptions expects an object");if(!k.current)return;const y={type:"SET_OPTIONS",options:a};A.current=Ee(A.current,y),L(y)},[]),Y=e.useCallback(a=>V("BACK",null,void 0,a),[V]),ee=e.useCallback((a,y)=>!k.current||we.current.getSnapshot().visible&&r.lockCloseWhileLoading!==!1?Promise.resolve(!1):g(a,y,{route:z,stack:c}),[r.lockCloseWhileLoading,g,z,c]),te=e.useRef(ee);te.current=ee;const ce=e.useCallback(a=>te.current("api",a),[]),me=e.useMemo(()=>({navigate:s,navigateAsync:p,replace:C,reset:w,setParams:H,setOptions:U,goBack:Y,close:ce,setLoading:se}),[s,p,C,w,H,U,Y,ce,se]),fe=e.useMemo(()=>({canGoBack:c.length>1,stack:c,currentRoute:z}),[c]);e.useLayoutEffect(()=>E.current.publish(fe),[fe]);const ie=e.useRef(null);ie.current||(ie.current=Object.defineProperties({},{canGoBack:{enumerable:!0,get:()=>E.current.getSnapshot().canGoBack},stack:{enumerable:!0,get:()=>E.current.getSnapshot().stack},currentRoute:{enumerable:!0,get:()=>E.current.getSnapshot().currentRoute}}));const Ce=e.useMemo(()=>Object.assign(ie.current,me),[me]);e.useLayoutEffect(()=>{j.current=!1;const a=[...q.current?.querySelectorAll("[data-modal-route-key]")??[]].find(D=>D.dataset.modalRouteKey===O);if(!a)return;const y=M.current.get(O);(y?.isConnected&&a.contains(y)&&!y.matches(":disabled")&&!y.closest("[inert], [hidden]")?y:a).focus({preventScroll:!0})},[O]),e.useEffect(()=>{let a=!1;for(const[T,D]of le.current)D.owner!=="global"&&D.owner!==O&&(le.current.delete(T),a=!0);a&&be();const y=new Set(c.map(T=>T.key));b(T=>{const D=Object.keys(T).filter(_=>!y.has(_));if(!D.length)return T;const ne={...T};return D.forEach(_=>delete ne[_]),ne});for(const T of M.current.keys())y.has(T)||M.current.delete(T)},[O,c,be]),e.useEffect(()=>{if(F.current?.key!==O){if(F.current){const a={from:F.current,to:z,stack:c};ae("onBlur",{route:F.current,...a}),ae("onNavigate",a),ae("onRouteChange",a)}ae("onFocus",{route:z,stack:c}),F.current=z}},[z,O,c,ae]),e.useEffect(()=>()=>{le.current.clear(),M.current.clear();for(const a of N.current.values())a.resolve({status:"dismissed"});N.current.clear()},[]),e.useEffect(()=>{X.current||(X.current=!0,l?.({route:z,stack:c}))},[]);const nt=e.useMemo(()=>ut(c,Z,r.maxCachedScreens),[c,Z,r.maxCachedScreens]),$e=e.useMemo(()=>({...Z[z.name],...z.options??{}}),[Z,z.name,z.options]);return u.jsx(_e.Provider,{value:K,children:u.jsx(st.Provider,{value:I.current,children:u.jsx(at.Provider,{value:B.current,children:u.jsx(ot.Provider,{value:Ce,children:u.jsx(Fe.Provider,{value:me,children:u.jsx(Oe.Provider,{value:E.current,children:u.jsx(je.Provider,{value:he,children:u.jsxs(ft,{dialogRef:q,options:r,requestClose:ee,exiting:m,children:[u.jsx(pt,{options:r,screen:$e,route:z,navigation:Ce,requestClose:ee,translate:i}),u.jsx("main",{className:"pmn-main",children:nt.map(a=>u.jsx(Et,{route:a,screen:Z[a.name],navigation:Ce,focused:a.key===O,resultEvent:S[a.key]??null,bodyClassName:r.bodyClassName,setFooter:ke,loadingApi:he,loadingStore:P.current,notifyError:d,registerDirtyGuard:v},a.key))}),u.jsx(Rt,{store:B.current,routeKey:O,screen:$e,options:r,route:z,navigation:Ce,requestClose:ee,translate:i,onError:d,loadingApi:he},O),u.jsx(kt,{store:P.current,translate:i}),u.jsx(Ct,{store:I.current,dismiss:G}),x&&u.jsxs("div",{className:"pmn-error",role:"alert",children:[u.jsx("span",{children:x.message||String(x)}),u.jsx("button",{type:"button",onClick:R,"aria-label":"Dismiss error",children:"×"})]})]})})})})})})})})}const St=".pmn-overlay,.pmn-dialog,.pmn-dialog *{box-sizing:border-box}.pmn-overlay{position:fixed;inset:0;z-index:1000;display:flex;overscroll-behavior:none;background:#00000073}.pmn-place-right{justify-content:flex-end;align-items:stretch}.pmn-place-left{justify-content:flex-start;align-items:stretch}.pmn-place-center{justify-content:center;align-items:center}.pmn-place-top{justify-content:center;align-items:flex-start}.pmn-place-bottom{justify-content:center;align-items:flex-end}.pmn-dialog{--pmn-surface:#fff;--pmn-body:#fff;--pmn-text:#0f172a;--pmn-muted:#475569;--pmn-border:#e2e8f0;--pmn-hover:#f1f5f9;--pmn-overlay-card:rgba(255,255,255,.92);color-scheme:light;position:relative;display:flex;flex-direction:column;min-height:0;width:100%;max-width:min(calc(100vw - var(--pmn-gap)*2),var(--pmn-max-width, var(--pmn-width)));max-height:min(calc(100dvh - var(--pmn-gap)*2),var(--pmn-max-height, 100dvh));height:var(--pmn-height, 100%);overflow:hidden;outline:none;box-shadow:0 25px 50px -12px #00000040;background:var(--pmn-surface);color:var(--pmn-text)}.pmn-place-left .pmn-dialog,.pmn-place-right .pmn-dialog{height:calc(100dvh - var(--pmn-gap)*2);max-height:calc(100dvh - var(--pmn-gap)*2)}.pmn-place-center .pmn-dialog{height:var(--pmn-height, auto);min-height:150px}.pmn-place-top .pmn-dialog,.pmn-place-bottom .pmn-dialog{height:var(--pmn-height, auto);min-height:0}.pmn-dialog[data-modal-theme=dark]{--pmn-surface:#334155;--pmn-body:#334155;--pmn-text:#f1f5f9;--pmn-muted:#cbd5e1;--pmn-border:#475569;--pmn-hover:#1e293b;--pmn-overlay-card:rgba(51,65,85,.94);color-scheme:dark}.pmn-main{min-height:0;flex:1;overflow:hidden;display:flex;flex-direction:column;background:transparent}.pmn-body{height:100%;min-height:0;overflow-y:auto;overscroll-behavior:contain;padding:16px;flex:1}.pmn-body[hidden]{display:none!important}.pmn-header{display:flex;flex-shrink:0;height:64px;align-items:center;gap:12px;padding:0 20px;background:transparent}.pmn-header h2{font-size:18px;font-weight:600;min-width:0;flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin:0}.pmn-header-spacer{flex:1}.pmn-border-bottom{border-bottom:1px solid var(--pmn-border)}.pmn-icon-button{display:inline-flex;align-items:center;justify-content:center;padding:8px;border:0;background:transparent;color:inherit;border-radius:8px;cursor:pointer}.pmn-icon-button:hover{background:var(--pmn-hover)}.pmn-footer{display:flex;flex-shrink:0;align-items:center;justify-content:flex-end;gap:12px;padding:16px 20px;background:transparent}.pmn-border-top{border-top:1px solid var(--pmn-border)}.pmn-button{padding:8px 16px;border-radius:8px;font-size:14px;font-weight:500;cursor:pointer}.pmn-button:disabled{opacity:.5;cursor:not-allowed}.pmn-button-secondary{border:1px solid var(--pmn-border);background:transparent;color:var(--pmn-text)}.pmn-button-secondary:hover:not(:disabled){background:var(--pmn-hover)}.pmn-button-primary{border:1px solid #2563eb;background:#2563eb;color:#fff}.pmn-button-primary:hover:not(:disabled){background:#1d4ed8}.pmn-loading-overlay{position:absolute;inset:0;z-index:50;display:flex;align-items:center;justify-content:center;background:#ffffffb8;backdrop-filter:blur(2px);-webkit-backdrop-filter:blur(2px);cursor:progress}.pmn-dialog[data-modal-theme=dark] .pmn-loading-overlay{background:#0f172ab8}.pmn-loading-content{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:14px;max-width:85%;text-align:center;color:var(--pmn-text);pointer-events:none}.pmn-loading-text{font-size:14px;font-weight:500;line-height:1.5;overflow-wrap:anywhere}.pmn-spinner{width:38px;height:38px;border:3px solid rgba(37,99,235,.2);border-top-color:#2563eb;border-radius:50%;animation:pmn-spin .8s linear infinite}@keyframes pmn-spin{to{transform:rotate(360deg)}}@media(prefers-reduced-motion:reduce){.pmn-spinner{animation-duration:1.8s}}.pmn-error{position:absolute;z-index:60;bottom:8px;left:12px;right:12px;display:flex;justify-content:space-between;gap:12px;padding:12px;border:1px solid #fca5a5;border-radius:8px;background:#fef2f2;color:#991b1b;font-size:13px}.pmn-error button{border:0;background:transparent;font-size:20px;cursor:pointer;color:inherit}.pmn-dialog input:not([type=checkbox]):not([type=radio]),.pmn-dialog textarea,.pmn-dialog select{color:var(--pmn-text);border-color:var(--pmn-border)}.pmn-error-screen{padding:24px;color:var(--pmn-text)}.pmn-error-screen p{color:#dc2626;overflow-wrap:anywhere}@media(max-width:640px){.pmn-overlay.pmn-mobile-fullscreen{padding:0!important}.pmn-mobile-fullscreen .pmn-dialog{max-width:100%;width:100%;height:100dvh;max-height:100dvh;border-radius:0!important}}@media(prefers-reduced-motion:reduce){.pmn-spinner{animation-duration:2s}}@keyframes pmn-fade-in{0%{opacity:0}to{opacity:1}}@keyframes pmn-fade-out{0%{opacity:1}to{opacity:0}}@keyframes pmn-scale-in{0%{opacity:0;transform:translateY(10px) scale(.97)}to{opacity:1;transform:none}}@keyframes pmn-scale-out{0%{opacity:1;transform:none}to{opacity:0;transform:translateY(10px) scale(.97)}}@keyframes pmn-right-in{0%{transform:translate(105%)}to{transform:none}}@keyframes pmn-right-out{0%{transform:none}to{transform:translate(105%)}}@keyframes pmn-left-in{0%{transform:translate(-105%)}to{transform:none}}@keyframes pmn-left-out{0%{transform:none}to{transform:translate(-105%)}}@keyframes pmn-top-in{0%{transform:translateY(-105%)}to{transform:none}}@keyframes pmn-top-out{0%{transform:none}to{transform:translateY(-105%)}}@keyframes pmn-bottom-in{0%{transform:translateY(105%)}to{transform:none}}@keyframes pmn-bottom-out{0%{transform:none}to{transform:translateY(105%)}}.pmn-entering{animation:pmn-fade-in var(--pmn-animation-duration) ease-out both}.pmn-exiting{animation:pmn-fade-out var(--pmn-animation-duration) ease-in both;pointer-events:none}.pmn-entering .pmn-dialog{animation:pmn-scale-in var(--pmn-animation-duration) cubic-bezier(.2,.8,.2,1) both}.pmn-exiting .pmn-dialog{animation:pmn-scale-out var(--pmn-animation-duration) ease-in both}.pmn-entering.pmn-place-right .pmn-dialog{animation-name:pmn-right-in}.pmn-exiting.pmn-place-right .pmn-dialog{animation-name:pmn-right-out}.pmn-entering.pmn-place-left .pmn-dialog{animation-name:pmn-left-in}.pmn-exiting.pmn-place-left .pmn-dialog{animation-name:pmn-left-out}.pmn-entering.pmn-place-top .pmn-dialog{animation-name:pmn-top-in}.pmn-exiting.pmn-place-top .pmn-dialog{animation-name:pmn-top-out}.pmn-entering.pmn-place-bottom .pmn-dialog{animation-name:pmn-bottom-in}.pmn-exiting.pmn-place-bottom .pmn-dialog{animation-name:pmn-bottom-out}.pmn-no-animation,.pmn-no-animation .pmn-dialog{animation:none!important}@media(prefers-reduced-motion:reduce){.pmn-entering,.pmn-exiting,.pmn-entering .pmn-dialog,.pmn-exiting .pmn-dialog{animation:none!important}}.pmn-toast-region{position:absolute;top:56px;left:12px;right:12px;z-index:80;display:flex;flex-direction:column;align-items:center;gap:8px;pointer-events:none;max-height:calc(100% - 72px);overflow:hidden}.pmn-toast{pointer-events:auto;display:flex;align-items:flex-start;gap:10px;width:max-content;max-width:100%;min-width:min(260px,100%);padding:11px 13px;border:1px solid var(--pmn-border);border-radius:9px;background:var(--pmn-surface);color:var(--pmn-text);box-shadow:0 5px 18px #0000001a;font-size:13px;line-height:1.5;overflow-wrap:anywhere}.pmn-toast-symbol{flex:0 0 20px;display:grid;place-items:center;width:20px;height:20px;border-radius:50%;font-size:13px;font-weight:700;background:var(--pmn-hover);color:var(--pmn-muted)}.pmn-toast-success .pmn-toast-symbol{background:#dcfce7;color:#15803d}.pmn-toast-error .pmn-toast-symbol{background:#fee2e2;color:#b91c1c}.pmn-toast-warning .pmn-toast-symbol{background:#fef3c7;color:#b45309}.pmn-toast-info .pmn-toast-symbol{background:#dbeafe;color:#1d4ed8}.pmn-toast-message{flex:1;min-width:0;white-space:pre-wrap}.pmn-toast-close{border:0;background:transparent;color:var(--pmn-muted);cursor:pointer;font-size:19px;line-height:18px;padding:0 1px}.pmn-toast-close:hover{color:var(--pmn-text)}.pmn-button-danger{background:#dc2626!important;color:#fff!important;border-color:#dc2626!important}",He="react-modal-navigation-styles",Ae=new WeakMap;function Mt(){e.useInsertionEffect(()=>{if(typeof document>"u")return;const t=document;let n=Ae.get(t);if(!n){let o=t.getElementById(He);const r=!o;o||(o=t.createElement("style"),o.id=He,o.setAttribute("data-react-modal-navigation",""),o.textContent=St,t.head.appendChild(o)),n={element:o,owned:r,count:0},Ae.set(t,n)}return n.count+=1,()=>{n.count-=1,n.count===0&&(n.owned&&n.element.remove(),Ae.delete(t))}},[])}function Se(t,n,o){if(typeof t=="string"){if(!t.trim())throw new TypeError("[react-modal-navigation] modal name must not be empty");return{name:t,params:n??{},options:o??{}}}if(t===null||typeof t!="object"||Array.isArray(t))throw new TypeError("[react-modal-navigation] open expects a modal name or a configuration object");const{name:r,screen:i,params:g={},options:l={},...f}=t;if(typeof r!="string"||!r.trim())throw new TypeError("[react-modal-navigation] open config requires a non-empty string name");if(l===null||typeof l!="object"||Array.isArray(l))throw new TypeError("[react-modal-navigation] open config options must be an object");if(i!==void 0&&(typeof i!="string"||!i.trim()))throw new TypeError("[react-modal-navigation] screen must be a non-empty string");return{name:r,...i===void 0?{}:{screen:i},params:g,options:{...f,...l}}}const jt={placement:"right",showHeader:!0,showBackButton:!0,showCloseButton:!0,viewportGap:5,borderRadius:12,closeOnOverlay:!1,closeOnEsc:!0},Tt=t=>({"modal.loading":"加载中...","modal.processing":"处理中...","modal.back":"返回","modal.close":"关闭","modal.cancel":"取消","modal.done":"完成"})[t]??t;function Nt({registry:t,children:n,defaultOptions:o={},backgroundColor:r,theme:i,translate:g=Tt,onError:l,confirmDiscard:f}){Mt();const[d,x]=e.useState(null),[R,v]=e.useState(null),[h,m]=e.useState(0),c=e.useRef(null),L=e.useRef(new Map),E=e.useRef([]),P=e.useRef(null),B=e.useRef(null),I=e.useRef(0),k=e.useRef(null),$=e.useRef(!1),K=e.useRef(0),G=e.useRef(null),S=e.useRef(new Map),[b,M]=e.useState(!1),q=e.useRef(f);q.current=f;const F=e.useCallback((s,p)=>(S.current.set(s,p),()=>{S.current.get(s)===p&&S.current.delete(s)}),[]),j=e.useCallback(async s=>{for(const p of S.current.values()){if(!p.dirty)continue;if((p.onBeforeDiscard?await p.onBeforeDiscard(s):q.current?await q.current(s):typeof window<"u"&&typeof window.confirm=="function"?window.confirm(p.message||"有未保存的修改,确定放弃吗?"):!1)===!1)return!1}return!0},[]),W=e.useCallback(async(s,p)=>{for(const C of s){const w=S.current.get(C);if(!w?.dirty)continue;if((w.onBeforeDiscard?await w.onBeforeDiscard(p):q.current?await q.current(p):typeof window<"u"&&typeof window.confirm=="function"?window.confirm(w.message||"有未保存的修改,确定放弃吗?"):!1)===!1)return!1}return!0},[]),N=e.useRef(!0),Q=e.useRef(null),J=e.useRef(l);J.current=l;const A=e.useCallback((s,p)=>{N.current&&v(s);try{J.current?J.current(s,p):console.error("[react-modal-navigation]",s)}catch(C){console.error("[react-modal-navigation] onError failed",C)}},[]),re=e.useCallback((s,p)=>{const C=L.current.get(s);L.current.delete(s),C?.(p)},[]),X=e.useCallback(s=>({...jt,...o,...i!==void 0?{theme:i}:{},...r!==void 0?{backgroundColor:r}:{},...s.config.modalOptions,...s.overrides}),[o,i,r]),ge=d?X(d):null,z=e.useRef(null);z.current=ge,Q.current=ge;const O=e.useCallback(async(s="api",p,C={})=>{const w=c.current;if(!w||k.current||$.current)return!1;k.current=w.id,$.current=!0;const H=Q.current??X(w),U={...C,reason:s,result:p,name:w.name};try{if(!await j(U)||await H.onBeforeClose?.(U)===!1||c.current?.id!==w.id||!N.current||(M(!0),await new Promise(Y=>{const ee=H.animation===!1||typeof window<"u"&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches?0:Math.max(0,Number(H.animationDuration??220)||0);setTimeout(Y,Math.min(ee,1e3))}),!N.current||c.current?.id!==w.id))return!1;c.current=null,G.current=null,x(null),M(!1),S.current.clear(),re(w.id,C.confirmed||p!==void 0?{status:"confirmed",value:p,reason:s}:{status:"dismissed",reason:s});try{await H.onClose?.(U)}catch(Y){A(Y,{phase:"onClose",name:w.name})}return!0}catch(Y){return A(Y,{phase:"onBeforeClose",name:w.name}),!1}finally{k.current===w.id&&(k.current=null),$.current=!1,!c.current&&N.current&&queueMicrotask(()=>B.current?.())}},[X,A,re,j]),oe=e.useCallback(async(s,p={},C={},w,H)=>{const U=t?.[s];if(!U)throw new Error(`[react-modal-navigation] Unknown modal: ${s}`);const Y=H??U.initialRoute;if(!U.screens?.[Y])throw new Error(`[react-modal-navigation] Unknown initial screen '${Y}' in modal '${s}'`);if(!N.current||$.current||k.current)return null;$.current=!0;const ee=K.current;try{const te=c.current;if(te){const me=Q.current??X(te),fe={reason:"replace",name:te.name,nextName:s};try{if(!await j(fe)||await me.onBeforeClose?.(fe)===!1)return null}catch(ie){return A(ie,{phase:"onBeforeClose",name:te.name}),null}if(!N.current||ee!==K.current||c.current?.id!==te.id)return null;c.current=null,G.current=null,x(null),S.current.clear(),re(te.id,{status:"replaced",reason:"replace"});try{await me.onClose?.(fe)}catch(ie){A(ie,{phase:"onClose",name:te.name})}if(!N.current||ee!==K.current)return null}const ce={id:++I.current,name:s,screen:Y,params:p,config:U,overrides:C};return c.current=ce,G.current=null,w&&L.current.set(ce.id,w),v(null),x(ce),ce.id}finally{$.current=!1}},[t,X,A,re,j]);P.current=oe;const he=e.useCallback(async()=>{if(!N.current||c.current||$.current||k.current)return;const s=E.current.shift();if(s){m(E.current.length);try{const p=await P.current(s.args.name,s.args.params,s.args.options,s.resolveResult,s.args.screen);p===null?(s.resolveResult?.({status:"dismissed",reason:"blocked"}),s.resolveId?.(null),queueMicrotask(()=>B.current?.())):s.resolveId?.(p)}catch(p){s.reject?.(p),queueMicrotask(()=>B.current?.())}}},[]);B.current=he;const be=e.useCallback((s,p,C)=>{const w=Se(s,p,C);return t?.[w.name]?new Promise((H,U)=>{E.current.push({args:w,resolveId:H,reject:U}),m(E.current.length),queueMicrotask(()=>B.current?.())}):Promise.reject(new Error(`[react-modal-navigation] Unknown modal: ${w.name}`))},[t]),le=e.useCallback((s,p,C)=>{const w=Se(s,p,C);return t?.[w.name]?new Promise((H,U)=>{E.current.push({args:w,resolveResult:H,reject:U}),m(E.current.length),queueMicrotask(()=>B.current?.())}):Promise.reject(new Error(`[react-modal-navigation] Unknown modal: ${w.name}`))},[t]),se=e.useCallback(s=>{if(!s||typeof s!="object"||Array.isArray(s))throw new TypeError("[react-modal-navigation] update expects an options object");const p=c.current;if(!p||$.current)return!1;const C={...p,overrides:{...p.overrides,...s}};return c.current=C,x(C),Q.current=X(C),!0},[X]),Z=e.useCallback((s="queue-cleared")=>{const p=E.current.splice(0);m(0);for(const C of p)C.resolveId?.(null),C.resolveResult?.({status:"dismissed",reason:s});return p.length},[]),we=e.useCallback((s,p,C)=>{const w=Se(s,p,C);return oe(w.name,w.params,w.options,void 0,w.screen)},[oe]),de=e.useCallback((s,p,C)=>{const w=Se(s,p,C);return new Promise((H,U)=>{oe(w.name,w.params,w.options,H,w.screen).then(Y=>{Y===null&&H({status:"dismissed",reason:"blocked"})},U)})},[oe]),ke=e.useCallback(s=>O("api",s),[O]),xe=e.useCallback((s="api")=>O(s),[O]),ye=e.useCallback(s=>O("confirm",s,{confirmed:!0}),[O]),ae=e.useCallback((s,p)=>G.current?.setLoading(s,p),[]),V=e.useMemo(()=>({open:we,openAsync:de,enqueue:be,enqueueAsync:le,update:se,clearQueue:Z,close:ke,dismiss:xe,confirm:ye,setLoading:ae,queueSize:h,isOpen:!!d,activeName:d?.name??null,error:R,clearError:()=>v(null)}),[we,de,be,le,se,Z,ke,xe,ye,ae,d,R,h]);return e.useEffect(()=>(N.current=!0,()=>{N.current=!1,K.current+=1,c.current=null;for(const p of L.current.values())p({status:"dismissed",reason:"unmount"});L.current.clear(),S.current.clear();const s=E.current.splice(0);for(const p of s)p.resolveId?.(null),p.resolveResult?.({status:"dismissed",reason:"unmount"})}),[]),u.jsxs(We.Provider,{value:V,children:[n,d&&u.jsx(Je,{config:d.config,initialScreen:d.screen,params:d.params,options:ge,translate:g,notifyError:A,error:R,clearError:()=>v(null),registerLoading:s=>{G.current=s},registerDirtyGuard:F,canNavigate:W,exiting:b,onRequestClose:O,onOpened:s=>{try{const p=z.current?.onOpen?.(s);Promise.resolve(p).catch(C=>A(C,{phase:"onOpen"}))}catch(p){A(p,{phase:"onOpen"})}}},d.id)]})}const Lt=Object.freeze({canGoBack:!1,stack:[],currentRoute:null}),Pt=()=>()=>{},Ue=()=>Lt;function Bt(){const t=e.useContext(We),n=e.useContext(Fe),o=e.useContext(Oe),r=e.useSyncExternalStore(o?.subscribe??Pt,o?.getSnapshot??Ue,o?.getSnapshot??Ue);if(!t)throw new Error("[react-modal-navigation] useModal requires <ModalProvider>");const i=e.useMemo(()=>{const g=()=>{if(!n)throw new Error("[react-modal-navigation] navigation requires an active modal screen; use modal.open() outside a modal");return n};return{navigate:(...l)=>g().navigate(...l),replace:(...l)=>g().replace(...l),reset:(...l)=>g().reset(...l),setParams:(...l)=>g().setParams(...l),setOptions:(...l)=>g().setOptions(...l),goBack:(...l)=>g().goBack(...l),close:(...l)=>g().close(...l),setLoading:(...l)=>g().setLoading(...l),canGoBack:r.canGoBack,stack:r.stack,currentRoute:r.currentRoute}},[n,r]);return e.useMemo(()=>({...t,modal:t,navigation:i}),[t,i])}function Xe(){const t=e.useContext(Fe);if(!t)throw new Error("useModalNavigationCommands requires an active modal screen");return t}function Ze(){const t=e.useContext(Oe);if(!t)throw new Error("useModalNavigationState requires an active modal screen");return e.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getSnapshot)}function At(){const t=Xe(),n=Ze();return e.useMemo(()=>({...t,...n}),[t,n])}function Ie(){const t=e.useContext(Me);if(!t)throw new Error("useIsFocused must be called inside a modal screen");return t.isFocused}function qt(t){const n=Ie();e.useEffect(()=>{if(n)return t()},[n,t])}function Ft(t){const n=e.useContext(Me);if(!n)throw new Error("useNavigationResult requires an active modal screen");const o=e.useRef(t),r=e.useRef(null);e.useEffect(()=>{o.current=t},[t]),e.useEffect(()=>{!n.isFocused||!n.resultEvent||r.current!==n.resultEvent.id&&(r.current=n.resultEvent.id,o.current(n.resultEvent.data))},[n.isFocused,n.resultEvent])}function Ot(t={}){const n=e.useContext(Me);if(!n)throw new Error("[react-modal-navigation] useModalFooter requires an active modal screen");const{setFooter:o,routeKey:r}=n,i=e.useRef(t);i.current=t;const g=e.useMemo(()=>(...S)=>i.current.done?.(...S),[]),l=e.useMemo(()=>(...S)=>(i.current.cancel??i.current.cancle)?.(...S),[]),f=e.useMemo(()=>(...S)=>i.current.renderFooter?.(...S),[]),d=typeof t.done=="function",x=typeof(t.cancel??t.cancle)=="function",R=typeof t.renderFooter=="function",{showFooter:v,showFooterBorder:h,doneDisabled:m,doneText:c,cancelText:L,loadingText:E,footerClassName:P}=t,B=e.useRef({source:null,normalized:void 0}),I=Array.isArray(t.actions)?t.actions:null,k=B.current.source;I===k||I&&k&&I.length===k.length&&I.every((S,b)=>{const M=k[b];return[...new Set([...Object.keys(S),...Object.keys(M)])].every(F=>F==="onClick"||Object.is(S[F],M[F]))})||(B.current={source:I?.map(S=>({...S}))??null,normalized:I?.map((S,b)=>({...S,onClick:(...M)=>(i.current.actions?.find(F=>F.key===S.key)??i.current.actions?.[b])?.onClick?.(...M)}))});const K=B.current.normalized,G=e.useMemo(()=>({showFooter:v,showFooterBorder:h,doneDisabled:m,doneText:c,cancelText:L,loadingText:E,footerClassName:P,...K!==void 0?{actions:K}:{},...d?{done:g}:{},...x?{cancel:l}:{},...R?{renderFooter:f}:{}}),[v,h,m,c,L,E,P,K,d,x,R,g,l,f]);e.useEffect(()=>{o(r,G)},[r,o,G]),e.useEffect(()=>()=>o(r,null),[r,o])}function et(){const t=e.useContext(je),n=e.useContext(De);if(!t||!n)throw new Error("[react-modal-navigation] useModalLoading requires an active modal screen");const o=e.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getSnapshot);return e.useMemo(()=>({...t,isLoading:o.visible}),[t,o.visible])}function Dt(){const t=e.useContext(je);if(!t)throw new Error("[react-modal-navigation] useModalLoadingCommands requires an active modal screen");return t}function It(){const t=e.useContext(De);if(!t)throw new Error("[react-modal-navigation] useModalLoadingState requires an active modal screen");return e.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getSnapshot)}function $t(){const t=et(),n=Ie(),o=e.useRef(!0),r=e.useRef(!1),[i,g]=e.useState(!1),[l,f]=e.useState(null),d=e.useRef(t);return d.current=t,e.useEffect(()=>(o.current=!0,()=>{o.current=!1}),[]),{run:e.useCallback(async(R,v={})=>{if(r.current)return{status:"busy"};if(typeof R!="function")throw new TypeError("[react-modal-navigation] run requires a function");r.current=!0,o.current&&(g(!0),f(null));const h=d.current.showLoading(v.loadingText);try{const m=await R();return o.current&&await v.onSuccess?.(m),{status:"success",value:m}}catch(m){if(o.current){f(m);try{await v.onError?.(m)}catch(c){console.error("[react-modal-navigation] onError failed",c)}}if(v.throwOnError)throw m;return{status:"error",error:m}}finally{h!=null&&d.current.hideLoading(h),r.current=!1,o.current&&g(!1)}},[]),pending:i,error:l,clearError:()=>f(null),isFocused:n}}function zt(t,n={}){const o=e.useContext(Ye);if(!o)throw new Error("[react-modal-navigation] useModalUnsavedChanges must be used inside a modal screen");const r=e.useRef({dirty:t,...n});r.current={dirty:t,...n};const{routeKey:i,registerDirtyGuard:g}=o;e.useEffect(()=>g(i,{get dirty(){return!!r.current.dirty},get message(){return r.current.message},get onBeforeDiscard(){return r.current.onBeforeDiscard}}),[i,g])}const Kt=()=>{const t=e.useContext(_e);if(!t)throw new Error("[react-modal-navigation] useToast requires an active modal");return t};function tt(){const t=e.useContext(Ve);if(!t)throw new Error("[react-modal-navigation] useModalRoute requires a modal screen");return t}function Gt(){return tt().params}exports.ModalNavigator=Je;exports.ModalProvider=Nt;exports.useFocusEffect=qt;exports.useIsFocused=Ie;exports.useModal=Bt;exports.useModalFooter=Ot;exports.useModalLoading=et;exports.useModalLoadingCommands=Dt;exports.useModalLoadingState=It;exports.useModalNavigation=At;exports.useModalNavigationCommands=Xe;exports.useModalNavigationState=Ze;exports.useModalParams=Gt;exports.useModalRoute=tt;exports.useModalTask=$t;exports.useModalUnsavedChanges=zt;exports.useNavigationResult=Ft;exports.useToast=Kt;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),e=require("react"),pt=require("react-dom"),rt=e.createContext(null),gt=e.createContext(null),je=e.createContext(null),Te=e.createContext(null),ot=e.createContext(null),at=e.createContext(null),De=e.createContext(null),ze=e.createContext(null),Ie=e.createContext(null),ht=e.createContext(null),bt=e.createContext(null),st=e.createContext(null);function yt(t){let n=t;const o=new Set;return{getSnapshot:()=>n,subscribe:r=>(o.add(r),()=>o.delete(r)),publish(r){if(n!==r){n=r;for(const c of[...o])c()}},listenerCount:()=>o.size}}function Be(t){let n=t;const o=new Set;return{getSnapshot:()=>n,subscribe:r=>(o.add(r),()=>o.delete(r)),publish(r){if(!Object.is(n,r)){n=r;for(const c of[...o])c()}},listenerCount:()=>o.size}}let xt=0;const $e=(t,n)=>({key:`modal-route-${++xt}`,name:t,params:n??{}}),ct=(t,n)=>[$e(t,n)];function Se(t,n){switch(n.type){case"RESET":return ct(n.name,n.params);case"NAVIGATE":{const o=t.findIndex(r=>r.name===n.name);return o<0?[...t,$e(n.name,n.params)]:t.slice(0,o+1).map((r,c)=>c===o?{...r,params:n.params??{}}:r)}case"SET_OPTIONS":return t.map((o,r)=>r===t.length-1?{...o,options:{...o.options??{},...n.options??{}}}:o);case"SET_PARAMS":return t.map((o,r)=>r===t.length-1?{...o,params:{...o.params??{},...n.params??{}}}:o);case"BACK":return t.length>1?t.slice(0,-1):t;case"REPLACE":return t.length?[...t.slice(0,-1),$e(n.name,n.params)]:t;default:return t}}function vt(t,n,o=1/0){const r=o===1/0?1/0:Math.max(0,Math.floor(Number(o)||0)),c=t.slice(0,-1).filter(m=>n[m.name]?.keepAlive!==!1),h=new Set((r===0?[]:c.slice(-r)).map(m=>m.key));return t.filter((m,f)=>f===t.length-1||h.has(m.key))}const Xe=()=>{if(typeof document>"u")return"light";const t=document.documentElement,n=document.body;return t.classList.contains("dark")||n.classList.contains("dark")||t.dataset.theme==="dark"||n.dataset.theme==="dark"?"dark":t.classList.contains("light")||n.classList.contains("light")||t.dataset.theme==="light"||n.dataset.theme==="light"?"light":window.matchMedia?.("(prefers-color-scheme: dark)").matches?"dark":"light"};let we=0;const se=[];let Fe=null;function wt(){if(we++,we===1){const n=document.documentElement,o=document.body,r={html:n.style.overflow,body:o.style.overflow,padding:o.style.paddingRight,width:o.style.getPropertyValue("--modal-scrollbar-width")},c=Math.max(0,window.innerWidth-n.clientWidth),h=parseFloat(getComputedStyle(o).paddingRight)||0;c&&(o.style.paddingRight=`${h+c}px`),o.style.setProperty("--modal-scrollbar-width",`${c}px`),n.style.overflow="hidden",o.style.overflow="hidden",Fe=()=>{n.style.overflow=r.html,o.style.overflow=r.body,o.style.paddingRight=r.padding,r.width?o.style.setProperty("--modal-scrollbar-width",r.width):o.style.removeProperty("--modal-scrollbar-width")}}let t=!1;return()=>{t||(t=!0,we=Math.max(0,we-1),we||(Fe?.(),Fe=null))}}const kt='a[href],button:not([disabled]),input:not([disabled]),textarea:not([disabled]),select:not([disabled]),[tabindex]:not([tabindex="-1"])',Ct=t=>!t.closest('[inert], [hidden], [aria-hidden="true"]')&&t.getClientRects().length>0&&getComputedStyle(t).visibility!=="hidden"&&getComputedStyle(t).display!=="none";function Rt({dialogRef:t,options:n,requestClose:o,children:r,exiting:c=!1}){const h=e.useRef(null),m=e.useRef(null),f=e.useRef(o);f.current=o;const p=e.useRef(n.closeOnEsc);p.current=n.closeOnEsc;const[y,R]=e.useState(Xe),v=n.theme==="light"||n.theme==="dark"?n.theme:y;e.useEffect(()=>{if(n.theme==="light"||n.theme==="dark")return;const b=()=>R(Xe()),S=new MutationObserver(b);for(const D of[document.documentElement,document.body])S.observe(D,{attributes:!0,attributeFilter:["class","data-theme"]});const $=window.matchMedia?.("(prefers-color-scheme: dark)");return $?.addEventListener?.("change",b),b(),()=>{S.disconnect(),$?.removeEventListener?.("change",b)}},[n.theme]),e.useEffect(()=>{m.current=document.activeElement;const b=wt(),S=h.current;se.push(S),t.current?.focus({preventScroll:!0});const $=M=>{const I=t.current;if(!I||se.at(-1)!==S)return;if(M.key==="Escape"&&p.current!==!1){M.preventDefault(),f.current("escape");return}if(M.key!=="Tab")return;const q=[...I.querySelectorAll(kt)].filter(Ct);if(!q.length){M.preventDefault(),I.focus();return}const te=q[0],ee=q.at(-1);I.contains(document.activeElement)?M.shiftKey&&(document.activeElement===te||document.activeElement===I)?(M.preventDefault(),ee.focus()):!M.shiftKey&&(document.activeElement===ee||document.activeElement===I)&&(M.preventDefault(),te.focus()):(M.preventDefault(),(M.shiftKey?ee:te).focus())},D=M=>{se.at(-1)===S&&t.current&&!t.current.contains(M.target)&&t.current.focus({preventScroll:!0})};return document.addEventListener("keydown",$),document.addEventListener("focusin",D),()=>{document.removeEventListener("keydown",$),document.removeEventListener("focusin",D);const M=se.at(-1)===S,I=se.indexOf(S);if(I!==-1&&se.splice(I,1),b(),M){const q=m.current;q?.isConnected&&!q.closest("[inert], [hidden]")?q.focus?.({preventScroll:!0}):se.at(-1)?.querySelector("[role=dialog]")?.focus?.({preventScroll:!0})}}},[t]);const u=n.backgroundColor??n.backgroudColor,d=typeof u=="string"?u:u?.[v],s=typeof d=="string"&&/^(#|rgb\(|rgba\(|hsl\(|hsla\(|oklch\(|color\(|var\()/.test(d.trim())?d:null,L={sm:400,md:560,lg:720,xl:960,full:"100%"},N=["center","left","right","top","bottom"].includes(n.placement)?n.placement:"right",B=b=>typeof b=="number"?`${b}px`:b,P=B(n.width??L[n.size]??460),j=B(n.height),k=B(n.maxHeight),F=B(n.maxWidth),H=Number(n.viewportGap??5),U=Number.isFinite(H)?Math.max(0,H):5,E=typeof n.borderRadius=="number"?`${n.borderRadius}px`:n.borderRadius??"12px";return pt.createPortal(l.jsx("div",{ref:h,className:`pmn-overlay ${c?"pmn-exiting":"pmn-entering"} ${n.animation===!1?"pmn-no-animation":""} pmn-place-${N} ${n.mobileFullscreen?"pmn-mobile-fullscreen":""}`,style:{padding:U,"--pmn-animation-duration":`${Math.min(1e3,Math.max(0,Number(n.animationDuration??220)||0))}ms`},onMouseDown:b=>{b.target===b.currentTarget&&n.closeOnOverlay===!0&&f.current("overlay")},children:l.jsx("section",{ref:t,tabIndex:-1,role:"dialog","aria-modal":"true","aria-label":n.ariaLabel??"Dialog","data-modal-theme":v,className:`pmn-dialog ${v==="dark"?"dark":""} ${!s&&d?d:""} ${n.className??""}`,style:{"--pmn-width":P,"--pmn-gap":`${U}px`,...j!==void 0?{"--pmn-height":j}:{},...k!==void 0?{"--pmn-max-height":k}:{},...F!==void 0?{"--pmn-max-width":F}:{},borderRadius:E,...s?{backgroundColor:s}:{}},children:r})}),document.body)}function et({back:t}){return l.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",width:"20",height:"20",fill:"none",stroke:"currentColor",strokeWidth:"2",children:t?l.jsx("path",{d:"m15 18-6-6 6-6"}):l.jsx("path",{d:"M18 6 6 18M6 6l12 12"})})}function Et({options:t,screen:n,route:o,navigation:r,requestClose:c,translate:h,canGoBack:m}){if(t.showHeader===!1)return null;const f=h??(d=>d),p=n.showTitle??t.showTitle??!0,y=typeof n.title=="function"?n.title({t:f,route:o,navigation:r}):n.title??o.name,R={route:o,navigation:r,close:c,canGoBack:m,title:y,t:f},v=n.renderHeader??t.renderHeader;if(v)return v(R);const u=n.renderHeaderRight??t.renderHeaderRight;return l.jsxs("header",{className:`pmn-header ${n.showHeaderBorder??t.showHeaderBorder?"pmn-border-bottom":""} ${t.headerClassName??""}`,children:[(n.showBackButton??t.showBackButton)!==!1&&m&&l.jsx("button",{type:"button",className:"pmn-icon-button","aria-label":f("modal.back"),onClick:()=>r.goBack(),children:l.jsx(et,{back:!0})}),p?l.jsx("h2",{children:y}):l.jsx("div",{className:"pmn-header-spacer"}),u?.(R),t.showCloseButton!==!1&&l.jsx("button",{type:"button",className:"pmn-icon-button","aria-label":f("modal.close"),onClick:()=>c("header"),children:l.jsx(et,{})})]})}function St({screen:t,options:n,override:o,route:r,navigation:c,requestClose:h,translate:m,onError:f,loadingApi:p}){const[y,R]=e.useState(null),v=e.useRef(new Set),u=e.useRef(!0);e.useEffect(()=>(u.current=!0,()=>{u.current=!1}),[]);const d=m??(b=>b),s={...n,...t,...o},{showFooter:L,renderFooter:N,done:B,cancel:P,cancle:j}=s,k=P??j,F={route:r,navigation:c,close:h,t:d};if(L===!1)return null;const H=`pmn-footer ${s.showFooterBorder?"pmn-border-top":""} ${s.footerClassName??""}`;if(typeof N=="function")return l.jsx("footer",{className:H,children:N({...F,pending:v.current.size>0})});const U=Array.isArray(s.actions)?s.actions:null;if(!U&&typeof B!="function"&&typeof k!="function")return null;const E=async(b,S,$)=>{if(v.current.has(b)||typeof S!="function")return;v.current.add(b),R(b);const D=p?.begin(r.key,$??s.loadingText??d("modal.processing"));try{await S(F)}catch(M){f?.(M,{phase:"footer",action:b,route:r})}finally{p?.end(r.key,D),v.current.delete(b),u.current&&R(M=>M===b?null:M)}};return U?l.jsx("footer",{className:H,children:U.filter(b=>!b.hidden).map(b=>{const S=v.current.has(b.key)||b.loading===!0;return l.jsx("button",{type:"button",disabled:b.disabled===!0||S,className:`pmn-button ${b.variant==="primary"||b.variant==="danger"?"pmn-button-primary":"pmn-button-secondary"} ${b.variant==="danger"?"pmn-button-danger":""}`,onClick:()=>E(b.key,b.onClick,b.loadingText),children:S?b.loadingText??s.loadingText??d("modal.processing"):b.label},b.key)})}):l.jsxs("footer",{className:H,children:[typeof k=="function"&&l.jsx("button",{type:"button",disabled:y!==null,onClick:()=>E("cancel",k),className:"pmn-button pmn-button-secondary",children:s.cancelText??d("modal.cancel")}),typeof B=="function"&&l.jsx("button",{type:"button",disabled:y!==null||s.doneDisabled===!0,onClick:()=>E("done",B),className:"pmn-button pmn-button-primary",children:y==="done"?s.loadingText??d("modal.processing"):s.doneText??d("modal.done")})]})}function Mt({loading:t,translate:n}){if(!t.visible)return null;const r=(n??(h=>h))("modal.loading"),c=t.text??(r==="modal.loading"?"加载中...":r);return l.jsx("div",{className:"pmn-loading-overlay",role:"status","aria-live":"polite","aria-busy":"true",children:l.jsxs("div",{className:"pmn-loading-content",children:[l.jsx("span",{className:"pmn-spinner","aria-hidden":"true"}),c&&l.jsx("span",{className:"pmn-loading-text",children:c})]})})}class jt extends e.Component{state={error:null};static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n,o){this.props.onError?.(n,{phase:"render",route:this.props.route,componentStack:o.componentStack})}componentDidUpdate(n){n.route?.key!==this.props.route?.key&&this.state.error&&this.setState({error:null})}render(){return this.state.error?l.jsxs("div",{role:"alert",className:"pmn-error-screen",children:[l.jsx("strong",{children:"页面加载失败"}),l.jsx("p",{children:this.state.error.message}),l.jsx("button",{type:"button",className:"pmn-button pmn-button-secondary",onClick:()=>this.setState({error:null}),children:"重试"})]}):this.props.children}}const Tt={success:"✓",error:"×",warning:"!",info:"i"};function Nt({items:t,dismiss:n}){return t.length?l.jsx("div",{className:"pmn-toast-region","aria-label":"Notifications",children:t.map(o=>l.jsxs("div",{className:`pmn-toast pmn-toast-${o.type}`,role:o.type==="error"||o.type==="warning"?"alert":"status",children:[l.jsx("span",{className:"pmn-toast-symbol","aria-hidden":"true",children:Tt[o.type]}),l.jsx("span",{className:"pmn-toast-message",children:o.message}),o.dismissible&&l.jsx("button",{type:"button",className:"pmn-toast-close","aria-label":"Dismiss notification",onClick:()=>n(o.id),children:"×"})]},o.id))}):null}function At(t,n){const o=e.useRef(0),r=e.useRef(new Map),c=e.useCallback(f=>{clearTimeout(r.current.get(f)),r.current.delete(f),n.current&&t.current.publish(t.current.getSnapshot().filter(p=>p.id!==f))},[]),h=e.useCallback((f,p={})=>{if(typeof f!="string"||!f.trim())throw new TypeError("[react-modal-navigation] toast message must be a non-empty string");const y=typeof p=="string"?{type:p}:p??{},R=["success","error","warning","info"].includes(y.type)?y.type:"info",v=++o.current,u=Number.isFinite(y.duration)?Math.max(0,y.duration):3e3;if(!n.current)return null;const d=t.current.getSnapshot(),s=d.slice(0,Math.max(0,d.length-4));for(const L of s)clearTimeout(r.current.get(L.id)),r.current.delete(L.id);return t.current.publish([...d.slice(-4),{id:v,message:f,type:R,dismissible:y.dismissible!==!1}]),u>0&&r.current.set(v,setTimeout(()=>c(v),u)),v},[c]),m=e.useMemo(()=>{const f=(p,y)=>h(p,y);for(const p of["success","error","warning","info"])f[p]=(y,R={})=>h(y,{...R,type:p});return f.promise=async(p,y,R={})=>{const v=h(y.loading,{...R,type:"info",duration:0});try{const u=await(typeof p=="function"?p():p);v!=null&&c(v);const d=typeof y.success=="function"?y.success(u):y.success;return d&&h(d,{...R,type:"success"}),u}catch(u){v!=null&&c(v);const d=typeof y.error=="function"?y.error(u):y.error;throw d&&h(d,{...R,type:"error"}),u}},f.dismiss=c,f.clear=()=>{for(const p of r.current.values())clearTimeout(p);r.current.clear(),t.current.publish([])},f},[h,c]);return e.useEffect(()=>()=>{for(const f of r.current.values())clearTimeout(f);r.current.clear()},[]),{toast:m,dismissToast:c}}function Lt(t,n,o){const r=e.useRef(new Map),c=e.useRef(0),h=e.useCallback(()=>{if(!n.current)return;const u=[...r.current.values()],d={visible:u.length>0,text:u.at(-1)?.text??null,count:u.length},s=t.current.getSnapshot();(s.visible!==d.visible||s.text!==d.text||s.count!==d.count)&&t.current.publish(d)},[]),m=e.useCallback((u,d)=>{if(!n.current||u!=="global"&&o.current!==u)return null;const s=++c.current;return r.current.set(s,{owner:u,text:d}),h(),s},[h]),f=e.useCallback((u,d)=>{if(d!=null)r.current.get(d)?.owner===u&&r.current.delete(d);else for(const[s,L]of r.current)L.owner===u&&r.current.delete(s);h()},[h]),p=e.useCallback((u,d)=>{u?(f("global"),m("global",d)):f("global")},[m,f]),y=e.useCallback((u,d,s)=>{d?(f(u),m(u,s)):f(u)},[m,f]);return{loadingApi:e.useMemo(()=>({setLoading:p,setScreenLoading:y,begin:m,end:f}),[p,y,m,f]),refreshLoading:h,loadingTasks:r,setLoading:p}}const Pt=e.memo(function({store:n,translate:o}){const r=e.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getSnapshot);return l.jsx(Mt,{loading:r,translate:o})}),qt=e.memo(function({store:n,dismiss:o}){const r=e.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getSnapshot);return l.jsx(Nt,{items:r,dismiss:o})}),Bt=e.memo(function({store:n,routeKey:o,...r}){const c=e.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getSnapshot);return l.jsx(St,{...r,override:c[o]})}),Ft=e.memo(function({route:n,screen:o,navigation:r,focused:c,resultEvent:h,setFooter:m,loadingApi:f,loadingStore:p,bodyClassName:y,notifyError:R,registerDirtyGuard:v,pageMotion:u}){const d=o.component,s=e.useRef(null),L=e.useRef(!1);e.useLayoutEffect(()=>{const j=c&&!L.current;if(L.current=c,!j||!u?.enabled||!s.current?.animate)return;const k=u.direction==="back"?-u.distance:u.distance,F=s.current.animate([{opacity:.18,transform:`translate3d(${k}px,0,0) scale(.985)`},{opacity:1,transform:"translate3d(0,0,0)"}],{duration:u.duration,easing:"cubic-bezier(.22,1,.36,1)"});return()=>F.cancel()},[c,u?.enabled,u?.direction,u?.duration,u?.distance]);const N=e.useMemo(()=>({isFocused:c,resultEvent:h,routeKey:n.key,setFooter:m}),[c,h,n.key,m]),B=e.useMemo(()=>({setLoading:(j,k)=>f.setScreenLoading(n.key,j,k),showLoading:j=>f.begin(n.key,j),hideLoading:j=>f.end(n.key,j)}),[f,n.key]),P=e.useMemo(()=>({routeKey:n.key,registerDirtyGuard:v}),[n.key,v]);return l.jsx(st.Provider,{value:n,children:l.jsx(ot.Provider,{value:P,children:l.jsx(je.Provider,{value:N,children:l.jsx(Te.Provider,{value:B,children:l.jsx(Ie.Provider,{value:p,children:l.jsx("div",{ref:s,hidden:!c,inert:!c,"data-modal-route-key":n.key,tabIndex:-1,className:`pmn-body ${c&&u?.enabled&&typeof Element<"u"&&!Element.prototype.animate?`pmn-page-enter pmn-page-${u.direction}`:""} ${y??""}`,style:c&&u?.enabled?{"--pmn-page-duration":`${u.duration}ms`,"--pmn-page-distance":`${u.distance}px`}:void 0,children:l.jsx(jt,{route:n,onError:R,children:l.jsx(d,{route:n,navigation:r})})})})})})})})});function it({config:t,initialScreen:n,params:o,options:r,translate:c,onRequestClose:h,onOpened:m,registerLoading:f,notifyError:p,error:y,clearError:R,registerDirtyGuard:v,canNavigate:u,exiting:d=!1}){const[s,L]=e.useReducer(Se,null,()=>ct(n??t.initialRoute,o)),N=e.useRef(null);N.current||(N.current=yt({canGoBack:s.length>1,stack:s,currentRoute:s.at(-1)}));const B=e.useRef(null),P=e.useRef(null),j=e.useRef(null);B.current||(B.current=Be({visible:!1,text:null,count:0})),P.current||(P.current=Be({})),j.current||(j.current=Be([]));const k=e.useRef(!0),F=e.useRef(0),{toast:H,dismissToast:U}=At(j,k);e.useEffect(()=>(k.current=!0,()=>{k.current=!1,F.current++}),[]);const[E,b]=e.useState({}),S=e.useRef(new Map),$=e.useRef(null),D=e.useRef(null),M=e.useRef(null),I=e.useRef(null),q=e.useRef(null),te=e.useRef(!1),ee=e.useRef(!1),_=e.useRef(new Map),ce=e.useRef(0),ne=e.useCallback((a,x,T)=>{for(const[A,G]of _.current)a.includes(G.key)&&(_.current.delete(A),G.resolve({status:x,...x==="returned"?{value:T}:{}}))},[]),V=e.useRef(s);V.current=s;const ie=e.useRef(u);ie.current=u;const re=e.useRef(!1),oe=e.useRef(0),W=s.at(-1),z=W.key,pe=e.useRef({key:z,depth:s.length}),ge=pe.current,ue=ge.key!==z,ke=s.length<ge.depth?"back":"forward";ue&&(pe.current={key:z,depth:s.length});const he=Math.min(1e3,Math.max(0,Number(r.pageAnimationDuration??360)||0)),X={distance:Math.min(300,Math.max(0,Number(r.pageAnimationDistance??96)||0)),enabled:r.pageAnimation!==!1&&r.animation!==!1&&he>0&&ue,direction:ke,duration:he},be=e.useRef(z);be.current=z;const{loadingApi:le,refreshLoading:Ce,loadingTasks:i,setLoading:g}=Lt(B,k,be),C=t.screens,w=B,K=e.useRef(f);K.current=f,e.useEffect(()=>(K.current?.({setLoading:g}),()=>K.current?.(null)),[g]);const Y=e.useCallback((a,x)=>{if(!k.current)return;const T=P.current.getSnapshot();if(x===null){if(!(a in T))return;const A={...T};delete A[a],P.current.publish(A);return}T[a]!==x&&P.current.publish({...T,[a]:x})},[]),Z=e.useCallback(()=>{if(typeof document>"u")return;const a=document.activeElement;if(!(a instanceof HTMLElement)||!$.current?.contains(a))return;const x=a.closest("[data-modal-route-key]");x&&S.current.set(x.dataset.modalRouteKey,a),$.current.focus({preventScroll:!0})},[]),ae=e.useCallback(a=>{if(!Object.prototype.hasOwnProperty.call(C,a))throw new Error(`[react-modal-navigation] Unknown modal screen: ${a}`)},[C]),J=e.useCallback((a,x)=>{try{Promise.resolve(r[a]?.(x)).catch(T=>p(T,{phase:a}))}catch(T){p(T,{phase:a})}},[r,p]),Q=e.useCallback(async(a,x,T,A)=>{if(!k.current||ee.current)return!1;const G=F.current,O=V.current,Ee=O.at(-1);if(a!=="BACK"&&ae(x),a==="BACK"&&O.length<=1)return!1;const Ze=a==="NAVIGATE"?O.findIndex(ve=>ve.name===x):-1,Pe=a==="RESET"?O:a==="BACK"||a==="REPLACE"?[Ee]:Ze>=0?O.slice(Ze+1):[];ee.current=!0;try{if(Pe.length&&ie.current&&!await ie.current(Pe.map(qe=>qe.key),{reason:"navigation",action:a,from:Ee,to:a==="BACK"?O.at(-2)?.name:x})||!k.current||G!==F.current||V.current.at(-1)?.key!==Ee.key)return!1;if(a==="BACK"&&A!==void 0){const fe=O.at(-2);b(qe=>({...qe,[fe.key]:{id:++oe.current,data:A}}))}a==="RESET"&&b({}),ne(Pe.map(fe=>fe.key),a==="BACK"?"returned":"removed",A);const ve=[...D.current?.querySelectorAll("[data-modal-route-key]")??[]].find(fe=>fe.dataset.modalRouteKey===Ee.key);M.current=ve?.cloneNode(!0)??null,Z();const Je={type:a,name:x,params:T};return V.current=Se(V.current,Je),L(Je),!0}catch(ve){return k.current&&p(ve,{phase:"navigationGuard",action:a}),!1}finally{ee.current=!1}},[ae,Z,p,ne]),ye=e.useCallback((a,x)=>Q("NAVIGATE",a,x),[Q]),de=e.useCallback(async(a,x)=>{if(!k.current)return{status:"cancelled"};if(V.current,!await Q("NAVIGATE",a,x)||!k.current)return{status:"cancelled"};const A=V.current.at(-1);return!A||A.name!==a?{status:"cancelled"}:new Promise(G=>{const O=++ce.current;_.current.set(O,{key:A.key,resolve:G})})},[Q]),me=e.useCallback((a,x)=>Q("REPLACE",a,x),[Q]),Ge=e.useCallback((a,x)=>Q("RESET",a,x),[Q]),He=e.useCallback(a=>{if(!a||typeof a!="object"||Array.isArray(a))throw new TypeError("[react-modal-navigation] setParams expects an object");if(!k.current)return;const x={type:"SET_PARAMS",params:a};V.current=Se(V.current,x),L(x)},[]),Ue=e.useCallback(a=>{if(!a||typeof a!="object"||Array.isArray(a))throw new TypeError("[react-modal-navigation] setOptions expects an object");if(!k.current)return;const x={type:"SET_OPTIONS",options:a};V.current=Se(V.current,x),L(x)},[]),We=e.useCallback(a=>Q("BACK",null,void 0,a),[Q]),xe=e.useCallback((a,x)=>!k.current||w.current.getSnapshot().visible&&r.lockCloseWhileLoading!==!1?Promise.resolve(!1):h(a,x,{route:W,stack:s}),[r.lockCloseWhileLoading,h,W,s]),Ye=e.useRef(xe);Ye.current=xe;const _e=e.useCallback(a=>Ye.current("api",a),[]),Ae=e.useMemo(()=>({navigate:ye,navigateAsync:de,replace:me,reset:Ge,setParams:He,setOptions:Ue,goBack:We,close:_e,setLoading:g}),[ye,de,me,Ge,He,Ue,We,_e,g]),Ve=e.useMemo(()=>({canGoBack:s.length>1,stack:s,currentRoute:W}),[s]);e.useLayoutEffect(()=>N.current.publish(Ve),[Ve]);const Le=e.useRef(null);Le.current||(Le.current=Object.defineProperties({},{canGoBack:{enumerable:!0,get:()=>N.current.getSnapshot().canGoBack},stack:{enumerable:!0,get:()=>N.current.getSnapshot().stack},currentRoute:{enumerable:!0,get:()=>N.current.getSnapshot().currentRoute}}));const Re=e.useMemo(()=>Object.assign(Le.current,Ae),[Ae]);e.useLayoutEffect(()=>{const a=M.current;if(M.current=null,I.current?.cancel?.(),I.current=null,D.current?.querySelectorAll("[data-pmn-outgoing]").forEach(O=>O.remove()),!ue||!X.enabled||!a||!D.current||typeof window<"u"&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches)return;const x=D.current;a.removeAttribute("hidden"),a.removeAttribute("tabindex"),a.setAttribute("aria-hidden","true"),a.setAttribute("inert",""),a.dataset.pmnOutgoing="true",a.querySelectorAll("[id]").forEach(O=>O.removeAttribute("id")),a.querySelectorAll("[autofocus]").forEach(O=>O.removeAttribute("autofocus")),a.style.cssText+=";position:absolute;inset:0;width:100%;height:100%;z-index:1;pointer-events:none;overflow:hidden;",x.appendChild(a);const T=X.direction==="back"?1:-1,A=()=>{a.remove(),I.current===G&&(I.current=null)};let G;if(a.animate)G=a.animate([{opacity:1,transform:"translate3d(0,0,0)"},{opacity:.45,transform:`translate3d(${T*X.distance}px,0,0) scale(.985)`}],{duration:X.duration,easing:"cubic-bezier(.22,1,.36,1)",fill:"forwards"}),G.addEventListener("finish",A,{once:!0}),G.addEventListener("cancel",A,{once:!0}),I.current=G;else{a.classList.add("pmn-page-exit",`pmn-page-exit-${X.direction}`),a.style.setProperty("--pmn-page-duration",`${X.duration}ms`),a.style.setProperty("--pmn-page-distance",`${X.distance}px`);const O=setTimeout(A,X.duration+40);G={cancel:()=>{clearTimeout(O),A()}},I.current=G}return()=>{G?.cancel?.(),a.remove()}},[z]),e.useLayoutEffect(()=>{te.current=!1;const a=[...$.current?.querySelectorAll("[data-modal-route-key]")??[]].find(A=>A.dataset.modalRouteKey===z);if(!a)return;const x=S.current.get(z);(x?.isConnected&&a.contains(x)&&!x.matches(":disabled")&&!x.closest("[inert], [hidden]")?x:a).focus({preventScroll:!0})},[z]),e.useEffect(()=>{let a=!1;for(const[T,A]of i.current)A.owner!=="global"&&A.owner!==z&&(i.current.delete(T),a=!0);a&&Ce();const x=new Set(s.map(T=>T.key));b(T=>{const A=Object.keys(T).filter(O=>!x.has(O));if(!A.length)return T;const G={...T};return A.forEach(O=>delete G[O]),G});for(const T of S.current.keys())x.has(T)||S.current.delete(T)},[z,s,Ce]),e.useEffect(()=>{if(q.current?.key!==z){if(q.current){const a={from:q.current,to:W,stack:s};J("onBlur",{route:q.current,...a}),J("onNavigate",a),J("onRouteChange",a)}J("onFocus",{route:W,stack:s}),q.current=W}},[W,z,s,J]),e.useEffect(()=>()=>{i.current.clear(),S.current.clear();for(const a of _.current.values())a.resolve({status:"dismissed"});_.current.clear()},[]),e.useEffect(()=>{re.current||(re.current=!0,m?.({route:W,stack:s}))},[]);const ft=e.useMemo(()=>vt(s,C,r.maxCachedScreens),[s,C,r.maxCachedScreens]),Qe=e.useMemo(()=>({...C[W.name],...W.options??{}}),[C,W.name,W.options]);return l.jsx(at.Provider,{value:H,children:l.jsx(bt.Provider,{value:j.current,children:l.jsx(ht.Provider,{value:P.current,children:l.jsx(gt.Provider,{value:Re,children:l.jsx(De.Provider,{value:Ae,children:l.jsx(ze.Provider,{value:N.current,children:l.jsx(Te.Provider,{value:le,children:l.jsxs(Rt,{dialogRef:$,options:r,requestClose:xe,exiting:d,children:[l.jsx(Et,{options:r,screen:Qe,route:W,navigation:Re,requestClose:xe,translate:c,canGoBack:s.length>1}),l.jsx("main",{ref:D,className:"pmn-main",children:ft.map(a=>l.jsx(Ft,{route:a,screen:C[a.name],navigation:Re,focused:a.key===z,resultEvent:E[a.key]??null,bodyClassName:r.bodyClassName,setFooter:Y,loadingApi:le,loadingStore:B.current,notifyError:p,registerDirtyGuard:v,pageMotion:X},a.key))}),l.jsx(Bt,{store:P.current,routeKey:z,screen:Qe,options:r,route:W,navigation:Re,requestClose:xe,translate:c,onError:p,loadingApi:le},z),l.jsx(Pt,{store:B.current,translate:c}),l.jsx(qt,{store:j.current,dismiss:U}),y&&l.jsxs("div",{className:"pmn-error",role:"alert",children:[l.jsx("span",{children:y.message||String(y)}),l.jsx("button",{type:"button",onClick:R,"aria-label":"Dismiss error",children:"×"})]})]})})})})})})})})}const Ot=".pmn-overlay,.pmn-dialog,.pmn-dialog *{box-sizing:border-box}.pmn-overlay{position:fixed;inset:0;z-index:1000;display:flex;overscroll-behavior:none;background:#00000073}.pmn-place-right{justify-content:flex-end;align-items:stretch}.pmn-place-left{justify-content:flex-start;align-items:stretch}.pmn-place-center{justify-content:center;align-items:center}.pmn-place-top{justify-content:center;align-items:flex-start}.pmn-place-bottom{justify-content:center;align-items:flex-end}.pmn-dialog{--pmn-surface:#fff;--pmn-body:#fff;--pmn-text:#0f172a;--pmn-muted:#475569;--pmn-border:#e2e8f0;--pmn-hover:#f1f5f9;--pmn-overlay-card:rgba(255,255,255,.92);color-scheme:light;position:relative;display:flex;flex-direction:column;min-height:0;width:100%;max-width:min(calc(100vw - var(--pmn-gap)*2),var(--pmn-max-width, var(--pmn-width)));max-height:min(calc(100dvh - var(--pmn-gap)*2),var(--pmn-max-height, 100dvh));height:var(--pmn-height, 100%);overflow:hidden;outline:none;box-shadow:0 25px 50px -12px #00000040;background:var(--pmn-surface);color:var(--pmn-text)}.pmn-place-left .pmn-dialog,.pmn-place-right .pmn-dialog{height:calc(100dvh - var(--pmn-gap)*2);max-height:calc(100dvh - var(--pmn-gap)*2)}.pmn-place-center .pmn-dialog{height:var(--pmn-height, auto);min-height:150px}.pmn-place-top .pmn-dialog,.pmn-place-bottom .pmn-dialog{height:var(--pmn-height, auto);min-height:0}.pmn-dialog[data-modal-theme=dark]{--pmn-surface:#334155;--pmn-body:#334155;--pmn-text:#f1f5f9;--pmn-muted:#cbd5e1;--pmn-border:#475569;--pmn-hover:#1e293b;--pmn-overlay-card:rgba(51,65,85,.94);color-scheme:dark}.pmn-main{min-height:0;flex:1;overflow:hidden;display:flex;flex-direction:column;background:transparent}.pmn-body{height:100%;min-height:0;overflow-y:auto;overscroll-behavior:contain;padding:16px;flex:1}.pmn-body[hidden]{display:none!important}.pmn-header{display:flex;flex-shrink:0;height:64px;align-items:center;gap:12px;padding:0 20px;background:transparent}.pmn-header h2{font-size:18px;font-weight:600;min-width:0;flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin:0}.pmn-header-spacer{flex:1}.pmn-border-bottom{border-bottom:1px solid var(--pmn-border)}.pmn-icon-button{display:inline-flex;align-items:center;justify-content:center;padding:8px;border:0;background:transparent;color:inherit;border-radius:8px;cursor:pointer}.pmn-icon-button:hover{background:var(--pmn-hover)}.pmn-footer{display:flex;flex-shrink:0;align-items:center;justify-content:flex-end;gap:12px;padding:16px 20px;background:transparent}.pmn-border-top{border-top:1px solid var(--pmn-border)}.pmn-button{padding:8px 16px;border-radius:8px;font-size:14px;font-weight:500;cursor:pointer}.pmn-button:disabled{opacity:.5;cursor:not-allowed}.pmn-button-secondary{border:1px solid var(--pmn-border);background:transparent;color:var(--pmn-text)}.pmn-button-secondary:hover:not(:disabled){background:var(--pmn-hover)}.pmn-button-primary{border:1px solid #2563eb;background:#2563eb;color:#fff}.pmn-button-primary:hover:not(:disabled){background:#1d4ed8}.pmn-loading-overlay{position:absolute;inset:0;z-index:50;display:flex;align-items:center;justify-content:center;background:#ffffffb8;backdrop-filter:blur(2px);-webkit-backdrop-filter:blur(2px);cursor:progress}.pmn-dialog[data-modal-theme=dark] .pmn-loading-overlay{background:#0f172ab8}.pmn-loading-content{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:14px;max-width:85%;text-align:center;color:var(--pmn-text);pointer-events:none}.pmn-loading-text{font-size:14px;font-weight:500;line-height:1.5;overflow-wrap:anywhere}.pmn-spinner{width:38px;height:38px;border:3px solid rgba(37,99,235,.2);border-top-color:#2563eb;border-radius:50%;animation:pmn-spin .8s linear infinite}@keyframes pmn-spin{to{transform:rotate(360deg)}}@media(prefers-reduced-motion:reduce){.pmn-spinner{animation-duration:1.8s}}.pmn-error{position:absolute;z-index:60;bottom:8px;left:12px;right:12px;display:flex;justify-content:space-between;gap:12px;padding:12px;border:1px solid #fca5a5;border-radius:8px;background:#fef2f2;color:#991b1b;font-size:13px}.pmn-error button{border:0;background:transparent;font-size:20px;cursor:pointer;color:inherit}.pmn-dialog input:not([type=checkbox]):not([type=radio]),.pmn-dialog textarea,.pmn-dialog select{color:var(--pmn-text);border-color:var(--pmn-border)}.pmn-error-screen{padding:24px;color:var(--pmn-text)}.pmn-error-screen p{color:#dc2626;overflow-wrap:anywhere}@media(max-width:640px){.pmn-overlay.pmn-mobile-fullscreen{padding:0!important}.pmn-mobile-fullscreen .pmn-dialog{max-width:100%;width:100%;height:100dvh;max-height:100dvh;border-radius:0!important}}@media(prefers-reduced-motion:reduce){.pmn-spinner{animation-duration:2s}}@keyframes pmn-fade-in{0%{opacity:0}to{opacity:1}}@keyframes pmn-fade-out{0%{opacity:1}to{opacity:0}}@keyframes pmn-scale-in{0%{opacity:0;transform:translateY(10px) scale(.97)}to{opacity:1;transform:none}}@keyframes pmn-scale-out{0%{opacity:1;transform:none}to{opacity:0;transform:translateY(10px) scale(.97)}}@keyframes pmn-right-in{0%{transform:translate(105%)}to{transform:none}}@keyframes pmn-right-out{0%{transform:none}to{transform:translate(105%)}}@keyframes pmn-left-in{0%{transform:translate(-105%)}to{transform:none}}@keyframes pmn-left-out{0%{transform:none}to{transform:translate(-105%)}}@keyframes pmn-top-in{0%{transform:translateY(-105%)}to{transform:none}}@keyframes pmn-top-out{0%{transform:none}to{transform:translateY(-105%)}}@keyframes pmn-bottom-in{0%{transform:translateY(105%)}to{transform:none}}@keyframes pmn-bottom-out{0%{transform:none}to{transform:translateY(105%)}}.pmn-entering{animation:pmn-fade-in var(--pmn-animation-duration) ease-out both}.pmn-exiting{animation:pmn-fade-out var(--pmn-animation-duration) ease-in both;pointer-events:none}.pmn-entering .pmn-dialog{animation:pmn-scale-in var(--pmn-animation-duration) cubic-bezier(.2,.8,.2,1) both}.pmn-exiting .pmn-dialog{animation:pmn-scale-out var(--pmn-animation-duration) ease-in both}.pmn-entering.pmn-place-right .pmn-dialog{animation-name:pmn-right-in}.pmn-exiting.pmn-place-right .pmn-dialog{animation-name:pmn-right-out}.pmn-entering.pmn-place-left .pmn-dialog{animation-name:pmn-left-in}.pmn-exiting.pmn-place-left .pmn-dialog{animation-name:pmn-left-out}.pmn-entering.pmn-place-top .pmn-dialog{animation-name:pmn-top-in}.pmn-exiting.pmn-place-top .pmn-dialog{animation-name:pmn-top-out}.pmn-entering.pmn-place-bottom .pmn-dialog{animation-name:pmn-bottom-in}.pmn-exiting.pmn-place-bottom .pmn-dialog{animation-name:pmn-bottom-out}.pmn-no-animation,.pmn-no-animation .pmn-dialog{animation:none!important}@media(prefers-reduced-motion:reduce){.pmn-entering,.pmn-exiting,.pmn-entering .pmn-dialog,.pmn-exiting .pmn-dialog{animation:none!important}}.pmn-toast-region{position:absolute;top:56px;left:12px;right:12px;z-index:80;display:flex;flex-direction:column;align-items:center;gap:8px;pointer-events:none;max-height:calc(100% - 72px);overflow:hidden}.pmn-toast{pointer-events:auto;display:flex;align-items:flex-start;gap:10px;width:max-content;max-width:100%;min-width:min(260px,100%);padding:11px 13px;border:1px solid var(--pmn-border);border-radius:9px;background:var(--pmn-surface);color:var(--pmn-text);box-shadow:0 5px 18px #0000001a;font-size:13px;line-height:1.5;overflow-wrap:anywhere}.pmn-toast-symbol{flex:0 0 20px;display:grid;place-items:center;width:20px;height:20px;border-radius:50%;font-size:13px;font-weight:700;background:var(--pmn-hover);color:var(--pmn-muted)}.pmn-toast-success .pmn-toast-symbol{background:#dcfce7;color:#15803d}.pmn-toast-error .pmn-toast-symbol{background:#fee2e2;color:#b91c1c}.pmn-toast-warning .pmn-toast-symbol{background:#fef3c7;color:#b45309}.pmn-toast-info .pmn-toast-symbol{background:#dbeafe;color:#1d4ed8}.pmn-toast-message{flex:1;min-width:0;white-space:pre-wrap}.pmn-toast-close{border:0;background:transparent;color:var(--pmn-muted);cursor:pointer;font-size:19px;line-height:18px;padding:0 1px}.pmn-toast-close:hover{color:var(--pmn-text)}.pmn-button-danger{background:#dc2626!important;color:#fff!important;border-color:#dc2626!important}@keyframes pmn-page-forward-in{0%{opacity:.18;transform:translate3d(var(--pmn-page-distance,96px),0,0) scale(.985)}to{opacity:1;transform:translateZ(0)}}@keyframes pmn-page-back-in{0%{opacity:.18;transform:translate3d(calc(-1 * var(--pmn-page-distance,96px)),0,0) scale(.985)}to{opacity:1;transform:translateZ(0)}}.pmn-page-enter{animation-duration:var(--pmn-page-duration,.36s);animation-timing-function:cubic-bezier(.2,.8,.2,1);animation-fill-mode:both;will-change:transform,opacity}.pmn-page-forward{animation-name:pmn-page-forward-in}.pmn-page-back{animation-name:pmn-page-back-in}@media(prefers-reduced-motion:reduce){.pmn-page-enter{animation:none!important;will-change:auto}}.pmn-main{position:relative;isolation:isolate}.pmn-page-exit{animation-duration:var(--pmn-page-duration,.36s);animation-timing-function:cubic-bezier(.22,1,.36,1);animation-fill-mode:forwards}@keyframes pmn-page-forward-out{to{opacity:.45;transform:translate3d(calc(-1 * var(--pmn-page-distance,96px)),0,0) scale(.985)}}@keyframes pmn-page-back-out{to{opacity:.45;transform:translate3d(var(--pmn-page-distance,96px),0,0) scale(.985)}}.pmn-page-exit-forward{animation-name:pmn-page-forward-out}.pmn-page-exit-back{animation-name:pmn-page-back-out}@media(prefers-reduced-motion:reduce){.pmn-page-exit{animation:none!important}}",tt="react-modal-navigation-styles",Oe=new WeakMap;function $t(){e.useInsertionEffect(()=>{if(typeof document>"u")return;const t=document;let n=Oe.get(t);if(!n){let o=t.getElementById(tt);const r=!o;o||(o=t.createElement("style"),o.id=tt,o.setAttribute("data-react-modal-navigation",""),o.textContent=Ot,t.head.appendChild(o)),n={element:o,owned:r,count:0},Oe.set(t,n)}return n.count+=1,()=>{n.count-=1,n.count===0&&(n.owned&&n.element.remove(),Oe.delete(t))}},[])}function Me(t,n,o){if(typeof t=="string"){if(!t.trim())throw new TypeError("[react-modal-navigation] modal name must not be empty");return{name:t,params:n??{},options:o??{}}}if(t===null||typeof t!="object"||Array.isArray(t))throw new TypeError("[react-modal-navigation] open expects a modal name or a configuration object");const{name:r,screen:c,params:h={},options:m={},...f}=t;if(typeof r!="string"||!r.trim())throw new TypeError("[react-modal-navigation] open config requires a non-empty string name");if(m===null||typeof m!="object"||Array.isArray(m))throw new TypeError("[react-modal-navigation] open config options must be an object");if(c!==void 0&&(typeof c!="string"||!c.trim()))throw new TypeError("[react-modal-navigation] screen must be a non-empty string");return{name:r,...c===void 0?{}:{screen:c},params:h,options:{...f,...m}}}const Dt={placement:"right",showHeader:!0,showBackButton:!0,showCloseButton:!0,viewportGap:5,borderRadius:12,closeOnOverlay:!1,closeOnEsc:!0},zt=t=>({"modal.loading":"加载中...","modal.processing":"处理中...","modal.back":"返回","modal.close":"关闭","modal.cancel":"取消","modal.done":"完成"})[t]??t;function It({registry:t,children:n,defaultOptions:o={},backgroundColor:r,theme:c,translate:h=zt,onError:m,confirmDiscard:f}){$t();const[p,y]=e.useState(null),[R,v]=e.useState(null),[u,d]=e.useState(0),s=e.useRef(null),L=e.useRef(new Map),N=e.useRef([]),B=e.useRef(null),P=e.useRef(null),j=e.useRef(0),k=e.useRef(null),F=e.useRef(!1),H=e.useRef(0),U=e.useRef(null),E=e.useRef(new Map),[b,S]=e.useState(!1),$=e.useRef(f);$.current=f;const D=e.useCallback((i,g)=>(E.current.set(i,g),()=>{E.current.get(i)===g&&E.current.delete(i)}),[]),M=e.useCallback(async i=>{for(const g of E.current.values()){if(!g.dirty)continue;if((g.onBeforeDiscard?await g.onBeforeDiscard(i):$.current?await $.current(i):typeof window<"u"&&typeof window.confirm=="function"?window.confirm(g.message||"有未保存的修改,确定放弃吗?"):!1)===!1)return!1}return!0},[]),I=e.useCallback(async(i,g)=>{for(const C of i){const w=E.current.get(C);if(!w?.dirty)continue;if((w.onBeforeDiscard?await w.onBeforeDiscard(g):$.current?await $.current(g):typeof window<"u"&&typeof window.confirm=="function"?window.confirm(w.message||"有未保存的修改,确定放弃吗?"):!1)===!1)return!1}return!0},[]),q=e.useRef(!0),te=e.useRef(null),ee=e.useRef(m);ee.current=m;const _=e.useCallback((i,g)=>{q.current&&v(i);try{ee.current?ee.current(i,g):console.error("[react-modal-navigation]",i)}catch(C){console.error("[react-modal-navigation] onError failed",C)}},[]),ce=e.useCallback((i,g)=>{const C=L.current.get(i);L.current.delete(i),C?.(g)},[]),ne=e.useCallback(i=>({...Dt,...o,...c!==void 0?{theme:c}:{},...r!==void 0?{backgroundColor:r}:{},...i.config.modalOptions,...i.overrides}),[o,c,r]),V=p?ne(p):null,ie=e.useRef(null);ie.current=V,te.current=V;const re=e.useCallback(async(i="api",g,C={})=>{const w=s.current;if(!w||k.current||F.current)return!1;k.current=w.id,F.current=!0;const K=te.current??ne(w),Y={...C,reason:i,result:g,name:w.name};try{if(!await M(Y)||await K.onBeforeClose?.(Y)===!1||s.current?.id!==w.id||!q.current||(S(!0),await new Promise(Z=>{const ae=K.animation===!1||typeof window<"u"&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches?0:Math.max(0,Number(K.animationDuration??220)||0);setTimeout(Z,Math.min(ae,1e3))}),!q.current||s.current?.id!==w.id))return!1;s.current=null,U.current=null,y(null),S(!1),E.current.clear(),ce(w.id,C.confirmed||g!==void 0?{status:"confirmed",value:g,reason:i}:{status:"dismissed",reason:i});try{await K.onClose?.(Y)}catch(Z){_(Z,{phase:"onClose",name:w.name})}return!0}catch(Z){return _(Z,{phase:"onBeforeClose",name:w.name}),!1}finally{k.current===w.id&&(k.current=null),F.current=!1,!s.current&&q.current&&queueMicrotask(()=>P.current?.())}},[ne,_,ce,M]),oe=e.useCallback(async(i,g={},C={},w,K)=>{const Y=t?.[i];if(!Y)throw new Error(`[react-modal-navigation] Unknown modal: ${i}`);const Z=K??Y.initialRoute;if(!Y.screens?.[Z])throw new Error(`[react-modal-navigation] Unknown initial screen '${Z}' in modal '${i}'`);if(!q.current||F.current||k.current)return null;F.current=!0;const ae=H.current;try{const J=s.current;if(J){const ye=te.current??ne(J),de={reason:"replace",name:J.name,nextName:i};try{if(!await M(de)||await ye.onBeforeClose?.(de)===!1)return null}catch(me){return _(me,{phase:"onBeforeClose",name:J.name}),null}if(!q.current||ae!==H.current||s.current?.id!==J.id)return null;s.current=null,U.current=null,y(null),E.current.clear(),ce(J.id,{status:"replaced",reason:"replace"});try{await ye.onClose?.(de)}catch(me){_(me,{phase:"onClose",name:J.name})}if(!q.current||ae!==H.current)return null}const Q={id:++j.current,name:i,screen:Z,params:g,config:Y,overrides:C};return s.current=Q,U.current=null,w&&L.current.set(Q.id,w),v(null),y(Q),Q.id}finally{F.current=!1}},[t,ne,_,ce,M]);B.current=oe;const W=e.useCallback(async()=>{if(!q.current||s.current||F.current||k.current)return;const i=N.current.shift();if(i){d(N.current.length);try{const g=await B.current(i.args.name,i.args.params,i.args.options,i.resolveResult,i.args.screen);g===null?(i.resolveResult?.({status:"dismissed",reason:"blocked"}),i.resolveId?.(null),queueMicrotask(()=>P.current?.())):i.resolveId?.(g)}catch(g){i.reject?.(g),queueMicrotask(()=>P.current?.())}}},[]);P.current=W;const z=e.useCallback((i,g,C)=>{const w=Me(i,g,C);return t?.[w.name]?new Promise((K,Y)=>{N.current.push({args:w,resolveId:K,reject:Y}),d(N.current.length),queueMicrotask(()=>P.current?.())}):Promise.reject(new Error(`[react-modal-navigation] Unknown modal: ${w.name}`))},[t]),pe=e.useCallback((i,g,C)=>{const w=Me(i,g,C);return t?.[w.name]?new Promise((K,Y)=>{N.current.push({args:w,resolveResult:K,reject:Y}),d(N.current.length),queueMicrotask(()=>P.current?.())}):Promise.reject(new Error(`[react-modal-navigation] Unknown modal: ${w.name}`))},[t]),ge=e.useCallback(i=>{if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("[react-modal-navigation] update expects an options object");const g=s.current;if(!g||F.current)return!1;const C={...g,overrides:{...g.overrides,...i}};return s.current=C,y(C),te.current=ne(C),!0},[ne]),ue=e.useCallback((i="queue-cleared")=>{const g=N.current.splice(0);d(0);for(const C of g)C.resolveId?.(null),C.resolveResult?.({status:"dismissed",reason:i});return g.length},[]),ke=e.useCallback((i,g,C)=>{const w=Me(i,g,C);return oe(w.name,w.params,w.options,void 0,w.screen)},[oe]),he=e.useCallback((i,g,C)=>{const w=Me(i,g,C);return new Promise((K,Y)=>{oe(w.name,w.params,w.options,K,w.screen).then(Z=>{Z===null&&K({status:"dismissed",reason:"blocked"})},Y)})},[oe]),Ne=e.useCallback(i=>re("api",i),[re]),X=e.useCallback((i="api")=>re(i),[re]),be=e.useCallback(i=>re("confirm",i,{confirmed:!0}),[re]),le=e.useCallback((i,g)=>U.current?.setLoading(i,g),[]),Ce=e.useMemo(()=>({open:ke,openAsync:he,enqueue:z,enqueueAsync:pe,update:ge,clearQueue:ue,close:Ne,dismiss:X,confirm:be,setLoading:le,queueSize:u,isOpen:!!p,activeName:p?.name??null,error:R,clearError:()=>v(null)}),[ke,he,z,pe,ge,ue,Ne,X,be,le,p,R,u]);return e.useEffect(()=>(q.current=!0,()=>{q.current=!1,H.current+=1,s.current=null;for(const g of L.current.values())g({status:"dismissed",reason:"unmount"});L.current.clear(),E.current.clear();const i=N.current.splice(0);for(const g of i)g.resolveId?.(null),g.resolveResult?.({status:"dismissed",reason:"unmount"})}),[]),l.jsxs(rt.Provider,{value:Ce,children:[n,p&&l.jsx(it,{config:p.config,initialScreen:p.screen,params:p.params,options:V,translate:h,notifyError:_,error:R,clearError:()=>v(null),registerLoading:i=>{U.current=i},registerDirtyGuard:D,canNavigate:I,exiting:b,onRequestClose:re,onOpened:i=>{try{const g=ie.current?.onOpen?.(i);Promise.resolve(g).catch(C=>_(C,{phase:"onOpen"}))}catch(g){_(g,{phase:"onOpen"})}}},p.id)]})}const Kt=Object.freeze({canGoBack:!1,stack:[],currentRoute:null}),Gt=()=>()=>{},nt=()=>Kt;function Ht(){const t=e.useContext(rt),n=e.useContext(De),o=e.useContext(ze),r=e.useSyncExternalStore(o?.subscribe??Gt,o?.getSnapshot??nt,o?.getSnapshot??nt);if(!t)throw new Error("[react-modal-navigation] useModal requires <ModalProvider>");const c=e.useMemo(()=>{const h=()=>{if(!n)throw new Error("[react-modal-navigation] navigation requires an active modal screen; use modal.open() outside a modal");return n};return{navigate:(...m)=>h().navigate(...m),replace:(...m)=>h().replace(...m),reset:(...m)=>h().reset(...m),setParams:(...m)=>h().setParams(...m),setOptions:(...m)=>h().setOptions(...m),goBack:(...m)=>h().goBack(...m),close:(...m)=>h().close(...m),setLoading:(...m)=>h().setLoading(...m),canGoBack:r.canGoBack,stack:r.stack,currentRoute:r.currentRoute}},[n,r]);return e.useMemo(()=>({...t,modal:t,navigation:c}),[t,c])}function ut(){const t=e.useContext(De);if(!t)throw new Error("useModalNavigationCommands requires an active modal screen");return t}function lt(){const t=e.useContext(ze);if(!t)throw new Error("useModalNavigationState requires an active modal screen");return e.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getSnapshot)}function Ut(){const t=ut(),n=lt();return e.useMemo(()=>({...t,...n}),[t,n])}function Ke(){const t=e.useContext(je);if(!t)throw new Error("useIsFocused must be called inside a modal screen");return t.isFocused}function Wt(t){const n=Ke();e.useEffect(()=>{if(n)return t()},[n,t])}function Yt(t){const n=e.useContext(je);if(!n)throw new Error("useNavigationResult requires an active modal screen");const o=e.useRef(t),r=e.useRef(null);e.useEffect(()=>{o.current=t},[t]),e.useEffect(()=>{!n.isFocused||!n.resultEvent||r.current!==n.resultEvent.id&&(r.current=n.resultEvent.id,o.current(n.resultEvent.data))},[n.isFocused,n.resultEvent])}function _t(t={}){const n=e.useContext(je);if(!n)throw new Error("[react-modal-navigation] useModalFooter requires an active modal screen");const{setFooter:o,routeKey:r}=n,c=e.useRef(t);c.current=t;const h=e.useMemo(()=>(...E)=>c.current.done?.(...E),[]),m=e.useMemo(()=>(...E)=>(c.current.cancel??c.current.cancle)?.(...E),[]),f=e.useMemo(()=>(...E)=>c.current.renderFooter?.(...E),[]),p=typeof t.done=="function",y=typeof(t.cancel??t.cancle)=="function",R=typeof t.renderFooter=="function",{showFooter:v,showFooterBorder:u,doneDisabled:d,doneText:s,cancelText:L,loadingText:N,footerClassName:B}=t,P=e.useRef({source:null,normalized:void 0}),j=Array.isArray(t.actions)?t.actions:null,k=P.current.source;j===k||j&&k&&j.length===k.length&&j.every((E,b)=>{const S=k[b];return[...new Set([...Object.keys(E),...Object.keys(S)])].every(D=>D==="onClick"||Object.is(E[D],S[D]))})||(P.current={source:j?.map(E=>({...E}))??null,normalized:j?.map((E,b)=>({...E,onClick:(...S)=>(c.current.actions?.find(D=>D.key===E.key)??c.current.actions?.[b])?.onClick?.(...S)}))});const H=P.current.normalized,U=e.useMemo(()=>({showFooter:v,showFooterBorder:u,doneDisabled:d,doneText:s,cancelText:L,loadingText:N,footerClassName:B,...H!==void 0?{actions:H}:{},...p?{done:h}:{},...y?{cancel:m}:{},...R?{renderFooter:f}:{}}),[v,u,d,s,L,N,B,H,p,y,R,h,m,f]);e.useEffect(()=>{o(r,U)},[r,o,U]),e.useEffect(()=>()=>o(r,null),[r,o])}function dt(){const t=e.useContext(Te),n=e.useContext(Ie);if(!t||!n)throw new Error("[react-modal-navigation] useModalLoading requires an active modal screen");const o=e.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getSnapshot);return e.useMemo(()=>({...t,isLoading:o.visible}),[t,o.visible])}function Vt(){const t=e.useContext(Te);if(!t)throw new Error("[react-modal-navigation] useModalLoadingCommands requires an active modal screen");return t}function Qt(){const t=e.useContext(Ie);if(!t)throw new Error("[react-modal-navigation] useModalLoadingState requires an active modal screen");return e.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getSnapshot)}function Zt(){const t=dt(),n=Ke(),o=e.useRef(!0),r=e.useRef(!1),[c,h]=e.useState(!1),[m,f]=e.useState(null),p=e.useRef(t);return p.current=t,e.useEffect(()=>(o.current=!0,()=>{o.current=!1}),[]),{run:e.useCallback(async(R,v={})=>{if(r.current)return{status:"busy"};if(typeof R!="function")throw new TypeError("[react-modal-navigation] run requires a function");r.current=!0,o.current&&(h(!0),f(null));const u=p.current.showLoading(v.loadingText);try{const d=await R();return o.current&&await v.onSuccess?.(d),{status:"success",value:d}}catch(d){if(o.current){f(d);try{await v.onError?.(d)}catch(s){console.error("[react-modal-navigation] onError failed",s)}}if(v.throwOnError)throw d;return{status:"error",error:d}}finally{u!=null&&p.current.hideLoading(u),r.current=!1,o.current&&h(!1)}},[]),pending:c,error:m,clearError:()=>f(null),isFocused:n}}function Jt(t,n={}){const o=e.useContext(ot);if(!o)throw new Error("[react-modal-navigation] useModalUnsavedChanges must be used inside a modal screen");const r=e.useRef({dirty:t,...n});r.current={dirty:t,...n};const{routeKey:c,registerDirtyGuard:h}=o;e.useEffect(()=>h(c,{get dirty(){return!!r.current.dirty},get message(){return r.current.message},get onBeforeDiscard(){return r.current.onBeforeDiscard}}),[c,h])}const Xt=()=>{const t=e.useContext(at);if(!t)throw new Error("[react-modal-navigation] useToast requires an active modal");return t};function mt(){const t=e.useContext(st);if(!t)throw new Error("[react-modal-navigation] useModalRoute requires a modal screen");return t}function en(){return mt().params}exports.ModalNavigator=it;exports.ModalProvider=It;exports.useFocusEffect=Wt;exports.useIsFocused=Ke;exports.useModal=Ht;exports.useModalFooter=_t;exports.useModalLoading=dt;exports.useModalLoadingCommands=Vt;exports.useModalLoadingState=Qt;exports.useModalNavigation=Ut;exports.useModalNavigationCommands=ut;exports.useModalNavigationState=lt;exports.useModalParams=en;exports.useModalRoute=mt;exports.useModalTask=Zt;exports.useModalUnsavedChanges=Jt;exports.useNavigationResult=Yt;exports.useToast=Xt;
|
package/dist/index.d.ts
CHANGED
|
@@ -58,6 +58,12 @@ export interface ModalOptions {
|
|
|
58
58
|
animation?: boolean;
|
|
59
59
|
/** Animation duration in ms (default 220, maximum effective 1000). */
|
|
60
60
|
animationDuration?: number;
|
|
61
|
+
/** Animate route changes inside the modal; default true. */
|
|
62
|
+
pageAnimation?: boolean;
|
|
63
|
+
/** Internal route animation duration in milliseconds; default 240. */
|
|
64
|
+
pageAnimationDuration?: number;
|
|
65
|
+
/** Slide distance in pixels (0–300, default 96). */
|
|
66
|
+
pageAnimationDistance?: number;
|
|
61
67
|
/** Position: centered modal, side drawer, or top/bottom sheet. Default: right. */
|
|
62
68
|
placement?: 'left' | 'right' | 'center' | 'top' | 'bottom';
|
|
63
69
|
theme?: ModalTheme;
|