dsh-workbench-sites 1.10.0 → 1.12.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.js CHANGED
@@ -38,6 +38,146 @@ var __copyProps = (to, from, except, desc) => {
38
38
  };
39
39
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
40
40
 
41
+ // packages/addons/lib/filter-checklist.cjs
42
+ var require_filter_checklist = __commonJS({
43
+ "packages/addons/lib/filter-checklist.cjs"(exports2, module2) {
44
+ "use strict";
45
+ var React2 = require("react");
46
+ var h2 = React2.createElement;
47
+ var NEAR = 24;
48
+ function nearBottom(el, threshold) {
49
+ if (!el) return false;
50
+ var gap = Number(threshold);
51
+ if (!isFinite(gap) || gap < 0) gap = NEAR;
52
+ return el.scrollTop + el.clientHeight >= el.scrollHeight - gap;
53
+ }
54
+ function FilterChecklist(props) {
55
+ var items = props.items || [];
56
+ var selected = props.selected || [];
57
+ var disabled = props.disabled === true;
58
+ var loading = props.loading === true;
59
+ var hasMore = props.hasMore === true;
60
+ var query = props.query || "";
61
+ var total = typeof props.total === "number" ? props.total : items.length;
62
+ var title = props.title || "\u5168\u90E8";
63
+ var selectedText = props.selectedText || "\u5DF2\u9009";
64
+ var clearText = props.clearText || "\u6E05\u7A7A";
65
+ var searchPlaceholder = props.searchPlaceholder || "\u641C\u7D22";
66
+ var emptyText = props.emptyText || "\u6682\u65E0\u6570\u636E";
67
+ var noMatchText = props.noMatchText || "\u6CA1\u6709\u5339\u914D\u9879";
68
+ var loadingText = props.loadingText || "\u52A0\u8F7D\u4E2D\u2026";
69
+ var noMoreText = typeof props.noMoreText === "string" ? props.noMoreText : "\u6CA1\u6709\u66F4\u591A";
70
+ var onToggle = props.onToggle || function() {
71
+ };
72
+ var onQuery = props.onQuery || function() {
73
+ };
74
+ var onLoadMore = props.onLoadMore;
75
+ var onClear = props.onClear || function() {
76
+ };
77
+ var single = props.mode === "single";
78
+ var onPick = typeof props.onPick === "function" ? props.onPick : onToggle;
79
+ function toggle(id) {
80
+ if (disabled) return;
81
+ onToggle(id);
82
+ }
83
+ function scroll(e) {
84
+ if (disabled || loading || !hasMore || !onLoadMore) return;
85
+ if (nearBottom(e.currentTarget)) onLoadMore();
86
+ }
87
+ var head = h2(
88
+ "div",
89
+ { className: "wbck-head" },
90
+ h2("span", { className: "wbck-grow" }, title + (total ? " \xB7 " + total : "")),
91
+ !single && selected.length ? h2("span", { className: "wbck-sel" }, selectedText + " " + selected.length) : null,
92
+ !single && (selected.length || query) ? h2("button", {
93
+ type: "button",
94
+ className: "wbck-clear",
95
+ title: clearText,
96
+ disabled,
97
+ onClick: function() {
98
+ if (disabled) return;
99
+ onClear();
100
+ }
101
+ }, clearText) : null
102
+ );
103
+ var body;
104
+ if (!items.length) {
105
+ body = h2("div", { className: "wbck-note", role: "status" }, loading ? loadingText : query ? noMatchText : emptyText);
106
+ } else {
107
+ body = items.map(function(x) {
108
+ var on = selected.indexOf(String(x.id)) >= 0;
109
+ if (single) {
110
+ return h2(
111
+ "button",
112
+ {
113
+ key: x.id,
114
+ type: "button",
115
+ role: "radio",
116
+ "aria-checked": on ? "true" : "false",
117
+ className: "wbck-opt" + (on ? " is-on" : ""),
118
+ disabled,
119
+ onClick: function() {
120
+ if (disabled) return;
121
+ onPick(x.id);
122
+ }
123
+ },
124
+ h2("span", { className: "wbck-nm", title: x.name }, x.name),
125
+ x.meta ? h2("span", { className: "wbck-meta" }, x.meta) : null
126
+ );
127
+ }
128
+ return h2(
129
+ "label",
130
+ { key: x.id, className: "wbck-opt" + (on ? " is-on" : "") },
131
+ h2("input", {
132
+ type: "checkbox",
133
+ checked: on,
134
+ disabled,
135
+ onChange: function() {
136
+ toggle(x.id);
137
+ }
138
+ }),
139
+ h2("span", { className: "wbck-nm", title: x.name }, x.name),
140
+ x.meta ? h2("span", { className: "wbck-meta" }, x.meta) : null
141
+ );
142
+ });
143
+ var more = loading ? loadingText : hasMore ? "" : noMoreText;
144
+ if (more) body = body.concat([h2("div", { key: "__more", className: "wbck-more", role: "status" }, more)]);
145
+ }
146
+ return h2(
147
+ "div",
148
+ { className: "wbck", "data-role": "checklist" },
149
+ h2(
150
+ "div",
151
+ { className: "wbck-search" },
152
+ h2("input", {
153
+ type: "search",
154
+ autoFocus: props.autoFocus !== false,
155
+ className: "wbck-input",
156
+ placeholder: searchPlaceholder,
157
+ "aria-label": searchPlaceholder,
158
+ value: query,
159
+ disabled,
160
+ onChange: function(e) {
161
+ onQuery(e.target.value);
162
+ }
163
+ })
164
+ ),
165
+ props.beforeHead || null,
166
+ head,
167
+ h2("div", {
168
+ className: "wbck-list",
169
+ onScroll: scroll,
170
+ role: single ? "radiogroup" : void 0,
171
+ "aria-label": single ? props.groupLabel || searchPlaceholder : void 0,
172
+ "aria-busy": loading ? "true" : "false"
173
+ }, body)
174
+ );
175
+ }
176
+ module2.exports = FilterChecklist;
177
+ module2.exports.nearBottom = nearBottom;
178
+ }
179
+ });
180
+
41
181
  // packages/addons/sites/client/ui/tagfilter.cjs
