@fuaran-ui/ops 0.4.0 → 0.5.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
@@ -1046,6 +1046,16 @@ var staticStringOpt = (v) => v === void 0 ? "null" : str(v);
1046
1046
  var staticStringList = (v) => jArray(v.map(str));
1047
1047
  var staticFloatSeq = (v) => jArray(v.map(num));
1048
1048
  var staticMarkerSeq = (v) => jArray(v.map(mapMarker));
1049
+ var rowValue = (row) => {
1050
+ if (row === null || typeof row !== "object") return "{}";
1051
+ const fields = [];
1052
+ for (const [k, v] of Object.entries(row)) {
1053
+ if (v === null || v === void 0) continue;
1054
+ fields.push([k, objValue(v)]);
1055
+ }
1056
+ return jObject(fields);
1057
+ };
1058
+ var staticRowSeq = (v) => jArray(v.map(rowValue));
1049
1059
  var cellKindErased = (k) => {
1050
1060
  switch (k.kind) {
1051
1061
  case "Text":
@@ -1127,7 +1137,8 @@ var gridSpec = (s) => {
1127
1137
  ["columns", jArray(s.columns.map(columnErased))],
1128
1138
  // 0.2.0 omitted-when-false.
1129
1139
  ...s.editable ? [["editable", bool(true)]] : [],
1130
- ["source", binding(s.source)]
1140
+ // fuaran#665 — rows are a typed Static payload now, not the opaque residual.
1141
+ ["source", binding(s.source, staticRowSeq)]
1131
1142
  ];
1132
1143
  if (s.onRowClick !== void 0) fields.push(["onRowClick", CLOSURE]);
1133
1144
  if (s.rowKey !== void 0) fields.push(["rowKey", CLOSURE]);
@@ -1145,7 +1156,8 @@ var gridSpec = (s) => {
1145
1156
  var chartSpec = (s) => {
1146
1157
  const fields = [
1147
1158
  ["kind", str(s.kind)],
1148
- ["source", binding(s.source)],
1159
+ // fuaran#665 — rows are a typed Static payload now, not the opaque residual.
1160
+ ["source", binding(s.source, staticRowSeq)],
1149
1161
  ["stacked", bool(s.stacked)],
1150
1162
  ["xField", str(s.xField)],
1151
1163
  ["yFields", jArray(s.yFields.map(str))]
@@ -4421,6 +4433,17 @@ var parseStaticFloatSeq = (p, v) => {
4421
4433
  return traverseIndexed(arr.value, (i, el) => requireFloat(`${p}[${i}]`, el));
4422
4434
  };
4423
4435
  var decodeBindingFloatSeq = (p, j) => decodeBinding(p, j, parseStaticFloatSeq, []);
4436
+ var parseStaticRows = (p, v) => {
4437
+ if (v.kind === "JNull") return ok([]);
4438
+ if (v.kind === "JString" && v.value === OPAQUE2) return ok([]);
4439
+ const arr = requireArray(p, v);
4440
+ if (!arr.ok) return arr;
4441
+ return traverseIndexed(
4442
+ arr.value,
4443
+ (i, el) => el.kind === "JObject" ? ok(decodeAstValue(el)) : wrongType(`${p}[${i}]`, "row object")
4444
+ );
4445
+ };
4446
+ var decodeBindingRows = (p, j) => decodeBinding(p, j, parseStaticRows, []);
4424
4447
  var decodeMapMarker = (path, j) => {
4425
4448
  const fo = requireObject(path, j);
4426
4449
  if (!fo.ok) return fo;
@@ -5850,7 +5873,7 @@ var decodeGridSpec = (path, j) => {
5850
5873
  "source",
5851
5874
  ["data", "rows"],
5852
5875
  "Grid source binding",
5853
- decodeBinding
5876
+ decodeBindingRows
5854
5877
  );
5855
5878
  if (!source.ok) return source;
5856
5879
  const hasRowClick = tryField(f, "onRowClick") !== void 0;
@@ -5891,7 +5914,7 @@ var decodeChartSpec = (path, j) => {
5891
5914
  "source",
5892
5915
  ["data"],
5893
5916
  "Chart source binding",
5894
- decodeBinding
5917
+ decodeBindingRows
5895
5918
  );
5896
5919
  if (!source.ok) return source;
5897
5920
  const xField = reqField(path, f, "xField", "xField string", requireString);