@underverse-ui/underverse 0.2.64 → 0.2.66
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 +25 -1
- package/dist/index.cjs +47 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +47 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -94,7 +94,31 @@ All components follow [Vercel Web Interface Guidelines](https://github.com/verce
|
|
|
94
94
|
|
|
95
95
|
---
|
|
96
96
|
|
|
97
|
-
##
|
|
97
|
+
## � Entry Points
|
|
98
|
+
|
|
99
|
+
Package được chia thành 2 entry points để tối ưu cho Server Components:
|
|
100
|
+
|
|
101
|
+
### Main Entry (Server-safe)
|
|
102
|
+
|
|
103
|
+
```tsx
|
|
104
|
+
// dist/index.js - Các components không phụ thuộc react-hook-form
|
|
105
|
+
// Có thể sử dụng trong cả Server Components và Client Components
|
|
106
|
+
import { Button, Skeleton, DatePicker, DataTable } from "@underverse-ui/underverse";
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Form Entry (Client-only)
|
|
110
|
+
|
|
111
|
+
```tsx
|
|
112
|
+
// dist/form.js - Form components (phụ thuộc react-hook-form)
|
|
113
|
+
// Chỉ sử dụng trong Client Components ("use client")
|
|
114
|
+
import { Form, FormField, FormItem, FormLabel, FormMessage } from "@underverse-ui/underverse/form";
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
**Lưu ý:** Form components yêu cầu `react-hook-form` và `@hookform/resolvers` nên chỉ hoạt động ở client-side.
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## �🚀 Quick Start
|
|
98
122
|
|
|
99
123
|
### Standalone React (Vite, CRA, etc.)
|
|
100
124
|
|
package/dist/index.cjs
CHANGED
|
@@ -13145,6 +13145,45 @@ function DataTable({
|
|
|
13145
13145
|
const cellPadding = density === "compact" ? "py-1.5 px-3" : density === "comfortable" ? "py-3 px-4" : "py-2.5 px-4";
|
|
13146
13146
|
const visibleColsSet = import_react32.default.useMemo(() => new Set(visibleCols), [visibleCols]);
|
|
13147
13147
|
const visibleColumns = columns.filter((c) => visibleColsSet.has(c.key));
|
|
13148
|
+
const stickyPositions = import_react32.default.useMemo(() => {
|
|
13149
|
+
const positions = {};
|
|
13150
|
+
let leftOffset = 0;
|
|
13151
|
+
for (const col of visibleColumns) {
|
|
13152
|
+
if (col.fixed === "left") {
|
|
13153
|
+
positions[col.key] = { left: leftOffset };
|
|
13154
|
+
const colWidth = typeof col.width === "number" ? col.width : parseInt(String(col.width) || "150", 10);
|
|
13155
|
+
leftOffset += colWidth;
|
|
13156
|
+
}
|
|
13157
|
+
}
|
|
13158
|
+
let rightOffset = 0;
|
|
13159
|
+
for (let i = visibleColumns.length - 1; i >= 0; i--) {
|
|
13160
|
+
const col = visibleColumns[i];
|
|
13161
|
+
if (col.fixed === "right") {
|
|
13162
|
+
positions[col.key] = { right: rightOffset };
|
|
13163
|
+
const colWidth = typeof col.width === "number" ? col.width : parseInt(String(col.width) || "150", 10);
|
|
13164
|
+
rightOffset += colWidth;
|
|
13165
|
+
}
|
|
13166
|
+
}
|
|
13167
|
+
return positions;
|
|
13168
|
+
}, [visibleColumns]);
|
|
13169
|
+
const getStickyColumnClass = (col, isHeader = false) => {
|
|
13170
|
+
if (!col.fixed) return "";
|
|
13171
|
+
return cn(
|
|
13172
|
+
"sticky z-10 bg-background",
|
|
13173
|
+
col.fixed === "left" && "shadow-[2px_0_5px_-2px_rgba(0,0,0,0.1)]",
|
|
13174
|
+
col.fixed === "right" && "shadow-[-2px_0_5px_-2px_rgba(0,0,0,0.1)]",
|
|
13175
|
+
isHeader && "z-20"
|
|
13176
|
+
// Header cần z-index cao hơn
|
|
13177
|
+
);
|
|
13178
|
+
};
|
|
13179
|
+
const getStickyColumnStyle = (col) => {
|
|
13180
|
+
if (!col.fixed) return {};
|
|
13181
|
+
const pos = stickyPositions[col.key];
|
|
13182
|
+
return {
|
|
13183
|
+
...pos?.left !== void 0 && { left: pos.left },
|
|
13184
|
+
...pos?.right !== void 0 && { right: pos.right }
|
|
13185
|
+
};
|
|
13186
|
+
};
|
|
13148
13187
|
const getRowKey = (row, idx) => {
|
|
13149
13188
|
if (!rowKey) return String(idx);
|
|
13150
13189
|
if (typeof rowKey === "function") return String(rowKey(row));
|
|
@@ -13205,12 +13244,13 @@ function DataTable({
|
|
|
13205
13244
|
const renderHeader = /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(TableRow, { children: visibleColumns.map((col, colIdx) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
13206
13245
|
TableHead,
|
|
13207
13246
|
{
|
|
13208
|
-
style: { width: col.width },
|
|
13247
|
+
style: { width: col.width, ...getStickyColumnStyle(col) },
|
|
13209
13248
|
className: cn(
|
|
13210
13249
|
// Use column-specific align if defined, otherwise use global headerAlign
|
|
13211
13250
|
(col.align === "right" || !col.align && headerAlign === "right") && "text-right",
|
|
13212
13251
|
(col.align === "center" || !col.align && headerAlign === "center") && "text-center",
|
|
13213
|
-
columnDividers && colIdx > 0 && "border-l border-border/60"
|
|
13252
|
+
columnDividers && colIdx > 0 && "border-l border-border/60",
|
|
13253
|
+
getStickyColumnClass(col, true)
|
|
13214
13254
|
),
|
|
13215
13255
|
children: (() => {
|
|
13216
13256
|
const isRightAlign = col.align === "right" || !col.align && headerAlign === "right";
|
|
@@ -13467,13 +13507,17 @@ function DataTable({
|
|
|
13467
13507
|
return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
13468
13508
|
TableCell,
|
|
13469
13509
|
{
|
|
13510
|
+
style: getStickyColumnStyle(col),
|
|
13470
13511
|
className: cn(
|
|
13471
13512
|
cellPadding,
|
|
13472
13513
|
col.align === "right" && "text-right",
|
|
13473
13514
|
col.align === "center" && "text-center",
|
|
13474
13515
|
columnDividers && colIdx > 0 && "border-l border-border/60",
|
|
13475
13516
|
isLastRow && col === visibleColumns[0] && "rounded-bl-2xl md:rounded-bl-3xl",
|
|
13476
|
-
isLastRow && col === visibleColumns[visibleColumns.length - 1] && "rounded-br-2xl md:rounded-br-3xl"
|
|
13517
|
+
isLastRow && col === visibleColumns[visibleColumns.length - 1] && "rounded-br-2xl md:rounded-br-3xl",
|
|
13518
|
+
getStickyColumnClass(col),
|
|
13519
|
+
// Giữ màu nền striped cho cột cố định
|
|
13520
|
+
col.fixed && striped && idx % 2 === 0 && "bg-muted/50!"
|
|
13477
13521
|
),
|
|
13478
13522
|
children: col.render ? col.render(value, row, idx) : String(value ?? "")
|
|
13479
13523
|
},
|