@monolith-forensics/monolith-ui 1.2.111 → 1.2.113

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.
@@ -0,0 +1 @@
1
+ export declare const LoadingCellIndicator: React.FC;
@@ -0,0 +1,30 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import styled from "styled-components";
3
+ const LoadingIndicator = styled.div `
4
+ @keyframes fadeInOut {
5
+ 0% {
6
+ background-color: ${({ theme }) => theme.palette.background.alt};
7
+ }
8
+ 50% {
9
+ background-color: ${({ theme }) => theme.palette.background.paper};
10
+ }
11
+ 100% {
12
+ background-color: ${({ theme }) => theme.palette.background.alt};
13
+ }
14
+ }
15
+
16
+ width: 100%;
17
+ height: 100%;
18
+ min-height: 20px;
19
+ border-radius: 4px;
20
+ animation: fadeInOut 1.25s ease-in-out infinite;
21
+ display: flex;
22
+ align-items: center;
23
+ justify-content: center;
24
+ font-size: 10px;
25
+ color: ${({ theme }) => theme.palette.text.secondary};
26
+ background-color: #f0f0f0;
27
+ `;
28
+ export const LoadingCellIndicator = () => {
29
+ return _jsx(LoadingIndicator, { children: "loading..." });
30
+ };
@@ -4,7 +4,7 @@ import TableRow from "./TableRow";
4
4
  import useTable from "./useTable";
5
5
  const StaticRows = ({ targetElm, listElm }) => {
6
6
  var _a;
7
- const { data } = useTable();
8
- return (_jsx(TBody, { className: "mfui-tbody", children: _jsx(TableViewPort, { className: "mfui-tbody-viewport", ref: targetElm, children: _jsx(TableListElement, { className: "mfui-tbody-list", ref: listElm, children: (_a = data === null || data === void 0 ? void 0 : data.map) === null || _a === void 0 ? void 0 : _a.call(data, (row, index) => (_jsx(TableRow, { rowData: row }, index))) }) }) }));
7
+ const { data, loadingRowIds, keyField } = useTable();
8
+ return (_jsx(TBody, { className: "mfui-tbody", children: _jsx(TableViewPort, { className: "mfui-tbody-viewport", ref: targetElm, children: _jsx(TableListElement, { className: "mfui-tbody-list", ref: listElm, children: (_a = data === null || data === void 0 ? void 0 : data.map) === null || _a === void 0 ? void 0 : _a.call(data, (row, index) => (_jsx(TableRow, { rowData: row, loading: !!keyField ? loadingRowIds === null || loadingRowIds === void 0 ? void 0 : loadingRowIds.includes(row[keyField]) : false }, index))) }) }) }));
9
9
  };
10
10
  export default StaticRows;
@@ -6,7 +6,8 @@ import useTable from "./useTable";
6
6
  import ActionCell from "./ActionCell";
7
7
  import ActionButton from "./ActionButton";
8
8
  import CheckBox from "../CheckBox";