42
182
  var require_tagfilter = __commonJS({
43
183
  "packages/addons/sites/client/ui/tagfilter.cjs"(exports2, module2) {
@@ -46,6 +186,7 @@ var require_tagfilter = __commonJS({
46
186
  var useState = React2.useState;
47
187
  var useEffect = React2.useEffect;
48
188
  var useCallback = React2.useCallback;
189
+ var FilterChecklist = require_filter_checklist();
49
190
  module2.exports = function TagFilter2(props) {
50
191
  var api = props.api;
51
192
  var text = props.text;
@@ -69,7 +210,16 @@ var require_tagfilter = __commonJS({
69
210
  var out = r.result || {};
70
211
  var records = out.records || [];
71
212
  setRows(function(prev) {
72
- return append ? prev.concat(records) : records;
213
+ if (!append) return records;
214
+ var seen = {};
215
+ var out2 = [];
216
+ prev.concat(records).forEach(function(x) {
217
+ var key = String(x.id);
218
+ if (seen[key]) return;
219
+ seen[key] = true;
220
+ out2.push(x);
221
+ });
222
+ return out2;
73
223
  });
74
224
  setTotal(out.total || 0);
75
225
  setPage(out.current || pageNumber);
@@ -128,69 +278,462 @@ var require_tagfilter = __commonJS({
128
278
  { className: "wbs-tagmenu", style: { width: 260 }, onClick: function(e) {
129
279
  e.stopPropagation();
130
280
  } },
281
+ h2(FilterChecklist, {
282
+ beforeHead: ids.length ? h2(
283
+ "div",
284
+ { style: { padding: "0 4px 4px" } },
285
+ h2("div", { className: "wbs-tagmenu-head" }, h2("span", null, text("tagSelected") + " " + ids.length)),
286
+ ids.map(function(id) {
287
+ return h2(
288
+ "button",
289
+ { key: id, className: "wbs-mini", style: { justifyContent: "space-between" }, onClick: function() {
290
+ toggle(id);
291
+ } },
292
+ h2("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" } }, names[String(id)] || "#" + id),
293
+ h2("span", null, "\xD7")
294
+ );
295
+ })
296
+ ) : null,
297
+ items: rows.map(function(x) {
298
+ return { id: x.id, name: x.name };
299
+ }),
300
+ selected: ids,
301
+ onToggle: toggle,
302
+ query,
303
+ onQuery: setQuery,
304
+ title: text("allTags"),
305
+ total,
306
+ clearText: text("clear"),
307
+ onClear: function() {
308
+ onChange([]);
309
+ setQuery("");
310
+ },
311
+ searchPlaceholder: text("tagSearchPlaceholder"),
312
+ loading,
313
+ hasMore,
314
+ onLoadMore: function() {
315
+ load(query, (page || 1) + 1, true);
316
+ },
317
+ emptyText: text("noTags"),
318
+ noMatchText: text("tagNoMatch"),
319
+ loadingText: text("loadingMore"),
320
+ noMoreText: text("noMore")
321
+ })
322
+ ) : null
323
+ );
324
+ };
325
+ }
326
+ });
327
+
328
+ // packages/addons/lib/date-picker.cjs
329
+ var require_date_picker = __commonJS({
330
+ "packages/addons/lib/date-picker.cjs"(exports2, module2) {
331
+ "use strict";
332
+ var ReactDefault = require("react");
333
+ var MONTH_EN = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
334
+ function pad(n) {
335
+ return String(n).padStart(2, "0");
336
+ }
337
+ function todayISO() {
338
+ var d = /* @__PURE__ */ new Date();
339
+ return d.getFullYear() + "-" + pad(d.getMonth() + 1) + "-" + pad(d.getDate());
340
+ }
341
+ function validDate(value) {
342
+ if (!value) return false;
343
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(value)) return false;
344
+ var d = /* @__PURE__ */ new Date(value + "T00:00:00Z");
345
+ return isFinite(d.getTime()) && d.toISOString().slice(0, 10) === value && value.slice(0, 4) !== "0000";
346
+ }
347
+ function toUTC(iso) {
348
+ return /* @__PURE__ */ new Date(iso + "T00:00:00Z");
349
+ }
350
+ function shiftDate(iso, days) {
351
+ var d = toUTC(iso);
352
+ d.setUTCDate(d.getUTCDate() + days);
353
+ return d.toISOString().slice(0, 10);
354
+ }
355
+ function shiftMonth(month, delta) {
356
+ var d = toUTC(month + "-01");
357
+ d.setUTCMonth(d.getUTCMonth() + delta);
358
+ return d.toISOString().slice(0, 7);
359
+ }
360
+ function monthKey(iso) {
361
+ return (iso || todayISO()).slice(0, 7);
362
+ }
363
+ function monthLabel(month, en) {
364
+ return en ? month.slice(0, 4) + "-" + month.slice(5) : month.slice(0, 4) + "\u5E74" + Number(month.slice(5)) + "\u6708";
365
+ }
366
+ function daysInMonth(month) {
367
+ return new Date(Date.UTC(Number(month.slice(0, 4)), Number(month.slice(5)), 0)).getUTCDate();
368
+ }
369
+ function normalizeRange(value) {
370
+ var from = value && validDate(value.from) ? value.from : "";
371
+ var to = value && validDate(value.to) ? value.to : "";
372
+ if (from && to && from > to) return { from: to, to: from, swapped: true };
373
+ return { from, to, swapped: false };
374
+ }
375
+ function clampDay(iso, min, max) {
376
+ if (min && iso < min) return false;
377
+ if (max && iso > max) return false;
378
+ return true;
379
+ }
380
+ function ctx(props) {
381
+ var R = props && props.React || ReactDefault;
382
+ return { R, h: props && props.h || R.createElement };
383
+ }
384
+ function usePopover(R, open, setOpen, root) {
385
+ R.useEffect(function() {
386
+ if (!open) return void 0;
387
+ function onDoc(ev) {
388
+ if (root.current && !root.current.contains(ev.target)) setOpen(false);
389
+ }
390
+ function onKey(ev) {
391
+ if (ev.key === "Escape") setOpen(false);
392
+ }
393
+ if (typeof document !== "undefined" && typeof document.addEventListener === "function") {
394
+ document.addEventListener("mousedown", onDoc);
395
+ document.addEventListener("keydown", onKey);
396
+ return function() {
397
+ document.removeEventListener("mousedown", onDoc);
398
+ document.removeEventListener("keydown", onKey);
399
+ };
400
+ }
401
+ return void 0;
402
+ }, [open]);
403
+ }
404
+ function Calendar(props) {
405
+ var h2 = props.h, p = props.prefix, en = props.lang === "en";
406
+ var month = props.month, cells = [];
407
+ var offset = toUTC(month + "-01").getUTCDay();
408
+ var count = daysInMonth(month);
409
+ var i;
410
+ for (i = 0; i < offset; i++) cells.push(h2("span", { key: "e" + i, "aria-hidden": "true" }));
411
+ for (i = 1; i <= count; i++) {
412
+ var day = month + "-" + pad(i);
413
+ var disabled = !clampDay(day, props.min, props.max);
414
+ var selected = props.isSelected ? props.isSelected(day) : false;
415
+ var between = props.isBetween ? props.isBetween(day) : false;
416
+ cells.push(h2("button", {
417
+ key: day,
418
+ type: "button",
419
+ disabled,
420
+ "data-day": day,
421
+ "aria-label": day,
422
+ "aria-pressed": selected,
423
+ "aria-current": day === todayISO() ? "date" : void 0,
424
+ className: p + "-dp-day" + (selected ? " is-on" : "") + (between ? " is-between" : "") + (day === todayISO() ? " is-today" : ""),
425
+ onClick: props.onPick.bind(null, day),
426
+ onKeyDown: function(ev) {
427
+ var delta = { ArrowLeft: -1, ArrowRight: 1, ArrowUp: -7, ArrowDown: 7 }[ev.key];
428
+ if (!delta) return;
429
+ ev.preventDefault();
430
+ var next = shiftDate(ev.currentTarget.getAttribute("data-day"), delta);
431
+ if (clampDay(next, props.min, props.max)) props.onMove(monthKey(next), next);
432
+ }
433
+ }, i));
434
+ }
435
+ return h2(
436
+ "div",
437
+ { className: p + "-dp-cal", role: "group", "aria-label": en ? "Calendar" : "\u65E5\u5386" },
438
+ h2(
439
+ "div",
440
+ { className: p + "-dp-head" },
441
+ h2("button", { type: "button", className: p + "-dp-nav", "aria-label": en ? "Previous month" : "\u4E0A\u4E2A\u6708", onClick: function() {
442
+ props.onMove(shiftMonth(month, -1), "");
443
+ } }, "\u2039"),
444
+ h2("strong", { className: p + "-dp-title", "aria-live": "polite" }, monthLabel(month, en)),
445
+ h2("button", { type: "button", className: p + "-dp-nav", "aria-label": en ? "Next month" : "\u4E0B\u4E2A\u6708", onClick: function() {
446
+ props.onMove(shiftMonth(month, 1), "");
447
+ } }, "\u203A")
448
+ ),
449
+ h2(
450
+ "div",
451
+ { className: p + "-dp-weekdays", "aria-hidden": "true" },
452
+ (en ? ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"] : ["\u65E5", "\u4E00", "\u4E8C", "\u4E09", "\u56DB", "\u4E94", "\u516D"]).map(function(w) {
453
+ return h2("span", { key: w }, w);
454
+ })
455
+ ),
456
+ h2("div", { className: p + "-dp-grid" }, cells)
457
+ );
458
+ }
459
+ function DatePicker(props) {
460
+ var c = ctx(props), R = c.R, h2 = c.h;
461
+ var p = props.prefix, en = props.lang === "en";
462
+ var value = validDate(props.value) ? props.value : "";
463
+ var openS = R.useState(!!props.defaultOpen), open = openS[0], setOpen = openS[1];
464
+ var monthS = R.useState(monthKey(value || props.max || todayISO())), month = monthS[0], setMonth = monthS[1];
465
+ var root = R.useRef(null);
466
+ usePopover(R, open, setOpen, root);
467
+ function pick(day) {
468
+ if (props.onChange) props.onChange(day);
469
+ setOpen(false);
470
+ }
471
+ function toggle() {
472
+ setMonth(monthKey(validDate(props.value) ? props.value : props.max || todayISO()));
473
+ setOpen(!open);
474
+ }
475
+ return h2(
476
+ "div",
477
+ { className: p + "-dp" + (props.className ? " " + props.className : ""), ref: root },
478
+ h2(
479
+ "div",
480
+ { className: p + "-dp-field" },
481
+ h2(
482
+ "button",
483
+ {
484
+ type: "button",
485
+ className: p + "-dp-trigger",
486
+ disabled: !!props.disabled,
487
+ "aria-haspopup": "dialog",
488
+ "aria-expanded": open,
489
+ "aria-label": (props.label ? props.label + ": " : "") + (value || props.placeholder || (en ? "Pick a date" : "\u9009\u62E9\u65E5\u671F")),
490
+ onClick: toggle
491
+ },
492
+ h2("span", { className: p + "-dp-glyph", "aria-hidden": "true" }),
493
+ h2("span", { className: p + "-dp-value" + (value ? "" : " is-empty") }, value || props.placeholder || (en ? "Pick a date" : "\u9009\u62E9\u65E5\u671F"))
494
+ ),
495
+ value && !props.disabled && props.clearable !== false ? h2("button", { type: "button", className: p + "-dp-clear", "aria-label": en ? "Clear date" : "\u6E05\u9664\u65E5\u671F", onClick: function() {
496
+ if (props.onChange) props.onChange("");
497
+ } }, "\xD7") : null
498
+ ),
499
+ open ? h2(
500
+ "div",
501
+ { className: p + "-dp-pop", role: "dialog", "aria-modal": "false", "aria-label": props.label || (en ? "Pick a date" : "\u9009\u62E9\u65E5\u671F") },
502
+ h2(Calendar, { h: h2, prefix: p, lang: props.lang, month, min: props.min, max: props.max, onMove: function(m) {
503
+ setMonth(m);
504
+ }, isSelected: function(d) {
505
+ return d === value;
506
+ }, onPick: pick }),
131
507
  h2(
132
508
  "div",
133
- { style: { padding: "2px 4px 6px" } },
134
- h2("input", {
135
- className: "wbs-input",
136
- autoFocus: true,
137
- value: query,
138
- placeholder: text("tagSearchPlaceholder"),
139
- onChange: function(e) {
140
- setQuery(e.target.value);
141
- }
142
- })
509
+ { className: p + "-dp-foot" },
510
+ h2("button", { type: "button", className: p + "-dp-link", onClick: function() {
511
+ pick(todayISO());
512
+ } }, en ? "Today" : "\u4ECA\u5929"),
513
+ props.min || props.max ? h2("span", { className: p + "-dp-hint" }, [props.min, props.max].filter(Boolean).join(" \u2014 ")) : null
514
+ )
515
+ ) : null
516
+ );
517
+ }
518
+ function RangePicker(props) {
519
+ var c = ctx(props), R = c.R, h2 = c.h;
520
+ var p = props.prefix, en = props.lang === "en";
521
+ var range = normalizeRange(props.value);
522
+ var from = range.from, to = range.to;
523
+ var openS = R.useState(!!props.defaultOpen), open = openS[0], setOpen = openS[1];
524
+ var startS = R.useState(""), start = startS[0], setStart = startS[1];
525
+ var monthS = R.useState(monthKey(from || to || props.max || todayISO())), month = monthS[0], setMonth = monthS[1];
526
+ var root = R.useRef(null);
527
+ usePopover(R, open, setOpen, root);
528
+ function apply(next) {
529
+ if (typeof props.onChange === "function") props.onChange(normalizeRange(next));
530
+ setStart("");
531
+ setOpen(false);
532
+ }
533
+ function pick(day) {
534
+ if (!start) {
535
+ setStart(day);
536
+ return;
537
+ }
538
+ apply({ from: start, to: day });
539
+ }
540
+ function toggle() {
541
+ setStart("");
542
+ setMonth(monthKey(from || to || props.max || todayISO()));
543
+ setOpen(!open);
544
+ }
545
+ var summary = from && to ? from + " \u2014 " + to : from ? from + (en ? " onward" : " \u8D77") : to ? (en ? "Until " : "\u622A\u81F3 ") + to : props.placeholder || (en ? "Choose date range" : "\u9009\u62E9\u65E5\u671F\u8303\u56F4");
546
+ return h2(
547
+ "div",
548
+ { className: p + "-dr" + (props.className ? " " + props.className : ""), ref: root },
549
+ h2(
550
+ "div",
551
+ { className: p + "-dp-field" },
552
+ h2(
553
+ "button",
554
+ {
555
+ type: "button",
556
+ className: p + "-dp-trigger",
557
+ "aria-haspopup": "dialog",
558
+ "aria-expanded": open,
559
+ "aria-label": (props.label || (en ? "Date range" : "\u65E5\u671F\u8303\u56F4")) + ": " + summary,
560
+ onClick: toggle
561
+ },
562
+ h2("span", { className: p + "-dp-glyph", "aria-hidden": "true" }),
563
+ h2("span", { className: p + "-dp-value" + (from || to ? "" : " is-empty") }, summary)
564
+ ),
565
+ (from || to) && props.clearable !== false ? h2("button", { type: "button", className: p + "-dp-clear", "aria-label": en ? "Clear range" : "\u6E05\u9664\u8303\u56F4", onClick: function() {
566
+ apply({ from: "", to: "" });
567
+ } }, "\xD7") : null
568
+ ),
569
+ open ? h2(
570
+ "div",
571
+ { className: p + "-dp-pop", role: "dialog", "aria-modal": "false", "aria-label": props.label || (en ? "Date range" : "\u65E5\u671F\u8303\u56F4") },
572
+ h2(Calendar, {
573
+ h: h2,
574
+ prefix: p,
575
+ lang: props.lang,
576
+ month,
577
+ min: props.min,
578
+ max: props.max,
579
+ onMove: function(m) {
580
+ setMonth(m);
581
+ },
582
+ isSelected: function(d) {
583
+ return start ? d === start : d === from || d === to;
584
+ },
585
+ isBetween: function(d) {
586
+ return start ? start < d && d < (to || "") : !!(from && to && d > from && d < to);
587
+ },
588
+ onPick: pick
589
+ }),
590
+ h2(
591
+ "p",
592
+ { className: p + "-dp-hint", role: "status" },
593
+ start ? en ? "Start " + start + " \xB7 pick the end date" : "\u8D77\u59CB " + start + " \xB7 \u8BF7\u9009\u62E9\u7ED3\u675F\u65E5\u671F" : en ? "Pick start, then end date" : "\u5148\u9009\u5F00\u59CB\u65E5\u671F\uFF0C\u518D\u9009\u7ED3\u675F\u65E5\u671F"
143
594
  ),
144
- ids.length ? h2(
595
+ start ? h2(
145
596
  "div",
146
- { style: { padding: "0 4px 4px", display: "flex", flexDirection: "column", gap: 3 } },
147
- h2("div", { className: "wbs-tagmenu-head" }, h2("span", null, text("tagSelected") + " " + ids.length)),
148
- ids.map(function(id) {
149
- return h2(
150
- "button",
151
- { key: id, className: "wbs-mini", style: { justifyContent: "space-between" }, onClick: function() {
152
- toggle(id);
153
- } },
154
- h2("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" } }, names[String(id)] || "#" + id),
155
- h2("span", null, "\xD7")
156
- );
157
- })
597
+ { className: p + "-dp-acts" },
598
+ h2("button", { type: "button", className: p + "-dp-link", onClick: function() {
599
+ apply({ from: start, to: "" });
600
+ } }, en ? "Only start" : "\u4EC5\u8D77\u59CB\u65E5\u671F"),
601
+ h2("button", { type: "button", className: p + "-dp-link", onClick: function() {
602
+ apply({ from: "", to: start });
603
+ } }, en ? "Only end" : "\u4EC5\u622A\u6B62\u65E5\u671F")
158
604
  ) : null,
159
605
  h2(
160
606
  "div",
161
- { className: "wbs-tagmenu-head" },
162
- h2("span", null, text("allTags") + (total ? " \xB7 " + total : "")),
163
- h2("span", { className: "wbs-grow" }),
164
- h2("button", { className: "wbs-mini", title: text("clear"), onClick: function() {
165
- onChange([]);
166
- setQuery("");
167
- } }, h2(Icon2, { name: "x", size: 12 }), text("clear"))
168
- ),
607
+ { className: p + "-dp-foot" },
608
+ h2("button", { type: "button", className: p + "-dp-link", onClick: function() {
609
+ setOpen(false);
610
+ setStart("");
611
+ } }, en ? "Cancel" : "\u53D6\u6D88")
612
+ )
613
+ ) : null
614
+ );
615
+ }
616
+ function MonthPicker(props) {
617
+ var c = ctx(props), R = c.R, h2 = c.h;
618
+ var p = props.prefix, en = props.lang === "en";
619
+ var value = /^\d{4}-\d{2}$/.test(props.value || "") ? props.value : "";
620
+ var base = value || monthKey(props.max || todayISO());
621
+ var openS = R.useState(!!props.defaultOpen), open = openS[0], setOpen = openS[1];
622
+ var yearS = R.useState(Number(base.slice(0, 4))), year = yearS[0], setYear = yearS[1];
623
+ var root = R.useRef(null);
624
+ usePopover(R, open, setOpen, root);
625
+ function pick(month) {
626
+ if (props.onChange) props.onChange(month);
627
+ setOpen(false);
628
+ }
629
+ var months = [];
630
+ for (var m = 1; m <= 12; m++) {
631
+ var key = year + "-" + pad(m);
632
+ months.push(h2("button", {
633
+ key,
634
+ type: "button",
635
+ "data-month": key,
636
+ "aria-pressed": key === value,
637
+ className: p + "-dp-day" + (key === value ? " is-on" : "") + (key === monthKey(todayISO()) ? " is-today" : ""),
638
+ onClick: pick.bind(null, key)
639
+ }, en ? MONTH_EN[m - 1] : m + "\u6708"));
640
+ }
641
+ return h2(
642
+ "div",
643
+ { className: p + "-dp" + (props.className ? " " + props.className : ""), ref: root },
644
+ h2(
645
+ "div",
646
+ { className: p + "-dp-field" },
169
647
  h2(
170
- "div",
648
+ "button",
171
649
  {
172
- style: { maxHeight: 240, overflow: "auto" },
173
- onScroll: function(e) {
174
- var el = e.currentTarget;
175
- if (!hasMore || loading) return;
176
- if (el.scrollTop + el.clientHeight >= el.scrollHeight - 24) load(query, (page || 1) + 1, true);
650
+ type: "button",
651
+ className: p + "-dp-trigger",
652
+ "aria-haspopup": "dialog",
653
+ "aria-expanded": open,
654
+ "aria-label": (props.label || (en ? "Pick a month" : "\u9009\u62E9\u6708\u4EFD")) + ": " + (value ? monthLabel(value, en) : ""),
655
+ onClick: function() {
656
+ setYear(Number((value || base).slice(0, 4)));
657
+ setOpen(!open);
177
658
  }
178
659
  },
179
- rows.length ? rows.map(function(t) {
180
- var on = ids.indexOf(String(t.id)) >= 0;
181
- return h2(
182
- "label",
183
- { key: t.id, className: "wbs-tagopt" },
184
- h2("input", { type: "checkbox", checked: on, onChange: function() {
185
- toggle(t.id);
186
- } }),
187
- h2("span", null, t.name)
188
- );
189
- }) : h2("div", { className: "wbs-note", style: { padding: 6 } }, loading ? text("loadingMore") : query ? text("tagNoMatch") : text("allTags")),
190
- rows.length ? h2("div", { className: "wbs-note", style: { padding: 6, textAlign: "center" } }, loading ? text("loadingMore") : hasMore ? "" : text("noMore")) : null
660
+ h2("span", { className: p + "-dp-glyph", "aria-hidden": "true" }),
661
+ h2("span", { className: p + "-dp-value" + (value ? "" : " is-empty") }, value ? monthLabel(value, en) : props.placeholder || (en ? "Pick a month" : "\u9009\u62E9\u6708\u4EFD"))
662
+ ),
663
+ value && props.clearable !== false ? h2("button", { type: "button", className: p + "-dp-clear", "aria-label": en ? "Clear month" : "\u6E05\u9664\u6708\u4EFD", onClick: function() {
664
+ if (props.onChange) props.onChange("");
665
+ } }, "\xD7") : null
666
+ ),
667
+ open ? h2(
668
+ "div",
669
+ { className: p + "-dp-pop is-months", role: "dialog", "aria-modal": "false", "aria-label": props.label || (en ? "Pick a month" : "\u9009\u62E9\u6708\u4EFD") },
670
+ h2(
671
+ "div",
672
+ { className: p + "-dp-head" },
673
+ h2("button", { type: "button", className: p + "-dp-nav", "aria-label": en ? "Previous year" : "\u4E0A\u4E00\u5E74", onClick: function() {
674
+ setYear(year - 1);
675
+ } }, "\u2039"),
676
+ h2("strong", { className: p + "-dp-title", "aria-live": "polite" }, en ? String(year) : year + "\u5E74"),
677
+ h2("button", { type: "button", className: p + "-dp-nav", "aria-label": en ? "Next year" : "\u4E0B\u4E00\u5E74", onClick: function() {
678
+ setYear(year + 1);
679
+ } }, "\u203A")
680
+ ),
681
+ h2("div", { className: p + "-dp-months" }, months),
682
+ h2(
683
+ "div",
684
+ { className: p + "-dp-foot" },
685
+ h2("button", { type: "button", className: p + "-dp-link", onClick: function() {
686
+ pick(monthKey(todayISO()));
687
+ } }, en ? "This month" : "\u672C\u6708"),
688
+ h2("button", { type: "button", className: p + "-dp-link", onClick: function() {
689
+ setOpen(false);
690
+ } }, en ? "Cancel" : "\u53D6\u6D88")
191
691
  )
192
692
  ) : null
193
693
  );
694
+ }
695
+ function InlineCalendar(props) {
696
+ var c = ctx(props), R = c.R, h2 = c.h;
697
+ var p = props.prefix;
698
+ var value = validDate(props.value) ? props.value : "";
699
+ var monthS = R.useState(monthKey(props.month || value || props.max || todayISO())), month = monthS[0], setMonth = monthS[1];
700
+ return h2(
701
+ "div",
702
+ { className: p + "-dp is-inline" },
703
+ h2(Calendar, {
704
+ h: h2,
705
+ prefix: p,
706
+ lang: props.lang,
707
+ month,
708
+ min: props.min,
709
+ max: props.max,
710
+ onMove: function(m) {
711
+ setMonth(m);
712
+ if (props.onMonthChange) props.onMonthChange(m);
713
+ },
714
+ isSelected: function(d) {
715
+ return d === value;
716
+ },
717
+ isBetween: props.isBetween,
718
+ onPick: function(d) {
719
+ if (props.onChange) props.onChange(d);
720
+ }
721
+ }),
722
+ props.footer ? h2("div", { className: p + "-dp-foot" }, props.footer) : null
723
+ );
724
+ }
725
+ module2.exports = {
726
+ DatePicker,
727
+ RangePicker,
728
+ MonthPicker,
729
+ InlineCalendar,
730
+ todayISO,
731
+ validDate,
732
+ shiftDate,
733
+ shiftMonth,
734
+ normalizeRange,
735
+ monthLabel,
736
+ daysInMonth
194
737
  };
195
738
  }
196
739
  });
