@raystack/apsara 0.14.1 → 0.14.3
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 +28 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +8 -0
- package/dist/index.js +29 -30
- package/dist/index.js.map +1 -1
- package/dist/table/DataTableFilterChips.d.ts.map +1 -1
- package/dist/table/DataTableFilterOptions.d.ts.map +1 -1
- package/dist/table/datatable.d.ts +7 -3
- package/dist/table/datatable.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -31757,14 +31757,18 @@ function DataTableFilterOptions({ children, ...props }) {
|
|
|
31757
31757
|
const { table, filteredColumns, addFilterColumn } = useTable();
|
|
31758
31758
|
const availableColumns = table
|
|
31759
31759
|
.getAllColumns()
|
|
31760
|
-
.filter((column) => typeof column.accessorFn !== "undefined" &&
|
|
31760
|
+
.filter((column) => typeof column.accessorFn !== "undefined" &&
|
|
31761
|
+
column.getCanHide() &&
|
|
31762
|
+
column.getCanFilter())
|
|
31761
31763
|
.filter((column) => !filteredColumns.includes(column.id));
|
|
31762
31764
|
return (jsxRuntimeExports$1.jsxs(DropdownMenu, { children: [jsxRuntimeExports$1.jsx(DropdownMenu.Trigger, { asChild: true, children: jsxRuntimeExports$1.jsx(Button$1, { variant: "ghost", ...props, children: children || (jsxRuntimeExports$1.jsxs(Flex, { gap: "small", align: "center", justify: "center", children: [jsxRuntimeExports$1.jsx(PlusIcon, { width: 12, height: "12" }), " Filter"] })) }) }), availableColumns.length ? (jsxRuntimeExports$1.jsxs(DropdownMenu.Content, { align: "end", className: "w-[150px]", children: [jsxRuntimeExports$1.jsx(DropdownMenu.Label, { children: "Filter column" }), jsxRuntimeExports$1.jsx(DropdownMenu.Separator, {}), availableColumns.map((column) => {
|
|
31763
|
-
|
|
31765
|
+
const columnHeader = column?.columnDef?.header;
|
|
31766
|
+
const columnName = (typeof columnHeader === "string" && columnHeader) || column.id;
|
|
31767
|
+
return (jsxRuntimeExports$1.jsx(DropdownMenu.Item, { onSelect: () => addFilterColumn(column.id), children: columnName }, column.id));
|
|
31764
31768
|
})] })) : null] }));
|
|
31765
31769
|
}
|
|
31766
31770
|
|
|
31767
|
-
var styles$4 = {"wrapper":"datatable-module_wrapper__Sxg2d","datatable":"datatable-module_datatable__z-Th2","table":"datatable-module_table__x2IkY","head":"datatable-module_head__zCfCW","toolbar":"datatable-module_toolbar__lO-aI","chip":"datatable-module_chip__IiwTD","chipWrapper":"datatable-module_chipWrapper__iz69x","filterOperator":"datatable-module_filterOperator__qtDsH","filterText":"datatable-module_filterText__w00L8","flex1":"datatable-module_flex1__fA-kQ"};
|
|
31771
|
+
var styles$4 = {"wrapper":"datatable-module_wrapper__Sxg2d","datatable":"datatable-module_datatable__z-Th2","table":"datatable-module_table__x2IkY","head":"datatable-module_head__zCfCW","toolbar":"datatable-module_toolbar__lO-aI","chip":"datatable-module_chip__IiwTD","chipWrapper":"datatable-module_chipWrapper__iz69x","filterOperator":"datatable-module_filterOperator__qtDsH","filterText":"datatable-module_filterText__w00L8","flex1":"datatable-module_flex1__fA-kQ","tRow":"datatable-module_tRow__GrMHh","tRowClick":"datatable-module_tRowClick__7wzkh"};
|
|
31768
31772
|
|
|
31769
31773
|
const columnTypesMap = {
|
|
31770
31774
|
select: "select",
|
|
@@ -32031,7 +32035,9 @@ function DataTableFilterChips(props) {
|
|
|
32031
32035
|
const { filteredColumns, table, updateColumnCustomFilter } = useTable();
|
|
32032
32036
|
const tableColumns = table
|
|
32033
32037
|
.getAllColumns()
|
|
32034
|
-
.filter((column) => typeof column.accessorFn !== "undefined" &&
|
|
32038
|
+
.filter((column) => typeof column.accessorFn !== "undefined" &&
|
|
32039
|
+
column.getCanHide() &&
|
|
32040
|
+
column.getCanFilter());
|
|
32035
32041
|
if (!filteredColumns.length)
|
|
32036
32042
|
return null;
|
|
32037
32043
|
return (jsxRuntimeExports$1.jsxs(Flex, { gap: "small", align: "center", className: styles$4.chipWrapper, ...props, children: [filteredColumns.map((filter, index) => {
|
|
@@ -32221,18 +32227,17 @@ function Skeleton({ count = 1, wrapper: Wrapper, className: customClassName, con
|
|
|
32221
32227
|
: elements));
|
|
32222
32228
|
}
|
|
32223
32229
|
|
|
32224
|
-
function DataTableRoot({ columns, data, emptyState, children, parentStyle, isLoading = false, ShouldShowHeader = true, ...props }) {
|
|
32230
|
+
function DataTableRoot({ columns, data, emptyState, children, parentStyle, isLoading = false, ShouldShowHeader = true, initialState, loaderRow = 5, onRowClick, ...props }) {
|
|
32225
32231
|
const [tableCustomFilter, setTableCustomFilter] = React.useState({});
|
|
32226
32232
|
const convertedChildren = React.Children.toArray(children);
|
|
32227
32233
|
const header = convertedChildren.find((child) => child.type === DataTableToolbar) || null;
|
|
32228
32234
|
const footer = convertedChildren.find((child) => child.type === DataTableFooter) || null;
|
|
32229
32235
|
const detail = convertedChildren.find((child) => child.type === TableDetailContainer) ||
|
|
32230
32236
|
null;
|
|
32231
|
-
const [
|
|
32232
|
-
const
|
|
32233
|
-
|
|
32234
|
-
|
|
32235
|
-
const [globalFilter, setGlobalFilter] = React.useState("");
|
|
32237
|
+
const [tableState, setTableState] = React.useState({});
|
|
32238
|
+
const tableData = isLoading
|
|
32239
|
+
? [...new Array(loaderRow)].map((_, i) => ({ id: i }))
|
|
32240
|
+
: data;
|
|
32236
32241
|
const { filteredColumns, addFilterColumn, removeFilterColumn, resetColumns } = useTableColumn();
|
|
32237
32242
|
const columnWithCustomFilter = columns.map((col) => {
|
|
32238
32243
|
// @ts-ignore;
|
|
@@ -32249,42 +32254,36 @@ function DataTableRoot({ columns, data, emptyState, children, parentStyle, isLoa
|
|
|
32249
32254
|
setTableCustomFilter((old) => ({ ...old, [id]: filterFn }));
|
|
32250
32255
|
};
|
|
32251
32256
|
const table = useReactTable({
|
|
32252
|
-
data,
|
|
32257
|
+
data: tableData,
|
|
32253
32258
|
columns: columnWithCustomFilter,
|
|
32254
32259
|
globalFilterFn: "auto",
|
|
32255
32260
|
enableRowSelection: true,
|
|
32256
32261
|
manualPagination: true,
|
|
32257
32262
|
pageCount: -1,
|
|
32258
|
-
|
|
32259
|
-
onSortingChange: setSorting,
|
|
32260
|
-
onColumnFiltersChange: setColumnFilters,
|
|
32261
|
-
onColumnVisibilityChange: setColumnVisibility,
|
|
32262
|
-
onRowSelectionChange: setRowSelection,
|
|
32263
|
+
onStateChange: (updater) => setTableState(updater),
|
|
32263
32264
|
getCoreRowModel: getCoreRowModel(),
|
|
32264
32265
|
getFilteredRowModel: getFilteredRowModel(),
|
|
32265
32266
|
getPaginationRowModel: getPaginationRowModel(),
|
|
32266
32267
|
getSortedRowModel: getSortedRowModel(),
|
|
32267
32268
|
getFacetedRowModel: getFacetedRowModel(),
|
|
32268
32269
|
getFacetedUniqueValues: getFacetedUniqueValues(),
|
|
32269
|
-
|
|
32270
|
-
|
|
32271
|
-
globalFilter,
|
|
32272
|
-
columnFilters,
|
|
32273
|
-
columnVisibility,
|
|
32274
|
-
rowSelection,
|
|
32275
|
-
},
|
|
32270
|
+
initialState,
|
|
32271
|
+
state: tableState,
|
|
32276
32272
|
});
|
|
32277
|
-
const tableStyle =
|
|
32278
|
-
|
|
32279
|
-
|
|
32273
|
+
const tableStyle = {
|
|
32274
|
+
...(table.getRowModel().rows?.length
|
|
32275
|
+
? { width: "100%" }
|
|
32276
|
+
: { width: "100%", height: "100%" }),
|
|
32277
|
+
...{ "border-collapse": "collapse" },
|
|
32278
|
+
};
|
|
32280
32279
|
return (jsxRuntimeExports$1.jsx(Flex, { direction: "column", justify: "between", className: styles$4.wrapper, children: jsxRuntimeExports$1.jsxs(TableContext.Provider, { value: {
|
|
32281
32280
|
table,
|
|
32282
|
-
globalFilter,
|
|
32281
|
+
globalFilter: tableState.globalFilter,
|
|
32283
32282
|
filteredColumns,
|
|
32284
32283
|
addFilterColumn,
|
|
32285
32284
|
removeFilterColumn,
|
|
32286
32285
|
resetColumns,
|
|
32287
|
-
onGlobalFilterChange:
|
|
32286
|
+
onGlobalFilterChange: (value) => setTableState((prev) => ({ ...prev, globalFilter: value })),
|
|
32288
32287
|
onChange: () => ({}),
|
|
32289
32288
|
tableCustomFilter,
|
|
32290
32289
|
updateColumnCustomFilter,
|
|
@@ -32302,7 +32301,7 @@ function DataTableRoot({ columns, data, emptyState, children, parentStyle, isLoa
|
|
|
32302
32301
|
}[header.column.getIsSorted()] ?? jsxRuntimeExports$1.jsx(CaretSortIcon, {})
|
|
32303
32302
|
: null] }) }, `${header.id}_${index}`));
|
|
32304
32303
|
}) }, headerGroup.id)))
|
|
32305
|
-
: null }), jsxRuntimeExports$1.jsx(Table.Body, { children: table.getRowModel().rows?.length ? (table.getRowModel().rows.map((row) => (jsxRuntimeExports$1.jsx(Table.Row, { "data-state": row.getIsSelected() && "selected", children: row.getVisibleCells().map((cell, index) => (jsxRuntimeExports$1.jsx(Table.Cell, { style: {
|
|
32304
|
+
: null }), jsxRuntimeExports$1.jsx(Table.Body, { children: table.getRowModel().rows?.length ? (table.getRowModel().rows.map((row) => (jsxRuntimeExports$1.jsx(Table.Row, { "data-state": row.getIsSelected() && "selected", onClick: () => onRowClick?.(row.original), className: `${styles$4.tRow} ${onRowClick ? styles$4.tRowClick : ""}`, children: row.getVisibleCells().map((cell, index) => (jsxRuntimeExports$1.jsx(Table.Cell, { style: {
|
|
32306
32305
|
...(cell.column.columnDef?.meta?.style ?? {}),
|
|
32307
32306
|
}, children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, `${cell.id}_${index}`))) }, row.id)))) : (jsxRuntimeExports$1.jsx(Table.Row, { children: jsxRuntimeExports$1.jsx(Table.Cell, { colSpan: columns.length, children: emptyState || "No results." }) })) })] }), detail] })] }), footer] }) }));
|
|
32308
32307
|
}
|