dsh-workbench-storage 1.5.5 → 1.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.js CHANGED
@@ -705,6 +705,10 @@ var require_filter_checklist_styles = __commonJS({
705
705
  ".wbck-opt:hover{background:color-mix(in srgb, currentColor 7%, transparent)}",
706
706
  ".wbck-opt.is-on{background:color-mix(in srgb, var(--wb-accent) 10%, transparent)}",
707
707
  ".wbck-opt input{margin:0;flex:none;accent-color:var(--wb-accent)}",
708
+ // 单选变体用 button 渲染(role="radio"),这里把浏览器默认按钮样式清掉,视觉与多选行一致。
709
+ '.wbck-opt[role="radio"]{appearance:none;width:100%;box-sizing:border-box;border:0;background:transparent;color:inherit;font:inherit;text-align:left}',
710
+ '.wbck-opt[role="radio"]:disabled{opacity:.55;cursor:not-allowed}',
711
+ '.wbck-opt[role="radio"]:focus-visible{outline:2px solid var(--wb-accent);outline-offset:-2px}',
708
712
  ".wbck-nm{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}",
709
713
  ".wbck-meta{margin-left:auto;flex:none;font-size:11.5px;color:var(--wb-muted)}",
710
714
  ".wbck-note{font-size:12px;color:var(--wb-muted);padding:8px 6px}",
@@ -2193,6 +2197,8 @@ var require_filter_checklist = __commonJS({
2193
2197
  var onLoadMore = props.onLoadMore;
2194
2198
  var onClear = props.onClear || function() {
2195
2199
  };
2200
+ var single = props.mode === "single";
2201
+ var onPick = typeof props.onPick === "function" ? props.onPick : onToggle;
2196
2202
  function toggle(id) {
2197
2203
  if (disabled) return;
2198
2204
  onToggle(id);
@@ -2205,8 +2211,8 @@ var require_filter_checklist = __commonJS({
2205
2211
  "div",
2206
2212
  { className: "wbck-head" },
2207
2213
  h2("span", { className: "wbck-grow" }, title + (total ? " \xB7 " + total : "")),
2208
- selected.length ? h2("span", { className: "wbck-sel" }, selectedText + " " + selected.length) : null,
2209
- selected.length || query ? h2("button", {
2214
+ !single && selected.length ? h2("span", { className: "wbck-sel" }, selectedText + " " + selected.length) : null,
2215
+ !single && (selected.length || query) ? h2("button", {
2210
2216
  type: "button",
2211
2217
  className: "wbck-clear",
2212
2218
  title: clearText,
@@ -2223,6 +2229,25 @@ var require_filter_checklist = __commonJS({
2223
2229
  } else {
2224
2230
  body = items.map(function(x) {
2225
2231
  var on = selected.indexOf(String(x.id)) >= 0;
2232
+ if (single) {
2233
+ return h2(
2234
+ "button",
2235
+ {
2236
+ key: x.id,
2237
+ type: "button",
2238
+ role: "radio",
2239
+ "aria-checked": on ? "true" : "false",
2240
+ className: "wbck-opt" + (on ? " is-on" : ""),
2241
+ disabled,
2242
+ onClick: function() {
2243
+ if (disabled) return;
2244
+ onPick(x.id);
2245
+ }
2246
+ },
2247
+ h2("span", { className: "wbck-nm", title: x.name }, x.name),
2248
+ x.meta ? h2("span", { className: "wbck-meta" }, x.meta) : null
2249
+ );
2250
+ }
2226
2251
  return h2(
2227
2252
  "label",
2228
2253
  { key: x.id, className: "wbck-opt" + (on ? " is-on" : "") },
@@ -2265,6 +2290,8 @@ var require_filter_checklist = __commonJS({
2265
2290
  h2("div", {
2266
2291
  className: "wbck-list",
2267
2292
  onScroll: scroll,
2293
+ role: single ? "radiogroup" : void 0,
2294
+ "aria-label": single ? props.groupLabel || searchPlaceholder : void 0,
2268
2295
  "aria-busy": loading ? "true" : "false"
2269
2296
  }, body)
2270
2297
  );
@@ -4657,8 +4684,21 @@ var require_action_schema_style = __commonJS({
4657
4684
  "." + P + " select:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#4f6ef7);outline-offset:1px}",
4658
4685
  "." + P + "-list{display:flex;flex-direction:column;gap:8px}",
4659
4686
  "." + P + "-card{border:1px solid var(--wb-border,#e3e5e9);border-radius:10px;padding:10px 12px;background:var(--wb-surface,var(--dsw-alias-bg-layer-1,transparent));display:flex;flex-direction:column;gap:8px;min-width:0}",
4660
- "." + P + "-cardhead{display:flex;align-items:center;gap:8px;flex-wrap:wrap}",
4661
- "." + P + "-cardhead code{font-weight:640}",
4687
+ "." + P + "-cardhead{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:start;gap:8px}",
4688
+ "." + P + "-cardmeta{display:flex;align-items:center;flex-wrap:wrap;gap:8px;min-width:0;min-height:24px}",
4689
+ "." + P + "-cardhead code{font-weight:640;overflow-wrap:anywhere;min-width:0}",
4690
+ "." + P + "-hintline{margin:0;color:var(--dsw-alias-label-tertiary,inherit);font-size:11.5px;line-height:1.5}",
4691
+ "." + P + "-toggle{display:inline-flex;align-items:center;gap:6px;min-height:24px;padding:0 2px;border:0;background:transparent;font:inherit;font-size:11.5px;color:var(--wb-muted);cursor:pointer}",
4692
+ "." + P + "-track{display:inline-flex;align-items:center;box-sizing:border-box;width:30px;height:18px;padding:2px;border:1px solid var(--wb-muted);border-radius:999px;background:var(--wb-surface);color:var(--wb-muted)}",
4693
+ "." + P + "-track::before{content:'';width:12px;height:12px;border-radius:50%;background:currentColor;transition:transform .15s ease}",
4694
+ "." + P + "-toggle[aria-checked=true] ." + P + "-track{background:var(--wb-accent);border-color:var(--wb-accent);color:var(--wb-card)}",
4695
+ "." + P + "-toggle[aria-checked=true] ." + P + "-track::before{transform:translateX(12px)}",
4696
+ "." + P + "-toggle:hover:not(:disabled) ." + P + "-track{outline:1px solid var(--wb-accent)}",
4697
+ "." + P + "-toggle:focus-visible{outline:2px solid var(--wb-accent);outline-offset:2px}",
4698
+ "." + P + "-toggle:disabled{opacity:.6;cursor:progress}",
4699
+ "@media(prefers-reduced-motion:reduce){." + P + "-track::before{transition:none}}",
4700
+ // 安全约束(不可放开):用警示色描边,和可切换的开关区分开。
4701
+ "." + P + "-locked{border-color:var(--wb-warn,#b7791f);color:var(--wb-warn,#b7791f)}",
4662
4702
  "." + P + "-desc{margin:0;color:var(--dsw-alias-label-secondary,inherit);line-height:1.55;font-size:12.5px}",
4663
4703
  // 搜索命中:用品牌色透明度叠加而不是写死浅色,深浅主题都可读;继承文字颜色、不覆盖 ::selection。
4664
4704
  "." + P + " mark." + P + "-hit{background:color-mix(in oklab,var(--dsw-alias-brand-primary,#4f6ef7) 22%,transparent);color:inherit;border-radius:2px;padding:0;font:inherit;box-decoration-break:clone;-webkit-box-decoration-break:clone}",
@@ -4710,6 +4750,15 @@ var require_action_schema_view = __commonJS({
4710
4750
  zh: {
4711
4751
  title: "Action",
4712
4752
  hint: "\u8FD0\u884C\u65F6\u6CE8\u518C \xB7 \u53EA\u8BFB",
4753
+ switchHint: "agent \u5F00\u5173\u843D\u672C\u673A\u3001\u5373\u6539\u5373\u751F\u6548\uFF1B\u754C\u9762\u64CD\u4F5C\u4E0D\u53D7\u5F71\u54CD\u3002",
4754
+ hostHint: "\u5BBF\u4E3B action \u7684 agent \u5F00\u5173\uFF1B\u6807\u300C\u4EC5\u754C\u9762 \xB7 \u5B89\u5168\u7EA6\u675F\u300D\u7684\u4E0D\u53EF\u653E\u5F00\u3002",
4755
+ agentSwitch: "agent \u53EF\u7528",
4756
+ agentLocked: "\u4EC5\u754C\u9762 \xB7 \u5B89\u5168\u7EA6\u675F",
4757
+ agentLockedHint: "\u8BE5 action \u53EA\u80FD\u5728\u754C\u9762\u6267\u884C\uFF08\u5B89\u5168\u7EA6\u675F\uFF09\uFF0Cagent \u5F00\u5173\u4E0D\u53EF\u653E\u5F00",
4758
+ agentSaving: "\u4FDD\u5B58\u4E2D\u2026",
4759
+ agentOnToast: "\u5DF2\u5141\u8BB8 agent \u8C03\u7528",
4760
+ agentOffToast: "\u5DF2\u7981\u6B62 agent \u8C03\u7528",
4761
+ agentFail: "\u5207\u6362 agent \u5F00\u5173\u5931\u8D25",
4713
4762
  domain: "\u57DF",
4714
4763
  versionLabel: "\u7248\u672C",
4715
4764
  shell: "\u5BBF\u4E3B",
@@ -4755,6 +4804,15 @@ var require_action_schema_view = __commonJS({
4755
4804
  en: {
4756
4805
  title: "Actions",
4757
4806
  hint: "runtime registry \xB7 read-only",
4807
+ switchHint: "The agent switch is stored locally and applies immediately; UI actions are unaffected.",
4808
+ hostHint: "Agent switch for host actions; items marked UI-only (security) cannot be opened up.",
4809
+ agentSwitch: "Agent callable",
4810
+ agentLocked: "UI only \xB7 security",
4811
+ agentLockedHint: "This action can only run from the UI (security constraint); the agent switch cannot be opened",
4812
+ agentSaving: "Saving\u2026",
4813
+ agentOnToast: "Agent calls allowed",
4814
+ agentOffToast: "Agent calls blocked",
4815
+ agentFail: "Failed to change the agent switch",
4758
4816
  domain: "Domain",
4759
4817
  versionLabel: "Version",
4760
4818
  shell: "Host",
@@ -4867,7 +4925,9 @@ var require_action_schema_view = __commonJS({
4867
4925
  }
4868
4926
  module2.exports = function createActionSchemaView(options) {
4869
4927
  var raw = String(options.domain || "");
4870
- var DOMAIN = raw.indexOf("wb-addon-") === 0 ? raw : "wb-addon-" + raw;
4928
+ var SOURCE = options.source === "actions.list" ? "actions.list" : "actionSchema";
4929
+ var DOMAIN = SOURCE === "actions.list" ? raw : raw.indexOf("wb-addon-") === 0 ? raw : "wb-addon-" + raw;
4930
+ var LIST_DOMAIN = options.listDomain ? String(options.listDomain) : DOMAIN;
4871
4931
  var prefix = options.prefix;
4872
4932
  var P = prefix + "-as";
4873
4933
  var Icon3 = options.Icon || null;
@@ -4911,6 +4971,8 @@ var require_action_schema_view = __commonJS({
4911
4971
  var typePick = typeState[0], setTypePick = typeState[1];
4912
4972
  var toastState = React.useState("");
4913
4973
  var toast = toastState[0], setToast = toastState[1];
4974
+ var savingState = React.useState("");
4975
+ var saving = savingState[0], setSaving = savingState[1];
4914
4976
  React.useEffect(function() {
4915
4977
  injectCss();
4916
4978
  }, []);
@@ -4919,9 +4981,10 @@ var require_action_schema_view = __commonJS({
4919
4981
  setLoading(true);
4920
4982
  setErr("");
4921
4983
  var pending;
4922
- var actionName = DOMAIN.replace(/^wb-addon-/, "") + ".actionSchema";
4984
+ var actionName = SOURCE === "actions.list" ? "actions.list" : DOMAIN.replace(/^wb-addon-/, "") + ".actionSchema";
4985
+ var callArgs = SOURCE === "actions.list" ? { detail: true, domain: LIST_DOMAIN } : void 0;
4923
4986
  if (api && typeof api.call === "function") {
4924
- pending = Promise.resolve(api.call(actionName)).then(function(r) {
4987
+ pending = Promise.resolve(api.call(actionName, callArgs)).then(function(r) {
4925
4988
  if (r && r.ok === false) return r;
4926
4989
  return r && r.result || r;
4927
4990
  });
@@ -4961,6 +5024,39 @@ var require_action_schema_view = __commonJS({
4961
5024
  plainCopy(text);
4962
5025
  done();
4963
5026
  }
5027
+ function setAgent(action, next) {
5028
+ var name = action.name;
5029
+ setSaving(name);
5030
+ setToast("");
5031
+ var fail = function(e) {
5032
+ setSaving("");
5033
+ setToast(t.agentFail + "\uFF1A" + String(e && e.message || e || ""));
5034
+ };
5035
+ var done = function(r) {
5036
+ setSaving("");
5037
+ var payload = r && typeof r === "object" && Object.prototype.hasOwnProperty.call(r, "result") ? r.result : r;
5038
+ if (r && r.ok === false) {
5039
+ setToast(t.agentFail + "\uFF1A" + String(r.error || r.text || ""));
5040
+ return;
5041
+ }
5042
+ var value = payload && typeof payload.agentEnabled === "boolean" ? payload.agentEnabled : next;
5043
+ setSnap(function(prev) {
5044
+ if (!prev || !Array.isArray(prev.actions)) return prev;
5045
+ return Object.assign({}, prev, {
5046
+ actions: prev.actions.map(function(a) {
5047
+ if (!a || a.name !== name) return a;
5048
+ return Object.assign({}, a, { agentEnabled: value });
5049
+ })
5050
+ });
5051
+ });
5052
+ setToast(value ? t.agentOnToast : t.agentOffToast);
5053
+ };
5054
+ if (!api || typeof api.call !== "function") {
5055
+ fail(new Error("no call api"));
5056
+ return;
5057
+ }
5058
+ Promise.resolve(api.call("actions.setAgentAccess", { action: name, agentEnabled: next })).then(done, fail);
5059
+ }
4964
5060
  var all = snap && Array.isArray(snap.actions) ? snap.actions.filter(function(a) {
4965
5061
  return a && a.domain === DOMAIN;
4966
5062
  }) : [];
@@ -5009,6 +5105,35 @@ var require_action_schema_view = __commonJS({
5009
5105
  h2("td", null, Highlight.hit(row.description, kw))
5010
5106
  );
5011
5107
  }
5108
+ function agentSwitch(action) {
5109
+ if (action.agentLocked === true) {
5110
+ return h2("span", {
5111
+ className: P + "-badge " + P + "-locked",
5112
+ title: t.agentLockedHint,
5113
+ "data-agent-locked": action.name
5114
+ }, t.agentLocked);
5115
+ }
5116
+ if (typeof action.agentEnabled !== "boolean") return null;
5117
+ var busy = saving === action.name;
5118
+ return h2(
5119
+ "button",
5120
+ {
5121
+ className: P + "-toggle",
5122
+ "data-agent-row": action.name,
5123
+ type: "button",
5124
+ role: "switch",
5125
+ "aria-checked": action.agentEnabled,
5126
+ disabled: busy,
5127
+ "data-agent-toggle": action.name,
5128
+ "aria-label": t.agentSwitch + " \xB7 " + action.name,
5129
+ onClick: function() {
5130
+ setAgent(action, !action.agentEnabled);
5131
+ }
5132
+ },
5133
+ h2("span", { className: P + "-track", "aria-hidden": true }),
5134
+ h2("span", null, busy ? t.agentSaving : t.agentSwitch)
5135
+ );
5136
+ }
5012
5137
  function card(action) {
5013
5138
  var rows = paramRows(action);
5014
5139
  var examples = Array.isArray(action.examples) ? action.examples : [];
@@ -5018,12 +5143,16 @@ var require_action_schema_view = __commonJS({
5018
5143
  h2(
5019
5144
  "div",
5020
5145
  { className: P + "-cardhead" },
5021
- h2("code", { className: P + "-mono" }, Highlight.hit(action.name, kw)),
5022
- // 域名在页头已展示一次,卡片内不再重复(所有条目必然同域,见 visible 过滤)。
5023
- h2("span", { className: P + "-badge" }, rows.length ? t.paramCount(rows.length) : t.noParams),
5024
- rows.some(function(row) {
5025
- return row.required;
5026
- }) ? h2("span", { className: P + "-badge " + P + "-req" }, t.required) : null
5146
+ h2(
5147
+ "div",
5148
+ { className: P + "-cardmeta" },
5149
+ h2("code", { className: P + "-mono" }, Highlight.hit(action.name, kw)),
5150
+ h2("span", { className: P + "-badge" }, rows.length ? t.paramCount(rows.length) : t.noParams),
5151
+ rows.some(function(row) {
5152
+ return row.required;
5153
+ }) ? h2("span", { className: P + "-badge " + P + "-req" }, t.required) : null
5154
+ ),
5155
+ agentSwitch(action)
5027
5156
  ),
5028
5157
  action.description ? h2("p", { className: P + "-desc" }, Highlight.hit(action.description, kw)) : null,
5029
5158
  rows.length ? h2(
@@ -5100,6 +5229,7 @@ var require_action_schema_view = __commonJS({
5100
5229
  h2("span", { className: P + "-badge" }, t.count(visible.length, all.length)),
5101
5230
  h2("span", { className: P + "-none" }, t.hint)
5102
5231
  ),
5232
+ h2("p", { className: P + "-hintline" }, SOURCE === "actions.list" ? t.hostHint : t.switchHint),
5103
5233
  snap ? h2(
5104
5234
  "div",
5105
5235
  { className: P + "-toolbar" },
@@ -5186,7 +5316,7 @@ if (host) {
5186
5316
  h = require("react").createElement, Icon2 = require_icons().Icon;
5187
5317
  host.registerAddon({
5188
5318
  id: "wb-addon-storage",
5189
- version: "1.5.5",
5319
+ version: "1.5.6",
5190
5320
  icon: (init_package(), __toCommonJS(package_exports)).default,
5191
5321
  views: [
5192
5322
  { id: "stats", icon: tabIcon2("chart"), title: { zh: "\u7EDF\u8BA1", en: "Statistics" }, component: require_stats().Stats },
package/lib/index.js CHANGED
@@ -67,7 +67,7 @@ export function apply(ctx) {
67
67
  id: "wb-addon-storage",
68
68
  title: "储物",
69
69
  description: "储物:记录物品名称、品牌、单位、库存文本、存放位置、图片URL、备注与可选标签",
70
- version: "1.5.5",
70
+ version: "1.5.6",
71
71
  tables: ["storage"],
72
72
  sync: storageSync,
73
73
  backupAfter: ["wb-addon-tags"],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-workbench-storage",
3
- "version": "1.5.5",
3
+ "version": "1.5.6",
4
4
  "type": "module",
5
5
  "description": "个人工作台储物插件:名称、品牌、位置、单位、库存文本与标签",
6
6
  "main": "lib/index.js",
@@ -9,8 +9,8 @@
9
9
  "id": "wb-addon-storage",
10
10
  "title": "储物",
11
11
  "description": "储物:统计/记录/配置/数据四个视图",
12
- "version": "1.5.5",
13
- "minShell": "0.5.7",
12
+ "version": "1.5.6",
13
+ "minShell": "0.8.0",
14
14
  "tables": [
15
15
  "storage"
16
16
  ],
@@ -47,7 +47,7 @@
47
47
  "./package.json": "./package.json"
48
48
  },
49
49
  "dependencies": {
50
- "dsh-workbench-host": "^0.7.0"
50
+ "dsh-workbench-host": "^0.8.0"
51
51
  },
52
52
  "dsh": {
53
53
  "bundle": {