dsh-workbench-danmaku 0.2.13 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.js CHANGED
@@ -2946,6 +2946,170 @@ var require_library = __commonJS({
2946
2946
  }
2947
2947
  });
2948
2948
 
2949
+ // packages/addons/lib/config-scheme-bar.cjs
2950
+ var require_config_scheme_bar = __commonJS({
2951
+ "packages/addons/lib/config-scheme-bar.cjs"(exports2, module2) {
2952
+ "use strict";
2953
+ var React = require("react");
2954
+ var h = React.createElement;
2955
+ var COPY = {
2956
+ zh: {
2957
+ title: "\u914D\u7F6E\u65B9\u6848",
2958
+ none: "\u4E0D\u4F7F\u7528\u65B9\u6848\uFF08\u63D2\u4EF6\u9ED8\u8BA4\u914D\u7F6E\uFF09",
2959
+ create: "\u65B0\u5EFA\u65B9\u6848",
2960
+ rename: "\u91CD\u547D\u540D",
2961
+ remove: "\u5220\u9664",
2962
+ namePlaceholder: "\u65B9\u6848\u540D\u79F0",
2963
+ ok: "\u786E\u5B9A",
2964
+ cancel: "\u53D6\u6D88",
2965
+ current: "\u5F53\u524D\u65B9\u6848",
2966
+ defaultHint: "\u672A\u9009\u62E9\u65B9\u6848\u65F6\u4F7F\u7528\u63D2\u4EF6\u9ED8\u8BA4\u914D\u7F6E\uFF1B\u4FEE\u6539\u4EFB\u610F\u8BBE\u7F6E\u4F1A\u81EA\u52A8\u65B0\u5EFA\u300C\u672C\u673A\u914D\u7F6E\u300D\u65B9\u6848\u3002",
2967
+ syncedHint: "\u65B9\u6848\u4F1A\u968F\u4E91\u7AEF\u540C\u6B65\u4E0E\u5907\u4EFD\u4E00\u8D77\u8D70\uFF1B\u5F53\u524D\u9009\u4E2D\u54EA\u4E2A\u65B9\u6848\u53EA\u4FDD\u5B58\u5728\u672C\u673A\u3002",
2968
+ confirmDelete: "\u5220\u9664\u5F53\u524D\u65B9\u6848\u540E\u4F1A\u56DE\u5230\u63D2\u4EF6\u9ED8\u8BA4\u914D\u7F6E\uFF0C\u786E\u5B9A\u5220\u9664\uFF1F",
2969
+ createTitle: "\u65B0\u5EFA\u914D\u7F6E\u65B9\u6848",
2970
+ renameTitle: "\u91CD\u547D\u540D\u914D\u7F6E\u65B9\u6848",
2971
+ fromCurrent: "\u4ECE\u5F53\u524D\u65B9\u6848\u590D\u5236",
2972
+ fromDefault: "\u4ECE\u63D2\u4EF6\u9ED8\u8BA4\u5F00\u59CB"
2973
+ },
2974
+ en: {
2975
+ title: "Config scheme",
2976
+ none: "No scheme (plugin defaults)",
2977
+ create: "New scheme",
2978
+ rename: "Rename",
2979
+ remove: "Delete",
2980
+ namePlaceholder: "Scheme name",
2981
+ ok: "OK",
2982
+ cancel: "Cancel",
2983
+ current: "Active scheme",
2984
+ defaultHint: 'With no scheme selected the plugin defaults apply. Editing any setting creates a local "My config" scheme automatically.',
2985
+ syncedHint: "Schemes sync to the cloud and travel with backups; which scheme this device uses stays local.",
2986
+ confirmDelete: "Deleting the active scheme returns to plugin defaults. Delete it?",
2987
+ createTitle: "New config scheme",
2988
+ renameTitle: "Rename config scheme",
2989
+ fromCurrent: "Copy active scheme",
2990
+ fromDefault: "Start from plugin defaults"
2991
+ }
2992
+ };
2993
+ var styles2 = [
2994
+ ".__P__-cfg-schemes{display:flex;flex-direction:column;gap:10px;padding:13px 16px;border:1px solid var(--cfg-line);border-radius:12px;background:var(--cfg-surface)}",
2995
+ ".__P__-cfg-schemes-main{display:flex;align-items:center;gap:10px;flex-wrap:wrap}",
2996
+ ".__P__-cfg-schemes-label{font-size:12.5px;font-weight:660;white-space:nowrap}",
2997
+ ".__P__-cfg-schemes-select{border:1px solid var(--cfg-line);background:var(--dsw-alias-bg-base,transparent);color:inherit;border-radius:9px;padding:7px 11px;font:inherit;font-size:13px;line-height:1.4;outline:none;min-width:190px;max-width:100%}",
2998
+ ".__P__-cfg-schemes-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)}",
2999
+ ".__P__-cfg-schemes-actions{display:flex;gap:7px;flex-wrap:wrap}",
3000
+ ".__P__-cfg-sbtn{appearance:none;border:1px solid var(--cfg-line);background:transparent;color:inherit;border-radius:8px;padding:5px 11px;font:inherit;font-size:12px;line-height:1.5;cursor:pointer;transition:background .12s ease,border-color .12s ease}",
3001
+ ".__P__-cfg-sbtn:hover:not(:disabled){background:var(--cfg-hover);border-color:color-mix(in oklab,currentColor 28%,var(--cfg-line))}",
3002
+ ".__P__-cfg-sbtn:disabled{opacity:.5;cursor:default}",
3003
+ ".__P__-cfg-sbtn.danger{color:var(--dsw-alias-state-error-primary,inherit)}",
3004
+ ".__P__-cfg-schemes-form{display:flex;align-items:center;gap:7px;flex-wrap:wrap}",
3005
+ ".__P__-cfg-schemes-input{flex:1 1 180px;min-width:120px;border:1px solid var(--cfg-line);background:var(--dsw-alias-bg-base,transparent);color:inherit;border-radius:8px;padding:6px 10px;font:inherit;font-size:13px;outline:none}",
3006
+ ".__P__-cfg-schemes-input:focus{border-color:var(--dsw-alias-brand-primary,currentColor)}",
3007
+ ".__P__-cfg-schemes-hint{font-size:11.5px;color:var(--cfg-muted);line-height:1.6}"
3008
+ ];
3009
+ function SchemeBar(props) {
3010
+ var lang = props.lang === "en" ? "en" : "zh";
3011
+ var c = props.copy ? Object.assign({}, COPY[lang], props.copy) : COPY[lang];
3012
+ var prefix = props.prefix || "wb";
3013
+ var cls = function(suffix) {
3014
+ return "." + prefix + "-cfg-" + suffix;
3015
+ };
3016
+ var schemes = Array.isArray(props.schemes) ? props.schemes : [];
3017
+ var activeId = props.activeId || "";
3018
+ var busy = Boolean(props.busy);
3019
+ var [editing, setEditing] = React.useState(null);
3020
+ var [name, setName] = React.useState("");
3021
+ var [from, setFrom] = React.useState("current");
3022
+ function begin(mode) {
3023
+ var current = schemes.filter(function(s) {
3024
+ return s.id === activeId;
3025
+ })[0];
3026
+ setName(mode === "rename" && current ? current.name : "");
3027
+ setFrom(current ? "current" : "default");
3028
+ setEditing(mode);
3029
+ }
3030
+ function submit(event) {
3031
+ if (event && event.preventDefault) event.preventDefault();
3032
+ var value = String(name || "").trim();
3033
+ if (!value || busy) return;
3034
+ if (editing === "rename") props.onRename(activeId, value);
3035
+ else props.onCreate(value, from);
3036
+ setEditing(null);
3037
+ setName("");
3038
+ }
3039
+ function remove() {
3040
+ if (typeof window !== "undefined" && window.confirm && !window.confirm(c.confirmDelete)) return;
3041
+ props.onDelete(activeId);
3042
+ }
3043
+ return h(
3044
+ "div",
3045
+ { className: prefix + "-cfg-schemes" },
3046
+ h(
3047
+ "div",
3048
+ { className: prefix + "-cfg-schemes-main" },
3049
+ h("span", { className: prefix + "-cfg-schemes-label" }, c.title),
3050
+ h(
3051
+ "select",
3052
+ {
3053
+ className: prefix + "-cfg-schemes-select",
3054
+ value: activeId,
3055
+ disabled: busy,
3056
+ onChange: function(event) {
3057
+ props.onActivate(event.target.value || null);
3058
+ },
3059
+ "aria-label": c.title
3060
+ },
3061
+ h("option", { value: "" }, c.none),
3062
+ schemes.map(function(s) {
3063
+ return h("option", { key: s.id, value: s.id }, s.name);
3064
+ })
3065
+ ),
3066
+ h("span", { className: prefix + "-cfg-schemes-hint" }, activeId ? c.current : "")
3067
+ ),
3068
+ editing ? h(
3069
+ "form",
3070
+ { className: prefix + "-cfg-schemes-form", onSubmit: submit },
3071
+ h("span", { className: prefix + "-cfg-schemes-label" }, editing === "rename" ? c.renameTitle : c.createTitle),
3072
+ h("input", {
3073
+ className: prefix + "-cfg-schemes-input",
3074
+ value: name,
3075
+ placeholder: c.namePlaceholder,
3076
+ maxLength: 64,
3077
+ autoFocus: true,
3078
+ disabled: busy,
3079
+ onChange: function(event) {
3080
+ setName(event.target.value);
3081
+ }
3082
+ }),
3083
+ editing === "create" && activeId ? h(
3084
+ "select",
3085
+ { className: prefix + "-cfg-schemes-select", value: from, disabled: busy, onChange: function(event) {
3086
+ setFrom(event.target.value);
3087
+ }, "aria-label": c.createTitle },
3088
+ h("option", { value: "current" }, c.fromCurrent),
3089
+ h("option", { value: "default" }, c.fromDefault)
3090
+ ) : null,
3091
+ h("button", { className: prefix + "-cfg-sbtn", type: "submit", disabled: busy || !String(name || "").trim() }, c.ok),
3092
+ h("button", { className: prefix + "-cfg-sbtn", type: "button", disabled: busy, onClick: function() {
3093
+ setEditing(null);
3094
+ } }, c.cancel)
3095
+ ) : h(
3096
+ "div",
3097
+ { className: prefix + "-cfg-schemes-actions" },
3098
+ h("button", { className: prefix + "-cfg-sbtn", type: "button", disabled: busy, onClick: function() {
3099
+ begin("create");
3100
+ } }, c.create),
3101
+ activeId ? h("button", { className: prefix + "-cfg-sbtn", type: "button", disabled: busy, onClick: function() {
3102
+ begin("rename");
3103
+ } }, c.rename) : null,
3104
+ activeId ? h("button", { className: prefix + "-cfg-sbtn danger", type: "button", disabled: busy, onClick: remove }, c.remove) : null
3105
+ ),
3106
+ h("div", { className: prefix + "-cfg-schemes-hint" }, activeId ? c.syncedHint : c.defaultHint)
3107
+ );
3108
+ }
3109
+ module2.exports = { SchemeBar, styles: styles2, COPY };
3110
+ }
3111
+ });
3112
+
2949
3113
  // packages/addons/danmaku/client/views/config.cjs
