dsh-workbench-sites 1.12.6 → 1.12.9
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 +421 -161
- package/lib/index.js +2 -1
- package/package.json +3 -3
package/lib/client.js
CHANGED
|
@@ -2860,11 +2860,262 @@ var require_charts = __commonJS({
|
|
|
2860
2860
|
}
|
|
2861
2861
|
});
|
|
2862
2862
|
|
|
2863
|
+
// packages/addons/lib/switch.cjs
|
|
2864
|
+
var require_switch = __commonJS({
|
|
2865
|
+
"packages/addons/lib/switch.cjs"(exports2, module2) {
|
|
2866
|
+
"use strict";
|
|
2867
|
+
var SWITCH_STYLES = [
|
|
2868
|
+
".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}",
|
|
2869
|
+
".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}",
|
|
2870
|
+
".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}",
|
|
2871
|
+
".wbctl-switch[aria-checked=true]{color:var(--wb-accent,#2563eb)}",
|
|
2872
|
+
".wbctl-switch[aria-checked=true] .wbctl-switch-track{background:var(--wb-accent,#2563eb)}",
|
|
2873
|
+
".wbctl-switch[aria-checked=true] .wbctl-switch-knob{transform:translateX(14px)}",
|
|
2874
|
+
".wbctl-switch:hover:not(:disabled) .wbctl-switch-track{outline:1px solid var(--wb-accent,#2563eb)}",
|
|
2875
|
+
".wbctl-switch:focus-visible{outline:2px solid var(--wb-accent,#2563eb);outline-offset:2px}",
|
|
2876
|
+
".wbctl-switch:disabled{opacity:.45;cursor:not-allowed}",
|
|
2877
|
+
".wbctl-switch-text{white-space:nowrap}",
|
|
2878
|
+
"@media (prefers-reduced-motion:reduce){.wbctl-switch-track,.wbctl-switch-knob{transition:none}}"
|
|
2879
|
+
];
|
|
2880
|
+
function Switch(props) {
|
|
2881
|
+
var h2 = props.h;
|
|
2882
|
+
var on = props.checked === true || props.checked === "true";
|
|
2883
|
+
var disabled = !!props.disabled;
|
|
2884
|
+
var text = props.label;
|
|
2885
|
+
if (props.showState) text = on ? props.onText || "\u5F00" : props.offText || "\u5173";
|
|
2886
|
+
return h2(
|
|
2887
|
+
"button",
|
|
2888
|
+
{
|
|
2889
|
+
type: "button",
|
|
2890
|
+
role: "switch",
|
|
2891
|
+
"aria-checked": on ? "true" : "false",
|
|
2892
|
+
className: "wbctl-switch" + (props.className ? " " + props.className : ""),
|
|
2893
|
+
disabled,
|
|
2894
|
+
title: props.title,
|
|
2895
|
+
"aria-label": text ? void 0 : props.ariaLabel,
|
|
2896
|
+
onClick: function(e) {
|
|
2897
|
+
e.preventDefault();
|
|
2898
|
+
if (disabled) return;
|
|
2899
|
+
if (typeof props.onChange === "function") props.onChange(!on);
|
|
2900
|
+
}
|
|
2901
|
+
},
|
|
2902
|
+
h2(
|
|
2903
|
+
"span",
|
|
2904
|
+
{ className: "wbctl-switch-track", "aria-hidden": "true" },
|
|
2905
|
+
h2("span", { className: "wbctl-switch-knob" })
|
|
2906
|
+
),
|
|
2907
|
+
text ? h2("span", { className: "wbctl-switch-text" }, text) : null
|
|
2908
|
+
);
|
|
2909
|
+
}
|
|
2910
|
+
module2.exports = { Switch, styles: SWITCH_STYLES };
|
|
2911
|
+
}
|
|
2912
|
+
});
|
|
2913
|
+
|
|
2914
|
+
// packages/addons/lib/number-field.cjs
|
|
2915
|
+
var require_number_field = __commonJS({
|
|
2916
|
+
"packages/addons/lib/number-field.cjs"(exports2, module2) {
|
|
2917
|
+
"use strict";
|
|
2918
|
+
var React2 = require("react");
|
|
2919
|
+
var NUM = /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)$/;
|
|
2920
|
+
var TEXT = {
|
|
2921
|
+
zh: {
|
|
2922
|
+
required: "\u8BF7\u586B\u5199\u6570\u5B57",
|
|
2923
|
+
invalid: "\u8BF7\u8F93\u5165\u6570\u5B57",
|
|
2924
|
+
integer: "\u9700\u8981\u662F\u6574\u6570",
|
|
2925
|
+
min: "\u4E0D\u80FD\u5C0F\u4E8E {min}",
|
|
2926
|
+
max: "\u4E0D\u80FD\u5927\u4E8E {max}",
|
|
2927
|
+
range: "\u9700\u8981\u5728 {min}\u2013{max} \u4E4B\u95F4",
|
|
2928
|
+
step: "\u9700\u8981\u662F {step} \u7684\u500D\u6570",
|
|
2929
|
+
unit: "\u5355\u4F4D"
|
|
2930
|
+
},
|
|
2931
|
+
en: {
|
|
2932
|
+
required: "Please enter a number",
|
|
2933
|
+
invalid: "Please enter a number",
|
|
2934
|
+
integer: "Must be a whole number",
|
|
2935
|
+
min: "Must be at least {min}",
|
|
2936
|
+
max: "Must be at most {max}",
|
|
2937
|
+
range: "Must be between {min} and {max}",
|
|
2938
|
+
step: "Must be a multiple of {step}",
|
|
2939
|
+
unit: "unit"
|
|
2940
|
+
}
|
|
2941
|
+
};
|
|
2942
|
+
function messages(lang) {
|
|
2943
|
+
return lang === "en" ? TEXT.en : TEXT.zh;
|
|
2944
|
+
}
|
|
2945
|
+
function fill(text, vars) {
|
|
2946
|
+
return String(text).replace(/\{(\w+)\}/g, function(m, key) {
|
|
2947
|
+
return vars && vars[key] !== void 0 ? String(vars[key]) : m;
|
|
2948
|
+
});
|
|
2949
|
+
}
|
|
2950
|
+
function validateNumber(raw, opts) {
|
|
2951
|
+
var o = opts || {};
|
|
2952
|
+
var M = messages(o.lang);
|
|
2953
|
+
var text = raw === null || raw === void 0 ? "" : String(raw).trim();
|
|
2954
|
+
if (text === "") {
|
|
2955
|
+
return o.allowEmpty ? { ok: true, value: null, error: "" } : { ok: false, value: null, error: M.required };
|
|
2956
|
+
}
|
|
2957
|
+
if (!NUM.test(text)) return { ok: false, value: null, error: M.invalid };
|
|
2958
|
+
var n = Number(text);
|
|
2959
|
+
if (!isFinite(n)) return { ok: false, value: null, error: M.invalid };
|
|
2960
|
+
if (o.integer && Math.round(n) !== n) return { ok: false, value: null, error: M.integer };
|
|
2961
|
+
var hasMin = o.min !== void 0 && o.min !== null && o.min !== "";
|
|
2962
|
+
var hasMax = o.max !== void 0 && o.max !== null && o.max !== "";
|
|
2963
|
+
if (hasMin && hasMax && n >= o.min && n <= o.max) {
|
|
2964
|
+
} else if (hasMin && hasMax) {
|
|
2965
|
+
return { ok: false, value: null, error: fill(M.range, { min: o.min, max: o.max }) };
|
|
2966
|
+
} else if (hasMin && n < o.min) {
|
|
2967
|
+
return { ok: false, value: null, error: fill(M.min, { min: o.min }) };
|
|
2968
|
+
} else if (hasMax && n > o.max) {
|
|
2969
|
+
return { ok: false, value: null, error: fill(M.max, { max: o.max }) };
|
|
2970
|
+
}
|
|
2971
|
+
if (o.step && Number(o.step) > 0) {
|
|
2972
|
+
var q = n / Number(o.step);
|
|
2973
|
+
if (Math.abs(q - Math.round(q)) > 1e-9) {
|
|
2974
|
+
return { ok: false, value: null, error: fill(M.step, { step: o.step }) };
|
|
2975
|
+
}
|
|
2976
|
+
}
|
|
2977
|
+
return { ok: true, value: n, error: "" };
|
|
2978
|
+
}
|
|
2979
|
+
function rangeHint(opts, lang) {
|
|
2980
|
+
var o = opts || {};
|
|
2981
|
+
var M = messages(lang);
|
|
2982
|
+
var en = lang === "en";
|
|
2983
|
+
var hasMin = o.min !== void 0 && o.min !== null && o.min !== "";
|
|
2984
|
+
var hasMax = o.max !== void 0 && o.max !== null && o.max !== "";
|
|
2985
|
+
var parts = [];
|
|
2986
|
+
if (hasMin && hasMax) parts.push(String(o.min) + "\u2013" + String(o.max));
|
|
2987
|
+
else if (hasMin) parts.push((en ? "\u2265 " : "\u2265 ") + String(o.min));
|
|
2988
|
+
else if (hasMax) parts.push((en ? "\u2264 " : "\u2264 ") + String(o.max));
|
|
2989
|
+
if (o.integer) parts.push(en ? "whole numbers" : "\u6574\u6570");
|
|
2990
|
+
else if (o.step && Number(o.step) > 0) parts.push((en ? "step " : "\u6B65\u957F ") + String(o.step));
|
|
2991
|
+
return parts.join(en ? ", " : "\uFF0C");
|
|
2992
|
+
}
|
|
2993
|
+
function NumberField(props) {
|
|
2994
|
+
var h2 = props.h || React2.createElement;
|
|
2995
|
+
var lang = props.lang;
|
|
2996
|
+
var M = messages(lang);
|
|
2997
|
+
var text = props.value === null || props.value === void 0 ? "" : String(props.value);
|
|
2998
|
+
var draftS = React2.useState(text);
|
|
2999
|
+
var draft = draftS[0];
|
|
3000
|
+
var setDraft = draftS[1];
|
|
3001
|
+
var focusS = React2.useState(false);
|
|
3002
|
+
var focused = focusS[0];
|
|
3003
|
+
var setFocused = focusS[1];
|
|
3004
|
+
var errS = React2.useState("");
|
|
3005
|
+
var err = errS[0];
|
|
3006
|
+
var setErr = errS[1];
|
|
3007
|
+
var lastRef = React2.useRef(text);
|
|
3008
|
+
var skipBlurRef = React2.useRef(false);
|
|
3009
|
+
React2.useEffect(
|
|
3010
|
+
function() {
|
|
3011
|
+
if (focused) return;
|
|
3012
|
+
if (lastRef.current === text) return;
|
|
3013
|
+
lastRef.current = text;
|
|
3014
|
+
setDraft(text);
|
|
3015
|
+
setErr("");
|
|
3016
|
+
},
|
|
3017
|
+
[text, focused]
|
|
3018
|
+
);
|
|
3019
|
+
function commit(raw) {
|
|
3020
|
+
var r = validateNumber(raw, props);
|
|
3021
|
+
if (!r.ok) {
|
|
3022
|
+
setErr(r.error);
|
|
3023
|
+
if (typeof props.onValidChange === "function") props.onValidChange(false, r.error);
|
|
3024
|
+
return false;
|
|
3025
|
+
}
|
|
3026
|
+
setErr("");
|
|
3027
|
+
if (typeof props.onValidChange === "function") props.onValidChange(true, "");
|
|
3028
|
+
var cur = props.value === null || props.value === void 0 ? null : Number(props.value);
|
|
3029
|
+
if (r.value !== cur) {
|
|
3030
|
+
lastRef.current = r.value === null ? "" : String(r.value);
|
|
3031
|
+
if (typeof props.onCommit === "function") props.onCommit(r.value);
|
|
3032
|
+
}
|
|
3033
|
+
return true;
|
|
3034
|
+
}
|
|
3035
|
+
var hint = props.hint !== void 0 ? props.hint : rangeHint(props, lang);
|
|
3036
|
+
var shown = props.hint === false ? "" : hint;
|
|
3037
|
+
return h2(
|
|
3038
|
+
"span",
|
|
3039
|
+
{ className: "wbctl-num" + (props.wide ? " is-wide" : "") + (props.className ? " " + props.className : "") },
|
|
3040
|
+
h2(
|
|
3041
|
+
"span",
|
|
3042
|
+
{ className: "wbctl-num-box" },
|
|
3043
|
+
h2("input", {
|
|
3044
|
+
className: "wbctl-num-input" + (err ? " is-invalid" : ""),
|
|
3045
|
+
type: "text",
|
|
3046
|
+
inputMode: props.integer || Number(props.step) === 1 ? "numeric" : "decimal",
|
|
3047
|
+
value: draft,
|
|
3048
|
+
disabled: !!props.disabled,
|
|
3049
|
+
placeholder: props.placeholder,
|
|
3050
|
+
title: props.title,
|
|
3051
|
+
"aria-label": props.ariaLabel,
|
|
3052
|
+
"aria-invalid": err ? "true" : void 0,
|
|
3053
|
+
onFocus: function() {
|
|
3054
|
+
setFocused(true);
|
|
3055
|
+
},
|
|
3056
|
+
onChange: function(e) {
|
|
3057
|
+
setDraft(e.target.value);
|
|
3058
|
+
if (err) setErr("");
|
|
3059
|
+
if (typeof props.onDraft === "function") props.onDraft(e.target.value);
|
|
3060
|
+
},
|
|
3061
|
+
onBlur: function() {
|
|
3062
|
+
setFocused(false);
|
|
3063
|
+
if (skipBlurRef.current) {
|
|
3064
|
+
skipBlurRef.current = false;
|
|
3065
|
+
return;
|
|
3066
|
+
}
|
|
3067
|
+
commit(draft);
|
|
3068
|
+
},
|
|
3069
|
+
onKeyDown: function(e) {
|
|
3070
|
+
if (e.key === "Enter") {
|
|
3071
|
+
e.preventDefault();
|
|
3072
|
+
if (e.target && e.target.blur) e.target.blur();
|
|
3073
|
+
} else if (e.key === "Escape") {
|
|
3074
|
+
e.preventDefault();
|
|
3075
|
+
skipBlurRef.current = true;
|
|
3076
|
+
setDraft(text);
|
|
3077
|
+
setErr("");
|
|
3078
|
+
if (e.target && e.target.blur) e.target.blur();
|
|
3079
|
+
}
|
|
3080
|
+
}
|
|
3081
|
+
}),
|
|
3082
|
+
props.unit ? h2("span", { className: "wbctl-num-unit" }, props.unit) : null
|
|
3083
|
+
),
|
|
3084
|
+
err ? h2("span", { className: "wbctl-num-err", role: "alert" }, err) : shown ? h2("span", { className: "wbctl-num-hint" }, shown) : null
|
|
3085
|
+
);
|
|
3086
|
+
}
|
|
3087
|
+
var NUMBER_STYLES = [
|
|
3088
|
+
".wbctl-num{display:inline-flex;flex-direction:column;gap:3px;min-width:0;max-width:100%}",
|
|
3089
|
+
".wbctl-num.is-wide{display:flex;width:100%}",
|
|
3090
|
+
".wbctl-num-box{display:inline-flex;align-items:center;gap:6px;min-width:0}",
|
|
3091
|
+
".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}",
|
|
3092
|
+
".wbctl-num-input:hover:not(:disabled){border-color:var(--wb-border,var(--wb-line))}",
|
|
3093
|
+
".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)}",
|
|
3094
|
+
".wbctl-num-input.is-invalid{border-color:var(--wb-danger,#dc2626)}",
|
|
3095
|
+
".wbctl-num-input.is-invalid:focus{outline-color:color-mix(in oklab,var(--wb-danger,#dc2626) 55%,transparent)}",
|
|
3096
|
+
".wbctl-num-input:disabled{opacity:.5;cursor:not-allowed}",
|
|
3097
|
+
".wbctl-num-unit{color:var(--wb-muted,inherit);font-size:12px;white-space:nowrap}",
|
|
3098
|
+
".wbctl-num-hint{color:var(--wb-muted,inherit);font-size:11px;line-height:1.4}",
|
|
3099
|
+
".wbctl-num-err{color:var(--wb-danger,#dc2626);font-size:11px;line-height:1.4}",
|
|
3100
|
+
"@media (prefers-reduced-motion:reduce){.wbctl-num-input{transition:none}}"
|
|
3101
|
+
];
|
|
3102
|
+
module2.exports = {
|
|
3103
|
+
NumberField,
|
|
3104
|
+
validateNumber,
|
|
3105
|
+
rangeHint,
|
|
3106
|
+
messages,
|
|
3107
|
+
styles: NUMBER_STYLES
|
|
3108
|
+
};
|
|
3109
|
+
}
|
|
3110
|
+
});
|
|
3111
|
+
|
|
2863
3112
|
// packages/addons/sites/client/views/config.cjs
|
|
2864
3113
|
var require_config = __commonJS({
|
|
2865
3114
|
"packages/addons/sites/client/views/config.cjs"(exports2, module2) {
|
|
2866
3115
|
var React2 = require("react");
|
|
2867
3116
|
var h2 = React2.createElement;
|
|
3117
|
+
var SW = require_switch();
|
|
3118
|
+
var NF = require_number_field();
|
|
2868
3119
|
var DOMAIN = "sites";
|
|
2869
3120
|
var PREFIX = "wbs";
|
|
2870
3121
|
var COPY = {
|
|
@@ -2939,13 +3190,6 @@ var require_config = __commonJS({
|
|
|
2939
3190
|
".__P__-cfg-select:focus,.__P__-cfg-input:focus{border-color:var(--dsw-alias-brand-primary,currentColor);box-shadow:0 0 0 3px color-mix(in oklab,var(--dsw-alias-brand-primary,currentColor) 14%,transparent)}",
|
|
2940
3191
|
".__P__-cfg-select{min-width:152px;padding-right:10px}",
|
|
2941
3192
|
".__P__-cfg-input{width:132px}",
|
|
2942
|
-
".__P__-cfg-switch{position:relative;display:inline-flex;align-items:center;gap:9px;cursor:pointer;font-size:12.5px;color:var(--cfg-muted);user-select:none}",
|
|
2943
|
-
".__P__-cfg-switch input{position:absolute;inset:0;width:100%;height:100%;margin:0;opacity:0;cursor:pointer}",
|
|
2944
|
-
".__P__-cfg-track{position:relative;width:38px;height:22px;border-radius:999px;background:color-mix(in oklab,currentColor 18%,transparent);transition:background .16s ease;flex:none}",
|
|
2945
|
-
".__P__-cfg-track::after{content:'';position:absolute;top:2px;left:2px;width:18px;height:18px;border-radius:50%;background:var(--dsw-alias-label-primary,currentColor);transition:transform .16s ease,background .16s ease}",
|
|
2946
|
-
".__P__-cfg-switch input:checked+.__P__-cfg-track{background:var(--dsw-alias-brand-primary,currentColor)}",
|
|
2947
|
-
".__P__-cfg-switch input:checked+.__P__-cfg-track::after{transform:translateX(16px);background:var(--dsw-alias-label-primary-inverted,var(--dsw-alias-bg-base))}",
|
|
2948
|
-
".__P__-cfg-switch input:focus-visible+.__P__-cfg-track{outline:2px solid var(--dsw-alias-brand-primary,currentColor);outline-offset:2px}",
|
|
2949
3193
|
".__P__-cfg-multi{display:flex;flex-wrap:wrap;gap:6px;justify-content:flex-end;max-width:100%}",
|
|
2950
3194
|
".__P__-cfg-multi label{position:relative;display:inline-flex;align-items:center;padding:5px 11px;border:1px solid var(--cfg-line);border-radius:999px;font-size:12px;color:var(--cfg-muted);cursor:pointer;line-height:1.4;transition:color .12s ease,border-color .12s ease,background .12s ease}",
|
|
2951
3195
|
".__P__-cfg-multi label:hover{background:var(--cfg-hover);color:var(--dsw-alias-label-primary,inherit)}",
|
|
@@ -2970,8 +3214,8 @@ var require_config = __commonJS({
|
|
|
2970
3214
|
".__P__-cfg-empty{border:1px dashed var(--cfg-line);border-radius:14px;padding:40px 16px;text-align:center;font-size:12.5px;color:var(--cfg-muted)}",
|
|
2971
3215
|
".__P__-cfg-error{display:flex;align-items:center;gap:10px;flex-wrap:wrap;border:1px solid color-mix(in oklab,var(--dsw-alias-state-error-primary,currentColor) 32%,var(--cfg-line));border-radius:10px;padding:10px 13px;color:var(--dsw-alias-state-error-primary,inherit);font-size:12.5px;line-height:1.5}",
|
|
2972
3216
|
"@media (max-width:820px){.__P__-cfg-row{grid-template-columns:1fr;gap:10px;padding:13px 16px}.__P__-cfg-control{justify-content:flex-start}.__P__-cfg-multi{justify-content:flex-start}.__P__-cfg-gtitle{padding:11px 16px}}",
|
|
2973
|
-
"@media (prefers-reduced-motion:reduce){.__P__-cfg-
|
|
2974
|
-
].join("\n").split("__P__").join(PREFIX);
|
|
3217
|
+
"@media (prefers-reduced-motion:reduce){.__P__-cfg-sk{animation:none;transition:none}}"
|
|
3218
|
+
].concat(SW.styles).concat(NF.styles).join("\n").split("__P__").join(PREFIX);
|
|
2975
3219
|
function injectCss() {
|
|
2976
3220
|
if (typeof document === "undefined") return;
|
|
2977
3221
|
var old = document.getElementById("wb-addon-" + DOMAIN + "-config-css");
|
|
@@ -3054,8 +3298,6 @@ var require_config = __commonJS({
|
|
|
3054
3298
|
var notice = noticeS[0], setNotice = noticeS[1];
|
|
3055
3299
|
var savingS = React2.useState("");
|
|
3056
3300
|
var savingId = savingS[0], setSavingId = savingS[1];
|
|
3057
|
-
var draftsS = React2.useState({});
|
|
3058
|
-
var drafts = draftsS[0], setDrafts = draftsS[1];
|
|
3059
3301
|
var busyS = React2.useState(false);
|
|
3060
3302
|
var busy = busyS[0], setBusy = busyS[1];
|
|
3061
3303
|
React2.useEffect(function() {
|
|
@@ -3141,38 +3383,20 @@ var require_config = __commonJS({
|
|
|
3141
3383
|
setNotice({ id: "", text: String(e && e.message || e), error: true });
|
|
3142
3384
|
});
|
|
3143
3385
|
}
|
|
3144
|
-
function commitDraft(item) {
|
|
3145
|
-
var raw = drafts[item.id];
|
|
3146
|
-
if (raw === void 0) return;
|
|
3147
|
-
var next = String(raw).trim();
|
|
3148
|
-
setDrafts(function(prev) {
|
|
3149
|
-
var copy = Object.assign({}, prev);
|
|
3150
|
-
delete copy[item.id];
|
|
3151
|
-
return copy;
|
|
3152
|
-
});
|
|
3153
|
-
if (next === "") return;
|
|
3154
|
-
var value = Number(next);
|
|
3155
|
-
if (!Number.isFinite(value)) return;
|
|
3156
|
-
if (sameValue(value, state.values[item.id])) return;
|
|
3157
|
-
save(item.id, value);
|
|
3158
|
-
}
|
|
3159
3386
|
function renderControl(item) {
|
|
3160
3387
|
var value = state.values[item.id];
|
|
3161
3388
|
var label = lang === "en" ? item.en : item.zh;
|
|
3162
3389
|
if (item.type === "bool") {
|
|
3163
|
-
return h2(
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
h2("span", { className: PREFIX + "-cfg-track", "aria-hidden": "true" }),
|
|
3174
|
-
h2("span", { className: PREFIX + "-cfg-switchstate" }, value === true ? t.on : t.off)
|
|
3175
|
-
);
|
|
3390
|
+
return h2(SW.Switch, {
|
|
3391
|
+
h: h2,
|
|
3392
|
+
checked: value === true,
|
|
3393
|
+
showState: true,
|
|
3394
|
+
onText: t.on,
|
|
3395
|
+
offText: t.off,
|
|
3396
|
+
onChange: function(next) {
|
|
3397
|
+
save(item.id, next);
|
|
3398
|
+
}
|
|
3399
|
+
});
|
|
3176
3400
|
}
|
|
3177
3401
|
if (item.type === "enum") {
|
|
3178
3402
|
return h2("select", {
|
|
@@ -3189,30 +3413,16 @@ var require_config = __commonJS({
|
|
|
3189
3413
|
}));
|
|
3190
3414
|
}
|
|
3191
3415
|
if (item.type === "int") {
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
value: draft,
|
|
3416
|
+
return h2(NF.NumberField, {
|
|
3417
|
+
h: h2,
|
|
3418
|
+
lang,
|
|
3419
|
+
value: value === void 0 ? "" : value,
|
|
3197
3420
|
min: item.min,
|
|
3198
3421
|
max: item.max,
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
var c = Object.assign({}, prev);
|
|
3204
|
-
c[item.id] = v;
|
|
3205
|
-
return c;
|
|
3206
|
-
});
|
|
3207
|
-
},
|
|
3208
|
-
onBlur: function() {
|
|
3209
|
-
commitDraft(item);
|
|
3210
|
-
},
|
|
3211
|
-
onKeyDown: function(e) {
|
|
3212
|
-
if (e.key === "Enter") {
|
|
3213
|
-
e.preventDefault();
|
|
3214
|
-
commitDraft(item);
|
|
3215
|
-
}
|
|
3422
|
+
integer: true,
|
|
3423
|
+
ariaLabel: label,
|
|
3424
|
+
onCommit: function(next) {
|
|
3425
|
+
save(item.id, next);
|
|
3216
3426
|
}
|
|
3217
3427
|
});
|
|
3218
3428
|
}
|
|
@@ -3985,13 +4195,6 @@ var require_data_style = __commonJS({
|
|
|
3985
4195
|
"." + P + "-search input:focus{border-color:var(--dsw-alias-brand-primary,currentColor);box-shadow:0 0 0 3px color-mix(in oklab,var(--dsw-alias-brand-primary,currentColor) 14%,transparent)}",
|
|
3986
4196
|
"." + P + "-select{border:1px solid var(--cfg-line);background:var(--dsw-alias-bg-base,transparent);color:inherit;border-radius:9px;padding:7px 10px;font:inherit;font-size:12px;outline:none}",
|
|
3987
4197
|
"." + P + "-select:focus{border-color:var(--dsw-alias-brand-primary,currentColor);box-shadow:0 0 0 3px color-mix(in oklab,var(--dsw-alias-brand-primary,currentColor) 14%,transparent)}",
|
|
3988
|
-
"." + P + "-switch{position:relative;display:inline-flex;align-items:center;gap:7px;cursor:pointer;font-size:12px;color:var(--cfg-muted);user-select:none;padding:4px 2px}",
|
|
3989
|
-
"." + P + "-switch input{position:absolute;inset:0;width:100%;height:100%;margin:0;opacity:0;cursor:pointer}",
|
|
3990
|
-
"." + P + "-track{position:relative;width:34px;height:20px;border-radius:999px;background:color-mix(in oklab,currentColor 18%,transparent);transition:background .16s ease;flex:none}",
|
|
3991
|
-
"." + P + "-track::after{content:'';position:absolute;top:2px;left:2px;width:16px;height:16px;border-radius:50%;background:var(--dsw-alias-label-primary,currentColor);transition:transform .16s ease,background .16s ease}",
|
|
3992
|
-
"." + P + "-switch input:checked+." + P + "-track{background:var(--dsw-alias-brand-primary,currentColor)}",
|
|
3993
|
-
"." + P + "-switch input:checked+." + P + "-track::after{transform:translateX(14px);background:var(--dsw-alias-label-primary-inverted,var(--dsw-alias-bg-base))}",
|
|
3994
|
-
"." + P + "-switch input:focus-visible+." + P + "-track{outline:2px solid var(--dsw-alias-brand-primary,currentColor);outline-offset:2px}",
|
|
3995
4198
|
"." + P + "-btn{display:inline-flex;align-items:center;gap:5px;border:1px solid var(--cfg-line);background:transparent;color:var(--cfg-muted);border-radius:8px;padding:6px 10px;font:inherit;font-size:11.5px;cursor:pointer;white-space:nowrap;transition:background .12s ease,color .12s ease}",
|
|
3996
4199
|
"." + P + "-btn:hover{background:var(--cfg-hover);color:var(--dsw-alias-label-primary,inherit)}",
|
|
3997
4200
|
"." + P + "-btn:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,currentColor);outline-offset:2px}",
|
|
@@ -4020,8 +4223,8 @@ var require_data_style = __commonJS({
|
|
|
4020
4223
|
"." + P + "-foot{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding-top:2px;font-size:11.5px;color:var(--cfg-muted)}",
|
|
4021
4224
|
"." + P + "-grow{flex:1}",
|
|
4022
4225
|
"." + P + "-pageinfo{font-variant-numeric:tabular-nums}",
|
|
4023
|
-
"." + P + "-jump{width:56px;
|
|
4024
|
-
"." + P + "-jump
|
|
4226
|
+
"." + P + "-jump .wbctl-num-input{width:56px;padding:4px 7px;font-size:11.5px;text-align:right}",
|
|
4227
|
+
"." + P + "-jump .wbctl-num-hint{display:none}",
|
|
4025
4228
|
"." + P + "-empty{border:1px dashed var(--cfg-line);border-radius:11px;padding:44px 16px;text-align:center;font-size:12.5px;color:var(--cfg-muted)}",
|
|
4026
4229
|
"." + P + "-err{display:flex;align-items:center;gap:10px;flex-wrap:wrap;border:1px solid color-mix(in oklab,var(--dsw-alias-state-error-primary,currentColor) 32%,var(--cfg-line));border-radius:10px;padding:9px 12px;color:var(--dsw-alias-state-error-primary,inherit);font-size:12px;line-height:1.5}",
|
|
4027
4230
|
"." + P + "-skwrap{display:flex;flex-direction:column;gap:1px;padding:2px}",
|
|
@@ -4059,7 +4262,7 @@ var require_data_style = __commonJS({
|
|
|
4059
4262
|
"." + P + "-images img{width:36px;height:36px;object-fit:cover;border-radius:5px}",
|
|
4060
4263
|
"." + P + "-gallery{display:flex;flex-direction:column;gap:12px;overflow:auto;flex:1}",
|
|
4061
4264
|
"." + P + "-gallery img{width:100%;height:auto;object-fit:contain;border-radius:8px}"
|
|
4062
|
-
].join("\n");
|
|
4265
|
+
].concat(require_switch().styles).concat(require_number_field().styles).join("\n");
|
|
4063
4266
|
if (DOMAIN === "storage") {
|
|
4064
4267
|
var buttons = "." + P + " :is(button)";
|
|
4065
4268
|
CSS += buttons + "{border:none;background:var(--wb-btn-bg);min-height:var(--wb-btn-size-sm);min-width:var(--wb-btn-size-sm)}" + buttons + ":enabled:hover{background:var(--wb-btn-hover-bg)}" + buttons + ":enabled:active{background:var(--wb-btn-active-bg)}" + buttons + ":disabled{background:var(--wb-btn-bg);color:var(--cfg-muted)}" + buttons + ":focus-visible{outline:var(--wb-btn-focus);outline-offset:var(--wb-btn-focus-offset)}." + P + "-fcell:has(button) input{padding-right:34px}";
|
|
@@ -4087,8 +4290,10 @@ var require_data_view = __commonJS({
|
|
|
4087
4290
|
"packages/addons/lib/data-view.cjs"(exports2, module2) {
|
|
4088
4291
|
"use strict";
|
|
4089
4292
|
var React2 = require("react");
|
|
4293
|
+
var NF = require_number_field();
|
|
4090
4294
|
var h2 = React2.createElement;
|
|
4091
4295
|
var COPY = require_data_copy();
|
|
4296
|
+
var SW = require_switch();
|
|
4092
4297
|
module2.exports = function createDataView(options) {
|
|
4093
4298
|
var DOMAIN = options.domain;
|
|
4094
4299
|
function icon(name) {
|
|
@@ -4642,17 +4847,18 @@ var require_data_view = __commonJS({
|
|
|
4642
4847
|
h2("button", { type: "button", className: P + "-btn", disabled: !data || page >= pages, onClick: function() {
|
|
4643
4848
|
setPage(Math.min(pages, page + 1));
|
|
4644
4849
|
} }, t.next + " \u203A"),
|
|
4645
|
-
h2(
|
|
4850
|
+
h2(NF.NumberField, {
|
|
4851
|
+
h: h2,
|
|
4852
|
+
lang,
|
|
4646
4853
|
className: P + "-jump",
|
|
4647
|
-
|
|
4854
|
+
value: page,
|
|
4648
4855
|
min: 1,
|
|
4649
4856
|
max: pages,
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
}
|
|
4857
|
+
integer: true,
|
|
4858
|
+
ariaLabel: t.jump,
|
|
4859
|
+
hint: false,
|
|
4860
|
+
onCommit: function(next) {
|
|
4861
|
+
if (next !== null) setPage(next);
|
|
4656
4862
|
}
|
|
4657
4863
|
}),
|
|
4658
4864
|
data && data.queryMs !== void 0 ? h2("span", null, fmt(t.queryTime, { n: data.queryMs })) : null
|
|
@@ -4749,25 +4955,23 @@ var require_data_view = __commonJS({
|
|
|
4749
4955
|
}
|
|
4750
4956
|
})
|
|
4751
4957
|
),
|
|
4752
|
-
h2(
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
|
|
4958
|
+
h2(SW.Switch, {
|
|
4959
|
+
h: h2,
|
|
4960
|
+
checked: includeDeleted,
|
|
4961
|
+
label: t.includeDeleted,
|
|
4962
|
+
onChange: function(next) {
|
|
4963
|
+
setIncludeDeleted(next);
|
|
4757
4964
|
setPage(1);
|
|
4758
|
-
}
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
h2("span", { className: P + "-track" }),
|
|
4769
|
-
h2("span", null, t.showSystem)
|
|
4770
|
-
),
|
|
4965
|
+
}
|
|
4966
|
+
}),
|
|
4967
|
+
h2(SW.Switch, {
|
|
4968
|
+
h: h2,
|
|
4969
|
+
checked: showSystem,
|
|
4970
|
+
label: t.showSystem,
|
|
4971
|
+
onChange: function(next) {
|
|
4972
|
+
setShowSystem(next);
|
|
4973
|
+
}
|
|
4974
|
+
}),
|
|
4771
4975
|
h2("span", { className: P + "-grow" }),
|
|
4772
4976
|
h2(
|
|
4773
4977
|
"label",
|
|
@@ -4953,7 +5157,6 @@ var require_copy = __commonJS({
|
|
|
4953
5157
|
externalAdd: "\u6DFB\u52A0\u5916\u8054",
|
|
4954
5158
|
unlink: "\u89E3\u9664\u5916\u8054",
|
|
4955
5159
|
accountEmpty: "\u8FD9\u4E2A\u7AD9\u70B9\u8FD8\u6CA1\u6709\u8D26\u53F7",
|
|
4956
|
-
cancel: "\u53D6\u6D88",
|
|
4957
5160
|
close: "\u5173\u95ED",
|
|
4958
5161
|
sensitiveHint: "\u5BC6\u7801/\u624B\u673A\u53F7/\u8EAB\u4EFD\u8BC1\u5199\u5E93\u524D\u52A0\u5BC6\uFF0C\u4EC5\u5728\u754C\u9762\u89E3\u9501\u4FDD\u9669\u7BB1\u540E\u53EF\u67E5\u770B\u4E0E\u590D\u5236\u3002",
|
|
4959
5162
|
vaultInvalid: "\u51ED\u636E\u96C6\u5408\u5DF2\u5931\u6548\uFF08\u96C6\u5408\u88AB\u5220\u9664\uFF09\uFF0C\u4FDD\u5B58\u4EFB\u4E00\u654F\u611F\u5B57\u6BB5\u5373\u53EF\u91CD\u5EFA\u3002",
|
|
@@ -5067,7 +5270,6 @@ var require_copy = __commonJS({
|
|
|
5067
5270
|
externalAdd: "Add link",
|
|
5068
5271
|
unlink: "Unlink",
|
|
5069
5272
|
accountEmpty: "No accounts yet",
|
|
5070
|
-
cancel: "Cancel",
|
|
5071
5273
|
close: "Close",
|
|
5072
5274
|
sensitiveHint: "Password / phone / ID card are encrypted before writing and can only be read after unlocking the vault.",
|
|
5073
5275
|
vaultInvalid: "The credential set is gone (deleted); saving any sensitive field rebuilds it.",
|
|
@@ -5325,7 +5527,7 @@ var require_styles = __commonJS({
|
|
|
5325
5527
|
".wbs-note{font-size:11px;color:var(--wbs-muted);line-height:1.6}",
|
|
5326
5528
|
"@media(max-width:860px){.wbs-body{flex-direction:column}.wbs-tree{width:100%;max-height:220px}.wbs-table{min-width:760px}.wbs-root{min-height:0}}",
|
|
5327
5529
|
"@media(max-width:600px){.wbs-head h2{font-size:18px}.wbs-linkrow{grid-template-columns:1fr 1fr}.wbs-modal{padding:14px}}"
|
|
5328
|
-
].concat(require_filter_checklist_styles()).concat(require_client_base_styles().secretFieldStyles).concat([require_date_picker_styles()("wbs")]).join("\n");
|
|
5530
|
+
].concat(require_filter_checklist_styles()).concat(require_client_base_styles().secretFieldStyles).concat([require_date_picker_styles()("wbs")]).concat(require_switch().styles).join("\n");
|
|
5329
5531
|
}
|
|
5330
5532
|
});
|
|
5331
5533
|
|
|
@@ -5935,16 +6137,13 @@ var require_action_schema_style = __commonJS({
|
|
|
5935
6137
|
"." + P + "-cardmeta{display:flex;align-items:center;flex-wrap:wrap;gap:8px;min-width:0;min-height:24px}",
|
|
5936
6138
|
"." + P + "-cardhead code{font-weight:640;overflow-wrap:anywhere;min-width:0}",
|
|
5937
6139
|
"." + P + "-hintline{margin:0;color:var(--dsw-alias-label-tertiary,inherit);font-size:11.5px;line-height:1.5}",
|
|
5938
|
-
"." + P + "-
|
|
5939
|
-
"." + P + "-
|
|
5940
|
-
"." + P + "-
|
|
5941
|
-
|
|
5942
|
-
"." + P + "-
|
|
5943
|
-
"." + P + "-
|
|
5944
|
-
"." + P + "-
|
|
5945
|
-
"." + P + "-toggle:disabled{opacity:.6;cursor:progress}",
|
|
5946
|
-
"@media(prefers-reduced-motion:reduce){." + P + "-track::before{transition:none}}",
|
|
5947
|
-
// 安全约束(不可放开):用警示色描边,和可切换的开关区分开。
|
|
6140
|
+
"." + P + "-origins{display:inline-flex;align-items:center;gap:10px;flex-wrap:wrap;justify-content:flex-end}",
|
|
6141
|
+
"." + P + "-origins-label{font-size:11px;color:var(--wb-muted);white-space:nowrap}",
|
|
6142
|
+
"." + P + "-origin{display:inline-flex;align-items:center;gap:4px;font-size:11.5px;color:var(--wb-muted);cursor:pointer;user-select:none}",
|
|
6143
|
+
// 该 action 本身不支持的来源:整项置灰、不可点,示意「不是没开,是开不了」。
|
|
6144
|
+
"." + P + "-origin-off{opacity:.55;cursor:not-allowed}",
|
|
6145
|
+
"." + P + "-origin input[type=checkbox]{width:13px;height:13px;margin:0;accent-color:var(--wb-accent);cursor:inherit}",
|
|
6146
|
+
"." + P + "-origin input[type=checkbox]:focus-visible{outline:2px solid var(--wb-accent);outline-offset:2px}",
|
|
5948
6147
|
"." + P + "-locked{border-color:var(--wb-warn,#b7791f);color:var(--wb-warn,#b7791f)}",
|
|
5949
6148
|
"." + P + "-desc{margin:0;color:var(--dsw-alias-label-secondary,inherit);line-height:1.55;font-size:12.5px}",
|
|
5950
6149
|
// 搜索命中:用品牌色透明度叠加而不是写死浅色,深浅主题都可读;继承文字颜色、不覆盖 ::selection。
|
|
@@ -5997,15 +6196,20 @@ var require_action_schema_view = __commonJS({
|
|
|
5997
6196
|
zh: {
|
|
5998
6197
|
title: "Action",
|
|
5999
6198
|
hint: "\u8FD0\u884C\u65F6\u6CE8\u518C \xB7 \u53EA\u8BFB",
|
|
6000
|
-
switchHint: "
|
|
6001
|
-
hostHint: "\u5BBF\u4E3B action \u7684
|
|
6002
|
-
|
|
6003
|
-
|
|
6004
|
-
|
|
6005
|
-
|
|
6006
|
-
|
|
6007
|
-
|
|
6008
|
-
|
|
6199
|
+
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",
|
|
6200
|
+
hostHint: "\u5BBF\u4E3B action \u7684\u5141\u8BB8\u6765\u6E90\uFF1B\u6807\u300C\u6765\u6E90\u56FA\u5B9A\u300D\u7684\u4E0D\u53EF\u4FEE\u6539\u3002",
|
|
6201
|
+
originsLabel: "\u5141\u8BB8\u6765\u6E90",
|
|
6202
|
+
originUi: "\u754C\u9762",
|
|
6203
|
+
originPlugin: "\u63D2\u4EF6",
|
|
6204
|
+
originAgent: "agent",
|
|
6205
|
+
originSync: "\u540C\u6B65",
|
|
6206
|
+
originsSaving: "\u4FDD\u5B58\u4E2D\u2026",
|
|
6207
|
+
originsToast: "\u5DF2\u66F4\u65B0\u5141\u8BB8\u6765\u6E90",
|
|
6208
|
+
originsFail: "\u66F4\u65B0\u5141\u8BB8\u6765\u6E90\u5931\u8D25",
|
|
6209
|
+
originsEmpty: "\u81F3\u5C11\u8981\u4FDD\u7559\u4E00\u4E2A\u6765\u6E90",
|
|
6210
|
+
originsUnsupported: "\u8BE5 action \u672C\u8EAB\u4E0D\u652F\u6301\u8FD9\u4E2A\u6765\u6E90",
|
|
6211
|
+
originsPinned: "\u6765\u6E90\u56FA\u5B9A",
|
|
6212
|
+
originsPinnedHint: "\u8BE5 action \u7684\u5141\u8BB8\u6765\u6E90\u88AB\u56FA\u5B9A\uFF08\u5B89\u5168\u7EA6\u675F\uFF09\uFF0C\u4E0D\u80FD\u4FEE\u6539",
|
|
6009
6213
|
domain: "\u57DF",
|
|
6010
6214
|
versionLabel: "\u7248\u672C",
|
|
6011
6215
|
shell: "\u5BBF\u4E3B",
|
|
@@ -6019,6 +6223,8 @@ var require_action_schema_view = __commonJS({
|
|
|
6019
6223
|
onlyOptional: "\u65E0\u5FC5\u586B\u9879",
|
|
6020
6224
|
filterType: "\u53C2\u6570\u7C7B\u578B",
|
|
6021
6225
|
allTypes: "\u5168\u90E8\u7C7B\u578B",
|
|
6226
|
+
filterOrigin: "\u5141\u8BB8\u6765\u6E90",
|
|
6227
|
+
allOrigins: "\u5168\u90E8\u6765\u6E90",
|
|
6022
6228
|
colName: "\u53C2\u6570",
|
|
6023
6229
|
colType: "\u7C7B\u578B",
|
|
6024
6230
|
colReq: "\u5FC5\u586B",
|
|
@@ -6051,15 +6257,22 @@ var require_action_schema_view = __commonJS({
|
|
|
6051
6257
|
en: {
|
|
6052
6258
|
title: "Actions",
|
|
6053
6259
|
hint: "runtime registry \xB7 read-only",
|
|
6054
|
-
switchHint: "
|
|
6055
|
-
hostHint: "
|
|
6056
|
-
|
|
6057
|
-
|
|
6058
|
-
|
|
6059
|
-
|
|
6060
|
-
|
|
6061
|
-
|
|
6062
|
-
|
|
6260
|
+
switchHint: "Allowed origins are stored locally and apply immediately: only checked origins may call the action; others get ACTION_ORIGIN_DENIED.",
|
|
6261
|
+
hostHint: "Allowed origins for host actions; items marked pinned cannot be changed.",
|
|
6262
|
+
originsLabel: "Origins",
|
|
6263
|
+
originUi: "UI",
|
|
6264
|
+
originPlugin: "Plugin",
|
|
6265
|
+
originAgent: "Agent",
|
|
6266
|
+
originSync: "Sync",
|
|
6267
|
+
originsSaving: "Saving\u2026",
|
|
6268
|
+
originsToast: "Allowed origins updated",
|
|
6269
|
+
originsFail: "Failed to update allowed origins",
|
|
6270
|
+
originsEmpty: "Keep at least one origin",
|
|
6271
|
+
originsUnsupported: "This action does not support this origin",
|
|
6272
|
+
originsPinned: "Pinned",
|
|
6273
|
+
originsPinnedHint: "Allowed origins are pinned for this action (security constraint) and cannot be changed",
|
|
6274
|
+
originsDefaultOn: "Allowed by default",
|
|
6275
|
+
originsDefaultOff: "Off by default, can be enabled",
|
|
6063
6276
|
domain: "Domain",
|
|
6064
6277
|
versionLabel: "Version",
|
|
6065
6278
|
shell: "Host",
|
|
@@ -6073,6 +6286,8 @@ var require_action_schema_view = __commonJS({
|
|
|
6073
6286
|
onlyOptional: "No required",
|
|
6074
6287
|
filterType: "Param type",
|
|
6075
6288
|
allTypes: "All types",
|
|
6289
|
+
filterOrigin: "Origins",
|
|
6290
|
+
allOrigins: "All origins",
|
|
6076
6291
|
colName: "Param",
|
|
6077
6292
|
colType: "Type",
|
|
6078
6293
|
colReq: "Required",
|
|
@@ -6216,6 +6431,8 @@ var require_action_schema_view = __commonJS({
|
|
|
6216
6431
|
var reqMode = reqState[0], setReqMode = reqState[1];
|
|
6217
6432
|
var typeState = React2.useState("");
|
|
6218
6433
|
var typePick = typeState[0], setTypePick = typeState[1];
|
|
6434
|
+
var originFilterState = React2.useState("");
|
|
6435
|
+
var originPick = originFilterState[0], setOriginPick = originFilterState[1];
|
|
6219
6436
|
var toastState = React2.useState("");
|
|
6220
6437
|
var toast = toastState[0], setToast = toastState[1];
|
|
6221
6438
|
var savingState = React2.useState("");
|
|
@@ -6271,38 +6488,53 @@ var require_action_schema_view = __commonJS({
|
|
|
6271
6488
|
plainCopy(text);
|
|
6272
6489
|
done();
|
|
6273
6490
|
}
|
|
6274
|
-
|
|
6491
|
+
var ORIGINS = ["ui", "plugin", "agent", "sync"];
|
|
6492
|
+
var originText = { ui: t.originUi, plugin: t.originPlugin, agent: t.originAgent, sync: t.originSync };
|
|
6493
|
+
function setOrigins(action, origin) {
|
|
6275
6494
|
var name = action.name;
|
|
6495
|
+
var current = Array.isArray(action.origins) ? action.origins.slice() : [];
|
|
6496
|
+
var index = current.indexOf(origin);
|
|
6497
|
+
var next = index >= 0 ? current.filter(function(o) {
|
|
6498
|
+
return o !== origin;
|
|
6499
|
+
}) : current.concat([origin]);
|
|
6500
|
+
if (next.length === 0) {
|
|
6501
|
+
setToast(t.originsEmpty);
|
|
6502
|
+
return;
|
|
6503
|
+
}
|
|
6504
|
+
next = ORIGINS.filter(function(o) {
|
|
6505
|
+
return next.indexOf(o) >= 0;
|
|
6506
|
+
});
|
|
6276
6507
|
setSaving(name);
|
|
6277
6508
|
setToast("");
|
|
6278
6509
|
var fail = function(e) {
|
|
6279
6510
|
setSaving("");
|
|
6280
|
-
setToast(t.
|
|
6511
|
+
setToast(t.originsFail + "\uFF1A" + String(e && e.message || e || ""));
|
|
6281
6512
|
};
|
|
6282
6513
|
var done = function(r) {
|
|
6283
6514
|
setSaving("");
|
|
6284
6515
|
var payload = r && typeof r === "object" && Object.prototype.hasOwnProperty.call(r, "result") ? r.result : r;
|
|
6285
6516
|
if (r && r.ok === false) {
|
|
6286
|
-
setToast(t.
|
|
6517
|
+
setToast(t.originsFail + "\uFF1A" + String(r.error || r.text || ""));
|
|
6287
6518
|
return;
|
|
6288
6519
|
}
|
|
6289
|
-
var value = payload &&
|
|
6520
|
+
var value = payload && Array.isArray(payload.origins) ? payload.origins : next;
|
|
6521
|
+
var source = payload && typeof payload.source === "string" ? payload.source : action.originsSource;
|
|
6290
6522
|
setSnap(function(prev) {
|
|
6291
6523
|
if (!prev || !Array.isArray(prev.actions)) return prev;
|
|
6292
6524
|
return Object.assign({}, prev, {
|
|
6293
6525
|
actions: prev.actions.map(function(a) {
|
|
6294
6526
|
if (!a || a.name !== name) return a;
|
|
6295
|
-
return Object.assign({}, a, {
|
|
6527
|
+
return Object.assign({}, a, { origins: value, originsSource: source });
|
|
6296
6528
|
})
|
|
6297
6529
|
});
|
|
6298
6530
|
});
|
|
6299
|
-
setToast(
|
|
6531
|
+
setToast(t.originsToast);
|
|
6300
6532
|
};
|
|
6301
6533
|
if (!api || typeof api.call !== "function") {
|
|
6302
6534
|
fail(new Error("no call api"));
|
|
6303
6535
|
return;
|
|
6304
6536
|
}
|
|
6305
|
-
Promise.resolve(api.call("actions.
|
|
6537
|
+
Promise.resolve(api.call("actions.setActionOrigins", { action: name, origins: next })).then(done, fail);
|
|
6306
6538
|
}
|
|
6307
6539
|
var all = snap && Array.isArray(snap.actions) ? snap.actions.filter(function(a) {
|
|
6308
6540
|
return a && a.domain === DOMAIN;
|
|
@@ -6337,6 +6569,7 @@ var require_action_schema_view = __commonJS({
|
|
|
6337
6569
|
if (typePick && !rows.some(function(row) {
|
|
6338
6570
|
return row.types.indexOf(typePick) >= 0;
|
|
6339
6571
|
})) return false;
|
|
6572
|
+
if (originPick && (!Array.isArray(a.origins) || a.origins.indexOf(originPick) < 0)) return false;
|
|
6340
6573
|
return true;
|
|
6341
6574
|
});
|
|
6342
6575
|
function paramRow(row) {
|
|
@@ -6352,33 +6585,45 @@ var require_action_schema_view = __commonJS({
|
|
|
6352
6585
|
h2("td", null, Highlight.hit(row.description, kw))
|
|
6353
6586
|
);
|
|
6354
6587
|
}
|
|
6355
|
-
function
|
|
6356
|
-
if (action.
|
|
6357
|
-
|
|
6358
|
-
|
|
6359
|
-
title: t.agentLockedHint,
|
|
6360
|
-
"data-agent-locked": action.name
|
|
6361
|
-
}, t.agentLocked);
|
|
6588
|
+
function originsChips(action) {
|
|
6589
|
+
if (!Array.isArray(action.origins)) return null;
|
|
6590
|
+
if (action.originsSource === "invalid") {
|
|
6591
|
+
return h2("span", { className: P + "-badge " + P + "-locked", title: t.originsPinnedHint, "data-origins-invalid": action.name }, t.originsPinned);
|
|
6362
6592
|
}
|
|
6363
|
-
if (typeof action.agentEnabled !== "boolean") return null;
|
|
6364
6593
|
var busy = saving === action.name;
|
|
6594
|
+
var pinned = action.name === "actions.setActionOrigins";
|
|
6595
|
+
var supported = Array.isArray(action.originsDeclared) ? action.originsDeclared : action.origins;
|
|
6365
6596
|
return h2(
|
|
6366
|
-
"
|
|
6367
|
-
{
|
|
6368
|
-
|
|
6369
|
-
|
|
6370
|
-
|
|
6371
|
-
|
|
6372
|
-
|
|
6373
|
-
|
|
6374
|
-
|
|
6375
|
-
|
|
6376
|
-
|
|
6377
|
-
|
|
6378
|
-
|
|
6379
|
-
|
|
6380
|
-
|
|
6381
|
-
|
|
6597
|
+
"div",
|
|
6598
|
+
{ className: P + "-origins", "data-origins-row": action.name },
|
|
6599
|
+
h2("span", { className: P + "-origins-label" }, t.originsLabel),
|
|
6600
|
+
ORIGINS.map(function(origin) {
|
|
6601
|
+
var on = action.origins.indexOf(origin) >= 0;
|
|
6602
|
+
var allowed = supported.indexOf(origin) >= 0;
|
|
6603
|
+
var preset = Array.isArray(action.originsDefault) ? action.originsDefault : supported;
|
|
6604
|
+
var byDefault = preset.indexOf(origin) >= 0;
|
|
6605
|
+
return h2(
|
|
6606
|
+
"label",
|
|
6607
|
+
{
|
|
6608
|
+
key: origin,
|
|
6609
|
+
className: P + "-origin" + (allowed ? "" : " " + P + "-origin-off"),
|
|
6610
|
+
title: pinned ? t.originsPinnedHint : !allowed ? t.originsUnsupported : originText[origin] + " \xB7 " + action.name + " \xB7 " + (byDefault ? t.originsDefaultOn : t.originsDefaultOff)
|
|
6611
|
+
},
|
|
6612
|
+
h2("input", {
|
|
6613
|
+
type: "checkbox",
|
|
6614
|
+
checked: on,
|
|
6615
|
+
disabled: busy || pinned || !allowed,
|
|
6616
|
+
"data-origin": origin,
|
|
6617
|
+
"data-origin-row": action.name,
|
|
6618
|
+
"data-origin-supported": allowed ? "1" : "0",
|
|
6619
|
+
onChange: function() {
|
|
6620
|
+
setOrigins(action, origin);
|
|
6621
|
+
}
|
|
6622
|
+
}),
|
|
6623
|
+
h2("span", null, originText[origin])
|
|
6624
|
+
);
|
|
6625
|
+
}),
|
|
6626
|
+
busy ? h2("span", { className: P + "-origins-label" }, t.originsSaving) : null
|
|
6382
6627
|
);
|
|
6383
6628
|
}
|
|
6384
6629
|
function card(action) {
|
|
@@ -6399,7 +6644,7 @@ var require_action_schema_view = __commonJS({
|
|
|
6399
6644
|
return row.required;
|
|
6400
6645
|
}) ? h2("span", { className: P + "-badge " + P + "-req" }, t.required) : null
|
|
6401
6646
|
),
|
|
6402
|
-
|
|
6647
|
+
originsChips(action)
|
|
6403
6648
|
),
|
|
6404
6649
|
action.description ? h2("p", { className: P + "-desc" }, Highlight.hit(action.description, kw)) : null,
|
|
6405
6650
|
rows.length ? h2(
|
|
@@ -6522,6 +6767,21 @@ var require_action_schema_view = __commonJS({
|
|
|
6522
6767
|
return h2("option", { value: name, key: name }, name);
|
|
6523
6768
|
})
|
|
6524
6769
|
)
|
|
6770
|
+
),
|
|
6771
|
+
h2(
|
|
6772
|
+
"label",
|
|
6773
|
+
{ className: P + "-none" },
|
|
6774
|
+
t.filterOrigin + " ",
|
|
6775
|
+
h2(
|
|
6776
|
+
"select",
|
|
6777
|
+
{ value: originPick, "aria-label": t.filterOrigin, "data-origin-filter": "", onChange: function(e) {
|
|
6778
|
+
setOriginPick(e.target.value);
|
|
6779
|
+
} },
|
|
6780
|
+
h2("option", { value: "" }, t.allOrigins),
|
|
6781
|
+
ORIGINS.map(function(origin) {
|
|
6782
|
+
return h2("option", { value: origin, key: origin }, originText[origin]);
|
|
6783
|
+
})
|
|
6784
|
+
)
|
|
6525
6785
|
)
|
|
6526
6786
|
) : null,
|
|
6527
6787
|
body,
|
|
@@ -7776,7 +8036,7 @@ var createOverlay = require_overlay();
|
|
|
7776
8036
|
injectCss();
|
|
7777
8037
|
host.registerAddon({
|
|
7778
8038
|
id: "wb-addon-sites",
|
|
7779
|
-
version: "1.12.
|
|
8039
|
+
version: "1.12.9",
|
|
7780
8040
|
icon: icons.ICONS["globe"],
|
|
7781
8041
|
views: [
|
|
7782
8042
|
{ id: "stats", icon: tabIcon("chart"), title: { zh: "\u7EDF\u8BA1", en: "Stats" }, component: statsView.SitesStatsView },
|
package/lib/index.js
CHANGED
|
@@ -100,7 +100,8 @@ export function apply(ctx) {
|
|
|
100
100
|
id: "wb-addon-sites",
|
|
101
101
|
title: "站点",
|
|
102
102
|
description: "站点收藏:目录树、链接与标签(标签需安装标签插件);含统计/记录/配置/数据四个视图",
|
|
103
|
-
version: "1.12.
|
|
103
|
+
version: "1.12.9",
|
|
104
|
+
category: "assets",
|
|
104
105
|
tables: ["site", "site_node", "site_node_mapping", "tag_mapping", "site_account", "site_account_external"],
|
|
105
106
|
sync: siteSync,
|
|
106
107
|
views: [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-workbench-sites",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "个人工作台站点插件:目录树、链接与标签",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"id": "wb-addon-sites",
|
|
10
10
|
"title": "站点",
|
|
11
11
|
"description": "站点 + 统计/记录/配置/数据四个视图:目录树、链接与标签,附表数据浏览",
|
|
12
|
-
"version": "1.12.
|
|
12
|
+
"version": "1.12.9",
|
|
13
13
|
"minShell": "0.8.0",
|
|
14
14
|
"tables": [
|
|
15
15
|
"site",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"./package.json": "./package.json"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"dsh-workbench-host": "^0.
|
|
63
|
+
"dsh-workbench-host": "^0.9.1"
|
|
64
64
|
},
|
|
65
65
|
"dsh": {
|
|
66
66
|
"bundle": {
|