dsh-workbench-sites 1.12.7 → 1.12.11

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
@@ -528,8 +528,9 @@ var require_overlay = __commonJS({
528
528
  var autoFocusDialog = opts.autoFocusDialog !== false;
529
529
  var focusableSelector = opts.focusableSelector || FOCUSABLE;
530
530
  function Modal(props) {
531
- var ref = React2.useRef(null);
532
- React2.useEffect(function() {
531
+ var R = props.React || React2;
532
+ var ref = R.useRef(null);
533
+ R.useEffect(function() {
533
534
  var previous = typeof document !== "undefined" ? document.activeElement : null;
534
535
  var focusIt = props.autoFocus !== void 0 ? props.autoFocus : autoFocusDialog;
535
536
  if (focusIt && ref.current) ref.current.focus();
@@ -595,6 +596,305 @@ var require_overlay = __commonJS({
595
596
  }
596
597
  });
597
598
 
599
+ // packages/addons/lib/stepper.cjs
600
+ var require_stepper = __commonJS({
601
+ "packages/addons/lib/stepper.cjs"(exports2, module2) {
602
+ "use strict";
603
+ function stepState(index, current, maxVisited) {
604
+ if (index === current) return "current";
605
+ if (index < current) return "done";
606
+ if (index <= maxVisited) return "visited";
607
+ return "todo";
608
+ }
609
+ function Steps(props) {
610
+ var h2 = props.h;
611
+ var steps = props.steps || [];
612
+ var current = props.current || 0;
613
+ var maxVisited = props.maxVisited === void 0 ? current : props.maxVisited;
614
+ var invalid = props.invalid || {};
615
+ var disabled = !!props.disabled;
616
+ var label = props.label || "\u6B65\u9AA4";
617
+ return h2(
618
+ "nav",
619
+ { className: "wbctl-steps" + (props.className ? " " + props.className : ""), "aria-label": label },
620
+ h2(
621
+ "ol",
622
+ { className: "wbctl-step-list" },
623
+ steps.map(function(step, index) {
624
+ var state = stepState(index, current, maxVisited);
625
+ var canJump = !disabled && typeof props.onJump === "function" && state !== "current" && state !== "todo";
626
+ var isInvalid = !!invalid[index] || !!invalid[step.key];
627
+ return h2(
628
+ "li",
629
+ { key: step.key || index, className: "wbctl-step-item" },
630
+ h2(
631
+ "button",
632
+ {
633
+ type: "button",
634
+ className: "wbctl-step",
635
+ "data-state": state,
636
+ "data-invalid": isInvalid ? "true" : null,
637
+ "aria-current": state === "current" ? "step" : void 0,
638
+ "aria-label": index + 1 + " \xB7 " + step.label + (state === "done" ? "\uFF08\u5DF2\u5B8C\u6210\uFF09" : ""),
639
+ disabled: disabled || state === "todo",
640
+ title: step.hint || "",
641
+ onClick: function() {
642
+ if (canJump) props.onJump(index);
643
+ }
644
+ },
645
+ h2("span", { className: "wbctl-step-index", "aria-hidden": "true" }, state === "done" ? "\u2713" : String(index + 1)),
646
+ h2("span", { className: "wbctl-step-label" }, step.label),
647
+ step.hint ? h2("span", { className: "wbctl-step-hint" }, step.hint) : null,
648
+ step.optional ? h2("span", { className: "wbctl-step-opt" }, "\u53EF\u9009") : null
649
+ )
650
+ );
651
+ })
652
+ )
653
+ );
654
+ }
655
+ var STYLES = [
656
+ ".wbctl-steps{display:block;min-width:0}",
657
+ ".wbctl-step-list{display:flex;align-items:stretch;gap:6px;list-style:none;margin:0 0 14px;padding:0;min-width:0}",
658
+ ".wbctl-step-item{display:flex;flex:1 1 0;min-width:0}",
659
+ ".wbctl-step{display:flex;align-items:center;gap:7px;flex:1 1 auto;min-width:0;padding:7px 9px;border:1px solid var(--wb-line,var(--wb-border));border-radius:10px;background:transparent;color:var(--wb-muted,inherit);font:inherit;font-size:12px;line-height:1.35;text-align:left;cursor:default;transition:background .14s ease,border-color .14s ease,color .14s ease}",
660
+ ".wbctl-step[data-state=done],.wbctl-step[data-state=visited]{color:inherit;cursor:pointer}",
661
+ ".wbctl-step[data-state=done]{border-color:color-mix(in oklab,var(--wb-ok,var(--wb-accent,#2563eb)) 36%,var(--wb-border))}",
662
+ ".wbctl-step[data-state=current]{border-color:color-mix(in oklab,var(--wb-accent,#2563eb) 58%,var(--wb-border));background:color-mix(in oklab,var(--wb-accent,#2563eb) 8%,transparent);color:inherit;font-weight:600}",
663
+ ".wbctl-step[data-state=visited]:hover,.wbctl-step[data-state=done]:hover{background:color-mix(in oklab,currentColor 7%,transparent)}",
664
+ ".wbctl-step[data-invalid=true]{border-color:var(--wb-danger,#d33)}",
665
+ ".wbctl-step:focus-visible{outline:2px solid var(--wb-accent,#2563eb);outline-offset:2px}",
666
+ ".wbctl-step:disabled{cursor:default;opacity:.72}",
667
+ ".wbctl-step-index{display:inline-flex;align-items:center;justify-content:center;flex:none;width:20px;height:20px;border-radius:50%;font-size:11px;font-variant-numeric:tabular-nums;background:color-mix(in oklab,currentColor 15%,transparent)}",
668
+ ".wbctl-step[data-state=current] .wbctl-step-index{background:var(--wb-accent,#2563eb);color:var(--wb-on-accent,#fff)}",
669
+ ".wbctl-step[data-state=done] .wbctl-step-index{background:color-mix(in oklab,var(--wb-ok,var(--wb-accent,#2563eb)) 20%,transparent);color:var(--wb-ok,var(--wb-accent,#2563eb))}",
670
+ ".wbctl-step-label{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}",
671
+ ".wbctl-step-hint{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px;font-weight:400;opacity:.62}",
672
+ ".wbctl-step-opt{flex:none;font-size:10px;font-weight:400;opacity:.55}",
673
+ "@media (max-width:760px){.wbctl-step{padding:6px 7px;font-size:11.5px}.wbctl-step-hint,.wbctl-step-opt{display:none}.wbctl-step-index{width:18px;height:18px;font-size:10px}}",
674
+ "@media (max-width:520px){.wbctl-step-list{gap:4px}.wbctl-step-label{white-space:normal}.wbctl-step{gap:5px}}",
675
+ "@media (prefers-reduced-motion:reduce){.wbctl-step{transition:none}}"
676
+ ];
677
+ module2.exports = { Steps, stepState, styles: STYLES };
678
+ }
679
+ });
680
+
681
+ // packages/addons/lib/staged-dialog.cjs
682
+ var require_staged_dialog = __commonJS({
683
+ "packages/addons/lib/staged-dialog.cjs"(exports2, module2) {
684
+ "use strict";
685
+ var defaultReact = require("react");
686
+ var overlayFactory = require_overlay();
687
+ var stepper = require_stepper();
688
+ function validateStep(step) {
689
+ if (!step || typeof step.validate !== "function") return "";
690
+ var message = step.validate();
691
+ return message ? String(message) : "";
692
+ }
693
+ function firstFailing(steps) {
694
+ var list = steps || [];
695
+ for (var i = 0; i < list.length; i += 1) {
696
+ var message = validateStep(list[i]);
697
+ if (message) return { index: i, key: list[i] && list[i].key, message };
698
+ }
699
+ return null;
700
+ }
701
+ function createStagedDialog(options) {
702
+ var opts = options || {};
703
+ var React2 = opts.React || defaultReact;
704
+ var h2 = React2.createElement;
705
+ var dialogClass = ((opts.dialogClass || "") + " wbctl-dialog").trim();
706
+ var Overlay = overlayFactory(
707
+ Object.assign({}, opts, {
708
+ React: React2,
709
+ dialogClass,
710
+ // 首焦点由外壳送进对话框,字段由 focusStep 负责,避免打开瞬间落进第一个输入框。
711
+ autoFocusDialog: opts.autoFocusDialog !== false
712
+ })
713
+ );
714
+ function StagedDialog(props) {
715
+ var R = props.React || React2;
716
+ var steps = props.steps || [];
717
+ var count = steps.length;
718
+ var busy = !!props.submitting || !!props.busy;
719
+ var indexState = R.useState(props.initialStep || 0);
720
+ var rawIndex = indexState[0];
721
+ var setIndex = indexState[1];
722
+ var index = count === 0 ? 0 : Math.min(Math.max(rawIndex, 0), count - 1);
723
+ var visitedState = R.useState(props.initialStep || 0);
724
+ var maxVisited = count === 0 ? 0 : Math.min(Math.max(visitedState[0], index), count - 1);
725
+ var setMaxVisited = visitedState[1];
726
+ var errorState = R.useState("");
727
+ var stepError = errorState[0];
728
+ var setStepError = errorState[1];
729
+ var invalidState = R.useState({});
730
+ var invalid = invalidState[0];
731
+ var setInvalid = invalidState[1];
732
+ var bodyRef = R.useRef(null);
733
+ var mounted = R.useRef(true);
734
+ function runValidate(step) {
735
+ return validateStep(step);
736
+ }
737
+ function markInvalid(i, bad) {
738
+ setInvalid(function(prev) {
739
+ var next2 = Object.assign({}, prev);
740
+ if (bad) next2[i] = true;
741
+ else delete next2[i];
742
+ return next2;
743
+ });
744
+ }
745
+ function focusBody() {
746
+ var el = bodyRef.current;
747
+ if (el && typeof el.focus === "function") el.focus();
748
+ }
749
+ R.useEffect(
750
+ function() {
751
+ if (!mounted.current) return;
752
+ focusBody();
753
+ },
754
+ [index]
755
+ );
756
+ R.useEffect(function() {
757
+ mounted.current = true;
758
+ return function() {
759
+ mounted.current = false;
760
+ };
761
+ }, []);
762
+ function goTo(i) {
763
+ if (busy || i < 0 || i >= count) return;
764
+ setIndex(i);
765
+ if (i > maxVisited) setMaxVisited(i);
766
+ setStepError("");
767
+ }
768
+ function fail(i, message) {
769
+ markInvalid(i, true);
770
+ goTo(i);
771
+ setStepError(message);
772
+ focusBody();
773
+ }
774
+ function next() {
775
+ if (busy) return;
776
+ var message = runValidate(steps[index]);
777
+ if (message) {
778
+ fail(index, message);
779
+ return;
780
+ }
781
+ markInvalid(index, false);
782
+ goTo(Math.min(index + 1, count - 1));
783
+ }
784
+ function back() {
785
+ if (busy || index === 0) return;
786
+ goTo(index - 1);
787
+ }
788
+ function jump(i) {
789
+ if (busy || i > maxVisited) return;
790
+ goTo(i);
791
+ }
792
+ function submit() {
793
+ if (busy) return;
794
+ var bad = firstFailing(steps);
795
+ if (bad) {
796
+ fail(bad.index, bad.message);
797
+ return;
798
+ }
799
+ for (var i = 0; i < count; i++) markInvalid(i, false);
800
+ setStepError("");
801
+ if (typeof props.onSubmit === "function") props.onSubmit();
802
+ }
803
+ function cancel() {
804
+ if (busy) return;
805
+ if (typeof props.onClose === "function") props.onClose();
806
+ }
807
+ var current = steps[index];
808
+ var isLast = index >= count - 1;
809
+ var saveText = props.submitText || "\u4FDD\u5B58";
810
+ var shownError = stepError || props.error || "";
811
+ return h2(
812
+ Overlay,
813
+ props,
814
+ count > 1 ? h2(stepper.Steps, {
815
+ h: h2,
816
+ steps: steps.map(function(step) {
817
+ return { key: step.key, label: step.label, hint: step.hint, optional: step.optional };
818
+ }),
819
+ current: index,
820
+ maxVisited,
821
+ onJump: jump,
822
+ invalid,
823
+ disabled: busy,
824
+ label: props.stepsLabel || "\u521B\u5EFA\u6B65\u9AA4"
825
+ }) : null,
826
+ h2(
827
+ "div",
828
+ {
829
+ className: "wbctl-dialog-body" + (props.bodyClassName ? " " + props.bodyClassName : ""),
830
+ ref: bodyRef,
831
+ tabIndex: -1
832
+ },
833
+ current ? current.render(h2, props) : null
834
+ ),
835
+ props.footerExtra || null,
836
+ shownError ? h2("div", { className: "wbctl-dialog-err", role: "alert" }, shownError) : null,
837
+ h2(
838
+ "div",
839
+ { className: "wbctl-dialog-foot" },
840
+ count > 1 ? h2("span", { className: "wbctl-dialog-progress" }, index + 1 + " / " + count) : null,
841
+ props.footerNote ? h2("span", { className: "wbctl-dialog-note" }, props.footerNote) : null,
842
+ h2("span", { className: "wbctl-dialog-spacer" }),
843
+ index > 0 ? h2(
844
+ "button",
845
+ { type: "button", className: "wbctl-btn", onClick: back, disabled: busy },
846
+ props.backText || "\u4E0A\u4E00\u6B65"
847
+ ) : null,
848
+ h2("button", { type: "button", className: "wbctl-btn", onClick: cancel, disabled: busy }, props.cancelText || "\u53D6\u6D88"),
849
+ h2(
850
+ "button",
851
+ {
852
+ type: "button",
853
+ className: "wbctl-btn wbctl-btn-p",
854
+ onClick: isLast ? submit : next,
855
+ // submitDisabled 只作用于末步的保存:插件据此把「结构性不合法」(JSON 语法、无可选 action)
856
+ // 提前反映成禁用态,避免用户点到保存才被弹回第一步。
857
+ disabled: busy || isLast && !!props.submitDisabled
858
+ },
859
+ busy ? saveText + "\u4E2D\u2026" : isLast ? saveText : props.nextText || "\u4E0B\u4E00\u6B65"
860
+ )
861
+ )
862
+ );
863
+ }
864
+ StagedDialog.displayName = opts.displayName || "StagedDialog";
865
+ return StagedDialog;
866
+ }
867
+ var STYLES = [
868
+ // 宽表单:内容多时给足横向空间,窄屏留 16px 边距后铺满。
869
+ ".wbctl-dialog{width:min(880px,calc(100vw - 32px));max-height:min(92vh,760px);display:flex;flex-direction:column;overflow:hidden}",
870
+ ".wbctl-dialog-body{flex:1 1 auto;min-height:0;overflow:auto;overscroll-behavior:contain;padding:2px 2px 10px;outline:none}",
871
+ ".wbctl-dialog-body:focus-visible{outline:none}",
872
+ ".wbctl-dialog-foot{display:flex;flex-wrap:wrap;align-items:center;gap:8px;padding-top:10px;margin-top:10px;border-top:1px solid var(--wb-line,var(--wb-border))}",
873
+ ".wbctl-dialog-progress{font-size:11.5px;color:var(--wb-muted,#666);font-variant-numeric:tabular-nums}",
874
+ ".wbctl-dialog-note{font-size:11.5px;color:var(--wb-muted,#666);min-width:0}",
875
+ ".wbctl-dialog-spacer{flex:1 1 auto}",
876
+ ".wbctl-dialog-err{margin-top:8px;padding:7px 10px;border-radius:8px;border:1px solid color-mix(in oklab,var(--wb-danger,#d33) 45%,transparent);background:color-mix(in oklab,var(--wb-danger,#d33) 8%,transparent);color:var(--wb-danger,#d33);font-size:12px}",
877
+ ".wbctl-btn{padding:6px 14px;border:1px solid var(--wb-border,#d0d5dd);border-radius:8px;background:var(--wb-card,#fff);color:inherit;font:inherit;font-size:12.5px;cursor:pointer}",
878
+ ".wbctl-btn:hover:not(:disabled){background:color-mix(in oklab,currentColor 7%,transparent)}",
879
+ ".wbctl-btn:focus-visible{outline:2px solid var(--wb-accent,#2563eb);outline-offset:2px}",
880
+ ".wbctl-btn:disabled{opacity:.55;cursor:default}",
881
+ ".wbctl-btn.wbctl-btn-p{background:var(--wb-accent,#2563eb);border-color:transparent;color:var(--wb-on-accent,#fff)}",
882
+ ".wbctl-btn.wbctl-btn-p:hover:not(:disabled){background:color-mix(in oklab,var(--wb-accent,#2563eb) 86%,#000)}",
883
+ // 确认步:键值对清单,各插件共用,避免再各写一套只读摘要。\n ".wbctl-review{display:flex;flex-direction:column;border:1px solid var(--wb-line,var(--wb-border));border-radius:10px;overflow:hidden}",\n ".wbctl-review-row{display:grid;grid-template-columns:96px minmax(0,1fr);gap:10px;padding:8px 12px;font-size:12.5px;background:var(--wb-surface,transparent)}",\n ".wbctl-review-row+.wbctl-review-row{border-top:1px solid var(--wb-line,var(--wb-border))}",\n ".wbctl-review-k{color:var(--wb-muted,inherit);font-size:11.5px;line-height:1.6}",\n ".wbctl-review-v{min-width:0;word-break:break-word;line-height:1.6}",\n ".wbctl-note{margin:10px 0 0;font-size:11.5px;color:var(--wb-muted,inherit)}",\n // 两列字段布局:内容多的弹窗不再单列拉长,窄屏回落单列。
884
+ ".wbctl-form{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px 14px}",
885
+ ".wbctl-form>.full{grid-column:1/-1}",
886
+ "@media (max-width:760px){.wbctl-dialog{width:calc(100vw - 16px);max-height:94vh}.wbctl-form{grid-template-columns:1fr}.wbctl-form>.full{grid-column:auto}}",
887
+ "@media (prefers-reduced-motion:reduce){.wbctl-btn{transition:none}}"
888
+ ];
889
+ module2.exports = {
890
+ createStagedDialog,
891
+ validateStep,
892
+ firstFailing,
893
+ styles: STYLES
894
+ };
895
+ }
896
+ });
897
+
598
898
  // packages/addons/lib/date-picker.cjs
599
899
  var require_date_picker = __commonJS({
600
900
  "packages/addons/lib/date-picker.cjs"(exports2, module2) {
@@ -2860,11 +3160,262 @@ var require_charts = __commonJS({
2860
3160
  }
2861
3161
  });
2862
3162
 
3163
+ // packages/addons/lib/switch.cjs
3164
+ var require_switch = __commonJS({
3165
+ "packages/addons/lib/switch.cjs"(exports2, module2) {
3166
+ "use strict";
3167
+ var SWITCH_STYLES = [
3168
+ ".wbctl-switch{display:inline-flex;align-items:center;gap:7px;min-height:24px;padding:2px;border:0;background:transparent;font:inherit;font-size:12px;color:var(--wb-muted,#6b7280);cursor:pointer;user-select:none;border-radius:999px}",
3169
+ ".wbctl-switch-track{position:relative;display:inline-flex;align-items:center;box-sizing:border-box;width:34px;height:20px;padding:2px;border-radius:999px;background:color-mix(in oklab,currentColor 22%,transparent);transition:background .16s ease;flex:none}",
3170
+ ".wbctl-switch-knob{display:block;width:16px;height:16px;border-radius:50%;background:var(--wb-card,#fff);box-shadow:0 1px 2px rgba(0,0,0,.25);transition:transform .16s ease}",
3171
+ ".wbctl-switch[aria-checked=true]{color:var(--wb-accent,#2563eb)}",
3172
+ ".wbctl-switch[aria-checked=true] .wbctl-switch-track{background:var(--wb-accent,#2563eb)}",
3173
+ ".wbctl-switch[aria-checked=true] .wbctl-switch-knob{transform:translateX(14px)}",
3174
+ ".wbctl-switch:hover:not(:disabled) .wbctl-switch-track{outline:1px solid var(--wb-accent,#2563eb)}",
3175
+ ".wbctl-switch:focus-visible{outline:2px solid var(--wb-accent,#2563eb);outline-offset:2px}",
3176
+ ".wbctl-switch:disabled{opacity:.45;cursor:not-allowed}",
3177
+ ".wbctl-switch-text{white-space:nowrap}",
3178
+ "@media (prefers-reduced-motion:reduce){.wbctl-switch-track,.wbctl-switch-knob{transition:none}}"
3179
+ ];
3180
+ function Switch(props) {
3181
+ var h2 = props.h;
3182
+ var on = props.checked === true || props.checked === "true";
3183
+ var disabled = !!props.disabled;
3184
+ var text = props.label;
3185
+ if (props.showState) text = on ? props.onText || "\u5F00" : props.offText || "\u5173";
3186
+ return h2(
3187
+ "button",
3188
+ {
3189
+ type: "button",
3190
+ role: "switch",
3191
+ "aria-checked": on ? "true" : "false",
3192
+ className: "wbctl-switch" + (props.className ? " " + props.className : ""),
3193
+ disabled,
3194
+ title: props.title,
3195
+ "aria-label": text ? void 0 : props.ariaLabel,
3196
+ onClick: function(e) {
3197
+ e.preventDefault();
3198
+ if (disabled) return;
3199
+ if (typeof props.onChange === "function") props.onChange(!on);
3200
+ }
3201
+ },
3202
+ h2(
3203
+ "span",
3204
+ { className: "wbctl-switch-track", "aria-hidden": "true" },
3205
+ h2("span", { className: "wbctl-switch-knob" })
3206
+ ),
3207
+ text ? h2("span", { className: "wbctl-switch-text" }, text) : null
3208
+ );
3209
+ }
3210
+ module2.exports = { Switch, styles: SWITCH_STYLES };
3211
+ }
3212
+ });
3213
+
3214
+ // packages/addons/lib/number-field.cjs
3215
+ var require_number_field = __commonJS({
3216
+ "packages/addons/lib/number-field.cjs"(exports2, module2) {
3217
+ "use strict";
3218
+ var React2 = require("react");
3219
+ var NUM = /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)$/;
3220
+ var TEXT = {
3221
+ zh: {
3222
+ required: "\u8BF7\u586B\u5199\u6570\u5B57",
3223
+ invalid: "\u8BF7\u8F93\u5165\u6570\u5B57",
3224
+ integer: "\u9700\u8981\u662F\u6574\u6570",
3225
+ min: "\u4E0D\u80FD\u5C0F\u4E8E {min}",
3226
+ max: "\u4E0D\u80FD\u5927\u4E8E {max}",
3227
+ range: "\u9700\u8981\u5728 {min}\u2013{max} \u4E4B\u95F4",
3228
+ step: "\u9700\u8981\u662F {step} \u7684\u500D\u6570",
3229
+ unit: "\u5355\u4F4D"
3230
+ },
3231
+ en: {
3232
+ required: "Please enter a number",
3233
+ invalid: "Please enter a number",
3234
+ integer: "Must be a whole number",
3235
+ min: "Must be at least {min}",
3236
+ max: "Must be at most {max}",
3237
+ range: "Must be between {min} and {max}",
3238
+ step: "Must be a multiple of {step}",
3239
+ unit: "unit"
3240
+ }
3241
+ };
3242
+ function messages(lang) {
3243
+ return lang === "en" ? TEXT.en : TEXT.zh;
3244
+ }
3245
+ function fill(text, vars) {
3246
+ return String(text).replace(/\{(\w+)\}/g, function(m, key) {
3247
+ return vars && vars[key] !== void 0 ? String(vars[key]) : m;
3248
+ });
3249
+ }
3250
+ function validateNumber(raw, opts) {
3251
+ var o = opts || {};
3252
+ var M = messages(o.lang);
3253
+ var text = raw === null || raw === void 0 ? "" : String(raw).trim();
3254
+ if (text === "") {
3255
+ return o.allowEmpty ? { ok: true, value: null, error: "" } : { ok: false, value: null, error: M.required };
3256
+ }
3257
+ if (!NUM.test(text)) return { ok: false, value: null, error: M.invalid };
3258
+ var n = Number(text);
3259
+ if (!isFinite(n)) return { ok: false, value: null, error: M.invalid };
3260
+ if (o.integer && Math.round(n) !== n) return { ok: false, value: null, error: M.integer };
3261
+ var hasMin = o.min !== void 0 && o.min !== null && o.min !== "";
3262
+ var hasMax = o.max !== void 0 && o.max !== null && o.max !== "";
3263
+ if (hasMin && hasMax && n >= o.min && n <= o.max) {
3264
+ } else if (hasMin && hasMax) {
3265
+ return { ok: false, value: null, error: fill(M.range, { min: o.min, max: o.max }) };
3266
+ } else if (hasMin && n < o.min) {
3267
+ return { ok: false, value: null, error: fill(M.min, { min: o.min }) };
3268
+ } else if (hasMax && n > o.max) {
3269
+ return { ok: false, value: null, error: fill(M.max, { max: o.max }) };
3270
+ }
3271
+ if (o.step && Number(o.step) > 0) {
3272
+ var q = n / Number(o.step);
3273
+ if (Math.abs(q - Math.round(q)) > 1e-9) {
3274
+ return { ok: false, value: null, error: fill(M.step, { step: o.step }) };
3275
+ }
3276
+ }
3277
+ return { ok: true, value: n, error: "" };
3278
+ }
3279
+ function rangeHint(opts, lang) {
3280
+ var o = opts || {};
3281
+ var M = messages(lang);
3282
+ var en = lang === "en";
3283
+ var hasMin = o.min !== void 0 && o.min !== null && o.min !== "";
3284
+ var hasMax = o.max !== void 0 && o.max !== null && o.max !== "";
3285
+ var parts = [];
3286
+ if (hasMin && hasMax) parts.push(String(o.min) + "\u2013" + String(o.max));
3287
+ else if (hasMin) parts.push((en ? "\u2265 " : "\u2265 ") + String(o.min));
3288
+ else if (hasMax) parts.push((en ? "\u2264 " : "\u2264 ") + String(o.max));
3289
+ if (o.integer) parts.push(en ? "whole numbers" : "\u6574\u6570");
3290
+ else if (o.step && Number(o.step) > 0) parts.push((en ? "step " : "\u6B65\u957F ") + String(o.step));
3291
+ return parts.join(en ? ", " : "\uFF0C");
3292
+ }
3293
+ function NumberField(props) {
3294
+ var h2 = props.h || React2.createElement;
3295
+ var lang = props.lang;
3296
+ var M = messages(lang);
3297
+ var text = props.value === null || props.value === void 0 ? "" : String(props.value);
3298
+ var draftS = React2.useState(text);
3299
+ var draft = draftS[0];
3300
+ var setDraft = draftS[1];
3301
+ var focusS = React2.useState(false);
3302
+ var focused = focusS[0];
3303
+ var setFocused = focusS[1];
3304
+ var errS = React2.useState("");
3305
+ var err = errS[0];
3306
+ var setErr = errS[1];
3307
+ var lastRef = React2.useRef(text);
3308
+ var skipBlurRef = React2.useRef(false);
3309
+ React2.useEffect(
3310
+ function() {
3311
+ if (focused) return;
3312
+ if (lastRef.current === text) return;
3313
+ lastRef.current = text;
3314
+ setDraft(text);
3315
+ setErr("");
3316
+ },
3317
+ [text, focused]
3318
+ );
3319
+ function commit(raw) {
3320
+ var r = validateNumber(raw, props);
3321
+ if (!r.ok) {
3322
+ setErr(r.error);
3323
+ if (typeof props.onValidChange === "function") props.onValidChange(false, r.error);
3324
+ return false;
3325
+ }
3326
+ setErr("");
3327
+ if (typeof props.onValidChange === "function") props.onValidChange(true, "");
3328
+ var cur = props.value === null || props.value === void 0 ? null : Number(props.value);
3329
+ if (r.value !== cur) {
3330
+ lastRef.current = r.value === null ? "" : String(r.value);
3331
+ if (typeof props.onCommit === "function") props.onCommit(r.value);
3332
+ }
3333
+ return true;
3334
+ }
3335
+ var hint = props.hint !== void 0 ? props.hint : rangeHint(props, lang);
3336
+ var shown = props.hint === false ? "" : hint;
3337
+ return h2(
3338
+ "span",
3339
+ { className: "wbctl-num" + (props.wide ? " is-wide" : "") + (props.className ? " " + props.className : "") },
3340
+ h2(
3341
+ "span",
3342
+ { className: "wbctl-num-box" },
3343
+ h2("input", {
3344
+ className: "wbctl-num-input" + (err ? " is-invalid" : ""),
3345
+ type: "text",
3346
+ inputMode: props.integer || Number(props.step) === 1 ? "numeric" : "decimal",
3347
+ value: draft,
3348
+ disabled: !!props.disabled,
3349
+ placeholder: props.placeholder,
3350
+ title: props.title,
3351
+ "aria-label": props.ariaLabel,
3352
+ "aria-invalid": err ? "true" : void 0,
3353
+ onFocus: function() {
3354
+ setFocused(true);
3355
+ },
3356
+ onChange: function(e) {
3357
+ setDraft(e.target.value);
3358
+ if (err) setErr("");
3359
+ if (typeof props.onDraft === "function") props.onDraft(e.target.value);
3360
+ },
3361
+ onBlur: function() {
3362
+ setFocused(false);
3363
+ if (skipBlurRef.current) {
3364
+ skipBlurRef.current = false;
3365
+ return;
3366
+ }
3367
+ commit(draft);
3368
+ },
3369
+ onKeyDown: function(e) {
3370
+ if (e.key === "Enter") {
3371
+ e.preventDefault();
3372
+ if (e.target && e.target.blur) e.target.blur();
3373
+ } else if (e.key === "Escape") {
3374
+ e.preventDefault();
3375
+ skipBlurRef.current = true;
3376
+ setDraft(text);
3377
+ setErr("");
3378
+ if (e.target && e.target.blur) e.target.blur();
3379
+ }
3380
+ }
3381
+ }),
3382
+ props.unit ? h2("span", { className: "wbctl-num-unit" }, props.unit) : null
3383
+ ),
3384
+ err ? h2("span", { className: "wbctl-num-err", role: "alert" }, err) : shown ? h2("span", { className: "wbctl-num-hint" }, shown) : null
3385
+ );
3386
+ }
3387
+ var NUMBER_STYLES = [
3388
+ ".wbctl-num{display:inline-flex;flex-direction:column;gap:3px;min-width:0;max-width:100%}",
3389
+ ".wbctl-num.is-wide{display:flex;width:100%}",
3390
+ ".wbctl-num-box{display:inline-flex;align-items:center;gap:6px;min-width:0}",
3391
+ ".wbctl-num-input{box-sizing:border-box;width:96px;min-width:0;padding:6px 9px;border:1px solid var(--wb-line,rgba(127,127,127,.35));border-radius:6px;background:var(--wb-surface,var(--wb-card,transparent));color:inherit;font:inherit;font-size:13px;font-variant-numeric:tabular-nums;transition:border-color .14s ease,outline-color .14s ease}",
3392
+ ".wbctl-num-input:hover:not(:disabled){border-color:var(--wb-border,var(--wb-line))}",
3393
+ ".wbctl-num-input:focus{outline:2px solid color-mix(in oklab,var(--wb-accent,#2563eb) 55%,transparent);outline-offset:1px;border-color:var(--wb-accent,#2563eb)}",
3394
+ ".wbctl-num-input.is-invalid{border-color:var(--wb-danger,#dc2626)}",
3395
+ ".wbctl-num-input.is-invalid:focus{outline-color:color-mix(in oklab,var(--wb-danger,#dc2626) 55%,transparent)}",
3396
+ ".wbctl-num-input:disabled{opacity:.5;cursor:not-allowed}",
3397
+ ".wbctl-num-unit{color:var(--wb-muted,inherit);font-size:12px;white-space:nowrap}",
3398
+ ".wbctl-num-hint{color:var(--wb-muted,inherit);font-size:11px;line-height:1.4}",
3399
+ ".wbctl-num-err{color:var(--wb-danger,#dc2626);font-size:11px;line-height:1.4}",
3400
+ "@media (prefers-reduced-motion:reduce){.wbctl-num-input{transition:none}}"
3401
+ ];
3402
+ module2.exports = {
3403
+ NumberField,
3404
+ validateNumber,
3405
+ rangeHint,
3406
+ messages,
3407
+ styles: NUMBER_STYLES
3408
+ };
3409
+ }
3410
+ });
3411
+
2863
3412
  // packages/addons/sites/client/views/config.cjs
2864
3413
  var require_config = __commonJS({
2865
3414
  "packages/addons/sites/client/views/config.cjs"(exports2, module2) {
2866
3415
  var React2 = require("react");
2867
3416
  var h2 = React2.createElement;
3417
+ var SW = require_switch();
3418
+ var NF = require_number_field();
2868
3419
  var DOMAIN = "sites";
2869
3420
  var PREFIX = "wbs";
2870
3421
  var COPY = {
@@ -2939,13 +3490,6 @@ var require_config = __commonJS({
2939
3490
  ".__P__-cfg-select:focus,.__P__-cfg-input:focus{border-color:var(--dsw-alias-brand-primary,currentColor);box-shadow:0 0 0 3px color-mix(in oklab,var(--dsw-alias-brand-primary,currentColor) 14%,transparent)}",
2940
3491
  ".__P__-cfg-select{min-width:152px;padding-right:10px}",
2941
3492
  ".__P__-cfg-input{width:132px}",
2942
- ".__P__-cfg-switch{position:relative;display:inline-flex;align-items:center;gap:9px;cursor:pointer;font-size:12.5px;color:var(--cfg-muted);user-select:none}",
2943
- ".__P__-cfg-switch input{position:absolute;inset:0;width:100%;height:100%;margin:0;opacity:0;cursor:pointer}",
2944
- ".__P__-cfg-track{position:relative;width:38px;height:22px;border-radius:999px;background:color-mix(in oklab,currentColor 18%,transparent);transition:background .16s ease;flex:none}",
2945
- ".__P__-cfg-track::after{content:'';position:absolute;top:2px;left:2px;width:18px;height:18px;border-radius:50%;background:var(--dsw-alias-label-primary,currentColor);transition:transform .16s ease,background .16s ease}",
2946
- ".__P__-cfg-switch input:checked+.__P__-cfg-track{background:var(--dsw-alias-brand-primary,currentColor)}",
2947
- ".__P__-cfg-switch input:checked+.__P__-cfg-track::after{transform:translateX(16px);background:var(--dsw-alias-label-primary-inverted,var(--dsw-alias-bg-base))}",
2948
- ".__P__-cfg-switch input:focus-visible+.__P__-cfg-track{outline:2px solid var(--dsw-alias-brand-primary,currentColor);outline-offset:2px}",
2949
3493
  ".__P__-cfg-multi{display:flex;flex-wrap:wrap;gap:6px;justify-content:flex-end;max-width:100%}",
2950
3494
  ".__P__-cfg-multi label{position:relative;display:inline-flex;align-items:center;padding:5px 11px;border:1px solid var(--cfg-line);border-radius:999px;font-size:12px;color:var(--cfg-muted);cursor:pointer;line-height:1.4;transition:color .12s ease,border-color .12s ease,background .12s ease}",
2951
3495
  ".__P__-cfg-multi label:hover{background:var(--cfg-hover);color:var(--dsw-alias-label-primary,inherit)}",
@@ -2970,8 +3514,8 @@ var require_config = __commonJS({
2970
3514
  ".__P__-cfg-empty{border:1px dashed var(--cfg-line);border-radius:14px;padding:40px 16px;text-align:center;font-size:12.5px;color:var(--cfg-muted)}",
2971
3515
  ".__P__-cfg-error{display:flex;align-items:center;gap:10px;flex-wrap:wrap;border:1px solid color-mix(in oklab,var(--dsw-alias-state-error-primary,currentColor) 32%,var(--cfg-line));border-radius:10px;padding:10px 13px;color:var(--dsw-alias-state-error-primary,inherit);font-size:12.5px;line-height:1.5}",
2972
3516
  "@media (max-width:820px){.__P__-cfg-row{grid-template-columns:1fr;gap:10px;padding:13px 16px}.__P__-cfg-control{justify-content:flex-start}.__P__-cfg-multi{justify-content:flex-start}.__P__-cfg-gtitle{padding:11px 16px}}",
2973
- "@media (prefers-reduced-motion:reduce){.__P__-cfg-track,.__P__-cfg-track::after,.__P__-cfg-sk{animation:none;transition:none}}"
2974
- ].join("\n").split("__P__").join(PREFIX);
3517
+ "@media (prefers-reduced-motion:reduce){.__P__-cfg-sk{animation:none;transition:none}}"
3518
+ ].concat(SW.styles).concat(NF.styles).join("\n").split("__P__").join(PREFIX);
2975
3519
  function injectCss() {
2976
3520
  if (typeof document === "undefined") return;
2977
3521
  var old = document.getElementById("wb-addon-" + DOMAIN + "-config-css");
@@ -3054,8 +3598,6 @@ var require_config = __commonJS({
3054
3598
  var notice = noticeS[0], setNotice = noticeS[1];
3055
3599
  var savingS = React2.useState("");
3056
3600
  var savingId = savingS[0], setSavingId = savingS[1];
3057
- var draftsS = React2.useState({});
3058
- var drafts = draftsS[0], setDrafts = draftsS[1];
3059
3601
  var busyS = React2.useState(false);
3060
3602
  var busy = busyS[0], setBusy = busyS[1];
3061
3603
  React2.useEffect(function() {
@@ -3141,38 +3683,20 @@ var require_config = __commonJS({
3141
3683
  setNotice({ id: "", text: String(e && e.message || e), error: true });
3142
3684
  });
3143
3685
  }
3144
- function commitDraft(item) {
3145
- var raw = drafts[item.id];
3146
- if (raw === void 0) return;
3147
- var next = String(raw).trim();
3148
- setDrafts(function(prev) {
3149
- var copy = Object.assign({}, prev);
3150
- delete copy[item.id];
3151
- return copy;
3152
- });
3153
- if (next === "") return;
3154
- var value = Number(next);
3155
- if (!Number.isFinite(value)) return;
3156
- if (sameValue(value, state.values[item.id])) return;
3157
- save(item.id, value);
3158
- }
3159
3686
  function renderControl(item) {
3160
3687
  var value = state.values[item.id];
3161
3688
  var label = lang === "en" ? item.en : item.zh;
3162
3689
  if (item.type === "bool") {
3163
- return h2(
3164
- "label",
3165
- { className: PREFIX + "-cfg-switch" },
3166
- h2("input", {
3167
- type: "checkbox",
3168
- checked: value === true,
3169
- onChange: function(e) {
3170
- save(item.id, e.target.checked);
3171
- }
3172
- }),
3173
- h2("span", { className: PREFIX + "-cfg-track", "aria-hidden": "true" }),
3174
- h2("span", { className: PREFIX + "-cfg-switchstate" }, value === true ? t.on : t.off)
3175
- );
3690
+ return h2(SW.Switch, {
3691
+ h: h2,
3692
+ checked: value === true,
3693
+ showState: true,
3694
+ onText: t.on,
3695
+ offText: t.off,
3696
+ onChange: function(next) {
3697
+ save(item.id, next);
3698
+ }
3699
+ });
3176
3700
  }
3177
3701
  if (item.type === "enum") {
3178
3702
  return h2("select", {
@@ -3189,30 +3713,16 @@ var require_config = __commonJS({
3189
3713
  }));
3190
3714
  }
3191
3715
  if (item.type === "int") {
3192
- var draft = drafts[item.id] !== void 0 ? drafts[item.id] : String(value);
3193
- return h2("input", {
3194
- className: PREFIX + "-cfg-input",
3195
- type: "number",
3196
- value: draft,
3716
+ return h2(NF.NumberField, {
3717
+ h: h2,
3718
+ lang,
3719
+ value: value === void 0 ? "" : value,
3197
3720
  min: item.min,
3198
3721
  max: item.max,
3199
- "aria-label": label,
3200
- onChange: function(e) {
3201
- var v = e.target.value;
3202
- setDrafts(function(prev) {
3203
- var c = Object.assign({}, prev);
3204
- c[item.id] = v;
3205
- return c;
3206
- });
3207
- },
3208
- onBlur: function() {
3209
- commitDraft(item);
3210
- },
3211
- onKeyDown: function(e) {
3212
- if (e.key === "Enter") {
3213
- e.preventDefault();
3214
- commitDraft(item);
3215
- }
3722
+ integer: true,
3723
+ ariaLabel: label,
3724
+ onCommit: function(next) {
3725
+ save(item.id, next);
3216
3726
  }
3217
3727
  });
3218
3728
  }
@@ -3985,13 +4495,6 @@ var require_data_style = __commonJS({
3985
4495
  "." + P + "-search input:focus{border-color:var(--dsw-alias-brand-primary,currentColor);box-shadow:0 0 0 3px color-mix(in oklab,var(--dsw-alias-brand-primary,currentColor) 14%,transparent)}",
3986
4496
  "." + P + "-select{border:1px solid var(--cfg-line);background:var(--dsw-alias-bg-base,transparent);color:inherit;border-radius:9px;padding:7px 10px;font:inherit;font-size:12px;outline:none}",
3987
4497
  "." + P + "-select:focus{border-color:var(--dsw-alias-brand-primary,currentColor);box-shadow:0 0 0 3px color-mix(in oklab,var(--dsw-alias-brand-primary,currentColor) 14%,transparent)}",
3988
- "." + P + "-switch{position:relative;display:inline-flex;align-items:center;gap:7px;cursor:pointer;font-size:12px;color:var(--cfg-muted);user-select:none;padding:4px 2px}",
3989
- "." + P + "-switch input{position:absolute;inset:0;width:100%;height:100%;margin:0;opacity:0;cursor:pointer}",
3990
- "." + P + "-track{position:relative;width:34px;height:20px;border-radius:999px;background:color-mix(in oklab,currentColor 18%,transparent);transition:background .16s ease;flex:none}",
3991
- "." + P + "-track::after{content:'';position:absolute;top:2px;left:2px;width:16px;height:16px;border-radius:50%;background:var(--dsw-alias-label-primary,currentColor);transition:transform .16s ease,background .16s ease}",
3992
- "." + P + "-switch input:checked+." + P + "-track{background:var(--dsw-alias-brand-primary,currentColor)}",
3993
- "." + P + "-switch input:checked+." + P + "-track::after{transform:translateX(14px);background:var(--dsw-alias-label-primary-inverted,var(--dsw-alias-bg-base))}",
3994
- "." + P + "-switch input:focus-visible+." + P + "-track{outline:2px solid var(--dsw-alias-brand-primary,currentColor);outline-offset:2px}",
3995
4498
  "." + P + "-btn{display:inline-flex;align-items:center;gap:5px;border:1px solid var(--cfg-line);background:transparent;color:var(--cfg-muted);border-radius:8px;padding:6px 10px;font:inherit;font-size:11.5px;cursor:pointer;white-space:nowrap;transition:background .12s ease,color .12s ease}",
3996
4499
  "." + P + "-btn:hover{background:var(--cfg-hover);color:var(--dsw-alias-label-primary,inherit)}",
3997
4500
  "." + P + "-btn:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,currentColor);outline-offset:2px}",
@@ -4020,8 +4523,8 @@ var require_data_style = __commonJS({
4020
4523
  "." + P + "-foot{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding-top:2px;font-size:11.5px;color:var(--cfg-muted)}",
4021
4524
  "." + P + "-grow{flex:1}",
4022
4525
  "." + P + "-pageinfo{font-variant-numeric:tabular-nums}",
4023
- "." + P + "-jump{width:56px;border:1px solid var(--cfg-line);background:var(--dsw-alias-bg-base,transparent);color:inherit;border-radius:7px;padding:4px 7px;font:inherit;font-size:11.5px;text-align:right;outline:none}",
4024
- "." + P + "-jump:focus{border-color:var(--dsw-alias-brand-primary,currentColor)}",
4526
+ "." + P + "-jump .wbctl-num-input{width:56px;padding:4px 7px;font-size:11.5px;text-align:right}",
4527
+ "." + P + "-jump .wbctl-num-hint{display:none}",
4025
4528
  "." + P + "-empty{border:1px dashed var(--cfg-line);border-radius:11px;padding:44px 16px;text-align:center;font-size:12.5px;color:var(--cfg-muted)}",
4026
4529
  "." + P + "-err{display:flex;align-items:center;gap:10px;flex-wrap:wrap;border:1px solid color-mix(in oklab,var(--dsw-alias-state-error-primary,currentColor) 32%,var(--cfg-line));border-radius:10px;padding:9px 12px;color:var(--dsw-alias-state-error-primary,inherit);font-size:12px;line-height:1.5}",
4027
4530
  "." + P + "-skwrap{display:flex;flex-direction:column;gap:1px;padding:2px}",
@@ -4059,7 +4562,7 @@ var require_data_style = __commonJS({
4059
4562
  "." + P + "-images img{width:36px;height:36px;object-fit:cover;border-radius:5px}",
4060
4563
  "." + P + "-gallery{display:flex;flex-direction:column;gap:12px;overflow:auto;flex:1}",
4061
4564
  "." + P + "-gallery img{width:100%;height:auto;object-fit:contain;border-radius:8px}"
4062
- ].join("\n");
4565
+ ].concat(require_switch().styles).concat(require_number_field().styles).join("\n");
4063
4566
  if (DOMAIN === "storage") {
4064
4567
  var buttons = "." + P + " :is(button)";
4065
4568
  CSS += buttons + "{border:none;background:var(--wb-btn-bg);min-height:var(--wb-btn-size-sm);min-width:var(--wb-btn-size-sm)}" + buttons + ":enabled:hover{background:var(--wb-btn-hover-bg)}" + buttons + ":enabled:active{background:var(--wb-btn-active-bg)}" + buttons + ":disabled{background:var(--wb-btn-bg);color:var(--cfg-muted)}" + buttons + ":focus-visible{outline:var(--wb-btn-focus);outline-offset:var(--wb-btn-focus-offset)}." + P + "-fcell:has(button) input{padding-right:34px}";
@@ -4087,8 +4590,10 @@ var require_data_view = __commonJS({
4087
4590
  "packages/addons/lib/data-view.cjs"(exports2, module2) {
4088
4591
  "use strict";
4089
4592
  var React2 = require("react");
4593
+ var NF = require_number_field();
4090
4594
  var h2 = React2.createElement;
4091
4595
  var COPY = require_data_copy();
4596
+ var SW = require_switch();
4092
4597
  module2.exports = function createDataView(options) {
4093
4598
  var DOMAIN = options.domain;
4094
4599
  function icon(name) {
@@ -4642,17 +5147,18 @@ var require_data_view = __commonJS({
4642
5147
  h2("button", { type: "button", className: P + "-btn", disabled: !data || page >= pages, onClick: function() {
4643
5148
  setPage(Math.min(pages, page + 1));
4644
5149
  } }, t.next + " \u203A"),
4645
- h2("input", {
5150
+ h2(NF.NumberField, {
5151
+ h: h2,
5152
+ lang,
4646
5153
  className: P + "-jump",
4647
- type: "number",
5154
+ value: page,
4648
5155
  min: 1,
4649
5156
  max: pages,
4650
- "aria-label": t.jump,
4651
- onKeyDown: function(e) {
4652
- if (e.key === "Enter") {
4653
- var n = Math.floor(Number(e.target.value));
4654
- if (n >= 1) setPage(Math.min(pages, n));
4655
- }
5157
+ integer: true,
5158
+ ariaLabel: t.jump,
5159
+ hint: false,
5160
+ onCommit: function(next) {
5161
+ if (next !== null) setPage(next);
4656
5162
  }
4657
5163
  }),
4658
5164
  data && data.queryMs !== void 0 ? h2("span", null, fmt(t.queryTime, { n: data.queryMs })) : null
@@ -4749,25 +5255,23 @@ var require_data_view = __commonJS({
4749
5255
  }
4750
5256
  })
4751
5257
  ),
4752
- h2(
4753
- "label",
4754
- { className: P + "-switch" },
4755
- h2("input", { type: "checkbox", checked: includeDeleted, onChange: function(e) {
4756
- setIncludeDeleted(e.target.checked);
5258
+ h2(SW.Switch, {
5259
+ h: h2,
5260
+ checked: includeDeleted,
5261
+ label: t.includeDeleted,
5262
+ onChange: function(next) {
5263
+ setIncludeDeleted(next);
4757
5264
  setPage(1);
4758
- } }),
4759
- h2("span", { className: P + "-track" }),
4760
- h2("span", null, t.includeDeleted)
4761
- ),
4762
- h2(
4763
- "label",
4764
- { className: P + "-switch" },
4765
- h2("input", { type: "checkbox", checked: showSystem, onChange: function(e) {
4766
- setShowSystem(e.target.checked);
4767
- } }),
4768
- h2("span", { className: P + "-track" }),
4769
- h2("span", null, t.showSystem)
4770
- ),
5265
+ }
5266
+ }),
5267
+ h2(SW.Switch, {
5268
+ h: h2,
5269
+ checked: showSystem,
5270
+ label: t.showSystem,
5271
+ onChange: function(next) {
5272
+ setShowSystem(next);
5273
+ }
5274
+ }),
4771
5275
  h2("span", { className: P + "-grow" }),
4772
5276
  h2(
4773
5277
  "label",
@@ -4953,7 +5457,6 @@ var require_copy = __commonJS({
4953
5457
  externalAdd: "\u6DFB\u52A0\u5916\u8054",
4954
5458
  unlink: "\u89E3\u9664\u5916\u8054",
4955
5459
  accountEmpty: "\u8FD9\u4E2A\u7AD9\u70B9\u8FD8\u6CA1\u6709\u8D26\u53F7",
4956
- cancel: "\u53D6\u6D88",
4957
5460
  close: "\u5173\u95ED",
4958
5461
  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",
4959
5462
  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",
@@ -5067,7 +5570,6 @@ var require_copy = __commonJS({
5067
5570
  externalAdd: "Add link",
5068
5571
  unlink: "Unlink",
5069
5572
  accountEmpty: "No accounts yet",
5070
- cancel: "Cancel",
5071
5573
  close: "Close",
5072
5574
  sensitiveHint: "Password / phone / ID card are encrypted before writing and can only be read after unlocking the vault.",
5073
5575
  vaultInvalid: "The credential set is gone (deleted); saving any sensitive field rebuilds it.",
@@ -5293,7 +5795,7 @@ var require_styles = __commonJS({
5293
5795
  ".wbs-toast{position:fixed;left:50%;bottom:38px;transform:translateX(-50%);z-index:1200;background:var(--dsw-alias-toast-bg,#26302d);color:var(--dsw-alias-toast-label,#fff);border-radius:8px;padding:8px 14px;font-size:12px;box-shadow:0 8px 24px rgba(0,0,0,.22);max-width:80vw}",
5294
5796
  ".wbs-toast.err{background:var(--dsw-alias-state-error-primary,#9d332b)}",
5295
5797
  ".wbs-mask{position:fixed;inset:0;z-index:900;background:rgba(24,28,26,.34);display:flex;align-items:center;justify-content:center;padding:22px}",
5296
- ".wbs-modal{width:min(700px,96vw);max-height:88vh;overflow:auto;background:var(--dsw-alias-bg-layer-1,#fffdf7);border:1px solid var(--wbs-line);border-radius:14px;box-shadow:0 24px 70px rgba(0,0,0,.24);padding:18px}",
5798
+ // 分步表单的字段容器:两列排布,窄屏回落单列(宽度与步骤条来自 lib/staged-dialog.cjs)。\n ".wbs-field{display:flex;flex-direction:column;gap:5px;min-width:0}",\n ".wbs-field.full{grid-column:1 / -1}",\n ".wbs-field .wbs-label{margin:0}",\n ".wbs-modal{width:min(700px,96vw);max-height:88vh;overflow:auto;background:var(--dsw-alias-bg-layer-1,#fffdf7);border:1px solid var(--wbs-line);border-radius:14px;box-shadow:0 24px 70px rgba(0,0,0,.24);padding:18px}",
5297
5799
  ".wbs-modal.small{width:min(430px,94vw)}",
5298
5800
  ".wbs-modal-title{display:flex;align-items:center;gap:8px;font-size:16px;font-weight:650;margin-bottom:4px}",
5299
5801
  ".wbs-modal-title .wbs-svg{color:var(--wbs-accent);opacity:.85;flex:none}",
@@ -5325,7 +5827,7 @@ var require_styles = __commonJS({
5325
5827
  ".wbs-note{font-size:11px;color:var(--wbs-muted);line-height:1.6}",
5326
5828
  "@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}}",
5327
5829
  "@media(max-width:600px){.wbs-head h2{font-size:18px}.wbs-linkrow{grid-template-columns:1fr 1fr}.wbs-modal{padding:14px}}"
5328
- ].concat(require_filter_checklist_styles()).concat(require_client_base_styles().secretFieldStyles).concat([require_date_picker_styles()("wbs")]).join("\n");
5830
+ ].concat(require_stepper().styles, require_staged_dialog().styles).concat(require_filter_checklist_styles()).concat(require_client_base_styles().secretFieldStyles).concat([require_date_picker_styles()("wbs")]).concat(require_switch().styles).join("\n");
5329
5831
  }
5330
5832
  });
5331
5833
 
@@ -5935,16 +6437,13 @@ var require_action_schema_style = __commonJS({
5935
6437
  "." + P + "-cardmeta{display:flex;align-items:center;flex-wrap:wrap;gap:8px;min-width:0;min-height:24px}",
5936
6438
  "." + P + "-cardhead code{font-weight:640;overflow-wrap:anywhere;min-width:0}",
5937
6439
  "." + P + "-hintline{margin:0;color:var(--dsw-alias-label-tertiary,inherit);font-size:11.5px;line-height:1.5}",
5938
- "." + 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}",
5939
- "." + 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)}",
5940
- "." + P + "-track::before{content:'';width:12px;height:12px;border-radius:50%;background:currentColor;transition:transform .15s ease}",
5941
- "." + P + "-toggle[aria-checked=true] ." + P + "-track{background:var(--wb-accent);border-color:var(--wb-accent);color:var(--wb-card)}",
5942
- "." + P + "-toggle[aria-checked=true] ." + P + "-track::before{transform:translateX(12px)}",
5943
- "." + P + "-toggle:hover:not(:disabled) ." + P + "-track{outline:1px solid var(--wb-accent)}",
5944
- "." + P + "-toggle:focus-visible{outline:2px solid var(--wb-accent);outline-offset:2px}",
5945
- "." + P + "-toggle:disabled{opacity:.6;cursor:progress}",
5946
- "@media(prefers-reduced-motion:reduce){." + P + "-track::before{transition:none}}",
5947
- // 安全约束(不可放开):用警示色描边,和可切换的开关区分开。
6440
+ "." + P + "-origins{display:inline-flex;align-items:center;gap:10px;flex-wrap:wrap;justify-content:flex-end}",
6441
+ "." + P + "-origins-label{font-size:11px;color:var(--wb-muted);white-space:nowrap}",
6442
+ "." + P + "-origin{display:inline-flex;align-items:center;gap:4px;font-size:11.5px;color:var(--wb-muted);cursor:pointer;user-select:none}",
6443
+ // 该 action 本身不支持的来源:整项置灰、不可点,示意「不是没开,是开不了」。
6444
+ "." + P + "-origin-off{opacity:.55;cursor:not-allowed}",
6445
+ "." + P + "-origin input[type=checkbox]{width:13px;height:13px;margin:0;accent-color:var(--wb-accent);cursor:inherit}",
6446
+ "." + P + "-origin input[type=checkbox]:focus-visible{outline:2px solid var(--wb-accent);outline-offset:2px}",
5948
6447
  "." + P + "-locked{border-color:var(--wb-warn,#b7791f);color:var(--wb-warn,#b7791f)}",
5949
6448
  "." + P + "-desc{margin:0;color:var(--dsw-alias-label-secondary,inherit);line-height:1.55;font-size:12.5px}",
5950
6449
  // 搜索命中:用品牌色透明度叠加而不是写死浅色,深浅主题都可读;继承文字颜色、不覆盖 ::selection。
@@ -5997,15 +6496,20 @@ var require_action_schema_view = __commonJS({
5997
6496
  zh: {
5998
6497
  title: "Action",
5999
6498
  hint: "\u8FD0\u884C\u65F6\u6CE8\u518C \xB7 \u53EA\u8BFB",
6000
- switchHint: "agent \u5F00\u5173\u843D\u672C\u673A\u3001\u5373\u6539\u5373\u751F\u6548\uFF1B\u754C\u9762\u64CD\u4F5C\u4E0D\u53D7\u5F71\u54CD\u3002",
6001
- 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",
6002
- agentSwitch: "agent \u53EF\u7528",
6003
- agentLocked: "\u4EC5\u754C\u9762 \xB7 \u5B89\u5168\u7EA6\u675F",
6004
- agentLockedHint: "\u8BE5 action \u53EA\u80FD\u5728\u754C\u9762\u6267\u884C\uFF08\u5B89\u5168\u7EA6\u675F\uFF09\uFF0Cagent \u5F00\u5173\u4E0D\u53EF\u653E\u5F00",
6005
- agentSaving: "\u4FDD\u5B58\u4E2D\u2026",
6006
- agentOnToast: "\u5DF2\u5141\u8BB8 agent \u8C03\u7528",
6007
- agentOffToast: "\u5DF2\u7981\u6B62 agent \u8C03\u7528",
6008
- agentFail: "\u5207\u6362 agent \u5F00\u5173\u5931\u8D25",
6499
+ switchHint: "\u5141\u8BB8\u6765\u6E90\u843D\u672C\u673A\u3001\u5373\u6539\u5373\u751F\u6548\uFF1A\u52FE\u4E0A\u7684\u6765\u6E90\u624D\u80FD\u8C03\u7528\u8BE5 action\uFF0C\u5176\u4F59\u4F1A\u88AB ACTION_ORIGIN_DENIED \u62E6\u4E0B\u3002",
6500
+ hostHint: "\u5BBF\u4E3B action \u7684\u5141\u8BB8\u6765\u6E90\uFF1B\u6807\u300C\u6765\u6E90\u56FA\u5B9A\u300D\u7684\u4E0D\u53EF\u4FEE\u6539\u3002",
6501
+ originsLabel: "\u5141\u8BB8\u6765\u6E90",
6502
+ originUi: "\u754C\u9762",
6503
+ originPlugin: "\u63D2\u4EF6",
6504
+ originAgent: "agent",
6505
+ originSync: "\u540C\u6B65",
6506
+ originsSaving: "\u4FDD\u5B58\u4E2D\u2026",
6507
+ originsToast: "\u5DF2\u66F4\u65B0\u5141\u8BB8\u6765\u6E90",
6508
+ originsFail: "\u66F4\u65B0\u5141\u8BB8\u6765\u6E90\u5931\u8D25",
6509
+ originsEmpty: "\u81F3\u5C11\u8981\u4FDD\u7559\u4E00\u4E2A\u6765\u6E90",
6510
+ originsUnsupported: "\u8BE5 action \u672C\u8EAB\u4E0D\u652F\u6301\u8FD9\u4E2A\u6765\u6E90",
6511
+ originsPinned: "\u6765\u6E90\u56FA\u5B9A",
6512
+ originsPinnedHint: "\u8BE5 action \u7684\u5141\u8BB8\u6765\u6E90\u88AB\u56FA\u5B9A\uFF08\u5B89\u5168\u7EA6\u675F\uFF09\uFF0C\u4E0D\u80FD\u4FEE\u6539",
6009
6513
  domain: "\u57DF",
6010
6514
  versionLabel: "\u7248\u672C",
6011
6515
  shell: "\u5BBF\u4E3B",
@@ -6019,6 +6523,8 @@ var require_action_schema_view = __commonJS({
6019
6523
  onlyOptional: "\u65E0\u5FC5\u586B\u9879",
6020
6524
  filterType: "\u53C2\u6570\u7C7B\u578B",
6021
6525
  allTypes: "\u5168\u90E8\u7C7B\u578B",
6526
+ filterOrigin: "\u5141\u8BB8\u6765\u6E90",
6527
+ allOrigins: "\u5168\u90E8\u6765\u6E90",
6022
6528
  colName: "\u53C2\u6570",
6023
6529
  colType: "\u7C7B\u578B",
6024
6530
  colReq: "\u5FC5\u586B",
@@ -6051,15 +6557,22 @@ var require_action_schema_view = __commonJS({
6051
6557
  en: {
6052
6558
  title: "Actions",
6053
6559
  hint: "runtime registry \xB7 read-only",
6054
- switchHint: "The agent switch is stored locally and applies immediately; UI actions are unaffected.",
6055
- hostHint: "Agent switch for host actions; items marked UI-only (security) cannot be opened up.",
6056
- agentSwitch: "Agent callable",
6057
- agentLocked: "UI only \xB7 security",
6058
- agentLockedHint: "This action can only run from the UI (security constraint); the agent switch cannot be opened",
6059
- agentSaving: "Saving\u2026",
6060
- agentOnToast: "Agent calls allowed",
6061
- agentOffToast: "Agent calls blocked",
6062
- agentFail: "Failed to change the agent switch",
6560
+ switchHint: "Allowed origins are stored locally and apply immediately: only checked origins may call the action; others get ACTION_ORIGIN_DENIED.",
6561
+ hostHint: "Allowed origins for host actions; items marked pinned cannot be changed.",
6562
+ originsLabel: "Origins",
6563
+ originUi: "UI",
6564
+ originPlugin: "Plugin",
6565
+ originAgent: "Agent",
6566
+ originSync: "Sync",
6567
+ originsSaving: "Saving\u2026",
6568
+ originsToast: "Allowed origins updated",
6569
+ originsFail: "Failed to update allowed origins",
6570
+ originsEmpty: "Keep at least one origin",
6571
+ originsUnsupported: "This action does not support this origin",
6572
+ originsPinned: "Pinned",
6573
+ originsPinnedHint: "Allowed origins are pinned for this action (security constraint) and cannot be changed",
6574
+ originsDefaultOn: "Allowed by default",
6575
+ originsDefaultOff: "Off by default, can be enabled",
6063
6576
  domain: "Domain",
6064
6577
  versionLabel: "Version",
6065
6578
  shell: "Host",
@@ -6073,6 +6586,8 @@ var require_action_schema_view = __commonJS({
6073
6586
  onlyOptional: "No required",
6074
6587
  filterType: "Param type",
6075
6588
  allTypes: "All types",
6589
+ filterOrigin: "Origins",
6590
+ allOrigins: "All origins",
6076
6591
  colName: "Param",
6077
6592
  colType: "Type",
6078
6593
  colReq: "Required",
@@ -6216,6 +6731,8 @@ var require_action_schema_view = __commonJS({
6216
6731
  var reqMode = reqState[0], setReqMode = reqState[1];
6217
6732
  var typeState = React2.useState("");
6218
6733
  var typePick = typeState[0], setTypePick = typeState[1];
6734
+ var originFilterState = React2.useState("");
6735
+ var originPick = originFilterState[0], setOriginPick = originFilterState[1];
6219
6736
  var toastState = React2.useState("");
6220
6737
  var toast = toastState[0], setToast = toastState[1];
6221
6738
  var savingState = React2.useState("");
@@ -6271,38 +6788,53 @@ var require_action_schema_view = __commonJS({
6271
6788
  plainCopy(text);
6272
6789
  done();
6273
6790
  }
6274
- function setAgent(action, next) {
6791
+ var ORIGINS = ["ui", "plugin", "agent", "sync"];
6792
+ var originText = { ui: t.originUi, plugin: t.originPlugin, agent: t.originAgent, sync: t.originSync };
6793
+ function setOrigins(action, origin) {
6275
6794
  var name = action.name;
6795
+ var current = Array.isArray(action.origins) ? action.origins.slice() : [];
6796
+ var index = current.indexOf(origin);
6797
+ var next = index >= 0 ? current.filter(function(o) {
6798
+ return o !== origin;
6799
+ }) : current.concat([origin]);
6800
+ if (next.length === 0) {
6801
+ setToast(t.originsEmpty);
6802
+ return;
6803
+ }
6804
+ next = ORIGINS.filter(function(o) {
6805
+ return next.indexOf(o) >= 0;
6806
+ });
6276
6807
  setSaving(name);
6277
6808
  setToast("");
6278
6809
  var fail = function(e) {
6279
6810
  setSaving("");
6280
- setToast(t.agentFail + "\uFF1A" + String(e && e.message || e || ""));
6811
+ setToast(t.originsFail + "\uFF1A" + String(e && e.message || e || ""));
6281
6812
  };
6282
6813
  var done = function(r) {
6283
6814
  setSaving("");
6284
6815
  var payload = r && typeof r === "object" && Object.prototype.hasOwnProperty.call(r, "result") ? r.result : r;
6285
6816
  if (r && r.ok === false) {
6286
- setToast(t.agentFail + "\uFF1A" + String(r.error || r.text || ""));
6817
+ setToast(t.originsFail + "\uFF1A" + String(r.error || r.text || ""));
6287
6818
  return;
6288
6819
  }
6289
- var value = payload && typeof payload.agentEnabled === "boolean" ? payload.agentEnabled : next;
6820
+ var value = payload && Array.isArray(payload.origins) ? payload.origins : next;
6821
+ var source = payload && typeof payload.source === "string" ? payload.source : action.originsSource;
6290
6822
  setSnap(function(prev) {
6291
6823
  if (!prev || !Array.isArray(prev.actions)) return prev;
6292
6824
  return Object.assign({}, prev, {
6293
6825
  actions: prev.actions.map(function(a) {
6294
6826
  if (!a || a.name !== name) return a;
6295
- return Object.assign({}, a, { agentEnabled: value });
6827
+ return Object.assign({}, a, { origins: value, originsSource: source });
6296
6828
  })
6297
6829
  });
6298
6830
  });
6299
- setToast(value ? t.agentOnToast : t.agentOffToast);
6831
+ setToast(t.originsToast);
6300
6832
  };
6301
6833
  if (!api || typeof api.call !== "function") {
6302
6834
  fail(new Error("no call api"));
6303
6835
  return;
6304
6836
  }
6305
- Promise.resolve(api.call("actions.setAgentAccess", { action: name, agentEnabled: next })).then(done, fail);
6837
+ Promise.resolve(api.call("actions.setActionOrigins", { action: name, origins: next })).then(done, fail);
6306
6838
  }
6307
6839
  var all = snap && Array.isArray(snap.actions) ? snap.actions.filter(function(a) {
6308
6840
  return a && a.domain === DOMAIN;
@@ -6337,6 +6869,7 @@ var require_action_schema_view = __commonJS({
6337
6869
  if (typePick && !rows.some(function(row) {
6338
6870
  return row.types.indexOf(typePick) >= 0;
6339
6871
  })) return false;
6872
+ if (originPick && (!Array.isArray(a.origins) || a.origins.indexOf(originPick) < 0)) return false;
6340
6873
  return true;
6341
6874
  });
6342
6875
  function paramRow(row) {
@@ -6352,33 +6885,45 @@ var require_action_schema_view = __commonJS({
6352
6885
  h2("td", null, Highlight.hit(row.description, kw))
6353
6886
  );
6354
6887
  }
6355
- function agentSwitch(action) {
6356
- if (action.agentLocked === true) {
6357
- return h2("span", {
6358
- className: P + "-badge " + P + "-locked",
6359
- title: t.agentLockedHint,
6360
- "data-agent-locked": action.name
6361
- }, t.agentLocked);
6888
+ function originsChips(action) {
6889
+ if (!Array.isArray(action.origins)) return null;
6890
+ if (action.originsSource === "invalid") {
6891
+ return h2("span", { className: P + "-badge " + P + "-locked", title: t.originsPinnedHint, "data-origins-invalid": action.name }, t.originsPinned);
6362
6892
  }
6363
- if (typeof action.agentEnabled !== "boolean") return null;
6364
6893
  var busy = saving === action.name;
6894
+ var pinned = action.name === "actions.setActionOrigins";
6895
+ var supported = Array.isArray(action.originsDeclared) ? action.originsDeclared : action.origins;
6365
6896
  return h2(
6366
- "button",
6367
- {
6368
- className: P + "-toggle",
6369
- "data-agent-row": action.name,
6370
- type: "button",
6371
- role: "switch",
6372
- "aria-checked": action.agentEnabled,
6373
- disabled: busy,
6374
- "data-agent-toggle": action.name,
6375
- "aria-label": t.agentSwitch + " \xB7 " + action.name,
6376
- onClick: function() {
6377
- setAgent(action, !action.agentEnabled);
6378
- }
6379
- },
6380
- h2("span", { className: P + "-track", "aria-hidden": true }),
6381
- h2("span", null, busy ? t.agentSaving : t.agentSwitch)
6897
+ "div",
6898
+ { className: P + "-origins", "data-origins-row": action.name },
6899
+ h2("span", { className: P + "-origins-label" }, t.originsLabel),
6900
+ ORIGINS.map(function(origin) {
6901
+ var on = action.origins.indexOf(origin) >= 0;
6902
+ var allowed = supported.indexOf(origin) >= 0;
6903
+ var preset = Array.isArray(action.originsDefault) ? action.originsDefault : supported;
6904
+ var byDefault = preset.indexOf(origin) >= 0;
6905
+ return h2(
6906
+ "label",
6907
+ {
6908
+ key: origin,
6909
+ className: P + "-origin" + (allowed ? "" : " " + P + "-origin-off"),
6910
+ title: pinned ? t.originsPinnedHint : !allowed ? t.originsUnsupported : originText[origin] + " \xB7 " + action.name + " \xB7 " + (byDefault ? t.originsDefaultOn : t.originsDefaultOff)
6911
+ },
6912
+ h2("input", {
6913
+ type: "checkbox",
6914
+ checked: on,
6915
+ disabled: busy || pinned || !allowed,
6916
+ "data-origin": origin,
6917
+ "data-origin-row": action.name,
6918
+ "data-origin-supported": allowed ? "1" : "0",
6919
+ onChange: function() {
6920
+ setOrigins(action, origin);
6921
+ }
6922
+ }),
6923
+ h2("span", null, originText[origin])
6924
+ );
6925
+ }),
6926
+ busy ? h2("span", { className: P + "-origins-label" }, t.originsSaving) : null
6382
6927
  );
6383
6928
  }
6384
6929
  function card(action) {
@@ -6399,7 +6944,7 @@ var require_action_schema_view = __commonJS({
6399
6944
  return row.required;
6400
6945
  }) ? h2("span", { className: P + "-badge " + P + "-req" }, t.required) : null
6401
6946
  ),
6402
- agentSwitch(action)
6947
+ originsChips(action)
6403
6948
  ),
6404
6949
  action.description ? h2("p", { className: P + "-desc" }, Highlight.hit(action.description, kw)) : null,
6405
6950
  rows.length ? h2(
@@ -6522,6 +7067,21 @@ var require_action_schema_view = __commonJS({
6522
7067
  return h2("option", { value: name, key: name }, name);
6523
7068
  })
6524
7069
  )
7070
+ ),
7071
+ h2(
7072
+ "label",
7073
+ { className: P + "-none" },
7074
+ t.filterOrigin + " ",
7075
+ h2(
7076
+ "select",
7077
+ { value: originPick, "aria-label": t.filterOrigin, "data-origin-filter": "", onChange: function(e) {
7078
+ setOriginPick(e.target.value);
7079
+ } },
7080
+ h2("option", { value: "" }, t.allOrigins),
7081
+ ORIGINS.map(function(origin) {
7082
+ return h2("option", { value: origin, key: origin }, originText[origin]);
7083
+ })
7084
+ )
6525
7085
  )
6526
7086
  ) : null,
6527
7087
  body,
@@ -6549,6 +7109,7 @@ var React = require("react");
6549
7109
  var h = React.createElement;
6550
7110
  var TagFilter = require_tagfilter();
6551
7111
  var createOverlay = require_overlay();
7112
+ var staged = require_staged_dialog();
6552
7113
  (function() {
6553
7114
  var host = window.__WB_HOST__;
6554
7115
  if (!host) {
@@ -6627,6 +7188,28 @@ var createOverlay = require_overlay();
6627
7188
  return props.small ? " small" : "";
6628
7189
  }
6629
7190
  });
7191
+ var SiteFormDialog = staged.createStagedDialog({
7192
+ React: React2,
7193
+ tag: "div",
7194
+ displayName: "SiteFormDialog",
7195
+ maskClass: "wbs-mask",
7196
+ dialogClass: "wbs-modal",
7197
+ header: function(p) {
7198
+ return h2(
7199
+ "div",
7200
+ { className: "wbs-modal-title" },
7201
+ h2(Icon2, { name: p.mode === "edit" ? "edit" : "plus", size: 15 }),
7202
+ p.title,
7203
+ h2("button", { type: "button", className: "wbs-mini wbs-modal-x", title: p.cancelLabel, disabled: !!p.submitting, onClick: p.onClose }, h2(Icon2, { name: "x", size: 15 }))
7204
+ );
7205
+ },
7206
+ closeOnEscape: function(p) {
7207
+ return !p.submitting;
7208
+ },
7209
+ closeOnMask: function(p) {
7210
+ return !p.submitting;
7211
+ }
7212
+ });
6630
7213
  function SiteFormModal(props) {
6631
7214
  var api = props.api;
6632
7215
  var lang = props.lang || "zh";
@@ -6634,8 +7217,6 @@ var createOverlay = require_overlay();
6634
7217
  var site = props.site;
6635
7218
  var current = props.current || { id: "0", path: [] };
6636
7219
  var tagOn = !!props.tagOn;
6637
- var maxStep = tagOn ? 2 : 1;
6638
- var [step, setStep] = useState(0);
6639
7220
  var [name, setName] = useState(site ? site.siteName : "");
6640
7221
  var [desc, setDesc] = useState(site ? site.description : "");
6641
7222
  var [links, setLinks] = useState(function() {
@@ -6729,33 +7310,23 @@ var createOverlay = require_overlay();
6729
7310
  }
6730
7311
  function removeLink(index) {
6731
7312
  setLinks(function(prev) {
6732
- var next2 = prev.filter(function(_, i) {
7313
+ var next = prev.filter(function(_, i) {
6733
7314
  return i !== index;
6734
7315
  });
6735
- return next2.length ? next2 : [{ description: "", link: "" }];
7316
+ return next.length ? next : [{ description: "", link: "" }];
6736
7317
  });
6737
7318
  if (defaultIdx === index) setDefaultIdx(0);
6738
7319
  else if (defaultIdx > index) setDefaultIdx(defaultIdx - 1);
6739
7320
  }
6740
- function validate(toStep) {
6741
- if (toStep >= 1 && !String(name).trim()) {
7321
+ function save() {
7322
+ if (!String(name).trim()) {
6742
7323
  setError(text(lang, "requiredName"));
6743
- return false;
7324
+ return;
6744
7325
  }
6745
- if (toStep >= 2 && !dirIds.length) {
7326
+ if (!dirIds.length) {
6746
7327
  setError(text(lang, "requiredDirs"));
6747
- return false;
7328
+ return;
6748
7329
  }
6749
- setError("");
6750
- return true;
6751
- }
6752
- function next() {
6753
- if (step >= maxStep) return;
6754
- if (!validate(step + 1)) return;
6755
- setStep(step + 1);
6756
- }
6757
- function save() {
6758
- if (!validate(2)) return;
6759
7330
  setSaving(true);
6760
7331
  setError("");
6761
7332
  var siteLinks = links.filter(function(l) {
@@ -6786,170 +7357,199 @@ var createOverlay = require_overlay();
6786
7357
  setError(errText(e));
6787
7358
  });
6788
7359
  }
6789
- var steps = tagOn ? [text(lang, "step1"), text(lang, "step2"), text(lang, "step3")] : [text(lang, "step1"), text(lang, "step2")];
6790
7360
  var title = mode === "edit" ? text(lang, "editTitle") : text(lang, "createTitle");
6791
- return h2(
6792
- Modal,
6793
- { "aria-label": title, onClose: saving ? null : props.onClose },
6794
- h2(
6795
- "div",
6796
- { className: "wbs-modal-title" },
6797
- h2(Icon2, { name: mode === "edit" ? "edit" : "plus", size: 15 }),
6798
- title,
6799
- h2("button", { type: "button", className: "wbs-mini wbs-modal-x", title: text(lang, "cancel"), onClick: props.onClose }, h2(Icon2, { name: "x", size: 15 }))
6800
- ),
6801
- h2("div", { className: "wbs-steps" }, steps.map(function(s, i) {
6802
- return h2("span", { key: i, className: "wbs-step" + (i === step ? " on" : "") }, i + 1 + " \xB7 " + s);
6803
- })),
6804
- step === 0 ? h2(
6805
- "div",
6806
- null,
6807
- h2("label", { className: "wbs-label" }, text(lang, "siteName")),
6808
- h2("input", {
6809
- className: "wbs-input",
6810
- value: name,
6811
- autoFocus: true,
6812
- placeholder: text(lang, "siteNamePh"),
6813
- onChange: function(e) {
6814
- setName(e.target.value);
6815
- }
6816
- }),
6817
- h2("label", { className: "wbs-label" }, text(lang, "desc")),
6818
- h2("textarea", {
6819
- className: "wbs-textarea",
6820
- value: desc,
6821
- placeholder: text(lang, "descPh"),
6822
- onChange: function(e) {
6823
- setDesc(e.target.value);
6824
- }
6825
- }),
6826
- h2("label", { className: "wbs-label" }, text(lang, "linkList")),
6827
- links.map(function(l, i) {
6828
- return h2(
7361
+ var steps = [
7362
+ {
7363
+ key: "basic",
7364
+ label: text(lang, "step1"),
7365
+ render: function(hh) {
7366
+ return hh(
6829
7367
  "div",
6830
- { className: "wbs-linkrow", key: i },
6831
- h2("input", {
6832
- className: "wbs-input",
6833
- value: l.description,
6834
- placeholder: text(lang, "linkDesc"),
6835
- onChange: function(e) {
6836
- updateLink(i, "description", e.target.value);
6837
- }
6838
- }),
6839
- h2("input", {
6840
- className: "wbs-input",
6841
- value: l.link,
6842
- placeholder: text(lang, "linkUrl"),
6843
- onChange: function(e) {
6844
- updateLink(i, "link", e.target.value);
6845
- }
6846
- }),
6847
- h2(
6848
- "label",
6849
- { className: "wbs-radio", title: text(lang, "setDefault") },
6850
- h2("input", {
6851
- type: "radio",
6852
- name: "wbs-default-link",
6853
- checked: defaultIdx === i,
6854
- onChange: function() {
6855
- setDefaultIdx(i);
7368
+ { className: "wbctl-form" },
7369
+ hh(
7370
+ "div",
7371
+ { className: "wbs-field" },
7372
+ hh("label", { className: "wbs-label" }, text(lang, "siteName")),
7373
+ hh("input", {
7374
+ className: "wbs-input",
7375
+ value: name,
7376
+ placeholder: text(lang, "siteNamePh"),
7377
+ onChange: function(e) {
7378
+ setName(e.target.value);
6856
7379
  }
6857
- }),
6858
- text(lang, "default")
7380
+ })
6859
7381
  ),
6860
- h2("button", { type: "button", className: "wbs-mini", title: text(lang, "removeLink"), onClick: function() {
6861
- removeLink(i);
6862
- } }, h2(Icon2, { name: "x", size: 13 }))
6863
- );
6864
- }),
6865
- h2("button", { type: "button", className: "wbs-btn sm", onClick: addLink }, h2(Icon2, { name: "plus", size: 13 }), text(lang, "addLink"))
6866
- ) : null,
6867
- step === 1 ? h2(
6868
- "div",
6869
- null,
6870
- h2("div", { className: "wbs-label" }, text(lang, "chooseDirs")),
6871
- !flatDirs.length ? h2("div", { className: "wbs-note" }, text(lang, "noDirs")) : h2(
6872
- "div",
6873
- { className: "wbs-dirlist" },
6874
- flatDirs.map(function(item) {
6875
- var id = String(item.node.id);
6876
- return h2(
6877
- "label",
6878
- {
6879
- key: id,
6880
- className: "wbs-dircheck",
6881
- style: { paddingLeft: 6 + item.depth * 16 }
6882
- },
6883
- h2("input", {
6884
- type: "checkbox",
6885
- checked: dirIds.indexOf(id) >= 0,
6886
- onChange: function() {
6887
- toggleDir(id);
7382
+ hh(
7383
+ "div",
7384
+ { className: "wbs-field" },
7385
+ hh("label", { className: "wbs-label" }, text(lang, "desc")),
7386
+ hh("textarea", {
7387
+ className: "wbs-textarea",
7388
+ rows: 3,
7389
+ value: desc,
7390
+ placeholder: text(lang, "descPh"),
7391
+ onChange: function(e) {
7392
+ setDesc(e.target.value);
6888
7393
  }
7394
+ })
7395
+ ),
7396
+ hh(
7397
+ "div",
7398
+ { className: "wbs-field full" },
7399
+ hh("label", { className: "wbs-label" }, text(lang, "linkList")),
7400
+ links.map(function(l, i) {
7401
+ return hh(
7402
+ "div",
7403
+ { className: "wbs-linkrow", key: i },
7404
+ hh("input", {
7405
+ className: "wbs-input",
7406
+ value: l.description,
7407
+ placeholder: text(lang, "linkDesc"),
7408
+ onChange: function(e) {
7409
+ updateLink(i, "description", e.target.value);
7410
+ }
7411
+ }),
7412
+ hh("input", {
7413
+ className: "wbs-input",
7414
+ value: l.link,
7415
+ placeholder: text(lang, "linkUrl"),
7416
+ onChange: function(e) {
7417
+ updateLink(i, "link", e.target.value);
7418
+ }
7419
+ }),
7420
+ hh(
7421
+ "label",
7422
+ { className: "wbs-radio", title: text(lang, "setDefault") },
7423
+ hh("input", {
7424
+ type: "radio",
7425
+ name: "wbs-default-link",
7426
+ checked: defaultIdx === i,
7427
+ onChange: function() {
7428
+ setDefaultIdx(i);
7429
+ }
7430
+ }),
7431
+ text(lang, "default")
7432
+ ),
7433
+ hh("button", { type: "button", className: "wbs-mini", title: text(lang, "removeLink"), onClick: function() {
7434
+ removeLink(i);
7435
+ } }, hh(Icon2, { name: "x", size: 13 }))
7436
+ );
6889
7437
  }),
6890
- h2("span", null, item.node.name)
6891
- );
6892
- })
6893
- ),
6894
- h2("div", { className: "wbs-note", style: { marginTop: 8 } }, "\u7AD9\u70B9\u53EF\u540C\u65F6\u6302\u5728\u591A\u4E2A\u76EE\u5F55\u4E0B\uFF1B\u5217\u8868\u4F1A\u6309\u76EE\u5F55\u5B50\u6811\u8FC7\u6EE4\u3002")
6895
- ) : null,
6896
- tagOn && step === 2 ? h2(
6897
- "div",
6898
- null,
6899
- h2("div", { className: "wbs-label" }, text(lang, "chooseTags")),
6900
- tags.length ? h2("div", { className: "wbs-chips" }, tags.map(function(t) {
6901
- return h2(
6902
- "span",
6903
- { className: "wbs-chip", key: t.id },
6904
- t.name,
6905
- h2("button", { type: "button", onClick: function() {
6906
- toggleTag(t);
6907
- }, title: "\u79FB\u9664" }, h2(Icon2, { name: "x", size: 12 }))
7438
+ hh("button", { type: "button", className: "wbs-btn sm", onClick: addLink }, hh(Icon2, { name: "plus", size: 13 }), text(lang, "addLink"))
7439
+ )
6908
7440
  );
6909
- })) : h2("div", { className: "wbs-note" }, "\u6682\u672A\u9009\u62E9\u6807\u7B7E"),
6910
- h2(
6911
- "div",
6912
- { className: "wbs-tagsearch", style: { marginTop: 10 } },
6913
- h2("input", {
6914
- className: "wbs-input",
6915
- value: tagQuery,
6916
- placeholder: text(lang, "tagSearch"),
6917
- onChange: function(e) {
6918
- setTagQuery(e.target.value);
6919
- }
6920
- })
6921
- ),
6922
- h2("div", { className: "wbs-tagresults" }, tagResults.length ? tagResults.map(function(t) {
6923
- var on = tags.some(function(x) {
6924
- return x.id === t.id;
6925
- });
6926
- return h2(
6927
- "button",
6928
- {
6929
- key: t.id,
6930
- type: "button",
6931
- className: "wbs-tagresult" + (on ? " on" : ""),
6932
- onClick: function() {
6933
- toggleTag(t);
6934
- }
6935
- },
6936
- h2(Icon2, { name: on ? "check" : "plus", size: 12 }),
6937
- h2("span", null, t.name)
7441
+ },
7442
+ validate: function() {
7443
+ return String(name).trim() ? "" : text(lang, "requiredName");
7444
+ }
7445
+ },
7446
+ {
7447
+ key: "dirs",
7448
+ label: text(lang, "step2"),
7449
+ render: function(hh) {
7450
+ return hh(
7451
+ "div",
7452
+ { className: "wbs-field" },
7453
+ hh("div", { className: "wbs-label" }, text(lang, "chooseDirs")),
7454
+ !flatDirs.length ? hh("div", { className: "wbs-note" }, text(lang, "noDirs")) : hh(
7455
+ "div",
7456
+ { className: "wbs-dirlist" },
7457
+ flatDirs.map(function(item) {
7458
+ var id = String(item.node.id);
7459
+ return hh(
7460
+ "label",
7461
+ {
7462
+ key: id,
7463
+ className: "wbs-dircheck",
7464
+ style: { paddingLeft: 6 + item.depth * 16 }
7465
+ },
7466
+ hh("input", {
7467
+ type: "checkbox",
7468
+ checked: dirIds.indexOf(id) >= 0,
7469
+ onChange: function() {
7470
+ toggleDir(id);
7471
+ }
7472
+ }),
7473
+ hh("span", null, item.node.name)
7474
+ );
7475
+ })
7476
+ ),
7477
+ hh("div", { className: "wbs-note", style: { marginTop: 8 } }, "\u7AD9\u70B9\u53EF\u540C\u65F6\u6302\u5728\u591A\u4E2A\u76EE\u5F55\u4E0B\uFF1B\u5217\u8868\u4F1A\u6309\u76EE\u5F55\u5B50\u6811\u8FC7\u6EE4\u3002")
6938
7478
  );
6939
- }) : h2("div", { className: "wbs-note", style: { padding: 6 } }, text(lang, "noTags"))),
6940
- h2("div", { className: "wbs-note", style: { marginTop: 8 } }, "\u6807\u7B7E\u7531\u6807\u7B7E\u5B50\u63D2\u4EF6\u63D0\u4F9B\uFF0C\u53EF\u591A\u9009\u3002")
6941
- ) : null,
6942
- h2(
6943
- "div",
6944
- { className: "wbs-formfoot" },
6945
- h2("div", { className: "wbs-formerr" }, error || ""),
6946
- step > 0 ? h2("button", { type: "button", className: "wbs-btn", disabled: saving, onClick: function() {
6947
- setStep(step - 1);
6948
- } }, h2(Icon2, { name: "chevron-left", size: 13 }), text(lang, "back")) : null,
6949
- h2("button", { type: "button", className: "wbs-btn", disabled: saving, onClick: props.onClose }, text(lang, "cancel")),
6950
- step < maxStep ? h2("button", { type: "button", className: "wbs-btn primary", onClick: next }, text(lang, "nextStep"), h2(Icon2, { name: "chevron-right", size: 13 })) : h2("button", { type: "button", className: "wbs-btn primary", disabled: saving, onClick: save }, h2(Icon2, { name: "check", size: 13 }), saving ? text(lang, "saving") : text(lang, "save"))
6951
- )
6952
- );
7479
+ },
7480
+ validate: function() {
7481
+ return dirIds.length ? "" : text(lang, "requiredDirs");
7482
+ }
7483
+ },
7484
+ tagOn ? {
7485
+ key: "tags",
7486
+ label: text(lang, "step3"),
7487
+ optional: true,
7488
+ render: function(hh) {
7489
+ return hh(
7490
+ "div",
7491
+ { className: "wbs-field" },
7492
+ hh("div", { className: "wbs-label" }, text(lang, "chooseTags")),
7493
+ tags.length ? hh("div", { className: "wbs-chips" }, tags.map(function(t) {
7494
+ return hh(
7495
+ "span",
7496
+ { className: "wbs-chip", key: t.id },
7497
+ t.name,
7498
+ hh("button", { type: "button", onClick: function() {
7499
+ toggleTag(t);
7500
+ }, title: "\u79FB\u9664" }, hh(Icon2, { name: "x", size: 12 }))
7501
+ );
7502
+ })) : hh("div", { className: "wbs-note" }, "\u6682\u672A\u9009\u62E9\u6807\u7B7E"),
7503
+ hh(
7504
+ "div",
7505
+ { className: "wbs-tagsearch", style: { marginTop: 10 } },
7506
+ hh("input", {
7507
+ className: "wbs-input",
7508
+ value: tagQuery,
7509
+ placeholder: text(lang, "tagSearch"),
7510
+ onChange: function(e) {
7511
+ setTagQuery(e.target.value);
7512
+ }
7513
+ })
7514
+ ),
7515
+ hh("div", { className: "wbs-tagresults" }, tagResults.length ? tagResults.map(function(t) {
7516
+ var on = tags.some(function(x) {
7517
+ return x.id === t.id;
7518
+ });
7519
+ return hh(
7520
+ "button",
7521
+ {
7522
+ key: t.id,
7523
+ type: "button",
7524
+ className: "wbs-tagresult" + (on ? " on" : ""),
7525
+ onClick: function() {
7526
+ toggleTag(t);
7527
+ }
7528
+ },
7529
+ hh(Icon2, { name: on ? "check" : "plus", size: 12 }),
7530
+ hh("span", null, t.name)
7531
+ );
7532
+ }) : hh("div", { className: "wbs-note", style: { padding: 6 } }, text(lang, "noTags"))),
7533
+ hh("div", { className: "wbs-note", style: { marginTop: 8 } }, "\u6807\u7B7E\u7531\u6807\u7B7E\u5B50\u63D2\u4EF6\u63D0\u4F9B\uFF0C\u53EF\u591A\u9009\u3002")
7534
+ );
7535
+ }
7536
+ } : null
7537
+ ].filter(Boolean);
7538
+ return h2(SiteFormDialog, {
7539
+ title,
7540
+ mode,
7541
+ cancelLabel: text(lang, "cancel"),
7542
+ steps,
7543
+ submitting: saving,
7544
+ error,
7545
+ onClose: props.onClose,
7546
+ onSubmit: save,
7547
+ submitText: text(lang, "save"),
7548
+ cancelText: text(lang, "cancel"),
7549
+ nextText: text(lang, "nextStep"),
7550
+ backText: text(lang, "back"),
7551
+ stepsLabel: text(lang, "createTitle")
7552
+ });
6953
7553
  }
6954
7554
  function DirModal(props) {
6955
7555
  var api = props.api;
@@ -7776,7 +8376,7 @@ var createOverlay = require_overlay();
7776
8376
  injectCss();
7777
8377
  host.registerAddon({
7778
8378
  id: "wb-addon-sites",
7779
- version: "1.12.7",
8379
+ version: "1.12.11",
7780
8380
  icon: icons.ICONS["globe"],
7781
8381
  views: [
7782
8382
  { id: "stats", icon: tabIcon("chart"), title: { zh: "\u7EDF\u8BA1", en: "Stats" }, component: statsView.SitesStatsView },