2950
3114
  var require_config = __commonJS({
2951
3115
  "packages/addons/danmaku/client/views/config.cjs"(exports2, module2) {
@@ -2956,7 +3120,11 @@ var require_config = __commonJS({
2956
3120
  var copy = require_copy();
2957
3121
  var SW = require_switch();
2958
3122
  var NF = require_number_field();
3123
+ var SB = require_config_scheme_bar();
2959
3124
  var DOMAIN = "danmaku";
3125
+ var SCHEME_CSS = [
3126
+ ".wbdm-wrap{--cfg-line:var(--wb-border,var(--dsw-alias-border-l2,color-mix(in oklab,currentColor 16%,transparent)));--cfg-surface:var(--wb-card,var(--wb-surface,var(--dsw-alias-bg-layer-1,transparent)));--cfg-muted:var(--wb-muted,var(--dsw-alias-label-secondary,color-mix(in oklab,currentColor 62%,transparent)));--cfg-hover:var(--dsw-alias-interactive-bg-hover,color-mix(in oklab,currentColor 5%,transparent))}"
3127
+ ].concat(SB.styles).join("\n").split("__P__").join("wbdm");
2960
3128
  var ICONS = {
2961
3129
  check: GLYPHS2["check"],
2962
3130
  power: GLYPHS2["power"],
@@ -2990,12 +3158,13 @@ var require_config = __commonJS({
2990
3158
  if (!body || !body.values) throw new Error("empty config");
2991
3159
  setState({
2992
3160
  ready: true,
2993
- values: Object.assign({}, fallback || {}, body.values),
3161
+ values: Object.assign({}, fallback || {}, body.values || {}),
2994
3162
  items: body.items || [],
2995
3163
  groups: body.groups || [],
2996
3164
  overrides: body.overrides || {},
2997
3165
  warnings: body.warnings || [],
2998
- error: ""
3166
+ error: "",
3167
+ state: body
2999
3168
  });
3000
3169
  }).catch(function(e) {
3001
3170
  if (!alive) return;
@@ -3013,7 +3182,20 @@ var require_config = __commonJS({
3013
3182
  return Object.assign({}, prev, { values: Object.assign({}, prev.values, next) });
3014
3183
  });
3015
3184
  }
3016
- return Object.assign({}, state, { setValues });
3185
+ function setBody(body) {
3186
+ if (!body) return;
3187
+ setState({
3188
+ ready: true,
3189
+ values: Object.assign({}, fallback || {}, body.values || {}),
3190
+ items: body.items || [],
3191
+ groups: body.groups || [],
3192
+ overrides: body.overrides || {},
3193
+ warnings: body.warnings || [],
3194
+ error: "",
3195
+ state: body
3196
+ });
3197
+ }
3198
+ return Object.assign({}, state, { setValues, setBody });
3017
3199
  }
3018
3200
  function labelOf(item, lang) {
3019
3201
  return lang === "en" ? item.en || item.zh || item.id : item.zh || item.en || item.id;
@@ -3165,9 +3347,24 @@ var require_config = __commonJS({
3165
3347
  var toastS = React.useState("");
3166
3348
  var toast = toastS[0];
3167
3349
  var setToast = toastS[1];
3350
+ var schemeBusyS = React.useState(false);
3351
+ var schemeBusy = schemeBusyS[0];
3352
+ var setSchemeBusy = schemeBusyS[1];
3353
+ var schemeNote = lang === "en" ? "Schemes sync to the cloud and travel with backups; which scheme this device uses stays local" : "\u914D\u7F6E\u65B9\u6848\u4F1A\u968F\u4E91\u7AEF\u540C\u6B65\u4E0E\u5907\u4EFD\uFF1B\u5F53\u524D\u9009\u4E2D\u54EA\u4E2A\u65B9\u6848\u53EA\u4FDD\u5B58\u5728\u672C\u673A";
3168
3354
  var seqRef = React.useRef(0);
3169
3355
  var aliveRef = React.useRef(true);
3170
3356
  React.useEffect(function() {
3357
+ if (typeof document !== "undefined") {
3358
+ var old = document.getElementById("wb-addon-danmaku-config-scheme-css");
3359
+ if (old) {
3360
+ old.textContent = SCHEME_CSS;
3361
+ } else {
3362
+ var el = document.createElement("style");
3363
+ el.id = "wb-addon-danmaku-config-scheme-css";
3364
+ el.textContent = SCHEME_CSS;
3365
+ document.head.appendChild(el);
3366
+ }
3367
+ }
3171
3368
  aliveRef.current = true;
3172
3369
  return function() {
3173
3370
  aliveRef.current = false;
@@ -3205,6 +3402,24 @@ var require_config = __commonJS({
3205
3402
  toastOnce(String(e && e.message || e));
3206
3403
  });
3207
3404
  }
3405
+ function schemeCall(action, args) {
3406
+ setSchemeBusy(true);
3407
+ return Promise.resolve(api.call(DOMAIN + "." + action, args || {})).then(function(r) {
3408
+ if (r && r.ok === false) throw new Error(r && r.error || C.saveFail);
3409
+ var body = unwrap(r) || {};
3410
+ var next = body.state || body;
3411
+ if (next && typeof cfg.setBody === "function") {
3412
+ cfg.setBody(next);
3413
+ seqRef.current += 1;
3414
+ setLocal({});
3415
+ }
3416
+ toastOnce(C.saved);
3417
+ }).catch(function(e) {
3418
+ toastOnce(String(e && e.message || e));
3419
+ }).then(function() {
3420
+ setSchemeBusy(false);
3421
+ });
3422
+ }
3208
3423
  function resetAll() {
3209
3424
  Promise.resolve(api.call(DOMAIN + ".configReset", {})).then(function(r) {
3210
3425
  if (r && r.ok === false) throw new Error(r && r.error || C.saveFail);
@@ -3285,7 +3500,7 @@ var require_config = __commonJS({
3285
3500
  "div",
3286
3501
  { className: "wbdm-hero-main" },
3287
3502
  h("div", { className: "wbdm-title" }, C.configTitle),
3288
- h("div", { className: "wbdm-sub" }, C.configHint)
3503
+ h("div", { className: "wbdm-sub" }, schemeNote)
3289
3504
  ),
3290
3505
  h(
3291
3506
  "button",
@@ -3331,6 +3546,26 @@ var require_config = __commonJS({
3331
3546
  "div",
3332
3547
  { className: "wbdm-wrap" },
3333
3548
  head,
3549
+ h(SB.SchemeBar, {
3550
+ key: "schemes",
3551
+ lang,
3552
+ prefix: "wbdm",
3553
+ schemes: cfg.state && cfg.state.schemes || [],
3554
+ activeId: cfg.state && cfg.state.scheme ? cfg.state.scheme.id : "",
3555
+ busy: schemeBusy,
3556
+ onActivate: function(id) {
3557
+ schemeCall("configSchemeActivate", { id: id || "" });
3558
+ },
3559
+ onCreate: function(name, from) {
3560
+ schemeCall("configSchemeCreate", { name, from: from || "current" });
3561
+ },
3562
+ onRename: function(id, name) {
3563
+ schemeCall("configSchemeRename", { id, name });
3564
+ },
3565
+ onDelete: function(id) {
3566
+ schemeCall("configSchemeDelete", { id });
3567
+ }
3568
+ }),
3334
3569
  toast ? h("div", { className: "wbdm-notice ok" }, toast) : null,
3335
3570
  cfg.warnings && cfg.warnings.length ? h("div", { className: "wbdm-notice warn" }, cfg.warnings.join("\uFF1B")) : null,
3336
3571
  sections,
@@ -3342,1048 +3577,6 @@ var require_config = __commonJS({
3342
3577
  }
3343
3578
  });
3344
3579
 
3345
- // packages/addons/lib/data-copy.cjs
3346
- var require_data_copy = __commonJS({
3347
- "packages/addons/lib/data-copy.cjs"(exports2, module2) {
3348
- "use strict";
3349
- var COPY = {
3350
- zh: {
3351
- title: "\u6570\u636E",
3352
- subtitle: "\u53EA\u8BFB\u6D4F\u89C8\u672C\u63D2\u4EF6\u8D1F\u8D23\u7684\u8868\uFF1B\u7CFB\u7EDF\u5217\u4E0E\u5DF2\u5220\u9664\u884C\u9ED8\u8BA4\u9690\u85CF",
3353
- tables: "\u8868",
3354
- rows: "\u884C",
3355
- deleted: "\u5DF2\u5220\u9664",
3356
- rowCount: "\u5171 {n} \u884C",
3357
- deletedCount: "\u5176\u4E2D {n} \u884C\u5DF2\u5220\u9664",
3358
- search: "\u641C\u7D22\u6240\u6709\u6587\u672C\u5217\u2026",
3359
- pageSize: "\u6BCF\u9875",
3360
- includeDeleted: "\u542B\u5DF2\u5220\u9664",
3361
- showSystem: "\u7CFB\u7EDF\u5217",
3362
- refresh: "\u5237\u65B0",
3363
- loading: "\u8F7D\u5165\u4E2D\u2026",
3364
- empty: "\u8FD9\u5F20\u8868\u8FD8\u6CA1\u6709\u6570\u636E",
3365
- emptyTable: "\u6CA1\u6709\u53EF\u5C55\u793A\u7684\u8868",
3366
- loadFail: "\u6570\u636E\u670D\u52A1\u4E0D\u53EF\u7528\uFF08\u63D2\u4EF6\u7248\u672C\u8FC7\u65E7\uFF1F\uFF09",
3367
- retry: "\u91CD\u8BD5",
3368
- queryFail: "\u67E5\u8BE2\u5931\u8D25\uFF1A",
3369
- noRows: "\u6CA1\u6709\u5339\u914D\u7684\u884C",
3370
- prev: "\u4E0A\u4E00\u9875",
3371
- next: "\u4E0B\u4E00\u9875",
3372
- pageInfo: "\u7B2C {page} / {pages} \u9875",
3373
- jump: "\u8DF3\u8F6C",
3374
- total: "\u5171 {n} \u884C",
3375
- copied: "\u5DF2\u590D\u5236",
3376
- copy: "\u590D\u5236",
3377
- close: "\u5173\u95ED",
3378
- drawerTitle: "{column} \xB7 \u7B2C {row} \u884C",
3379
- nullText: "NULL",
3380
- emptyText: "\u7A7A",
3381
- yes: "\u662F",
3382
- no: "\u5426",
3383
- json: "JSON",
3384
- queryTime: "{n} ms",
3385
- sortAsc: "\u5347\u5E8F",
3386
- sortDesc: "\u964D\u5E8F",
3387
- filterCol: "\u7B5B\u9009\u2026",
3388
- filterClear: "\u6E05\u9664\u7B5B\u9009",
3389
- index: "\u8868\u7D22\u5F15",
3390
- indexSub: "\u5F53\u524D\u9009\u4E2D\u8868\u7684\u7D22\u5F15\uFF08\u53EA\u8BFB\uFF09\uFF1B\u884C\u6570\u4E3A\u6240\u5C5E\u8868\u603B\u884C\u6570\uFF0C\u4E0D\u662F\u7D22\u5F15\u6761\u76EE\u6570",
3391
- idxName: "\u7D22\u5F15\u540D",
3392
- idxColumns: "\u5217",
3393
- idxType: "\u7C7B\u578B",
3394
- idxSource: "\u6765\u6E90",
3395
- idxUnique: "\u552F\u4E00",
3396
- idxNormal: "\u666E\u901A",
3397
- idxAuto: "\u81EA\u52A8",
3398
- idxCreated: "\u663E\u5F0F\u521B\u5EFA",
3399
- idxCount: "\u5171 {n} \u4E2A\u7D22\u5F15",
3400
- idxNoExtra: "\u8BE5\u8868\u9664\u4E3B\u952E\u5916\u6CA1\u6709\u989D\u5916\u7D22\u5F15",
3401
- idxRowsHelp: "\u6240\u5C5E\u8868\u603B\u884C\u6570\uFF08\u542B\u5DF2\u5220\u9664\u884C\uFF09\uFF0C\u4E0D\u662F\u7D22\u5F15\u6761\u76EE\u6570",
3402
- idxTable: "\u8868",
3403
- idxRows: "\u884C\u6570",
3404
- idxCols: "\u5217\u6570",
3405
- idxKey: "\u4E3B\u952E",
3406
- idxIndexes: "\u7D22\u5F15",
3407
- idxLastWrite: "\u6700\u8FD1\u5199\u5165",
3408
- idxNone: "\u65E0",
3409
- idxEmpty: "\u5F53\u524D\u8868\u6CA1\u6709\u53EF\u7528\u7684\u7D22\u5F15\u7EDF\u8BA1",
3410
- idxTables: "\u8868",
3411
- idxAt: "\u7EDF\u8BA1\u65F6\u95F4"
3412
- },
3413
- en: {
3414
- title: "Data",
3415
- subtitle: "Read-only view of this plugin's tables; system and deleted rows are hidden by default",
3416
- tables: "Tables",
3417
- rows: "rows",
3418
- deleted: "deleted",
3419
- rowCount: "{n} rows",
3420
- deletedCount: "{n} deleted",
3421
- search: "Search all text columns\u2026",
3422
- pageSize: "Rows",
3423
- includeDeleted: "Deleted",
3424
- showSystem: "System",
3425
- refresh: "Refresh",
3426
- loading: "Loading\u2026",
3427
- empty: "This table has no rows yet",
3428
- emptyTable: "No tables to show",
3429
- loadFail: "Data service unavailable (plugin too old?)",
3430
- retry: "Retry",
3431
- queryFail: "Query failed: ",
3432
- noRows: "No matching rows",
3433
- prev: "Previous",
3434
- next: "Next",
3435
- pageInfo: "Page {page} / {pages}",
3436
- jump: "Jump",
3437
- total: "{n} rows",
3438
- copied: "Copied",
3439
- copy: "Copy",
3440
- close: "Close",
3441
- drawerTitle: "{column} \xB7 row {row}",
3442
- nullText: "NULL",
3443
- emptyText: "empty",
3444
- yes: "Yes",
3445
- no: "No",
3446
- json: "JSON",
3447
- queryTime: "{n} ms",
3448
- sortAsc: "ascending",
3449
- sortDesc: "descending",
3450
- filterCol: "Filter\u2026",
3451
- filterClear: "Clear filter",
3452
- index: "Table index",
3453
- indexSub: "Indexes of the selected table (read-only); rows are the table total, not index entries",
3454
- idxName: "Index name",
3455
- idxColumns: "Columns",
3456
- idxType: "Type",
3457
- idxSource: "Source",
3458
- idxUnique: "Unique",
3459
- idxNormal: "Normal",
3460
- idxAuto: "Automatic",
3461
- idxCreated: "Explicit",
3462
- idxCount: "{n} indexes",
3463
- idxNoExtra: "This table has no indexes other than its primary key",
3464
- idxRowsHelp: "Total table rows (including deleted rows), not index entries",
3465
- idxTable: "Table",
3466
- idxRows: "Rows",
3467
- idxCols: "Cols",
3468
- idxKey: "Primary key",
3469
- idxIndexes: "Indexes",
3470
- idxLastWrite: "Last write",
3471
- idxNone: "\u2014",
3472
- idxEmpty: "No index statistics available for this table",
3473
- idxTables: "Tables",
3474
- idxAt: "Generated"
3475
- }
3476
- };
3477
- module2.exports = COPY;
3478
- }
3479
- });
3480
-
3481
- // packages/addons/lib/visual-tokens.cjs
3482
- var require_visual_tokens = __commonJS({
3483
- "packages/addons/lib/visual-tokens.cjs"(exports2, module2) {
3484
- module2.exports = `
3485
- :where(.wbt-root,.wbi-root,.wbi-cfg,.wbt-data,.wbs-data,.wbg-data,.wbi-data,.wb-desc){--wb-radius-sm:8px;--wb-radius-card:12px;--wb-space-sm:8px;--wb-space-md:14px;--wb-border:var(--dsw-alias-border-l2,color-mix(in oklab,currentColor 16%,transparent));--wb-description-bg:color-mix(in oklab,var(--dsw-alias-brand-primary,#5b7fd6) 7%,transparent);--wb-description-line:color-mix(in oklab,var(--dsw-alias-brand-primary,#5b7fd6) 34%,transparent);--wb-motion:140ms;--wb-btn-bg:transparent;--wb-btn-hover-bg:color-mix(in oklab,currentColor 6%,transparent);--wb-btn-active-bg:color-mix(in oklab,currentColor 11%,transparent);--wb-btn-primary-bg:var(--dsw-alias-brand-primary,#2563eb);--wb-btn-primary-fg:var(--dsw-alias-label-primary-inverted,#fff);--wb-btn-danger-fg:var(--dsw-alias-state-error-primary,#b91c1c);--wb-btn-size-sm:32px;--wb-btn-focus:2px solid var(--dsw-alias-brand-primary,#2563eb);--wb-btn-focus-offset:2px}
3486
- .wb-desc{background:var(--wb-description-bg);border-left-color:var(--wb-description-line);border-radius:0 var(--wb-radius-sm) var(--wb-radius-sm) 0}
3487
- `;
3488
- }
3489
- });
3490
-
3491
- // packages/addons/lib/data-style.cjs
3492
- var require_data_style = __commonJS({
3493
- "packages/addons/lib/data-style.cjs"(exports2, module2) {
3494
- "use strict";
3495
- module2.exports = function(DOMAIN, PREFIX) {
3496
- var P = PREFIX + "-data";
3497
- var CSS = [
3498
- require_visual_tokens(),
3499
- "." + P + "-search:has(.wbi-svg) input{padding-left:30px}." + P + "-search>.wbi-svg{position:absolute;left:10px;top:50%;transform:translateY(-50%)}",
3500
- "." + P + "-btn{transition:background var(--wb-motion),border-color var(--wb-motion)}",
3501
- "@media(max-width:480px){." + P + "-head>." + P + "-btn:has(.wbi-svg){width:32px;height:32px;padding:0;justify-content:center}." + P + "-head>." + P + "-btn:has(.wbi-svg) ." + P + "-btnlabel{display:none}}",
3502
- "." + P + "{--cfg-line:var(--wb-border);--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:grid;grid-template-columns:216px minmax(0,1fr);gap:16px;width:100%;min-width:0;color:inherit;font-size:13px;align-items:start}",
3503
- "." + P + "-side{position:sticky;top:12px;display:flex;flex-direction:column;gap:3px;border:1px solid var(--cfg-line);border-radius:var(--wb-radius-card);background:var(--cfg-surface);padding:8px;box-shadow:0 1px 2px color-mix(in oklab,currentColor 3%,transparent)}",
3504
- "." + P + "-sidetitle{display:flex;align-items:center;justify-content:space-between;padding:6px 10px 8px;font-size:11px;font-weight:660;letter-spacing:.6px;text-transform:uppercase;color:var(--cfg-faint)}",
3505
- "." + P + "-stab{display:flex;flex-direction:column;gap:3px;align-items:stretch;border:1px solid transparent;background:transparent;border-radius:9px;padding:8px 10px;font:inherit;color:inherit;text-align:left;cursor:pointer;position:relative;transition:background .12s ease,border-color .12s ease}",
3506
- "." + P + "-stab:hover{background:var(--cfg-hover)}",
3507
- "." + P + "-stab:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,currentColor);outline-offset:2px}",
3508
- "." + P + "-stab.on{background:color-mix(in oklab,currentColor 6%,transparent);border-color:var(--cfg-line)}",
3509
- "." + P + "-stab.on::before{content:'';position:absolute;left:-1px;top:9px;bottom:9px;width:2px;border-radius:2px;background:var(--dsw-alias-brand-primary,currentColor)}",
3510
- "." + P + "-stabname{display:flex;align-items:center;gap:6px;font-size:12.5px;font-weight:600;line-height:1.4;min-width:0}",
3511
- "." + P + "-stabname span:first-child{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}",
3512
- "." + P + "-sidetable{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:10.5px;color:var(--cfg-muted);margin-top:3px;letter-spacing:.2px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}",
3513
- "." + P + "-sidecount{margin-left:auto;font-size:10.5px;font-variant-numeric:tabular-nums;color:var(--cfg-muted);background:color-mix(in oklab,currentColor 8%,transparent);border-radius:999px;padding:1px 7px;flex:none}",
3514
- "." + P + "-main{display:flex;flex-direction:column;gap:10px;min-width:0;border:1px solid var(--cfg-line);border-radius:var(--wb-radius-card);background:var(--cfg-surface);padding:14px 16px 12px;box-shadow:0 1px 2px color-mix(in oklab,currentColor 3%,transparent)}",
3515
- "." + P + "-head{display:flex;align-items:flex-start;gap:12px;flex-wrap:wrap}",
3516
- "." + P + "-headmain{min-width:0;flex:1}",
3517
- "." + P + "-head h2{margin:0;font-size:16px;font-weight:660;letter-spacing:.1px;display:flex;align-items:center;gap:8px;flex-wrap:wrap}",
3518
- "." + P + "-code{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:11px;font-weight:500;color:var(--cfg-muted);background:color-mix(in oklab,currentColor 6%,transparent);border-radius:6px;padding:2px 6px}",
3519
- "." + P + "-sub{font-size:11.5px;color:var(--cfg-muted);line-height:1.55;margin-top:4px}",
3520
- "." + P + "-toolbar{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding:2px 0 4px}",
3521
- "." + P + "-search{position:relative;flex:1;min-width:180px;max-width:340px}",
3522
- "." + P + "-search input{width:100%;border:1px solid var(--cfg-line);background:var(--dsw-alias-bg-base,transparent);color:inherit;border-radius:9px;padding:8px 11px;font:inherit;font-size:12.5px;outline:none;transition:border-color .15s ease,box-shadow .15s ease}",
3523
- "." + P + "-search input:hover{border-color:color-mix(in oklab,currentColor 28%,var(--cfg-line))}",
3524
- "." + 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)}",
3525
- "." + 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}",
3526
- "." + 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)}",
3527
- "." + 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}",
3528
- "." + P + "-btn:hover{background:var(--cfg-hover);color:var(--dsw-alias-label-primary,inherit)}",
3529
- "." + P + "-btn:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,currentColor);outline-offset:2px}",
3530
- "." + P + "-btn:disabled{opacity:.45;cursor:not-allowed}",
3531
- "." + P + "-btn[aria-busy='true']{opacity:.6}",
3532
- "." + P + "-tablewrap{overflow:auto;max-height:calc(100vh - 300px);border:1px solid var(--cfg-line);border-radius:11px;background:var(--dsw-alias-bg-base,transparent)}",
3533
- "." + P + "-table{border-collapse:separate;border-spacing:0;width:max-content;min-width:100%;font-size:12.5px}",
3534
- "." + P + "-table th{position:sticky;top:0;z-index:2;background:var(--cfg-surface);border-bottom:1px solid var(--cfg-line);padding:0;text-align:left;font-weight:600;white-space:nowrap}",
3535
- "." + P + "-thbtn{display:flex;align-items:baseline;gap:6px;width:100%;border:0;background:transparent;color:inherit;font:inherit;font-size:11.5px;font-weight:660;letter-spacing:.2px;padding:9px 12px;cursor:pointer;text-align:left;white-space:nowrap}",
3536
- "." + P + "-thbtn:hover{background:var(--cfg-hover)}",
3537
- "." + P + "-thbtn:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,currentColor);outline-offset:-2px}",
3538
- "." + P + "-coltype{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:9.5px;font-weight:500;color:var(--cfg-faint);letter-spacing:.3px}",
3539
- "." + P + "-sortmark{color:var(--dsw-alias-brand-primary,currentColor);font-size:10px}",
3540
- "." + P + "-rownum{position:sticky;left:0;z-index:1;background:var(--cfg-surface);color:var(--cfg-faint);text-align:right;font-variant-numeric:tabular-nums;font-size:10.5px;padding:0 8px;width:1%;white-space:nowrap;border-right:1px solid color-mix(in oklab,currentColor 7%,transparent)}",
3541
- "." + P + "-table thead ." + P + "-rownum{z-index:3}",
3542
- "." + P + "-cell{padding:7px 12px;border-bottom:1px solid color-mix(in oklab,currentColor 6%,transparent);max-width:340px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;cursor:default;vertical-align:top}",
3543
- "." + P + "-table tbody tr:hover ." + P + "-cell{background:var(--cfg-hover)}",
3544
- "." + P + "-table tbody tr:nth-child(even) ." + P + "-cell,." + P + "-table tbody tr:nth-child(even) ." + P + "-rownum{background:color-mix(in oklab,currentColor 2.5%,transparent)}",
3545
- "." + P + "-cell.num{text-align:right;font-variant-numeric:tabular-nums}",
3546
- "." + P + "-cell.mono{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:11.5px}",
3547
- "." + P + "-cell.null{color:var(--cfg-faint);font-style:italic}",
3548
- "." + P + "-cell.json .v{color:var(--dsw-alias-brand-primary,inherit)}",
3549
- "." + P + "-tr.deleted ." + P + "-cell,." + P + "-tr.deleted ." + P + "-rownum{opacity:.55}",
3550
- "." + P + "-tr.deleted ." + P + "-cell .v{text-decoration:line-through;text-decoration-color:color-mix(in oklab,currentColor 35%,transparent)}",
3551
- "." + P + "-delbadge{display:inline-block;margin-left:6px;font-size:9.5px;line-height:1.5;padding:0 5px;border-radius:999px;background:color-mix(in oklab,var(--dsw-alias-state-error-primary,currentColor) 14%,transparent);color:var(--dsw-alias-state-error-primary,inherit);vertical-align:middle}",
3552
- "." + P + "-foot{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding-top:2px;font-size:11.5px;color:var(--cfg-muted)}",
3553
- "." + P + "-grow{flex:1}",
3554
- "." + P + "-pageinfo{font-variant-numeric:tabular-nums}",
3555
- "." + P + "-jump .wbctl-num-input{width:56px;padding:4px 7px;font-size:11.5px;text-align:right}",
3556
- "." + P + "-jump .wbctl-num-hint{display:none}",
3557
- "." + 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)}",
3558
- "." + 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}",
3559
- "." + P + "-skwrap{display:flex;flex-direction:column;gap:1px;padding:2px}",
3560
- "." + P + "-sk{height:26px;border-radius:4px;background:var(--dsw-alias-bg-skeleton,color-mix(in oklab,currentColor 6%,transparent));animation:" + PREFIX + "-data-pulse 1.4s ease-in-out infinite}",
3561
- "@keyframes " + PREFIX + "-data-pulse{0%,100%{opacity:.6}50%{opacity:1}}",
3562
- "." + P + "-toast{position:fixed;left:50%;bottom:26px;transform:translateX(-50%);z-index:40;background:var(--dsw-alias-bg-layer-1,var(--cfg-surface));border:1px solid var(--cfg-line);border-radius:999px;padding:7px 14px;font-size:12px;color:var(--dsw-alias-label-primary,inherit);box-shadow:0 6px 24px color-mix(in oklab,currentColor 18%,transparent)}",
3563
- "." + P + "-mask{position:fixed;inset:0;z-index:30;background:color-mix(in oklab,currentColor 26%,transparent)}",
3564
- "." + P + "-drawer{position:fixed;top:0;right:0;bottom:0;z-index:31;width:min(520px,92vw);display:flex;flex-direction:column;gap:12px;background:var(--dsw-alias-bg-layer-1,var(--cfg-surface));border-left:1px solid var(--cfg-line);box-shadow:-8px 0 28px color-mix(in oklab,currentColor 16%,transparent);padding:18px 20px}",
3565
- "." + P + "-drawer h3{margin:0;font-size:14px;font-weight:660;display:flex;align-items:center;gap:8px;flex-wrap:wrap}",
3566
- "." + P + "-drawer pre{margin:0;flex:1;overflow:auto;border:1px solid var(--cfg-line);border-radius:10px;background:var(--dsw-alias-bg-base,transparent);padding:12px 14px;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:12px;line-height:1.65;white-space:pre-wrap;word-break:break-word}",
3567
- "." + P + "-drawerfoot{display:flex;gap:8px;justify-content:flex-end}",
3568
- "." + P + "-sr{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}",
3569
- "@media (max-width:900px){." + P + "{grid-template-columns:minmax(0,1fr)}." + P + "-side{position:static;flex-direction:row;flex-wrap:wrap;gap:6px;padding:6px}." + P + "-sidetitle{display:none}." + P + "-stab{padding:6px 10px;flex:none}." + P + "-sidecount{display:none}." + P + "-tablewrap{max-height:calc(100vh - 260px)}}",
3570
- "@media (prefers-reduced-motion:reduce){." + P + " *,." + P + "-track,." + P + "-track::after,." + P + "-sk,." + P + "-drawer{transition:none;animation:none}}",
3571
- "." + P + "-idxsub{font-size:11.5px;color:var(--cfg-muted);line-height:1.55}",
3572
- "." + P + "-idxsum{display:flex;gap:16px;flex-wrap:wrap;font-size:11.5px;color:var(--cfg-muted)}",
3573
- "." + P + "-idxsum b{font-weight:660;color:var(--dsw-alias-label-primary,inherit);font-variant-numeric:tabular-nums}",
3574
- "." + P + "-idxtable{width:100%;table-layout:fixed}." + P + "-idxtable ." + P + "-cell{white-space:normal;overflow-wrap:anywhere;max-width:none}." + P + "-idxtable th:first-child{width:30%}." + P + "-idxtable th:nth-child(2){width:28%}",
3575
- "." + P + "-idxtags{display:flex;flex-wrap:wrap;gap:4px;max-width:280px}",
3576
- "." + P + "-idxchip{display:inline-block;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:10px;line-height:1.6;border-radius:999px;padding:0 7px;background:color-mix(in oklab,currentColor 7%,transparent);color:var(--cfg-muted);white-space:nowrap}",
3577
- "." + P + "-idxchip.u{background:color-mix(in oklab,var(--dsw-alias-brand-primary,currentColor) 15%,transparent);color:var(--dsw-alias-brand-primary,inherit)}",
3578
- "." + P + "-idxnone{color:var(--cfg-faint)}",
3579
- "." + P + "-frow th{padding:0 8px 6px;border-bottom:1px solid var(--cfg-line)}",
3580
- "." + P + "-fcell{position:relative;display:block;min-width:96px}",
3581
- "." + P + "-finput{width:100%;box-sizing:border-box;border:1px solid transparent;border-radius:6px;background:color-mix(in oklab,currentColor 4%,transparent);color:inherit;font:inherit;font-size:11.5px;padding:3px 18px 3px 6px;min-width:0}",
3582
- "." + P + "-finput:hover{background:color-mix(in oklab,currentColor 7%,transparent)}",
3583
- "." + P + "-finput:focus{outline:none;border-color:var(--dsw-alias-brand-primary,currentColor);background:var(--cfg-surface)}",
3584
- "." + P + "-fclear{position:absolute;right:2px;top:50%;transform:translateY(-50%);border:0;background:transparent;color:var(--cfg-muted);cursor:pointer;font-size:13px;line-height:1;padding:2px 4px;border-radius:4px}",
3585
- "." + P + "-fclear:hover{color:inherit;background:var(--cfg-hover)}",
3586
- "." + P + "-emptycell{padding:22px 12px;text-align:center;color:var(--cfg-muted)}",
3587
- "." + P + " *{box-sizing:border-box}",
3588
- "." + P + "-tabs{display:flex;gap:6px;border-bottom:1px solid var(--cfg-line);padding-bottom:9px}",
3589
- "." + P + "-tabs [aria-selected=true]{background:var(--cfg-hover);color:inherit;font-weight:660}",
3590
- "." + P + "-images{display:flex;gap:5px;align-items:center}",
3591
- "." + P + "-images img{width:36px;height:36px;object-fit:cover;border-radius:5px}",
3592
- "." + P + "-gallery{display:flex;flex-direction:column;gap:12px;overflow:auto;flex:1}",
3593
- "." + P + "-gallery img{width:100%;height:auto;object-fit:contain;border-radius:8px}"
3594
- ].concat(require_switch().styles).concat(require_number_field().styles).join("\n");
3595
- if (DOMAIN === "storage") {
3596
- var buttons = "." + P + " :is(button)";
3597
- 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}";
3598
- }
3599
- function injectCss() {
3600
- if (typeof document === "undefined") return;
3601
- var old = document.getElementById("wb-addon-" + DOMAIN + "-data-css");
3602
- if (old) {
3603
- old.textContent = CSS;
3604
- return;
3605
- }
3606
- var style = document.createElement("style");
3607
- style.id = "wb-addon-" + DOMAIN + "-data-css";
3608
- style.setAttribute("data-wb-addon", "wb-addon-" + DOMAIN);
3609
- style.textContent = CSS;
3610
- document.head.appendChild(style);
3611
- }
3612
- return injectCss;
3613
- };
3614
- }
3615
- });
3616
-
3617
- // packages/addons/lib/data-view.cjs
3618
- var require_data_view = __commonJS({
3619
- "packages/addons/lib/data-view.cjs"(exports2, module2) {
3620
- "use strict";
3621
- var React = require("react");
3622
- var NF = require_number_field();
3623
- var h = React.createElement;
3624
- var COPY = require_data_copy();
3625
- var SW = require_switch();
3626
- module2.exports = function createDataView(options) {
3627
- var DOMAIN = options.domain;
3628
- function icon(name) {
3629
- return options.Icon ? h(options.Icon, { name }) : null;
3630
- }
3631
- var P = options.prefix + "-data";
3632
- var configView = { useConfig: options.useConfig };
3633
- var columnHooks = options.columns || {};
3634
- var injectCss = require_data_style()(DOMAIN, options.prefix);
3635
- var CFG_FALLBACK = {
3636
- "data.pageSize": 50,
3637
- "data.showSystemColumns": false,
3638
- "data.includeDeleted": false
3639
- };
3640
- var PAGE_SIZES = [10, 25, 50, 100, 200];
3641
- function unwrap(r) {
3642
- return r && r.result !== void 0 ? r.result : r;
3643
- }
3644
- function fmt(template, vars) {
3645
- return String(template).replace(/\{(\w+)\}/g, function(m, key) {
3646
- return vars[key] === void 0 ? m : String(vars[key]);
3647
- });
3648
- }
3649
- function pad2(n) {
3650
- return n < 10 ? "0" + n : String(n);
3651
- }
3652
- function timeText(ms) {
3653
- var d = new Date(Number(ms));
3654
- if (!Number.isFinite(d.getTime())) return String(ms);
3655
- return d.getFullYear() + "-" + pad2(d.getMonth() + 1) + "-" + pad2(d.getDate()) + " " + pad2(d.getHours()) + ":" + pad2(d.getMinutes());
3656
- }
3657
- function looksJson(value) {
3658
- var text = String(value).trim();
3659
- if (!text || text[0] !== "{" && text[0] !== "[") return false;
3660
- try {
3661
- JSON.parse(text);
3662
- return true;
3663
- } catch (e) {
3664
- return false;
3665
- }
3666
- }
3667
- function rawText(value, col) {
3668
- if (value === null || value === void 0) return "";
3669
- return String(value);
3670
- }
3671
- function DataView(props) {
3672
- var api = props.api;
3673
- var lang = props.lang === "en" ? "en" : "zh";
3674
- var t = Object.assign({}, COPY[lang], { indexSub: fmt(COPY[lang].indexSub, { tables: options.tables.join(" / "), domain: DOMAIN }) });
3675
- var cfgWrap = configView.useConfig(api, CFG_FALLBACK);
3676
- var cfg = cfgWrap.values;
3677
- var tablesS = React.useState(null);
3678
- var tables = tablesS[0], setTables = tablesS[1];
3679
- var activeS = React.useState("");
3680
- var active = activeS[0], setActive = activeS[1];
3681
- var dataS = React.useState(null);
3682
- var data = dataS[0], setData = dataS[1];
3683
- var loadingS = React.useState(false);
3684
- var loadingRows = loadingS[0], setLoadingRows = loadingS[1];
3685
- var loadingTablesS = React.useState(true);
3686
- var loadingTables = loadingTablesS[0], setLoadingTables = loadingTablesS[1];
3687
- var errorS = React.useState("");
3688
- var error = errorS[0], setError = errorS[1];
3689
- var pageS = React.useState(1);
3690
- var page = pageS[0], setPage = pageS[1];
3691
- var sizeS = React.useState(0);
3692
- var pageSize = sizeS[0], setPageSize = sizeS[1];
3693
- var sortS = React.useState("");
3694
- var sort = sortS[0], setSort = sortS[1];
3695
- var orderS = React.useState("desc");
3696
- var order = orderS[0], setOrder = orderS[1];
3697
- var searchDraftS = React.useState("");
3698
- var searchDraft = searchDraftS[0], setSearchDraft = searchDraftS[1];
3699
- var searchS = React.useState("");
3700
- var search = searchS[0], setSearch = searchS[1];
3701
- var filterDraftS = React.useState({});
3702
- var filterDraft = filterDraftS[0], setFilterDraft = filterDraftS[1];
3703
- var filtersS = React.useState({});
3704
- var filters = filtersS[0], setFilters = filtersS[1];
3705
- var includeDeletedS = React.useState(null);
3706
- var includeDeletedRaw = includeDeletedS[0], setIncludeDeleted = includeDeletedS[1];
3707
- var showSystemS = React.useState(null);
3708
- var showSystemRaw = showSystemS[0], setShowSystem = showSystemS[1];
3709
- var drawerS = React.useState(null);
3710
- var drawer = drawerS[0], setDrawer = drawerS[1];
3711
- var toastS = React.useState("");
3712
- var toast = toastS[0], setToast = toastS[1];
3713
- var filtersKey = JSON.stringify(filters);
3714
- var reqRef = React.useRef(0);
3715
- var toastTimer = React.useRef(null);
3716
- var refreshS = React.useState(0);
3717
- function refresh() {
3718
- loadTables();
3719
- refreshS[1](function(n) {
3720
- return n + 1;
3721
- });
3722
- }
3723
- var indexReqRef = React.useRef(0);
3724
- var indexS = React.useState(null);
3725
- var index = indexS[0], setIndex = indexS[1];
3726
- var indexBusyS = React.useState(false);
3727
- var indexBusy = indexBusyS[0], setIndexBusy = indexBusyS[1];
3728
- var cfgSize = Number(cfg["data.pageSize"]) || 50;
3729
- var size = pageSize || (PAGE_SIZES.indexOf(cfgSize) >= 0 ? cfgSize : 50);
3730
- var includeDeleted = includeDeletedRaw === null ? cfg["data.includeDeleted"] === true : includeDeletedRaw;
3731
- var showSystem = showSystemRaw === null ? cfg["data.showSystemColumns"] === true : showSystemRaw;
3732
- function say(text) {
3733
- setToast(text);
3734
- if (toastTimer.current) clearTimeout(toastTimer.current);
3735
- toastTimer.current = setTimeout(function() {
3736
- setToast("");
3737
- }, 1600);
3738
- }
3739
- function loadTables() {
3740
- setLoadingTables(true);
3741
- Promise.resolve((options.tablesLoader || function(a) {
3742
- return a.call(DOMAIN + ".dataTables");
3743
- })(api)).then(function(r) {
3744
- if (r && r.ok === false) throw new Error(r && r.error || t.loadFail);
3745
- var body = unwrap(r);
3746
- if (!body || !Array.isArray(body.tables)) throw new Error(t.loadFail);
3747
- setTables(body.tables);
3748
- setError("");
3749
- if (!active && body.tables.length) setActive(body.tables[0].name);
3750
- }).catch(function(e) {
3751
- setError(String(e && e.message || e) || t.loadFail);
3752
- }).then(function() {
3753
- setLoadingTables(false);
3754
- });
3755
- }
3756
- React.useEffect(function() {
3757
- injectCss();
3758
- loadTables();
3759
- return function() {
3760
- indexReqRef.current++;
3761
- if (toastTimer.current) clearTimeout(toastTimer.current);
3762
- };
3763
- }, []);
3764
- function selectTable(name) {
3765
- if (name === active) return;
3766
- reqRef.current++;
3767
- setActive(name);
3768
- setData(null);
3769
- setDrawer(null);
3770
- setError("");
3771
- setLoadingRows(true);
3772
- setPage(1);
3773
- setSort("");
3774
- setOrder("desc");
3775
- setSearch("");
3776
- setSearchDraft("");
3777
- setFilterDraft({});
3778
- setFilters({});
3779
- }
3780
- React.useEffect(function() {
3781
- if (searchDraft === search) return void 0;
3782
- var timer = setTimeout(function() {
3783
- setSearch(searchDraft);
3784
- setPage(1);
3785
- }, 280);
3786
- return function() {
3787
- clearTimeout(timer);
3788
- };
3789
- }, [searchDraft]);
3790
- React.useEffect(function() {
3791
- if (JSON.stringify(filterDraft) === JSON.stringify(filters)) return void 0;
3792
- var timer = setTimeout(function() {
3793
- setFilters(filterDraft);
3794
- setPage(1);
3795
- }, 280);
3796
- return function() {
3797
- clearTimeout(timer);
3798
- };
3799
- }, [filterDraft]);
3800
- React.useEffect(function() {
3801
- if (!active || !cfgWrap.ready || index) return void 0;
3802
- var req = ++reqRef.current;
3803
- setLoadingRows(true);
3804
- var args = { table: active, page, pageSize: size, order, includeDeleted };
3805
- if (sort) args.sort = sort;
3806
- if (search) args.search = search;
3807
- if (Object.keys(filters).length) args.filters = filters;
3808
- Promise.resolve((options.query || function(a, q) {
3809
- return a.call(DOMAIN + ".dataQuery", q);
3810
- })(api, args)).then(function(r) {
3811
- if (req !== reqRef.current) return;
3812
- if (r && r.ok === false) throw new Error(r && r.error || t.queryFail);
3813
- var body = unwrap(r);
3814
- if (!body) throw new Error(t.queryFail);
3815
- setData(body);
3816
- setError("");
3817
- if (body.page !== page) setPage(body.page);
3818
- }).catch(function(e) {
3819
- if (req !== reqRef.current) return;
3820
- setError(String(e && e.message || e) || t.queryFail);
3821
- }).then(function() {
3822
- if (req === reqRef.current) setLoadingRows(false);
3823
- });
3824
- return function() {
3825
- reqRef.current++;
3826
- };
3827
- }, [active, page, size, sort, order, search, includeDeleted, cfgWrap.ready, filtersKey, refreshS[0], !!index]);
3828
- React.useEffect(function() {
3829
- if (!drawer) return void 0;
3830
- function onKey(e) {
3831
- if (e.key === "Escape") setDrawer(null);
3832
- }
3833
- document.addEventListener("keydown", onKey);
3834
- return function() {
3835
- document.removeEventListener("keydown", onKey);
3836
- };
3837
- }, [drawer]);
3838
- var current = null;
3839
- if (tables) {
3840
- for (var i = 0; i < tables.length; i++) if (tables[i].name === active) current = tables[i];
3841
- }
3842
- function leaveIndex() {
3843
- indexReqRef.current++;
3844
- setIndex(null);
3845
- setIndexBusy(false);
3846
- setError("");
3847
- }
3848
- function loadIndex() {
3849
- reqRef.current++;
3850
- setError("");
3851
- var req = ++indexReqRef.current;
3852
- setIndex([]);
3853
- setIndexBusy(true);
3854
- Promise.resolve(api.call(DOMAIN + ".dataTables", { stats: true })).then(function(r) {
3855
- if (req !== indexReqRef.current) return;
3856
- if (r && r.ok === false) throw new Error(r.error || t.loadFail);
3857
- var payload = unwrap(r) || {};
3858
- var rows = (payload.tables || []).map(function(tb) {
3859
- return { table: tb, stats: tb.stats || null };
3860
- });
3861
- setIndex(rows);
3862
- setError("");
3863
- setIndexBusy(false);
3864
- }).catch(function(e) {
3865
- if (req !== indexReqRef.current) return;
3866
- setError(String(e.message || e));
3867
- setIndex([]);
3868
- setIndexBusy(false);
3869
- });
3870
- }
3871
- function renderIndex() {
3872
- var row = (index || []).filter(function(r) {
3873
- return r.table.name === active;
3874
- })[0];
3875
- var tb = row ? row.table : current;
3876
- var st = row && row.stats;
3877
- var indexes = st ? st.indexes || [] : [];
3878
- var hasExtra = indexes.some(function(ix) {
3879
- return ix.origin !== "pk";
3880
- });
3881
- var count = st && st.rows !== void 0 ? st.rows : tb && tb.count;
3882
- return h(
3883
- "div",
3884
- { className: P + "-idx" },
3885
- h(
3886
- "div",
3887
- { className: P + "-head" },
3888
- h(
3889
- "div",
3890
- { className: P + "-headmain" },
3891
- h("h2", null, icon("database"), tableLabel(tb), h("span", { className: P + "-code" }, active)),
3892
- h("div", { className: P + "-idxsub" }, t.indexSub)
3893
- ),
3894
- h("button", {
3895
- type: "button",
3896
- className: P + "-btn",
3897
- "aria-label": t.refresh,
3898
- title: t.refresh,
3899
- "aria-busy": indexBusy ? "true" : "false",
3900
- onClick: function() {
3901
- loadIndex();
3902
- }
3903
- }, icon("refresh"), h("span", { className: P + "-btnlabel" }, t.refresh))
3904
- ),
3905
- st ? h(
3906
- "div",
3907
- { className: P + "-idxsum" },
3908
- h("span", null, t.idxRows, " ", h("b", null, String(count))),
3909
- h("span", null, t.idxCols, " ", h("b", null, String(st.columnCount === void 0 ? (tb.columns || []).length : st.columnCount))),
3910
- h("span", null, fmt(t.idxCount, { n: indexes.length }))
3911
- ) : null,
3912
- indexBusy ? options.Skeleton ? h(options.Skeleton, { lang, label: t.loading }) : h("div", { className: P + "-empty", role: "status", "aria-busy": "true" }, t.loading) : !st ? h("div", { className: P + "-empty" }, t.idxEmpty) : !hasExtra ? h("div", { className: P + "-empty" }, t.idxNoExtra) : h(
3913
- "div",
3914
- { className: P + "-tablewrap" },
3915
- h(
3916
- "table",
3917
- { className: P + "-table " + P + "-idxtable" },
3918
- h("thead", null, h(
3919
- "tr",
3920
- null,
3921
- [t.idxName, t.idxColumns, t.idxType, t.idxSource, t.idxRows].map(function(label) {
3922
- return h("th", { scope: "col", key: label }, h("span", { className: P + "-thbtn" }, label));
3923
- })
3924
- )),
3925
- h("tbody", null, indexes.map(function(ix) {
3926
- return h(
3927
- "tr",
3928
- { className: P + "-tr", key: ix.name },
3929
- h("td", { className: P + "-cell mono" }, ix.name),
3930
- h("td", { className: P + "-cell mono" }, (ix.columns || []).join(", ") || t.idxNone),
3931
- h("td", { className: P + "-cell" }, ix.origin === "pk" ? t.idxKey : ix.unique ? t.idxUnique : t.idxNormal),
3932
- h("td", { className: P + "-cell" }, /^sqlite_autoindex_/.test(ix.name) ? t.idxAuto : t.idxCreated),
3933
- h("td", { className: P + "-cell num", title: t.idxRowsHelp }, String(count))
3934
- );
3935
- }))
3936
- )
3937
- )
3938
- );
3939
- }
3940
- function tableLabel(tb) {
3941
- if (!tb || !tb.label) return "";
3942
- return lang === "en" ? tb.label.en || tb.label.zh : tb.label.zh || tb.label.en;
3943
- }
3944
- function colLabel(col) {
3945
- if (!col.label) return col.name;
3946
- return lang === "en" ? col.label.en || col.label.zh : col.label.zh || col.label.en;
3947
- }
3948
- function visibleColumns() {
3949
- var cols = data && data.columns ? data.columns.map(function(col) {
3950
- var hook = columnHooks[col.name];
3951
- return hook && hook.kind ? Object.assign({}, col, { kind: hook.kind, type: hook.type || col.type }) : col;
3952
- }) : [];
3953
- return cols.filter(function(c) {
3954
- return showSystem || !c.system;
3955
- });
3956
- }
3957
- function toggleSort(name) {
3958
- if (sort !== name) {
3959
- setSort(name);
3960
- setOrder("desc");
3961
- return;
3962
- }
3963
- if (order === "desc") {
3964
- setOrder("asc");
3965
- return;
3966
- }
3967
- setSort("");
3968
- setOrder("desc");
3969
- }
3970
- function ariaSort(name) {
3971
- if (sort !== name) return "none";
3972
- return order === "asc" ? "ascending" : "descending";
3973
- }
3974
- function copyCell(value) {
3975
- var text = value === null || value === void 0 ? "" : String(value);
3976
- try {
3977
- if (navigator.clipboard && navigator.clipboard.writeText) navigator.clipboard.writeText(text);
3978
- else {
3979
- var ta = document.createElement("textarea");
3980
- ta.value = text;
3981
- ta.style.position = "fixed";
3982
- ta.style.opacity = "0";
3983
- document.body.appendChild(ta);
3984
- ta.select();
3985
- document.execCommand("copy");
3986
- document.body.removeChild(ta);
3987
- }
3988
- say(t.copied);
3989
- } catch (e) {
3990
- }
3991
- }
3992
- function cellText(col, value) {
3993
- if (value === null || value === void 0) return null;
3994
- if (col.kind === "bool") return value ? t.yes : t.no;
3995
- if (col.kind === "timestamp") return timeText(value);
3996
- return String(value);
3997
- }
3998
- function cellClass(col, value) {
3999
- var cls = P + "-cell";
4000
- if (value === null || value === void 0) return cls + " null";
4001
- if (col.kind === "number") return cls + " num";
4002
- if (col.kind === "id" || col.kind === "path") return cls + " mono";
4003
- if (col.kind === "text" && looksJson(value)) return cls + " json";
4004
- return cls;
4005
- }
4006
- function cellTitle(col, value) {
4007
- if (value === null || value === void 0) return t.nullText;
4008
- if (col.kind === "timestamp") return String(value);
4009
- if (col.kind === "bool") return value ? "1" : "0";
4010
- return String(value);
4011
- }
4012
- function renderCell(row, col) {
4013
- var value = row[col.name];
4014
- var hook = columnHooks[col.name];
4015
- function openDetail() {
4016
- setDrawer({ column: colLabel(col), name: col.name, row: (data.page - 1) * data.pageSize + row.__i + 1, value });
4017
- }
4018
- var text = cellText(col, value);
4019
- var content;
4020
- if (text === null) content = h("span", { className: "v" }, t.nullText);
4021
- else if (text === "") content = h("span", { className: "v" }, '""');
4022
- else content = h("span", { className: "v" }, text);
4023
- if (hook && hook.render) content = hook.render({ value, row, col, lang, prefix: P, openDetail });
4024
- return h("td", {
4025
- key: col.name,
4026
- className: cellClass(col, value),
4027
- title: cellTitle(col, value),
4028
- onClick: function() {
4029
- copyCell(value);
4030
- },
4031
- onDoubleClick: openDetail
4032
- }, content);
4033
- }
4034
- function activeFilterCount() {
4035
- var n = 0;
4036
- for (var k in filters) if (Object.prototype.hasOwnProperty.call(filters, k)) n++;
4037
- return n;
4038
- }
4039
- function filterCell(col) {
4040
- var val = filterDraft[col.name] === void 0 ? "" : filterDraft[col.name];
4041
- return h(
4042
- "th",
4043
- { key: col.name, scope: "col", className: P + "-fth" },
4044
- h(
4045
- "span",
4046
- { className: P + "-fcell" },
4047
- h("input", {
4048
- className: P + "-finput",
4049
- type: "search",
4050
- value: val,
4051
- placeholder: t.filterCol,
4052
- "aria-label": t.filterCol + " " + colLabel(col),
4053
- title: colLabel(col) + " \xB7 " + t.filterCol,
4054
- onChange: function(e) {
4055
- var v = e.target.value;
4056
- setFilterDraft(function(prev) {
4057
- var next = Object.assign({}, prev);
4058
- if (v) next[col.name] = v;
4059
- else delete next[col.name];
4060
- return next;
4061
- });
4062
- }
4063
- }),
4064
- val ? h("button", {
4065
- type: "button",
4066
- className: P + "-fclear",
4067
- title: t.filterClear,
4068
- "aria-label": t.filterClear + " " + colLabel(col),
4069
- onClick: function() {
4070
- setFilterDraft(function(prev) {
4071
- var next = Object.assign({}, prev);
4072
- delete next[col.name];
4073
- return next;
4074
- });
4075
- }
4076
- }, "\xD7") : null
4077
- )
4078
- );
4079
- }
4080
- function renderRows() {
4081
- if (loadingRows && !data && options.Skeleton) return h(options.Skeleton, { lang, label: t.loading });
4082
- if (loadingRows && !data) {
4083
- return h(
4084
- "div",
4085
- { className: P + "-skwrap", "aria-busy": "true" },
4086
- h("span", { className: P + "-sr" }, t.loading),
4087
- [0, 1, 2, 3, 4, 5, 6, 7].map(function(i2) {
4088
- return h("div", { key: i2, className: P + "-sk" });
4089
- })
4090
- );
4091
- }
4092
- if (error) {
4093
- return h(
4094
- "div",
4095
- { className: P + "-err", role: "alert" },
4096
- h("span", null, t.queryFail + error),
4097
- h("button", { type: "button", className: P + "-btn", onClick: refresh }, t.retry)
4098
- );
4099
- }
4100
- if (!data) return h("div", { className: P + "-empty" }, t.empty);
4101
- var cols = visibleColumns();
4102
- var rows = data.rows || [];
4103
- var narrowing = !!search || activeFilterCount() > 0;
4104
- return h(
4105
- "div",
4106
- { className: P + "-tablewrap" },
4107
- h(
4108
- "table",
4109
- { className: P + "-table" },
4110
- h(
4111
- "thead",
4112
- null,
4113
- h(
4114
- "tr",
4115
- null,
4116
- h("th", { className: P + "-rownum", scope: "col" }, "#"),
4117
- cols.map(function(col) {
4118
- return h(
4119
- "th",
4120
- { key: col.name, scope: "col", "aria-sort": ariaSort(col.name) },
4121
- h(
4122
- "button",
4123
- {
4124
- type: "button",
4125
- className: P + "-thbtn",
4126
- title: colLabel(col) + " \xB7 " + col.type,
4127
- onClick: function() {
4128
- toggleSort(col.name);
4129
- }
4130
- },
4131
- h("span", null, colLabel(col)),
4132
- h("span", { className: P + "-coltype" }, String(col.type || "").toLowerCase()),
4133
- sort === col.name ? h("span", { className: P + "-sortmark", "aria-hidden": "true" }, order === "asc" ? "\u25B2" : "\u25BC") : null
4134
- )
4135
- );
4136
- })
4137
- ),
4138
- h(
4139
- "tr",
4140
- { className: P + "-frow" },
4141
- h("th", { className: P + "-rownum", scope: "col" }, ""),
4142
- cols.map(filterCell)
4143
- )
4144
- ),
4145
- h("tbody", null, rows.length ? rows.map(function(row, idx) {
4146
- row.__i = idx;
4147
- var deleted = row.deleted_at !== null && row.deleted_at !== void 0;
4148
- return h(
4149
- "tr",
4150
- { key: row.id || idx, className: P + "-tr" + (deleted ? " deleted" : "") },
4151
- h("td", { className: P + "-rownum" }, (data.page - 1) * data.pageSize + idx + 1),
4152
- cols.map(function(col) {
4153
- var cell = renderCell(row, col);
4154
- if (deleted && col.name === "id") {
4155
- return React.cloneElement(cell, { key: col.name }, cell.props.children, h("span", { className: P + "-delbadge" }, t.deleted));
4156
- }
4157
- return cell;
4158
- })
4159
- );
4160
- }) : h("tr", null, h("td", { className: P + "-emptycell", colSpan: cols.length + 1 }, narrowing ? t.noRows : t.empty)))
4161
- )
4162
- );
4163
- }
4164
- function renderFoot() {
4165
- var pages = data ? data.pages : 1;
4166
- var total = data ? data.total : 0;
4167
- return h(
4168
- "div",
4169
- { className: P + "-foot" },
4170
- h("span", null, fmt(t.total, { n: total })),
4171
- h("span", { className: P + "-grow" }),
4172
- h("button", { type: "button", className: P + "-btn", disabled: !data || page <= 1, onClick: function() {
4173
- setPage(Math.max(1, page - 1));
4174
- } }, "\u2039 " + t.prev),
4175
- h("span", { className: P + "-pageinfo" }, fmt(t.pageInfo, { page: data ? data.page : 1, pages })),
4176
- h("button", { type: "button", className: P + "-btn", disabled: !data || page >= pages, onClick: function() {
4177
- setPage(Math.min(pages, page + 1));
4178
- } }, t.next + " \u203A"),
4179
- h(NF.NumberField, {
4180
- h,
4181
- lang,
4182
- className: P + "-jump",
4183
- value: page,
4184
- min: 1,
4185
- max: pages,
4186
- integer: true,
4187
- ariaLabel: t.jump,
4188
- hint: false,
4189
- onCommit: function(next) {
4190
- if (next !== null) setPage(next);
4191
- }
4192
- }),
4193
- data && data.queryMs !== void 0 ? h("span", null, fmt(t.queryTime, { n: data.queryMs })) : null
4194
- );
4195
- }
4196
- if (!tables && loadingTables && options.Skeleton) return h(options.Skeleton, { lang, label: t.loading });
4197
- if (!tables && loadingTables) {
4198
- return h("div", { className: P + "-skwrap", "aria-busy": "true" }, h("span", { className: P + "-sr" }, t.loading), [0, 1, 2, 3].map(function(i2) {
4199
- return h("div", { key: i2, className: P + "-sk" });
4200
- }));
4201
- }
4202
- if (!tables) {
4203
- return h("div", { className: P + "-err", role: "alert" }, h("span", null, t.loadFail), h("button", { type: "button", className: P + "-btn", onClick: loadTables }, t.retry));
4204
- }
4205
- if (!tables.length) return h("div", { className: P + "-empty" }, t.emptyTable);
4206
- return h(
4207
- "div",
4208
- { className: P },
4209
- h(
4210
- "div",
4211
- { className: P + "-side" },
4212
- h("div", { className: P + "-sidetitle" }, h("span", null, icon("table"), t.tables), h("span", null, String(tables.length))),
4213
- tables.map(function(tb) {
4214
- return h(
4215
- "button",
4216
- {
4217
- key: tb.name,
4218
- type: "button",
4219
- className: P + "-stab" + (tb.name === active ? " on" : ""),
4220
- "aria-pressed": tb.name === active,
4221
- onClick: function() {
4222
- selectTable(tb.name);
4223
- }
4224
- },
4225
- h(
4226
- "span",
4227
- { className: P + "-stabname" },
4228
- h("span", null, tableLabel(tb)),
4229
- h("span", { className: P + "-sidecount" }, tb.count === void 0 || tb.count === null ? "" : String(tb.count))
4230
- ),
4231
- h("span", { className: P + "-sidetable" }, tb.name)
4232
- );
4233
- })
4234
- ),
4235
- h(
4236
- "div",
4237
- { className: P + "-main" },
4238
- h(
4239
- "div",
4240
- { className: P + "-tabs", role: "tablist", "aria-label": t.title },
4241
- h("button", { type: "button", role: "tab", className: P + "-btn", "aria-selected": !index, onClick: leaveIndex }, icon("list"), lang === "en" ? "Row data" : "\u884C\u6570\u636E"),
4242
- h("button", { type: "button", role: "tab", className: P + "-btn", "aria-selected": !!index, onClick: loadIndex }, icon("database"), t.index)
4243
- ),
4244
- index && error ? h("div", { className: P + "-err", role: "alert" }, error) : null,
4245
- index ? renderIndex() : [
4246
- h(
4247
- "div",
4248
- { className: P + "-head" },
4249
- h(
4250
- "div",
4251
- { className: P + "-headmain" },
4252
- h("h2", null, icon("database"), tableLabel(current), h("span", { className: P + "-code" }, active)),
4253
- h(
4254
- "div",
4255
- { className: P + "-sub" },
4256
- current && data && data.total !== void 0 ? fmt(t.rowCount, { n: data.total }) : "",
4257
- current && current.deletedCount ? " \xB7 " + fmt(t.deletedCount, { n: current.deletedCount }) : "",
4258
- " \xB7 " + t.subtitle
4259
- )
4260
- ),
4261
- h("button", {
4262
- type: "button",
4263
- className: P + "-btn",
4264
- "aria-label": t.refresh,
4265
- title: t.refresh,
4266
- "aria-busy": loadingRows ? "true" : "false",
4267
- onClick: refresh
4268
- }, icon("refresh"), h("span", { className: P + "-btnlabel" }, t.refresh))
4269
- ),
4270
- h(
4271
- "div",
4272
- { className: P + "-toolbar" },
4273
- h(
4274
- "div",
4275
- { className: P + "-search" },
4276
- icon("search"),
4277
- h("input", {
4278
- type: "search",
4279
- value: searchDraft,
4280
- placeholder: t.search,
4281
- "aria-label": t.search,
4282
- onChange: function(e) {
4283
- setSearchDraft(e.target.value);
4284
- }
4285
- })
4286
- ),
4287
- h(SW.Switch, {
4288
- h,
4289
- checked: includeDeleted,
4290
- label: t.includeDeleted,
4291
- onChange: function(next) {
4292
- setIncludeDeleted(next);
4293
- setPage(1);
4294
- }
4295
- }),
4296
- h(SW.Switch, {
4297
- h,
4298
- checked: showSystem,
4299
- label: t.showSystem,
4300
- onChange: function(next) {
4301
- setShowSystem(next);
4302
- }
4303
- }),
4304
- h("span", { className: P + "-grow" }),
4305
- h(
4306
- "label",
4307
- { style: { display: "inline-flex", alignItems: "center", gap: "6px", fontSize: "11.5px", color: "var(--cfg-muted)" } },
4308
- h("span", null, t.pageSize),
4309
- h("select", {
4310
- className: P + "-select",
4311
- value: size,
4312
- onChange: function(e) {
4313
- setPageSize(Number(e.target.value));
4314
- setPage(1);
4315
- }
4316
- }, PAGE_SIZES.map(function(n) {
4317
- return h("option", { key: n, value: n }, String(n));
4318
- }))
4319
- )
4320
- ),
4321
- renderRows(),
4322
- renderFoot()
4323
- ]
4324
- ),
4325
- drawer ? h(
4326
- "div",
4327
- null,
4328
- h("div", { className: P + "-mask", onClick: function() {
4329
- setDrawer(null);
4330
- } }),
4331
- h(
4332
- "aside",
4333
- { className: P + "-drawer", role: "dialog", "aria-modal": "true", "aria-label": drawer.column },
4334
- h("h3", null, fmt(t.drawerTitle, { column: drawer.column, row: drawer.row }), h("span", { className: P + "-code" }, drawer.name)),
4335
- columnHooks[drawer.name] && columnHooks[drawer.name].detail ? columnHooks[drawer.name].detail({ value: drawer.value, lang, prefix: P }) : h("pre", null, drawerText(drawer.value)),
4336
- h(
4337
- "div",
4338
- { className: P + "-drawerfoot" },
4339
- h("button", { type: "button", className: P + "-btn", onClick: function() {
4340
- copyCell(drawer.value);
4341
- } }, t.copy),
4342
- h("button", { type: "button", className: P + "-btn", onClick: function() {
4343
- setDrawer(null);
4344
- } }, t.close)
4345
- )
4346
- )
4347
- ) : null,
4348
- toast ? h("div", { className: P + "-toast", role: "status" }, toast) : null
4349
- );
4350
- }
4351
- function drawerText(value) {
4352
- if (value === null || value === void 0) return "NULL";
4353
- if (typeof value === "string" && looksJson(value)) {
4354
- try {
4355
- return JSON.stringify(JSON.parse(value), null, 2);
4356
- } catch (e) {
4357
- return value;
4358
- }
4359
- }
4360
- if (typeof value === "object") {
4361
- try {
4362
- return JSON.stringify(value, null, 2);
4363
- } catch (e) {
4364
- return String(value);
4365
- }
4366
- }
4367
- return String(value);
4368
- }
4369
- return { DataView, DOMAIN };
4370
- };
4371
- }
4372
- });
4373
-
4374
- // packages/addons/danmaku/client/views/data.cjs
4375
- var require_data = __commonJS({
4376
- "packages/addons/danmaku/client/views/data.cjs"(exports2, module2) {
4377
- "use strict";
4378
- module2.exports = require_data_view()({
4379
- domain: "danmaku",
4380
- prefix: "wbdm",
4381
- tables: ["danmaku"],
4382
- useConfig: require_config().useConfig
4383
- });
4384
- }
4385
- });
4386
-
4387
3580
  // packages/addons/lib/highlight.cjs
4388
3581
  var require_highlight = __commonJS({
4389
3582
  "packages/addons/lib/highlight.cjs"(exports2, module2) {
@@ -4428,6 +3621,80 @@ var require_highlight = __commonJS({
4428
3621
  }
4429
3622
  });
4430
3623
 
3624
+ // node_modules/.pnpm/lucide-react@1.70.0_react@19.2.0/node_modules/lucide-react/dist/esm/icons/chevron-right.mjs
3625
+ var chevron_right_exports = {};
3626
+ __export(chevron_right_exports, {
3627
+ __iconData: () => __iconData17,
3628
+ default: () => ChevronRight
3629
+ });
3630
+ var __iconData17, ChevronRight;
3631
+ var init_chevron_right = __esm({
3632
+ "node_modules/.pnpm/lucide-react@1.70.0_react@19.2.0/node_modules/lucide-react/dist/esm/icons/chevron-right.mjs"() {
3633
+ init_createLucideIcon();
3634
+ __iconData17 = {
3635
+ name: "chevron-right",
3636
+ size: 24,
3637
+ node: [["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]]
3638
+ };
3639
+ __iconData17.node;
3640
+ ChevronRight = createLucideIcon(__iconData17);
3641
+ }
3642
+ });
3643
+
3644
+ // packages/addons/lib/disclosure-styles.cjs
3645
+ var require_disclosure_styles = __commonJS({
3646
+ "packages/addons/lib/disclosure-styles.cjs"(exports2, module2) {
3647
+ "use strict";
3648
+ module2.exports = [
3649
+ ".wb-disc{min-width:0;border:0;padding:0;margin:0}",
3650
+ // 原生 details/summary 保留键盘与无障碍语义,这里只接管观感:去掉默认三角并铺满整行。
3651
+ ".wb-disc>summary{display:flex;align-items:center;gap:6px;cursor:pointer;font-size:12.5px;font-weight:600;line-height:1.6;color:inherit;user-select:none;list-style:none;padding:2px 8px 2px 2px;margin:-2px -8px -2px -2px;border-radius:7px}",
3652
+ ".wb-disc>summary::-webkit-details-marker{display:none}",
3653
+ '.wb-disc>summary::marker{content:""}',
3654
+ ".wb-disc>summary:hover{background:color-mix(in oklab,currentColor 6%,transparent)}",
3655
+ ".wb-disc>summary:focus-visible{outline:2px solid var(--wb-accent,var(--dsw-alias-brand-primary,Highlight));outline-offset:2px}",
3656
+ ".wb-disc-chev{flex:0 0 auto;width:14px;height:14px;transition:transform 160ms ease}",
3657
+ ".wb-disc[open]>summary .wb-disc-chev{transform:rotate(90deg)}",
3658
+ ".wb-disc-title{min-width:0;overflow-wrap:anywhere}",
3659
+ ".wb-disc-meta{font-weight:400;font-size:12px;color:var(--wb-muted,var(--dsw-alias-label-tertiary,GrayText))}",
3660
+ ".wb-disc-body{margin-top:8px;min-width:0;animation:wb-disc-in 160ms ease}",
3661
+ "@keyframes wb-disc-in{from{opacity:0;transform:translateY(-2px)}to{opacity:1;transform:none}}",
3662
+ "@media(prefers-reduced-motion:reduce){.wb-disc-chev{transition:none}.wb-disc-body{animation:none}}"
3663
+ ].join("\n");
3664
+ }
3665
+ });
3666
+
3667
+ // packages/addons/lib/disclosure.cjs
3668
+ var require_disclosure = __commonJS({
3669
+ "packages/addons/lib/disclosure.cjs"(exports2, module2) {
3670
+ "use strict";
3671
+ var ChevronRight2 = (init_chevron_right(), __toCommonJS(chevron_right_exports)).default;
3672
+ function createDisclosure(React) {
3673
+ var h = React.createElement;
3674
+ function Disclosure(props) {
3675
+ var attrs = Object.assign({ className: ("wb-disc " + (props.className || "")).trim() }, props.attrs || {});
3676
+ if (props.open !== void 0) attrs.open = !!props.open;
3677
+ else if (props.defaultOpen !== void 0) attrs.open = !!props.defaultOpen;
3678
+ if (props.onToggle) attrs.onToggle = props.onToggle;
3679
+ return h(
3680
+ "details",
3681
+ attrs,
3682
+ h(
3683
+ "summary",
3684
+ null,
3685
+ h(ChevronRight2, { className: "wb-disc-chev", "aria-hidden": true, focusable: false }),
3686
+ h("span", { className: "wb-disc-title" }, props.title),
3687
+ props.meta != null && props.meta !== "" ? h("span", { className: "wb-disc-meta" }, props.meta) : null
3688
+ ),
3689
+ h("div", { className: "wb-disc-body" }, props.children)
3690
+ );
3691
+ }
3692
+ return { Disclosure, css: require_disclosure_styles() };
3693
+ }
3694
+ module2.exports = { createDisclosure, css: require_disclosure_styles() };
3695
+ }
3696
+ });
3697
+
4431
3698
  // packages/addons/lib/action-schema-style.cjs
4432
3699
  var require_action_schema_style = __commonJS({
4433
3700
  "packages/addons/lib/action-schema-style.cjs"(exports2, module2) {
@@ -4477,12 +3744,8 @@ var require_action_schema_style = __commonJS({
4477
3744
  "." + P + "-copy{border:1px solid var(--wb-border,#e3e5e9);border-radius:7px;background:transparent;color:inherit;font:inherit;font-size:11.5px;padding:2px 8px;cursor:pointer}",
4478
3745
  "." + P + "-copy:hover{background:var(--dsw-alias-interactive-bg-hover,color-mix(in oklab,currentColor 5%,transparent))}",
4479
3746
  "." + P + "-copy:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#4f6ef7);outline-offset:2px}",
4480
- "." + P + " details>summary{cursor:pointer;font-size:11.5px;color:var(--dsw-alias-label-secondary,inherit);width:max-content}",
4481
- "." + P + " details>summary:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#4f6ef7);outline-offset:2px}",
4482
- // 参数折叠面板:折叠时只留一行「参数 · 必填 n」,展开后与表格之间留一点气口。
3747
+ // 折叠头观感已收口到共享控件 disclosure-styles.cjs(.wb-disc),这里不再重复定义 details>summary。
4483
3748
  "." + P + "-params{min-width:0}",
4484
- "." + P + "-params>summary{user-select:none;max-width:100%}",
4485
- "." + P + "-params[open]>summary{margin-bottom:6px}",
4486
3749
  "." + P + "-empty{padding:24px;text-align:center;border:1px dashed var(--wb-border,#e3e5e9);border-radius:10px;color:var(--dsw-alias-label-tertiary,inherit)}",
4487
3750
  "." + P + "-error{padding:12px;border:1px solid var(--dsw-alias-state-error-primary,#d9534f);border-radius:10px;color:var(--dsw-alias-state-error-primary,#d9534f);display:flex;gap:10px;align-items:center;flex-wrap:wrap;overflow-wrap:anywhere}",
4488
3751
  "." + P + "-toast{position:sticky;bottom:8px;align-self:flex-start;border-radius:999px;padding:3px 10px;background:var(--dsw-alias-bg-skeleton,#f2f3f5);font-size:11.5px;max-width:100%}",
@@ -4492,7 +3755,7 @@ var require_action_schema_style = __commonJS({
4492
3755
  // 中等宽度(521–760px)三个筛选项正好排成一行,避免第三项独占一行显得参差。
4493
3756
  "@media(min-width:521px) and (max-width:760px){." + P + "-toolbar{grid-template-columns:repeat(3,minmax(0,1fr))}}",
4494
3757
  "@media(max-width:420px){." + P + "-toolbar{grid-template-columns:minmax(0,1fr) minmax(0,1fr)}." + P + "-card{padding:10px}." + P + "-table tr{padding:8px 0}}"
4495
- ].join("\n");
3758
+ ].join("\n") + "\n" + require_disclosure_styles();
4496
3759
  return function injectCss() {
4497
3760
  if (typeof document === "undefined") return;
4498
3761
  var id = "wb-addon-" + DOMAIN + "-actions-css";
@@ -4517,6 +3780,7 @@ var require_action_schema_view = __commonJS({
4517
3780
  "use strict";
4518
3781
  var React = require("react");
4519
3782
  var createHighlight = require_highlight()(React);
3783
+ var Disclosure = require_disclosure().createDisclosure(React).Disclosure;
4520
3784
  var h = React.createElement;
4521
3785
  var COPY = {
4522
3786
  zh: {
@@ -5001,10 +4265,12 @@ var require_action_schema_view = __commonJS({
5001
4265
  ),
5002
4266
  action.description ? h("p", { className: P + "-desc" }, Highlight.hit(action.description, kw)) : null,
5003
4267
  rows.length ? h(
5004
- "details",
4268
+ Disclosure,
5005
4269
  {
5006
4270
  className: P + "-params",
5007
- "data-params-fold": action.name,
4271
+ title: t.params,
4272
+ meta: required ? t.requiredCount(required) : "",
4273
+ attrs: { "data-params-fold": action.name },
5008
4274
  open,
5009
4275
  // 原生 details 自带键盘与无障碍语义,这里只记下用户的开合;
5010
4276
  // 筛选变化引起的程序性开合也会触发 toggle,记下的值与当次默认一致,随后由 resetFolds 清掉。
@@ -5018,7 +4284,6 @@ var require_action_schema_view = __commonJS({
5018
4284
  });
5019
4285
  }
5020
4286
  },
5021
- h("summary", null, t.params + (required ? " \xB7 " + t.requiredCount(required) : "")),
5022
4287
  h(
5023
4288
  "table",
5024
4289
  { className: P + "-table" },
@@ -5055,9 +4320,8 @@ var require_action_schema_view = __commonJS({
5055
4320
  }) : h("div", { className: P + "-none" }, t.noExamples)
5056
4321
  ),
5057
4322
  h(
5058
- "details",
5059
- null,
5060
- h("summary", null, t.raw),
4323
+ Disclosure,
4324
+ { title: t.raw },
5061
4325
  h("pre", { className: P + "-pre" }, JSON.stringify(action.input || {}, null, 2))
5062
4326
  )
5063
4327
  );
@@ -5213,7 +4477,6 @@ var icons = {
5213
4477
  megaphone: GLYPHS["megaphone"],
5214
4478
  list: GLYPHS["list"],
5215
4479
  settings: GLYPHS["settings"],
5216
- database: GLYPHS["database"],
5217
4480
  play: GLYPHS["play"]
5218
4481
  };
5219
4482
  function makeTab(React) {
@@ -5228,7 +4491,7 @@ function definition(host) {
5228
4491
  var tab = makeTab(host.react);
5229
4492
  return {
5230
4493
  id: ADDON_ID,
5231
- version: "0.2.13",
4494
+ version: "0.3.2",
5232
4495
  icon: tab("megaphone"),
5233
4496
  views: [
5234
4497
  {
@@ -5243,12 +4506,6 @@ function definition(host) {
5243
4506
  title: { zh: "\u914D\u7F6E", en: "Settings" },
5244
4507
  component: require_config()
5245
4508
  },
5246
- {
5247
- id: "data",
5248
- icon: tab("database"),
5249
- title: { zh: "\u6570\u636E", en: "Data" },
5250
- component: require_data()
5251
- },
5252
4509
  {
5253
4510
  id: "actions",
5254
4511
  icon: tab("play"),