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