@@ -763,11 +1306,60 @@ var init_plus = __esm({
763
1306
  }
764
1307
  });
765
1308
 
1309
+ // packages/addons/lib/date-picker-styles.cjs
1310
+ var require_date_picker_styles = __commonJS({
1311
+ "packages/addons/lib/date-picker-styles.cjs"(exports2, module2) {
1312
+ "use strict";
1313
+ module2.exports = function datePickerStyles(prefix) {
1314
+ var p = String(prefix || "wb");
1315
+ return [
1316
+ ".{p}-dp,.{p}-dr{position:relative;min-width:0}",
1317
+ ".{p}-dp-field{display:flex;align-items:center;gap:6px;min-width:0}",
1318
+ ".{p}-dp-trigger{display:flex;align-items:center;gap:8px;min-width:0;width:100%;padding:8px 10px;border:1px solid var(--wb-border);border-radius:8px;background:var(--wb-surface);color:var(--wb-text,inherit);font:inherit;text-align:left;cursor:pointer;transition:border-color .15s,box-shadow .15s}",
1319
+ ".{p}-dp-trigger:hover{border-color:var(--wb-accent)}",
1320
+ ".{p}-dp-trigger:focus-visible{outline:2px solid var(--wb-accent);outline-offset:1px}",
1321
+ ".{p}-dp-trigger[disabled]{opacity:.55;cursor:not-allowed}",
1322
+ ".{p}-dp-glyph{width:13px;height:13px;flex:none;border:1.5px solid currentColor;border-radius:3px;position:relative;opacity:.72}",
1323
+ '.{p}-dp-glyph::before{content:"";position:absolute;left:-1.5px;right:-1.5px;top:3px;border-top:1.5px solid currentColor}',
1324
+ '.{p}-dp-glyph::after{content:"";position:absolute;left:3px;top:-3px;width:1.5px;height:3px;background:currentColor;box-shadow:4px 0 currentColor}',
1325
+ ".{p}-dp-value{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-variant-numeric:tabular-nums}",
1326
+ ".{p}-dp-value.is-empty{color:var(--wb-muted)}",
1327
+ ".{p}-dp-clear{flex:none;width:22px;height:22px;padding:0;border:0;border-radius:50%;background:color-mix(in srgb,var(--wb-muted) 14%,transparent);color:var(--wb-muted);font:inherit;line-height:1;cursor:pointer}",
1328
+ ".{p}-dp-clear:hover{color:var(--wb-danger);background:color-mix(in srgb,var(--wb-danger) 16%,transparent)}",
1329
+ ".{p}-dp-pop{position:absolute;z-index:40;top:calc(100% + 6px);left:0;width:272px;padding:10px;border:1px solid var(--wb-border);border-radius:12px;background:var(--wb-card);box-shadow:0 16px 40px color-mix(in srgb,var(--wb-text,var(--wb-border)) 18%,transparent);animation:{p}-dp-in .14s ease-out}",
1330
+ ".{p}-dp-head{display:flex;align-items:center;gap:6px;margin-bottom:8px}",
1331
+ ".{p}-dp-title{flex:1;text-align:center;font-size:13px;font-weight:600;font-variant-numeric:tabular-nums}",
1332
+ ".{p}-dp-nav{width:26px;height:26px;padding:0;border:1px solid var(--wb-border);border-radius:7px;background:transparent;color:inherit;font:inherit;line-height:1;cursor:pointer}",
1333
+ ".{p}-dp-nav:hover{border-color:var(--wb-accent);color:var(--wb-accent)}",
1334
+ ".{p}-dp-weekdays,.{p}-dp-grid{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));gap:2px}",
1335
+ ".{p}-dp-weekdays{margin-bottom:4px;font-size:11px;color:var(--wb-muted);text-align:center}",
1336
+ ".{p}-dp-day{min-width:0;height:30px;padding:0;border:0;border-radius:7px;background:transparent;color:inherit;font:inherit;font-variant-numeric:tabular-nums;cursor:pointer}",
1337
+ ".{p}-dp-day:hover{background:color-mix(in srgb,var(--wb-accent) 12%,transparent)}",
1338
+ ".{p}-dp-day.is-between{background:color-mix(in srgb,var(--wb-accent) 16%,transparent);border-radius:0}",
1339
+ ".{p}-dp-day.is-today{box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--wb-accent) 55%,transparent)}",
1340
+ ".{p}-dp-day.is-on{background:var(--wb-accent);color:var(--wb-on-accent,inherit);font-weight:600}",
1341
+ ".{p}-dp-day:disabled{opacity:.35;cursor:not-allowed}",
1342
+ ".{p}-dp-day:focus-visible{outline:2px solid var(--wb-accent);outline-offset:-2px}",
1343
+ ".{p}-dp-foot{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-top:8px;padding-top:8px;border-top:1px solid var(--wb-line)}",
1344
+ ".{p}-dp-acts{display:flex;flex-wrap:wrap;gap:6px;margin-top:6px}",
1345
+ ".{p}-dp-link{padding:4px 8px;border:0;border-radius:6px;background:color-mix(in srgb,var(--wb-muted) 12%,transparent);color:inherit;font:inherit;font-size:12px;cursor:pointer}",
1346
+ ".{p}-dp-link:hover{background:color-mix(in srgb,var(--wb-accent) 16%,transparent);color:var(--wb-accent)}",
1347
+ ".{p}-dp-hint{margin:6px 0 0;font-size:11px;color:var(--wb-muted)}",
1348
+ ".{p}-dp-pop.is-months{width:248px}",
1349
+ ".{p}-dp-months{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:4px;margin-bottom:6px}",
1350
+ ".{p}-dp-months .{p}-dp-day{height:34px}",
1351
+ "@keyframes {p}-dp-in{from{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:none}}"
1352
+ ].join("\n").replace(/\{p\}/g, p);
1353
+ };
1354
+ }
1355
+ });
1356
+
766
1357
  // packages/addons/sites/client/stats/charts.cjs
