react-modal-navigation 1.1.4 → 1.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/style.css CHANGED
@@ -63,3 +63,15 @@
63
63
  .pmn-exiting.pmn-place-bottom .pmn-dialog{animation-name:pmn-bottom-out}
64
64
  .pmn-no-animation,.pmn-no-animation .pmn-dialog{animation:none!important}
65
65
  @media(prefers-reduced-motion:reduce){.pmn-entering,.pmn-exiting,.pmn-entering .pmn-dialog,.pmn-exiting .pmn-dialog{animation:none!important}}
66
+
67
+ /* Modal-local toast region; clipped by .pmn-dialog and never portaled outside. */
68
+ .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}
69
+ .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 rgba(0,0,0,.10);font-size:13px;line-height:1.5;overflow-wrap:anywhere}
70
+ .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)}
71
+ .pmn-toast-success .pmn-toast-symbol{background:#dcfce7;color:#15803d}
72
+ .pmn-toast-error .pmn-toast-symbol{background:#fee2e2;color:#b91c1c}
73
+ .pmn-toast-warning .pmn-toast-symbol{background:#fef3c7;color:#b45309}
74
+ .pmn-toast-info .pmn-toast-symbol{background:#dbeafe;color:#1d4ed8}
75
+ .pmn-toast-message{flex:1;min-width:0;white-space:pre-wrap}
76
+ .pmn-toast-close{border:0;background:transparent;color:var(--pmn-muted);cursor:pointer;font-size:19px;line-height:18px;padding:0 1px}
77
+ .pmn-toast-close:hover{color:var(--pmn-text)}
package/docs/API.md CHANGED
@@ -516,3 +516,41 @@ modal.setLoading(true, { text: t("common.loading") });
516
516
  modal.setLoading(false);
517
517
  ```
518
518
 
519
+
520
+
521
+ ## 弹窗内部 Toast 消息提醒
522
+
523
+ `useToast()` 只在当前弹窗的范围内显示消息,不会向全局 `document.body` 添加通知。支持成功、错误、警告、信息四种状态,最多同时显示 5 条;默认 3000ms 后自动消失。
524
+
525
+ ```jsx
526
+ import { useToast } from 'react-modal-navigation';
527
+ import { useTranslation } from 'react-i18next';
528
+
529
+ function EditDevice() {
530
+ const toast = useToast();
531
+ const { t } = useTranslation();
532
+ const save = async () => {
533
+ try {
534
+ await saveDevice();
535
+ toast.success(t('device.saveSuccess'));
536
+ } catch (error) {
537
+ toast.error(t('device.saveFailed'), { duration: 5000 });
538
+ }
539
+ };
540
+ return <button onClick={save}>{t('common.save')}</button>;
541
+ }
542
+ ```
543
+
544
+ ```jsx
545
+ const toast = useToast();
546
+ toast('操作提示'); // 默认 info
547
+ toast.info('请先填写名称');
548
+ toast.success('保存成功');
549
+ toast.warning('设备暂时离线');
550
+ toast.error('保存失败', { duration: 5000 });
551
+ const id = toast('持续提醒', { duration: 0 }); // 不自动关闭
552
+ toast.dismiss(id); // 关闭指定消息
553
+ toast.clear(); // 清空当前弹窗消息
554
+ ```
555
+
556
+ `duration` 单位毫秒;设为 `0` 则不自动消失。`dismissible: false` 隐藏关闭按钮。消息区域始终限制在弹窗内,弹窗关闭时通知自动销毁。国际化文案由业务侧调用 `t()` 后传入。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-modal-navigation",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "description": "React 19 modal navigation with automatic built-in CSS, Promise results and typed hooks",
5
5
  "type": "module",
6
6
  "license": "MIT",