@raystack/apsara 0.18.6 → 0.19.0
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 +38 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +38 -15
- package/dist/index.js.map +1 -1
- package/dist/table/datatable.d.ts +2 -1
- package/dist/table/datatable.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4362,7 +4362,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
4362
4362
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
4363
4363
|
PERFORMANCE OF THIS SOFTWARE.
|
|
4364
4364
|
***************************************************************************** */
|
|
4365
|
-
/* global Reflect, Promise */
|
|
4365
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
4366
4366
|
|
|
4367
4367
|
|
|
4368
4368
|
var __assign = function() {
|
|
@@ -4396,7 +4396,12 @@ function __spreadArray(to, from, pack) {
|
|
|
4396
4396
|
}
|
|
4397
4397
|
}
|
|
4398
4398
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
4399
|
-
}
|
|
4399
|
+
}
|
|
4400
|
+
|
|
4401
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
4402
|
+
var e = new Error(message);
|
|
4403
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
4404
|
+
};
|
|
4400
4405
|
|
|
4401
4406
|
var zeroRightClassName = 'right-scroll-bar-position';
|
|
4402
4407
|
var fullWidthClassName = 'width-before-scroll-bar';
|
|
@@ -32114,7 +32119,7 @@ function Skeleton({ count = 1, wrapper: Wrapper, className: customClassName, con
|
|
|
32114
32119
|
: elements));
|
|
32115
32120
|
}
|
|
32116
32121
|
|
|
32117
|
-
function DataTableRoot({ columns, data, emptyState, children, parentStyle, isLoading = false, ShouldShowHeader = true, initialState, loaderRow =
|
|
32122
|
+
function DataTableRoot({ columns, data, emptyState, children, parentStyle, isLoading = false, ShouldShowHeader = true, initialState, loaderRow = 2, onRowClick, onStateChange = () => { }, onLoadMore, ...props }) {
|
|
32118
32123
|
const [tableCustomFilter, setTableCustomFilter] = useState({});
|
|
32119
32124
|
const convertedChildren = Children.toArray(children);
|
|
32120
32125
|
const header = convertedChildren.find((child) => child.type === DataTableToolbar) || null;
|
|
@@ -32122,18 +32127,15 @@ function DataTableRoot({ columns, data, emptyState, children, parentStyle, isLoa
|
|
|
32122
32127
|
const detail = convertedChildren.find((child) => child.type === TableDetailContainer) ||
|
|
32123
32128
|
null;
|
|
32124
32129
|
const [tableState, setTableState] = useState({});
|
|
32125
|
-
const
|
|
32126
|
-
|
|
32127
|
-
: data;
|
|
32130
|
+
const observerRef = useRef(null);
|
|
32131
|
+
const getLoader = (loaderRow, columns) => ([...new Array(loaderRow)].map((_, rowIndex) => (jsxRuntimeExports.jsx(Table.Row, { children: columns.map((_, colIndex) => (jsxRuntimeExports.jsx(Table.Cell, { children: jsxRuntimeExports.jsx(Skeleton, { containerClassName: styles$4.flex1, highlightColor: "var(--background-base)", baseColor: "var(--background-base-hover)" }) }, `col_${colIndex}`))) }, `row_${rowIndex}`))));
|
|
32128
32132
|
const { filteredColumns, addFilterColumn, removeFilterColumn, resetColumns } = useTableColumn();
|
|
32129
32133
|
const columnWithCustomFilter = useMemo(() => columns.map((col) => {
|
|
32130
32134
|
const colId = col.id || col?.accessorKey;
|
|
32131
32135
|
const filterFn = colId && tableCustomFilter.hasOwnProperty(colId)
|
|
32132
32136
|
? tableCustomFilter[colId]
|
|
32133
32137
|
: undefined;
|
|
32134
|
-
const cell =
|
|
32135
|
-
? () => (jsxRuntimeExports.jsx(Skeleton, { containerClassName: styles$4.flex1, highlightColor: "var(--background-base)", baseColor: "var(--background-base-hover)" }))
|
|
32136
|
-
: col.cell;
|
|
32138
|
+
const { cell } = col;
|
|
32137
32139
|
return {
|
|
32138
32140
|
...col,
|
|
32139
32141
|
cell,
|
|
@@ -32149,7 +32151,7 @@ function DataTableRoot({ columns, data, emptyState, children, parentStyle, isLoa
|
|
|
32149
32151
|
setTableCustomFilter((old) => ({ ...old, [id]: filterFn }));
|
|
32150
32152
|
};
|
|
32151
32153
|
const table = useReactTable({
|
|
32152
|
-
data
|
|
32154
|
+
data,
|
|
32153
32155
|
columns: columnWithCustomFilter,
|
|
32154
32156
|
globalFilterFn: "auto",
|
|
32155
32157
|
enableRowSelection: true,
|
|
@@ -32165,6 +32167,25 @@ function DataTableRoot({ columns, data, emptyState, children, parentStyle, isLoa
|
|
|
32165
32167
|
initialState,
|
|
32166
32168
|
state: tableState,
|
|
32167
32169
|
});
|
|
32170
|
+
const lastRowRef = useCallback((node) => {
|
|
32171
|
+
if (isLoading)
|
|
32172
|
+
return;
|
|
32173
|
+
if (observerRef.current)
|
|
32174
|
+
observerRef.current.disconnect();
|
|
32175
|
+
observerRef.current = new IntersectionObserver((entries) => {
|
|
32176
|
+
if (entries[0].isIntersecting && onLoadMore) {
|
|
32177
|
+
onLoadMore();
|
|
32178
|
+
}
|
|
32179
|
+
});
|
|
32180
|
+
if (node)
|
|
32181
|
+
observerRef.current.observe(node);
|
|
32182
|
+
}, [isLoading, onLoadMore]);
|
|
32183
|
+
useEffect(() => {
|
|
32184
|
+
return () => {
|
|
32185
|
+
if (observerRef.current)
|
|
32186
|
+
observerRef.current.disconnect();
|
|
32187
|
+
};
|
|
32188
|
+
}, []);
|
|
32168
32189
|
const tableStyle = {
|
|
32169
32190
|
...(table.getRowModel().rows?.length
|
|
32170
32191
|
? { width: "100%" }
|
|
@@ -32197,11 +32218,13 @@ function DataTableRoot({ columns, data, emptyState, children, parentStyle, isLoa
|
|
|
32197
32218
|
}[header.column.getIsSorted()] ?? jsxRuntimeExports.jsx(CaretSortIcon, {})
|
|
32198
32219
|
: null] }) }, `${header.id}_${index}`));
|
|
32199
32220
|
}) }, headerGroup.id)))
|
|
32200
|
-
: null }), jsxRuntimeExports.
|
|
32201
|
-
|
|
32202
|
-
|
|
32203
|
-
|
|
32204
|
-
|
|
32221
|
+
: null }), jsxRuntimeExports.jsxs(Table.Body, { children: [table.getRowModel().rows?.length ? (table.getRowModel().rows.map((row, rowIndex) => (jsxRuntimeExports.jsx(Table.Row, { "data-state": row.getIsSelected() && "selected", onClick: () => onRowClick?.(row.original), className: isLoading
|
|
32222
|
+
? ""
|
|
32223
|
+
: `${styles$4.tRow} ${onRowClick ? styles$4.tRowClick : ""}`, ref: rowIndex === table.getRowModel().rows.length - 1
|
|
32224
|
+
? lastRowRef
|
|
32225
|
+
: null, children: row.getVisibleCells().map((cell, index) => (jsxRuntimeExports.jsx(Table.Cell, { style: {
|
|
32226
|
+
...(cell.column.columnDef?.meta?.style ?? {}),
|
|
32227
|
+
}, children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, `${cell.id}_${index}`))) }, row.id)))) : (jsxRuntimeExports.jsx(Table.Row, { children: jsxRuntimeExports.jsx(Table.Cell, { colSpan: columns.length, children: emptyState || "No results." }) })), isLoading && getLoader(loaderRow, columns)] })] }), detail] })] }), footer] }) }));
|
|
32205
32228
|
}
|
|
32206
32229
|
const DataTable = Object.assign(DataTableRoot, {
|
|
32207
32230
|
Toolbar: DataTableToolbar,
|