767
1358
  var require_charts = __commonJS({
768
1359
  "packages/addons/sites/client/stats/charts.cjs"(exports2, module2) {
769
1360
  var React2 = require("react");
770
1361
  var h2 = React2.createElement;
1362
+ var DP = require_date_picker();
771
1363
  var ICONS = {
772
1364
  "refresh": (init_refresh_cw(), __toCommonJS(refresh_cw_exports)).default,
773
1365
  "globe": (init_globe(), __toCommonJS(globe_exports)).default,
@@ -794,8 +1386,7 @@ var require_charts = __commonJS({
794
1386
  ".@-seg{display:inline-flex;border:1px solid var(--dsw-alias-border-l2,#e5e6eb);border-radius:9px;overflow:hidden;background:var(--dsw-alias-bg-layer-1,#fff)}",
795
1387
  ".@-seg button{appearance:none;border:0;background:transparent;color:var(--dsw-alias-label-secondary,#646a73);font-size:12px;padding:6px 10px;cursor:pointer;white-space:nowrap}",
796
1388
  ".@-seg button.@-on{background:var(--dsw-alias-brand-primary,#4f6ef7);color:var(--dsw-alias-label-primary-inverted,#fff)}",
797
- ".@-range{display:inline-flex;align-items:center;gap:4px;border:1px solid var(--dsw-alias-border-l2,#e5e6eb);border-radius:9px;padding:2px 6px;background:var(--dsw-alias-bg-layer-1,#fff)}",
798
- ".@-range:focus-within{border-color:var(--dsw-alias-brand-primary,#4f6ef7)}",
1389
+ ".@-range{display:inline-flex;align-items:center;gap:4px}",
799
1390
  ".@-date{appearance:none;border:0;background:transparent;color:var(--dsw-alias-label-secondary,#646a73);font-family:inherit;font-size:12px;padding:4px 2px;width:116px;outline:none}",
800
1391
  ".@-date::-webkit-calendar-picker-indicator{opacity:.55;cursor:pointer}",
801
1392
  ".@-dash{color:var(--dsw-alias-label-tertiary,#8f959e);font-size:12px}",
@@ -859,7 +1450,8 @@ var require_charts = __commonJS({
859
1450
  "@keyframes @-pulse{0%,100%{opacity:.55}50%{opacity:1}}",
860
1451
  "@media (max-width:900px){.@-scard{grid-column:span 12}.@-span-3,.@-span-4,.@-span-6,.@-span-8{grid-column:span 12}.@-kpis{grid-template-columns:repeat(2,minmax(0,1fr))}}",
861
1452
  "@media (max-width:600px){.@-stats{padding-bottom:16px}.@-hist{height:130px}.@-kpi-v{font-size:22px}}",
862
- "@media (prefers-reduced-motion:reduce){.@-sk{animation:none}}"
1453
+ "@media (prefers-reduced-motion:reduce){.@-sk{animation:none}}",
1454
+ require_date_picker_styles()(prefix)
863
1455
  ].join("\n").replace(/@-/g, prefix + "-");
864
1456
  }
865
1457
  function makeCharts(prefix) {
@@ -1166,28 +1758,18 @@ var require_charts = __commonJS({
1166
1758
  h2(
1167
1759
  "div",
1168
1760
  { className: prefix + "-range", role: "group", "aria-label": props.customAria || "\u81EA\u5B9A\u4E49\u65E5\u671F\u8303\u56F4" },
1169
- h2("input", {
1170
- type: "date",
1171
- className: prefix + "-date",
1172
- value: from,
1173
- max: props.today || void 0,
1174
- "aria-label": props.fromLabel || "\u8D77\u59CB\u65E5\u671F",
1175
- title: props.fromLabel || "\u8D77\u59CB\u65E5\u671F",
1176
- onChange: function(e) {
1177
- setDate("from", e.target.value);
1178
- }
1179
- }),
1180
- h2("span", { className: prefix + "-dash", "aria-hidden": "true" }, "\u2013"),
1181
- h2("input", {
1182
- type: "date",
1183
- className: prefix + "-date",
1184
- value: to,
1185
- min: from || void 0,
1761
+ h2(DP.RangePicker, {
1762
+ React: React2,
1763
+ h: h2,
1764
+ prefix,
1765
+ lang: props.lang,
1766
+ label: props.customAria || "\u81EA\u5B9A\u4E49\u65E5\u671F\u8303\u56F4",
1767
+ value: { from, to },
1186
1768
  max: props.today || void 0,
1187
- "aria-label": props.toLabel || "\u7EC8\u6B62\u65E5\u671F",
1188
- title: props.toLabel || "\u7EC8\u6B62\u65E5\u671F",
1189
- onChange: function(e) {
1190
- setDate("to", e.target.value);
1769
+ clearable: false,
1770
+ onChange: function(next) {
1771
+ if (typeof props.onCustomChange !== "function") return;
1772
+ props.onCustomChange({ from: next.from, to: next.to });
1191
1773
  }
1192
1774
  }),
1193
1775
  from || to ? h2("button", {
@@ -2615,7 +3197,9 @@ var require_data_view = __commonJS({
2615
3197
  }
2616
3198
  function loadTables() {
2617
3199
  setLoadingTables(true);
2618
- Promise.resolve(api.call(DOMAIN + ".dataTables")).then(function(r) {
3200
+ Promise.resolve((options.tablesLoader || function(a) {
3201
+ return a.call(DOMAIN + ".dataTables");
3202
+ })(api)).then(function(r) {
2619
3203
  if (r && r.ok === false) throw new Error(r && r.error || t.loadFail);
2620
3204
  var body = unwrap(r);
2621
3205
  if (!body || !Array.isArray(body.tables)) throw new Error(t.loadFail);
@@ -2680,7 +3264,9 @@ var require_data_view = __commonJS({
2680
3264
  if (sort) args.sort = sort;
2681
3265
  if (search) args.search = search;
2682
3266
  if (Object.keys(filters).length) args.filters = filters;
2683
- Promise.resolve(api.call(DOMAIN + ".dataQuery", args)).then(function(r) {
3267
+ Promise.resolve((options.query || function(a, q) {
3268
+ return a.call(DOMAIN + ".dataQuery", q);
3269
+ })(api, args)).then(function(r) {
2684
3270
  if (req !== reqRef.current) return;
2685
3271
  if (r && r.ok === false) throw new Error(r && r.error || t.queryFail);
2686
3272
  var body = unwrap(r);
@@ -3062,7 +3648,7 @@ var require_data_view = __commonJS({
3062
3648
  }
3063
3649
  }
3064
3650
  }),
3065
- h2("span", null, fmt(t.queryTime, { n: data ? data.queryMs : 0 }))
3651
+ data && data.queryMs !== void 0 ? h2("span", null, fmt(t.queryTime, { n: data.queryMs })) : null
3066
3652
  );
3067
3653
  }
3068
3654
  if (!tables && loadingTables && options.Skeleton) return h2(options.Skeleton, { lang, label: t.loading });
@@ -3098,7 +3684,7 @@ var require_data_view = __commonJS({
3098
3684
  "span",
3099
3685
  { className: P + "-stabname" },
3100
3686
  h2("span", null, tableLabel(tb)),
3101
- h2("span", { className: P + "-sidecount" }, String(tb.count))
3687
+ h2("span", { className: P + "-sidecount" }, tb.count === void 0 || tb.count === null ? "" : String(tb.count))
3102
3688
  ),
3103
3689
  h2("span", { className: P + "-sidetable" }, tb.name)
3104
3690
  );
@@ -3125,7 +3711,7 @@ var require_data_view = __commonJS({
3125
3711
  h2(
3126
3712
  "div",
3127
3713
  { className: P + "-sub" },
3128
- current ? fmt(t.rowCount, { n: current.count }) : "",
3714
+ current && data && data.total !== void 0 ? fmt(t.rowCount, { n: data.total }) : "",
3129
3715
  current && current.deletedCount ? " \xB7 " + fmt(t.deletedCount, { n: current.deletedCount }) : "",
3130
3716
  " \xB7 " + t.subtitle
3131
3717
  )
@@ -4068,6 +4654,7 @@ var require_copy = __commonJS({
4068
4654
  cancel: "\u53D6\u6D88",
4069
4655
  close: "\u5173\u95ED",
4070
4656
  sensitiveHint: "\u5BC6\u7801/\u624B\u673A\u53F7/\u8EAB\u4EFD\u8BC1\u5199\u5E93\u524D\u52A0\u5BC6\uFF0C\u4EC5\u5728\u754C\u9762\u89E3\u9501\u4FDD\u9669\u7BB1\u540E\u53EF\u67E5\u770B\u4E0E\u590D\u5236\u3002",
4657
+ vaultInvalid: "\u51ED\u636E\u96C6\u5408\u5DF2\u5931\u6548\uFF08\u96C6\u5408\u88AB\u5220\u9664\uFF09\uFF0C\u4FDD\u5B58\u4EFB\u4E00\u654F\u611F\u5B57\u6BB5\u5373\u53EF\u91CD\u5EFA\u3002",
4071
4658
  vaultNotSet: "\u8D26\u53F7\u4FDD\u9669\u7BB1\u5C1A\u672A\u8BBE\u7F6E\u53E3\u4EE4\uFF1A\u8BBE\u7F6E\u53E3\u4EE4\u540E\u624D\u80FD\u586B\u5199\u5BC6\u7801\u3001\u624B\u673A\u53F7\u4E0E\u8EAB\u4EFD\u8BC1\u3002",
4072
4659
  vaultLocked: "\u8D26\u53F7\u4FDD\u9669\u7BB1\u5DF2\u9501\u5B9A\uFF1A\u8F93\u5165\u53E3\u4EE4\u540E\u5373\u53EF\u67E5\u770B\u4E0E\u586B\u5199\u654F\u611F\u5B57\u6BB5\u3002",
4073
4660
  vaultUnlocked: "\u8D26\u53F7\u4FDD\u9669\u7BB1\u5DF2\u89E3\u9501\uFF0C\u7A7A\u95F2 {min} \u5206\u949F\u81EA\u52A8\u9501\u5B9A\u3002",
@@ -4077,7 +4664,9 @@ var require_copy = __commonJS({
4077
4664
  passphrase: "\u8F93\u5165\u53E3\u4EE4\uFF08\u81F3\u5C11 8 \u4F4D\uFF09",
4078
4665
  passphraseAgain: "\u518D\u8F93\u4E00\u6B21\u53E3\u4EE4",
4079
4666
  passTooShort: "\u53E3\u4EE4\u81F3\u5C11 8 \u4F4D",
4080
- passMismatch: "\u4E24\u6B21\u53E3\u4EE4\u4E0D\u4E00\u81F4"
4667
+ passMismatch: "\u4E24\u6B21\u53E3\u4EE4\u4E0D\u4E00\u81F4",
4668
+ showPlain: "\u663E\u793A\u660E\u6587",
4669
+ hidePlain: "\u9690\u85CF\u660E\u6587"
4081
4670
  },
4082
4671
  en: {
4083
4672
  title: "Sites",
@@ -4179,6 +4768,7 @@ var require_copy = __commonJS({
4179
4768
  cancel: "Cancel",
4180
4769
  close: "Close",
4181
4770
  sensitiveHint: "Password / phone / ID card are encrypted before writing and can only be read after unlocking the vault.",
4771
+ vaultInvalid: "The credential set is gone (deleted); saving any sensitive field rebuilds it.",
4182
4772
  vaultNotSet: "Vault passphrase is not set yet: set one before filling in password, phone or ID card.",
4183
4773
  vaultLocked: "Vault is locked: unlock to view or edit sensitive fields.",
4184
4774
  vaultUnlocked: "Vault unlocked; it locks after {min} idle minutes.",
@@ -4188,12 +4778,95 @@ var require_copy = __commonJS({
4188
4778
  passphrase: "Passphrase (8+ characters)",
4189
4779
  passphraseAgain: "Repeat passphrase",
4190
4780
  passTooShort: "Passphrase must be at least 8 characters",
4191
- passMismatch: "Passphrases do not match"
4781
+ passMismatch: "Passphrases do not match",
4782
+ showPlain: "Show plain text",
4783
+ hidePlain: "Hide plain text"
4192
4784
  }
4193
4785
  };
4194
4786
  }
4195
4787
  });
4196
4788
 
4789
+ // packages/addons/lib/filter-checklist-styles.cjs
4790
+ var require_filter_checklist_styles = __commonJS({
4791
+ "packages/addons/lib/filter-checklist-styles.cjs"(exports2, module2) {
4792
+ "use strict";
4793
+ module2.exports = [
4794
+ ".wbck{display:flex;flex-direction:column;min-width:0}",
4795
+ ".wbck-search{padding:0 0 6px}",
4796
+ ".wbck-input{width:100%;box-sizing:border-box;font:inherit;font-size:12.5px;padding:6px 9px;border:1px solid var(--wb-border);border-radius:8px;background:var(--wb-surface);color:inherit}",
4797
+ ".wbck-input:focus-visible{outline:2px solid var(--wb-accent);outline-offset:1px}",
4798
+ ".wbck-input:disabled{opacity:.6;cursor:not-allowed}",
4799
+ ".wbck-head{display:flex;align-items:center;gap:6px;font-size:11.5px;color:var(--wb-muted);padding:2px 4px 7px}",
4800
+ ".wbck-grow{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}",
4801
+ ".wbck-sel{flex:none;color:var(--wb-accent)}",
4802
+ ".wbck-clear{appearance:none;flex:none;border:0;background:transparent;color:inherit;border-radius:4px;margin:0;padding:3px 5px;font:inherit;font-size:11.5px;line-height:1;cursor:pointer;opacity:.75}",
4803
+ ".wbck-clear:hover:enabled{opacity:1;background:color-mix(in srgb, currentColor 8%, transparent)}",
4804
+ ".wbck-clear:focus-visible{outline:2px solid var(--wb-accent);outline-offset:1px}",
4805
+ ".wbck-clear:disabled{opacity:.4;cursor:not-allowed}",
4806
+ ".wbck-list{max-height:220px;overflow:auto;overscroll-behavior:contain;border:1px solid var(--wb-border);border-radius:10px;padding:2px}",
4807
+ ".wbck-opt{display:flex;align-items:center;gap:7px;padding:6px;border-radius:6px;font-size:12.5px;cursor:pointer}",
4808
+ ".wbck-opt:hover{background:color-mix(in srgb, currentColor 7%, transparent)}",
4809
+ ".wbck-opt.is-on{background:color-mix(in srgb, var(--wb-accent) 10%, transparent)}",
4810
+ ".wbck-opt input{margin:0;flex:none;accent-color:var(--wb-accent)}",
4811
+ // 单选变体用 button 渲染(role="radio"),这里把浏览器默认按钮样式清掉,视觉与多选行一致。
4812
+ '.wbck-opt[role="radio"]{appearance:none;width:100%;box-sizing:border-box;border:0;background:transparent;color:inherit;font:inherit;text-align:left}',
4813
+ '.wbck-opt[role="radio"]:disabled{opacity:.55;cursor:not-allowed}',
4814
+ '.wbck-opt[role="radio"]:focus-visible{outline:2px solid var(--wb-accent);outline-offset:-2px}',
4815
+ ".wbck-nm{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}",
4816
+ ".wbck-meta{margin-left:auto;flex:none;font-size:11.5px;color:var(--wb-muted)}",
4817
+ ".wbck-note{font-size:12px;color:var(--wb-muted);padding:8px 6px}",
4818
+ ".wbck-more{font-size:11px;color:var(--wb-muted);text-align:center;padding:6px 0 2px;opacity:.8}",
4819
+ "@media (max-width:760px){.wbck-list{max-height:200px}}"
4820
+ ];
4821
+ }
4822
+ });
4823
+
4824
+ // packages/addons/lib/client-base-styles.cjs
4825
+ var require_client_base_styles = __commonJS({
4826
+ "packages/addons/lib/client-base-styles.cjs"(exports2, module2) {
4827
+ "use strict";
4828
+ var SECRET_FIELD = [
4829
+ ".wb-secret-field{position:relative;display:flex;align-items:center;min-width:0}",
4830
+ ".wb-secret-field input{flex:1 1 auto;min-width:0;padding-right:34px}",
4831
+ ".wb-eye{position:absolute;right:4px;display:inline-flex;align-items:center;justify-content:center;background:transparent;border:0;border-radius:6px;padding:4px;color:var(--wb-muted,#6b7280);cursor:pointer}",
4832
+ ".wb-eye:hover:not(:disabled){color:var(--wb-accent,#2563eb);background:color-mix(in srgb, var(--wb-accent,#2563eb) 12%, transparent)}",
4833
+ ".wb-eye:focus-visible{outline:2px solid var(--wb-accent,#2563eb);outline-offset:1px}",
4834
+ ".wb-eye:disabled{opacity:.45;cursor:not-allowed}"
4835
+ ];
4836
+ module2.exports = function baseStyles(prefix) {
4837
+ var p = String(prefix || "wb");
4838
+ var s = "." + p;
4839
+ return SECRET_FIELD.concat([
4840
+ s + "-wrap{display:flex;flex-direction:column;gap:12px;padding:16px;overflow:auto;height:100%;box-sizing:border-box}",
4841
+ s + "-head{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap}",
4842
+ s + "-title{font-size:16px;font-weight:650;margin:0}",
4843
+ s + "-sub{font-size:12px;color:var(--wb-muted,#6b7280);margin:2px 0 0}",
4844
+ s + "-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}",
4845
+ s + "-card{border:1px solid var(--wb-border,#e5e7eb);border-radius:10px;background:var(--wb-surface,#fff);padding:12px}",
4846
+ s + "-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:10px}",
4847
+ s + "-kpi{font-size:22px;font-weight:700;line-height:1.2}" + s + "-kpi-label{font-size:12px;color:var(--wb-muted,#6b7280)}",
4848
+ s + "-table{width:100%;border-collapse:collapse;font-size:12px}" + s + "-table th," + s + "-table td{padding:7px 8px;border-bottom:1px solid var(--wb-border,#eef0f3);text-align:left;vertical-align:top}",
4849
+ s + "-table th{font-weight:600;color:var(--wb-muted,#6b7280);white-space:nowrap}",
4850
+ s + "-btn{border:1px solid var(--wb-border,#d1d5db);background:var(--wb-surface,#fff);color:inherit;border-radius:7px;padding:5px 10px;font-size:12px;cursor:pointer}",
4851
+ s + "-btn:hover:not(:disabled){border-color:var(--wb-accent,#2563eb)}" + s + "-btn:disabled{opacity:.5;cursor:default}",
4852
+ s + "-btn.primary{background:var(--wb-accent,#2563eb);border-color:var(--wb-accent,#2563eb);color:#fff}",
4853
+ s + "-btn.danger{color:#b91c1c;border-color:#fecaca}",
4854
+ s + "-field{display:flex;flex-direction:column;gap:4px;font-size:12px}" + s + "-label{font-weight:600}",
4855
+ s + "-field input," + s + "-field select," + s + "-field textarea{border:1px solid var(--wb-border,#d1d5db);border-radius:7px;padding:6px 8px;font:inherit;background:var(--wb-surface,#fff);color:inherit;min-width:0}",
4856
+ s + "-hint{color:var(--wb-muted,#6b7280);font-size:11px}" + s + "-notice{padding:8px 10px;border-radius:8px;font-size:12px;background:#eff6ff;color:#1e40af}",
4857
+ s + "-notice.error{background:#fef2f2;color:#b91c1c}" + s + "-notice.ok{background:#ecfdf5;color:#047857}",
4858
+ s + "-empty{padding:18px;text-align:center;color:var(--wb-muted,#6b7280);font-size:12px;border:1px dashed var(--wb-border,#e5e7eb);border-radius:8px}",
4859
+ s + "-pill{display:inline-block;padding:1px 7px;border-radius:999px;font-size:11px;background:#f3f4f6;color:#374151}",
4860
+ s + "-pill.ok{background:#ecfdf5;color:#047857}" + s + "-pill.error{background:#fef2f2;color:#b91c1c}" + s + "-pill.warn{background:#fffbeb;color:#b45309}",
4861
+ s + "-json{margin:0;padding:8px;background:#f8fafc;border-radius:8px;font-size:11px;max-height:240px;overflow:auto}",
4862
+ s + "-muted{color:var(--wb-muted,#6b7280)}" + s + "-link{color:var(--wb-accent,#2563eb);cursor:pointer;text-decoration:none}",
4863
+ s + "-form{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:10px}"
4864
+ ]);
4865
+ };
4866
+ module2.exports.secretFieldStyles = SECRET_FIELD;
4867
+ }
4868
+ });
4869
+
4197
4870
  // packages/addons/sites/client/ui/styles.cjs
4198
4871
  var require_styles = __commonJS({
4199
4872
  "packages/addons/sites/client/ui/styles.cjs"(exports2, module2) {
@@ -4350,55 +5023,592 @@ var require_styles = __commonJS({
4350
5023
  ".wbs-note{font-size:11px;color:var(--wbs-muted);line-height:1.6}",
4351
5024
  "@media(max-width:860px){.wbs-body{flex-direction:column}.wbs-tree{width:100%;max-height:220px}.wbs-table{min-width:760px}.wbs-root{min-height:0}}",
4352
5025
  "@media(max-width:600px){.wbs-head h2{font-size:18px}.wbs-linkrow{grid-template-columns:1fr 1fr}.wbs-modal{padding:14px}}"
4353
- ].join("\n");
5026
+ ].concat(require_filter_checklist_styles()).concat(require_client_base_styles().secretFieldStyles).concat([require_date_picker_styles()("wbs")]).join("\n");
4354
5027
  }
4355
5028
  });
4356
5029
 
4357
- // packages/addons/lib/highlight.cjs
4358
- var require_highlight = __commonJS({
4359
- "packages/addons/lib/highlight.cjs"(exports2, module2) {
5030
+ // packages/addons/lib/secret-field.cjs
5031
+ var require_secret_field = __commonJS({
5032
+ "packages/addons/lib/secret-field.cjs"(exports2, module2) {
4360
5033
  "use strict";
4361
- module2.exports = function(React2) {
4362
- var h2 = React2.createElement;
4363
- function sourceOf(keyword) {
4364
- var pattern = keyword.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
4365
- return pattern.replace(/[a-zA-Z]/g, function(letter) {
4366
- return "[" + letter.toLowerCase() + letter.toUpperCase() + "]";
4367
- });
4368
- }
4369
- return function createHighlight(prefix) {
4370
- var className = String(prefix || "wb") + "-hit";
4371
- function hit(rawText, rawKeyword) {
4372
- var text = rawText == null ? "" : String(rawText);
4373
- var keyword = rawKeyword == null ? "" : String(rawKeyword);
4374
- if (!keyword) return text;
4375
- var matcher, match, end = 0, parts = [];
5034
+ var Eye2 = (init_eye(), __toCommonJS(eye_exports)).default;
5035
+ var EyeOff2 = (init_eye_off(), __toCommonJS(eye_off_exports)).default;
5036
+ function SecretField(props) {
5037
+ var h2 = props.h;
5038
+ var show = Boolean(props.show);
5039
+ var label = show ? props.hideLabel || "\u9690\u85CF\u660E\u6587" : props.showLabel || "\u663E\u793A\u660E\u6587";
5040
+ var Ico = show ? EyeOff2 : Eye2;
5041
+ function toggle(e) {
5042
+ e.preventDefault();
5043
+ e.stopPropagation();
5044
+ var box = e.currentTarget && e.currentTarget.parentNode;
5045
+ if (props.onToggle) props.onToggle();
5046
+ var input = box && box.querySelector ? box.querySelector("input") : null;
5047
+ if (!input || !input.focus) return;
5048
+ input.focus();
5049
+ var end = String(input.value == null ? "" : input.value).length;
5050
+ if (input.setSelectionRange) {
4376
5051
  try {
4377
- matcher = new RegExp(sourceOf(keyword), "g");
4378
- } catch (error) {
4379
- return text;
4380
- }
4381
- while (match = matcher.exec(text)) {
4382
- if (match.index > end) parts.push(text.slice(end, match.index));
4383
- parts.push(h2("mark", { className, key: match.index }, match[0]));
4384
- end = match.index + match[0].length;
4385
- if (!match[0]) matcher.lastIndex += 1;
5052
+ input.setSelectionRange(end, end);
5053
+ } catch (err) {
4386
5054
  }
4387
- if (!parts.length) return text;
4388
- if (end < text.length) parts.push(text.slice(end));
4389
- return parts;
4390
- }
4391
- function Highlight(props) {
4392
- return hit(props.text, props.keyword);
4393
5055
  }
4394
- Highlight.hit = hit;
4395
- return Highlight;
4396
- };
4397
- };
4398
- }
4399
- });
4400
-
4401
- // packages/addons/lib/action-schema-style.cjs
5056
+ }
5057
+ return h2(
5058
+ "div",
5059
+ { className: "wb-secret-field" + (props.className ? " " + props.className : "") },
5060
+ h2("input", {
5061
+ type: show ? "text" : "password",
5062
+ className: props.inputClassName || void 0,
5063
+ id: props.id || void 0,
5064
+ name: props.name || void 0,
5065
+ autoComplete: props.autoComplete || "new-password",
5066
+ autoFocus: props.autoFocus ? true : void 0,
5067
+ spellCheck: false,
5068
+ disabled: props.disabled ? true : void 0,
5069
+ "aria-label": props.ariaLabel || void 0,
5070
+ value: props.value == null ? "" : props.value,
5071
+ placeholder: props.placeholder || void 0,
5072
+ onChange: function(e) {
5073
+ if (props.onChange) props.onChange(e.target.value);
5074
+ },
5075
+ onKeyDown: props.onKeyDown || void 0
5076
+ }),
5077
+ h2("button", {
5078
+ type: "button",
5079
+ className: "wb-eye",
5080
+ title: label,
5081
+ "aria-label": label,
5082
+ "aria-pressed": show ? "true" : "false",
5083
+ tabIndex: props.disabled ? -1 : void 0,
5084
+ onClick: toggle
5085
+ }, h2(Ico, { size: 15, strokeWidth: 2, "aria-hidden": "true" }))
5086
+ );
5087
+ }
5088
+ module2.exports = SecretField;
5089
+ }
5090
+ });
5091
+
5092
+ // packages/addons/sites/client/ui/accounts-modal.cjs
5093
+ var require_accounts_modal = __commonJS({
5094
+ "packages/addons/sites/client/ui/accounts-modal.cjs"(exports2, module2) {
5095
+ "use strict";
5096
+ module2.exports = function createAccountsModal(deps) {
5097
+ var h2 = deps.h;
5098
+ var React2 = deps.React;
5099
+ var useState = deps.useState;
5100
+ var useEffect = deps.useEffect;
5101
+ var Modal = deps.Modal;
5102
+ var Icon2 = deps.Icon;
5103
+ var text = deps.text;
5104
+ var callApi = deps.callApi;
5105
+ var errText = deps.errText;
5106
+ var SecretField = require_secret_field();
5107
+ function AccountModal(props) {
5108
+ var api = props.api;
5109
+ var lang = props.lang || "zh";
5110
+ var site = props.site;
5111
+ var [accounts, setAccounts] = useState([]);
5112
+ var [vault, setVault] = useState({});
5113
+ var [loading, setLoading] = useState(true);
5114
+ var [error, setError] = useState("");
5115
+ var [busy, setBusy] = useState(false);
5116
+ var [draft, setDraft] = useState(null);
5117
+ var [pass, setPass] = useState("");
5118
+ var [pass2, setPass2] = useState("");
5119
+ var [cascade, setCascade] = useState([]);
5120
+ var [pickKey, setPickKey] = useState("");
5121
+ var [pendingDelete, setPendingDelete] = useState("");
5122
+ var [shown, setShown] = useState({});
5123
+ var [binding, setBinding] = useState(null);
5124
+ var [vaultPassShow, setVaultPassShow] = useState(false);
5125
+ var [vaultPass2Show, setVaultPass2Show] = useState(false);
5126
+ var [draftPassShow, setDraftPassShow] = useState(false);
5127
+ function mapVault(st) {
5128
+ var r = st || {};
5129
+ var idle = Number(r.idleTimeoutSec) > 0 ? Math.round(Number(r.idleTimeoutSec) / 60) : 15;
5130
+ return {
5131
+ installed: true,
5132
+ enabled: Boolean(r.initialized),
5133
+ unlocked: !r.locked,
5134
+ locked: Boolean(r.locked),
5135
+ unlockMode: r.unlockMode,
5136
+ idleMinutes: idle,
5137
+ remainingMs: r.locked ? 0 : idle * 60 * 1e3
5138
+ };
5139
+ }
5140
+ function reload() {
5141
+ setLoading(true);
5142
+ return Promise.all([
5143
+ callApi(api, "sites.accounts.list", { siteId: site.id }),
5144
+ callApi(api, "vault.status", {}),
5145
+ callApi(api, "vault.bindingsOf", { subjectType: "site", subjectId: site.id })
5146
+ ]).then(function(out) {
5147
+ setAccounts(out[0].accounts || []);
5148
+ setVault(mapVault(out[1]));
5149
+ setBinding(out[2] && out[2].items && out[2].items[0] || null);
5150
+ setError("");
5151
+ }).catch(function(e) {
5152
+ setError(errText(e));
5153
+ }).finally(function() {
5154
+ setLoading(false);
5155
+ });
5156
+ }
5157
+ function loadCascade() {
5158
+ callApi(api, "sites.accounts.cascade", { excludeSiteId: site.id }).then(function(r) {
5159
+ var list = [];
5160
+ (r.groups || []).forEach(function(g) {
5161
+ g.accounts.forEach(function(a) {
5162
+ list.push({ id: a.id, label: g.siteName + " \xB7 " + a.accountKey });
5163
+ });
5164
+ });
5165
+ setCascade(list);
5166
+ }).catch(function() {
5167
+ setCascade([]);
5168
+ });
5169
+ }
5170
+ useEffect(function() {
5171
+ reload();
5172
+ loadCascade();
5173
+ }, [site.id]);
5174
+ function guard(fn) {
5175
+ setBusy(true);
5176
+ setError("");
5177
+ return Promise.resolve().then(fn).catch(function(e) {
5178
+ setError(errText(e));
5179
+ }).finally(function() {
5180
+ setBusy(false);
5181
+ });
5182
+ }
5183
+ function submitVault() {
5184
+ if (!pass || pass.length < 12) {
5185
+ setError(text(lang, "passTooShort"));
5186
+ return;
5187
+ }
5188
+ if (!vault.enabled && pass !== pass2) {
5189
+ setError(text(lang, "passMismatch"));
5190
+ return;
5191
+ }
5192
+ guard(function() {
5193
+ var req = vault.enabled ? callApi(api, "vault.unlock", { passphrase: pass }) : callApi(api, "vault.setup", { passphrase: pass, mode: "A" });
5194
+ return req.then(function() {
5195
+ setPass("");
5196
+ setPass2("");
5197
+ return reload();
5198
+ });
5199
+ });
5200
+ }
5201
+ function lockVault() {
5202
+ guard(function() {
5203
+ return callApi(api, "vault.lock", {}).then(function() {
5204
+ setShown({});
5205
+ return reload();
5206
+ });
5207
+ });
5208
+ }
5209
+ function bindGroup() {
5210
+ guard(function() {
5211
+ return callApi(api, "vault.groupCreate", { name: "\u7AD9\u70B9\u8D26\u53F7 \xB7 " + (site.siteName || site.id) }).then(function(g) {
5212
+ return callApi(api, "vault.bind", { subjectType: "site", subjectId: site.id, groupId: g.id });
5213
+ }).then(function() {
5214
+ return reload();
5215
+ });
5216
+ });
5217
+ }
5218
+ function saveDraft() {
5219
+ var body = {
5220
+ accountKey: draft.accountKey,
5221
+ account: draft.account,
5222
+ remark: draft.remark
5223
+ };
5224
+ if (draft.password) body.password = draft.password;
5225
+ if (draft.phoneNumber) body.phoneNumber = draft.phoneNumber;
5226
+ if (draft.identityCard) body.identityCard = draft.identityCard;
5227
+ guard(function() {
5228
+ var req = draft.id ? callApi(api, "sites.accounts.update", Object.assign({ id: draft.id }, body)) : callApi(api, "sites.accounts.create", Object.assign({ siteId: site.id }, body));
5229
+ return req.then(function() {
5230
+ setDraft(null);
5231
+ props.onChanged && props.onChanged();
5232
+ return reload();
5233
+ });
5234
+ });
5235
+ }
5236
+ function removeAccount(id) {
5237
+ guard(function() {
5238
+ return callApi(api, "sites.accounts.delete", { id }).then(function() {
5239
+ setPendingDelete("");
5240
+ props.onChanged && props.onChanged();
5241
+ return reload();
5242
+ });
5243
+ });
5244
+ }
5245
+ function reveal(acc) {
5246
+ guard(function() {
5247
+ return callApi(api, "sites.accounts.get", { id: acc.id }).then(function(r) {
5248
+ var ids = r.secretIds || {};
5249
+ var jobs = [["password", "password"], ["phone", "phoneNumber"], ["identity", "identityCard"]].filter(function(pair) {
5250
+ return ids[pair[0]];
5251
+ }).map(function(pair) {
5252
+ return callApi(api, "vault.secretReveal", { id: ids[pair[0]] }).then(function(res) {
5253
+ var v = {};
5254
+ v[pair[1]] = res && res.secret !== void 0 ? res.secret : "";
5255
+ return v;
5256
+ }).catch(function() {
5257
+ return null;
5258
+ });
5259
+ });
5260
+ return Promise.all(jobs).then(function(list) {
5261
+ var out = {};
5262
+ list.forEach(function(v) {
5263
+ if (v) Object.assign(out, v);
5264
+ });
5265
+ setShown(function(prev) {
5266
+ var next = Object.assign({}, prev);
5267
+ next[acc.id] = out;
5268
+ return next;
5269
+ });
5270
+ });
5271
+ });
5272
+ });
5273
+ }
5274
+ function copyText(value) {
5275
+ if (!value) return;
5276
+ try {
5277
+ navigator.clipboard.writeText(value);
5278
+ if (typeof showToast === "function") showToast(text(lang, "copied"));
5279
+ } catch (e) {
5280
+ setError(String(e && e.message || e));
5281
+ }
5282
+ }
5283
+ function linkExternal(acc) {
5284
+ if (!pickKey) return;
5285
+ guard(function() {
5286
+ return callApi(api, "sites.accounts.link", { nativeAccountId: acc.id, externalAccountId: pickKey }).then(function() {
5287
+ setPickKey("");
5288
+ return reload();
5289
+ });
5290
+ });
5291
+ }
5292
+ function unlink(acc, rel) {
5293
+ guard(function() {
5294
+ return callApi(api, "sites.accounts.unlink", { nativeAccountId: acc.id, externalAccountId: rel.accountId }).then(function() {
5295
+ return reload();
5296
+ });
5297
+ });
5298
+ }
5299
+ function renderVaultBar() {
5300
+ if (!vault.enabled) {
5301
+ return h2(
5302
+ "div",
5303
+ { className: "wbs-vaultbar" },
5304
+ h2("div", { className: "wbs-vault-hint" }, text(lang, "vaultNotSet")),
5305
+ h2(
5306
+ "div",
5307
+ { className: "wbs-vault-form" },
5308
+ h2(SecretField, {
5309
+ h: h2,
5310
+ inputClassName: "wbs-input",
5311
+ autoComplete: "new-password",
5312
+ ariaLabel: text(lang, "passphrase"),
5313
+ placeholder: text(lang, "passphrase"),
5314
+ showLabel: text(lang, "showPlain"),
5315
+ hideLabel: text(lang, "hidePlain"),
5316
+ value: pass,
5317
+ show: vaultPassShow,
5318
+ onChange: setPass,
5319
+ onToggle: function() {
5320
+ setVaultPassShow(!vaultPassShow);
5321
+ }
5322
+ }),
5323
+ h2(SecretField, {
5324
+ h: h2,
5325
+ inputClassName: "wbs-input",
5326
+ autoComplete: "new-password",
5327
+ ariaLabel: text(lang, "passphraseAgain"),
5328
+ placeholder: text(lang, "passphraseAgain"),
5329
+ showLabel: text(lang, "showPlain"),
5330
+ hideLabel: text(lang, "hidePlain"),
5331
+ value: pass2,
5332
+ show: vaultPass2Show,
5333
+ onChange: setPass2,
5334
+ onToggle: function() {
5335
+ setVaultPass2Show(!vaultPass2Show);
5336
+ }
5337
+ }),
5338
+ h2("button", { className: "wbs-btn", disabled: busy, onClick: submitVault }, text(lang, "vaultSetup"))
5339
+ )
5340
+ );
5341
+ }
5342
+ if (!vault.unlocked) {
5343
+ return h2(
5344
+ "div",
5345
+ { className: "wbs-vaultbar locked" },
5346
+ h2("div", { className: "wbs-vault-hint" }, text(lang, "vaultLocked")),
5347
+ h2(
5348
+ "div",
5349
+ { className: "wbs-vault-form" },
5350
+ h2(SecretField, {
5351
+ h: h2,
5352
+ inputClassName: "wbs-input",
5353
+ autoComplete: "current-password",
5354
+ ariaLabel: text(lang, "passphrase"),
5355
+ placeholder: text(lang, "passphrase"),
5356
+ showLabel: text(lang, "showPlain"),
5357
+ hideLabel: text(lang, "hidePlain"),
5358
+ value: pass,
5359
+ show: vaultPassShow,
5360
+ onChange: setPass,
5361
+ onToggle: function() {
5362
+ setVaultPassShow(!vaultPassShow);
5363
+ }
5364
+ }),
5365
+ h2("button", { className: "wbs-btn", disabled: busy, onClick: submitVault }, text(lang, "vaultUnlock"))
5366
+ )
5367
+ );
5368
+ }
5369
+ return h2(
5370
+ "div",
5371
+ { className: "wbs-vaultbar unlocked" },
5372
+ h2("div", { className: "wbs-vault-hint" }, text(lang, "vaultUnlocked", { min: vault.idleMinutes || 15 })),
5373
+ h2("div", { className: "wbs-grow" }),
5374
+ binding ? h2("span", { className: "wbs-chip" }, "\u51ED\u636E\u7EC4\uFF1A" + (binding.groupName || binding.groupId)) : h2(
5375
+ React2.Fragment,
5376
+ null,
5377
+ h2("span", { className: "wbs-vault-hint" }, "\u672C\u7AD9\u70B9\u5C1A\u672A\u5173\u8054\u51ED\u636E\u7EC4"),
5378
+ h2("button", { className: "wbs-btn sm", disabled: busy, onClick: bindGroup }, h2(Icon2, { name: "plus", size: 12 }), "\u521B\u5EFA\u5E76\u5173\u8054")
5379
+ ),
5380
+ h2("button", { className: "wbs-btn sm", disabled: busy, onClick: lockVault }, h2(Icon2, { name: "lock", size: 12 }), text(lang, "vaultLock"))
5381
+ );
5382
+ }
5383
+ function renderDraft() {
5384
+ var d = draft;
5385
+ function setField(key, v) {
5386
+ setDraft(function(prev) {
5387
+ var next = Object.assign({}, prev);
5388
+ next[key] = v;
5389
+ return next;
5390
+ });
5391
+ }
5392
+ function field(key, label, type, ph) {
5393
+ var input = type === "password" ? h2(SecretField, {
5394
+ h: h2,
5395
+ inputClassName: "wbs-input",
5396
+ autoComplete: "new-password",
5397
+ ariaLabel: label,
5398
+ placeholder: ph || "",
5399
+ showLabel: text(lang, "showPlain"),
5400
+ hideLabel: text(lang, "hidePlain"),
5401
+ value: d[key] || "",
5402
+ show: draftPassShow,
5403
+ onChange: function(v) {
5404
+ setField(key, v);
5405
+ },
5406
+ onToggle: function() {
5407
+ setDraftPassShow(!draftPassShow);
5408
+ }
5409
+ }) : h2("input", {
5410
+ className: "wbs-input",
5411
+ type: type || "text",
5412
+ placeholder: ph || "",
5413
+ value: d[key] || "",
5414
+ onChange: function(e) {
5415
+ setField(key, e.target.value);
5416
+ }
5417
+ });
5418
+ return h2(
5419
+ React2.Fragment,
5420
+ null,
5421
+ h2("label", { className: "wbs-label" }, label),
5422
+ input
5423
+ );
5424
+ }
5425
+ return h2(
5426
+ "div",
5427
+ { className: "wbs-accdraft" },
5428
+ h2("div", { className: "wbs-accdraft-title" }, d.id ? text(lang, "editAccount") : text(lang, "addAccount")),
5429
+ field("accountKey", text(lang, "accountKey") + " *", "text", "prod-admin"),
5430
+ field("account", text(lang, "loginName")),
5431
+ field("password", text(lang, "password"), "password"),
5432
+ field("phoneNumber", text(lang, "phone")),
5433
+ field("identityCard", text(lang, "identity")),
5434
+ field("remark", text(lang, "remark")),
5435
+ h2("div", { className: "wbs-vault-hint" }, text(lang, "sensitiveHint")),
5436
+ h2(
5437
+ "div",
5438
+ { className: "wbs-formfoot" },
5439
+ h2("div", { className: "wbs-grow" }),
5440
+ h2("button", { className: "wbs-btn", disabled: busy, onClick: function() {
5441
+ setDraft(null);
5442
+ } }, text(lang, "cancel")),
5443
+ h2("button", { className: "wbs-btn primary", disabled: busy, onClick: saveDraft }, text(lang, "save"))
5444
+ )
5445
+ );
5446
+ }
5447
+ return h2(
5448
+ Modal,
5449
+ { onClose: props.onClose },
5450
+ h2(
5451
+ "div",
5452
+ { className: "wbs-modal-title" },
5453
+ h2(Icon2, { name: "key", size: 15 }),
5454
+ text(lang, "accountsTitle", { name: site.siteName }),
5455
+ h2("button", { type: "button", className: "wbs-mini wbs-modal-x", title: text(lang, "cancel"), onClick: props.onClose }, h2(Icon2, { name: "x", size: 15 }))
5456
+ ),
5457
+ h2("div", { className: "wbs-modal-sub" }, text(lang, "accountsSub")),
5458
+ renderVaultBar(),
5459
+ error ? h2("div", { className: "wbs-error" }, error) : null,
5460
+ draft ? renderDraft() : h2(
5461
+ React2.Fragment,
5462
+ null,
5463
+ loading ? h2("div", { className: "wbs-loading" }, text(lang, "loading")) : null,
5464
+ !loading && !accounts.length ? h2("div", { className: "wbs-acc-empty" }, text(lang, "accountEmpty")) : null,
5465
+ !loading ? accounts.map(function(acc) {
5466
+ var plain = shown[acc.id] || null;
5467
+ return h2(
5468
+ "div",
5469
+ { className: "wbs-accrow", key: acc.id },
5470
+ h2(
5471
+ "div",
5472
+ { className: "wbs-accrow-head" },
5473
+ h2("b", null, acc.accountKey || "\u2014"),
5474
+ acc.account ? h2("span", { className: "wbs-acc-login" }, acc.account) : null,
5475
+ h2("div", { className: "wbs-grow" }),
5476
+ h2("button", { className: "wbs-btn sm icononly", title: text(lang, "edit"), onClick: function() {
5477
+ setDraft({ id: acc.id, accountKey: acc.accountKey, account: acc.account, remark: acc.remark, password: "", phoneNumber: "", identityCard: "" });
5478
+ } }, h2(Icon2, { name: "edit", size: 12 })),
5479
+ pendingDelete === acc.id ? h2(
5480
+ React2.Fragment,
5481
+ null,
5482
+ h2("button", { className: "wbs-btn sm danger", disabled: busy, onClick: function() {
5483
+ removeAccount(acc.id);
5484
+ } }, text(lang, "confirm")),
5485
+ h2("button", { className: "wbs-btn sm", onClick: function() {
5486
+ setPendingDelete("");
5487
+ } }, text(lang, "cancel"))
5488
+ ) : h2("button", { className: "wbs-btn sm danger icononly", title: text(lang, "del"), onClick: function() {
5489
+ setPendingDelete(acc.id);
5490
+ } }, h2(Icon2, { name: "trash", size: 12 }))
5491
+ ),
5492
+ acc.vaultInvalid ? h2("div", { className: "wbs-error" }, text(lang, "vaultInvalid")) : null,
5493
+ h2(
5494
+ "div",
5495
+ { className: "wbs-accrow-fields" },
5496
+ h2(
5497
+ "div",
5498
+ null,
5499
+ h2("i", null, text(lang, "password")),
5500
+ h2("span", null, plain ? plain.password || "\u2014" : acc.hasPassword ? "\u2022\u2022\u2022\u2022\u2022\u2022" : "\u2014"),
5501
+ acc.hasPassword ? h2("button", { className: "wbs-mini", title: text(lang, "reveal"), onClick: function() {
5502
+ if (plain) {
5503
+ setShown(function(prev) {
5504
+ var next = Object.assign({}, prev);
5505
+ delete next[acc.id];
5506
+ return next;
5507
+ });
5508
+ } else {
5509
+ reveal(acc);
5510
+ }
5511
+ } }, h2(Icon2, { name: plain ? "eye-off" : "eye", size: 11 })) : null,
5512
+ acc.hasPassword ? h2("button", { className: "wbs-mini", title: text(lang, "copy"), onClick: function() {
5513
+ if (plain) copyText(plain.password);
5514
+ else reveal(acc);
5515
+ } }, h2(Icon2, { name: "copy", size: 11 })) : null
5516
+ ),
5517
+ h2("div", null, h2("i", null, text(lang, "phone")), h2("span", null, plain ? plain.phoneNumber || "\u2014" : acc.phoneNumber || "\u2014")),
5518
+ h2("div", null, h2("i", null, text(lang, "identity")), h2("span", null, plain ? plain.identityCard || "\u2014" : acc.identityCard || "\u2014")),
5519
+ acc.remark ? h2("div", { className: "wbs-acc-remark" }, h2("i", null, text(lang, "remark")), h2("span", null, acc.remark)) : null
5520
+ ),
5521
+ h2(
5522
+ "div",
5523
+ { className: "wbs-accrow-ext" },
5524
+ (acc.externals || []).map(function(rel) {
5525
+ return h2(
5526
+ "span",
5527
+ { className: "wbs-chip", key: rel.relationId },
5528
+ rel.siteName + " \xB7 " + rel.accountKey,
5529
+ h2("button", { className: "wbs-mini", title: text(lang, "unlink"), onClick: function() {
5530
+ unlink(acc, rel);
5531
+ } }, h2(Icon2, { name: "x", size: 10 }))
5532
+ );
5533
+ }),
5534
+ h2(
5535
+ "select",
5536
+ { className: "wbs-select wbs-acc-extsel", value: pickKey, onChange: function(e) {
5537
+ setPickKey(e.target.value);
5538
+ } },
5539
+ h2("option", { value: "" }, text(lang, "externalPick")),
5540
+ cascade.map(function(o) {
5541
+ return h2("option", { key: o.id, value: o.id }, o.label);
5542
+ })
5543
+ ),
5544
+ h2("button", { className: "wbs-btn sm", disabled: !pickKey || busy, onClick: function() {
5545
+ linkExternal(acc);
5546
+ } }, text(lang, "externalAdd"))
5547
+ )
5548
+ );
5549
+ }) : null,
5550
+ !loading ? h2(
5551
+ "div",
5552
+ { className: "wbs-formfoot" },
5553
+ h2("button", { className: "wbs-btn primary", disabled: busy, onClick: function() {
5554
+ setDraft({ id: "", accountKey: "", account: "", password: "", phoneNumber: "", identityCard: "", remark: "" });
5555
+ } }, h2(Icon2, { name: "plus", size: 12 }), text(lang, "addAccount")),
5556
+ h2("div", { className: "wbs-grow" }),
5557
+ h2("button", { className: "wbs-btn", onClick: props.onClose }, text(lang, "close"))
5558
+ ) : null
5559
+ )
5560
+ );
5561
+ }
5562
+ return AccountModal;
5563
+ };
5564
+ }
5565
+ });
5566
+
5567
+ // packages/addons/lib/highlight.cjs
5568
+ var require_highlight = __commonJS({
5569
+ "packages/addons/lib/highlight.cjs"(exports2, module2) {
5570
+ "use strict";
5571
+ module2.exports = function(React2) {
5572
+ var h2 = React2.createElement;
5573
+ function sourceOf(keyword) {
5574
+ var pattern = keyword.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
5575
+ return pattern.replace(/[a-zA-Z]/g, function(letter) {
5576
+ return "[" + letter.toLowerCase() + letter.toUpperCase() + "]";
5577
+ });
5578
+ }
5579
+ return function createHighlight(prefix) {
5580
+ var className = String(prefix || "wb") + "-hit";
5581
+ function hit(rawText, rawKeyword) {
5582
+ var text = rawText == null ? "" : String(rawText);
5583
+ var keyword = rawKeyword == null ? "" : String(rawKeyword);
5584
+ if (!keyword) return text;
5585
+ var matcher, match, end = 0, parts = [];
5586
+ try {
5587
+ matcher = new RegExp(sourceOf(keyword), "g");
5588
+ } catch (error) {
5589
+ return text;
5590
+ }
5591
+ while (match = matcher.exec(text)) {
5592
+ if (match.index > end) parts.push(text.slice(end, match.index));
5593
+ parts.push(h2("mark", { className, key: match.index }, match[0]));
5594
+ end = match.index + match[0].length;
5595
+ if (!match[0]) matcher.lastIndex += 1;
5596
+ }
5597
+ if (!parts.length) return text;
5598
+ if (end < text.length) parts.push(text.slice(end));
5599
+ return parts;
5600
+ }
5601
+ function Highlight(props) {
5602
+ return hit(props.text, props.keyword);
5603
+ }
5604
+ Highlight.hit = hit;
5605
+ return Highlight;
5606
+ };
5607
+ };
5608
+ }
5609
+ });
5610
+
5611
+ // packages/addons/lib/action-schema-style.cjs
4402
5612
  var require_action_schema_style = __commonJS({
4403
5613
  "packages/addons/lib/action-schema-style.cjs"(exports2, module2) {
4404
5614
  "use strict";
@@ -4419,8 +5629,21 @@ var require_action_schema_style = __commonJS({
4419
5629
  "." + P + " select:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#4f6ef7);outline-offset:1px}",
4420
5630
  "." + P + "-list{display:flex;flex-direction:column;gap:8px}",
4421
5631
  "." + P + "-card{border:1px solid var(--wb-border,#e3e5e9);border-radius:10px;padding:10px 12px;background:var(--wb-surface,var(--dsw-alias-bg-layer-1,transparent));display:flex;flex-direction:column;gap:8px;min-width:0}",
4422
- "." + P + "-cardhead{display:flex;align-items:center;gap:8px;flex-wrap:wrap}",
4423
- "." + P + "-cardhead code{font-weight:640}",
5632
+ "." + P + "-cardhead{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:start;gap:8px}",
5633
+ "." + P + "-cardmeta{display:flex;align-items:center;flex-wrap:wrap;gap:8px;min-width:0;min-height:24px}",
5634
+ "." + P + "-cardhead code{font-weight:640;overflow-wrap:anywhere;min-width:0}",
5635
+ "." + P + "-hintline{margin:0;color:var(--dsw-alias-label-tertiary,inherit);font-size:11.5px;line-height:1.5}",
5636
+ "." + 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}",
5637
+ "." + 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)}",
5638
+ "." + P + "-track::before{content:'';width:12px;height:12px;border-radius:50%;background:currentColor;transition:transform .15s ease}",
5639
+ "." + P + "-toggle[aria-checked=true] ." + P + "-track{background:var(--wb-accent);border-color:var(--wb-accent);color:var(--wb-card)}",
5640
+ "." + P + "-toggle[aria-checked=true] ." + P + "-track::before{transform:translateX(12px)}",
5641
+ "." + P + "-toggle:hover:not(:disabled) ." + P + "-track{outline:1px solid var(--wb-accent)}",
5642
+ "." + P + "-toggle:focus-visible{outline:2px solid var(--wb-accent);outline-offset:2px}",
5643
+ "." + P + "-toggle:disabled{opacity:.6;cursor:progress}",
5644
+ "@media(prefers-reduced-motion:reduce){." + P + "-track::before{transition:none}}",
5645
+ // 安全约束(不可放开):用警示色描边,和可切换的开关区分开。
5646
+ "." + P + "-locked{border-color:var(--wb-warn,#b7791f);color:var(--wb-warn,#b7791f)}",
4424
5647
  "." + P + "-desc{margin:0;color:var(--dsw-alias-label-secondary,inherit);line-height:1.55;font-size:12.5px}",
4425
5648
  // 搜索命中:用品牌色透明度叠加而不是写死浅色,深浅主题都可读;继承文字颜色、不覆盖 ::selection。
4426
5649
  "." + P + " mark." + P + "-hit{background:color-mix(in oklab,var(--dsw-alias-brand-primary,#4f6ef7) 22%,transparent);color:inherit;border-radius:2px;padding:0;font:inherit;box-decoration-break:clone;-webkit-box-decoration-break:clone}",
@@ -4472,6 +5695,15 @@ var require_action_schema_view = __commonJS({
4472
5695
  zh: {
4473
5696
  title: "Action",
4474
5697
  hint: "\u8FD0\u884C\u65F6\u6CE8\u518C \xB7 \u53EA\u8BFB",
5698
+ switchHint: "agent \u5F00\u5173\u843D\u672C\u673A\u3001\u5373\u6539\u5373\u751F\u6548\uFF1B\u754C\u9762\u64CD\u4F5C\u4E0D\u53D7\u5F71\u54CD\u3002",
5699
+ 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",
5700
+ agentSwitch: "agent \u53EF\u7528",
5701
+ agentLocked: "\u4EC5\u754C\u9762 \xB7 \u5B89\u5168\u7EA6\u675F",
5702
+ agentLockedHint: "\u8BE5 action \u53EA\u80FD\u5728\u754C\u9762\u6267\u884C\uFF08\u5B89\u5168\u7EA6\u675F\uFF09\uFF0Cagent \u5F00\u5173\u4E0D\u53EF\u653E\u5F00",
5703
+ agentSaving: "\u4FDD\u5B58\u4E2D\u2026",
5704
+ agentOnToast: "\u5DF2\u5141\u8BB8 agent \u8C03\u7528",
5705
+ agentOffToast: "\u5DF2\u7981\u6B62 agent \u8C03\u7528",
5706
+ agentFail: "\u5207\u6362 agent \u5F00\u5173\u5931\u8D25",
4475
5707
  domain: "\u57DF",
4476
5708
  versionLabel: "\u7248\u672C",
4477
5709
  shell: "\u5BBF\u4E3B",
@@ -4517,6 +5749,15 @@ var require_action_schema_view = __commonJS({
4517
5749
  en: {
4518
5750
  title: "Actions",
4519
5751
  hint: "runtime registry \xB7 read-only",
5752
+ switchHint: "The agent switch is stored locally and applies immediately; UI actions are unaffected.",
5753
+ hostHint: "Agent switch for host actions; items marked UI-only (security) cannot be opened up.",
5754
+ agentSwitch: "Agent callable",
5755
+ agentLocked: "UI only \xB7 security",
5756
+ agentLockedHint: "This action can only run from the UI (security constraint); the agent switch cannot be opened",
5757
+ agentSaving: "Saving\u2026",
5758
+ agentOnToast: "Agent calls allowed",
5759
+ agentOffToast: "Agent calls blocked",
5760
+ agentFail: "Failed to change the agent switch",
4520
5761
  domain: "Domain",
4521
5762
  versionLabel: "Version",
4522
5763
  shell: "Host",
@@ -4629,7 +5870,9 @@ var require_action_schema_view = __commonJS({
4629
5870
  }
4630
5871
  module2.exports = function createActionSchemaView(options) {
4631
5872
  var raw = String(options.domain || "");
4632
- var DOMAIN = raw.indexOf("wb-addon-") === 0 ? raw : "wb-addon-" + raw;
5873
+ var SOURCE = options.source === "actions.list" ? "actions.list" : "actionSchema";
5874
+ var DOMAIN = SOURCE === "actions.list" ? raw : raw.indexOf("wb-addon-") === 0 ? raw : "wb-addon-" + raw;
5875
+ var LIST_DOMAIN = options.listDomain ? String(options.listDomain) : DOMAIN;
4633
5876
  var prefix = options.prefix;
4634
5877
  var P = prefix + "-as";
4635
5878
  var Icon2 = options.Icon || null;
@@ -4673,6 +5916,8 @@ var require_action_schema_view = __commonJS({
4673
5916
  var typePick = typeState[0], setTypePick = typeState[1];
4674
5917
  var toastState = React2.useState("");
4675
5918
  var toast = toastState[0], setToast = toastState[1];
5919
+ var savingState = React2.useState("");
5920
+ var saving = savingState[0], setSaving = savingState[1];
4676
5921
  React2.useEffect(function() {
4677
5922
  injectCss();
4678
5923
  }, []);
@@ -4681,9 +5926,10 @@ var require_action_schema_view = __commonJS({
4681
5926
  setLoading(true);
4682
5927
  setErr("");
4683
5928
  var pending;
4684
- var actionName = DOMAIN.replace(/^wb-addon-/, "") + ".actionSchema";
5929
+ var actionName = SOURCE === "actions.list" ? "actions.list" : DOMAIN.replace(/^wb-addon-/, "") + ".actionSchema";
5930
+ var callArgs = SOURCE === "actions.list" ? { detail: true, domain: LIST_DOMAIN } : void 0;
4685
5931
  if (api && typeof api.call === "function") {
4686
- pending = Promise.resolve(api.call(actionName)).then(function(r) {
5932
+ pending = Promise.resolve(api.call(actionName, callArgs)).then(function(r) {
4687
5933
  if (r && r.ok === false) return r;
4688
5934
  return r && r.result || r;
4689
5935
  });
@@ -4723,6 +5969,39 @@ var require_action_schema_view = __commonJS({
4723
5969
  plainCopy(text);
4724
5970
  done();
4725
5971
  }
5972
+ function setAgent(action, next) {
5973
+ var name = action.name;
5974
+ setSaving(name);
5975
+ setToast("");
5976
+ var fail = function(e) {
5977
+ setSaving("");
5978
+ setToast(t.agentFail + "\uFF1A" + String(e && e.message || e || ""));
5979
+ };
5980
+ var done = function(r) {
5981
+ setSaving("");
5982
+ var payload = r && typeof r === "object" && Object.prototype.hasOwnProperty.call(r, "result") ? r.result : r;
5983
+ if (r && r.ok === false) {
5984
+ setToast(t.agentFail + "\uFF1A" + String(r.error || r.text || ""));
5985
+ return;
5986
+ }
5987
+ var value = payload && typeof payload.agentEnabled === "boolean" ? payload.agentEnabled : next;
5988
+ setSnap(function(prev) {
5989
+ if (!prev || !Array.isArray(prev.actions)) return prev;
5990
+ return Object.assign({}, prev, {
5991
+ actions: prev.actions.map(function(a) {
5992
+ if (!a || a.name !== name) return a;
5993
+ return Object.assign({}, a, { agentEnabled: value });
5994
+ })
5995
+ });
5996
+ });
5997
+ setToast(value ? t.agentOnToast : t.agentOffToast);
5998
+ };
5999
+ if (!api || typeof api.call !== "function") {
6000
+ fail(new Error("no call api"));
6001
+ return;
6002
+ }
6003
+ Promise.resolve(api.call("actions.setAgentAccess", { action: name, agentEnabled: next })).then(done, fail);
6004
+ }
4726
6005
  var all = snap && Array.isArray(snap.actions) ? snap.actions.filter(function(a) {
4727
6006
  return a && a.domain === DOMAIN;
4728
6007
  }) : [];
@@ -4771,6 +6050,35 @@ var require_action_schema_view = __commonJS({
4771
6050
  h2("td", null, Highlight.hit(row.description, kw))
4772
6051
  );
4773
6052
  }
6053
+ function agentSwitch(action) {
6054
+ if (action.agentLocked === true) {
6055
+ return h2("span", {
6056
+ className: P + "-badge " + P + "-locked",
6057
+ title: t.agentLockedHint,
6058
+ "data-agent-locked": action.name
6059
+ }, t.agentLocked);
6060
+ }
6061
+ if (typeof action.agentEnabled !== "boolean") return null;
6062
+ var busy = saving === action.name;
6063
+ return h2(
6064
+ "button",
6065
+ {
6066
+ className: P + "-toggle",
6067
+ "data-agent-row": action.name,
6068
+ type: "button",
6069
+ role: "switch",
6070
+ "aria-checked": action.agentEnabled,
6071
+ disabled: busy,
6072
+ "data-agent-toggle": action.name,
6073
+ "aria-label": t.agentSwitch + " \xB7 " + action.name,
6074
+ onClick: function() {
6075
+ setAgent(action, !action.agentEnabled);
6076
+ }
6077
+ },
6078
+ h2("span", { className: P + "-track", "aria-hidden": true }),
6079
+ h2("span", null, busy ? t.agentSaving : t.agentSwitch)
6080
+ );
6081
+ }
4774
6082
  function card(action) {
4775
6083
  var rows = paramRows(action);
4776
6084
  var examples = Array.isArray(action.examples) ? action.examples : [];
@@ -4780,12 +6088,16 @@ var require_action_schema_view = __commonJS({
4780
6088
  h2(
4781
6089
  "div",
4782
6090
  { className: P + "-cardhead" },
4783
- h2("code", { className: P + "-mono" }, Highlight.hit(action.name, kw)),
4784
- h2("span", { className: P + "-badge" }, action.domain),
4785
- h2("span", { className: P + "-badge" }, rows.length ? t.paramCount(rows.length) : t.noParams),
4786
- rows.some(function(row) {
4787
- return row.required;
4788
- }) ? h2("span", { className: P + "-badge " + P + "-req" }, t.required) : null
6091
+ h2(
6092
+ "div",
6093
+ { className: P + "-cardmeta" },
6094
+ h2("code", { className: P + "-mono" }, Highlight.hit(action.name, kw)),
6095
+ h2("span", { className: P + "-badge" }, rows.length ? t.paramCount(rows.length) : t.noParams),
6096
+ rows.some(function(row) {
6097
+ return row.required;
6098
+ }) ? h2("span", { className: P + "-badge " + P + "-req" }, t.required) : null
6099
+ ),
6100
+ agentSwitch(action)
4789
6101
  ),
4790
6102
  action.description ? h2("p", { className: P + "-desc" }, Highlight.hit(action.description, kw)) : null,
4791
6103
  rows.length ? h2(
@@ -4862,6 +6174,7 @@ var require_action_schema_view = __commonJS({
4862
6174
  h2("span", { className: P + "-badge" }, t.count(visible.length, all.length)),
4863
6175
  h2("span", { className: P + "-none" }, t.hint)
4864
6176
  ),
6177
+ h2("p", { className: P + "-hintline" }, SOURCE === "actions.list" ? t.hostHint : t.switchHint),
4865
6178
  snap ? h2(
4866
6179
  "div",
4867
6180
  { className: P + "-toolbar" },
@@ -5404,353 +6717,17 @@ var TagFilter = require_tagfilter();
5404
6717
  )
5405
6718
  );
5406
6719
  }
5407
- function AccountModal(props) {
5408
- var api = props.api;
5409
- var lang = props.lang || "zh";
5410
- var site = props.site;
5411
- var [accounts, setAccounts] = useState([]);
5412
- var [vault, setVault] = useState({});
5413
- var [loading, setLoading] = useState(true);
5414
- var [error, setError] = useState("");
5415
- var [busy, setBusy] = useState(false);
5416
- var [draft, setDraft] = useState(null);
5417
- var [pass, setPass] = useState("");
5418
- var [pass2, setPass2] = useState("");
5419
- var [cascade, setCascade] = useState([]);
5420
- var [pickKey, setPickKey] = useState("");
5421
- var [pendingDelete, setPendingDelete] = useState("");
5422
- var [shown, setShown] = useState({});
5423
- function reload() {
5424
- setLoading(true);
5425
- return Promise.all([
5426
- callApi(api, "sites.accounts.list", { siteId: site.id }),
5427
- callApi(api, "sites.vault.status", {})
5428
- ]).then(function(out) {
5429
- setAccounts(out[0].accounts || []);
5430
- setVault(out[1] || {});
5431
- setError("");
5432
- }).catch(function(e) {
5433
- setError(errText(e));
5434
- }).finally(function() {
5435
- setLoading(false);
5436
- });
5437
- }
5438
- function loadCascade() {
5439
- callApi(api, "sites.accounts.cascade", { excludeSiteId: site.id }).then(function(r) {
5440
- var list = [];
5441
- (r.groups || []).forEach(function(g) {
5442
- g.accounts.forEach(function(a) {
5443
- list.push({ id: a.id, label: g.siteName + " \xB7 " + a.accountKey });
5444
- });
5445
- });
5446
- setCascade(list);
5447
- }).catch(function() {
5448
- setCascade([]);
5449
- });
5450
- }
5451
- useEffect(function() {
5452
- reload();
5453
- loadCascade();
5454
- }, [site.id]);
5455
- function guard(fn) {
5456
- setBusy(true);
5457
- setError("");
5458
- return Promise.resolve().then(fn).catch(function(e) {
5459
- setError(errText(e));
5460
- }).finally(function() {
5461
- setBusy(false);
5462
- });
5463
- }
5464
- function submitVault() {
5465
- if (!pass || pass.length < 8) {
5466
- setError(text(lang, "passTooShort"));
5467
- return;
5468
- }
5469
- if (!vault.enabled && pass !== pass2) {
5470
- setError(text(lang, "passMismatch"));
5471
- return;
5472
- }
5473
- guard(function() {
5474
- var name = vault.enabled ? "sites.vault.unlock" : "sites.vault.setup";
5475
- var args = vault.enabled ? { passphrase: pass } : { passphrase: pass };
5476
- return callApi(api, name, args).then(function() {
5477
- setPass("");
5478
- setPass2("");
5479
- return reload();
5480
- });
5481
- });
5482
- }
5483
- function lockVault() {
5484
- guard(function() {
5485
- return callApi(api, "sites.vault.lock", {}).then(function() {
5486
- setShown({});
5487
- return reload();
5488
- });
5489
- });
5490
- }
5491
- function saveDraft() {
5492
- var body = {
5493
- accountKey: draft.accountKey,
5494
- account: draft.account,
5495
- remark: draft.remark
5496
- };
5497
- if (draft.password) body.password = draft.password;
5498
- if (draft.phoneNumber) body.phoneNumber = draft.phoneNumber;
5499
- if (draft.identityCard) body.identityCard = draft.identityCard;
5500
- guard(function() {
5501
- var req = draft.id ? callApi(api, "sites.accounts.update", Object.assign({ id: draft.id }, body)) : callApi(api, "sites.accounts.create", Object.assign({ siteId: site.id }, body));
5502
- return req.then(function() {
5503
- setDraft(null);
5504
- props.onChanged && props.onChanged();
5505
- return reload();
5506
- });
5507
- });
5508
- }
5509
- function removeAccount(id) {
5510
- guard(function() {
5511
- return callApi(api, "sites.accounts.delete", { id }).then(function() {
5512
- setPendingDelete("");
5513
- props.onChanged && props.onChanged();
5514
- return reload();
5515
- });
5516
- });
5517
- }
5518
- function reveal(acc) {
5519
- guard(function() {
5520
- return callApi(api, "sites.accounts.reveal", { id: acc.id }).then(function(r) {
5521
- setShown(function(prev) {
5522
- var next = Object.assign({}, prev);
5523
- next[acc.id] = r;
5524
- return next;
5525
- });
5526
- });
5527
- });
5528
- }
5529
- function copyText(value) {
5530
- if (!value) return;
5531
- try {
5532
- navigator.clipboard.writeText(value);
5533
- showToast(text(lang, "copied"));
5534
- } catch (e) {
5535
- setError(String(e && e.message || e));
5536
- }
5537
- }
5538
- function linkExternal(acc) {
5539
- if (!pickKey) return;
5540
- guard(function() {
5541
- return callApi(api, "sites.accounts.link", { nativeAccountId: acc.id, externalAccountId: pickKey }).then(function() {
5542
- setPickKey("");
5543
- return reload();
5544
- });
5545
- });
5546
- }
5547
- function unlink(acc, rel) {
5548
- guard(function() {
5549
- return callApi(api, "sites.accounts.unlink", { nativeAccountId: acc.id, externalAccountId: rel.accountId }).then(function() {
5550
- return reload();
5551
- });
5552
- });
5553
- }
5554
- function renderVaultBar() {
5555
- if (!vault.enabled) {
5556
- return h2(
5557
- "div",
5558
- { className: "wbs-vaultbar" },
5559
- h2("div", { className: "wbs-vault-hint" }, text(lang, "vaultNotSet")),
5560
- h2(
5561
- "div",
5562
- { className: "wbs-vault-form" },
5563
- h2("input", { className: "wbs-input", type: "password", placeholder: text(lang, "passphrase"), value: pass, onChange: function(e) {
5564
- setPass(e.target.value);
5565
- } }),
5566
- h2("input", { className: "wbs-input", type: "password", placeholder: text(lang, "passphraseAgain"), value: pass2, onChange: function(e) {
5567
- setPass2(e.target.value);
5568
- } }),
5569
- h2("button", { className: "wbs-btn", disabled: busy, onClick: submitVault }, text(lang, "vaultSetup"))
5570
- )
5571
- );
5572
- }
5573
- if (!vault.unlocked) {
5574
- return h2(
5575
- "div",
5576
- { className: "wbs-vaultbar locked" },
5577
- h2("div", { className: "wbs-vault-hint" }, text(lang, "vaultLocked")),
5578
- h2(
5579
- "div",
5580
- { className: "wbs-vault-form" },
5581
- h2("input", { className: "wbs-input", type: "password", placeholder: text(lang, "passphrase"), value: pass, onChange: function(e) {
5582
- setPass(e.target.value);
5583
- } }),
5584
- h2("button", { className: "wbs-btn", disabled: busy, onClick: submitVault }, text(lang, "vaultUnlock"))
5585
- )
5586
- );
5587
- }
5588
- return h2(
5589
- "div",
5590
- { className: "wbs-vaultbar unlocked" },
5591
- h2("div", { className: "wbs-vault-hint" }, text(lang, "vaultUnlocked", { min: vault.idleMinutes || 15 })),
5592
- h2("button", { className: "wbs-btn sm", disabled: busy, onClick: lockVault }, h2(Icon2, { name: "lock", size: 12 }), text(lang, "vaultLock"))
5593
- );
5594
- }
5595
- function renderDraft() {
5596
- var d = draft;
5597
- function field(key, label, type, ph) {
5598
- return h2(
5599
- React2.Fragment,
5600
- null,
5601
- h2("label", { className: "wbs-label" }, label),
5602
- h2("input", {
5603
- className: "wbs-input",
5604
- type: type || "text",
5605
- placeholder: ph || "",
5606
- value: d[key] || "",
5607
- onChange: function(e) {
5608
- var v = e.target.value;
5609
- setDraft(function(prev) {
5610
- var next = Object.assign({}, prev);
5611
- next[key] = v;
5612
- return next;
5613
- });
5614
- }
5615
- })
5616
- );
5617
- }
5618
- return h2(
5619
- "div",
5620
- { className: "wbs-accdraft" },
5621
- h2("div", { className: "wbs-accdraft-title" }, d.id ? text(lang, "editAccount") : text(lang, "addAccount")),
5622
- field("accountKey", text(lang, "accountKey") + " *", "text", "prod-admin"),
5623
- field("account", text(lang, "loginName")),
5624
- field("password", text(lang, "password"), "password"),
5625
- field("phoneNumber", text(lang, "phone")),
5626
- field("identityCard", text(lang, "identity")),
5627
- field("remark", text(lang, "remark")),
5628
- h2("div", { className: "wbs-vault-hint" }, text(lang, "sensitiveHint")),
5629
- h2(
5630
- "div",
5631
- { className: "wbs-formfoot" },
5632
- h2("div", { className: "wbs-grow" }),
5633
- h2("button", { className: "wbs-btn", disabled: busy, onClick: function() {
5634
- setDraft(null);
5635
- } }, text(lang, "cancel")),
5636
- h2("button", { className: "wbs-btn primary", disabled: busy, onClick: saveDraft }, text(lang, "save"))
5637
- )
5638
- );
5639
- }
5640
- return h2(
5641
- Modal,
5642
- { onClose: props.onClose },
5643
- h2(
5644
- "div",
5645
- { className: "wbs-modal-title" },
5646
- h2(Icon2, { name: "key", size: 15 }),
5647
- text(lang, "accountsTitle", { name: site.siteName }),
5648
- h2("button", { type: "button", className: "wbs-mini wbs-modal-x", title: text(lang, "cancel"), onClick: props.onClose }, h2(Icon2, { name: "x", size: 15 }))
5649
- ),
5650
- h2("div", { className: "wbs-modal-sub" }, text(lang, "accountsSub")),
5651
- renderVaultBar(),
5652
- error ? h2("div", { className: "wbs-error" }, error) : null,
5653
- draft ? renderDraft() : h2(
5654
- React2.Fragment,
5655
- null,
5656
- loading ? h2("div", { className: "wbs-loading" }, text(lang, "loading")) : null,
5657
- !loading && !accounts.length ? h2("div", { className: "wbs-acc-empty" }, text(lang, "accountEmpty")) : null,
5658
- !loading ? accounts.map(function(acc) {
5659
- var plain = shown[acc.id] || null;
5660
- return h2(
5661
- "div",
5662
- { className: "wbs-accrow", key: acc.id },
5663
- h2(
5664
- "div",
5665
- { className: "wbs-accrow-head" },
5666
- h2("b", null, acc.accountKey || "\u2014"),
5667
- acc.account ? h2("span", { className: "wbs-acc-login" }, acc.account) : null,
5668
- h2("div", { className: "wbs-grow" }),
5669
- h2("button", { className: "wbs-btn sm icononly", title: text(lang, "edit"), onClick: function() {
5670
- setDraft({ id: acc.id, accountKey: acc.accountKey, account: acc.account, remark: acc.remark, password: "", phoneNumber: "", identityCard: "" });
5671
- } }, h2(Icon2, { name: "edit", size: 12 })),
5672
- pendingDelete === acc.id ? h2(
5673
- React2.Fragment,
5674
- null,
5675
- h2("button", { className: "wbs-btn sm danger", disabled: busy, onClick: function() {
5676
- removeAccount(acc.id);
5677
- } }, text(lang, "confirm")),
5678
- h2("button", { className: "wbs-btn sm", onClick: function() {
5679
- setPendingDelete("");
5680
- } }, text(lang, "cancel"))
5681
- ) : h2("button", { className: "wbs-btn sm danger icononly", title: text(lang, "del"), onClick: function() {
5682
- setPendingDelete(acc.id);
5683
- } }, h2(Icon2, { name: "trash", size: 12 }))
5684
- ),
5685
- h2(
5686
- "div",
5687
- { className: "wbs-accrow-fields" },
5688
- h2(
5689
- "div",
5690
- null,
5691
- h2("i", null, text(lang, "password")),
5692
- h2("span", null, plain ? plain.password || "\u2014" : acc.hasPassword ? "\u2022\u2022\u2022\u2022\u2022\u2022" : "\u2014"),
5693
- acc.hasPassword ? h2("button", { className: "wbs-mini", title: text(lang, "reveal"), onClick: function() {
5694
- if (plain) {
5695
- setShown(function(prev) {
5696
- var next = Object.assign({}, prev);
5697
- delete next[acc.id];
5698
- return next;
5699
- });
5700
- } else {
5701
- reveal(acc);
5702
- }
5703
- } }, h2(Icon2, { name: plain ? "eye-off" : "eye", size: 11 })) : null,
5704
- acc.hasPassword ? h2("button", { className: "wbs-mini", title: text(lang, "copy"), onClick: function() {
5705
- if (plain) copyText(plain.password);
5706
- else reveal(acc);
5707
- } }, h2(Icon2, { name: "copy", size: 11 })) : null
5708
- ),
5709
- h2("div", null, h2("i", null, text(lang, "phone")), h2("span", null, plain ? plain.phoneNumber || "\u2014" : acc.phoneNumber || "\u2014")),
5710
- h2("div", null, h2("i", null, text(lang, "identity")), h2("span", null, plain ? plain.identityCard || "\u2014" : acc.identityCard || "\u2014")),
5711
- acc.remark ? h2("div", { className: "wbs-acc-remark" }, h2("i", null, text(lang, "remark")), h2("span", null, acc.remark)) : null
5712
- ),
5713
- h2(
5714
- "div",
5715
- { className: "wbs-accrow-ext" },
5716
- (acc.externals || []).map(function(rel) {
5717
- return h2(
5718
- "span",
5719
- { className: "wbs-chip", key: rel.relationId },
5720
- rel.siteName + " \xB7 " + rel.accountKey,
5721
- h2("button", { className: "wbs-mini", title: text(lang, "unlink"), onClick: function() {
5722
- unlink(acc, rel);
5723
- } }, h2(Icon2, { name: "x", size: 10 }))
5724
- );
5725
- }),
5726
- h2(
5727
- "select",
5728
- { className: "wbs-select wbs-acc-extsel", value: pickKey, onChange: function(e) {
5729
- setPickKey(e.target.value);
5730
- } },
5731
- h2("option", { value: "" }, text(lang, "externalPick")),
5732
- cascade.map(function(o) {
5733
- return h2("option", { key: o.id, value: o.id }, o.label);
5734
- })
5735
- ),
5736
- h2("button", { className: "wbs-btn sm", disabled: !pickKey || busy, onClick: function() {
5737
- linkExternal(acc);
5738
- } }, text(lang, "externalAdd"))
5739
- )
5740
- );
5741
- }) : null,
5742
- !loading ? h2(
5743
- "div",
5744
- { className: "wbs-formfoot" },
5745
- h2("button", { className: "wbs-btn primary", disabled: busy, onClick: function() {
5746
- setDraft({ id: "", accountKey: "", account: "", password: "", phoneNumber: "", identityCard: "", remark: "" });
5747
- } }, h2(Icon2, { name: "plus", size: 12 }), text(lang, "addAccount")),
5748
- h2("div", { className: "wbs-grow" }),
5749
- h2("button", { className: "wbs-btn", onClick: props.onClose }, text(lang, "close"))
5750
- ) : null
5751
- )
5752
- );
5753
- }
6720
+ var AccountModal = require_accounts_modal()({
6721
+ h: h2,
6722
+ React: React2,
6723
+ useState,
6724
+ useEffect,
6725
+ Modal,
6726
+ Icon: Icon2,
6727
+ text,
6728
+ callApi,
6729
+ errText
6730
+ });
5754
6731
  function DeleteSiteModal(props) {
5755
6732
  var api = props.api;
5756
6733
  var lang = props.lang || "zh";
@@ -6496,7 +7473,8 @@ var TagFilter = require_tagfilter();
6496
7473
  injectCss();
6497
7474
  host.registerAddon({
6498
7475
  id: "wb-addon-sites",
6499
- version: "1.10.0",
7476
+ version: "1.12.4",
7477
+ icon: (init_globe(), __toCommonJS(globe_exports)).default,
6500
7478
  views: [
6501
7479
  { id: "stats", icon: tabIcon("chart"), title: { zh: "\u7EDF\u8BA1", en: "Stats" }, component: statsView.SitesStatsView },
6502
7480
  { id: "sites", icon: tabIcon("globe"), title: { zh: "\u8BB0\u5F55", en: "Records" }, component: SitesView },