dsh-workbench-salary 0.4.4 → 0.4.6

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/cordis.patch.yml CHANGED
@@ -1,5 +1,12 @@
1
+ # 工资插件:插入宿主行和本插件自己的插件行。
2
+ #
3
+ # 宿主行必须由子插件插入:宿主是传递依赖,DSH 只把 profile 的直接依赖选进
4
+ # dsh.profile.bundles,所以单独装一个子插件时宿主不会被自动选入,只能靠这行加载。
5
+ # 但宿主行用块式写法时,插件市场会把它算进本插件的 insertedIds,任何第二个
6
+ # dsh-workbench 系插件都会被判「和已安装的插件冲突」并整次回滚;写成流式(flow style)
7
+ # 既能被 js-yaml 和 DSH 正常解析、插入同一行,又不会被市场那套逐行正则数到。
8
+ # 详见 docs/AGENTS规范/03-安装与交付.md。
1
9
  - insert:
2
- - id: workbench
3
- name: dsh-workbench-host
10
+ - { id: workbench, name: 'dsh-workbench-host' }
4
11
  - id: workbench-salary
5
- name: dsh-workbench-salary
12
+ name: 'dsh-workbench-salary'
package/lib/client.js CHANGED
@@ -578,6 +578,406 @@ 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
+
581
981
  // packages/addons/lib/number-field.cjs
582
982
  var require_number_field = __commonJS({
583
983
  "packages/addons/lib/number-field.cjs"(exports2, module2) {
@@ -1012,9 +1412,11 @@ var require_styles = __commonJS({
1012
1412
  var AMOUNT = [
1013
1413
  ".wbsal-form-grid .wbctl-num{width:100%}",
1014
1414
  ".wbsal-form-grid .wbctl-num-box{width:100%}",
1015
- ".wbsal-form-grid .wbctl-num-input{width:100%;box-sizing:border-box;text-align:right}"
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}"
1016
1418
  ];
1017
- module2.exports = BASE.concat(PAGE, [DATE], AMOUNT, require_number_field().styles).join("\n");
1419
+ module2.exports = BASE.concat(PAGE, [DATE], AMOUNT, require_stepper().styles, require_staged_dialog().styles, require_number_field().styles).join("\n");
1018
1420
  }
1019
1421
  });
1020
1422
 
@@ -3092,115 +3494,45 @@ var require_stats = __commonJS({
3092
3494
  }
3093
3495
  });
3094
3496
 
