@flamingo-stack/openframe-frontend-core 0.0.846 → 0.0.847
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-manager-table.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/file-manager/file-manager-table.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAQrD,wBAAgB,gBAAgB,CAAC,EAC/B,KAAK,EACL,aAAa,EACb,cAAqB,EACrB,OAAO,EAAE,WAAmB,EAC5B,cAAsB,EACtB,YAAY,EACZ,WAAW,EACX,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,SAAS,GACV,EAAE,qBAAqB,+
|
|
1
|
+
{"version":3,"file":"file-manager-table.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/file-manager/file-manager-table.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAQrD,wBAAgB,gBAAgB,CAAC,EAC/B,KAAK,EACL,aAAa,EACb,cAAqB,EACrB,OAAO,EAAE,WAAmB,EAC5B,cAAsB,EACtB,YAAY,EACZ,WAAW,EACX,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,SAAS,GACV,EAAE,qBAAqB,+BAuFvB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import { useMemo } from "react";
|
|
4
4
|
import { cn } from "../../../utils/cn.js";
|
|
5
5
|
import { Checkbox } from "../checkbox.js";
|
|
6
6
|
import { LoadingItems, useLoadingScope } from "../loading-scope.js";
|
|
@@ -36,99 +36,68 @@ function FileManagerTable({
|
|
|
36
36
|
const someSelected = useMemo(() => {
|
|
37
37
|
return selectedFiles.length > 0 && selectedFiles.length < files.length;
|
|
38
38
|
}, [files.length, selectedFiles.length]);
|
|
39
|
-
const containerRef = useRef(null);
|
|
40
|
-
const [measuredHeight, setTableHeight] = useState(null);
|
|
41
|
-
const tableHeight = loading || files.length === 0 ? null : measuredHeight;
|
|
42
|
-
useLayoutEffect(() => {
|
|
43
|
-
if (loading || files.length === 0) return void 0;
|
|
44
|
-
const handleResize = () => {
|
|
45
|
-
const node = containerRef.current;
|
|
46
|
-
if (!node) return;
|
|
47
|
-
const rect = node.getBoundingClientRect();
|
|
48
|
-
const availableHeight = window.innerHeight - rect.top;
|
|
49
|
-
setTableHeight(availableHeight > 0 ? availableHeight : null);
|
|
50
|
-
};
|
|
51
|
-
handleResize();
|
|
52
|
-
window.addEventListener("resize", handleResize);
|
|
53
|
-
window.addEventListener("scroll", handleResize, true);
|
|
54
|
-
const resizeObserver = new ResizeObserver(handleResize);
|
|
55
|
-
const parent = containerRef.current?.parentElement;
|
|
56
|
-
if (parent) {
|
|
57
|
-
resizeObserver.observe(parent);
|
|
58
|
-
} else if (containerRef.current) {
|
|
59
|
-
resizeObserver.observe(containerRef.current);
|
|
60
|
-
}
|
|
61
|
-
return () => {
|
|
62
|
-
window.removeEventListener("resize", handleResize);
|
|
63
|
-
window.removeEventListener("scroll", handleResize, true);
|
|
64
|
-
resizeObserver.disconnect();
|
|
65
|
-
};
|
|
66
|
-
}, [loading, files.length]);
|
|
67
39
|
const handleSelectAll = (checked) => {
|
|
68
40
|
onSelectAll?.(checked);
|
|
69
41
|
};
|
|
70
42
|
if (!loading && files.length === 0) {
|
|
71
43
|
return /* @__PURE__ */ jsx(FileManagerEmpty, {});
|
|
72
44
|
}
|
|
73
|
-
return
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
showCheckboxes && /* @__PURE__ */ jsx(
|
|
82
|
-
"div",
|
|
83
|
-
{
|
|
84
|
-
className: FILE_MANAGER_CHECKBOX_CELL_CLASS,
|
|
85
|
-
inert: loading || void 0,
|
|
86
|
-
"aria-hidden": loading || void 0,
|
|
87
|
-
children: /* @__PURE__ */ jsx(
|
|
88
|
-
Checkbox,
|
|
89
|
-
{
|
|
90
|
-
checked: allSelected || someSelected,
|
|
91
|
-
onCheckedChange: handleSelectAll,
|
|
92
|
-
boxClassName: FILE_MANAGER_CHECKBOX_BOX_CLASS
|
|
93
|
-
}
|
|
94
|
-
)
|
|
95
|
-
}
|
|
96
|
-
),
|
|
97
|
-
/* @__PURE__ */ jsx("div", { className: cn(FILE_MANAGER_NAME_CELL_CLASS, HEADER_LABEL_CLASS), children: "NAME" }),
|
|
98
|
-
/* @__PURE__ */ jsx("div", { className: cn(FILE_MANAGER_SIZE_CELL_BOX_CLASS, HEADER_LABEL_CLASS), children: "SIZE" }),
|
|
99
|
-
/* @__PURE__ */ jsx("div", { className: cn(FILE_MANAGER_MODIFIED_CELL_BOX_CLASS, HEADER_LABEL_CLASS), children: "EDITED" }),
|
|
100
|
-
/* @__PURE__ */ jsx("div", { className: FILE_MANAGER_ACTIONS_CELL_BOX_CLASS })
|
|
101
|
-
] }),
|
|
102
|
-
/* @__PURE__ */ jsx("div", { className: "flex-1 divide-y divide-ods-border overflow-auto rounded-b-lg", children: loading ? (
|
|
103
|
-
// A folder listing has no page size: a typical folder's rows, each the row's own loading form.
|
|
104
|
-
/* @__PURE__ */ jsx(LoadingItems, { count: FILE_MANAGER_SKELETON_ROWS, children: () => /* @__PURE__ */ jsx(FileManagerTableRow, { loading: true, showCheckbox: showCheckboxes, showPath: isSearchResult, "data-loading-item": true }) })
|
|
105
|
-
) : files.map((file) => /* @__PURE__ */ jsx(
|
|
106
|
-
FileManagerTableRow,
|
|
45
|
+
return (
|
|
46
|
+
// The height its parent gives it, both forms: the rows scroll inside, under the header. Not
|
|
47
|
+
// the window's: whatever is below the parent (a docked composer, a page's padding) would
|
|
48
|
+
// hide the last rows under it. A parent of no definite height lets the table grow with its rows.
|
|
49
|
+
/* @__PURE__ */ jsxs("div", { className: cn("flex h-full flex-col rounded-lg border border-ods-border bg-ods-bg", className), children: [
|
|
50
|
+
/* @__PURE__ */ jsxs("div", { className: "flex h-12 items-center rounded-t-lg border-b border-ods-border bg-ods-bg-surface px-4", children: [
|
|
51
|
+
showCheckboxes && /* @__PURE__ */ jsx(
|
|
52
|
+
"div",
|
|
107
53
|
{
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
onFolderOpen?.(file);
|
|
118
|
-
}
|
|
119
|
-
},
|
|
120
|
-
onDoubleClick: () => {
|
|
121
|
-
if (file.type === "folder" && !isSearchResult) {
|
|
122
|
-
onFolderOpen?.(file);
|
|
54
|
+
className: FILE_MANAGER_CHECKBOX_CELL_CLASS,
|
|
55
|
+
inert: loading || void 0,
|
|
56
|
+
"aria-hidden": loading || void 0,
|
|
57
|
+
children: /* @__PURE__ */ jsx(
|
|
58
|
+
Checkbox,
|
|
59
|
+
{
|
|
60
|
+
checked: allSelected || someSelected,
|
|
61
|
+
onCheckedChange: handleSelectAll,
|
|
62
|
+
boxClassName: FILE_MANAGER_CHECKBOX_BOX_CLASS
|
|
123
63
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
),
|
|
67
|
+
/* @__PURE__ */ jsx("div", { className: cn(FILE_MANAGER_NAME_CELL_CLASS, HEADER_LABEL_CLASS), children: "NAME" }),
|
|
68
|
+
/* @__PURE__ */ jsx("div", { className: cn(FILE_MANAGER_SIZE_CELL_BOX_CLASS, HEADER_LABEL_CLASS), children: "SIZE" }),
|
|
69
|
+
/* @__PURE__ */ jsx("div", { className: cn(FILE_MANAGER_MODIFIED_CELL_BOX_CLASS, HEADER_LABEL_CLASS), children: "EDITED" }),
|
|
70
|
+
/* @__PURE__ */ jsx("div", { className: FILE_MANAGER_ACTIONS_CELL_BOX_CLASS })
|
|
71
|
+
] }),
|
|
72
|
+
/* @__PURE__ */ jsx("div", { className: "flex-1 divide-y divide-ods-border overflow-auto rounded-b-lg", children: loading ? (
|
|
73
|
+
// A folder listing has no page size: a typical folder's rows, each the row's own loading form.
|
|
74
|
+
/* @__PURE__ */ jsx(LoadingItems, { count: FILE_MANAGER_SKELETON_ROWS, children: () => /* @__PURE__ */ jsx(FileManagerTableRow, { loading: true, showCheckbox: showCheckboxes, showPath: isSearchResult, "data-loading-item": true }) })
|
|
75
|
+
) : files.map((file) => /* @__PURE__ */ jsx(
|
|
76
|
+
FileManagerTableRow,
|
|
77
|
+
{
|
|
78
|
+
file,
|
|
79
|
+
isSelected: selectedFiles.includes(file.id),
|
|
80
|
+
showCheckbox: showCheckboxes,
|
|
81
|
+
showPath: isSearchResult,
|
|
82
|
+
onSelect: (selected) => onSelectFile?.(file.id, selected),
|
|
83
|
+
onClick: () => {
|
|
84
|
+
if (isSearchResult) {
|
|
85
|
+
onFileClick?.(file);
|
|
86
|
+
} else if (file.type === "folder") {
|
|
87
|
+
onFolderOpen?.(file);
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
onDoubleClick: () => {
|
|
91
|
+
if (file.type === "folder" && !isSearchResult) {
|
|
92
|
+
onFolderOpen?.(file);
|
|
93
|
+
}
|
|
127
94
|
},
|
|
128
|
-
file.id
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
95
|
+
onActionClick: (action) => onFileAction?.(action, file.id),
|
|
96
|
+
"data-loading-item": true
|
|
97
|
+
},
|
|
98
|
+
file.id
|
|
99
|
+
)) })
|
|
100
|
+
] })
|
|
132
101
|
);
|
|
133
102
|
}
|
|
134
103
|
export {
|
|
@@ -423,99 +423,68 @@ function FileManagerTable({
|
|
|
423
423
|
const someSelected = _react.useMemo.call(void 0, () => {
|
|
424
424
|
return selectedFiles.length > 0 && selectedFiles.length < files.length;
|
|
425
425
|
}, [files.length, selectedFiles.length]);
|
|
426
|
-
const containerRef = _react.useRef.call(void 0, null);
|
|
427
|
-
const [measuredHeight, setTableHeight] = _react.useState.call(void 0, null);
|
|
428
|
-
const tableHeight = loading || files.length === 0 ? null : measuredHeight;
|
|
429
|
-
_react.useLayoutEffect.call(void 0, () => {
|
|
430
|
-
if (loading || files.length === 0) return void 0;
|
|
431
|
-
const handleResize = () => {
|
|
432
|
-
const node = containerRef.current;
|
|
433
|
-
if (!node) return;
|
|
434
|
-
const rect = node.getBoundingClientRect();
|
|
435
|
-
const availableHeight = window.innerHeight - rect.top;
|
|
436
|
-
setTableHeight(availableHeight > 0 ? availableHeight : null);
|
|
437
|
-
};
|
|
438
|
-
handleResize();
|
|
439
|
-
window.addEventListener("resize", handleResize);
|
|
440
|
-
window.addEventListener("scroll", handleResize, true);
|
|
441
|
-
const resizeObserver = new ResizeObserver(handleResize);
|
|
442
|
-
const parent = _optionalChain([containerRef, 'access', _7 => _7.current, 'optionalAccess', _8 => _8.parentElement]);
|
|
443
|
-
if (parent) {
|
|
444
|
-
resizeObserver.observe(parent);
|
|
445
|
-
} else if (containerRef.current) {
|
|
446
|
-
resizeObserver.observe(containerRef.current);
|
|
447
|
-
}
|
|
448
|
-
return () => {
|
|
449
|
-
window.removeEventListener("resize", handleResize);
|
|
450
|
-
window.removeEventListener("scroll", handleResize, true);
|
|
451
|
-
resizeObserver.disconnect();
|
|
452
|
-
};
|
|
453
|
-
}, [loading, files.length]);
|
|
454
426
|
const handleSelectAll = (checked) => {
|
|
455
|
-
_optionalChain([onSelectAll, 'optionalCall',
|
|
427
|
+
_optionalChain([onSelectAll, 'optionalCall', _7 => _7(checked)]);
|
|
456
428
|
};
|
|
457
429
|
if (!loading && files.length === 0) {
|
|
458
430
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, FileManagerEmpty, {});
|
|
459
431
|
}
|
|
460
|
-
return
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
showCheckboxes && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
469
|
-
"div",
|
|
470
|
-
{
|
|
471
|
-
className: FILE_MANAGER_CHECKBOX_CELL_CLASS,
|
|
472
|
-
inert: loading || void 0,
|
|
473
|
-
"aria-hidden": loading || void 0,
|
|
474
|
-
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
475
|
-
_chunk5SZ4ILU3cjs.Checkbox,
|
|
476
|
-
{
|
|
477
|
-
checked: allSelected || someSelected,
|
|
478
|
-
onCheckedChange: handleSelectAll,
|
|
479
|
-
boxClassName: FILE_MANAGER_CHECKBOX_BOX_CLASS
|
|
480
|
-
}
|
|
481
|
-
)
|
|
482
|
-
}
|
|
483
|
-
),
|
|
484
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: _chunk63A4GZMBcjs.cn.call(void 0, FILE_MANAGER_NAME_CELL_CLASS, HEADER_LABEL_CLASS), children: "NAME" }),
|
|
485
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: _chunk63A4GZMBcjs.cn.call(void 0, FILE_MANAGER_SIZE_CELL_BOX_CLASS, HEADER_LABEL_CLASS), children: "SIZE" }),
|
|
486
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: _chunk63A4GZMBcjs.cn.call(void 0, FILE_MANAGER_MODIFIED_CELL_BOX_CLASS, HEADER_LABEL_CLASS), children: "EDITED" }),
|
|
487
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: FILE_MANAGER_ACTIONS_CELL_BOX_CLASS })
|
|
488
|
-
] }),
|
|
489
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex-1 divide-y divide-ods-border overflow-auto rounded-b-lg", children: loading ? (
|
|
490
|
-
// A folder listing has no page size: a typical folder's rows, each the row's own loading form.
|
|
491
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk63A4GZMBcjs.LoadingItems, { count: FILE_MANAGER_SKELETON_ROWS, children: () => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, FileManagerTableRow, { loading: true, showCheckbox: showCheckboxes, showPath: isSearchResult, "data-loading-item": true }) })
|
|
492
|
-
) : files.map((file) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
493
|
-
FileManagerTableRow,
|
|
432
|
+
return (
|
|
433
|
+
// The height its parent gives it, both forms: the rows scroll inside, under the header. Not
|
|
434
|
+
// the window's: whatever is below the parent (a docked composer, a page's padding) would
|
|
435
|
+
// hide the last rows under it. A parent of no definite height lets the table grow with its rows.
|
|
436
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: _chunk63A4GZMBcjs.cn.call(void 0, "flex h-full flex-col rounded-lg border border-ods-border bg-ods-bg", className), children: [
|
|
437
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex h-12 items-center rounded-t-lg border-b border-ods-border bg-ods-bg-surface px-4", children: [
|
|
438
|
+
showCheckboxes && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
439
|
+
"div",
|
|
494
440
|
{
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
_optionalChain([onFolderOpen, 'optionalCall', _12 => _12(file)]);
|
|
505
|
-
}
|
|
506
|
-
},
|
|
507
|
-
onDoubleClick: () => {
|
|
508
|
-
if (file.type === "folder" && !isSearchResult) {
|
|
509
|
-
_optionalChain([onFolderOpen, 'optionalCall', _13 => _13(file)]);
|
|
441
|
+
className: FILE_MANAGER_CHECKBOX_CELL_CLASS,
|
|
442
|
+
inert: loading || void 0,
|
|
443
|
+
"aria-hidden": loading || void 0,
|
|
444
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
445
|
+
_chunk5SZ4ILU3cjs.Checkbox,
|
|
446
|
+
{
|
|
447
|
+
checked: allSelected || someSelected,
|
|
448
|
+
onCheckedChange: handleSelectAll,
|
|
449
|
+
boxClassName: FILE_MANAGER_CHECKBOX_BOX_CLASS
|
|
510
450
|
}
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
451
|
+
)
|
|
452
|
+
}
|
|
453
|
+
),
|
|
454
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: _chunk63A4GZMBcjs.cn.call(void 0, FILE_MANAGER_NAME_CELL_CLASS, HEADER_LABEL_CLASS), children: "NAME" }),
|
|
455
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: _chunk63A4GZMBcjs.cn.call(void 0, FILE_MANAGER_SIZE_CELL_BOX_CLASS, HEADER_LABEL_CLASS), children: "SIZE" }),
|
|
456
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: _chunk63A4GZMBcjs.cn.call(void 0, FILE_MANAGER_MODIFIED_CELL_BOX_CLASS, HEADER_LABEL_CLASS), children: "EDITED" }),
|
|
457
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: FILE_MANAGER_ACTIONS_CELL_BOX_CLASS })
|
|
458
|
+
] }),
|
|
459
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex-1 divide-y divide-ods-border overflow-auto rounded-b-lg", children: loading ? (
|
|
460
|
+
// A folder listing has no page size: a typical folder's rows, each the row's own loading form.
|
|
461
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk63A4GZMBcjs.LoadingItems, { count: FILE_MANAGER_SKELETON_ROWS, children: () => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, FileManagerTableRow, { loading: true, showCheckbox: showCheckboxes, showPath: isSearchResult, "data-loading-item": true }) })
|
|
462
|
+
) : files.map((file) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
463
|
+
FileManagerTableRow,
|
|
464
|
+
{
|
|
465
|
+
file,
|
|
466
|
+
isSelected: selectedFiles.includes(file.id),
|
|
467
|
+
showCheckbox: showCheckboxes,
|
|
468
|
+
showPath: isSearchResult,
|
|
469
|
+
onSelect: (selected) => _optionalChain([onSelectFile, 'optionalCall', _8 => _8(file.id, selected)]),
|
|
470
|
+
onClick: () => {
|
|
471
|
+
if (isSearchResult) {
|
|
472
|
+
_optionalChain([onFileClick, 'optionalCall', _9 => _9(file)]);
|
|
473
|
+
} else if (file.type === "folder") {
|
|
474
|
+
_optionalChain([onFolderOpen, 'optionalCall', _10 => _10(file)]);
|
|
475
|
+
}
|
|
514
476
|
},
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
477
|
+
onDoubleClick: () => {
|
|
478
|
+
if (file.type === "folder" && !isSearchResult) {
|
|
479
|
+
_optionalChain([onFolderOpen, 'optionalCall', _11 => _11(file)]);
|
|
480
|
+
}
|
|
481
|
+
},
|
|
482
|
+
onActionClick: (action) => _optionalChain([onFileAction, 'optionalCall', _12 => _12(action, file.id)]),
|
|
483
|
+
"data-loading-item": true
|
|
484
|
+
},
|
|
485
|
+
file.id
|
|
486
|
+
)) })
|
|
487
|
+
] })
|
|
519
488
|
);
|
|
520
489
|
}
|
|
521
490
|
|
|
@@ -591,8 +560,8 @@ function FileManager({
|
|
|
591
560
|
return items;
|
|
592
561
|
}, [currentPath]);
|
|
593
562
|
const handleBreadcrumbClick = (path) => {
|
|
594
|
-
_optionalChain([onBreadcrumbClick, 'optionalCall',
|
|
595
|
-
_optionalChain([onNavigate, 'optionalCall',
|
|
563
|
+
_optionalChain([onBreadcrumbClick, 'optionalCall', _13 => _13(path)]);
|
|
564
|
+
_optionalChain([onNavigate, 'optionalCall', _14 => _14(path)]);
|
|
596
565
|
};
|
|
597
566
|
const handleFolderOpen = (file) => {
|
|
598
567
|
let newPath;
|
|
@@ -612,14 +581,14 @@ function FileManager({
|
|
|
612
581
|
newPath = currentPath + separator + file.name;
|
|
613
582
|
}
|
|
614
583
|
}
|
|
615
|
-
_optionalChain([onFolderOpen, 'optionalCall',
|
|
616
|
-
_optionalChain([onNavigate, 'optionalCall',
|
|
584
|
+
_optionalChain([onFolderOpen, 'optionalCall', _15 => _15(file)]);
|
|
585
|
+
_optionalChain([onNavigate, 'optionalCall', _16 => _16(newPath)]);
|
|
617
586
|
};
|
|
618
587
|
const handleSelectAll = (selected) => {
|
|
619
|
-
_optionalChain([onSelectAll, 'optionalCall',
|
|
588
|
+
_optionalChain([onSelectAll, 'optionalCall', _17 => _17(selected)]);
|
|
620
589
|
};
|
|
621
590
|
const handleSelectFile = (fileId, selected) => {
|
|
622
|
-
_optionalChain([onSelectFile, 'optionalCall',
|
|
591
|
+
_optionalChain([onSelectFile, 'optionalCall', _18 => _18(fileId, selected)]);
|
|
623
592
|
};
|
|
624
593
|
return (
|
|
625
594
|
// One tree in both forms (nothing remounts when the folder answers); the region says it is loading, once.
|
|
@@ -637,11 +606,11 @@ function FileManager({
|
|
|
637
606
|
{
|
|
638
607
|
canPaste,
|
|
639
608
|
hasSelection: selectedFiles.length > 0,
|
|
640
|
-
onNewFolder: () => _optionalChain([onFileAction, 'optionalCall',
|
|
641
|
-
onPaste: () => _optionalChain([onFileAction, 'optionalCall',
|
|
642
|
-
onCopy: () => _optionalChain([onFileAction, 'optionalCall',
|
|
643
|
-
onCut: () => _optionalChain([onFileAction, 'optionalCall',
|
|
644
|
-
onUpload: () => _optionalChain([onFileAction, 'optionalCall',
|
|
609
|
+
onNewFolder: () => _optionalChain([onFileAction, 'optionalCall', _19 => _19("new-folder")]),
|
|
610
|
+
onPaste: () => _optionalChain([onFileAction, 'optionalCall', _20 => _20("paste")]),
|
|
611
|
+
onCopy: () => _optionalChain([onFileAction, 'optionalCall', _21 => _21("copy")]),
|
|
612
|
+
onCut: () => _optionalChain([onFileAction, 'optionalCall', _22 => _22("cut")]),
|
|
613
|
+
onUpload: () => _optionalChain([onFileAction, 'optionalCall', _23 => _23("upload")]),
|
|
645
614
|
onSelectAll: () => handleSelectAll(true)
|
|
646
615
|
}
|
|
647
616
|
)
|
|
@@ -651,7 +620,7 @@ function FileManager({
|
|
|
651
620
|
{
|
|
652
621
|
userValue: true,
|
|
653
622
|
value: searchQuery,
|
|
654
|
-
onChange: (e) => _optionalChain([onSearch, 'optionalCall',
|
|
623
|
+
onChange: (e) => _optionalChain([onSearch, 'optionalCall', _24 => _24(e.target.value)]),
|
|
655
624
|
placeholder: "Search...",
|
|
656
625
|
disabled: disableSearch,
|
|
657
626
|
startAdornment: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkZ74QE57Tcjs.SearchIcon, {}),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
4
|
import { cn } from '../../../utils/cn';
|
|
5
5
|
import { Checkbox } from '../checkbox';
|
|
6
6
|
import { LoadingItems, useLoadingScope } from '../loading-scope';
|
|
@@ -45,45 +45,6 @@ export function FileManagerTable({
|
|
|
45
45
|
return selectedFiles.length > 0 && selectedFiles.length < files.length;
|
|
46
46
|
}, [files.length, selectedFiles.length]);
|
|
47
47
|
|
|
48
|
-
const containerRef = useRef<HTMLDivElement>(null);
|
|
49
|
-
const [measuredHeight, setTableHeight] = useState<number | null>(null);
|
|
50
|
-
// There is nothing to size while the skeleton or the empty state is showing,
|
|
51
|
-
// and that is knowable during render — masking it here means the effect no
|
|
52
|
-
// longer has to write `null` back into state (a second render pass) every
|
|
53
|
-
// time a fetch starts or a filter empties the list.
|
|
54
|
-
const tableHeight = loading || files.length === 0 ? null : measuredHeight;
|
|
55
|
-
|
|
56
|
-
useLayoutEffect(() => {
|
|
57
|
-
if (loading || files.length === 0) return undefined;
|
|
58
|
-
|
|
59
|
-
const handleResize = () => {
|
|
60
|
-
const node = containerRef.current;
|
|
61
|
-
if (!node) return;
|
|
62
|
-
const rect = node.getBoundingClientRect();
|
|
63
|
-
const availableHeight = window.innerHeight - rect.top;
|
|
64
|
-
setTableHeight(availableHeight > 0 ? availableHeight : null);
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
handleResize();
|
|
68
|
-
|
|
69
|
-
window.addEventListener('resize', handleResize);
|
|
70
|
-
window.addEventListener('scroll', handleResize, true);
|
|
71
|
-
|
|
72
|
-
const resizeObserver = new ResizeObserver(handleResize);
|
|
73
|
-
const parent = containerRef.current?.parentElement;
|
|
74
|
-
if (parent) {
|
|
75
|
-
resizeObserver.observe(parent);
|
|
76
|
-
} else if (containerRef.current) {
|
|
77
|
-
resizeObserver.observe(containerRef.current);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return () => {
|
|
81
|
-
window.removeEventListener('resize', handleResize);
|
|
82
|
-
window.removeEventListener('scroll', handleResize, true);
|
|
83
|
-
resizeObserver.disconnect();
|
|
84
|
-
};
|
|
85
|
-
}, [loading, files.length]);
|
|
86
|
-
|
|
87
48
|
const handleSelectAll = (checked: boolean) => {
|
|
88
49
|
onSelectAll?.(checked);
|
|
89
50
|
};
|
|
@@ -93,11 +54,10 @@ export function FileManagerTable({
|
|
|
93
54
|
}
|
|
94
55
|
|
|
95
56
|
return (
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
>
|
|
57
|
+
// The height its parent gives it, both forms: the rows scroll inside, under the header. Not
|
|
58
|
+
// the window's: whatever is below the parent (a docked composer, a page's padding) would
|
|
59
|
+
// hide the last rows under it. A parent of no definite height lets the table grow with its rows.
|
|
60
|
+
<div className={cn('flex h-full flex-col rounded-lg border border-ods-border bg-ods-bg', className)}>
|
|
101
61
|
{/* ONE header in both forms: the column labels are copy, and while the folder is read the select-all box is the
|
|
102
62
|
real checkbox, inert. */}
|
|
103
63
|
<div className="flex h-12 items-center rounded-t-lg border-b border-ods-border bg-ods-bg-surface px-4">
|