@monolith-forensics/monolith-ui 1.2.112 → 1.2.114
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.
|
@@ -310,14 +310,15 @@ DropDownProps = {}, debounceTime = 150, sort = false, disabled = false, }) => {
|
|
|
310
310
|
const value = e.target.value;
|
|
311
311
|
setInputValue(value || "");
|
|
312
312
|
debouncedHandleChange(value);
|
|
313
|
-
|
|
313
|
+
if (!isOpen)
|
|
314
|
+
setIsOpen(true);
|
|
314
315
|
};
|
|
315
316
|
const debouncedHandleChange = useDebouncedCallback((value) => {
|
|
316
317
|
if (searchFn) {
|
|
317
318
|
searchFn(value);
|
|
318
319
|
}
|
|
319
320
|
else {
|
|
320
|
-
|
|
321
|
+
handleSearch(value);
|
|
321
322
|
}
|
|
322
323
|
if (allowCustomValue && value) {
|
|
323
324
|
const existingItem = resolvedOptions.find((item) => item.value.toLowerCase() === value.toLowerCase());
|
|
@@ -358,6 +359,7 @@ DropDownProps = {}, debounceTime = 150, sort = false, disabled = false, }) => {
|
|
|
358
359
|
};
|
|
359
360
|
const handleChangeSelection = useCallback((option) => {
|
|
360
361
|
!isControlled.current && setValueState(option);
|
|
362
|
+
setInputValue((option === null || option === void 0 ? void 0 : option.label) || "");
|
|
361
363
|
onChange === null || onChange === void 0 ? void 0 : onChange(option === null || option === void 0 ? void 0 : option.value, option);
|
|
362
364
|
}, [onChange]);
|
|
363
365
|
const handleAddItem = useCallback((newItem) => {
|
|
@@ -398,6 +400,7 @@ DropDownProps = {}, debounceTime = 150, sort = false, disabled = false, }) => {
|
|
|
398
400
|
newItem = filteredItems[index + 1];
|
|
399
401
|
}
|
|
400
402
|
!isControlled.current && setValueState(newItem);
|
|
403
|
+
setInputValue(newItem.label || "");
|
|
401
404
|
onChange === null || onChange === void 0 ? void 0 : onChange(newItem.value, newItem);
|
|
402
405
|
return;
|
|
403
406
|
}
|
|
@@ -419,6 +422,7 @@ DropDownProps = {}, debounceTime = 150, sort = false, disabled = false, }) => {
|
|
|
419
422
|
newItem = filteredItems[index - 1];
|
|
420
423
|
}
|
|
421
424
|
!isControlled.current && setValueState(newItem);
|
|
425
|
+
setInputValue(newItem.label || "");
|
|
422
426
|
onChange === null || onChange === void 0 ? void 0 : onChange(newItem.value, newItem);
|
|
423
427
|
return;
|
|
424
428
|
}
|
|
@@ -442,6 +446,13 @@ DropDownProps = {}, debounceTime = 150, sort = false, disabled = false, }) => {
|
|
|
442
446
|
setIsOpen(true);
|
|
443
447
|
}
|
|
444
448
|
};
|
|
449
|
+
const handleSearch = (value) => {
|
|
450
|
+
if (searchable) {
|
|
451
|
+
setSearchValue(value);
|
|
452
|
+
update();
|
|
453
|
+
onSearch === null || onSearch === void 0 ? void 0 : onSearch(searchValue);
|
|
454
|
+
}
|
|
455
|
+
};
|
|
445
456
|
const referenceEl = (_b = refs === null || refs === void 0 ? void 0 : refs.reference) === null || _b === void 0 ? void 0 : _b.current;
|
|
446
457
|
const contentWidth = ((_e = (_d = (_c = referenceEl === null || referenceEl === void 0 ? void 0 : referenceEl.getClientRects) === null || _c === void 0 ? void 0 : _c.call(referenceEl)) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.width) || "100%";
|
|
447
458
|
const scrollEl = scrollContainerRef === null || scrollContainerRef === void 0 ? void 0 : scrollContainerRef.current;
|
|
@@ -471,10 +482,6 @@ DropDownProps = {}, debounceTime = 150, sort = false, disabled = false, }) => {
|
|
|
471
482
|
document.addEventListener("click", close);
|
|
472
483
|
return () => document.removeEventListener("click", close);
|
|
473
484
|
}, [refs.floating, refs.reference, handleBlur]);
|
|
474
|
-
// handle input value change
|
|
475
|
-
useEffect(() => {
|
|
476
|
-
setInputValue((_value === null || _value === void 0 ? void 0 : _value.label) || "");
|
|
477
|
-
}, [_value]);
|
|
478
485
|
// handle scroll item into view
|
|
479
486
|
useEffect(() => {
|
|
480
487
|
var _a, _b;
|
|
@@ -483,13 +490,6 @@ DropDownProps = {}, debounceTime = 150, sort = false, disabled = false, }) => {
|
|
|
483
490
|
item.scrollIntoView({ block: "nearest" });
|
|
484
491
|
}
|
|
485
492
|
}, [_value]);
|
|
486
|
-
// make calls to onSearch callback
|
|
487
|
-
useEffect(() => {
|
|
488
|
-
if (searchable) {
|
|
489
|
-
update();
|
|
490
|
-
onSearch === null || onSearch === void 0 ? void 0 : onSearch(searchValue);
|
|
491
|
-
}
|
|
492
|
-
}, [searchValue]);
|
|
493
493
|
useEffect(() => {
|
|
494
494
|
if (bottomHeight < 250) {
|
|
495
495
|
setPlacement("top-start");
|
|
@@ -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";
|