@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.d.cts
CHANGED
|
@@ -2442,6 +2442,10 @@ interface USChoroplethProps {
|
|
|
2442
2442
|
/** Show a ranking of this many states beside the map (below it when the component is narrow).
|
|
2443
2443
|
* Leave unset for no ranking. */
|
|
2444
2444
|
topN?: number;
|
|
2445
|
+
/** What 100% is, for every share the component prints (readout, ranking, table). Defaults to the sum
|
|
2446
|
+
* of `values`; pass a larger whole count when some of what you counted has no state. Smaller than
|
|
2447
|
+
* the sum throws. */
|
|
2448
|
+
total?: number;
|
|
2445
2449
|
className?: string;
|
|
2446
2450
|
}
|
|
2447
2451
|
/**
|
|
@@ -2463,7 +2467,7 @@ interface USChoroplethProps {
|
|
|
2463
2467
|
* The outlines and the geo libraries (d3-geo, topojson-client, us-atlas) are one separate chunk,
|
|
2464
2468
|
* fetched when the map first renders; the legend, ranking and table show at once.
|
|
2465
2469
|
*/
|
|
2466
|
-
declare function USChoropleth({ values, label, valueLabel, formatValue, formatReadout, topN, className }: USChoroplethProps): React.JSX.Element;
|
|
2470
|
+
declare function USChoropleth({ values, label, valueLabel, formatValue, formatReadout, topN, total, className }: USChoroplethProps): React.JSX.Element;
|
|
2467
2471
|
|
|
2468
2472
|
/**
|
|
2469
2473
|
* Multi-select control with a 44px comfortable hit area.
|
package/dist/index.d.ts
CHANGED
|
@@ -2442,6 +2442,10 @@ interface USChoroplethProps {
|
|
|
2442
2442
|
/** Show a ranking of this many states beside the map (below it when the component is narrow).
|
|
2443
2443
|
* Leave unset for no ranking. */
|
|
2444
2444
|
topN?: number;
|
|
2445
|
+
/** What 100% is, for every share the component prints (readout, ranking, table). Defaults to the sum
|
|
2446
|
+
* of `values`; pass a larger whole count when some of what you counted has no state. Smaller than
|
|
2447
|
+
* the sum throws. */
|
|
2448
|
+
total?: number;
|
|
2445
2449
|
className?: string;
|
|
2446
2450
|
}
|
|
2447
2451
|
/**
|
|
@@ -2463,7 +2467,7 @@ interface USChoroplethProps {
|
|
|
2463
2467
|
* The outlines and the geo libraries (d3-geo, topojson-client, us-atlas) are one separate chunk,
|
|
2464
2468
|
* fetched when the map first renders; the legend, ranking and table show at once.
|
|
2465
2469
|
*/
|
|
2466
|
-
declare function USChoropleth({ values, label, valueLabel, formatValue, formatReadout, topN, className }: USChoroplethProps): React.JSX.Element;
|
|
2470
|
+
declare function USChoropleth({ values, label, valueLabel, formatValue, formatReadout, topN, total, className }: USChoroplethProps): React.JSX.Element;
|
|
2467
2471
|
|
|
2468
2472
|
/**
|
|
2469
2473
|
* Multi-select control with a 44px comfortable hit area.
|
package/dist/index.js
CHANGED
|
@@ -6423,9 +6423,9 @@ function formatShare(share) {
|
|
|
6423
6423
|
return tenths >= 10 ? `${Math.round(percent)}%` : `${tenths.toFixed(1)}%`;
|
|
6424
6424
|
}
|
|
6425
6425
|
var byValue = (a, b) => b.value - a.value;
|
|
6426
|
-
function buildChoroplethModel(values, topN) {
|
|
6426
|
+
function buildChoroplethModel(values, topN, givenTotal) {
|
|
6427
6427
|
const byCode = /* @__PURE__ */ new Map();
|
|
6428
|
-
let
|
|
6428
|
+
let sum = 0;
|
|
6429
6429
|
for (const { state, value } of values) {
|
|
6430
6430
|
if (!isUsStateCode(state)) throw new Error(`USChoropleth: "${state}" is not a US state code`);
|
|
6431
6431
|
if (byCode.has(state)) throw new Error(`USChoropleth: ${state} is given more than once`);
|
|
@@ -6433,8 +6433,12 @@ function buildChoroplethModel(values, topN) {
|
|
|
6433
6433
|
throw new Error(`USChoropleth: the value for ${state} must be a whole count of 0 or more, got ${value}`);
|
|
6434
6434
|
}
|
|
6435
6435
|
byCode.set(state, value);
|
|
6436
|
-
|
|
6436
|
+
sum += value;
|
|
6437
|
+
}
|
|
6438
|
+
if (givenTotal !== void 0 && !(Number.isInteger(givenTotal) && givenTotal >= sum)) {
|
|
6439
|
+
throw new Error(`USChoropleth: total must be a whole count of at least the sum of values (${sum}), got ${givenTotal}`);
|
|
6437
6440
|
}
|
|
6441
|
+
const total = givenTotal ?? sum;
|
|
6438
6442
|
const share = (value) => total === 0 ? 0 : value / total;
|
|
6439
6443
|
const rows = US_STATES.map((state) => {
|
|
6440
6444
|
const value = byCode.get(state.code) ?? 0;
|
|
@@ -6544,8 +6548,8 @@ function StateTable({ model, valueLabel, formatValue }) {
|
|
|
6544
6548
|
];
|
|
6545
6549
|
return /* @__PURE__ */ jsx66(Collapsible, { title: TABLE_TITLE, children: /* @__PURE__ */ jsx66(DataTable, { columns, rows: model.rows, rowKey: "code", compact: true }) });
|
|
6546
6550
|
}
|
|
6547
|
-
function USChoropleth({ values, label, valueLabel, formatValue, formatReadout, topN, className = "" }) {
|
|
6548
|
-
const model = React44.useMemo(() => buildChoroplethModel(values, topN ?? 0), [values, topN]);
|
|
6551
|
+
function USChoropleth({ values, label, valueLabel, formatValue, formatReadout, topN, total, className = "" }) {
|
|
6552
|
+
const model = React44.useMemo(() => buildChoroplethModel(values, topN ?? 0, total), [values, topN, total]);
|
|
6549
6553
|
const figures = React44.useMemo(() => new Map(model.rows.map((row) => [row.code, row])), [model]);
|
|
6550
6554
|
const { state, retry } = useUsStateShapes();
|
|
6551
6555
|
return /* @__PURE__ */ jsxs56("div", { className: ["fd-uschoro", className].filter(Boolean).join(" "), children: [
|