dsh-workbench-salary 0.4.0 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/client.js +459 -108
- package/lib/domain/actions.js +2 -1
- package/lib/index.js +2 -1
- package/package.json +3 -3
package/lib/client.js
CHANGED
|
@@ -578,6 +578,204 @@ var require_date_picker_styles = __commonJS({
|
|
|
578
578
|
}
|
|
579
579
|
});
|
|
580
580
|
|
|
581
|
+
// packages/addons/lib/number-field.cjs
|
|
582
|
+
var require_number_field = __commonJS({
|
|
583
|
+
"packages/addons/lib/number-field.cjs"(exports2, module2) {
|
|
584
|
+
"use strict";
|
|
585
|
+
var React = require("react");
|
|
586
|
+
var NUM = /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)$/;
|
|
587
|
+
var TEXT = {
|
|
588
|
+
zh: {
|
|
589
|
+
required: "\u8BF7\u586B\u5199\u6570\u5B57",
|
|
590
|
+
invalid: "\u8BF7\u8F93\u5165\u6570\u5B57",
|
|
591
|
+
integer: "\u9700\u8981\u662F\u6574\u6570",
|
|
592
|
+
min: "\u4E0D\u80FD\u5C0F\u4E8E {min}",
|
|
593
|
+
max: "\u4E0D\u80FD\u5927\u4E8E {max}",
|
|
594
|
+
range: "\u9700\u8981\u5728 {min}\u2013{max} \u4E4B\u95F4",
|
|
595
|
+
step: "\u9700\u8981\u662F {step} \u7684\u500D\u6570",
|
|
596
|
+
unit: "\u5355\u4F4D"
|
|
597
|
+
},
|
|
598
|
+
en: {
|
|
599
|
+
required: "Please enter a number",
|
|
600
|
+
invalid: "Please enter a number",
|
|
601
|
+
integer: "Must be a whole number",
|
|
602
|
+
min: "Must be at least {min}",
|
|
603
|
+
max: "Must be at most {max}",
|
|
604
|
+
range: "Must be between {min} and {max}",
|
|
605
|
+
step: "Must be a multiple of {step}",
|
|
606
|
+
unit: "unit"
|
|
607
|
+
}
|
|
608
|
+
};
|
|
609
|
+
function messages(lang) {
|
|
610
|
+
return lang === "en" ? TEXT.en : TEXT.zh;
|
|
611
|
+
}
|
|
612
|
+
function fill(text, vars) {
|
|
613
|
+
return String(text).replace(/\{(\w+)\}/g, function(m, key) {
|
|
614
|
+
return vars && vars[key] !== void 0 ? String(vars[key]) : m;
|
|
615
|
+
});
|
|
616
|
+
}
|
|
617
|
+
function validateNumber(raw, opts) {
|
|
618
|
+
var o = opts || {};
|
|
619
|
+
var M = messages(o.lang);
|
|
620
|
+
var text = raw === null || raw === void 0 ? "" : String(raw).trim();
|
|
621
|
+
if (text === "") {
|
|
622
|
+
return o.allowEmpty ? { ok: true, value: null, error: "" } : { ok: false, value: null, error: M.required };
|
|
623
|
+
}
|
|
624
|
+
if (!NUM.test(text)) return { ok: false, value: null, error: M.invalid };
|
|
625
|
+
var n = Number(text);
|
|
626
|
+
if (!isFinite(n)) return { ok: false, value: null, error: M.invalid };
|
|
627
|
+
if (o.integer && Math.round(n) !== n) return { ok: false, value: null, error: M.integer };
|
|
628
|
+
var hasMin = o.min !== void 0 && o.min !== null && o.min !== "";
|
|
629
|
+
var hasMax = o.max !== void 0 && o.max !== null && o.max !== "";
|
|
630
|
+
if (hasMin && hasMax && n >= o.min && n <= o.max) {
|
|
631
|
+
} else if (hasMin && hasMax) {
|
|
632
|
+
return { ok: false, value: null, error: fill(M.range, { min: o.min, max: o.max }) };
|
|
633
|
+
} else if (hasMin && n < o.min) {
|
|
634
|
+
return { ok: false, value: null, error: fill(M.min, { min: o.min }) };
|
|
635
|
+
} else if (hasMax && n > o.max) {
|
|
636
|
+
return { ok: false, value: null, error: fill(M.max, { max: o.max }) };
|
|
637
|
+
}
|
|
638
|
+
if (o.step && Number(o.step) > 0) {
|
|
639
|
+
var q = n / Number(o.step);
|
|
640
|
+
if (Math.abs(q - Math.round(q)) > 1e-9) {
|
|
641
|
+
return { ok: false, value: null, error: fill(M.step, { step: o.step }) };
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
return { ok: true, value: n, error: "" };
|
|
645
|
+
}
|
|
646
|
+
function rangeHint(opts, lang) {
|
|
647
|
+
var o = opts || {};
|
|
648
|
+
var M = messages(lang);
|
|
649
|
+
var en = lang === "en";
|
|
650
|
+
var hasMin = o.min !== void 0 && o.min !== null && o.min !== "";
|
|
651
|
+
var hasMax = o.max !== void 0 && o.max !== null && o.max !== "";
|
|
652
|
+
var parts = [];
|
|
653
|
+
if (hasMin && hasMax) parts.push(String(o.min) + "\u2013" + String(o.max));
|
|
654
|
+
else if (hasMin) parts.push((en ? "\u2265 " : "\u2265 ") + String(o.min));
|
|
655
|
+
else if (hasMax) parts.push((en ? "\u2264 " : "\u2264 ") + String(o.max));
|
|
656
|
+
if (o.integer) parts.push(en ? "whole numbers" : "\u6574\u6570");
|
|
657
|
+
else if (o.step && Number(o.step) > 0) parts.push((en ? "step " : "\u6B65\u957F ") + String(o.step));
|
|
658
|
+
return parts.join(en ? ", " : "\uFF0C");
|
|
659
|
+
}
|
|
660
|
+
function NumberField(props) {
|
|
661
|
+
var h = props.h || React.createElement;
|
|
662
|
+
var lang = props.lang;
|
|
663
|
+
var M = messages(lang);
|
|
664
|
+
var text = props.value === null || props.value === void 0 ? "" : String(props.value);
|
|
665
|
+
var draftS = React.useState(text);
|
|
666
|
+
var draft = draftS[0];
|
|
667
|
+
var setDraft = draftS[1];
|
|
668
|
+
var focusS = React.useState(false);
|
|
669
|
+
var focused = focusS[0];
|
|
670
|
+
var setFocused = focusS[1];
|
|
671
|
+
var errS = React.useState("");
|
|
672
|
+
var err = errS[0];
|
|
673
|
+
var setErr = errS[1];
|
|
674
|
+
var lastRef = React.useRef(text);
|
|
675
|
+
var skipBlurRef = React.useRef(false);
|
|
676
|
+
React.useEffect(
|
|
677
|
+
function() {
|
|
678
|
+
if (focused) return;
|
|
679
|
+
if (lastRef.current === text) return;
|
|
680
|
+
lastRef.current = text;
|
|
681
|
+
setDraft(text);
|
|
682
|
+
setErr("");
|
|
683
|
+
},
|
|
684
|
+
[text, focused]
|
|
685
|
+
);
|
|
686
|
+
function commit(raw) {
|
|
687
|
+
var r = validateNumber(raw, props);
|
|
688
|
+
if (!r.ok) {
|
|
689
|
+
setErr(r.error);
|
|
690
|
+
if (typeof props.onValidChange === "function") props.onValidChange(false, r.error);
|
|
691
|
+
return false;
|
|
692
|
+
}
|
|
693
|
+
setErr("");
|
|
694
|
+
if (typeof props.onValidChange === "function") props.onValidChange(true, "");
|
|
695
|
+
var cur = props.value === null || props.value === void 0 ? null : Number(props.value);
|
|
696
|
+
if (r.value !== cur) {
|
|
697
|
+
lastRef.current = r.value === null ? "" : String(r.value);
|
|
698
|
+
if (typeof props.onCommit === "function") props.onCommit(r.value);
|
|
699
|
+
}
|
|
700
|
+
return true;
|
|
701
|
+
}
|
|
702
|
+
var hint = props.hint !== void 0 ? props.hint : rangeHint(props, lang);
|
|
703
|
+
var shown = props.hint === false ? "" : hint;
|
|
704
|
+
return h(
|
|
705
|
+
"span",
|
|
706
|
+
{ className: "wbctl-num" + (props.wide ? " is-wide" : "") + (props.className ? " " + props.className : "") },
|
|
707
|
+
h(
|
|
708
|
+
"span",
|
|
709
|
+
{ className: "wbctl-num-box" },
|
|
710
|
+
h("input", {
|
|
711
|
+
className: "wbctl-num-input" + (err ? " is-invalid" : ""),
|
|
712
|
+
type: "text",
|
|
713
|
+
inputMode: props.integer || Number(props.step) === 1 ? "numeric" : "decimal",
|
|
714
|
+
value: draft,
|
|
715
|
+
disabled: !!props.disabled,
|
|
716
|
+
placeholder: props.placeholder,
|
|
717
|
+
title: props.title,
|
|
718
|
+
"aria-label": props.ariaLabel,
|
|
719
|
+
"aria-invalid": err ? "true" : void 0,
|
|
720
|
+
onFocus: function() {
|
|
721
|
+
setFocused(true);
|
|
722
|
+
},
|
|
723
|
+
onChange: function(e) {
|
|
724
|
+
setDraft(e.target.value);
|
|
725
|
+
if (err) setErr("");
|
|
726
|
+
if (typeof props.onDraft === "function") props.onDraft(e.target.value);
|
|
727
|
+
},
|
|
728
|
+
onBlur: function() {
|
|
729
|
+
setFocused(false);
|
|
730
|
+
if (skipBlurRef.current) {
|
|
731
|
+
skipBlurRef.current = false;
|
|
732
|
+
return;
|
|
733
|
+
}
|
|
734
|
+
commit(draft);
|
|
735
|
+
},
|
|
736
|
+
onKeyDown: function(e) {
|
|
737
|
+
if (e.key === "Enter") {
|
|
738
|
+
e.preventDefault();
|
|
739
|
+
if (e.target && e.target.blur) e.target.blur();
|
|
740
|
+
} else if (e.key === "Escape") {
|
|
741
|
+
e.preventDefault();
|
|
742
|
+
skipBlurRef.current = true;
|
|
743
|
+
setDraft(text);
|
|
744
|
+
setErr("");
|
|
745
|
+
if (e.target && e.target.blur) e.target.blur();
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
}),
|
|
749
|
+
props.unit ? h("span", { className: "wbctl-num-unit" }, props.unit) : null
|
|
750
|
+
),
|
|
751
|
+
err ? h("span", { className: "wbctl-num-err", role: "alert" }, err) : shown ? h("span", { className: "wbctl-num-hint" }, shown) : null
|
|
752
|
+
);
|
|
753
|
+
}
|
|
754
|
+
var NUMBER_STYLES = [
|
|
755
|
+
".wbctl-num{display:inline-flex;flex-direction:column;gap:3px;min-width:0;max-width:100%}",
|
|
756
|
+
".wbctl-num.is-wide{display:flex;width:100%}",
|
|
757
|
+
".wbctl-num-box{display:inline-flex;align-items:center;gap:6px;min-width:0}",
|
|
758
|
+
".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}",
|
|
759
|
+
".wbctl-num-input:hover:not(:disabled){border-color:var(--wb-border,var(--wb-line))}",
|
|
760
|
+
".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)}",
|
|
761
|
+
".wbctl-num-input.is-invalid{border-color:var(--wb-danger,#dc2626)}",
|
|
762
|
+
".wbctl-num-input.is-invalid:focus{outline-color:color-mix(in oklab,var(--wb-danger,#dc2626) 55%,transparent)}",
|
|
763
|
+
".wbctl-num-input:disabled{opacity:.5;cursor:not-allowed}",
|
|
764
|
+
".wbctl-num-unit{color:var(--wb-muted,inherit);font-size:12px;white-space:nowrap}",
|
|
765
|
+
".wbctl-num-hint{color:var(--wb-muted,inherit);font-size:11px;line-height:1.4}",
|
|
766
|
+
".wbctl-num-err{color:var(--wb-danger,#dc2626);font-size:11px;line-height:1.4}",
|
|
767
|
+
"@media (prefers-reduced-motion:reduce){.wbctl-num-input{transition:none}}"
|
|
768
|
+
];
|
|
769
|
+
module2.exports = {
|
|
770
|
+
NumberField,
|
|
771
|
+
validateNumber,
|
|
772
|
+
rangeHint,
|
|
773
|
+
messages,
|
|
774
|
+
styles: NUMBER_STYLES
|
|
775
|
+
};
|
|
776
|
+
}
|
|
777
|
+
});
|
|
778
|
+
|
|
581
779
|
// packages/addons/salary/client/ui/styles.cjs
|
|
582
780
|
var require_styles = __commonJS({
|
|
583
781
|
"packages/addons/salary/client/ui/styles.cjs"(exports2, module2) {
|
|
@@ -811,7 +1009,63 @@ var require_styles = __commonJS({
|
|
|
811
1009
|
"@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
1010
|
];
|
|
813
1011
|
var DATE = require_date_picker_styles()("wbsal");
|
|
814
|
-
|
|
1012
|
+
var AMOUNT = [
|
|
1013
|
+
".wbsal-form-grid .wbctl-num{width:100%}",
|
|
1014
|
+
".wbsal-form-grid .wbctl-num-box{width:100%}",
|
|
1015
|
+
".wbsal-form-grid .wbctl-num-input{width:100%;box-sizing:border-box;text-align:right}"
|
|
1016
|
+
];
|
|
1017
|
+
module2.exports = BASE.concat(PAGE, [DATE], AMOUNT, require_number_field().styles).join("\n");
|
|
1018
|
+
}
|
|
1019
|
+
});
|
|
1020
|
+
|
|
1021
|
+
// packages/addons/lib/switch.cjs
|
|
1022
|
+
var require_switch = __commonJS({
|
|
1023
|
+
"packages/addons/lib/switch.cjs"(exports2, module2) {
|
|
1024
|
+
"use strict";
|
|
1025
|
+
var SWITCH_STYLES = [
|
|
1026
|
+
".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}",
|
|
1027
|
+
".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}",
|
|
1028
|
+
".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}",
|
|
1029
|
+
".wbctl-switch[aria-checked=true]{color:var(--wb-accent,#2563eb)}",
|
|
1030
|
+
".wbctl-switch[aria-checked=true] .wbctl-switch-track{background:var(--wb-accent,#2563eb)}",
|
|
1031
|
+
".wbctl-switch[aria-checked=true] .wbctl-switch-knob{transform:translateX(14px)}",
|
|
1032
|
+
".wbctl-switch:hover:not(:disabled) .wbctl-switch-track{outline:1px solid var(--wb-accent,#2563eb)}",
|
|
1033
|
+
".wbctl-switch:focus-visible{outline:2px solid var(--wb-accent,#2563eb);outline-offset:2px}",
|
|
1034
|
+
".wbctl-switch:disabled{opacity:.45;cursor:not-allowed}",
|
|
1035
|
+
".wbctl-switch-text{white-space:nowrap}",
|
|
1036
|
+
"@media (prefers-reduced-motion:reduce){.wbctl-switch-track,.wbctl-switch-knob{transition:none}}"
|
|
1037
|
+
];
|
|
1038
|
+
function Switch(props) {
|
|
1039
|
+
var h = props.h;
|
|
1040
|
+
var on = props.checked === true || props.checked === "true";
|
|
1041
|
+
var disabled = !!props.disabled;
|
|
1042
|
+
var text = props.label;
|
|
1043
|
+
if (props.showState) text = on ? props.onText || "\u5F00" : props.offText || "\u5173";
|
|
1044
|
+
return h(
|
|
1045
|
+
"button",
|
|
1046
|
+
{
|
|
1047
|
+
type: "button",
|
|
1048
|
+
role: "switch",
|
|
1049
|
+
"aria-checked": on ? "true" : "false",
|
|
1050
|
+
className: "wbctl-switch" + (props.className ? " " + props.className : ""),
|
|
1051
|
+
disabled,
|
|
1052
|
+
title: props.title,
|
|
1053
|
+
"aria-label": text ? void 0 : props.ariaLabel,
|
|
1054
|
+
onClick: function(e) {
|
|
1055
|
+
e.preventDefault();
|
|
1056
|
+
if (disabled) return;
|
|
1057
|
+
if (typeof props.onChange === "function") props.onChange(!on);
|
|
1058
|
+
}
|
|
1059
|
+
},
|
|
1060
|
+
h(
|
|
1061
|
+
"span",
|
|
1062
|
+
{ className: "wbctl-switch-track", "aria-hidden": "true" },
|
|
1063
|
+
h("span", { className: "wbctl-switch-knob" })
|
|
1064
|
+
),
|
|
1065
|
+
text ? h("span", { className: "wbctl-switch-text" }, text) : null
|
|
1066
|
+
);
|
|
1067
|
+
}
|
|
1068
|
+
module2.exports = { Switch, styles: SWITCH_STYLES };
|
|
815
1069
|
}
|
|
816
1070
|
});
|
|
817
1071
|
|
|
@@ -921,6 +1175,11 @@ var require_client_common = __commonJS({
|
|
|
921
1175
|
call,
|
|
922
1176
|
errText,
|
|
923
1177
|
fmtTime,
|
|
1178
|
+
Switch: require_switch().Switch,
|
|
1179
|
+
switchStyles: require_switch().styles,
|
|
1180
|
+
NumberField: require_number_field().NumberField,
|
|
1181
|
+
numberFieldStyles: require_number_field().styles,
|
|
1182
|
+
validateNumber: require_number_field().validateNumber,
|
|
924
1183
|
Btn,
|
|
925
1184
|
Field,
|
|
926
1185
|
Notice,
|
|
@@ -2938,6 +3197,7 @@ var require_records = __commonJS({
|
|
|
2938
3197
|
"packages/addons/salary/client/views/records.cjs"(exports2, module2) {
|
|
2939
3198
|
"use strict";
|
|
2940
3199
|
var createOverlay = require_overlay();
|
|
3200
|
+
var NF = require_number_field();
|
|
2941
3201
|
var FormOverlay = createOverlay({
|
|
2942
3202
|
maskClass: "wbsal-mask",
|
|
2943
3203
|
dialogClass: "wbsal-modal"
|
|
@@ -2966,6 +3226,9 @@ var require_records = __commonJS({
|
|
|
2966
3226
|
var msg = msgState[0], setMsg = msgState[1];
|
|
2967
3227
|
var savingState = React.useState(false);
|
|
2968
3228
|
var saving = savingState[0], setSaving = savingState[1];
|
|
3229
|
+
var badState = React.useState({});
|
|
3230
|
+
var badKeys = badState[0], setBadKeys = badState[1];
|
|
3231
|
+
var moneyInvalid = Object.keys(badKeys).length > 0;
|
|
2969
3232
|
var modalOpen = !!form;
|
|
2970
3233
|
React.useEffect(function() {
|
|
2971
3234
|
if (!modalOpen || typeof document === "undefined" || typeof document.addEventListener !== "function" || !document.body) return void 0;
|
|
@@ -2994,6 +3257,7 @@ var require_records = __commonJS({
|
|
|
2994
3257
|
setConfirmId("");
|
|
2995
3258
|
setOpenId("");
|
|
2996
3259
|
setMsg(null);
|
|
3260
|
+
setBadKeys({});
|
|
2997
3261
|
var payDate = pickDate("monthly");
|
|
2998
3262
|
setForm({ mode: "create", id: "", payDate, incomePeriod: defaultPeriod(payDate, "monthly"), cycle: "monthly", employmentType: "", note: F.defaultNote(payDate, "monthly"), values: F.blankValues(), lockGross: false });
|
|
2999
3263
|
}
|
|
@@ -3005,6 +3269,7 @@ var require_records = __commonJS({
|
|
|
3005
3269
|
var incomeZero = F.INCOME_KEYS.every(function(key) {
|
|
3006
3270
|
return !F.num(item[key]);
|
|
3007
3271
|
});
|
|
3272
|
+
setBadKeys({});
|
|
3008
3273
|
setConfirmId("");
|
|
3009
3274
|
setOpenId("");
|
|
3010
3275
|
setMsg(null);
|
|
@@ -3016,6 +3281,7 @@ var require_records = __commonJS({
|
|
|
3016
3281
|
function closeForm() {
|
|
3017
3282
|
setForm(null);
|
|
3018
3283
|
setMsg(null);
|
|
3284
|
+
setBadKeys({});
|
|
3019
3285
|
}
|
|
3020
3286
|
function setField(key, value) {
|
|
3021
3287
|
setForm(function(prev) {
|
|
@@ -3042,6 +3308,24 @@ var require_records = __commonJS({
|
|
|
3042
3308
|
return Object.assign({}, prev, { values });
|
|
3043
3309
|
});
|
|
3044
3310
|
}
|
|
3311
|
+
function markAmount(key, ok) {
|
|
3312
|
+
setBadKeys(function(prev) {
|
|
3313
|
+
var known = !!prev[key];
|
|
3314
|
+
if (known === !ok) return prev;
|
|
3315
|
+
var next = Object.assign({}, prev);
|
|
3316
|
+
if (ok) delete next[key];
|
|
3317
|
+
else next[key] = true;
|
|
3318
|
+
return next;
|
|
3319
|
+
});
|
|
3320
|
+
}
|
|
3321
|
+
function firstBadAmount() {
|
|
3322
|
+
var keys = F.KEYS;
|
|
3323
|
+
for (var i = 0; i < keys.length; i += 1) {
|
|
3324
|
+
var check = NF.validateNumber(form.values[keys[i]], amountRules(keys[i]));
|
|
3325
|
+
if (!check.ok) return { key: keys[i], error: check.error };
|
|
3326
|
+
}
|
|
3327
|
+
return null;
|
|
3328
|
+
}
|
|
3045
3329
|
function recalcFromDetail() {
|
|
3046
3330
|
setForm(function(prev) {
|
|
3047
3331
|
var computed = F.totals(prev.values);
|
|
@@ -3051,6 +3335,11 @@ var require_records = __commonJS({
|
|
|
3051
3335
|
}
|
|
3052
3336
|
function submit() {
|
|
3053
3337
|
if (!form) return;
|
|
3338
|
+
var bad = firstBadAmount();
|
|
3339
|
+
if (bad) {
|
|
3340
|
+
setMsg({ kind: "error", text: F.LABELS[bad.key] + "\uFF1A" + bad.error });
|
|
3341
|
+
return;
|
|
3342
|
+
}
|
|
3054
3343
|
var computed = F.totals(form.values);
|
|
3055
3344
|
var payload = {
|
|
3056
3345
|
payDate: form.payDate,
|
|
@@ -3106,19 +3395,29 @@ var require_records = __commonJS({
|
|
|
3106
3395
|
var currentYear = (/* @__PURE__ */ new Date()).getFullYear();
|
|
3107
3396
|
var yearOptions = ["", String(currentYear + 1), String(currentYear), String(currentYear - 1), String(currentYear - 2)];
|
|
3108
3397
|
var latest = status.data || {};
|
|
3398
|
+
function amountRules(key) {
|
|
3399
|
+
return { min: key === "performanceBonus" ? void 0 : 0, step: 0.01, allowEmpty: true, lang };
|
|
3400
|
+
}
|
|
3109
3401
|
function amountInput(key, disabled) {
|
|
3110
|
-
return h(
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3402
|
+
return h(NF.NumberField, {
|
|
3403
|
+
h,
|
|
3404
|
+
lang,
|
|
3405
|
+
wide: true,
|
|
3406
|
+
className: "wbsal-amount",
|
|
3115
3407
|
value: form.values[key],
|
|
3116
3408
|
disabled,
|
|
3117
|
-
|
|
3118
|
-
|
|
3409
|
+
hint: false,
|
|
3410
|
+
min: amountRules(key).min,
|
|
3411
|
+
step: 0.01,
|
|
3412
|
+
allowEmpty: true,
|
|
3413
|
+
ariaLabel: F.LABELS[key],
|
|
3414
|
+
onDraft: function(raw) {
|
|
3415
|
+
setValue(key, raw);
|
|
3416
|
+
markAmount(key, NF.validateNumber(raw, amountRules(key)).ok);
|
|
3119
3417
|
},
|
|
3120
|
-
|
|
3121
|
-
setValue(key,
|
|
3418
|
+
onCommit: function(next) {
|
|
3419
|
+
setValue(key, next === null ? "" : String(next));
|
|
3420
|
+
markAmount(key, true);
|
|
3122
3421
|
}
|
|
3123
3422
|
});
|
|
3124
3423
|
}
|
|
@@ -3249,7 +3548,7 @@ var require_records = __commonJS({
|
|
|
3249
3548
|
h(
|
|
3250
3549
|
"div",
|
|
3251
3550
|
{ 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"),
|
|
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"),
|
|
3253
3552
|
h(C.Btn, { h, kind: "ghost", onClick: closeForm }, "\u53D6\u6D88")
|
|
3254
3553
|
)
|
|
3255
3554
|
);
|
|
@@ -3764,13 +4063,6 @@ var require_data_style = __commonJS({
|
|
|
3764
4063
|
"." + 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
4064
|
"." + 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
4065
|
"." + 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
4066
|
"." + 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
4067
|
"." + P + "-btn:hover{background:var(--cfg-hover);color:var(--dsw-alias-label-primary,inherit)}",
|
|
3776
4068
|
"." + P + "-btn:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,currentColor);outline-offset:2px}",
|
|
@@ -3799,8 +4091,8 @@ var require_data_style = __commonJS({
|
|
|
3799
4091
|
"." + P + "-foot{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding-top:2px;font-size:11.5px;color:var(--cfg-muted)}",
|
|
3800
4092
|
"." + P + "-grow{flex:1}",
|
|
3801
4093
|
"." + P + "-pageinfo{font-variant-numeric:tabular-nums}",
|
|
3802
|
-
"." + P + "-jump{width:56px;
|
|
3803
|
-
"." + P + "-jump
|
|
4094
|
+
"." + P + "-jump .wbctl-num-input{width:56px;padding:4px 7px;font-size:11.5px;text-align:right}",
|
|
4095
|
+
"." + P + "-jump .wbctl-num-hint{display:none}",
|
|
3804
4096
|
"." + 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
4097
|
"." + 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
4098
|
"." + P + "-skwrap{display:flex;flex-direction:column;gap:1px;padding:2px}",
|
|
@@ -3838,7 +4130,7 @@ var require_data_style = __commonJS({
|
|
|
3838
4130
|
"." + P + "-images img{width:36px;height:36px;object-fit:cover;border-radius:5px}",
|
|
3839
4131
|
"." + P + "-gallery{display:flex;flex-direction:column;gap:12px;overflow:auto;flex:1}",
|
|
3840
4132
|
"." + P + "-gallery img{width:100%;height:auto;object-fit:contain;border-radius:8px}"
|
|
3841
|
-
].join("\n");
|
|
4133
|
+
].concat(require_switch().styles).concat(require_number_field().styles).join("\n");
|
|
3842
4134
|
if (DOMAIN === "storage") {
|
|
3843
4135
|
var buttons = "." + P + " :is(button)";
|
|
3844
4136
|
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 +4158,10 @@ var require_data_view = __commonJS({
|
|
|
3866
4158
|
"packages/addons/lib/data-view.cjs"(exports2, module2) {
|
|
3867
4159
|
"use strict";
|
|
3868
4160
|
var React = require("react");
|
|
4161
|
+
var NF = require_number_field();
|
|
3869
4162
|
var h = React.createElement;
|
|
3870
4163
|
var COPY = require_data_copy();
|
|
4164
|
+
var SW = require_switch();
|
|
3871
4165
|
module2.exports = function createDataView(options) {
|
|
3872
4166
|
var DOMAIN = options.domain;
|
|
3873
4167
|
function icon(name) {
|
|
@@ -4421,17 +4715,18 @@ var require_data_view = __commonJS({
|
|
|
4421
4715
|
h("button", { type: "button", className: P + "-btn", disabled: !data || page >= pages, onClick: function() {
|
|
4422
4716
|
setPage(Math.min(pages, page + 1));
|
|
4423
4717
|
} }, t.next + " \u203A"),
|
|
4424
|
-
h(
|
|
4718
|
+
h(NF.NumberField, {
|
|
4719
|
+
h,
|
|
4720
|
+
lang,
|
|
4425
4721
|
className: P + "-jump",
|
|
4426
|
-
|
|
4722
|
+
value: page,
|
|
4427
4723
|
min: 1,
|
|
4428
4724
|
max: pages,
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
}
|
|
4725
|
+
integer: true,
|
|
4726
|
+
ariaLabel: t.jump,
|
|
4727
|
+
hint: false,
|
|
4728
|
+
onCommit: function(next) {
|
|
4729
|
+
if (next !== null) setPage(next);
|
|
4435
4730
|
}
|
|
4436
4731
|
}),
|
|
4437
4732
|
data && data.queryMs !== void 0 ? h("span", null, fmt(t.queryTime, { n: data.queryMs })) : null
|
|
@@ -4528,25 +4823,23 @@ var require_data_view = __commonJS({
|
|
|
4528
4823
|
}
|
|
4529
4824
|
})
|
|
4530
4825
|
),
|
|
4531
|
-
h(
|
|
4532
|
-
|
|
4533
|
-
|
|
4534
|
-
|
|
4535
|
-
|
|
4826
|
+
h(SW.Switch, {
|
|
4827
|
+
h,
|
|
4828
|
+
checked: includeDeleted,
|
|
4829
|
+
label: t.includeDeleted,
|
|
4830
|
+
onChange: function(next) {
|
|
4831
|
+
setIncludeDeleted(next);
|
|
4536
4832
|
setPage(1);
|
|
4537
|
-
}
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
h("span", { className: P + "-track" }),
|
|
4548
|
-
h("span", null, t.showSystem)
|
|
4549
|
-
),
|
|
4833
|
+
}
|
|
4834
|
+
}),
|
|
4835
|
+
h(SW.Switch, {
|
|
4836
|
+
h,
|
|
4837
|
+
checked: showSystem,
|
|
4838
|
+
label: t.showSystem,
|
|
4839
|
+
onChange: function(next) {
|
|
4840
|
+
setShowSystem(next);
|
|
4841
|
+
}
|
|
4842
|
+
}),
|
|
4550
4843
|
h("span", { className: P + "-grow" }),
|
|
4551
4844
|
h(
|
|
4552
4845
|
"label",
|
|
@@ -4704,16 +4997,13 @@ var require_action_schema_style = __commonJS({
|
|
|
4704
4997
|
"." + P + "-cardmeta{display:flex;align-items:center;flex-wrap:wrap;gap:8px;min-width:0;min-height:24px}",
|
|
4705
4998
|
"." + P + "-cardhead code{font-weight:640;overflow-wrap:anywhere;min-width:0}",
|
|
4706
4999
|
"." + P + "-hintline{margin:0;color:var(--dsw-alias-label-tertiary,inherit);font-size:11.5px;line-height:1.5}",
|
|
4707
|
-
"." + P + "-
|
|
4708
|
-
"." + P + "-
|
|
4709
|
-
"." + P + "-
|
|
4710
|
-
|
|
4711
|
-
"." + P + "-
|
|
4712
|
-
"." + P + "-
|
|
4713
|
-
"." + P + "-
|
|
4714
|
-
"." + P + "-toggle:disabled{opacity:.6;cursor:progress}",
|
|
4715
|
-
"@media(prefers-reduced-motion:reduce){." + P + "-track::before{transition:none}}",
|
|
4716
|
-
// 安全约束(不可放开):用警示色描边,和可切换的开关区分开。
|
|
5000
|
+
"." + P + "-origins{display:inline-flex;align-items:center;gap:10px;flex-wrap:wrap;justify-content:flex-end}",
|
|
5001
|
+
"." + P + "-origins-label{font-size:11px;color:var(--wb-muted);white-space:nowrap}",
|
|
5002
|
+
"." + P + "-origin{display:inline-flex;align-items:center;gap:4px;font-size:11.5px;color:var(--wb-muted);cursor:pointer;user-select:none}",
|
|
5003
|
+
// 该 action 本身不支持的来源:整项置灰、不可点,示意「不是没开,是开不了」。
|
|
5004
|
+
"." + P + "-origin-off{opacity:.55;cursor:not-allowed}",
|
|
5005
|
+
"." + P + "-origin input[type=checkbox]{width:13px;height:13px;margin:0;accent-color:var(--wb-accent);cursor:inherit}",
|
|
5006
|
+
"." + P + "-origin input[type=checkbox]:focus-visible{outline:2px solid var(--wb-accent);outline-offset:2px}",
|
|
4717
5007
|
"." + P + "-locked{border-color:var(--wb-warn,#b7791f);color:var(--wb-warn,#b7791f)}",
|
|
4718
5008
|
"." + P + "-desc{margin:0;color:var(--dsw-alias-label-secondary,inherit);line-height:1.55;font-size:12.5px}",
|
|
4719
5009
|
// 搜索命中:用品牌色透明度叠加而不是写死浅色,深浅主题都可读;继承文字颜色、不覆盖 ::selection。
|
|
@@ -4766,15 +5056,20 @@ var require_action_schema_view = __commonJS({
|
|
|
4766
5056
|
zh: {
|
|
4767
5057
|
title: "Action",
|
|
4768
5058
|
hint: "\u8FD0\u884C\u65F6\u6CE8\u518C \xB7 \u53EA\u8BFB",
|
|
4769
|
-
switchHint: "
|
|
4770
|
-
hostHint: "\u5BBF\u4E3B action \u7684
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
5059
|
+
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",
|
|
5060
|
+
hostHint: "\u5BBF\u4E3B action \u7684\u5141\u8BB8\u6765\u6E90\uFF1B\u6807\u300C\u6765\u6E90\u56FA\u5B9A\u300D\u7684\u4E0D\u53EF\u4FEE\u6539\u3002",
|
|
5061
|
+
originsLabel: "\u5141\u8BB8\u6765\u6E90",
|
|
5062
|
+
originUi: "\u754C\u9762",
|
|
5063
|
+
originPlugin: "\u63D2\u4EF6",
|
|
5064
|
+
originAgent: "agent",
|
|
5065
|
+
originSync: "\u540C\u6B65",
|
|
5066
|
+
originsSaving: "\u4FDD\u5B58\u4E2D\u2026",
|
|
5067
|
+
originsToast: "\u5DF2\u66F4\u65B0\u5141\u8BB8\u6765\u6E90",
|
|
5068
|
+
originsFail: "\u66F4\u65B0\u5141\u8BB8\u6765\u6E90\u5931\u8D25",
|
|
5069
|
+
originsEmpty: "\u81F3\u5C11\u8981\u4FDD\u7559\u4E00\u4E2A\u6765\u6E90",
|
|
5070
|
+
originsUnsupported: "\u8BE5 action \u672C\u8EAB\u4E0D\u652F\u6301\u8FD9\u4E2A\u6765\u6E90",
|
|
5071
|
+
originsPinned: "\u6765\u6E90\u56FA\u5B9A",
|
|
5072
|
+
originsPinnedHint: "\u8BE5 action \u7684\u5141\u8BB8\u6765\u6E90\u88AB\u56FA\u5B9A\uFF08\u5B89\u5168\u7EA6\u675F\uFF09\uFF0C\u4E0D\u80FD\u4FEE\u6539",
|
|
4778
5073
|
domain: "\u57DF",
|
|
4779
5074
|
versionLabel: "\u7248\u672C",
|
|
4780
5075
|
shell: "\u5BBF\u4E3B",
|
|
@@ -4788,6 +5083,8 @@ var require_action_schema_view = __commonJS({
|
|
|
4788
5083
|
onlyOptional: "\u65E0\u5FC5\u586B\u9879",
|
|
4789
5084
|
filterType: "\u53C2\u6570\u7C7B\u578B",
|
|
4790
5085
|
allTypes: "\u5168\u90E8\u7C7B\u578B",
|
|
5086
|
+
filterOrigin: "\u5141\u8BB8\u6765\u6E90",
|
|
5087
|
+
allOrigins: "\u5168\u90E8\u6765\u6E90",
|
|
4791
5088
|
colName: "\u53C2\u6570",
|
|
4792
5089
|
colType: "\u7C7B\u578B",
|
|
4793
5090
|
colReq: "\u5FC5\u586B",
|
|
@@ -4820,15 +5117,22 @@ var require_action_schema_view = __commonJS({
|
|
|
4820
5117
|
en: {
|
|
4821
5118
|
title: "Actions",
|
|
4822
5119
|
hint: "runtime registry \xB7 read-only",
|
|
4823
|
-
switchHint: "
|
|
4824
|
-
hostHint: "
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
|
|
5120
|
+
switchHint: "Allowed origins are stored locally and apply immediately: only checked origins may call the action; others get ACTION_ORIGIN_DENIED.",
|
|
5121
|
+
hostHint: "Allowed origins for host actions; items marked pinned cannot be changed.",
|
|
5122
|
+
originsLabel: "Origins",
|
|
5123
|
+
originUi: "UI",
|
|
5124
|
+
originPlugin: "Plugin",
|
|
5125
|
+
originAgent: "Agent",
|
|
5126
|
+
originSync: "Sync",
|
|
5127
|
+
originsSaving: "Saving\u2026",
|
|
5128
|
+
originsToast: "Allowed origins updated",
|
|
5129
|
+
originsFail: "Failed to update allowed origins",
|
|
5130
|
+
originsEmpty: "Keep at least one origin",
|
|
5131
|
+
originsUnsupported: "This action does not support this origin",
|
|
5132
|
+
originsPinned: "Pinned",
|
|
5133
|
+
originsPinnedHint: "Allowed origins are pinned for this action (security constraint) and cannot be changed",
|
|
5134
|
+
originsDefaultOn: "Allowed by default",
|
|
5135
|
+
originsDefaultOff: "Off by default, can be enabled",
|
|
4832
5136
|
domain: "Domain",
|
|
4833
5137
|
versionLabel: "Version",
|
|
4834
5138
|
shell: "Host",
|
|
@@ -4842,6 +5146,8 @@ var require_action_schema_view = __commonJS({
|
|
|
4842
5146
|
onlyOptional: "No required",
|
|
4843
5147
|
filterType: "Param type",
|
|
4844
5148
|
allTypes: "All types",
|
|
5149
|
+
filterOrigin: "Origins",
|
|
5150
|
+
allOrigins: "All origins",
|
|
4845
5151
|
colName: "Param",
|
|
4846
5152
|
colType: "Type",
|
|
4847
5153
|
colReq: "Required",
|
|
@@ -4985,6 +5291,8 @@ var require_action_schema_view = __commonJS({
|
|
|
4985
5291
|
var reqMode = reqState[0], setReqMode = reqState[1];
|
|
4986
5292
|
var typeState = React.useState("");
|
|
4987
5293
|
var typePick = typeState[0], setTypePick = typeState[1];
|
|
5294
|
+
var originFilterState = React.useState("");
|
|
5295
|
+
var originPick = originFilterState[0], setOriginPick = originFilterState[1];
|
|
4988
5296
|
var toastState = React.useState("");
|
|
4989
5297
|
var toast = toastState[0], setToast = toastState[1];
|
|
4990
5298
|
var savingState = React.useState("");
|
|
@@ -5040,38 +5348,53 @@ var require_action_schema_view = __commonJS({
|
|
|
5040
5348
|
plainCopy(text);
|
|
5041
5349
|
done();
|
|
5042
5350
|
}
|
|
5043
|
-
|
|
5351
|
+
var ORIGINS = ["ui", "plugin", "agent", "sync"];
|
|
5352
|
+
var originText = { ui: t.originUi, plugin: t.originPlugin, agent: t.originAgent, sync: t.originSync };
|
|
5353
|
+
function setOrigins(action, origin) {
|
|
5044
5354
|
var name = action.name;
|
|
5355
|
+
var current = Array.isArray(action.origins) ? action.origins.slice() : [];
|
|
5356
|
+
var index = current.indexOf(origin);
|
|
5357
|
+
var next = index >= 0 ? current.filter(function(o) {
|
|
5358
|
+
return o !== origin;
|
|
5359
|
+
}) : current.concat([origin]);
|
|
5360
|
+
if (next.length === 0) {
|
|
5361
|
+
setToast(t.originsEmpty);
|
|
5362
|
+
return;
|
|
5363
|
+
}
|
|
5364
|
+
next = ORIGINS.filter(function(o) {
|
|
5365
|
+
return next.indexOf(o) >= 0;
|
|
5366
|
+
});
|
|
5045
5367
|
setSaving(name);
|
|
5046
5368
|
setToast("");
|
|
5047
5369
|
var fail = function(e) {
|
|
5048
5370
|
setSaving("");
|
|
5049
|
-
setToast(t.
|
|
5371
|
+
setToast(t.originsFail + "\uFF1A" + String(e && e.message || e || ""));
|
|
5050
5372
|
};
|
|
5051
5373
|
var done = function(r) {
|
|
5052
5374
|
setSaving("");
|
|
5053
5375
|
var payload = r && typeof r === "object" && Object.prototype.hasOwnProperty.call(r, "result") ? r.result : r;
|
|
5054
5376
|
if (r && r.ok === false) {
|
|
5055
|
-
setToast(t.
|
|
5377
|
+
setToast(t.originsFail + "\uFF1A" + String(r.error || r.text || ""));
|
|
5056
5378
|
return;
|
|
5057
5379
|
}
|
|
5058
|
-
var value = payload &&
|
|
5380
|
+
var value = payload && Array.isArray(payload.origins) ? payload.origins : next;
|
|
5381
|
+
var source = payload && typeof payload.source === "string" ? payload.source : action.originsSource;
|
|
5059
5382
|
setSnap(function(prev) {
|
|
5060
5383
|
if (!prev || !Array.isArray(prev.actions)) return prev;
|
|
5061
5384
|
return Object.assign({}, prev, {
|
|
5062
5385
|
actions: prev.actions.map(function(a) {
|
|
5063
5386
|
if (!a || a.name !== name) return a;
|
|
5064
|
-
return Object.assign({}, a, {
|
|
5387
|
+
return Object.assign({}, a, { origins: value, originsSource: source });
|
|
5065
5388
|
})
|
|
5066
5389
|
});
|
|
5067
5390
|
});
|
|
5068
|
-
setToast(
|
|
5391
|
+
setToast(t.originsToast);
|
|
5069
5392
|
};
|
|
5070
5393
|
if (!api || typeof api.call !== "function") {
|
|
5071
5394
|
fail(new Error("no call api"));
|
|
5072
5395
|
return;
|
|
5073
5396
|
}
|
|
5074
|
-
Promise.resolve(api.call("actions.
|
|
5397
|
+
Promise.resolve(api.call("actions.setActionOrigins", { action: name, origins: next })).then(done, fail);
|
|
5075
5398
|
}
|
|
5076
5399
|
var all = snap && Array.isArray(snap.actions) ? snap.actions.filter(function(a) {
|
|
5077
5400
|
return a && a.domain === DOMAIN;
|
|
@@ -5106,6 +5429,7 @@ var require_action_schema_view = __commonJS({
|
|
|
5106
5429
|
if (typePick && !rows.some(function(row) {
|
|
5107
5430
|
return row.types.indexOf(typePick) >= 0;
|
|
5108
5431
|
})) return false;
|
|
5432
|
+
if (originPick && (!Array.isArray(a.origins) || a.origins.indexOf(originPick) < 0)) return false;
|
|
5109
5433
|
return true;
|
|
5110
5434
|
});
|
|
5111
5435
|
function paramRow(row) {
|
|
@@ -5121,33 +5445,45 @@ var require_action_schema_view = __commonJS({
|
|
|
5121
5445
|
h("td", null, Highlight.hit(row.description, kw))
|
|
5122
5446
|
);
|
|
5123
5447
|
}
|
|
5124
|
-
function
|
|
5125
|
-
if (action.
|
|
5126
|
-
|
|
5127
|
-
|
|
5128
|
-
title: t.agentLockedHint,
|
|
5129
|
-
"data-agent-locked": action.name
|
|
5130
|
-
}, t.agentLocked);
|
|
5448
|
+
function originsChips(action) {
|
|
5449
|
+
if (!Array.isArray(action.origins)) return null;
|
|
5450
|
+
if (action.originsSource === "invalid") {
|
|
5451
|
+
return h("span", { className: P + "-badge " + P + "-locked", title: t.originsPinnedHint, "data-origins-invalid": action.name }, t.originsPinned);
|
|
5131
5452
|
}
|
|
5132
|
-
if (typeof action.agentEnabled !== "boolean") return null;
|
|
5133
5453
|
var busy = saving === action.name;
|
|
5454
|
+
var pinned = action.name === "actions.setActionOrigins";
|
|
5455
|
+
var supported = Array.isArray(action.originsDeclared) ? action.originsDeclared : action.origins;
|
|
5134
5456
|
return h(
|
|
5135
|
-
"
|
|
5136
|
-
{
|
|
5137
|
-
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
|
|
5144
|
-
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
|
|
5149
|
-
|
|
5150
|
-
|
|
5457
|
+
"div",
|
|
5458
|
+
{ className: P + "-origins", "data-origins-row": action.name },
|
|
5459
|
+
h("span", { className: P + "-origins-label" }, t.originsLabel),
|
|
5460
|
+
ORIGINS.map(function(origin) {
|
|
5461
|
+
var on = action.origins.indexOf(origin) >= 0;
|
|
5462
|
+
var allowed = supported.indexOf(origin) >= 0;
|
|
5463
|
+
var preset = Array.isArray(action.originsDefault) ? action.originsDefault : supported;
|
|
5464
|
+
var byDefault = preset.indexOf(origin) >= 0;
|
|
5465
|
+
return h(
|
|
5466
|
+
"label",
|
|
5467
|
+
{
|
|
5468
|
+
key: origin,
|
|
5469
|
+
className: P + "-origin" + (allowed ? "" : " " + P + "-origin-off"),
|
|
5470
|
+
title: pinned ? t.originsPinnedHint : !allowed ? t.originsUnsupported : originText[origin] + " \xB7 " + action.name + " \xB7 " + (byDefault ? t.originsDefaultOn : t.originsDefaultOff)
|
|
5471
|
+
},
|
|
5472
|
+
h("input", {
|
|
5473
|
+
type: "checkbox",
|
|
5474
|
+
checked: on,
|
|
5475
|
+
disabled: busy || pinned || !allowed,
|
|
5476
|
+
"data-origin": origin,
|
|
5477
|
+
"data-origin-row": action.name,
|
|
5478
|
+
"data-origin-supported": allowed ? "1" : "0",
|
|
5479
|
+
onChange: function() {
|
|
5480
|
+
setOrigins(action, origin);
|
|
5481
|
+
}
|
|
5482
|
+
}),
|
|
5483
|
+
h("span", null, originText[origin])
|
|
5484
|
+
);
|
|
5485
|
+
}),
|
|
5486
|
+
busy ? h("span", { className: P + "-origins-label" }, t.originsSaving) : null
|
|
5151
5487
|
);
|
|
5152
5488
|
}
|
|
5153
5489
|
function card(action) {
|
|
@@ -5168,7 +5504,7 @@ var require_action_schema_view = __commonJS({
|
|
|
5168
5504
|
return row.required;
|
|
5169
5505
|
}) ? h("span", { className: P + "-badge " + P + "-req" }, t.required) : null
|
|
5170
5506
|
),
|
|
5171
|
-
|
|
5507
|
+
originsChips(action)
|
|
5172
5508
|
),
|
|
5173
5509
|
action.description ? h("p", { className: P + "-desc" }, Highlight.hit(action.description, kw)) : null,
|
|
5174
5510
|
rows.length ? h(
|
|
@@ -5291,6 +5627,21 @@ var require_action_schema_view = __commonJS({
|
|
|
5291
5627
|
return h("option", { value: name, key: name }, name);
|
|
5292
5628
|
})
|
|
5293
5629
|
)
|
|
5630
|
+
),
|
|
5631
|
+
h(
|
|
5632
|
+
"label",
|
|
5633
|
+
{ className: P + "-none" },
|
|
5634
|
+
t.filterOrigin + " ",
|
|
5635
|
+
h(
|
|
5636
|
+
"select",
|
|
5637
|
+
{ value: originPick, "aria-label": t.filterOrigin, "data-origin-filter": "", onChange: function(e) {
|
|
5638
|
+
setOriginPick(e.target.value);
|
|
5639
|
+
} },
|
|
5640
|
+
h("option", { value: "" }, t.allOrigins),
|
|
5641
|
+
ORIGINS.map(function(origin) {
|
|
5642
|
+
return h("option", { value: origin, key: origin }, originText[origin]);
|
|
5643
|
+
})
|
|
5644
|
+
)
|
|
5294
5645
|
)
|
|
5295
5646
|
) : null,
|
|
5296
5647
|
body,
|
|
@@ -5358,7 +5709,7 @@ var GLYPHS = require_icons2().ICONS;
|
|
|
5358
5709
|
ensureStyles();
|
|
5359
5710
|
host.registerAddon({
|
|
5360
5711
|
id: "wb-addon-salary",
|
|
5361
|
-
version: "0.4.
|
|
5712
|
+
version: "0.4.4",
|
|
5362
5713
|
icon: GLYPHS["wallet"],
|
|
5363
5714
|
views: [
|
|
5364
5715
|
{ id: "stats", icon: tabIcon("stats"), title: { zh: "\u7EDF\u8BA1", en: "Stats" }, component: withProps(require_stats(), "\u7EDF\u8BA1") },
|
package/lib/domain/actions.js
CHANGED
|
@@ -121,7 +121,8 @@ export function registerSalaryActions(api, salary) {
|
|
|
121
121
|
}),
|
|
122
122
|
});
|
|
123
123
|
action("salary.dataQuery", {
|
|
124
|
-
|
|
124
|
+
origins: ["ui", "agent"],
|
|
125
|
+
originsDefault: ["ui"],
|
|
125
126
|
description: "只读:白名单表查询(仅 UI;limit ≤ 100)",
|
|
126
127
|
input: obj({ table: { type: "string", enum: ["salary_record"] }, limit: num("1–100,默认 20") }, ["table"]),
|
|
127
128
|
execute: (args, ctx) => {
|
package/lib/index.js
CHANGED
|
@@ -28,7 +28,8 @@ export function apply(ctx) {
|
|
|
28
28
|
id: "wb-addon-salary",
|
|
29
29
|
title: "工资",
|
|
30
30
|
description: "按日期记录日结/月结工资:用工类型、收入项、税前扣款、社保公积金、个税与实发",
|
|
31
|
-
version: "0.4.
|
|
31
|
+
version: "0.4.4",
|
|
32
|
+
category: "finance",
|
|
32
33
|
tables: ["salary_record"],
|
|
33
34
|
sync: { tables: [] },
|
|
34
35
|
views: VIEWS,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-workbench-salary",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
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.
|
|
19
|
+
"version": "0.4.4",
|
|
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.
|
|
46
|
+
"dsh-workbench-host": "^0.9.1"
|
|
47
47
|
},
|
|
48
48
|
"dsh": {
|
|
49
49
|
"bundle": {
|