dsh-workbench-salary 0.4.1 → 0.4.5

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
@@ -578,6 +578,604 @@ var require_date_picker_styles = __commonJS({
578
578
  }
579
579
  });
580
580
 
581
+ // packages/addons/lib/stepper.cjs
582
+ var require_stepper = __commonJS({
583
+ "packages/addons/lib/stepper.cjs"(exports2, module2) {
584
+ "use strict";
585
+ function stepState(index, current, maxVisited) {
586
+ if (index === current) return "current";
587
+ if (index < current) return "done";
588
+ if (index <= maxVisited) return "visited";
589
+ return "todo";
590
+ }
591
+ function Steps(props) {
592
+ var h = props.h;
593
+ var steps = props.steps || [];
594
+ var current = props.current || 0;
595
+ var maxVisited = props.maxVisited === void 0 ? current : props.maxVisited;
596
+ var invalid = props.invalid || {};
597
+ var disabled = !!props.disabled;
598
+ var label = props.label || "\u6B65\u9AA4";
599
+ return h(
600
+ "nav",
601
+ { className: "wbctl-steps" + (props.className ? " " + props.className : ""), "aria-label": label },
602
+ h(
603
+ "ol",
604
+ { className: "wbctl-step-list" },
605
+ steps.map(function(step, index) {
606
+ var state = stepState(index, current, maxVisited);
607
+ var canJump = !disabled && typeof props.onJump === "function" && state !== "current" && state !== "todo";
608
+ var isInvalid = !!invalid[index] || !!invalid[step.key];
609
+ return h(
610
+ "li",
611
+ { key: step.key || index, className: "wbctl-step-item" },
612
+ h(
613
+ "button",
614
+ {
615
+ type: "button",
616
+ className: "wbctl-step",
617
+ "data-state": state,
618
+ "data-invalid": isInvalid ? "true" : null,
619
+ "aria-current": state === "current" ? "step" : void 0,
620
+ "aria-label": index + 1 + " \xB7 " + step.label + (state === "done" ? "\uFF08\u5DF2\u5B8C\u6210\uFF09" : ""),
621
+ disabled: disabled || state === "todo",
622
+ title: step.hint || "",
623
+ onClick: function() {
624
+ if (canJump) props.onJump(index);
625
+ }
626
+ },
627
+ h("span", { className: "wbctl-step-index", "aria-hidden": "true" }, state === "done" ? "\u2713" : String(index + 1)),
628
+ h("span", { className: "wbctl-step-label" }, step.label),
629
+ step.hint ? h("span", { className: "wbctl-step-hint" }, step.hint) : null,
630
+ step.optional ? h("span", { className: "wbctl-step-opt" }, "\u53EF\u9009") : null
631
+ )
632
+ );
633
+ })
634
+ )
635
+ );
636
+ }
637
+ var STYLES = [
638
+ ".wbctl-steps{display:block;min-width:0}",
639
+ ".wbctl-step-list{display:flex;align-items:stretch;gap:6px;list-style:none;margin:0 0 14px;padding:0;min-width:0}",
640
+ ".wbctl-step-item{display:flex;flex:1 1 0;min-width:0}",
641
+ ".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}",
642
+ ".wbctl-step[data-state=done],.wbctl-step[data-state=visited]{color:inherit;cursor:pointer}",
643
+ ".wbctl-step[data-state=done]{border-color:color-mix(in oklab,var(--wb-ok,var(--wb-accent,#2563eb)) 36%,var(--wb-border))}",
644
+ ".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}",
645
+ ".wbctl-step[data-state=visited]:hover,.wbctl-step[data-state=done]:hover{background:color-mix(in oklab,currentColor 7%,transparent)}",
646
+ ".wbctl-step[data-invalid=true]{border-color:var(--wb-danger,#d33)}",
647
+ ".wbctl-step:focus-visible{outline:2px solid var(--wb-accent,#2563eb);outline-offset:2px}",
648
+ ".wbctl-step:disabled{cursor:default;opacity:.72}",
649
+ ".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)}",
650
+ ".wbctl-step[data-state=current] .wbctl-step-index{background:var(--wb-accent,#2563eb);color:var(--wb-on-accent,#fff)}",
651
+ ".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))}",
652
+ ".wbctl-step-label{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}",
653
+ ".wbctl-step-hint{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px;font-weight:400;opacity:.62}",
654
+ ".wbctl-step-opt{flex:none;font-size:10px;font-weight:400;opacity:.55}",
655
+ "@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}}",
656
+ "@media (max-width:520px){.wbctl-step-list{gap:4px}.wbctl-step-label{white-space:normal}.wbctl-step{gap:5px}}",
657
+ "@media (prefers-reduced-motion:reduce){.wbctl-step{transition:none}}"
658
+ ];
659
+ module2.exports = { Steps, stepState, styles: STYLES };
660
+ }
661
+ });
662
+
663
+ // packages/addons/lib/overlay.cjs
664
+ var require_overlay = __commonJS({
665
+ "packages/addons/lib/overlay.cjs"(exports2, module2) {
666
+ "use strict";
667
+ var defaultReact = require("react");
668
+ var FOCUSABLE = "button:not(:disabled),input:not(:disabled),textarea:not(:disabled),select:not(:disabled),a[href]";
669
+ module2.exports = function createOverlay(options) {
670
+ var opts = options || {};
671
+ var React = opts.React || defaultReact;
672
+ var h = React.createElement;
673
+ var tag = opts.tag || "section";
674
+ var maskClass = opts.maskClass;
675
+ var dialogClass = opts.dialogClass;
676
+ var dialogClassOf = opts.dialogClassOf || function() {
677
+ return "";
678
+ };
679
+ var ariaLabelOf = opts.ariaLabelOf || function(props) {
680
+ return props["aria-label"] || props.title;
681
+ };
682
+ var ariaLabelledByOf = opts.ariaLabelledByOf || function() {
683
+ return null;
684
+ };
685
+ var header = opts.header || null;
686
+ var closeOnEscape = opts.closeOnEscape || function() {
687
+ return true;
688
+ };
689
+ var closeOnMask = opts.closeOnMask || function() {
690
+ return true;
691
+ };
692
+ var extraKeyDown = opts.onKeyDown || null;
693
+ var autoFocusDialog = opts.autoFocusDialog !== false;
694
+ var focusableSelector = opts.focusableSelector || FOCUSABLE;
695
+ function Modal(props) {
696
+ var R = props.React || React;
697
+ var ref = R.useRef(null);
698
+ R.useEffect(function() {
699
+ var previous = typeof document !== "undefined" ? document.activeElement : null;
700
+ var focusIt = props.autoFocus !== void 0 ? props.autoFocus : autoFocusDialog;
701
+ if (focusIt && ref.current) ref.current.focus();
702
+ return function() {
703
+ if (previous && previous.isConnected) previous.focus();
704
+ };
705
+ }, []);
706
+ function onKeyDown(e) {
707
+ if (extraKeyDown && extraKeyDown(e, props, ref)) return;
708
+ if (e.key === "Escape") {
709
+ if (!(props.closeOnEscape !== void 0 ? props.closeOnEscape : closeOnEscape(props))) return;
710
+ e.preventDefault();
711
+ e.stopPropagation();
712
+ if (props.onClose) props.onClose();
713
+ return;
714
+ }
715
+ if (e.key !== "Tab" || !ref.current) return;
716
+ var els = ref.current.querySelectorAll(focusableSelector);
717
+ if (!els.length) {
718
+ e.preventDefault();
719
+ return;
720
+ }
721
+ var first = els[0];
722
+ var last = els[els.length - 1];
723
+ if (e.shiftKey && (document.activeElement === first || document.activeElement === ref.current)) {
724
+ e.preventDefault();
725
+ last.focus();
726
+ }
727
+ if (!e.shiftKey && document.activeElement === last) {
728
+ e.preventDefault();
729
+ first.focus();
730
+ }
731
+ }
732
+ var labelledBy = ariaLabelledByOf(props);
733
+ return h(
734
+ "div",
735
+ {
736
+ className: maskClass,
737
+ onMouseDown: function(e) {
738
+ var allowed = props.closeOnMask !== void 0 ? props.closeOnMask : closeOnMask(props);
739
+ if (e.target === e.currentTarget && props.onClose && allowed) props.onClose();
740
+ }
741
+ },
742
+ h(
743
+ tag,
744
+ {
745
+ className: dialogClass + dialogClassOf(props),
746
+ role: "dialog",
747
+ "aria-modal": true,
748
+ "aria-label": labelledBy ? null : ariaLabelOf(props),
749
+ "aria-labelledby": labelledBy || null,
750
+ ref,
751
+ tabIndex: -1,
752
+ onKeyDown
753
+ },
754
+ header ? header(props) : null,
755
+ props.children
756
+ )
757
+ );
758
+ }
759
+ return Modal;
760
+ };
761
+ }
762
+ });
763
+
764
+ // packages/addons/lib/staged-dialog.cjs
765
+ var require_staged_dialog = __commonJS({
766
+ "packages/addons/lib/staged-dialog.cjs"(exports2, module2) {
767
+ "use strict";
768
+ var defaultReact = require("react");
769
+ var overlayFactory = require_overlay();
770
+ var stepper = require_stepper();
771
+ function validateStep(step) {
772
+ if (!step || typeof step.validate !== "function") return "";
773
+ var message = step.validate();
774
+ return message ? String(message) : "";
775
+ }
776
+ function firstFailing(steps) {
777
+ var list = steps || [];
778
+ for (var i = 0; i < list.length; i += 1) {
779
+ var message = validateStep(list[i]);
780
+ if (message) return { index: i, key: list[i] && list[i].key, message };
781
+ }
782
+ return null;
783
+ }
784
+ function createStagedDialog(options) {
785
+ var opts = options || {};
786
+ var React = opts.React || defaultReact;
787
+ var h = React.createElement;
788
+ var dialogClass = ((opts.dialogClass || "") + " wbctl-dialog").trim();
789
+ var Overlay = overlayFactory(
790
+ Object.assign({}, opts, {
791
+ React,
792
+ dialogClass,
793
+ // 首焦点由外壳送进对话框,字段由 focusStep 负责,避免打开瞬间落进第一个输入框。
794
+ autoFocusDialog: opts.autoFocusDialog !== false
795
+ })
796
+ );
797
+ function StagedDialog(props) {
798
+ var R = props.React || React;
799
+ var steps = props.steps || [];
800
+ var count = steps.length;
801
+ var busy = !!props.submitting || !!props.busy;
802
+ var indexState = R.useState(props.initialStep || 0);
803
+ var rawIndex = indexState[0];
804
+ var setIndex = indexState[1];
805
+ var index = count === 0 ? 0 : Math.min(Math.max(rawIndex, 0), count - 1);
806
+ var visitedState = R.useState(props.initialStep || 0);
807
+ var maxVisited = count === 0 ? 0 : Math.min(Math.max(visitedState[0], index), count - 1);
808
+ var setMaxVisited = visitedState[1];
809
+ var errorState = R.useState("");
810
+ var stepError = errorState[0];
811
+ var setStepError = errorState[1];
812
+ var invalidState = R.useState({});
813
+ var invalid = invalidState[0];
814
+ var setInvalid = invalidState[1];
815
+ var bodyRef = R.useRef(null);
816
+ var mounted = R.useRef(true);
817
+ function runValidate(step) {
818
+ return validateStep(step);
819
+ }
820
+ function markInvalid(i, bad) {
821
+ setInvalid(function(prev) {
822
+ var next2 = Object.assign({}, prev);
823
+ if (bad) next2[i] = true;
824
+ else delete next2[i];
825
+ return next2;
826
+ });
827
+ }
828
+ function focusBody() {
829
+ var el = bodyRef.current;
830
+ if (el && typeof el.focus === "function") el.focus();
831
+ }
832
+ R.useEffect(
833
+ function() {
834
+ if (!mounted.current) return;
835
+ focusBody();
836
+ },
837
+ [index]
838
+ );
839
+ R.useEffect(function() {
840
+ mounted.current = true;
841
+ return function() {
842
+ mounted.current = false;
843
+ };
844
+ }, []);
845
+ function goTo(i) {
846
+ if (busy || i < 0 || i >= count) return;
847
+ setIndex(i);
848
+ if (i > maxVisited) setMaxVisited(i);
849
+ setStepError("");
850
+ }
851
+ function fail(i, message) {
852
+ markInvalid(i, true);
853
+ goTo(i);
854
+ setStepError(message);
855
+ focusBody();
856
+ }
857
+ function next() {
858
+ if (busy) return;
859
+ var message = runValidate(steps[index]);
860
+ if (message) {
861
+ fail(index, message);
862
+ return;
863
+ }
864
+ markInvalid(index, false);
865
+ goTo(Math.min(index + 1, count - 1));
866
+ }
867
+ function back() {
868
+ if (busy || index === 0) return;
869
+ goTo(index - 1);
870
+ }
871
+ function jump(i) {
872
+ if (busy || i > maxVisited) return;
873
+ goTo(i);
874
+ }
875
+ function submit() {
876
+ if (busy) return;
877
+ var bad = firstFailing(steps);
878
+ if (bad) {
879
+ fail(bad.index, bad.message);
880
+ return;
881
+ }
882
+ for (var i = 0; i < count; i++) markInvalid(i, false);
883
+ setStepError("");
884
+ if (typeof props.onSubmit === "function") props.onSubmit();
885
+ }
886
+ function cancel() {
887
+ if (busy) return;
888
+ if (typeof props.onClose === "function") props.onClose();
889
+ }
890
+ var current = steps[index];
891
+ var isLast = index >= count - 1;
892
+ var saveText = props.submitText || "\u4FDD\u5B58";
893
+ var shownError = stepError || props.error || "";
894
+ return h(
895
+ Overlay,
896
+ props,
897
+ count > 1 ? h(stepper.Steps, {
898
+ h,
899
+ steps: steps.map(function(step) {
900
+ return { key: step.key, label: step.label, hint: step.hint, optional: step.optional };
901
+ }),
902
+ current: index,
903
+ maxVisited,
904
+ onJump: jump,
905
+ invalid,
906
+ disabled: busy,
907
+ label: props.stepsLabel || "\u521B\u5EFA\u6B65\u9AA4"
908
+ }) : null,
909
+ h(
910
+ "div",
911
+ {
912
+ className: "wbctl-dialog-body" + (props.bodyClassName ? " " + props.bodyClassName : ""),
913
+ ref: bodyRef,
914
+ tabIndex: -1
915
+ },
916
+ current ? current.render(h, props) : null
917
+ ),
918
+ props.footerExtra || null,
919
+ shownError ? h("div", { className: "wbctl-dialog-err", role: "alert" }, shownError) : null,
920
+ h(
921
+ "div",
922
+ { className: "wbctl-dialog-foot" },
923
+ count > 1 ? h("span", { className: "wbctl-dialog-progress" }, index + 1 + " / " + count) : null,
924
+ props.footerNote ? h("span", { className: "wbctl-dialog-note" }, props.footerNote) : null,
925
+ h("span", { className: "wbctl-dialog-spacer" }),
926
+ index > 0 ? h(
927
+ "button",
928
+ { type: "button", className: "wbctl-btn", onClick: back, disabled: busy },
929
+ props.backText || "\u4E0A\u4E00\u6B65"
930
+ ) : null,
931
+ h("button", { type: "button", className: "wbctl-btn", onClick: cancel, disabled: busy }, props.cancelText || "\u53D6\u6D88"),
932
+ h(
933
+ "button",
934
+ {
935
+ type: "button",
936
+ className: "wbctl-btn wbctl-btn-p",
937
+ onClick: isLast ? submit : next,
938
+ // submitDisabled 只作用于末步的保存:插件据此把「结构性不合法」(JSON 语法、无可选 action)
939
+ // 提前反映成禁用态,避免用户点到保存才被弹回第一步。
940
+ disabled: busy || isLast && !!props.submitDisabled
941
+ },
942
+ busy ? saveText + "\u4E2D\u2026" : isLast ? saveText : props.nextText || "\u4E0B\u4E00\u6B65"
943
+ )
944
+ )
945
+ );
946
+ }
947
+ StagedDialog.displayName = opts.displayName || "StagedDialog";
948
+ return StagedDialog;
949
+ }
950
+ var STYLES = [
951
+ // 宽表单:内容多时给足横向空间,窄屏留 16px 边距后铺满。
952
+ ".wbctl-dialog{width:min(880px,calc(100vw - 32px));max-height:min(92vh,760px);display:flex;flex-direction:column;overflow:hidden}",
953
+ ".wbctl-dialog-body{flex:1 1 auto;min-height:0;overflow:auto;overscroll-behavior:contain;padding:2px 2px 10px;outline:none}",
954
+ ".wbctl-dialog-body:focus-visible{outline:none}",
955
+ ".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))}",
956
+ ".wbctl-dialog-progress{font-size:11.5px;color:var(--wb-muted,#666);font-variant-numeric:tabular-nums}",
957
+ ".wbctl-dialog-note{font-size:11.5px;color:var(--wb-muted,#666);min-width:0}",
958
+ ".wbctl-dialog-spacer{flex:1 1 auto}",
959
+ ".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}",
960
+ ".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}",
961
+ ".wbctl-btn:hover:not(:disabled){background:color-mix(in oklab,currentColor 7%,transparent)}",
962
+ ".wbctl-btn:focus-visible{outline:2px solid var(--wb-accent,#2563eb);outline-offset:2px}",
963
+ ".wbctl-btn:disabled{opacity:.55;cursor:default}",
964
+ ".wbctl-btn.wbctl-btn-p{background:var(--wb-accent,#2563eb);border-color:transparent;color:var(--wb-on-accent,#fff)}",
965
+ ".wbctl-btn.wbctl-btn-p:hover:not(:disabled){background:color-mix(in oklab,var(--wb-accent,#2563eb) 86%,#000)}",
966
+ // 确认步:键值对清单,各插件共用,避免再各写一套只读摘要。\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 // 两列字段布局:内容多的弹窗不再单列拉长,窄屏回落单列。
967
+ ".wbctl-form{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px 14px}",
968
+ ".wbctl-form>.full{grid-column:1/-1}",
969
+ "@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}}",
970
+ "@media (prefers-reduced-motion:reduce){.wbctl-btn{transition:none}}"
971
+ ];
972
+ module2.exports = {
973
+ createStagedDialog,
974
+ validateStep,
975
+ firstFailing,
976
+ styles: STYLES
977
+ };
978
+ }
979
+ });
980
+
981
+ // packages/addons/lib/number-field.cjs
982
+ var require_number_field = __commonJS({
983
+ "packages/addons/lib/number-field.cjs"(exports2, module2) {
984
+ "use strict";
985
+ var React = require("react");
986
+ var NUM = /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)$/;
987
+ var TEXT = {
988
+ zh: {
989
+ required: "\u8BF7\u586B\u5199\u6570\u5B57",
990
+ invalid: "\u8BF7\u8F93\u5165\u6570\u5B57",
991
+ integer: "\u9700\u8981\u662F\u6574\u6570",
992
+ min: "\u4E0D\u80FD\u5C0F\u4E8E {min}",
993
+ max: "\u4E0D\u80FD\u5927\u4E8E {max}",
994
+ range: "\u9700\u8981\u5728 {min}\u2013{max} \u4E4B\u95F4",
995
+ step: "\u9700\u8981\u662F {step} \u7684\u500D\u6570",
996
+ unit: "\u5355\u4F4D"
997
+ },
998
+ en: {
999
+ required: "Please enter a number",
1000
+ invalid: "Please enter a number",
1001
+ integer: "Must be a whole number",
1002
+ min: "Must be at least {min}",
1003
+ max: "Must be at most {max}",
1004
+ range: "Must be between {min} and {max}",
1005
+ step: "Must be a multiple of {step}",
1006
+ unit: "unit"
1007
+ }
1008
+ };
1009
+ function messages(lang) {
1010
+ return lang === "en" ? TEXT.en : TEXT.zh;
1011
+ }
1012
+ function fill(text, vars) {
1013
+ return String(text).replace(/\{(\w+)\}/g, function(m, key) {
1014
+ return vars && vars[key] !== void 0 ? String(vars[key]) : m;
1015
+ });
1016
+ }
1017
+ function validateNumber(raw, opts) {
1018
+ var o = opts || {};
1019
+ var M = messages(o.lang);
1020
+ var text = raw === null || raw === void 0 ? "" : String(raw).trim();
1021
+ if (text === "") {
1022
+ return o.allowEmpty ? { ok: true, value: null, error: "" } : { ok: false, value: null, error: M.required };
1023
+ }
1024
+ if (!NUM.test(text)) return { ok: false, value: null, error: M.invalid };
1025
+ var n = Number(text);
1026
+ if (!isFinite(n)) return { ok: false, value: null, error: M.invalid };
1027
+ if (o.integer && Math.round(n) !== n) return { ok: false, value: null, error: M.integer };
1028
+ var hasMin = o.min !== void 0 && o.min !== null && o.min !== "";
1029
+ var hasMax = o.max !== void 0 && o.max !== null && o.max !== "";
1030
+ if (hasMin && hasMax && n >= o.min && n <= o.max) {
1031
+ } else if (hasMin && hasMax) {
1032
+ return { ok: false, value: null, error: fill(M.range, { min: o.min, max: o.max }) };
1033
+ } else if (hasMin && n < o.min) {
1034
+ return { ok: false, value: null, error: fill(M.min, { min: o.min }) };
1035
+ } else if (hasMax && n > o.max) {
1036
+ return { ok: false, value: null, error: fill(M.max, { max: o.max }) };
1037
+ }
1038
+ if (o.step && Number(o.step) > 0) {
1039
+ var q = n / Number(o.step);
1040
+ if (Math.abs(q - Math.round(q)) > 1e-9) {
1041
+ return { ok: false, value: null, error: fill(M.step, { step: o.step }) };
1042
+ }
1043
+ }
1044
+ return { ok: true, value: n, error: "" };
1045
+ }
1046
+ function rangeHint(opts, lang) {
1047
+ var o = opts || {};
1048
+ var M = messages(lang);
1049
+ var en = lang === "en";
1050
+ var hasMin = o.min !== void 0 && o.min !== null && o.min !== "";
1051
+ var hasMax = o.max !== void 0 && o.max !== null && o.max !== "";
1052
+ var parts = [];
1053
+ if (hasMin && hasMax) parts.push(String(o.min) + "\u2013" + String(o.max));
1054
+ else if (hasMin) parts.push((en ? "\u2265 " : "\u2265 ") + String(o.min));
1055
+ else if (hasMax) parts.push((en ? "\u2264 " : "\u2264 ") + String(o.max));
1056
+ if (o.integer) parts.push(en ? "whole numbers" : "\u6574\u6570");
1057
+ else if (o.step && Number(o.step) > 0) parts.push((en ? "step " : "\u6B65\u957F ") + String(o.step));
1058
+ return parts.join(en ? ", " : "\uFF0C");
1059
+ }
1060
+ function NumberField(props) {
1061
+ var h = props.h || React.createElement;
1062
+ var lang = props.lang;
1063
+ var M = messages(lang);
1064
+ var text = props.value === null || props.value === void 0 ? "" : String(props.value);
1065
+ var draftS = React.useState(text);
1066
+ var draft = draftS[0];
1067
+ var setDraft = draftS[1];
1068
+ var focusS = React.useState(false);
1069
+ var focused = focusS[0];
1070
+ var setFocused = focusS[1];
1071
+ var errS = React.useState("");
1072
+ var err = errS[0];
1073
+ var setErr = errS[1];
1074
+ var lastRef = React.useRef(text);
1075
+ var skipBlurRef = React.useRef(false);
1076
+ React.useEffect(
1077
+ function() {
1078
+ if (focused) return;
1079
+ if (lastRef.current === text) return;
1080
+ lastRef.current = text;
1081
+ setDraft(text);
1082
+ setErr("");
1083
+ },
1084
+ [text, focused]
1085
+ );
1086
+ function commit(raw) {
1087
+ var r = validateNumber(raw, props);
1088
+ if (!r.ok) {
1089
+ setErr(r.error);
1090
+ if (typeof props.onValidChange === "function") props.onValidChange(false, r.error);
1091
+ return false;
1092
+ }
1093
+ setErr("");
1094
+ if (typeof props.onValidChange === "function") props.onValidChange(true, "");
1095
+ var cur = props.value === null || props.value === void 0 ? null : Number(props.value);
1096
+ if (r.value !== cur) {
1097
+ lastRef.current = r.value === null ? "" : String(r.value);
1098
+ if (typeof props.onCommit === "function") props.onCommit(r.value);
1099
+ }
1100
+ return true;
1101
+ }
1102
+ var hint = props.hint !== void 0 ? props.hint : rangeHint(props, lang);
1103
+ var shown = props.hint === false ? "" : hint;
1104
+ return h(
1105
+ "span",
1106
+ { className: "wbctl-num" + (props.wide ? " is-wide" : "") + (props.className ? " " + props.className : "") },
1107
+ h(
1108
+ "span",
1109
+ { className: "wbctl-num-box" },
1110
+ h("input", {
1111
+ className: "wbctl-num-input" + (err ? " is-invalid" : ""),
1112
+ type: "text",
1113
+ inputMode: props.integer || Number(props.step) === 1 ? "numeric" : "decimal",
1114
+ value: draft,
1115
+ disabled: !!props.disabled,
1116
+ placeholder: props.placeholder,
1117
+ title: props.title,
1118
+ "aria-label": props.ariaLabel,
1119
+ "aria-invalid": err ? "true" : void 0,
1120
+ onFocus: function() {
1121
+ setFocused(true);
1122
+ },
1123
+ onChange: function(e) {
1124
+ setDraft(e.target.value);
1125
+ if (err) setErr("");
1126
+ if (typeof props.onDraft === "function") props.onDraft(e.target.value);
1127
+ },
1128
+ onBlur: function() {
1129
+ setFocused(false);
1130
+ if (skipBlurRef.current) {
1131
+ skipBlurRef.current = false;
1132
+ return;
1133
+ }
1134
+ commit(draft);
1135
+ },
1136
+ onKeyDown: function(e) {
1137
+ if (e.key === "Enter") {
1138
+ e.preventDefault();
1139
+ if (e.target && e.target.blur) e.target.blur();
1140
+ } else if (e.key === "Escape") {
1141
+ e.preventDefault();
1142
+ skipBlurRef.current = true;
1143
+ setDraft(text);
1144
+ setErr("");
1145
+ if (e.target && e.target.blur) e.target.blur();
1146
+ }
1147
+ }
1148
+ }),
1149
+ props.unit ? h("span", { className: "wbctl-num-unit" }, props.unit) : null
1150
+ ),
1151
+ err ? h("span", { className: "wbctl-num-err", role: "alert" }, err) : shown ? h("span", { className: "wbctl-num-hint" }, shown) : null
1152
+ );
1153
+ }
1154
+ var NUMBER_STYLES = [
1155
+ ".wbctl-num{display:inline-flex;flex-direction:column;gap:3px;min-width:0;max-width:100%}",
1156
+ ".wbctl-num.is-wide{display:flex;width:100%}",
1157
+ ".wbctl-num-box{display:inline-flex;align-items:center;gap:6px;min-width:0}",
1158
+ ".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}",
1159
+ ".wbctl-num-input:hover:not(:disabled){border-color:var(--wb-border,var(--wb-line))}",
1160
+ ".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)}",
1161
+ ".wbctl-num-input.is-invalid{border-color:var(--wb-danger,#dc2626)}",
1162
+ ".wbctl-num-input.is-invalid:focus{outline-color:color-mix(in oklab,var(--wb-danger,#dc2626) 55%,transparent)}",
1163
+ ".wbctl-num-input:disabled{opacity:.5;cursor:not-allowed}",
1164
+ ".wbctl-num-unit{color:var(--wb-muted,inherit);font-size:12px;white-space:nowrap}",
1165
+ ".wbctl-num-hint{color:var(--wb-muted,inherit);font-size:11px;line-height:1.4}",
1166
+ ".wbctl-num-err{color:var(--wb-danger,#dc2626);font-size:11px;line-height:1.4}",
1167
+ "@media (prefers-reduced-motion:reduce){.wbctl-num-input{transition:none}}"
1168
+ ];
1169
+ module2.exports = {
1170
+ NumberField,
1171
+ validateNumber,
1172
+ rangeHint,
1173
+ messages,
1174
+ styles: NUMBER_STYLES
1175
+ };
1176
+ }
1177
+ });
1178
+
581
1179
  // packages/addons/salary/client/ui/styles.cjs
