@fuaran-ui/ops 0.5.0 → 0.6.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.
package/dist/index.cjs CHANGED
@@ -385,6 +385,9 @@ var binding = (b, staticEnc = objValue) => {
385
385
  }
386
386
  case "Computed":
387
387
  return caseObj("Computed", [["fn", CLOSURE]]);
388
+ // No wire fields: the instant is host-furnished at resolve time.
389
+ case "Now":
390
+ return caseObj("Now", []);
388
391
  case "I18n": {
389
392
  const fields = [];
390
393
  if (b.args !== void 0) {
@@ -879,6 +882,11 @@ var formFieldKind = (autoBind, k) => {
879
882
  ...handlerField("onToggle", k.onToggle),
880
883
  ...valueField(k.value, schema.controlValueDefaults.checkbox, (v) => binding(v))
881
884
  ]);
885
+ case "Toggle":
886
+ return caseObj("Toggle", [
887
+ ...handlerField("onToggle", k.onToggle),
888
+ ...valueField(k.value, schema.controlValueDefaults.checkbox, (v) => binding(v))
889
+ ]);
882
890
  case "Choice":
883
891
  return caseObj("Choice", [
884
892
  ...handlerField("onChange", k.onChange),
@@ -1444,7 +1452,10 @@ var nodeKind = (k) => {
1444
1452
  )
1445
1453
  ],
1446
1454
  ["default", node(k.spec.default)],
1447
- ["stateKey", str(k.spec.stateKey)]
1455
+ // Phase 768 collapse rule — State(key, no default) keeps the compact
1456
+ // canonical `stateKey` spelling (existing fixtures stay byte-identical);
1457
+ // any other selector encodes as `on`.
1458
+ k.spec.on.kind === "State" && k.spec.on.defaultValue === void 0 ? ["stateKey", str(k.spec.on.key)] : ["on", binding(k.spec.on, str)]
1448
1459
  ]);
1449
1460
  case "FragmentDecl": {
1450
1461
  const fields = [
@@ -4166,6 +4177,13 @@ var decodeBinding = (path, j, parseStatic = (_p, v) => ok(decodeAstValue(v)), pl
4166
4177
  }
4167
4178
  case "Computed":
4168
4179
  return ok({ kind: "Computed", compute: () => void 0 });
4180
+ // The projection decodes to the IDENTITY (the Phase 427 Selection fix
4181
+ // replayed): the host-furnished instant is already the wire-shaped string,
4182
+ // so a decoded reader receives it as-is. A value-discarding placeholder
4183
+ // here would make every decoded `Now` resolve to nothing even when the
4184
+ // host furnishes the instant.
4185
+ case "Now":
4186
+ return ok({ kind: "Now", project: (iso) => iso });
4169
4187
  case "I18n": {
4170
4188
  const key = reqField(path, f, "key", "i18n key string", requireString);
4171
4189
  if (!key.ok) return key;
@@ -5311,6 +5329,14 @@ var decodeFormFieldKind = (autoBind, path, j) => {
5311
5329
  ...onToggleField
5312
5330
  }) : v;
5313
5331
  }
5332
+ case "Toggle": {
5333
+ const v = valueOr(decodeBinding, schema.controlValueDefaults.checkbox, "Toggle value binding");
5334
+ return v.ok ? ok({
5335
+ kind: "Toggle",
5336
+ value: v.value,
5337
+ ...onToggleField
5338
+ }) : v;
5339
+ }
5314
5340
  case "Choice": {
5315
5341
  const options = reqField(
5316
5342
  path,
@@ -6580,8 +6606,22 @@ var decodeNodeKind = (path, j) => {
6580
6606
  return ok({ kind: "ErrorBoundary", spec: { child: child.value, fallback: fallback.value } });
6581
6607
  }
6582
6608
  case "Switch": {
6583
- const stateKey = reqField(path, f, "stateKey", "Switch stateKey string", requireString);
6584
- if (!stateKey.ok) return stateKey;
6609
+ const onJ = tryField(f, "on");
6610
+ const on = onJ !== void 0 ? decodeBinding(`${path}.on`, onJ) : (() => {
6611
+ const stateKey = reqField(
6612
+ path,
6613
+ f,
6614
+ "stateKey",
6615
+ "Switch stateKey string",
6616
+ requireString
6617
+ );
6618
+ return stateKey.ok ? ok({
6619
+ kind: "State",
6620
+ key: stateKey.value,
6621
+ defaultValue: void 0
6622
+ }) : stateKey;
6623
+ })();
6624
+ if (!on.ok) return on;
6585
6625
  const casesArr = reqField(path, f, "cases", "Switch cases array", requireArray);
6586
6626
  if (!casesArr.ok) return casesArr;
6587
6627
  const cases = traverseIndexed(casesArr.value, (i, item) => {
@@ -6599,7 +6639,7 @@ var decodeNodeKind = (path, j) => {
6599
6639
  if (!def.ok) return def;
6600
6640
  return ok({
6601
6641
  kind: "Switch",
6602
- spec: { stateKey: stateKey.value, cases: cases.value, default: def.value }
6642
+ spec: { on: on.value, cases: cases.value, default: def.value }
6603
6643
  });
6604
6644
  }
6605
6645
  case "FragmentDecl": {