@underverse-ui/underverse 0.2.9 → 0.2.10
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 +48 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +53 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -10058,6 +10058,7 @@ function DataTable({
|
|
|
10058
10058
|
toolbar,
|
|
10059
10059
|
enableColumnVisibilityToggle = true,
|
|
10060
10060
|
enableDensityToggle = true,
|
|
10061
|
+
enableHeaderAlignToggle = false,
|
|
10061
10062
|
striped = true,
|
|
10062
10063
|
// Mặc định bật màu nền sẽn kẽ cho các dòng
|
|
10063
10064
|
columnDividers = false,
|
|
@@ -10065,6 +10066,7 @@ function DataTable({
|
|
|
10065
10066
|
labels
|
|
10066
10067
|
}) {
|
|
10067
10068
|
const t = (0, import_next_intl7.useTranslations)("Common");
|
|
10069
|
+
const [headerAlign, setHeaderAlign] = import_react23.default.useState("left");
|
|
10068
10070
|
const [visibleCols, setVisibleCols] = import_react23.default.useState(() => columns.filter((c) => c.visible !== false).map((c) => c.key));
|
|
10069
10071
|
const [filters, setFilters] = import_react23.default.useState({});
|
|
10070
10072
|
const [sort, setSort] = import_react23.default.useState(null);
|
|
@@ -10147,18 +10149,21 @@ function DataTable({
|
|
|
10147
10149
|
{
|
|
10148
10150
|
style: { width: col.width },
|
|
10149
10151
|
className: cn(
|
|
10150
|
-
|
|
10151
|
-
col.align === "
|
|
10152
|
+
// Use column-specific align if defined, otherwise use global headerAlign
|
|
10153
|
+
(col.align === "right" || !col.align && headerAlign === "right") && "text-right",
|
|
10154
|
+
(col.align === "center" || !col.align && headerAlign === "center") && "text-center",
|
|
10152
10155
|
columnDividers && colIdx > 0 && "border-l border-border/60"
|
|
10153
10156
|
),
|
|
10154
|
-
children:
|
|
10155
|
-
|
|
10157
|
+
children: (() => {
|
|
10158
|
+
const isRightAlign = col.align === "right" || !col.align && headerAlign === "right";
|
|
10159
|
+
const isCenterAlign = col.align === "center" || !col.align && headerAlign === "center";
|
|
10160
|
+
const titleContent = /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex items-center gap-1 min-w-0 flex-shrink", children: [
|
|
10156
10161
|
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: "truncate font-medium text-sm", children: col.title }),
|
|
10157
10162
|
col.sortable && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
10158
10163
|
"button",
|
|
10159
10164
|
{
|
|
10160
10165
|
className: cn(
|
|
10161
|
-
"
|
|
10166
|
+
"p-1 rounded-sm transition-all duration-200 hover:bg-accent",
|
|
10162
10167
|
sort?.key === col.key ? "opacity-100 bg-accent" : "opacity-60 hover:opacity-100"
|
|
10163
10168
|
),
|
|
10164
10169
|
onClick: () => {
|
|
@@ -10197,11 +10202,11 @@ function DataTable({
|
|
|
10197
10202
|
] })
|
|
10198
10203
|
}
|
|
10199
10204
|
)
|
|
10200
|
-
] })
|
|
10201
|
-
col.filter && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
10205
|
+
] });
|
|
10206
|
+
const filterContent = col.filter && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
10202
10207
|
Popover,
|
|
10203
10208
|
{
|
|
10204
|
-
placement: "bottom-start",
|
|
10209
|
+
placement: isRightAlign ? "bottom-end" : "bottom-start",
|
|
10205
10210
|
trigger: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
10206
10211
|
"button",
|
|
10207
10212
|
{
|
|
@@ -10232,14 +10237,32 @@ function DataTable({
|
|
|
10232
10237
|
return newFilters;
|
|
10233
10238
|
});
|
|
10234
10239
|
},
|
|
10235
|
-
className: "text-xs text-
|
|
10240
|
+
className: "text-xs text-destructive hover:underline",
|
|
10236
10241
|
children: "Clear filter"
|
|
10237
10242
|
}
|
|
10238
10243
|
)
|
|
10239
10244
|
] })
|
|
10240
10245
|
}
|
|
10241
|
-
)
|
|
10242
|
-
|
|
10246
|
+
);
|
|
10247
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
10248
|
+
"div",
|
|
10249
|
+
{
|
|
10250
|
+
className: cn(
|
|
10251
|
+
"flex items-center gap-2 select-none min-h-[2.5rem]",
|
|
10252
|
+
isRightAlign && "justify-end",
|
|
10253
|
+
isCenterAlign && "justify-center",
|
|
10254
|
+
!isRightAlign && !isCenterAlign && "justify-between"
|
|
10255
|
+
),
|
|
10256
|
+
children: isRightAlign ? /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(import_jsx_runtime47.Fragment, { children: [
|
|
10257
|
+
filterContent,
|
|
10258
|
+
titleContent
|
|
10259
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(import_jsx_runtime47.Fragment, { children: [
|
|
10260
|
+
titleContent,
|
|
10261
|
+
filterContent
|
|
10262
|
+
] })
|
|
10263
|
+
}
|
|
10264
|
+
);
|
|
10265
|
+
})()
|
|
10243
10266
|
},
|
|
10244
10267
|
col.key
|
|
10245
10268
|
)) });
|
|
@@ -10330,6 +10353,20 @@ function DataTable({
|
|
|
10330
10353
|
))
|
|
10331
10354
|
}
|
|
10332
10355
|
),
|
|
10356
|
+
enableHeaderAlignToggle && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
10357
|
+
DropdownMenu_default,
|
|
10358
|
+
{
|
|
10359
|
+
trigger: /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(Button_default, { variant: "ghost", size: "sm", className: "h-8 px-2", children: [
|
|
10360
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("svg", { className: "w-4 h-4 mr-1", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M4 6h16M4 12h10M4 18h16" }) }),
|
|
10361
|
+
labels?.headerAlign || t("headerAlign")
|
|
10362
|
+
] }),
|
|
10363
|
+
items: [
|
|
10364
|
+
{ label: labels?.alignLeft || t("alignLeft"), onClick: () => setHeaderAlign("left") },
|
|
10365
|
+
{ label: labels?.alignCenter || t("alignCenter"), onClick: () => setHeaderAlign("center") },
|
|
10366
|
+
{ label: labels?.alignRight || t("alignRight"), onClick: () => setHeaderAlign("right") }
|
|
10367
|
+
]
|
|
10368
|
+
}
|
|
10369
|
+
),
|
|
10333
10370
|
toolbar
|
|
10334
10371
|
] })
|
|
10335
10372
|
] }),
|