@underverse-ui/underverse 0.2.8 → 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 CHANGED
@@ -2332,6 +2332,7 @@ var Modal = ({
2332
2332
  if (!isMounted || !isOpen && !isVisible) {
2333
2333
  return null;
2334
2334
  }
2335
+ const maxWidthClass = width ? "max-w-none" : fullWidth ? "max-w-full" : sizeStyles3[size];
2335
2336
  const modalContent = /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: cn("fixed inset-0 z-[9999] flex items-center justify-center", overlayClassName), onClick: handleOverlayClick, children: [
2336
2337
  /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2337
2338
  "div",
@@ -2346,9 +2347,9 @@ var Modal = ({
2346
2347
  "div",
2347
2348
  {
2348
2349
  className: cn(
2349
- "relative w-full rounded-lg bg-card text-card-foreground shadow-xl",
2350
+ "relative w-full rounded-lg bg-card text-card-foreground shadow-xl",
2350
2351
  "transition-all duration-200 ease-out",
2351
- fullWidth ? "max-w-full" : sizeStyles3[size],
2352
+ maxWidthClass,
2352
2353
  fullWidth && "mx-0",
2353
2354
  className
2354
2355
  ),
@@ -10057,6 +10058,7 @@ function DataTable({
10057
10058
  toolbar,
10058
10059
  enableColumnVisibilityToggle = true,
10059
10060
  enableDensityToggle = true,
10061
+ enableHeaderAlignToggle = false,
10060
10062
  striped = true,
10061
10063
  // Mặc định bật màu nền sẽn kẽ cho các dòng
10062
10064
  columnDividers = false,
@@ -10064,6 +10066,7 @@ function DataTable({
10064
10066
  labels
10065
10067
  }) {
10066
10068
  const t = (0, import_next_intl7.useTranslations)("Common");
10069
+ const [headerAlign, setHeaderAlign] = import_react23.default.useState("left");
10067
10070
  const [visibleCols, setVisibleCols] = import_react23.default.useState(() => columns.filter((c) => c.visible !== false).map((c) => c.key));
10068
10071
  const [filters, setFilters] = import_react23.default.useState({});
10069
10072
  const [sort, setSort] = import_react23.default.useState(null);
@@ -10146,18 +10149,21 @@ function DataTable({
10146
10149
  {
10147
10150
  style: { width: col.width },
10148
10151
  className: cn(
10149
- col.align === "right" && "text-right",
10150
- col.align === "center" && "text-center",
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",
10151
10155
  columnDividers && colIdx > 0 && "border-l border-border/60"
10152
10156
  ),
10153
- children: /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex items-center justify-between gap-2 select-none min-h-[2.5rem]", children: [
10154
- /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "flex items-center gap-1 min-w-0 flex-1", children: [
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: [
10155
10161
  /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("span", { className: "truncate font-medium text-sm", children: col.title }),
10156
10162
  col.sortable && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
10157
10163
  "button",
10158
10164
  {
10159
10165
  className: cn(
10160
- "ml-1 p-1 rounded-sm transition-all duration-200 hover:bg-accent",
10166
+ "p-1 rounded-sm transition-all duration-200 hover:bg-accent",
10161
10167
  sort?.key === col.key ? "opacity-100 bg-accent" : "opacity-60 hover:opacity-100"
10162
10168
  ),
10163
10169
  onClick: () => {
@@ -10196,11 +10202,11 @@ function DataTable({
10196
10202
  ] })
10197
10203
  }
10198
10204
  )
10199
- ] }),
10200
- col.filter && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
10205
+ ] });
10206
+ const filterContent = col.filter && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
10201
10207
  Popover,
10202
10208
  {
10203
- placement: "bottom-start",
10209
+ placement: isRightAlign ? "bottom-end" : "bottom-start",
10204
10210
  trigger: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
10205
10211
  "button",
10206
10212
  {
@@ -10231,14 +10237,32 @@ function DataTable({
10231
10237
  return newFilters;
10232
10238
  });
10233
10239
  },
10234
- className: "text-xs text-muted-foreground hover:text-foreground underline mt-1",
10240
+ className: "text-xs text-destructive hover:underline",
10235
10241
  children: "Clear filter"
10236
10242
  }
10237
10243
  )
10238
10244
  ] })
10239
10245
  }
10240
- )
10241
- ] })
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
+ })()
10242
10266
  },
10243
10267
  col.key
10244
10268
  )) });
@@ -10329,6 +10353,20 @@ function DataTable({
10329
10353
  ))
10330
10354
  }
10331
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
+ ),
10332
10370
  toolbar
10333
10371
  ] })
10334
10372
  ] }),