@labpane/ui 1.2.0 → 1.3.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.js +85 -54
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2913,10 +2913,25 @@ var HistogramChart = React26.forwardRef(
|
|
|
2913
2913
|
const activeIndex = Math.min(inspected, bins.length - 1);
|
|
2914
2914
|
const active = bins[activeIndex];
|
|
2915
2915
|
const right = width - 20;
|
|
2916
|
-
const
|
|
2917
|
-
|
|
2916
|
+
const data = React26.useMemo(() => {
|
|
2917
|
+
const max2 = tallest(bins);
|
|
2918
|
+
const total2 = bins.reduce((sum, bin) => sum + bin.count, 0);
|
|
2919
|
+
return {
|
|
2920
|
+
max: max2,
|
|
2921
|
+
total: total2,
|
|
2922
|
+
descriptions: bins.map(describeBin),
|
|
2923
|
+
counts: bins.map((bin) => formatNumber(bin.count)),
|
|
2924
|
+
ticks: [0, 0.5, 1].map(
|
|
2925
|
+
(fraction) => formatNumber(Math.round(max2 * fraction))
|
|
2926
|
+
),
|
|
2927
|
+
totalLabel: formatNumber(total2),
|
|
2928
|
+
first: bins.length ? formatNumber(bins[0].from) : "",
|
|
2929
|
+
last: bins.length ? formatNumber(bins.at(-1).to) : ""
|
|
2930
|
+
};
|
|
2931
|
+
}, [bins]);
|
|
2932
|
+
const { max, total } = data;
|
|
2918
2933
|
const barWidth = (right - LEFT) / bins.length;
|
|
2919
|
-
const count = active ? `${
|
|
2934
|
+
const count = active ? `${data.counts[activeIndex]} ${unit}` : "";
|
|
2920
2935
|
const share = active && total > 0 ? ` (${(active.count / total * 100).toFixed(1)}%)` : "";
|
|
2921
2936
|
const binAt = (clientX, element) => {
|
|
2922
2937
|
const rect = element.getBoundingClientRect();
|
|
@@ -2952,7 +2967,7 @@ var HistogramChart = React26.forwardRef(
|
|
|
2952
2967
|
/* @__PURE__ */ jsxs15("div", { className: "labui:flex labui:flex-wrap labui:items-center labui:justify-between labui:gap-2 labui:border-b labui:px-4 labui:py-3 labui:text-sm", children: [
|
|
2953
2968
|
/* @__PURE__ */ jsx27("span", { className: "labui:font-medium", children: label }),
|
|
2954
2969
|
/* @__PURE__ */ jsxs15("span", { className: "labui:text-muted-foreground labui:tabular-nums", children: [
|
|
2955
|
-
|
|
2970
|
+
data.totalLabel,
|
|
2956
2971
|
" ",
|
|
2957
2972
|
unit
|
|
2958
2973
|
] })
|
|
@@ -2966,8 +2981,9 @@ var HistogramChart = React26.forwardRef(
|
|
|
2966
2981
|
children: [
|
|
2967
2982
|
xLabel,
|
|
2968
2983
|
" ",
|
|
2969
|
-
|
|
2970
|
-
":
|
|
2984
|
+
data.descriptions[activeIndex],
|
|
2985
|
+
":",
|
|
2986
|
+
" ",
|
|
2971
2987
|
/* @__PURE__ */ jsx27("strong", { children: count }),
|
|
2972
2988
|
share
|
|
2973
2989
|
]
|
|
@@ -2985,13 +3001,13 @@ var HistogramChart = React26.forwardRef(
|
|
|
2985
3001
|
"aria-valuemin": 0,
|
|
2986
3002
|
"aria-valuemax": bins.length - 1,
|
|
2987
3003
|
"aria-valuenow": activeIndex,
|
|
2988
|
-
"aria-valuetext": `${xLabel} ${
|
|
3004
|
+
"aria-valuetext": `${xLabel} ${data.descriptions[activeIndex]}: ${count}${share}`,
|
|
2989
3005
|
tabIndex: 0,
|
|
2990
3006
|
onPointerMove: (event) => setInspected(binAt(event.clientX, event.currentTarget)),
|
|
2991
3007
|
onClick: click,
|
|
2992
3008
|
onKeyDown: keydown,
|
|
2993
3009
|
children: [
|
|
2994
|
-
[0, 0.5, 1].map((fraction) => {
|
|
3010
|
+
[0, 0.5, 1].map((fraction, index) => {
|
|
2995
3011
|
const y = BOTTOM - fraction * (BOTTOM - TOP);
|
|
2996
3012
|
return /* @__PURE__ */ jsxs15("g", { "aria-hidden": "true", children: [
|
|
2997
3013
|
/* @__PURE__ */ jsx27(
|
|
@@ -3009,7 +3025,7 @@ var HistogramChart = React26.forwardRef(
|
|
|
3009
3025
|
textAnchor: "end",
|
|
3010
3026
|
fill: "var(--labui-muted-foreground)",
|
|
3011
3027
|
fontSize: 11,
|
|
3012
|
-
children:
|
|
3028
|
+
children: data.ticks[index]
|
|
3013
3029
|
}
|
|
3014
3030
|
)
|
|
3015
3031
|
] }, fraction);
|
|
@@ -3050,7 +3066,7 @@ var HistogramChart = React26.forwardRef(
|
|
|
3050
3066
|
y: BOTTOM + 20,
|
|
3051
3067
|
fill: "var(--labui-muted-foreground)",
|
|
3052
3068
|
fontSize: 11,
|
|
3053
|
-
children:
|
|
3069
|
+
children: data.first
|
|
3054
3070
|
}
|
|
3055
3071
|
),
|
|
3056
3072
|
/* @__PURE__ */ jsx27(
|
|
@@ -3061,7 +3077,7 @@ var HistogramChart = React26.forwardRef(
|
|
|
3061
3077
|
textAnchor: "end",
|
|
3062
3078
|
fill: "var(--labui-muted-foreground)",
|
|
3063
3079
|
fontSize: 11,
|
|
3064
|
-
children:
|
|
3080
|
+
children: data.last
|
|
3065
3081
|
}
|
|
3066
3082
|
),
|
|
3067
3083
|
/* @__PURE__ */ jsx27(
|
|
@@ -4771,19 +4787,17 @@ var mono = (id, header, value) => ({
|
|
|
4771
4787
|
...column(id, header, (row) => show(value(row))),
|
|
4772
4788
|
className: "labui:font-mono"
|
|
4773
4789
|
});
|
|
4774
|
-
var num = (id, header, value, digits = 0, headerDetail) =>
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
headerDetail
|
|
4786
|
-
});
|
|
4790
|
+
var num = (id, header, value, digits = 0, headerDetail) => {
|
|
4791
|
+
const formatter = new Intl.NumberFormat("en-US", {
|
|
4792
|
+
minimumFractionDigits: digits,
|
|
4793
|
+
maximumFractionDigits: digits
|
|
4794
|
+
});
|
|
4795
|
+
return {
|
|
4796
|
+
...column(id, header, value, (row) => formatter.format(value(row))),
|
|
4797
|
+
numeric: true,
|
|
4798
|
+
headerDetail
|
|
4799
|
+
};
|
|
4800
|
+
};
|
|
4787
4801
|
|
|
4788
4802
|
// table-layout.ts
|
|
4789
4803
|
var margin = 32;
|
|
@@ -4994,6 +5008,44 @@ function HeaderCell({
|
|
|
4994
5008
|
}
|
|
4995
5009
|
);
|
|
4996
5010
|
}
|
|
5011
|
+
function RowCells({
|
|
5012
|
+
row,
|
|
5013
|
+
columns,
|
|
5014
|
+
index,
|
|
5015
|
+
rowHeight
|
|
5016
|
+
}) {
|
|
5017
|
+
return /* @__PURE__ */ jsx45(Fragment6, { children: columns.map((column2) => {
|
|
5018
|
+
const Cell = column2.rowHeader ? "th" : "td";
|
|
5019
|
+
const content = column2.cell(row, index);
|
|
5020
|
+
return /* @__PURE__ */ jsx45(
|
|
5021
|
+
Cell,
|
|
5022
|
+
{
|
|
5023
|
+
scope: column2.rowHeader ? "row" : void 0,
|
|
5024
|
+
className: cn(
|
|
5025
|
+
cellPadding,
|
|
5026
|
+
"labui:align-middle",
|
|
5027
|
+
column2.rowHeader && "labui:text-left labui:font-medium labui:text-foreground",
|
|
5028
|
+
typeof column2.className === "function" ? column2.className(row, index) : column2.className,
|
|
5029
|
+
columnClasses(column2),
|
|
5030
|
+
rowHeight && "labui:overflow-hidden labui:py-0 labui:text-ellipsis labui:whitespace-nowrap"
|
|
5031
|
+
),
|
|
5032
|
+
children: rowHeight ? /* @__PURE__ */ jsx45(
|
|
5033
|
+
"div",
|
|
5034
|
+
{
|
|
5035
|
+
className: cn(
|
|
5036
|
+
"labui:flex labui:items-center labui:overflow-hidden",
|
|
5037
|
+
(column2.numeric || column2.align === "end") && "labui:justify-end"
|
|
5038
|
+
),
|
|
5039
|
+
style: { height: rowHeight - 1 },
|
|
5040
|
+
children: content
|
|
5041
|
+
}
|
|
5042
|
+
) : content
|
|
5043
|
+
},
|
|
5044
|
+
column2.id
|
|
5045
|
+
);
|
|
5046
|
+
}) });
|
|
5047
|
+
}
|
|
5048
|
+
var MemoRowCells = React46.memo(RowCells);
|
|
4997
5049
|
function SkeletonRows({
|
|
4998
5050
|
columns,
|
|
4999
5051
|
count
|
|
@@ -5220,36 +5272,15 @@ function Table({
|
|
|
5220
5272
|
onRowActivate?.(row);
|
|
5221
5273
|
} : void 0,
|
|
5222
5274
|
onKeyDown: interactive ? (event) => rowKeyDown(row, at, event) : void 0,
|
|
5223
|
-
children:
|
|
5224
|
-
|
|
5225
|
-
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
"labui:align-middle",
|
|
5233
|
-
column2.rowHeader && "labui:text-left labui:font-medium labui:text-foreground",
|
|
5234
|
-
typeof column2.className === "function" ? column2.className(row, index) : column2.className,
|
|
5235
|
-
columnClasses(column2),
|
|
5236
|
-
rowHeight && "labui:overflow-hidden labui:py-0 labui:text-ellipsis labui:whitespace-nowrap"
|
|
5237
|
-
),
|
|
5238
|
-
children: rowHeight ? /* @__PURE__ */ jsx45(
|
|
5239
|
-
"div",
|
|
5240
|
-
{
|
|
5241
|
-
className: cn(
|
|
5242
|
-
"labui:flex labui:items-center labui:overflow-hidden",
|
|
5243
|
-
(column2.numeric || column2.align === "end") && "labui:justify-end"
|
|
5244
|
-
),
|
|
5245
|
-
style: { height: rowHeight - 1 },
|
|
5246
|
-
children: content
|
|
5247
|
-
}
|
|
5248
|
-
) : content
|
|
5249
|
-
},
|
|
5250
|
-
column2.id
|
|
5251
|
-
);
|
|
5252
|
-
})
|
|
5275
|
+
children: /* @__PURE__ */ jsx45(
|
|
5276
|
+
MemoRowCells,
|
|
5277
|
+
{
|
|
5278
|
+
row,
|
|
5279
|
+
columns,
|
|
5280
|
+
index,
|
|
5281
|
+
rowHeight
|
|
5282
|
+
}
|
|
5283
|
+
)
|
|
5253
5284
|
},
|
|
5254
5285
|
key2
|
|
5255
5286
|
);
|