@flytedan/flytebot-design-system 0.62.0 → 0.63.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 +9 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +9 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -7569,9 +7569,9 @@ function formatShare(share) {
|
|
|
7569
7569
|
return tenths >= 10 ? `${Math.round(percent)}%` : `${tenths.toFixed(1)}%`;
|
|
7570
7570
|
}
|
|
7571
7571
|
var byValue = (a, b) => b.value - a.value;
|
|
7572
|
-
function buildChoroplethModel(values, topN) {
|
|
7572
|
+
function buildChoroplethModel(values, topN, givenTotal) {
|
|
7573
7573
|
const byCode = /* @__PURE__ */ new Map();
|
|
7574
|
-
let
|
|
7574
|
+
let sum = 0;
|
|
7575
7575
|
for (const { state, value } of values) {
|
|
7576
7576
|
if (!isUsStateCode(state)) throw new Error(`USChoropleth: "${state}" is not a US state code`);
|
|
7577
7577
|
if (byCode.has(state)) throw new Error(`USChoropleth: ${state} is given more than once`);
|
|
@@ -7579,8 +7579,12 @@ function buildChoroplethModel(values, topN) {
|
|
|
7579
7579
|
throw new Error(`USChoropleth: the value for ${state} must be a whole count of 0 or more, got ${value}`);
|
|
7580
7580
|
}
|
|
7581
7581
|
byCode.set(state, value);
|
|
7582
|
-
|
|
7582
|
+
sum += value;
|
|
7583
|
+
}
|
|
7584
|
+
if (givenTotal !== void 0 && !(Number.isInteger(givenTotal) && givenTotal >= sum)) {
|
|
7585
|
+
throw new Error(`USChoropleth: total must be a whole count of at least the sum of values (${sum}), got ${givenTotal}`);
|
|
7583
7586
|
}
|
|
7587
|
+
const total = givenTotal ?? sum;
|
|
7584
7588
|
const share = (value) => total === 0 ? 0 : value / total;
|
|
7585
7589
|
const rows = US_STATES.map((state) => {
|
|
7586
7590
|
const value = byCode.get(state.code) ?? 0;
|
|
@@ -7690,8 +7694,8 @@ function StateTable({ model, valueLabel, formatValue }) {
|
|
|
7690
7694
|
];
|
|
7691
7695
|
return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Collapsible, { title: TABLE_TITLE, children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(DataTable, { columns, rows: model.rows, rowKey: "code", compact: true }) });
|
|
7692
7696
|
}
|
|
7693
|
-
function USChoropleth({ values, label, valueLabel, formatValue, formatReadout, topN, className = "" }) {
|
|
7694
|
-
const model = React44.useMemo(() => buildChoroplethModel(values, topN ?? 0), [values, topN]);
|
|
7697
|
+
function USChoropleth({ values, label, valueLabel, formatValue, formatReadout, topN, total, className = "" }) {
|
|
7698
|
+
const model = React44.useMemo(() => buildChoroplethModel(values, topN ?? 0, total), [values, topN, total]);
|
|
7695
7699
|
const figures = React44.useMemo(() => new Map(model.rows.map((row) => [row.code, row])), [model]);
|
|
7696
7700
|
const { state, retry } = useUsStateShapes();
|
|
7697
7701
|
return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: ["fd-uschoro", className].filter(Boolean).join(" "), children: [
|