@shapesos/clay 0.15.0 → 0.17.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/README.md +14 -0
- package/dist/artifacts.cjs +52 -23
- package/dist/artifacts.cjs.map +1 -1
- package/dist/artifacts.js +2 -2
- package/dist/blocks.cjs +52 -23
- package/dist/blocks.cjs.map +1 -1
- package/dist/blocks.css +1 -1
- package/dist/blocks.js +3 -3
- package/dist/chart.cjs +52 -23
- package/dist/chart.cjs.map +1 -1
- package/dist/chart.d.cts +8 -14
- package/dist/chart.d.ts +8 -14
- package/dist/chart.js +1 -1
- package/dist/chat.cjs +52 -23
- package/dist/chat.cjs.map +1 -1
- package/dist/chat.js +4 -4
- package/dist/{chunk-MDAWYZBI.js → chunk-46ZYTBX5.js} +2 -2
- package/dist/{chunk-XFJ6XMJZ.js → chunk-6YZ65KPW.js} +2 -2
- package/dist/{chunk-3THOTQO3.js → chunk-B6GAPZ2R.js} +3 -3
- package/dist/{chunk-YZB6YXKK.js → chunk-PUVZ2S3F.js} +56 -27
- package/dist/chunk-PUVZ2S3F.js.map +1 -0
- package/dist/index.cjs +52 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4 -4
- package/package.json +1 -1
- package/dist/chunk-YZB6YXKK.js.map +0 -1
- /package/dist/{chunk-MDAWYZBI.js.map → chunk-46ZYTBX5.js.map} +0 -0
- /package/dist/{chunk-XFJ6XMJZ.js.map → chunk-6YZ65KPW.js.map} +0 -0
- /package/dist/{chunk-3THOTQO3.js.map → chunk-B6GAPZ2R.js.map} +0 -0
package/dist/artifacts.js
CHANGED
|
@@ -11,11 +11,11 @@ import {
|
|
|
11
11
|
artifactToClipboardText,
|
|
12
12
|
artifactTypes,
|
|
13
13
|
isSafeDownloadUrl
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-6YZ65KPW.js";
|
|
15
15
|
import "./chunk-PYDVANWI.js";
|
|
16
16
|
import "./chunk-LXYCT4YO.js";
|
|
17
17
|
import "./chunk-OLJIJYB5.js";
|
|
18
|
-
import "./chunk-
|
|
18
|
+
import "./chunk-PUVZ2S3F.js";
|
|
19
19
|
import "./chunk-C77QMQNT.js";
|
|
20
20
|
import "./chunk-UXT2H3FM.js";
|
|
21
21
|
import "./chunk-JF3P66JF.js";
|
package/dist/blocks.cjs
CHANGED
|
@@ -1289,6 +1289,11 @@ var CHART_PALETTE = [
|
|
|
1289
1289
|
];
|
|
1290
1290
|
var OTHERS_SLICE_COLOR = colors["brown-60"];
|
|
1291
1291
|
var DEFAULT_OTHERS_CATEGORY_LABELS = ["others", "other"];
|
|
1292
|
+
var NONE_CATEGORY_VALUES = ["", "(none)", "none", "null", "undefined", "n/a", "-"];
|
|
1293
|
+
function isNoneCategory(value) {
|
|
1294
|
+
if (value === null || value === void 0) return true;
|
|
1295
|
+
return NONE_CATEGORY_VALUES.includes(String(value).trim().toLowerCase());
|
|
1296
|
+
}
|
|
1292
1297
|
function isOthersCategory(value, labels) {
|
|
1293
1298
|
if (value === null || value === void 0) return false;
|
|
1294
1299
|
if (labels.length === 0) return false;
|
|
@@ -1344,6 +1349,13 @@ function truncateLabel(value, maxChars) {
|
|
|
1344
1349
|
if (s.length <= maxChars) return s;
|
|
1345
1350
|
return s.slice(0, Math.max(1, maxChars - 1)).trimEnd() + "\u2026";
|
|
1346
1351
|
}
|
|
1352
|
+
var compactNumberFormat = new Intl.NumberFormat("en-US", { notation: "compact", maximumFractionDigits: 1 });
|
|
1353
|
+
function compactNumberTickFormatter(value) {
|
|
1354
|
+
if (value === null || value === void 0) return "";
|
|
1355
|
+
const n = typeof value === "number" ? value : Number(value);
|
|
1356
|
+
if (!Number.isFinite(n)) return String(value);
|
|
1357
|
+
return compactNumberFormat.format(n);
|
|
1358
|
+
}
|
|
1347
1359
|
function evenlyDistributedVisibleIndices(n, target) {
|
|
1348
1360
|
if (n <= target) {
|
|
1349
1361
|
return new Set(Array.from({ length: n }, (_, i) => i));
|
|
@@ -1397,7 +1409,6 @@ function BarChart({
|
|
|
1397
1409
|
showGrid = true,
|
|
1398
1410
|
showXAxis = true,
|
|
1399
1411
|
showYAxis = true,
|
|
1400
|
-
showValueLabels,
|
|
1401
1412
|
xAxisInterval = 0,
|
|
1402
1413
|
xAxisAngle,
|
|
1403
1414
|
xAxisTickFormatter
|
|
@@ -1408,7 +1419,6 @@ function BarChart({
|
|
|
1408
1419
|
[data, seriesKeys]
|
|
1409
1420
|
);
|
|
1410
1421
|
const resolvedShowLegend = showLegend ?? series.length > 1;
|
|
1411
|
-
const resolvedShowValueLabels = showValueLabels ?? (!stacked && series.length === 1);
|
|
1412
1422
|
const resolvedAngle = xAxisAngle ?? (coercedData.length >= 8 ? -30 : 0);
|
|
1413
1423
|
const resolvedTickFormatter = (0, import_react9.useMemo)(
|
|
1414
1424
|
() => xAxisTickFormatter ?? defaultBarTickFormatter(coercedData.length),
|
|
@@ -1431,7 +1441,7 @@ function BarChart({
|
|
|
1431
1441
|
tickFormatter: resolvedTickFormatter
|
|
1432
1442
|
}
|
|
1433
1443
|
) : null,
|
|
1434
|
-
showYAxis ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_recharts2.YAxis, { ...CHART_AXIS_PROPS, width: 40 }) : null,
|
|
1444
|
+
showYAxis ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_recharts2.YAxis, { ...CHART_AXIS_PROPS, width: 40, tickFormatter: compactNumberTickFormatter }) : null,
|
|
1435
1445
|
showTooltip ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_recharts2.Tooltip, { cursor: { fill: BAR_TOOLTIP_CURSOR_FILL }, content: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ChartTooltipContent, {}) }) : null,
|
|
1436
1446
|
resolvedShowLegend ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1437
1447
|
import_recharts2.Legend,
|
|
@@ -1450,8 +1460,7 @@ function BarChart({
|
|
|
1450
1460
|
name: s.label,
|
|
1451
1461
|
fill: colorForSeriesIndex(i, palette),
|
|
1452
1462
|
stackId: stacked ? "default" : s.key,
|
|
1453
|
-
radius: barRadius(stacked, i, series.length)
|
|
1454
|
-
children: resolvedShowValueLabels ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_recharts2.LabelList, { dataKey: s.key, position: "top", style: CHART_VALUE_LABEL_STYLE }) : null
|
|
1463
|
+
radius: barRadius(stacked, i, series.length)
|
|
1455
1464
|
},
|
|
1456
1465
|
s.key
|
|
1457
1466
|
))
|
|
@@ -1570,7 +1579,7 @@ function LineChart({
|
|
|
1570
1579
|
tickFormatter: resolvedTickFormatter
|
|
1571
1580
|
}
|
|
1572
1581
|
) : null,
|
|
1573
|
-
showYAxis ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_recharts3.YAxis, { ...CHART_AXIS_PROPS, width: 40 }) : null,
|
|
1582
|
+
showYAxis ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_recharts3.YAxis, { ...CHART_AXIS_PROPS, width: 40, tickFormatter: compactNumberTickFormatter }) : null,
|
|
1574
1583
|
showTooltip ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_recharts3.Tooltip, { content: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ChartTooltipContent, {}) }) : null,
|
|
1575
1584
|
resolvedShowLegend ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1576
1585
|
import_recharts3.Legend,
|
|
@@ -1628,6 +1637,42 @@ var LineChartVariantService = {
|
|
|
1628
1637
|
// src/components/chart/pie-chart/pie-chart.tsx
|
|
1629
1638
|
var import_react11 = require("react");
|
|
1630
1639
|
var import_recharts4 = require("recharts");
|
|
1640
|
+
|
|
1641
|
+
// src/components/chart/pie-chart/utils.ts
|
|
1642
|
+
function mergedOthersLabel(leftoverRows, categoryKey, othersCategoryLabels) {
|
|
1643
|
+
const explicit = leftoverRows.find((row) => isOthersCategory(row[categoryKey], othersCategoryLabels));
|
|
1644
|
+
if (explicit) return String(explicit[categoryKey]);
|
|
1645
|
+
const fallback = othersCategoryLabels[0] ?? "Other";
|
|
1646
|
+
return fallback.charAt(0).toUpperCase() + fallback.slice(1);
|
|
1647
|
+
}
|
|
1648
|
+
function buildPieSlices(data, categoryKey, valueKey, othersCategoryLabels, palette) {
|
|
1649
|
+
const namedRows = [];
|
|
1650
|
+
const namedColors = [];
|
|
1651
|
+
const leftoverRows = [];
|
|
1652
|
+
for (const row of data) {
|
|
1653
|
+
const isLeftover = othersCategoryLabels.length > 0 && (isNoneCategory(row[categoryKey]) || isOthersCategory(row[categoryKey], othersCategoryLabels));
|
|
1654
|
+
if (isLeftover) {
|
|
1655
|
+
leftoverRows.push(row);
|
|
1656
|
+
} else {
|
|
1657
|
+
namedRows.push(row);
|
|
1658
|
+
namedColors.push(colorForSeriesIndex(namedRows.length - 1, palette));
|
|
1659
|
+
}
|
|
1660
|
+
}
|
|
1661
|
+
if (leftoverRows.length === 0) {
|
|
1662
|
+
return { orderedData: namedRows, sliceColors: namedColors };
|
|
1663
|
+
}
|
|
1664
|
+
const total = leftoverRows.reduce((sum, row) => sum + (Number(row[valueKey]) || 0), 0);
|
|
1665
|
+
const mergedRow = {
|
|
1666
|
+
[categoryKey]: mergedOthersLabel(leftoverRows, categoryKey, othersCategoryLabels),
|
|
1667
|
+
[valueKey]: total
|
|
1668
|
+
};
|
|
1669
|
+
return {
|
|
1670
|
+
orderedData: [...namedRows, mergedRow],
|
|
1671
|
+
sliceColors: [...namedColors, OTHERS_SLICE_COLOR]
|
|
1672
|
+
};
|
|
1673
|
+
}
|
|
1674
|
+
|
|
1675
|
+
// src/components/chart/pie-chart/pie-chart.tsx
|
|
1631
1676
|
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
1632
1677
|
function PieChart({
|
|
1633
1678
|
data,
|
|
@@ -1646,23 +1691,7 @@ function PieChart({
|
|
|
1646
1691
|
}) {
|
|
1647
1692
|
const { orderedData, sliceColors } = (0, import_react11.useMemo)(() => {
|
|
1648
1693
|
const coerced = coerceNumericColumns(data, [valueKey]);
|
|
1649
|
-
|
|
1650
|
-
const namedColors = [];
|
|
1651
|
-
const othersRows = [];
|
|
1652
|
-
const othersColors = [];
|
|
1653
|
-
for (const row of coerced) {
|
|
1654
|
-
if (isOthersCategory(row[categoryKey], othersCategoryLabels)) {
|
|
1655
|
-
othersRows.push(row);
|
|
1656
|
-
othersColors.push(OTHERS_SLICE_COLOR);
|
|
1657
|
-
} else {
|
|
1658
|
-
namedRows.push(row);
|
|
1659
|
-
namedColors.push(colorForSeriesIndex(namedRows.length - 1, palette));
|
|
1660
|
-
}
|
|
1661
|
-
}
|
|
1662
|
-
return {
|
|
1663
|
-
orderedData: [...namedRows, ...othersRows],
|
|
1664
|
-
sliceColors: [...namedColors, ...othersColors]
|
|
1665
|
-
};
|
|
1694
|
+
return buildPieSlices(coerced, categoryKey, valueKey, othersCategoryLabels, palette);
|
|
1666
1695
|
}, [data, valueKey, categoryKey, othersCategoryLabels, palette]);
|
|
1667
1696
|
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ChartContainer, { height, width, className, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_recharts4.PieChart, { margin: PIE_CHART_MARGIN, children: [
|
|
1668
1697
|
showTooltip ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_recharts4.Tooltip, { content: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ChartTooltipContent, {}) }) : null,
|