@fuaran-ui/ops 0.3.0 → 0.4.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
@@ -1092,6 +1092,16 @@ var cellKindErased = (k) => {
1092
1092
  ["labelFn", CLOSURE],
1093
1093
  ["toneFn", CLOSURE]
1094
1094
  ]);
1095
+ // Phase 750 — the declarative pill. `default` is omitted-when-`Default` (the Phase
1096
+ // 460 discipline); `jObject` Ordinal-sorts, so push order is irrelevant.
1097
+ case "TonedPill": {
1098
+ const fields = [
1099
+ ["field", str(k.field)],
1100
+ ["map", jObject(Object.entries(k.map).map(([v, t]) => [v, str(t)]))]
1101
+ ];
1102
+ if (k.defaultTone !== "Default") fields.push(["default", str(k.defaultTone)]);
1103
+ return caseObj("TonedPill", fields);
1104
+ }
1095
1105
  case "Progress":
1096
1106
  return caseObj("Progress", [
1097
1107
  ["fractionFn", CLOSURE],
@@ -3016,14 +3026,18 @@ var EMPHASIS_ALIASES = {
3016
3026
  Subtle: "Quiet",
3017
3027
  Muted: "Quiet"
3018
3028
  };
3029
+ var TONE_NAMES = [
3030
+ "Default",
3031
+ "Subdued",
3032
+ "Brand",
3033
+ "Success",
3034
+ "Warning",
3035
+ "Critical",
3036
+ "Info"
3037
+ ];
3019
3038
  var decodeTone = (p, j) => {
3020
3039
  if (j.kind === "JString" && j.value in TONE_ALIASES) return ok(TONE_ALIASES[j.value]);
3021
- return bareEnum(
3022
- p,
3023
- j,
3024
- ["Default", "Subdued", "Brand", "Success", "Warning", "Critical", "Info"],
3025
- "ToneVariant"
3026
- );
3040
+ return bareEnum(p, j, TONE_NAMES, "ToneVariant");
3027
3041
  };
3028
3042
  var decodeWeight = (p, j) => (
3029
3043
  // StyleWeight deliberately not aliased — `Bold`/`Heavy` is font-weight intent, but
@@ -5621,6 +5635,56 @@ var decodeInputKind = (path, j) => {
5621
5635
  return unknownDuCase(path, d.value, "Form | Filters | Button | FileUpload | Select");
5622
5636
  }
5623
5637
  };
5638
+ var decodeToneMap = (path, j) => {
5639
+ const fo = requireObject(path, j);
5640
+ if (!fo.ok) return fo;
5641
+ const out = {};
5642
+ for (const [k, v] of fo.value) {
5643
+ const entryPath = `${path}.${k}`;
5644
+ const t = decodeTone(entryPath, v);
5645
+ if (!t.ok) {
5646
+ if (t.error.code !== "UNKNOWN_DU_CASE") return t;
5647
+ const got = v.kind === "JString" ? v.value : "";
5648
+ return makeError(
5649
+ "UNKNOWN_DU_CASE",
5650
+ entryPath,
5651
+ `tone-map value '${got}' for '${k}' is not a ToneVariant`,
5652
+ TONE_NAMES.join(" | ")
5653
+ );
5654
+ }
5655
+ out[k] = t.value;
5656
+ }
5657
+ return ok(out);
5658
+ };
5659
+ var TONE_MAP_KEYS = ["map", "toneMap", "tones"];
5660
+ var decodeTonedPill = (path, f) => {
5661
+ const field2 = reqField(
5662
+ path,
5663
+ f,
5664
+ "field",
5665
+ "TonedPill row-field name (drives the label and the map key)",
5666
+ requireString
5667
+ );
5668
+ if (!field2.ok) return field2;
5669
+ const map = reqFieldAliased(
5670
+ path,
5671
+ f,
5672
+ "map",
5673
+ ["toneMap", "tones"],
5674
+ "TonedPill value\u2192ToneVariant map",
5675
+ decodeToneMap
5676
+ );
5677
+ if (!map.ok) return map;
5678
+ const defaultTone = optField(path, f, "default", decodeTone);
5679
+ if (!defaultTone.ok) return defaultTone;
5680
+ const k = {
5681
+ kind: "TonedPill",
5682
+ field: field2.value,
5683
+ map: map.value,
5684
+ defaultTone: defaultTone.value ?? "Default"
5685
+ };
5686
+ return ok(k);
5687
+ };
5624
5688
  var decodeCellKindErased = (path, j) => {
5625
5689
  const fo = requireObject(path, j);
5626
5690
  if (!fo.ok) return fo;
@@ -5673,6 +5737,8 @@ var decodeCellKindErased = (path, j) => {
5673
5737
  return ok(k);
5674
5738
  }
5675
5739
  case "Pill": {
5740
+ if (TONE_MAP_KEYS.some((key) => tryField(f, key) !== void 0))
5741
+ return decodeTonedPill(path, f);
5676
5742
  const k = {
5677
5743
  kind: "Pill",
5678
5744
  label: () => ({ kind: "Literal", value: CLOSURE2 }),
@@ -5680,6 +5746,8 @@ var decodeCellKindErased = (path, j) => {
5680
5746
  };
5681
5747
  return ok(k);
5682
5748
  }
5749
+ case "TonedPill":
5750
+ return decodeTonedPill(path, f);
5683
5751
  case "Progress": {
5684
5752
  const k = { kind: "Progress", fraction: () => 0 };
5685
5753
  return ok(k);
@@ -5695,7 +5763,7 @@ var decodeCellKindErased = (path, j) => {
5695
5763
  return unknownDuCase(
5696
5764
  path,
5697
5765
  d.value,
5698
- "Text | Numeric | Date | Editable | Checkbox | Button | ButtonGroup | Link | Pill | Progress | Custom"
5766
+ "Text | Numeric | Date | Editable | Checkbox | Button | ButtonGroup | Link | Pill | TonedPill | Progress | Custom"
5699
5767
  );
5700
5768
  }
5701
5769
  };