@umami/react-zen 1.0.5 → 1.0.6
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.d.mts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +52 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +52 -31
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -409,6 +409,11 @@ type DataTableSorting = {
|
|
|
409
409
|
interface DataTableProps<TData extends RowData = any> extends ComponentProps<typeof Table> {
|
|
410
410
|
data?: TData[];
|
|
411
411
|
displayMode?: 'table' | 'cards';
|
|
412
|
+
/**
|
|
413
|
+
* In card mode, lays the cards out in as many columns as fit, each at least this wide
|
|
414
|
+
* (e.g. `'360px'`). Without it, cards stack in a single column.
|
|
415
|
+
*/
|
|
416
|
+
cardMinWidth?: string;
|
|
412
417
|
/** Returns a row's unique id. Defaults to the row's `id` property, or its index without one. */
|
|
413
418
|
getRowId?: (row: TData, index: number) => string;
|
|
414
419
|
/** Adds a checkbox column for selecting rows. */
|
|
@@ -455,7 +460,7 @@ interface DataColumnProps<TData = any> extends Omit<HTMLAttributes<HTMLTableCell
|
|
|
455
460
|
}
|
|
456
461
|
/** Declares a column of a DataTable. Renders nothing on its own. */
|
|
457
462
|
declare function DataColumn<TData = any>(_props: DataColumnProps<TData>): null;
|
|
458
|
-
declare function DataTable<TData extends RowData = any>({ data, displayMode, getRowId, selectionMode, selectedRows: selectedRowsProp, defaultSelectedRows, onSelectedRowsChange, sorting: sortingProp, defaultSorting, onSortingChange, filter, pageSize, pageIndex: pageIndexProp, defaultPageIndex, onPageIndexChange, emptyState, className, children, ...props }: DataTableProps<TData>): react_jsx_runtime.JSX.Element;
|
|
463
|
+
declare function DataTable<TData extends RowData = any>({ data, displayMode, cardMinWidth, getRowId, selectionMode, selectedRows: selectedRowsProp, defaultSelectedRows, onSelectedRowsChange, sorting: sortingProp, defaultSorting, onSortingChange, filter, pageSize, pageIndex: pageIndexProp, defaultPageIndex, onPageIndexChange, emptyState, className, children, ...props }: DataTableProps<TData>): react_jsx_runtime.JSX.Element;
|
|
459
464
|
|
|
460
465
|
declare function Calendar({ className, classNames, showOutsideDays, captionLayout, buttonVariant, locale, formatters, components, ...props }: React$1.ComponentProps<typeof DayPicker> & {
|
|
461
466
|
buttonVariant?: React$1.ComponentProps<typeof Button>["variant"];
|
package/dist/index.d.ts
CHANGED
|
@@ -409,6 +409,11 @@ type DataTableSorting = {
|
|
|
409
409
|
interface DataTableProps<TData extends RowData = any> extends ComponentProps<typeof Table> {
|
|
410
410
|
data?: TData[];
|
|
411
411
|
displayMode?: 'table' | 'cards';
|
|
412
|
+
/**
|
|
413
|
+
* In card mode, lays the cards out in as many columns as fit, each at least this wide
|
|
414
|
+
* (e.g. `'360px'`). Without it, cards stack in a single column.
|
|
415
|
+
*/
|
|
416
|
+
cardMinWidth?: string;
|
|
412
417
|
/** Returns a row's unique id. Defaults to the row's `id` property, or its index without one. */
|
|
413
418
|
getRowId?: (row: TData, index: number) => string;
|
|
414
419
|
/** Adds a checkbox column for selecting rows. */
|
|
@@ -455,7 +460,7 @@ interface DataColumnProps<TData = any> extends Omit<HTMLAttributes<HTMLTableCell
|
|
|
455
460
|
}
|
|
456
461
|
/** Declares a column of a DataTable. Renders nothing on its own. */
|
|
457
462
|
declare function DataColumn<TData = any>(_props: DataColumnProps<TData>): null;
|
|
458
|
-
declare function DataTable<TData extends RowData = any>({ data, displayMode, getRowId, selectionMode, selectedRows: selectedRowsProp, defaultSelectedRows, onSelectedRowsChange, sorting: sortingProp, defaultSorting, onSortingChange, filter, pageSize, pageIndex: pageIndexProp, defaultPageIndex, onPageIndexChange, emptyState, className, children, ...props }: DataTableProps<TData>): react_jsx_runtime.JSX.Element;
|
|
463
|
+
declare function DataTable<TData extends RowData = any>({ data, displayMode, cardMinWidth, getRowId, selectionMode, selectedRows: selectedRowsProp, defaultSelectedRows, onSelectedRowsChange, sorting: sortingProp, defaultSorting, onSortingChange, filter, pageSize, pageIndex: pageIndexProp, defaultPageIndex, onPageIndexChange, emptyState, className, children, ...props }: DataTableProps<TData>): react_jsx_runtime.JSX.Element;
|
|
459
464
|
|
|
460
465
|
declare function Calendar({ className, classNames, showOutsideDays, captionLayout, buttonVariant, locale, formatters, components, ...props }: React$1.ComponentProps<typeof DayPicker> & {
|
|
461
466
|
buttonVariant?: React$1.ComponentProps<typeof Button>["variant"];
|
package/dist/index.js
CHANGED
|
@@ -3611,6 +3611,7 @@ function renderCell(column, row, index) {
|
|
|
3611
3611
|
function DataTable({
|
|
3612
3612
|
data = [],
|
|
3613
3613
|
displayMode = "table",
|
|
3614
|
+
cardMinWidth,
|
|
3614
3615
|
getRowId = defaultGetRowId,
|
|
3615
3616
|
selectionMode = "none",
|
|
3616
3617
|
selectedRows: selectedRowsProp,
|
|
@@ -3684,6 +3685,7 @@ function DataTable({
|
|
|
3684
3685
|
"div",
|
|
3685
3686
|
{
|
|
3686
3687
|
"data-slot": "data-table-pagination",
|
|
3688
|
+
style: { gridColumn: "1 / -1" },
|
|
3687
3689
|
className: "flex w-full items-center justify-between gap-4 py-3 text-sm text-muted-foreground",
|
|
3688
3690
|
children: [
|
|
3689
3691
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
@@ -3717,39 +3719,58 @@ function DataTable({
|
|
|
3717
3719
|
]
|
|
3718
3720
|
}
|
|
3719
3721
|
);
|
|
3720
|
-
const empty = /* @__PURE__ */ jsxRuntime.jsx(
|
|
3722
|
+
const empty = /* @__PURE__ */ jsxRuntime.jsx(
|
|
3723
|
+
"div",
|
|
3724
|
+
{
|
|
3725
|
+
"data-slot": "data-table-empty",
|
|
3726
|
+
style: { gridColumn: "1 / -1" },
|
|
3727
|
+
className: "py-10 text-center text-sm text-muted-foreground",
|
|
3728
|
+
children: emptyState
|
|
3729
|
+
}
|
|
3730
|
+
);
|
|
3721
3731
|
if (displayMode === "cards") {
|
|
3722
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
}))
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3732
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3733
|
+
Grid,
|
|
3734
|
+
{
|
|
3735
|
+
width: "100%",
|
|
3736
|
+
gap: "6",
|
|
3737
|
+
columns: cardMinWidth ? `repeat(auto-fill, minmax(min(${cardMinWidth}, 100%), 1fr))` : void 0,
|
|
3738
|
+
alignItems: cardMinWidth ? "start" : void 0,
|
|
3739
|
+
"data-slot": "data-table",
|
|
3740
|
+
"data-display-mode": "cards",
|
|
3741
|
+
children: [
|
|
3742
|
+
rows.length === 0 ? empty : rows.map((row) => {
|
|
3743
|
+
const items = visibleColumns.map((column) => ({
|
|
3744
|
+
label: column.label,
|
|
3745
|
+
value: renderCell(column, row.original, row.index)
|
|
3746
|
+
}));
|
|
3747
|
+
if (isSelectable) {
|
|
3748
|
+
items.unshift({
|
|
3749
|
+
label: "",
|
|
3750
|
+
value: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3751
|
+
Checkbox,
|
|
3752
|
+
{
|
|
3753
|
+
"aria-label": "Select row",
|
|
3754
|
+
checked: row.getIsSelected(),
|
|
3755
|
+
onCheckedChange: (checked) => row.toggleSelected(checked)
|
|
3756
|
+
}
|
|
3757
|
+
)
|
|
3758
|
+
});
|
|
3759
|
+
}
|
|
3760
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3761
|
+
DataCard,
|
|
3733
3762
|
{
|
|
3734
|
-
"
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
}
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
"data-state": row.getIsSelected() ? "selected" : void 0,
|
|
3746
|
-
data: items
|
|
3747
|
-
},
|
|
3748
|
-
row.id
|
|
3749
|
-
);
|
|
3750
|
-
}),
|
|
3751
|
-
pagination
|
|
3752
|
-
] });
|
|
3763
|
+
"data-row-id": row.id,
|
|
3764
|
+
"data-state": row.getIsSelected() ? "selected" : void 0,
|
|
3765
|
+
data: items
|
|
3766
|
+
},
|
|
3767
|
+
row.id
|
|
3768
|
+
);
|
|
3769
|
+
}),
|
|
3770
|
+
pagination
|
|
3771
|
+
]
|
|
3772
|
+
}
|
|
3773
|
+
);
|
|
3753
3774
|
}
|
|
3754
3775
|
const gridTemplateColumns = [
|
|
3755
3776
|
...isSelectable ? [SELECTION_COLUMN_WIDTH] : [],
|