@powerhousedao/connect 1.0.19-staging.0 → 1.0.20-dev.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/.env +1 -1
- package/dist/assets/{app-B0t4z_0j.js → app-BRmEr17M.js} +8654 -3164
- package/dist/assets/app-BRmEr17M.js.map +1 -0
- package/dist/assets/{app-CDOWlDp2.css → app-BzvMUA_5.css} +118 -0
- package/dist/assets/{app-loader-DiF8OhX3.css → app-loader-DaCxVT0x.css} +134 -0
- package/dist/assets/{app-loader-C-1MIlBU.js → app-loader-_6yU4PFI.js} +522 -264
- package/dist/assets/app-loader-_6yU4PFI.js.map +1 -0
- package/dist/assets/browser--PdVaTAw.js +27234 -0
- package/dist/assets/browser--PdVaTAw.js.map +1 -0
- package/dist/assets/{ccip-CiyFdT-G.js → ccip-oTEe2poK.js} +4 -3
- package/dist/assets/ccip-oTEe2poK.js.map +1 -0
- package/dist/assets/{content-DhAAoiTj.js → content-B1Gquii9.js} +1051 -374
- package/dist/assets/content-B1Gquii9.js.map +1 -0
- package/dist/assets/{index-BYJBV0RH.js → index-C47jzF-n.js} +21 -15
- package/dist/assets/index-C47jzF-n.js.map +1 -0
- package/dist/assets/index-CXljh8x6.js +208 -0
- package/dist/assets/index-CXljh8x6.js.map +1 -0
- package/dist/assets/{index-D-cXDDE0.js → index-Csy31V2Q.js} +4 -3
- package/dist/assets/index-Csy31V2Q.js.map +1 -0
- package/dist/assets/{index-DMkr0pEM.js → index-DSo3d6TG.js} +7 -6
- package/dist/assets/index-DSo3d6TG.js.map +1 -0
- package/dist/assets/{main.DTarSVWp.js → main.CUjcRUhx.js} +2 -1
- package/dist/assets/main.CUjcRUhx.js.map +1 -0
- package/dist/assets/reactor-analytics-C7JH8QS3.js +44 -0
- package/dist/assets/reactor-analytics-C7JH8QS3.js.map +1 -0
- package/dist/assets/router-B-9X40Vx.js +1585 -0
- package/dist/assets/router-B-9X40Vx.js.map +1 -0
- package/dist/assets/{style-Ce3V83BE.css → style-BPUyhu8E.css} +3 -0
- package/dist/external-packages.js +1 -0
- package/dist/external-packages.js.map +1 -0
- package/dist/hmr.js +1 -0
- package/dist/hmr.js.map +1 -0
- package/dist/index.html +1 -1
- package/dist/service-worker.js +1 -0
- package/dist/service-worker.js.map +1 -0
- package/dist/vite-envs.sh +1 -1
- package/package.json +10 -9
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment as Fragment$1 } from "react/jsx-runtime";
|
|
2
|
-
import { t as twMerge, B as Button,
|
|
2
|
+
import { t as twMerge, B as Button, aQ as mergeClassNameProps, x as ERROR, aR as MISSING, C as CONFLICT, S as SUCCESS, aS as SYNCING, aT as INITIAL_SYNC, aU as ConnectDropdownMenu, aV as useOnClickOutside, aW as useEventListener, aX as useCopyToClipboard, aY as Select, aZ as Provider, a_ as Root3, a$ as Trigger, b0 as Portal, b1 as Content2, b2 as validateInitialState, b3 as validateStateSchemaName, b4 as validateModules, b5 as useDocumentDrives, A as useUiNodesContext, b6 as useDriveContext, b7 as FILE$1, F as useUnwrappedReactor, b8 as useConnectDid, b9 as useConnectCrypto, o as useTranslation, G as useModal, ba as useAtomValue, bb as themeAtom, bc as useUser, bd as useUserPermissions$1, p as useUiNodes, be as exportFile, bf as useGetDocumentModelModule, bg as addActionContext$1, bh as signOperation$1, e as useDocumentDriveServer, bi as useHotkeys, bj as DriveLayout, bk as DriveContextProvider, bl as SearchBar, N as useAnalyticsStore, bm as useQueryClient, u as useQuery, a6 as AnalyticsPath, bn as useAnalyticsEngine, a5 as DateTime, bo as AnalyticsGranularity, bp as useGetEditor, bq as isSameDocument, n as useNavigate, s as useAsyncReactor, br as useFilteredDocumentModels, bs as useDriveEditor, bt as useDocumentDriveById, z as useParams, q as useDocumentDrives$1, w as toast } from "./app-BRmEr17M.js";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import React__default, { useState, useCallback, useMemo, useEffect, Fragment, useRef, useLayoutEffect, memo as memo$1, createElement, useSyncExternalStore, Suspense } from "react";
|
|
5
|
-
import {
|
|
5
|
+
import { $ as Icon, bY as getDimensions, bZ as READ, b_ as nodeOptionsMap, b$ as defaultFileOptions, c0 as DELETE, c1 as RENAME, c2 as WRITE, c3 as DUPLICATE, c4 as defaultFolderOptions, c5 as garbageCollect, c6 as sortOperations, c7 as UI_NODE, aR as DRIVE, aB as FILE, ae as buildSignedOperation, ap as generateId$1, ay as isFolderNode, aD as generateNodesCopy, aE as copyNode, aC as moveNode, aA as updateNode, az as deleteNode, at as generateAddNodeAction, au as isFileNode, ax as addFolder, c8 as undo, c9 as redo, _ as logger, aS as FOLDER, ca as useDocumentDispatch$1, am as driveDocumentModelModule } from "./app-loader-_6yU4PFI.js";
|
|
6
|
+
import { E as ENSAvatar, a as ErrorBoundary } from "./router-B-9X40Vx.js";
|
|
6
7
|
import { flushSync } from "react-dom";
|
|
7
|
-
import "./main.
|
|
8
|
+
import "./main.CUjcRUhx.js";
|
|
8
9
|
const PaginationButton = ({ active = false, ...props }) => {
|
|
9
10
|
const className = twMerge("h-8 min-w-8 border border-solid border-gray-300 bg-white px-3 py-1 text-xs text-gray-900 hover:bg-gray-100", !active && "border-0");
|
|
10
11
|
return jsx(Button, { color: "light", size: "small", ...mergeClassNameProps(props, className), children: props.children });
|
|
@@ -151,131 +152,12 @@ function DefaultEditorLoader(props) {
|
|
|
151
152
|
const { message: message2 = "Loading editor", ...divProps } = props;
|
|
152
153
|
return jsx("div", { className: "grid h-full place-items-center", ...divProps, children: jsxs("div", { className: "-mt-20 grid place-items-center", children: [jsx("h3", { className: "mb-4 text-xl", children: message2 }), jsx(AnimatedLoader, {})] }) });
|
|
153
154
|
}
|
|
154
|
-
const DocumentToolbar = (props) => {
|
|
155
|
-
const { undo: undo2, canUndo, redo: redo2, canRedo, title, onClose, onExport, className, onShowRevisionHistory, onSwitchboardLinkClick, onShowTimeline } = props;
|
|
156
|
-
const isUndoDisabled = !canUndo || !undo2;
|
|
157
|
-
const isRedoDisabled = !canRedo || !redo2;
|
|
158
|
-
const isExportDisabled = !onExport;
|
|
159
|
-
const isSwitchboardLinkDisabled = !onSwitchboardLinkClick;
|
|
160
|
-
const isRevisionHistoryDisabled = !onShowRevisionHistory;
|
|
161
|
-
const isTimelineDisabled = !onShowTimeline;
|
|
162
|
-
return jsxs("div", { className: twMerge("flex h-12 w-full items-center justify-between rounded-xl border border-gray-200 bg-slate-50 px-4", className), children: [jsxs("div", { className: "flex items-center gap-x-2", children: [jsx("button", { className: twMerge("grid size-8 place-items-center rounded-lg border border-gray-200 bg-white", isUndoDisabled ? "cursor-not-allowed" : "cursor-pointer active:opacity-70"), onClick: undo2, disabled: isUndoDisabled, children: jsx(Icon, { name: "ArrowCouterclockwise", size: 16, className: isUndoDisabled ? "text-gray-500" : "text-gray-900" }) }), jsx("button", { className: twMerge("grid size-8 place-items-center rounded-lg border border-gray-200 bg-white", isRedoDisabled ? "cursor-not-allowed" : "cursor-pointer active:opacity-70"), onClick: redo2, disabled: isRedoDisabled, children: jsx("div", { className: "-scale-x-100", children: jsx(Icon, { name: "ArrowCouterclockwise", size: 16, className: isRedoDisabled ? "text-gray-500" : "text-gray-900" }) }) }), jsx("button", { className: twMerge("flex h-8 items-center rounded-lg border border-gray-200 bg-white px-3 text-sm", isExportDisabled ? "cursor-not-allowed" : "cursor-pointer active:opacity-70"), onClick: onExport, disabled: isExportDisabled, children: jsx("span", { className: isExportDisabled ? "text-gray-500" : "text-gray-900", children: "Export" }) })] }), jsx("div", { className: "flex items-center", children: jsx("h1", { className: "text-sm font-medium text-gray-500", children: title }) }), jsxs("div", { className: "flex items-center gap-x-2", children: [jsx("button", { className: twMerge("grid size-8 place-items-center rounded-lg border border-gray-200 bg-white", isSwitchboardLinkDisabled ? "cursor-not-allowed" : "cursor-pointer active:opacity-70"), onClick: onSwitchboardLinkClick, disabled: isSwitchboardLinkDisabled, children: jsx(Icon, { name: "Drive", size: 16, className: isSwitchboardLinkDisabled ? "text-gray-500" : "text-gray-900" }) }), jsx("button", { className: twMerge("grid size-8 place-items-center rounded-lg border border-gray-200 bg-white", isRevisionHistoryDisabled ? "cursor-not-allowed" : "cursor-pointer active:opacity-70"), onClick: onShowRevisionHistory, disabled: isRevisionHistoryDisabled, children: jsx(Icon, { name: "History", size: 16, className: isRevisionHistoryDisabled ? "text-gray-500" : "text-gray-900" }) }), jsx("button", { className: twMerge("grid size-8 place-items-center rounded-lg border border-gray-200 bg-white", isTimelineDisabled ? "cursor-not-allowed" : "cursor-pointer active:opacity-70"), onClick: onShowTimeline, disabled: isTimelineDisabled, children: jsx(Icon, { name: "Timeline", size: 16, className: twMerge("text-gray-900", isTimelineDisabled && "opacity-50") }) }), jsx("button", { className: "grid size-8 cursor-pointer place-items-center rounded-lg border border-gray-200 bg-white active:opacity-70", onClick: onClose, children: jsx(Icon, { name: "XmarkLight", size: 16, className: "text-gray-900" }) })] })] });
|
|
163
|
-
};
|
|
164
|
-
const syncIcons = {
|
|
165
|
-
SYNCING: "Syncing",
|
|
166
|
-
SUCCESS: "Synced",
|
|
167
|
-
CONFLICT: "Error",
|
|
168
|
-
MISSING: "Circle",
|
|
169
|
-
ERROR: "Error",
|
|
170
|
-
INITIAL_SYNC: "Syncing"
|
|
171
|
-
};
|
|
172
|
-
function SyncStatusIcon(props) {
|
|
173
|
-
const { syncStatus, className, overrideSyncIcons = {}, ...iconProps } = props;
|
|
174
|
-
const icons = { ...syncIcons, ...overrideSyncIcons };
|
|
175
|
-
const syncStatusIcons = {
|
|
176
|
-
[INITIAL_SYNC]: jsx(Icon, { size: 16, ...iconProps, className: twMerge("text-blue-900", className), name: icons[INITIAL_SYNC] }),
|
|
177
|
-
[SYNCING]: jsx(Icon, { size: 16, ...iconProps, className: twMerge("text-blue-900", className), name: icons[SYNCING] }),
|
|
178
|
-
[SUCCESS]: jsx(Icon, { size: 16, ...iconProps, className: twMerge("text-green-900", className), name: icons[SUCCESS] }),
|
|
179
|
-
[CONFLICT]: jsx(Icon, { size: 16, ...iconProps, className: twMerge("text-orange-900", className), name: icons[CONFLICT] }),
|
|
180
|
-
[MISSING]: jsx(Icon, { size: 16, ...iconProps, className: twMerge("text-red-900", className), name: icons[MISSING] }),
|
|
181
|
-
[ERROR]: jsx(Icon, { size: 16, ...iconProps, className: twMerge("text-red-900", className), name: icons[ERROR] })
|
|
182
|
-
};
|
|
183
|
-
return syncStatusIcons[syncStatus];
|
|
184
|
-
}
|
|
185
|
-
function FileItem(props) {
|
|
186
|
-
const { uiNode, className, customDocumentIconSrc, onSelectNode, onRenameNode, onDuplicateNode, onDeleteNode, isAllowedToCreateDocuments } = props;
|
|
187
|
-
const [mode, setMode] = useState(READ);
|
|
188
|
-
const [isDropdownMenuOpen, setIsDropdownMenuOpen] = useState(false);
|
|
189
|
-
const { dragProps } = useDrag({ uiNode });
|
|
190
|
-
const isReadMode = mode === READ;
|
|
191
|
-
const dropdownMenuHandlers = {
|
|
192
|
-
[DUPLICATE]: () => onDuplicateNode(uiNode),
|
|
193
|
-
[RENAME]: () => setMode(WRITE),
|
|
194
|
-
[DELETE]: () => onDeleteNode(uiNode)
|
|
195
|
-
};
|
|
196
|
-
const dropdownMenuOptions = Object.entries(nodeOptionsMap).map(([id, option]) => ({
|
|
197
|
-
...option,
|
|
198
|
-
id
|
|
199
|
-
})).filter((option) => defaultFileOptions.includes(option.id));
|
|
200
|
-
function onSubmit(name) {
|
|
201
|
-
onRenameNode(name, uiNode);
|
|
202
|
-
setMode(READ);
|
|
203
|
-
}
|
|
204
|
-
function onCancel() {
|
|
205
|
-
setMode(READ);
|
|
206
|
-
}
|
|
207
|
-
function onClick() {
|
|
208
|
-
onSelectNode(uiNode);
|
|
209
|
-
}
|
|
210
|
-
function onDropdownMenuOptionClick(itemId) {
|
|
211
|
-
const handler = dropdownMenuHandlers[itemId];
|
|
212
|
-
if (!handler) {
|
|
213
|
-
console.error(`No handler found for dropdown menu item: ${itemId}`);
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
handler();
|
|
217
|
-
setIsDropdownMenuOpen(false);
|
|
218
|
-
}
|
|
219
|
-
const iconSrc = getDocumentIconSrc(uiNode.documentType, customDocumentIconSrc);
|
|
220
|
-
const iconNode = jsxs("div", { className: "relative", children: [jsx("img", { alt: "file icon", className: "max-w-none", height: 34, src: iconSrc, width: 32 }), isReadMode && uiNode.syncStatus && jsx("div", { className: "absolute bottom-[-2px] right-0 size-3 rounded-full bg-white", children: jsx("div", { className: "absolute left-[-2px] top-[-2px]", children: jsx(SyncStatusIcon, { overrideSyncIcons: { SUCCESS: "CheckCircleFill" }, syncStatus: uiNode.syncStatus }) }) })] });
|
|
221
|
-
const containerStyles = twMerge("group flex h-12 cursor-pointer select-none items-center rounded-lg bg-gray-200 px-2 text-gray-600 hover:text-gray-800", className);
|
|
222
|
-
const content = isReadMode ? jsxs("div", { className: "flex w-52 items-center justify-between", children: [jsxs("div", { className: "mr-2 truncate group-hover:mr-0", children: [jsx("div", { className: "max-h-6 truncate text-sm font-medium group-hover:text-gray-800", children: uiNode.name }), jsx("div", { className: "max-h-6 truncate text-xs font-medium text-gray-600 group-hover:text-gray-800", children: uiNode.documentType })] }), isAllowedToCreateDocuments ? jsx(ConnectDropdownMenu, { items: dropdownMenuOptions, onItemClick: onDropdownMenuOptionClick, onOpenChange: setIsDropdownMenuOpen, open: isDropdownMenuOpen, children: jsx("button", { className: twMerge("hidden group-hover:block", isDropdownMenuOpen && "block"), onClick: (e) => {
|
|
223
|
-
e.stopPropagation();
|
|
224
|
-
setIsDropdownMenuOpen(true);
|
|
225
|
-
}, children: jsx(Icon, { className: "text-gray-600", name: "VerticalDots" }) }) }) : null] }) : jsx(NodeInput, { className: "ml-3 flex-1 font-medium", defaultValue: uiNode.name, onCancel, onSubmit });
|
|
226
|
-
return jsx("div", { className: "relative w-64", onClick, children: jsx("div", { ...dragProps, className: containerStyles, children: jsxs("div", { className: "flex items-center", children: [jsx("div", { className: "mr-1.5", children: iconNode }), content] }) }) });
|
|
227
|
-
}
|
|
228
|
-
function FolderItem(props) {
|
|
229
|
-
const { uiNode, isAllowedToCreateDocuments, className, onRenameNode, onDuplicateNode, onDeleteNode, onSelectNode, onAddFile, onCopyNode, onMoveNode } = props;
|
|
230
|
-
const [mode, setMode] = useState(READ);
|
|
231
|
-
const [isDropdownMenuOpen, setIsDropdownMenuOpen] = useState(false);
|
|
232
|
-
const { dragProps } = useDrag({ ...props, uiNode });
|
|
233
|
-
const { isDropTarget, dropProps } = useDrop({
|
|
234
|
-
uiNode,
|
|
235
|
-
onAddFile,
|
|
236
|
-
onCopyNode,
|
|
237
|
-
onMoveNode
|
|
238
|
-
});
|
|
239
|
-
const isReadMode = mode === READ;
|
|
240
|
-
function onCancel() {
|
|
241
|
-
setMode(READ);
|
|
242
|
-
}
|
|
243
|
-
function onSubmit(name) {
|
|
244
|
-
onRenameNode(name, uiNode);
|
|
245
|
-
setMode(READ);
|
|
246
|
-
}
|
|
247
|
-
function onClick() {
|
|
248
|
-
onSelectNode(uiNode);
|
|
249
|
-
}
|
|
250
|
-
const dropdownMenuHandlers = {
|
|
251
|
-
[DUPLICATE]: () => onDuplicateNode(uiNode),
|
|
252
|
-
[RENAME]: () => setMode(WRITE),
|
|
253
|
-
[DELETE]: () => onDeleteNode(uiNode)
|
|
254
|
-
};
|
|
255
|
-
const dropdownMenuOptions = Object.entries(nodeOptionsMap).map(([id, option]) => ({
|
|
256
|
-
...option,
|
|
257
|
-
id
|
|
258
|
-
})).filter((option) => defaultFolderOptions.includes(option.id));
|
|
259
|
-
function onDropdownMenuOptionClick(itemId) {
|
|
260
|
-
const handler = dropdownMenuHandlers[itemId];
|
|
261
|
-
if (!handler) {
|
|
262
|
-
console.error(`No handler found for dropdown menu item: ${itemId}`);
|
|
263
|
-
return;
|
|
264
|
-
}
|
|
265
|
-
handler();
|
|
266
|
-
setIsDropdownMenuOpen(false);
|
|
267
|
-
}
|
|
268
|
-
const content = isReadMode || !isAllowedToCreateDocuments ? jsx("div", { className: "ml-3 max-h-6 truncate font-medium text-gray-600 group-hover:text-gray-800", children: uiNode.name }) : jsx(NodeInput, { className: "ml-3 font-medium", defaultValue: uiNode.name, onCancel, onSubmit });
|
|
269
|
-
const containerStyles = twMerge("group flex h-12 cursor-pointer select-none items-center rounded-lg bg-gray-200 px-2", className, isDropTarget && "bg-blue-100");
|
|
270
|
-
return jsx("div", { className: "relative w-64", onClick, children: jsxs("div", { ...dragProps, ...dropProps, className: containerStyles, children: [jsxs("div", { className: "flex items-center overflow-hidden", children: [jsx("div", { className: "p-1", children: jsxs("div", { className: "relative", children: [jsx(Icon, { name: "FolderClose", size: 24 }), isReadMode && uiNode.syncStatus ? jsx("div", { className: "absolute bottom-[-3px] right-[-2px] size-3 rounded-full bg-white", children: jsx("div", { className: "absolute left-[-2px] top-[-2px]", children: jsx(SyncStatusIcon, { overrideSyncIcons: {
|
|
271
|
-
SUCCESS: "CheckCircleFill"
|
|
272
|
-
}, syncStatus: uiNode.syncStatus }) }) }) : null] }) }), content] }), isReadMode && isAllowedToCreateDocuments ? jsx(ConnectDropdownMenu, { items: dropdownMenuOptions, onItemClick: onDropdownMenuOptionClick, onOpenChange: setIsDropdownMenuOpen, open: isDropdownMenuOpen, children: jsx("button", { className: twMerge("ml-auto hidden group-hover:block", isDropdownMenuOpen && "block"), onClick: (e) => {
|
|
273
|
-
e.stopPropagation();
|
|
274
|
-
setIsDropdownMenuOpen(true);
|
|
275
|
-
}, children: jsx(Icon, { className: "text-gray-600", name: "VerticalDots" }) }) }) : null] }) });
|
|
276
|
-
}
|
|
277
155
|
const millisecondsInWeek = 6048e5;
|
|
278
156
|
const millisecondsInDay = 864e5;
|
|
157
|
+
const millisecondsInMinute = 6e4;
|
|
158
|
+
const millisecondsInHour = 36e5;
|
|
159
|
+
const minutesInMonth = 43200;
|
|
160
|
+
const minutesInDay = 1440;
|
|
279
161
|
const constructFromSymbol = Symbol.for("constructDateFrom");
|
|
280
162
|
function constructFrom(date, value) {
|
|
281
163
|
if (typeof date === "function") return date(value);
|
|
@@ -343,7 +225,7 @@ function getTimezoneOffsetInMilliseconds(date) {
|
|
|
343
225
|
function normalizeDates(context, ...dates) {
|
|
344
226
|
const normalize = constructFrom.bind(
|
|
345
227
|
null,
|
|
346
|
-
dates.find((date) => typeof date === "object")
|
|
228
|
+
context || dates.find((date) => typeof date === "object")
|
|
347
229
|
);
|
|
348
230
|
return dates.map(normalize);
|
|
349
231
|
}
|
|
@@ -371,12 +253,83 @@ function startOfISOWeekYear(date, options) {
|
|
|
371
253
|
fourthOfJanuary.setHours(0, 0, 0, 0);
|
|
372
254
|
return startOfISOWeek(fourthOfJanuary);
|
|
373
255
|
}
|
|
256
|
+
function compareAsc(dateLeft, dateRight) {
|
|
257
|
+
const diff = +toDate(dateLeft) - +toDate(dateRight);
|
|
258
|
+
if (diff < 0) return -1;
|
|
259
|
+
else if (diff > 0) return 1;
|
|
260
|
+
return diff;
|
|
261
|
+
}
|
|
262
|
+
function constructNow(date) {
|
|
263
|
+
return constructFrom(date, Date.now());
|
|
264
|
+
}
|
|
374
265
|
function isDate(value) {
|
|
375
266
|
return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
|
|
376
267
|
}
|
|
377
268
|
function isValid(date) {
|
|
378
269
|
return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date)));
|
|
379
270
|
}
|
|
271
|
+
function differenceInCalendarMonths(laterDate, earlierDate, options) {
|
|
272
|
+
const [laterDate_, earlierDate_] = normalizeDates(
|
|
273
|
+
options == null ? void 0 : options.in,
|
|
274
|
+
laterDate,
|
|
275
|
+
earlierDate
|
|
276
|
+
);
|
|
277
|
+
const yearsDiff = laterDate_.getFullYear() - earlierDate_.getFullYear();
|
|
278
|
+
const monthsDiff = laterDate_.getMonth() - earlierDate_.getMonth();
|
|
279
|
+
return yearsDiff * 12 + monthsDiff;
|
|
280
|
+
}
|
|
281
|
+
function getRoundingMethod(method) {
|
|
282
|
+
return (number) => {
|
|
283
|
+
const round = method ? Math[method] : Math.trunc;
|
|
284
|
+
const result = round(number);
|
|
285
|
+
return result === 0 ? 0 : result;
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
function differenceInMilliseconds(laterDate, earlierDate) {
|
|
289
|
+
return +toDate(laterDate) - +toDate(earlierDate);
|
|
290
|
+
}
|
|
291
|
+
function endOfDay(date, options) {
|
|
292
|
+
const _date = toDate(date, options == null ? void 0 : options.in);
|
|
293
|
+
_date.setHours(23, 59, 59, 999);
|
|
294
|
+
return _date;
|
|
295
|
+
}
|
|
296
|
+
function endOfMonth(date, options) {
|
|
297
|
+
const _date = toDate(date, options == null ? void 0 : options.in);
|
|
298
|
+
const month = _date.getMonth();
|
|
299
|
+
_date.setFullYear(_date.getFullYear(), month + 1, 0);
|
|
300
|
+
_date.setHours(23, 59, 59, 999);
|
|
301
|
+
return _date;
|
|
302
|
+
}
|
|
303
|
+
function isLastDayOfMonth(date, options) {
|
|
304
|
+
const _date = toDate(date, options == null ? void 0 : options.in);
|
|
305
|
+
return +endOfDay(_date, options) === +endOfMonth(_date, options);
|
|
306
|
+
}
|
|
307
|
+
function differenceInMonths(laterDate, earlierDate, options) {
|
|
308
|
+
const [laterDate_, workingLaterDate, earlierDate_] = normalizeDates(
|
|
309
|
+
options == null ? void 0 : options.in,
|
|
310
|
+
laterDate,
|
|
311
|
+
laterDate,
|
|
312
|
+
earlierDate
|
|
313
|
+
);
|
|
314
|
+
const sign = compareAsc(workingLaterDate, earlierDate_);
|
|
315
|
+
const difference = Math.abs(
|
|
316
|
+
differenceInCalendarMonths(workingLaterDate, earlierDate_)
|
|
317
|
+
);
|
|
318
|
+
if (difference < 1) return 0;
|
|
319
|
+
if (workingLaterDate.getMonth() === 1 && workingLaterDate.getDate() > 27)
|
|
320
|
+
workingLaterDate.setDate(30);
|
|
321
|
+
workingLaterDate.setMonth(workingLaterDate.getMonth() - sign * difference);
|
|
322
|
+
let isLastMonthNotFull = compareAsc(workingLaterDate, earlierDate_) === -sign;
|
|
323
|
+
if (isLastDayOfMonth(laterDate_) && difference === 1 && compareAsc(laterDate_, earlierDate_) === 1) {
|
|
324
|
+
isLastMonthNotFull = false;
|
|
325
|
+
}
|
|
326
|
+
const result = sign * (difference - +isLastMonthNotFull);
|
|
327
|
+
return result === 0 ? 0 : result;
|
|
328
|
+
}
|
|
329
|
+
function differenceInSeconds(laterDate, earlierDate, options) {
|
|
330
|
+
const diff = differenceInMilliseconds(laterDate, earlierDate) / 1e3;
|
|
331
|
+
return getRoundingMethod(options == null ? void 0 : options.roundingMethod)(diff);
|
|
332
|
+
}
|
|
380
333
|
function startOfYear(date, options) {
|
|
381
334
|
const date_ = toDate(date, options == null ? void 0 : options.in);
|
|
382
335
|
date_.setFullYear(date_.getFullYear(), 0, 1);
|
|
@@ -446,7 +399,7 @@ const formatDistanceLocale = {
|
|
|
446
399
|
other: "almost {{count}} years"
|
|
447
400
|
}
|
|
448
401
|
};
|
|
449
|
-
const formatDistance = (token, count, options) => {
|
|
402
|
+
const formatDistance$1 = (token, count, options) => {
|
|
450
403
|
let result;
|
|
451
404
|
const tokenValue = formatDistanceLocale[token];
|
|
452
405
|
if (typeof tokenValue === "string") {
|
|
@@ -862,7 +815,7 @@ const match = {
|
|
|
862
815
|
};
|
|
863
816
|
const enUS = {
|
|
864
817
|
code: "en-US",
|
|
865
|
-
formatDistance,
|
|
818
|
+
formatDistance: formatDistance$1,
|
|
866
819
|
formatLong,
|
|
867
820
|
formatRelative,
|
|
868
821
|
localize,
|
|
@@ -1764,75 +1717,574 @@ function cleanEscapedString(input) {
|
|
|
1764
1717
|
}
|
|
1765
1718
|
return matched[1].replace(doubleQuoteRegExp, "'");
|
|
1766
1719
|
}
|
|
1767
|
-
function
|
|
1768
|
-
const
|
|
1769
|
-
const
|
|
1770
|
-
const
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1720
|
+
function formatDistance(laterDate, earlierDate, options) {
|
|
1721
|
+
const defaultOptions2 = getDefaultOptions();
|
|
1722
|
+
const locale = (options == null ? void 0 : options.locale) ?? defaultOptions2.locale ?? enUS;
|
|
1723
|
+
const minutesInAlmostTwoDays = 2520;
|
|
1724
|
+
const comparison = compareAsc(laterDate, earlierDate);
|
|
1725
|
+
if (isNaN(comparison)) throw new RangeError("Invalid time value");
|
|
1726
|
+
const localizeOptions = Object.assign({}, options, {
|
|
1727
|
+
addSuffix: options == null ? void 0 : options.addSuffix,
|
|
1728
|
+
comparison
|
|
1729
|
+
});
|
|
1730
|
+
const [laterDate_, earlierDate_] = normalizeDates(
|
|
1731
|
+
options == null ? void 0 : options.in,
|
|
1732
|
+
...comparison > 0 ? [earlierDate, laterDate] : [laterDate, earlierDate]
|
|
1733
|
+
);
|
|
1734
|
+
const seconds = differenceInSeconds(earlierDate_, laterDate_);
|
|
1735
|
+
const offsetInSeconds = (getTimezoneOffsetInMilliseconds(earlierDate_) - getTimezoneOffsetInMilliseconds(laterDate_)) / 1e3;
|
|
1736
|
+
const minutes = Math.round((seconds - offsetInSeconds) / 60);
|
|
1737
|
+
let months;
|
|
1738
|
+
if (minutes < 2) {
|
|
1739
|
+
if (options == null ? void 0 : options.includeSeconds) {
|
|
1740
|
+
if (seconds < 5) {
|
|
1741
|
+
return locale.formatDistance("lessThanXSeconds", 5, localizeOptions);
|
|
1742
|
+
} else if (seconds < 10) {
|
|
1743
|
+
return locale.formatDistance("lessThanXSeconds", 10, localizeOptions);
|
|
1744
|
+
} else if (seconds < 20) {
|
|
1745
|
+
return locale.formatDistance("lessThanXSeconds", 20, localizeOptions);
|
|
1746
|
+
} else if (seconds < 40) {
|
|
1747
|
+
return locale.formatDistance("halfAMinute", 0, localizeOptions);
|
|
1748
|
+
} else if (seconds < 60) {
|
|
1749
|
+
return locale.formatDistance("lessThanXMinutes", 1, localizeOptions);
|
|
1750
|
+
} else {
|
|
1751
|
+
return locale.formatDistance("xMinutes", 1, localizeOptions);
|
|
1752
|
+
}
|
|
1753
|
+
} else {
|
|
1754
|
+
if (minutes === 0) {
|
|
1755
|
+
return locale.formatDistance("lessThanXMinutes", 1, localizeOptions);
|
|
1756
|
+
} else {
|
|
1757
|
+
return locale.formatDistance("xMinutes", minutes, localizeOptions);
|
|
1758
|
+
}
|
|
1775
1759
|
}
|
|
1776
|
-
|
|
1777
|
-
|
|
1760
|
+
} else if (minutes < 45) {
|
|
1761
|
+
return locale.formatDistance("xMinutes", minutes, localizeOptions);
|
|
1762
|
+
} else if (minutes < 90) {
|
|
1763
|
+
return locale.formatDistance("aboutXHours", 1, localizeOptions);
|
|
1764
|
+
} else if (minutes < minutesInDay) {
|
|
1765
|
+
const hours = Math.round(minutes / 60);
|
|
1766
|
+
return locale.formatDistance("aboutXHours", hours, localizeOptions);
|
|
1767
|
+
} else if (minutes < minutesInAlmostTwoDays) {
|
|
1768
|
+
return locale.formatDistance("xDays", 1, localizeOptions);
|
|
1769
|
+
} else if (minutes < minutesInMonth) {
|
|
1770
|
+
const days = Math.round(minutes / minutesInDay);
|
|
1771
|
+
return locale.formatDistance("xDays", days, localizeOptions);
|
|
1772
|
+
} else if (minutes < minutesInMonth * 2) {
|
|
1773
|
+
months = Math.round(minutes / minutesInMonth);
|
|
1774
|
+
return locale.formatDistance("aboutXMonths", months, localizeOptions);
|
|
1775
|
+
}
|
|
1776
|
+
months = differenceInMonths(earlierDate_, laterDate_);
|
|
1777
|
+
if (months < 12) {
|
|
1778
|
+
const nearestMonth = Math.round(minutes / minutesInMonth);
|
|
1779
|
+
return locale.formatDistance("xMonths", nearestMonth, localizeOptions);
|
|
1780
|
+
} else {
|
|
1781
|
+
const monthsSinceStartOfYear = months % 12;
|
|
1782
|
+
const years = Math.trunc(months / 12);
|
|
1783
|
+
if (monthsSinceStartOfYear < 3) {
|
|
1784
|
+
return locale.formatDistance("aboutXYears", years, localizeOptions);
|
|
1785
|
+
} else if (monthsSinceStartOfYear < 9) {
|
|
1786
|
+
return locale.formatDistance("overXYears", years, localizeOptions);
|
|
1787
|
+
} else {
|
|
1788
|
+
return locale.formatDistance("almostXYears", years + 1, localizeOptions);
|
|
1778
1789
|
}
|
|
1779
|
-
}
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
function formatDistanceToNow(date, options) {
|
|
1793
|
+
return formatDistance(date, constructNow(date), options);
|
|
1794
|
+
}
|
|
1795
|
+
function parseISO(argument, options) {
|
|
1796
|
+
const invalidDate = () => constructFrom(options == null ? void 0 : options.in, NaN);
|
|
1797
|
+
const additionalDigits = 2;
|
|
1798
|
+
const dateStrings = splitDateString(argument);
|
|
1799
|
+
let date;
|
|
1800
|
+
if (dateStrings.date) {
|
|
1801
|
+
const parseYearResult = parseYear(dateStrings.date, additionalDigits);
|
|
1802
|
+
date = parseDate(parseYearResult.restDateString, parseYearResult.year);
|
|
1803
|
+
}
|
|
1804
|
+
if (!date || isNaN(+date)) return invalidDate();
|
|
1805
|
+
const timestamp = +date;
|
|
1806
|
+
let time = 0;
|
|
1807
|
+
let offset;
|
|
1808
|
+
if (dateStrings.time) {
|
|
1809
|
+
time = parseTime(dateStrings.time);
|
|
1810
|
+
if (isNaN(time)) return invalidDate();
|
|
1811
|
+
}
|
|
1812
|
+
if (dateStrings.timezone) {
|
|
1813
|
+
offset = parseTimezone(dateStrings.timezone);
|
|
1814
|
+
if (isNaN(offset)) return invalidDate();
|
|
1815
|
+
} else {
|
|
1816
|
+
const tmpDate = new Date(timestamp + time);
|
|
1817
|
+
const result = toDate(0, options == null ? void 0 : options.in);
|
|
1818
|
+
result.setFullYear(
|
|
1819
|
+
tmpDate.getUTCFullYear(),
|
|
1820
|
+
tmpDate.getUTCMonth(),
|
|
1821
|
+
tmpDate.getUTCDate()
|
|
1822
|
+
);
|
|
1823
|
+
result.setHours(
|
|
1824
|
+
tmpDate.getUTCHours(),
|
|
1825
|
+
tmpDate.getUTCMinutes(),
|
|
1826
|
+
tmpDate.getUTCSeconds(),
|
|
1827
|
+
tmpDate.getUTCMilliseconds()
|
|
1828
|
+
);
|
|
1829
|
+
return result;
|
|
1830
|
+
}
|
|
1831
|
+
return toDate(timestamp + time + offset, options == null ? void 0 : options.in);
|
|
1832
|
+
}
|
|
1833
|
+
const patterns = {
|
|
1834
|
+
dateTimeDelimiter: /[T ]/,
|
|
1835
|
+
timeZoneDelimiter: /[Z ]/i,
|
|
1836
|
+
timezone: /([Z+-].*)$/
|
|
1837
|
+
};
|
|
1838
|
+
const dateRegex = /^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/;
|
|
1839
|
+
const timeRegex = /^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/;
|
|
1840
|
+
const timezoneRegex = /^([+-])(\d{2})(?::?(\d{2}))?$/;
|
|
1841
|
+
function splitDateString(dateString) {
|
|
1842
|
+
const dateStrings = {};
|
|
1843
|
+
const array = dateString.split(patterns.dateTimeDelimiter);
|
|
1844
|
+
let timeString;
|
|
1845
|
+
if (array.length > 2) {
|
|
1846
|
+
return dateStrings;
|
|
1847
|
+
}
|
|
1848
|
+
if (/:/.test(array[0])) {
|
|
1849
|
+
timeString = array[0];
|
|
1850
|
+
} else {
|
|
1851
|
+
dateStrings.date = array[0];
|
|
1852
|
+
timeString = array[1];
|
|
1853
|
+
if (patterns.timeZoneDelimiter.test(dateStrings.date)) {
|
|
1854
|
+
dateStrings.date = dateString.split(patterns.timeZoneDelimiter)[0];
|
|
1855
|
+
timeString = dateString.substr(
|
|
1856
|
+
dateStrings.date.length,
|
|
1857
|
+
dateString.length
|
|
1858
|
+
);
|
|
1791
1859
|
}
|
|
1792
1860
|
}
|
|
1793
|
-
|
|
1861
|
+
if (timeString) {
|
|
1862
|
+
const token = patterns.timezone.exec(timeString);
|
|
1863
|
+
if (token) {
|
|
1864
|
+
dateStrings.time = timeString.replace(token[1], "");
|
|
1865
|
+
dateStrings.timezone = token[1];
|
|
1866
|
+
} else {
|
|
1867
|
+
dateStrings.time = timeString;
|
|
1868
|
+
}
|
|
1869
|
+
}
|
|
1870
|
+
return dateStrings;
|
|
1794
1871
|
}
|
|
1795
|
-
function
|
|
1796
|
-
const
|
|
1797
|
-
|
|
1872
|
+
function parseYear(dateString, additionalDigits) {
|
|
1873
|
+
const regex = new RegExp(
|
|
1874
|
+
"^(?:(\\d{4}|[+-]\\d{" + (4 + additionalDigits) + "})|(\\d{2}|[+-]\\d{" + (2 + additionalDigits) + "})$)"
|
|
1875
|
+
);
|
|
1876
|
+
const captures = dateString.match(regex);
|
|
1877
|
+
if (!captures) return { year: NaN, restDateString: "" };
|
|
1878
|
+
const year = captures[1] ? parseInt(captures[1]) : null;
|
|
1879
|
+
const century = captures[2] ? parseInt(captures[2]) : null;
|
|
1880
|
+
return {
|
|
1881
|
+
year: century === null ? year : century * 100,
|
|
1882
|
+
restDateString: dateString.slice((captures[1] || captures[2]).length)
|
|
1883
|
+
};
|
|
1798
1884
|
}
|
|
1799
|
-
function
|
|
1800
|
-
|
|
1801
|
-
const
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1885
|
+
function parseDate(dateString, year) {
|
|
1886
|
+
if (year === null) return /* @__PURE__ */ new Date(NaN);
|
|
1887
|
+
const captures = dateString.match(dateRegex);
|
|
1888
|
+
if (!captures) return /* @__PURE__ */ new Date(NaN);
|
|
1889
|
+
const isWeekDate = !!captures[4];
|
|
1890
|
+
const dayOfYear = parseDateUnit(captures[1]);
|
|
1891
|
+
const month = parseDateUnit(captures[2]) - 1;
|
|
1892
|
+
const day = parseDateUnit(captures[3]);
|
|
1893
|
+
const week = parseDateUnit(captures[4]);
|
|
1894
|
+
const dayOfWeek = parseDateUnit(captures[5]) - 1;
|
|
1895
|
+
if (isWeekDate) {
|
|
1896
|
+
if (!validateWeekDate(year, week, dayOfWeek)) {
|
|
1897
|
+
return /* @__PURE__ */ new Date(NaN);
|
|
1898
|
+
}
|
|
1899
|
+
return dayOfISOWeekYear(year, week, dayOfWeek);
|
|
1900
|
+
} else {
|
|
1901
|
+
const date = /* @__PURE__ */ new Date(0);
|
|
1902
|
+
if (!validateDate(year, month, day) || !validateDayOfYearDate(year, dayOfYear)) {
|
|
1903
|
+
return /* @__PURE__ */ new Date(NaN);
|
|
1904
|
+
}
|
|
1905
|
+
date.setUTCFullYear(year, month, Math.max(dayOfYear, day));
|
|
1906
|
+
return date;
|
|
1808
1907
|
}
|
|
1809
|
-
return jsxs("button", { className: "flex h-8 items-center gap-1 rounded-lg bg-slate-50 pl-1 pr-2 text-xs text-slate-100", onClick: handleCopy(docId), children: [jsx(Icon, { name: "Link" }), "DOC ID", jsx("span", { className: "text-gray-900", children: docId })] });
|
|
1810
1908
|
}
|
|
1811
|
-
function
|
|
1812
|
-
|
|
1813
|
-
const items = [
|
|
1814
|
-
{ displayValue: "Global scope", value: "global" },
|
|
1815
|
-
{ displayValue: "Local scope", value: "local" }
|
|
1816
|
-
];
|
|
1817
|
-
return jsx(Select, { absolutePositionMenu: true, containerClassName: "bg-slate-50 text-gray-500 rounded-lg w-fit text-xs z-10", id: "scope select", itemClassName: "py-2 text-gray-500 grid grid-cols-[auto,auto] gap-1", items, menuClassName: "min-w-0 text-gray-500", onChange, value });
|
|
1909
|
+
function parseDateUnit(value) {
|
|
1910
|
+
return value ? parseInt(value) : 1;
|
|
1818
1911
|
}
|
|
1819
|
-
function
|
|
1820
|
-
const
|
|
1821
|
-
|
|
1912
|
+
function parseTime(timeString) {
|
|
1913
|
+
const captures = timeString.match(timeRegex);
|
|
1914
|
+
if (!captures) return NaN;
|
|
1915
|
+
const hours = parseTimeUnit(captures[1]);
|
|
1916
|
+
const minutes = parseTimeUnit(captures[2]);
|
|
1917
|
+
const seconds = parseTimeUnit(captures[3]);
|
|
1918
|
+
if (!validateTime(hours, minutes, seconds)) {
|
|
1919
|
+
return NaN;
|
|
1920
|
+
}
|
|
1921
|
+
return hours * millisecondsInHour + minutes * millisecondsInMinute + seconds * 1e3;
|
|
1822
1922
|
}
|
|
1823
|
-
function
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1923
|
+
function parseTimeUnit(value) {
|
|
1924
|
+
return value && parseFloat(value.replace(",", ".")) || 0;
|
|
1925
|
+
}
|
|
1926
|
+
function parseTimezone(timezoneString) {
|
|
1927
|
+
if (timezoneString === "Z") return 0;
|
|
1928
|
+
const captures = timezoneString.match(timezoneRegex);
|
|
1929
|
+
if (!captures) return 0;
|
|
1930
|
+
const sign = captures[1] === "+" ? -1 : 1;
|
|
1931
|
+
const hours = parseInt(captures[2]);
|
|
1932
|
+
const minutes = captures[3] && parseInt(captures[3]) || 0;
|
|
1933
|
+
if (!validateTimezone(hours, minutes)) {
|
|
1934
|
+
return NaN;
|
|
1935
|
+
}
|
|
1936
|
+
return sign * (hours * millisecondsInHour + minutes * millisecondsInMinute);
|
|
1937
|
+
}
|
|
1938
|
+
function dayOfISOWeekYear(isoWeekYear, week, day) {
|
|
1939
|
+
const date = /* @__PURE__ */ new Date(0);
|
|
1940
|
+
date.setUTCFullYear(isoWeekYear, 0, 4);
|
|
1941
|
+
const fourthOfJanuaryDay = date.getUTCDay() || 7;
|
|
1942
|
+
const diff = (week - 1) * 7 + day + 1 - fourthOfJanuaryDay;
|
|
1943
|
+
date.setUTCDate(date.getUTCDate() + diff);
|
|
1944
|
+
return date;
|
|
1945
|
+
}
|
|
1946
|
+
const daysInMonths = [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
1947
|
+
function isLeapYearIndex(year) {
|
|
1948
|
+
return year % 400 === 0 || year % 4 === 0 && year % 100 !== 0;
|
|
1949
|
+
}
|
|
1950
|
+
function validateDate(year, month, date) {
|
|
1951
|
+
return month >= 0 && month <= 11 && date >= 1 && date <= (daysInMonths[month] || (isLeapYearIndex(year) ? 29 : 28));
|
|
1952
|
+
}
|
|
1953
|
+
function validateDayOfYearDate(year, dayOfYear) {
|
|
1954
|
+
return dayOfYear >= 1 && dayOfYear <= (isLeapYearIndex(year) ? 366 : 365);
|
|
1955
|
+
}
|
|
1956
|
+
function validateWeekDate(_year, week, day) {
|
|
1957
|
+
return week >= 1 && week <= 53 && day >= 0 && day <= 6;
|
|
1958
|
+
}
|
|
1959
|
+
function validateTime(hours, minutes, seconds) {
|
|
1960
|
+
if (hours === 24) {
|
|
1961
|
+
return minutes === 0 && seconds === 0;
|
|
1962
|
+
}
|
|
1963
|
+
return seconds >= 0 && seconds < 60 && minutes >= 0 && minutes < 60 && hours >= 0 && hours < 25;
|
|
1964
|
+
}
|
|
1965
|
+
function validateTimezone(_hours, minutes) {
|
|
1966
|
+
return minutes >= 0 && minutes <= 59;
|
|
1967
|
+
}
|
|
1968
|
+
const HDivider = (props) => {
|
|
1969
|
+
const { className, timestamp, title, subtitle, onClick, isSelected = false } = props;
|
|
1970
|
+
const [open, setOpen] = useState(false);
|
|
1971
|
+
const hasContent = !!title || !!subtitle || !!timestamp;
|
|
1972
|
+
useEffect(() => {
|
|
1973
|
+
if (open) {
|
|
1974
|
+
setOpen(false);
|
|
1975
|
+
setTimeout(() => hasContent && setOpen(true), 50);
|
|
1834
1976
|
}
|
|
1835
|
-
|
|
1977
|
+
}, [title, subtitle, timestamp, hasContent]);
|
|
1978
|
+
const formatTimestamp2 = (isoString) => {
|
|
1979
|
+
if (!isoString)
|
|
1980
|
+
return "";
|
|
1981
|
+
try {
|
|
1982
|
+
return formatDistanceToNow(new Date(isoString), { addSuffix: true });
|
|
1983
|
+
} catch {
|
|
1984
|
+
return isoString;
|
|
1985
|
+
}
|
|
1986
|
+
};
|
|
1987
|
+
const tooltipContent = jsxs("div", { className: "flex flex-col text-xs", children: [!!title && jsx("div", { children: title }), !!subtitle && jsx("div", { className: "text-gray-300", children: subtitle }), !!timestamp && jsx("div", { children: formatTimestamp2(timestamp) })] });
|
|
1988
|
+
const handleMouseEnter = () => {
|
|
1989
|
+
if (hasContent) {
|
|
1990
|
+
setOpen(true);
|
|
1991
|
+
}
|
|
1992
|
+
};
|
|
1993
|
+
const handleMouseLeave = () => {
|
|
1994
|
+
setOpen(false);
|
|
1995
|
+
};
|
|
1996
|
+
return jsxs("div", { className: "relative", onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, children: [isSelected && jsx(Icon, { name: "TimelineCaret", color: "#4EA9FF", size: 10, className: "absolute top-[-11px] z-40" }), jsx(Tooltip, { className: "rounded-md bg-gray-900 text-white", content: tooltipContent, open: open && hasContent, onOpenChange: setOpen, delayDuration: 0, side: "bottom", sideOffset: 5, children: jsx("div", { className: twMerge("mx-0.5 flex h-[25px] w-1.5 cursor-pointer flex-col items-center justify-center rounded-[2px] hover:bg-blue-300", isSelected && "bg-blue-300", className), onClick, "data-title": title, "data-subtitle": subtitle, "data-timestamp": timestamp, children: jsx("div", { className: "h-0.5 w-1 rounded-full bg-gray-500" }) }) })] });
|
|
1997
|
+
};
|
|
1998
|
+
const getBarHeight = (size = 0) => {
|
|
1999
|
+
switch (true) {
|
|
2000
|
+
case size <= 0:
|
|
2001
|
+
return "h-[1px]";
|
|
2002
|
+
case size === 1:
|
|
2003
|
+
return "h-[3px]";
|
|
2004
|
+
case size === 2:
|
|
2005
|
+
return "h-[6px]";
|
|
2006
|
+
case size === 3:
|
|
2007
|
+
return "h-[9px]";
|
|
2008
|
+
case size >= 4:
|
|
2009
|
+
return "h-[12px]";
|
|
2010
|
+
default:
|
|
2011
|
+
return "h-[1px]";
|
|
2012
|
+
}
|
|
2013
|
+
};
|
|
2014
|
+
const formatTimestamp = (isoString) => {
|
|
2015
|
+
if (!isoString)
|
|
2016
|
+
return "";
|
|
2017
|
+
try {
|
|
2018
|
+
const date = parseISO(isoString);
|
|
2019
|
+
return format(date, "HH:mm, dd, MMMM");
|
|
2020
|
+
} catch {
|
|
2021
|
+
return isoString;
|
|
2022
|
+
}
|
|
2023
|
+
};
|
|
2024
|
+
const TimelineBar = ({ onClick, className, timestamp, additions, deletions, addSize = 0, delSize = 0, isSelected = false }) => {
|
|
2025
|
+
const [open, setOpen] = useState(false);
|
|
2026
|
+
const noChanges = addSize === 0 && delSize === 0;
|
|
2027
|
+
const addBarHeight = getBarHeight(addSize);
|
|
2028
|
+
const delBarHeight = getBarHeight(delSize);
|
|
2029
|
+
const tooltipContent = jsxs("div", { className: "flex flex-col text-xs", children: [jsx("div", { children: formatTimestamp(timestamp) }), jsx("div", { className: "text-green-900", children: `${additions} additions +` }), jsx("div", { className: "text-red-700", children: `${deletions} deletions -` })] });
|
|
2030
|
+
const handleMouseEnter = () => {
|
|
2031
|
+
if (!noChanges) {
|
|
2032
|
+
setOpen(true);
|
|
2033
|
+
}
|
|
2034
|
+
};
|
|
2035
|
+
const handleMouseLeave = () => {
|
|
2036
|
+
setOpen(false);
|
|
2037
|
+
};
|
|
2038
|
+
return jsxs("div", { className: "relative", onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, children: [isSelected && jsx(Icon, { name: "TimelineCaret", color: "#4EA9FF", size: 10, className: "absolute left-[-2px] top-[-11px] z-40" }), noChanges ? jsx("div", { className: twMerge("flex h-[25px] w-1.5 cursor-pointer flex-col items-center justify-center rounded-[2px] hover:bg-blue-300", className), "data-timestamp": timestamp, onClick, children: jsx("div", { className: "size-[3px] rounded-full bg-gray-500" }) }) : jsx(Tooltip, { className: "rounded-md bg-gray-900 text-white", content: tooltipContent, open, onOpenChange: setOpen, delayDuration: 0, side: "bottom", sideOffset: 5, children: jsxs("div", { className: twMerge("flex h-[25px] w-1.5 cursor-pointer flex-col items-center justify-center rounded-[2px] hover:bg-blue-300", className, isSelected && "bg-blue-300"), "data-timestamp": timestamp, onClick, children: [jsx("div", { className: "flex h-3 w-0.5 items-end", children: jsx("div", { className: twMerge("h-3 w-0.5 rounded-t-full bg-green-600", addBarHeight) }) }), jsx("div", { className: "flex h-3 w-0.5 items-start", children: jsx("div", { className: twMerge("h-3 w-0.5 rounded-b-full bg-red-600", delBarHeight) }) })] }) })] });
|
|
2039
|
+
};
|
|
2040
|
+
const defaultTimeLineItem = {
|
|
2041
|
+
id: "default",
|
|
2042
|
+
type: "bar",
|
|
2043
|
+
addSize: 0,
|
|
2044
|
+
delSize: 0
|
|
2045
|
+
};
|
|
2046
|
+
const DocumentTimeline = (props) => {
|
|
2047
|
+
const { timeline = [], onItemClick } = props;
|
|
2048
|
+
const [selectedItem, setSelectedItem] = useState(null);
|
|
2049
|
+
const scrollContainerRef = useRef(null);
|
|
2050
|
+
const handleClick = (item) => {
|
|
2051
|
+
if (item.id === selectedItem || item.id === defaultTimeLineItem.id) {
|
|
2052
|
+
onItemClick == null ? void 0 : onItemClick(null);
|
|
2053
|
+
setSelectedItem(null);
|
|
2054
|
+
} else {
|
|
2055
|
+
onItemClick == null ? void 0 : onItemClick(item);
|
|
2056
|
+
setSelectedItem(item.id);
|
|
2057
|
+
}
|
|
2058
|
+
};
|
|
2059
|
+
const mergedTimelineItems = [...timeline, defaultTimeLineItem];
|
|
2060
|
+
const [unselectedItems, selectedItems] = useMemo(() => {
|
|
2061
|
+
const indexSelected = mergedTimelineItems.findIndex((item) => item.id === selectedItem);
|
|
2062
|
+
return indexSelected === -1 ? [mergedTimelineItems, []] : [
|
|
2063
|
+
mergedTimelineItems.slice(0, indexSelected),
|
|
2064
|
+
mergedTimelineItems.slice(indexSelected)
|
|
2065
|
+
];
|
|
2066
|
+
}, [mergedTimelineItems, selectedItem]);
|
|
2067
|
+
const renderTimelineItems = useCallback((items) => {
|
|
2068
|
+
return items.map((item) => {
|
|
2069
|
+
if (item.type === "divider") {
|
|
2070
|
+
const { timestamp, title, subtitle } = item;
|
|
2071
|
+
return jsx(HDivider, { timestamp, title, subtitle, onClick: () => handleClick(item), isSelected: item.id === selectedItem }, item.id);
|
|
2072
|
+
}
|
|
2073
|
+
return jsx(TimelineBar, { timestamp: item.timestamp, addSize: item.addSize, delSize: item.delSize, additions: item.additions, deletions: item.deletions, isSelected: item.id === selectedItem, onClick: () => handleClick(item) }, item.id);
|
|
2074
|
+
});
|
|
2075
|
+
}, [handleClick, selectedItem]);
|
|
2076
|
+
const unselectedContent = useMemo(() => renderTimelineItems(unselectedItems), [unselectedItems, renderTimelineItems]);
|
|
2077
|
+
const selectedContent = useMemo(() => renderTimelineItems(selectedItems), [selectedItems, renderTimelineItems]);
|
|
2078
|
+
useEffect(() => {
|
|
2079
|
+
if (scrollContainerRef.current) {
|
|
2080
|
+
scrollContainerRef.current.scrollLeft = scrollContainerRef.current.scrollWidth;
|
|
2081
|
+
}
|
|
2082
|
+
}, []);
|
|
2083
|
+
return jsx(TooltipProvider, { delayDuration: 0, skipDelayDuration: 0, children: jsxs("div", { className: "relative h-[36px] w-full", children: [jsx("div", { className: "absolute left-[0px] z-[20] h-[17px] w-[6px] bg-white", children: jsx("div", { className: "mt-[11px] h-[6px] w-[6px] rounded-tl-md bg-slate-50" }) }), jsx("div", { className: "absolute right-[0px] top-[11px] z-[20] h-[6px] w-[6px] bg-white", children: jsx("div", { className: "h-[6px] w-[6px] rounded-tr-md bg-slate-50" }) }), jsx("div", { className: "absolute inset-x-0 bottom-0 h-[25px] rounded-md bg-slate-50" }), jsx("div", { className: "absolute inset-x-0 bottom-0 h-[36px]", children: jsx("div", { ref: scrollContainerRef, className: "h-full overflow-x-auto rounded-md", children: jsxs("div", { className: "ml-auto flex h-[36px] w-max items-end px-2 pb-0", children: [jsx("div", { className: "flex", children: unselectedContent }), jsx("div", { className: "flex rounded-sm bg-blue-200", children: selectedContent })] }) }) }), jsx("div", { className: "pointer-events-none absolute bottom-0 left-0 z-10 h-[25px] w-2 rounded-l-md bg-slate-50" }), jsx("div", { className: "pointer-events-none absolute bottom-0 right-0 z-10 h-[25px] w-2 rounded-r-md bg-slate-50" })] }) });
|
|
2084
|
+
};
|
|
2085
|
+
const DocumentToolbar = (props) => {
|
|
2086
|
+
const { undo: undo2, canUndo, redo: redo2, canRedo, title, onClose, onExport, className, onShowRevisionHistory, onSwitchboardLinkClick, timelineItems = [], onTimelineItemClick, initialTimelineVisible = false, timelineButtonVisible = false } = props;
|
|
2087
|
+
const [showTimeline, setShowTimeline] = useState(initialTimelineVisible);
|
|
2088
|
+
const isUndoDisabled = !canUndo || !undo2;
|
|
2089
|
+
const isRedoDisabled = !canRedo || !redo2;
|
|
2090
|
+
const isExportDisabled = !onExport;
|
|
2091
|
+
const isSwitchboardLinkDisabled = !onSwitchboardLinkClick;
|
|
2092
|
+
const isRevisionHistoryDisabled = !onShowRevisionHistory;
|
|
2093
|
+
const isTimelineDisabled = timelineItems.length === 0;
|
|
2094
|
+
useEffect(() => {
|
|
2095
|
+
if (initialTimelineVisible) {
|
|
2096
|
+
setShowTimeline(true);
|
|
2097
|
+
}
|
|
2098
|
+
}, [initialTimelineVisible]);
|
|
2099
|
+
const handleTimelineToggle = () => {
|
|
2100
|
+
if (isTimelineDisabled)
|
|
2101
|
+
return;
|
|
2102
|
+
setShowTimeline(!showTimeline);
|
|
2103
|
+
};
|
|
2104
|
+
return jsxs("div", { className: "flex w-full flex-col", children: [jsxs("div", { className: twMerge("flex h-12 w-full items-center justify-between rounded-xl border border-gray-200 bg-slate-50 px-4", className), children: [jsxs("div", { className: "flex items-center gap-x-2", children: [jsx("button", { className: twMerge("grid size-8 place-items-center rounded-lg border border-gray-200 bg-white", isUndoDisabled ? "cursor-not-allowed" : "cursor-pointer active:opacity-70"), onClick: undo2, disabled: isUndoDisabled, children: jsx(Icon, { name: "ArrowCouterclockwise", size: 16, className: isUndoDisabled ? "text-gray-500" : "text-gray-900" }) }), jsx("button", { className: twMerge("grid size-8 place-items-center rounded-lg border border-gray-200 bg-white", isRedoDisabled ? "cursor-not-allowed" : "cursor-pointer active:opacity-70"), onClick: redo2, disabled: isRedoDisabled, children: jsx("div", { className: "-scale-x-100", children: jsx(Icon, { name: "ArrowCouterclockwise", size: 16, className: isRedoDisabled ? "text-gray-500" : "text-gray-900" }) }) }), jsx("button", { className: twMerge("flex h-8 items-center rounded-lg border border-gray-200 bg-white px-3 text-sm", isExportDisabled ? "cursor-not-allowed" : "cursor-pointer active:opacity-70"), onClick: onExport, disabled: isExportDisabled, children: jsx("span", { className: isExportDisabled ? "text-gray-500" : "text-gray-900", children: "Export" }) })] }), jsx("div", { className: "flex items-center", children: jsx("h1", { className: "text-sm font-medium text-gray-500", children: title }) }), jsxs("div", { className: "flex items-center gap-x-2", children: [jsx("button", { className: twMerge("grid size-8 place-items-center rounded-lg border border-gray-200 bg-white", isSwitchboardLinkDisabled ? "cursor-not-allowed" : "cursor-pointer active:opacity-70"), onClick: onSwitchboardLinkClick, disabled: isSwitchboardLinkDisabled, children: jsx(Icon, { name: "Drive", size: 16, className: isSwitchboardLinkDisabled ? "text-gray-500" : "text-gray-900" }) }), jsx("button", { className: twMerge("grid size-8 place-items-center rounded-lg border border-gray-200 bg-white", isRevisionHistoryDisabled ? "cursor-not-allowed" : "cursor-pointer active:opacity-70"), onClick: onShowRevisionHistory, disabled: isRevisionHistoryDisabled, children: jsx(Icon, { name: "History", size: 16, className: isRevisionHistoryDisabled ? "text-gray-500" : "text-gray-900" }) }), timelineButtonVisible && jsx("button", { className: twMerge("grid size-8 place-items-center rounded-lg border border-gray-200 bg-white", isTimelineDisabled ? "cursor-not-allowed" : "cursor-pointer active:opacity-70"), onClick: handleTimelineToggle, disabled: isTimelineDisabled, "aria-pressed": showTimeline, children: jsx(Icon, { name: "Timeline", size: 16, className: twMerge("text-gray-900", isTimelineDisabled && "opacity-50", showTimeline && "text-blue-600") }) }), jsx("button", { className: "grid size-8 cursor-pointer place-items-center rounded-lg border border-gray-200 bg-white active:opacity-70", onClick: onClose, children: jsx(Icon, { name: "XmarkLight", size: 16, className: "text-gray-900" }) })] })] }), showTimeline && jsx("div", { className: "mt-2 w-full", children: jsx(DocumentTimeline, { timeline: timelineItems, onItemClick: onTimelineItemClick }) })] });
|
|
2105
|
+
};
|
|
2106
|
+
const syncIcons = {
|
|
2107
|
+
SYNCING: "Syncing",
|
|
2108
|
+
SUCCESS: "Synced",
|
|
2109
|
+
CONFLICT: "Error",
|
|
2110
|
+
MISSING: "Circle",
|
|
2111
|
+
ERROR: "Error",
|
|
2112
|
+
INITIAL_SYNC: "Syncing"
|
|
2113
|
+
};
|
|
2114
|
+
function SyncStatusIcon(props) {
|
|
2115
|
+
const { syncStatus, className, overrideSyncIcons = {}, ...iconProps } = props;
|
|
2116
|
+
const icons = { ...syncIcons, ...overrideSyncIcons };
|
|
2117
|
+
const syncStatusIcons = {
|
|
2118
|
+
[INITIAL_SYNC]: jsx(Icon, { size: 16, ...iconProps, className: twMerge("text-blue-900", className), name: icons[INITIAL_SYNC] }),
|
|
2119
|
+
[SYNCING]: jsx(Icon, { size: 16, ...iconProps, className: twMerge("text-blue-900", className), name: icons[SYNCING] }),
|
|
2120
|
+
[SUCCESS]: jsx(Icon, { size: 16, ...iconProps, className: twMerge("text-green-900", className), name: icons[SUCCESS] }),
|
|
2121
|
+
[CONFLICT]: jsx(Icon, { size: 16, ...iconProps, className: twMerge("text-orange-900", className), name: icons[CONFLICT] }),
|
|
2122
|
+
[MISSING]: jsx(Icon, { size: 16, ...iconProps, className: twMerge("text-red-900", className), name: icons[MISSING] }),
|
|
2123
|
+
[ERROR]: jsx(Icon, { size: 16, ...iconProps, className: twMerge("text-red-900", className), name: icons[ERROR] })
|
|
2124
|
+
};
|
|
2125
|
+
return syncStatusIcons[syncStatus];
|
|
2126
|
+
}
|
|
2127
|
+
function FileItem(props) {
|
|
2128
|
+
const { uiNode, className, customDocumentIconSrc, onSelectNode, onRenameNode, onDuplicateNode, onDeleteNode, isAllowedToCreateDocuments } = props;
|
|
2129
|
+
const [mode, setMode] = useState(READ);
|
|
2130
|
+
const [isDropdownMenuOpen, setIsDropdownMenuOpen] = useState(false);
|
|
2131
|
+
const { dragProps } = useDrag({ uiNode });
|
|
2132
|
+
const isReadMode = mode === READ;
|
|
2133
|
+
const dropdownMenuHandlers = {
|
|
2134
|
+
[DUPLICATE]: () => onDuplicateNode(uiNode),
|
|
2135
|
+
[RENAME]: () => setMode(WRITE),
|
|
2136
|
+
[DELETE]: () => onDeleteNode(uiNode)
|
|
2137
|
+
};
|
|
2138
|
+
const dropdownMenuOptions = Object.entries(nodeOptionsMap).map(([id, option]) => ({
|
|
2139
|
+
...option,
|
|
2140
|
+
id
|
|
2141
|
+
})).filter((option) => defaultFileOptions.includes(option.id));
|
|
2142
|
+
function onSubmit(name) {
|
|
2143
|
+
onRenameNode(name, uiNode);
|
|
2144
|
+
setMode(READ);
|
|
2145
|
+
}
|
|
2146
|
+
function onCancel() {
|
|
2147
|
+
setMode(READ);
|
|
2148
|
+
}
|
|
2149
|
+
function onClick() {
|
|
2150
|
+
onSelectNode(uiNode);
|
|
2151
|
+
}
|
|
2152
|
+
function onDropdownMenuOptionClick(itemId) {
|
|
2153
|
+
const handler = dropdownMenuHandlers[itemId];
|
|
2154
|
+
if (!handler) {
|
|
2155
|
+
console.error(`No handler found for dropdown menu item: ${itemId}`);
|
|
2156
|
+
return;
|
|
2157
|
+
}
|
|
2158
|
+
handler();
|
|
2159
|
+
setIsDropdownMenuOpen(false);
|
|
2160
|
+
}
|
|
2161
|
+
const iconSrc = getDocumentIconSrc(uiNode.documentType, customDocumentIconSrc);
|
|
2162
|
+
const iconNode = jsxs("div", { className: "relative", children: [jsx("img", { alt: "file icon", className: "max-w-none", height: 34, src: iconSrc, width: 32 }), isReadMode && uiNode.syncStatus && jsx("div", { className: "absolute bottom-[-2px] right-0 size-3 rounded-full bg-white", children: jsx("div", { className: "absolute left-[-2px] top-[-2px]", children: jsx(SyncStatusIcon, { overrideSyncIcons: { SUCCESS: "CheckCircleFill" }, syncStatus: uiNode.syncStatus }) }) })] });
|
|
2163
|
+
const containerStyles = twMerge("group flex h-12 cursor-pointer select-none items-center rounded-lg bg-gray-200 px-2 text-gray-600 hover:text-gray-800", className);
|
|
2164
|
+
const content = isReadMode ? jsxs("div", { className: "flex w-52 items-center justify-between", children: [jsxs("div", { className: "mr-2 truncate group-hover:mr-0", children: [jsx("div", { className: "max-h-6 truncate text-sm font-medium group-hover:text-gray-800", children: uiNode.name }), jsx("div", { className: "max-h-6 truncate text-xs font-medium text-gray-600 group-hover:text-gray-800", children: uiNode.documentType })] }), isAllowedToCreateDocuments ? jsx(ConnectDropdownMenu, { items: dropdownMenuOptions, onItemClick: onDropdownMenuOptionClick, onOpenChange: setIsDropdownMenuOpen, open: isDropdownMenuOpen, children: jsx("button", { className: twMerge("hidden group-hover:block", isDropdownMenuOpen && "block"), onClick: (e) => {
|
|
2165
|
+
e.stopPropagation();
|
|
2166
|
+
setIsDropdownMenuOpen(true);
|
|
2167
|
+
}, children: jsx(Icon, { className: "text-gray-600", name: "VerticalDots" }) }) }) : null] }) : jsx(NodeInput, { className: "ml-3 flex-1 font-medium", defaultValue: uiNode.name, onCancel, onSubmit });
|
|
2168
|
+
return jsx("div", { className: "relative w-64", onClick, children: jsx("div", { ...dragProps, className: containerStyles, children: jsxs("div", { className: "flex items-center", children: [jsx("div", { className: "mr-1.5", children: iconNode }), content] }) }) });
|
|
2169
|
+
}
|
|
2170
|
+
function FolderItem(props) {
|
|
2171
|
+
const { uiNode, isAllowedToCreateDocuments, className, onRenameNode, onDuplicateNode, onDeleteNode, onSelectNode, onAddFile, onCopyNode, onMoveNode } = props;
|
|
2172
|
+
const [mode, setMode] = useState(READ);
|
|
2173
|
+
const [isDropdownMenuOpen, setIsDropdownMenuOpen] = useState(false);
|
|
2174
|
+
const { dragProps } = useDrag({ ...props, uiNode });
|
|
2175
|
+
const { isDropTarget, dropProps } = useDrop({
|
|
2176
|
+
uiNode,
|
|
2177
|
+
onAddFile,
|
|
2178
|
+
onCopyNode,
|
|
2179
|
+
onMoveNode
|
|
2180
|
+
});
|
|
2181
|
+
const isReadMode = mode === READ;
|
|
2182
|
+
function onCancel() {
|
|
2183
|
+
setMode(READ);
|
|
2184
|
+
}
|
|
2185
|
+
function onSubmit(name) {
|
|
2186
|
+
onRenameNode(name, uiNode);
|
|
2187
|
+
setMode(READ);
|
|
2188
|
+
}
|
|
2189
|
+
function onClick() {
|
|
2190
|
+
onSelectNode(uiNode);
|
|
2191
|
+
}
|
|
2192
|
+
const dropdownMenuHandlers = {
|
|
2193
|
+
[DUPLICATE]: () => onDuplicateNode(uiNode),
|
|
2194
|
+
[RENAME]: () => setMode(WRITE),
|
|
2195
|
+
[DELETE]: () => onDeleteNode(uiNode)
|
|
2196
|
+
};
|
|
2197
|
+
const dropdownMenuOptions = Object.entries(nodeOptionsMap).map(([id, option]) => ({
|
|
2198
|
+
...option,
|
|
2199
|
+
id
|
|
2200
|
+
})).filter((option) => defaultFolderOptions.includes(option.id));
|
|
2201
|
+
function onDropdownMenuOptionClick(itemId) {
|
|
2202
|
+
const handler = dropdownMenuHandlers[itemId];
|
|
2203
|
+
if (!handler) {
|
|
2204
|
+
console.error(`No handler found for dropdown menu item: ${itemId}`);
|
|
2205
|
+
return;
|
|
2206
|
+
}
|
|
2207
|
+
handler();
|
|
2208
|
+
setIsDropdownMenuOpen(false);
|
|
2209
|
+
}
|
|
2210
|
+
const content = isReadMode || !isAllowedToCreateDocuments ? jsx("div", { className: "ml-3 max-h-6 truncate font-medium text-gray-600 group-hover:text-gray-800", children: uiNode.name }) : jsx(NodeInput, { className: "ml-3 font-medium", defaultValue: uiNode.name, onCancel, onSubmit });
|
|
2211
|
+
const containerStyles = twMerge("group flex h-12 cursor-pointer select-none items-center rounded-lg bg-gray-200 px-2", className, isDropTarget && "bg-blue-100");
|
|
2212
|
+
return jsx("div", { className: "relative w-64", onClick, children: jsxs("div", { ...dragProps, ...dropProps, className: containerStyles, children: [jsxs("div", { className: "flex items-center overflow-hidden", children: [jsx("div", { className: "p-1", children: jsxs("div", { className: "relative", children: [jsx(Icon, { name: "FolderClose", size: 24 }), isReadMode && uiNode.syncStatus ? jsx("div", { className: "absolute bottom-[-3px] right-[-2px] size-3 rounded-full bg-white", children: jsx("div", { className: "absolute left-[-2px] top-[-2px]", children: jsx(SyncStatusIcon, { overrideSyncIcons: {
|
|
2213
|
+
SUCCESS: "CheckCircleFill"
|
|
2214
|
+
}, syncStatus: uiNode.syncStatus }) }) }) : null] }) }), content] }), isReadMode && isAllowedToCreateDocuments ? jsx(ConnectDropdownMenu, { items: dropdownMenuOptions, onItemClick: onDropdownMenuOptionClick, onOpenChange: setIsDropdownMenuOpen, open: isDropdownMenuOpen, children: jsx("button", { className: twMerge("ml-auto hidden group-hover:block", isDropdownMenuOpen && "block"), onClick: (e) => {
|
|
2215
|
+
e.stopPropagation();
|
|
2216
|
+
setIsDropdownMenuOpen(true);
|
|
2217
|
+
}, children: jsx(Icon, { className: "text-gray-600", name: "VerticalDots" }) }) }) : null] }) });
|
|
2218
|
+
}
|
|
2219
|
+
function NodeInput(props) {
|
|
2220
|
+
const { onSubmit, onCancel, defaultValue, className, minLength = 1, ...inputProps } = props;
|
|
2221
|
+
const [value, setValue] = useState(defaultValue ?? "");
|
|
2222
|
+
const ref = useRef(null);
|
|
2223
|
+
useOnClickOutside(ref, handleSubmit);
|
|
2224
|
+
useEventListener("keyup", (e) => {
|
|
2225
|
+
if (e.key === "Enter") {
|
|
2226
|
+
handleSubmit();
|
|
2227
|
+
}
|
|
2228
|
+
if (e.key === "Escape") {
|
|
2229
|
+
onCancel();
|
|
2230
|
+
}
|
|
2231
|
+
});
|
|
2232
|
+
useLayoutEffect(() => {
|
|
2233
|
+
setTimeout(() => {
|
|
2234
|
+
var _a, _b, _c;
|
|
2235
|
+
(_a = ref.current) == null ? void 0 : _a.focus();
|
|
2236
|
+
(_b = ref.current) == null ? void 0 : _b.select();
|
|
2237
|
+
(_c = ref.current) == null ? void 0 : _c.scroll({ left: 9999 });
|
|
2238
|
+
}, 100);
|
|
2239
|
+
}, []);
|
|
2240
|
+
function handleSubmit() {
|
|
2241
|
+
if (value.length >= minLength) {
|
|
2242
|
+
onSubmit(value);
|
|
2243
|
+
}
|
|
2244
|
+
}
|
|
2245
|
+
return jsx("input", { ...inputProps, autoFocus: true, className: twMerge("bg-inherit text-inherit outline-none", className), minLength, onChange: (e) => setValue(e.target.value), ref, required: true, type: "text", value });
|
|
2246
|
+
}
|
|
2247
|
+
function Branch(props) {
|
|
2248
|
+
const { branch = "main" } = props;
|
|
2249
|
+
return jsxs("button", { className: "flex h-8 items-center gap-1 rounded-lg bg-slate-50 pl-1 pr-2 text-xs text-slate-100", children: [jsx(Icon, { name: "Branch" }), jsx("span", { children: "BRANCH" }), jsx("span", { className: "text-gray-900", children: branch })] });
|
|
2250
|
+
}
|
|
2251
|
+
function DocId(props) {
|
|
2252
|
+
const { docId } = props;
|
|
2253
|
+
const [, copy] = useCopyToClipboard();
|
|
2254
|
+
function handleCopy(text) {
|
|
2255
|
+
return () => {
|
|
2256
|
+
copy(text).catch((error) => {
|
|
2257
|
+
console.error("Failed to copy!", error);
|
|
2258
|
+
});
|
|
2259
|
+
};
|
|
2260
|
+
}
|
|
2261
|
+
return jsxs("button", { className: "flex h-8 items-center gap-1 rounded-lg bg-slate-50 pl-1 pr-2 text-xs text-slate-100", onClick: handleCopy(docId), children: [jsx(Icon, { name: "Link" }), "DOC ID", jsx("span", { className: "text-gray-900", children: docId })] });
|
|
2262
|
+
}
|
|
2263
|
+
function Scope(props) {
|
|
2264
|
+
const { value, onChange } = props;
|
|
2265
|
+
const items = [
|
|
2266
|
+
{ displayValue: "Global scope", value: "global" },
|
|
2267
|
+
{ displayValue: "Local scope", value: "local" }
|
|
2268
|
+
];
|
|
2269
|
+
return jsx(Select, { absolutePositionMenu: true, containerClassName: "bg-slate-50 text-gray-500 rounded-lg w-fit text-xs z-10", id: "scope select", itemClassName: "py-2 text-gray-500 grid grid-cols-[auto,auto] gap-1", items, menuClassName: "min-w-0 text-gray-500", onChange, value });
|
|
2270
|
+
}
|
|
2271
|
+
function Header(props) {
|
|
2272
|
+
const { title, docId, scope, onChangeScope, onClose, className, ...divProps } = props;
|
|
2273
|
+
return jsxs("header", { className: twMerge("flex items-center justify-between bg-transparent", className), ...divProps, children: [jsxs("div", { className: "flex items-center gap-3", children: [jsx("button", { className: "shadow-button rounded-lg bg-gray-50 p-1 text-slate-100", onClick: onClose, children: jsx(Icon, { name: "VariantArrowLeft" }) }), jsx("h1", { className: "text-xs", children: title })] }), jsxs("div", { className: "flex items-center gap-2", children: [jsx(DocId, { docId }), jsx(Branch, {}), jsx(Scope, { onChange: onChangeScope, value: scope })] })] });
|
|
2274
|
+
}
|
|
2275
|
+
function memo(getDeps, fn, opts) {
|
|
2276
|
+
let deps = opts.initialDeps ?? [];
|
|
2277
|
+
let result;
|
|
2278
|
+
function memoizedFunction() {
|
|
2279
|
+
var _a, _b, _c, _d;
|
|
2280
|
+
let depTime;
|
|
2281
|
+
if (opts.key && ((_a = opts.debug) == null ? void 0 : _a.call(opts))) depTime = Date.now();
|
|
2282
|
+
const newDeps = getDeps();
|
|
2283
|
+
const depsChanged = newDeps.length !== deps.length || newDeps.some((dep, index) => deps[index] !== dep);
|
|
2284
|
+
if (!depsChanged) {
|
|
2285
|
+
return result;
|
|
2286
|
+
}
|
|
2287
|
+
deps = newDeps;
|
|
1836
2288
|
let resultTime;
|
|
1837
2289
|
if (opts.key && ((_b = opts.debug) == null ? void 0 : _b.call(opts))) resultTime = Date.now();
|
|
1838
2290
|
result = fn(...newDeps);
|
|
@@ -2857,8 +3309,8 @@ function RevisionHistory(props) {
|
|
|
2857
3309
|
return jsxs(TooltipProvider, { children: [jsx(Header, { docId: documentId, onChangeScope, onClose, scope, title: documentTitle }), PaginationComponent, jsx("div", { className: "mt-4 flex justify-center rounded-md bg-slate-50 p-4", children: visibleOperations.length > 0 ? jsx("div", { className: "grid grid-cols-[minmax(min-content,1018px)]", children: jsx(Timeline, { globalOperations: scope === "global" ? pageItems : [], localOperations: scope === "local" ? pageItems : [], scope }) }) : jsx("h3", { className: "my-40 text-gray-600", children: "This document has no recorded operations yet." }) }), PaginationComponent] });
|
|
2858
3310
|
}
|
|
2859
3311
|
function Tooltip(props) {
|
|
2860
|
-
const { children, content, open, defaultOpen, onOpenChange, className, ...rest } = props;
|
|
2861
|
-
return jsxs(Root3, { defaultOpen, delayDuration: 0, onOpenChange, open, children: [jsx(Trigger, { asChild: true, children }), jsx(Portal, { children: jsx(Content2, { ...rest, className: twMerge("shadow-tooltip rounded-lg border border-gray-200 bg-white p-2 text-xs", className), children: content }) })] });
|
|
3312
|
+
const { children, content, open, defaultOpen, onOpenChange, className, side = "top", sideOffset = 5, ...rest } = props;
|
|
3313
|
+
return jsxs(Root3, { defaultOpen, delayDuration: 0, onOpenChange, open, children: [jsx(Trigger, { asChild: true, children }), jsx(Portal, { children: jsx(Content2, { ...rest, side, sideOffset, className: twMerge("shadow-tooltip rounded-lg border border-gray-200 bg-white p-2 text-xs", className), children: content }) })] });
|
|
2862
3314
|
}
|
|
2863
3315
|
const TooltipProvider = Provider;
|
|
2864
3316
|
const BUDGET = "powerhouse/budget-statement";
|
|
@@ -3488,6 +3940,17 @@ function useEditorProps(document2, node, documentDispatch, onAddOperation) {
|
|
|
3488
3940
|
isAllowedToEditDocuments: (userPermissions == null ? void 0 : userPermissions.isAllowedToEditDocuments) ?? false
|
|
3489
3941
|
};
|
|
3490
3942
|
}
|
|
3943
|
+
function useGetDocument() {
|
|
3944
|
+
const { openFile } = useDocumentDriveServer();
|
|
3945
|
+
const getDocument = useCallback(
|
|
3946
|
+
async (driveId, documentId, options) => {
|
|
3947
|
+
const document2 = await openFile(driveId, documentId, options);
|
|
3948
|
+
return document2;
|
|
3949
|
+
},
|
|
3950
|
+
[openFile]
|
|
3951
|
+
);
|
|
3952
|
+
return getDocument;
|
|
3953
|
+
}
|
|
3491
3954
|
function useSyncStatus(driveId, documentId) {
|
|
3492
3955
|
const { getSyncStatusSync, onSyncStatus, documentDrives } = useDocumentDriveServer();
|
|
3493
3956
|
const syncStatus = useSyncExternalStore(
|
|
@@ -3558,36 +4021,363 @@ const useUndoRedoShortcuts = (props) => {
|
|
|
3558
4021
|
[canRedo, redo2]
|
|
3559
4022
|
);
|
|
3560
4023
|
};
|
|
3561
|
-
function
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
}, props.loadingTimeout ?? 200);
|
|
3567
|
-
}, [props]);
|
|
3568
|
-
if (!showLoading) return null;
|
|
3569
|
-
const { customEditorLoader, ...defaultProps } = props;
|
|
3570
|
-
if (customEditorLoader) return /* @__PURE__ */ jsx(Fragment$1, { children: customEditorLoader });
|
|
3571
|
-
return /* @__PURE__ */ jsx(DefaultEditorLoader, { ...defaultProps });
|
|
3572
|
-
}
|
|
3573
|
-
function EditorError({ message: message2 }) {
|
|
3574
|
-
return /* @__PURE__ */ jsx("div", { className: "flex size-full items-center justify-center", children: /* @__PURE__ */ jsx("h3", { className: "text-lg font-semibold", children: message2 }) });
|
|
4024
|
+
function getDocumentSpec(doc) {
|
|
4025
|
+
if ("documentModelState" in doc) {
|
|
4026
|
+
return doc.documentModelState;
|
|
4027
|
+
}
|
|
4028
|
+
return doc.documentModel;
|
|
3575
4029
|
}
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
4030
|
+
const CreateDocument = ({ documentModels, createDocument }) => {
|
|
4031
|
+
return jsxs("div", { className: "px-6", children: [jsx("h3", { className: "mb-3 mt-4 text-xl font-bold text-gray-600", children: "New document" }), jsx("div", { className: "flex w-full flex-wrap gap-4", children: documentModels == null ? void 0 : documentModels.map((doc) => {
|
|
4032
|
+
const spec = getDocumentSpec(doc);
|
|
4033
|
+
return jsx(Button, { color: "light", "aria-details": spec.description, onClick: () => createDocument(doc), children: jsx("span", { className: "text-sm", children: spec.name }) }, spec.id);
|
|
4034
|
+
}) })] });
|
|
4035
|
+
};
|
|
4036
|
+
function sortUiNodesByName(a, b) {
|
|
4037
|
+
return a.name.localeCompare(b.name);
|
|
3579
4038
|
}
|
|
3580
|
-
const
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
4039
|
+
const GAP = 8;
|
|
4040
|
+
const ITEM_WIDTH = 256;
|
|
4041
|
+
const ITEM_HEIGHT = 48;
|
|
4042
|
+
const USED_SPACE = 420;
|
|
4043
|
+
function FileContentView(props) {
|
|
4044
|
+
const parentRef = useRef(null);
|
|
4045
|
+
const { t } = useTranslation();
|
|
4046
|
+
const windowSize = useWindowSize();
|
|
4047
|
+
const { fileNodes, ...fileProps } = props;
|
|
4048
|
+
const availableWidth = windowSize.innerWidth - USED_SPACE;
|
|
4049
|
+
const columnCount = Math.floor(availableWidth / (ITEM_WIDTH + GAP)) || 1;
|
|
4050
|
+
const rowCount = Math.ceil(fileNodes.length / columnCount);
|
|
4051
|
+
const rowVirtualizer = useVirtualizer({
|
|
4052
|
+
count: rowCount,
|
|
4053
|
+
getScrollElement: () => parentRef.current,
|
|
4054
|
+
estimateSize: (index) => {
|
|
4055
|
+
if (index > 0) {
|
|
4056
|
+
return ITEM_HEIGHT + GAP;
|
|
4057
|
+
}
|
|
4058
|
+
return ITEM_HEIGHT;
|
|
4059
|
+
},
|
|
4060
|
+
overscan: 5
|
|
4061
|
+
});
|
|
4062
|
+
const columnVirtualizer = useVirtualizer({
|
|
4063
|
+
horizontal: true,
|
|
4064
|
+
count: columnCount,
|
|
4065
|
+
getScrollElement: () => parentRef.current,
|
|
4066
|
+
estimateSize: (index) => {
|
|
4067
|
+
if (index > 0) {
|
|
4068
|
+
return ITEM_WIDTH + GAP;
|
|
4069
|
+
}
|
|
4070
|
+
return ITEM_WIDTH;
|
|
4071
|
+
},
|
|
4072
|
+
overscan: 5
|
|
4073
|
+
});
|
|
4074
|
+
const getItemIndex = (rowIndex, columnIndex) => rowIndex * columnCount + columnIndex;
|
|
4075
|
+
const getItem = (rowIndex, columnIndex) => {
|
|
4076
|
+
const index = getItemIndex(rowIndex, columnIndex);
|
|
4077
|
+
return fileNodes[index] || null;
|
|
4078
|
+
};
|
|
4079
|
+
if (fileNodes.length === 0) {
|
|
4080
|
+
return jsx("div", { className: "mb-8 text-sm text-gray-400", children: t("folderView.sections.documents.empty", {
|
|
4081
|
+
defaultValue: "No documents or files 📄"
|
|
4082
|
+
}) });
|
|
4083
|
+
}
|
|
4084
|
+
const renderItem = (rowIndex, columnIndex) => {
|
|
4085
|
+
const fileNode = getItem(rowIndex, columnIndex);
|
|
4086
|
+
if (!fileNode) {
|
|
4087
|
+
return null;
|
|
4088
|
+
}
|
|
4089
|
+
return jsx("div", { style: {
|
|
4090
|
+
marginLeft: columnIndex === 0 ? 0 : GAP
|
|
4091
|
+
}, children: jsx(FileItem, { uiNode: fileNode, ...fileProps }, fileNode.id) });
|
|
4092
|
+
};
|
|
4093
|
+
return jsx("div", { ref: parentRef, style: {
|
|
4094
|
+
height: `400px`,
|
|
4095
|
+
width: `100%`,
|
|
4096
|
+
overflow: "auto"
|
|
4097
|
+
}, children: jsx("div", { style: {
|
|
4098
|
+
height: `${rowVirtualizer.getTotalSize()}px`,
|
|
4099
|
+
width: `${columnVirtualizer.getTotalSize()}px`,
|
|
4100
|
+
position: "relative"
|
|
4101
|
+
}, children: rowVirtualizer.getVirtualItems().map((virtualRow) => jsx(React__default.Fragment, { children: columnVirtualizer.getVirtualItems().map((virtualColumn) => jsx("div", { style: {
|
|
4102
|
+
position: "absolute",
|
|
4103
|
+
top: 0,
|
|
4104
|
+
left: 0,
|
|
4105
|
+
marginTop: virtualRow.index === 0 ? 0 : GAP,
|
|
4106
|
+
width: `${virtualColumn.size}px`,
|
|
4107
|
+
height: `${virtualRow.size}px`,
|
|
4108
|
+
transform: `translateX(${virtualColumn.start}px) translateY(${virtualRow.start}px)`
|
|
4109
|
+
}, children: renderItem(virtualRow.index, virtualColumn.index) }, virtualColumn.key)) }, virtualRow.key)) }) });
|
|
4110
|
+
}
|
|
4111
|
+
function FolderView(props) {
|
|
4112
|
+
const { node, className, isDropTarget, containerProps, ...nodeProps } = props;
|
|
4113
|
+
const { t } = useTranslation();
|
|
4114
|
+
const folderNodes = node.children.filter((node2) => node2.kind === FOLDER).sort(sortUiNodesByName);
|
|
4115
|
+
const fileNodes = node.children.filter((node2) => node2.kind === FILE).sort(sortUiNodesByName);
|
|
4116
|
+
const folderCallbacks = {
|
|
4117
|
+
onSelectNode: (node2) => nodeProps.onSelectNode(node2),
|
|
4118
|
+
onRenameNode: (name, node2) => nodeProps.onRenameNode(name, node2),
|
|
4119
|
+
onDuplicateNode: (node2) => nodeProps.onDuplicateNode(node2),
|
|
4120
|
+
onDeleteNode: (node2) => nodeProps.onDeleteNode(node2)
|
|
4121
|
+
};
|
|
4122
|
+
const fileCallbacks = {
|
|
4123
|
+
onSelectNode: (node2) => nodeProps.onSelectNode(node2),
|
|
4124
|
+
onRenameNode: (name, node2) => nodeProps.onRenameNode(name, node2),
|
|
4125
|
+
onDuplicateNode: (node2) => nodeProps.onDuplicateNode(node2),
|
|
4126
|
+
onDeleteNode: (node2) => nodeProps.onDeleteNode(node2)
|
|
4127
|
+
};
|
|
4128
|
+
const baseNodeCallbacks = {
|
|
4129
|
+
onAddFile: async (file, parentNode) => {
|
|
4130
|
+
await nodeProps.onAddFile(file, parentNode);
|
|
4131
|
+
},
|
|
4132
|
+
onCopyNode: async (uiNode, targetNode) => {
|
|
4133
|
+
await nodeProps.onCopyNode(uiNode, targetNode);
|
|
4134
|
+
},
|
|
4135
|
+
onMoveNode: async (uiNode, targetNode) => {
|
|
4136
|
+
await nodeProps.onMoveNode(uiNode, targetNode);
|
|
4137
|
+
}
|
|
4138
|
+
};
|
|
4139
|
+
return jsxs("div", { className: twMerge("rounded-md border-2 border-transparent p-2", isDropTarget && "border-dashed border-blue-100", className), ...containerProps, children: [jsx(DriveLayout.ContentSection, { title: t("folderView.sections.folders.title", {
|
|
4140
|
+
defaultValue: "Folders"
|
|
4141
|
+
}), className: "mb-4", children: folderNodes.length > 0 ? folderNodes.map((folderNode) => jsx(FolderItem, { uiNode: folderNode, ...baseNodeCallbacks, ...folderCallbacks, isAllowedToCreateDocuments: nodeProps.isAllowedToCreateDocuments }, folderNode.id)) : jsx("div", { className: "mb-8 text-sm text-gray-400", children: t("folderView.sections.folders.empty", {
|
|
4142
|
+
defaultValue: "No documents or files 📄"
|
|
4143
|
+
}) }) }), jsx(DriveLayout.ContentSection, { title: t("folderView.sections.documents.title", {
|
|
4144
|
+
defaultValue: "Documents and files"
|
|
4145
|
+
}), children: jsx("div", { className: twMerge("w-full", fileNodes.length > 0 ? "min-h-[400px]" : "min-h-14"), children: jsx(FileContentView, { fileNodes, ...fileCallbacks, isAllowedToCreateDocuments: nodeProps.isAllowedToCreateDocuments }) }) })] });
|
|
4146
|
+
}
|
|
4147
|
+
function BaseEditor(props) {
|
|
4148
|
+
const { document: document2, dispatch, className, children } = props;
|
|
4149
|
+
const { state: { global: { id: driveId } } } = document2;
|
|
4150
|
+
const { showSearchBar, isAllowedToCreateDocuments, documentModels, showCreateDocumentModal } = useDriveContext();
|
|
4151
|
+
const { driveNodes, selectedNode, selectedNodePath, getNodeById, setSelectedNode } = useUiNodesContext();
|
|
4152
|
+
const driveNode = useMemo(() => driveNodes.find((n) => n.id === driveId), [driveNodes, driveId]);
|
|
4153
|
+
const { addDocument, addFile, addFolder: addFolder2, renameNode, deleteNode: deleteNode2, moveNode: moveNode2, copyNode: copyNode2, duplicateNode } = useDriveActionsWithUiNodes(document2, dispatch);
|
|
4154
|
+
const onCreateDocument = useCallback(async (documentModel) => {
|
|
4155
|
+
const { name } = await showCreateDocumentModal(documentModel);
|
|
4156
|
+
const document3 = documentModel.utils.createDocument();
|
|
4157
|
+
await addDocument(name, documentModel.documentModel.name, document3, selectedNode == null ? void 0 : selectedNode.id);
|
|
4158
|
+
}, [addDocument, showCreateDocumentModal, selectedNode == null ? void 0 : selectedNode.id]);
|
|
4159
|
+
const { isDropTarget, dropProps } = useDrop({
|
|
4160
|
+
uiNode: selectedNode,
|
|
4161
|
+
onAddFile: addFile,
|
|
4162
|
+
onCopyNode: copyNode2,
|
|
4163
|
+
onMoveNode: moveNode2
|
|
4164
|
+
});
|
|
4165
|
+
const { breadcrumbs, onBreadcrumbSelected } = useBreadcrumbs({
|
|
4166
|
+
selectedNodePath,
|
|
4167
|
+
getNodeById,
|
|
4168
|
+
setSelectedNode
|
|
4169
|
+
});
|
|
4170
|
+
if (!driveNode) {
|
|
4171
|
+
return jsx("div", { children: "Drive not found" });
|
|
4172
|
+
} else if ((selectedNode == null ? void 0 : selectedNode.kind) === FILE$1) {
|
|
4173
|
+
return jsx(Fragment$1, {});
|
|
4174
|
+
}
|
|
4175
|
+
return jsxs(DriveLayout, { className, children: [children, jsxs(DriveLayout.Header, { children: [jsx(Breadcrumbs, { breadcrumbs, createEnabled: isAllowedToCreateDocuments, onCreate: addFolder2, onBreadcrumbSelected }), showSearchBar && jsx(SearchBar, {})] }), jsx(DriveLayout.Content, { children: jsx(FolderView, { node: selectedNode || driveNode, onSelectNode: setSelectedNode, onRenameNode: renameNode, onDuplicateNode: duplicateNode, onDeleteNode: deleteNode2, onAddFile: addFile, onCopyNode: copyNode2, onMoveNode: moveNode2, isDropTarget, isAllowedToCreateDocuments }) }), jsx(DriveLayout.Footer, { children: isAllowedToCreateDocuments && jsx(CreateDocument, { documentModels, createDocument: onCreateDocument }) })] });
|
|
4176
|
+
}
|
|
4177
|
+
function Editor(props) {
|
|
4178
|
+
return jsx(DriveContextProvider, { value: props.context, children: jsx(BaseEditor, { ...props }) });
|
|
4179
|
+
}
|
|
4180
|
+
const GenericDriveExplorer = {
|
|
4181
|
+
Component: Editor
|
|
4182
|
+
};
|
|
4183
|
+
function useAnalyticsQueryWrapper(options) {
|
|
4184
|
+
const { queryFn, ...queryOptions } = options;
|
|
4185
|
+
const store = useAnalyticsStore();
|
|
4186
|
+
const engine = useAnalyticsEngine();
|
|
4187
|
+
return useQuery({
|
|
4188
|
+
...queryOptions,
|
|
4189
|
+
queryFn: () => {
|
|
4190
|
+
if (!store || !engine) {
|
|
4191
|
+
throw new Error("No analytics store available. Use within an AnalyticsProvider.");
|
|
4192
|
+
}
|
|
4193
|
+
return queryFn({ store, engine });
|
|
4194
|
+
}
|
|
4195
|
+
});
|
|
4196
|
+
}
|
|
4197
|
+
function useAnalyticsQuery(query, options) {
|
|
4198
|
+
const store = useAnalyticsStore();
|
|
4199
|
+
const { data: querySources } = useQuerySources(query);
|
|
4200
|
+
const queryClient = useQueryClient();
|
|
4201
|
+
const subscriptions = useRef([]);
|
|
4202
|
+
const result = useAnalyticsQueryWrapper({
|
|
4203
|
+
queryKey: ["analytics", "query", query],
|
|
4204
|
+
queryFn: ({ engine }) => engine.execute(query),
|
|
4205
|
+
...options
|
|
4206
|
+
});
|
|
4207
|
+
useEffect(() => {
|
|
4208
|
+
if (!(querySources == null ? void 0 : querySources.length) || !store) {
|
|
4209
|
+
return;
|
|
4210
|
+
}
|
|
4211
|
+
querySources.forEach((source) => {
|
|
4212
|
+
const unsub = store.subscribeToSource(source, () => {
|
|
4213
|
+
return queryClient.invalidateQueries({
|
|
4214
|
+
queryKey: ["analytics", "query", query]
|
|
4215
|
+
});
|
|
4216
|
+
});
|
|
4217
|
+
subscriptions.current.push(unsub);
|
|
4218
|
+
});
|
|
4219
|
+
return () => {
|
|
4220
|
+
subscriptions.current.forEach((unsub) => unsub());
|
|
4221
|
+
subscriptions.current = [];
|
|
4222
|
+
};
|
|
4223
|
+
}, [querySources]);
|
|
4224
|
+
return result;
|
|
4225
|
+
}
|
|
4226
|
+
function useMatchingSeries(query, options) {
|
|
4227
|
+
const result = useAnalyticsQueryWrapper({
|
|
4228
|
+
queryKey: ["analytics", "matchingSeries", query],
|
|
4229
|
+
queryFn: ({ store }) => store.getMatchingSeries(query),
|
|
4230
|
+
...options
|
|
4231
|
+
});
|
|
4232
|
+
return result;
|
|
4233
|
+
}
|
|
4234
|
+
function useQuerySources(query, options) {
|
|
4235
|
+
const { data: matchingSeries } = useMatchingSeries(query);
|
|
4236
|
+
return useQuery({
|
|
4237
|
+
queryKey: ["analytics", "sources", query],
|
|
4238
|
+
queryFn: () => {
|
|
4239
|
+
if (!(matchingSeries == null ? void 0 : matchingSeries.length)) {
|
|
4240
|
+
return [];
|
|
4241
|
+
}
|
|
4242
|
+
const uniqueSources = [
|
|
4243
|
+
...new Set(matchingSeries.map((s) => s.source.toString()))
|
|
4244
|
+
];
|
|
4245
|
+
return uniqueSources.map((source) => AnalyticsPath.fromString(source));
|
|
4246
|
+
},
|
|
4247
|
+
enabled: !!matchingSeries,
|
|
4248
|
+
...options
|
|
4249
|
+
});
|
|
4250
|
+
}
|
|
4251
|
+
const getBarSize = (value) => {
|
|
4252
|
+
if (value <= 0)
|
|
4253
|
+
return 0;
|
|
4254
|
+
if (value > 0 && value <= 50)
|
|
4255
|
+
return 1;
|
|
4256
|
+
if (value > 50 && value <= 100)
|
|
4257
|
+
return 2;
|
|
4258
|
+
if (value > 100 && value <= 250)
|
|
4259
|
+
return 3;
|
|
4260
|
+
return 4;
|
|
4261
|
+
};
|
|
4262
|
+
const useTimelineItems = (documentId, startTimestamp) => {
|
|
4263
|
+
const start = startTimestamp ? DateTime.fromISO(startTimestamp) : DateTime.now().startOf("day");
|
|
4264
|
+
const { data: diffResult, isLoading } = useAnalyticsQuery({
|
|
4265
|
+
start,
|
|
4266
|
+
end: DateTime.now().endOf("day"),
|
|
4267
|
+
granularity: AnalyticsGranularity.Hourly,
|
|
4268
|
+
metrics: ["Count"],
|
|
4269
|
+
select: {
|
|
4270
|
+
changes: [AnalyticsPath.fromString(`changes`)],
|
|
4271
|
+
document: [AnalyticsPath.fromString(`document/${documentId}`)]
|
|
4272
|
+
},
|
|
4273
|
+
lod: {
|
|
4274
|
+
changes: 2
|
|
4275
|
+
},
|
|
4276
|
+
currency: AnalyticsPath.fromString("")
|
|
4277
|
+
});
|
|
4278
|
+
const mappedResult = useMemo(() => {
|
|
4279
|
+
if (!diffResult)
|
|
4280
|
+
return [];
|
|
4281
|
+
return diffResult.sort((a, b) => {
|
|
4282
|
+
const aDate = new Date(a.start);
|
|
4283
|
+
const bDate = new Date(b.start);
|
|
4284
|
+
return aDate.getTime() - bDate.getTime();
|
|
4285
|
+
}).filter((result) => {
|
|
4286
|
+
return result.rows.every((row) => row.value > 0);
|
|
4287
|
+
}).map((result) => {
|
|
4288
|
+
const { additions, deletions } = result.rows.reduce((acc, row) => {
|
|
4289
|
+
if (row.dimensions.changes.path === "changes/add") {
|
|
4290
|
+
acc.additions += row.value;
|
|
4291
|
+
} else if (row.dimensions.changes.path === "changes/remove") {
|
|
4292
|
+
acc.deletions += row.value;
|
|
4293
|
+
}
|
|
4294
|
+
return acc;
|
|
4295
|
+
}, { additions: 0, deletions: 0 });
|
|
4296
|
+
const startDate = new Date(result.start);
|
|
4297
|
+
return {
|
|
4298
|
+
id: startDate.toISOString(),
|
|
4299
|
+
type: "bar",
|
|
4300
|
+
addSize: getBarSize(additions),
|
|
4301
|
+
delSize: getBarSize(deletions),
|
|
4302
|
+
additions,
|
|
4303
|
+
deletions,
|
|
4304
|
+
timestamp: startDate.toISOString(),
|
|
4305
|
+
startDate,
|
|
4306
|
+
endDate: new Date(result.end),
|
|
4307
|
+
revision: 0
|
|
4308
|
+
};
|
|
4309
|
+
});
|
|
4310
|
+
}, [diffResult]);
|
|
4311
|
+
const resultWithDividers = useMemo(() => {
|
|
4312
|
+
if (!mappedResult.length)
|
|
4313
|
+
return [];
|
|
4314
|
+
const result = [];
|
|
4315
|
+
mappedResult.forEach((item, index) => {
|
|
4316
|
+
result.push(item);
|
|
4317
|
+
if (index < mappedResult.length - 1) {
|
|
4318
|
+
const currentDate = new Date(item.startDate);
|
|
4319
|
+
const nextDate = new Date(mappedResult[index + 1].startDate);
|
|
4320
|
+
const currentHour = currentDate.getHours();
|
|
4321
|
+
const nextHour = nextDate.getHours();
|
|
4322
|
+
const currentDay = currentDate.toDateString();
|
|
4323
|
+
const nextDay = nextDate.toDateString();
|
|
4324
|
+
if (currentDay !== nextDay || currentDay === nextDay && Math.abs(nextHour - currentHour) > 1) {
|
|
4325
|
+
result.push({
|
|
4326
|
+
id: `divider-${item.id}-${mappedResult[index + 1].id}`,
|
|
4327
|
+
type: "divider",
|
|
4328
|
+
revision: 0
|
|
4329
|
+
});
|
|
4330
|
+
}
|
|
4331
|
+
}
|
|
4332
|
+
});
|
|
4333
|
+
return result;
|
|
4334
|
+
}, [mappedResult]);
|
|
4335
|
+
return {
|
|
4336
|
+
isLoading,
|
|
4337
|
+
data: resultWithDividers
|
|
4338
|
+
};
|
|
4339
|
+
};
|
|
4340
|
+
const getRevisionFromDate = (startDate, endDate, operations = []) => {
|
|
4341
|
+
if (!startDate || !endDate)
|
|
4342
|
+
return 0;
|
|
4343
|
+
const operation = operations.find((operation2) => {
|
|
4344
|
+
const operationDate = new Date(operation2.timestamp);
|
|
4345
|
+
return operationDate >= startDate && operationDate <= endDate;
|
|
4346
|
+
});
|
|
4347
|
+
return operation ? operation.index : 0;
|
|
4348
|
+
};
|
|
4349
|
+
function EditorLoader(props) {
|
|
4350
|
+
const [showLoading, setShowLoading] = useState(false);
|
|
4351
|
+
useEffect(() => {
|
|
4352
|
+
setTimeout(() => {
|
|
4353
|
+
setShowLoading(true);
|
|
4354
|
+
}, props.loadingTimeout ?? 200);
|
|
4355
|
+
}, [props]);
|
|
4356
|
+
if (!showLoading) return null;
|
|
4357
|
+
const { customEditorLoader, ...defaultProps } = props;
|
|
4358
|
+
if (customEditorLoader) return /* @__PURE__ */ jsx(Fragment$1, { children: customEditorLoader });
|
|
4359
|
+
return /* @__PURE__ */ jsx(DefaultEditorLoader, { ...defaultProps });
|
|
4360
|
+
}
|
|
4361
|
+
function EditorError({ message: message2 }) {
|
|
4362
|
+
return /* @__PURE__ */ jsx("div", { className: "flex size-full items-center justify-center", children: /* @__PURE__ */ jsx("h3", { className: "text-lg font-semibold", children: message2 }) });
|
|
4363
|
+
}
|
|
4364
|
+
function FallbackEditorError(props) {
|
|
4365
|
+
const message2 = props.error instanceof Error ? props.error.message : props.error;
|
|
4366
|
+
return /* @__PURE__ */ jsx(EditorError, { message: message2 });
|
|
4367
|
+
}
|
|
4368
|
+
const DocumentEditor = (props) => {
|
|
4369
|
+
const {
|
|
4370
|
+
fileNodeDocument,
|
|
4371
|
+
document: initialDocument,
|
|
3584
4372
|
onClose,
|
|
3585
4373
|
onChange,
|
|
3586
4374
|
onExport,
|
|
3587
4375
|
onAddOperation,
|
|
4376
|
+
onGetDocumentRevision,
|
|
3588
4377
|
onOpenSwitchboardLink
|
|
3589
4378
|
} = props;
|
|
3590
4379
|
const documentId = fileNodeDocument == null ? void 0 : fileNodeDocument.documentId;
|
|
4380
|
+
const [selectedTimelineItem, setSelectedTimelineItem] = useState(null);
|
|
3591
4381
|
const [revisionHistoryVisible, setRevisionHistoryVisible] = useState(false);
|
|
3592
4382
|
const theme = useAtomValue(themeAtom);
|
|
3593
4383
|
const user = useUser() || void 0;
|
|
@@ -3613,6 +4403,10 @@ const DocumentEditor = (props) => {
|
|
|
3613
4403
|
[theme, user]
|
|
3614
4404
|
);
|
|
3615
4405
|
const userPermissions = useUserPermissions$1();
|
|
4406
|
+
const timelineItems = useTimelineItems(
|
|
4407
|
+
documentId,
|
|
4408
|
+
initialDocument == null ? void 0 : initialDocument.created
|
|
4409
|
+
);
|
|
3616
4410
|
const currentDocument = useRef({ ...fileNodeDocument, document: document2 });
|
|
3617
4411
|
useEffect(() => {
|
|
3618
4412
|
var _a;
|
|
@@ -3789,7 +4583,8 @@ const DocumentEditor = (props) => {
|
|
|
3789
4583
|
const {
|
|
3790
4584
|
disableExternalControls,
|
|
3791
4585
|
documentToolbarEnabled,
|
|
3792
|
-
showSwitchboardLink
|
|
4586
|
+
showSwitchboardLink,
|
|
4587
|
+
timelineEnabled
|
|
3793
4588
|
} = editor.config || {};
|
|
3794
4589
|
const handleSwitchboardLinkClick = showSwitchboardLink !== false ? onOpenSwitchboardLink : void 0;
|
|
3795
4590
|
return /* @__PURE__ */ jsxs("div", { className: "relative h-full", id: "document-editor-context", children: [
|
|
@@ -3800,7 +4595,10 @@ const DocumentEditor = (props) => {
|
|
|
3800
4595
|
onExport,
|
|
3801
4596
|
onShowRevisionHistory: showRevisionHistory,
|
|
3802
4597
|
title: fileNodeDocument.name || document2.name,
|
|
3803
|
-
onSwitchboardLinkClick: handleSwitchboardLinkClick
|
|
4598
|
+
onSwitchboardLinkClick: handleSwitchboardLinkClick,
|
|
4599
|
+
timelineButtonVisible: timelineEnabled,
|
|
4600
|
+
timelineItems: timelineItems.data,
|
|
4601
|
+
onTimelineItemClick: setSelectedTimelineItem
|
|
3804
4602
|
}
|
|
3805
4603
|
),
|
|
3806
4604
|
!disableExternalControls && /* @__PURE__ */ jsxs("div", { className: "mb-4 flex justify-end gap-10", children: [
|
|
@@ -3830,7 +4628,16 @@ const DocumentEditor = (props) => {
|
|
|
3830
4628
|
EditorComponent,
|
|
3831
4629
|
{
|
|
3832
4630
|
error,
|
|
3833
|
-
context
|
|
4631
|
+
context: {
|
|
4632
|
+
...context,
|
|
4633
|
+
getDocumentRevision: onGetDocumentRevision,
|
|
4634
|
+
readMode: !!selectedTimelineItem,
|
|
4635
|
+
selectedTimelineRevision: getRevisionFromDate(
|
|
4636
|
+
selectedTimelineItem == null ? void 0 : selectedTimelineItem.startDate,
|
|
4637
|
+
selectedTimelineItem == null ? void 0 : selectedTimelineItem.endDate,
|
|
4638
|
+
document2.operations.global
|
|
4639
|
+
)
|
|
4640
|
+
},
|
|
3834
4641
|
document: document2,
|
|
3835
4642
|
documentNodeName: fileNodeDocument.name,
|
|
3836
4643
|
dispatch,
|
|
@@ -3868,6 +4675,7 @@ function DocumentEditorContainer() {
|
|
|
3868
4675
|
renameNode,
|
|
3869
4676
|
getDocumentModelModule
|
|
3870
4677
|
} = useUiNodes();
|
|
4678
|
+
const getDocument = useGetDocument();
|
|
3871
4679
|
const handleAddOperationToSelectedDocument = useCallback(
|
|
3872
4680
|
async (operation) => {
|
|
3873
4681
|
if (!selectedDocument) {
|
|
@@ -3930,6 +4738,20 @@ function DocumentEditorContainer() {
|
|
|
3930
4738
|
},
|
|
3931
4739
|
[getDocumentModelModule, showModal, t]
|
|
3932
4740
|
);
|
|
4741
|
+
const onGetDocumentRevision = useCallback(
|
|
4742
|
+
(options) => {
|
|
4743
|
+
if (!selectedNode) {
|
|
4744
|
+
console.error("No selected node");
|
|
4745
|
+
return Promise.reject(new Error("No selected node"));
|
|
4746
|
+
}
|
|
4747
|
+
return getDocument(
|
|
4748
|
+
selectedNode.driveId,
|
|
4749
|
+
selectedNode.id,
|
|
4750
|
+
options
|
|
4751
|
+
);
|
|
4752
|
+
},
|
|
4753
|
+
[getDocument, selectedNode]
|
|
4754
|
+
);
|
|
3933
4755
|
const onExport = useCallback(() => {
|
|
3934
4756
|
if (selectedDocument) {
|
|
3935
4757
|
return exportDocument(selectedDocument);
|
|
@@ -3951,6 +4773,7 @@ function DocumentEditorContainer() {
|
|
|
3951
4773
|
onChange: onDocumentChangeHandler,
|
|
3952
4774
|
onClose,
|
|
3953
4775
|
onExport,
|
|
4776
|
+
onGetDocumentRevision,
|
|
3954
4777
|
onAddOperation: handleAddOperationToSelectedDocument,
|
|
3955
4778
|
onOpenSwitchboardLink
|
|
3956
4779
|
}
|
|
@@ -3959,165 +4782,6 @@ function DocumentEditorContainer() {
|
|
|
3959
4782
|
fileNodeDocument.documentId
|
|
3960
4783
|
);
|
|
3961
4784
|
}
|
|
3962
|
-
function getDocumentSpec(doc) {
|
|
3963
|
-
if ("documentModelState" in doc) {
|
|
3964
|
-
return doc.documentModelState;
|
|
3965
|
-
}
|
|
3966
|
-
return doc.documentModel;
|
|
3967
|
-
}
|
|
3968
|
-
const CreateDocument = ({ documentModels, createDocument }) => {
|
|
3969
|
-
return jsxs("div", { className: "px-6", children: [jsx("h3", { className: "mb-3 mt-4 text-xl font-bold text-gray-600", children: "New document" }), jsx("div", { className: "flex w-full flex-wrap gap-4", children: documentModels == null ? void 0 : documentModels.map((doc) => {
|
|
3970
|
-
const spec = getDocumentSpec(doc);
|
|
3971
|
-
return jsx(Button, { color: "light", "aria-details": spec.description, onClick: () => createDocument(doc), children: jsx("span", { className: "text-sm", children: spec.name }) }, spec.id);
|
|
3972
|
-
}) })] });
|
|
3973
|
-
};
|
|
3974
|
-
function sortUiNodesByName(a, b) {
|
|
3975
|
-
return a.name.localeCompare(b.name);
|
|
3976
|
-
}
|
|
3977
|
-
const GAP = 8;
|
|
3978
|
-
const ITEM_WIDTH = 256;
|
|
3979
|
-
const ITEM_HEIGHT = 48;
|
|
3980
|
-
const USED_SPACE = 420;
|
|
3981
|
-
function FileContentView(props) {
|
|
3982
|
-
const parentRef = useRef(null);
|
|
3983
|
-
const { t } = useTranslation();
|
|
3984
|
-
const windowSize = useWindowSize();
|
|
3985
|
-
const { fileNodes, ...fileProps } = props;
|
|
3986
|
-
const availableWidth = windowSize.innerWidth - USED_SPACE;
|
|
3987
|
-
const columnCount = Math.floor(availableWidth / (ITEM_WIDTH + GAP)) || 1;
|
|
3988
|
-
const rowCount = Math.ceil(fileNodes.length / columnCount);
|
|
3989
|
-
const rowVirtualizer = useVirtualizer({
|
|
3990
|
-
count: rowCount,
|
|
3991
|
-
getScrollElement: () => parentRef.current,
|
|
3992
|
-
estimateSize: (index) => {
|
|
3993
|
-
if (index > 0) {
|
|
3994
|
-
return ITEM_HEIGHT + GAP;
|
|
3995
|
-
}
|
|
3996
|
-
return ITEM_HEIGHT;
|
|
3997
|
-
},
|
|
3998
|
-
overscan: 5
|
|
3999
|
-
});
|
|
4000
|
-
const columnVirtualizer = useVirtualizer({
|
|
4001
|
-
horizontal: true,
|
|
4002
|
-
count: columnCount,
|
|
4003
|
-
getScrollElement: () => parentRef.current,
|
|
4004
|
-
estimateSize: (index) => {
|
|
4005
|
-
if (index > 0) {
|
|
4006
|
-
return ITEM_WIDTH + GAP;
|
|
4007
|
-
}
|
|
4008
|
-
return ITEM_WIDTH;
|
|
4009
|
-
},
|
|
4010
|
-
overscan: 5
|
|
4011
|
-
});
|
|
4012
|
-
const getItemIndex = (rowIndex, columnIndex) => rowIndex * columnCount + columnIndex;
|
|
4013
|
-
const getItem = (rowIndex, columnIndex) => {
|
|
4014
|
-
const index = getItemIndex(rowIndex, columnIndex);
|
|
4015
|
-
return fileNodes[index] || null;
|
|
4016
|
-
};
|
|
4017
|
-
if (fileNodes.length === 0) {
|
|
4018
|
-
return jsx("div", { className: "mb-8 text-sm text-gray-400", children: t("folderView.sections.documents.empty", {
|
|
4019
|
-
defaultValue: "No documents or files 📄"
|
|
4020
|
-
}) });
|
|
4021
|
-
}
|
|
4022
|
-
const renderItem = (rowIndex, columnIndex) => {
|
|
4023
|
-
const fileNode = getItem(rowIndex, columnIndex);
|
|
4024
|
-
if (!fileNode) {
|
|
4025
|
-
return null;
|
|
4026
|
-
}
|
|
4027
|
-
return jsx("div", { style: {
|
|
4028
|
-
marginLeft: columnIndex === 0 ? 0 : GAP
|
|
4029
|
-
}, children: jsx(FileItem, { uiNode: fileNode, ...fileProps }, fileNode.id) });
|
|
4030
|
-
};
|
|
4031
|
-
return jsx("div", { ref: parentRef, style: {
|
|
4032
|
-
height: `400px`,
|
|
4033
|
-
width: `100%`,
|
|
4034
|
-
overflow: "auto"
|
|
4035
|
-
}, children: jsx("div", { style: {
|
|
4036
|
-
height: `${rowVirtualizer.getTotalSize()}px`,
|
|
4037
|
-
width: `${columnVirtualizer.getTotalSize()}px`,
|
|
4038
|
-
position: "relative"
|
|
4039
|
-
}, children: rowVirtualizer.getVirtualItems().map((virtualRow) => jsx(React__default.Fragment, { children: columnVirtualizer.getVirtualItems().map((virtualColumn) => jsx("div", { style: {
|
|
4040
|
-
position: "absolute",
|
|
4041
|
-
top: 0,
|
|
4042
|
-
left: 0,
|
|
4043
|
-
marginTop: virtualRow.index === 0 ? 0 : GAP,
|
|
4044
|
-
width: `${virtualColumn.size}px`,
|
|
4045
|
-
height: `${virtualRow.size}px`,
|
|
4046
|
-
transform: `translateX(${virtualColumn.start}px) translateY(${virtualRow.start}px)`
|
|
4047
|
-
}, children: renderItem(virtualRow.index, virtualColumn.index) }, virtualColumn.key)) }, virtualRow.key)) }) });
|
|
4048
|
-
}
|
|
4049
|
-
function FolderView(props) {
|
|
4050
|
-
const { node, className, isDropTarget, containerProps, ...nodeProps } = props;
|
|
4051
|
-
const { t } = useTranslation();
|
|
4052
|
-
const folderNodes = node.children.filter((node2) => node2.kind === FOLDER).sort(sortUiNodesByName);
|
|
4053
|
-
const fileNodes = node.children.filter((node2) => node2.kind === FILE).sort(sortUiNodesByName);
|
|
4054
|
-
const folderCallbacks = {
|
|
4055
|
-
onSelectNode: (node2) => nodeProps.onSelectNode(node2),
|
|
4056
|
-
onRenameNode: (name, node2) => nodeProps.onRenameNode(name, node2),
|
|
4057
|
-
onDuplicateNode: (node2) => nodeProps.onDuplicateNode(node2),
|
|
4058
|
-
onDeleteNode: (node2) => nodeProps.onDeleteNode(node2)
|
|
4059
|
-
};
|
|
4060
|
-
const fileCallbacks = {
|
|
4061
|
-
onSelectNode: (node2) => nodeProps.onSelectNode(node2),
|
|
4062
|
-
onRenameNode: (name, node2) => nodeProps.onRenameNode(name, node2),
|
|
4063
|
-
onDuplicateNode: (node2) => nodeProps.onDuplicateNode(node2),
|
|
4064
|
-
onDeleteNode: (node2) => nodeProps.onDeleteNode(node2)
|
|
4065
|
-
};
|
|
4066
|
-
const baseNodeCallbacks = {
|
|
4067
|
-
onAddFile: async (file, parentNode) => {
|
|
4068
|
-
await nodeProps.onAddFile(file, parentNode);
|
|
4069
|
-
},
|
|
4070
|
-
onCopyNode: async (uiNode, targetNode) => {
|
|
4071
|
-
await nodeProps.onCopyNode(uiNode, targetNode);
|
|
4072
|
-
},
|
|
4073
|
-
onMoveNode: async (uiNode, targetNode) => {
|
|
4074
|
-
await nodeProps.onMoveNode(uiNode, targetNode);
|
|
4075
|
-
}
|
|
4076
|
-
};
|
|
4077
|
-
return jsxs("div", { className: twMerge("rounded-md border-2 border-transparent p-2", isDropTarget && "border-dashed border-blue-100", className), ...containerProps, children: [jsx(DriveLayout.ContentSection, { title: t("folderView.sections.folders.title", {
|
|
4078
|
-
defaultValue: "Folders"
|
|
4079
|
-
}), className: "mb-4", children: folderNodes.length > 0 ? folderNodes.map((folderNode) => jsx(FolderItem, { uiNode: folderNode, ...baseNodeCallbacks, ...folderCallbacks, isAllowedToCreateDocuments: nodeProps.isAllowedToCreateDocuments }, folderNode.id)) : jsx("div", { className: "mb-8 text-sm text-gray-400", children: t("folderView.sections.folders.empty", {
|
|
4080
|
-
defaultValue: "No documents or files 📄"
|
|
4081
|
-
}) }) }), jsx(DriveLayout.ContentSection, { title: t("folderView.sections.documents.title", {
|
|
4082
|
-
defaultValue: "Documents and files"
|
|
4083
|
-
}), children: jsx("div", { className: twMerge("w-full", fileNodes.length > 0 ? "min-h-[400px]" : "min-h-14"), children: jsx(FileContentView, { fileNodes, ...fileCallbacks, isAllowedToCreateDocuments: nodeProps.isAllowedToCreateDocuments }) }) })] });
|
|
4084
|
-
}
|
|
4085
|
-
function BaseEditor(props) {
|
|
4086
|
-
const { document: document2, dispatch, className, children } = props;
|
|
4087
|
-
const { state: { global: { id: driveId } } } = document2;
|
|
4088
|
-
const { showSearchBar, isAllowedToCreateDocuments, documentModels, showCreateDocumentModal } = useDriveContext();
|
|
4089
|
-
const { driveNodes, selectedNode, selectedNodePath, getNodeById, setSelectedNode } = useUiNodesContext();
|
|
4090
|
-
const driveNode = useMemo(() => driveNodes.find((n) => n.id === driveId), [driveNodes, driveId]);
|
|
4091
|
-
const { addDocument, addFile, addFolder: addFolder2, renameNode, deleteNode: deleteNode2, moveNode: moveNode2, copyNode: copyNode2, duplicateNode } = useDriveActionsWithUiNodes(document2, dispatch);
|
|
4092
|
-
const onCreateDocument = useCallback(async (documentModel) => {
|
|
4093
|
-
const { name } = await showCreateDocumentModal(documentModel);
|
|
4094
|
-
const document3 = documentModel.utils.createDocument();
|
|
4095
|
-
await addDocument(name, documentModel.documentModel.name, document3, selectedNode == null ? void 0 : selectedNode.id);
|
|
4096
|
-
}, [addDocument, showCreateDocumentModal, selectedNode == null ? void 0 : selectedNode.id]);
|
|
4097
|
-
const { isDropTarget, dropProps } = useDrop({
|
|
4098
|
-
uiNode: selectedNode,
|
|
4099
|
-
onAddFile: addFile,
|
|
4100
|
-
onCopyNode: copyNode2,
|
|
4101
|
-
onMoveNode: moveNode2
|
|
4102
|
-
});
|
|
4103
|
-
const { breadcrumbs, onBreadcrumbSelected } = useBreadcrumbs({
|
|
4104
|
-
selectedNodePath,
|
|
4105
|
-
getNodeById,
|
|
4106
|
-
setSelectedNode
|
|
4107
|
-
});
|
|
4108
|
-
if (!driveNode) {
|
|
4109
|
-
return jsx("div", { children: "Drive not found" });
|
|
4110
|
-
} else if ((selectedNode == null ? void 0 : selectedNode.kind) === FILE$1) {
|
|
4111
|
-
return jsx(Fragment$1, {});
|
|
4112
|
-
}
|
|
4113
|
-
return jsxs(DriveLayout, { className, children: [children, jsxs(DriveLayout.Header, { children: [jsx(Breadcrumbs, { breadcrumbs, createEnabled: isAllowedToCreateDocuments, onCreate: addFolder2, onBreadcrumbSelected }), showSearchBar && jsx(SearchBar, {})] }), jsx(DriveLayout.Content, { children: jsx(FolderView, { node: selectedNode || driveNode, onSelectNode: setSelectedNode, onRenameNode: renameNode, onDuplicateNode: duplicateNode, onDeleteNode: deleteNode2, onAddFile: addFile, onCopyNode: copyNode2, onMoveNode: moveNode2, isDropTarget, isAllowedToCreateDocuments }) }), jsx(DriveLayout.Footer, { children: isAllowedToCreateDocuments && jsx(CreateDocument, { documentModels, createDocument: onCreateDocument }) })] });
|
|
4114
|
-
}
|
|
4115
|
-
function Editor(props) {
|
|
4116
|
-
return jsx(DriveContextProvider, { value: props.context, children: jsx(BaseEditor, { ...props }) });
|
|
4117
|
-
}
|
|
4118
|
-
const GenericDriveExplorer = {
|
|
4119
|
-
Component: Editor
|
|
4120
|
-
};
|
|
4121
4785
|
function useDocumentsState(args) {
|
|
4122
4786
|
const { reactor, driveId, documentIds, options } = args;
|
|
4123
4787
|
const [statesByDocumentId, setStatesByDocumentId] = useState({});
|
|
@@ -4304,6 +4968,17 @@ function DriveEditorContainer() {
|
|
|
4304
4968
|
const { addFile, addDocument } = useDocumentDriveServer();
|
|
4305
4969
|
const documentModels = useFilteredDocumentModels();
|
|
4306
4970
|
const useDriveDocumentState = makeDriveDocumentStateHook(reactor);
|
|
4971
|
+
const getDocument = useGetDocument();
|
|
4972
|
+
const onGetDocumentRevision = useCallback(
|
|
4973
|
+
(documentId, options) => {
|
|
4974
|
+
if (!selectedNode) {
|
|
4975
|
+
console.error("No selected node");
|
|
4976
|
+
return Promise.reject(new Error("No selected node"));
|
|
4977
|
+
}
|
|
4978
|
+
return getDocument(selectedNode.driveId, documentId, options);
|
|
4979
|
+
},
|
|
4980
|
+
[getDocument, selectedNode]
|
|
4981
|
+
);
|
|
4307
4982
|
const driveContext = useMemo(
|
|
4308
4983
|
() => ({
|
|
4309
4984
|
showSearchBar: false,
|
|
@@ -4346,7 +5021,8 @@ function DriveEditorContainer() {
|
|
|
4346
5021
|
...editorProps,
|
|
4347
5022
|
context: {
|
|
4348
5023
|
...editorProps.context,
|
|
4349
|
-
...driveContext
|
|
5024
|
+
...driveContext,
|
|
5025
|
+
getDocumentRevision: onGetDocumentRevision
|
|
4350
5026
|
},
|
|
4351
5027
|
onSwitchboardLinkClick: void 0,
|
|
4352
5028
|
document: document2,
|
|
@@ -4380,7 +5056,7 @@ function Content() {
|
|
|
4380
5056
|
}, [selectedDriveNode, selectedNode, addFile]);
|
|
4381
5057
|
useEffect(() => {
|
|
4382
5058
|
if ((status === "LOADED" || status === "ERROR") && !documentDrives.find(
|
|
4383
|
-
(d) => d.state.global.id === driveId || d.
|
|
5059
|
+
(d) => d.state.global.id === driveId || d.slug === driveId || d.state.global.name === driveId
|
|
4384
5060
|
)) {
|
|
4385
5061
|
toast(/* @__PURE__ */ jsxs("p", { children: [
|
|
4386
5062
|
"Drive ",
|
|
@@ -4395,3 +5071,4 @@ function Content() {
|
|
|
4395
5071
|
export {
|
|
4396
5072
|
Content as default
|
|
4397
5073
|
};
|
|
5074
|
+
//# sourceMappingURL=content-B1Gquii9.js.map
|