dsh-workbench-tasks 5.2.33 → 5.2.35

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.
Files changed (3) hide show
  1. package/lib/client.js +808 -284
  2. package/lib/index.js +5 -1
  3. package/package.json +4 -4
package/lib/client.js CHANGED
@@ -2316,11 +2316,262 @@ var require_charts = __commonJS({
2316
2316
  }
2317
2317
  });
2318
2318
 
2319
+ // packages/addons/lib/switch.cjs
2320
+ var require_switch = __commonJS({
2321
+ "packages/addons/lib/switch.cjs"(exports2, module2) {
2322
+ "use strict";
2323
+ var SWITCH_STYLES = [
2324
+ ".wbctl-switch{display:inline-flex;align-items:center;gap:7px;min-height:24px;padding:2px;border:0;background:transparent;font:inherit;font-size:12px;color:var(--wb-muted,#6b7280);cursor:pointer;user-select:none;border-radius:999px}",
2325
+ ".wbctl-switch-track{position:relative;display:inline-flex;align-items:center;box-sizing:border-box;width:34px;height:20px;padding:2px;border-radius:999px;background:color-mix(in oklab,currentColor 22%,transparent);transition:background .16s ease;flex:none}",
2326
+ ".wbctl-switch-knob{display:block;width:16px;height:16px;border-radius:50%;background:var(--wb-card,#fff);box-shadow:0 1px 2px rgba(0,0,0,.25);transition:transform .16s ease}",
2327
+ ".wbctl-switch[aria-checked=true]{color:var(--wb-accent,#2563eb)}",
2328
+ ".wbctl-switch[aria-checked=true] .wbctl-switch-track{background:var(--wb-accent,#2563eb)}",
2329
+ ".wbctl-switch[aria-checked=true] .wbctl-switch-knob{transform:translateX(14px)}",
2330
+ ".wbctl-switch:hover:not(:disabled) .wbctl-switch-track{outline:1px solid var(--wb-accent,#2563eb)}",
2331
+ ".wbctl-switch:focus-visible{outline:2px solid var(--wb-accent,#2563eb);outline-offset:2px}",
2332
+ ".wbctl-switch:disabled{opacity:.45;cursor:not-allowed}",
2333
+ ".wbctl-switch-text{white-space:nowrap}",
2334
+ "@media (prefers-reduced-motion:reduce){.wbctl-switch-track,.wbctl-switch-knob{transition:none}}"
2335
+ ];
2336
+ function Switch(props) {
2337
+ var h = props.h;
2338
+ var on = props.checked === true || props.checked === "true";
2339
+ var disabled = !!props.disabled;
2340
+ var text = props.label;
2341
+ if (props.showState) text = on ? props.onText || "\u5F00" : props.offText || "\u5173";
2342
+ return h(
2343
+ "button",
2344
+ {
2345
+ type: "button",
2346
+ role: "switch",
2347
+ "aria-checked": on ? "true" : "false",
2348
+ className: "wbctl-switch" + (props.className ? " " + props.className : ""),
2349
+ disabled,
2350
+ title: props.title,
2351
+ "aria-label": text ? void 0 : props.ariaLabel,
2352
+ onClick: function(e) {
2353
+ e.preventDefault();
2354
+ if (disabled) return;
2355
+ if (typeof props.onChange === "function") props.onChange(!on);
2356
+ }
2357
+ },
2358
+ h(
2359
+ "span",
2360
+ { className: "wbctl-switch-track", "aria-hidden": "true" },
2361
+ h("span", { className: "wbctl-switch-knob" })
2362
+ ),
2363
+ text ? h("span", { className: "wbctl-switch-text" }, text) : null
2364
+ );
2365
+ }
2366
+ module2.exports = { Switch, styles: SWITCH_STYLES };
2367
+ }
2368
+ });
2369
+
2370
+ // packages/addons/lib/number-field.cjs
2371
+ var require_number_field = __commonJS({
2372
+ "packages/addons/lib/number-field.cjs"(exports2, module2) {
2373
+ "use strict";
2374
+ var React = require("react");
2375
+ var NUM = /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)$/;
2376
+ var TEXT = {
2377
+ zh: {
2378
+ required: "\u8BF7\u586B\u5199\u6570\u5B57",
2379
+ invalid: "\u8BF7\u8F93\u5165\u6570\u5B57",
2380
+ integer: "\u9700\u8981\u662F\u6574\u6570",
2381
+ min: "\u4E0D\u80FD\u5C0F\u4E8E {min}",
2382
+ max: "\u4E0D\u80FD\u5927\u4E8E {max}",
2383
+ range: "\u9700\u8981\u5728 {min}\u2013{max} \u4E4B\u95F4",
2384
+ step: "\u9700\u8981\u662F {step} \u7684\u500D\u6570",
2385
+ unit: "\u5355\u4F4D"
2386
+ },
2387
+ en: {
2388
+ required: "Please enter a number",
2389
+ invalid: "Please enter a number",
2390
+ integer: "Must be a whole number",
2391
+ min: "Must be at least {min}",
2392
+ max: "Must be at most {max}",
2393
+ range: "Must be between {min} and {max}",
2394
+ step: "Must be a multiple of {step}",
2395
+ unit: "unit"
2396
+ }
2397
+ };
2398
+ function messages(lang) {
2399
+ return lang === "en" ? TEXT.en : TEXT.zh;
2400
+ }
2401
+ function fill(text, vars) {
2402
+ return String(text).replace(/\{(\w+)\}/g, function(m, key) {
2403
+ return vars && vars[key] !== void 0 ? String(vars[key]) : m;
2404
+ });
2405
+ }
2406
+ function validateNumber(raw, opts) {
2407
+ var o = opts || {};
2408
+ var M = messages(o.lang);
2409
+ var text = raw === null || raw === void 0 ? "" : String(raw).trim();
2410
+ if (text === "") {
2411
+ return o.allowEmpty ? { ok: true, value: null, error: "" } : { ok: false, value: null, error: M.required };
2412
+ }
2413
+ if (!NUM.test(text)) return { ok: false, value: null, error: M.invalid };
2414
+ var n = Number(text);
2415
+ if (!isFinite(n)) return { ok: false, value: null, error: M.invalid };
2416
+ if (o.integer && Math.round(n) !== n) return { ok: false, value: null, error: M.integer };
2417
+ var hasMin = o.min !== void 0 && o.min !== null && o.min !== "";
2418
+ var hasMax = o.max !== void 0 && o.max !== null && o.max !== "";
2419
+ if (hasMin && hasMax && n >= o.min && n <= o.max) {
2420
+ } else if (hasMin && hasMax) {
2421
+ return { ok: false, value: null, error: fill(M.range, { min: o.min, max: o.max }) };
2422
+ } else if (hasMin && n < o.min) {
2423
+ return { ok: false, value: null, error: fill(M.min, { min: o.min }) };
2424
+ } else if (hasMax && n > o.max) {
2425
+ return { ok: false, value: null, error: fill(M.max, { max: o.max }) };
2426
+ }
2427
+ if (o.step && Number(o.step) > 0) {
2428
+ var q = n / Number(o.step);
2429
+ if (Math.abs(q - Math.round(q)) > 1e-9) {
2430
+ return { ok: false, value: null, error: fill(M.step, { step: o.step }) };
2431
+ }
2432
+ }
2433
+ return { ok: true, value: n, error: "" };
2434
+ }
2435
+ function rangeHint(opts, lang) {
2436
+ var o = opts || {};
2437
+ var M = messages(lang);
2438
+ var en = lang === "en";
2439
+ var hasMin = o.min !== void 0 && o.min !== null && o.min !== "";
2440
+ var hasMax = o.max !== void 0 && o.max !== null && o.max !== "";
2441
+ var parts = [];
2442
+ if (hasMin && hasMax) parts.push(String(o.min) + "\u2013" + String(o.max));
2443
+ else if (hasMin) parts.push((en ? "\u2265 " : "\u2265 ") + String(o.min));
2444
+ else if (hasMax) parts.push((en ? "\u2264 " : "\u2264 ") + String(o.max));
2445
+ if (o.integer) parts.push(en ? "whole numbers" : "\u6574\u6570");
2446
+ else if (o.step && Number(o.step) > 0) parts.push((en ? "step " : "\u6B65\u957F ") + String(o.step));
2447
+ return parts.join(en ? ", " : "\uFF0C");
2448
+ }
2449
+ function NumberField(props) {
2450
+ var h = props.h || React.createElement;
2451
+ var lang = props.lang;
2452
+ var M = messages(lang);
2453
+ var text = props.value === null || props.value === void 0 ? "" : String(props.value);
2454
+ var draftS = React.useState(text);
2455
+ var draft = draftS[0];
2456
+ var setDraft = draftS[1];
2457
+ var focusS = React.useState(false);
2458
+ var focused = focusS[0];
2459
+ var setFocused = focusS[1];
2460
+ var errS = React.useState("");
2461
+ var err = errS[0];
2462
+ var setErr = errS[1];
2463
+ var lastRef = React.useRef(text);
2464
+ var skipBlurRef = React.useRef(false);
2465
+ React.useEffect(
2466
+ function() {
2467
+ if (focused) return;
2468
+ if (lastRef.current === text) return;
2469
+ lastRef.current = text;
2470
+ setDraft(text);
2471
+ setErr("");
2472
+ },
2473
+ [text, focused]
2474
+ );
2475
+ function commit(raw) {
2476
+ var r = validateNumber(raw, props);
2477
+ if (!r.ok) {
2478
+ setErr(r.error);
2479
+ if (typeof props.onValidChange === "function") props.onValidChange(false, r.error);
2480
+ return false;
2481
+ }
2482
+ setErr("");
2483
+ if (typeof props.onValidChange === "function") props.onValidChange(true, "");
2484
+ var cur = props.value === null || props.value === void 0 ? null : Number(props.value);
2485
+ if (r.value !== cur) {
2486
+ lastRef.current = r.value === null ? "" : String(r.value);
2487
+ if (typeof props.onCommit === "function") props.onCommit(r.value);
2488
+ }
2489
+ return true;
2490
+ }
2491
+ var hint = props.hint !== void 0 ? props.hint : rangeHint(props, lang);
2492
+ var shown = props.hint === false ? "" : hint;
2493
+ return h(
2494
+ "span",
2495
+ { className: "wbctl-num" + (props.wide ? " is-wide" : "") + (props.className ? " " + props.className : "") },
2496
+ h(
2497
+ "span",
2498
+ { className: "wbctl-num-box" },
2499
+ h("input", {
2500
+ className: "wbctl-num-input" + (err ? " is-invalid" : ""),
2501
+ type: "text",
2502
+ inputMode: props.integer || Number(props.step) === 1 ? "numeric" : "decimal",
2503
+ value: draft,
2504
+ disabled: !!props.disabled,
2505
+ placeholder: props.placeholder,
2506
+ title: props.title,
2507
+ "aria-label": props.ariaLabel,
2508
+ "aria-invalid": err ? "true" : void 0,
2509
+ onFocus: function() {
2510
+ setFocused(true);
2511
+ },
2512
+ onChange: function(e) {
2513
+ setDraft(e.target.value);
2514
+ if (err) setErr("");
2515
+ if (typeof props.onDraft === "function") props.onDraft(e.target.value);
2516
+ },
2517
+ onBlur: function() {
2518
+ setFocused(false);
2519
+ if (skipBlurRef.current) {
2520
+ skipBlurRef.current = false;
2521
+ return;
2522
+ }
2523
+ commit(draft);
2524
+ },
2525
+ onKeyDown: function(e) {
2526
+ if (e.key === "Enter") {
2527
+ e.preventDefault();
2528
+ if (e.target && e.target.blur) e.target.blur();
2529
+ } else if (e.key === "Escape") {
2530
+ e.preventDefault();
2531
+ skipBlurRef.current = true;
2532
+ setDraft(text);
2533
+ setErr("");
2534
+ if (e.target && e.target.blur) e.target.blur();
2535
+ }
2536
+ }
2537
+ }),
2538
+ props.unit ? h("span", { className: "wbctl-num-unit" }, props.unit) : null
2539
+ ),
2540
+ err ? h("span", { className: "wbctl-num-err", role: "alert" }, err) : shown ? h("span", { className: "wbctl-num-hint" }, shown) : null
2541
+ );
2542
+ }
2543
+ var NUMBER_STYLES = [
2544
+ ".wbctl-num{display:inline-flex;flex-direction:column;gap:3px;min-width:0;max-width:100%}",
2545
+ ".wbctl-num.is-wide{display:flex;width:100%}",
2546
+ ".wbctl-num-box{display:inline-flex;align-items:center;gap:6px;min-width:0}",
2547
+ ".wbctl-num-input{box-sizing:border-box;width:96px;min-width:0;padding:6px 9px;border:1px solid var(--wb-line,rgba(127,127,127,.35));border-radius:6px;background:var(--wb-surface,var(--wb-card,transparent));color:inherit;font:inherit;font-size:13px;font-variant-numeric:tabular-nums;transition:border-color .14s ease,outline-color .14s ease}",
2548
+ ".wbctl-num-input:hover:not(:disabled){border-color:var(--wb-border,var(--wb-line))}",
2549
+ ".wbctl-num-input:focus{outline:2px solid color-mix(in oklab,var(--wb-accent,#2563eb) 55%,transparent);outline-offset:1px;border-color:var(--wb-accent,#2563eb)}",
2550
+ ".wbctl-num-input.is-invalid{border-color:var(--wb-danger,#dc2626)}",
2551
+ ".wbctl-num-input.is-invalid:focus{outline-color:color-mix(in oklab,var(--wb-danger,#dc2626) 55%,transparent)}",
2552
+ ".wbctl-num-input:disabled{opacity:.5;cursor:not-allowed}",
2553
+ ".wbctl-num-unit{color:var(--wb-muted,inherit);font-size:12px;white-space:nowrap}",
2554
+ ".wbctl-num-hint{color:var(--wb-muted,inherit);font-size:11px;line-height:1.4}",
2555
+ ".wbctl-num-err{color:var(--wb-danger,#dc2626);font-size:11px;line-height:1.4}",
2556
+ "@media (prefers-reduced-motion:reduce){.wbctl-num-input{transition:none}}"
2557
+ ];
2558
+ module2.exports = {
2559
+ NumberField,
2560
+ validateNumber,
2561
+ rangeHint,
2562
+ messages,
2563
+ styles: NUMBER_STYLES
2564
+ };
2565
+ }
2566
+ });
2567
+
2319
2568
  // packages/addons/tasks/client/views/config.cjs
