@parallelworks/ui 0.19.0 → 0.19.1
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/{chunks/memoryStore-CC91S5LP.js → ai/adapter/memoryStore.js} +2 -2
- package/dist/ai/adapter/mock/index.js +2 -80
- package/dist/ai/adapter/mock/mockAdapter.js +81 -0
- package/dist/ai/adapter/openai/createOpenAIStream.js +33 -0
- package/dist/ai/adapter/openai/errors.js +37 -0
- package/dist/ai/adapter/openai/index.js +5 -333
- package/dist/ai/adapter/openai/openaiAdapter.js +54 -0
- package/dist/ai/adapter/openai/responses.js +108 -0
- package/dist/ai/adapter/openai/sse.js +112 -0
- package/dist/{chunks/types-Yy0NrerF.js → ai/adapter/types.js} +1 -1
- package/dist/ai/agent/classifier.js +12 -0
- package/dist/ai/agent/diff.js +223 -0
- package/dist/ai/agent/diffHighlight.js +101 -0
- package/dist/ai/agent/permissions.js +29 -0
- package/dist/ai/agent/toolfmt.js +383 -0
- package/dist/ai/agent/transcript.js +127 -0
- package/dist/ai/components/AllocationSelector.js +56 -0
- package/dist/ai/components/AttachmentManager.js +144 -0
- package/dist/ai/components/AttachmentUpload.js +179 -0
- package/dist/ai/components/BlockedGroupBanner.js +29 -0
- package/dist/ai/components/BranchNavigator.js +57 -0
- package/dist/ai/components/ChatEmptyState.js +171 -0
- package/dist/ai/components/ChatInput.js +265 -0
- package/dist/ai/components/ChatLayout.js +15 -0
- package/dist/ai/components/ChatMessage.js +338 -0
- package/dist/ai/components/ChatMessageList.js +301 -0
- package/dist/ai/components/ChatSidebar.js +345 -0
- package/dist/ai/components/ChatThread.js +198 -0
- package/dist/ai/components/ComposerChrome.js +50 -0
- package/dist/ai/components/ComposerFrame.js +33 -0
- package/dist/ai/components/DragOverlay.js +20 -0
- package/dist/ai/components/ModelSelector.js +343 -0
- package/dist/ai/components/ShareDialog.js +260 -0
- package/dist/ai/components/SlashMenu.js +91 -0
- package/dist/ai/components/agent/ActivityLine.js +151 -0
- package/dist/ai/components/agent/AgentMessageParts.js +721 -0
- package/dist/ai/components/agent/PermissionPicker.js +38 -0
- package/dist/ai/components/attachmentKeys.js +10 -0
- package/dist/ai/core/ChatProvider.js +848 -0
- package/dist/ai/core/KeyboardShortcutsProvider.js +9 -0
- package/dist/ai/core/chatReducer.js +223 -0
- package/dist/ai/core/config.js +45 -0
- package/dist/ai/core/events.js +4 -0
- package/dist/ai/core/exportConversation.js +42 -0
- package/dist/ai/core/greeting.js +38 -0
- package/dist/ai/core/parts.js +84 -0
- package/dist/ai/core/useDragDrop.js +36 -0
- package/dist/ai/core/useKeyboardShortcuts.js +77 -0
- package/dist/ai/core/useSSEStream.js +98 -0
- package/dist/ai/index.js +43 -6644
- package/dist/ai/strings.js +175 -0
- package/dist/ai/ui/Avatar.js +35 -0
- package/dist/ai/ui/Dropdown.js +110 -0
- package/dist/ai/ui/Markdown.js +79 -0
- package/dist/ai/ui/Notice.js +77 -0
- package/dist/ai/ui/codeBreaks.js +36 -0
- package/dist/ai/ui/prose.js +13 -0
- package/dist/ai/ui/sidebar.js +148 -0
- package/dist/ai/utils.js +23 -0
- package/dist/components/AddMenu.js +46 -0
- package/dist/components/Avatar.js +46 -0
- package/dist/{chunks/BareModal-BtRiQezg.js → components/BareModal.js} +1 -1
- package/dist/components/Breadcrumbs.js +83 -0
- package/dist/components/Button.js +83 -0
- package/dist/components/Callout.js +23 -0
- package/dist/components/Card.js +31 -0
- package/dist/components/CollapsiblePanel.js +77 -0
- package/dist/{chunks/ConfirmModal-aOR4O1QE.js → components/ConfirmModal.js} +4 -9
- package/dist/components/CopyToClipboard.js +81 -0
- package/dist/{chunks/Markdown-CM-FenNE.js → components/CreateModal.js} +9 -116
- package/dist/components/DescriptionList.js +42 -0
- package/dist/components/Dropdown.js +349 -0
- package/dist/components/EmptyState.js +27 -0
- package/dist/components/Filter.js +32 -0
- package/dist/components/FilterPill.js +13 -0
- package/dist/components/IconButton.js +34 -0
- package/dist/{chunks/Indicator-hBSIxOPK.js → components/Indicator.js} +1 -1
- package/dist/components/Input.js +88 -0
- package/dist/components/LetterBadge.js +13 -0
- package/dist/components/Listbox.js +123 -0
- package/dist/{chunks/Loader-BXoXTZGc.js → components/Loader.js} +1 -1
- package/dist/components/Markdown.js +15 -0
- package/dist/components/MultiSelect.js +171 -0
- package/dist/components/Overview.js +39 -0
- package/dist/components/PageHeader.js +194 -0
- package/dist/components/Pagination.js +35 -0
- package/dist/{chunks/Provider-CDYurraE.js → components/Provider.js} +1 -1
- package/dist/{chunks/RequiredMark-DfLdYbYZ.js → components/RequiredMark.js} +1 -1
- package/dist/components/SectionHeader.js +11 -0
- package/dist/components/SettingModeOption.js +30 -0
- package/dist/components/SettingRow.js +35 -0
- package/dist/components/SettingsCard.js +31 -0
- package/dist/components/SettingsGroup.js +17 -0
- package/dist/components/Sort.js +42 -0
- package/dist/components/StatusBadge.js +63 -0
- package/dist/components/SwitchToggle.js +59 -0
- package/dist/{chunks/SwitchToggleSmall-FcsaYSTs.js → components/SwitchToggleSmall.js} +1 -1
- package/dist/{chunks/Table-DU2MW8xz.js → components/Table.js} +3 -3
- package/dist/components/Toggle.js +20 -0
- package/dist/{chunks/Tooltip-K5HJr4_p.js → components/Tooltip.js} +2 -27
- package/dist/{chunks/StatusBadge-C1Blx_cW.js → components/dropdownUtils.js} +2 -63
- package/dist/{chunks/focus-D_iZJTW1.js → components/focus.js} +1 -1
- package/dist/components/ghostButton.js +7 -0
- package/dist/components/inputClasses.js +4 -0
- package/dist/components/keys.js +27 -0
- package/dist/components/relativeTime.js +32 -0
- package/dist/{chunks/useCssIsDark-DHr05dG2.js → components/useCssIsDark.js} +1 -1
- package/dist/{chunks/duration-BOv8Phl8.js → duration.js} +1 -1
- package/dist/editor/Editor.js +13 -0
- package/dist/editor/EditorField.js +53 -0
- package/dist/editor/FormCodePanel.js +173 -0
- package/dist/{chunks/Monaco-DJ8MW-Dq.js → editor/Monaco.js} +4 -2
- package/dist/editor/index.js +6 -1
- package/dist/editor/themes.js +91 -0
- package/dist/editor/workers.js +29 -0
- package/dist/editor/yaml.js +15 -0
- package/dist/file-explorer/FileExplorer.js +1402 -0
- package/dist/file-explorer/FileExplorerContext.js +370 -0
- package/dist/{chunks/CodePreviewEditor-YqQBz1YL.js → file-explorer/FilePreview/CodePreviewEditor.js} +3 -2
- package/dist/file-explorer/FilePreview/Inline.js +45 -0
- package/dist/file-explorer/FilePreview/StreamedBadge.js +16 -0
- package/dist/file-explorer/FilePreview/Viewer.js +526 -0
- package/dist/file-explorer/FilePreview/index.js +266 -0
- package/dist/file-explorer/FilePreview/parse.js +63 -0
- package/dist/file-explorer/FilePreview/previewCache.js +98 -0
- package/dist/file-explorer/FilePreview/previewType.js +151 -0
- package/dist/file-explorer/FilePreview/readCappedBytes.js +196 -0
- package/dist/file-explorer/FilePreview/useObjectBlobUrl.js +95 -0
- package/dist/file-explorer/FilePreview/useObjectText.js +109 -0
- package/dist/file-explorer/FilePreview/usePresignedUrl.js +73 -0
- package/dist/file-explorer/FileRow.js +165 -0
- package/dist/file-explorer/FileRowsWindow.js +92 -0
- package/dist/file-explorer/FileTable.js +172 -0
- package/dist/file-explorer/FileTableHeaders.js +49 -0
- package/dist/file-explorer/LoadMoreRow.js +46 -0
- package/dist/file-explorer/TreeView.js +376 -0
- package/dist/file-explorer/helpers.js +537 -0
- package/dist/file-explorer/index.js +7 -5671
- package/dist/file-explorer/lib/batch.js +39 -0
- package/dist/file-explorer/lib/errors.js +9 -0
- package/dist/file-explorer/lib/paging.js +124 -0
- package/dist/file-explorer/lib/utils.js +322 -0
- package/dist/file-explorer/toasts.js +400 -0
- package/dist/file-explorer/treeRows.js +73 -0
- package/dist/file-explorer/useNearEnd.js +27 -0
- package/dist/form/FieldWrapper.js +54 -0
- package/dist/form/Fields/BooleanField.js +51 -0
- package/dist/form/Fields/CheckboxGroupField.js +72 -0
- package/dist/form/Fields/ColorField.js +33 -0
- package/dist/form/Fields/DropdownField.js +49 -0
- package/dist/form/Fields/DurationField.js +130 -0
- package/dist/form/Fields/LabelField.js +19 -0
- package/dist/form/Fields/MultiDropdownField.js +40 -0
- package/dist/form/Fields/NumberField.js +51 -0
- package/dist/form/Fields/ObjectField.js +54 -0
- package/dist/form/Fields/RadioField.js +49 -0
- package/dist/form/Fields/RangeField.js +58 -0
- package/dist/form/Fields/ResourceOptionIcon.js +21 -0
- package/dist/form/Fields/StepField.js +6 -0
- package/dist/form/Fields/StringField.js +37 -0
- package/dist/form/Fields/TextAreaField.js +31 -0
- package/dist/form/Fields/durationValidity.js +11 -0
- package/dist/form/Form.js +643 -0
- package/dist/form/SpecialTypes/DropdownWrapper.js +30 -0
- package/dist/form/SpecialTypes/FormikCustomDropdown.js +122 -0
- package/dist/form/SpecialTypes/FormikCustomInput.js +111 -0
- package/dist/form/SpecialTypes/FormikMultiSelectDropdown.js +31 -0
- package/dist/form/SpecialTypes/FormikNumericInput.js +60 -0
- package/dist/form/Wizard/WizardContainer.js +138 -0
- package/dist/form/Wizard/WizardNavigation.js +92 -0
- package/dist/form/Wizard/WizardStepContent.js +35 -0
- package/dist/form/Wizard/WizardStepIndicator.js +108 -0
- package/dist/form/Wizard/useWizardState.js +118 -0
- package/dist/form/Wizard/utils.js +34 -0
- package/dist/form/fieldContext.js +26 -0
- package/dist/form/fieldRegistry.js +50 -0
- package/dist/form/index.js +17 -2321
- package/dist/{chunks/FieldWrapper-Cszwg-4B.js → form/lib.js} +2 -97
- package/dist/form/useParsedOpts.js +62 -0
- package/dist/form/usePrevious.js +11 -0
- package/dist/form/utils/checkShowIfObject.js +14 -0
- package/dist/form/utils/duration.js +69 -0
- package/dist/form/utils/getParentValue.js +23 -0
- package/dist/form/utils/getPlaceholder.js +9 -0
- package/dist/form/utils/getValueUsingPath.js +23 -0
- package/dist/form/utils/secondaryField.js +22 -0
- package/dist/graph/AnnotationBanner.js +141 -0
- package/dist/graph/Collapse.js +41 -0
- package/dist/graph/DependencyGraph.js +1398 -0
- package/dist/graph/JobSummary.js +104 -0
- package/dist/graph/MatrixGroup.js +107 -0
- package/dist/graph/Reveal.js +57 -0
- package/dist/graph/TreeView.js +711 -0
- package/dist/graph/index.js +1 -2519
- package/dist/graph/types.js +6 -0
- package/dist/index.js +46 -599
- package/dist/list/ActionToolbar.js +184 -0
- package/dist/list/HoverCard.js +73 -0
- package/dist/list/ListPage.js +145 -0
- package/dist/list/ListPager.js +59 -0
- package/dist/list/ListTable.js +163 -0
- package/dist/list/ListViewControls.js +372 -0
- package/dist/list/RowContextMenu.js +350 -0
- package/dist/list/UserHoverCard.js +117 -0
- package/dist/list/index.js +11 -2
- package/dist/list/listSearch.js +137 -0
- package/dist/list/listView.js +210 -0
- package/dist/list/textEntry.js +10 -0
- package/dist/{chunks/logviewer-BTKuQWzw.js → logviewer/LogViewer.js} +4 -82
- package/dist/logviewer/index.js +2 -1
- package/dist/logviewer/segments.js +80 -0
- package/package.json +1 -1
- package/dist/chunks/PageHeader-0kG_iypP.js +0 -692
- package/dist/chunks/SwitchToggle-DShNdcao.js +0 -758
- package/dist/chunks/editor-Dk1rbV75.js +0 -361
- package/dist/chunks/list-CJm875m7.js +0 -1418
- /package/dist/{chunks/MarkdownImpl-CyeTVvSt.js → components/MarkdownImpl.js} +0 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { useSlots, useStrings } from "../components/Provider.js";
|
|
2
|
+
import { FileIcon, FolderIcon } from "../icons.js";
|
|
3
|
+
import { canPreview } from "./FilePreview/previewType.js";
|
|
4
|
+
import { getNodeIcon } from "./helpers.js";
|
|
5
|
+
import { FileRow } from "./FileRow.js";
|
|
6
|
+
import { LoadMoreRow } from "./LoadMoreRow.js";
|
|
7
|
+
import { useEffect } from "react";
|
|
8
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
//#region src/file-explorer/FileRowsWindow.tsx
|
|
10
|
+
/** `start`/`end` include scrollMargin but getTotalSize() does not, so the margin
|
|
11
|
+
* has to come back out of both. */
|
|
12
|
+
function spacerHeights(items, totalSize, scrollMargin) {
|
|
13
|
+
const first = items[0];
|
|
14
|
+
const last = items[items.length - 1];
|
|
15
|
+
if (!first || !last) return {
|
|
16
|
+
top: 0,
|
|
17
|
+
bottom: 0
|
|
18
|
+
};
|
|
19
|
+
return {
|
|
20
|
+
top: Math.max(0, first.start - scrollMargin),
|
|
21
|
+
bottom: Math.max(0, totalSize - (last.end - scrollMargin))
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/** Must stay a single child of `<Table>`: Table re-keys children by traversal
|
|
25
|
+
* index, so a count that varied with scroll position would remount every row. */
|
|
26
|
+
function FileRowsWindow({ items, padTop, padBottom, nodes, checkedItems, activeIndex, rowIdPrefix, scrollEl, loadMore, getItems, openMenu, onOpen, onToggleCheck, onPreview }) {
|
|
27
|
+
const { storageIconUrl } = useSlots();
|
|
28
|
+
const storageIconAlt = useStrings().fileExplorer.chrome.storageIconAlt;
|
|
29
|
+
useNestedScrollerWarning(scrollEl, nodes.length);
|
|
30
|
+
useRowPitchAudit(scrollEl, nodes, items);
|
|
31
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
32
|
+
padTop > 0 && /* @__PURE__ */ jsx(Spacer, { height: padTop }, "pad-top"),
|
|
33
|
+
items.map((item) => {
|
|
34
|
+
const node = nodes[item.index];
|
|
35
|
+
if (!node) return loadMore ? /* @__PURE__ */ jsx(LoadMoreRow, {
|
|
36
|
+
rowId: `${rowIdPrefix}-${item.index}`,
|
|
37
|
+
rowIndex: item.index + 2,
|
|
38
|
+
loading: loadMore.loading,
|
|
39
|
+
error: loadMore.error,
|
|
40
|
+
auto: loadMore.auto,
|
|
41
|
+
root: scrollEl,
|
|
42
|
+
onLoadMore: loadMore.onLoadMore
|
|
43
|
+
}, "load-more") : null;
|
|
44
|
+
const icon = getNodeIcon(node, storageIconUrl, storageIconAlt) ?? (node.type === "directory" ? /* @__PURE__ */ jsx(FolderIcon, { className: "h-4 w-4 text-sky-500/80" }) : /* @__PURE__ */ jsx(FileIcon, { className: "h-4 w-4 theme-muted-text" }));
|
|
45
|
+
return /* @__PURE__ */ jsx(FileRow, {
|
|
46
|
+
rowId: `${rowIdPrefix}-${item.index}`,
|
|
47
|
+
rowIndex: item.index + 2,
|
|
48
|
+
active: item.index === activeIndex,
|
|
49
|
+
node,
|
|
50
|
+
icon,
|
|
51
|
+
checked: checkedItems.has(node.path),
|
|
52
|
+
canPreview: canPreview(node),
|
|
53
|
+
getItems: () => getItems(node),
|
|
54
|
+
openMenu,
|
|
55
|
+
onOpen,
|
|
56
|
+
onToggleCheck,
|
|
57
|
+
onPreview
|
|
58
|
+
}, node.path);
|
|
59
|
+
}),
|
|
60
|
+
padBottom > 0 && /* @__PURE__ */ jsx(Spacer, { height: padBottom }, "pad-bottom")
|
|
61
|
+
] });
|
|
62
|
+
}
|
|
63
|
+
function Spacer({ height }) {
|
|
64
|
+
return /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsx("tr", {
|
|
65
|
+
"aria-hidden": "true",
|
|
66
|
+
className: "border-0",
|
|
67
|
+
children: /* @__PURE__ */ jsx("td", {
|
|
68
|
+
colSpan: 5,
|
|
69
|
+
style: {
|
|
70
|
+
height,
|
|
71
|
+
padding: 0
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
|
+
}) });
|
|
75
|
+
}
|
|
76
|
+
/** A nested overflow container stealing the scroll leaves the virtualizer at
|
|
77
|
+
* scrollTop 0 forever, rendering only the first window. */
|
|
78
|
+
function useNestedScrollerWarning(scrollEl, count) {
|
|
79
|
+
useEffect(() => {}, [scrollEl, count]);
|
|
80
|
+
}
|
|
81
|
+
/** The constants must equal the row *pitch*, not the row's own height —
|
|
82
|
+
* under border-collapse the shared border sits between rows. A 1px error
|
|
83
|
+
* compounds to 10,000px across a 10k-row directory. */
|
|
84
|
+
function useRowPitchAudit(scrollEl, nodes, items) {
|
|
85
|
+
useEffect(() => {}, [
|
|
86
|
+
scrollEl,
|
|
87
|
+
nodes,
|
|
88
|
+
items
|
|
89
|
+
]);
|
|
90
|
+
}
|
|
91
|
+
//#endregion
|
|
92
|
+
export { FileRowsWindow, spacerHeights };
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { Table } from "../components/Table.js";
|
|
2
|
+
import { listTableFixedProps } from "../list/ListTable.js";
|
|
3
|
+
import { fileRowHeight } from "./FileRow.js";
|
|
4
|
+
import { FileRowsWindow, spacerHeights } from "./FileRowsWindow.js";
|
|
5
|
+
import { FileTableHeaders } from "./FileTableHeaders.js";
|
|
6
|
+
import cx from "classnames";
|
|
7
|
+
import { useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
10
|
+
//#region src/file-explorer/FileTable.tsx
|
|
11
|
+
/** The file table. Give it a `key` of the folder path: a folder change must reset
|
|
12
|
+
* the cursor, the scroll offset and the virtualizer's measurements, and a remount
|
|
13
|
+
* does all three without a synchronising effect. */
|
|
14
|
+
function FileTable({ nodes, checkedItems, allSelected, someSelected, onSelectAll, getItems, openMenu, onOpen, onToggleCheck, onPreview, loadMore }) {
|
|
15
|
+
const [scrollEl, setScrollEl] = useState(null);
|
|
16
|
+
const [activeIndex, setActiveIndex] = useState(-1);
|
|
17
|
+
const [theadHeight, setTheadHeight] = useState(0);
|
|
18
|
+
const rowIdPrefix = useId();
|
|
19
|
+
useLayoutEffect(() => {
|
|
20
|
+
const thead = scrollEl?.querySelector("thead");
|
|
21
|
+
if (thead instanceof HTMLElement) setTheadHeight(thead.offsetHeight);
|
|
22
|
+
}, [scrollEl]);
|
|
23
|
+
const getRowKey = useCallback((index) => nodes[index]?.path ?? "load-more", [nodes]);
|
|
24
|
+
const estimateSize = useCallback((index) => {
|
|
25
|
+
const node = nodes[index];
|
|
26
|
+
return node ? fileRowHeight(node) : 45;
|
|
27
|
+
}, [nodes]);
|
|
28
|
+
const virtualizer = useVirtualizer({
|
|
29
|
+
count: nodes.length + (loadMore ? 1 : 0),
|
|
30
|
+
getScrollElement: () => scrollEl,
|
|
31
|
+
estimateSize,
|
|
32
|
+
getItemKey: getRowKey,
|
|
33
|
+
overscan: 8,
|
|
34
|
+
scrollMargin: theadHeight
|
|
35
|
+
});
|
|
36
|
+
const moveCursor = useCallback((next) => {
|
|
37
|
+
const clamped = Math.min(nodes.length - 1, Math.max(0, next));
|
|
38
|
+
setActiveIndex(clamped);
|
|
39
|
+
virtualizer.scrollToIndex(clamped);
|
|
40
|
+
}, [nodes.length, virtualizer]);
|
|
41
|
+
const handleOpen = useCallback((node) => {
|
|
42
|
+
setActiveIndex(nodes.findIndex((n) => n.path === node.path));
|
|
43
|
+
onOpen(node);
|
|
44
|
+
}, [nodes, onOpen]);
|
|
45
|
+
const rowIndexOf = useCallback((target) => {
|
|
46
|
+
const tr = target instanceof HTMLElement ? target.closest("tr") : null;
|
|
47
|
+
if (!tr?.id.startsWith(`${rowIdPrefix}-`)) return -1;
|
|
48
|
+
const index = Number(tr.id.slice(rowIdPrefix.length + 1));
|
|
49
|
+
return Number.isInteger(index) ? index : -1;
|
|
50
|
+
}, [rowIdPrefix]);
|
|
51
|
+
const handleKeyDown = useCallback((e) => {
|
|
52
|
+
if (nodes.length === 0) return;
|
|
53
|
+
const page = Math.max(1, Math.floor((scrollEl?.clientHeight ?? 0) / 45));
|
|
54
|
+
const fromRow = e.target === e.currentTarget ? -1 : rowIndexOf(e.target);
|
|
55
|
+
const from = fromRow >= 0 ? fromRow : activeIndex;
|
|
56
|
+
const step = (delta) => from < 0 ? 0 : from + delta;
|
|
57
|
+
const go = (next) => {
|
|
58
|
+
e.preventDefault();
|
|
59
|
+
if (e.target !== e.currentTarget) e.currentTarget.focus({ preventScroll: true });
|
|
60
|
+
moveCursor(next);
|
|
61
|
+
};
|
|
62
|
+
switch (e.key) {
|
|
63
|
+
case "ArrowDown":
|
|
64
|
+
go(step(1));
|
|
65
|
+
return;
|
|
66
|
+
case "ArrowUp":
|
|
67
|
+
go(step(-1));
|
|
68
|
+
return;
|
|
69
|
+
case "PageDown":
|
|
70
|
+
go(step(page));
|
|
71
|
+
return;
|
|
72
|
+
case "PageUp":
|
|
73
|
+
go(step(-page));
|
|
74
|
+
return;
|
|
75
|
+
case "Home":
|
|
76
|
+
go(0);
|
|
77
|
+
return;
|
|
78
|
+
case "End":
|
|
79
|
+
go(nodes.length - 1);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (e.target !== e.currentTarget || from < 0) return;
|
|
83
|
+
const node = nodes[from];
|
|
84
|
+
if (!node) return;
|
|
85
|
+
if (e.key === "Enter") {
|
|
86
|
+
e.preventDefault();
|
|
87
|
+
onOpen(node);
|
|
88
|
+
} else if (e.key === " ") {
|
|
89
|
+
e.preventDefault();
|
|
90
|
+
onToggleCheck(node, !checkedItems.has(node.path));
|
|
91
|
+
}
|
|
92
|
+
}, [
|
|
93
|
+
nodes,
|
|
94
|
+
activeIndex,
|
|
95
|
+
scrollEl,
|
|
96
|
+
moveCursor,
|
|
97
|
+
onOpen,
|
|
98
|
+
onToggleCheck,
|
|
99
|
+
checkedItems,
|
|
100
|
+
rowIndexOf
|
|
101
|
+
]);
|
|
102
|
+
const items = virtualizer.getVirtualItems();
|
|
103
|
+
const { top, bottom } = spacerHeights(items, virtualizer.getTotalSize(), theadHeight);
|
|
104
|
+
const incomplete = !!loadMore;
|
|
105
|
+
const anchorRef = useRef(null);
|
|
106
|
+
const wasIncomplete = useRef(incomplete);
|
|
107
|
+
const visibleStart = virtualizer.range?.startIndex;
|
|
108
|
+
useEffect(() => {
|
|
109
|
+
if (visibleStart !== void 0) anchorRef.current = nodes[visibleStart]?.path ?? null;
|
|
110
|
+
}, [visibleStart, nodes]);
|
|
111
|
+
useLayoutEffect(() => {
|
|
112
|
+
if (wasIncomplete.current && !incomplete) {
|
|
113
|
+
const index = anchorRef.current ? nodes.findIndex((node) => node.path === anchorRef.current) : -1;
|
|
114
|
+
if (index > 0) virtualizer.scrollToIndex(index, { align: "start" });
|
|
115
|
+
}
|
|
116
|
+
wasIncomplete.current = incomplete;
|
|
117
|
+
}, [
|
|
118
|
+
incomplete,
|
|
119
|
+
nodes,
|
|
120
|
+
virtualizer
|
|
121
|
+
]);
|
|
122
|
+
const activeRowId = useMemo(() => activeIndex >= 0 && items.some((i) => i.index === activeIndex) ? `${rowIdPrefix}-${activeIndex}` : void 0, [
|
|
123
|
+
activeIndex,
|
|
124
|
+
items,
|
|
125
|
+
rowIdPrefix
|
|
126
|
+
]);
|
|
127
|
+
const handleFocus = (e) => {
|
|
128
|
+
if (e.target !== e.currentTarget || activeIndex >= 0 || nodes.length === 0) return;
|
|
129
|
+
setActiveIndex(Math.min(virtualizer.range?.startIndex ?? 0, nodes.length - 1));
|
|
130
|
+
};
|
|
131
|
+
return /* @__PURE__ */ jsx("div", {
|
|
132
|
+
ref: setScrollEl,
|
|
133
|
+
className: "h-full overflow-auto",
|
|
134
|
+
children: /* @__PURE__ */ jsxs(Table, {
|
|
135
|
+
...listTableFixedProps,
|
|
136
|
+
className: cx(listTableFixedProps.className, "group/grid focus:outline-none"),
|
|
137
|
+
wrapperClassName: "overflow-x-auto",
|
|
138
|
+
tableProps: {
|
|
139
|
+
role: "grid",
|
|
140
|
+
"aria-label": "Files",
|
|
141
|
+
"aria-rowcount": loadMore ? -1 : nodes.length + 1,
|
|
142
|
+
"aria-multiselectable": true,
|
|
143
|
+
tabIndex: 0,
|
|
144
|
+
onKeyDown: handleKeyDown,
|
|
145
|
+
onFocus: handleFocus,
|
|
146
|
+
...activeRowId && { "aria-activedescendant": activeRowId }
|
|
147
|
+
},
|
|
148
|
+
children: [/* @__PURE__ */ jsx(FileTableHeaders, {
|
|
149
|
+
allSelected,
|
|
150
|
+
someSelected,
|
|
151
|
+
onSelectAll
|
|
152
|
+
}), /* @__PURE__ */ jsx(FileRowsWindow, {
|
|
153
|
+
items,
|
|
154
|
+
padTop: top,
|
|
155
|
+
padBottom: bottom,
|
|
156
|
+
nodes,
|
|
157
|
+
checkedItems,
|
|
158
|
+
activeIndex,
|
|
159
|
+
rowIdPrefix,
|
|
160
|
+
scrollEl,
|
|
161
|
+
loadMore,
|
|
162
|
+
getItems,
|
|
163
|
+
openMenu,
|
|
164
|
+
onOpen: handleOpen,
|
|
165
|
+
onToggleCheck,
|
|
166
|
+
onPreview
|
|
167
|
+
})]
|
|
168
|
+
})
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
//#endregion
|
|
172
|
+
export { FileTable };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { useStrings } from "../components/Provider.js";
|
|
2
|
+
import { Table } from "../components/Table.js";
|
|
3
|
+
import { ListActionsHeader } from "../list/ListTable.js";
|
|
4
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
//#region src/file-explorer/FileTableHeaders.tsx
|
|
6
|
+
/** Carries `isTableHeader` so `Table` hoists these into `<thead>`; a bare fragment
|
|
7
|
+
* would land in `<tbody>`, since Children.toArray only flattens arrays. */
|
|
8
|
+
function FileTableHeaders({ allSelected, someSelected, onSelectAll }) {
|
|
9
|
+
const t = useStrings().fileExplorer;
|
|
10
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
11
|
+
/* @__PURE__ */ jsx(Table.Header, {
|
|
12
|
+
caps: false,
|
|
13
|
+
className: "py-2",
|
|
14
|
+
style: { minWidth: 200 },
|
|
15
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
16
|
+
className: "flex items-center gap-2.5",
|
|
17
|
+
children: [/* @__PURE__ */ jsx("input", {
|
|
18
|
+
type: "checkbox",
|
|
19
|
+
"aria-label": t.chrome.selectAll,
|
|
20
|
+
className: "h-4 w-4 cursor-pointer rounded border-(--theme-border) text-blue-500 focus:ring-blue-500 focus:ring-offset-0",
|
|
21
|
+
ref: (el) => {
|
|
22
|
+
if (el) el.indeterminate = someSelected && !allSelected;
|
|
23
|
+
},
|
|
24
|
+
onChange: onSelectAll,
|
|
25
|
+
checked: allSelected
|
|
26
|
+
}), /* @__PURE__ */ jsx("span", { children: t.chrome.name })]
|
|
27
|
+
})
|
|
28
|
+
}),
|
|
29
|
+
/* @__PURE__ */ jsx(Table.Header, {
|
|
30
|
+
caps: false,
|
|
31
|
+
className: "w-[14%] py-2",
|
|
32
|
+
children: "Size"
|
|
33
|
+
}),
|
|
34
|
+
/* @__PURE__ */ jsx(Table.Header, {
|
|
35
|
+
caps: false,
|
|
36
|
+
className: "w-[14%] py-2",
|
|
37
|
+
children: "Type"
|
|
38
|
+
}),
|
|
39
|
+
/* @__PURE__ */ jsx(Table.Header, {
|
|
40
|
+
caps: false,
|
|
41
|
+
className: "w-[22%] py-2",
|
|
42
|
+
children: "Last Modified"
|
|
43
|
+
}),
|
|
44
|
+
/* @__PURE__ */ jsx(ListActionsHeader, { actionCount: 1 })
|
|
45
|
+
] });
|
|
46
|
+
}
|
|
47
|
+
FileTableHeaders.isTableHeader = true;
|
|
48
|
+
//#endregion
|
|
49
|
+
export { FileTableHeaders };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useStrings } from "../components/Provider.js";
|
|
2
|
+
import Loader from "../components/Loader.js";
|
|
3
|
+
import { useNearEnd } from "./useNearEnd.js";
|
|
4
|
+
import { useRef } from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
function LoadMoreRow({ rowId, rowIndex, loading, error, auto, root, onLoadMore }) {
|
|
7
|
+
const t = useStrings().fileExplorer;
|
|
8
|
+
const ref = useRef(null);
|
|
9
|
+
useNearEnd(ref, {
|
|
10
|
+
active: auto && !loading && !error,
|
|
11
|
+
root,
|
|
12
|
+
onNear: onLoadMore
|
|
13
|
+
});
|
|
14
|
+
return /* @__PURE__ */ jsx("tr", {
|
|
15
|
+
ref,
|
|
16
|
+
id: rowId,
|
|
17
|
+
"aria-rowindex": rowIndex,
|
|
18
|
+
style: { height: 45 },
|
|
19
|
+
children: /* @__PURE__ */ jsx("td", {
|
|
20
|
+
colSpan: 5,
|
|
21
|
+
className: "px-4 text-sm theme-muted-text",
|
|
22
|
+
children: error ? /* @__PURE__ */ jsxs("span", {
|
|
23
|
+
className: "flex items-center gap-2",
|
|
24
|
+
children: [/* @__PURE__ */ jsx("span", { children: error }), /* @__PURE__ */ jsx("button", {
|
|
25
|
+
type: "button",
|
|
26
|
+
className: "cursor-pointer underline theme-link",
|
|
27
|
+
onClick: onLoadMore,
|
|
28
|
+
children: t.retry
|
|
29
|
+
})]
|
|
30
|
+
}) : loading ? /* @__PURE__ */ jsxs("span", {
|
|
31
|
+
className: "flex items-center gap-2",
|
|
32
|
+
children: [/* @__PURE__ */ jsx(Loader, {
|
|
33
|
+
size: 16,
|
|
34
|
+
full: false
|
|
35
|
+
}), /* @__PURE__ */ jsx("span", { children: t.loadingMore })]
|
|
36
|
+
}) : /* @__PURE__ */ jsx("button", {
|
|
37
|
+
type: "button",
|
|
38
|
+
className: "cursor-pointer underline theme-link",
|
|
39
|
+
onClick: onLoadMore,
|
|
40
|
+
children: t.loadMore
|
|
41
|
+
})
|
|
42
|
+
})
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
export { LoadMoreRow };
|