エクスクルーシブ

Deep Pause <mv-deep-pause>

単純なオン/オフスイッチの代わりに、ひとまとまりの対象を一貫して一時停止します(オンラインストアの休暇モード、サブスクリプション、ワークスペース、連携、広告キャンペーン、休暇に入る人など)。

文化的リファレンス

眠れる森の美女(La Belle au bois dormant)、シャルル・ペロー(1697年、童話)。王女が百年の眠りに落ちると、良い妖精は城の者たちを全員一緒に眠らせます。そうすれば、その間に何ひとつ先へ進むことなく、すべてが同じ瞬間に元のままの状態で目覚めるからです。UI では、ストア、サブスクリプション、インテグレーション全体を一時停止すると、それに属するものすべてが一緒に凍結され、眠るものと起きたままのものが一覧表示され、その間に届いたものが集計されます。目覚めるときにはすべてが一斉に再開し、元どおりには戻れなかった少数の項目が示されます。

仕組み

単なるオン/オフのスイッチではなく、あるもの全体をまとめて一貫して一時停止します(オンラインストアの休暇モード、サブスクリプション、ワークスペース、インテグレーション、広告キャンペーン、休暇に入る人)。一時停止の前に、一緒に凍結されるものと動き続けるものを 2 つのリストで示すインベントリーが表示されます。アプリが許可する項目ごとの例外(「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」。破壊的な操作は 2 回目の押下で確定)が用意されます。

カテゴリーフィードバック
タイプWeb Component(<mv-deep-pause>)
ステータス安定版
キット誠実なシステム状態
同時にインストールされるものbutton, input, checkbox, radio, switch, textarea
Keywordsexclusive, 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 &amp; 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タイプDefaultDescription
subjectstringName of the thing being paused (“Harbor & Pine Ceramics”, “CRM sync”), shown as the card title and used in announcements.
openbooleanShows the pause plan (inventory, wake plan, incoming policy) while awake. Set by the “Pause…” button; removed on Cancel, Escape or once paused.
paused-atISO date-timeMoment 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.
incomingqueue | decline | forwardqueueDefault policy for what arrives while paused: hold it for the wake summary, decline it with a reply message, or forward it to someone.
incoming-optionsspace-separated listqueue decline forwardPolicies the app supports; the others are not offered.
incoming-labelstringrequestsWhat arrives, in the plural (“orders and messages”, “webhook events”), used in “While paused, new …”.
max-daysnumberLatest allowed wake date, in days from today (date input max and validation).
localeBCP 47 tagen-USLocale of dates, relative days, durations and counts.
heading-level2..63Level of the title heading; section and list headings follow one and two levels below (read once, at first connection).
data-stateawake | paused | wokeSet 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
itemsArray<{ 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.
heldArray<{ 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.
pausedAtDate | nullStart of the current pause; settable (like the paused-at attribute) to restore a pause from the server.
wakeAtDate | nullPlanned wake moment of the current plan or pause; settable (Date, ISO string or "YYYY-MM-DD"; null = manual).
asleepnumber (ms)Time paused so far (read-only, 0 when not paused).
stringsPartial<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

NameDescription
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

NameDescription
mv-pauseCancelable, 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-wakeCancelable, 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-actionCancelable, 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-changeCancelable, when the wake date is changed while paused. detail: { wake: Date | null, previous: Date | null, waitUntil(promise) }.
mv-dismissThe wake summary was closed. detail: { unresolved: [{ id, count }] } for held groups left without a decision.

Content structure

NameDescription
(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

NameDescription
mv-deep-pause-headAlways-visible header: -icon, -title (heading, focus target after pause), -status (dot + word: Active / Paused / Resumed), -sub, -open (“Pause…”).
mv-deep-pause-planPlan 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-asleepPaused 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-reviewWake 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

NameDefaultDescription
--mv-deep-pause-tonevar(--mv-info)Paused tint: frozen column and marks, facts icons, breathing dot, card border while paused.
--mv-deep-pause-okvar(--mv-success)Running and resumed color: keeps-running marks, exception tags, resumed checks.
--mv-deep-pause-cautionvar(--mv-warning)Caveats and items that could not resume exactly.
--mv-deep-pause-radiusvar(--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.

このページは AI で翻訳されています。翻訳の問題を報告