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