独家
Deep Pause <mv-deep-pause>
为整个事物提供连贯的暂停(网店的度假模式、订阅、工作区、集成、广告活动、某人休假),而不只是一个简单的开关。
文化出处
睡美人(La Belle au bois dormant),夏尔·佩罗(1697 年,童话)。公主陷入百年沉睡时,善良的仙女让整个王宫的人和她一起沉睡,这样一切都会在同一时刻原样醒来,其间什么都没有改变。在 UI 中,暂停整个商店、订阅或集成会把它所拥有的一切一起冻结,列出哪些沉睡、哪些保持清醒,记录其间到达的内容,并在唤醒时一次性全部重启,同时指出少数无法原样恢复的事项。
工作原理
对整个对象进行一致的暂停(网店的假期模式、订阅、工作区、集成、广告活动、员工休假),而不只是一个简单的开关。暂停前,一份清单用两个列表说明哪些会一起冻结、哪些继续运行,包含应用允许的逐项例外(“Keep taking bookings”)、根据日期计算的内联提醒(“The FALL20 code ends on October 6, before it wakes”)、唤醒计划(手动,或在某个以文字写出并附 “in 24 days” 的日期)以及其间到达内容的处理策略(暂存待后处理、以可编辑且随唤醒日期更新的回复拒绝,或转发)。mv-pause 可取消,其 waitUntil(promise) 会在你的后端真正冻结一切时让 UI 保持忙碌状态,因此只有在暂停确实生效后才显示已暂停状态。暂停期间,一张平静的常驻卡片显示沉睡时长、唤醒计划、传入策略以及暂存内容的实时计数(由你的应用调用 hold(id, n):“1,284 webhook events queued”)、可能无法原样恢复的事项,以及一份可折叠的清单;唤醒日期可以就地修改。唤醒(手动、在唤醒时间自动执行或由代码触发)会经过可取消的 mv-wake,其 promise 可以报告无法原样恢复的事项;其间日期已过的事项会被自动标记。随后唤醒摘要列出已恢复的内容和需要查看的内容,每个暂存组都通过 mv-held-action 提供各自的选项(“Send now / Review / Discard”,破坏性操作需再按一次确认)。
| 分类 | 反馈 |
|---|---|
| 类型 | Web Component(<mv-deep-pause>) |
| 状态 | 稳定版 |
| 套件 | 诚实的系统状态 |
| 同时安装 | button, input, checkbox, radio, switch, textarea |
| Keywords | exclusive, culture, pause, resume, vacation-mode, hold, snooze, suspend, freeze, subscription, workspace, integration, campaign, leave, queue, held-items, wake-date, inventory, settings |
When to use
- A store, workspace or subscription offers a vacation or pause mode that stops several things at once and must restart them together
- Pausing an integration, automation or ad campaign must say exactly what stops, what keeps running and what happens to incoming events
- An account or seat is put on hold (leave, seasonal business) and people need a wake date and a clear picture of what was held meanwhile
- On resume, queued orders, held emails or skipped jobs need an explicit decision instead of being silently sent or dropped
Avoid when
- A single setting turns on or off with no side effects to inventory → use Switch instead
- The change is a permanent removal (delete, archive, revoke) and the point is to show what depends on the item → use Wobble instead
- Access is granted for a limited time and must end on its own, like an admin mode or a trial → use Midnight instead
安装
node scripts/add.mjs deep-pause --out ./src/marvelous使用 Marvelous UI MCP 服务器的 AI 智能体:install_components({ slugs: ["deep-pause"], target_dir: "<absolute path>/src/marvelous", framework: "react" })。
复制的文件(含依赖):tokens/tokens.css, core/base.css, components/button/button.css, components/input/input.css, components/checkbox/checkbox.css, components/radio/radio.css, components/switch/switch.css, core/dom.js, core/element.js, components/textarea/textarea.css, components/textarea/char-count.js, core/motion.js, components/deep-pause/deep-pause.js, components/deep-pause/deep-pause.css。
用法
快速开始,最小可运行标记:
<mv-deep-pause subject="CRM sync" incoming-label="webhook events">
<ul data-group="freeze"><li>Outgoing webhooks</li><li>Nightly contact import</li></ul>
<ul data-group="keep"><li>Contacts and history</li></ul>
</mv-deep-pause>标准标记,可在此基础上通过属性、data-* 和 CSS 变量进行定制:
<div id="dp-demo" style="width:min(100%,60rem);margin-inline:auto">
<style>
#dp-demo { display:grid; gap:1.75rem; align-content:start }
#dp-demo .dp-case { display:grid; gap:.75rem }
#dp-demo .dp-cap { display:flex; align-items:baseline; justify-content:space-between; gap:.5rem 1rem; flex-wrap:wrap }
#dp-demo .dp-cap h4 { margin:0; font-size:.8125rem; font-weight:600; color:var(--mv-fg-muted); letter-spacing:.04em; text-transform:uppercase }
#dp-demo .dp-cap p { margin:0; color:var(--mv-fg-subtle); font-size:.75rem }
#dp-demo .dp-bar { display:flex; align-items:center; gap:.5rem .75rem; flex-wrap:wrap; padding:.625rem .875rem; border:1px dashed var(--mv-border); border-radius:var(--mv-radius-lg); background:var(--mv-bg-subtle) }
#dp-demo .dp-bar .mv-choice { font-size:.8125rem; margin-inline-start:auto }
#dp-demo .dp-log { flex:1 1 16rem; min-width:0; margin:0; color:var(--mv-fg-subtle); font:.75rem/1.4 var(--mv-font-mono); overflow:hidden; text-overflow:ellipsis; white-space:nowrap }
</style>
<!-- 1 · Vacation mode for an online store: starts on the plan, before pausing -->
<section class="dp-case" aria-label="Store vacation mode">
<div class="dp-cap">
<h4>Store vacation mode</h4>
<p>Flip an exception, pick a wake date, then pause.</p>
</div>
<mv-deep-pause id="dp-store" subject="Harbor & Pine Ceramics" open incoming="queue" incoming-label="orders and messages" max-days="90">
<ul data-group="freeze">
<li data-id="checkout" data-detail="The storefront stays visible with a “back soon” notice">Checkout and new orders</li>
<li data-id="emails" data-detail="4 scheduled · next one goes out Friday">Marketing emails</li>
<li data-id="automations" data-detail="Abandoned cart and restock alerts">2 automations</li>
<li data-id="billing" data-detail="Your $39.00 plan pauses; the next charge moves by the pause length">Billing</li>
<li data-id="promo" data-expires-label="The FALL20 code">Fall promotion (FALL20)</li>
<li data-id="workshops" data-optional data-exception="Keep taking bookings" data-detail="Pottery workshops on Saturdays">Public booking page</li>
<li data-id="chat" data-optional data-kept data-exception="Keep answering" data-detail="Replies from your phone">Customer chat</li>
</ul>
<ul data-group="keep">
<li>Products, orders and customer data</li>
<li>API read access for your accounting app</li>
<li>Team logins (3 members)</li>
</ul>
<ul data-group="held">
<li data-id="orders" data-one="order queued" data-actions="release:Process now=Processed, review:Review~">orders queued</li>
<li data-id="mails" data-one="email held" data-actions="send:Send now=Sent, review:Review~, discard:Discard!=Discarded">emails held</li>
<li data-id="messages" data-one="message answered" data-actions="reply:Reply personally=Replied, archive:Archive=Archived">messages answered</li>
</ul>
</mv-deep-pause>
<div class="dp-bar">
<button type="button" class="mv-button" data-variant="outline" data-size="sm" id="dp-order">Simulate an order</button>
<button type="button" class="mv-button" data-variant="outline" data-size="sm" id="dp-message">Simulate a message</button>
<p class="dp-log" id="dp-store-log" aria-live="polite">Plan open: nothing is paused yet.</p>
<label class="mv-choice"><input type="checkbox" role="switch" class="mv-switch" data-size="sm" id="dp-fail"> Make the server fail</label>
</div>
</section>
<!-- 2 · An integration already paused for a few days, woken manually -->
<section class="dp-case" aria-label="Paused integration">
<div class="dp-cap">
<h4>Integration on hold</h4>
<p>Paused 3 days ago. Wake it to see what was held and what didn’t resume exactly.</p>
</div>
<mv-deep-pause id="dp-sync" subject="CRM sync · Tarnwick Traders" incoming="queue" incoming-options="queue decline" incoming-label="webhook events"></mv-deep-pause>
<div class="dp-bar">
<button type="button" class="mv-button" data-variant="outline" data-size="sm" id="dp-webhooks">Simulate 40 webhook events</button>
<p class="dp-log" id="dp-sync-log" aria-live="polite">Paused. Events are being queued.</p>
<button type="button" class="mv-button" data-variant="ghost" data-size="sm" id="dp-reset">Reset demo</button>
</div>
</section>
<script type="module">
const DAY = 864e5;
const store = document.getElementById("dp-store");
const sync = document.getElementById("dp-sync");
const fail = document.getElementById("dp-fail");
const at = (days) => new Date(Date.now() + days * DAY);
const iso = (d) => `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`;
const logger = (id) => (text) => {
const t = new Date().toLocaleTimeString("en-US", { hour: "numeric", minute: "2-digit", second: "2-digit" });
document.getElementById(id).textContent = `${t} · ${text}`;
};
// A fake API: 700 ms round trip, optionally failing.
const server = () => new Promise((resolve, reject) => setTimeout(() => (fail.checked ? reject(new Error("503")) : resolve()), 700));
/* 1 · Store: dates relative to today so the demo never goes stale. */
const storeLog = logger("dp-store-log");
store.wakeAt = iso(at(24));
const promo = store.items.map((i) => (i.id === "promo" ? { ...i, expires: iso(at(12)), detail: "20% off pottery, sitewide" } : i));
store.items = promo;
store.addEventListener("mv-pause", (e) => {
const { freezes, keeps, wake, incoming } = e.detail;
storeLog(`Freezing ${freezes.length} together, ${keeps.length} keep running · wake ${wake ? wake.toLocaleDateString("en-US") : "manually"} · ${incoming.policy}`);
e.detail.waitUntil(server());
});
store.addEventListener("mv-pause-error", () => storeLog("Pause failed: nothing was frozen."));
store.addEventListener("mv-wake", (e) => {
storeLog(`Waking after ${Math.round(e.detail.asleep / 1000)} s (${e.detail.reason})…`);
e.detail.waitUntil(server());
});
store.addEventListener("mv-wake-error", () => storeLog("Wake failed: still paused."));
store.addEventListener("mv-held-action", (e) => {
storeLog(`${e.detail.action} → ${e.detail.count} ${e.detail.label}`);
e.detail.waitUntil(server());
});
store.addEventListener("mv-dismiss", (e) => storeLog(e.detail.unresolved.length ? `Closed with ${e.detail.unresolved.length} held group(s) left for later.` : "All settled."));
// What arrives while the store is paused: the app counts it, the component shows it.
document.getElementById("dp-order").addEventListener("click", () => {
if (store.hold("orders") === false) storeLog("The store is open: orders go straight through.");
else storeLog("New order queued.");
});
document.getElementById("dp-message").addEventListener("click", () => {
if (store.hold("messages") === false) storeLog("The store is open: messages go straight to you.");
else storeLog("New message answered with your auto-reply.");
});
// The scheduled marketing emails get held as soon as the store is paused.
store.addEventListener("mv-pause", () => setTimeout(() => { store.hold("mails", 3); store.hold("orders", 2); }, 900));
/* 2 · Integration: inventory and held counts from JS, restored in the paused state. */
const syncLog = logger("dp-sync-log");
const setupSync = () => {
sync.items = [
{ id: "contacts", label: "Contact sync", detail: "Every 15 minutes, both directions", group: "freeze" },
{ id: "deals", label: "Deal stage webhooks", detail: "Outgoing, 3 endpoints", group: "freeze" },
{ id: "enrich", label: "Nightly enrichment job", detail: "Runs at 2:00 AM", group: "freeze" },
{ id: "token", label: "Sandbox API token", detail: "Used by the staging mirror", group: "freeze", expires: iso(at(-1)), expiresLabel: "The sandbox token" },
{ id: "read", label: "Read-only API access", group: "keep" },
{ id: "audit", label: "Audit log", group: "keep" },
{ id: "mapping", label: "Field mapping settings", group: "keep" },
];
sync.held = [
{ id: "events", label: "webhook events queued", one: "webhook event queued", count: 1284, actions: [{ id: "replay", label: "Replay in order", done: "Replayed" }, { id: "review", label: "Inspect", resolves: false }, { id: "drop", label: "Drop", tone: "danger", done: "Dropped" }] },
{ id: "jobs", label: "sync jobs skipped", one: "sync job skipped", count: 6, actions: [{ id: "run", label: "Run a catch-up sync", done: "Caught up" }, { id: "skip", label: "Skip them", done: "Skipped" }] },
];
sync.pausedAt = new Date(Date.now() - 3 * DAY - 4 * 36e5);
};
setupSync();
sync.addEventListener("mv-wake", (e) => {
syncLog(`Resuming ${e.detail.freezes.length} jobs together…`);
// The server can report what did not come back exactly.
e.detail.waitUntil(new Promise((r) => setTimeout(() => r({ changed: [{ id: "enrich", note: "Last night’s run was skipped; the next one is tonight at 2:00 AM." }] }), 700)));
});
sync.addEventListener("mv-held-action", (e) => {
syncLog(`${e.detail.action} → ${e.detail.count} ${e.detail.label}`);
e.detail.waitUntil(new Promise((r) => setTimeout(r, 600)));
});
sync.addEventListener("mv-dismiss", () => syncLog("Back to normal."));
document.getElementById("dp-webhooks").addEventListener("click", () => {
syncLog(sync.hold("events", 40) === false ? "Not paused: events are delivered live." : "40 events queued.");
});
document.getElementById("dp-reset").addEventListener("click", () => { setupSync(); syncLog("Paused. Events are being queued."); });
</script>
</div>API
Attributes
| Name | 类型 | Default | Description |
|---|---|---|---|
subject | string | Name of the thing being paused (“Harbor & Pine Ceramics”, “CRM sync”), shown as the card title and used in announcements. | |
open | boolean | Shows the pause plan (inventory, wake plan, incoming policy) while awake. Set by the “Pause…” button; removed on Cancel, Escape or once paused. | |
paused-at | ISO date-time | Moment the pause started. Set it from your server to render the paused state directly (no event); removing it returns to awake. Reflected by the component after a successful pause. | |
wake | "YYYY-MM-DD" | ISO date-time | "manual" | Planned wake moment. A date alone means the start of that day, local time. Absent or "manual" = only a person or your code wakes it. Seeds the plan while awake, drives the scheduled wake while paused, reflected after a pause or a wake-date change. | |
incoming | queue | decline | forward | queue | Default policy for what arrives while paused: hold it for the wake summary, decline it with a reply message, or forward it to someone. |
incoming-options | space-separated list | queue decline forward | Policies the app supports; the others are not offered. |
incoming-label | string | requests | What arrives, in the plural (“orders and messages”, “webhook events”), used in “While paused, new …”. |
max-days | number | Latest allowed wake date, in days from today (date input max and validation). | |
locale | BCP 47 tag | en-US | Locale of dates, relative days, durations and counts. |
heading-level | 2..6 | 3 | Level of the title heading; section and list headings follow one and two levels below (read once, at first connection). |
data-state | awake | paused | woke | Set by the component (styleable). data-open while the plan is shown, data-busy while a waitUntil promise runs, data-settle="paused | woke" during the shared transition. |
Properties
| Name | 类型 | Description |
|---|---|---|
items | Array<{ id, label, detail?, group: "freeze" | "keep", optional?, kept?, exception?, caveat?, expires?, expiresLabel? }> | Inventory. optional lets the user keep a freeze item running (switch labelled by exception, default “Keep running”), kept is that choice’s initial value; caveat is a fixed warning; expires (date) produces computed caveats before pausing and an automatic “ended while paused” flag on wake. Declarative alternative: <ul data-group="freeze|keep"> children whose <li> carry data-id, data-detail, data-optional, data-kept, data-exception, data-caveat, data-expires, data-expires-label (read once, then removed). Setting it while paused updates what is shown as frozen. |
held | Array<{ id, label, one?, count?, actions? }> | Groups of things held while paused. label is plural (“emails held”), one singular; actions = [{ id, label, done?, tone?: "danger" | "primary", resolves? }] (default Process now / Review / Discard; resolves: false keeps the group open, like Review; danger needs a second press). Declarative alternative: <ul data-group="held"><li data-id data-one data-count data-actions="send:Send now=Sent, review:Review~, discard:Discard!=Discarded"> (=text shown once done, ! = danger, ~ = resolves: false). Read back with resolved action ids. |
state | "awake" | "paused" | "woke" | Current phase (read-only). woke is the wake summary, until Done. |
pausedAt | Date | null | Start of the current pause; settable (like the paused-at attribute) to restore a pause from the server. |
wakeAt | Date | null | Planned wake moment of the current plan or pause; settable (Date, ISO string or "YYYY-MM-DD"; null = manual). |
asleep | number (ms) | Time paused so far (read-only, 0 when not paused). |
strings | Partial<Record<string, string>> | Overrides for every visible text and announcement (English defaults; placeholders such as {subject}, {date}, {relative}, {duration}, {count}, {incoming}). Default action labels (release, review, discard, released, discarded) are overridable here too. |
Methods
| Name | Description |
|---|---|
showPlan() / hidePlan() | Shows or hides the pause plan (awake only), like toggling the open attribute. |
pause() | Pauses with the current plan, exactly like the Pause now button (validation, cancelable mv-pause, waitUntil). Returns Promise<boolean>. |
wakeUp({ reason? }) | Wakes now (reason defaults to "api"): cancelable mv-wake, waitUntil, then the wake summary. Returns Promise<boolean>. |
hold(id, n = 1) | Counts n more things held in a group while paused (n may be negative). Returns the new count, or false when not paused or the group is unknown. Never announced, so it never chatters. |
flag(id, note) | Marks a frozen item that will not (or did not) resume exactly, with the reason; shown under “May not resume exactly” while paused and in the wake summary. flag(id, null) clears it. |
dismiss() | Closes the wake summary (like Done) and returns to awake. |
Events
| Name | Description |
|---|---|
mv-pause | Cancelable, before anything is shown as paused. detail: { freezes: ids, keeps: ids, exceptions: ids, wake: Date | null, incoming: { policy, message?, forwardTo? }, waitUntil(promise) }. Freeze everything in your backend inside waitUntil: the button stays busy meanwhile, a rejection keeps the plan open with an error (mv-pause-error { error }). |
mv-wake | Cancelable, before waking. detail: { reason: "manual" | "scheduled" | "api", pausedAt, wake, asleep (ms), freezes, held: [{ id, count }], waitUntil(promise) }. The promise may resolve to { changed: [{ id, note }] } to flag items that did not resume exactly. Rejection keeps it paused with an error (mv-wake-error { reason, error }). Cancelling a scheduled wake stops it retrying until the plan changes. |
mv-held-action | Cancelable, when a choice is made for a held group in the wake summary. detail: { id, action, count, label, waitUntil(promise) }. Rejection shows an error on that row; success marks the group done (unless the action has resolves: false) and moves focus to the next decision. |
mv-plan-change | Cancelable, when the wake date is changed while paused. detail: { wake: Date | null, previous: Date | null, waitUntil(promise) }. |
mv-dismiss | The wake summary was closed. detail: { unresolved: [{ id, count }] } for held groups left without a decision. |
Content structure
| Name | Description |
|---|---|
(declarative inventory) | Optional children <ul data-group="freeze">, <ul data-group="keep"> and <ul data-group="held"> are read once at first connection and replaced by the component’s own markup (ignored when the items / held properties were set first). |
CSS classes
| Name | Description |
|---|---|
mv-deep-pause-head | Always-visible header: -icon, -title (heading, focus target after pause), -status (dot + word: Active / Paused / Resumed), -sub, -open (“Pause…”). |
mv-deep-pause-plan | Plan section: -inventory with two -col (data-group freeze | keep, -col-head, -col-count), -item rows (data-group, data-exception, -mark, -item-label, -item-detail, -tag, -caveat, -except switch), -options (wake and incoming fieldsets, -subfield, -hint), -error, -footer (-summary, -actions). |
mv-deep-pause-asleep | Paused section: -facts (dl of -fact: time asleep, wake plan, incoming policy), -held with -tile counters, -caveat-box, -details (read-only inventory), -rewake editor. |
mv-deep-pause-review | Wake summary: -group lists of -line (data-tone ok | caution) for resumed and not-exact items, -rows of held groups (-row, data-resolved, data-empty, -row-actions, -row-state). |
CSS variables
| Name | Default | Description |
|---|---|---|
--mv-deep-pause-tone | var(--mv-info) | Paused tint: frozen column and marks, facts icons, breathing dot, card border while paused. |
--mv-deep-pause-ok | var(--mv-success) | Running and resumed color: keeps-running marks, exception tags, resumed checks. |
--mv-deep-pause-caution | var(--mv-warning) | Caveats and items that could not resume exactly. |
--mv-deep-pause-radius | var(--mv-radius-xl) | Card corner radius. |
Accessibility
The card is a plain region of real headings (heading-level, default h3 for the subject, then one and two levels below) and lists: what freezes and what keeps running are two separate <ul>, each labelled by its heading and count, with a distinct icon per list and an “Exception” tag in words, so nothing relies on color. Exceptions are native switches (role="switch") named “Keep running, <item>” through aria-labelledby; toggling one moves the row to the other list and keeps focus on its switch. Wake and incoming choices are native radio groups in fieldsets with legends; the date field has a real label, its min/max, and a hint (aria-describedby) that restates the choice as text (“Wakes on Monday, October 19, in 24 days.”) or explains the error with aria-invalid; the forward field has its own error message. Every date is written in words in the component’s locale, relative days come from Intl.RelativeTimeFormat, and the status is always a word (Active / Paused / Resumed) next to the colored dot. After a pause, focus moves to the title and “<subject> is paused. Wakes on …” is announced politely; after a wake, focus moves to the summary heading and the count of resumed and not-exact items is announced. Focus only moves when it was inside the component (or the action came from its buttons), never when your code pauses or wakes it in the background. Busy buttons get aria-busy and aria-disabled while a waitUntil promise runs; failures appear in role="alert" messages and nothing is shown as paused or awake until it is true. Held counters update silently (read on demand), destructive held choices need a second press on the same button, which is announced (“Press Confirm: discard again to confirm.”) and disarms after 5 seconds; after each decision focus moves to the next one, then to Done. Escape cancels the plan or the wake-date editor and returns focus to the button that opened it. Reduced motion (OS or data-motion="reduce"): no breathing dot, no settle transition, rows move without sliding. Forced colors: borders and the dot use system colors.