@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 CHANGED
@@ -61,6 +61,20 @@ typographyMixin(typographyTypes.GEIST_BODY_XS_MEDIUM);
61
61
  // => CSS string ready to use in template literals
62
62
  ```
63
63
 
64
+ ### Tailwind typography utilities
65
+
66
+ When consuming `dist/blocks.css` (the Tailwind layer), every entry in `typographyStyles` is also exposed as a `text-*` utility — one class sets font-size + line-height + font-weight + letter-spacing. The name is the token in kebab-case (`GEIST_BODY_XS_MEDIUM` → `text-geist-body-xs-medium`). Pair with `font-sans` (Geist) or `font-serif` (Crimson Pro); for italic Crimson types add the `italic` utility (Tailwind's font-size utilities don't carry `font-style`).
67
+
68
+ | Token family | Example utility | Use for |
69
+ | --- | --- | --- |
70
+ | `GEIST_DISPLAY_*` | `text-geist-display-l-bold` | Hero / page titles |
71
+ | `GEIST_HEADING_*` | `text-geist-heading-s-bold` | Section headings |
72
+ | `GEIST_BODY_*` | `text-geist-body-m-regular`, `text-geist-body-xs-medium` | Body copy, labels |
73
+ | `GEIST_LABEL_*` | `text-geist-label-caption-regular` | Captions, metadata |
74
+ | `CRIMSON_PRO_*` | `text-crimson-pro-display-xl-regular-italic` (+ `font-serif italic`) | Editorial / decorative |
75
+
76
+ The full list is the keys of `typographyStyles` in `src/tokens/typography.ts`; the utilities are generated by `scripts/generate-theme-tokens.ts` into `src/styles/_theme-tokens.css`.
77
+
64
78
  ---
65
79
 
66
80
  ## Chat
@@ -981,6 +981,11 @@ var CHART_PALETTE = [
981
981
  ];
982
982
  var OTHERS_SLICE_COLOR = colors["brown-60"];
983
983
  var DEFAULT_OTHERS_CATEGORY_LABELS = ["others", "other"];
984
+ var NONE_CATEGORY_VALUES = ["", "(none)", "none", "null", "undefined", "n/a", "-"];
985
+ function isNoneCategory(value) {
986
+ if (value === null || value === void 0) return true;
987
+ return NONE_CATEGORY_VALUES.includes(String(value).trim().toLowerCase());
988
+ }
984
989
  function isOthersCategory(value, labels) {
985
990
  if (value === null || value === void 0) return false;
986
991
  if (labels.length === 0) return false;
@@ -1036,6 +1041,13 @@ function truncateLabel(value, maxChars) {
1036
1041
  if (s.length <= maxChars) return s;
1037
1042
  return s.slice(0, Math.max(1, maxChars - 1)).trimEnd() + "\u2026";
1038
1043
  }
1044
+ var compactNumberFormat = new Intl.NumberFormat("en-US", { notation: "compact", maximumFractionDigits: 1 });
1045
+ function compactNumberTickFormatter(value) {
1046
+ if (value === null || value === void 0) return "";
1047
+ const n = typeof value === "number" ? value : Number(value);
1048
+ if (!Number.isFinite(n)) return String(value);
1049
+ return compactNumberFormat.format(n);
1050
+ }
1039
1051
  function evenlyDistributedVisibleIndices(n, target) {
1040
1052
  if (n <= target) {
1041
1053
  return new Set(Array.from({ length: n }, (_, i) => i));
@@ -1089,7 +1101,6 @@ function BarChart({
1089
1101
  showGrid = true,
1090
1102
  showXAxis = true,
1091
1103
  showYAxis = true,
1092
- showValueLabels,
1093
1104
  xAxisInterval = 0,
1094
1105
  xAxisAngle,
1095
1106
  xAxisTickFormatter
@@ -1100,7 +1111,6 @@ function BarChart({
1100
1111
  [data, seriesKeys]
1101
1112
  );
1102
1113
  const resolvedShowLegend = showLegend ?? series.length > 1;
1103
- const resolvedShowValueLabels = showValueLabels ?? (!stacked && series.length === 1);
1104
1114
  const resolvedAngle = xAxisAngle ?? (coercedData.length >= 8 ? -30 : 0);
1105
1115
  const resolvedTickFormatter = (0, import_react9.useMemo)(
1106
1116
  () => xAxisTickFormatter ?? defaultBarTickFormatter(coercedData.length),
@@ -1123,7 +1133,7 @@ function BarChart({
1123
1133
  tickFormatter: resolvedTickFormatter
1124
1134
  }
1125
1135
  ) : null,
1126
- showYAxis ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_recharts2.YAxis, { ...CHART_AXIS_PROPS, width: 40 }) : null,
1136
+ showYAxis ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_recharts2.YAxis, { ...CHART_AXIS_PROPS, width: 40, tickFormatter: compactNumberTickFormatter }) : null,
1127
1137
  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,
1128
1138
  resolvedShowLegend ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1129
1139
  import_recharts2.Legend,
@@ -1142,8 +1152,7 @@ function BarChart({
1142
1152
  name: s.label,
1143
1153
  fill: colorForSeriesIndex(i, palette),
1144
1154
  stackId: stacked ? "default" : s.key,
1145
- radius: barRadius(stacked, i, series.length),
1146
- children: resolvedShowValueLabels ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_recharts2.LabelList, { dataKey: s.key, position: "top", style: CHART_VALUE_LABEL_STYLE }) : null
1155
+ radius: barRadius(stacked, i, series.length)
1147
1156
  },
1148
1157
  s.key
1149
1158
  ))
@@ -1262,7 +1271,7 @@ function LineChart({
1262
1271
  tickFormatter: resolvedTickFormatter
1263
1272
  }
1264
1273
  ) : null,
1265
- showYAxis ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_recharts3.YAxis, { ...CHART_AXIS_PROPS, width: 40 }) : null,
1274
+ showYAxis ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_recharts3.YAxis, { ...CHART_AXIS_PROPS, width: 40, tickFormatter: compactNumberTickFormatter }) : null,
1266
1275
  showTooltip ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_recharts3.Tooltip, { content: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ChartTooltipContent, {}) }) : null,
1267
1276
  resolvedShowLegend ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1268
1277
  import_recharts3.Legend,
@@ -1320,6 +1329,42 @@ var LineChartVariantService = {
1320
1329
  // src/components/chart/pie-chart/pie-chart.tsx
1321
1330
  var import_react11 = require("react");
1322
1331
  var import_recharts4 = require("recharts");
1332
+
1333
+ // src/components/chart/pie-chart/utils.ts
1334
+ function mergedOthersLabel(leftoverRows, categoryKey, othersCategoryLabels) {
1335
+ const explicit = leftoverRows.find((row) => isOthersCategory(row[categoryKey], othersCategoryLabels));
1336
+ if (explicit) return String(explicit[categoryKey]);
1337
+ const fallback = othersCategoryLabels[0] ?? "Other";
1338
+ return fallback.charAt(0).toUpperCase() + fallback.slice(1);
1339
+ }
1340
+ function buildPieSlices(data, categoryKey, valueKey, othersCategoryLabels, palette) {
1341
+ const namedRows = [];
1342
+ const namedColors = [];
1343
+ const leftoverRows = [];
1344
+ for (const row of data) {
1345
+ const isLeftover = othersCategoryLabels.length > 0 && (isNoneCategory(row[categoryKey]) || isOthersCategory(row[categoryKey], othersCategoryLabels));
1346
+ if (isLeftover) {
1347
+ leftoverRows.push(row);
1348
+ } else {
1349
+ namedRows.push(row);
1350
+ namedColors.push(colorForSeriesIndex(namedRows.length - 1, palette));
1351
+ }
1352
+ }
1353
+ if (leftoverRows.length === 0) {
1354
+ return { orderedData: namedRows, sliceColors: namedColors };
1355
+ }
1356
+ const total = leftoverRows.reduce((sum, row) => sum + (Number(row[valueKey]) || 0), 0);
1357
+ const mergedRow = {
1358
+ [categoryKey]: mergedOthersLabel(leftoverRows, categoryKey, othersCategoryLabels),
1359
+ [valueKey]: total
1360
+ };
1361
+ return {
1362
+ orderedData: [...namedRows, mergedRow],
1363
+ sliceColors: [...namedColors, OTHERS_SLICE_COLOR]
1364
+ };
1365
+ }
1366
+
1367
+ // src/components/chart/pie-chart/pie-chart.tsx
1323
1368
  var import_jsx_runtime16 = require("react/jsx-runtime");
1324
1369
  function PieChart({
1325
1370
  data,
@@ -1338,23 +1383,7 @@ function PieChart({
1338
1383
  }) {
1339
1384
  const { orderedData, sliceColors } = (0, import_react11.useMemo)(() => {
1340
1385
  const coerced = coerceNumericColumns(data, [valueKey]);
1341
- const namedRows = [];
1342
- const namedColors = [];
1343
- const othersRows = [];
1344
- const othersColors = [];
1345
- for (const row of coerced) {
1346
- if (isOthersCategory(row[categoryKey], othersCategoryLabels)) {
1347
- othersRows.push(row);
1348
- othersColors.push(OTHERS_SLICE_COLOR);
1349
- } else {
1350
- namedRows.push(row);
1351
- namedColors.push(colorForSeriesIndex(namedRows.length - 1, palette));
1352
- }
1353
- }
1354
- return {
1355
- orderedData: [...namedRows, ...othersRows],
1356
- sliceColors: [...namedColors, ...othersColors]
1357
- };
1386
+ return buildPieSlices(coerced, categoryKey, valueKey, othersCategoryLabels, palette);
1358
1387
  }, [data, valueKey, categoryKey, othersCategoryLabels, palette]);
1359
1388
  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: [
1360
1389
  showTooltip ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_recharts4.Tooltip, { content: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ChartTooltipContent, {}) }) : null,