9
- const TableRow = ({ rowData, rowStyle }) => {
9
+ import { LoadingCellIndicator } from "./LoadingCellIndicator";
10
+ const TableRow = ({ rowData, loading, rowStyle }) => {
10
11
  const { columnState, enableActionButton, onActionButtonClick, actionButtonIcon: Icon, enableSelection, selectRow, deselectRow, isRowSelected, onRowUpdated, } = useTable();
11
12
  const selected = isRowSelected(rowData);
12
13
  const handleSelectionChange = (e) => {
@@ -15,6 +16,13 @@ const TableRow = ({ rowData, rowStyle }) => {
15
16
  return (_jsxs(TR, { className: "mfui-tr", style: rowStyle, "data-key": rowData.__key, "data-selected": selected, children: [enableSelection && (_jsx(ActionCell, { className: `mfui-td column-select`, children: _jsx(InnerCellContent, { className: "mfui inner-cell-content row-action", children: _jsx(CheckBox, { className: `mfui-checkbox`, value: selected, onChange: (e) => handleSelectionChange(e) }) }) })), enableActionButton && (_jsx(ActionCell, { className: `mfui-td column-action`, children: _jsx(InnerCellContent, { className: "mfui inner-cell-content row-action", children: _jsx(ActionButton, { variant: "subtle", onClick: () => onActionButtonClick === null || onActionButtonClick === void 0 ? void 0 : onActionButtonClick(rowData), children: Icon ? _jsx(Icon, { size: 14 }) : _jsx(Maximize2Icon, { size: 14 }) }) }) })), columnState.map((column, index) => {
16
17
  if (column.visible === false)
17
18
  return null;
19
+ if (loading) {
20
+ return (_jsx(TD, { className: `mfui-td column-${column.columnId}`, "data-field": column.dataField, style: {
21
+ width: column.width,
22
+ minWidth: column.minWidth,
23
+ flex: column.width ? "0 0 auto" : "1",
24
+ }, children: _jsx(LoadingCellIndicator, {}) }, index));
25
+ }
18
26
  return (_jsxs(TD, { className: `mfui-td column-${column.columnId}`, "data-field": column.dataField, style: {
19
27
  width: column.width,
20
28
  minWidth: column.minWidth,
@@ -5,7 +5,7 @@ import useTable from "./useTable";
5
5
  import TableDefaults from "./TableDefaults";
6
6
  import TableRow from "./TableRow";
7
7
  const VirtualizedRows = ({ tableDimensions, targetElm, listElm, rowHeight, headerRowHeight }) => {
8
- const { data, compactState } = useTable();
8
+ const { data, compactState, loadingRowIds, keyField } = useTable();
9
9
  const effectiveRowHeight = compactState
10
10
  ? TableDefaults.row.height.compact
11
11
  : rowHeight
@@ -22,7 +22,7 @@ const VirtualizedRows = ({ tableDimensions, targetElm, listElm, rowHeight, heade
22
22
  }, children: ({ data, index, style }) => {
23
23
  var _a;
24
24
  const row = ((_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a[index]) || {};
25
- return (_jsx(TableRow, { rowData: row, rowStyle: Object.assign(Object.assign({}, style), { height: rowHeight }) }, index));
25
+ return (_jsx(TableRow, { rowData: row, loading: !!keyField ? loadingRowIds === null || loadingRowIds === void 0 ? void 0 : loadingRowIds.includes(row[keyField]) : false, rowStyle: Object.assign(Object.assign({}, style), { height: rowHeight }) }, index));
26
26
  } }) }));
27
27
  };
28
28
  export default VirtualizedRows;
@@ -105,6 +105,7 @@ export type TableContextType = {
105
105
  rowHeight?: number;
106
106
  virtualized?: boolean;
107
107
  loading?: boolean;
108
+ loadingRowIds?: (string | number)[];
108
109
  tableElement: MutableRefObject<HTMLDivElement | null>;
109
110
  headerRowElm: MutableRefObject<HTMLDivElement | null>;
110
111
  tableDimensions: TableDimensions;
@@ -197,6 +198,7 @@ export interface TableRowProps {
197
198
  [key: string]: any;
198
199
  };
199
200
  rowStyle?: React.CSSProperties;
201
+ loading?: boolean;
200
202
  }
201
203
  export interface OnColumnChangeProps {
202
204
  columnState: ColumnState[];
@@ -251,6 +253,7 @@ export interface TableProps {
251
253
  minHeight?: number;
252
254
  virtualized?: boolean;
253
255
  loading?: boolean;
256
+ loadingRowIds?: (string | number)[];
254
257
  compact?: boolean;
255
258
  headerRowHeight?: number;
256
259
  rowHeight?: number;
@@ -0,0 +1 @@
1
+ export declare const getPdfTextContent: (pdf: File) => Promise<string>;
@@ -0,0 +1,24 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { pdfjs } from "react-pdf";
11
+ pdfjs.GlobalWorkerOptions.workerSrc = new URL("pdfjs-dist/legacy/build/pdf.worker.min.mjs", import.meta.url).toString();
12
+ export const getPdfTextContent = (pdf) => __awaiter(void 0, void 0, void 0, function* () {
13
+ const arrayBuffer = yield pdf.arrayBuffer();
14
+ const loadingTask = pdfjs.getDocument({ data: new Uint8Array(arrayBuffer) });
15
+ const pdfDoc = yield loadingTask.promise;
16
+ let fullText = "";
17
+ for (let pageNum = 1; pageNum <= pdfDoc.numPages; pageNum++) {
18
+ const page = yield pdfDoc.getPage(pageNum);
19
+ const content = yield page.getTextContent();
20
+ const pageText = content.items.map((item) => item.str).join(" ");
21
+ fullText += `\n\nPage ${pageNum}:\n${pageText}`;
22
+ }
23
+ return fullText;
24
+ });
@@ -0,0 +1 @@
1
+ export * from "./getPdfTextContent";
@@ -0,0 +1 @@
1
+ export * from "./getPdfTextContent";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monolith-forensics/monolith-ui",
3
- "version": "1.2.111",
3
+ "version": "1.2.113",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "author": "Matt Danner (Monolith Forensics LLC)",