@raystack/apsara 0.14.2 → 0.14.4
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 +25 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +8 -0
- package/dist/index.js +26 -37
- package/dist/index.js.map +1 -1
- package/dist/table/DataTableClearFilter.d.ts.map +1 -1
- package/dist/table/FilteredChip.d.ts.map +1 -1
- package/dist/table/datatable.d.ts +6 -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
|
@@ -31730,7 +31730,7 @@ function DataTableClearFilter({ children, ...props }) {
|
|
|
31730
31730
|
return (jsxRuntimeExports$1.jsx(Button$1, { variant: "ghost", onClick: () => {
|
|
31731
31731
|
table.resetColumnFilters();
|
|
31732
31732
|
resetColumns();
|
|
31733
|
-
},
|
|
31733
|
+
}, ...props, children: children || (jsxRuntimeExports$1.jsxs(Flex, { gap: "small", align: "center", justify: "center", style: { textWrap: "nowrap" }, children: ["Clear filters ", jsxRuntimeExports$1.jsx(Cross2Icon, { width: 12, height: "12" })] })) }));
|
|
31734
31734
|
}
|
|
31735
31735
|
|
|
31736
31736
|
function DataTableFilterOptions({ children, ...props }) {
|
|
@@ -31748,7 +31748,7 @@ function DataTableFilterOptions({ children, ...props }) {
|
|
|
31748
31748
|
})] })) : null] }));
|
|
31749
31749
|
}
|
|
31750
31750
|
|
|
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"};
|
|
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"};
|
|
31752
31752
|
|
|
31753
31753
|
const columnTypesMap = {
|
|
31754
31754
|
select: "select",
|
|
@@ -31946,15 +31946,14 @@ const getFilterValueType = ({ filterOperation, columnType, }) => {
|
|
|
31946
31946
|
return filterValueTypeMap.text;
|
|
31947
31947
|
}
|
|
31948
31948
|
};
|
|
31949
|
-
const FilterValues = ({ columnType = filterValueTypeMap.text, options = [], onValueChange, filterOperation, ...props }) => {
|
|
31950
|
-
const [value, setValue] = useState(
|
|
31951
|
-
value:
|
|
31952
|
-
|
|
31953
|
-
|
|
31954
|
-
|
|
31955
|
-
from: new Date(),
|
|
31956
|
-
}
|
|
31957
|
-
});
|
|
31949
|
+
const FilterValues = ({ column, columnType = filterValueTypeMap.text, options = [], onValueChange, filterOperation, ...props }) => {
|
|
31950
|
+
const [value, setValue] = useState(column?.columnDef?.meta?.defaultValue
|
|
31951
|
+
? { value: (column?.columnDef.meta).defaultValue }
|
|
31952
|
+
: {
|
|
31953
|
+
value: "",
|
|
31954
|
+
date: new Date(),
|
|
31955
|
+
dateRange: { to: new Date(), from: new Date() },
|
|
31956
|
+
});
|
|
31958
31957
|
const valueType = getFilterValueType({ filterOperation, columnType });
|
|
31959
31958
|
useEffect(() => {
|
|
31960
31959
|
if (onValueChange) {
|
|
@@ -32008,7 +32007,7 @@ const FilteredChip = ({ column, updateColumnCustomFilter, }) => {
|
|
|
32008
32007
|
setFilterOperation(undefined);
|
|
32009
32008
|
setFilterValue({});
|
|
32010
32009
|
}
|
|
32011
|
-
return (jsxRuntimeExports$1.jsxs(Box, { className: styles$4.chip, children: [jsxRuntimeExports$1.jsx(Text, { className: styles$4.filterText, children: columnName }), jsxRuntimeExports$1.jsx(Operation, { columnType: filterVariant, onOperationSelect: setFilterOperation }), filterOperation?.hideValueField ? null : (jsxRuntimeExports$1.jsx(FilterValues, { columnType: filterVariant, options: options, onValueChange: setFilterValue, filterOperation: filterOperation })), jsxRuntimeExports$1.jsx(Flex, { children: jsxRuntimeExports$1.jsx(Cross1Icon, { height: "12", width: "12", onClick: removeFilter }) })] }));
|
|
32010
|
+
return (jsxRuntimeExports$1.jsxs(Box, { className: styles$4.chip, children: [jsxRuntimeExports$1.jsx(Text, { className: styles$4.filterText, children: columnName }), jsxRuntimeExports$1.jsx(Operation, { columnType: filterVariant, onOperationSelect: setFilterOperation }), filterOperation?.hideValueField ? null : (jsxRuntimeExports$1.jsx(FilterValues, { column: column, columnType: filterVariant, options: options, onValueChange: setFilterValue, filterOperation: filterOperation })), jsxRuntimeExports$1.jsx(Flex, { children: jsxRuntimeExports$1.jsx(Cross1Icon, { height: "12", width: "12", onClick: removeFilter }) })] }));
|
|
32012
32011
|
};
|
|
32013
32012
|
|
|
32014
32013
|
function DataTableFilterChips(props) {
|
|
@@ -32207,21 +32206,17 @@ function Skeleton({ count = 1, wrapper: Wrapper, className: customClassName, con
|
|
|
32207
32206
|
: elements));
|
|
32208
32207
|
}
|
|
32209
32208
|
|
|
32210
|
-
function DataTableRoot({ columns, data, emptyState, children, parentStyle, isLoading = false, ShouldShowHeader = true, loaderRow = 5, ...props }) {
|
|
32211
|
-
const [tableCustomFilter, setTableCustomFilter] =
|
|
32209
|
+
function DataTableRoot({ columns, data, emptyState, children, parentStyle, isLoading = false, ShouldShowHeader = true, initialState, loaderRow = 5, onRowClick, ...props }) {
|
|
32210
|
+
const [tableCustomFilter, setTableCustomFilter] = useState({});
|
|
32212
32211
|
const convertedChildren = Children.toArray(children);
|
|
32213
32212
|
const header = convertedChildren.find((child) => child.type === DataTableToolbar) || null;
|
|
32214
32213
|
const footer = convertedChildren.find((child) => child.type === DataTableFooter) || null;
|
|
32215
32214
|
const detail = convertedChildren.find((child) => child.type === TableDetailContainer) ||
|
|
32216
32215
|
null;
|
|
32217
|
-
const [
|
|
32218
|
-
const [columnFilters, setColumnFilters] = React__default.useState([]);
|
|
32216
|
+
const [tableState, setTableState] = useState({});
|
|
32219
32217
|
const tableData = isLoading
|
|
32220
32218
|
? [...new Array(loaderRow)].map((_, i) => ({ id: i }))
|
|
32221
32219
|
: data;
|
|
32222
|
-
const [columnVisibility, setColumnVisibility] = React__default.useState({});
|
|
32223
|
-
const [rowSelection, setRowSelection] = React__default.useState({});
|
|
32224
|
-
const [globalFilter, setGlobalFilter] = React__default.useState("");
|
|
32225
32220
|
const { filteredColumns, addFilterColumn, removeFilterColumn, resetColumns } = useTableColumn();
|
|
32226
32221
|
const columnWithCustomFilter = columns.map((col) => {
|
|
32227
32222
|
// @ts-ignore;
|
|
@@ -32244,36 +32239,30 @@ function DataTableRoot({ columns, data, emptyState, children, parentStyle, isLoa
|
|
|
32244
32239
|
enableRowSelection: true,
|
|
32245
32240
|
manualPagination: true,
|
|
32246
32241
|
pageCount: -1,
|
|
32247
|
-
|
|
32248
|
-
onSortingChange: setSorting,
|
|
32249
|
-
onColumnFiltersChange: setColumnFilters,
|
|
32250
|
-
onColumnVisibilityChange: setColumnVisibility,
|
|
32251
|
-
onRowSelectionChange: setRowSelection,
|
|
32242
|
+
onStateChange: (updater) => setTableState(updater),
|
|
32252
32243
|
getCoreRowModel: getCoreRowModel(),
|
|
32253
32244
|
getFilteredRowModel: getFilteredRowModel(),
|
|
32254
32245
|
getPaginationRowModel: getPaginationRowModel(),
|
|
32255
32246
|
getSortedRowModel: getSortedRowModel(),
|
|
32256
32247
|
getFacetedRowModel: getFacetedRowModel(),
|
|
32257
32248
|
getFacetedUniqueValues: getFacetedUniqueValues(),
|
|
32258
|
-
|
|
32259
|
-
|
|
32260
|
-
globalFilter,
|
|
32261
|
-
columnFilters,
|
|
32262
|
-
columnVisibility,
|
|
32263
|
-
rowSelection,
|
|
32264
|
-
},
|
|
32249
|
+
initialState,
|
|
32250
|
+
state: tableState,
|
|
32265
32251
|
});
|
|
32266
|
-
const tableStyle =
|
|
32267
|
-
|
|
32268
|
-
|
|
32252
|
+
const tableStyle = {
|
|
32253
|
+
...(table.getRowModel().rows?.length
|
|
32254
|
+
? { width: "100%" }
|
|
32255
|
+
: { width: "100%", height: "100%" }),
|
|
32256
|
+
...{ "border-collapse": "collapse" },
|
|
32257
|
+
};
|
|
32269
32258
|
return (jsxRuntimeExports$1.jsx(Flex, { direction: "column", justify: "between", className: styles$4.wrapper, children: jsxRuntimeExports$1.jsxs(TableContext.Provider, { value: {
|
|
32270
32259
|
table,
|
|
32271
|
-
globalFilter,
|
|
32260
|
+
globalFilter: tableState.globalFilter,
|
|
32272
32261
|
filteredColumns,
|
|
32273
32262
|
addFilterColumn,
|
|
32274
32263
|
removeFilterColumn,
|
|
32275
32264
|
resetColumns,
|
|
32276
|
-
onGlobalFilterChange:
|
|
32265
|
+
onGlobalFilterChange: (value) => setTableState((prev) => ({ ...prev, globalFilter: value })),
|
|
32277
32266
|
onChange: () => ({}),
|
|
32278
32267
|
tableCustomFilter,
|
|
32279
32268
|
updateColumnCustomFilter,
|
|
@@ -32291,7 +32280,7 @@ function DataTableRoot({ columns, data, emptyState, children, parentStyle, isLoa
|
|
|
32291
32280
|
}[header.column.getIsSorted()] ?? jsxRuntimeExports$1.jsx(CaretSortIcon, {})
|
|
32292
32281
|
: null] }) }, `${header.id}_${index}`));
|
|
32293
32282
|
}) }, headerGroup.id)))
|
|
32294
|
-
: 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: {
|
|
32283
|
+
: 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: {
|
|
32295
32284
|
...(cell.column.columnDef?.meta?.style ?? {}),
|
|
32296
32285
|
}, 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] }) }));
|
|
32297
32286
|
}
|