2320
2569
  var require_config = __commonJS({
2321
2570
  "packages/addons/tasks/client/views/config.cjs"(exports2, module2) {
2322
2571
  var React = require("react");
2323
2572
  var h = React.createElement;
2573
+ var SW = require_switch();
2574
+ var NF = require_number_field();
2324
2575
  var DOMAIN = "tasks";
2325
2576
  var PREFIX = "wbt";
2326
2577
  var COPY = {
@@ -2395,13 +2646,6 @@ var require_config = __commonJS({
2395
2646
  ".__P__-cfg-select:focus,.__P__-cfg-input:focus{border-color:var(--dsw-alias-brand-primary,currentColor);box-shadow:0 0 0 3px color-mix(in oklab,var(--dsw-alias-brand-primary,currentColor) 14%,transparent)}",
2396
2647
  ".__P__-cfg-select{min-width:152px;padding-right:10px}",
2397
2648
  ".__P__-cfg-input{width:132px}",
2398
- ".__P__-cfg-switch{position:relative;display:inline-flex;align-items:center;gap:9px;cursor:pointer;font-size:12.5px;color:var(--cfg-muted);user-select:none}",
2399
- ".__P__-cfg-switch input{position:absolute;inset:0;width:100%;height:100%;margin:0;opacity:0;cursor:pointer}",
2400
- ".__P__-cfg-track{position:relative;width:38px;height:22px;border-radius:999px;background:color-mix(in oklab,currentColor 18%,transparent);transition:background .16s ease;flex:none}",
2401
- ".__P__-cfg-track::after{content:'';position:absolute;top:2px;left:2px;width:18px;height:18px;border-radius:50%;background:var(--dsw-alias-label-primary,currentColor);transition:transform .16s ease,background .16s ease}",
2402
- ".__P__-cfg-switch input:checked+.__P__-cfg-track{background:var(--dsw-alias-brand-primary,currentColor)}",
2403
- ".__P__-cfg-switch input:checked+.__P__-cfg-track::after{transform:translateX(16px);background:var(--dsw-alias-label-primary-inverted,var(--dsw-alias-bg-base))}",
2404
- ".__P__-cfg-switch input:focus-visible+.__P__-cfg-track{outline:2px solid var(--dsw-alias-brand-primary,currentColor);outline-offset:2px}",
2405
2649
  ".__P__-cfg-multi{display:flex;flex-wrap:wrap;gap:6px;justify-content:flex-end;max-width:100%}",
2406
2650
  ".__P__-cfg-multi label{position:relative;display:inline-flex;align-items:center;padding:5px 11px;border:1px solid var(--cfg-line);border-radius:999px;font-size:12px;color:var(--cfg-muted);cursor:pointer;line-height:1.4;transition:color .12s ease,border-color .12s ease,background .12s ease}",
2407
2651
  ".__P__-cfg-multi label:hover{background:var(--cfg-hover);color:var(--dsw-alias-label-primary,inherit)}",
@@ -2426,8 +2670,8 @@ var require_config = __commonJS({
2426
2670
  ".__P__-cfg-empty{border:1px dashed var(--cfg-line);border-radius:14px;padding:40px 16px;text-align:center;font-size:12.5px;color:var(--cfg-muted)}",
2427
2671
  ".__P__-cfg-error{display:flex;align-items:center;gap:10px;flex-wrap:wrap;border:1px solid color-mix(in oklab,var(--dsw-alias-state-error-primary,currentColor) 32%,var(--cfg-line));border-radius:10px;padding:10px 13px;color:var(--dsw-alias-state-error-primary,inherit);font-size:12.5px;line-height:1.5}",
2428
2672
  "@media (max-width:820px){.__P__-cfg-row{grid-template-columns:1fr;gap:10px;padding:13px 16px}.__P__-cfg-control{justify-content:flex-start}.__P__-cfg-multi{justify-content:flex-start}.__P__-cfg-gtitle{padding:11px 16px}}",
2429
- "@media (prefers-reduced-motion:reduce){.__P__-cfg-track,.__P__-cfg-track::after,.__P__-cfg-sk{animation:none;transition:none}}"
2430
- ].join("\n").split("__P__").join(PREFIX);
2673
+ "@media (prefers-reduced-motion:reduce){.__P__-cfg-sk{animation:none;transition:none}}"
2674
+ ].concat(SW.styles).concat(NF.styles).join("\n").split("__P__").join(PREFIX);
2431
2675
  function injectCss() {
2432
2676
  if (typeof document === "undefined") return;
2433
2677
  var old = document.getElementById("wb-addon-" + DOMAIN + "-config-css");
@@ -2510,8 +2754,6 @@ var require_config = __commonJS({
2510
2754
  var notice = noticeS[0], setNotice = noticeS[1];
2511
2755
  var savingS = React.useState("");
2512
2756
  var savingId = savingS[0], setSavingId = savingS[1];
2513
- var draftsS = React.useState({});
2514
- var drafts = draftsS[0], setDrafts = draftsS[1];
2515
2757
  var busyS = React.useState(false);
2516
2758
  var busy = busyS[0], setBusy = busyS[1];
2517
2759
  var requestLock = React.useRef(false), mounted = React.useRef(true);
@@ -2626,40 +2868,21 @@ var require_config = __commonJS({
2626
2868
  setNotice({ id: "", text: String(e && e.message || e), error: true });
2627
2869
  }).finally(release);
2628
2870
  }
2629
- function commitDraft(item) {
2630
- if (requestLock.current) return;
2631
- var raw = drafts[item.id];
2632
- if (raw === void 0) return;
2633
- var next = String(raw).trim();
2634
- setDrafts(function(prev) {
2635
- var copy = Object.assign({}, prev);
2636
- delete copy[item.id];
2637
- return copy;
2638
- });
2639
- if (next === "") return;
2640
- var value = Number(next);
2641
- if (!Number.isFinite(value)) return;
2642
- if (sameValue(value, state.values[item.id])) return;
2643
- save(item.id, value);
2644
- }
2645
2871
  function renderControl(item) {
2646
2872
  var value = state.values[item.id];
2647
2873
  var label = lang === "en" ? item.en : item.zh;
2648
2874
  if (item.type === "bool") {
2649
- return h(
2650
- "label",
2651
- { className: PREFIX + "-cfg-switch" },
2652
- h("input", {
2653
- type: "checkbox",
2654
- disabled: locked,
2655
- checked: value === true,
2656
- onChange: function(e) {
2657
- save(item.id, e.target.checked);
2658
- }
2659
- }),
2660
- h("span", { className: PREFIX + "-cfg-track", "aria-hidden": "true" }),
2661
- h("span", { className: PREFIX + "-cfg-switchstate" }, value === true ? t.on : t.off)
2662
- );
2875
+ return h(SW.Switch, {
2876
+ h,
2877
+ checked: value === true,
2878
+ disabled: locked,
2879
+ showState: true,
2880
+ onText: t.on,
2881
+ offText: t.off,
2882
+ onChange: function(next) {
2883
+ save(item.id, next);
2884
+ }
2885
+ });
2663
2886
  }
2664
2887
  if (item.type === "enum") {
2665
2888
  return h("select", {
@@ -2677,31 +2900,17 @@ var require_config = __commonJS({
2677
2900
  }));
2678
2901
  }
2679
2902
  if (item.type === "int") {
2680
- var draft = drafts[item.id] !== void 0 ? drafts[item.id] : String(value);
2681
- return h("input", {
2682
- className: PREFIX + "-cfg-input",
2683
- disabled: locked,
2684
- type: "number",
2685
- value: draft,
2903
+ return h(NF.NumberField, {
2904
+ h,
2905
+ lang,
2906
+ value: value === void 0 ? "" : value,
2686
2907
  min: item.min,
2687
2908
  max: item.max,
2688
- "aria-label": label,
2689
- onChange: function(e) {
2690
- var v = e.target.value;
2691
- setDrafts(function(prev) {
2692
- var c = Object.assign({}, prev);
2693
- c[item.id] = v;
2694
- return c;
2695
- });
2696
- },
2697
- onBlur: function() {
2698
- commitDraft(item);
2699
- },
2700
- onKeyDown: function(e) {
2701
- if (e.key === "Enter") {
2702
- e.preventDefault();
2703
- commitDraft(item);
2704
- }
2909
+ integer: true,
2910
+ disabled: locked,
2911
+ ariaLabel: label,
2912
+ onCommit: function(next) {
2913
+ save(item.id, next);
2705
2914
  }
2706
2915
  });
2707
2916
  }
@@ -4514,13 +4723,6 @@ var require_data_style = __commonJS({
4514
4723
  "." + P + "-search input:focus{border-color:var(--dsw-alias-brand-primary,currentColor);box-shadow:0 0 0 3px color-mix(in oklab,var(--dsw-alias-brand-primary,currentColor) 14%,transparent)}",
4515
4724
  "." + P + "-select{border:1px solid var(--cfg-line);background:var(--dsw-alias-bg-base,transparent);color:inherit;border-radius:9px;padding:7px 10px;font:inherit;font-size:12px;outline:none}",
4516
4725
  "." + P + "-select:focus{border-color:var(--dsw-alias-brand-primary,currentColor);box-shadow:0 0 0 3px color-mix(in oklab,var(--dsw-alias-brand-primary,currentColor) 14%,transparent)}",
4517
- "." + P + "-switch{position:relative;display:inline-flex;align-items:center;gap:7px;cursor:pointer;font-size:12px;color:var(--cfg-muted);user-select:none;padding:4px 2px}",
4518
- "." + P + "-switch input{position:absolute;inset:0;width:100%;height:100%;margin:0;opacity:0;cursor:pointer}",
4519
- "." + P + "-track{position:relative;width:34px;height:20px;border-radius:999px;background:color-mix(in oklab,currentColor 18%,transparent);transition:background .16s ease;flex:none}",
4520
- "." + P + "-track::after{content:'';position:absolute;top:2px;left:2px;width:16px;height:16px;border-radius:50%;background:var(--dsw-alias-label-primary,currentColor);transition:transform .16s ease,background .16s ease}",
4521
- "." + P + "-switch input:checked+." + P + "-track{background:var(--dsw-alias-brand-primary,currentColor)}",
4522
- "." + P + "-switch input:checked+." + P + "-track::after{transform:translateX(14px);background:var(--dsw-alias-label-primary-inverted,var(--dsw-alias-bg-base))}",
4523
- "." + P + "-switch input:focus-visible+." + P + "-track{outline:2px solid var(--dsw-alias-brand-primary,currentColor);outline-offset:2px}",
4524
4726
  "." + P + "-btn{display:inline-flex;align-items:center;gap:5px;border:1px solid var(--cfg-line);background:transparent;color:var(--cfg-muted);border-radius:8px;padding:6px 10px;font:inherit;font-size:11.5px;cursor:pointer;white-space:nowrap;transition:background .12s ease,color .12s ease}",
4525
4727
  "." + P + "-btn:hover{background:var(--cfg-hover);color:var(--dsw-alias-label-primary,inherit)}",
4526
4728
  "." + P + "-btn:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,currentColor);outline-offset:2px}",
@@ -4549,8 +4751,8 @@ var require_data_style = __commonJS({
4549
4751
  "." + P + "-foot{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding-top:2px;font-size:11.5px;color:var(--cfg-muted)}",
4550
4752
  "." + P + "-grow{flex:1}",
4551
4753
  "." + P + "-pageinfo{font-variant-numeric:tabular-nums}",
4552
- "." + P + "-jump{width:56px;border:1px solid var(--cfg-line);background:var(--dsw-alias-bg-base,transparent);color:inherit;border-radius:7px;padding:4px 7px;font:inherit;font-size:11.5px;text-align:right;outline:none}",
4553
- "." + P + "-jump:focus{border-color:var(--dsw-alias-brand-primary,currentColor)}",
4754
+ "." + P + "-jump .wbctl-num-input{width:56px;padding:4px 7px;font-size:11.5px;text-align:right}",
4755
+ "." + P + "-jump .wbctl-num-hint{display:none}",
4554
4756
  "." + P + "-empty{border:1px dashed var(--cfg-line);border-radius:11px;padding:44px 16px;text-align:center;font-size:12.5px;color:var(--cfg-muted)}",
4555
4757
  "." + P + "-err{display:flex;align-items:center;gap:10px;flex-wrap:wrap;border:1px solid color-mix(in oklab,var(--dsw-alias-state-error-primary,currentColor) 32%,var(--cfg-line));border-radius:10px;padding:9px 12px;color:var(--dsw-alias-state-error-primary,inherit);font-size:12px;line-height:1.5}",
4556
4758
  "." + P + "-skwrap{display:flex;flex-direction:column;gap:1px;padding:2px}",
@@ -4588,7 +4790,7 @@ var require_data_style = __commonJS({
4588
4790
  "." + P + "-images img{width:36px;height:36px;object-fit:cover;border-radius:5px}",
4589
4791
  "." + P + "-gallery{display:flex;flex-direction:column;gap:12px;overflow:auto;flex:1}",
4590
4792
  "." + P + "-gallery img{width:100%;height:auto;object-fit:contain;border-radius:8px}"
4591
- ].join("\n");
4793
+ ].concat(require_switch().styles).concat(require_number_field().styles).join("\n");
4592
4794
  if (DOMAIN === "storage") {
4593
4795
  var buttons = "." + P + " :is(button)";
4594
4796
  CSS += buttons + "{border:none;background:var(--wb-btn-bg);min-height:var(--wb-btn-size-sm);min-width:var(--wb-btn-size-sm)}" + buttons + ":enabled:hover{background:var(--wb-btn-hover-bg)}" + buttons + ":enabled:active{background:var(--wb-btn-active-bg)}" + buttons + ":disabled{background:var(--wb-btn-bg);color:var(--cfg-muted)}" + buttons + ":focus-visible{outline:var(--wb-btn-focus);outline-offset:var(--wb-btn-focus-offset)}." + P + "-fcell:has(button) input{padding-right:34px}";
@@ -4616,8 +4818,10 @@ var require_data_view = __commonJS({
4616
4818
  "packages/addons/lib/data-view.cjs"(exports2, module2) {
4617
4819
  "use strict";
4618
4820
  var React = require("react");
4821
+ var NF = require_number_field();
4619
4822
  var h = React.createElement;
4620
4823
  var COPY = require_data_copy();
4824
+ var SW = require_switch();
4621
4825
  module2.exports = function createDataView(options) {
4622
4826
  var DOMAIN = options.domain;
4623
4827
  function icon(name) {
@@ -5171,17 +5375,18 @@ var require_data_view = __commonJS({
5171
5375
  h("button", { type: "button", className: P + "-btn", disabled: !data || page >= pages, onClick: function() {
5172
5376
  setPage(Math.min(pages, page + 1));
5173
5377
  } }, t.next + " \u203A"),
5174
- h("input", {
5378
+ h(NF.NumberField, {
5379
+ h,
5380
+ lang,
5175
5381
  className: P + "-jump",
5176
- type: "number",
5382
+ value: page,
5177
5383
  min: 1,
5178
5384
  max: pages,
5179
- "aria-label": t.jump,
5180
- onKeyDown: function(e) {
5181
- if (e.key === "Enter") {
5182
- var n = Math.floor(Number(e.target.value));
5183
- if (n >= 1) setPage(Math.min(pages, n));
5184
- }
5385
+ integer: true,
5386
+ ariaLabel: t.jump,
5387
+ hint: false,
5388
+ onCommit: function(next) {
5389
+ if (next !== null) setPage(next);
5185
5390
  }
5186
5391
  }),
5187
5392
  data && data.queryMs !== void 0 ? h("span", null, fmt(t.queryTime, { n: data.queryMs })) : null
@@ -5278,25 +5483,23 @@ var require_data_view = __commonJS({
5278
5483
  }
5279
5484
  })
5280
5485
  ),
5281
- h(
5282
- "label",
5283
- { className: P + "-switch" },
5284
- h("input", { type: "checkbox", checked: includeDeleted, onChange: function(e) {
5285
- setIncludeDeleted(e.target.checked);
5486
+ h(SW.Switch, {
5487
+ h,
5488
+ checked: includeDeleted,
5489
+ label: t.includeDeleted,
5490
+ onChange: function(next) {
5491
+ setIncludeDeleted(next);
5286
5492
  setPage(1);
5287
- } }),
5288
- h("span", { className: P + "-track" }),
5289
- h("span", null, t.includeDeleted)
5290
- ),
5291
- h(
5292
- "label",
5293
- { className: P + "-switch" },
5294
- h("input", { type: "checkbox", checked: showSystem, onChange: function(e) {
5295
- setShowSystem(e.target.checked);
5296
- } }),
5297
- h("span", { className: P + "-track" }),
5298
- h("span", null, t.showSystem)
5299
- ),
5493
+ }
5494
+ }),
5495
+ h(SW.Switch, {
5496
+ h,
5497
+ checked: showSystem,
5498
+ label: t.showSystem,
5499
+ onChange: function(next) {
5500
+ setShowSystem(next);
5501
+ }
5502
+ }),
5300
5503
  h("span", { className: P + "-grow" }),
5301
5504
  h(
5302
5505
  "label",
@@ -5449,16 +5652,13 @@ var require_action_schema_style = __commonJS({
5449
5652
  "." + P + "-cardmeta{display:flex;align-items:center;flex-wrap:wrap;gap:8px;min-width:0;min-height:24px}",
5450
5653
  "." + P + "-cardhead code{font-weight:640;overflow-wrap:anywhere;min-width:0}",
5451
5654
  "." + P + "-hintline{margin:0;color:var(--dsw-alias-label-tertiary,inherit);font-size:11.5px;line-height:1.5}",
5452
- "." + P + "-toggle{display:inline-flex;align-items:center;gap:6px;min-height:24px;padding:0 2px;border:0;background:transparent;font:inherit;font-size:11.5px;color:var(--wb-muted);cursor:pointer}",
5453
- "." + P + "-track{display:inline-flex;align-items:center;box-sizing:border-box;width:30px;height:18px;padding:2px;border:1px solid var(--wb-muted);border-radius:999px;background:var(--wb-surface);color:var(--wb-muted)}",
5454
- "." + P + "-track::before{content:'';width:12px;height:12px;border-radius:50%;background:currentColor;transition:transform .15s ease}",
5455
- "." + P + "-toggle[aria-checked=true] ." + P + "-track{background:var(--wb-accent);border-color:var(--wb-accent);color:var(--wb-card)}",
5456
- "." + P + "-toggle[aria-checked=true] ." + P + "-track::before{transform:translateX(12px)}",
5457
- "." + P + "-toggle:hover:not(:disabled) ." + P + "-track{outline:1px solid var(--wb-accent)}",
5458
- "." + P + "-toggle:focus-visible{outline:2px solid var(--wb-accent);outline-offset:2px}",
5459
- "." + P + "-toggle:disabled{opacity:.6;cursor:progress}",
5460
- "@media(prefers-reduced-motion:reduce){." + P + "-track::before{transition:none}}",
5461
- // 安全约束(不可放开):用警示色描边,和可切换的开关区分开。
5655
+ "." + P + "-origins{display:inline-flex;align-items:center;gap:10px;flex-wrap:wrap;justify-content:flex-end}",
5656
+ "." + P + "-origins-label{font-size:11px;color:var(--wb-muted);white-space:nowrap}",
5657
+ "." + P + "-origin{display:inline-flex;align-items:center;gap:4px;font-size:11.5px;color:var(--wb-muted);cursor:pointer;user-select:none}",
5658
+ // 该 action 本身不支持的来源:整项置灰、不可点,示意「不是没开,是开不了」。
5659
+ "." + P + "-origin-off{opacity:.55;cursor:not-allowed}",
5660
+ "." + P + "-origin input[type=checkbox]{width:13px;height:13px;margin:0;accent-color:var(--wb-accent);cursor:inherit}",
5661
+ "." + P + "-origin input[type=checkbox]:focus-visible{outline:2px solid var(--wb-accent);outline-offset:2px}",
5462
5662
  "." + P + "-locked{border-color:var(--wb-warn,#b7791f);color:var(--wb-warn,#b7791f)}",
5463
5663
  "." + P + "-desc{margin:0;color:var(--dsw-alias-label-secondary,inherit);line-height:1.55;font-size:12.5px}",
5464
5664
  // 搜索命中:用品牌色透明度叠加而不是写死浅色,深浅主题都可读;继承文字颜色、不覆盖 ::selection。
@@ -5511,15 +5711,20 @@ var require_action_schema_view = __commonJS({
5511
5711
  zh: {
5512
5712
  title: "Action",
5513
5713
  hint: "\u8FD0\u884C\u65F6\u6CE8\u518C \xB7 \u53EA\u8BFB",
5514
- switchHint: "agent \u5F00\u5173\u843D\u672C\u673A\u3001\u5373\u6539\u5373\u751F\u6548\uFF1B\u754C\u9762\u64CD\u4F5C\u4E0D\u53D7\u5F71\u54CD\u3002",
5515
- hostHint: "\u5BBF\u4E3B action \u7684 agent \u5F00\u5173\uFF1B\u6807\u300C\u4EC5\u754C\u9762 \xB7 \u5B89\u5168\u7EA6\u675F\u300D\u7684\u4E0D\u53EF\u653E\u5F00\u3002",
5516
- agentSwitch: "agent \u53EF\u7528",
5517
- agentLocked: "\u4EC5\u754C\u9762 \xB7 \u5B89\u5168\u7EA6\u675F",
5518
- agentLockedHint: "\u8BE5 action \u53EA\u80FD\u5728\u754C\u9762\u6267\u884C\uFF08\u5B89\u5168\u7EA6\u675F\uFF09\uFF0Cagent \u5F00\u5173\u4E0D\u53EF\u653E\u5F00",
5519
- agentSaving: "\u4FDD\u5B58\u4E2D\u2026",
5520
- agentOnToast: "\u5DF2\u5141\u8BB8 agent \u8C03\u7528",
5521
- agentOffToast: "\u5DF2\u7981\u6B62 agent \u8C03\u7528",
5522
- agentFail: "\u5207\u6362 agent \u5F00\u5173\u5931\u8D25",
5714
+ switchHint: "\u5141\u8BB8\u6765\u6E90\u843D\u672C\u673A\u3001\u5373\u6539\u5373\u751F\u6548\uFF1A\u52FE\u4E0A\u7684\u6765\u6E90\u624D\u80FD\u8C03\u7528\u8BE5 action\uFF0C\u5176\u4F59\u4F1A\u88AB ACTION_ORIGIN_DENIED \u62E6\u4E0B\u3002",
5715
+ hostHint: "\u5BBF\u4E3B action \u7684\u5141\u8BB8\u6765\u6E90\uFF1B\u6807\u300C\u6765\u6E90\u56FA\u5B9A\u300D\u7684\u4E0D\u53EF\u4FEE\u6539\u3002",
5716
+ originsLabel: "\u5141\u8BB8\u6765\u6E90",
5717
+ originUi: "\u754C\u9762",
5718
+ originPlugin: "\u63D2\u4EF6",
5719
+ originAgent: "agent",
5720
+ originSync: "\u540C\u6B65",
5721
+ originsSaving: "\u4FDD\u5B58\u4E2D\u2026",
5722
+ originsToast: "\u5DF2\u66F4\u65B0\u5141\u8BB8\u6765\u6E90",
5723
+ originsFail: "\u66F4\u65B0\u5141\u8BB8\u6765\u6E90\u5931\u8D25",
5724
+ originsEmpty: "\u81F3\u5C11\u8981\u4FDD\u7559\u4E00\u4E2A\u6765\u6E90",
5725
+ originsUnsupported: "\u8BE5 action \u672C\u8EAB\u4E0D\u652F\u6301\u8FD9\u4E2A\u6765\u6E90",
5726
+ originsPinned: "\u6765\u6E90\u56FA\u5B9A",
5727
+ originsPinnedHint: "\u8BE5 action \u7684\u5141\u8BB8\u6765\u6E90\u88AB\u56FA\u5B9A\uFF08\u5B89\u5168\u7EA6\u675F\uFF09\uFF0C\u4E0D\u80FD\u4FEE\u6539",
5523
5728
  domain: "\u57DF",
5524
5729
  versionLabel: "\u7248\u672C",
5525
5730
  shell: "\u5BBF\u4E3B",
@@ -5533,6 +5738,8 @@ var require_action_schema_view = __commonJS({
5533
5738
  onlyOptional: "\u65E0\u5FC5\u586B\u9879",
5534
5739
  filterType: "\u53C2\u6570\u7C7B\u578B",
5535
5740
  allTypes: "\u5168\u90E8\u7C7B\u578B",
5741
+ filterOrigin: "\u5141\u8BB8\u6765\u6E90",
5742
+ allOrigins: "\u5168\u90E8\u6765\u6E90",
5536
5743
  colName: "\u53C2\u6570",
5537
5744
  colType: "\u7C7B\u578B",
5538
5745
  colReq: "\u5FC5\u586B",
@@ -5565,15 +5772,22 @@ var require_action_schema_view = __commonJS({
5565
5772
  en: {
5566
5773
  title: "Actions",
5567
5774
  hint: "runtime registry \xB7 read-only",
5568
- switchHint: "The agent switch is stored locally and applies immediately; UI actions are unaffected.",
5569
- hostHint: "Agent switch for host actions; items marked UI-only (security) cannot be opened up.",
5570
- agentSwitch: "Agent callable",
5571
- agentLocked: "UI only \xB7 security",
5572
- agentLockedHint: "This action can only run from the UI (security constraint); the agent switch cannot be opened",
5573
- agentSaving: "Saving\u2026",
5574
- agentOnToast: "Agent calls allowed",
5575
- agentOffToast: "Agent calls blocked",
5576
- agentFail: "Failed to change the agent switch",
5775
+ switchHint: "Allowed origins are stored locally and apply immediately: only checked origins may call the action; others get ACTION_ORIGIN_DENIED.",
5776
+ hostHint: "Allowed origins for host actions; items marked pinned cannot be changed.",
5777
+ originsLabel: "Origins",
5778
+ originUi: "UI",
5779
+ originPlugin: "Plugin",
5780
+ originAgent: "Agent",
5781
+ originSync: "Sync",
5782
+ originsSaving: "Saving\u2026",
5783
+ originsToast: "Allowed origins updated",
5784
+ originsFail: "Failed to update allowed origins",
5785
+ originsEmpty: "Keep at least one origin",
5786
+ originsUnsupported: "This action does not support this origin",
5787
+ originsPinned: "Pinned",
5788
+ originsPinnedHint: "Allowed origins are pinned for this action (security constraint) and cannot be changed",
5789
+ originsDefaultOn: "Allowed by default",
5790
+ originsDefaultOff: "Off by default, can be enabled",
5577
5791
  domain: "Domain",
5578
5792
  versionLabel: "Version",
5579
5793
  shell: "Host",
@@ -5587,6 +5801,8 @@ var require_action_schema_view = __commonJS({
5587
5801
  onlyOptional: "No required",
5588
5802
  filterType: "Param type",
5589
5803
  allTypes: "All types",
5804
+ filterOrigin: "Origins",
5805
+ allOrigins: "All origins",
5590
5806
  colName: "Param",
5591
5807
  colType: "Type",
5592
5808
  colReq: "Required",
@@ -5730,6 +5946,8 @@ var require_action_schema_view = __commonJS({
5730
5946
  var reqMode = reqState[0], setReqMode = reqState[1];
5731
5947
  var typeState = React.useState("");
5732
5948
  var typePick = typeState[0], setTypePick = typeState[1];
5949
+ var originFilterState = React.useState("");
5950
+ var originPick = originFilterState[0], setOriginPick = originFilterState[1];
5733
5951
  var toastState = React.useState("");
5734
5952
  var toast = toastState[0], setToast = toastState[1];
5735
5953
  var savingState = React.useState("");
@@ -5785,38 +6003,53 @@ var require_action_schema_view = __commonJS({
5785
6003
  plainCopy(text);
5786
6004
  done();
5787
6005
  }
5788
- function setAgent(action, next) {
6006
+ var ORIGINS = ["ui", "plugin", "agent", "sync"];
6007
+ var originText = { ui: t.originUi, plugin: t.originPlugin, agent: t.originAgent, sync: t.originSync };
6008
+ function setOrigins(action, origin) {
5789
6009
  var name = action.name;
6010
+ var current = Array.isArray(action.origins) ? action.origins.slice() : [];
6011
+ var index = current.indexOf(origin);
6012
+ var next = index >= 0 ? current.filter(function(o) {
6013
+ return o !== origin;
6014
+ }) : current.concat([origin]);
6015
+ if (next.length === 0) {
6016
+ setToast(t.originsEmpty);
6017
+ return;
6018
+ }
6019
+ next = ORIGINS.filter(function(o) {
6020
+ return next.indexOf(o) >= 0;
6021
+ });
5790
6022
  setSaving(name);
5791
6023
  setToast("");
5792
6024
  var fail = function(e) {
5793
6025
  setSaving("");
5794
- setToast(t.agentFail + "\uFF1A" + String(e && e.message || e || ""));
6026
+ setToast(t.originsFail + "\uFF1A" + String(e && e.message || e || ""));
5795
6027
  };
5796
6028
  var done = function(r) {
5797
6029
  setSaving("");
5798
6030
  var payload = r && typeof r === "object" && Object.prototype.hasOwnProperty.call(r, "result") ? r.result : r;
5799
6031
  if (r && r.ok === false) {
5800
- setToast(t.agentFail + "\uFF1A" + String(r.error || r.text || ""));
6032
+ setToast(t.originsFail + "\uFF1A" + String(r.error || r.text || ""));
5801
6033
  return;
5802
6034
  }
5803
- var value = payload && typeof payload.agentEnabled === "boolean" ? payload.agentEnabled : next;
6035
+ var value = payload && Array.isArray(payload.origins) ? payload.origins : next;
6036
+ var source = payload && typeof payload.source === "string" ? payload.source : action.originsSource;
5804
6037
  setSnap(function(prev) {
5805
6038
  if (!prev || !Array.isArray(prev.actions)) return prev;
5806
6039
  return Object.assign({}, prev, {
5807
6040
  actions: prev.actions.map(function(a) {
5808
6041
  if (!a || a.name !== name) return a;
5809
- return Object.assign({}, a, { agentEnabled: value });
6042
+ return Object.assign({}, a, { origins: value, originsSource: source });
5810
6043
  })
5811
6044
  });
5812
6045
  });
5813
- setToast(value ? t.agentOnToast : t.agentOffToast);
6046
+ setToast(t.originsToast);
5814
6047
  };
5815
6048
  if (!api || typeof api.call !== "function") {
5816
6049
  fail(new Error("no call api"));
5817
6050
  return;
5818
6051
  }
5819
- Promise.resolve(api.call("actions.setAgentAccess", { action: name, agentEnabled: next })).then(done, fail);
6052
+ Promise.resolve(api.call("actions.setActionOrigins", { action: name, origins: next })).then(done, fail);
5820
6053
  }
5821
6054
  var all = snap && Array.isArray(snap.actions) ? snap.actions.filter(function(a) {
5822
6055
  return a && a.domain === DOMAIN;
@@ -5851,6 +6084,7 @@ var require_action_schema_view = __commonJS({
5851
6084
  if (typePick && !rows.some(function(row) {
5852
6085
  return row.types.indexOf(typePick) >= 0;
5853
6086
  })) return false;
6087
+ if (originPick && (!Array.isArray(a.origins) || a.origins.indexOf(originPick) < 0)) return false;
5854
6088
  return true;
5855
6089
  });
5856
6090
  function paramRow(row) {
@@ -5866,33 +6100,45 @@ var require_action_schema_view = __commonJS({
5866
6100
  h("td", null, Highlight.hit(row.description, kw))
5867
6101
  );
5868
6102
  }
5869
- function agentSwitch(action) {
5870
- if (action.agentLocked === true) {
5871
- return h("span", {
5872
- className: P + "-badge " + P + "-locked",
5873
- title: t.agentLockedHint,
5874
- "data-agent-locked": action.name
5875
- }, t.agentLocked);
6103
+ function originsChips(action) {
6104
+ if (!Array.isArray(action.origins)) return null;
6105
+ if (action.originsSource === "invalid") {
6106
+ return h("span", { className: P + "-badge " + P + "-locked", title: t.originsPinnedHint, "data-origins-invalid": action.name }, t.originsPinned);
5876
6107
  }
5877
- if (typeof action.agentEnabled !== "boolean") return null;
5878
6108
  var busy = saving === action.name;
6109
+ var pinned = action.name === "actions.setActionOrigins";
6110
+ var supported = Array.isArray(action.originsDeclared) ? action.originsDeclared : action.origins;
5879
6111
  return h(
5880
- "button",
5881
- {
5882
- className: P + "-toggle",
5883
- "data-agent-row": action.name,
5884
- type: "button",
5885
- role: "switch",
5886
- "aria-checked": action.agentEnabled,
5887
- disabled: busy,
5888
- "data-agent-toggle": action.name,
5889
- "aria-label": t.agentSwitch + " \xB7 " + action.name,
5890
- onClick: function() {
5891
- setAgent(action, !action.agentEnabled);
5892
- }
5893
- },
5894
- h("span", { className: P + "-track", "aria-hidden": true }),
5895
- h("span", null, busy ? t.agentSaving : t.agentSwitch)
6112
+ "div",
6113
+ { className: P + "-origins", "data-origins-row": action.name },
6114
+ h("span", { className: P + "-origins-label" }, t.originsLabel),
6115
+ ORIGINS.map(function(origin) {
6116
+ var on = action.origins.indexOf(origin) >= 0;
6117
+ var allowed = supported.indexOf(origin) >= 0;
6118
+ var preset = Array.isArray(action.originsDefault) ? action.originsDefault : supported;
6119
+ var byDefault = preset.indexOf(origin) >= 0;
6120
+ return h(
6121
+ "label",
6122
+ {
6123
+ key: origin,
6124
+ className: P + "-origin" + (allowed ? "" : " " + P + "-origin-off"),
6125
+ title: pinned ? t.originsPinnedHint : !allowed ? t.originsUnsupported : originText[origin] + " \xB7 " + action.name + " \xB7 " + (byDefault ? t.originsDefaultOn : t.originsDefaultOff)
6126
+ },
6127
+ h("input", {
6128
+ type: "checkbox",
6129
+ checked: on,
6130
+ disabled: busy || pinned || !allowed,
6131
+ "data-origin": origin,
6132
+ "data-origin-row": action.name,
6133
+ "data-origin-supported": allowed ? "1" : "0",
6134
+ onChange: function() {
6135
+ setOrigins(action, origin);
6136
+ }
6137
+ }),
6138
+ h("span", null, originText[origin])
6139
+ );
6140
+ }),
6141
+ busy ? h("span", { className: P + "-origins-label" }, t.originsSaving) : null
5896
6142
  );
5897
6143
  }
5898
6144
  function card(action) {
@@ -5913,7 +6159,7 @@ var require_action_schema_view = __commonJS({
5913
6159
  return row.required;
5914
6160
  }) ? h("span", { className: P + "-badge " + P + "-req" }, t.required) : null
5915
6161
  ),
5916
- agentSwitch(action)
6162
+ originsChips(action)
5917
6163
  ),
5918
6164
  action.description ? h("p", { className: P + "-desc" }, Highlight.hit(action.description, kw)) : null,
5919
6165
  rows.length ? h(
@@ -6036,6 +6282,21 @@ var require_action_schema_view = __commonJS({
6036
6282
  return h("option", { value: name, key: name }, name);
6037
6283
  })
6038
6284
  )
6285
+ ),
6286
+ h(
6287
+ "label",
6288
+ { className: P + "-none" },
6289
+ t.filterOrigin + " ",
6290
+ h(
6291
+ "select",
6292
+ { value: originPick, "aria-label": t.filterOrigin, "data-origin-filter": "", onChange: function(e) {
6293
+ setOriginPick(e.target.value);
6294
+ } },
6295
+ h("option", { value: "" }, t.allOrigins),
6296
+ ORIGINS.map(function(origin) {
6297
+ return h("option", { value: origin, key: origin }, originText[origin]);
6298
+ })
6299
+ )
6039
6300
  )
6040
6301
  ) : null,
6041
6302
  body,
@@ -6129,7 +6390,6 @@ var require_copy = __commonJS({
6129
6390
  nodeDescPh: "\u5199\u6E05\u8FD9\u5F20\u8868\u662F\u505A\u4EC0\u4E48\u7684\uFF0C\u4EE5\u540E\u53EF\u6309\u63CF\u8FF0\u5173\u952E\u8BCD\u68C0\u7D22\u5B9A\u4F4D",
6130
6391
  needName: "\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A",
6131
6392
  nodeDescSave: "\u63CF\u8FF0\u5DF2\u4FDD\u5B58",
6132
- editTitle: "\u7F16\u8F91\u4EFB\u52A1",
6133
6393
  deleteConfirm: "\u786E\u5B9A\u5220\u9664\u8FD9\u4E2A\u8282\u70B9\u53CA\u5176\u5B50\u6811\uFF1F\u5B50\u6811\u4E2D\u7684\u4EFB\u52A1\u4F1A\u88AB\u8F6F\u5220\u9664\u3002",
6134
6394
  deleteTaskConfirm: "\u786E\u5B9A\u5220\u9664\u8FD9\u6761\u4EFB\u52A1\u5417\uFF1F\u5220\u9664\u540E\u4E0D\u53EF\u6062\u590D\u3002",
6135
6395
  batchDelete: "\u6279\u91CF\u5220\u9664",
@@ -6296,7 +6556,6 @@ var require_copy = __commonJS({
6296
6556
  nodeDescPh: "Say what this table is for; agents can find it by description keywords",
6297
6557
  needName: "Name is required",
6298
6558
  nodeDescSave: "Description saved",
6299
- editTitle: "Edit task",
6300
6559
  deleteConfirm: "Delete this node and its subtree? Tasks under it will be soft-deleted.",
6301
6560
  deleteTaskConfirm: "Delete this task? This cannot be undone.",
6302
6561
  batchDelete: "Delete",
@@ -7652,6 +7911,7 @@ var require_icons2 = __commonJS({
7652
7911
  tag: (init_tag(), __toCommonJS(tag_exports)).default,
7653
7912
  clock: (init_clock(), __toCommonJS(clock_exports)).default,
7654
7913
  refresh: (init_refresh_cw(), __toCommonJS(refresh_cw_exports)).default
7914
+ // 「原邮件」回链:从邮件建出来的任务要能跳回去看一眼原文。
7655
7915
  }, {});
7656
7916
  module2.exports = { ICONS: set.ICONS, Icon: set.Icon };
7657
7917
  }
@@ -8796,7 +9056,7 @@ var require_styles = __commonJS({
8796
9056
  ".wbt-body{display:flex;gap:14px;align-items:stretch;min-height:0;flex:1;overflow:hidden}",
8797
9057
  ".wbt-filter-panel{flex:0 0 248px;width:248px;min-width:0;max-height:100%;overflow-y:auto;overscroll-behavior:contain;border:1px solid var(--wbt-line);border-radius:10px;background:var(--wbt-bg);box-sizing:border-box;padding:12px}",
8798
9058
  ".wbt-filter-content{display:flex;flex-direction:column;gap:12px}.wbt-filter-toggle{display:none}.wbt-filter-group{display:flex;flex-direction:column;gap:8px;min-width:0;margin:0;padding:10px 0;border:0;border-bottom:1px solid var(--wbt-line)}.wbt-filter-group legend{font-weight:600;padding:0}.wbt-filter-search{display:flex;gap:4px}.wbt-filter-search input{width:100%;min-width:0}.wbt-filter-panel .wbt-check{white-space:normal}.wbt-filter-panel .wbt-tagmenu{position:static;width:100%;box-sizing:border-box;max-height:240px}.wbt-filter-panel .wbt-tagfilter{flex-wrap:wrap}.wbt-filter-panel input:disabled{opacity:.45;cursor:not-allowed}.wbt-filter-panel .wbt-mhint{margin:0;line-height:1.6}.wbt-filter-panel .wbt-field input{width:100%;box-sizing:border-box}",
8799
- ".wbt-limit-row{display:flex;flex-direction:column;gap:4px;min-width:0}.wbt-limit-head{display:flex;align-items:baseline;gap:6px;flex-wrap:wrap;min-width:0}.wbt-limit-hint{margin:0;font-size:11.5px;line-height:1.6;opacity:.65;overflow-wrap:anywhere}.wbt-limit-head>strong{font-weight:560;font-size:12.5px;flex:none}.wbt-limit-fields{display:flex;align-items:center;gap:4px;min-width:0}.wbt-limit-fields input{flex:1 1 0;width:0;min-width:0;box-sizing:border-box;text-align:center;padding-left:6px;padding-right:6px}.wbt-limit-fields .wbt-limit-input{background-color:var(--wbt-surface);border:1px solid var(--wbt-line);border-radius:8px;padding:6px 4px;font-size:13px;color:inherit;font-variant-numeric:tabular-nums;-moz-appearance:textfield;appearance:textfield}.wbt-limit-fields .wbt-limit-input:focus{border-color:var(--wbt-accent);outline:none;box-shadow:0 0 0 3px color-mix(in oklab,var(--wbt-accent) 18%,transparent)}.wbt-limit-fields .wbt-limit-input::-webkit-outer-spin-button,.wbt-limit-fields .wbt-limit-input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}.wbt-limit-fields>span{flex:none;opacity:.55;font-size:11.5px}.wbt-limit-clear{flex:none;padding:2px 6px;line-height:1.2}.wbt-limit-unit{font-size:11px;opacity:.55;overflow-wrap:anywhere;min-width:0}",
9059
+ ".wbt-limit-row{display:flex;flex-direction:column;gap:4px;min-width:0}.wbt-limit-head{display:flex;align-items:baseline;gap:6px;flex-wrap:wrap;min-width:0}.wbt-limit-hint{margin:0;font-size:11.5px;line-height:1.6;opacity:.65;overflow-wrap:anywhere}.wbt-limit-head>strong{font-weight:560;font-size:12.5px;flex:none}.wbt-limit-fields{display:flex;align-items:flex-start;gap:4px;min-width:0}.wbt-limit-fields .wbctl-num{flex:1 1 0;min-width:0;width:0}.wbt-limit-fields .wbctl-num-box{width:100%}.wbt-limit-fields .wbctl-num-input{width:100%;box-sizing:border-box;text-align:center;padding:6px 4px;border-radius:8px;border-color:var(--wbt-line);background-color:var(--wbt-surface)}.wbt-limit-fields>span{flex:none;opacity:.55;font-size:11.5px}.wbt-limit-fields .wbt-limit-join{padding-top:7px}.wbt-limit-fields .wbt-limit-clear{margin-top:1px}.wbt-limit-clear{flex:none;padding:2px 6px;line-height:1.2}.wbt-limit-fields .wbctl-num-err{overflow-wrap:anywhere}.wbt-limit-unit{font-size:11px;opacity:.55;overflow-wrap:anywhere;min-width:0}",
8800
9060
  ".wbt-presets{gap:6px}.wbt-preset-list{display:flex;flex-wrap:wrap;gap:6px}.wbt-preset{padding:4px 9px;border:1px solid var(--wbt-line);border-radius:999px;background:var(--wbt-surface);color:inherit;font-size:12px;line-height:1.5;white-space:normal}.wbt-preset:hover{border-color:var(--wbt-accent)}.wbt-preset.active{background:var(--wbt-accent);border-color:var(--wbt-accent);color:#fff}.wbt-preset:focus-visible{outline:2px solid var(--wbt-accent);outline-offset:2px}.wbt-target-group{gap:8px}",
8801
9061
  ".wbt-status-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px 8px}.wbt-status-grid .wbt-check{min-width:0;overflow-wrap:anywhere}.wbt-pathrow>.wbt-sum{flex:none;white-space:nowrap}",
8802
9062
  ".wbt-nav{display:flex;flex-direction:column;gap:2px;flex:0 0 138px;width:138px;padding:3px 0;border-right:1px solid var(--wbt-line)}",
@@ -8971,7 +9231,7 @@ var require_styles = __commonJS({
8971
9231
  ".wbt-create-tl .wbt-timeline-picker{display:flex;flex-direction:column;gap:6px;min-width:0}",
8972
9232
  ".wbt-create-tl .wbt-picker-list{max-height:180px;scrollbar-gutter:stable}",
8973
9233
  ".wbt-create-tl .wbt-timeline-pager{margin-top:4px;font-size:11.5px}",
8974
- ".wbt-field>span{opacity:.62;font-size:11.5px}",
9234
+ ".wbt-field>span{opacity:.62;font-size:11.5px}.wbt-field>span.wbctl-num{opacity:1;font-size:12px;align-self:stretch}.wbt-field .wbt-difficulty-num{width:110px}",
8975
9235
  ".wbt-modal-foot{display:flex;gap:8px;justify-content:flex-end;align-items:center;margin-top:2px}",
8976
9236
  // 预览面板:只让内容区滚动,头部标题与右上角 × 固定不动(滚动壳限定在 .wbt-preview,不影响其它弹窗)。
8977
9237
  ".wbt-preview{overflow:hidden}",
@@ -9030,8 +9290,23 @@ var require_styles = __commonJS({
9030
9290
  ".wbt-countdown.overdue{color:var(--dsw-alias-label-primary-inverted,#fff);background:var(--dsw-alias-state-error-primary,#e5484d);border-color:transparent}",
9031
9291
  "@media (max-width:760px){.wbt-body{flex-direction:column;gap:8px}.wbt-nav{flex-direction:row;width:100%;flex:0 0 auto;overflow-x:auto;border-right:none;border-bottom:1px solid var(--wbt-line);padding:0 0 6px}.wbt-tab{width:auto;white-space:nowrap;padding:6px 9px}.wbt-tab.on{box-shadow:inset 0 -2px 0 var(--wbt-accent)}.wbt-nav-sep{width:1px;height:18px;flex:none;margin:auto 4px}.wbt-tree-slot{flex:0 0 auto;width:auto;margin-right:0}.wbt-pathrow .wbt-search{flex:1 1 160px;max-width:none}}",
9032
9292
  "@media (max-width:760px){.wbt-filter-panel{width:100%;flex:0 0 auto;padding:8px;max-height:40%}.wbt-filter-toggle{display:inline-flex}.wbt-filter-panel:not(.expanded) .wbt-filter-content{display:none}.wbt-filter-panel.expanded .wbt-filter-content{padding-top:10px}.wbt-content{width:100%;box-sizing:border-box}}",
9033
- "@media (max-width:640px){.wbt-form{grid-template-columns:1fr}.wbt-drawer{width:94vw}.wbt-search{width:100%}.wbt-item{padding:9px}.wbt-ops{width:100%;justify-content:flex-end}}"
9034
- ].concat(require_filter_checklist_styles(), require_date_picker_styles()("wbt")).join("\n");
9293
+ "@media (max-width:640px){.wbt-form{grid-template-columns:1fr}.wbt-drawer{width:94vw}.wbt-search{width:100%}.wbt-item{padding:9px}.wbt-ops{width:100%;justify-content:flex-end}}",
9294
+ // ── 插槽贡献:渲染在别的插件的界面里(如邮件详情动作条) ──
9295
+ // 那里没有 .wbt-root,--wbt-* 变量不存在,所以每个变量都带主题变量兜底。
9296
+ ".wbt-metazone:empty{display:none}",
9297
+ ".wbtx-slot{position:relative;display:inline-flex;align-items:center;gap:6px}",
9298
+ ".wbtx-slot-btn{font-size:12.5px;white-space:nowrap}",
9299
+ ".wbtx-slot-btn[aria-expanded=true]{border-color:var(--wbt-accent,var(--wb-accent));color:var(--wbt-accent,var(--wb-accent))}",
9300
+ ".wbtx-slot-panel{position:absolute;top:calc(100% + 6px);right:0;z-index:40;display:flex;flex-direction:column;gap:8px;width:264px;padding:10px;border-radius:10px;border:1px solid var(--wbt-line,var(--wb-border));background:var(--dsw-alias-bg-layer-1,var(--wb-card,transparent));box-shadow:0 12px 28px color-mix(in oklab,var(--wbt-line,var(--wb-border)) 60%,transparent);text-align:left}",
9301
+ ".wbtx-slot-row{display:flex;flex-direction:column;gap:4px;font-size:11.5px;color:var(--wbt-muted,var(--wb-muted))}",
9302
+ ".wbtx-slot-input{width:100%;box-sizing:border-box;font-size:12.5px}",
9303
+ ".wbtx-slot-muted{font-size:12px;color:var(--wbt-muted,var(--wb-muted))}",
9304
+ ".wbtx-slot-foot{display:flex;justify-content:flex-end;gap:8px}",
9305
+ ".wbtx-slot-done{display:inline-flex;align-items:center;gap:8px;font-size:12px}",
9306
+ ".wbtx-slot-note{color:var(--wbt-muted,var(--wb-muted))}",
9307
+ ".wbtx-slot-link{border:0;background:transparent;padding:0;font:inherit;font-size:12px;color:var(--wbt-accent,var(--wb-accent));cursor:pointer;text-decoration:underline}",
9308
+ ".wbt-mailback{font-size:11.5px;padding:2px 7px}"
9309
+ ].concat(require_filter_checklist_styles(), require_date_picker_styles()("wbt"), require_switch().styles, require_number_field().styles).join("\n");
9035
9310
  }
9036
9311
  });
9037
9312
 
@@ -9048,12 +9323,12 @@ var require_timeline_styles = __commonJS({
9048
9323
  ".wbt-timeline-toolbar-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-left:auto}",
9049
9324
  ".wbt-timeline-columns{display:grid;grid-template-columns:minmax(240px,32%) minmax(0,1fr);gap:12px;align-items:start}",
9050
9325
  ".wbt-timeline-left,.wbt-timeline-right{min-width:0;border:1px solid var(--wbt-line);border-radius:var(--wb-radius-card,10px);padding:12px}",
9051
- ".wbt-timeline-single{display:flex;align-items:center;gap:8px;margin:0;font-size:13px;white-space:nowrap}.wbt-timeline-search input{min-width:0;flex:1}",
9326
+ ".wbt-timeline-search input{min-width:0;flex:1}",
9052
9327
  ".wbt-timeline-list{max-height:840px;overflow:auto;overscroll-behavior:contain}.wbt-timeline-left>.wbt-timeline-list,.wbt-timeline-left>.wbt-err{margin-top:2px}.wbt-timeline-view .wbt-timeline-option{position:relative;box-sizing:border-box;min-height:56px;padding:10px 12px;border:0;border-bottom:1px solid var(--wbt-line);border-radius:var(--wb-radius-sm,6px);display:flex;flex-direction:column;gap:4px;cursor:pointer;color:inherit;background:transparent;background-image:none}",
9053
9328
  ".wbt-timeline-option-title{display:flex;gap:8px;align-items:center;min-width:0}.wbt-timeline-option-title strong{font-size:13px;font-weight:560;line-height:1.4;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;overflow-wrap:anywhere}.wbt-timeline-option>span{font-size:11.5px;opacity:.6;font-variant-numeric:tabular-nums;overflow-wrap:anywhere}",
9054
9329
  ".wbt-timeline-option>.wbt-timeline-excerpt{display:block;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}",
9055
9330
  ".wbt-timeline-view .wbt-timeline-option.current{box-shadow:inset 3px 0 var(--wbt-accent),inset 0 0 0 1px var(--wbt-line);background:color-mix(in oklab,var(--wbt-accent) 8%,transparent);background-image:none}.wbt-timeline-view .wbt-timeline-option:hover{background:color-mix(in oklab,var(--wbt-accent) 12%,transparent)}",
9056
- ".wbt-timeline-option:focus-visible,.wbt-timeline-view button:focus-visible,.wbt-timeline-modal button:focus-visible{outline:2px solid var(--wbt-accent);outline-offset:2px}.wbt-timeline-option input[type=checkbox],.wbt-timeline-single input{appearance:auto;width:15px;height:15px;flex:none;accent-color:var(--wbt-accent)}",
9331
+ ".wbt-timeline-option:focus-visible,.wbt-timeline-view button:focus-visible,.wbt-timeline-modal button:focus-visible{outline:2px solid var(--wbt-accent);outline-offset:2px}.wbt-timeline-option input[type=checkbox]{appearance:auto;width:15px;height:15px;flex:none;accent-color:var(--wbt-accent)}",
9057
9332
  ".wbt-timeline-pager{justify-content:space-between;font-size:12px;margin-top:12px}.wbt-timeline-right h3,.wbt-timeline-summary h4{font-size:15px;font-weight:600;margin:0 0 8px;overflow-wrap:anywhere}.wbt-timeline-eyebrow{font-size:11.5px;opacity:.55;margin-bottom:4px;overflow-wrap:anywhere}",
9058
9333
  ".wbt-timeline-summary{min-width:0}.wbt-timeline-desc{max-height:64px;overflow:hidden;margin:0 0 8px;white-space:pre-wrap;overflow-wrap:anywhere}.wbt-timeline-actions{margin:8px 0}.wbt-timeline-actions>.wbt-act-del{margin-left:auto}",
9059
9334
  ".wbt-timeline-right>.wbt-timeline-members{min-height:0;max-height:65vh;overflow-y:auto;overscroll-behavior-y:contain;scrollbar-gutter:stable}",
@@ -9071,6 +9346,27 @@ var require_timeline_styles = __commonJS({
9071
9346
  }
9072
9347
  });
9073
9348
 
9349
+ // packages/addons/tasks/client/ui/inject-css.cjs
9350
+ var require_inject_css = __commonJS({
9351
+ "packages/addons/tasks/client/ui/inject-css.cjs"(exports2, module2) {
9352
+ "use strict";
9353
+ var CSS = require_styles() + "\n" + require_timeline_styles();
9354
+ module2.exports = function injectTasksCss() {
9355
+ if (typeof document === "undefined") return;
9356
+ var old = document.getElementById("wb-addon-tasks-v2-css");
9357
+ if (old) {
9358
+ old.textContent = CSS;
9359
+ return;
9360
+ }
9361
+ var s = document.createElement("style");
9362
+ s.id = "wb-addon-tasks-v2-css";
9363
+ s.setAttribute("data-wb-addon", "wb-addon-tasks");
9364
+ s.textContent = CSS;
9365
+ document.head.appendChild(s);
9366
+ };
9367
+ }
9368
+ });
9369
+
9074
9370
  // packages/addons/tasks/client/ui/highlight.cjs
9075
9371
  var require_highlight2 = __commonJS({
9076
9372
  "packages/addons/tasks/client/ui/highlight.cjs"(exports2, module2) {
@@ -9093,6 +9389,7 @@ var require_task_item = __commonJS({
9093
9389
  var statusInfo = deps.statusInfo, stars = deps.stars, pClass = deps.pClass;
9094
9390
  var today = deps.today, daysBetween = deps.daysBetween, cx = deps.cx;
9095
9391
  var Icon2 = deps.Icon, Countdown = deps.Countdown, PathCrumbs = deps.PathCrumbs;
9392
+ var Slot = deps.Slot;
9096
9393
  function TaskItem(props) {
9097
9394
  var t = props.t;
9098
9395
  var initialMode = props.bodyMode === "text" ? "text" : "markdown";
@@ -9208,13 +9505,25 @@ var require_task_item = __commonJS({
9208
9505
  );
9209
9506
  var opsNode = h("div", { className: "wbt-ops", key: "ops" }, ops);
9210
9507
  var tagBlock = tagNodes.length ? h("div", { className: "wbt-tags", key: "tags" }, tagNodes) : null;
9508
+ var sourceBlock = h(Slot, {
9509
+ slot: "item.actions",
9510
+ ownerId: "wb-addon-tasks",
9511
+ lang: props.lang,
9512
+ key: "source",
9513
+ item: {
9514
+ kind: "task",
9515
+ id: String(task.id || ""),
9516
+ title: String(task.title || ""),
9517
+ description: String(task.description || "")
9518
+ }
9519
+ });
9211
9520
  var wsList = Array.isArray(task.workspaces) ? task.workspaces : [];
9212
9521
  var wsBlock = wsList.length ? h("div", { className: "wbt-wschips", key: "workspaces" }, wsList.map(function(w) {
9213
9522
  return h("span", { className: "wbt-wschip wbt-wschip-ro", key: String(w.id), title: w.dir || "" }, (w.dir ? "" : "\u25E6 ") + (w.title || w.id));
9214
9523
  })) : null;
9215
9524
  var metaBlock = meta.length ? h("div", { className: "wbt-foot", key: "meta" }, h("div", { className: "wbt-meta" }, meta)) : null;
9216
9525
  var pathBlock = task.path && task.path.length ? h("div", { className: "wbt-taskpath", key: "path" }, h(PathCrumbs, { path: task.path, t, onPick: props.onPathPick })) : null;
9217
- var metaZone = tagBlock || wsBlock || metaBlock || pathBlock ? h("div", { className: "wbt-metazone", key: "metazone" }, tagBlock, wsBlock, metaBlock, pathBlock) : null;
9526
+ var metaZone = tagBlock || sourceBlock || wsBlock || metaBlock || pathBlock ? h("div", { className: "wbt-metazone", key: "metazone" }, tagBlock, sourceBlock, wsBlock, metaBlock, pathBlock) : null;
9218
9527
  var idNode = String(task.id || "") ? h("div", {
9219
9528
  className: "wbt-item-id",
9220
9529
  key: "taskid",
@@ -9672,32 +9981,37 @@ var require_workspace_select = __commonJS({
9672
9981
  var require_difficulty_field = __commonJS({
9673
9982
  "packages/addons/tasks/client/item/difficulty-field.cjs"(exports2, module2) {
9674
9983
  "use strict";
9984
+ var NF = require_number_field();
9675
9985
  module2.exports = function(React) {
9676
9986
  var h = React.createElement;
9677
- return function difficultyField(t, value, onChange, id) {
9987
+ return function difficultyField(t, value, onChange, id, lang) {
9678
9988
  var n = Number(value) || 0, full = Math.floor(n), half = n - full >= 0.5;
9679
9989
  var stars = "\u2605".repeat(full) + (half ? "\u2BEA" : "") + "\u2606".repeat(Math.max(0, 5 - full - (half ? 1 : 0)));
9680
9990
  return h(
9681
9991
  "div",
9682
9992
  { className: "wbt-field full" },
9683
- h("label", { htmlFor: id }, t.difficulty + " (0\u20135)"),
9993
+ h("span", { className: "wbt-field-label" }, t.difficulty + " (0\u20135)"),
9684
9994
  h(
9685
9995
  "div",
9686
9996
  { className: "wbt-row" },
9687
- h("input", {
9688
- id,
9689
- className: "wbt-input",
9690
- type: "number",
9997
+ h(NF.NumberField, {
9998
+ h,
9999
+ lang,
10000
+ value,
9691
10001
  min: 0,
9692
10002
  max: 5,
9693
10003
  step: 0.5,
9694
- "aria-label": t.difficulty,
9695
- "aria-describedby": id + "-hint",
10004
+ allowEmpty: true,
10005
+ ariaLabel: t.difficulty,
9696
10006
  placeholder: t.difficultyUnsetHint,
9697
- value,
9698
- onChange: function(e) {
9699
- var raw = e.target.value;
9700
- onChange(raw === "" ? "" : Math.max(0, Math.min(5, Number(raw) || 0)));
10007
+ hint: false,
10008
+ className: "wbt-difficulty-num",
10009
+ // 键入期同步草稿,让 ★ 预览即时更新;提交只在失焦/回车且合法时发生。
10010
+ onDraft: function(raw) {
10011
+ onChange(raw);
10012
+ },
10013
+ onCommit: function(next) {
10014
+ onChange(next === null ? "" : String(next));
9701
10015
  }
9702
10016
  }),
9703
10017
  h("span", { className: "wbt-stars", "aria-hidden": true }, n > 0 ? stars : t.difficultyUnset),
@@ -9928,6 +10242,7 @@ var require_ownership_fields = __commonJS({
9928
10242
  "use strict";
9929
10243
  var limits = require_limits();
9930
10244
  var ownership = require_ownership();
10245
+ var SW = require_switch();
9931
10246
  module2.exports = function(React) {
9932
10247
  var h = React.createElement;
9933
10248
  var Picker = require_table_picker()(React);
@@ -9981,14 +10296,14 @@ var require_ownership_fields = __commonJS({
9981
10296
  "div",
9982
10297
  { className: "wbt-field full" },
9983
10298
  h(Selection, { form, set, tree: props.tree, recommended: props.recommended, edit: props.edit, current: props.current, currentId: props.currentId }),
9984
- !props.edit ? h("label", { className: "wbt-check" }, h("input", {
9985
- type: "checkbox",
9986
- "aria-label": "\u6CA1\u6709\u5408\u9002\u7684\u8868\uFF1F\u65B0\u5EFA\u8282\u70B9",
10299
+ !props.edit ? h(SW.Switch, {
10300
+ h,
9987
10301
  checked: !!form.newPath,
9988
- onChange: function(e) {
9989
- props.setMany({ newPath: e.target.checked, tableId: "", confirmed: false });
10302
+ label: "\u6CA1\u6709\u5408\u9002\u7684\u8868\uFF1F\u65B0\u5EFA\u8282\u70B9",
10303
+ onChange: function(next) {
10304
+ props.setMany({ newPath: next, tableId: "", confirmed: false });
9990
10305
  }
9991
- }), "\u6CA1\u6709\u5408\u9002\u7684\u8868\uFF1F\u65B0\u5EFA\u8282\u70B9") : null,
10306
+ }) : null,
9992
10307
  form.newPath ? h(
9993
10308
  "div",
9994
10309
  null,
@@ -10021,15 +10336,15 @@ var require_ownership_fields = __commonJS({
10021
10336
  );
10022
10337
  }),
10023
10338
  plan.error ? h("div", { className: "wbt-err", role: "alert" }, plan.error) : null,
10024
- h("label", { className: "wbt-check" }, h("input", {
10025
- type: "checkbox",
10026
- "aria-label": "\u786E\u8BA4\u65B0\u5EFA\u8DEF\u5F84",
10339
+ h(SW.Switch, {
10340
+ h,
10027
10341
  checked: !!form.confirmed,
10028
10342
  disabled: !!plan.error,
10029
- onChange: function(e) {
10030
- set("confirmed", e.target.checked);
10343
+ label: "\u786E\u8BA4\u4EE5\u4E0A\u8DEF\u5F84\u4E0E\u804C\u8D23\uFF0C\u968F\u4EFB\u52A1\u4E00\u8D77\u63D0\u4EA4",
10344
+ onChange: function(next) {
10345
+ set("confirmed", next);
10031
10346
  }
10032
- }), "\u786E\u8BA4\u4EE5\u4E0A\u8DEF\u5F84\u4E0E\u804C\u8D23\uFF0C\u968F\u4EFB\u52A1\u4E00\u8D77\u63D0\u4EA4")
10347
+ })
10033
10348
  ) : null
10034
10349
  );
10035
10350
  };
@@ -10040,16 +10355,13 @@ var require_ownership_fields = __commonJS({
10040
10355
  // packages/addons/tasks/client/modals/create-modal.cjs
10041
10356
  var require_create_modal = __commonJS({
10042
10357
  "packages/addons/tasks/client/modals/create-modal.cjs"(exports2, module2) {
10358
+ var NF = require_number_field();
10043
10359
  function initialPriority(source, origin, fallback) {
10044
10360
  var original = Number(origin && origin.priority);
10045
10361
  if (source === "2" && Number.isInteger(original) && original >= 1 && original <= 10) return original;
10046
10362
  var n = Number(fallback);
10047
10363
  return Number.isFinite(n) ? Math.min(10, Math.max(1, Math.floor(n))) : 1;
10048
10364
  }
10049
- function clampInputPriority(value) {
10050
- if (String(value).trim() === "" || Number(value) === 0 || !Number.isFinite(Number(value))) return value;
10051
- return Math.min(10, Math.max(1, Math.floor(Number(value))));
10052
- }
10053
10365
  function validatePriority(value, source, t) {
10054
10366
  var n = Number(value);
10055
10367
  return String(value).trim() !== "" && Number.isInteger(n) && n >= 1 && n <= 10 ? "" : source === "2" ? t.restartPriorityError : t.activePriorityError;
@@ -10110,6 +10422,7 @@ var require_create_modal = __commonJS({
10110
10422
  }
10111
10423
  var active = source === "2" || form.status === "0";
10112
10424
  var priorityError = active ? validatePriority(form.priority, source, t) : "";
10425
+ var difficultyCheck = NF.validateNumber(form.difficulty, { min: 0, max: 5, step: 0.5, allowEmpty: true, lang: props.lang });
10113
10426
  var plan = ownership.preview(props.tree, form.tablePath, form.pathDescriptions);
10114
10427
  var targetValid = form.newPath ? !plan.error && form.confirmed : tables.some(function(x) {
10115
10428
  return x.id === form.tableId;
@@ -10131,7 +10444,7 @@ var require_create_modal = __commonJS({
10131
10444
  }
10132
10445
  function set(k, v) {
10133
10446
  var next = Object.assign({}, form);
10134
- next[k] = k === "priority" ? clampInputPriority(v) : v;
10447
+ next[k] = v;
10135
10448
  setForm(next);
10136
10449
  }
10137
10450
  function failed(message) {
@@ -10148,6 +10461,10 @@ var require_create_modal = __commonJS({
10148
10461
  }
10149
10462
  function submit() {
10150
10463
  if (priorityError || isBusy || submission.pending) return;
10464
+ if (!difficultyCheck.ok) {
10465
+ setError(difficultyCheck.error);
10466
+ return;
10467
+ }
10151
10468
  if (source === "2" && !(origin && origin.timelineId)) {
10152
10469
  setError(tr("\u8BF7\u5148\u624B\u52A8\u5EFA\u7ACB\u5E76\u5173\u8054\u65F6\u95F4\u7EBF\uFF0C\u518D\u91CD\u542F"));
10153
10470
  return;
@@ -10177,7 +10494,7 @@ var require_create_modal = __commonJS({
10177
10494
  tags: splitTags(form.tags),
10178
10495
  status: source === "2" ? "0" : String(form.status),
10179
10496
  priority: active ? Number(form.priority) : 0,
10180
- difficulty: Number(form.difficulty) || 0,
10497
+ difficulty: difficultyCheck.value || 0,
10181
10498
  publishDate: form.publishDate,
10182
10499
  targetDate: form.targetDate,
10183
10500
  source: source === "2" ? "2" : form.timelineId ? "1" : "0"
@@ -10259,9 +10576,29 @@ var require_create_modal = __commonJS({
10259
10576
  h("option", { value: "2" }, "\u5DF2\u5B8C\u6210"),
10260
10577
  h("option", { value: "1" }, "\u5DF2\u5173\u95ED")
10261
10578
  )),
10262
- h("label", { className: "wbt-field" }, h("span", null, t.priority + "\uFF081\u201310\uFF09"), h("input", { className: "wbt-input", type: "number", min: 1, max: 10, step: 1, disabled: !active, "aria-invalid": !!priorityError, "aria-describedby": priorityError ? "wbt-create-priority-error" : void 0, value: form.priority, onChange: function(e) {
10263
- set("priority", e.target.value);
10264
- } })),
10579
+ h(
10580
+ "div",
10581
+ { className: "wbt-field" },
10582
+ h("span", { className: "wbt-field-label" }, t.priority + "\uFF081\u201310\uFF09"),
10583
+ h(NF.NumberField, {
10584
+ h,
10585
+ lang: props.lang,
10586
+ value: form.priority,
10587
+ min: 1,
10588
+ max: 10,
10589
+ integer: true,
10590
+ disabled: !active,
10591
+ hint: false,
10592
+ ariaLabel: t.priority,
10593
+ // 键入即写入草稿;合法性由下面的 priorityError 实时判定,绝不回写夹取后的值。
10594
+ onDraft: function(raw) {
10595
+ set("priority", raw);
10596
+ },
10597
+ onCommit: function(next) {
10598
+ set("priority", String(next));
10599
+ }
10600
+ })
10601
+ ),
10265
10602
  fields({ form, set, setMany, tree: props.tree, recommended: props.defaultTableId || origin && origin.tableId }),
10266
10603
  h("label", { className: "wbt-field" }, h("span", null, t.publishDate), h(DP.DatePicker, { React, h, prefix: "wbt", lang: props.lang, label: t.publishDate, value: form.publishDate, onChange: function(next) {
10267
10604
  set("publishDate", next);
@@ -10274,7 +10611,7 @@ var require_create_modal = __commonJS({
10274
10611
  } })) : null,
10275
10612
  difficultyField(t, form.difficulty, function(value) {
10276
10613
  set("difficulty", value);
10277
- }, "wbt-create-difficulty"),
10614
+ }, "wbt-create-difficulty", props.lang),
10278
10615
  source !== "2" && form.status === "1" ? h("label", { className: "wbt-field" }, h("span", null, t.shutdownDate), h(DP.DatePicker, { React, h, prefix: "wbt", lang: props.lang, label: t.shutdownDate, value: form.shutdownDate, onChange: function(next) {
10279
10616
  set("shutdownDate", next);
10280
10617
  } })) : null
@@ -10285,7 +10622,7 @@ var require_create_modal = __commonJS({
10285
10622
  "div",
10286
10623
  { className: "wbt-modal-foot" },
10287
10624
  h("button", { className: "wbt-btn ghost", disabled: isBusy, onClick: requestClose }, t.cancel),
10288
- h("button", { className: "wbt-btn primary", disabled: isBusy || !!priorityError || !targetValid || source === "2" && !(origin && origin.timelineId), onClick: submit }, isBusy ? "\u2026" : t.create)
10625
+ h("button", { className: "wbt-btn primary", disabled: isBusy || !!priorityError || !difficultyCheck.ok || !targetValid || source === "2" && !(origin && origin.timelineId), onClick: submit }, isBusy ? "\u2026" : t.create)
10289
10626
  )
10290
10627
  )
10291
10628
  );
@@ -10295,6 +10632,197 @@ var require_create_modal = __commonJS({
10295
10632
  }
10296
10633
  });
10297
10634
 
10635
+ // packages/addons/tasks/client/views/slot-task-from-message.cjs
10636
+ var require_slot_task_from_message = __commonJS({
10637
+ "packages/addons/tasks/client/views/slot-task-from-message.cjs"(exports2, module2) {
10638
+ "use strict";
10639
+ module2.exports = function(deps) {
10640
+ var React = deps.React;
10641
+ var h = React.createElement;
10642
+ var Icon2 = deps.Icon;
10643
+ var injectCss = deps.injectCss;
10644
+ var KIND = "mail.message";
10645
+ function flattenTables(nodes, out) {
10646
+ var list = out || [];
10647
+ (nodes || []).forEach(function(node) {
10648
+ if (!node) return;
10649
+ if (String(node.type) === "1") list.push({ id: String(node.id), name: String(node.name || node.path || node.id) });
10650
+ if (node.children && node.children.length) flattenTables(node.children, list);
10651
+ });
10652
+ return list;
10653
+ }
10654
+ function defaultTitle(item, en) {
10655
+ var subject = String(item && item.title || "").trim();
10656
+ if (subject) return subject;
10657
+ return en ? "Follow up: (no subject)" : "\u8DDF\u8FDB\uFF1A\uFF08\u65E0\u4E3B\u9898\uFF09";
10658
+ }
10659
+ function buildDescription(item, en) {
10660
+ var lines = [en ? "Created from a mail message." : "\u7531\u90AE\u4EF6\u521B\u5EFA\u3002"];
10661
+ if (item.subtitle) lines.push((en ? "From: " : "\u53D1\u4EF6\u4EBA\uFF1A") + item.subtitle);
10662
+ if (item.title) lines.push((en ? "Subject: " : "\u4E3B\u9898\uFF1A") + item.title);
10663
+ lines.push((en ? "Source mail: " : "\u6765\u6E90\u90AE\u4EF6\uFF1A") + "wb-mail:" + item.id);
10664
+ return lines.join("\n");
10665
+ }
10666
+ return function TaskFromMessage(props) {
10667
+ React.useEffect(function() {
10668
+ injectCss();
10669
+ }, []);
10670
+ var item = props.item;
10671
+ var en = props.lang === "en";
10672
+ var api = props.api;
10673
+ var open = React.useState(false);
10674
+ var tables = React.useState(null);
10675
+ var tableId = React.useState("");
10676
+ var title = React.useState("");
10677
+ var busy = React.useState(false);
10678
+ var error = React.useState("");
10679
+ var created = React.useState(null);
10680
+ if (!item || item.kind !== KIND || !item.id) return null;
10681
+ function loadTables() {
10682
+ if (tables[0] !== null) return;
10683
+ tables[1](void 0);
10684
+ api.call("taskNodes.tree").then(function(r) {
10685
+ if (!r || !r.ok) throw new Error(r && r.error || "tree load failed");
10686
+ var list = flattenTables(Array.isArray(r.result) ? r.result : []);
10687
+ tables[1](list);
10688
+ if (list.length === 1) tableId[1](list[0].id);
10689
+ }).catch(function(e) {
10690
+ tables[1]([]);
10691
+ error[1](String(e && e.message || e));
10692
+ });
10693
+ }
10694
+ function toggle() {
10695
+ if (!open[0]) {
10696
+ title[1](defaultTitle(item, en));
10697
+ loadTables();
10698
+ }
10699
+ open[1](!open[0]);
10700
+ }
10701
+ function submit() {
10702
+ if (busy[0]) return;
10703
+ var name = String(title[0] || "").trim();
10704
+ if (!name) {
10705
+ error[1](en ? "Title is required" : "\u6807\u9898\u4E0D\u80FD\u4E3A\u7A7A");
10706
+ return;
10707
+ }
10708
+ if (!tableId[0]) {
10709
+ error[1](en ? "Pick a target table" : "\u8BF7\u9009\u62E9\u76EE\u6807\u8868");
10710
+ return;
10711
+ }
10712
+ busy[1](true);
10713
+ error[1]("");
10714
+ api.call("tasks.create", {
10715
+ title: name,
10716
+ description: buildDescription(item, en),
10717
+ tableId: tableId[0],
10718
+ dedupeKey: KIND + ":" + item.id
10719
+ }).then(function(r) {
10720
+ if (!r || !r.ok) throw new Error(r && r.error || "create failed");
10721
+ created[1](r.result || {});
10722
+ open[1](false);
10723
+ }).catch(function(e) {
10724
+ error[1](String(e && e.message || e));
10725
+ }).finally(function() {
10726
+ busy[1](false);
10727
+ });
10728
+ }
10729
+ if (created[0]) {
10730
+ var task = created[0];
10731
+ var shortId = String(task.id || "").slice(0, 8);
10732
+ return h(
10733
+ "span",
10734
+ { className: "wbtx-slot-done" },
10735
+ h("span", { className: "wbtx-slot-note" }, (en ? "Task created" : "\u5DF2\u5EFA\u4EFB\u52A1") + (shortId ? " \xB7 " + shortId : "")),
10736
+ h("button", {
10737
+ type: "button",
10738
+ className: "wbtx-slot-link",
10739
+ onClick: function(e) {
10740
+ e.stopPropagation();
10741
+ props.onNavigate("tasks");
10742
+ }
10743
+ }, en ? "Open tasks" : "\u53BB\u4EFB\u52A1\u9875")
10744
+ );
10745
+ }
10746
+ var loading = tables[0] === void 0;
10747
+ var options = Array.isArray(tables[0]) ? tables[0] : [];
10748
+ return h(
10749
+ "span",
10750
+ { className: "wbtx-slot" },
10751
+ h("button", {
10752
+ type: "button",
10753
+ className: "wbt-btn wbtx-slot-btn",
10754
+ "aria-expanded": !!open[0],
10755
+ disabled: busy[0],
10756
+ title: en ? "Create a task from this message" : "\u628A\u8FD9\u5C01\u90AE\u4EF6\u53D8\u6210\u4EFB\u52A1",
10757
+ onClick: function(e) {
10758
+ e.stopPropagation();
10759
+ toggle();
10760
+ }
10761
+ }, h(Icon2, { name: "plus", size: 13 }), en ? "New task" : "\u5EFA\u4EFB\u52A1"),
10762
+ open[0] ? h(
10763
+ "span",
10764
+ { className: "wbtx-slot-panel" },
10765
+ h(
10766
+ "label",
10767
+ { className: "wbtx-slot-row" },
10768
+ h("span", null, en ? "Title" : "\u6807\u9898"),
10769
+ h("input", {
10770
+ className: "wbt-input wbtx-slot-input",
10771
+ value: title[0],
10772
+ autoFocus: true,
10773
+ onChange: function(e) {
10774
+ title[1](e.target.value);
10775
+ },
10776
+ onKeyDown: function(e) {
10777
+ if (e.key === "Enter") {
10778
+ e.preventDefault();
10779
+ submit();
10780
+ }
10781
+ if (e.key === "Escape") open[1](false);
10782
+ }
10783
+ })
10784
+ ),
10785
+ h(
10786
+ "label",
10787
+ { className: "wbtx-slot-row" },
10788
+ h("span", null, en ? "Table" : "\u76EE\u6807\u8868"),
10789
+ loading ? h("span", { className: "wbtx-slot-muted" }, en ? "Loading\u2026" : "\u8BFB\u53D6\u4E2D\u2026") : options.length ? h("select", {
10790
+ className: "wbt-input wbtx-slot-input",
10791
+ value: tableId[0],
10792
+ onChange: function(e) {
10793
+ tableId[1](e.target.value);
10794
+ }
10795
+ }, [h("option", { key: "", value: "" }, en ? "Pick a table" : "\u9009\u62E9\u76EE\u6807\u8868")].concat(
10796
+ options.map(function(o) {
10797
+ return h("option", { key: o.id, value: o.id }, o.name);
10798
+ })
10799
+ )) : h("span", { className: "wbtx-slot-muted" }, en ? "No task table yet" : "\u8FD8\u6CA1\u6709\u4EFB\u52A1\u8868")
10800
+ ),
10801
+ error[0] ? h("span", { className: "wbt-err", role: "alert" }, error[0]) : null,
10802
+ h(
10803
+ "span",
10804
+ { className: "wbtx-slot-foot" },
10805
+ h("button", { type: "button", className: "wbt-btn ghost", onClick: function(e) {
10806
+ e.stopPropagation();
10807
+ open[1](false);
10808
+ } }, en ? "Cancel" : "\u53D6\u6D88"),
10809
+ h("button", {
10810
+ type: "button",
10811
+ className: "wbt-btn primary",
10812
+ disabled: busy[0] || loading || !options.length,
10813
+ onClick: function(e) {
10814
+ e.stopPropagation();
10815
+ submit();
10816
+ }
10817
+ }, busy[0] ? "\u2026" : en ? "Create" : "\u521B\u5EFA")
10818
+ )
10819
+ ) : null
10820
+ );
10821
+ };
10822
+ };
10823
+ }
10824
+ });
10825
+
10298
10826
  // packages/addons/tasks/client/timeline/timeline-member-rows.cjs
10299
10827
  var require_timeline_member_rows = __commonJS({
10300
10828
  "packages/addons/tasks/client/timeline/timeline-member-rows.cjs"(exports2, module2) {
@@ -10578,6 +11106,7 @@ var require_task_timeline_modal = __commonJS({
10578
11106
  var require_edit_modal = __commonJS({
10579
11107
  "packages/addons/tasks/client/modals/edit-modal.cjs"(exports2, module2) {
10580
11108
  "use strict";
11109
+ var NF = require_number_field();
10581
11110
  module2.exports = function createEditModal(React, statusInfo, stars) {
10582
11111
  var h = React.createElement;
10583
11112
  var difficultyField = require_difficulty_field()(React);
@@ -10641,12 +11170,22 @@ var require_edit_modal = __commonJS({
10641
11170
  });
10642
11171
  }
10643
11172
  var titleOk = String(form.title).trim().length > 0;
11173
+ var priorityCheck = canPriority ? NF.validateNumber(form.priority, { min: String(task.status) === "1" ? 0 : 1, max: 10, integer: true, lang: props.lang }) : { ok: true, value: 0, error: "" };
11174
+ var difficultyCheck = NF.validateNumber(form.difficulty, { min: 0, max: 5, step: 0.5, allowEmpty: true, lang: props.lang });
10644
11175
  function submit() {
10645
11176
  if (isBusy || submission.pending) return;
10646
11177
  if (!titleOk) {
10647
11178
  setErr(t.needTitle);
10648
11179
  return;
10649
11180
  }
11181
+ if (!priorityCheck.ok) {
11182
+ setErr(priorityCheck.error);
11183
+ return;
11184
+ }
11185
+ if (!difficultyCheck.ok) {
11186
+ setErr(difficultyCheck.error);
11187
+ return;
11188
+ }
10650
11189
  var patch = { id: task.id, title: String(form.title).trim(), description: String(form.description || "") };
10651
11190
  if (form.tableId && form.tableId !== String(task.tableId || "")) {
10652
11191
  if (!ownership.tables(props.tree).some(function(x) {
@@ -10658,13 +11197,10 @@ var require_edit_modal = __commonJS({
10658
11197
  patch.tableId = form.tableId;
10659
11198
  }
10660
11199
  if (canPriority) {
10661
- var p = Math.round(Number(form.priority));
10662
- if (!isFinite(p)) p = 1;
10663
- if (!Number.isFinite(p)) p = 0;
10664
- patch.priority = Math.max(1, Math.min(10, p));
11200
+ patch.priority = priorityCheck.value;
10665
11201
  if (String(form.targetDate || "").trim()) patch.targetDate = String(form.targetDate).trim();
10666
11202
  }
10667
- patch.difficulty = Math.max(0, Math.min(5, Number(form.difficulty) || 0));
11203
+ patch.difficulty = difficultyCheck.value || 0;
10668
11204
  patch.workspaceIds = (form.workspaceIds || []).slice();
10669
11205
  if (String(form.review) !== String(task.review || "")) patch.review = String(form.review);
10670
11206
  submission.pending = true;
@@ -10733,16 +11269,30 @@ var require_edit_modal = __commonJS({
10733
11269
  } })
10734
11270
  ) : null,
10735
11271
  canPriority ? h(
10736
- "label",
11272
+ "div",
10737
11273
  { className: "wbt-field" },
10738
- h("span", null, t.priority + "\uFF081\u201310\uFF09"),
10739
- h("input", { className: "wbt-input", type: "number", min: 1, max: 10, step: 1, value: form.priority, onChange: function(e) {
10740
- set("priority", e.target.value);
10741
- } })
11274
+ h("span", { className: "wbt-field-label" }, t.priority + "\uFF081\u201310\uFF09"),
11275
+ h(NF.NumberField, {
11276
+ h,
11277
+ lang: props.lang,
11278
+ value: form.priority,
11279
+ min: 1,
11280
+ max: 10,
11281
+ integer: true,
11282
+ hint: false,
11283
+ ariaLabel: t.priority,
11284
+ // 键入即写草稿,合法性交给 priorityCheck(保存按钮据此禁用),绝不夹取。
11285
+ onDraft: function(raw) {
11286
+ set("priority", raw);
11287
+ },
11288
+ onCommit: function(next) {
11289
+ set("priority", String(next));
11290
+ }
11291
+ })
10742
11292
  ) : null,
10743
11293
  difficultyField(t, form.difficulty, function(value) {
10744
11294
  set("difficulty", value);
10745
- }, "wbt-edit-difficulty"),
11295
+ }, "wbt-edit-difficulty", props.lang),
10746
11296
  h(WorkspaceSelect, { api: props.api, lang: props.lang, value: form.workspaceIds, onChange: function(ids) {
10747
11297
  set("workspaceIds", ids);
10748
11298
  } }),
@@ -10751,7 +11301,7 @@ var require_edit_modal = __commonJS({
10751
11301
  "div",
10752
11302
  { className: "wbt-modal-foot" },
10753
11303
  h("button", { className: "wbt-btn ghost", disabled: isBusy, onClick: requestClose }, t.cancel),
10754
- h("button", { className: "wbt-btn primary", disabled: isBusy || !titleOk, onClick: submit }, isBusy ? "\u2026" : t.save)
11304
+ h("button", { className: "wbt-btn primary", disabled: isBusy || !titleOk || !priorityCheck.ok || !difficultyCheck.ok, onClick: submit }, isBusy ? "\u2026" : t.save)
10755
11305
  )
10756
11306
  )
10757
11307
  );
@@ -11141,43 +11691,7 @@ var require_task_filter_panel = __commonJS({
11141
11691
  var model = require_task_filter_model();
11142
11692
  var DateFilter = require_date_filter().DateFilter;
11143
11693
  var WorkspaceFilter = require_workspacefilter();
11144
- function NumberInput(p) {
11145
- var React = p.React, draftState = React.useState(String(p.value)), draft = draftState[0], setDraft = draftState[1];
11146
- React.useEffect(function() {
11147
- setDraft(String(p.value));
11148
- }, [p.value]);
11149
- function commit(node) {
11150
- var result = p.commit(node.validity && node.validity.badInput ? "invalid" : draft);
11151
- setDraft(result === void 0 ? String(p.value) : result);
11152
- }
11153
- return React.createElement("input", {
11154
- type: "number",
11155
- className: "wbt-input wbt-limit-input",
11156
- min: p.min,
11157
- max: p.max,
11158
- step: p.step,
11159
- inputMode: p.step === 1 ? "numeric" : "decimal",
11160
- value: draft,
11161
- "aria-label": p.label,
11162
- placeholder: p.placeholder,
11163
- onChange: function(e) {
11164
- setDraft(e.target.value);
11165
- },
11166
- onBlur: function(e) {
11167
- commit(e.currentTarget);
11168
- },
11169
- onKeyDown: function(e) {
11170
- if (e.key === "Enter") {
11171
- e.preventDefault();
11172
- e.currentTarget.blur();
11173
- }
11174
- if (e.key === "Escape") {
11175
- e.preventDefault();
11176
- setDraft(String(p.value));
11177
- }
11178
- }
11179
- });
11180
- }
11694
+ var NF = require_number_field();
11181
11695
  module2.exports = function renderFilterPanel(React, p) {
11182
11696
  var h = React.createElement, en = p.lang === "en", value = p.value;
11183
11697
  var title = en ? "Filters" : "\u7B5B\u9009";
@@ -11207,7 +11721,8 @@ var require_task_filter_panel = __commonJS({
11207
11721
  p.onHint(hints.join(" \xB7 "));
11208
11722
  change(result.value);
11209
11723
  }
11210
- function setLimit(key, end, text) {
11724
+ function setLimit(key, end, next) {
11725
+ var text = next === null || next === void 0 ? "" : String(next);
11211
11726
  var result = model.limit(value, key, end, text);
11212
11727
  if (!result) {
11213
11728
  p.onHint(en ? key === "difficulty" ? "Difficulty takes 0.5 steps from 0 to 5" : "Priority takes whole numbers 0\u201310" : key === "difficulty" ? "\u96BE\u5EA6\u4EC5\u63A5\u53D7 0\u20135 \u4E4B\u95F4\u7684\u534A\u6863\u6570\u503C" : "\u4F18\u5148\u7EA7\u4EC5\u63A5\u53D7 0\u201310 \u7684\u6574\u6570");
@@ -11219,15 +11734,28 @@ var require_task_filter_panel = __commonJS({
11219
11734
  p.onHint(hints.join(" \xB7 "));
11220
11735
  if (result.clearsMissing && p.onMissingChange) p.onMissingChange(false);
11221
11736
  change(result.value);
11222
- return result.value[key][end];
11223
11737
  }
11224
11738
  function limitRow(key, label) {
11225
11739
  var box = value[key], spec = model.limits[key];
11226
11740
  function field(end) {
11227
11741
  var labelText = en ? (end === "min" ? "Minimum " : "Maximum ") + label : (end === "min" ? "\u6700\u4F4E" : "\u6700\u9AD8") + label;
11228
- return h(NumberInput, { React, value: box[end], min: spec.min, max: spec.max, step: spec.step, label: labelText, placeholder: String(end === "min" ? spec.min : spec.max), commit: function(text) {
11229
- return setLimit(key, end, text);
11230
- } });
11742
+ return h(NF.NumberField, {
11743
+ h,
11744
+ lang: p.lang,
11745
+ value: box[end],
11746
+ min: spec.min,
11747
+ max: spec.max,
11748
+ step: spec.step,
11749
+ integer: spec.step === 1,
11750
+ allowEmpty: true,
11751
+ hint: false,
11752
+ className: "wbt-limit-field",
11753
+ ariaLabel: labelText,
11754
+ placeholder: String(end === "min" ? spec.min : spec.max),
11755
+ onCommit: function(next) {
11756
+ setLimit(key, end, next);
11757
+ }
11758
+ });
11231
11759
  }
11232
11760
  function clear() {
11233
11761
  p.onHint("");
@@ -11435,6 +11963,7 @@ var require_tasks_view = __commonJS({
11435
11963
  var React = deps.React, configView = deps.configView, CFG_FALLBACK = deps.CFG_FALLBACK, COPY = deps.COPY, injectCss = deps.injectCss, allTables = deps.allTables, findFirstTable = deps.findFirstTable, treeWalk = deps.treeWalk, treeFlat = deps.treeFlat, cx = deps.cx, Icon2 = deps.Icon, TaskItem = deps.TaskItem, PathCrumbs = deps.PathCrumbs, TagFilter = deps.TagFilter, TreeNode = deps.TreeNode, CreateModal = deps.CreateModal, TimelineModal = deps.TimelineModal, NodeModal = deps.NodeModal, EditModal = deps.EditModal, DoneModal = deps.DoneModal, BatchModal = deps.BatchModal;
11436
11964
  var h = React.createElement, filters = require_task_filter_model(), renderFilters = require_task_filter_panel(), claimBatch = require_claim_batch(), renderSelectionBar = require_selection_bar();
11437
11965
  var TaskPreview = require_task_preview()(React, TaskItem);
11966
+ var SW = require_switch();
11438
11967
  function TasksView(props) {
11439
11968
  var lang = props.lang === "en" ? "en" : "zh";
11440
11969
  var cfg = configView.useConfig(props.api, CFG_FALLBACK);
@@ -12025,16 +12554,16 @@ var require_tasks_view = __commonJS({
12025
12554
  api,
12026
12555
  t,
12027
12556
  Icon: Icon2,
12028
- missing: h("label", { className: "wbt-check" }, h("input", {
12029
- type: "checkbox",
12030
- checked: difficultyMissing,
12031
- onChange: function(e) {
12032
- var next = e.target.checked;
12557
+ missing: h(SW.Switch, {
12558
+ h,
12559
+ checked: !!difficultyMissing,
12560
+ label: t.difficultyMissing,
12561
+ onChange: function(next) {
12033
12562
  setDifficultyMissing(next);
12034
12563
  if (next) setFilterValue(filters.clearDifficulty(filterValue));
12035
12564
  setPageNumber(1);
12036
12565
  }
12037
- }), t.difficultyMissing)
12566
+ })
12038
12567
  });
12039
12568
  var listBody = loading ? h("div", { className: "wbt-empty" }, t.loading) : error ? h("div", { className: "wbt-err" }, t.error + error) : data.records.length === 0 ? h("div", { className: "wbt-empty" }, t.empty) : h("div", { className: "wbt-list" }, data.records.map(function(task) {
12040
12569
  return h(TaskItem, {
@@ -12358,6 +12887,7 @@ var require_tasks_view = __commonJS({
12358
12887
  t,
12359
12888
  api,
12360
12889
  task: doneTask,
12890
+ lang: props.lang,
12361
12891
  onClose: function() {
12362
12892
  setDoneTask(null);
12363
12893
  },
@@ -12551,6 +13081,7 @@ var require_timeline_view = __commonJS({
12551
13081
  var receipts = require_ownership();
12552
13082
  var splitTitle = require_timeline_title();
12553
13083
  var Highlight = require_highlight2()(React);
13084
+ var SW = require_switch();
12554
13085
  function result(r) {
12555
13086
  if (!r || !r.ok) throw new Error(r && r.error || "Request failed");
12556
13087
  return r.result;
@@ -12789,10 +13320,10 @@ var require_timeline_view = __commonJS({
12789
13320
  } }),
12790
13321
  h("button", { className: "wbt-btn", type: "submit" }, t.timelineSearchButton)
12791
13322
  ),
12792
- h("label", { className: "wbt-timeline-single" }, h("input", { type: "checkbox", "aria-label": t.timelineSingletons, checked: single, onChange: function(e) {
12793
- setSingle(e.target.checked);
13323
+ h(SW.Switch, { h, checked: !!single, label: t.timelineSingletons, onChange: function(next) {
13324
+ setSingle(next);
12794
13325
  setPage(1);
12795
- } }), t.timelineSingletons)
13326
+ } })
12796
13327
  ),
12797
13328
  h(
12798
13329
  "div",
@@ -13146,20 +13677,7 @@ var require_timeline_view = __commonJS({
13146
13677
  title: over ? "\u5DF2\u8D85\u8FC7\u8BA1\u5212\u5B8C\u6210\u65F6\u95F4" : "\u8DDD\u8BA1\u5212\u5B8C\u6210"
13147
13678
  }, h(Icon2, { name: "clock", size: 11 }), h("span", { className: "wbt-cd-num" }, text));
13148
13679
  }
13149
- var CSS = require_styles() + "\n" + require_timeline_styles();
13150
- function injectCss() {
13151
- if (typeof document === "undefined") return;
13152
- var old = document.getElementById("wb-addon-tasks-v2-css");
13153
- if (old) {
13154
- old.textContent = CSS;
13155
- return;
13156
- }
13157
- var s = document.createElement("style");
13158
- s.id = "wb-addon-tasks-v2-css";
13159
- s.setAttribute("data-wb-addon", "wb-addon-tasks");
13160
- s.textContent = CSS;
13161
- document.head.appendChild(s);
13162
- }
13680
+ var injectCss = require_inject_css();
13163
13681
  function cx() {
13164
13682
  return Array.prototype.filter.call(arguments, Boolean).join(" ");
13165
13683
  }
@@ -13283,7 +13801,9 @@ var require_timeline_view = __commonJS({
13283
13801
  cx,
13284
13802
  Icon: Icon2,
13285
13803
  Countdown,
13286
- PathCrumbs
13804
+ PathCrumbs,
13805
+ // 任务详情也开 item.actions 落点:来源插件把「回到原处」挂进来。
13806
+ Slot: host.Slot
13287
13807
  });
13288
13808
  function TreeNode(props) {
13289
13809
  var node = props.node;
@@ -13475,6 +13995,7 @@ var require_timeline_view = __commonJS({
13475
13995
  );
13476
13996
  }
13477
13997
  var CreateModal = require_create_modal()({ React, allTables, tagNames, splitTags, today, addDays, hostHasAddon });
13998
+ var slotTaskFromMessage = require_slot_task_from_message()({ React, Icon: Icon2, injectCss });
13478
13999
  var TimelineModal = require_task_timeline_modal()(React, statusInfo);
13479
14000
  function DoneModal(props) {
13480
14001
  var t = props.t;
@@ -13494,7 +14015,7 @@ var require_timeline_view = __commonJS({
13494
14015
  { className: "wbt-modal", style: { width: "420px" } },
13495
14016
  h("div", { className: "wbt-modal-head" }, h("h3", null, t.complete + " \xB7 " + props.task.title), h("button", { className: "wbt-icon", onClick: props.onClose }, "\xD7")),
13496
14017
  h("div", { className: "wbt-mhint" }, t.difficultyHint),
13497
- require_difficulty_field()(React)(t, value, setValue, "wbt-done-difficulty"),
14018
+ require_difficulty_field()(React)(t, value, setValue, "wbt-done-difficulty", props.lang),
13498
14019
  h(
13499
14020
  "label",
13500
14021
  { className: "wbt-field", style: { marginTop: "12px" } },
@@ -13544,8 +14065,11 @@ var require_timeline_view = __commonJS({
13544
14065
  var TimelineView = require_timeline_view()({ React, COPY, injectCss, statusInfo, configView, CFG_FALLBACK, TaskItem, EditModal, DoneModal, TimelineModal, CreateModal });
13545
14066
  host.registerAddon({
13546
14067
  id: "wb-addon-tasks",
13547
- version: "5.2.33",
14068
+ version: "5.2.35",
13548
14069
  icon: ICONS["list-checks"],
14070
+ // 贡献声明写在 registerAddon 里:卸载任务插件时宿主按 addonId 一起撤销,
14071
+ // 不会在邮件里留一个渲染即报错的孤儿按钮。
14072
+ slots: [{ slot: "item.actions", id: "tasks.create-from-mail", order: 100, component: slotTaskFromMessage }],
13549
14073
  views: [
13550
14074
  { id: "stats", icon: tabIcon("chart"), title: { zh: "\u7EDF\u8BA1", en: "Stats" }, component: statsView.TasksStatsView, keepAlive: true },
13551
14075
  { id: "tasks", icon: tabIcon("list"), title: { zh: "\u8BB0\u5F55", en: "Records" }, component: TasksView },