@dimah-s3/ui 2.0.0-beta.1 → 2.0.0-beta.3
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/components/dimah-s3/attachment/file-name.d.ts +5 -0
- package/dist/components/dimah-s3/attachment/file-name.d.ts.map +1 -1
- package/dist/components/dimah-s3/list/object-list-context.d.ts +12 -2
- package/dist/components/dimah-s3/list/object-list-context.d.ts.map +1 -1
- package/dist/components/dimah-s3/list/object-list-entry.d.ts.map +1 -1
- package/dist/components/dimah-s3/list/object-list-item-menu.d.ts +6 -4
- package/dist/components/dimah-s3/list/object-list-item-menu.d.ts.map +1 -1
- package/dist/components/dimah-s3/list/object-list-keyboard.d.ts +3 -1
- package/dist/components/dimah-s3/list/object-list-keyboard.d.ts.map +1 -1
- package/dist/components/dimah-s3/list/object-list-rename.d.ts +11 -0
- package/dist/components/dimah-s3/list/object-list-rename.d.ts.map +1 -0
- package/dist/components/dimah-s3/list/object-list.d.ts.map +1 -1
- package/dist/index.js +258 -37
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import type { ComponentProps } from "react";
|
|
2
|
+
/** The stem, and a short extension kept visible while the stem shortens. */
|
|
3
|
+
export declare function splitFileName(name: string): {
|
|
4
|
+
stem: string;
|
|
5
|
+
extension: string;
|
|
6
|
+
};
|
|
2
7
|
/** Props for {@link FileName}. Other props go to the outer `<span>`. */
|
|
3
8
|
export type FileNameProps = Omit<ComponentProps<"span">, "children"> & {
|
|
4
9
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-name.d.ts","sourceRoot":"","sources":["../../../../src/components/dimah-s3/attachment/file-name.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"file-name.d.ts","sourceRoot":"","sources":["../../../../src/components/dimah-s3/attachment/file-name.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAM5C,4EAA4E;AAC5E,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB,CAMA;AAED,wEAAwE;AACxE,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC,GAAG;IACrE,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,EACvB,IAAI,EACJ,SAAS,EAAE,aAAoB,EAC/B,SAAS,EACT,GAAG,KAAK,EACT,EAAE,aAAa,+BAgBf"}
|
|
@@ -8,8 +8,9 @@ export type ObjectListRenderers<TItem> = {
|
|
|
8
8
|
renderEntry?: (entry: ObjectListEntry<TItem>) => ReactNode;
|
|
9
9
|
/**
|
|
10
10
|
* Trailing controls. Defaults to `ObjectListItemMenu` on files when the
|
|
11
|
-
* list has `download`, `share`, or `
|
|
12
|
-
* can be uploaded into them
|
|
11
|
+
* list has `download`, `share`, `delete`, or `renameFile`, and on folders
|
|
12
|
+
* when files can be uploaded into them or the source has `renameFolder`.
|
|
13
|
+
* Return `null` to hide them.
|
|
13
14
|
*/
|
|
14
15
|
renderActions?: (entry: ObjectListEntry<TItem>) => ReactNode;
|
|
15
16
|
/**
|
|
@@ -55,6 +56,15 @@ export type ObjectListContextValue<TItem> = ObjectListRenderers<TItem> & {
|
|
|
55
56
|
onOpenItem: ((item: TItem) => void) | undefined;
|
|
56
57
|
/** Object keys stored in a folder. Lets bulk delete include folders. */
|
|
57
58
|
resolveFolderKeys: ((folder: ObjectListFolder) => Promise<readonly string[]>) | undefined;
|
|
59
|
+
/** Entry key whose name is a field, or `null`. */
|
|
60
|
+
renamingKey: string | null;
|
|
61
|
+
/** Turn that entry's name into the rename field. */
|
|
62
|
+
startRename: (key: string) => void;
|
|
63
|
+
/**
|
|
64
|
+
* Close the rename field. With `focus`, the row takes focus once its
|
|
65
|
+
* button is back.
|
|
66
|
+
*/
|
|
67
|
+
cancelRename: (focus?: boolean) => void;
|
|
58
68
|
};
|
|
59
69
|
export declare function ObjectListProvider<TItem>({ value, children, }: {
|
|
60
70
|
value: ObjectListContextValue<TItem>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object-list-context.d.ts","sourceRoot":"","sources":["../../../../src/components/dimah-s3/list/object-list-context.tsx"],"names":[],"mappings":"AAEA,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAClE,OAAO,KAAK,EACV,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,4BAA4B,EAC5B,eAAe,EAChB,MAAM,iBAAiB,CAAC;AAEzB,+EAA+E;AAC/E,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,CAAC;AAE7C,sEAAsE;AACtE,MAAM,MAAM,mBAAmB,CAAC,KAAK,IAAI;IACvC,qGAAqG;IACrG,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,CAAC,KAAK,CAAC,KAAK,SAAS,CAAC;IAC3D
|
|
1
|
+
{"version":3,"file":"object-list-context.d.ts","sourceRoot":"","sources":["../../../../src/components/dimah-s3/list/object-list-context.tsx"],"names":[],"mappings":"AAEA,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAClE,OAAO,KAAK,EACV,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,4BAA4B,EAC5B,eAAe,EAChB,MAAM,iBAAiB,CAAC;AAEzB,+EAA+E;AAC/E,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,CAAC;AAE7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,CAAC,KAAK,CAAC,GAAG,IAAI,CAExC;AAED,2DAA2D;AAC3D,wBAAgB,kBAAkB,CAChC,KAAK,GAAG,OAAO,KACZ,eAAe,CAAC,KAAK,CAAC,GAAG,IAAI,CAEjC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object-list-entry.d.ts","sourceRoot":"","sources":["../../../../src/components/dimah-s3/list/object-list-entry.tsx"],"names":[],"mappings":"AAEA,OAAO,EAA2B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,EAIL,KAAK,eAAe,EACrB,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"object-list-entry.d.ts","sourceRoot":"","sources":["../../../../src/components/dimah-s3/list/object-list-entry.tsx"],"names":[],"mappings":"AAEA,OAAO,EAA2B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,EAIL,KAAK,eAAe,EACrB,MAAM,iBAAiB,CAAC;AAezB,wEAAwE;AACxE,MAAM,MAAM,oBAAoB,CAAC,KAAK,IAAI;IACxC,KAAK,EAAE,eAAe,CAAC,KAAK,CAAC,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mEAAmE;IACnE,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,iEAAiE;IACjE,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,iDAAiD;IACjD,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,sCAAsC;IACtC,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC;AAEF,sEAAsE;AACtE,wBAAgB,kBAAkB,CAAC,EACjC,OAAO,EACP,aAAa,EACb,KAAK,EACL,eAAe,EACf,SAAS,GACV,EAAE;IACD,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IAC/D,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,+BAuBA;AAMD,kCAAkC;AAClC,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,EAAE,oBAAoB,CAAC,KAAK,CAAC,+BAyEtE;AAED,mCAAmC;AACnC,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,EAAE,oBAAoB,CAAC,KAAK,CAAC,+BA0EvE"}
|
|
@@ -36,8 +36,8 @@ export type ObjectListItemMenuProps = {
|
|
|
36
36
|
*/
|
|
37
37
|
expiresIn?: number;
|
|
38
38
|
/**
|
|
39
|
-
* Extra rows, after Copy link and before Delete.
|
|
40
|
-
* Use this for actions the menu does not provide
|
|
39
|
+
* Extra rows, after Copy link and Rename, and before Delete.
|
|
40
|
+
* Use this for actions the menu does not provide.
|
|
41
41
|
*/
|
|
42
42
|
actions?: readonly ObjectListMenuAction[];
|
|
43
43
|
/** More `DropdownMenuItem`s, after `actions`. */
|
|
@@ -48,9 +48,11 @@ export type ObjectListItemMenuProps = {
|
|
|
48
48
|
/**
|
|
49
49
|
* Overflow menu for one entry.
|
|
50
50
|
*
|
|
51
|
-
* - Files: Download, Copy link,
|
|
51
|
+
* - Files: Download, Copy link, Rename when the source has `renameFile`,
|
|
52
|
+
* your actions, Delete.
|
|
52
53
|
* - Folders: Upload to this folder (the keyboard path to a folder drop),
|
|
53
|
-
*
|
|
54
|
+
* Rename when the source has `renameFolder`, then your actions. Upload
|
|
55
|
+
* is disabled while the list's `upload` is.
|
|
54
56
|
*
|
|
55
57
|
* Inside an `ObjectList` every prop is optional: the key, name, size, and
|
|
56
58
|
* hooks come from the entry and the list. Download runs the list's
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object-list-item-menu.d.ts","sourceRoot":"","sources":["../../../../src/components/dimah-s3/list/object-list-item-menu.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAoB,KAAK,SAAS,EAAkB,MAAM,OAAO,CAAC;AAEzE,OAAO,EAGL,KAAK,iBAAiB,EACvB,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"object-list-item-menu.d.ts","sourceRoot":"","sources":["../../../../src/components/dimah-s3/list/object-list-item-menu.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAoB,KAAK,SAAS,EAAkB,MAAM,OAAO,CAAC;AAEzE,OAAO,EAGL,KAAK,iBAAiB,EACvB,MAAM,iBAAiB,CAAC;AA8BzB,mDAAmD;AACnD,MAAM,MAAM,oBAAoB,GAAG;IACjC,iBAAiB;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,6BAA6B;IAC7B,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,+DAA+D;IAC/D,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,4CAA4C;AAC5C,MAAM,MAAM,uBAAuB,GAAG;IACpC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oEAAoE;IACpE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,oBAAoB,EAAE,CAAC;IAC1C,iDAAiD;IACjD,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,qCAAqC;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,SAAS,EAAE,aAAa,EACxB,QAAQ,EAAE,YAAY,EACtB,QAAQ,EAAE,YAAY,EACtB,KAAK,EAAE,SAAS,EAChB,SAAS,EACT,OAAO,EACP,QAAQ,EACR,SAAS,GACV,EAAE,uBAAuB,sCA8IzB"}
|
|
@@ -7,13 +7,15 @@ import type { ObjectListView } from "./object-list-context.js";
|
|
|
7
7
|
* - Space on an entry: toggle its checkbox. Shift extends the range.
|
|
8
8
|
* - Ctrl+A / Cmd+A: select every loaded entry. Escape: clear.
|
|
9
9
|
* - Backspace or Alt+ArrowUp: open the parent folder.
|
|
10
|
+
* - F2: rename the focused row, when the source can.
|
|
10
11
|
*
|
|
11
12
|
* Fields, menus, and dialogs keep their own keys.
|
|
12
13
|
*/
|
|
13
|
-
export declare function useObjectListKeyboard<TItem>({ list, selection, view, }: {
|
|
14
|
+
export declare function useObjectListKeyboard<TItem>({ list, selection, view, startRename, }: {
|
|
14
15
|
list: UseObjectListReturn<TItem>;
|
|
15
16
|
selection: UseObjectListSelectionReturn<TItem> | null;
|
|
16
17
|
view: ObjectListView;
|
|
18
|
+
startRename: (key: string) => void;
|
|
17
19
|
}): {
|
|
18
20
|
onKeyDown: (event: KeyboardEvent<HTMLElement>) => void;
|
|
19
21
|
onKeyUp: (event: KeyboardEvent<HTMLElement>) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object-list-keyboard.d.ts","sourceRoot":"","sources":["../../../../src/components/dimah-s3/list/object-list-keyboard.ts"],"names":[],"mappings":"AAEA,OAAO,EAAU,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,KAAK,EACV,mBAAmB,EACnB,4BAA4B,EAC7B,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gDAAgD,CAAC;
|
|
1
|
+
{"version":3,"file":"object-list-keyboard.d.ts","sourceRoot":"","sources":["../../../../src/components/dimah-s3/list/object-list-keyboard.ts"],"names":[],"mappings":"AAEA,OAAO,EAAU,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,KAAK,EACV,mBAAmB,EACnB,4BAA4B,EAC7B,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gDAAgD,CAAC;AAOrF;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,EAC3C,IAAI,EACJ,SAAS,EACT,IAAI,EACJ,WAAW,GACZ,EAAE;IACD,IAAI,EAAE,mBAAmB,CAAC,KAAK,CAAC,CAAC;IACjC,SAAS,EAAE,4BAA4B,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;IACtD,IAAI,EAAE,cAAc,CAAC;IACrB,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC;uBAW2B,aAAa,CAAC,WAAW,CAAC;qBAuD5B,aAAa,CAAC,WAAW,CAAC;EAOnD"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ObjectListEntry, type UseObjectListReturn } from "@dimah-s3/react";
|
|
2
|
+
/** True when the source can rename this entry. */
|
|
3
|
+
export declare function canRenameEntry<TItem>(entry: ObjectListEntry<TItem>, list: UseObjectListReturn<TItem>): boolean;
|
|
4
|
+
/**
|
|
5
|
+
* The name field for the entry being renamed. Enter saves, Escape restores
|
|
6
|
+
* the name, and leaving the field saves. Mounted by the default row and tile.
|
|
7
|
+
*/
|
|
8
|
+
export declare function ObjectListRenameField<TItem>({ entry, }: {
|
|
9
|
+
entry: ObjectListEntry<TItem>;
|
|
10
|
+
}): import("react").JSX.Element;
|
|
11
|
+
//# sourceMappingURL=object-list-rename.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object-list-rename.d.ts","sourceRoot":"","sources":["../../../../src/components/dimah-s3/list/object-list-rename.tsx"],"names":[],"mappings":"AAUA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACzB,MAAM,iBAAiB,CAAC;AASzB,kDAAkD;AAClD,wBAAgB,cAAc,CAAC,KAAK,EAClC,KAAK,EAAE,eAAe,CAAC,KAAK,CAAC,EAC7B,IAAI,EAAE,mBAAmB,CAAC,KAAK,CAAC,GAC/B,OAAO,CAIT;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,EAC3C,KAAK,GACN,EAAE;IACD,KAAK,EAAE,eAAe,CAAC,KAAK,CAAC,CAAC;CAC/B,+BAmKA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object-list.d.ts","sourceRoot":"","sources":["../../../../src/components/dimah-s3/list/object-list.tsx"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"object-list.d.ts","sourceRoot":"","sources":["../../../../src/components/dimah-s3/list/object-list.tsx"],"names":[],"mappings":"AAEA,OAAO,EAQL,KAAK,SAAS,EAEf,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EACV,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,4BAA4B,EAC5B,eAAe,EAChB,MAAM,iBAAiB,CAAC;AAgBzB,OAAO,EAIL,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACpB,MAAM,gDAAgD,CAAC;AAgBxD,oCAAoC;AACpC,MAAM,MAAM,eAAe,CAAC,KAAK,IAAI,mBAAmB,CAAC,KAAK,CAAC,GAAG;IAChE,2EAA2E;IAC3E,IAAI,EAAE,mBAAmB,CAAC,KAAK,CAAC,CAAC;IACjC;;;OAGG;IACH,SAAS,CAAC,EAAE,4BAA4B,CAAC,KAAK,CAAC,CAAC;IAChD;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB;;;OAGG;IACH,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAC7B;;;OAGG;IACH,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B;;;;;OAKG;IACH,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,oDAAoD;IACpD,IAAI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jB,OAAO,EACP,gBAAgB,EAChB,KAAK,EACL,QAAiB,EACjB,MAAM,EACN,SAAS,EACT,SAAS,EACT,QAAQ,EACR,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,UAAU,GACX,EAAE,eAAe,CAAC,KAAK,CAAC,+BAmKxB"}
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { createContext, useContext, useMemo, useId, useRef, useCallback, useEffect, useState, useSyncExternalStore, useEffectEvent, useLayoutEffect } from 'react';
|
|
3
3
|
import { truncateFileName, objectKeyOf, mergeUploadRequest } from '@dimah-s3/react/engine';
|
|
4
4
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
|
-
import { CloudUpload, XIcon, RotateCwIcon, PauseIcon, BanIcon, FileUpIcon, CameraIcon, Trash2Icon, LoaderIcon, DownloadIcon, MoreHorizontalIcon, LinkIcon, SearchIcon, HomeIcon, FolderIcon, FolderPlusIcon, CheckIcon, ArrowDownUpIcon, ListIcon, LayoutGridIcon, UserIcon, LoaderCircleIcon, AlertCircleIcon, CheckCircleIcon, MinusIcon, ChevronRightIcon, Loader2Icon, CircleCheckIcon, InfoIcon, TriangleAlertIcon, OctagonXIcon } from 'lucide-react';
|
|
5
|
+
import { CloudUpload, XIcon, RotateCwIcon, PauseIcon, BanIcon, FileUpIcon, CameraIcon, Trash2Icon, LoaderIcon, DownloadIcon, MoreHorizontalIcon, PencilIcon, LinkIcon, SearchIcon, HomeIcon, FolderIcon, FolderPlusIcon, CheckIcon, ArrowDownUpIcon, ListIcon, LayoutGridIcon, UserIcon, LoaderCircleIcon, AlertCircleIcon, CheckCircleIcon, MinusIcon, ChevronRightIcon, Loader2Icon, CircleCheckIcon, InfoIcon, TriangleAlertIcon, OctagonXIcon } from 'lucide-react';
|
|
6
6
|
import { useTranslations } from '@fuma-translate/react';
|
|
7
7
|
import { cn } from 'cn';
|
|
8
8
|
import { Button as Button$1 } from '@base-ui/react/button';
|
|
@@ -3252,6 +3252,179 @@ function ObjectListAnnouncer({
|
|
|
3252
3252
|
}
|
|
3253
3253
|
);
|
|
3254
3254
|
}
|
|
3255
|
+
function Spinner({
|
|
3256
|
+
className,
|
|
3257
|
+
...props
|
|
3258
|
+
}) {
|
|
3259
|
+
return /* @__PURE__ */ jsx(
|
|
3260
|
+
Loader2Icon,
|
|
3261
|
+
{
|
|
3262
|
+
"data-slot": "spinner",
|
|
3263
|
+
role: "status",
|
|
3264
|
+
"aria-label": "Loading",
|
|
3265
|
+
className: cn("size-4 animate-spin", className),
|
|
3266
|
+
...props
|
|
3267
|
+
}
|
|
3268
|
+
);
|
|
3269
|
+
}
|
|
3270
|
+
function canRenameEntry(entry, list) {
|
|
3271
|
+
return entry.kind === "file" ? list.renameFile != null : list.renameFolder != null;
|
|
3272
|
+
}
|
|
3273
|
+
function ObjectListRenameField({
|
|
3274
|
+
entry
|
|
3275
|
+
}) {
|
|
3276
|
+
const t = useTranslations();
|
|
3277
|
+
const formatError = useFormatDimahError();
|
|
3278
|
+
const { list, cancelRename } = useObjectListContext();
|
|
3279
|
+
const inputId = useId();
|
|
3280
|
+
const errorId = useId();
|
|
3281
|
+
const inputRef = useRef(null);
|
|
3282
|
+
const lock = useRef(false);
|
|
3283
|
+
const closed = useRef(false);
|
|
3284
|
+
const [name, setName] = useState(entry.name);
|
|
3285
|
+
const [pending, setPending] = useState(false);
|
|
3286
|
+
const [error, setError] = useState(null);
|
|
3287
|
+
const folder = entry.kind === "folder";
|
|
3288
|
+
const label = folder ? t("Folder name", { note: "object list new folder" }) : t("File name", { note: "object list rename" });
|
|
3289
|
+
useEffect(() => {
|
|
3290
|
+
const input = inputRef.current;
|
|
3291
|
+
if (!input) return;
|
|
3292
|
+
input.focus();
|
|
3293
|
+
const end = folder ? entry.name.length : splitFileName(entry.name).stem.length;
|
|
3294
|
+
input.setSelectionRange(0, end);
|
|
3295
|
+
}, [entry.name, folder]);
|
|
3296
|
+
function finish(focus) {
|
|
3297
|
+
if (closed.current) return;
|
|
3298
|
+
closed.current = true;
|
|
3299
|
+
cancelRename(focus);
|
|
3300
|
+
}
|
|
3301
|
+
async function save(focus) {
|
|
3302
|
+
if (closed.current || lock.current) return;
|
|
3303
|
+
const trimmed = name.trim();
|
|
3304
|
+
if (!trimmed) {
|
|
3305
|
+
setError(
|
|
3306
|
+
folder ? t("Enter a folder name", { note: "object list new folder" }) : t("Enter a file name", { note: "object list rename" })
|
|
3307
|
+
);
|
|
3308
|
+
return;
|
|
3309
|
+
}
|
|
3310
|
+
if (trimmed === entry.name) {
|
|
3311
|
+
finish(focus);
|
|
3312
|
+
return;
|
|
3313
|
+
}
|
|
3314
|
+
lock.current = true;
|
|
3315
|
+
setPending(true);
|
|
3316
|
+
setError(null);
|
|
3317
|
+
try {
|
|
3318
|
+
if (entry.kind === "folder") {
|
|
3319
|
+
await list.renameFolder?.(entry.folder, trimmed);
|
|
3320
|
+
} else {
|
|
3321
|
+
await list.renameFile?.(entry.item, trimmed);
|
|
3322
|
+
}
|
|
3323
|
+
} catch (err) {
|
|
3324
|
+
lock.current = false;
|
|
3325
|
+
setPending(false);
|
|
3326
|
+
setError(formatError(err));
|
|
3327
|
+
inputRef.current?.focus();
|
|
3328
|
+
return;
|
|
3329
|
+
}
|
|
3330
|
+
finish(focus);
|
|
3331
|
+
}
|
|
3332
|
+
function onBlur(event) {
|
|
3333
|
+
if (closed.current || lock.current) return;
|
|
3334
|
+
const next = event.relatedTarget;
|
|
3335
|
+
if (next instanceof Node && event.currentTarget.contains(next)) return;
|
|
3336
|
+
const trimmed = name.trim();
|
|
3337
|
+
if (!trimmed || trimmed === entry.name) {
|
|
3338
|
+
finish(false);
|
|
3339
|
+
return;
|
|
3340
|
+
}
|
|
3341
|
+
void save(false);
|
|
3342
|
+
}
|
|
3343
|
+
const confirm = /* @__PURE__ */ jsx(
|
|
3344
|
+
Button,
|
|
3345
|
+
{
|
|
3346
|
+
type: "submit",
|
|
3347
|
+
variant: "ghost",
|
|
3348
|
+
size: "icon-sm",
|
|
3349
|
+
className: "shrink-0",
|
|
3350
|
+
"aria-label": t("Rename", { note: "object list menu" }),
|
|
3351
|
+
disabled: pending,
|
|
3352
|
+
focusableWhenDisabled: true,
|
|
3353
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
3354
|
+
children: pending ? /* @__PURE__ */ jsx(Spinner, {}) : /* @__PURE__ */ jsx(CheckIcon, {})
|
|
3355
|
+
}
|
|
3356
|
+
);
|
|
3357
|
+
const cancel = /* @__PURE__ */ jsx(
|
|
3358
|
+
Button,
|
|
3359
|
+
{
|
|
3360
|
+
type: "button",
|
|
3361
|
+
variant: "ghost",
|
|
3362
|
+
size: "icon-sm",
|
|
3363
|
+
className: "shrink-0",
|
|
3364
|
+
"aria-label": t("Cancel", { note: "object list rename" }),
|
|
3365
|
+
disabled: pending,
|
|
3366
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
3367
|
+
onClick: () => finish(true),
|
|
3368
|
+
children: /* @__PURE__ */ jsx(XIcon, {})
|
|
3369
|
+
}
|
|
3370
|
+
);
|
|
3371
|
+
function onSubmit(event) {
|
|
3372
|
+
event.preventDefault();
|
|
3373
|
+
void save(true);
|
|
3374
|
+
}
|
|
3375
|
+
return /* @__PURE__ */ jsxs(
|
|
3376
|
+
"form",
|
|
3377
|
+
{
|
|
3378
|
+
"data-slot": "object-list-rename",
|
|
3379
|
+
"aria-busy": pending || void 0,
|
|
3380
|
+
className: "flex min-w-0 flex-1 flex-col gap-1",
|
|
3381
|
+
onSubmit,
|
|
3382
|
+
onBlur,
|
|
3383
|
+
children: [
|
|
3384
|
+
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-center gap-1", children: [
|
|
3385
|
+
/* @__PURE__ */ jsx("label", { htmlFor: inputId, className: "sr-only", children: label }),
|
|
3386
|
+
/* @__PURE__ */ jsx(
|
|
3387
|
+
"input",
|
|
3388
|
+
{
|
|
3389
|
+
ref: inputRef,
|
|
3390
|
+
id: inputId,
|
|
3391
|
+
value: name,
|
|
3392
|
+
dir: "auto",
|
|
3393
|
+
maxLength: 255,
|
|
3394
|
+
autoComplete: "off",
|
|
3395
|
+
readOnly: pending,
|
|
3396
|
+
"aria-invalid": error != null || void 0,
|
|
3397
|
+
"aria-describedby": error != null ? errorId : void 0,
|
|
3398
|
+
className: cn(
|
|
3399
|
+
"h-7 min-w-0 flex-1 rounded-md border border-dimah-s3-border bg-transparent px-2 text-sm text-dimah-s3-foreground outline-none focus-visible:border-dimah-s3-ring focus-visible:ring-3 focus-visible:ring-dimah-s3-ring/50 aria-invalid:border-dimah-s3-destructive aria-invalid:ring-dimah-s3-destructive/20"
|
|
3400
|
+
),
|
|
3401
|
+
onChange: (event) => {
|
|
3402
|
+
setName(event.target.value);
|
|
3403
|
+
setError(null);
|
|
3404
|
+
},
|
|
3405
|
+
onKeyDown: (event) => {
|
|
3406
|
+
if (event.key !== "Escape" || lock.current) return;
|
|
3407
|
+
event.preventDefault();
|
|
3408
|
+
finish(true);
|
|
3409
|
+
}
|
|
3410
|
+
}
|
|
3411
|
+
),
|
|
3412
|
+
confirm,
|
|
3413
|
+
cancel
|
|
3414
|
+
] }),
|
|
3415
|
+
error != null ? /* @__PURE__ */ jsx(
|
|
3416
|
+
"p",
|
|
3417
|
+
{
|
|
3418
|
+
id: errorId,
|
|
3419
|
+
role: "alert",
|
|
3420
|
+
className: "text-xs [overflow-wrap:anywhere] text-dimah-s3-destructive",
|
|
3421
|
+
children: error
|
|
3422
|
+
}
|
|
3423
|
+
) : null
|
|
3424
|
+
]
|
|
3425
|
+
}
|
|
3426
|
+
);
|
|
3427
|
+
}
|
|
3255
3428
|
function folderUploadCall(list, parent) {
|
|
3256
3429
|
return list.uploadOptions ? { uploadOptions: list.uploadOptions(parent) } : void 0;
|
|
3257
3430
|
}
|
|
@@ -3407,8 +3580,9 @@ function ObjectListItemMenu({
|
|
|
3407
3580
|
const extra = actions ?? [];
|
|
3408
3581
|
const showTransfer = download != null || linkSource != null;
|
|
3409
3582
|
const showExtra = extra.length > 0 || children != null;
|
|
3583
|
+
const canRename = context != null && entry != null && canRenameEntry(entry, context.list);
|
|
3410
3584
|
if (!isFile && !folder) return null;
|
|
3411
|
-
if (!showTransfer && !showExtra && !uploadToFolder && remove == null) {
|
|
3585
|
+
if (!showTransfer && !showExtra && !uploadToFolder && !canRename && remove == null) {
|
|
3412
3586
|
return null;
|
|
3413
3587
|
}
|
|
3414
3588
|
return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
@@ -3432,18 +3606,18 @@ function ObjectListItemMenu({
|
|
|
3432
3606
|
}
|
|
3433
3607
|
),
|
|
3434
3608
|
/* @__PURE__ */ jsxs(DropdownMenuContent, { align: "end", className: "min-w-44", children: [
|
|
3435
|
-
uploadToFolder ? /* @__PURE__ */
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3609
|
+
uploadToFolder || showTransfer || canRename ? /* @__PURE__ */ jsxs(DropdownMenuGroup, { children: [
|
|
3610
|
+
uploadToFolder ? /* @__PURE__ */ jsxs(
|
|
3611
|
+
DropdownMenuItem,
|
|
3612
|
+
{
|
|
3613
|
+
disabled: listUpload?.disabled,
|
|
3614
|
+
onClick: uploadToFolder,
|
|
3615
|
+
children: [
|
|
3616
|
+
/* @__PURE__ */ jsx(CloudUpload, {}),
|
|
3617
|
+
t("Upload to this folder", { note: "object list menu" })
|
|
3618
|
+
]
|
|
3619
|
+
}
|
|
3620
|
+
) : null,
|
|
3447
3621
|
download ? /* @__PURE__ */ jsx(
|
|
3448
3622
|
DownloadItem,
|
|
3449
3623
|
{
|
|
@@ -3461,9 +3635,21 @@ function ObjectListItemMenu({
|
|
|
3461
3635
|
fileName,
|
|
3462
3636
|
expiresIn
|
|
3463
3637
|
}
|
|
3638
|
+
) : null,
|
|
3639
|
+
canRename ? /* @__PURE__ */ jsxs(
|
|
3640
|
+
DropdownMenuItem,
|
|
3641
|
+
{
|
|
3642
|
+
onClick: () => {
|
|
3643
|
+
if (entry) context?.startRename(entry.key);
|
|
3644
|
+
},
|
|
3645
|
+
children: [
|
|
3646
|
+
/* @__PURE__ */ jsx(PencilIcon, {}),
|
|
3647
|
+
t("Rename", { note: "object list menu" })
|
|
3648
|
+
]
|
|
3649
|
+
}
|
|
3464
3650
|
) : null
|
|
3465
3651
|
] }) : null,
|
|
3466
|
-
showExtra && (showTransfer || uploadToFolder) ? /* @__PURE__ */ jsx(DropdownMenuSeparator, {}) : null,
|
|
3652
|
+
showExtra && (showTransfer || uploadToFolder || canRename) ? /* @__PURE__ */ jsx(DropdownMenuSeparator, {}) : null,
|
|
3467
3653
|
showExtra ? /* @__PURE__ */ jsxs(DropdownMenuGroup, { children: [
|
|
3468
3654
|
extra.map((action, index) => /* @__PURE__ */ jsxs(
|
|
3469
3655
|
DropdownMenuItem,
|
|
@@ -3482,7 +3668,7 @@ function ObjectListItemMenu({
|
|
|
3482
3668
|
)),
|
|
3483
3669
|
children
|
|
3484
3670
|
] }) : null,
|
|
3485
|
-
remove && (showTransfer || showExtra) ? /* @__PURE__ */ jsx(DropdownMenuSeparator, {}) : null,
|
|
3671
|
+
remove && (showTransfer || uploadToFolder || canRename || showExtra) ? /* @__PURE__ */ jsx(DropdownMenuSeparator, {}) : null,
|
|
3486
3672
|
remove ? /* @__PURE__ */ jsx(DropdownMenuGroup, { children: /* @__PURE__ */ jsx(
|
|
3487
3673
|
DeleteItem,
|
|
3488
3674
|
{
|
|
@@ -3653,7 +3839,10 @@ function ObjectListRow(props) {
|
|
|
3653
3839
|
),
|
|
3654
3840
|
children: [
|
|
3655
3841
|
parts.checkbox,
|
|
3656
|
-
/* @__PURE__ */ jsxs(
|
|
3842
|
+
parts.renaming ? /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-center gap-2.5 self-stretch", children: [
|
|
3843
|
+
/* @__PURE__ */ jsx("span", { className: "flex size-8 shrink-0 items-center justify-center", children: parts.media ?? /* @__PURE__ */ jsx(EntryMedia, { entry, className: "size-8 rounded-[4px]" }) }),
|
|
3844
|
+
/* @__PURE__ */ jsx(ObjectListRenameField, { entry })
|
|
3845
|
+
] }) : /* @__PURE__ */ jsxs(
|
|
3657
3846
|
EntryTrigger,
|
|
3658
3847
|
{
|
|
3659
3848
|
parts,
|
|
@@ -3703,7 +3892,10 @@ function ObjectListTile(props) {
|
|
|
3703
3892
|
className
|
|
3704
3893
|
),
|
|
3705
3894
|
children: [
|
|
3706
|
-
/* @__PURE__ */ jsxs(
|
|
3895
|
+
parts.renaming ? /* @__PURE__ */ jsxs("div", { className: "flex h-full min-w-0 flex-col", children: [
|
|
3896
|
+
/* @__PURE__ */ jsx("span", { className: "flex aspect-[4/3] w-full items-center justify-center overflow-hidden bg-dimah-s3-muted/60", children: parts.media ?? /* @__PURE__ */ jsx(EntryMedia, { entry, tile: true }) }),
|
|
3897
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 px-2 py-1.5", children: /* @__PURE__ */ jsx(ObjectListRenameField, { entry }) })
|
|
3898
|
+
] }) : /* @__PURE__ */ jsxs(
|
|
3707
3899
|
EntryTrigger,
|
|
3708
3900
|
{
|
|
3709
3901
|
parts,
|
|
@@ -3748,13 +3940,16 @@ function useEntryParts({
|
|
|
3748
3940
|
const defaultDescription = useDefaultDescription(entry);
|
|
3749
3941
|
const selectable = selection != null && selection.canSelect(entry);
|
|
3750
3942
|
const selected = selectable && selection.isSelected(entry.key);
|
|
3943
|
+
const renaming = context.renamingKey === entry.key;
|
|
3944
|
+
const canRename = canRenameEntry(entry, list);
|
|
3751
3945
|
const open = entry.kind === "folder" ? () => list.openFolder(entry.folder) : onOpenItem ? () => onOpenItem(entry.item) : null;
|
|
3752
3946
|
const folderCall = entry.kind === "folder" && upload ? folderUploadCall(list, entry.id) : void 0;
|
|
3753
|
-
const hasMenu = entry.kind === "file" ? context.download != null || context.share != null || context.delete != null : folderCall != null;
|
|
3947
|
+
const hasMenu = entry.kind === "file" ? context.download != null || context.share != null || context.delete != null || canRename : folderCall != null || canRename;
|
|
3754
3948
|
const resolvedActions = actions !== void 0 ? actions : context.renderActions ? context.renderActions(entry) : hasMenu ? /* @__PURE__ */ jsx(ObjectListItemMenu, {}) : null;
|
|
3755
3949
|
return {
|
|
3756
3950
|
selected,
|
|
3757
3951
|
selecting: selection?.isSelecting === true,
|
|
3952
|
+
renaming,
|
|
3758
3953
|
checkbox: selectable && selection ? /* @__PURE__ */ jsx(
|
|
3759
3954
|
ObjectListCheckbox,
|
|
3760
3955
|
{
|
|
@@ -3956,21 +4151,6 @@ function Skeleton({ className, ...props }) {
|
|
|
3956
4151
|
}
|
|
3957
4152
|
);
|
|
3958
4153
|
}
|
|
3959
|
-
function Spinner({
|
|
3960
|
-
className,
|
|
3961
|
-
...props
|
|
3962
|
-
}) {
|
|
3963
|
-
return /* @__PURE__ */ jsx(
|
|
3964
|
-
Loader2Icon,
|
|
3965
|
-
{
|
|
3966
|
-
"data-slot": "spinner",
|
|
3967
|
-
role: "status",
|
|
3968
|
-
"aria-label": "Loading",
|
|
3969
|
-
className: cn("size-4 animate-spin", className),
|
|
3970
|
-
...props
|
|
3971
|
-
}
|
|
3972
|
-
);
|
|
3973
|
-
}
|
|
3974
4154
|
function ObjectListEmpty({
|
|
3975
4155
|
title,
|
|
3976
4156
|
description,
|
|
@@ -4851,7 +5031,8 @@ var TRIGGER = "[data-slot=object-list-entry-trigger]";
|
|
|
4851
5031
|
function useObjectListKeyboard({
|
|
4852
5032
|
list,
|
|
4853
5033
|
selection,
|
|
4854
|
-
view
|
|
5034
|
+
view,
|
|
5035
|
+
startRename
|
|
4855
5036
|
}) {
|
|
4856
5037
|
const spaceRef = useRef(false);
|
|
4857
5038
|
function selectableKey(target) {
|
|
@@ -4886,6 +5067,15 @@ function useObjectListKeyboard({
|
|
|
4886
5067
|
list.goUp();
|
|
4887
5068
|
return;
|
|
4888
5069
|
}
|
|
5070
|
+
if (event.key === "F2" && !modifier && !event.altKey && !event.shiftKey) {
|
|
5071
|
+
if (!target.matches(TRIGGER)) return;
|
|
5072
|
+
const key = target.dataset.entryKey;
|
|
5073
|
+
const entry = key ? list.entries.find((item) => item.key === key) : null;
|
|
5074
|
+
if (!entry || !canRenameEntry(entry, list)) return;
|
|
5075
|
+
event.preventDefault();
|
|
5076
|
+
startRename(entry.key);
|
|
5077
|
+
return;
|
|
5078
|
+
}
|
|
4889
5079
|
if (event.key === " " && !modifier) {
|
|
4890
5080
|
const key = selectableKey(target);
|
|
4891
5081
|
if (!key || !selection) return;
|
|
@@ -5081,6 +5271,22 @@ function ObjectList({
|
|
|
5081
5271
|
useRefreshListAfterUpload(upload, list.refresh);
|
|
5082
5272
|
const deleteFocus = useFocusAfterDelete();
|
|
5083
5273
|
const { announcement, announce } = useObjectListAnnouncement();
|
|
5274
|
+
const [renamingKey, setRenamingKey] = useState(null);
|
|
5275
|
+
const renameFocusKey = useRef(null);
|
|
5276
|
+
const previousRenaming = useRef(null);
|
|
5277
|
+
if (renamingKey != null && !list.entries.some((entry) => entry.key === renamingKey)) {
|
|
5278
|
+
setRenamingKey(null);
|
|
5279
|
+
}
|
|
5280
|
+
useEffect(() => {
|
|
5281
|
+
const previous = previousRenaming.current;
|
|
5282
|
+
previousRenaming.current = renamingKey;
|
|
5283
|
+
if (previous == null || renamingKey != null) return;
|
|
5284
|
+
if (renameFocusKey.current !== previous) return;
|
|
5285
|
+
renameFocusKey.current = null;
|
|
5286
|
+
document.querySelector(
|
|
5287
|
+
`[data-slot="object-list-entry-trigger"][data-entry-key="${CSS.escape(previous)}"]`
|
|
5288
|
+
)?.focus();
|
|
5289
|
+
}, [renamingKey]);
|
|
5084
5290
|
const frameHeight = cssLength(height);
|
|
5085
5291
|
const frameMaxHeight = cssLength(maxHeight);
|
|
5086
5292
|
const context = {
|
|
@@ -5105,6 +5311,16 @@ function ObjectList({
|
|
|
5105
5311
|
loadMore,
|
|
5106
5312
|
onOpenItem,
|
|
5107
5313
|
resolveFolderKeys,
|
|
5314
|
+
renamingKey,
|
|
5315
|
+
startRename(key) {
|
|
5316
|
+
const target = list.entries.find((entry) => entry.key === key);
|
|
5317
|
+
if (!target || !canRenameEntry(target, list)) return;
|
|
5318
|
+
setRenamingKey(key);
|
|
5319
|
+
},
|
|
5320
|
+
cancelRename(focus = false) {
|
|
5321
|
+
if (focus) renameFocusKey.current = renamingKey;
|
|
5322
|
+
setRenamingKey(null);
|
|
5323
|
+
},
|
|
5108
5324
|
renderEntry,
|
|
5109
5325
|
renderActions,
|
|
5110
5326
|
renderDescription,
|
|
@@ -5218,8 +5434,13 @@ function ObjectListFrame({
|
|
|
5218
5434
|
style,
|
|
5219
5435
|
children
|
|
5220
5436
|
}) {
|
|
5221
|
-
const { list, selection, upload, view, label, sizing } = useObjectListContext();
|
|
5222
|
-
const keyboard = useObjectListKeyboard({
|
|
5437
|
+
const { list, selection, upload, view, label, sizing, startRename } = useObjectListContext();
|
|
5438
|
+
const keyboard = useObjectListKeyboard({
|
|
5439
|
+
list,
|
|
5440
|
+
selection,
|
|
5441
|
+
view,
|
|
5442
|
+
startRename
|
|
5443
|
+
});
|
|
5223
5444
|
const busy = list.isLoading || list.isRefreshing || list.isLoadingMore;
|
|
5224
5445
|
const call = folderUploadCall(list, list.parent);
|
|
5225
5446
|
const takesFiles = upload != null && !upload.disabled;
|