3095
- // packages/addons/lib/overlay.cjs
3096
- var require_overlay = __commonJS({
3097
- "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) {
3098
3500
  "use strict";
3099
- var defaultReact = require("react");
3100
- var FOCUSABLE = "button:not(:disabled),input:not(:disabled),textarea:not(:disabled),select:not(:disabled),a[href]";
3101
- module2.exports = function createOverlay(options) {
3102
- var opts = options || {};
3103
- var React = opts.React || defaultReact;
3104
- var h = React.createElement;
3105
- var tag = opts.tag || "section";
3106
- var maskClass = opts.maskClass;
3107
- var dialogClass = opts.dialogClass;
3108
- var dialogClassOf = opts.dialogClassOf || function() {
3109
- return "";
3110
- };
3111
- 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) {
3112
3509
  return props["aria-label"] || props.title;
3113
- };
3114
- var ariaLabelledByOf = opts.ariaLabelledByOf || function() {
3115
- return null;
3116
- };
3117
- var header = opts.header || null;
3118
- var closeOnEscape = opts.closeOnEscape || function() {
3119
- return true;
3120
- };
3121
- var closeOnMask = opts.closeOnMask || function() {
3122
- return true;
3123
- };
3124
- var extraKeyDown = opts.onKeyDown || null;
3125
- var autoFocusDialog = opts.autoFocusDialog !== false;
3126
- var focusableSelector = opts.focusableSelector || FOCUSABLE;
3127
- function Modal(props) {
3128
- var ref = React.useRef(null);
3129
- React.useEffect(function() {
3130
- var previous = typeof document !== "undefined" ? document.activeElement : null;
3131
- var focusIt = props.autoFocus !== void 0 ? props.autoFocus : autoFocusDialog;
3132
- if (focusIt && ref.current) ref.current.focus();
3133
- return function() {
3134
- if (previous && previous.isConnected) previous.focus();
3135
- };
3136
- }, []);
3137
- function onKeyDown(e) {
3138
- if (extraKeyDown && extraKeyDown(e, props, ref)) return;
3139
- if (e.key === "Escape") {
3140
- if (!(props.closeOnEscape !== void 0 ? props.closeOnEscape : closeOnEscape(props))) return;
3141
- e.preventDefault();
3142
- e.stopPropagation();
3143
- if (props.onClose) props.onClose();
3144
- return;
3145
- }
3146
- if (e.key !== "Tab" || !ref.current) return;
3147
- var els = ref.current.querySelectorAll(focusableSelector);
3148
- if (!els.length) {
3149
- e.preventDefault();
3150
- return;
3151
- }
3152
- var first = els[0];
3153
- var last = els[els.length - 1];
3154
- if (e.shiftKey && (document.activeElement === first || document.activeElement === ref.current)) {
3155
- e.preventDefault();
3156
- last.focus();
3157
- }
3158
- if (!e.shiftKey && document.activeElement === last) {
3159
- e.preventDefault();
3160
- first.focus();
3161
- }
3162
- }
3163
- var labelledBy = ariaLabelledByOf(props);
3510
+ },
3511
+ header: function(props) {
3512
+ var h = props.h;
3513
+ var C = salaryCommon;
3164
3514
  return h(
3165
3515
  "div",
3166
- {
3167
- className: maskClass,
3168
- onMouseDown: function(e) {
3169
- var allowed = props.closeOnMask !== void 0 ? props.closeOnMask : closeOnMask(props);
3170
- if (e.target === e.currentTarget && props.onClose && allowed) props.onClose();
3171
- }
3172
- },
3516
+ { className: "wbsal-form-head" },
3173
3517
  h(
3174
- tag,
3175
- {
3176
- className: dialogClass + dialogClassOf(props),
3177
- role: "dialog",
3178
- "aria-modal": true,
3179
- "aria-label": labelledBy ? null : ariaLabelOf(props),
3180
- "aria-labelledby": labelledBy || null,
3181
- ref,
3182
- tabIndex: -1,
3183
- onKeyDown
3184
- },
3185
- header ? header(props) : null,
3186
- 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"
3187
3527
  )
3188
3528
  );
3529
+ },
3530
+ closeOnEscape: function(props) {
3531
+ return !props.submitting;
3532
+ },
3533
+ closeOnMask: function(props) {
3534
+ return !props.submitting;
3189
3535
  }
3190
- return Modal;
3191
- };
3192
- }
3193
- });
3194
-
3195
- // packages/addons/salary/client/views/records.cjs
3196
- var require_records = __commonJS({
3197
- "packages/addons/salary/client/views/records.cjs"(exports2, module2) {
3198
- "use strict";
3199
- var createOverlay = require_overlay();
3200
- var NF = require_number_field();
3201
- var FormOverlay = createOverlay({
3202
- maskClass: "wbsal-mask",
3203
- dialogClass: "wbsal-modal"
3204
3536
  });
3205
3537
  module2.exports = function Records(props) {
3206
3538
  var h = props.h, React = props.React, api = props.api, lang = props.lang;
@@ -3232,14 +3564,9 @@ var require_records = __commonJS({
3232
3564
  var modalOpen = !!form;
3233
3565
  React.useEffect(function() {
3234
3566
  if (!modalOpen || typeof document === "undefined" || typeof document.addEventListener !== "function" || !document.body) return void 0;
3235
- function onKey(event) {
3236
- if (event.key === "Escape") closeForm();
3237
- }
3238
- document.addEventListener("keydown", onKey);
3239
3567
  var previous = document.body.style.overflow;
3240
3568
  document.body.style.overflow = "hidden";
3241
3569
  return function() {
3242
- document.removeEventListener("keydown", onKey);
3243
3570
  document.body.style.overflow = previous;
3244
3571
  };
3245
3572
  }, [modalOpen, form && form.mode, form && form.id]);
@@ -3421,141 +3748,170 @@ var require_records = __commonJS({
3421
3748
  }
3422
3749
  });
3423
3750
  }
3424
- function renderForm() {
3751
+ function renderModal() {
3752
+ var label = form.mode === "edit" ? "\u7F16\u8F91\u5DE5\u8D44" : "\u8BB0\u4E00\u7B14\u5DE5\u8D44";
3425
3753
  var computed = F.totals(form.values);
3426
3754
  var lockedGross = form.lockGross;
3427
3755
  var sameDayCount = items.filter(function(item) {
3428
3756
  return item.payDate === form.payDate && item.id !== form.id;
3429
3757
  }).length;
3430
- return h(
3431
- "div",
3432
- { className: "wbsal-card wbsal-form wbsal-form-modal" },
3433
- h(
3434
- "div",
3435
- { className: "wbsal-form-head" },
3436
- h(
3437
- "div",
3438
- null,
3439
- h("div", { className: "wbsal-eyebrow" }, form.mode === "edit" ? "EDIT RECORD" : "NEW RECORD"),
3440
- h("h3", null, form.mode === "edit" ? "\u7F16\u8F91\u5DE5\u8D44" : "\u8BB0\u4E00\u7B14\u5DE5\u8D44")
3441
- ),
3442
- h(C.Btn, { h, kind: "ghost", onClick: closeForm }, "\u5173\u95ED")
3443
- ),
3444
- h(
3445
- "div",
3446
- { className: "wbsal-form-meta" },
3447
- h(
3448
- C.Field,
3449
- { h, label: "\u5230\u8D26\u65E5" },
3450
- h(DP.DatePicker, { React, h, prefix: "wbsal", lang, label: "\u5230\u8D26\u65E5", value: form.payDate, onChange: function(next) {
3451
- setField("payDate", next);
3452
- } })
3453
- ),
3454
- h(
3455
- C.Field,
3456
- { h, label: "\u7ED3\u7B97\u65B9\u5F0F" },
3457
- h(
3458
- "select",
3459
- { className: "wbsal-input", value: form.cycle, onChange: function(e) {
3460
- setField("cycle", e.target.value);
3461
- } },
3462
- h("option", { value: "monthly" }, "\u6708\u7ED3"),
3463
- h("option", { value: "daily" }, "\u65E5\u7ED3")
3464
- )
3465
- ),
3466
- h(
3467
- C.Field,
3468
- { h, label: "\u7528\u5DE5\u7C7B\u578B" },
3469
- h(
3470
- "select",
3471
- { className: "wbsal-input", value: form.employmentType, onChange: function(e) {
3472
- setField("employmentType", e.target.value);
3473
- } },
3474
- F.EMPLOYMENT_TYPES.map(function(t) {
3475
- return h("option", { key: t.value || "none", value: t.value }, t.label);
3476
- })
3477
- )
3478
- ),
3479
- h(
3480
- C.Field,
3481
- { h, label: "\u5DE5\u8D44\u6240\u5C5E\u671F" },
3482
- h((form.incomePeriod ? form.incomePeriod.length === 10 : form.cycle === "daily") ? DP.DatePicker : DP.MonthPicker, {
3483
- React,
3484
- h,
3485
- prefix: "wbsal",
3486
- lang,
3487
- label: "\u5DE5\u8D44\u6240\u5C5E\u671F",
3488
- placeholder: "\u672A\u5F52\u5C5E",
3489
- value: form.incomePeriod || "",
3490
- onChange: function(next) {
3491
- setField("incomePeriod", next);
3492
- }
3493
- })
3494
- ),
3495
- h(C.Field, { h, label: "\u5907\u6CE8" }, h("input", { className: "wbsal-input", value: form.note, onChange: function(e) {
3496
- setField("note", e.target.value);
3497
- } }))
3498
- ),
3499
- 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,
3500
- F.GROUPS.map(function(group) {
3501
- return h(
3758
+ function groupsBlock(hh, groups2) {
3759
+ return hh("div", { className: "wbsal-steps-groups" }, groups2.map(function(group) {
3760
+ return hh(
3502
3761
  "div",
3503
3762
  { key: group.id, className: "wbsal-form-group" },
3504
- h(
3763
+ hh(
3505
3764
  "div",
3506
3765
  { className: "wbsal-group-head" },
3507
- h("div", { className: "wbsal-group-title" }, group.title),
3508
- h("span", null, group.hint)
3766
+ hh("div", { className: "wbsal-group-title" }, group.title),
3767
+ hh("span", null, group.hint)
3509
3768
  ),
3510
- h("div", { className: "wbsal-form-grid" }, group.keys.map(function(key) {
3511
- 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));
3512
3771
  }))
3513
3772
  );
3514
- }),
3515
- h(
3516
- "div",
3517
- { className: "wbsal-form-group" },
3518
- h(
3519
- "div",
3520
- { className: "wbsal-group-head" },
3521
- h("div", { className: "wbsal-group-title" }, "\u6C47\u603B"),
3522
- h("span", null, "\u9ED8\u8BA4\u6309\u660E\u7EC6\u5B9E\u65F6\u8BA1\u7B97\uFF0C\u4E5F\u53EF\u4EE5\u76F4\u63A5\u6539")
3523
- ),
3524
- h(
3525
- "div",
3526
- { className: "wbsal-form-grid" },
3527
- h(C.Field, { h, label: "\u5E94\u53D1\u7A0E\u524D\u5DE5\u8D44" }, amountInput("grossPay", lockedGross)),
3528
- h(C.Field, { h, label: "\u5B9E\u53D1\u5DE5\u8D44" }, amountInput("netPay", false))
3529
- )
3530
- ),
3531
- h(
3532
- "div",
3533
- { className: "wbsal-summary" },
3534
- h("div", null, h("span", null, "\u6536\u5165\u5408\u8BA1"), h("b", null, F.money(computed.income))),
3535
- h("div", null, h("span", null, "\u7A0E\u524D\u6263\u6B3E"), h("b", null, F.money(computed.preTax))),
3536
- h("div", null, h("span", null, "\u793E\u4FDD\u516C\u79EF\u91D1"), h("b", null, F.money(computed.social))),
3537
- h("div", null, h("span", null, "\u4E2A\u7A0E+\u7A0E\u540E"), h("b", null, F.money(computed.tax))),
3538
- h("div", null, h("span", null, "\u5E94\u53D1"), h("b", null, F.money(F.num(form.values.grossPay)))),
3539
- h("div", null, h("span", null, "\u5B9E\u53D1"), h("b", null, F.money(F.num(form.values.netPay)))),
3540
- lockedGross ? h(
3541
- "div",
3542
- { className: "wbsal-lock" },
3543
- 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"),
3544
- h(C.Btn, { h, onClick: recalcFromDetail }, "\u6309\u660E\u7EC6\u91CD\u7B97")
3545
- ) : null
3546
- ),
3547
- h(C.Notice, { h, kind: msg && msg.kind, text: msg && msg.text }),
3548
- h(
3549
- "div",
3550
- { className: "wbsal-form-actions" },
3551
- h(C.Btn, { h, kind: "primary", onClick: submit, disabled: saving || moneyInvalid }, saving ? "\u4FDD\u5B58\u4E2D\u2026" : form.mode === "edit" ? "\u4FDD\u5B58\u4FEE\u6539" : "\u4FDD\u5B58"),
3552
- h(C.Btn, { h, kind: "ghost", onClick: closeForm }, "\u53D6\u6D88")
3553
- )
3554
- );
3555
- }
3556
- function renderModal() {
3557
- var label = form.mode === "edit" ? "\u7F16\u8F91\u5DE5\u8D44" : "\u8BB0\u4E00\u7B14\u5DE5\u8D44";
3558
- 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
+ });
3559
3915
  }
3560
3916
  function renderDetail(item) {
3561
3917
  var blocks = F.GROUPS.map(function(group) {
@@ -5709,7 +6065,7 @@ var GLYPHS = require_icons2().ICONS;
5709
6065
  ensureStyles();
5710
6066
  host.registerAddon({
5711
6067
  id: "wb-addon-salary",
5712
- version: "0.4.4",
6068
+ version: "0.4.6",
5713
6069
  icon: GLYPHS["wallet"],
5714
6070
  views: [
5715
6071
  { id: "stats", icon: tabIcon("stats"), title: { zh: "\u7EDF\u8BA1", en: "Stats" }, component: withProps(require_stats(), "\u7EDF\u8BA1") },
package/lib/index.js CHANGED
@@ -28,7 +28,7 @@ export function apply(ctx) {
28
28
  id: "wb-addon-salary",
29
29
  title: "工资",
30
30
  description: "按日期记录日结/月结工资:用工类型、收入项、税前扣款、社保公积金、个税与实发",
31
- version: "0.4.4",
31
+ version: "0.4.5",
32
32
  category: "finance",
33
33
  tables: ["salary_record"],
34
34
  sync: { tables: [] },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-workbench-salary",
3
- "version": "0.4.4",
3
+ "version": "0.4.6",
4
4
  "description": "个人工作台工资插件:按发薪日期记录工资构成、扣款与实发",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -16,7 +16,7 @@
16
16
  "addon": {
17
17
  "id": "wb-addon-salary",
18
18
  "title": "工资",
19
- "version": "0.4.4",
19
+ "version": "0.4.6",
20
20
  "minShell": "0.8.0",
21
21
  "tables": [
22
22
  "salary_record"
@@ -43,7 +43,7 @@
43
43
  }
44
44
  },
45
45
  "dependencies": {
46
- "dsh-workbench-host": "^0.9.1"
46
+ "dsh-workbench-host": "^0.10.0"
47
47
  },
48
48
  "dsh": {
49
49
  "bundle": {