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