dsh-ledger-memory 0.1.0 → 0.2.0

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.
Files changed (4) hide show
  1. package/README.md +108 -1495
  2. package/lib/client.js +62 -0
  3. package/lib/index.js +628 -10
  4. package/package.json +3 -2
package/lib/client.js CHANGED
@@ -266,6 +266,22 @@ window.__ModuleLoader__.load({
266
266
  border: 1px solid var(--dsw-alias-border-l1); border-radius: 8px;
267
267
  }
268
268
  .pl-settings__mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
269
+ /* 二选一(模式):把两个选项的**取舍**都摆在眼前,不下拉折叠 */
270
+ .pl-settings__choices { display: flex; flex-direction: column; gap: 6px; width: 100%; }
271
+ .pl-settings__choice {
272
+ display: flex; gap: 8px; align-items: flex-start; cursor: pointer;
273
+ padding: 8px 10px; border-radius: 8px;
274
+ border: 1px solid var(--dsw-alias-border-l1);
275
+ background: var(--dsw-alias-bg-layer-1);
276
+ }
277
+ .pl-settings__choice--on {
278
+ border-color: var(--dsw-alias-state-success-primary);
279
+ background: var(--dsw-alias-bg-layer-2);
280
+ }
281
+ .pl-settings__choice input { margin-top: 2px; flex: none; }
282
+ .pl-settings__choice-body { display: flex; flex-direction: column; gap: 2px; }
283
+ .pl-settings__choice-label { font-size: 13px; color: var(--dsw-alias-label-primary); }
284
+ .pl-settings__choice-hint { font-size: 12px; line-height: 1.55; color: var(--dsw-alias-label-secondary); }
269
285
  `;
270
286
 
271
287
  function installCss(ctx) {
@@ -334,6 +350,51 @@ window.__ModuleLoader__.load({
334
350
  ]);
335
351
  }
336
352
 
353
+ /**
354
+ * 二选一(含以上)行 —— 每个选项一个单选按钮 + 名字 + 说明。
355
+ *
356
+ * ★ 为什么不用下拉框:这一项的两个选项**各有各的取舍**(省一次模型输出 vs
357
+ * 按内容分流),用户需要**看见取舍**才能选对。下拉框把说明藏起来了。
358
+ * ★ 选项来自宿主(`spec.options` 是**已展开的数组** —— 宿主那边是取值函数,
359
+ * 为躲 TDZ;见宿主 `SETTING_SPECS` 的注释)。客户端**不认识任何模式名**,
360
+ * 只按 `value`/`label`/`hint` 渲染 ⇒ 以后加第三个模式**不用改本文件**。
361
+ */
362
+ function ChoiceRow(props) {
363
+ const { spec, value, onChange, disabled } = props;
364
+ const opts = Array.isArray(spec.options) ? spec.options : [];
365
+ return h(Row, { label: spec.label, hint: spec.hint, stack: true }, [
366
+ h(
367
+ "div",
368
+ { key: "g", className: "pl-settings__choices" },
369
+ opts.map((o) =>
370
+ h(
371
+ "label",
372
+ {
373
+ key: String(o.value),
374
+ className:
375
+ "pl-settings__choice" + (String(o.value) === String(value) ? " pl-settings__choice--on" : ""),
376
+ },
377
+ [
378
+ h("input", {
379
+ key: "r",
380
+ type: "radio",
381
+ name: spec.key,
382
+ value: o.value,
383
+ checked: String(o.value) === String(value),
384
+ disabled: disabled === true,
385
+ onChange: () => onChange(o.value),
386
+ }),
387
+ h("span", { key: "t", className: "pl-settings__choice-body" }, [
388
+ h("span", { key: "l", className: "pl-settings__choice-label" }, o.label || String(o.value)),
389
+ o.hint ? h("span", { key: "h", className: "pl-settings__choice-hint" }, o.hint) : null,
390
+ ]),
391
+ ]
392
+ )
393
+ )
394
+ ),
395
+ ]);
396
+ }
397
+
337
398
  /** 档位行(文本框,逗号分隔)。 */
338
399
  function TiersRow(props) {
339
400
  const { spec, value, onChange, disabled } = props;
@@ -394,6 +455,7 @@ window.__ModuleLoader__.load({
394
455
  const value = draft[spec.key];
395
456
  const set = (v) => setDraft(Object.assign({}, draft, { [spec.key]: v }));
396
457
  if (spec.kind === "boolean") return h(BoolRow, { key: spec.key, spec, value, onChange: set, disabled });
458
+ if (spec.kind === "choice") return h(ChoiceRow, { key: spec.key, spec, value, onChange: set, disabled });
397
459
  if (spec.kind === "number") return h(NumberRow, { key: spec.key, spec, value, onChange: set, disabled });
398
460
  if (spec.kind === "tiers") return h(TiersRow, { key: spec.key, spec, value, onChange: set, disabled });
399
461
  if (spec.kind === "levels") return h(LevelsRow, { key: spec.key, spec, value, onChange: set, disabled });