dsh-workbench-storage 1.5.9 → 1.5.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/client.js +420 -158
- package/lib/index.js +1 -1
- package/package.json +3 -3
package/lib/client.js
CHANGED
|
@@ -3288,6 +3288,255 @@ var require_config_copy = __commonJS({
|
|
|
3288
3288
|
}
|
|
3289
3289
|
});
|
|
3290
3290
|
|
|
3291
|
+
// packages/addons/lib/switch.cjs
|
|
3292
|
+
var require_switch = __commonJS({
|
|
3293
|
+
"packages/addons/lib/switch.cjs"(exports2, module2) {
|
|
3294
|
+
"use strict";
|
|
3295
|
+
var SWITCH_STYLES = [
|
|
3296
|
+
".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}",
|
|
3297
|
+
".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}",
|
|
3298
|
+
".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}",
|
|
3299
|
+
".wbctl-switch[aria-checked=true]{color:var(--wb-accent,#2563eb)}",
|
|
3300
|
+
".wbctl-switch[aria-checked=true] .wbctl-switch-track{background:var(--wb-accent,#2563eb)}",
|
|
3301
|
+
".wbctl-switch[aria-checked=true] .wbctl-switch-knob{transform:translateX(14px)}",
|
|
3302
|
+
".wbctl-switch:hover:not(:disabled) .wbctl-switch-track{outline:1px solid var(--wb-accent,#2563eb)}",
|
|
3303
|
+
".wbctl-switch:focus-visible{outline:2px solid var(--wb-accent,#2563eb);outline-offset:2px}",
|
|
3304
|
+
".wbctl-switch:disabled{opacity:.45;cursor:not-allowed}",
|
|
3305
|
+
".wbctl-switch-text{white-space:nowrap}",
|
|
3306
|
+
"@media (prefers-reduced-motion:reduce){.wbctl-switch-track,.wbctl-switch-knob{transition:none}}"
|
|
3307
|
+
];
|
|
3308
|
+
function Switch(props) {
|
|
3309
|
+
var h2 = props.h;
|
|
3310
|
+
var on = props.checked === true || props.checked === "true";
|
|
3311
|
+
var disabled = !!props.disabled;
|
|
3312
|
+
var text = props.label;
|
|
3313
|
+
if (props.showState) text = on ? props.onText || "\u5F00" : props.offText || "\u5173";
|
|
3314
|
+
return h2(
|
|
3315
|
+
"button",
|
|
3316
|
+
{
|
|
3317
|
+
type: "button",
|
|
3318
|
+
role: "switch",
|
|
3319
|
+
"aria-checked": on ? "true" : "false",
|
|
3320
|
+
className: "wbctl-switch" + (props.className ? " " + props.className : ""),
|
|
3321
|
+
disabled,
|
|
3322
|
+
title: props.title,
|
|
3323
|
+
"aria-label": text ? void 0 : props.ariaLabel,
|
|
3324
|
+
onClick: function(e) {
|
|
3325
|
+
e.preventDefault();
|
|
3326
|
+
if (disabled) return;
|
|
3327
|
+
if (typeof props.onChange === "function") props.onChange(!on);
|
|
3328
|
+
}
|
|
3329
|
+
},
|
|
3330
|
+
h2(
|
|
3331
|
+
"span",
|
|
3332
|
+
{ className: "wbctl-switch-track", "aria-hidden": "true" },
|
|
3333
|
+
h2("span", { className: "wbctl-switch-knob" })
|
|
3334
|
+
),
|
|
3335
|
+
text ? h2("span", { className: "wbctl-switch-text" }, text) : null
|
|
3336
|
+
);
|
|
3337
|
+
}
|
|
3338
|
+
module2.exports = { Switch, styles: SWITCH_STYLES };
|
|
3339
|
+
}
|
|
3340
|
+
});
|
|
3341
|
+
|
|
3342
|
+
// packages/addons/lib/number-field.cjs
|
|
3343
|
+
var require_number_field = __commonJS({
|
|
3344
|
+
"packages/addons/lib/number-field.cjs"(exports2, module2) {
|
|
3345
|
+
"use strict";
|
|
3346
|
+
var React = require("react");
|
|
3347
|
+
var NUM = /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)$/;
|
|
3348
|
+
var TEXT = {
|
|
3349
|
+
zh: {
|
|
3350
|
+
required: "\u8BF7\u586B\u5199\u6570\u5B57",
|
|
3351
|
+
invalid: "\u8BF7\u8F93\u5165\u6570\u5B57",
|
|
3352
|
+
integer: "\u9700\u8981\u662F\u6574\u6570",
|
|
3353
|
+
min: "\u4E0D\u80FD\u5C0F\u4E8E {min}",
|
|
3354
|
+
max: "\u4E0D\u80FD\u5927\u4E8E {max}",
|
|
3355
|
+
range: "\u9700\u8981\u5728 {min}\u2013{max} \u4E4B\u95F4",
|
|
3356
|
+
step: "\u9700\u8981\u662F {step} \u7684\u500D\u6570",
|
|
3357
|
+
unit: "\u5355\u4F4D"
|
|
3358
|
+
},
|
|
3359
|
+
en: {
|
|
3360
|
+
required: "Please enter a number",
|
|
3361
|
+
invalid: "Please enter a number",
|
|
3362
|
+
integer: "Must be a whole number",
|
|
3363
|
+
min: "Must be at least {min}",
|
|
3364
|
+
max: "Must be at most {max}",
|
|
3365
|
+
range: "Must be between {min} and {max}",
|
|
3366
|
+
step: "Must be a multiple of {step}",
|
|
3367
|
+
unit: "unit"
|
|
3368
|
+
}
|
|
3369
|
+
};
|
|
3370
|
+
function messages(lang) {
|
|
3371
|
+
return lang === "en" ? TEXT.en : TEXT.zh;
|
|
3372
|
+
}
|
|
3373
|
+
function fill(text, vars) {
|
|
3374
|
+
return String(text).replace(/\{(\w+)\}/g, function(m, key) {
|
|
3375
|
+
return vars && vars[key] !== void 0 ? String(vars[key]) : m;
|
|
3376
|
+
});
|
|
3377
|
+
}
|
|
3378
|
+
function validateNumber(raw, opts) {
|
|
3379
|
+
var o = opts || {};
|
|
3380
|
+
var M = messages(o.lang);
|
|
3381
|
+
var text = raw === null || raw === void 0 ? "" : String(raw).trim();
|
|
3382
|
+
if (text === "") {
|
|
3383
|
+
return o.allowEmpty ? { ok: true, value: null, error: "" } : { ok: false, value: null, error: M.required };
|
|
3384
|
+
}
|
|
3385
|
+
if (!NUM.test(text)) return { ok: false, value: null, error: M.invalid };
|
|
3386
|
+
var n = Number(text);
|
|
3387
|
+
if (!isFinite(n)) return { ok: false, value: null, error: M.invalid };
|
|
3388
|
+
if (o.integer && Math.round(n) !== n) return { ok: false, value: null, error: M.integer };
|
|
3389
|
+
var hasMin = o.min !== void 0 && o.min !== null && o.min !== "";
|
|
3390
|
+
var hasMax = o.max !== void 0 && o.max !== null && o.max !== "";
|
|
3391
|
+
if (hasMin && hasMax && n >= o.min && n <= o.max) {
|
|
3392
|
+
} else if (hasMin && hasMax) {
|
|
3393
|
+
return { ok: false, value: null, error: fill(M.range, { min: o.min, max: o.max }) };
|
|
3394
|
+
} else if (hasMin && n < o.min) {
|
|
3395
|
+
return { ok: false, value: null, error: fill(M.min, { min: o.min }) };
|
|
3396
|
+
} else if (hasMax && n > o.max) {
|
|
3397
|
+
return { ok: false, value: null, error: fill(M.max, { max: o.max }) };
|
|
3398
|
+
}
|
|
3399
|
+
if (o.step && Number(o.step) > 0) {
|
|
3400
|
+
var q = n / Number(o.step);
|
|
3401
|
+
if (Math.abs(q - Math.round(q)) > 1e-9) {
|
|
3402
|
+
return { ok: false, value: null, error: fill(M.step, { step: o.step }) };
|
|
3403
|
+
}
|
|
3404
|
+
}
|
|
3405
|
+
return { ok: true, value: n, error: "" };
|
|
3406
|
+
}
|
|
3407
|
+
function rangeHint(opts, lang) {
|
|
3408
|
+
var o = opts || {};
|
|
3409
|
+
var M = messages(lang);
|
|
3410
|
+
var en = lang === "en";
|
|
3411
|
+
var hasMin = o.min !== void 0 && o.min !== null && o.min !== "";
|
|
3412
|
+
var hasMax = o.max !== void 0 && o.max !== null && o.max !== "";
|
|
3413
|
+
var parts = [];
|
|
3414
|
+
if (hasMin && hasMax) parts.push(String(o.min) + "\u2013" + String(o.max));
|
|
3415
|
+
else if (hasMin) parts.push((en ? "\u2265 " : "\u2265 ") + String(o.min));
|
|
3416
|
+
else if (hasMax) parts.push((en ? "\u2264 " : "\u2264 ") + String(o.max));
|
|
3417
|
+
if (o.integer) parts.push(en ? "whole numbers" : "\u6574\u6570");
|
|
3418
|
+
else if (o.step && Number(o.step) > 0) parts.push((en ? "step " : "\u6B65\u957F ") + String(o.step));
|
|
3419
|
+
return parts.join(en ? ", " : "\uFF0C");
|
|
3420
|
+
}
|
|
3421
|
+
function NumberField(props) {
|
|
3422
|
+
var h2 = props.h || React.createElement;
|
|
3423
|
+
var lang = props.lang;
|
|
3424
|
+
var M = messages(lang);
|
|
3425
|
+
var text = props.value === null || props.value === void 0 ? "" : String(props.value);
|
|
3426
|
+
var draftS = React.useState(text);
|
|
3427
|
+
var draft = draftS[0];
|
|
3428
|
+
var setDraft = draftS[1];
|
|
3429
|
+
var focusS = React.useState(false);
|
|
3430
|
+
var focused = focusS[0];
|
|
3431
|
+
var setFocused = focusS[1];
|
|
3432
|
+
var errS = React.useState("");
|
|
3433
|
+
var err = errS[0];
|
|
3434
|
+
var setErr = errS[1];
|
|
3435
|
+
var lastRef = React.useRef(text);
|
|
3436
|
+
var skipBlurRef = React.useRef(false);
|
|
3437
|
+
React.useEffect(
|
|
3438
|
+
function() {
|
|
3439
|
+
if (focused) return;
|
|
3440
|
+
if (lastRef.current === text) return;
|
|
3441
|
+
lastRef.current = text;
|
|
3442
|
+
setDraft(text);
|
|
3443
|
+
setErr("");
|
|
3444
|
+
},
|
|
3445
|
+
[text, focused]
|
|
3446
|
+
);
|
|
3447
|
+
function commit(raw) {
|
|
3448
|
+
var r = validateNumber(raw, props);
|
|
3449
|
+
if (!r.ok) {
|
|
3450
|
+
setErr(r.error);
|
|
3451
|
+
if (typeof props.onValidChange === "function") props.onValidChange(false, r.error);
|
|
3452
|
+
return false;
|
|
3453
|
+
}
|
|
3454
|
+
setErr("");
|
|
3455
|
+
if (typeof props.onValidChange === "function") props.onValidChange(true, "");
|
|
3456
|
+
var cur = props.value === null || props.value === void 0 ? null : Number(props.value);
|
|
3457
|
+
if (r.value !== cur) {
|
|
3458
|
+
lastRef.current = r.value === null ? "" : String(r.value);
|
|
3459
|
+
if (typeof props.onCommit === "function") props.onCommit(r.value);
|
|
3460
|
+
}
|
|
3461
|
+
return true;
|
|
3462
|
+
}
|
|
3463
|
+
var hint = props.hint !== void 0 ? props.hint : rangeHint(props, lang);
|
|
3464
|
+
var shown = props.hint === false ? "" : hint;
|
|
3465
|
+
return h2(
|
|
3466
|
+
"span",
|
|
3467
|
+
{ className: "wbctl-num" + (props.wide ? " is-wide" : "") + (props.className ? " " + props.className : "") },
|
|
3468
|
+
h2(
|
|
3469
|
+
"span",
|
|
3470
|
+
{ className: "wbctl-num-box" },
|
|
3471
|
+
h2("input", {
|
|
3472
|
+
className: "wbctl-num-input" + (err ? " is-invalid" : ""),
|
|
3473
|
+
type: "text",
|
|
3474
|
+
inputMode: props.integer || Number(props.step) === 1 ? "numeric" : "decimal",
|
|
3475
|
+
value: draft,
|
|
3476
|
+
disabled: !!props.disabled,
|
|
3477
|
+
placeholder: props.placeholder,
|
|
3478
|
+
title: props.title,
|
|
3479
|
+
"aria-label": props.ariaLabel,
|
|
3480
|
+
"aria-invalid": err ? "true" : void 0,
|
|
3481
|
+
onFocus: function() {
|
|
3482
|
+
setFocused(true);
|
|
3483
|
+
},
|
|
3484
|
+
onChange: function(e) {
|
|
3485
|
+
setDraft(e.target.value);
|
|
3486
|
+
if (err) setErr("");
|
|
3487
|
+
if (typeof props.onDraft === "function") props.onDraft(e.target.value);
|
|
3488
|
+
},
|
|
3489
|
+
onBlur: function() {
|
|
3490
|
+
setFocused(false);
|
|
3491
|
+
if (skipBlurRef.current) {
|
|
3492
|
+
skipBlurRef.current = false;
|
|
3493
|
+
return;
|
|
3494
|
+
}
|
|
3495
|
+
commit(draft);
|
|
3496
|
+
},
|
|
3497
|
+
onKeyDown: function(e) {
|
|
3498
|
+
if (e.key === "Enter") {
|
|
3499
|
+
e.preventDefault();
|
|
3500
|
+
if (e.target && e.target.blur) e.target.blur();
|
|
3501
|
+
} else if (e.key === "Escape") {
|
|
3502
|
+
e.preventDefault();
|
|
3503
|
+
skipBlurRef.current = true;
|
|
3504
|
+
setDraft(text);
|
|
3505
|
+
setErr("");
|
|
3506
|
+
if (e.target && e.target.blur) e.target.blur();
|
|
3507
|
+
}
|
|
3508
|
+
}
|
|
3509
|
+
}),
|
|
3510
|
+
props.unit ? h2("span", { className: "wbctl-num-unit" }, props.unit) : null
|
|
3511
|
+
),
|
|
3512
|
+
err ? h2("span", { className: "wbctl-num-err", role: "alert" }, err) : shown ? h2("span", { className: "wbctl-num-hint" }, shown) : null
|
|
3513
|
+
);
|
|
3514
|
+
}
|
|
3515
|
+
var NUMBER_STYLES = [
|
|
3516
|
+
".wbctl-num{display:inline-flex;flex-direction:column;gap:3px;min-width:0;max-width:100%}",
|
|
3517
|
+
".wbctl-num.is-wide{display:flex;width:100%}",
|
|
3518
|
+
".wbctl-num-box{display:inline-flex;align-items:center;gap:6px;min-width:0}",
|
|
3519
|
+
".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}",
|
|
3520
|
+
".wbctl-num-input:hover:not(:disabled){border-color:var(--wb-border,var(--wb-line))}",
|
|
3521
|
+
".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)}",
|
|
3522
|
+
".wbctl-num-input.is-invalid{border-color:var(--wb-danger,#dc2626)}",
|
|
3523
|
+
".wbctl-num-input.is-invalid:focus{outline-color:color-mix(in oklab,var(--wb-danger,#dc2626) 55%,transparent)}",
|
|
3524
|
+
".wbctl-num-input:disabled{opacity:.5;cursor:not-allowed}",
|
|
3525
|
+
".wbctl-num-unit{color:var(--wb-muted,inherit);font-size:12px;white-space:nowrap}",
|
|
3526
|
+
".wbctl-num-hint{color:var(--wb-muted,inherit);font-size:11px;line-height:1.4}",
|
|
3527
|
+
".wbctl-num-err{color:var(--wb-danger,#dc2626);font-size:11px;line-height:1.4}",
|
|
3528
|
+
"@media (prefers-reduced-motion:reduce){.wbctl-num-input{transition:none}}"
|
|
3529
|
+
];
|
|
3530
|
+
module2.exports = {
|
|
3531
|
+
NumberField,
|
|
3532
|
+
validateNumber,
|
|
3533
|
+
rangeHint,
|
|
3534
|
+
messages,
|
|
3535
|
+
styles: NUMBER_STYLES
|
|
3536
|
+
};
|
|
3537
|
+
}
|
|
3538
|
+
});
|
|
3539
|
+
|
|
3291
3540
|
// packages/addons/storage/client/views/config.cjs
|
|
3292
3541
|
var require_config = __commonJS({
|
|
3293
3542
|
"packages/addons/storage/client/views/config.cjs"(exports2, module2) {
|
|
@@ -3297,6 +3546,8 @@ var require_config = __commonJS({
|
|
|
3297
3546
|
var DOMAIN = "storage";
|
|
3298
3547
|
var PREFIX = "wbi";
|
|
3299
3548
|
var COPY = require_config_copy();
|
|
3549
|
+
var SW = require_switch();
|
|
3550
|
+
var NF = require_number_field();
|
|
3300
3551
|
var CSS = [
|
|
3301
3552
|
".__P__-cfg{--cfg-line:var(--wb-line,var(--dsw-alias-border-l2,color-mix(in oklab,currentColor 16%,transparent)));--cfg-surface:var(--wb-surface,var(--dsw-alias-bg-layer-1,transparent));--cfg-muted:var(--dsw-alias-label-secondary,color-mix(in oklab,currentColor 62%,transparent));--cfg-faint:var(--dsw-alias-label-tertiary,color-mix(in oklab,currentColor 42%,transparent));--cfg-hover:var(--dsw-alias-interactive-bg-hover,color-mix(in oklab,currentColor 5%,transparent));display:flex;flex-direction:column;gap:16px;width:100%;min-width:0;padding-bottom:6px;color:inherit;font-size:13.5px}",
|
|
3302
3553
|
".__P__-cfg-head{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;flex-wrap:wrap}",
|
|
@@ -3323,13 +3574,6 @@ var require_config = __commonJS({
|
|
|
3323
3574
|
".__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)}",
|
|
3324
3575
|
".__P__-cfg-select{min-width:152px;padding-right:10px}",
|
|
3325
3576
|
".__P__-cfg-input{width:132px}",
|
|
3326
|
-
".__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}",
|
|
3327
|
-
".__P__-cfg-switch input{position:absolute;inset:0;width:100%;height:100%;margin:0;opacity:0;cursor:pointer}",
|
|
3328
|
-
".__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}",
|
|
3329
|
-
".__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}",
|
|
3330
|
-
".__P__-cfg-switch input:checked+.__P__-cfg-track{background:var(--dsw-alias-brand-primary,currentColor)}",
|
|
3331
|
-
".__P__-cfg-switch input:checked+.__P__-cfg-track::after{transform:translateX(16px);background:var(--dsw-alias-label-primary-inverted,var(--dsw-alias-bg-base))}",
|
|
3332
|
-
".__P__-cfg-switch input:focus-visible+.__P__-cfg-track{outline:2px solid var(--dsw-alias-brand-primary,currentColor);outline-offset:2px}",
|
|
3333
3577
|
".__P__-cfg-multi{display:flex;flex-wrap:wrap;gap:6px;justify-content:flex-end;max-width:100%}",
|
|
3334
3578
|
".__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}",
|
|
3335
3579
|
".__P__-cfg-multi label:hover{background:var(--cfg-hover);color:var(--dsw-alias-label-primary,inherit)}",
|
|
@@ -3354,8 +3598,8 @@ var require_config = __commonJS({
|
|
|
3354
3598
|
".__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)}",
|
|
3355
3599
|
".__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}",
|
|
3356
3600
|
"@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}}",
|
|
3357
|
-
"@media (prefers-reduced-motion:reduce){.__P__-cfg-
|
|
3358
|
-
].join("\n").split("__P__").join(PREFIX);
|
|
3601
|
+
"@media (prefers-reduced-motion:reduce){.__P__-cfg-sk{animation:none;transition:none}}"
|
|
3602
|
+
].concat(SW.styles).concat(NF.styles).join("\n").split("__P__").join(PREFIX);
|
|
3359
3603
|
function injectCss() {
|
|
3360
3604
|
if (typeof document === "undefined") return;
|
|
3361
3605
|
var old = document.getElementById("wb-addon-" + DOMAIN + "-config-css");
|
|
@@ -3441,8 +3685,6 @@ var require_config = __commonJS({
|
|
|
3441
3685
|
var notice = noticeS[0], setNotice = noticeS[1];
|
|
3442
3686
|
var savingS = React.useState("");
|
|
3443
3687
|
var savingId = savingS[0], setSavingId = savingS[1];
|
|
3444
|
-
var draftsS = React.useState({});
|
|
3445
|
-
var drafts = draftsS[0], setDrafts = draftsS[1];
|
|
3446
3688
|
var busyS = React.useState(false);
|
|
3447
3689
|
var busy = busyS[0], setBusy = busyS[1];
|
|
3448
3690
|
React.useEffect(function() {
|
|
@@ -3538,38 +3780,20 @@ var require_config = __commonJS({
|
|
|
3538
3780
|
setNotice({ id: "", text: String(e && e.message || e), error: true });
|
|
3539
3781
|
});
|
|
3540
3782
|
}
|
|
3541
|
-
function commitDraft(item) {
|
|
3542
|
-
var raw = drafts[item.id];
|
|
3543
|
-
if (raw === void 0) return;
|
|
3544
|
-
var next = String(raw).trim();
|
|
3545
|
-
setDrafts(function(prev) {
|
|
3546
|
-
var copy = Object.assign({}, prev);
|
|
3547
|
-
delete copy[item.id];
|
|
3548
|
-
return copy;
|
|
3549
|
-
});
|
|
3550
|
-
if (next === "") return;
|
|
3551
|
-
var value = Number(next);
|
|
3552
|
-
if (!Number.isFinite(value)) return;
|
|
3553
|
-
if (sameValue(value, state.values[item.id])) return;
|
|
3554
|
-
save(item.id, value);
|
|
3555
|
-
}
|
|
3556
3783
|
function renderControl(item) {
|
|
3557
3784
|
var value = state.values[item.id];
|
|
3558
3785
|
var label = lang === "en" ? item.en : item.zh;
|
|
3559
3786
|
if (item.type === "bool") {
|
|
3560
|
-
return h2(
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
h2("span", { className: PREFIX + "-cfg-track", "aria-hidden": "true" }),
|
|
3571
|
-
h2("span", { className: PREFIX + "-cfg-switchstate" }, value === true ? t.on : t.off)
|
|
3572
|
-
);
|
|
3787
|
+
return h2(SW.Switch, {
|
|
3788
|
+
h: h2,
|
|
3789
|
+
checked: value === true,
|
|
3790
|
+
showState: true,
|
|
3791
|
+
onText: t.on,
|
|
3792
|
+
offText: t.off,
|
|
3793
|
+
onChange: function(next) {
|
|
3794
|
+
save(item.id, next);
|
|
3795
|
+
}
|
|
3796
|
+
});
|
|
3573
3797
|
}
|
|
3574
3798
|
if (item.type === "enum") {
|
|
3575
3799
|
return h2(
|
|
@@ -3590,30 +3814,16 @@ var require_config = __commonJS({
|
|
|
3590
3814
|
);
|
|
3591
3815
|
}
|
|
3592
3816
|
if (item.type === "int") {
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
value: draft,
|
|
3817
|
+
return h2(NF.NumberField, {
|
|
3818
|
+
h: h2,
|
|
3819
|
+
lang,
|
|
3820
|
+
value: value === void 0 ? "" : value,
|
|
3598
3821
|
min: item.min,
|
|
3599
3822
|
max: item.max,
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
var c = Object.assign({}, prev);
|
|
3605
|
-
c[item.id] = v;
|
|
3606
|
-
return c;
|
|
3607
|
-
});
|
|
3608
|
-
},
|
|
3609
|
-
onBlur: function() {
|
|
3610
|
-
commitDraft(item);
|
|
3611
|
-
},
|
|
3612
|
-
onKeyDown: function(e) {
|
|
3613
|
-
if (e.key === "Enter") {
|
|
3614
|
-
e.preventDefault();
|
|
3615
|
-
commitDraft(item);
|
|
3616
|
-
}
|
|
3823
|
+
integer: true,
|
|
3824
|
+
ariaLabel: label,
|
|
3825
|
+
onCommit: function(next) {
|
|
3826
|
+
save(item.id, next);
|
|
3617
3827
|
}
|
|
3618
3828
|
});
|
|
3619
3829
|
}
|
|
@@ -3979,13 +4189,6 @@ var require_data_style = __commonJS({
|
|
|
3979
4189
|
"." + 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)}",
|
|
3980
4190
|
"." + 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}",
|
|
3981
4191
|
"." + 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)}",
|
|
3982
|
-
"." + 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}",
|
|
3983
|
-
"." + P + "-switch input{position:absolute;inset:0;width:100%;height:100%;margin:0;opacity:0;cursor:pointer}",
|
|
3984
|
-
"." + 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}",
|
|
3985
|
-
"." + 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}",
|
|
3986
|
-
"." + P + "-switch input:checked+." + P + "-track{background:var(--dsw-alias-brand-primary,currentColor)}",
|
|
3987
|
-
"." + P + "-switch input:checked+." + P + "-track::after{transform:translateX(14px);background:var(--dsw-alias-label-primary-inverted,var(--dsw-alias-bg-base))}",
|
|
3988
|
-
"." + P + "-switch input:focus-visible+." + P + "-track{outline:2px solid var(--dsw-alias-brand-primary,currentColor);outline-offset:2px}",
|
|
3989
4192
|
"." + 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}",
|
|
3990
4193
|
"." + P + "-btn:hover{background:var(--cfg-hover);color:var(--dsw-alias-label-primary,inherit)}",
|
|
3991
4194
|
"." + P + "-btn:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,currentColor);outline-offset:2px}",
|
|
@@ -4014,8 +4217,8 @@ var require_data_style = __commonJS({
|
|
|
4014
4217
|
"." + P + "-foot{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding-top:2px;font-size:11.5px;color:var(--cfg-muted)}",
|
|
4015
4218
|
"." + P + "-grow{flex:1}",
|
|
4016
4219
|
"." + P + "-pageinfo{font-variant-numeric:tabular-nums}",
|
|
4017
|
-
"." + P + "-jump{width:56px;
|
|
4018
|
-
"." + P + "-jump
|
|
4220
|
+
"." + P + "-jump .wbctl-num-input{width:56px;padding:4px 7px;font-size:11.5px;text-align:right}",
|
|
4221
|
+
"." + P + "-jump .wbctl-num-hint{display:none}",
|
|
4019
4222
|
"." + 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)}",
|
|
4020
4223
|
"." + 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}",
|
|
4021
4224
|
"." + P + "-skwrap{display:flex;flex-direction:column;gap:1px;padding:2px}",
|
|
@@ -4053,7 +4256,7 @@ var require_data_style = __commonJS({
|
|
|
4053
4256
|
"." + P + "-images img{width:36px;height:36px;object-fit:cover;border-radius:5px}",
|
|
4054
4257
|
"." + P + "-gallery{display:flex;flex-direction:column;gap:12px;overflow:auto;flex:1}",
|
|
4055
4258
|
"." + P + "-gallery img{width:100%;height:auto;object-fit:contain;border-radius:8px}"
|
|
4056
|
-
].join("\n");
|
|
4259
|
+
].concat(require_switch().styles).concat(require_number_field().styles).join("\n");
|
|
4057
4260
|
if (DOMAIN === "storage") {
|
|
4058
4261
|
var buttons = "." + P + " :is(button)";
|
|
4059
4262
|
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}";
|
|
@@ -4081,8 +4284,10 @@ var require_data_view = __commonJS({
|
|
|
4081
4284
|
"packages/addons/lib/data-view.cjs"(exports2, module2) {
|
|
4082
4285
|
"use strict";
|
|
4083
4286
|
var React = require("react");
|
|
4287
|
+
var NF = require_number_field();
|
|
4084
4288
|
var h2 = React.createElement;
|
|
4085
4289
|
var COPY = require_data_copy();
|
|
4290
|
+
var SW = require_switch();
|
|
4086
4291
|
module2.exports = function createDataView(options) {
|
|
4087
4292
|
var DOMAIN = options.domain;
|
|
4088
4293
|
function icon(name) {
|
|
@@ -4636,17 +4841,18 @@ var require_data_view = __commonJS({
|
|
|
4636
4841
|
h2("button", { type: "button", className: P + "-btn", disabled: !data || page >= pages, onClick: function() {
|
|
4637
4842
|
setPage(Math.min(pages, page + 1));
|
|
4638
4843
|
} }, t.next + " \u203A"),
|
|
4639
|
-
h2(
|
|
4844
|
+
h2(NF.NumberField, {
|
|
4845
|
+
h: h2,
|
|
4846
|
+
lang,
|
|
4640
4847
|
className: P + "-jump",
|
|
4641
|
-
|
|
4848
|
+
value: page,
|
|
4642
4849
|
min: 1,
|
|
4643
4850
|
max: pages,
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
}
|
|
4851
|
+
integer: true,
|
|
4852
|
+
ariaLabel: t.jump,
|
|
4853
|
+
hint: false,
|
|
4854
|
+
onCommit: function(next) {
|
|
4855
|
+
if (next !== null) setPage(next);
|
|
4650
4856
|
}
|
|
4651
4857
|
}),
|
|
4652
4858
|
data && data.queryMs !== void 0 ? h2("span", null, fmt(t.queryTime, { n: data.queryMs })) : null
|
|
@@ -4743,25 +4949,23 @@ var require_data_view = __commonJS({
|
|
|
4743
4949
|
}
|
|
4744
4950
|
})
|
|
4745
4951
|
),
|
|
4746
|
-
h2(
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
|
|
4952
|
+
h2(SW.Switch, {
|
|
4953
|
+
h: h2,
|
|
4954
|
+
checked: includeDeleted,
|
|
4955
|
+
label: t.includeDeleted,
|
|
4956
|
+
onChange: function(next) {
|
|
4957
|
+
setIncludeDeleted(next);
|
|
4751
4958
|
setPage(1);
|
|
4752
|
-
}
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
h2("span", { className: P + "-track" }),
|
|
4763
|
-
h2("span", null, t.showSystem)
|
|
4764
|
-
),
|
|
4959
|
+
}
|
|
4960
|
+
}),
|
|
4961
|
+
h2(SW.Switch, {
|
|
4962
|
+
h: h2,
|
|
4963
|
+
checked: showSystem,
|
|
4964
|
+
label: t.showSystem,
|
|
4965
|
+
onChange: function(next) {
|
|
4966
|
+
setShowSystem(next);
|
|
4967
|
+
}
|
|
4968
|
+
}),
|
|
4765
4969
|
h2("span", { className: P + "-grow" }),
|
|
4766
4970
|
h2(
|
|
4767
4971
|
"label",
|
|
@@ -4943,16 +5147,13 @@ var require_action_schema_style = __commonJS({
|
|
|
4943
5147
|
"." + P + "-cardmeta{display:flex;align-items:center;flex-wrap:wrap;gap:8px;min-width:0;min-height:24px}",
|
|
4944
5148
|
"." + P + "-cardhead code{font-weight:640;overflow-wrap:anywhere;min-width:0}",
|
|
4945
5149
|
"." + P + "-hintline{margin:0;color:var(--dsw-alias-label-tertiary,inherit);font-size:11.5px;line-height:1.5}",
|
|
4946
|
-
"." + P + "-
|
|
4947
|
-
"." + P + "-
|
|
4948
|
-
"." + P + "-
|
|
4949
|
-
|
|
4950
|
-
"." + P + "-
|
|
4951
|
-
"." + P + "-
|
|
4952
|
-
"." + P + "-
|
|
4953
|
-
"." + P + "-toggle:disabled{opacity:.6;cursor:progress}",
|
|
4954
|
-
"@media(prefers-reduced-motion:reduce){." + P + "-track::before{transition:none}}",
|
|
4955
|
-
// 安全约束(不可放开):用警示色描边,和可切换的开关区分开。
|
|
5150
|
+
"." + P + "-origins{display:inline-flex;align-items:center;gap:10px;flex-wrap:wrap;justify-content:flex-end}",
|
|
5151
|
+
"." + P + "-origins-label{font-size:11px;color:var(--wb-muted);white-space:nowrap}",
|
|
5152
|
+
"." + P + "-origin{display:inline-flex;align-items:center;gap:4px;font-size:11.5px;color:var(--wb-muted);cursor:pointer;user-select:none}",
|
|
5153
|
+
// 该 action 本身不支持的来源:整项置灰、不可点,示意「不是没开,是开不了」。
|
|
5154
|
+
"." + P + "-origin-off{opacity:.55;cursor:not-allowed}",
|
|
5155
|
+
"." + P + "-origin input[type=checkbox]{width:13px;height:13px;margin:0;accent-color:var(--wb-accent);cursor:inherit}",
|
|
5156
|
+
"." + P + "-origin input[type=checkbox]:focus-visible{outline:2px solid var(--wb-accent);outline-offset:2px}",
|
|
4956
5157
|
"." + P + "-locked{border-color:var(--wb-warn,#b7791f);color:var(--wb-warn,#b7791f)}",
|
|
4957
5158
|
"." + P + "-desc{margin:0;color:var(--dsw-alias-label-secondary,inherit);line-height:1.55;font-size:12.5px}",
|
|
4958
5159
|
// 搜索命中:用品牌色透明度叠加而不是写死浅色,深浅主题都可读;继承文字颜色、不覆盖 ::selection。
|
|
@@ -5005,15 +5206,20 @@ var require_action_schema_view = __commonJS({
|
|
|
5005
5206
|
zh: {
|
|
5006
5207
|
title: "Action",
|
|
5007
5208
|
hint: "\u8FD0\u884C\u65F6\u6CE8\u518C \xB7 \u53EA\u8BFB",
|
|
5008
|
-
switchHint: "
|
|
5009
|
-
hostHint: "\u5BBF\u4E3B action \u7684
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5209
|
+
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",
|
|
5210
|
+
hostHint: "\u5BBF\u4E3B action \u7684\u5141\u8BB8\u6765\u6E90\uFF1B\u6807\u300C\u6765\u6E90\u56FA\u5B9A\u300D\u7684\u4E0D\u53EF\u4FEE\u6539\u3002",
|
|
5211
|
+
originsLabel: "\u5141\u8BB8\u6765\u6E90",
|
|
5212
|
+
originUi: "\u754C\u9762",
|
|
5213
|
+
originPlugin: "\u63D2\u4EF6",
|
|
5214
|
+
originAgent: "agent",
|
|
5215
|
+
originSync: "\u540C\u6B65",
|
|
5216
|
+
originsSaving: "\u4FDD\u5B58\u4E2D\u2026",
|
|
5217
|
+
originsToast: "\u5DF2\u66F4\u65B0\u5141\u8BB8\u6765\u6E90",
|
|
5218
|
+
originsFail: "\u66F4\u65B0\u5141\u8BB8\u6765\u6E90\u5931\u8D25",
|
|
5219
|
+
originsEmpty: "\u81F3\u5C11\u8981\u4FDD\u7559\u4E00\u4E2A\u6765\u6E90",
|
|
5220
|
+
originsUnsupported: "\u8BE5 action \u672C\u8EAB\u4E0D\u652F\u6301\u8FD9\u4E2A\u6765\u6E90",
|
|
5221
|
+
originsPinned: "\u6765\u6E90\u56FA\u5B9A",
|
|
5222
|
+
originsPinnedHint: "\u8BE5 action \u7684\u5141\u8BB8\u6765\u6E90\u88AB\u56FA\u5B9A\uFF08\u5B89\u5168\u7EA6\u675F\uFF09\uFF0C\u4E0D\u80FD\u4FEE\u6539",
|
|
5017
5223
|
domain: "\u57DF",
|
|
5018
5224
|
versionLabel: "\u7248\u672C",
|
|
5019
5225
|
shell: "\u5BBF\u4E3B",
|
|
@@ -5027,6 +5233,8 @@ var require_action_schema_view = __commonJS({
|
|
|
5027
5233
|
onlyOptional: "\u65E0\u5FC5\u586B\u9879",
|
|
5028
5234
|
filterType: "\u53C2\u6570\u7C7B\u578B",
|
|
5029
5235
|
allTypes: "\u5168\u90E8\u7C7B\u578B",
|
|
5236
|
+
filterOrigin: "\u5141\u8BB8\u6765\u6E90",
|
|
5237
|
+
allOrigins: "\u5168\u90E8\u6765\u6E90",
|
|
5030
5238
|
colName: "\u53C2\u6570",
|
|
5031
5239
|
colType: "\u7C7B\u578B",
|
|
5032
5240
|
colReq: "\u5FC5\u586B",
|
|
@@ -5059,15 +5267,22 @@ var require_action_schema_view = __commonJS({
|
|
|
5059
5267
|
en: {
|
|
5060
5268
|
title: "Actions",
|
|
5061
5269
|
hint: "runtime registry \xB7 read-only",
|
|
5062
|
-
switchHint: "
|
|
5063
|
-
hostHint: "
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
|
-
|
|
5068
|
-
|
|
5069
|
-
|
|
5070
|
-
|
|
5270
|
+
switchHint: "Allowed origins are stored locally and apply immediately: only checked origins may call the action; others get ACTION_ORIGIN_DENIED.",
|
|
5271
|
+
hostHint: "Allowed origins for host actions; items marked pinned cannot be changed.",
|
|
5272
|
+
originsLabel: "Origins",
|
|
5273
|
+
originUi: "UI",
|
|
5274
|
+
originPlugin: "Plugin",
|
|
5275
|
+
originAgent: "Agent",
|
|
5276
|
+
originSync: "Sync",
|
|
5277
|
+
originsSaving: "Saving\u2026",
|
|
5278
|
+
originsToast: "Allowed origins updated",
|
|
5279
|
+
originsFail: "Failed to update allowed origins",
|
|
5280
|
+
originsEmpty: "Keep at least one origin",
|
|
5281
|
+
originsUnsupported: "This action does not support this origin",
|
|
5282
|
+
originsPinned: "Pinned",
|
|
5283
|
+
originsPinnedHint: "Allowed origins are pinned for this action (security constraint) and cannot be changed",
|
|
5284
|
+
originsDefaultOn: "Allowed by default",
|
|
5285
|
+
originsDefaultOff: "Off by default, can be enabled",
|
|
5071
5286
|
domain: "Domain",
|
|
5072
5287
|
versionLabel: "Version",
|
|
5073
5288
|
shell: "Host",
|
|
@@ -5081,6 +5296,8 @@ var require_action_schema_view = __commonJS({
|
|
|
5081
5296
|
onlyOptional: "No required",
|
|
5082
5297
|
filterType: "Param type",
|
|
5083
5298
|
allTypes: "All types",
|
|
5299
|
+
filterOrigin: "Origins",
|
|
5300
|
+
allOrigins: "All origins",
|
|
5084
5301
|
colName: "Param",
|
|
5085
5302
|
colType: "Type",
|
|
5086
5303
|
colReq: "Required",
|
|
@@ -5224,6 +5441,8 @@ var require_action_schema_view = __commonJS({
|
|
|
5224
5441
|
var reqMode = reqState[0], setReqMode = reqState[1];
|
|
5225
5442
|
var typeState = React.useState("");
|
|
5226
5443
|
var typePick = typeState[0], setTypePick = typeState[1];
|
|
5444
|
+
var originFilterState = React.useState("");
|
|
5445
|
+
var originPick = originFilterState[0], setOriginPick = originFilterState[1];
|
|
5227
5446
|
var toastState = React.useState("");
|
|
5228
5447
|
var toast = toastState[0], setToast = toastState[1];
|
|
5229
5448
|
var savingState = React.useState("");
|
|
@@ -5279,38 +5498,53 @@ var require_action_schema_view = __commonJS({
|
|
|
5279
5498
|
plainCopy(text);
|
|
5280
5499
|
done();
|
|
5281
5500
|
}
|
|
5282
|
-
|
|
5501
|
+
var ORIGINS = ["ui", "plugin", "agent", "sync"];
|
|
5502
|
+
var originText = { ui: t.originUi, plugin: t.originPlugin, agent: t.originAgent, sync: t.originSync };
|
|
5503
|
+
function setOrigins(action, origin) {
|
|
5283
5504
|
var name = action.name;
|
|
5505
|
+
var current = Array.isArray(action.origins) ? action.origins.slice() : [];
|
|
5506
|
+
var index = current.indexOf(origin);
|
|
5507
|
+
var next = index >= 0 ? current.filter(function(o) {
|
|
5508
|
+
return o !== origin;
|
|
5509
|
+
}) : current.concat([origin]);
|
|
5510
|
+
if (next.length === 0) {
|
|
5511
|
+
setToast(t.originsEmpty);
|
|
5512
|
+
return;
|
|
5513
|
+
}
|
|
5514
|
+
next = ORIGINS.filter(function(o) {
|
|
5515
|
+
return next.indexOf(o) >= 0;
|
|
5516
|
+
});
|
|
5284
5517
|
setSaving(name);
|
|
5285
5518
|
setToast("");
|
|
5286
5519
|
var fail = function(e) {
|
|
5287
5520
|
setSaving("");
|
|
5288
|
-
setToast(t.
|
|
5521
|
+
setToast(t.originsFail + "\uFF1A" + String(e && e.message || e || ""));
|
|
5289
5522
|
};
|
|
5290
5523
|
var done = function(r) {
|
|
5291
5524
|
setSaving("");
|
|
5292
5525
|
var payload = r && typeof r === "object" && Object.prototype.hasOwnProperty.call(r, "result") ? r.result : r;
|
|
5293
5526
|
if (r && r.ok === false) {
|
|
5294
|
-
setToast(t.
|
|
5527
|
+
setToast(t.originsFail + "\uFF1A" + String(r.error || r.text || ""));
|
|
5295
5528
|
return;
|
|
5296
5529
|
}
|
|
5297
|
-
var value = payload &&
|
|
5530
|
+
var value = payload && Array.isArray(payload.origins) ? payload.origins : next;
|
|
5531
|
+
var source = payload && typeof payload.source === "string" ? payload.source : action.originsSource;
|
|
5298
5532
|
setSnap(function(prev) {
|
|
5299
5533
|
if (!prev || !Array.isArray(prev.actions)) return prev;
|
|
5300
5534
|
return Object.assign({}, prev, {
|
|
5301
5535
|
actions: prev.actions.map(function(a) {
|
|
5302
5536
|
if (!a || a.name !== name) return a;
|
|
5303
|
-
return Object.assign({}, a, {
|
|
5537
|
+
return Object.assign({}, a, { origins: value, originsSource: source });
|
|
5304
5538
|
})
|
|
5305
5539
|
});
|
|
5306
5540
|
});
|
|
5307
|
-
setToast(
|
|
5541
|
+
setToast(t.originsToast);
|
|
5308
5542
|
};
|
|
5309
5543
|
if (!api || typeof api.call !== "function") {
|
|
5310
5544
|
fail(new Error("no call api"));
|
|
5311
5545
|
return;
|
|
5312
5546
|
}
|
|
5313
|
-
Promise.resolve(api.call("actions.
|
|
5547
|
+
Promise.resolve(api.call("actions.setActionOrigins", { action: name, origins: next })).then(done, fail);
|
|
5314
5548
|
}
|
|
5315
5549
|
var all = snap && Array.isArray(snap.actions) ? snap.actions.filter(function(a) {
|
|
5316
5550
|
return a && a.domain === DOMAIN;
|
|
@@ -5345,6 +5579,7 @@ var require_action_schema_view = __commonJS({
|
|
|
5345
5579
|
if (typePick && !rows.some(function(row) {
|
|
5346
5580
|
return row.types.indexOf(typePick) >= 0;
|
|
5347
5581
|
})) return false;
|
|
5582
|
+
if (originPick && (!Array.isArray(a.origins) || a.origins.indexOf(originPick) < 0)) return false;
|
|
5348
5583
|
return true;
|
|
5349
5584
|
});
|
|
5350
5585
|
function paramRow(row) {
|
|
@@ -5360,33 +5595,45 @@ var require_action_schema_view = __commonJS({
|
|
|
5360
5595
|
h2("td", null, Highlight.hit(row.description, kw))
|
|
5361
5596
|
);
|
|
5362
5597
|
}
|
|
5363
|
-
function
|
|
5364
|
-
if (action.
|
|
5365
|
-
|
|
5366
|
-
|
|
5367
|
-
title: t.agentLockedHint,
|
|
5368
|
-
"data-agent-locked": action.name
|
|
5369
|
-
}, t.agentLocked);
|
|
5598
|
+
function originsChips(action) {
|
|
5599
|
+
if (!Array.isArray(action.origins)) return null;
|
|
5600
|
+
if (action.originsSource === "invalid") {
|
|
5601
|
+
return h2("span", { className: P + "-badge " + P + "-locked", title: t.originsPinnedHint, "data-origins-invalid": action.name }, t.originsPinned);
|
|
5370
5602
|
}
|
|
5371
|
-
if (typeof action.agentEnabled !== "boolean") return null;
|
|
5372
5603
|
var busy = saving === action.name;
|
|
5604
|
+
var pinned = action.name === "actions.setActionOrigins";
|
|
5605
|
+
var supported = Array.isArray(action.originsDeclared) ? action.originsDeclared : action.origins;
|
|
5373
5606
|
return h2(
|
|
5374
|
-
"
|
|
5375
|
-
{
|
|
5376
|
-
|
|
5377
|
-
|
|
5378
|
-
|
|
5379
|
-
|
|
5380
|
-
|
|
5381
|
-
|
|
5382
|
-
|
|
5383
|
-
|
|
5384
|
-
|
|
5385
|
-
|
|
5386
|
-
|
|
5387
|
-
|
|
5388
|
-
|
|
5389
|
-
|
|
5607
|
+
"div",
|
|
5608
|
+
{ className: P + "-origins", "data-origins-row": action.name },
|
|
5609
|
+
h2("span", { className: P + "-origins-label" }, t.originsLabel),
|
|
5610
|
+
ORIGINS.map(function(origin) {
|
|
5611
|
+
var on = action.origins.indexOf(origin) >= 0;
|
|
5612
|
+
var allowed = supported.indexOf(origin) >= 0;
|
|
5613
|
+
var preset = Array.isArray(action.originsDefault) ? action.originsDefault : supported;
|
|
5614
|
+
var byDefault = preset.indexOf(origin) >= 0;
|
|
5615
|
+
return h2(
|
|
5616
|
+
"label",
|
|
5617
|
+
{
|
|
5618
|
+
key: origin,
|
|
5619
|
+
className: P + "-origin" + (allowed ? "" : " " + P + "-origin-off"),
|
|
5620
|
+
title: pinned ? t.originsPinnedHint : !allowed ? t.originsUnsupported : originText[origin] + " \xB7 " + action.name + " \xB7 " + (byDefault ? t.originsDefaultOn : t.originsDefaultOff)
|
|
5621
|
+
},
|
|
5622
|
+
h2("input", {
|
|
5623
|
+
type: "checkbox",
|
|
5624
|
+
checked: on,
|
|
5625
|
+
disabled: busy || pinned || !allowed,
|
|
5626
|
+
"data-origin": origin,
|
|
5627
|
+
"data-origin-row": action.name,
|
|
5628
|
+
"data-origin-supported": allowed ? "1" : "0",
|
|
5629
|
+
onChange: function() {
|
|
5630
|
+
setOrigins(action, origin);
|
|
5631
|
+
}
|
|
5632
|
+
}),
|
|
5633
|
+
h2("span", null, originText[origin])
|
|
5634
|
+
);
|
|
5635
|
+
}),
|
|
5636
|
+
busy ? h2("span", { className: P + "-origins-label" }, t.originsSaving) : null
|
|
5390
5637
|
);
|
|
5391
5638
|
}
|
|
5392
5639
|
function card(action) {
|
|
@@ -5407,7 +5654,7 @@ var require_action_schema_view = __commonJS({
|
|
|
5407
5654
|
return row.required;
|
|
5408
5655
|
}) ? h2("span", { className: P + "-badge " + P + "-req" }, t.required) : null
|
|
5409
5656
|
),
|
|
5410
|
-
|
|
5657
|
+
originsChips(action)
|
|
5411
5658
|
),
|
|
5412
5659
|
action.description ? h2("p", { className: P + "-desc" }, Highlight.hit(action.description, kw)) : null,
|
|
5413
5660
|
rows.length ? h2(
|
|
@@ -5530,6 +5777,21 @@ var require_action_schema_view = __commonJS({
|
|
|
5530
5777
|
return h2("option", { value: name, key: name }, name);
|
|
5531
5778
|
})
|
|
5532
5779
|
)
|
|
5780
|
+
),
|
|
5781
|
+
h2(
|
|
5782
|
+
"label",
|
|
5783
|
+
{ className: P + "-none" },
|
|
5784
|
+
t.filterOrigin + " ",
|
|
5785
|
+
h2(
|
|
5786
|
+
"select",
|
|
5787
|
+
{ value: originPick, "aria-label": t.filterOrigin, "data-origin-filter": "", onChange: function(e) {
|
|
5788
|
+
setOriginPick(e.target.value);
|
|
5789
|
+
} },
|
|
5790
|
+
h2("option", { value: "" }, t.allOrigins),
|
|
5791
|
+
ORIGINS.map(function(origin) {
|
|
5792
|
+
return h2("option", { value: origin, key: origin }, originText[origin]);
|
|
5793
|
+
})
|
|
5794
|
+
)
|
|
5533
5795
|
)
|
|
5534
5796
|
) : null,
|
|
5535
5797
|
body,
|
|
@@ -5571,7 +5833,7 @@ if (host) {
|
|
|
5571
5833
|
h = require("react").createElement, icons = require_icons2(), Icon2 = icons.Icon, GLYPHS = icons.ICONS;
|
|
5572
5834
|
host.registerAddon({
|
|
5573
5835
|
id: "wb-addon-storage",
|
|
5574
|
-
version: "1.5.
|
|
5836
|
+
version: "1.5.11",
|
|
5575
5837
|
icon: GLYPHS["package"],
|
|
5576
5838
|
views: [
|
|
5577
5839
|
{ id: "stats", icon: tabIcon2("chart"), title: { zh: "\u7EDF\u8BA1", en: "Statistics" }, component: require_stats().Stats },
|
package/lib/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-workbench-storage",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "个人工作台储物插件:名称、品牌、位置、单位、库存文本与标签",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"id": "wb-addon-storage",
|
|
10
10
|
"title": "储物",
|
|
11
11
|
"description": "储物:统计/记录/配置/数据四个视图",
|
|
12
|
-
"version": "1.5.
|
|
12
|
+
"version": "1.5.11",
|
|
13
13
|
"minShell": "0.8.0",
|
|
14
14
|
"tables": [
|
|
15
15
|
"storage"
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"./package.json": "./package.json"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"dsh-workbench-host": "^0.
|
|
50
|
+
"dsh-workbench-host": "^0.9.1"
|
|
51
51
|
},
|
|
52
52
|
"dsh": {
|
|
53
53
|
"bundle": {
|