@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.css
CHANGED
|
@@ -2033,6 +2033,14 @@ html[data-theme="dark"] {
|
|
|
2033
2033
|
flex: 1;
|
|
2034
2034
|
}
|
|
2035
2035
|
|
|
2036
|
+
.datatable-module_tRow__GrMHh:hover {
|
|
2037
|
+
background-color: var(--background-base-hover);
|
|
2038
|
+
}
|
|
2039
|
+
|
|
2040
|
+
.datatable-module_tRowClick__7wzkh:hover {
|
|
2041
|
+
cursor: pointer;
|
|
2042
|
+
}
|
|
2043
|
+
|
|
2036
2044
|
.table-module_table__mqnXB {
|
|
2037
2045
|
width: 100%;
|
|
2038
2046
|
font-size: 12px;
|
package/dist/index.js
CHANGED
|
@@ -31737,14 +31737,18 @@ function DataTableFilterOptions({ children, ...props }) {
|
|
|
31737
31737
|
const { table, filteredColumns, addFilterColumn } = useTable();
|
|
31738
31738
|
const availableColumns = table
|
|
31739
31739
|
.getAllColumns()
|
|
31740
|
-
.filter((column) => typeof column.accessorFn !== "undefined" &&
|
|
31740
|
+
.filter((column) => typeof column.accessorFn !== "undefined" &&
|
|
31741
|
+
column.getCanHide() &&
|
|
31742
|
+
column.getCanFilter())
|
|
31741
31743
|
.filter((column) => !filteredColumns.includes(column.id));
|
|
31742
31744
|
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) => {
|
|
31743
|
-
|
|
31745
|
+
const columnHeader = column?.columnDef?.header;
|
|
31746
|
+
const columnName = (typeof columnHeader === "string" && columnHeader) || column.id;
|
|
31747
|
+
return (jsxRuntimeExports$1.jsx(DropdownMenu.Item, { onSelect: () => addFilterColumn(column.id), children: columnName }, column.id));
|
|
31744
31748
|
})] })) : null] }));
|
|
31745
31749
|
}
|
|
31746
31750
|
|
|
31747
|
-
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"};
|
|
31751
|
+
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"};
|
|
31748
31752
|
|
|
31749
31753
|
const columnTypesMap = {
|
|
31750
31754
|
select: "select",
|
|
@@ -32011,7 +32015,9 @@ function DataTableFilterChips(props) {
|
|
|
32011
32015
|
const { filteredColumns, table, updateColumnCustomFilter } = useTable();
|
|
32012
32016
|
const tableColumns = table
|
|
32013
32017
|
.getAllColumns()
|
|
32014
|
-
.filter((column) => typeof column.accessorFn !== "undefined" &&
|
|
32018
|
+
.filter((column) => typeof column.accessorFn !== "undefined" &&
|
|
32019
|
+
column.getCanHide() &&
|
|
32020
|
+
column.getCanFilter());
|
|
32015
32021
|
if (!filteredColumns.length)
|
|
32016
32022
|
return null;
|
|
32017
32023
|
return (jsxRuntimeExports$1.jsxs(Flex, { gap: "small", align: "center", className: styles$4.chipWrapper, ...props, children: [filteredColumns.map((filter, index) => {
|
|
@@ -32201,18 +32207,17 @@ function Skeleton({ count = 1, wrapper: Wrapper, className: customClassName, con
|
|
|
32201
32207
|
: elements));
|
|
32202
32208
|
}
|
|
32203
32209
|
|
|
32204
|
-
function DataTableRoot({ columns, data, emptyState, children, parentStyle, isLoading = false, ShouldShowHeader = true, ...props }) {
|
|
32205
|
-
const [tableCustomFilter, setTableCustomFilter] =
|
|
32210
|
+
function DataTableRoot({ columns, data, emptyState, children, parentStyle, isLoading = false, ShouldShowHeader = true, initialState, loaderRow = 5, onRowClick, ...props }) {
|
|
32211
|
+
const [tableCustomFilter, setTableCustomFilter] = useState({});
|
|
32206
32212
|
const convertedChildren = Children.toArray(children);
|
|
32207
32213
|
const header = convertedChildren.find((child) => child.type === DataTableToolbar) || null;
|
|
32208
32214
|
const footer = convertedChildren.find((child) => child.type === DataTableFooter) || null;
|
|
32209
32215
|
const detail = convertedChildren.find((child) => child.type === TableDetailContainer) ||
|
|
32210
32216
|
null;
|
|
32211
|
-
const [
|
|
32212
|
-
const
|
|
32213
|
-
|
|
32214
|
-
|
|
32215
|
-
const [globalFilter, setGlobalFilter] = React__default.useState("");
|
|
32217
|
+
const [tableState, setTableState] = useState({});
|
|
32218
|
+
const tableData = isLoading
|
|
32219
|
+
? [...new Array(loaderRow)].map((_, i) => ({ id: i }))
|
|
32220
|
+
: data;
|
|
32216
32221
|
const { filteredColumns, addFilterColumn, removeFilterColumn, resetColumns } = useTableColumn();
|
|
32217
32222
|
const columnWithCustomFilter = columns.map((col) => {
|
|
32218
32223
|
// @ts-ignore;
|
|
@@ -32229,42 +32234,36 @@ function DataTableRoot({ columns, data, emptyState, children, parentStyle, isLoa
|
|
|
32229
32234
|
setTableCustomFilter((old) => ({ ...old, [id]: filterFn }));
|
|
32230
32235
|
};
|
|
32231
32236
|
const table = useReactTable({
|
|
32232
|
-
data,
|
|
32237
|
+
data: tableData,
|
|
32233
32238
|
columns: columnWithCustomFilter,
|
|
32234
32239
|
globalFilterFn: "auto",
|
|
32235
32240
|
enableRowSelection: true,
|
|
32236
32241
|
manualPagination: true,
|
|
32237
32242
|
pageCount: -1,
|
|
32238
|
-
|
|
32239
|
-
onSortingChange: setSorting,
|
|
32240
|
-
onColumnFiltersChange: setColumnFilters,
|
|
32241
|
-
onColumnVisibilityChange: setColumnVisibility,
|
|
32242
|
-
onRowSelectionChange: setRowSelection,
|
|
32243
|
+
onStateChange: (updater) => setTableState(updater),
|
|
32243
32244
|
getCoreRowModel: getCoreRowModel(),
|
|
32244
32245
|
getFilteredRowModel: getFilteredRowModel(),
|
|
32245
32246
|
getPaginationRowModel: getPaginationRowModel(),
|
|
32246
32247
|
getSortedRowModel: getSortedRowModel(),
|
|
32247
32248
|
getFacetedRowModel: getFacetedRowModel(),
|
|
32248
32249
|
getFacetedUniqueValues: getFacetedUniqueValues(),
|
|
32249
|
-
|
|
32250
|
-
|
|
32251
|
-
globalFilter,
|
|
32252
|
-
columnFilters,
|
|
32253
|
-
columnVisibility,
|
|
32254
|
-
rowSelection,
|
|
32255
|
-
},
|
|
32250
|
+
initialState,
|
|
32251
|
+
state: tableState,
|
|
32256
32252
|
});
|
|
32257
|
-
const tableStyle =
|
|
32258
|
-
|
|
32259
|
-
|
|
32253
|
+
const tableStyle = {
|
|
32254
|
+
...(table.getRowModel().rows?.length
|
|
32255
|
+
? { width: "100%" }
|
|
32256
|
+
: { width: "100%", height: "100%" }),
|
|
32257
|
+
...{ "border-collapse": "collapse" },
|
|
32258
|
+
};
|
|
32260
32259
|
return (jsxRuntimeExports$1.jsx(Flex, { direction: "column", justify: "between", className: styles$4.wrapper, children: jsxRuntimeExports$1.jsxs(TableContext.Provider, { value: {
|
|
32261
32260
|
table,
|
|
32262
|
-
globalFilter,
|
|
32261
|
+
globalFilter: tableState.globalFilter,
|
|
32263
32262
|
filteredColumns,
|
|
32264
32263
|
addFilterColumn,
|
|
32265
32264
|
removeFilterColumn,
|
|
32266
32265
|
resetColumns,
|
|
32267
|
-
onGlobalFilterChange:
|
|
32266
|
+
onGlobalFilterChange: (value) => setTableState((prev) => ({ ...prev, globalFilter: value })),
|
|
32268
32267
|
onChange: () => ({}),
|
|
32269
32268
|
tableCustomFilter,
|
|
32270
32269
|
updateColumnCustomFilter,
|
|
@@ -32282,7 +32281,7 @@ function DataTableRoot({ columns, data, emptyState, children, parentStyle, isLoa
|
|
|
32282
32281
|
}[header.column.getIsSorted()] ?? jsxRuntimeExports$1.jsx(CaretSortIcon, {})
|
|
32283
32282
|
: null] }) }, `${header.id}_${index}`));
|
|
32284
32283
|
}) }, headerGroup.id)))
|
|
32285
|
-
: 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: {
|
|
32284
|
+
: 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: {
|
|
32286
32285
|
...(cell.column.columnDef?.meta?.style ?? {}),
|
|
32287
32286
|
}, 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] }) }));
|
|
32288
32287
|
}
|