dsh-workbench-salary 0.4.10 → 0.4.12

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
@@ -5465,6 +5465,10 @@ var require_action_schema_style = __commonJS({
5465
5465
  "." + P + "-copy:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#4f6ef7);outline-offset:2px}",
5466
5466
  "." + P + " details>summary{cursor:pointer;font-size:11.5px;color:var(--dsw-alias-label-secondary,inherit);width:max-content}",
5467
5467
  "." + P + " details>summary:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#4f6ef7);outline-offset:2px}",
5468
+ // 参数折叠面板:折叠时只留一行「参数 · 必填 n」,展开后与表格之间留一点气口。
5469
+ "." + P + "-params{min-width:0}",
5470
+ "." + P + "-params>summary{user-select:none;max-width:100%}",
5471
+ "." + P + "-params[open]>summary{margin-bottom:6px}",
5468
5472
  "." + P + "-empty{padding:24px;text-align:center;border:1px dashed var(--wb-border,#e3e5e9);border-radius:10px;color:var(--dsw-alias-label-tertiary,inherit)}",
5469
5473
  "." + 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}",
5470
5474
  "." + 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%}",
@@ -5544,6 +5548,10 @@ var require_action_schema_view = __commonJS({
5544
5548
  paramCount: function(n) {
5545
5549
  return n + " \u4E2A\u53C2\u6570";
5546
5550
  },
5551
+ params: "\u53C2\u6570",
5552
+ requiredCount: function(n) {
5553
+ return "\u5FC5\u586B " + n;
5554
+ },
5547
5555
  examples: "\u793A\u4F8B",
5548
5556
  noExamples: "\u65E0\u793A\u4F8B",
5549
5557
  copy: "\u590D\u5236",
@@ -5607,6 +5615,10 @@ var require_action_schema_view = __commonJS({
5607
5615
  paramCount: function(n) {
5608
5616
  return n + " params";
5609
5617
  },
5618
+ params: "Parameters",
5619
+ requiredCount: function(n) {
5620
+ return n + " required";
5621
+ },
5610
5622
  examples: "Examples",
5611
5623
  noExamples: "No examples",
5612
5624
  copy: "Copy",
@@ -5745,6 +5757,8 @@ var require_action_schema_view = __commonJS({
5745
5757
  var toast = toastState[0], setToast = toastState[1];
5746
5758
  var savingState = React.useState("");
5747
5759
  var saving = savingState[0], setSaving = savingState[1];
5760
+ var foldsState = React.useState({});
5761
+ var folds = foldsState[0], setFolds = foldsState[1];
5748
5762
  React.useEffect(function() {
5749
5763
  injectCss();
5750
5764
  }, []);
@@ -5844,6 +5858,15 @@ var require_action_schema_view = __commonJS({
5844
5858
  }
5845
5859
  Promise.resolve(api.call("actions.setActionOrigins", { action: name, origins: next })).then(done, fail);
5846
5860
  }
5861
+ function paramsOpen(action) {
5862
+ if (Object.prototype.hasOwnProperty.call(folds, action.name)) return folds[action.name] === true;
5863
+ return Boolean(String(query || "").trim()) || reqMode !== "all" || Boolean(typePick);
5864
+ }
5865
+ function resetFolds() {
5866
+ setFolds(function(prev) {
5867
+ return Object.keys(prev).length ? {} : prev;
5868
+ });
5869
+ }
5847
5870
  var all = snap && Array.isArray(snap.actions) ? snap.actions.filter(function(a) {
5848
5871
  return a && a.domain === DOMAIN;
5849
5872
  }) : [];
@@ -5940,6 +5963,10 @@ var require_action_schema_view = __commonJS({
5940
5963
  }
5941
5964
  function card(action) {
5942
5965
  var rows = paramRows(action);
5966
+ var required = rows.filter(function(row) {
5967
+ return row.required;
5968
+ }).length;
5969
+ var open = paramsOpen(action);
5943
5970
  var examples = Array.isArray(action.examples) ? action.examples : [];
5944
5971
  return h(
5945
5972
  "div",
@@ -5960,18 +5987,38 @@ var require_action_schema_view = __commonJS({
5960
5987
  ),
5961
5988
  action.description ? h("p", { className: P + "-desc" }, Highlight.hit(action.description, kw)) : null,
5962
5989
  rows.length ? h(
5963
- "table",
5964
- { className: P + "-table" },
5965
- h("thead", null, h(
5966
- "tr",
5967
- null,
5968
- h("th", null, t.colName),
5969
- h("th", null, t.colType),
5970
- h("th", null, t.colReq),
5971
- h("th", null, t.colExtra),
5972
- h("th", null, t.colDesc)
5973
- )),
5974
- h("tbody", null, rows.map(paramRow))
5990
+ "details",
5991
+ {
5992
+ className: P + "-params",
5993
+ "data-params-fold": action.name,
5994
+ open,
5995
+ // 原生 details 自带键盘与无障碍语义,这里只记下用户的开合;
5996
+ // 筛选变化引起的程序性开合也会触发 toggle,记下的值与当次默认一致,随后由 resetFolds 清掉。
5997
+ onToggle: function(e) {
5998
+ var next = !!(e && e.currentTarget && e.currentTarget.open);
5999
+ setFolds(function(prev) {
6000
+ if (prev[action.name] === next) return prev;
6001
+ var out = Object.assign({}, prev);
6002
+ out[action.name] = next;
6003
+ return out;
6004
+ });
6005
+ }
6006
+ },
6007
+ h("summary", null, t.params + (required ? " \xB7 " + t.requiredCount(required) : "")),
6008
+ h(
6009
+ "table",
6010
+ { className: P + "-table" },
6011
+ h("thead", null, h(
6012
+ "tr",
6013
+ null,
6014
+ h("th", null, t.colName),
6015
+ h("th", null, t.colType),
6016
+ h("th", null, t.colReq),
6017
+ h("th", null, t.colExtra),
6018
+ h("th", null, t.colDesc)
6019
+ )),
6020
+ h("tbody", null, rows.map(paramRow))
6021
+ )
5975
6022
  ) : h("div", { className: P + "-none" }, t.noParams),
5976
6023
  h(
5977
6024
  "div",
@@ -6048,6 +6095,7 @@ var require_action_schema_view = __commonJS({
6048
6095
  "aria-label": t.search,
6049
6096
  onChange: function(e) {
6050
6097
  setQuery(e.target.value);
6098
+ resetFolds();
6051
6099
  }
6052
6100
  })
6053
6101
  ),
@@ -6059,6 +6107,7 @@ var require_action_schema_view = __commonJS({
6059
6107
  "select",
6060
6108
  { value: reqMode, "aria-label": t.filterReq, onChange: function(e) {
6061
6109
  setReqMode(e.target.value);
6110
+ resetFolds();
6062
6111
  } },
6063
6112
  h("option", { value: "all" }, t.all),
6064
6113
  h("option", { value: "required" }, t.onlyRequired),
@@ -6073,6 +6122,7 @@ var require_action_schema_view = __commonJS({
6073
6122
  "select",
6074
6123
  { value: typePick, "aria-label": t.filterType, onChange: function(e) {
6075
6124
  setTypePick(e.target.value);
6125
+ resetFolds();
6076
6126
  } },
6077
6127
  h("option", { value: "" }, t.allTypes),
6078
6128
  typeOptions.map(function(name) {
@@ -6157,7 +6207,7 @@ var GLYPHS = require_icons2().ICONS;
6157
6207
  ensureStyles();
6158
6208
  host.registerAddon({
6159
6209
  id: "wb-addon-salary",
6160
- version: "0.4.10",
6210
+ version: "0.4.12",
6161
6211
  icon: GLYPHS["wallet"],
6162
6212
  views: [
6163
6213
  { id: "stats", icon: tabIcon("stats"), title: { zh: "\u7EDF\u8BA1", en: "Stats" }, component: withProps(require_stats(), "\u7EDF\u8BA1") },
package/lib/index.js CHANGED
@@ -1,5 +1,9 @@
1
1
  /** wb-addon-salary:按日期记录日结/月结工资、收入项、扣款项与实发统计。 */
2
2
  import { bindClock, ensureSchema } from "./db/db.js";
3
+ import { createRequire } from "node:module";
4
+
5
+ // 版本号只认 package.json:首页插件卡读的就是这里注册的 version。
6
+ const ADDON_VERSION = createRequire(import.meta.url)("../package.json").version;
3
7
  import { createSalary } from "./domain/salary.js";
4
8
  import { registerSalaryActions } from "./domain/actions.js";
5
9
 
@@ -28,7 +32,7 @@ export function apply(ctx) {
28
32
  id: "wb-addon-salary",
29
33
  title: "工资",
30
34
  description: "按日期记录日结/月结工资:用工类型、收入项、税前扣款、社保公积金、个税与实发",
31
- version: "0.4.5",
35
+ version: ADDON_VERSION,
32
36
  category: "finance",
33
37
  tables: ["salary_record"],
34
38
  sync: { tables: [] },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-workbench-salary",
3
- "version": "0.4.10",
3
+ "version": "0.4.12",
4
4
  "description": "个人工作台工资插件:按发薪日期记录工资构成、扣款与实发",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -16,7 +16,7 @@
16
16
  "addon": {
17
17
  "id": "wb-addon-salary",
18
18
  "title": "工资",
19
- "version": "0.4.10",
19
+ "version": "0.4.12",
20
20
  "minShell": "0.8.0",
21
21
  "tables": [
22
22
  "salary_record"
@@ -43,7 +43,7 @@
43
43
  }
44
44
  },
45
45
  "dependencies": {
46
- "dsh-workbench-host": "^0.10.4"
46
+ "dsh-workbench-host": "^0.10.6"
47
47
  },
48
48
  "dsh": {
49
49
  "bundle": {