react-modal-navigation 1.1.7 → 1.1.9
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 +30 -0
- package/README.md +67 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +22 -1
- package/dist/index.js +735 -591
- package/dist/style.css +32 -0
- package/docs/API.md +16 -0
- package/docs/PERFORMANCE.md +19 -0
- package/package.json +1 -1
package/dist/style.css
CHANGED
|
@@ -77,3 +77,35 @@
|
|
|
77
77
|
.pmn-toast-close:hover{color:var(--pmn-text)}
|
|
78
78
|
|
|
79
79
|
.pmn-button-danger{background:#dc2626!important;color:#fff!important;border-color:#dc2626!important}
|
|
80
|
+
|
|
81
|
+
/* Internal page navigation (distinct from opening/closing the modal). */
|
|
82
|
+
@keyframes pmn-page-forward-in { from { opacity:.18; transform:translate3d(var(--pmn-page-distance,96px),0,0) scale(.985) } to { opacity:1; transform:translate3d(0,0,0) } }
|
|
83
|
+
@keyframes pmn-page-back-in { from { opacity:.18; transform:translate3d(calc(-1 * var(--pmn-page-distance,96px)),0,0) scale(.985) } to { opacity:1; transform:translate3d(0,0,0) } }
|
|
84
|
+
.pmn-page-enter { animation-duration:var(--pmn-page-duration,360ms); animation-timing-function:cubic-bezier(.2,.8,.2,1); animation-fill-mode:both; will-change:transform,opacity; }
|
|
85
|
+
.pmn-page-forward { animation-name:pmn-page-forward-in; }
|
|
86
|
+
.pmn-page-back { animation-name:pmn-page-back-in; }
|
|
87
|
+
@media (prefers-reduced-motion:reduce) { .pmn-page-enter { animation:none!important; will-change:auto; } }
|
|
88
|
+
|
|
89
|
+
/* Simultaneous incoming/outgoing pages: outgoing layer is an inert visual snapshot. */
|
|
90
|
+
.pmn-main{position:relative;isolation:isolate}
|
|
91
|
+
.pmn-page-exit{animation-duration:var(--pmn-page-duration,360ms);animation-timing-function:cubic-bezier(.22,1,.36,1);animation-fill-mode:forwards}
|
|
92
|
+
@keyframes pmn-page-forward-out{to{opacity:.45;transform:translate3d(calc(-1 * var(--pmn-page-distance,96px)),0,0) scale(.985)}}
|
|
93
|
+
@keyframes pmn-page-back-out{to{opacity:.45;transform:translate3d(var(--pmn-page-distance,96px),0,0) scale(.985)}}
|
|
94
|
+
.pmn-page-exit-forward{animation-name:pmn-page-forward-out}
|
|
95
|
+
.pmn-page-exit-back{animation-name:pmn-page-back-out}
|
|
96
|
+
@media(prefers-reduced-motion:reduce){.pmn-page-exit{animation:none!important}}
|
|
97
|
+
|
|
98
|
+
/* Full-width push/pop: incoming layer stays above the outgoing layer. */
|
|
99
|
+
.pmn-main>.pmn-body{position:relative;width:100%;flex:1 0 100%;background:var(--pmn-body)}
|
|
100
|
+
.pmn-page-forward,.pmn-page-back{z-index:2}
|
|
101
|
+
@keyframes pmn-page-forward-in{from{opacity:1;transform:translate3d(100%,0,0)}to{opacity:1;transform:translate3d(0,0,0)}}
|
|
102
|
+
@keyframes pmn-page-back-in{from{opacity:1;transform:translate3d(-100%,0,0)}to{opacity:1;transform:translate3d(0,0,0)}}
|
|
103
|
+
@keyframes pmn-page-forward-out{to{opacity:1;transform:translate3d(-100%,0,0)}}
|
|
104
|
+
@keyframes pmn-page-back-out{to{opacity:1;transform:translate3d(100%,0,0)}}
|
|
105
|
+
|
|
106
|
+
/* Top-positioned dialogs respect an independent offset and remain scrollable. */
|
|
107
|
+
.pmn-place-top .pmn-dialog{max-height:min(calc(100dvh - var(--pmn-top-offset, var(--pmn-gap)) - var(--pmn-gap)),var(--pmn-max-height,100dvh))}
|
|
108
|
+
.pmn-lazy-loading{display:flex;min-height:80px;align-items:center;justify-content:center;color:var(--pmn-muted);font-size:14px}
|
|
109
|
+
|
|
110
|
+
/* Top offset must reduce available dialog height, not just move its starting point. */
|
|
111
|
+
.pmn-place-top .pmn-dialog{max-height:min(calc(100dvh - var(--pmn-top-offset, var(--pmn-gap)) - var(--pmn-gap)),var(--pmn-max-height,100dvh))}
|
package/docs/API.md
CHANGED
|
@@ -627,3 +627,19 @@ import type { TypedModalNavigation } from 'react-modal-navigation';
|
|
|
627
627
|
type Routes = { UserDetail: { userId: number }; DeviceList: undefined };
|
|
628
628
|
type Navigation = TypedModalNavigation<Routes>;
|
|
629
629
|
```
|
|
630
|
+
|
|
631
|
+
### 页面切换动画
|
|
632
|
+
|
|
633
|
+
- `pageAnimation?: boolean` — 默认 `true`,控制弹窗内部的页面切换动画。
|
|
634
|
+
- `pageAnimationDuration?: number` — 默认 `360`,单位毫秒,范围限制在 0–1000。
|
|
635
|
+
- `animation: false` — 同时禁用弹窗开关动画和内部页面动画。
|
|
636
|
+
- `prefers-reduced-motion: reduce` — 自动禁用内部页面动画。
|
|
637
|
+
|
|
638
|
+
页面动画仅在当前路由 `key` 变化时触发;`navigate`、`goBack`、`replace` 等操作无需修改调用方式。
|
|
639
|
+
|
|
640
|
+
- `pageAnimationDistance?: number` — 默认 `96`,页面进入滑动距离(像素),范围 0–300。
|
|
641
|
+
|
|
642
|
+
|
|
643
|
+
## Single-page registry (v1.1.6)
|
|
644
|
+
|
|
645
|
+
`{ component: AddDevice, title: 'Add device', modalOptions: { placement: 'center' } }` is supported as a registry item. A registry with exactly one `screens` entry is also rendered in lightweight single-page mode. Modal opening and closing APIs remain unchanged. No navigation history, reducer, KeepAlive cache or page transitions are initialized. Navigation-only commands are unavailable in this mode and return `false` (or `{status:'cancelled'}` for `navigateAsync`).
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Performance and lifecycle notes
|
|
2
|
+
|
|
3
|
+
## Architecture
|
|
4
|
+
|
|
5
|
+
- Single-screen modals bypass stack reducers and route-transition snapshots.
|
|
6
|
+
- Single-screen navigation command context now retains stable function identities across `setParams` and `setOptions`. Reactive route data continues through the navigation state store.
|
|
7
|
+
- Footer, loading, and toast regions subscribe independently via `useSyncExternalStore`.
|
|
8
|
+
- Lazy screen components use Suspense boundaries in both navigator modes.
|
|
9
|
+
- Closing transitions use a cancellable waiter; provider unmount clears outstanding timeouts and settles modal promises.
|
|
10
|
+
|
|
11
|
+
## Suggested browser verification
|
|
12
|
+
|
|
13
|
+
1. Record React Profiler commits for single-screen `setParams`, Footer loading, and toast changes.
|
|
14
|
+
2. Open/close the modal 100 times; verify listeners and DOM nodes return to baseline.
|
|
15
|
+
3. Exercise rapid open/close, async `onBeforeClose`, unmount during exit, and queue replacement.
|
|
16
|
+
4. Compare cold lazy import versus warm open with production bundles.
|
|
17
|
+
5. Check reduced-motion preference and navigation animation cancellation in real browsers.
|
|
18
|
+
|
|
19
|
+
These are validation scenarios, not measured benchmark claims. Run `npm test`, `npm run typecheck`, `npm run test:react`, and `npm run build` in a fully provisioned environment before publishing.
|