@fuaran-ui/ops 0.4.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),
@@ -1046,6 +1054,16 @@ var staticStringOpt = (v) => v === void 0 ? "null" : str(v);
1046
1054
  var staticStringList = (v) => jArray(v.map(str));
1047
1055
  var staticFloatSeq = (v) => jArray(v.map(num));
1048
1056
  var staticMarkerSeq = (v) => jArray(v.map(mapMarker));
1057
+ var rowValue = (row) => {
1058
+ if (row === null || typeof row !== "object") return "{}";
1059
+ const fields = [];
1060
+ for (const [k, v] of Object.entries(row)) {
1061
+ if (v === null || v === void 0) continue;
1062
+ fields.push([k, objValue(v)]);
1063
+ }
1064
+ return jObject(fields);
1065
+ };
1066
+ var staticRowSeq = (v) => jArray(v.map(rowValue));
1049
1067
  var cellKindErased = (k) => {
1050
1068
  switch (k.kind) {
1051
1069
  case "Text":
@@ -1127,7 +1145,8 @@ var gridSpec = (s) => {
1127
1145
  ["columns", jArray(s.columns.map(columnErased))],
1128
1146
  // 0.2.0 omitted-when-false.
1129
1147
  ...s.editable ? [["editable", bool(true)]] : [],
1130
- ["source", binding(s.source)]
1148
+ // fuaran#665 — rows are a typed Static payload now, not the opaque residual.
1149
+ ["source", binding(s.source, staticRowSeq)]
1131
1150
  ];
1132
1151
  if (s.onRowClick !== void 0) fields.push(["onRowClick", CLOSURE]);
1133
1152
  if (s.rowKey !== void 0) fields.push(["rowKey", CLOSURE]);
@@ -1145,7 +1164,8 @@ var gridSpec = (s) => {
1145
1164
  var chartSpec = (s) => {
1146
1165
  const fields = [
1147
1166
  ["kind", str(s.kind)],
1148
- ["source", binding(s.source)],
1167
+ // fuaran#665 — rows are a typed Static payload now, not the opaque residual.
1168
+ ["source", binding(s.source, staticRowSeq)],
1149
1169
  ["stacked", bool(s.stacked)],
1150
1170
  ["xField", str(s.xField)],
1151
1171
  ["yFields", jArray(s.yFields.map(str))]
@@ -1430,7 +1450,10 @@ var nodeKind = (k) => {
1430
1450
  )
1431
1451
  ],
1432
1452
  ["default", node(k.spec.default)],
1433
- ["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)]
1434
1457
  ]);
1435
1458
  case "FragmentDecl": {
1436
1459
  const fields = [
@@ -4152,6 +4175,13 @@ var decodeBinding = (path, j, parseStatic = (_p, v) => ok(decodeAstValue(v)), pl
4152
4175
  }
4153
4176
  case "Computed":
4154
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 });
4155
4185
  case "I18n": {
4156
4186
  const key = reqField(path, f, "key", "i18n key string", requireString);
4157
4187
  if (!key.ok) return key;
@@ -4421,6 +4451,17 @@ var parseStaticFloatSeq = (p, v) => {
4421
4451
  return traverseIndexed(arr.value, (i, el) => requireFloat(`${p}[${i}]`, el));
4422
4452
  };
4423
4453
  var decodeBindingFloatSeq = (p, j) => decodeBinding(p, j, parseStaticFloatSeq, []);
4454
+ var parseStaticRows = (p, v) => {
4455
+ if (v.kind === "JNull") return ok([]);
4456
+ if (v.kind === "JString" && v.value === OPAQUE2) return ok([]);
4457
+ const arr = requireArray(p, v);
4458
+ if (!arr.ok) return arr;
4459
+ return traverseIndexed(
4460
+ arr.value,
4461
+ (i, el) => el.kind === "JObject" ? ok(decodeAstValue(el)) : wrongType(`${p}[${i}]`, "row object")
4462
+ );
4463
+ };
4464
+ var decodeBindingRows = (p, j) => decodeBinding(p, j, parseStaticRows, []);
4424
4465
  var decodeMapMarker = (path, j) => {
4425
4466
  const fo = requireObject(path, j);
4426
4467
  if (!fo.ok) return fo;
@@ -5286,6 +5327,14 @@ var decodeFormFieldKind = (autoBind, path, j) => {
5286
5327
  ...onToggleField
5287
5328
  }) : v;
5288
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
+ }
5289
5338
  case "Choice": {
5290
5339
  const options = reqField(
5291
5340
  path,
@@ -5850,7 +5899,7 @@ var decodeGridSpec = (path, j) => {
5850
5899
  "source",
5851
5900
  ["data", "rows"],
5852
5901
  "Grid source binding",
5853
- decodeBinding
5902
+ decodeBindingRows
5854
5903
  );
5855
5904
  if (!source.ok) return source;
5856
5905
  const hasRowClick = tryField(f, "onRowClick") !== void 0;
@@ -5891,7 +5940,7 @@ var decodeChartSpec = (path, j) => {
5891
5940
  "source",
5892
5941
  ["data"],
5893
5942
  "Chart source binding",
5894
- decodeBinding
5943
+ decodeBindingRows
5895
5944
  );
5896
5945
  if (!source.ok) return source;
5897
5946
  const xField = reqField(path, f, "xField", "xField string", requireString);
@@ -6555,8 +6604,22 @@ var decodeNodeKind = (path, j) => {
6555
6604
  return ok({ kind: "ErrorBoundary", spec: { child: child.value, fallback: fallback.value } });
6556
6605
  }
6557
6606
  case "Switch": {
6558
- const stateKey = reqField(path, f, "stateKey", "Switch stateKey string", requireString);
6559
- 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;
6560
6623
  const casesArr = reqField(path, f, "cases", "Switch cases array", requireArray);
6561
6624
  if (!casesArr.ok) return casesArr;
6562
6625
  const cases = traverseIndexed(casesArr.value, (i, item) => {
@@ -6574,7 +6637,7 @@ var decodeNodeKind = (path, j) => {
6574
6637
  if (!def.ok) return def;
6575
6638
  return ok({
6576
6639
  kind: "Switch",
6577
- spec: { stateKey: stateKey.value, cases: cases.value, default: def.value }
6640
+ spec: { on: on.value, cases: cases.value, default: def.value }
6578
6641
  });
6579
6642
  }
6580
6643
  case "FragmentDecl": {