@underverse-ui/underverse 1.0.162 → 1.0.163
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/api-reference.json +1 -1
- package/dist/index.cjs +17 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +17 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -2573,6 +2573,18 @@ type DataTableColumn<T> = {
|
|
|
2573
2573
|
type ColumnColorGroup = {
|
|
2574
2574
|
/** Display label for this group (e.g. "Bắt buộc", "Tùy chọn") */
|
|
2575
2575
|
label: string;
|
|
2576
|
+
/**
|
|
2577
|
+
* Optional override for the header cell text color of columns in this group.
|
|
2578
|
+
* Accepts any valid CSS color (hex, rgb, rgba, color-mix, var(--token), ...).
|
|
2579
|
+
* When omitted, the table picks a readable foreground (black or white) based
|
|
2580
|
+
* on the perceived luminance of the column's `colorTag` via WCAG formula.
|
|
2581
|
+
*
|
|
2582
|
+
* Useful when:
|
|
2583
|
+
* - the auto-picker doesn't match your brand palette
|
|
2584
|
+
* - you want a fixed color that survives light/dark theme swaps
|
|
2585
|
+
* (e.g., a CSS var like `var(--foreground)`)
|
|
2586
|
+
*/
|
|
2587
|
+
headerTextColor?: string;
|
|
2576
2588
|
};
|
|
2577
2589
|
type Sorter = {
|
|
2578
2590
|
key: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -2573,6 +2573,18 @@ type DataTableColumn<T> = {
|
|
|
2573
2573
|
type ColumnColorGroup = {
|
|
2574
2574
|
/** Display label for this group (e.g. "Bắt buộc", "Tùy chọn") */
|
|
2575
2575
|
label: string;
|
|
2576
|
+
/**
|
|
2577
|
+
* Optional override for the header cell text color of columns in this group.
|
|
2578
|
+
* Accepts any valid CSS color (hex, rgb, rgba, color-mix, var(--token), ...).
|
|
2579
|
+
* When omitted, the table picks a readable foreground (black or white) based
|
|
2580
|
+
* on the perceived luminance of the column's `colorTag` via WCAG formula.
|
|
2581
|
+
*
|
|
2582
|
+
* Useful when:
|
|
2583
|
+
* - the auto-picker doesn't match your brand palette
|
|
2584
|
+
* - you want a fixed color that survives light/dark theme swaps
|
|
2585
|
+
* (e.g., a CSS var like `var(--foreground)`)
|
|
2586
|
+
*/
|
|
2587
|
+
headerTextColor?: string;
|
|
2576
2588
|
};
|
|
2577
2589
|
type Sorter = {
|
|
2578
2590
|
key: string;
|
package/dist/index.js
CHANGED
|
@@ -22979,6 +22979,16 @@ function getHeaderBgColor(colorTag) {
|
|
|
22979
22979
|
if (!rgb) return colorTag;
|
|
22980
22980
|
return toRgba(rgb[0], rgb[1], rgb[2], 1);
|
|
22981
22981
|
}
|
|
22982
|
+
function getReadableForeground(colorTag) {
|
|
22983
|
+
const rgb = parseColor(colorTag);
|
|
22984
|
+
if (!rgb) return void 0;
|
|
22985
|
+
const toLinear = (c) => {
|
|
22986
|
+
const s = c / 255;
|
|
22987
|
+
return s <= 0.03928 ? s / 12.92 : Math.pow((s + 0.055) / 1.055, 2.4);
|
|
22988
|
+
};
|
|
22989
|
+
const L = 0.2126 * toLinear(rgb[0]) + 0.7152 * toLinear(rgb[1]) + 0.0722 * toLinear(rgb[2]);
|
|
22990
|
+
return L > 0.5 ? "rgba(15, 23, 42, 0.92)" : "rgba(255, 255, 255, 0.95)";
|
|
22991
|
+
}
|
|
22982
22992
|
function groupColumnsByColorTag(leafCols, colorGroups) {
|
|
22983
22993
|
const groupsMap = /* @__PURE__ */ new Map();
|
|
22984
22994
|
const ungrouped = [];
|
|
@@ -23040,7 +23050,8 @@ function DataTableHeader({
|
|
|
23040
23050
|
getStickyHeaderClass,
|
|
23041
23051
|
getStickyHeaderCellStyle,
|
|
23042
23052
|
sortByLabel,
|
|
23043
|
-
t
|
|
23053
|
+
t,
|
|
23054
|
+
columnColorGroups
|
|
23044
23055
|
}) {
|
|
23045
23056
|
const gi18n = useGlobalI18n();
|
|
23046
23057
|
const renderFilterControl = React56.useCallback(
|
|
@@ -23189,7 +23200,7 @@ function DataTableHeader({
|
|
|
23189
23200
|
title: gi18n.filterByColumn ? gi18n.filterByColumn(columnLabel) : `Filter by ${columnLabel}`,
|
|
23190
23201
|
className: cn(
|
|
23191
23202
|
"p-1.5 rounded-lg transition-all duration-200 hover:bg-accent",
|
|
23192
|
-
filters[col.key] ? "bg-accent
|
|
23203
|
+
filters[col.key] ? "bg-accent opacity-100" : "opacity-60 hover:opacity-100"
|
|
23193
23204
|
),
|
|
23194
23205
|
"aria-label": gi18n.filterByColumn ? gi18n.filterByColumn(columnLabel) : `Filter by ${columnLabel}`,
|
|
23195
23206
|
children: /* @__PURE__ */ jsx65(FilterIcon, { className: "w-4 h-4" })
|
|
@@ -23258,6 +23269,7 @@ function DataTableHeader({
|
|
|
23258
23269
|
const showBorderLeft = columnDividers && cellIndex > 0 && !isAfterFixedLeft && !col.fixed;
|
|
23259
23270
|
const isLastCell = cellIndex === row.length - 1;
|
|
23260
23271
|
const headerBackgroundColor = isLeaf && col.colorTag ? getHeaderBgColor(col.colorTag) : "var(--muted)";
|
|
23272
|
+
const headerColor = isLeaf && col.colorTag ? columnColorGroups?.[col.colorTag]?.headerTextColor ?? getReadableForeground(col.colorTag) : void 0;
|
|
23261
23273
|
return /* @__PURE__ */ jsxs53(
|
|
23262
23274
|
TableHead,
|
|
23263
23275
|
{
|
|
@@ -23267,6 +23279,7 @@ function DataTableHeader({
|
|
|
23267
23279
|
style: {
|
|
23268
23280
|
width: col.width,
|
|
23269
23281
|
backgroundColor: headerBackgroundColor,
|
|
23282
|
+
color: headerColor,
|
|
23270
23283
|
...getStickyHeaderCellStyle(headerCell)
|
|
23271
23284
|
},
|
|
23272
23285
|
className: cn(
|
|
@@ -24314,7 +24327,8 @@ function DataTable({
|
|
|
24314
24327
|
getStickyHeaderClass,
|
|
24315
24328
|
getStickyHeaderCellStyle,
|
|
24316
24329
|
sortByLabel: labels?.sortBy,
|
|
24317
|
-
t
|
|
24330
|
+
t,
|
|
24331
|
+
columnColorGroups
|
|
24318
24332
|
}
|
|
24319
24333
|
) }),
|
|
24320
24334
|
/* @__PURE__ */ jsx68(
|