582
1180
  var require_styles = __commonJS({
583
1181
  "packages/addons/salary/client/ui/styles.cjs"(exports2, module2) {
@@ -811,7 +1409,65 @@ var require_styles = __commonJS({
811
1409
  "@media (max-width:760px){.wbsal-detail{grid-template-columns:minmax(0,1fr)}.wbsal-page{padding:16px 14px 36px}.wbsal-table th,.wbsal-table td{padding:9px 10px}.wbsal-opt,.wbsal-table th.opt{display:none}.wbsal-comp-row{grid-template-columns:80px minmax(50px,1fr) 112px}.wbsal-chart{height:170px}}"
812
1410
  ];
813
1411
  var DATE = require_date_picker_styles()("wbsal");
814
- module2.exports = BASE.concat(PAGE, [DATE]).join("\n");
1412
+ var AMOUNT = [
1413
+ ".wbsal-form-grid .wbctl-num{width:100%}",
1414
+ ".wbsal-form-grid .wbctl-num-box{width:100%}",
1415
+ ".wbsal-form-grid .wbctl-num-input{width:100%;box-sizing:border-box;text-align:right}",
1416
+ // 分阶段表单:每组金额之间留出间距,步骤内容区不再被外层卡片裁切。
1417
+ ".wbsal-steps-groups{display:flex;flex-direction:column;gap:16px}"
1418
+ ];
1419
+ module2.exports = BASE.concat(PAGE, [DATE], AMOUNT, require_stepper().styles, require_staged_dialog().styles, require_number_field().styles).join("\n");
1420
+ }
1421
+ });
1422
+
1423
+ // packages/addons/lib/switch.cjs
1424
+ var require_switch = __commonJS({
1425
+ "packages/addons/lib/switch.cjs"(exports2, module2) {
1426
+ "use strict";
1427
+ var SWITCH_STYLES = [
1428
+ ".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}",
1429
+ ".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}",
1430
+ ".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}",
1431
+ ".wbctl-switch[aria-checked=true]{color:var(--wb-accent,#2563eb)}",
1432
+ ".wbctl-switch[aria-checked=true] .wbctl-switch-track{background:var(--wb-accent,#2563eb)}",
1433
+ ".wbctl-switch[aria-checked=true] .wbctl-switch-knob{transform:translateX(14px)}",
1434
+ ".wbctl-switch:hover:not(:disabled) .wbctl-switch-track{outline:1px solid var(--wb-accent,#2563eb)}",
1435
+ ".wbctl-switch:focus-visible{outline:2px solid var(--wb-accent,#2563eb);outline-offset:2px}",
1436
+ ".wbctl-switch:disabled{opacity:.45;cursor:not-allowed}",
1437
+ ".wbctl-switch-text{white-space:nowrap}",
1438
+ "@media (prefers-reduced-motion:reduce){.wbctl-switch-track,.wbctl-switch-knob{transition:none}}"
1439
+ ];
1440
+ function Switch(props) {
1441
+ var h = props.h;
1442
+ var on = props.checked === true || props.checked === "true";
1443
+ var disabled = !!props.disabled;
1444
+ var text = props.label;
1445
+ if (props.showState) text = on ? props.onText || "\u5F00" : props.offText || "\u5173";
1446
+ return h(
1447
+ "button",
1448
+ {
1449
+ type: "button",
1450
+ role: "switch",
1451
+ "aria-checked": on ? "true" : "false",
1452
+ className: "wbctl-switch" + (props.className ? " " + props.className : ""),
1453
+ disabled,
1454
+ title: props.title,
1455
+ "aria-label": text ? void 0 : props.ariaLabel,
1456
+ onClick: function(e) {
1457
+ e.preventDefault();
1458
+ if (disabled) return;
1459
+ if (typeof props.onChange === "function") props.onChange(!on);
1460
+ }
1461
+ },
1462
+ h(
1463
+ "span",
1464
+ { className: "wbctl-switch-track", "aria-hidden": "true" },
1465
+ h("span", { className: "wbctl-switch-knob" })
1466
+ ),
1467
+ text ? h("span", { className: "wbctl-switch-text" }, text) : null
1468
+ );
1469
+ }
1470
+ module2.exports = { Switch, styles: SWITCH_STYLES };
815
1471
  }
816
1472
  });
817
1473
 
@@ -921,6 +1577,11 @@ var require_client_common = __commonJS({
921
1577
  call,
922
1578
  errText,
923
1579
  fmtTime,
1580
+ Switch: require_switch().Switch,
1581
+ switchStyles: require_switch().styles,
1582
+ NumberField: require_number_field().NumberField,
1583
+ numberFieldStyles: require_number_field().styles,
1584
+ validateNumber: require_number_field().validateNumber,
924
1585
  Btn,
925
1586
  Field,
926
1587
  Notice,
@@ -2833,114 +3494,45 @@ var require_stats = __commonJS({
2833
3494
  }
2834
3495
  });
2835
3496
 
2836
- // packages/addons/lib/overlay.cjs
2837
- var require_overlay = __commonJS({
2838
- "packages/addons/lib/overlay.cjs"(exports2, module2) {
3497
+ // packages/addons/salary/client/views/records.cjs
3498
+ var require_records = __commonJS({
3499
+ "packages/addons/salary/client/views/records.cjs"(exports2, module2) {
2839
3500
  "use strict";
2840
- var defaultReact = require("react");
2841
- var FOCUSABLE = "button:not(:disabled),input:not(:disabled),textarea:not(:disabled),select:not(:disabled),a[href]";
2842
- module2.exports = function createOverlay(options) {
2843
- var opts = options || {};
2844
- var React = opts.React || defaultReact;
2845
- var h = React.createElement;
2846
- var tag = opts.tag || "section";
2847
- var maskClass = opts.maskClass;
2848
- var dialogClass = opts.dialogClass;
2849
- var dialogClassOf = opts.dialogClassOf || function() {
2850
- return "";
2851
- };
2852
- var ariaLabelOf = opts.ariaLabelOf || function(props) {
3501
+ var staged = require_staged_dialog();
3502
+ var salaryCommon = require_common();
3503
+ var NF = require_number_field();
3504
+ var FormDialog = staged.createStagedDialog({
3505
+ maskClass: "wbsal-mask",
3506
+ dialogClass: "wbsal-modal",
3507
+ displayName: "SalaryFormDialog",
3508
+ ariaLabelOf: function(props) {
2853
3509
  return props["aria-label"] || props.title;
2854
- };
2855
- var ariaLabelledByOf = opts.ariaLabelledByOf || function() {
2856
- return null;
2857
- };
2858
- var header = opts.header || null;
2859
- var closeOnEscape = opts.closeOnEscape || function() {
2860
- return true;
2861
- };
2862
- var closeOnMask = opts.closeOnMask || function() {
2863
- return true;
2864
- };
2865
- var extraKeyDown = opts.onKeyDown || null;
2866
- var autoFocusDialog = opts.autoFocusDialog !== false;
2867
- var focusableSelector = opts.focusableSelector || FOCUSABLE;
2868
- function Modal(props) {
2869
- var ref = React.useRef(null);
2870
- React.useEffect(function() {
2871
- var previous = typeof document !== "undefined" ? document.activeElement : null;
2872
- var focusIt = props.autoFocus !== void 0 ? props.autoFocus : autoFocusDialog;
2873
- if (focusIt && ref.current) ref.current.focus();
2874
- return function() {
2875
- if (previous && previous.isConnected) previous.focus();
2876
- };
2877
- }, []);
2878
- function onKeyDown(e) {
2879
- if (extraKeyDown && extraKeyDown(e, props, ref)) return;
2880
- if (e.key === "Escape") {
2881
- if (!(props.closeOnEscape !== void 0 ? props.closeOnEscape : closeOnEscape(props))) return;
2882
- e.preventDefault();
2883
- e.stopPropagation();
2884
- if (props.onClose) props.onClose();
2885
- return;
2886
- }
2887
- if (e.key !== "Tab" || !ref.current) return;
2888
- var els = ref.current.querySelectorAll(focusableSelector);
2889
- if (!els.length) {
2890
- e.preventDefault();
2891
- return;
2892
- }
2893
- var first = els[0];
2894
- var last = els[els.length - 1];
2895
- if (e.shiftKey && (document.activeElement === first || document.activeElement === ref.current)) {
2896
- e.preventDefault();
2897
- last.focus();
2898
- }
2899
- if (!e.shiftKey && document.activeElement === last) {
2900
- e.preventDefault();
2901
- first.focus();
2902
- }
2903
- }
2904
- var labelledBy = ariaLabelledByOf(props);
3510
+ },
3511
+ header: function(props) {
3512
+ var h = props.h;
3513
+ var C = salaryCommon;
2905
3514
  return h(
2906
3515
  "div",
2907
- {
2908
- className: maskClass,
2909
- onMouseDown: function(e) {
2910
- var allowed = props.closeOnMask !== void 0 ? props.closeOnMask : closeOnMask(props);
2911
- if (e.target === e.currentTarget && props.onClose && allowed) props.onClose();
2912
- }
2913
- },
3516
+ { className: "wbsal-form-head" },
2914
3517
  h(
2915
- tag,
2916
- {
2917
- className: dialogClass + dialogClassOf(props),
2918
- role: "dialog",
2919
- "aria-modal": true,
2920
- "aria-label": labelledBy ? null : ariaLabelOf(props),
2921
- "aria-labelledby": labelledBy || null,
2922
- ref,
2923
- tabIndex: -1,
2924
- onKeyDown
2925
- },
2926
- header ? header(props) : null,
2927
- props.children
3518
+ "div",
3519
+ null,
3520
+ h("div", { className: "wbsal-eyebrow" }, props.eyebrow || ""),
3521
+ h("h3", null, props.title)
3522
+ ),
3523
+ h(
3524
+ C.Btn,
3525
+ { h, kind: "ghost", onClick: props.onClose, disabled: !!props.submitting },
3526
+ "\u5173\u95ED"
2928
3527
  )
2929
3528
  );
3529
+ },
3530
+ closeOnEscape: function(props) {
3531
+ return !props.submitting;
3532
+ },
3533
+ closeOnMask: function(props) {
3534
+ return !props.submitting;
2930
3535
  }
2931
- return Modal;
2932
- };
2933
- }
2934
- });
2935
-
2936
- // packages/addons/salary/client/views/records.cjs
2937
- var require_records = __commonJS({
2938
- "packages/addons/salary/client/views/records.cjs"(exports2, module2) {
2939
- "use strict";
2940
- var createOverlay = require_overlay();
2941
- var FormOverlay = createOverlay({
2942
- maskClass: "wbsal-mask",
2943
- dialogClass: "wbsal-modal"
2944
3536
  });
2945
3537
  module2.exports = function Records(props) {
2946
3538
  var h = props.h, React = props.React, api = props.api, lang = props.lang;
@@ -2966,17 +3558,15 @@ var require_records = __commonJS({
2966
3558
  var msg = msgState[0], setMsg = msgState[1];
2967
3559
  var savingState = React.useState(false);
2968
3560
  var saving = savingState[0], setSaving = savingState[1];
3561
+ var badState = React.useState({});
3562
+ var badKeys = badState[0], setBadKeys = badState[1];
3563
+ var moneyInvalid = Object.keys(badKeys).length > 0;
2969
3564
  var modalOpen = !!form;
2970
3565
  React.useEffect(function() {
2971
3566
  if (!modalOpen || typeof document === "undefined" || typeof document.addEventListener !== "function" || !document.body) return void 0;
2972
- function onKey(event) {
2973
- if (event.key === "Escape") closeForm();
2974
- }
2975
- document.addEventListener("keydown", onKey);
2976
3567
  var previous = document.body.style.overflow;
2977
3568
  document.body.style.overflow = "hidden";
2978
3569
  return function() {
2979
- document.removeEventListener("keydown", onKey);
2980
3570
  document.body.style.overflow = previous;
2981
3571
  };
2982
3572
  }, [modalOpen, form && form.mode, form && form.id]);
@@ -2994,6 +3584,7 @@ var require_records = __commonJS({
2994
3584
  setConfirmId("");
2995
3585
  setOpenId("");
2996
3586
  setMsg(null);
3587
+ setBadKeys({});
2997
3588
  var payDate = pickDate("monthly");
2998
3589
  setForm({ mode: "create", id: "", payDate, incomePeriod: defaultPeriod(payDate, "monthly"), cycle: "monthly", employmentType: "", note: F.defaultNote(payDate, "monthly"), values: F.blankValues(), lockGross: false });
2999
3590
  }
@@ -3005,6 +3596,7 @@ var require_records = __commonJS({
3005
3596
  var incomeZero = F.INCOME_KEYS.every(function(key) {
3006
3597
  return !F.num(item[key]);
3007
3598
  });
3599
+ setBadKeys({});
3008
3600
  setConfirmId("");
3009
3601
  setOpenId("");
3010
3602
  setMsg(null);
@@ -3016,6 +3608,7 @@ var require_records = __commonJS({
3016
3608
  function closeForm() {
3017
3609
  setForm(null);
3018
3610
  setMsg(null);
3611
+ setBadKeys({});
3019
3612
  }
3020
3613
  function setField(key, value) {
3021
3614
  setForm(function(prev) {
@@ -3042,6 +3635,24 @@ var require_records = __commonJS({
3042
3635
  return Object.assign({}, prev, { values });
3043
3636
  });
3044
3637
  }
3638
+ function markAmount(key, ok) {
3639
+ setBadKeys(function(prev) {
3640
+ var known = !!prev[key];
3641
+ if (known === !ok) return prev;
3642
+ var next = Object.assign({}, prev);
3643
+ if (ok) delete next[key];
3644
+ else next[key] = true;
3645
+ return next;
3646
+ });
3647
+ }
3648
+ function firstBadAmount() {
3649
+ var keys = F.KEYS;
3650
+ for (var i = 0; i < keys.length; i += 1) {
3651
+ var check = NF.validateNumber(form.values[keys[i]], amountRules(keys[i]));
3652
+ if (!check.ok) return { key: keys[i], error: check.error };
3653
+ }
3654
+ return null;
3655
+ }
3045
3656
  function recalcFromDetail() {
3046
3657
  setForm(function(prev) {
3047
3658
  var computed = F.totals(prev.values);
@@ -3051,6 +3662,11 @@ var require_records = __commonJS({
3051
3662
  }
3052
3663
  function submit() {
3053
3664
  if (!form) return;
3665
+ var bad = firstBadAmount();
3666
+ if (bad) {
3667
+ setMsg({ kind: "error", text: F.LABELS[bad.key] + "\uFF1A" + bad.error });
3668
+ return;
3669
+ }
3054
3670
  var computed = F.totals(form.values);
3055
3671
  var payload = {
3056
3672
  payDate: form.payDate,
@@ -3106,157 +3722,196 @@ var require_records = __commonJS({
3106
3722
  var currentYear = (/* @__PURE__ */ new Date()).getFullYear();
3107
3723
  var yearOptions = ["", String(currentYear + 1), String(currentYear), String(currentYear - 1), String(currentYear - 2)];
3108
3724
  var latest = status.data || {};
3725
+ function amountRules(key) {
3726
+ return { min: key === "performanceBonus" ? void 0 : 0, step: 0.01, allowEmpty: true, lang };
3727
+ }
3109
3728
  function amountInput(key, disabled) {
3110
- return h("input", {
3111
- className: "wbsal-input",
3112
- type: "number",
3113
- step: "0.01",
3114
- min: key === "performanceBonus" ? void 0 : "0",
3729
+ return h(NF.NumberField, {
3730
+ h,
3731
+ lang,
3732
+ wide: true,
3733
+ className: "wbsal-amount",
3115
3734
  value: form.values[key],
3116
3735
  disabled,
3117
- onChange: function(e) {
3118
- setValue(key, e.target.value);
3736
+ hint: false,
3737
+ min: amountRules(key).min,
3738
+ step: 0.01,
3739
+ allowEmpty: true,
3740
+ ariaLabel: F.LABELS[key],
3741
+ onDraft: function(raw) {
3742
+ setValue(key, raw);
3743
+ markAmount(key, NF.validateNumber(raw, amountRules(key)).ok);
3119
3744
  },
3120
- onBlur: function() {
3121
- setValue(key, F.fmtAmount(F.num(form.values[key])));
3745
+ onCommit: function(next) {
3746
+ setValue(key, next === null ? "" : String(next));
3747
+ markAmount(key, true);
3122
3748
  }
3123
3749
  });
3124
3750
  }
3125
- function renderForm() {
3751
+ function renderModal() {
3752
+ var label = form.mode === "edit" ? "\u7F16\u8F91\u5DE5\u8D44" : "\u8BB0\u4E00\u7B14\u5DE5\u8D44";
3126
3753
  var computed = F.totals(form.values);
3127
3754
  var lockedGross = form.lockGross;
3128
3755
  var sameDayCount = items.filter(function(item) {
3129
3756
  return item.payDate === form.payDate && item.id !== form.id;
3130
3757
  }).length;
3131
- return h(
3132
- "div",
3133
- { className: "wbsal-card wbsal-form wbsal-form-modal" },
3134
- h(
3135
- "div",
3136
- { className: "wbsal-form-head" },
3137
- h(
3138
- "div",
3139
- null,
3140
- h("div", { className: "wbsal-eyebrow" }, form.mode === "edit" ? "EDIT RECORD" : "NEW RECORD"),
3141
- h("h3", null, form.mode === "edit" ? "\u7F16\u8F91\u5DE5\u8D44" : "\u8BB0\u4E00\u7B14\u5DE5\u8D44")
3142
- ),
3143
- h(C.Btn, { h, kind: "ghost", onClick: closeForm }, "\u5173\u95ED")
3144
- ),
3145
- h(
3146
- "div",
3147
- { className: "wbsal-form-meta" },
3148
- h(
3149
- C.Field,
3150
- { h, label: "\u5230\u8D26\u65E5" },
3151
- h(DP.DatePicker, { React, h, prefix: "wbsal", lang, label: "\u5230\u8D26\u65E5", value: form.payDate, onChange: function(next) {
3152
- setField("payDate", next);
3153
- } })
3154
- ),
3155
- h(
3156
- C.Field,
3157
- { h, label: "\u7ED3\u7B97\u65B9\u5F0F" },
3158
- h(
3159
- "select",
3160
- { className: "wbsal-input", value: form.cycle, onChange: function(e) {
3161
- setField("cycle", e.target.value);
3162
- } },
3163
- h("option", { value: "monthly" }, "\u6708\u7ED3"),
3164
- h("option", { value: "daily" }, "\u65E5\u7ED3")
3165
- )
3166
- ),
3167
- h(
3168
- C.Field,
3169
- { h, label: "\u7528\u5DE5\u7C7B\u578B" },
3170
- h(
3171
- "select",
3172
- { className: "wbsal-input", value: form.employmentType, onChange: function(e) {
3173
- setField("employmentType", e.target.value);
3174
- } },
3175
- F.EMPLOYMENT_TYPES.map(function(t) {
3176
- return h("option", { key: t.value || "none", value: t.value }, t.label);
3177
- })
3178
- )
3179
- ),
3180
- h(
3181
- C.Field,
3182
- { h, label: "\u5DE5\u8D44\u6240\u5C5E\u671F" },
3183
- h((form.incomePeriod ? form.incomePeriod.length === 10 : form.cycle === "daily") ? DP.DatePicker : DP.MonthPicker, {
3184
- React,
3185
- h,
3186
- prefix: "wbsal",
3187
- lang,
3188
- label: "\u5DE5\u8D44\u6240\u5C5E\u671F",
3189
- placeholder: "\u672A\u5F52\u5C5E",
3190
- value: form.incomePeriod || "",
3191
- onChange: function(next) {
3192
- setField("incomePeriod", next);
3193
- }
3194
- })
3195
- ),
3196
- h(C.Field, { h, label: "\u5907\u6CE8" }, h("input", { className: "wbsal-input", value: form.note, onChange: function(e) {
3197
- setField("note", e.target.value);
3198
- } }))
3199
- ),
3200
- sameDayCount > 0 ? h(C.Notice, { h, text: "\u8BE5\u65E5\u5DF2\u6709 " + sameDayCount + " \u7B14\u8BB0\u5F55\uFF1B\u4FDD\u5B58\u4F1A\u65B0\u589E\u4E00\u6761\uFF0C\u4E0D\u4F1A\u8986\u76D6\u3002" }) : null,
3201
- F.GROUPS.map(function(group) {
3202
- return h(
3758
+ function groupsBlock(hh, groups2) {
3759
+ return hh("div", { className: "wbsal-steps-groups" }, groups2.map(function(group) {
3760
+ return hh(
3203
3761
  "div",
3204
3762
  { key: group.id, className: "wbsal-form-group" },
3205
- h(
3763
+ hh(
3206
3764
  "div",
3207
3765
  { className: "wbsal-group-head" },
3208
- h("div", { className: "wbsal-group-title" }, group.title),
3209
- h("span", null, group.hint)
3766
+ hh("div", { className: "wbsal-group-title" }, group.title),
3767
+ hh("span", null, group.hint)
3210
3768
  ),
3211
- h("div", { className: "wbsal-form-grid" }, group.keys.map(function(key) {
3212
- return h(C.Field, { key, h, label: F.LABELS[key] }, amountInput(key, false));
3769
+ hh("div", { className: "wbsal-form-grid" }, group.keys.map(function(key) {
3770
+ return hh(C.Field, { key, h: hh, label: F.LABELS[key] }, amountInput(key, false));
3213
3771
  }))
3214
3772
  );
3215
- }),
3216
- h(
3217
- "div",
3218
- { className: "wbsal-form-group" },
3219
- h(
3220
- "div",
3221
- { className: "wbsal-group-head" },
3222
- h("div", { className: "wbsal-group-title" }, "\u6C47\u603B"),
3223
- h("span", null, "\u9ED8\u8BA4\u6309\u660E\u7EC6\u5B9E\u65F6\u8BA1\u7B97\uFF0C\u4E5F\u53EF\u4EE5\u76F4\u63A5\u6539")
3224
- ),
3225
- h(
3226
- "div",
3227
- { className: "wbsal-form-grid" },
3228
- h(C.Field, { h, label: "\u5E94\u53D1\u7A0E\u524D\u5DE5\u8D44" }, amountInput("grossPay", lockedGross)),
3229
- h(C.Field, { h, label: "\u5B9E\u53D1\u5DE5\u8D44" }, amountInput("netPay", false))
3230
- )
3231
- ),
3232
- h(
3233
- "div",
3234
- { className: "wbsal-summary" },
3235
- h("div", null, h("span", null, "\u6536\u5165\u5408\u8BA1"), h("b", null, F.money(computed.income))),
3236
- h("div", null, h("span", null, "\u7A0E\u524D\u6263\u6B3E"), h("b", null, F.money(computed.preTax))),
3237
- h("div", null, h("span", null, "\u793E\u4FDD\u516C\u79EF\u91D1"), h("b", null, F.money(computed.social))),
3238
- h("div", null, h("span", null, "\u4E2A\u7A0E+\u7A0E\u540E"), h("b", null, F.money(computed.tax))),
3239
- h("div", null, h("span", null, "\u5E94\u53D1"), h("b", null, F.money(F.num(form.values.grossPay)))),
3240
- h("div", null, h("span", null, "\u5B9E\u53D1"), h("b", null, F.money(F.num(form.values.netPay)))),
3241
- lockedGross ? h(
3242
- "div",
3243
- { className: "wbsal-lock" },
3244
- h("span", { className: "wbsal-muted" }, "\u8FD9\u6761\u5386\u53F2\u8BB0\u5F55\u53EA\u6709\u6C47\u603B\u503C\uFF0C\u5E94\u53D1\u5DF2\u9501\u5B9A\uFF0C\u907F\u514D\u88AB\u660E\u7EC6\u91CD\u7B97\u6E05\u96F6\u3002"),
3245
- h(C.Btn, { h, onClick: recalcFromDetail }, "\u6309\u660E\u7EC6\u91CD\u7B97")
3246
- ) : null
3247
- ),
3248
- h(C.Notice, { h, kind: msg && msg.kind, text: msg && msg.text }),
3249
- h(
3250
- "div",
3251
- { className: "wbsal-form-actions" },
3252
- h(C.Btn, { h, kind: "primary", onClick: submit, disabled: saving }, saving ? "\u4FDD\u5B58\u4E2D\u2026" : form.mode === "edit" ? "\u4FDD\u5B58\u4FEE\u6539" : "\u4FDD\u5B58"),
3253
- h(C.Btn, { h, kind: "ghost", onClick: closeForm }, "\u53D6\u6D88")
3254
- )
3255
- );
3256
- }
3257
- function renderModal() {
3258
- var label = form.mode === "edit" ? "\u7F16\u8F91\u5DE5\u8D44" : "\u8BB0\u4E00\u7B14\u5DE5\u8D44";
3259
- return h(FormOverlay, { "aria-label": label, onClose: closeForm }, renderForm());
3773
+ }));
3774
+ }
3775
+ return h(FormDialog, {
3776
+ h,
3777
+ React,
3778
+ title: label,
3779
+ eyebrow: form.mode === "edit" ? "EDIT RECORD" : "NEW RECORD",
3780
+ // 测试按步渲染校验金额控件,正常打开仍从第一步开始。
3781
+ initialStep: props.initialStep,
3782
+ submitting: saving,
3783
+ error: msg && msg.kind === "error" ? msg.text : "",
3784
+ onClose: saving ? null : closeForm,
3785
+ onSubmit: submit,
3786
+ submitText: form.mode === "edit" ? "\u4FDD\u5B58\u4FEE\u6539" : "\u4FDD\u5B58",
3787
+ cancelText: "\u53D6\u6D88",
3788
+ nextText: "\u4E0B\u4E00\u6B65",
3789
+ backText: "\u4E0A\u4E00\u6B65",
3790
+ steps: [
3791
+ {
3792
+ key: "basic",
3793
+ label: "\u57FA\u7840\u4FE1\u606F",
3794
+ hint: "\u65E5\u671F\u4E0E\u5F52\u5C5E",
3795
+ render: function(hh) {
3796
+ return hh(
3797
+ "div",
3798
+ { className: "wbsal-form-meta" },
3799
+ hh(
3800
+ C.Field,
3801
+ { h: hh, label: "\u5230\u8D26\u65E5" },
3802
+ hh(DP.DatePicker, { React, h: hh, prefix: "wbsal", lang, label: "\u5230\u8D26\u65E5", value: form.payDate, onChange: function(next) {
3803
+ setField("payDate", next);
3804
+ } })
3805
+ ),
3806
+ hh(
3807
+ C.Field,
3808
+ { h: hh, label: "\u7ED3\u7B97\u65B9\u5F0F" },
3809
+ hh(
3810
+ "select",
3811
+ { className: "wbsal-input", value: form.cycle, onChange: function(e) {
3812
+ setField("cycle", e.target.value);
3813
+ } },
3814
+ hh("option", { value: "monthly" }, "\u6708\u7ED3"),
3815
+ hh("option", { value: "daily" }, "\u65E5\u7ED3")
3816
+ )
3817
+ ),
3818
+ hh(
3819
+ C.Field,
3820
+ { h: hh, label: "\u7528\u5DE5\u7C7B\u578B" },
3821
+ hh(
3822
+ "select",
3823
+ { className: "wbsal-input", value: form.employmentType, onChange: function(e) {
3824
+ setField("employmentType", e.target.value);
3825
+ } },
3826
+ F.EMPLOYMENT_TYPES.map(function(t) {
3827
+ return hh("option", { key: t.value || "none", value: t.value }, t.label);
3828
+ })
3829
+ )
3830
+ ),
3831
+ hh(
3832
+ C.Field,
3833
+ { h: hh, label: "\u5DE5\u8D44\u6240\u5C5E\u671F" },
3834
+ hh((form.incomePeriod ? form.incomePeriod.length === 10 : form.cycle === "daily") ? DP.DatePicker : DP.MonthPicker, {
3835
+ React,
3836
+ h: hh,
3837
+ prefix: "wbsal",
3838
+ lang,
3839
+ label: "\u5DE5\u8D44\u6240\u5C5E\u671F",
3840
+ placeholder: "\u672A\u5F52\u5C5E",
3841
+ value: form.incomePeriod || "",
3842
+ onChange: function(next) {
3843
+ setField("incomePeriod", next);
3844
+ }
3845
+ })
3846
+ ),
3847
+ hh(
3848
+ C.Field,
3849
+ { h: hh, label: "\u5907\u6CE8" },
3850
+ hh("input", { className: "wbsal-input", value: form.note, onChange: function(e) {
3851
+ setField("note", e.target.value);
3852
+ } })
3853
+ )
3854
+ );
3855
+ }
3856
+ },
3857
+ {
3858
+ key: "amount",
3859
+ label: "\u91D1\u989D\u660E\u7EC6",
3860
+ hint: "\u6309\u5206\u7EC4\u586B\u6536\u5165\u4E0E\u6263\u6B3E",
3861
+ render: function(hh) {
3862
+ return groupsBlock(hh, F.GROUPS);
3863
+ },
3864
+ validate: function() {
3865
+ var bad = firstBadAmount();
3866
+ return bad ? F.LABELS[bad.key] + "\uFF1A" + bad.error : "";
3867
+ }
3868
+ },
3869
+ {
3870
+ key: "summary",
3871
+ label: "\u6C47\u603B\u786E\u8BA4",
3872
+ hint: "\u9ED8\u8BA4\u6309\u660E\u7EC6\u5B9E\u65F6\u8BA1\u7B97",
3873
+ render: function(hh) {
3874
+ return hh(
3875
+ "div",
3876
+ { className: "wbsal-steps-groups" },
3877
+ hh(
3878
+ "div",
3879
+ { className: "wbsal-form-group" },
3880
+ hh(
3881
+ "div",
3882
+ { className: "wbsal-group-head" },
3883
+ hh("div", { className: "wbsal-group-title" }, "\u6C47\u603B"),
3884
+ hh("span", null, "\u9ED8\u8BA4\u6309\u660E\u7EC6\u5B9E\u65F6\u8BA1\u7B97\uFF0C\u4E5F\u53EF\u4EE5\u76F4\u63A5\u6539")
3885
+ ),
3886
+ hh(
3887
+ "div",
3888
+ { className: "wbsal-form-grid" },
3889
+ hh(C.Field, { h: hh, label: "\u5E94\u53D1\u7A0E\u524D\u5DE5\u8D44" }, amountInput("grossPay", lockedGross)),
3890
+ hh(C.Field, { h: hh, label: "\u5B9E\u53D1\u5DE5\u8D44" }, amountInput("netPay", false))
3891
+ )
3892
+ ),
3893
+ sameDayCount > 0 ? hh(C.Notice, { h: hh, text: "\u8BE5\u65E5\u5DF2\u6709 " + sameDayCount + " \u7B14\u8BB0\u5F55\uFF1B\u4FDD\u5B58\u4F1A\u65B0\u589E\u4E00\u6761\uFF0C\u4E0D\u4F1A\u8986\u76D6\u3002" }) : null,
3894
+ hh(
3895
+ "div",
3896
+ { className: "wbsal-summary" },
3897
+ hh("div", null, hh("span", null, "\u6536\u5165\u5408\u8BA1"), hh("b", null, F.money(computed.income))),
3898
+ hh("div", null, hh("span", null, "\u7A0E\u524D\u6263\u6B3E"), hh("b", null, F.money(computed.preTax))),
3899
+ hh("div", null, hh("span", null, "\u793E\u4FDD\u516C\u79EF\u91D1"), hh("b", null, F.money(computed.social))),
3900
+ hh("div", null, hh("span", null, "\u4E2A\u7A0E+\u7A0E\u540E"), hh("b", null, F.money(computed.tax))),
3901
+ hh("div", null, hh("span", null, "\u5E94\u53D1"), hh("b", null, F.money(F.num(form.values.grossPay)))),
3902
+ hh("div", null, hh("span", null, "\u5B9E\u53D1"), hh("b", null, F.money(F.num(form.values.netPay)))),
3903
+ lockedGross ? hh(
3904
+ "div",
3905
+ { className: "wbsal-lock" },
3906
+ hh("span", { className: "wbsal-muted" }, "\u8FD9\u6761\u5386\u53F2\u8BB0\u5F55\u53EA\u6709\u6C47\u603B\u503C\uFF0C\u5E94\u53D1\u5DF2\u9501\u5B9A\uFF0C\u907F\u514D\u88AB\u660E\u7EC6\u91CD\u7B97\u6E05\u96F6\u3002"),
3907
+ hh(C.Btn, { h: hh, onClick: recalcFromDetail }, "\u6309\u660E\u7EC6\u91CD\u7B97")
3908
+ ) : null
3909
+ )
3910
+ );
3911
+ }
3912
+ }
3913
+ ]
3914
+ });
3260
3915
  }
3261
3916
  function renderDetail(item) {
3262
3917
  var blocks = F.GROUPS.map(function(group) {
@@ -3764,13 +4419,6 @@ var require_data_style = __commonJS({
3764
4419
  "." + 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)}",
3765
4420
  "." + 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}",
3766
4421
  "." + 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)}",
3767
- "." + 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}",
3768
- "." + P + "-switch input{position:absolute;inset:0;width:100%;height:100%;margin:0;opacity:0;cursor:pointer}",
3769
- "." + 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}",
3770
- "." + 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}",
3771
- "." + P + "-switch input:checked+." + P + "-track{background:var(--dsw-alias-brand-primary,currentColor)}",
3772
- "." + P + "-switch input:checked+." + P + "-track::after{transform:translateX(14px);background:var(--dsw-alias-label-primary-inverted,var(--dsw-alias-bg-base))}",
3773
- "." + P + "-switch input:focus-visible+." + P + "-track{outline:2px solid var(--dsw-alias-brand-primary,currentColor);outline-offset:2px}",
3774
4422
  "." + 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}",
3775
4423
  "." + P + "-btn:hover{background:var(--cfg-hover);color:var(--dsw-alias-label-primary,inherit)}",
3776
4424
  "." + P + "-btn:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,currentColor);outline-offset:2px}",
@@ -3799,8 +4447,8 @@ var require_data_style = __commonJS({
3799
4447
  "." + P + "-foot{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding-top:2px;font-size:11.5px;color:var(--cfg-muted)}",
3800
4448
  "." + P + "-grow{flex:1}",
3801
4449
  "." + P + "-pageinfo{font-variant-numeric:tabular-nums}",
3802
- "." + 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}",
3803
- "." + P + "-jump:focus{border-color:var(--dsw-alias-brand-primary,currentColor)}",
4450
+ "." + P + "-jump .wbctl-num-input{width:56px;padding:4px 7px;font-size:11.5px;text-align:right}",
4451
+ "." + P + "-jump .wbctl-num-hint{display:none}",
3804
4452
  "." + 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)}",
3805
4453
  "." + 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}",
3806
4454
  "." + P + "-skwrap{display:flex;flex-direction:column;gap:1px;padding:2px}",
@@ -3838,7 +4486,7 @@ var require_data_style = __commonJS({
3838
4486
  "." + P + "-images img{width:36px;height:36px;object-fit:cover;border-radius:5px}",
3839
4487
  "." + P + "-gallery{display:flex;flex-direction:column;gap:12px;overflow:auto;flex:1}",
3840
4488
  "." + P + "-gallery img{width:100%;height:auto;object-fit:contain;border-radius:8px}"
3841
- ].join("\n");
4489
+ ].concat(require_switch().styles).concat(require_number_field().styles).join("\n");
3842
4490
  if (DOMAIN === "storage") {
3843
4491
  var buttons = "." + P + " :is(button)";
3844
4492
  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}";
@@ -3866,8 +4514,10 @@ var require_data_view = __commonJS({
3866
4514
  "packages/addons/lib/data-view.cjs"(exports2, module2) {
3867
4515
  "use strict";
3868
4516
  var React = require("react");
4517
+ var NF = require_number_field();
3869
4518
  var h = React.createElement;
3870
4519
  var COPY = require_data_copy();
4520
+ var SW = require_switch();
3871
4521
  module2.exports = function createDataView(options) {
3872
4522
  var DOMAIN = options.domain;
3873
4523
  function icon(name) {
@@ -4421,17 +5071,18 @@ var require_data_view = __commonJS({
4421
5071
  h("button", { type: "button", className: P + "-btn", disabled: !data || page >= pages, onClick: function() {
4422
5072
  setPage(Math.min(pages, page + 1));
4423
5073
  } }, t.next + " \u203A"),
4424
- h("input", {
5074
+ h(NF.NumberField, {
5075
+ h,
5076
+ lang,
4425
5077
  className: P + "-jump",
4426
- type: "number",
5078
+ value: page,
4427
5079
  min: 1,
4428
5080
  max: pages,
4429
- "aria-label": t.jump,
4430
- onKeyDown: function(e) {
4431
- if (e.key === "Enter") {
4432
- var n = Math.floor(Number(e.target.value));
4433
- if (n >= 1) setPage(Math.min(pages, n));
4434
- }
5081
+ integer: true,
5082
+ ariaLabel: t.jump,
5083
+ hint: false,
5084
+ onCommit: function(next) {
5085
+ if (next !== null) setPage(next);
4435
5086
  }
4436
5087
  }),
4437
5088
  data && data.queryMs !== void 0 ? h("span", null, fmt(t.queryTime, { n: data.queryMs })) : null
@@ -4528,25 +5179,23 @@ var require_data_view = __commonJS({
4528
5179
  }
4529
5180
  })
4530
5181
  ),
4531
- h(
4532
- "label",
4533
- { className: P + "-switch" },
4534
- h("input", { type: "checkbox", checked: includeDeleted, onChange: function(e) {
4535
- setIncludeDeleted(e.target.checked);
5182
+ h(SW.Switch, {
5183
+ h,
5184
+ checked: includeDeleted,
5185
+ label: t.includeDeleted,
5186
+ onChange: function(next) {
5187
+ setIncludeDeleted(next);
4536
5188
  setPage(1);
4537
- } }),
4538
- h("span", { className: P + "-track" }),
4539
- h("span", null, t.includeDeleted)
4540
- ),
4541
- h(
4542
- "label",
4543
- { className: P + "-switch" },
4544
- h("input", { type: "checkbox", checked: showSystem, onChange: function(e) {
4545
- setShowSystem(e.target.checked);
4546
- } }),
4547
- h("span", { className: P + "-track" }),
4548
- h("span", null, t.showSystem)
4549
- ),
5189
+ }
5190
+ }),
5191
+ h(SW.Switch, {
5192
+ h,
5193
+ checked: showSystem,
5194
+ label: t.showSystem,
5195
+ onChange: function(next) {
5196
+ setShowSystem(next);
5197
+ }
5198
+ }),
4550
5199
  h("span", { className: P + "-grow" }),
4551
5200
  h(
4552
5201
  "label",
@@ -4704,16 +5353,13 @@ var require_action_schema_style = __commonJS({
4704
5353
  "." + P + "-cardmeta{display:flex;align-items:center;flex-wrap:wrap;gap:8px;min-width:0;min-height:24px}",
4705
5354
  "." + P + "-cardhead code{font-weight:640;overflow-wrap:anywhere;min-width:0}",
4706
5355
  "." + P + "-hintline{margin:0;color:var(--dsw-alias-label-tertiary,inherit);font-size:11.5px;line-height:1.5}",
4707
- "." + 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}",
4708
- "." + 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)}",
4709
- "." + P + "-track::before{content:'';width:12px;height:12px;border-radius:50%;background:currentColor;transition:transform .15s ease}",
4710
- "." + P + "-toggle[aria-checked=true] ." + P + "-track{background:var(--wb-accent);border-color:var(--wb-accent);color:var(--wb-card)}",
4711
- "." + P + "-toggle[aria-checked=true] ." + P + "-track::before{transform:translateX(12px)}",
4712
- "." + P + "-toggle:hover:not(:disabled) ." + P + "-track{outline:1px solid var(--wb-accent)}",
4713
- "." + P + "-toggle:focus-visible{outline:2px solid var(--wb-accent);outline-offset:2px}",
4714
- "." + P + "-toggle:disabled{opacity:.6;cursor:progress}",
4715
- "@media(prefers-reduced-motion:reduce){." + P + "-track::before{transition:none}}",
4716
- // 安全约束(不可放开):用警示色描边,和可切换的开关区分开。
5356
+ "." + P + "-origins{display:inline-flex;align-items:center;gap:10px;flex-wrap:wrap;justify-content:flex-end}",
5357
+ "." + P + "-origins-label{font-size:11px;color:var(--wb-muted);white-space:nowrap}",
5358
+ "." + P + "-origin{display:inline-flex;align-items:center;gap:4px;font-size:11.5px;color:var(--wb-muted);cursor:pointer;user-select:none}",
5359
+ // 该 action 本身不支持的来源:整项置灰、不可点,示意「不是没开,是开不了」。
5360
+ "." + P + "-origin-off{opacity:.55;cursor:not-allowed}",
5361
+ "." + P + "-origin input[type=checkbox]{width:13px;height:13px;margin:0;accent-color:var(--wb-accent);cursor:inherit}",
5362
+ "." + P + "-origin input[type=checkbox]:focus-visible{outline:2px solid var(--wb-accent);outline-offset:2px}",
4717
5363
  "." + P + "-locked{border-color:var(--wb-warn,#b7791f);color:var(--wb-warn,#b7791f)}",
4718
5364
  "." + P + "-desc{margin:0;color:var(--dsw-alias-label-secondary,inherit);line-height:1.55;font-size:12.5px}",
4719
5365
  // 搜索命中:用品牌色透明度叠加而不是写死浅色,深浅主题都可读;继承文字颜色、不覆盖 ::selection。
@@ -4766,15 +5412,20 @@ var require_action_schema_view = __commonJS({
4766
5412
  zh: {
4767
5413
  title: "Action",
4768
5414
  hint: "\u8FD0\u884C\u65F6\u6CE8\u518C \xB7 \u53EA\u8BFB",
4769
- switchHint: "agent \u5F00\u5173\u843D\u672C\u673A\u3001\u5373\u6539\u5373\u751F\u6548\uFF1B\u754C\u9762\u64CD\u4F5C\u4E0D\u53D7\u5F71\u54CD\u3002",
4770
- 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",
4771
- agentSwitch: "agent \u53EF\u7528",
4772
- agentLocked: "\u4EC5\u754C\u9762 \xB7 \u5B89\u5168\u7EA6\u675F",
4773
- agentLockedHint: "\u8BE5 action \u53EA\u80FD\u5728\u754C\u9762\u6267\u884C\uFF08\u5B89\u5168\u7EA6\u675F\uFF09\uFF0Cagent \u5F00\u5173\u4E0D\u53EF\u653E\u5F00",
4774
- agentSaving: "\u4FDD\u5B58\u4E2D\u2026",
4775
- agentOnToast: "\u5DF2\u5141\u8BB8 agent \u8C03\u7528",
4776
- agentOffToast: "\u5DF2\u7981\u6B62 agent \u8C03\u7528",
4777
- agentFail: "\u5207\u6362 agent \u5F00\u5173\u5931\u8D25",
5415
+ 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",
5416
+ hostHint: "\u5BBF\u4E3B action \u7684\u5141\u8BB8\u6765\u6E90\uFF1B\u6807\u300C\u6765\u6E90\u56FA\u5B9A\u300D\u7684\u4E0D\u53EF\u4FEE\u6539\u3002",
5417
+ originsLabel: "\u5141\u8BB8\u6765\u6E90",
5418
+ originUi: "\u754C\u9762",
5419
+ originPlugin: "\u63D2\u4EF6",
5420
+ originAgent: "agent",
5421
+ originSync: "\u540C\u6B65",
5422
+ originsSaving: "\u4FDD\u5B58\u4E2D\u2026",
5423
+ originsToast: "\u5DF2\u66F4\u65B0\u5141\u8BB8\u6765\u6E90",
5424
+ originsFail: "\u66F4\u65B0\u5141\u8BB8\u6765\u6E90\u5931\u8D25",
5425
+ originsEmpty: "\u81F3\u5C11\u8981\u4FDD\u7559\u4E00\u4E2A\u6765\u6E90",
5426
+ originsUnsupported: "\u8BE5 action \u672C\u8EAB\u4E0D\u652F\u6301\u8FD9\u4E2A\u6765\u6E90",
5427
+ originsPinned: "\u6765\u6E90\u56FA\u5B9A",
5428
+ originsPinnedHint: "\u8BE5 action \u7684\u5141\u8BB8\u6765\u6E90\u88AB\u56FA\u5B9A\uFF08\u5B89\u5168\u7EA6\u675F\uFF09\uFF0C\u4E0D\u80FD\u4FEE\u6539",
4778
5429
  domain: "\u57DF",
4779
5430
  versionLabel: "\u7248\u672C",
4780
5431
  shell: "\u5BBF\u4E3B",
@@ -4788,6 +5439,8 @@ var require_action_schema_view = __commonJS({
4788
5439
  onlyOptional: "\u65E0\u5FC5\u586B\u9879",
4789
5440
  filterType: "\u53C2\u6570\u7C7B\u578B",
4790
5441
  allTypes: "\u5168\u90E8\u7C7B\u578B",
5442
+ filterOrigin: "\u5141\u8BB8\u6765\u6E90",
5443
+ allOrigins: "\u5168\u90E8\u6765\u6E90",
4791
5444
  colName: "\u53C2\u6570",
4792
5445
  colType: "\u7C7B\u578B",
4793
5446
  colReq: "\u5FC5\u586B",
@@ -4820,15 +5473,22 @@ var require_action_schema_view = __commonJS({
4820
5473
  en: {
4821
5474
  title: "Actions",
4822
5475
  hint: "runtime registry \xB7 read-only",
4823
- switchHint: "The agent switch is stored locally and applies immediately; UI actions are unaffected.",
4824
- hostHint: "Agent switch for host actions; items marked UI-only (security) cannot be opened up.",
4825
- agentSwitch: "Agent callable",
4826
- agentLocked: "UI only \xB7 security",
4827
- agentLockedHint: "This action can only run from the UI (security constraint); the agent switch cannot be opened",
4828
- agentSaving: "Saving\u2026",
4829
- agentOnToast: "Agent calls allowed",
4830
- agentOffToast: "Agent calls blocked",
4831
- agentFail: "Failed to change the agent switch",
5476
+ switchHint: "Allowed origins are stored locally and apply immediately: only checked origins may call the action; others get ACTION_ORIGIN_DENIED.",
5477
+ hostHint: "Allowed origins for host actions; items marked pinned cannot be changed.",
5478
+ originsLabel: "Origins",
5479
+ originUi: "UI",
5480
+ originPlugin: "Plugin",
5481
+ originAgent: "Agent",
5482
+ originSync: "Sync",
5483
+ originsSaving: "Saving\u2026",
5484
+ originsToast: "Allowed origins updated",
5485
+ originsFail: "Failed to update allowed origins",
5486
+ originsEmpty: "Keep at least one origin",
5487
+ originsUnsupported: "This action does not support this origin",
5488
+ originsPinned: "Pinned",
5489
+ originsPinnedHint: "Allowed origins are pinned for this action (security constraint) and cannot be changed",
5490
+ originsDefaultOn: "Allowed by default",
5491
+ originsDefaultOff: "Off by default, can be enabled",
4832
5492
  domain: "Domain",
4833
5493
  versionLabel: "Version",
4834
5494
  shell: "Host",
@@ -4842,6 +5502,8 @@ var require_action_schema_view = __commonJS({
4842
5502
  onlyOptional: "No required",
4843
5503
  filterType: "Param type",
4844
5504
  allTypes: "All types",
5505
+ filterOrigin: "Origins",
5506
+ allOrigins: "All origins",
4845
5507
  colName: "Param",
4846
5508
  colType: "Type",
4847
5509
  colReq: "Required",
@@ -4985,6 +5647,8 @@ var require_action_schema_view = __commonJS({
4985
5647
  var reqMode = reqState[0], setReqMode = reqState[1];
4986
5648
  var typeState = React.useState("");
4987
5649
  var typePick = typeState[0], setTypePick = typeState[1];
5650
+ var originFilterState = React.useState("");
5651
+ var originPick = originFilterState[0], setOriginPick = originFilterState[1];
4988
5652
  var toastState = React.useState("");
4989
5653
  var toast = toastState[0], setToast = toastState[1];
4990
5654
  var savingState = React.useState("");
@@ -5040,38 +5704,53 @@ var require_action_schema_view = __commonJS({
5040
5704
  plainCopy(text);
5041
5705
  done();
5042
5706
  }
5043
- function setAgent(action, next) {
5707
+ var ORIGINS = ["ui", "plugin", "agent", "sync"];
5708
+ var originText = { ui: t.originUi, plugin: t.originPlugin, agent: t.originAgent, sync: t.originSync };
5709
+ function setOrigins(action, origin) {
5044
5710
  var name = action.name;
5711
+ var current = Array.isArray(action.origins) ? action.origins.slice() : [];
5712
+ var index = current.indexOf(origin);
5713
+ var next = index >= 0 ? current.filter(function(o) {
5714
+ return o !== origin;
5715
+ }) : current.concat([origin]);
5716
+ if (next.length === 0) {
5717
+ setToast(t.originsEmpty);
5718
+ return;
5719
+ }
5720
+ next = ORIGINS.filter(function(o) {
5721
+ return next.indexOf(o) >= 0;
5722
+ });
5045
5723
  setSaving(name);
5046
5724
  setToast("");
5047
5725
  var fail = function(e) {
5048
5726
  setSaving("");
5049
- setToast(t.agentFail + "\uFF1A" + String(e && e.message || e || ""));
5727
+ setToast(t.originsFail + "\uFF1A" + String(e && e.message || e || ""));
5050
5728
  };
5051
5729
  var done = function(r) {
5052
5730
  setSaving("");
5053
5731
  var payload = r && typeof r === "object" && Object.prototype.hasOwnProperty.call(r, "result") ? r.result : r;
5054
5732
  if (r && r.ok === false) {
5055
- setToast(t.agentFail + "\uFF1A" + String(r.error || r.text || ""));
5733
+ setToast(t.originsFail + "\uFF1A" + String(r.error || r.text || ""));
5056
5734
  return;
5057
5735
  }
5058
- var value = payload && typeof payload.agentEnabled === "boolean" ? payload.agentEnabled : next;
5736
+ var value = payload && Array.isArray(payload.origins) ? payload.origins : next;
5737
+ var source = payload && typeof payload.source === "string" ? payload.source : action.originsSource;
5059
5738
  setSnap(function(prev) {
5060
5739
  if (!prev || !Array.isArray(prev.actions)) return prev;
5061
5740
  return Object.assign({}, prev, {
5062
5741
  actions: prev.actions.map(function(a) {
5063
5742
  if (!a || a.name !== name) return a;
5064
- return Object.assign({}, a, { agentEnabled: value });
5743
+ return Object.assign({}, a, { origins: value, originsSource: source });
5065
5744
  })
5066
5745
  });
5067
5746
  });
5068
- setToast(value ? t.agentOnToast : t.agentOffToast);
5747
+ setToast(t.originsToast);
5069
5748
  };
5070
5749
  if (!api || typeof api.call !== "function") {
5071
5750
  fail(new Error("no call api"));
5072
5751
  return;
5073
5752
  }
5074
- Promise.resolve(api.call("actions.setAgentAccess", { action: name, agentEnabled: next })).then(done, fail);
5753
+ Promise.resolve(api.call("actions.setActionOrigins", { action: name, origins: next })).then(done, fail);
5075
5754
  }
5076
5755
  var all = snap && Array.isArray(snap.actions) ? snap.actions.filter(function(a) {
5077
5756
  return a && a.domain === DOMAIN;
@@ -5106,6 +5785,7 @@ var require_action_schema_view = __commonJS({
5106
5785
  if (typePick && !rows.some(function(row) {
5107
5786
  return row.types.indexOf(typePick) >= 0;
5108
5787
  })) return false;
5788
+ if (originPick && (!Array.isArray(a.origins) || a.origins.indexOf(originPick) < 0)) return false;
5109
5789
  return true;
5110
5790
  });
5111
5791
  function paramRow(row) {
@@ -5121,33 +5801,45 @@ var require_action_schema_view = __commonJS({
5121
5801
  h("td", null, Highlight.hit(row.description, kw))
5122
5802
  );
5123
5803
  }
5124
- function agentSwitch(action) {
5125
- if (action.agentLocked === true) {
5126
- return h("span", {
5127
- className: P + "-badge " + P + "-locked",
5128
- title: t.agentLockedHint,
5129
- "data-agent-locked": action.name
5130
- }, t.agentLocked);
5804
+ function originsChips(action) {
5805
+ if (!Array.isArray(action.origins)) return null;
5806
+ if (action.originsSource === "invalid") {
5807
+ return h("span", { className: P + "-badge " + P + "-locked", title: t.originsPinnedHint, "data-origins-invalid": action.name }, t.originsPinned);
5131
5808
  }
5132
- if (typeof action.agentEnabled !== "boolean") return null;
5133
5809
  var busy = saving === action.name;
5810
+ var pinned = action.name === "actions.setActionOrigins";
5811
+ var supported = Array.isArray(action.originsDeclared) ? action.originsDeclared : action.origins;
5134
5812
  return h(
5135
- "button",
5136
- {
5137
- className: P + "-toggle",
5138
- "data-agent-row": action.name,
5139
- type: "button",
5140
- role: "switch",
5141
- "aria-checked": action.agentEnabled,
5142
- disabled: busy,
5143
- "data-agent-toggle": action.name,
5144
- "aria-label": t.agentSwitch + " \xB7 " + action.name,
5145
- onClick: function() {
5146
- setAgent(action, !action.agentEnabled);
5147
- }
5148
- },
5149
- h("span", { className: P + "-track", "aria-hidden": true }),
5150
- h("span", null, busy ? t.agentSaving : t.agentSwitch)
5813
+ "div",
5814
+ { className: P + "-origins", "data-origins-row": action.name },
5815
+ h("span", { className: P + "-origins-label" }, t.originsLabel),
5816
+ ORIGINS.map(function(origin) {
5817
+ var on = action.origins.indexOf(origin) >= 0;
5818
+ var allowed = supported.indexOf(origin) >= 0;
5819
+ var preset = Array.isArray(action.originsDefault) ? action.originsDefault : supported;
5820
+ var byDefault = preset.indexOf(origin) >= 0;
5821
+ return h(
5822
+ "label",
5823
+ {
5824
+ key: origin,
5825
+ className: P + "-origin" + (allowed ? "" : " " + P + "-origin-off"),
5826
+ title: pinned ? t.originsPinnedHint : !allowed ? t.originsUnsupported : originText[origin] + " \xB7 " + action.name + " \xB7 " + (byDefault ? t.originsDefaultOn : t.originsDefaultOff)
5827
+ },
5828
+ h("input", {
5829
+ type: "checkbox",
5830
+ checked: on,
5831
+ disabled: busy || pinned || !allowed,
5832
+ "data-origin": origin,
5833
+ "data-origin-row": action.name,
5834
+ "data-origin-supported": allowed ? "1" : "0",
5835
+ onChange: function() {
5836
+ setOrigins(action, origin);
5837
+ }
5838
+ }),
5839
+ h("span", null, originText[origin])
5840
+ );
5841
+ }),
5842
+ busy ? h("span", { className: P + "-origins-label" }, t.originsSaving) : null
5151
5843
  );
5152
5844
  }
5153
5845
  function card(action) {
@@ -5168,7 +5860,7 @@ var require_action_schema_view = __commonJS({
5168
5860
  return row.required;
5169
5861
  }) ? h("span", { className: P + "-badge " + P + "-req" }, t.required) : null
5170
5862
  ),
5171
- agentSwitch(action)
5863
+ originsChips(action)
5172
5864
  ),
5173
5865
  action.description ? h("p", { className: P + "-desc" }, Highlight.hit(action.description, kw)) : null,
5174
5866
  rows.length ? h(
@@ -5291,6 +5983,21 @@ var require_action_schema_view = __commonJS({
5291
5983
  return h("option", { value: name, key: name }, name);
5292
5984
  })
5293
5985
  )
5986
+ ),
5987
+ h(
5988
+ "label",
5989
+ { className: P + "-none" },
5990
+ t.filterOrigin + " ",
5991
+ h(
5992
+ "select",
5993
+ { value: originPick, "aria-label": t.filterOrigin, "data-origin-filter": "", onChange: function(e) {
5994
+ setOriginPick(e.target.value);
5995
+ } },
5996
+ h("option", { value: "" }, t.allOrigins),
5997
+ ORIGINS.map(function(origin) {
5998
+ return h("option", { value: origin, key: origin }, originText[origin]);
5999
+ })
6000
+ )
5294
6001
  )
5295
6002
  ) : null,
5296
6003
  body,
@@ -5358,7 +6065,7 @@ var GLYPHS = require_icons2().ICONS;
5358
6065
  ensureStyles();
5359
6066
  host.registerAddon({
5360
6067
  id: "wb-addon-salary",
5361
- version: "0.4.1",
6068
+ version: "0.4.5",
5362
6069
  icon: GLYPHS["wallet"],
5363
6070
  views: [
5364
6071
  { id: "stats", icon: tabIcon("stats"), title: { zh: "\u7EDF\u8BA1", en: "Stats" }, component: withProps(require_stats(), "\u7EDF\u8BA1") },